index.vue 12 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424
  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', 474)"
  22. @saveColumn="saveColumn('crud', 'option', 'optionBack', 474)"
  23. @on-load="onLoad"
  24. >
  25. <template slot="menuLeft">
  26. <el-button type="primary" size="small" icon="el-icon-plus" @click="addButton">创建单据 </el-button>
  27. <el-button type="success" size="small" :disabled="selectionList.length != 1" @click="copyButton">复制单据 </el-button>
  28. <!-- <el-button type="warning" size="small" disabled @click="outExport">导 出 </el-button> -->
  29. </template>
  30. <template slot="menu" slot-scope="{ row, index }">
  31. <el-button size="small" icon="el-icon-edit" type="text" @click="rowEdit(row)">编辑</el-button>
  32. <el-button size="small" icon="el-icon-delete" type="text" @click="rowDel(row, index)" :disabled="row.count > 0">删 除</el-button>
  33. </template>
  34. <template slot="sysNo" slot-scope="{ row }">
  35. <span style="color: #1e9fff;cursor: pointer;" @click="rowEdit(row)">{{ row.sysNo }}</span>
  36. </template>
  37. <template slot="purchaseCompanyName" slot-scope="{ row }">
  38. <span style="color: #1e9fff;cursor: pointer;" @click="rowEdit(row)">{{ row.purchaseCompanyName }}</span>
  39. </template>
  40. <template slot="contractNo" slot-scope="{ row }">
  41. <span style="color: #1e9fff;cursor: pointer;" @click="rowEdit(row)">{{ row.contractNo }}</span>
  42. </template>
  43. </avue-crud>
  44. </basic-container>
  45. <detailsPage v-if="!isShow" :detailData="detailData" :pageIds="pageIds" @goBack="goBack"></detailsPage>
  46. </div>
  47. </template>
  48. <script>
  49. import { getList, remove } from "@/api/boxManagement/buyContainer/index.js";
  50. import { getWorkDicts } from "@/api/system/dictbiz";
  51. import detailsPage from "./detailsPage";
  52. import { getToken } from "@/util/auth";
  53. import _ from "lodash";
  54. export default {
  55. name: "代理箱",
  56. data() {
  57. return {
  58. isShow: true,
  59. pageIds: [],
  60. form: {},
  61. query: {
  62. type: "DL"
  63. },
  64. loading: false,
  65. page: {
  66. pageSize: 10,
  67. currentPage: 1,
  68. total: 0,
  69. pageSizes: [10, 20, 30, 40, 50, 100, 200, 300, 400, 500]
  70. },
  71. selectionList: [],
  72. option: {},
  73. optionBack: {
  74. height: "auto",
  75. calcHeight: 30,
  76. menuWidth: 140,
  77. tip: false,
  78. searchShow: true,
  79. searchMenuSpan: 18,
  80. border: true,
  81. index: true,
  82. addBtn: false,
  83. viewBtn: false,
  84. editBtn: false,
  85. delBtn: false,
  86. selection: true,
  87. searchIcon: true,
  88. align: "center",
  89. searchIndex: 3,
  90. summaryText: "合计",
  91. showSummary: true,
  92. sumColumnList: [
  93. {
  94. name: "totalAmount",
  95. type: "sum",
  96. decimals: 2
  97. }
  98. ],
  99. column: [
  100. {
  101. label: "箱号",
  102. prop: "code",
  103. width: 100,
  104. search: true,
  105. searchOrder: 1,
  106. overHidden: true
  107. },
  108. {
  109. label: "代理名称",
  110. prop: "purchaseCompanyName",
  111. width: 200,
  112. overHidden: true,
  113. search: true,
  114. searchOrder: 2,
  115. type: "select",
  116. filterable: true,
  117. remote: true,
  118. dicUrl: "/api/blade-los/bcorps/listByType?status=0&current=1&size=5&corpTypeName=国内同行及代理,国外同行及代理&cnName={{key}}",
  119. props: {
  120. label: "shortName",
  121. value: "shortName",
  122. desc: "code",
  123. res: "data.records"
  124. }
  125. },
  126. {
  127. label: "系统号",
  128. prop: "sysNo",
  129. width: 150,
  130. overHidden: true
  131. },
  132. {
  133. label: "合同号",
  134. prop: "contractNo",
  135. width: 150,
  136. search: true,
  137. searchOrder: 3,
  138. overHidden: true
  139. },
  140. {
  141. label: "日期",
  142. prop: "effectiveDate",
  143. width: 100,
  144. search: true,
  145. searchOrder: 4,
  146. searchProp: "effectiveDateList",
  147. overHidden: true,
  148. type: "date",
  149. searchRange: true,
  150. searchDefaultTime: ["00:00:00", "23:59:59"],
  151. format: "yyyy-MM-dd",
  152. valueFormat: "yyyy-MM-dd HH:mm:ss"
  153. },
  154. {
  155. label: "到期日期",
  156. prop: "expiryDate",
  157. width: 100,
  158. search: true,
  159. searchOrder: 5,
  160. searchProp: "expiryDateList",
  161. overHidden: true,
  162. type: "date",
  163. searchRange: true,
  164. searchDefaultTime: ["00:00:00", "23:59:59"],
  165. format: "yyyy-MM-dd",
  166. valueFormat: "yyyy-MM-dd HH:mm:ss"
  167. },
  168. {
  169. label: "场站",
  170. prop: "stationCname",
  171. width: 80,
  172. overHidden: true
  173. },
  174. {
  175. label: "港口",
  176. prop: "addressCname",
  177. width: 80,
  178. overHidden: true
  179. },
  180. {
  181. label: "目的港",
  182. prop: "podCname",
  183. width: 80,
  184. overHidden: true
  185. },
  186. {
  187. label: "制单人",
  188. prop: "createUserName",
  189. overHidden: true,
  190. width: 80
  191. },
  192. {
  193. label: "制单日期",
  194. prop: "createTime",
  195. type: "date",
  196. overHidden: true,
  197. width: 100,
  198. format: "yyyy-MM-dd",
  199. valueFormat: "yyyy-MM-dd HH:mm:ss"
  200. },
  201. {
  202. label: "修改人",
  203. prop: "updateUserName",
  204. overHidden: true,
  205. width: 80
  206. },
  207. {
  208. label: "修改日期",
  209. prop: "updateTime",
  210. type: "date",
  211. overHidden: true,
  212. width: 100,
  213. format: "yyyy-MM-dd",
  214. valueFormat: "yyyy-MM-dd HH:mm:ss"
  215. }
  216. ]
  217. },
  218. data: []
  219. };
  220. },
  221. components: {
  222. detailsPage
  223. },
  224. async created() {
  225. this.option = await this.getColumnData(this.getColumnName(474), this.optionBack);
  226. },
  227. activated() {
  228. setTimeout(() => {
  229. if (this.$route.query.id) {
  230. this.detailData = {
  231. id: this.$route.query.id
  232. };
  233. this.isShow = false;
  234. }
  235. if (this.$route.query.params) {
  236. this.detailData = {
  237. id: this.$route.query.params
  238. };
  239. this.isShow = false;
  240. }
  241. }, 100);
  242. },
  243. methods: {
  244. addButton() {
  245. this.pageIds = [];
  246. this.isShow = false;
  247. },
  248. copyButton() {
  249. this.isShow = false;
  250. this.detailData = {
  251. copyId: this.selectionList[0].id
  252. };
  253. },
  254. rowEdit(row) {
  255. this.pageIds = [];
  256. this.data.forEach(item => {
  257. this.pageIds.push(item.id);
  258. });
  259. this.detailData = {
  260. id: row.id
  261. };
  262. this.isShow = false;
  263. },
  264. // 删除
  265. rowDel(row, index) {
  266. if (row.item == 1) {
  267. return this.$message.error("存在明细不允许删除");
  268. }
  269. this.$confirm("确定将选择数据删除?", {
  270. confirmButtonText: "确定",
  271. cancelButtonText: "取消",
  272. type: "warning"
  273. }).then(() => {
  274. remove({ ids: row.id }).then(res => {
  275. this.onLoad(this.page, this.query);
  276. this.$message.success("成功删除");
  277. });
  278. });
  279. },
  280. searchReset() {
  281. this.query = this.$options.data().query;
  282. // this.onLoad(this.page);
  283. },
  284. // 搜索按钮点击
  285. searchChange(params, done) {
  286. this.page.currentPage = 1;
  287. this.onLoad(this.page, this.query);
  288. done();
  289. },
  290. selectionChange(list) {
  291. this.selectionList = list;
  292. },
  293. currentChange(currentPage) {
  294. this.page.currentPage = currentPage;
  295. },
  296. sizeChange(pageSize) {
  297. this.page.pageSize = pageSize;
  298. },
  299. refreshChange() {
  300. this.onLoad(this.page, this.query);
  301. },
  302. onLoad(page, params = {}) {
  303. let obj = {};
  304. obj = {
  305. ...Object.assign(params, this.query)
  306. };
  307. this.loading = true;
  308. getList(page.currentPage, page.pageSize, obj)
  309. .then(res => {
  310. this.data = res.data.data.records;
  311. this.page.total = res.data.data.total;
  312. this.$nextTick(() => {
  313. this.$refs.crud.doLayout();
  314. this.$refs.crud.dicInit();
  315. });
  316. })
  317. .finally(() => {
  318. this.loading = false;
  319. });
  320. },
  321. // 详情的返回列表
  322. goBack() {
  323. this.pageIds = [];
  324. // 初始化数据
  325. if (JSON.stringify(this.$route.query) != "{}") {
  326. this.$router.$avueRouter.closeTag();
  327. this.$router.push({
  328. path: "/boxManagement/buyContainer/index"
  329. });
  330. }
  331. this.detailData = {};
  332. this.isShow = true;
  333. this.onLoad(this.page, this.query);
  334. },
  335. outExport() {
  336. let config = { params: { ...this.query } };
  337. if (config.params) {
  338. for (const propName of Object.keys(config.params)) {
  339. const value = config.params[propName];
  340. if (value !== null && typeof value !== "undefined") {
  341. if (value instanceof Array) {
  342. for (const key of Object.keys(value)) {
  343. let params = propName + "[" + key + "]";
  344. config.params[params] = value[key];
  345. }
  346. delete config.params[propName];
  347. }
  348. }
  349. }
  350. }
  351. const routeData = this.$router.resolve({
  352. path: "/api/blade-los/routecost/exportRouteCost", //跳转目标窗口的地址
  353. query: {
  354. ...config.params, //括号内是要传递给新窗口的参数
  355. identification: this.url
  356. }
  357. });
  358. window.open(routeData.href.slice(1, routeData.href.length) + "&" + `${this.website.tokenHeader}=${getToken()}`);
  359. },
  360. //自定义列保存
  361. async saveColumn(ref, option, optionBack, code) {
  362. /**
  363. * 已定义全局方法,直接使用,saveColumnData保存列数据方法,参数传值(表格名称,当前表格的option数据)
  364. * 已定义全局方法,直接使用,getColumnName方法用来获取枚举值,参数根据自己定义的code值获取中文名
  365. * 一定要执行异步操作,要等接口成功返回,才能执行下一行代码
  366. */
  367. const inSave = await this.saveColumnData(this.getColumnName(code), this[option]);
  368. if (inSave) {
  369. this.$message.success("保存成功");
  370. //关闭窗口
  371. this.$refs[ref].$refs.dialogColumn.columnBox = false;
  372. this.selectionList = [];
  373. this.searchReset();
  374. }
  375. },
  376. //自定义列重置
  377. async resetColumn(ref, option, optionBack, code) {
  378. this[option] = this[optionBack];
  379. const inSave = await this.delColumnData(this.getColumnName(code), this[optionBack]);
  380. if (inSave) {
  381. this.$message.success("重置成功");
  382. this.$refs[ref].$refs.dialogColumn.columnBox = false;
  383. this.selectionList = [];
  384. this.searchReset();
  385. }
  386. },
  387. // 更改表格颜色
  388. headerClassName(tab) {
  389. //颜色间隔
  390. let back = "";
  391. if (tab.columnIndex >= 0 && tab.column.level === 1) {
  392. if (tab.columnIndex % 2 === 0) {
  393. back = "back-one";
  394. } else if (tab.columnIndex % 2 === 1) {
  395. back = "back-two";
  396. }
  397. }
  398. return back;
  399. }
  400. }
  401. };
  402. </script>
  403. <style lang="scss" scoped>
  404. ::v-deep #out-table .back-one {
  405. background: #ecf5ff !important;
  406. text-align: center;
  407. }
  408. ::v-deep #out-table .back-two {
  409. background: #ecf5ff !important;
  410. text-align: center;
  411. }
  412. .pointerClick {
  413. cursor: pointer;
  414. color: #1e9fff;
  415. }
  416. ::v-deep .el-col-md-8 {
  417. width: 24.33333%;
  418. }
  419. </style>