index.vue 15 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527
  1. <template>
  2. <div>
  3. <avue-crud
  4. :option="option"
  5. :search.sync="search"
  6. v-model="form"
  7. :table-loading="loading"
  8. :data="dataList"
  9. ref="crud"
  10. :key="key"
  11. @on-load="onLoad"
  12. @row-save="rowSave"
  13. @row-update="(row,index,done,loading)=>{rowSave(row,done,loading,index)}"
  14. @search-change="searchChange"
  15. :upload-delete="uploadDelete"
  16. :before-close="beforeClose"
  17. @row-del="rowDel"
  18. @selection-change="selectionChange"
  19. @refresh-change="refreshChange"
  20. @resetColumn="resetColumnTwo('crud','option','optionList',238)"
  21. @saveColumn="saveColumnTwo('crud','option','optionList',238)"
  22. :page.sync="page">
  23. <!-- <template slot-scope="scope" slot="menuLeft">-->
  24. <!-- <el-button type="success" size="small" icon="el-icon-bottom" @click="excelBox = true">导入-->
  25. <!-- </el-button>-->
  26. <!-- <el-button type="warning"-->
  27. <!-- icon="el-icon-download"-->
  28. <!-- size="small"-->
  29. <!-- @click="outExport">导出-->
  30. <!-- </el-button>-->
  31. <!-- </template>-->
  32. <template slot="leasingCompanyIdForm">
  33. <crop-select v-model="form.leasingCompanyId" @getCorpData="getGSData" corpType="GS"/>
  34. </template>
  35. <template slot="addressIdForm">
  36. <port-info v-model="form.addressId" type="id" @balabalaTow="balabala"/>
  37. </template>
  38. <template slot="addressIdSearch">
  39. <port-info v-model="search.addressId" type="id"/>
  40. </template>
  41. <template slot="addressId" slot-scope="{row}">
  42. {{ row.address }}
  43. </template>
  44. <template slot="leasingCompanyIdSearch">
  45. <crop-select v-model="search.leasingCompanyId" corpType="KH"/>
  46. </template>
  47. <template slot="leasingCompanyId" slot-scope="{row}">
  48. {{ row.leasingCompany }}
  49. </template>
  50. </avue-crud>
  51. <!-- <el-dialog title="导入客户" append-to-body :visible.sync="excelBox" width="555px" :close-on-click-modal="false"-->
  52. <!-- v-dialog-drag>-->
  53. <!-- <avue-form :option="excelOption" v-model="excelForm" table-loading="excelLoading"-->
  54. <!-- :upload-before="uploadBefore" :upload-after="uploadAfter">-->
  55. <!-- <template slot="excelTemplate">-->
  56. <!-- <el-button type="primary" @click="derivation">-->
  57. <!-- 点击下载<i class="el-icon-download el-icon&#45;&#45;right"></i>-->
  58. <!-- </el-button>-->
  59. <!-- </template>-->
  60. <!-- </avue-form>-->
  61. <!-- <p style="text-align: center;color: #DC0505">-->
  62. <!-- 温馨提示 第一次导入时请先下载模板-->
  63. <!-- </p>-->
  64. <!-- </el-dialog>-->
  65. </div>
  66. </template>
  67. <script>
  68. import {addUpdate, boxRemove, getList, remove} from "@/api/box/archives";
  69. import {getToken} from "@/util/auth";
  70. import {getAllBoxs} from "@/api/basicData/portinformation";
  71. export default {
  72. name: "archives",
  73. data() {
  74. return {
  75. excelBox: false,
  76. loading: false,
  77. search: {},
  78. form: {},
  79. excelForm: {},
  80. dataList: [],
  81. page: {
  82. pageSize: 20,
  83. currentPage: 1,
  84. total: 0,
  85. pageSizes: [10, 20, 30, 40, 50, 100, 200, 300, 400, 500]
  86. },
  87. excelOption: {
  88. submitBtn: false,
  89. emptyBtn: false,
  90. column: [
  91. {
  92. label: "模板下载",
  93. prop: "excelTemplate",
  94. formslot: true,
  95. span: 24
  96. },
  97. {
  98. label: "模板上传",
  99. prop: "excelFile",
  100. type: "upload",
  101. drag: true,
  102. loadText: "模板上传中,请稍等",
  103. span: 24,
  104. propsHttp: {
  105. res: "data"
  106. },
  107. tip: "请上传 .xls,.xlsx 标准格式文件",
  108. action: "/api/blade-box-tube/archives/import-descParts-info"
  109. }
  110. ]
  111. },
  112. key: 0,
  113. option: {},
  114. optionList: {
  115. index: true,
  116. span: 8,
  117. border: true,
  118. selection: true,
  119. reserveSelection: true,
  120. searchMenuPosition: "right",
  121. align: "center",
  122. menu:false,
  123. addBtn:false,
  124. searchSpan: 8,
  125. searchIcon: true,
  126. searchIndex: 2,
  127. highlightCurrentRow: true,
  128. dialogWidth: "70%",
  129. column: [{
  130. label: '合同号',
  131. prop: 'contractNo',
  132. width: 100,
  133. overHidden: true,
  134. search: true,
  135. }, {
  136. label: '箱号',
  137. prop: 'code',
  138. width: 100,
  139. overHidden: true,
  140. search: true,
  141. }, {
  142. label: '箱类型',
  143. prop: 'typeId',
  144. width: 100,
  145. overHidden: true,
  146. search: true,
  147. filterable: true,
  148. type: 'select',
  149. dataType: 'number',
  150. props: {
  151. label: 'name',
  152. value: 'id'
  153. },
  154. dicUrl: '/api/blade-client/container/listMessage'
  155. }, {
  156. label: '最新地点',
  157. prop: 'addressId',
  158. width: 100,
  159. overHidden: true,
  160. search: true,
  161. }, {
  162. label: '最新日期',
  163. prop: 'newDate',
  164. width: 100,
  165. searchProp: 'newDateList',
  166. overHidden: true,
  167. search: true,
  168. type: "date",
  169. searchRange: true,
  170. searchDefaultTime: ["00:00:00", "23:59:59"],
  171. format: "yyyy-MM-dd",
  172. valueFormat: "yyyy-MM-dd HH:mm:ss"
  173. }, {
  174. label: '租赁公司',
  175. prop: 'leasingCompanyId',
  176. width: 100,
  177. overHidden: true,
  178. search: true,
  179. }, {
  180. label: '箱来源',
  181. prop: 'boxSource',
  182. width: 100,
  183. overHidden: true,
  184. search: true,
  185. filterable: true,
  186. type: 'select',
  187. dicUrl: "/api/blade-system/dict-biz/dictionary?code=box_source",
  188. props: {
  189. label: "dictValue",
  190. value: "dictKey"
  191. }
  192. }, {
  193. label: '箱状态',
  194. prop: 'boxStatus',
  195. width: 100,
  196. overHidden: true,
  197. search: true,
  198. filterable: true,
  199. type: 'select',
  200. dicUrl: "/api/blade-system/dict-biz/dictionary?code=box_status",
  201. props: {
  202. label: "dictValue",
  203. value: "dictKey"
  204. }
  205. }, {
  206. label: '租赁方式',
  207. prop: 'leaseMethod',
  208. width: 100,
  209. overHidden: true,
  210. filterable: true,
  211. type: 'select',
  212. dicUrl: "/api/blade-system/dict-biz/dictionary?code=lease_method",
  213. props: {
  214. label: "dictValue",
  215. value: "dictKey"
  216. }
  217. }, {
  218. label: '空重(kg)',
  219. prop: 'emptyWeight',
  220. width: 100,
  221. overHidden: true,
  222. type: 'number',
  223. controls: false,
  224. }, {
  225. label: '毛重(kg)',
  226. prop: 'gorssWeight',
  227. width: 100,
  228. overHidden: true,
  229. type: 'number',
  230. controls: false,
  231. }, {
  232. label: '皮重(kg)',
  233. prop: 'tare',
  234. width: 100,
  235. overHidden: true,
  236. type: 'number',
  237. controls: false,
  238. }, {
  239. label: '装载重量(kg)',
  240. prop: 'loadingWeight',
  241. width: 100,
  242. overHidden: true,
  243. type: 'number',
  244. controls: false,
  245. }, {
  246. label: '容积(m³)',
  247. prop: 'volume',
  248. type: 'number',
  249. controls: false,
  250. overHidden: true,
  251. width: 100
  252. }, {
  253. label: '状态',
  254. width: 100,
  255. overHidden: true,
  256. search: true,
  257. filterable: true,
  258. prop: 'status',
  259. type: 'select',
  260. dicUrl: "/api/blade-system/dict-biz/dictionary?code=box_archives_status",
  261. props: {
  262. label: "dictValue",
  263. value: "dictKey"
  264. }
  265. }, {
  266. label: '造箱公司',
  267. prop: 'boxMakingCompany',
  268. width: 100,
  269. overHidden: true,
  270. search: true,
  271. }, {
  272. label: '造箱日期',
  273. prop: 'boxMakingDate',
  274. searchProp: 'boxMakingDateList',
  275. width: 100,
  276. overHidden: true,
  277. search: true,
  278. type: "date",
  279. searchRange: true,
  280. searchDefaultTime: ["00:00:00", "23:59:59"],
  281. format: "yyyy-MM-dd",
  282. valueFormat: "yyyy-MM-dd HH:mm:ss"
  283. }, {
  284. label: '起租日期',
  285. prop: 'leaseCommencementDate',
  286. searchProp: 'leaseCommencementDateList',
  287. width: 100,
  288. overHidden: true,
  289. search: true,
  290. type: "date",
  291. searchRange: true,
  292. searchDefaultTime: ["00:00:00", "23:59:59"],
  293. format: "yyyy-MM-dd",
  294. valueFormat: "yyyy-MM-dd HH:mm:ss"
  295. }, {
  296. label: '购入日期',
  297. prop: 'purchaseDate',
  298. width: 100,
  299. overHidden: true,
  300. type: "date",
  301. searchRange: true,
  302. searchDefaultTime: ["00:00:00", "23:59:59"],
  303. format: "yyyy-MM-dd",
  304. valueFormat: "yyyy-MM-dd HH:mm:ss"
  305. }, {
  306. label: '箱龄',
  307. prop: 'boxAge',
  308. overHidden: true,
  309. width: 100,
  310. }, {
  311. label: '照片',
  312. prop: 'filesList',
  313. width: 200,
  314. overHidden: true,
  315. type: 'upload',
  316. span: 24,
  317. listType: 'picture-card',
  318. tip: '只能上传jpg/png文件,且不超过500kb',
  319. propsHttp: {
  320. url: 'link',
  321. name: 'originalName',
  322. res: 'data'
  323. },
  324. action: '/api/blade-resource/oss/endpoint/put-file'
  325. }]
  326. }
  327. }
  328. },
  329. model: {
  330. prop: "listData",
  331. event: "callBack"
  332. },
  333. props: {
  334. listData: {
  335. type: Array,
  336. default: function () {
  337. return [];
  338. }
  339. }
  340. },
  341. async created() {
  342. this.option = await this.getColumnData(this.getColumnName(238), this.optionList);
  343. this.key++
  344. this.findObject(this.option.column, "typeId").change = ({value, column}) => {
  345. getAllBoxs().then(res => {
  346. for (let item of res.data.data){
  347. if (value == item.id){
  348. this.form.name = item.name
  349. }
  350. }
  351. })
  352. }
  353. let i = 0;
  354. this.option.column.forEach(item => {
  355. if (item.search) i++
  356. })
  357. if (i % 3 !== 0) {
  358. const num = 3 - Number(i % 3)
  359. this.option.searchMenuSpan = num * 8;
  360. this.option.searchMenuPosition = "right";
  361. }
  362. },
  363. methods: {
  364. //导出
  365. outExport() {
  366. this.$confirm('是否导出当前所有箱档案?', '提示', {
  367. confirmButtonText: '确定',
  368. cancelButtonText: '取消',
  369. type: 'warning'
  370. }).then(() => {
  371. let queryParams = this.search
  372. const routeData = this.$router.resolve({
  373. path: '/api/blade-box-tube/archives/export-archives-out', //跳转目标窗口的地址
  374. query: {
  375. 'Blade-Auth': getToken(),
  376. ...queryParams //括号内是要传递给新窗口的参数
  377. }
  378. })
  379. window.open(routeData.href.slice(1, routeData.href.length));
  380. }).catch(() => {
  381. this.$message({
  382. type: 'info',
  383. message: '已取消' //
  384. });
  385. })
  386. },
  387. derivation() {
  388. window.open(
  389. `/api/blade-box-tube/archives/export-archives-info?${this.website.tokenHeader
  390. }=${getToken()}`
  391. );
  392. },
  393. uploadBefore(file, done, loading) {
  394. done();
  395. loading = true;
  396. },
  397. uploadAfter(res, done, loading, column) {
  398. this.excelBox = false;
  399. this.$message.success("导入成功!");
  400. this.onLoad(this.page, this.search);
  401. loading = false;
  402. done();
  403. },
  404. balabala(val) {
  405. if (val === null) {
  406. this.form.address = ''
  407. } else {
  408. this.form.address = val.name
  409. }
  410. },
  411. getGSData(row) {
  412. this.form.leasingCompany = row.cname
  413. },
  414. //关闭弹窗前
  415. beforeClose(done, type) {
  416. this.onLoad(this.page, this.search)
  417. done()
  418. },
  419. //刷新
  420. refreshChange() {
  421. this.onLoad(this.page, this.search)
  422. },
  423. selectionChange(list){
  424. this.$emit("callBack", list);
  425. },
  426. rowDel(form, index) {
  427. this.$confirm('此操作将永久删除该行, 是否继续?', '提示', {
  428. confirmButtonText: '确定',
  429. cancelButtonText: '取消',
  430. type: 'warning'
  431. }).then(() => {
  432. remove(form.id).then(res => {
  433. this.$message({
  434. type: 'success',
  435. message: '删除成功!'
  436. });
  437. })
  438. }).catch(() => {
  439. });
  440. },
  441. uploadDelete(file, column) {
  442. return new Promise((resolve, reject)=>{
  443. this.$confirm('此操作将永久删除该文件, 是否继续?', '提示', {
  444. confirmButtonText: '确定',
  445. cancelButtonText: '取消',
  446. type: 'warning'
  447. }).then(() => {
  448. if (this.form.filesList[file.uid].id){
  449. boxRemove(this.form.filesList[file.uid].id).then(res => {
  450. this.$message({
  451. type: 'success',
  452. message: '删除成功!'
  453. });
  454. resolve();
  455. })
  456. }else {
  457. resolve();
  458. }
  459. }).catch(()=>{
  460. reject();
  461. this.$message({
  462. type: "info",
  463. message: "已取消删除"
  464. });
  465. })
  466. })
  467. },
  468. rowSave(form, done, loading, index) {
  469. done()
  470. addUpdate(form).then(res => {
  471. this.onLoad(this.page, this.search)
  472. })
  473. },
  474. searchChange(params, done) {
  475. done();
  476. this.onLoad(this.page, params)
  477. },
  478. onLoad(page, params = {}) {
  479. params = {
  480. ...params,
  481. current: page.currentPage,
  482. size: page.pageSize,
  483. status:"待使用",
  484. ...Object.assign(params, this.search)
  485. }
  486. this.loading = true
  487. getList(params).then(res => {
  488. this.dataList = res.data.data.records
  489. this.page.total = res.data.data.total
  490. this.loading = false
  491. }).finally(() => {
  492. this.loading = false
  493. })
  494. },
  495. //自定义列保存
  496. async saveColumnTwo(ref, option, optionBack, code) {
  497. /**
  498. * 已定义全局方法,直接使用,saveColumnData保存列数据方法,参数传值(表格名称,当前表格的option数据)
  499. * 已定义全局方法,直接使用,getColumnName方法用来获取枚举值,参数根据自己定义的code值获取中文名
  500. * 一定要执行异步操作,要等接口成功返回,才能执行下一行代码
  501. */
  502. const inSave = await this.saveColumnData(this.getColumnName(code), this[option]);
  503. if (inSave) {
  504. this.$message.success("保存成功");
  505. //关闭窗口
  506. this.$refs[ref].$refs.dialogColumn.columnBox = false;
  507. }
  508. },
  509. //自定义列重置
  510. async resetColumnTwo(ref, option, optionBack, code) {
  511. this[option] = this[optionBack];
  512. const inSave = await this.delColumnData(this.getColumnName(code), this[optionBack]);
  513. if (inSave) {
  514. this.$message.success("重置成功");
  515. this.$refs[ref].$refs.dialogColumn.columnBox = false;
  516. }
  517. },
  518. }
  519. }
  520. </script>
  521. <style scoped>
  522. </style>