index.vue 11 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396
  1. <template>
  2. <div>
  3. <basic-container>
  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. :header-cell-class-name="headerClassName"
  12. ref="crud"
  13. @search-change="searchChange"
  14. @search-reset="searchReset"
  15. @selection-change="selectionChange"
  16. @current-change="currentChange"
  17. @size-change="sizeChange"
  18. @refresh-change="refreshChange"
  19. @resetColumn="resetColumn('crud', 'option', 'optionBack', 539)"
  20. @saveColumn="saveColumn('crud', 'option', 'optionBack', 539)"
  21. @on-load="onLoad"
  22. >
  23. <template slot="menuLeft">
  24. <el-button type="primary" size="small" @click="allClick('excel导入')">import</el-button>
  25. <el-button type="warning" size="small" @click="outExport">export</el-button>
  26. </template>
  27. <template slot="cntrNoSearch">
  28. <el-input v-model="query.cntrNo" size="small" placeholder="请输入箱号 多个箱号用空格区分" type="textarea" autosize></el-input>
  29. </template>
  30. </avue-crud>
  31. </basic-container>
  32. <el-dialog title="导入数据" append-to-body :visible.sync="excelBox" width="555px" :close-on-click-modal="false" v-dialog-drag>
  33. <avue-form
  34. v-if="excelBox"
  35. :option="excelOption"
  36. v-model="excelForm"
  37. :table-loading="excelLoading"
  38. :upload-before="uploadBefore"
  39. :upload-after="onSuccess"
  40. >
  41. <template slot="excelTemplate">
  42. <el-button type="primary" @click="handleGet"> 点击下载<i class="el-icon-download el-icon--right"></i> </el-button>
  43. </template>
  44. </avue-form>
  45. <p style="text-align: center;color: #DC0505">
  46. 温馨提示 第一次导入时请先下载模板
  47. </p>
  48. </el-dialog>
  49. </div>
  50. </template>
  51. <script>
  52. import { getList } from "@/api/iosBasicData/containerReminder.js";
  53. import dicSelect from "@/components/dicSelect/main";
  54. import { getToken } from "@/util/auth";
  55. import { getBcorpsattnList } from "@/api/iosBasicData/bcorpsattn";
  56. export default {
  57. name: "ReturnContainerReminder",
  58. data() {
  59. return {
  60. excelBox:false,
  61. excelForm: {},
  62. excelLoading: false,
  63. excelOption: {
  64. submitBtn: false,
  65. emptyBtn: false,
  66. column: [
  67. {
  68. label: "模板下载",
  69. prop: "excelTemplate",
  70. formslot: true,
  71. span: 24,
  72. display: true
  73. },
  74. {
  75. label: "模板上传",
  76. prop: "excelFile",
  77. type: "upload",
  78. drag: true,
  79. loadText: "模板上传中,请稍等",
  80. span: 24,
  81. propsHttp: {
  82. res: "data"
  83. },
  84. tip: "请上传 .xls,.xlsx 标准格式文件",
  85. action: "/api/blade-los/boxdynamicsrecord/importExcel?type=JC"
  86. }
  87. ]
  88. },
  89. firstPage: false,
  90. form: {},
  91. query: {},
  92. loading: false,
  93. page: {
  94. pageSize: 20,
  95. currentPage: 1,
  96. total: 0,
  97. pageSizes: [10, 20, 30, 40, 50, 100, 200, 300, 400, 500]
  98. },
  99. selectionList: [],
  100. option: {},
  101. optionBack: {
  102. height: "auto",
  103. calcHeight: 30,
  104. menuWidth: 140,
  105. menu: false,
  106. tip: false,
  107. searchShow: true,
  108. searchMenuSpan: 18,
  109. border: true,
  110. index: true,
  111. addBtn: false,
  112. viewBtn: false,
  113. editBtn: false,
  114. delBtn: false,
  115. selection: true,
  116. searchIcon: true,
  117. align: "center",
  118. searchIndex: 3,
  119. column: [
  120. {
  121. label: "branchName",
  122. prop: "branchId",
  123. hide: true,
  124. type: "select",
  125. filterable: true,
  126. dicUrl: "/api/blade-system/dept/lazy-list",
  127. props: {
  128. label: "deptName",
  129. value: "id"
  130. },
  131. search: false
  132. },
  133. {
  134. label: "ContainerNO",
  135. prop: "cntrNo",
  136. search: true,
  137. width: 120,
  138. overHidden: true
  139. },
  140. {
  141. label: "ReleaseRef",
  142. prop: "containerNumber",
  143. overHidden: true,
  144. width: 120,
  145. search: true
  146. },
  147. {
  148. label: "ContainerType",
  149. prop: "boxType",
  150. width: 140,
  151. overHidden: true
  152. },
  153. {
  154. label: "ATA",
  155. prop: "actualEta",
  156. overHidden: true,
  157. width: 100,
  158. type: "date",
  159. format: "yyyy-MM-dd",
  160. valueFormat: "yyyy-MM-dd"
  161. },
  162. {
  163. label: "port",
  164. prop: "podCnName",
  165. overHidden: true
  166. },
  167. {
  168. label: "depot",
  169. prop: "podStationCname",
  170. overHidden: true
  171. },
  172. {
  173. label: "depotLink",
  174. prop: "podCyContact",
  175. overHidden: true
  176. },
  177. {
  178. label: "depotTel",
  179. prop: "podCyTel",
  180. overHidden: true
  181. },
  182. {
  183. label: "depotEMail",
  184. prop: "podCyEmail",
  185. width: 120,
  186. overHidden: true
  187. },
  188. {
  189. label: "MB/L NO",
  190. prop: "mblno",
  191. overHidden: true,
  192. search: true
  193. },
  194. {
  195. label: "HB/L NO",
  196. prop: "hblno",
  197. overHidden: true,
  198. search: true
  199. },
  200. {
  201. label: "ReleaseRefType",
  202. prop: "boxSrcType",
  203. search: true,
  204. searchLabelWidth: 90,
  205. type: "select",
  206. dicUrl: "/api/blade-system/dict-biz/dictionary?code=boxCategory",
  207. props: {
  208. label: "dictValue",
  209. value: "dictValue"
  210. },
  211. hide: true,
  212. overHidden: true
  213. }
  214. ]
  215. },
  216. data: [],
  217. saberUserInfo: {}
  218. };
  219. },
  220. components: {
  221. dicSelect
  222. },
  223. async created() {
  224. this.saberUserInfo = JSON.parse(localStorage.getItem("saber-userInfo")).content;
  225. this.option = await this.getColumnData(this.getColumnName(539), this.optionBack);
  226. if (this.saberUserInfo.role_name.indexOf("admin") != -1 || this.saberUserInfo.role_name.indexOf("总部") != -1) {
  227. this.option.searchMenuSpan = 12;
  228. this.option.column.forEach(item => {
  229. if (item.prop == "branchId") {
  230. item.search = true;
  231. }
  232. });
  233. }
  234. this.$nextTick(() => {
  235. this.$refs.crud.doLayout();
  236. this.$refs.crud.dicInit();
  237. });
  238. },
  239. methods: {
  240. allClick(name) {
  241. if (name == "excel导入") {
  242. this.excelBox = true;
  243. }
  244. },
  245. // 下载模板
  246. handleGet() {
  247. window.open(`/api/blade-los/boxReminderStatistics/returnContainerReminderExport?${this.website.tokenHeader}=${getToken()}`);
  248. },
  249. uploadBefore(file, done, loading) {
  250. done();
  251. loading = true;
  252. },
  253. // 上传成功
  254. onSuccess(res, done, loading, column) {
  255. if (res == "操作成功" || res.msg == "操作成功") {
  256. this.$message.success("上传成功!");
  257. }
  258. this.excelBox = false;
  259. // this.$message.success("导入成功!");
  260. loading = false;
  261. this.onLoad(this.page, this.query);
  262. done();
  263. },
  264. searchReset() {
  265. this.query = {};
  266. },
  267. // 搜索按钮点击
  268. searchChange(params, done) {
  269. this.page.currentPage = 1;
  270. this.onLoad(this.page, this.query);
  271. done();
  272. },
  273. selectionChange(list) {
  274. this.selectionList = list;
  275. },
  276. currentChange(currentPage) {
  277. this.page.currentPage = currentPage;
  278. },
  279. sizeChange(pageSize) {
  280. this.page.pageSize = pageSize;
  281. },
  282. refreshChange() {
  283. this.onLoad(this.page, this.query);
  284. },
  285. onLoad(page, params = {}) {
  286. let obj = {};
  287. obj = {
  288. ...Object.assign(params, this.query),
  289. cntrNo: this.query.cntrNo ? this.query.cntrNo.split(" ").join(",") : null
  290. };
  291. this.loading = true;
  292. getList(page.currentPage, page.pageSize, obj)
  293. .then(res => {
  294. this.data = res.data.data.records;
  295. this.page.total = res.data.data.total;
  296. })
  297. .finally(() => {
  298. this.loading = false;
  299. });
  300. },
  301. outExport() {
  302. let config = { params: { ...this.query } };
  303. if (config.params) {
  304. for (const propName of Object.keys(config.params)) {
  305. const value = config.params[propName];
  306. if (value !== null && typeof value !== "undefined") {
  307. if (value instanceof Array) {
  308. for (const key of Object.keys(value)) {
  309. let params = propName + "[" + key + "]";
  310. config.params[params] = value[key];
  311. }
  312. delete config.params[propName];
  313. }
  314. }
  315. }
  316. }
  317. const routeData = this.$router.resolve({
  318. path: "/api/blade-los/boxReminderStatistics/returnContainerReminderExport", //跳转目标窗口的地址
  319. query: {
  320. ...config.params, //括号内是要传递给新窗口的参数
  321. cntrNo: this.query.cntrNo ? this.query.cntrNo.split(" ").join(",") : null
  322. }
  323. });
  324. window.open(routeData.href.slice(1, routeData.href.length) + "&" + `${this.website.tokenHeader}=${getToken()}`);
  325. },
  326. //自定义列保存
  327. async saveColumn(ref, option, optionBack, code) {
  328. /**
  329. * 已定义全局方法,直接使用,saveColumnData保存列数据方法,参数传值(表格名称,当前表格的option数据)
  330. * 已定义全局方法,直接使用,getColumnName方法用来获取枚举值,参数根据自己定义的code值获取中文名
  331. * 一定要执行异步操作,要等接口成功返回,才能执行下一行代码
  332. */
  333. const inSave = await this.saveColumnData(this.getColumnName(code), this[option]);
  334. if (inSave) {
  335. this.$message.success("保存成功");
  336. //关闭窗口
  337. this.$refs[ref].$refs.dialogColumn.columnBox = false;
  338. }
  339. },
  340. //自定义列重置
  341. async resetColumn(ref, option, optionBack, code) {
  342. this[option] = this[optionBack];
  343. const inSave = await this.delColumnData(this.getColumnName(code), this[optionBack]);
  344. if (this.saberUserInfo.role_name.indexOf("admin") != -1 || this.saberUserInfo.role_name.indexOf("总部") != -1) {
  345. this.option.searchMenuSpan = 12;
  346. this.option.column.forEach(item => {
  347. if (item.prop == "branchId") {
  348. item.search = true;
  349. }
  350. });
  351. }
  352. if (inSave) {
  353. this.$message.success("重置成功");
  354. this.$refs[ref].$refs.dialogColumn.columnBox = false;
  355. }
  356. },
  357. // 更改表格颜色
  358. headerClassName(tab) {
  359. //颜色间隔
  360. let back = "";
  361. if (tab.columnIndex >= 0 && tab.column.level === 1) {
  362. if (tab.columnIndex % 2 === 0) {
  363. back = "back-one";
  364. } else if (tab.columnIndex % 2 === 1) {
  365. back = "back-two";
  366. }
  367. }
  368. return back;
  369. }
  370. }
  371. };
  372. </script>
  373. <style lang="scss" scoped>
  374. ::v-deep #out-table .back-one {
  375. background: #ecf5ff !important;
  376. text-align: center;
  377. }
  378. ::v-deep #out-table .back-two {
  379. background: #ecf5ff !important;
  380. text-align: center;
  381. }
  382. .pointerClick {
  383. cursor: pointer;
  384. color: #1e9fff;
  385. }
  386. ::v-deep .el-col-md-8 {
  387. width: 24.33333%;
  388. }
  389. </style>