carupload.vue 17 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544
  1. <template>
  2. <div class="carupload">
  3. <!-- 头部细节部分 -->
  4. <div class="title">
  5. <el-row>
  6. <el-col :span="24">
  7. <div class="top">
  8. <el-upload
  9. class="upload-demo"
  10. ref="upload"
  11. action="http://invoice.back.jkcredit.com/"
  12. :on-preview="handlePreview"
  13. :on-remove="handleRemove"
  14. :on-change="handleSuccess"
  15. :auto-upload="false">
  16. <el-button slot="trigger" size="small" type="primary">选取文件</el-button>
  17. <el-button style="margin-left: 10px;" size="small" type="success" @click="batchUpload" v-loading.fullscreen.lock="fullscreenLoading">提交</el-button>
  18. <div style="margin-top: 10px;">导入文件:</div>
  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" style="margin: 0;" v-model="userName"></el-input>
  27. <el-input placeholder="用户所在公司" class="input-demo" v-model="userCompany"></el-input>
  28. <el-input placeholder="批次号" class="input-demo" v-model="batchNumber"></el-input>
  29. <el-button style="margin-left: 1%;" @click="DownloadTemplate">下载模板</el-button>
  30. <el-button type="success" style="margin-left: 1%;" @click="queryLook">查询</el-button>
  31. <!-- <el-button type="info" style="margin-left: 1%;">重置</el-button> -->
  32. </div>
  33. </el-col>
  34. </el-row>
  35. </div>
  36. <!-- 头部细节部分结束 -->
  37. <!-- 表格部分 -->
  38. <template>
  39. <el-table
  40. v-loading="loading"
  41. ref="multipleTable"
  42. :data="usertable"
  43. height="370px"
  44. border
  45. tooltip-effect="dark">
  46. <el-table-column
  47. label="用户名"
  48. prop="userName"
  49. show-overflow-tooltip>
  50. </el-table-column>
  51. <el-table-column
  52. label="用户手机号"
  53. prop="userPhone"
  54. show-overflow-tooltip>
  55. </el-table-column>
  56. <el-table-column
  57. prop="userCompany"
  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;" @click="checkLook(scope.row.id)">查看</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. style="font-size: 0px;">
  99. <template>
  100. <div class="tou">无车承运人备案列表</div>
  101. <div class="line"></div>
  102. <div class="styleType">
  103. <el-input placeholder="用户手机号" class="theinput" v-model="userPhone"></el-input>
  104. <el-input placeholder="车牌号" class="theinput" v-model="plateNumber"></el-input>
  105. <label>车牌颜色:</label>
  106. <el-select v-model="plateColor" placeholder="请选择车牌颜色">
  107. <el-option
  108. v-for="item in optionone"
  109. :key="item.value"
  110. :label="item.label"
  111. :value="item.value">
  112. </el-option>
  113. </el-select>
  114. <!-- <el-input placeholder="车牌颜色" class="theinput" ></el-input> -->
  115. <el-button type="success" style="margin-left: 1%;" @click="queryLookTwo">查询</el-button>
  116. <!-- <el-button type="info" style="margin-left: 1%;">重置</el-button> -->
  117. </div>
  118. <el-table
  119. v-loading="loading"
  120. ref="multipleTable"
  121. :data="usertabletwo"
  122. border
  123. tooltip-effect="dark">
  124. <el-table-column
  125. label="用户名"
  126. prop="userName"
  127. show-overflow-tooltip>
  128. </el-table-column>
  129. <el-table-column
  130. label="用户手机号"
  131. prop="userPhone"
  132. show-overflow-tooltip>
  133. </el-table-column>
  134. <el-table-column
  135. prop="userCompany"
  136. label="用户所在公司"
  137. show-overflow-tooltip>
  138. </el-table-column>
  139. <el-table-column
  140. prop="plateNumber"
  141. label="车牌号"
  142. show-overflow-tooltip>
  143. </el-table-column>
  144. <el-table-column
  145. label="车牌颜色"
  146. show-overflow-tooltip>
  147. <template slot-scope="scope">
  148. <span v-if="scope.row.plateColor == 0">蓝色</span>
  149. <span v-else-if="scope.row.plateColor == 1">黄色</span>
  150. <span v-else-if="scope.row.plateColor == 2">黑色</span>
  151. <span v-else-if="scope.row.plateColor == 3">白色</span>
  152. <span v-else-if="scope.row.plateColor == 4">渐变绿色</span>
  153. <span v-else-if="scope.row.plateColor == 5">黄绿渐变色</span>
  154. <span v-else-if="scope.row.plateColor == 6">蓝白渐变色</span>
  155. <span v-else-if="scope.row.plateColor == 9">未确定</span>
  156. </template>
  157. </el-table-column>
  158. <el-table-column
  159. prop="batchNumber"
  160. label="批次号"
  161. show-overflow-tooltip>
  162. </el-table-column>
  163. <el-table-column
  164. label="创建时间"
  165. show-overflow-tooltip>
  166. <template slot-scope="scope" show-overflow-tooltip>
  167. <span>{{scope.row.createTime | fmtDate}}</span>
  168. </template>
  169. </el-table-column>
  170. <el-table-column
  171. label="是否备案成功"
  172. show-overflow-tooltip>
  173. <template slot-scope="scope">
  174. <span v-if="scope.row.isSuccess == 1">备案成功(有ETC)</span>
  175. <span v-else-if="scope.row.isSuccess == 2">备案失败(没有ETC)</span>
  176. <span v-else-if="scope.row.isSuccess == 3">备案失败(车辆已备案)</span>
  177. </template>
  178. </el-table-column>
  179. </el-table>
  180. </template>
  181. <div class="blocks">
  182. <el-pagination
  183. @size-change="handleSize"
  184. @current-change="handleCurrent"
  185. :current-page="currenttwo"
  186. :page-sizes="[6, 8, 10]"
  187. :page-size="pagesizetwo"
  188. layout="total, sizes, prev, pager, next, jumper"
  189. :total="totaltwo">
  190. </el-pagination>
  191. </div>
  192. </el-dialog>
  193. </div>
  194. </template>
  195. <script>
  196. export default{
  197. data() {
  198. return {
  199. loading: false,
  200. fullscreenLoading: false,
  201. userName: '',
  202. userCompany: '',
  203. batchNumber: '',
  204. userPhone: '',
  205. plateNumber: '',
  206. plateColor: '',
  207. optionone: [{
  208. value: '0',
  209. label: '蓝色'
  210. }, {
  211. value: '1',
  212. label: '黄色'
  213. }, {
  214. value: '2',
  215. label: '黑色'
  216. }, {
  217. value: '3',
  218. label: '白色'
  219. }, {
  220. value: '4',
  221. label: '渐变绿色'
  222. }, {
  223. value: '5',
  224. label: '黄绿渐变色'
  225. }, {
  226. value: '6',
  227. label: '蓝白渐变色'
  228. }, {
  229. value: '9',
  230. label: '未确定'
  231. }],
  232. addList: false,
  233. current: 1,
  234. pagesize: 8,
  235. total: 0,
  236. currenttwo: 1,
  237. pagesizetwo: 8,
  238. totaltwo: 0,
  239. batch: '',
  240. batchId: '',
  241. usertable: [],
  242. usertabletwo: [],
  243. formUserList: {
  244. "userId": "",
  245. "file": "",
  246. "roleId": ""
  247. },
  248. }
  249. },
  250. created() {
  251. this.loadData();
  252. },
  253. methods: {
  254. // 列表展示
  255. async loadData() {
  256. this.formUserList.userId = sessionStorage.getItem('userId');
  257. this.formUserList.roleId = sessionStorage.getItem('roleId');
  258. if(this.formUserList.roleId == 1) {
  259. const formData = new FormData();
  260. formData.append('current', this.current);
  261. formData.append('size', this.pagesize);
  262. formData.append('type', 1);
  263. const response = await this.$http.post(`batch/list`, formData);
  264. if (response.data.code === 0) {
  265. this.loading = false;
  266. this.usertable = response.data.data.records;
  267. this.total = response.data.data.total;
  268. };
  269. }else {
  270. const formData = new FormData();
  271. formData.append('current', this.current);
  272. formData.append('size', this.pagesize);
  273. formData.append('userId', this.formUserList.userId);
  274. formData.append('type', 1);
  275. const response = await this.$http.post(`batch/list`, formData);
  276. if (response.data.code === 0) {
  277. this.loading = false;
  278. this.usertable = response.data.data.records;
  279. this.total = response.data.data.total;
  280. };
  281. };
  282. },
  283. //查询
  284. async queryLook() {
  285. if(this.formUserList.roleId == 1) {
  286. const formData = new FormData();
  287. formData.append('current', this.current);
  288. formData.append('size', this.pagesize);
  289. formData.append('type', 1);
  290. formData.append('userName', this.userName);
  291. formData.append('userCompany', this.userCompany);
  292. formData.append('batchNumber', this.batchNumber);
  293. const response = await this.$http.post(`batch/list`, formData);
  294. if (response.data.code === 0) {
  295. this.loading = false;
  296. this.usertable = response.data.data.records;
  297. this.total = response.data.data.total;
  298. };
  299. }else {
  300. const formData = new FormData();
  301. formData.append('current', this.current);
  302. formData.append('size', this.pagesize);
  303. formData.append('userId', this.formUserList.userId);
  304. formData.append('type', 1);
  305. formData.append('userName', this.userName);
  306. formData.append('userCompany', this.userCompany);
  307. formData.append('batchNumber', this.batchNumber);
  308. const response = await this.$http.post(`batch/list`, formData);
  309. if (response.data.code === 0) {
  310. this.loading = false;
  311. this.usertable = response.data.data.records;
  312. this.total = response.data.data.total;
  313. };
  314. };
  315. },
  316. // 下载模板
  317. DownloadTemplate() {
  318. var url = 'http://invoice.back.jkcredit.com/carFreeCarrierRegister/downTemp';
  319. window.location.href= url;
  320. },
  321. // 批量上传模板信息
  322. async batchUpload() {
  323. this.fullscreenLoading = true;
  324. const formData = new FormData();
  325. formData.append('userId', this.formUserList.userId);
  326. formData.append('file', this.formUserList.file);
  327. const response = await this.$http.post(`carFreeCarrierRegister/excel`,formData);
  328. var {data: { code, msg, data }} = response;
  329. if(code === 0 && msg === 'success') {
  330. this.loadData();
  331. this.fullscreenLoading = false;
  332. this.$message.success('上传成功');
  333. }else if(code === 1 && msg == null && data == null) {
  334. this.fullscreenLoading = false;
  335. this.$message.error('数据存在错误,请检查文件中数据');
  336. }else {
  337. this.fullscreenLoading = false;
  338. this.$message.error(msg);
  339. }
  340. },
  341. // 查看批次数据
  342. async checkLook(id) {
  343. this.addList = true;
  344. this.batchId = id;
  345. this.loadDataCar();
  346. },
  347. // 查看批次数据
  348. async loadDataCar() {
  349. if(this.formUserList.roleId == 1) {
  350. const formData = new FormData();
  351. formData.append('current', this.currenttwo);
  352. formData.append('size', this.pagesizetwo);
  353. formData.append('batchId', this.batchId);
  354. const response = await this.$http.post(`carFreeCarrierRegister/list`, formData);
  355. if (response.data.code === 0) {
  356. this.loading = false;
  357. this.usertabletwo = response.data.data.records;
  358. this.totaltwo = response.data.data.total;
  359. }
  360. }else {
  361. const formData = new FormData();
  362. formData.append('current', this.currenttwo);
  363. formData.append('size', this.pagesizetwo);
  364. formData.append('batchId', this.batchId);
  365. formData.append('userId', this.formUserList.userId);
  366. const response = await this.$http.post(`carFreeCarrierRegister/list`, formData);
  367. if (response.data.code === 0) {
  368. this.loading = false;
  369. this.usertabletwo = response.data.data.records;
  370. this.totaltwo = response.data.data.total;
  371. }
  372. }
  373. },
  374. //查看(二)
  375. async queryLookTwo(){
  376. if(this.formUserList.roleId == 1) {
  377. const formData = new FormData();
  378. formData.append('current', this.currenttwo);
  379. formData.append('size', this.pagesizetwo);
  380. formData.append('batchId', this.batchId);
  381. formData.append('userPhone', this.userPhone);
  382. formData.append('plateNumber', this.plateNumber);
  383. formData.append('plateColor', this.plateColor);
  384. const response = await this.$http.post(`carFreeCarrierRegister/list`, formData);
  385. if (response.data.code === 0) {
  386. this.loading = false;
  387. this.usertabletwo = response.data.data.records;
  388. this.totaltwo = response.data.data.total;
  389. }
  390. }else {
  391. const formData = new FormData();
  392. formData.append('current', this.currenttwo);
  393. formData.append('size', this.pagesizetwo);
  394. formData.append('batchId', this.batchId);
  395. formData.append('userId', this.formUserList.userId);
  396. formData.append('userPhone', this.userPhone);
  397. formData.append('plateNumber', this.plateNumber);
  398. formData.append('plateColor', this.plateColor);
  399. const response = await this.$http.post(`carFreeCarrierRegister/list`, formData);
  400. if (response.data.code === 0) {
  401. this.loading = false;
  402. this.usertabletwo = response.data.data.records;
  403. this.totaltwo = response.data.data.total;
  404. }
  405. }
  406. },
  407. // 清空表单数据
  408. handleEditDialogClose() {
  409. this.userPhone = '';
  410. this.plateNumber = '';
  411. this.plateColor = '';
  412. this.current = 1;
  413. this.pagesize = 8;
  414. this.currenttwo = 1;
  415. this.pagesizetwo = 8;
  416. },
  417. handleRemove(file, fileList) {
  418. console.log(file, fileList);
  419. },
  420. handlePreview(file) {
  421. console.log(file);
  422. },
  423. handleSuccess (a) {
  424. this.formUserList.file = a.raw;
  425. },
  426. // 分页方法
  427. handleSizeChange(val) {
  428. this.pagesize = val;
  429. if(this.userName !== '' || this.userCompany !== '' || this.batchNumber !== '') {
  430. this.queryLook();
  431. }else{
  432. this.loadData();
  433. };
  434. console.log(`每页 ${val} 条`);
  435. },
  436. handleCurrentChange(val) {
  437. this.current = val;
  438. if(this.userName !== '' || this.userCompany !== '' || this.batchNumber !== '') {
  439. this.queryLook();
  440. }else{
  441. this.loadData();
  442. };
  443. console.log(`当前页: ${val}`);
  444. },
  445. handleSize(val) {
  446. this.pagesizetwo = val;
  447. if(this.userPhone !== '' || this.plateNumber !== '' || this.plateColor !== '') {
  448. this.queryLookTwo();
  449. }else{
  450. this.loadDataCar();
  451. };
  452. console.log(`每页 ${val} 条`);
  453. },
  454. handleCurrent(val) {
  455. this.currenttwo = val;
  456. if(this.userPhone !== '' || this.plateNumber !== '' || this.plateColor !== '') {
  457. this.queryLookTwo();
  458. }else{
  459. this.loadDataCar();
  460. };
  461. console.log(`当前页: ${val}`);
  462. }
  463. }
  464. };
  465. </script>
  466. <style>
  467. .carupload {
  468. border: 1px solid #d9d9d9;
  469. border-radius: 10px;
  470. }
  471. .carupload .upload-demo {
  472. display: inline-block;
  473. }
  474. .carupload .title {
  475. font-size: 5px;
  476. margin-bottom: 20px;
  477. }
  478. .carupload .top {
  479. padding-top: 20px;
  480. padding-left: 20px;
  481. }
  482. .carupload .text {
  483. display: inline-block;
  484. color: #000;
  485. font-size: 16px ;
  486. margin-left: 1%;
  487. }
  488. .carupload .tou {
  489. font-size: 20px;
  490. height: 30px;
  491. line-height: 30px;
  492. padding-top: 15px;
  493. }
  494. .carupload .line {
  495. margin-top: 15px;
  496. margin-bottom: 15px;
  497. width: 100%;
  498. height: 2px;
  499. background-color: #d9d9d9;
  500. }
  501. .carupload .theinput {
  502. display: inline-block;
  503. width: 20%;
  504. }
  505. .carupload .styleType {
  506. margin-top: 20px;
  507. margin-bottom: 20px;
  508. }
  509. .carupload .input-demo {
  510. display: inline-block;
  511. width: 20%;
  512. margin-left: 1%;
  513. }
  514. .carupload .block {
  515. font-size: 5px;
  516. text-align: center;
  517. margin-top: 15px;
  518. margin-bottom: 20px;
  519. }
  520. .carupload .blocks {
  521. font-size: 5px;
  522. text-align: center;
  523. margin-top: 20px;
  524. padding-bottom: 20px;
  525. }
  526. .carupload .el-dialog {
  527. width: 90%;
  528. }
  529. .carupload .el-dialog__header, .el-dialog__body {
  530. padding: 0 20px;
  531. }
  532. </style>