index.vue 17 KB

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