index.vue 10 KB

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