index.vue 10 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289
  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', 423)"
  9. @saveColumn="saveColumn('crud', 'option', 'optionBack', 423)" @on-load="onLoad">
  10. <template slot="menuLeft">
  11. <el-button type="primary" size="small" icon="el-icon-plus" @click="addButton">新 增
  12. </el-button>
  13. <el-button type="warning" size="small" @click="outExport">导 出
  14. </el-button>
  15. </template>
  16. <template slot="menu" slot-scope="{ row, index }">
  17. <el-button size="small" icon="el-icon-edit" type="text" @click="rowEdit(row)">编辑</el-button>
  18. <el-button size="small" icon="el-icon-delete" type="text" @click="rowDel(row, index)"
  19. :disabled="row.orderStatus != '录入'">删 除</el-button>
  20. </template>
  21. <template slot="contractNo" slot-scope="{ row }">
  22. <span style="color: #1e9fff;cursor: pointer;" @click="rowEdit(row)">{{ row.contractNo }}</span>
  23. </template>
  24. </avue-crud>
  25. </basic-container>
  26. <detailsPage v-if="!isShow" :detailData="detailData" @goBack="goBack"></detailsPage>
  27. </div>
  28. </template>
  29. <script>
  30. import { getList, remove} from "@/api/tradeAgency/tradeAgency";
  31. import { getWorkDicts } from "@/api/system/dictbiz";
  32. import detailsPage from "./detailsPage";
  33. import { getToken } from "@/util/auth";
  34. import dicSelect from "@/components/dicSelect/main";
  35. import _ from "lodash";
  36. export default {
  37. data() {
  38. return {
  39. isShow: true,
  40. form: {},
  41. query: { },
  42. loading: false,
  43. page: {
  44. pageSize: 10,
  45. currentPage: 1,
  46. total: 0
  47. },
  48. selectionList: [],
  49. option: {},
  50. optionBack: {
  51. height: 'auto',
  52. calcHeight: 30,
  53. menuWidth: 140,
  54. tip: false,
  55. searchShow: true,
  56. searchMenuSpan: 18,
  57. border: true,
  58. index: true,
  59. addBtn: false,
  60. viewBtn: false,
  61. editBtn: false,
  62. delBtn: false,
  63. selection: true,
  64. searchIcon: true,
  65. align: 'center',
  66. searchIndex: 3,
  67. column: [
  68. {
  69. label: "客户名称",
  70. prop: "corpId",
  71. overHidden: true,
  72. search: true,
  73. type: 'select',
  74. filterable: true,
  75. remote: true,
  76. dicUrl: "/api/blade-los/bcorps/listByType?cnName={{key}}",
  77. props: {
  78. label: 'cnName',
  79. value: 'id',
  80. res: 'data.records'
  81. },
  82. hide: true,
  83. showColumn: false,
  84. },
  85. {
  86. label: "客户名称",
  87. prop: "corpName",
  88. overHidden: true,
  89. },
  90. {
  91. label: "积分有效期",
  92. prop: "contractNo",
  93. overHidden: true,
  94. },
  95. {
  96. label: "产生积分",
  97. prop: "billNo",
  98. overHidden: true,
  99. },
  100. {
  101. label: "使用积分",
  102. prop: "orderReleaseMethod",
  103. overHidden: true,
  104. },
  105. {
  106. label: "余额",
  107. prop: "orderNo",
  108. overHidden: true,
  109. }
  110. ]
  111. },
  112. data: [],
  113. };
  114. },
  115. components: {
  116. detailsPage,
  117. dicSelect
  118. },
  119. async created() {
  120. this.option = await this.getColumnData(this.getColumnName(423), this.optionBack);
  121. },
  122. activated() { },
  123. methods: {
  124. addButton() {
  125. this.isShow = false
  126. },
  127. rowEdit(row) {
  128. this.detailData = {
  129. id: row.itemId
  130. };
  131. this.isShow = false
  132. },
  133. // 删除
  134. rowDel(row, index) {
  135. this.$confirm("确定将选择数据删除?", {
  136. confirmButtonText: "确定",
  137. cancelButtonText: "取消",
  138. type: "warning"
  139. }).then(() => {
  140. remove({ ids: row.itemId }).then(res => {
  141. this.onLoad(this.page, this.query);
  142. this.$message.success("成功删除");
  143. })
  144. })
  145. },
  146. searchReset() {
  147. this.query = this.$options.data().query;
  148. this.onLoad(this.page);
  149. },
  150. // 搜索按钮点击
  151. searchChange(params, done) {
  152. this.page.currentPage = 1;
  153. this.onLoad(this.page, this.query);
  154. done();
  155. },
  156. selectionChange(list) {
  157. this.selectionList = list;
  158. },
  159. currentChange(currentPage) {
  160. this.page.currentPage = currentPage;
  161. },
  162. sizeChange(pageSize) {
  163. this.page.pageSize = pageSize;
  164. },
  165. refreshChange() {
  166. this.onLoad(this.page, this.query);
  167. },
  168. onLoad(page, params = {}) {
  169. let obj = {}
  170. obj = {
  171. ...Object.assign(params, this.query),
  172. }
  173. this.loading = true;
  174. getList(page.currentPage, page.pageSize, obj).then(res => {
  175. this.data = res.data.data.records;
  176. this.page.total = res.data.data.total;
  177. this.$nextTick(() => {
  178. this.$refs.crud.doLayout();
  179. this.$refs.crud.dicInit();
  180. });
  181. }).finally(() => {
  182. this.loading = false;
  183. })
  184. },
  185. // 详情的返回列表
  186. goBack() {
  187. // 初始化数据
  188. if (JSON.stringify(this.$route.query) != "{}") {
  189. this.$router.$avueRouter.closeTag();
  190. this.$router.push({
  191. path: "/tradeAgency/tradeAgency/index"
  192. });
  193. }
  194. this.detailData = {}
  195. this.isShow = true;
  196. this.onLoad(this.page, this.query);
  197. },
  198. outExport() {
  199. let config = { params: { ...this.query } }
  200. if (config.params) {
  201. for (const propName of Object.keys(config.params)) {
  202. const value = config.params[propName];
  203. if (value !== null && typeof (value) !== "undefined") {
  204. if (value instanceof Array) {
  205. for (const key of Object.keys(value)) {
  206. let params = propName + '[' + key + ']';
  207. config.params[params] = value[key]
  208. }
  209. delete config.params[propName]
  210. }
  211. }
  212. }
  213. }
  214. const routeData = this.$router.resolve({
  215. path: '/api/blade-los/agentview/export', //跳转目标窗口的地址
  216. query: {
  217. ...config.params, //括号内是要传递给新窗口的参数
  218. identification: this.url
  219. }
  220. })
  221. window.open(routeData.href.slice(1, routeData.href.length) + '&' + `${this.website.tokenHeader}=${getToken()}`);
  222. },
  223. //自定义列保存
  224. async saveColumn(ref, option, optionBack, code) {
  225. /**
  226. * 已定义全局方法,直接使用,saveColumnData保存列数据方法,参数传值(表格名称,当前表格的option数据)
  227. * 已定义全局方法,直接使用,getColumnName方法用来获取枚举值,参数根据自己定义的code值获取中文名
  228. * 一定要执行异步操作,要等接口成功返回,才能执行下一行代码
  229. */
  230. const inSave = await this.saveColumnData(this.getColumnName(code), this[option]);
  231. if (inSave) {
  232. this.$message.success("保存成功");
  233. //关闭窗口
  234. this.$refs[ref].$refs.dialogColumn.columnBox = false;
  235. this.searchReset()
  236. }
  237. },
  238. //自定义列重置
  239. async resetColumn(ref, option, optionBack, code) {
  240. this[option] = this[optionBack];
  241. const inSave = await this.delColumnData(this.getColumnName(code), this[optionBack]);
  242. if (inSave) {
  243. this.$message.success("重置成功");
  244. this.$refs[ref].$refs.dialogColumn.columnBox = false;
  245. this.searchReset()
  246. }
  247. },
  248. // 更改表格颜色
  249. headerClassName(tab) {
  250. //颜色间隔
  251. let back = ""
  252. if (tab.columnIndex >= 0 && tab.column.level === 1) {
  253. if (tab.columnIndex % 2 === 0) {
  254. back = "back-one"
  255. } else if (tab.columnIndex % 2 === 1) {
  256. back = "back-two"
  257. }
  258. }
  259. return back;
  260. },
  261. }
  262. }
  263. </script>
  264. <style scoped>
  265. ::v-deep#out-table .back-one {
  266. background: #ecf5ff !important;
  267. text-align: center;
  268. }
  269. ::v-deep#out-table .back-two {
  270. background: #ecf5ff !important;
  271. text-align: center;
  272. }
  273. .pointerClick {
  274. cursor: pointer;
  275. color: #1e9fff;
  276. }
  277. ::v-deep .el-col-md-8 {
  278. width: 24.33333%;
  279. }
  280. </style>