index.vue 16 KB

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