carupload.vue 18 KB

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