index.vue 14 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453
  1. <template>
  2. <div>
  3. <basic-container v-if="isShow">
  4. <avue-crud :option="option"
  5. :table-loading="loading"
  6. :data="data"
  7. :page.sync="page"
  8. :permission="permissionList"
  9. :before-open="beforeOpen"
  10. v-model="form"
  11. id="out-table"
  12. :header-cell-class-name="headerClassName"
  13. ref="crud"
  14. @row-update="rowUpdate"
  15. @row-save="rowSave"
  16. @row-del="rowDel"
  17. @search-change="searchChange"
  18. @search-reset="searchReset"
  19. @selection-change="selectionChange"
  20. @current-change="currentChange"
  21. @size-change="sizeChange"
  22. @refresh-change="refreshChange"
  23. @resetColumn="resetColumnTwo('crud', 'option', 'optionBack', 322)"
  24. @saveColumn="saveColumnTwo('crud', 'option', 'optionBack', 322)"
  25. @on-load="onLoad">
  26. <template slot="menuLeft">
  27. <el-button type="primary"
  28. size="small"
  29. icon="el-icon-plus"
  30. @click="addbtnfun()">新建AMEND
  31. </el-button>
  32. <el-button type="danger"
  33. size="small"
  34. icon="el-icon-delete"
  35. plain
  36. @click="handleDelete">批量删除
  37. </el-button>
  38. </template>
  39. <template slot="menu" slot-scope="{ row }">
  40. <el-button
  41. type="text"
  42. size="small"
  43. icon="el-icon-edit"
  44. @click.stop="rowEdit(row)">修改
  45. </el-button>
  46. <el-button
  47. type="text"
  48. size="small"
  49. :disabled="row.status == 1 || row.status == 2 || row.status == 3"
  50. @click.stop="rowDel(row)"
  51. icon="el-icon-delete" >删除
  52. </el-button>
  53. </template>
  54. <template slot="billNo" slot-scope="{ row }">
  55. <span style="color: #1e9fff;cursor: pointer;" @click="rowEdit(row)">{{row.billNo}}</span>
  56. </template>
  57. </avue-crud>
  58. </basic-container>
  59. <amends-details ref="amendsDetails" v-if="!isShow" @goBack="goBack"></amends-details>
  60. </div>
  61. </template>
  62. <script>
  63. import {amendsList, amendsDetail, amendsSubmit, amendsRemove} from "@/api/iosBasicData/amends";
  64. import amendsDetails from "@/views/iosBasicData/siamends/amendsDetails.vue";
  65. import {mapGetters} from "vuex";
  66. import {getWorkDicts} from "@/api/system/dictbiz";
  67. import {getBcorpslistByType} from "@/api/iosBasicData/bcorps";
  68. export default {
  69. components:{amendsDetails},
  70. data() {
  71. return {
  72. isShow:true,
  73. form: {},
  74. query: {},
  75. loading: true,
  76. page: {
  77. pageSize: 10,
  78. currentPage: 1,
  79. total: 0
  80. },
  81. selectionList: [],
  82. option:{},
  83. optionBack: {
  84. height:'auto',
  85. calcHeight: 30,
  86. tip: false,
  87. searchShow: true,
  88. searchMenuSpan: 6,
  89. border: true,
  90. index: true,
  91. viewBtn: true,
  92. selection: true,
  93. dialogClickModal: false,
  94. menuWidth:'140',
  95. column: [
  96. {
  97. label: "客户名称",
  98. prop: "corpCnName",
  99. search:true,
  100. overHidden:true,
  101. type:'select',
  102. filterable:true,
  103. remote:true,
  104. dicUrl: "/api/blade-los/bcorps/listByType?cnName={{key}}",
  105. dicData:[],
  106. props: {
  107. label: 'cnName',
  108. value: 'cnName',
  109. res:'data.records'
  110. },
  111. },
  112. {
  113. label: "单据编号",
  114. prop: "billNo",
  115. search:true,
  116. overHidden:true,
  117. },
  118. {
  119. label: "所属团队",
  120. prop: "teamName",
  121. overHidden:true,
  122. },
  123. {
  124. label: "原MB/L NO",
  125. prop: "mblno",
  126. search:true,
  127. overHidden:true,
  128. },
  129. {
  130. label: "原HB/L NO",
  131. prop: "hblno",
  132. search:true,
  133. overHidden:true,
  134. },
  135. {
  136. label: "BOOKING NO",
  137. prop: "bookingNo",
  138. searchLabelWidth:100,
  139. search:true,
  140. overHidden:true,
  141. },
  142. {
  143. label: "原船名",
  144. prop: "vesselCnName",
  145. overHidden:true,
  146. },
  147. {
  148. label: "原航次",
  149. prop: "voyageNo",
  150. overHidden:true,
  151. },
  152. {
  153. label: "原外提单号",
  154. prop: "refno",
  155. search:true,
  156. overHidden:true,
  157. },
  158. {
  159. label: "单据日期",
  160. prop: "billDate",
  161. overHidden:true,
  162. },
  163. {
  164. label: "原单据编号",
  165. prop: "origBillNo",
  166. search:true,
  167. overHidden:true,
  168. },
  169. {
  170. label: "单据类型",
  171. prop: "origBillType",
  172. overHidden:true,
  173. rules: [{
  174. required: true,
  175. message: "请输入单据类型, DD=直单(默认) MM=主单 MH=主分单 HH=从分单",
  176. trigger: "blur"
  177. }]
  178. },
  179. {
  180. label: "状态",
  181. prop: "status",
  182. search:true,
  183. type: "select",
  184. dicUrl: "/api/blade-system/dict-biz/dictionary?code=ameno_status",
  185. dicData:[],
  186. props: {
  187. label: "dictValue",
  188. value: "dictKey"
  189. },
  190. overHidden:true,
  191. },
  192. {
  193. label: "单据开始日期",
  194. prop: "billDateStart",
  195. search:true,
  196. overHidden:true,
  197. hide:true,
  198. searchLabelWidth:'100',
  199. type: "date",
  200. format: "yyyy-MM-dd",
  201. valueFormat: "yyyy-MM-dd HH:mm:ss",
  202. },
  203. {
  204. label: "单据结束日期",
  205. prop: "billDateEnd",
  206. search:true,
  207. overHidden:true,
  208. hide:true,
  209. searchLabelWidth:'100',
  210. type: "date",
  211. format: "yyyy-MM-dd",
  212. valueFormat: "yyyy-MM-dd HH:mm:ss",
  213. },
  214. {
  215. label: "备注",
  216. prop: "remarks",
  217. overHidden:true,
  218. },
  219. ]
  220. },
  221. data: []
  222. };
  223. },
  224. computed: {
  225. ...mapGetters(["permission"]),
  226. permissionList() {
  227. return {
  228. addBtn: this.vaildData(this.permission.amends_add, false),
  229. viewBtn: this.vaildData(this.permission.amends_view, false),
  230. delBtn: this.vaildData(this.permission.amends_delete, false),
  231. editBtn: this.vaildData(this.permission.amends_edit, false)
  232. };
  233. },
  234. ids() {
  235. let ids = [];
  236. this.selectionList.forEach(ele => {
  237. ids.push(ele.id);
  238. });
  239. return ids.join(",");
  240. }
  241. },
  242. async created() {
  243. this.option = await this.getColumnData(this.getColumnName(322), this.optionBack);
  244. if (this.$route.query.billId) {
  245. // 从审批里查看跳进来的
  246. this.rowEdit({id:this.$route.query.billId})
  247. }
  248. this.$store.commit('SIA_IN_DETAIL')
  249. this.getWorkDictsfun()
  250. },
  251. methods: {
  252. getWorkDictsfun(){
  253. getBcorpslistByType(1,10).then(res=>{
  254. this.findObject(this.option.column, "corpCnName").dicData = res.data.data.records
  255. })
  256. // 状态
  257. getWorkDicts('ameno_status').then(res=>{
  258. this.findObject(this.option.column, "status").dicData = res.data.data
  259. })
  260. },
  261. // 新建amend
  262. addbtnfun(){
  263. this.isShow = false
  264. },
  265. // 编辑
  266. rowEdit(row) {
  267. this.isShow = false
  268. this.$nextTick(()=>{
  269. this.$refs.amendsDetails.amendsDetailfun(row.id)
  270. })
  271. },
  272. // 详情的返回列表
  273. goBack() {
  274. // 初始化数据
  275. if (JSON.stringify(this.$route.query) != "{}") {
  276. this.$router.$avueRouter.closeTag();
  277. this.$router.push({
  278. path: "/iosBasicData/amends/index"
  279. });
  280. }
  281. this.isShow = true;
  282. this.onLoad(this.page, this.search);
  283. },
  284. rowSave(row, done, loading) {
  285. amendsSubmit(row).then(() => {
  286. this.onLoad(this.page);
  287. this.$message({
  288. type: "success",
  289. message: "操作成功!"
  290. });
  291. done();
  292. }, error => {
  293. loading();
  294. window.console.log(error);
  295. });
  296. },
  297. rowUpdate(row, index, done, loading) {
  298. amendsSubmit(row).then(() => {
  299. this.onLoad(this.page);
  300. this.$message({
  301. type: "success",
  302. message: "操作成功!"
  303. });
  304. done();
  305. }, error => {
  306. loading();
  307. console.log(error);
  308. });
  309. },
  310. rowDel(row) {
  311. this.$confirm("确定将选择数据删除?", {
  312. confirmButtonText: "确定",
  313. cancelButtonText: "取消",
  314. type: "warning"
  315. })
  316. .then(() => {
  317. return amendsRemove(row.id);
  318. })
  319. .then(() => {
  320. this.onLoad(this.page);
  321. this.$message({
  322. type: "success",
  323. message: "操作成功!"
  324. });
  325. });
  326. },
  327. handleDelete() {
  328. if (this.selectionList.length === 0) {
  329. this.$message.warning("请选择至少一条数据");
  330. return;
  331. }
  332. for (let item of this.selectionList) {
  333. if (item.status == 1 || item.status == 2 || item.status == 3) {
  334. return this.$message.warning('请选择还未请核的数据')
  335. }
  336. }
  337. this.$confirm("确定将选择数据删除?", {
  338. confirmButtonText: "确定",
  339. cancelButtonText: "取消",
  340. type: "warning"
  341. })
  342. .then(() => {
  343. return amendsRemove(this.ids);
  344. })
  345. .then(() => {
  346. this.onLoad(this.page);
  347. this.$message({
  348. type: "success",
  349. message: "操作成功!"
  350. });
  351. this.$refs.crud.toggleSelection();
  352. });
  353. },
  354. beforeOpen(done, type) {
  355. if (["edit", "view"].includes(type)) {
  356. amendsDetail(this.form.id).then(res => {
  357. this.form = res.data.data;
  358. });
  359. }
  360. done();
  361. },
  362. searchReset() {
  363. this.query = {};
  364. this.onLoad(this.page);
  365. },
  366. searchChange(params, done) {
  367. this.query = params;
  368. this.page.currentPage = 1;
  369. this.onLoad(this.page, params);
  370. done();
  371. },
  372. selectionChange(list) {
  373. this.selectionList = list;
  374. },
  375. selectionClear() {
  376. this.selectionList = [];
  377. this.$refs.crud.toggleSelection();
  378. },
  379. currentChange(currentPage){
  380. this.page.currentPage = currentPage;
  381. },
  382. sizeChange(pageSize){
  383. this.page.pageSize = pageSize;
  384. },
  385. refreshChange() {
  386. this.onLoad(this.page, this.query);
  387. },
  388. onLoad(page, params = {}) {
  389. this.loading = true;
  390. amendsList(page.currentPage, page.pageSize, {...Object.assign(params, this.query),businessType: 'SIA'}).then(res => {
  391. const data = res.data.data;
  392. this.page.total = data.total;
  393. this.data = data.records.map(item=>{
  394. item.status = item.status + ''
  395. return item
  396. })
  397. this.loading = false;
  398. this.selectionClear();
  399. });
  400. },
  401. //自定义列保存
  402. async saveColumnTwo(ref, option, optionBack, code) {
  403. /**
  404. * 已定义全局方法,直接使用,saveColumnData保存列数据方法,参数传值(表格名称,当前表格的option数据)
  405. * 已定义全局方法,直接使用,getColumnName方法用来获取枚举值,参数根据自己定义的code值获取中文名
  406. * 一定要执行异步操作,要等接口成功返回,才能执行下一行代码
  407. */
  408. const inSave = await this.saveColumnData(this.getColumnName(code), this[option]);
  409. if (inSave) {
  410. this.$message.success("保存成功");
  411. //关闭窗口
  412. this.$refs[ref].$refs.dialogColumn.columnBox = false;
  413. }
  414. },
  415. //自定义列重置
  416. async resetColumnTwo(ref, option, optionBack, code) {
  417. this[option] = this[optionBack];
  418. const inSave = await this.delColumnData(this.getColumnName(code), this[optionBack]);
  419. if (inSave) {
  420. this.$message.success("重置成功");
  421. this.$refs[ref].$refs.dialogColumn.columnBox = false;
  422. }
  423. },
  424. // 更改表格颜色
  425. headerClassName(tab){
  426. //颜色间隔
  427. let back = ""
  428. if (tab.columnIndex >= 0 && tab.column.level === 1) {
  429. if (tab.columnIndex % 2 === 0) {
  430. back = "back-one"
  431. } else if (tab.columnIndex % 2 === 1) {
  432. back = "back-two"
  433. }
  434. }
  435. return back;
  436. },
  437. }
  438. };
  439. </script>
  440. <style scoped>
  441. ::v-deep#out-table .back-one {
  442. background: #ecf5ff !important;
  443. text-align: center;
  444. }
  445. ::v-deep#out-table .back-two {
  446. background: #ecf5ff !important;
  447. text-align: center;
  448. }
  449. </style>