index.vue 16 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484
  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. :disabled="saberUserInfo.role_name.indexOf('允许修改他人业务') == -1?saberUserInfo.user_id != row.createUser:false"
  45. @click.stop="rowEdit(row)">修改
  46. </el-button>
  47. <el-button
  48. type="text"
  49. size="small"
  50. :disabled="row.status == 1 || row.status == 2 || row.status == 3 || (saberUserInfo.role_name.indexOf('允许修改他人业务') == -1?saberUserInfo.user_id != row.createUser:false)"
  51. @click.stop="rowDel(row)"
  52. icon="el-icon-delete" >删除
  53. </el-button>
  54. </template>
  55. <template slot="billNo" slot-scope="{ row }">
  56. <span style="color: #1e9fff;cursor: pointer;"
  57. v-if="saberUserInfo.role_name.indexOf('允许修改他人业务') == -1?saberUserInfo.user_id == row.createUser:true"
  58. @click="rowEdit(row)">{{row.billNo}}
  59. </span>
  60. <span v-else >{{row.billNo}}</span>
  61. </template>
  62. </avue-crud>
  63. </basic-container>
  64. <amends-details ref="amendsDetails" v-if="!isShow" @goBack="goBack"></amends-details>
  65. </div>
  66. </template>
  67. <script>
  68. import {amendsList, amendsDetail, amendsSubmit, amendsRemove} from "@/api/iosBasicData/amends";
  69. import amendsDetails from "@/views/iosBasicData/aeamends/amendsDetails.vue";
  70. import {mapGetters} from "vuex";
  71. import {getWorkDicts} from "@/api/system/dictbiz";
  72. import {getBcorpslistByType} from "@/api/iosBasicData/bcorps";
  73. export default {
  74. components:{amendsDetails},
  75. data() {
  76. return {
  77. isShow:true,
  78. form: {},
  79. query: {},
  80. loading: true,
  81. page: {
  82. pageSize: 10,
  83. currentPage: 1,
  84. total: 0
  85. },
  86. selectionList: [],
  87. option:{},
  88. optionBack: {
  89. height:'auto',
  90. calcHeight: 30,
  91. tip: false,
  92. searchShow: true,
  93. searchMenuSpan: 6,
  94. border: true,
  95. index: true,
  96. viewBtn: true,
  97. selection: true,
  98. dialogClickModal: false,
  99. menuWidth:'140',
  100. searchIcon:true,
  101. searchIndex:3,
  102. column: [
  103. {
  104. label: "客户名称",
  105. prop: "corpCnName",
  106. search:true,
  107. overHidden:true,
  108. type:'select',
  109. filterable:true,
  110. remote:true,
  111. dicUrl: "/api/blade-los/bcorps/listByType?cnName={{key}}",
  112. dicData:[],
  113. props: {
  114. label: 'cnName',
  115. value: 'cnName',
  116. res:'data.records'
  117. },
  118. },
  119. {
  120. label: "单据编号",
  121. prop: "billNo",
  122. search:true,
  123. overHidden:true,
  124. },
  125. {
  126. label: "所属团队",
  127. prop: "teamName",
  128. overHidden:true,
  129. },
  130. {
  131. label: "原MB/L NO",
  132. prop: "mblno",
  133. search:true,
  134. overHidden:true,
  135. },
  136. {
  137. label: "原HB/L NO",
  138. prop: "hblno",
  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: "RETMBLNO",
  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. saberUserInfo:{}, // 当前登录人个人信息
  223. };
  224. },
  225. computed: {
  226. ...mapGetters(["permission"]),
  227. permissionList() {
  228. return {
  229. addBtn: this.vaildData(this.permission.amends_add, false),
  230. viewBtn: this.vaildData(this.permission.amends_view, false),
  231. delBtn: this.vaildData(this.permission.amends_delete, false),
  232. editBtn: this.vaildData(this.permission.amends_edit, false)
  233. };
  234. },
  235. ids() {
  236. let ids = [];
  237. this.selectionList.forEach(ele => {
  238. ids.push(ele.id);
  239. });
  240. return ids.join(",");
  241. }
  242. },
  243. async created() {
  244. // 获取当前登录人个人信息
  245. this.saberUserInfo = JSON.parse(localStorage.getItem('saber-userInfo')).content
  246. this.option = await this.getColumnData(this.getColumnName(322), this.optionBack);
  247. if (this.$route.query.billId) {
  248. // 从审批里查看跳进来的
  249. this.rowEdit({id:this.$route.query.billId})
  250. }
  251. this.$store.commit('AEA_IN_DETAIL')
  252. this.getWorkDictsfun()
  253. },
  254. methods: {
  255. getWorkDictsfun(){
  256. getBcorpslistByType(1,10).then(res=>{
  257. this.findObject(this.option.column, "corpCnName").dicData = res.data.data.records
  258. })
  259. // 状态
  260. getWorkDicts('ameno_status').then(res=>{
  261. this.findObject(this.option.column, "status").dicData = res.data.data
  262. })
  263. },
  264. // 新建amend
  265. addbtnfun(){
  266. this.isShow = false
  267. },
  268. // 编辑
  269. rowEdit(row) {
  270. this.isShow = false
  271. this.$nextTick(()=>{
  272. this.$refs.amendsDetails.amendsDetailfun(row.id)
  273. })
  274. },
  275. // 详情的返回列表
  276. goBack() {
  277. // 初始化数据
  278. if (JSON.stringify(this.$route.query) != "{}") {
  279. this.$router.$avueRouter.closeTag();
  280. this.$router.push({
  281. path: "/iosBasicData/amends/index"
  282. });
  283. }
  284. this.isShow = true;
  285. this.onLoad(this.page, this.search);
  286. },
  287. rowSave(row, done, loading) {
  288. amendsSubmit(row).then(() => {
  289. this.onLoad(this.page);
  290. this.$message({
  291. type: "success",
  292. message: "操作成功!"
  293. });
  294. done();
  295. }, error => {
  296. loading();
  297. window.console.log(error);
  298. });
  299. },
  300. rowUpdate(row, index, done, loading) {
  301. amendsSubmit(row).then(() => {
  302. this.onLoad(this.page);
  303. this.$message({
  304. type: "success",
  305. message: "操作成功!"
  306. });
  307. done();
  308. }, error => {
  309. loading();
  310. console.log(error);
  311. });
  312. },
  313. rowDel(row) {
  314. this.$confirm("确定将选择数据删除?", {
  315. confirmButtonText: "确定",
  316. cancelButtonText: "取消",
  317. type: "warning"
  318. })
  319. .then(() => {
  320. return amendsRemove(row.id);
  321. })
  322. .then(() => {
  323. this.onLoad(this.page);
  324. this.$message({
  325. type: "success",
  326. message: "操作成功!"
  327. });
  328. });
  329. },
  330. // 批量删除
  331. handleDelete() {
  332. if (this.selectionList.length === 0) {
  333. this.$message.warning("请选择至少一条数据");
  334. return;
  335. }
  336. // 判断是否可以编辑别人业务 true 就没有权限
  337. if (this.ModifyOthersfun()) return;
  338. for (let item of this.selectionList) {
  339. if (item.status == 1 || item.status == 2 || item.status == 3) {
  340. return this.$message.warning('请选择还未请核的数据')
  341. }
  342. }
  343. this.$confirm("确定将选择数据删除?", {
  344. confirmButtonText: "确定",
  345. cancelButtonText: "取消",
  346. type: "warning"
  347. })
  348. .then(() => {
  349. return amendsRemove(this.ids);
  350. })
  351. .then(() => {
  352. this.onLoad(this.page);
  353. this.$message({
  354. type: "success",
  355. message: "操作成功!"
  356. });
  357. this.$refs.crud.toggleSelection();
  358. });
  359. },
  360. // 判断是否可以编辑别人业务
  361. ModifyOthersfun(){
  362. let sumArr = []
  363. const h = this.$createElement
  364. // 判断是否有权限
  365. if (this.saberUserInfo.role_name.indexOf('允许修改他人业务') != -1) return false
  366. // 当前登录人和选择的创建人对比是不是一个人
  367. for (let item of this.selectionList) {
  368. if (this.saberUserInfo.user_id != item.createUser) {
  369. sumArr.push(h('p', `你没有"允许修改他人业务"权限,请重新选择数据`))
  370. }
  371. }
  372. if(sumArr.length != 0) {
  373. this.$confirm('提示', {
  374. message:h('div', sumArr),
  375. confirmButtonText: "确定",
  376. cancelButtonText: "取消",
  377. type: "warning"
  378. }).catch(err=>{})
  379. return true
  380. }
  381. },
  382. beforeOpen(done, type) {
  383. if (["edit", "view"].includes(type)) {
  384. amendsDetail(this.form.id).then(res => {
  385. this.form = res.data.data;
  386. });
  387. }
  388. done();
  389. },
  390. searchReset() {
  391. this.query = {};
  392. this.onLoad(this.page);
  393. },
  394. searchChange(params, done) {
  395. this.query = params;
  396. this.page.currentPage = 1;
  397. this.onLoad(this.page, params);
  398. done();
  399. },
  400. selectionChange(list) {
  401. this.selectionList = list;
  402. },
  403. selectionClear() {
  404. this.selectionList = [];
  405. this.$refs.crud.toggleSelection();
  406. },
  407. currentChange(currentPage){
  408. this.page.currentPage = currentPage;
  409. },
  410. sizeChange(pageSize){
  411. this.page.pageSize = pageSize;
  412. },
  413. refreshChange() {
  414. this.onLoad(this.page, this.query);
  415. },
  416. onLoad(page, params = {}) {
  417. this.loading = true;
  418. amendsList(page.currentPage, page.pageSize, {...Object.assign(params, this.query),businessType: 'AEA'}).then(res => {
  419. const data = res.data.data;
  420. this.page.total = data.total;
  421. this.data = data.records.map(item=>{
  422. item.status = item.status + ''
  423. return item
  424. })
  425. this.loading = false;
  426. this.selectionClear();
  427. });
  428. },
  429. //自定义列保存
  430. async saveColumnTwo(ref, option, optionBack, code) {
  431. /**
  432. * 已定义全局方法,直接使用,saveColumnData保存列数据方法,参数传值(表格名称,当前表格的option数据)
  433. * 已定义全局方法,直接使用,getColumnName方法用来获取枚举值,参数根据自己定义的code值获取中文名
  434. * 一定要执行异步操作,要等接口成功返回,才能执行下一行代码
  435. */
  436. const inSave = await this.saveColumnData(this.getColumnName(code), this[option]);
  437. if (inSave) {
  438. this.$message.success("保存成功");
  439. //关闭窗口
  440. this.$refs[ref].$refs.dialogColumn.columnBox = false;
  441. }
  442. },
  443. //自定义列重置
  444. async resetColumnTwo(ref, option, optionBack, code) {
  445. this[option] = this[optionBack];
  446. const inSave = await this.delColumnData(this.getColumnName(code), this[optionBack]);
  447. if (inSave) {
  448. this.$message.success("重置成功");
  449. this.$refs[ref].$refs.dialogColumn.columnBox = false;
  450. }
  451. },
  452. // 更改表格颜色
  453. headerClassName(tab){
  454. //颜色间隔
  455. let back = ""
  456. if (tab.columnIndex >= 0 && tab.column.level === 1) {
  457. if (tab.columnIndex % 2 === 0) {
  458. back = "back-one"
  459. } else if (tab.columnIndex % 2 === 1) {
  460. back = "back-two"
  461. }
  462. }
  463. return back;
  464. },
  465. }
  466. };
  467. </script>
  468. <style scoped>
  469. ::v-deep#out-table .back-one {
  470. background: #ecf5ff !important;
  471. text-align: center;
  472. }
  473. ::v-deep#out-table .back-two {
  474. background: #ecf5ff !important;
  475. text-align: center;
  476. }
  477. /deep/ .el-col-md-8 {
  478. width: 24.33333%;
  479. }
  480. </style>