index.vue 11 KB

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