index.vue 14 KB

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