index.vue 18 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678
  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. filterable:true,
  166. dicUrl: "/api/blade-client/land-driver/driver-list?vehicleId={{key}}",
  167. props: {
  168. label: "name",
  169. value: "id"
  170. },
  171. }, {
  172. label: '挂车号',
  173. prop: 'trailerNo',
  174. index: 4,
  175. width: 140,
  176. cell: true,
  177. overHidden: true,
  178. search: true,
  179. span: 8,
  180. searchSpan: 8,
  181. }, {
  182. label: '燃油类型',
  183. prop: 'fuelType',
  184. index: 5,
  185. width: 140,
  186. cell: true,
  187. overHidden: true,
  188. search: true,
  189. span: 8,
  190. searchSpan: 8,
  191. }, {
  192. type: "select",
  193. dicUrl: "/api/blade-system/dict-biz/dictionary?code=carType",
  194. props: {
  195. label: "dictValue",
  196. value: "dictValue"
  197. },
  198. label: '车辆类型',
  199. prop: 'type',
  200. index: 6,
  201. width: 140,
  202. cell: true,
  203. overHidden: true,
  204. search: true,
  205. span: 8,
  206. searchSpan: 8,
  207. }, {
  208. label: '车辆品牌',
  209. prop: 'brand',
  210. index: 7,
  211. width: 140,
  212. cell: true,
  213. overHidden: true,
  214. search: true,
  215. span: 8,
  216. searchSpan: 8,
  217. }, {
  218. label: '制造单位',
  219. prop: 'manufacturer',
  220. index: 8,
  221. width: 140,
  222. cell: true,
  223. overHidden: true,
  224. search: true,
  225. span: 8,
  226. searchSpan: 8,
  227. }, {
  228. label: '发证机关',
  229. prop: 'issuingAuthority',
  230. index: 9,
  231. width: 140,
  232. cell: true,
  233. overHidden: true,
  234. search: true,
  235. span: 8,
  236. searchSpan: 8,
  237. }, {
  238. label: '牵引车辆型号',
  239. prop: 'towModel',
  240. index: 10,
  241. width: 140,
  242. cell: true,
  243. overHidden: true,
  244. search: true,
  245. span: 8,
  246. searchSpan: 8,
  247. }, {
  248. label: '牵引车车架号',
  249. prop: 'towVin',
  250. index: 11,
  251. width: 140,
  252. cell: true,
  253. overHidden: true,
  254. search: true,
  255. span: 8,
  256. searchSpan: 8,
  257. }, {
  258. label: '挂车型号',
  259. prop: 'trailerModel',
  260. index: 12,
  261. width: 140,
  262. cell: true,
  263. overHidden: true,
  264. search: true,
  265. span: 8,
  266. searchSpan: 8,
  267. }, {
  268. label: '挂车车架号',
  269. prop: 'trailerVin',
  270. index: 13,
  271. width: 140,
  272. cell: true,
  273. overHidden: true,
  274. search: true,
  275. span: 8,
  276. searchSpan: 8,
  277. }, {
  278. label: '发动机型号',
  279. prop: 'engineModel',
  280. index: 14,
  281. width: 140,
  282. cell: true,
  283. overHidden: true,
  284. search: true,
  285. span: 8,
  286. searchSpan: 8,
  287. }, {
  288. label: '核载人数',
  289. prop: 'allowPassenger',
  290. index: 15,
  291. width: 140,
  292. cell: true,
  293. overHidden: true,
  294. search: true,
  295. span: 8,
  296. searchSpan: 8,
  297. }, {
  298. label: '购车日期',
  299. prop: 'purchaseDate',
  300. index: 16,
  301. width: 140,
  302. cell: true,
  303. overHidden: true,
  304. search: true,
  305. searchRange: true,
  306. span: 8,
  307. searchSpan: 8,
  308. type: "date",
  309. searchDefaultTime: ['00:00:00', '23:59:59'],
  310. format: "yyyy-MM-dd",
  311. valueFormat: "yyyy-MM-dd HH:mm:ss",
  312. }, {
  313. label: '注册日期',
  314. prop: 'registerDate',
  315. index: 17,
  316. width: 140,
  317. overHidden: true,
  318. type: "date",
  319. searchRange: true,
  320. search: true,
  321. span: 8,
  322. searchSpan: 8,
  323. searchDefaultTime: ['00:00:00', '23:59:59'],
  324. format: "yyyy-MM-dd",
  325. valueFormat: "yyyy-MM-dd HH:mm:ss",
  326. }, {
  327. label: '报废日期',
  328. prop: 'scrapDate',
  329. index: 18,
  330. width: 140,
  331. overHidden: true,
  332. search: true,
  333. searchRange: true,
  334. span: 8,
  335. searchSpan: 8,
  336. type: "date",
  337. searchDefaultTime: ['00:00:00', '23:59:59'],
  338. format: "yyyy-MM-dd",
  339. valueFormat: "yyyy-MM-dd HH:mm:ss",
  340. }, {
  341. label: '外廓尺寸mm',
  342. prop: 'oto',
  343. index: 19,
  344. width: 140,
  345. cell: true,
  346. overHidden: true,
  347. span: 8,
  348. searchSpan: 8,
  349. }, {
  350. label: '总重量kg',
  351. prop: 'totalWeight',
  352. index: 20,
  353. width: 140,
  354. cell: true,
  355. overHidden: true,
  356. span: 8,
  357. searchSpan: 8,
  358. }, {
  359. label: '核定重量kg',
  360. prop: 'approvedWeight',
  361. index: 21,
  362. width: 140,
  363. cell: true,
  364. overHidden: true,
  365. span: 8,
  366. searchSpan: 8,
  367. }, {
  368. label: '装备重量kg',
  369. prop: 'equipmentWeight',
  370. index: 22,
  371. width: 140,
  372. cell: true,
  373. overHidden: true,
  374. span: 8,
  375. searchSpan: 8,
  376. }, {
  377. label: '年审',
  378. prop: 'inspectExpired',
  379. overHidden: true,
  380. type: "date",
  381. searchRange: true,
  382. search: true,
  383. span: 8,
  384. searchSpan: 8,
  385. searchDefaultTime: ['00:00:00', '23:59:59'],
  386. format: "yyyy-MM-dd",
  387. valueFormat: "yyyy-MM-dd HH:mm:ss",
  388. }, {
  389. label: '保险',
  390. prop: 'insuranceExpired',
  391. overHidden: true,
  392. type: "date",
  393. searchRange: true,
  394. search: true,
  395. span: 8,
  396. searchSpan: 8,
  397. searchDefaultTime: ['00:00:00', '23:59:59'],
  398. format: "yyyy-MM-dd",
  399. valueFormat: "yyyy-MM-dd HH:mm:ss",
  400. }, {
  401. label: '位置获取来源',
  402. prop: 'locationSource',
  403. span: 8,
  404. searchSpan: 8,
  405. type: 'select',
  406. dicUrl: "/api/blade-system/dict-biz/dictionary?code=location_source",
  407. props: {
  408. label: "dictValue",
  409. value: "dictKey"
  410. }
  411. }, {
  412. label: 'gpsid',
  413. index: 19,
  414. prop: 'gpsid',
  415. span: 8,
  416. searchSpan: 8,
  417. },
  418. // {
  419. // label: '信用等级',
  420. // width: 150,
  421. // span: 8,
  422. // searchSpan: 8,
  423. // prop: 'salesman',
  424. // search: true,
  425. // overHidden: true,
  426. // type: "select",
  427. // dicUrl: "/api/blade-system/dict-biz/dictionary?code=credit_rating",
  428. // props: {
  429. // label: "dictValue",
  430. // value: "dictKey"
  431. // },
  432. // },
  433. {
  434. label: '附件',
  435. prop: 'fileList',
  436. type: 'dynamic',
  437. hide: true,
  438. showColumn: false,
  439. span: 24,
  440. children: {
  441. align: 'center',
  442. stripe: true,
  443. headerAlign: 'center',
  444. rowAdd: (done) => {
  445. // this.$message.success('新增回调');
  446. done()
  447. },
  448. rowDel: (row, done) => {
  449. if (row.id) {
  450. removeFile(row.id).then(res => {
  451. done();
  452. })
  453. } else {
  454. done();
  455. }
  456. },
  457. column: [{
  458. width: 360,
  459. label: '文件地址',
  460. prop: "url"
  461. }, {
  462. width: 200,
  463. label: '文件名称',
  464. prop: "fileName",
  465. formslot: true
  466. }, {
  467. width: 200,
  468. label: '文件属性',
  469. type: "select",
  470. dicUrl: "/api/blade-system/dict-biz/dictionary?code=file_type",
  471. props: {
  472. label: "dictValue",
  473. value: "dictValue"
  474. }
  475. }, {
  476. label: '备注',
  477. prop: "remarks",
  478. }]
  479. }
  480. },
  481. {
  482. label: '司机变更记录',
  483. prop: 'vehicleChangeList',
  484. type: 'dynamic',
  485. span: 24,
  486. hide: true,
  487. showColumn: false,
  488. children: {
  489. align: 'center',
  490. headerAlign: 'center',
  491. addBtn: false,
  492. stripe: true,
  493. delBtn: false,
  494. cellBtn: false,
  495. column: [
  496. {
  497. label: '司机名',
  498. prop: "driverName",
  499. cell: false
  500. }, {
  501. label: '变更人',
  502. prop: "changeUserName",
  503. cell: false
  504. }, {
  505. label: '变更日期',
  506. prop: "changeTime",
  507. cell: false
  508. }]
  509. }
  510. }
  511. ]
  512. },
  513. page: {
  514. pageSize: 10,
  515. currentPage: 1,
  516. total: 0,
  517. pageSizes: [10, 50, 100, 200, 300]
  518. },
  519. query:{},
  520. search: {},
  521. loading: false,
  522. action: "/api/blade-resource/oss/endpoint/put-file",
  523. headers: {"Blade-Auth": "Bearer " + getToken()},
  524. ids: [], // id集合
  525. form: {},
  526. excelBox: false
  527. }
  528. },
  529. created() {
  530. let i = 0;
  531. this.option.column.forEach(item => {
  532. if (item.search) i++
  533. })
  534. if (i % 3 !== 0) {
  535. const num = 3 - Number(i % 3)
  536. this.option.searchMenuSpan = num * 8;
  537. this.option.searchMenuPosition = "right";
  538. }
  539. },
  540. methods: {
  541. handleImport() {
  542. this.excelBox = true;
  543. },
  544. uploadAfter(res, done, loading, column) {
  545. this.excelBox = false;
  546. this.refreshChange();
  547. done();
  548. },
  549. handleTemplate() {
  550. window.open(`/api/blade-client/land-vehicle/import-template?${this.website.tokenHeader}=${getToken()}`);
  551. },
  552. //点击行编辑时查看
  553. beforeOpen(done, type) {
  554. if (this.form.id) {
  555. detailDelegationList(this.form.id).then(res => {
  556. this.form = res.data.data
  557. done()
  558. })
  559. } else {
  560. done()
  561. }
  562. },
  563. // 获得高度
  564. searchCriteriaSwitch(type) {
  565. if (type) {
  566. this.option.height = this.option.height - 322
  567. } else {
  568. this.option.height = this.option.height + 322
  569. }
  570. this.$refs.crud.getTableHeight()
  571. },
  572. onLoad(page, params) {
  573. const queryParams = Object.assign({}, this.query, {
  574. size: page.pageSize,
  575. current: page.currentPage,
  576. })
  577. getCarList(queryParams).then(res => {
  578. this.dataList = res.data.data.records;
  579. this.page.total = res.data.data.total;
  580. this.option.height = window.innerHeight - 240;
  581. })
  582. },
  583. rowSave(form, done, loading) {
  584. carSubmit(form).then(res => {
  585. this.$message.success(form.id ? '修改成功' : '新增成功')
  586. })
  587. this.onLoad(this.page)
  588. done();
  589. },
  590. rowUpdate(form, index, done) {
  591. carSubmit(form).then(res => {
  592. this.$message.success(form.id ? '修改成功' : '新增成功')
  593. })
  594. this.onLoad(this.page)
  595. done();
  596. },
  597. rowDel(row) {
  598. this.$confirm("确定将选择数据删除?", {
  599. confirmButtonText: "确定",
  600. cancelButtonText: "取消",
  601. type: "warning"
  602. }).then(() => {
  603. const ids = this.ids.length == 0 ? row.id : this.ids.join(',');
  604. carRemove({ids}).then(res => {
  605. this.$message.success('删除成功');
  606. this.onLoad(this.page);
  607. })
  608. })
  609. },
  610. //附件上传成功
  611. onSuccessTwo(response, row) {
  612. row.url = response.data.link
  613. row.fileName = response.data.originalName
  614. },
  615. //下载附件
  616. download(row) {
  617. if (row.url) {
  618. window.open(row.url)
  619. } else {
  620. this.$message.warning('无附件,请上传附件后再查看');
  621. }
  622. },
  623. // 搜索
  624. searchChange(params, done) {
  625. this.page.currentPage = 1;
  626. let data = params
  627. if (data.purchaseDate) {
  628. data.beginPurchaseDate = params.purchaseDate[0]
  629. data.endPurchaseDate = params.purchaseDate[1]
  630. }
  631. if (data.registerDate) {
  632. data.beginRegisterDate = params.registerDate[0]
  633. data.endRegisterDate = params.registerDate[1]
  634. }
  635. if (data.scrapDate) {
  636. data.beginScrapDate = params.scrapDate[0]
  637. data.endScrapDate = params.scrapDate[1]
  638. }
  639. if (data.inspectExpired) {
  640. data.beginInspectExpired = params.inspectExpired[0]
  641. data.endInspectExpired = params.inspectExpired[1]
  642. }
  643. if (data.insuranceExpired) {
  644. data.beginInsuranceExpired = params.insuranceExpired[0]
  645. data.endInsuranceExpired = params.insuranceExpired[1]
  646. }
  647. delete data.purchaseDate
  648. delete data.registerDate
  649. delete data.scrapDate
  650. delete data.inspectExpired
  651. delete data.insuranceExpired
  652. this.query = data
  653. this.onLoad(this.page, data);
  654. done()
  655. },
  656. // 重置
  657. searchReset() {
  658. },
  659. //刷新
  660. refreshChange() {
  661. this.onLoad(this.page, this.search)
  662. },
  663. currentChange(currentPage) {
  664. this.page.currentPage = currentPage;
  665. },
  666. sizeChange(pageSize) {
  667. this.page.pageSize = pageSize;
  668. },
  669. },
  670. }
  671. </script>
  672. <style scoped>
  673. </style>