history.vue 17 KB

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