history.vue 17 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527
  1. <template>
  2. <div class="history">
  3. <!-- 头部细节部分 -->
  4. <div class="title">
  5. <el-row>
  6. <el-col :span="24">
  7. <div class="top">
  8. <span style="margin-top: 10px;">导入文件:</span>
  9. <el-upload
  10. class="upload-demo"
  11. ref="upload"
  12. action="http://invoice.back.jkcredit.com/"
  13. :on-preview="handlePreview"
  14. :on-remove="handleRemove"
  15. :on-change="handleSuccess"
  16. :auto-upload="false">
  17. <el-button slot="trigger" size="small" type="primary">选取文件</el-button>
  18. <el-button style="margin-left: 10px;" size="small" type="success" @click="batchUpload" v-loading.fullscreen.lock="fullscreenLoading">开票</el-button>
  19. </el-upload>
  20. </div>
  21. </el-col>
  22. </el-row>
  23. <el-row>
  24. <el-col :span="24">
  25. <div class="top">
  26. <el-input placeholder="主体账号名称" class="input-demo" v-model="companyName"></el-input>
  27. <el-input placeholder="批次号" class="input-demo" v-model="batchNum"></el-input>
  28. <el-button style="margin-left: 1%;" @click="DownloadTemplate">下载模板</el-button>
  29. <el-button type="success" style="margin-left: 1%;" @click="firstLoadData">查询</el-button>
  30. <!-- <el-button type="info" style="margin-left: 1%;">重置</el-button> -->
  31. </div>
  32. </el-col>
  33. </el-row>
  34. </div>
  35. <!-- 头部细节部分结束 -->
  36. <!-- 表格部分 -->
  37. <template>
  38. <el-table
  39. class="table"
  40. v-loading="loading"
  41. ref="multipleTable"
  42. :data="usertable"
  43. :height="heightt"
  44. border
  45. tooltip-effect="dark">
  46. <el-table-column
  47. label="用户名"
  48. prop="customerName"
  49. show-overflow-tooltip>
  50. </el-table-column>
  51. <!-- <el-table-column
  52. label="用户手机号"
  53. prop="customerPhone"
  54. show-overflow-tooltip>
  55. </el-table-column> -->
  56. <el-table-column
  57. prop="company"
  58. label="主账号名称"
  59. show-overflow-tooltip>
  60. </el-table-column>
  61. <el-table-column
  62. prop="batchNumber"
  63. label="批次号"
  64. show-overflow-tooltip>
  65. </el-table-column>
  66. <el-table-column
  67. label="创建时间"
  68. show-overflow-tooltip>
  69. <template slot-scope="scope" show-overflow-tooltip>
  70. <span>{{scope.row.createTime | fmtDate}}</span>
  71. </template>
  72. </el-table-column>
  73. <el-table-column
  74. label="操作"
  75. width="80">
  76. <template slot-scope="scope" show-overflow-tooltip>
  77. <span style="cursor:pointer;color: blue;" @click="checkLook(scope.row.batchNumber)">查看</span>
  78. </template>
  79. </el-table-column>
  80. </el-table>
  81. </template>
  82. <!-- 分页 -->
  83. <div class="block">
  84. <el-pagination
  85. @size-change="handleSizeChange"
  86. @current-change="handleCurrentChange"
  87. :current-page="current"
  88. :page-sizes="[6, 8, 10]"
  89. :page-size="pagesize"
  90. layout="total, sizes, prev, pager, next, jumper"
  91. :total="total">
  92. </el-pagination>
  93. </div>
  94. <!-- 查看 -->
  95. <el-dialog
  96. @close="handleEditDialogClose"
  97. :visible.sync="addList"
  98. class="ttt"
  99. style="font-size: 0px;">
  100. <template>
  101. <div class="tou">运单历史列表</div>
  102. <div class="line"></div>
  103. <div class="styleType">
  104. <el-input placeholder="运单编号" class="theinput" v-model="billNum"></el-input>
  105. <el-input placeholder="车牌号" class="theinput" v-model="plateNum"></el-input>
  106. <el-input placeholder="税号" class="theinput" v-model="taxPlayerCode"></el-input>
  107. <el-select v-model="success" placeholder="是否成功">
  108. <el-option
  109. v-for="item in optionone"
  110. :key="item.value"
  111. :label="item.label"
  112. :value="item.value">
  113. </el-option>
  114. </el-select>
  115. <el-button type="success" style="margin-left: 1%;" @click="twoLoadData">查询</el-button>
  116. <el-button type="success" style="margin-left: 1%;" @click="exportExcel">导出</el-button>
  117. <!-- <el-button type="info" style="margin-left: 1%;">重置</el-button> -->
  118. </div>
  119. <el-table
  120. v-loading="loading"
  121. ref="multipleTable"
  122. :data="usertabletwo"
  123. border
  124. tooltip-effect="dark">
  125. <el-table-column
  126. label="运单编号"
  127. prop="billNum"
  128. show-overflow-tooltip>
  129. </el-table-column>
  130. <el-table-column
  131. prop="taxplayerCode"
  132. label="税号"
  133. show-overflow-tooltip>
  134. </el-table-column>
  135. <el-table-column
  136. label="车牌号码"
  137. prop="plateNum"
  138. show-overflow-tooltip>
  139. </el-table-column>
  140. <el-table-column
  141. prop="startTime"
  142. label="运单开始时间"
  143. show-overflow-tooltip>
  144. </el-table-column>
  145. <el-table-column
  146. prop="sourceAddr"
  147. label="运单开始地址"
  148. show-overflow-tooltip>
  149. </el-table-column>
  150. <el-table-column
  151. prop="destAddr"
  152. label="运单目的地址"
  153. show-overflow-tooltip>
  154. </el-table-column>
  155. <el-table-column
  156. prop="predictEndTime"
  157. label="运单预计完成时间"
  158. show-overflow-tooltip>
  159. </el-table-column>
  160. <el-table-column
  161. prop="fee"
  162. label="运单费用(元)"
  163. show-overflow-tooltip>
  164. <template slot-scope="scope" show-overflow-tooltip>
  165. <span>{{scope.row.fee / 100}}</span>
  166. </template>
  167. </el-table-column>
  168. <!-- <el-table-column
  169. prop="billwayStatus"
  170. label="运单状态"
  171. show-overflow-tooltip>
  172. <template slot-scope="scope">
  173. <span v-if="scope.row.billwayStatus == 1" style="color: green">未结束</span>
  174. <span v-else-if="scope.row.billwayStatus == -2" style="color: red">上传失败</span>
  175. <span v-else-if="scope.row.billwayStatus == -3" style="color: red">结束指令上传失败</span>
  176. <span v-else-if="scope.row.billwayStatus == 2" style="color: green">开票中</span>
  177. <span v-else-if="scope.row.billwayStatus == 3" style="color: green">开票完成</span>
  178. <span v-else-if="scope.row.billwayStatus == 4" style="color: red">超时运单</span>
  179. </template>
  180. </el-table-column> -->
  181. <el-table-column
  182. label="是否成功"
  183. show-overflow-tooltip>
  184. <template slot-scope="scope">
  185. <span v-if="scope.row.billwayStatus == -2 || scope.row.billwayStatus == -3" style="color: red">失败</span>
  186. <span v-else-if="scope.row.billwayStatus != -2 && scope.row.billwayStatus != -3" style="color: green">成功</span>
  187. </template>
  188. </el-table-column>
  189. <el-table-column
  190. prop="failReason"
  191. label="失败原因"
  192. show-overflow-tooltip>
  193. </el-table-column>
  194. </el-table>
  195. </template>
  196. <div class="blocks">
  197. <el-pagination
  198. @size-change="handleSize"
  199. @current-change="handleCurrent"
  200. :current-page="currenttwo"
  201. :page-sizes="[6, 8, 10]"
  202. :page-size="pagesizetwo"
  203. layout="total, sizes, prev, pager, next, jumper"
  204. :total="totaltwo">
  205. </el-pagination>
  206. </div>
  207. </el-dialog>
  208. </div>
  209. </template>
  210. <script>
  211. import FileSaver from "file-saver";
  212. import XLSX from "xlsx";
  213. export default{
  214. data() {
  215. return {
  216. loading: false,
  217. fullscreenLoading: false,
  218. userName: '',
  219. customerName: '',
  220. companyName: '',
  221. billNum: '',
  222. plateNum: '',
  223. success:'',
  224. taxPlayerCode: '',
  225. hightt:'0px',
  226. status: '',
  227. addList: false,
  228. current: 1,
  229. pagesize: 8,
  230. total: 0,
  231. currenttwo: 1,
  232. pagesizetwo: 8,
  233. totaltwo: 0,
  234. batchNum: '',
  235. batchNumberQ:'',
  236. usertable: [],
  237. usertabletwo: [],
  238. formUserList: {
  239. "customerName": "",
  240. "file": "",
  241. "roleId": ""
  242. },
  243. isSuccess: '',
  244. optionone: [{
  245. value: '1',
  246. label: '成功'
  247. }, {
  248. value: '2',
  249. label: '失败'
  250. }],
  251. }
  252. },
  253. created() {
  254. this.heightt = tableHeight;
  255. this.formUserList.customerName = sessionStorage.getItem('userName');
  256. this.loadData();
  257. },
  258. methods: {
  259. firstLoadData(){
  260. this.current = 1;
  261. this.pagesize = 8;
  262. this.loadData();
  263. },
  264. // 列表展示
  265. async loadData() {
  266. const formData = new FormData();
  267. formData.append('current', this.current);
  268. formData.append('size', this.pagesize);
  269. formData.append('customerName',this.formUserList.customerName);
  270. formData.append('company', this.companyName);
  271. formData.append('batchNumber', this.batchNum);
  272. formData.append('operType', 3);
  273. const response = await this.$http.post(`noCar/findBatchList`, formData);
  274. if (response.data.code === 0) {
  275. this.loading = false;
  276. this.usertable = response.data.data.records;
  277. this.total = response.data.data.total;
  278. }
  279. },
  280. // 下载模板
  281. DownloadTemplate() {
  282. //var url = 'http://invoice.back.jkcredit.com/carFreeCarrierBill/downTemp';
  283. var url = hostUrl+"noCar/templateDownload?fileName=3"
  284. window.location.href= url;
  285. },
  286. // 批量上传模板信息
  287. async batchUpload() {
  288. const isLt50M = this.formUserList.file.size / 1024 / 1024 < 50;
  289. let extName = this.formUserList.file.name.substring(this.formUserList.file.name.lastIndexOf(".")).toLowerCase();
  290. let AllUpExt = ".xlsx";
  291. if( extName != AllUpExt){
  292. this.$message.error('格式错误!请上传xlsx的文件');
  293. return false;
  294. }
  295. if (!isLt50M) {
  296. this.$message.error('上传文件大小不能超过50MB!');
  297. return false;
  298. }
  299. const loading = this.$loading({
  300. lock: true,
  301. text: '系统正在努力接收中,过程大概需要几分钟的时间,请您耐心等待...',
  302. spinner: 'el-icon-loading',
  303. background: 'rgba(0, 0, 0, 0.7)'
  304. });
  305. const formData = new FormData();
  306. formData.append('customerName', this.formUserList.customerName);
  307. formData.append('file', this.formUserList.file);
  308. const response = await this.$http.post(`noCar/batchImprotHistoryBillWay`,formData);
  309. var {data: { code, msg, data }} = response;
  310. if(code === 0 && msg === 'success') {
  311. this.loadData();
  312. loading.close();
  313. this.$message.success('上传成功');
  314. }else if(code === 1 && msg == null && data == null) {
  315. loading.close();
  316. this.$message.error('数据存在错误,请检查文件中数据,金额是否有空的,时间是否全是时间格式');
  317. }else {
  318. loading.close();
  319. this.$message.error("数据存在错误,请检查文件中数据,金额是否有空的,时间是否全是时间格式");
  320. }
  321. },
  322. // 查看批次数据
  323. async checkLook(id) {
  324. this.addList = true;
  325. this.batchNumberQ = id;
  326. this.loadDataCar();
  327. },
  328. twoLoadData(){
  329. this.currenttwo = 1;
  330. this.pagesizetwo = 8;
  331. this.loadDataCar();
  332. },
  333. // 查看历史数据
  334. async loadDataCar() {
  335. const formData = new FormData();
  336. formData.append('current', this.currenttwo);
  337. formData.append('size', this.pagesizetwo);
  338. formData.append('customerName', this.formUserList.customerName);
  339. formData.append('batchNum', this.batchNumberQ);
  340. formData.append('billNum', this.billNum);
  341. formData.append('success', this.success);
  342. formData.append('plateNum', this.plateNum);
  343. formData.append('taxplayerCode', this.taxPlayerCode);
  344. formData.append('hisFlag', 1);
  345. const response = await this.$http.post(`noCar/findImportBillWay`, formData);
  346. if (response.data.code === 0) {
  347. this.loading = false;
  348. this.usertabletwo = response.data.data.records;
  349. this.totaltwo = response.data.data.total;
  350. }
  351. },
  352. formartNum(wb){
  353. var sheet = wb['Sheets']['Sheet1'];
  354. var replaceTemp = [];
  355. debugger;
  356. for(var i in sheet){
  357. if(sheet[i]['v'] == '运单费用(元)'){
  358. replaceTemp.push(i.replace(/[0-9]/g,''));
  359. continue;
  360. }
  361. if(replaceTemp.includes(i.replace(/[0-9]/g,''))){
  362. sheet[i]['t']='n';
  363. }
  364. }
  365. },
  366. async exportExcel() {
  367. let curr = this.currenttwo;
  368. let pagesize1 = this.pagesizetwo;
  369. this.currenttwo = 1;
  370. this.pagesizetwo = this.totaltwo;
  371. await this.loadDataCar();
  372. // 设置当前日期
  373. let time = new Date();
  374. //console.log(time);
  375. let year = time.getFullYear();
  376. let month = time.getMonth() + 1;
  377. let day = time.getDate();
  378. let name = "历史运单上传列表_"+year + "" + month + "" + day;
  379. // console.log(name)
  380. /* generate workbook object from table */
  381. // .table要导出的是哪一个表格
  382. var wb = XLSX.utils.table_to_book(document.querySelector(".ttt"),{ raw: true });
  383. this.formartNum(wb);
  384. /* get binary string as output */
  385. var wbout = XLSX.write(wb, {
  386. bookType: "xlsx",
  387. bookSST: true,
  388. type: "array"
  389. });
  390. try {
  391. // name+'.xlsx'表示导出的excel表格名字
  392. FileSaver.saveAs(
  393. new Blob([wbout], { type: "application/octet-stream" }),
  394. name + ".xlsx"
  395. );
  396. } catch (e) {
  397. if (typeof console !== "undefined") console.log(e, wbout);
  398. }
  399. this.currenttwo = curr;
  400. this.pagesizetwo = pagesize1;
  401. this.loadDataCar();
  402. return wbout;
  403. },
  404. // 清空表单数据
  405. handleEditDialogClose() {
  406. this.num = '';
  407. this.plateNumber = '';
  408. this.taxPlayerCode = '';
  409. this.current = 1;
  410. this.pagesize = 8;
  411. this.currenttwo = 1;
  412. this.pagesizetwo = 8;
  413. },
  414. handleRemove(file, fileList) {
  415. console.log(file, fileList);
  416. },
  417. handlePreview(file) {
  418. console.log(file);
  419. },
  420. handleSuccess (a) {
  421. this.formUserList.file = a.raw;
  422. },
  423. // 分页方法
  424. handleSizeChange(val) {
  425. this.pagesize = val;
  426. this.loadData();
  427. console.log(`每页 ${val} 条`);
  428. },
  429. handleCurrentChange(val) {
  430. this.current = val;
  431. this.loadData();
  432. console.log(`当前页: ${val}`);
  433. },
  434. handleSize(val) {
  435. this.pagesizetwo = val;
  436. this.loadDataCar();
  437. console.log(`每页 ${val} 条`);
  438. },
  439. handleCurrent(val) {
  440. this.currenttwo = val;
  441. this.loadDataCar();
  442. console.log(`当前页: ${val}`);
  443. }
  444. }
  445. };
  446. </script>
  447. <style>
  448. .history {
  449. border: 1px solid #d9d9d9;
  450. border-radius: 10px;
  451. }
  452. .history .upload-demo {
  453. display: inline-block;
  454. }
  455. .history .title {
  456. font-size: 5px;
  457. margin-bottom: 20px;
  458. }
  459. .history .top {
  460. padding-top: 20px;
  461. padding-left: 20px;
  462. }
  463. .history .text {
  464. display: inline-block;
  465. color: #000;
  466. font-size: 16px ;
  467. margin-left: 1%;
  468. }
  469. .history .tou {
  470. font-size: 20px;
  471. height: 30px;
  472. line-height: 30px;
  473. padding-top: 15px;
  474. }
  475. .history .line {
  476. margin-top: 15px;
  477. margin-bottom: 15px;
  478. width: 100%;
  479. height: 2px;
  480. background-color: #d9d9d9;
  481. }
  482. .history .theinput {
  483. display: inline-block;
  484. width: 20%;
  485. }
  486. .history .styleType {
  487. margin-top: 20px;
  488. margin-bottom: 20px;
  489. }
  490. .history .input-demo {
  491. display: inline-block;
  492. width: 20%;
  493. margin-left: 1%;
  494. }
  495. .history .block {
  496. font-size: 5px;
  497. text-align: center;
  498. margin-top: 15px;
  499. margin-bottom: 20px;
  500. }
  501. .history .blocks {
  502. font-size: 5px;
  503. text-align: center;
  504. margin-top: 20px;
  505. padding-bottom: 20px;
  506. }
  507. .history .el-dialog {
  508. width: 90%;
  509. }
  510. .history .el-dialog__header, .el-dialog__body {
  511. padding: 0 20px;
  512. }
  513. </style>