mergeCustomers.vue 6.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226
  1. <template>
  2. <div>
  3. <el-dialog title="合并客户" :visible.sync="dialogVisible" append-to-body width="60%" :before-close="handleClose">
  4. <avue-crud
  5. v-if="dialogVisible"
  6. :option="option"
  7. :table-loading="loading"
  8. :data="data"
  9. :page.sync="page"
  10. :search.sync="query"
  11. ref="crud"
  12. @current-row-change="handleCurrentRowChange"
  13. id="out-table"
  14. :header-cell-class-name="headerClassName"
  15. @search-change="searchChange"
  16. @search-reset="searchReset"
  17. @current-change="currentChange"
  18. @size-change="sizeChange"
  19. @on-load="onLoad"
  20. >
  21. </avue-crud>
  22. <span slot="footer" class="dialog-footer">
  23. <el-button @click="dialogVisible = false" size="mini">取 消</el-button>
  24. <el-button type="primary" @click="submit" size="mini">合 并</el-button>
  25. </span>
  26. </el-dialog>
  27. </div>
  28. </template>
  29. <script>
  30. import { BcorpsList, mergeCorps } from "@/api/iosBasicData/bcorps";
  31. export default {
  32. props: {},
  33. data() {
  34. return {
  35. quotationObj: null,
  36. form: {},
  37. ids: null,
  38. data: [],
  39. query: {},
  40. dialogVisible: false,
  41. loading: false,
  42. page: {
  43. pageSize: 20,
  44. currentPage: 1,
  45. total: 0,
  46. pageSizes: [10, 20, 30, 40, 50, 100, 200, 300, 400, 500]
  47. },
  48. option: {
  49. height: 500,
  50. calcHeight: 30,
  51. border: true,
  52. index: true,
  53. addBtn: false,
  54. viewBtn: false,
  55. delBtn: false,
  56. editBtn: false,
  57. menu: false,
  58. header: false,
  59. searchSpan: 8,
  60. searchIndex: 2,
  61. searchMenuSpan: 16,
  62. highlightCurrentRow: true,
  63. column: [
  64. {
  65. label: "客户编号",
  66. prop: "code",
  67. overHidden: true
  68. },
  69. {
  70. label: "客户简称",
  71. prop: "shortName",
  72. overHidden: true
  73. },
  74. {
  75. label: "客户名称",
  76. prop: "cnName",
  77. search: true,
  78. overHidden: true
  79. },
  80. {
  81. label: "英文名称",
  82. prop: "enName",
  83. overHidden: true
  84. }
  85. ]
  86. }
  87. };
  88. },
  89. async created() {
  90. // this.option = await this.getColumnData(this.getColumnName(309.6), this.optionBack);
  91. },
  92. methods: {
  93. openDialog(val) {
  94. this.dialogVisible = true;
  95. this.quotationObj = null;
  96. this.page.pageSize = 20;
  97. this.page.currentPage = 1;
  98. this.page.total = 0;
  99. this.query = {};
  100. this.form = {};
  101. this.form = val;
  102. },
  103. handleCurrentRowChange(val) {
  104. this.quotationObj = val;
  105. },
  106. submit() {
  107. if (!this.quotationObj) {
  108. return this.$message.error("请选择数据");
  109. }
  110. this.$confirm(`确定要将${this.quotationObj.cnName}合并到${this.form.cnName}?`, "提示", {
  111. confirmButtonText: "确定",
  112. cancelButtonText: "取消",
  113. type: "warning"
  114. }).then(() => {
  115. let obj = {
  116. id: this.form.id,
  117. mergeId: this.quotationObj.id
  118. };
  119. const loading = this.$loading({
  120. lock: true,
  121. text: "加载中",
  122. spinner: "el-icon-loading",
  123. background: "rgba(255,255,255,0.7)"
  124. });
  125. mergeCorps(obj)
  126. .then(res => {
  127. this.$message.success("操作成功");
  128. this.$emit("importData");
  129. this.dialogVisible = false;
  130. })
  131. .catch(() => {
  132. loading.close();
  133. });
  134. });
  135. },
  136. searchReset() {
  137. this.query = {};
  138. this.onLoad(this.page);
  139. },
  140. searchChange(params, done) {
  141. this.query = params;
  142. this.page.currentPage = 1;
  143. this.onLoad(this.page, this.query);
  144. done();
  145. },
  146. currentChange(currentPage) {
  147. this.page.currentPage = currentPage;
  148. },
  149. sizeChange(pageSize) {
  150. this.page.pageSize = pageSize;
  151. },
  152. onLoad(page, params = {}) {
  153. let obj = {
  154. ...Object.assign(params, this.query),
  155. status: 0
  156. };
  157. this.loading = true;
  158. BcorpsList(page.currentPage,page.pageSize, obj)
  159. .then(res => {
  160. this.page.total = res.data.data.total;
  161. this.data = res.data.data.records;
  162. })
  163. .finally(() => {
  164. this.loading = false;
  165. });
  166. },
  167. //自定义列保存
  168. async saveColumn(ref, option, optionBack, code) {
  169. /**
  170. * 已定义全局方法,直接使用,saveColumnData保存列数据方法,参数传值(表格名称,当前表格的option数据)
  171. * 已定义全局方法,直接使用,getColumnName方法用来获取枚举值,参数根据自己定义的code值获取中文名
  172. * 一定要执行异步操作,要等接口成功返回,才能执行下一行代码
  173. */
  174. const inSave = await this.saveColumnData(this.getColumnName(code), this[option]);
  175. if (inSave) {
  176. this.$message.success("保存成功");
  177. //关闭窗口
  178. this.$refs[ref].$refs.dialogColumn.columnBox = false;
  179. this.searchReset();
  180. }
  181. },
  182. //自定义列重置
  183. async resetColumn(ref, option, optionBack, code) {
  184. this[option] = this[optionBack];
  185. const inSave = await this.delColumnData(this.getColumnName(code), this[optionBack]);
  186. if (inSave) {
  187. this.$message.success("重置成功");
  188. this.$refs[ref].$refs.dialogColumn.columnBox = false;
  189. }
  190. },
  191. // 更改表格颜色
  192. headerClassName(tab) {
  193. //颜色间隔
  194. let back = "";
  195. if (tab.columnIndex >= 0 && tab.column.level === 1) {
  196. if (tab.columnIndex % 2 === 0) {
  197. back = "back-one";
  198. } else if (tab.columnIndex % 2 === 1) {
  199. back = "back-two";
  200. }
  201. }
  202. return back;
  203. }
  204. }
  205. };
  206. </script>
  207. <style lang="scss" scoped>
  208. ::v-deep #out-table .back-one {
  209. background: #ecf5ff !important;
  210. text-align: center;
  211. padding: 4px 0;
  212. }
  213. ::v-deep #out-table .back-two {
  214. background: #ecf5ff !important;
  215. text-align: center;
  216. padding: 4px 0;
  217. }
  218. ::v-deep .el-dialog .el-dialog__body {
  219. padding: 0px 10px !important;
  220. }
  221. </style>