index.vue 8.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250
  1. <template>
  2. <div>
  3. <basic-container v-if="isShow">
  4. <avue-crud :option="option" :table-loading="loading" :data="data" :page.sync="page" :search.sync="query"
  5. v-model="form" id="out-table" :header-cell-class-name="headerClassName" ref="crud" @row-del="rowDel"
  6. @search-change="searchChange" @search-reset="searchReset" @selection-change="selectionChange"
  7. @current-change="currentChange" @size-change="sizeChange" @refresh-change="refreshChange"
  8. @resetColumn="resetColumn('crud', 'option', 'optionBack', 383)"
  9. @saveColumn="saveColumn('crud', 'option', 'optionBack', 383)" @on-load="onLoad">
  10. <template slot="menu" slot-scope="{ row, index }">
  11. <el-button size="small" icon="el-icon-edit" type="text" @click="rowEdit(row)">编辑</el-button>
  12. </template>
  13. <template slot="businessNo" slot-scope="{ row }">
  14. <span style="color: #1e9fff" @click="rowEdit(row)">{{ row.businessNo }}</span>
  15. </template>
  16. </avue-crud>
  17. </basic-container>
  18. <detailsPage v-if="!isShow" :detailData="detailData" @goBack="goBack"></detailsPage>
  19. </div>
  20. </template>
  21. <script>
  22. import { getList, remove, copyAgent } from "@/api/tradeAgency/exchangePurchasing";
  23. import detailsPage from "./detailsPage";
  24. export default {
  25. data() {
  26. return {
  27. detailData: {},
  28. isShow: true,
  29. form: {},
  30. query: {
  31. businessType: 'MYDL-STL',
  32. dc: 'D'
  33. },
  34. loading: false,
  35. page: {
  36. pageSize: 10,
  37. currentPage: 1,
  38. total: 0,
  39. },
  40. selectionList: [],
  41. option: {},
  42. optionBack: {
  43. height: 'auto',
  44. calcHeight: 30,
  45. menuWidth: 80,
  46. searchShow: true,
  47. searchMenuSpan: 12,
  48. border: true,
  49. index: true,
  50. addBtn: false,
  51. viewBtn: false,
  52. editBtn: false,
  53. delBtn: false,
  54. searchIcon: true,
  55. searchIndex: 3,
  56. column: [
  57. {
  58. label: "客户名称",
  59. prop: "corpName",
  60. overHidden: true,
  61. search: true,
  62. type: 'select',
  63. filterable: true,
  64. remote: true,
  65. dicUrl: "/api/blade-los/bcorps/listByType?cnName={{key}}",
  66. props: {
  67. label: 'cnName',
  68. value: 'cnName',
  69. res: 'data.records'
  70. },
  71. searchOrder: 1,
  72. },
  73. {
  74. label: "业务号",
  75. prop: "businessNo",
  76. overHidden: true,
  77. search: true,
  78. searchOrder: 2,
  79. },
  80. {
  81. label: "业务日期",
  82. prop: "businessDate",
  83. type: "date",
  84. format: "yyyy-MM-dd",
  85. valueFormat: "yyyy-MM-dd 00:00:00",
  86. overHidden: true
  87. },
  88. {
  89. label: "金额",
  90. prop: "goodsValue",
  91. overHidden: true,
  92. },
  93. {
  94. label: "备注",
  95. prop: "remarks",
  96. overHidden: true
  97. }
  98. ]
  99. },
  100. data: [],
  101. };
  102. },
  103. components: {
  104. detailsPage,
  105. },
  106. async created() {
  107. this.option = await this.getColumnData(this.getColumnName(383), this.optionBack);
  108. },
  109. activated() {
  110. setTimeout(() => {
  111. if (this.$route.query.billNo) {
  112. this.isShow = false
  113. this.$store.commit("IN_FIRSTSET_DETAIL");
  114. }
  115. }, 100);
  116. },
  117. methods: {
  118. rowEdit(row) {
  119. this.detailData = {
  120. id: row.id
  121. };
  122. this.isShow = false
  123. this.$store.commit("IN_FIRSTSET_DETAIL");
  124. },
  125. // 编辑
  126. inEdit(row) {
  127. },
  128. searchReset() {
  129. this.query = this.$options.data().query;
  130. this.onLoad(this.page);
  131. },
  132. // 搜索按钮点击
  133. searchChange(params, done) {
  134. this.page.currentPage = 1;
  135. this.onLoad(this.page, this.query);
  136. done();
  137. },
  138. selectionChange(list) {
  139. this.selectionList = list;
  140. },
  141. currentChange(currentPage) {
  142. this.page.currentPage = currentPage;
  143. },
  144. sizeChange(pageSize) {
  145. this.page.pageSize = pageSize;
  146. },
  147. refreshChange() {
  148. this.onLoad(this.page, this.query);
  149. },
  150. onLoad(page, params = {}) {
  151. let obj = {}
  152. obj = {
  153. ...Object.assign(params, this.query),
  154. }
  155. console.log(obj)
  156. this.loading = true;
  157. getList(page.currentPage, page.pageSize, obj).then(res => {
  158. this.data = res.data.data.records;
  159. this.page.total = res.data.data.total;
  160. this.$nextTick(() => {
  161. this.$refs.crud.doLayout();
  162. this.$refs.crud.dicInit();
  163. });
  164. }).finally(() => {
  165. this.loading = false;
  166. })
  167. },
  168. // 详情的返回列表
  169. goBack() {
  170. // 初始化数据
  171. if (JSON.stringify(this.$route.query) != "{}") {
  172. this.$router.$avueRouter.closeTag();
  173. this.$router.push({
  174. path: "/tradeAgency/firstSettlement/index"
  175. });
  176. }
  177. this.$store.commit("OUT_FIRSTSET_DETAIL");
  178. this.detailData = {}
  179. this.isShow = true;
  180. this.onLoad(this.page, this.search);
  181. },
  182. //自定义列保存
  183. async saveColumn(ref, option, optionBack, code) {
  184. /**
  185. * 已定义全局方法,直接使用,saveColumnData保存列数据方法,参数传值(表格名称,当前表格的option数据)
  186. * 已定义全局方法,直接使用,getColumnName方法用来获取枚举值,参数根据自己定义的code值获取中文名
  187. * 一定要执行异步操作,要等接口成功返回,才能执行下一行代码
  188. */
  189. const inSave = await this.saveColumnData(this.getColumnName(code), this[option]);
  190. if (inSave) {
  191. this.$message.success("保存成功");
  192. //关闭窗口
  193. this.$refs[ref].$refs.dialogColumn.columnBox = false;
  194. this.searchReset()
  195. }
  196. },
  197. //自定义列重置
  198. async resetColumn(ref, option, optionBack, code) {
  199. this[option] = this[optionBack];
  200. const inSave = await this.delColumnData(this.getColumnName(code), this[optionBack]);
  201. if (inSave) {
  202. this.$message.success("重置成功");
  203. this.$refs[ref].$refs.dialogColumn.columnBox = false;
  204. this.searchReset()
  205. }
  206. },
  207. // 更改表格颜色
  208. headerClassName(tab) {
  209. //颜色间隔
  210. let back = ""
  211. if (tab.columnIndex >= 0 && tab.column.level === 1) {
  212. if (tab.columnIndex % 2 === 0) {
  213. back = "back-one"
  214. } else if (tab.columnIndex % 2 === 1) {
  215. back = "back-two"
  216. }
  217. }
  218. return back;
  219. },
  220. }
  221. }
  222. </script>
  223. <style scoped>
  224. ::v-deep#out-table .back-one {
  225. background: #ecf5ff !important;
  226. text-align: center;
  227. }
  228. ::v-deep#out-table .back-two {
  229. background: #ecf5ff !important;
  230. text-align: center;
  231. }
  232. .pointerClick {
  233. cursor: pointer;
  234. color: #1e9fff;
  235. }
  236. ::v-deep .el-col-md-8 {
  237. width: 24.33333%;
  238. }
  239. </style>