index.vue 13 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437
  1. <template>
  2. <div>
  3. <basic-container v-if="isShow">
  4. <avue-crud :option="option" :table-loading="loading" :data="data" :page.sync="page" :search.sync="query"
  5. v-model="form" id="out-table" :header-cell-class-name="headerClassName" ref="crud" @row-del="rowDel"
  6. @search-change="searchChange" @search-reset="searchReset" @selection-change="selectionChange"
  7. @current-change="currentChange" @size-change="sizeChange" @refresh-change="refreshChange"
  8. @resetColumn="resetColumn('crud', 'option', 'optionBack', 514)"
  9. @saveColumn="saveColumn('crud', 'option', 'optionBack', 514)" @on-load="onLoad">
  10. <template slot="menuLeft">
  11. <el-button type="primary" size="small" icon="el-icon-upload" @click="allClick('excel导入')">excel导入
  12. </el-button>
  13. <el-button type="success" size="small" icon="el-icon-upload" @click="allClick('edi导入')">edi导入
  14. </el-button>
  15. <!-- <el-button type="warning" size="small" disabled @click="outExport">导 出
  16. </el-button> -->
  17. </template>
  18. <template slot="menu" slot-scope="{ row, index }">
  19. <el-button size="small" type="text" @click="rowEdit(row)">{{ row.$cellEdit ? '保存' : '编辑' }}</el-button>
  20. </template>
  21. <template slot="fileType" slot-scope="{ row }">
  22. <span style="color: #1e9fff;cursor: pointer;" @click="inDetail(row)">{{ row.fileType }}</span>
  23. </template>
  24. </avue-crud>
  25. </basic-container>
  26. <detailsPage v-if="!isShow" :detailData="detailData" @goBack="goBack"></detailsPage>
  27. <el-dialog title="导入数据" append-to-body :visible.sync="excelBox" width="555px" :close-on-click-modal="false"
  28. v-dialog-drag>
  29. <avue-form v-if="excelBox" :option="excelOption" v-model="excelForm" :table-loading="excelLoading"
  30. :upload-before="uploadBefore" :upload-after="onSuccess">
  31. <template slot="excelTemplate">
  32. <el-button type="primary" @click="handleGet">
  33. 点击下载<i class="el-icon-download el-icon--right"></i>
  34. </el-button>
  35. </template>
  36. </avue-form>
  37. <p style="text-align: center;color: #DC0505">
  38. 温馨提示 第一次导入时请先下载模板
  39. </p>
  40. </el-dialog>
  41. <import-module ref="importModule" @refreshData="refreshData" />
  42. </div>
  43. </template>
  44. <script>
  45. import { getList, submit, emptyContainerEntryFtp } from "@/api/boxManagement/record/index.js";
  46. import detailsPage from "./detailsPage";
  47. import importModule from "./components/importModule.vue";
  48. import { getToken } from "@/util/auth";
  49. import _ from "lodash";
  50. export default {
  51. data() {
  52. return {
  53. excelBox: false,
  54. excelForm: {},
  55. excelLoading: false,
  56. excelOption: {
  57. submitBtn: false,
  58. emptyBtn: false,
  59. column: [
  60. {
  61. label: "模板下载",
  62. prop: "excelTemplate",
  63. formslot: true,
  64. span: 24
  65. },
  66. {
  67. label: "模板上传",
  68. prop: "excelFile",
  69. type: "upload",
  70. drag: true,
  71. loadText: "模板上传中,请稍等",
  72. span: 24,
  73. propsHttp: {
  74. res: "data"
  75. },
  76. tip: "请上传 .xls,.xlsx 标准格式文件",
  77. action: "/api/blade-los/boxdynamicsrecord/importExcel?type=CC"
  78. }
  79. ]
  80. },
  81. isShow: true,
  82. form: {},
  83. query: {
  84. approachExit: "CC",
  85. },
  86. loading: false,
  87. page: {
  88. pageSize: 10,
  89. currentPage: 1,
  90. total: 0
  91. },
  92. selectionList: [],
  93. option: {},
  94. optionBack: {
  95. height: 'auto',
  96. calcHeight: 30,
  97. menuWidth: 60,
  98. tip: false,
  99. searchShow: true,
  100. searchMenuSpan: 12,
  101. border: true,
  102. index: true,
  103. addBtn: false,
  104. viewBtn: false,
  105. editBtn: false,
  106. delBtn: false,
  107. selection: true,
  108. searchIcon: true,
  109. align: 'center',
  110. searchIndex: 3,
  111. column: [
  112. {
  113. label: '文件类型',
  114. prop: 'fileType',
  115. overHidden: true,
  116. },
  117. {
  118. label: '导入时间',
  119. prop: 'importDate',
  120. overHidden: true,
  121. },
  122. {
  123. label: '港口',
  124. prop: 'portCname',
  125. overHidden: true,
  126. search: true,
  127. type: "select",
  128. filterable: true,
  129. remote: true,
  130. dicUrl: "/api/blade-los/bports/list?status=0&size=5&current=1&cnName={{key}}",
  131. props: {
  132. label: "cnName",
  133. value: "cnName",
  134. desc: 'code',
  135. res: "data.records"
  136. },
  137. },
  138. {
  139. label: '场站',
  140. prop: 'stationCname',
  141. overHidden: true,
  142. search: true,
  143. type: "select",
  144. filterable: true,
  145. remote: true,
  146. dicUrl: "/api/blade-los/bcorps/list?status=0&size=5&current=1&cnName={{key}}",
  147. props: {
  148. label: "cnName",
  149. value: "cnName",
  150. desc: 'code',
  151. res: "data.records"
  152. },
  153. },
  154. {
  155. label: '放箱号',
  156. prop: 'containerNumber',
  157. search: true,
  158. hide: true,
  159. overHidden: true,
  160. },
  161. {
  162. label: '提单号',
  163. prop: 'mblno',
  164. search: true,
  165. hide: true,
  166. overHidden: true,
  167. },
  168. {
  169. label: '箱号',
  170. prop: 'boxCode',
  171. search: true,
  172. hide: true,
  173. overHidden: true,
  174. },
  175. {
  176. label: '状态',
  177. prop: 'boxDynamics',
  178. search: true,
  179. overHidden: true,
  180. },
  181. {
  182. label: '备注',
  183. prop: 'remarks',
  184. cell: true,
  185. overHidden: true,
  186. }
  187. ]
  188. },
  189. data: [],
  190. };
  191. },
  192. components: {
  193. detailsPage,
  194. importModule
  195. },
  196. async created() {
  197. this.option = await this.getColumnData(this.getColumnName(514), this.optionBack);
  198. },
  199. activated() {
  200. setTimeout(() => {
  201. }, 100);
  202. },
  203. methods: {
  204. refreshData() {
  205. this.refreshChange()
  206. },
  207. allClick(name) {
  208. if (name == 'excel导入') {
  209. this.excelBox = true;
  210. }
  211. if (name == 'edi导入') {
  212. this.$DialogForm.show({
  213. title: '出场导入',
  214. width: '30%',
  215. menuPosition: 'right',
  216. option: {
  217. submitText: '确定',
  218. emptyText: '取消',
  219. column: [
  220. {
  221. label: "场站",
  222. span: 24,
  223. prop: "corpId",
  224. type: 'select',
  225. filterable: true,
  226. remote: true,
  227. dicUrl: "/api/blade-los/bcorps/selectList?status=0&corpTypeName=场站&size=5&current=1&shortName={{key}}",
  228. props: {
  229. label: "shortName",
  230. value: "id",
  231. desc: 'code',
  232. res: "data.records"
  233. },
  234. rules: [{
  235. required: true,
  236. message: "选择场站",
  237. trigger: "blur",
  238. }],
  239. },
  240. ]
  241. },
  242. beforeClose: (done) => {
  243. done()
  244. },
  245. callback: (res) => {
  246. res.done()
  247. console.log(res)
  248. let obj = {
  249. corpId: res.data.corpId,
  250. type: 'OUT'
  251. }
  252. emptyContainerEntryFtp(obj).then(res => {
  253. this.$message.success("操作成功!");
  254. this.$refs.importModule.openDialog(6, res.data.data)
  255. })
  256. res.close()
  257. }
  258. })
  259. }
  260. },
  261. uploadBefore(file, done, loading) {
  262. done();
  263. loading = true;
  264. },
  265. // 上传成功
  266. onSuccess(res, done, loading, column) {
  267. if (res == '操作成功') {
  268. this.$message.success("上传成功!");
  269. }
  270. this.excelBox = false;
  271. // this.$message.success("导入成功!");
  272. loading = false;
  273. this.onLoad(this.page, this.query);
  274. done();
  275. },
  276. // 下载模板
  277. handleGet() {
  278. window.open(
  279. `/api/blade-los/boxdynamicsrecord/exportTemplate?${this.website.tokenHeader
  280. }=${getToken()}`
  281. );
  282. },
  283. inDetail(row) {
  284. this.detailData = {
  285. id: row.id
  286. };
  287. this.isShow = false
  288. },
  289. rowEdit(row) {
  290. if (row.$cellEdit == true) {
  291. submit(row).then(res => {
  292. this.$message.success("保存成功!");
  293. this.$set(row, "$cellEdit", false);
  294. this.onLoad(this.page, this.query);
  295. })
  296. } else {
  297. this.$set(row, "$cellEdit", true);
  298. }
  299. },
  300. searchReset() {
  301. this.query = this.$options.data().query;
  302. this.onLoad(this.page);
  303. },
  304. // 搜索按钮点击
  305. searchChange(params, done) {
  306. this.page.currentPage = 1;
  307. this.onLoad(this.page, this.query);
  308. done();
  309. },
  310. selectionChange(list) {
  311. this.selectionList = list;
  312. },
  313. currentChange(currentPage) {
  314. this.page.currentPage = currentPage;
  315. },
  316. sizeChange(pageSize) {
  317. this.page.pageSize = pageSize;
  318. },
  319. refreshChange() {
  320. this.onLoad(this.page, this.query);
  321. },
  322. onLoad(page, params = {}) {
  323. let obj = {}
  324. obj = {
  325. ...Object.assign(params, this.query),
  326. }
  327. this.loading = true;
  328. getList(page.currentPage, page.pageSize, obj).then(res => {
  329. this.data = res.data.data.records;
  330. this.page.total = res.data.data.total;
  331. this.$nextTick(() => {
  332. this.$refs.crud.doLayout();
  333. this.$refs.crud.dicInit();
  334. });
  335. }).finally(() => {
  336. this.loading = false;
  337. })
  338. },
  339. // 详情的返回列表
  340. goBack() {
  341. // 初始化数据
  342. this.detailData = {}
  343. this.isShow = true;
  344. this.onLoad(this.page, this.query);
  345. },
  346. outExport() {
  347. let config = { params: { ...this.query } }
  348. if (config.params) {
  349. for (const propName of Object.keys(config.params)) {
  350. const value = config.params[propName];
  351. if (value !== null && typeof (value) !== "undefined") {
  352. if (value instanceof Array) {
  353. for (const key of Object.keys(value)) {
  354. let params = propName + '[' + key + ']';
  355. config.params[params] = value[key]
  356. }
  357. delete config.params[propName]
  358. }
  359. }
  360. }
  361. }
  362. const routeData = this.$router.resolve({
  363. path: '/api/blade-los/routecost/exportRouteCost', //跳转目标窗口的地址
  364. query: {
  365. ...config.params, //括号内是要传递给新窗口的参数
  366. identification: this.url
  367. }
  368. })
  369. window.open(routeData.href.slice(1, routeData.href.length) + '&' + `${this.website.tokenHeader}=${getToken()}`);
  370. },
  371. //自定义列保存
  372. async saveColumn(ref, option, optionBack, code) {
  373. /**
  374. * 已定义全局方法,直接使用,saveColumnData保存列数据方法,参数传值(表格名称,当前表格的option数据)
  375. * 已定义全局方法,直接使用,getColumnName方法用来获取枚举值,参数根据自己定义的code值获取中文名
  376. * 一定要执行异步操作,要等接口成功返回,才能执行下一行代码
  377. */
  378. const inSave = await this.saveColumnData(this.getColumnName(code), this[option]);
  379. if (inSave) {
  380. this.$message.success("保存成功");
  381. //关闭窗口
  382. this.$refs[ref].$refs.dialogColumn.columnBox = false;
  383. this.selectionList = []
  384. this.searchReset()
  385. }
  386. },
  387. //自定义列重置
  388. async resetColumn(ref, option, optionBack, code) {
  389. this[option] = this[optionBack];
  390. const inSave = await this.delColumnData(this.getColumnName(code), this[optionBack]);
  391. if (inSave) {
  392. this.$message.success("重置成功");
  393. this.$refs[ref].$refs.dialogColumn.columnBox = false;
  394. this.selectionList = []
  395. this.searchReset()
  396. }
  397. },
  398. // 更改表格颜色
  399. headerClassName(tab) {
  400. //颜色间隔
  401. let back = ""
  402. if (tab.columnIndex >= 0 && tab.column.level === 1) {
  403. if (tab.columnIndex % 2 === 0) {
  404. back = "back-one"
  405. } else if (tab.columnIndex % 2 === 1) {
  406. back = "back-two"
  407. }
  408. }
  409. return back;
  410. },
  411. }
  412. }
  413. </script>
  414. <style lang="scss" scoped>
  415. ::v-deep #out-table .back-one {
  416. background: #ecf5ff !important;
  417. text-align: center;
  418. }
  419. ::v-deep #out-table .back-two {
  420. background: #ecf5ff !important;
  421. text-align: center;
  422. }
  423. .pointerClick {
  424. cursor: pointer;
  425. color: #1e9fff;
  426. }
  427. ::v-deep .el-col-md-8 {
  428. width: 24.33333%;
  429. }
  430. </style>