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