index.vue 17 KB

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