index.vue 11 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458
  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. @search-reset="searchReset"
  18. @refresh-change="refreshChange"
  19. @current-change="currentChange"
  20. @size-change="sizeChange"
  21. @search-criteria-switch="searchCriteriaSwitch"
  22. >
  23. <template slot="urlForm" slot-scope="{ row }">
  24. <el-input
  25. placeholder="文件地址"
  26. size="small"
  27. v-if="row.$cellEdit"
  28. v-model="row.url"
  29. class="input-with-select">
  30. <el-button size="small" type="primary" slot="prepend" @click="download(row)">查看</el-button>
  31. <el-upload
  32. class="upload-demo"
  33. :show-file-list="false"
  34. slot="append"
  35. :action="action"
  36. :headers="headers"
  37. :on-success="(response)=>{onSuccessTwo(response,row)}"
  38. :multiple="false">
  39. <el-button size="small" type="primary">上传</el-button>
  40. </el-upload>
  41. </el-input>
  42. <span v-else>{{ row.url }}</span>
  43. </template>
  44. <template slot="fleetIdForm" slot-scope="{ row }">
  45. <span>{{row}}</span>
  46. <crop-select
  47. v-model="form.fleetId"
  48. corpType="KH"
  49. />
  50. </template>
  51. <template slot="fleetIdSearch">
  52. <crop-select v-model="search.fleetId" corpType="KH"></crop-select>
  53. </template>
  54. </avue-crud>
  55. </basic-container>
  56. </div>
  57. </template>
  58. <script>
  59. import { getCarList, carSubmit, carRemove } from "@/api/landTransportation/car";
  60. import {getToken} from '@/util/auth';
  61. export default {
  62. name: "index",
  63. data(){
  64. return{
  65. dataList:[],
  66. option:{
  67. searchIcon: true,
  68. searchIndex: 2,
  69. searchMenuSpan: 24,
  70. align:'center',
  71. index: true,
  72. column:[{
  73. label: '车牌号',
  74. prop: 'plateNo',
  75. index: 1,
  76. width: 140,
  77. cell: true,
  78. overHidden: true,
  79. search:true,
  80. span: 8,
  81. searchSpan: 8,
  82. rules: [{
  83. required: true,
  84. message: "请输入车牌号",
  85. trigger: "blur"
  86. }],
  87. },{
  88. label: '车队名称',
  89. prop: 'fleetId',
  90. index: 2,
  91. width: 140,
  92. cell: true,
  93. overHidden: true,
  94. search:true,
  95. span: 8,
  96. searchSpan: 8,
  97. },{
  98. label: '司机名称',
  99. prop: 'driverId',
  100. index: 3,
  101. width: 140,
  102. cell: true,
  103. overHidden: true,
  104. search:true,
  105. span: 8,
  106. searchSpan: 8,
  107. },{
  108. label: '挂车号',
  109. prop: 'trailerNo',
  110. index: 4,
  111. width: 140,
  112. cell: true,
  113. overHidden: true,
  114. search:true,
  115. span: 8,
  116. searchSpan: 8,
  117. },{
  118. label: '燃油类型',
  119. prop: 'fuelType',
  120. index: 5,
  121. width: 140,
  122. cell: true,
  123. overHidden: true,
  124. search:true,
  125. span: 8,
  126. searchSpan: 8,
  127. },{
  128. type: "select",
  129. dicUrl: "/api/blade-system/dict-biz/dictionary?code=carType",
  130. props: {
  131. label: "dictValue",
  132. value: "dictValue"
  133. },
  134. label: '车辆类型',
  135. prop: 'type',
  136. index: 6,
  137. width: 140,
  138. cell: true,
  139. overHidden: true,
  140. search:true,
  141. span: 8,
  142. searchSpan: 8,
  143. },{
  144. label: '车辆品牌',
  145. prop: 'brand',
  146. index: 7,
  147. width: 140,
  148. cell: true,
  149. overHidden: true,
  150. search:true,
  151. span: 8,
  152. searchSpan: 8,
  153. },{
  154. label: '制造单位',
  155. prop: 'manufacturer',
  156. index: 8,
  157. width: 140,
  158. cell: true,
  159. overHidden: true,
  160. search:true,
  161. span: 8,
  162. searchSpan: 8,
  163. },{
  164. label: '发证机关',
  165. prop: 'issuingAuthority',
  166. index: 9,
  167. width: 140,
  168. cell: true,
  169. overHidden: true,
  170. search:true,
  171. span: 8,
  172. searchSpan: 8,
  173. },{
  174. label: '牵引车辆型号',
  175. prop: 'towModel',
  176. index: 10,
  177. width: 140,
  178. cell: true,
  179. overHidden: true,
  180. search:true,
  181. span: 8,
  182. searchSpan: 8,
  183. },{
  184. label: '牵引车车架号',
  185. prop: 'towVin',
  186. index: 11,
  187. width: 140,
  188. cell: true,
  189. overHidden: true,
  190. search:true,
  191. span: 8,
  192. searchSpan: 8,
  193. },{
  194. label: '挂车型号',
  195. prop: 'trailerModel',
  196. index: 12,
  197. width: 140,
  198. cell: true,
  199. overHidden: true,
  200. search:true,
  201. span: 8,
  202. searchSpan: 8,
  203. },{
  204. label: '挂车车架号',
  205. prop: 'trailerVin',
  206. index: 13,
  207. width: 140,
  208. cell: true,
  209. overHidden: true,
  210. search:true,
  211. span: 8,
  212. searchSpan: 8,
  213. },{
  214. label: '发动机型号',
  215. prop: 'engineModel',
  216. index: 14,
  217. width: 140,
  218. cell: true,
  219. overHidden: true,
  220. search:true,
  221. span: 8,
  222. searchSpan: 8,
  223. },{
  224. label: '核载人数',
  225. prop: 'allowPassenger',
  226. index: 15,
  227. width: 140,
  228. cell: true,
  229. overHidden: true,
  230. search:true,
  231. span: 8,
  232. searchSpan: 8,
  233. },{
  234. label: '购车日期',
  235. prop: 'purchaseDate',
  236. index: 16,
  237. width: 140,
  238. cell: true,
  239. overHidden: true,
  240. search:true,
  241. span: 8,
  242. searchSpan: 8,
  243. },{
  244. label: '注册日期',
  245. prop: 'registerDate',
  246. index: 17,
  247. width: 140,
  248. cell: true,
  249. overHidden: true,
  250. search:true,
  251. span: 8,
  252. searchSpan: 8,
  253. },{
  254. label: '报废日期',
  255. prop: 'scrapDate',
  256. index: 18,
  257. width: 140,
  258. cell: true,
  259. overHidden: true,
  260. search:true,
  261. span: 8,
  262. searchSpan: 8,
  263. },{
  264. label: '外廓尺寸mm',
  265. prop: 'oto',
  266. index: 19,
  267. width: 140,
  268. cell: true,
  269. overHidden: true,
  270. search:true,
  271. span: 8,
  272. searchSpan: 8,
  273. },{
  274. label: '总重量kg',
  275. prop: 'totalWeight',
  276. index: 20,
  277. width: 140,
  278. cell: true,
  279. overHidden: true,
  280. search:true,
  281. span: 8,
  282. searchSpan: 8,
  283. },{
  284. label: '核定重量kg',
  285. prop: 'approvedWeight',
  286. index: 21,
  287. width: 140,
  288. cell: true,
  289. overHidden: true,
  290. search:true,
  291. span: 8,
  292. searchSpan: 8,
  293. },{
  294. label: '装备重量kg',
  295. prop: 'equipmentWeight',
  296. index: 22,
  297. width: 140,
  298. cell: true,
  299. overHidden: true,
  300. search:true,
  301. span: 8,
  302. searchSpan: 8,
  303. },{
  304. label: '附件',
  305. prop: 'fileList',
  306. type: 'dynamic',
  307. hide: true,
  308. showColumn: false,
  309. span:24,
  310. children: {
  311. align: 'center',
  312. headerAlign: 'center',
  313. rowAdd:(done)=>{
  314. // this.$message.success('新增回调');
  315. done()
  316. },
  317. rowDel:(row,done)=>{
  318. // this.$message.success('删除回调'+JSON.stringify(row));
  319. done();
  320. },
  321. column: [{
  322. width: 200,
  323. label: '文件名称',
  324. prop: "fileName",
  325. formslot: true
  326. }, {
  327. width: 360,
  328. label: '文件地址',
  329. prop: "url"
  330. }, {
  331. width: 200,
  332. label: '文件属性',
  333. type: "select",
  334. dicUrl: "/api/blade-system/dict-biz/dictionary?code=file_type",
  335. props: {
  336. label: "dictValue",
  337. value: "dictValue"
  338. }
  339. }, {
  340. label: '备注',
  341. prop: "remarks",
  342. }]
  343. }
  344. }]
  345. },
  346. page: {
  347. pageSize: 10,
  348. currentPage: 1,
  349. total: 0,
  350. pageSizes: [10,50,100,200,300]
  351. },
  352. search: {},
  353. loading: false,
  354. action: "/api/blade-resource/oss/endpoint/put-file",
  355. headers: { "Blade-Auth": "Bearer " + getToken() },
  356. ids: [], // id集合
  357. form: {},
  358. }
  359. },
  360. created() {
  361. let i = 0;
  362. this.option.column.forEach(item => {
  363. if (item.search) i++
  364. })
  365. if (i % 3 !== 0){
  366. const num = 3 - Number(i % 3)
  367. this.option.searchMenuSpan = num * 8;
  368. this.option.searchMenuPosition = "right";
  369. }
  370. },
  371. methods: {
  372. // 获得高度
  373. searchCriteriaSwitch(type){
  374. if (type){
  375. this.option.height = this.option.height - 390
  376. }else {
  377. this.option.height = this.option.height + 390
  378. }
  379. this.$refs.crud.getTableHeight()
  380. },
  381. onLoad(page, params) {
  382. const queryParams = Object.assign({}, params, {
  383. size: page.pageSize,
  384. current: page.currentPage,
  385. })
  386. getCarList(queryParams).then(res => {
  387. this.dataList = res.data.data.records;
  388. this.page.total = res.data.data.total;
  389. this.option.height = window.innerHeight - 240;
  390. })
  391. },
  392. rowSave(form, done, loading) {
  393. carSubmit(form).then(res => {
  394. this.$message.success(form.id? '修改成功': '新增成功')
  395. })
  396. this.onLoad(this.page)
  397. done();
  398. },
  399. rowUpdate(form,index,done) {
  400. carSubmit(form).then(res => {
  401. this.$message.success(form.id? '修改成功': '新增成功')
  402. })
  403. this.onLoad(this.page)
  404. done();
  405. },
  406. rowDel(row) {
  407. this.$confirm("确定将选择数据删除?", {
  408. confirmButtonText: "确定",
  409. cancelButtonText: "取消",
  410. type: "warning"
  411. }).then(() => {
  412. const ids = this.ids.length == 0? row.id: this.ids.join(',');
  413. carRemove({ids}).then(res => {
  414. this.$message.success('删除成功');
  415. this.onLoad(this.page);
  416. })
  417. })
  418. },
  419. //附件上传成功
  420. onSuccessTwo(response,row){
  421. row.url = response.data.link
  422. row.fileName = response.data.originalName
  423. },
  424. //下载附件
  425. download(row){
  426. if (row.url){
  427. window.open(row.url)
  428. }else {
  429. this.$message.warning('无附件,请上传附件后再查看');
  430. }
  431. },
  432. // 搜索
  433. searchChange(params, done) {
  434. this.page.currentPage = 1;
  435. this.onLoad(this.page, params);
  436. done()
  437. },
  438. // 重置
  439. searchReset() {},
  440. //刷新
  441. refreshChange() {
  442. this.onLoad(this.page, this.search)
  443. },
  444. currentChange(currentPage) {
  445. this.page.currentPage = currentPage;
  446. },
  447. sizeChange(pageSize) {
  448. this.page.pageSize = pageSize;
  449. },
  450. },
  451. }
  452. </script>
  453. <style scoped>
  454. </style>