index.vue 16 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493
  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. id="out-table"
  10. :header-cell-class-name="headerClassName"
  11. :before-open="beforeOpen"
  12. v-model="form"
  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', 307)"
  24. @saveColumn="saveColumnTwo('crud', 'option', 'optionBack', 307)"
  25. @on-load="onLoad">
  26. <template slot="billNo" slot-scope="scope">
  27. <avue-text-ellipsis :text="scope.row.billNo" :height="30" use-tooltip placement="top">
  28. <small slot="more">...</small>
  29. </avue-text-ellipsis>
  30. </template>
  31. <template slot="agreementNo" slot-scope="scope">
  32. <avue-text-ellipsis :text="scope.row.agreementNo" :height="30" use-tooltip placement="top">
  33. <small slot="more">...</small>
  34. </avue-text-ellipsis>
  35. </template>
  36. <template slot="corpCnName" slot-scope="scope">
  37. <avue-text-ellipsis :text="scope.row.corpCnName" :height="30" use-tooltip placement="top">
  38. <small slot="more">...</small>
  39. </avue-text-ellipsis>
  40. </template>
  41. <template slot="corpEnName" slot-scope="scope">
  42. <avue-text-ellipsis :text="scope.row.corpEnName" :height="30" use-tooltip placement="top">
  43. <small slot="more">...</small>
  44. </avue-text-ellipsis>
  45. </template>
  46. <template slot="menuLeft">
  47. <el-button type="primary"
  48. size="small"
  49. icon="el-icon-plus"
  50. @click="addbtnfun()">新建费用模板
  51. </el-button>
  52. <el-button type="danger"
  53. size="small"
  54. icon="el-icon-delete"
  55. plain
  56. @click="handleDelete">删 除
  57. </el-button>
  58. </template>
  59. <template slot-scope="scope" slot="menu">
  60. <el-button :type="scope.type" :size="scope.size" icon="el-icon-edit"
  61. @click.stop="rowCellfun(scope.row, scope.index)">编辑
  62. </el-button>
  63. <el-button :type="scope.type" :size="scope.size" icon="el-icon-delete"
  64. @click.stop="rowDel(scope.row, scope.index)">删除
  65. </el-button>
  66. </template>
  67. </avue-crud>
  68. </basic-container>
  69. <agreementpriceitems ref="agreementpriceitems" v-if="!isShow" :detailData="detailData" @goBack="goBack"></agreementpriceitems>
  70. </div>
  71. </template>
  72. <script>
  73. import {agreementpriceList, agreementpriceDetail, agreementpriceSubmit, agreementpriceRemove} from "@/api/iosBasicData/agreementprice";
  74. import {mapGetters} from "vuex";
  75. import agreementpriceitems from "@/views/financialManagementF/agreementprice/agreementpriceitems.vue";
  76. export default {
  77. components: {agreementpriceitems},
  78. data() {
  79. return {
  80. // 详情传递的数据
  81. detailData:{},
  82. isShow:true,
  83. form: {},
  84. query: {},
  85. loading: true,
  86. page: {
  87. pageSize: 10,
  88. currentPage: 1,
  89. total: 0
  90. },
  91. selectionList: [],
  92. option:{},
  93. optionBack: {
  94. addBtn:false,
  95. height:'auto',
  96. calcHeight: 30,
  97. tip: false,
  98. searchShow: true,
  99. searchMenuSpan: 6,
  100. border: true,
  101. index: true,
  102. viewBtn: true,
  103. selection: true,
  104. dialogClickModal: false,
  105. column: [
  106. {
  107. label: "单据编码",
  108. prop: "billNo",
  109. width: "180",
  110. search: true,
  111. rules: [{
  112. required: true,
  113. message: "请输入单位编码",
  114. trigger: "blur"
  115. }]
  116. },
  117. {
  118. label: "单位编码",
  119. prop: "agreementNo",
  120. width: "180",
  121. search: true,
  122. rules: [{
  123. required: true,
  124. message: "请输入单位编码",
  125. trigger: "blur"
  126. }]
  127. },
  128. // {
  129. // label: "客户 Id",
  130. // prop: "corpId",
  131. // hide:true,
  132. // display:false,
  133. // },
  134. {
  135. label: "客户名称",
  136. prop: "corpCnName",
  137. width: "180",
  138. search: true,
  139. rules: [{
  140. required: true,
  141. message: "请输入客户中文名称",
  142. trigger: "blur"
  143. }]
  144. },
  145. {
  146. label: "客户英文名称",
  147. prop: "corpEnName",
  148. width:180,
  149. rules: [{
  150. required: true,
  151. message: "请输入客户英文名称",
  152. trigger: "blur"
  153. }]
  154. },
  155. {
  156. label: "授信等级",
  157. prop: "creditLevel",
  158. // rules: [{
  159. // required: true,
  160. // message: "请输入授信等级,A=A级,B=B级,B+=B+级,B-=B-级,C=C级,D=黑名单",
  161. // trigger: "blur"
  162. // }]
  163. },
  164. {
  165. label: "协议生效日期",
  166. prop: "effectiveDate",
  167. width:160,
  168. },
  169. {
  170. label: "协议失效日期",
  171. prop: "expiringDate",
  172. width:160,
  173. },
  174. {
  175. label: "人民币协议金额",
  176. prop: "amountCny",
  177. width:120,
  178. },
  179. {
  180. label: "美元协议金额",
  181. prop: "amountUsd",
  182. width:120,
  183. },
  184. // {
  185. // label: "协议签订人 Id",
  186. // prop: "signedId",
  187. //
  188. // },
  189. {
  190. label: "协议签订人姓名",
  191. prop: "signedName",
  192. width:120,
  193. },
  194. {
  195. label: "账期备注",
  196. prop: "accountPeriodRemarks",
  197. span:24,
  198. type: 'textarea',
  199. width: "180",
  200. slot: true,
  201. minRows: 3,
  202. },
  203. {
  204. label: "备注",
  205. prop: "remarks",
  206. span:24,
  207. type: 'textarea',
  208. width: "180",
  209. slot: true,
  210. minRows: 3,
  211. },
  212. {
  213. label: "状态",
  214. prop: "status",
  215. type:'select',
  216. dicData:[{
  217. label:'启用',
  218. value:0
  219. },{
  220. label:'停用',
  221. value:1
  222. }],
  223. },
  224. {
  225. label: "是否已删除(0 否 1是)",
  226. prop: "isDeleted",
  227. hide:true,
  228. display:false,
  229. },
  230. {
  231. label: "创建人",
  232. prop: "createUserName",
  233. display:false,
  234. },
  235. {
  236. label: "创建部门",
  237. prop: "createDeptName",
  238. display:false,
  239. },
  240. {
  241. label: "创建时间",
  242. prop: "createTime",
  243. width:160,
  244. display:false,
  245. },
  246. {
  247. label: "修改人",
  248. prop: "updateUserName",
  249. display:false,
  250. },
  251. {
  252. label: "修改时间",
  253. prop: "updateTime",
  254. display:false,
  255. },
  256. ]
  257. },
  258. data: []
  259. };
  260. },
  261. computed: {
  262. ...mapGetters(["permission"]),
  263. permissionList() {
  264. return {
  265. addBtn: this.vaildData(this.permission.agreementprice_add, false),
  266. viewBtn: this.vaildData(this.permission.agreementprice_view, false),
  267. delBtn: this.vaildData(this.permission.agreementprice_delete, false),
  268. editBtn: this.vaildData(this.permission.agreementprice_edit, false)
  269. };
  270. },
  271. ids() {
  272. let ids = [];
  273. this.selectionList.forEach(ele => {
  274. ids.push(ele.id);
  275. });
  276. return ids.join(",");
  277. }
  278. },
  279. async created() {
  280. this.option = await this.getColumnData(this.getColumnName(307), this.optionBack);
  281. },
  282. methods: {
  283. // 添加弹窗开启
  284. addbtnfun(){
  285. this.detailData.seeDisabled = false
  286. this.isShow = false
  287. },
  288. // 编辑详情打开
  289. rowCellfun(row, index) {
  290. this.detailData = {
  291. seeDisabled:true,
  292. id:row.id
  293. }
  294. this.isShow = false
  295. this.$nextTick(() => {
  296. this.$refs.agreementpriceitems.agreementpriceDetailfun(row.id)
  297. })
  298. },
  299. // 详情的返回列表
  300. goBack(){
  301. // 初始化数据
  302. // this.detailData = this.$options.data().detailData;
  303. if (JSON.stringify(this.$route.query) != "{}") {
  304. this.$router.$avueRouter.closeTag();
  305. this.$router.push({
  306. path: "/iosBasicData/losbfeestemplate/index"
  307. });
  308. }
  309. this.isShow = true;
  310. this.onLoad(this.page, this.search);
  311. },
  312. rowSave(row, done, loading) {
  313. agreementpriceSubmit(row).then(() => {
  314. this.onLoad(this.page);
  315. this.$message({
  316. type: "success",
  317. message: "操作成功!"
  318. });
  319. done();
  320. }, error => {
  321. loading();
  322. window.console.log(error);
  323. });
  324. },
  325. rowUpdate(row, index, done, loading) {
  326. agreementpriceSubmit(row).then(() => {
  327. this.onLoad(this.page);
  328. this.$message({
  329. type: "success",
  330. message: "操作成功!"
  331. });
  332. done();
  333. }, error => {
  334. loading();
  335. console.log(error);
  336. });
  337. },
  338. rowDel(row) {
  339. if (row.status === 1) {
  340. this.$confirm("确定将选择数据删除?", {
  341. confirmButtonText: "确定",
  342. cancelButtonText: "取消",
  343. type: "warning"
  344. })
  345. .then(() => {
  346. return agreementpriceRemove(row.id);
  347. })
  348. .then(() => {
  349. this.onLoad(this.page);
  350. this.$message({
  351. type: "success",
  352. message: "操作成功!"
  353. });
  354. });
  355. } else {
  356. this.$message({
  357. message: '非禁用状态无法删除',
  358. type: 'warning'
  359. });
  360. }
  361. },
  362. handleDelete() {
  363. if (this.selectionList.length === 0) {
  364. this.$message.warning("请选择至少一条数据");
  365. return;
  366. }
  367. for (const selection of this.selectionList) {
  368. if (selection.status == 0) {
  369. this.$message.warning("选中的数据中有启用数据,启用数据不可删除!");
  370. return;
  371. }
  372. }
  373. this.$confirm("确定将选择数据删除?", {
  374. confirmButtonText: "确定",
  375. cancelButtonText: "取消",
  376. type: "warning"
  377. })
  378. .then(() => {
  379. return agreementpriceRemove(this.ids);
  380. })
  381. .then(() => {
  382. this.onLoad(this.page);
  383. this.$message({
  384. type: "success",
  385. message: "操作成功!"
  386. });
  387. this.$refs.crud.toggleSelection();
  388. });
  389. },
  390. beforeOpen(done, type) {
  391. if (["edit", "view"].includes(type)) {
  392. agreementpriceDetail(this.form.id).then(res => {
  393. this.form = res.data.data;
  394. });
  395. }
  396. done();
  397. },
  398. searchReset() {
  399. this.query = {};
  400. this.onLoad(this.page);
  401. },
  402. searchChange(params, done) {
  403. this.query = params;
  404. this.page.currentPage = 1;
  405. this.onLoad(this.page, params);
  406. done();
  407. },
  408. selectionChange(list) {
  409. this.selectionList = list;
  410. },
  411. selectionClear() {
  412. this.selectionList = [];
  413. this.$refs.crud.toggleSelection();
  414. },
  415. currentChange(currentPage){
  416. this.page.currentPage = currentPage;
  417. },
  418. sizeChange(pageSize){
  419. this.page.pageSize = pageSize;
  420. },
  421. refreshChange() {
  422. this.onLoad(this.page, this.query);
  423. },
  424. onLoad(page, params = {}) {
  425. this.loading = true;
  426. agreementpriceList(page.currentPage, page.pageSize, Object.assign(params, this.query)).then(res => {
  427. const data = res.data.data;
  428. this.page.total = data.total;
  429. this.data = data.records;
  430. this.loading = false;
  431. this.selectionClear();
  432. });
  433. },
  434. //自定义列保存
  435. async saveColumnTwo(ref, option, optionBack, code) {
  436. /**
  437. * 已定义全局方法,直接使用,saveColumnData保存列数据方法,参数传值(表格名称,当前表格的option数据)
  438. * 已定义全局方法,直接使用,getColumnName方法用来获取枚举值,参数根据自己定义的code值获取中文名
  439. * 一定要执行异步操作,要等接口成功返回,才能执行下一行代码
  440. */
  441. const inSave = await this.saveColumnData(this.getColumnName(code), this[option]);
  442. if (inSave) {
  443. this.$message.success("保存成功");
  444. //关闭窗口
  445. this.$refs[ref].$refs.dialogColumn.columnBox = false;
  446. }
  447. },
  448. //自定义列重置
  449. async resetColumnTwo(ref, option, optionBack, code) {
  450. this[option] = this[optionBack];
  451. const inSave = await this.delColumnData(this.getColumnName(code), this[optionBack]);
  452. if (inSave) {
  453. this.$message.success("重置成功");
  454. this.$refs[ref].$refs.dialogColumn.columnBox = false;
  455. }
  456. },
  457. // 更改表格颜色
  458. headerClassName(tab){
  459. //颜色间隔
  460. let back = ""
  461. if (tab.columnIndex >= 0 && tab.column.level === 1) {
  462. if (tab.columnIndex % 2 === 0) {
  463. back = "back-one"
  464. } else if (tab.columnIndex % 2 === 1) {
  465. back = "back-two"
  466. }
  467. }
  468. return back;
  469. },
  470. }
  471. };
  472. </script>
  473. <style scoped>
  474. ::v-deep#out-table .back-one {
  475. background: #ecf5ff !important;
  476. }
  477. ::v-deep#out-table .back-two {
  478. background: #ecf5ff !important;
  479. }
  480. </style>