index.vue 18 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658
  1. <template>
  2. <div>
  3. <basic-container>
  4. <avue-crud
  5. ref="crud"
  6. :data="dataList"
  7. :option="option"
  8. :page.sync="page"
  9. :search.sync="search"
  10. :table-loading="loading"
  11. v-model="form"
  12. @on-load="onLoad"
  13. @row-save="rowSave"
  14. @row-update="rowUpdate"
  15. @row-del="rowDel"
  16. @search-change="searchChange"
  17. :before-open="beforeOpen"
  18. @search-reset="searchReset"
  19. @refresh-change="refreshChange"
  20. @current-change="currentChange"
  21. @size-change="sizeChange"
  22. @search-criteria-switch="searchCriteriaSwitch"
  23. >
  24. <template slot="menuLeft">
  25. <el-button type="primary"
  26. size="small"
  27. icon="el-icon-upload2"
  28. @click="handleImport">导入
  29. </el-button>
  30. </template>
  31. <template slot="urlForm" slot-scope="{ row }">
  32. <el-input
  33. placeholder="文件地址"
  34. size="small"
  35. v-if="row.$cellEdit"
  36. v-model="row.url"
  37. class="input-with-select">
  38. <el-button size="small" type="primary" slot="prepend" @click="download(row)">查看</el-button>
  39. <el-upload
  40. class="upload-demo"
  41. :show-file-list="false"
  42. slot="append"
  43. :action="action"
  44. :headers="headers"
  45. :on-success="(response)=>{onSuccessTwo(response,row)}"
  46. :multiple="false">
  47. <el-button size="small" type="primary">上传</el-button>
  48. </el-upload>
  49. </el-input>
  50. <span v-else>{{ row.url }}</span>
  51. </template>
  52. <template slot="fleetIdForm" slot-scope="{ row }">
  53. <span>{{ row }}</span>
  54. <crop-select
  55. v-model="form.fleetId"
  56. corpType="CD"
  57. />
  58. </template>
  59. <template slot="fleetIdSearch">
  60. <crop-select v-model="search.fleetId" corpType="CD"></crop-select>
  61. </template>
  62. <template slot="fleetId" slot-scope="{row,disabled}">
  63. <span>{{ row.fleetName }}</span>
  64. </template>
  65. <template slot="driverId" slot-scope="{row,disabled}">
  66. <span>{{ row.driverName }}</span>
  67. </template>
  68. </avue-crud>
  69. <el-dialog title="导入"
  70. append-to-body
  71. :visible.sync="excelBox"
  72. width="555px">
  73. <avue-form :option="excelOption" v-model="excelForm" :upload-after="uploadAfter">
  74. <template slot="excelTemplate">
  75. <el-button type="primary" @click="handleTemplate">
  76. 点击下载<i class="el-icon-download el-icon--right"></i>
  77. </el-button>
  78. </template>
  79. </avue-form>
  80. <p style="text-align: center;color: #DC0505">
  81. 温馨提示 第一次导入时请先下载模板
  82. </p>
  83. </el-dialog>
  84. </basic-container>
  85. </div>
  86. </template>
  87. <script>
  88. import {getCarList, carSubmit, carRemove, detailDelegationList, removeFile} from "@/api/landTransportation/car";
  89. import {getToken} from '@/util/auth';
  90. export default {
  91. name: "index",
  92. data() {
  93. return {
  94. dataList: [],
  95. excelOption: {
  96. submitBtn: false,
  97. emptyBtn: false,
  98. column: [
  99. {
  100. label: '模板下载',
  101. prop: 'excelTemplate',
  102. formslot: true,
  103. span: 24,
  104. }, {
  105. label: '模板上传',
  106. prop: 'excelFile',
  107. type: 'upload',
  108. drag: true,
  109. loadText: '模板上传中,请稍等',
  110. span: 24,
  111. propsHttp: {
  112. res: 'data'
  113. },
  114. tip: '请上传 .xls,.xlsx 标准格式文件',
  115. action: "/api/blade-client/land-vehicle/import-data"
  116. }
  117. ]
  118. },
  119. excelForm: {},
  120. option: {
  121. dialogWidth: '85%',
  122. searchIcon: true,
  123. searchIndex: 2,
  124. searchMenuSpan: 24,
  125. stripe: true,
  126. searchLabelWidth: 100,
  127. align: 'center',
  128. index: true,
  129. column: [{
  130. label: '车牌号',
  131. prop: 'plateNo',
  132. index: 1,
  133. width: 140,
  134. cell: true,
  135. overHidden: true,
  136. search: true,
  137. span: 8,
  138. searchSpan: 8,
  139. rules: [{
  140. required: true,
  141. message: "请输入车牌号",
  142. trigger: "blur"
  143. }],
  144. }, {
  145. label: '车队名称',
  146. prop: 'fleetId',
  147. index: 2,
  148. width: 140,
  149. cell: true,
  150. overHidden: true,
  151. search: true,
  152. span: 8,
  153. searchSpan: 8,
  154. }, {
  155. label: '司机名称',
  156. prop: 'driverId',
  157. index: 3,
  158. width: 140,
  159. cell: true,
  160. overHidden: true,
  161. search: true,
  162. span: 8,
  163. searchSpan: 8,
  164. type: 'select',
  165. dicUrl: "/api/blade-client/land-driver/driver-list?vehicleId={{key}}",
  166. props: {
  167. label: "name",
  168. value: "id"
  169. },
  170. }, {
  171. label: '挂车号',
  172. prop: 'trailerNo',
  173. index: 4,
  174. width: 140,
  175. cell: true,
  176. overHidden: true,
  177. search: true,
  178. span: 8,
  179. searchSpan: 8,
  180. }, {
  181. label: '燃油类型',
  182. prop: 'fuelType',
  183. index: 5,
  184. width: 140,
  185. cell: true,
  186. overHidden: true,
  187. search: true,
  188. span: 8,
  189. searchSpan: 8,
  190. }, {
  191. type: "select",
  192. dicUrl: "/api/blade-system/dict-biz/dictionary?code=carType",
  193. props: {
  194. label: "dictValue",
  195. value: "dictValue"
  196. },
  197. label: '车辆类型',
  198. prop: 'type',
  199. index: 6,
  200. width: 140,
  201. cell: true,
  202. overHidden: true,
  203. search: true,
  204. span: 8,
  205. searchSpan: 8,
  206. }, {
  207. label: '车辆品牌',
  208. prop: 'brand',
  209. index: 7,
  210. width: 140,
  211. cell: true,
  212. overHidden: true,
  213. search: true,
  214. span: 8,
  215. searchSpan: 8,
  216. }, {
  217. label: '制造单位',
  218. prop: 'manufacturer',
  219. index: 8,
  220. width: 140,
  221. cell: true,
  222. overHidden: true,
  223. search: true,
  224. span: 8,
  225. searchSpan: 8,
  226. }, {
  227. label: '发证机关',
  228. prop: 'issuingAuthority',
  229. index: 9,
  230. width: 140,
  231. cell: true,
  232. overHidden: true,
  233. search: true,
  234. span: 8,
  235. searchSpan: 8,
  236. }, {
  237. label: '牵引车辆型号',
  238. prop: 'towModel',
  239. index: 10,
  240. width: 140,
  241. cell: true,
  242. overHidden: true,
  243. search: true,
  244. span: 8,
  245. searchSpan: 8,
  246. }, {
  247. label: '牵引车车架号',
  248. prop: 'towVin',
  249. index: 11,
  250. width: 140,
  251. cell: true,
  252. overHidden: true,
  253. search: true,
  254. span: 8,
  255. searchSpan: 8,
  256. }, {
  257. label: '挂车型号',
  258. prop: 'trailerModel',
  259. index: 12,
  260. width: 140,
  261. cell: true,
  262. overHidden: true,
  263. search: true,
  264. span: 8,
  265. searchSpan: 8,
  266. }, {
  267. label: '挂车车架号',
  268. prop: 'trailerVin',
  269. index: 13,
  270. width: 140,
  271. cell: true,
  272. overHidden: true,
  273. search: true,
  274. span: 8,
  275. searchSpan: 8,
  276. }, {
  277. label: '发动机型号',
  278. prop: 'engineModel',
  279. index: 14,
  280. width: 140,
  281. cell: true,
  282. overHidden: true,
  283. search: true,
  284. span: 8,
  285. searchSpan: 8,
  286. }, {
  287. label: '核载人数',
  288. prop: 'allowPassenger',
  289. index: 15,
  290. width: 140,
  291. cell: true,
  292. overHidden: true,
  293. search: true,
  294. span: 8,
  295. searchSpan: 8,
  296. }, {
  297. label: '购车日期',
  298. prop: 'purchaseDate',
  299. index: 16,
  300. width: 140,
  301. cell: true,
  302. overHidden: true,
  303. search: true,
  304. searchRange: true,
  305. span: 8,
  306. searchSpan: 8,
  307. type: "date",
  308. searchDefaultTime: ['00:00:00', '23:59:59'],
  309. format: "yyyy-MM-dd",
  310. valueFormat: "yyyy-MM-dd HH:mm:ss",
  311. }, {
  312. label: '注册日期',
  313. prop: 'registerDate',
  314. index: 17,
  315. width: 140,
  316. overHidden: true,
  317. type: "date",
  318. searchRange: true,
  319. search: true,
  320. span: 8,
  321. searchSpan: 8,
  322. searchDefaultTime: ['00:00:00', '23:59:59'],
  323. format: "yyyy-MM-dd",
  324. valueFormat: "yyyy-MM-dd HH:mm:ss",
  325. }, {
  326. label: '报废日期',
  327. prop: 'scrapDate',
  328. index: 18,
  329. width: 140,
  330. overHidden: true,
  331. search: true,
  332. searchRange: true,
  333. span: 8,
  334. searchSpan: 8,
  335. type: "date",
  336. searchDefaultTime: ['00:00:00', '23:59:59'],
  337. format: "yyyy-MM-dd",
  338. valueFormat: "yyyy-MM-dd HH:mm:ss",
  339. }, {
  340. label: '外廓尺寸mm',
  341. prop: 'oto',
  342. index: 19,
  343. width: 140,
  344. cell: true,
  345. overHidden: true,
  346. span: 8,
  347. searchSpan: 8,
  348. }, {
  349. label: '总重量kg',
  350. prop: 'totalWeight',
  351. index: 20,
  352. width: 140,
  353. cell: true,
  354. overHidden: true,
  355. span: 8,
  356. searchSpan: 8,
  357. }, {
  358. label: '核定重量kg',
  359. prop: 'approvedWeight',
  360. index: 21,
  361. width: 140,
  362. cell: true,
  363. overHidden: true,
  364. span: 8,
  365. searchSpan: 8,
  366. }, {
  367. label: '装备重量kg',
  368. prop: 'equipmentWeight',
  369. index: 22,
  370. width: 140,
  371. cell: true,
  372. overHidden: true,
  373. span: 8,
  374. searchSpan: 8,
  375. }, {
  376. label: '年审',
  377. prop: 'inspectExpired',
  378. overHidden: true,
  379. type: "date",
  380. searchRange: true,
  381. search: true,
  382. span: 8,
  383. searchSpan: 8,
  384. searchDefaultTime: ['00:00:00', '23:59:59'],
  385. format: "yyyy-MM-dd",
  386. valueFormat: "yyyy-MM-dd HH:mm:ss",
  387. }, {
  388. label: '保险',
  389. prop: 'insuranceExpired',
  390. overHidden: true,
  391. type: "date",
  392. searchRange: true,
  393. search: true,
  394. span: 8,
  395. searchSpan: 8,
  396. searchDefaultTime: ['00:00:00', '23:59:59'],
  397. format: "yyyy-MM-dd",
  398. valueFormat: "yyyy-MM-dd HH:mm:ss",
  399. },
  400. // {
  401. // label: '信用等级',
  402. // width: 150,
  403. // span: 8,
  404. // searchSpan: 8,
  405. // prop: 'salesman',
  406. // search: true,
  407. // overHidden: true,
  408. // type: "select",
  409. // dicUrl: "/api/blade-system/dict-biz/dictionary?code=credit_rating",
  410. // props: {
  411. // label: "dictValue",
  412. // value: "dictKey"
  413. // },
  414. // },
  415. {
  416. label: '附件',
  417. prop: 'fileList',
  418. type: 'dynamic',
  419. hide: true,
  420. showColumn: false,
  421. span: 24,
  422. children: {
  423. align: 'center',
  424. stripe: true,
  425. headerAlign: 'center',
  426. rowAdd: (done) => {
  427. // this.$message.success('新增回调');
  428. done()
  429. },
  430. rowDel: (row, done) => {
  431. if (row.id) {
  432. removeFile(row.id).then(res => {
  433. done();
  434. })
  435. } else {
  436. done();
  437. }
  438. },
  439. column: [{
  440. width: 360,
  441. label: '文件地址',
  442. prop: "url"
  443. }, {
  444. width: 200,
  445. label: '文件名称',
  446. prop: "fileName",
  447. formslot: true
  448. }, {
  449. width: 200,
  450. label: '文件属性',
  451. type: "select",
  452. dicUrl: "/api/blade-system/dict-biz/dictionary?code=file_type",
  453. props: {
  454. label: "dictValue",
  455. value: "dictValue"
  456. }
  457. }, {
  458. label: '备注',
  459. prop: "remarks",
  460. }]
  461. }
  462. },
  463. {
  464. label: '司机变更记录',
  465. prop: 'vehicleChangeList',
  466. type: 'dynamic',
  467. span: 24,
  468. hide: true,
  469. showColumn: false,
  470. children: {
  471. align: 'center',
  472. headerAlign: 'center',
  473. addBtn: false,
  474. stripe: true,
  475. delBtn: false,
  476. cellBtn: false,
  477. column: [
  478. {
  479. label: '司机名',
  480. prop: "driverName",
  481. cell: false
  482. }, {
  483. label: '变更人',
  484. prop: "changeUserName",
  485. cell: false
  486. }, {
  487. label: '变更日期',
  488. prop: "changeTime",
  489. cell: false
  490. }]
  491. }
  492. }
  493. ]
  494. },
  495. page: {
  496. pageSize: 10,
  497. currentPage: 1,
  498. total: 0,
  499. pageSizes: [10, 50, 100, 200, 300]
  500. },
  501. search: {},
  502. loading: false,
  503. action: "/api/blade-resource/oss/endpoint/put-file",
  504. headers: {"Blade-Auth": "Bearer " + getToken()},
  505. ids: [], // id集合
  506. form: {},
  507. excelBox: false
  508. }
  509. },
  510. created() {
  511. let i = 0;
  512. this.option.column.forEach(item => {
  513. if (item.search) i++
  514. })
  515. if (i % 3 !== 0) {
  516. const num = 3 - Number(i % 3)
  517. this.option.searchMenuSpan = num * 8;
  518. this.option.searchMenuPosition = "right";
  519. }
  520. },
  521. methods: {
  522. handleImport() {
  523. this.excelBox = true;
  524. },
  525. uploadAfter(res, done, loading, column) {
  526. this.excelBox = false;
  527. this.refreshChange();
  528. done();
  529. },
  530. handleTemplate() {
  531. window.open(`/api/blade-client/land-vehicle/import-template?${this.website.tokenHeader}=${getToken()}`);
  532. },
  533. //点击行编辑时查看
  534. beforeOpen(done, type) {
  535. if (this.form.id) {
  536. detailDelegationList(this.form.id).then(res => {
  537. this.form = res.data.data
  538. done()
  539. })
  540. } else {
  541. done()
  542. }
  543. },
  544. // 获得高度
  545. searchCriteriaSwitch(type) {
  546. if (type) {
  547. this.option.height = this.option.height - 322
  548. } else {
  549. this.option.height = this.option.height + 322
  550. }
  551. this.$refs.crud.getTableHeight()
  552. },
  553. onLoad(page, params) {
  554. const queryParams = Object.assign({}, params, {
  555. size: page.pageSize,
  556. current: page.currentPage,
  557. })
  558. getCarList(queryParams).then(res => {
  559. this.dataList = res.data.data.records;
  560. this.page.total = res.data.data.total;
  561. this.option.height = window.innerHeight - 240;
  562. })
  563. },
  564. rowSave(form, done, loading) {
  565. carSubmit(form).then(res => {
  566. this.$message.success(form.id ? '修改成功' : '新增成功')
  567. })
  568. this.onLoad(this.page)
  569. done();
  570. },
  571. rowUpdate(form, index, done) {
  572. carSubmit(form).then(res => {
  573. this.$message.success(form.id ? '修改成功' : '新增成功')
  574. })
  575. this.onLoad(this.page)
  576. done();
  577. },
  578. rowDel(row) {
  579. this.$confirm("确定将选择数据删除?", {
  580. confirmButtonText: "确定",
  581. cancelButtonText: "取消",
  582. type: "warning"
  583. }).then(() => {
  584. const ids = this.ids.length == 0 ? row.id : this.ids.join(',');
  585. carRemove({ids}).then(res => {
  586. this.$message.success('删除成功');
  587. this.onLoad(this.page);
  588. })
  589. })
  590. },
  591. //附件上传成功
  592. onSuccessTwo(response, row) {
  593. row.url = response.data.link
  594. row.fileName = response.data.originalName
  595. },
  596. //下载附件
  597. download(row) {
  598. if (row.url) {
  599. window.open(row.url)
  600. } else {
  601. this.$message.warning('无附件,请上传附件后再查看');
  602. }
  603. },
  604. // 搜索
  605. searchChange(params, done) {
  606. this.page.currentPage = 1;
  607. let data = params
  608. if (data.purchaseDate) {
  609. data.beginPurchaseDate = params.purchaseDate[0]
  610. data.endPurchaseDate = params.purchaseDate[1]
  611. }
  612. if (data.registerDate) {
  613. data.beginRegisterDate = params.registerDate[0]
  614. data.endRegisterDate = params.registerDate[1]
  615. }
  616. if (data.scrapDate) {
  617. data.beginScrapDate = params.scrapDate[0]
  618. data.endScrapDate = params.scrapDate[1]
  619. }
  620. if (data.inspectExpired) {
  621. data.beginInspectExpired = params.inspectExpired[0]
  622. data.endInspectExpired = params.inspectExpired[1]
  623. }
  624. if (data.insuranceExpired) {
  625. data.beginInsuranceExpired = params.insuranceExpired[0]
  626. data.endInsuranceExpired = params.insuranceExpired[1]
  627. }
  628. delete data.purchaseDate
  629. delete data.registerDate
  630. delete data.scrapDate
  631. delete data.inspectExpired
  632. delete data.insuranceExpired
  633. this.onLoad(this.page, data);
  634. done()
  635. },
  636. // 重置
  637. searchReset() {
  638. },
  639. //刷新
  640. refreshChange() {
  641. this.onLoad(this.page, this.search)
  642. },
  643. currentChange(currentPage) {
  644. this.page.currentPage = currentPage;
  645. },
  646. sizeChange(pageSize) {
  647. this.page.pageSize = pageSize;
  648. },
  649. },
  650. }
  651. </script>
  652. <style scoped>
  653. </style>