billway.vue 21 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563
  1. <template>
  2. <div class="billWay_container">
  3. <div class="title">
  4. <el-row>
  5. <el-col :span="24">
  6. <div class="demo-input-suffix" style="margin-left: 10px;margin-top: 15px;">
  7. <el-upload :action="url" :http-request="importExcel" list-type="text" :show-file-list="false" >
  8. <el-button type="primary">导入参数</el-button>
  9. <el-select style="margin-left: 120px;" v-model="noCarWayBill.billwayStatus" placeholder="运单状态">
  10. <el-option
  11. v-for="item in tradeStatus"
  12. :key="item.value"
  13. :label="item.label"
  14. :value="item.value">
  15. </el-option>
  16. </el-select>
  17. </el-upload>
  18. </div>
  19. <div class="demo-input-suffix" style="margin-top: 5px;">
  20. <el-input placeholder="客户名称" class="input-demo" v-model="noCarWayBill.customerName"></el-input>
  21. <el-input placeholder="公司名称" class="input-demo" v-model="noCarWayBill.companyName"></el-input>
  22. <el-input placeholder="税号" class="input-demo" v-model="noCarWayBill.taxplayerCode"></el-input>
  23. <el-input placeholder="运单编号" class="input-demo" v-model="noCarWayBill.billNum"></el-input>
  24. <el-button style="margin-right: 1%;" @click="DownloadTemplate">查询模板下载</el-button>
  25. <el-button type="primary" style="margin-left: 1%;" @click="exportExcel">导出报表</el-button>
  26. </div>
  27. <div class="demo-input-suffix" style="margin-top: 5px;margin-left: 10px;">
  28. <el-input placeholder="车牌号" class="input-demo" v-model="noCarWayBill.plateNum"></el-input>
  29. <el-date-picker v-model="noCarWayBill.startBegin" type="datetimerange" value-format="yyyy-MM-dd HH:mm:ss" range-separator="至" start-placeholder="运单上传开始指令始" end-placeholder="运单上传开始指令止"></el-date-picker>
  30. <el-date-picker v-model="noCarWayBill.endBegin" type="datetimerange" value-format="yyyy-MM-dd HH:mm:ss" range-separator="至" start-placeholder="运单上传结束指令始" end-placeholder="运单上传结束指令止"></el-date-picker>
  31. <!-- <el-date-picker v-model="noCarWayBill.startEnd" type="date" placeholder="开始指令上传时间止"></el-date-picker>
  32. <el-date-picker v-model="noCarWayBill.startBegin" type="date" placeholder="开始指令上传时间始"></el-date-picker> -->
  33. <!-- <el-date-picker v-model="noCarWayBill.endBegin" type="date" placeholder="结束指令上传时间始"></el-date-picker>
  34. <el-date-picker v-model="noCarWayBill.endEnd" type="date" placeholder="结束指令上传时间止"></el-date-picker> -->
  35. <el-button type="success" style="margin-left: 1%;" @click="firstLoadData">查询</el-button>
  36. <el-button type="success" style="margin-left: 1%;" @click="updateStatus">更新状态</el-button>
  37. </div>
  38. </el-col>
  39. </el-row>
  40. </div>
  41. <!-- 表格部分 -->
  42. <template>
  43. <el-table
  44. class="table"
  45. v-loading="loading"
  46. ref="multipleTable"
  47. :data="billWayTable"
  48. :height="heightt"
  49. border
  50. tooltip-effect="dark" @selection-change="handleSelectionChange">
  51. <el-table-column
  52. type="selection"
  53. width="55">
  54. </el-table-column>
  55. <el-table-column
  56. label="客户名称"
  57. prop="customerName"
  58. show-overflow-tooltip>
  59. </el-table-column>
  60. <el-table-column
  61. label="企业编号"
  62. prop="companyNum"
  63. show-overflow-tooltip>
  64. </el-table-column>
  65. <el-table-column
  66. prop="companyName"
  67. label="公司名称"
  68. show-overflow-tooltip>
  69. </el-table-column>
  70. <el-table-column
  71. prop="billNum"
  72. label="运单编号"
  73. show-overflow-tooltip>
  74. </el-table-column>
  75. <el-table-column
  76. prop="taxplayerCode"
  77. label="税号"
  78. show-overflow-tooltip>
  79. </el-table-column>
  80. <el-table-column
  81. label="车牌号码"
  82. prop="plateNum"
  83. show-overflow-tooltip>
  84. </el-table-column>
  85. <el-table-column
  86. prop="startTime"
  87. label="运单开始时间"
  88. width="120"
  89. show-overflow-tooltip>
  90. </el-table-column>
  91. <el-table-column
  92. prop="intfaceStartTime"
  93. label="开始指令时间"
  94. width="120"
  95. show-overflow-tooltip>
  96. </el-table-column>
  97. <el-table-column
  98. prop="predictEndTime"
  99. label="运单结束时间"
  100. width="120"
  101. show-overflow-tooltip>
  102. </el-table-column>
  103. <el-table-column
  104. prop="interfaceEndTime"
  105. label="结束指令时间"
  106. width="120"
  107. show-overflow-tooltip>
  108. </el-table-column>
  109. <el-table-column
  110. prop="sourceAddr"
  111. label="运单开始地址"
  112. width="120"
  113. show-overflow-tooltip>
  114. </el-table-column>
  115. <el-table-column
  116. prop="destAddr"
  117. label="运单结束地址"
  118. width="120"
  119. show-overflow-tooltip>
  120. </el-table-column>
  121. <el-table-column
  122. prop="fee"
  123. label="运单费用"
  124. show-overflow-tooltip>
  125. <template slot-scope="scope">
  126. <span>{{scope.row.fee/100| rounding}}</span>
  127. </template>
  128. </el-table-column>
  129. <el-table-column
  130. label="运单状态"
  131. show-overflow-tooltip>
  132. <template slot-scope="scope">
  133. <span v-if="scope.row.billwayStatus == 1" style="color: green">未结束</span>
  134. <span v-else-if="scope.row.billwayStatus == -2" style="color: red">上传失败</span>
  135. <span v-else-if="scope.row.billwayStatus == -3" style="color: red">结束指令上传失败</span>
  136. <span v-else-if="scope.row.billwayStatus == 2" style="color: green">开票中</span>
  137. <span v-else-if="scope.row.billwayStatus == 3" style="color: green">开票完成</span>
  138. <span v-else-if="scope.row.billwayStatus == 4" style="color: red">超时运单</span>
  139. </template>
  140. </el-table-column>
  141. <el-table-column
  142. label="是否成功"
  143. show-overflow-tooltip>
  144. <template slot-scope="scope">
  145. <span v-if="scope.row.billwayStatus == -2 || scope.row.billwayStatus == -3" style="color: red">失败</span>
  146. <span v-else-if="scope.row.billwayStatus != -2 && scope.row.billwayStatus != -3" style="color: green">成功</span>
  147. </template>
  148. </el-table-column>
  149. <el-table-column
  150. prop="failReason"
  151. label="失败原因"
  152. show-overflow-tooltip>
  153. </el-table-column>
  154. <el-table-column
  155. prop="updateTime"
  156. label="最后更新时间"
  157. width="120"
  158. show-overflow-tooltip>
  159. </el-table-column>
  160. <el-table-column
  161. prop="hisFlag"
  162. label="运单类型"
  163. show-overflow-tooltip>
  164. <template slot-scope="scope">
  165. <span v-if="scope.row.hisFlag == 0" >实时运单</span>
  166. <span v-else-if="scope.row.hisFlag == 1">历史运单</span>
  167. </template>
  168. </el-table-column>
  169. <el-table-column
  170. prop="interType"
  171. label="对接方式"
  172. show-overflow-tooltip>
  173. <template slot-scope="scope">
  174. <span v-if="scope.row.interType == 0">接口</span>
  175. <span v-if="scope.row.interType == 1">平台</span>
  176. <span v-if="scope.row.interType == 3">迁移数据</span>
  177. </template>
  178. </el-table-column>
  179. </el-table>
  180. </template>
  181. <!-- 分页 -->
  182. <div class="block">
  183. <el-pagination
  184. @size-change="handleSizeChange"
  185. @current-change="handleCurrentChange"
  186. :current-page="current"
  187. :page-sizes="[6, 8, 10, 20, 50, 100]"
  188. :page-size="pagesize"
  189. layout="total, sizes, prev, pager, next, jumper"
  190. :total="total">
  191. </el-pagination>
  192. </div>
  193. </div>
  194. </template>
  195. <script type="text/javascript">
  196. import FileSaver from "file-saver";
  197. import CsvExportor from "csv-exportor";
  198. import XLSX from "xlsx";
  199. export default {
  200. data(){
  201. return{
  202. noCarWayBill:{
  203. billNum:''
  204. },
  205. formUserList: {
  206. "file": ""
  207. },
  208. tradeStatus:[
  209. {"label":"上传失败","value":"-2"},
  210. {"label":"结束指令上传失败","value":"-3"},
  211. {"label":"未结束","value":"1"},
  212. {"label":"开票中","value":"2"},
  213. {"label":"开票完成","value":"3"},
  214. {"label":"超时运单","value":"4"}],
  215. multipleSelection: [],
  216. optionone: [{
  217. value: 0,
  218. label: '实时运单'
  219. }, {
  220. value: 1,
  221. label: '历史运单'
  222. }],
  223. billWayTable:[],
  224. current: 1,
  225. pagesize: 8,
  226. hightt:'0px',
  227. total:''
  228. }
  229. },
  230. created() {
  231. //设置表格高度
  232. this.heightt = '300px';
  233. this.loadData();
  234. },
  235. filters: {
  236. rounding (value) {
  237. return value.toFixed(2)
  238. }
  239. },
  240. methods:{
  241. firstLoadData(){
  242. this.current = 1;
  243. this.pagesize = 8;
  244. this.loadData();
  245. },
  246. // 列表展示
  247. async loadData() {
  248. const formData = new FormData();
  249. formData.append('current', this.current);
  250. formData.append('size', this.pagesize);
  251. for(var i in this.noCarWayBill){
  252. formData.append(i,this.noCarWayBill[i]);
  253. }
  254. const response = await this.$http.post(`noCar/findBillWay`, formData);
  255. if (response.data.code === 0) {
  256. this.billWayTable = response.data.data.records;
  257. this.total = response.data.data.total;
  258. }
  259. },
  260. importExcel (content) {
  261. const file = content.file
  262. // let file = file.files[0] // 使用传统的input方法需要加上这一步
  263. const filename = file.name
  264. if(!filename||typeof filename!='string'){
  265. this.$message('格式错误!请重新选择')
  266. return
  267. }
  268. let a = filename.split('').reverse().join('');
  269. let types = a.substring(0,a.search(/\./)).split('').reverse().join('');
  270. const fileType = ['xlsx', 'xlc', 'xlm', 'xls', 'xlt', 'xlw', 'csv'].some(item => item === types)
  271. if (!fileType) {
  272. this.$message(fileType+'格式错误!请重新选择xlsx xls格式')
  273. return
  274. }
  275. this.file2Xce(file).then(tabJson => {
  276. var billNums = '';
  277. if (tabJson && tabJson.length > 0) {
  278. this.xlsxJson = tabJson
  279. this.fileList = this.xlsxJson[0].sheet
  280. this.fileList.forEach((item, index, arr) => {
  281. if(item['运单编号']!=null && item['运单编号']!='' && typeof item['运单编号']!='undefined'){
  282. billNums+= item['运单编号'].trim()+',';
  283. }
  284. });
  285. }
  286. if(billNums!=''){
  287. this.noCarWayBill.billNum =billNums.substring(0,billNums.length-1);
  288. }
  289. })
  290. },
  291. file2Xce (file) {
  292. return new Promise(function (resolve, reject) {
  293. const reader = new FileReader()
  294. reader.onload = function (e) {
  295. const data = e.target.result
  296. this.wb = XLSX.read(data, {
  297. type: 'binary'
  298. })
  299. const result = []
  300. var are = (this.wb.Sheets.Sheet1)['!ref'];
  301. var areRe = are.replace('A1','A2');
  302. (this.wb.Sheets.Sheet1)['!ref'] = areRe;
  303. this.wb.SheetNames.forEach((sheetName) => {
  304. result.push({
  305. sheetName: sheetName,
  306. sheet: XLSX.utils.sheet_to_json(this.wb.Sheets[sheetName])
  307. })
  308. })
  309. resolve(result)
  310. }
  311. // reader.readAsBinaryString(file.raw)
  312. reader.readAsBinaryString(file) // 传统input方法
  313. })
  314. },
  315. // 下载模板
  316. DownloadTemplate() {
  317. var url = hostUrl+"noCar/templateDownload?fileName=5"
  318. window.location.href= url;
  319. },
  320. handleRemove(file, fileList) {
  321. },
  322. handlePreview(file) {
  323. },
  324. handleSuccess (a) {
  325. this.formUserList.file = a.raw;
  326. },
  327. handleSelectionChange(value){
  328. this.multipleSelection = value;
  329. },
  330. async updateStatus(){
  331. const formData = new FormData();
  332. formData.append('noCarWayBillStr', JSON.stringify(this.multipleSelection));
  333. const response = await this.$http.post(`noCar/updateStatus`,formData);
  334. if(response.data.code === 0) {
  335. this.loadData();
  336. this.$message({
  337. type: 'success',
  338. message: '更新成功'
  339. });
  340. }else {
  341. this.$message({
  342. type: 'error',
  343. message: '更新失败'
  344. });
  345. }
  346. },
  347. // 分页方法
  348. handleSizeChange(val) {
  349. this.pagesize = val;
  350. this.loadData();
  351. },
  352. handleCurrentChange(val) {
  353. this.current = val;
  354. this.loadData();
  355. },
  356. // 批量上传模板信息
  357. async batchUpload() {
  358. this.fullscreenLoading = true;
  359. const formData = new FormData();
  360. formData.append('file', this.formUserList.file);
  361. const response = await this.$http.post(`noCar/batchImportNocarBillWay`,formData);
  362. var {data: { code, msg, data }} = response;
  363. if(code === 0 && msg === '1') {
  364. this.fullscreenLoading = false;
  365. this.billWayTable = response.data.data;
  366. this.total = response.data.data.length;
  367. }else {
  368. this.fullscreenLoading = false;
  369. this.$message.error('数据存在错误,请检查文件中数据');
  370. }
  371. },
  372. formartNum(wb){
  373. var sheet = wb['Sheets']['Sheet1'];
  374. var replaceTemp = [];
  375. for(var i in sheet){
  376. if(sheet[i]['v'] == '运单费用'){
  377. replaceTemp.push(i.replace(/[0-9]/g,''));
  378. continue;
  379. }
  380. if(replaceTemp.includes(i.replace(/[0-9]/g,''))){
  381. sheet[i]['t']='n';
  382. }
  383. }
  384. },
  385. async exportExcel() {
  386. const loading = this.$loading({
  387. lock: true,
  388. text: '系统正在努力接收中,过程大概需要几分钟的时间,请您耐心等待...',
  389. spinner: 'el-icon-loading',
  390. background: 'rgba(0, 0, 0, 0.7)'
  391. });
  392. var recodes = [];
  393. for(var j=1;j<=this.total/10000+1;j++){
  394. const formData = new FormData();
  395. formData.append('current', j);
  396. formData.append('size', 10000);
  397. for(var i in this.noCarWayBill){
  398. formData.append(i,this.noCarWayBill[i]);
  399. }
  400. const response = await this.$http.post(`noCar/findBillWay`, formData);
  401. if (response.data.code === 0) {
  402. recodes = recodes.concat(response.data.data.records);
  403. }
  404. }
  405. // 设置当前日期
  406. let time = new Date();
  407. let year = time.getFullYear();
  408. let month = time.getMonth() + 1;
  409. let day = time.getDate();
  410. let name = "无车运单查询列表_"+year + "" + month + "" + day;
  411. let cloums = [
  412. {"title":"客户名称","key":"customerName"},
  413. {"title":"企业编号","key":"companyNum"},
  414. {"title":"公司名称","key":"companyName"},
  415. {"title":"运单号","key":"billNum"},
  416. {"title":"税号","key":"taxplayerCode"},
  417. {"title":"车牌号码","key":"plateNum"},
  418. {"title":"运单开始时间","key":"startTime"},
  419. {"title":"开始指令时间","key":"intfaceStartTime"},
  420. {"title":"运单结束时间","key":"predictEndTime"},
  421. {"title":"结束指令时间","key":"interfaceEndTime"},
  422. {"title":"运单开始地址","key":"sourceAddr"},
  423. {"title":"运单结束地址","key":"destAddr"},
  424. {"title":"运单费用(元)","key":"fee"},
  425. {"title":"运单状态","key":"billwayStatus"},
  426. {"title":"失败原因","key":"failReason"},
  427. {"title":"运单类型","key":"hisFlag"},
  428. ];
  429. await this.exportExcelComm(cloums,recodes,name,loading);
  430. },
  431. formatJson (filterVal, jsonData) {
  432. return jsonData.map(v => filterVal.map(j => {
  433. if(j == 'billwayStatus'){
  434. if(v[j] == 1){
  435. return "未结束";
  436. } else if(v[j] == -2){
  437. return "上传失败";
  438. }else if(v[j] == -3){
  439. return "指令结束上传失败";
  440. }else if(v[j] == 2){
  441. return "开票中";
  442. }else if(v[j] == 3){
  443. return "开票完成";
  444. }else {
  445. return "超时运单";
  446. }
  447. }else if(j =='fee'){
  448. return v[j]/100;
  449. }else if(j=='hisFlag'){
  450. if(v[j] == 0){
  451. return "实时运单";
  452. }else{
  453. return "历史运单";
  454. }
  455. }else if(j=='billNum'){
  456. return v[j]+'\t';
  457. }
  458. else{
  459. return v[j];
  460. }
  461. }));
  462. },
  463. // 导出Excel
  464. exportExcelComm(columns,list,excelName,loading){
  465. require.ensure([], () => {
  466. const { export_json_to_excel } = require('@/vendor/Export2Excel');
  467. let tHeader = []
  468. let filterVal = []
  469. columns.forEach(item =>{
  470. tHeader.push(item.title)
  471. filterVal.push(item.key)
  472. })
  473. // for(var i =0;i<list.length/100000;i++){
  474. // const data = this.formatJson(filterVal, list.slice(i*100000,(i+1)*100000>list.length?list.length:(i+1)*100000));
  475. // export_json_to_excel(tHeader, data, excelName+'_'+i);
  476. // }
  477. const data = this.formatJson(filterVal,list);
  478. data.unshift(tHeader);
  479. CsvExportor.downloadCsv(data, { tHeader }, excelName+".csv");
  480. loading.close();
  481. })
  482. }
  483. }
  484. };
  485. </script>
  486. <style>
  487. .billWay_container {
  488. border: 1px solid #d9d9d9;
  489. border-radius: 10px;
  490. }
  491. .billWay_container .title {
  492. font-size: 5px;
  493. margin-bottom: 20px;
  494. }
  495. .billWay_container .top {
  496. padding-top: 20px;
  497. padding-left: 20px;
  498. }
  499. .billWay_container .text {
  500. display: inline-block;
  501. color: #000;
  502. font-size: 16px ;
  503. margin-left: 1%;
  504. }
  505. .billWay_container .input-demo {
  506. display: inline-block;
  507. width: 15%;
  508. margin-left: 1%;
  509. }
  510. .billWay_container .block {
  511. font-size: 5px;
  512. text-align: center;
  513. margin-top: 25px;
  514. margin-bottom: 25px;
  515. }
  516. .billWay_container .el-dialog {
  517. width: 60%;
  518. }
  519. .billWay_container .el-dialog__header, .el-dialog__body {
  520. padding: 0 20px;
  521. }
  522. .billWay_container .tou {
  523. font-size: 20px;
  524. height: 30px;
  525. line-height: 30px;
  526. padding-top: 15px;
  527. }
  528. .billWay_container .line {
  529. margin-top: 15px;
  530. margin-bottom: 15px;
  531. width: 100%;
  532. height: 2px;
  533. background-color: #d9d9d9;
  534. }
  535. .billWay_container .xinxi {
  536. text-align: center;
  537. margin: 15px auto;
  538. font-size: 18px;
  539. }
  540. </style>