index.vue 8.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266
  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', 416)"
  9. @saveColumn="saveColumn('crud', 'option', 'optionBack', 416)" @on-load="onLoad">
  10. <template slot="menuLeft">
  11. <el-button type="primary" size="small" icon="el-icon-plus" @click="addButton">新 增
  12. </el-button>
  13. </template>
  14. <template slot-scope="{row}" slot="menu">
  15. <el-button type="text" size="small" icon="el-icon-edit" @click.stop="rowEdit(row)">编 辑
  16. </el-button>
  17. <el-button type="text" size="small" icon="el-icon-edit" @click.stop="rowDel(row)">删 除
  18. </el-button>
  19. </template>
  20. </avue-crud>
  21. </basic-container>
  22. <detailsPage v-if="!isShow" :detailData="detailData" @goBack="goBack"></detailsPage>
  23. </div>
  24. </template>
  25. <script>
  26. import { getList, remove } from "@/api/serviceConfiguration/modifyData";
  27. import detailsPage from "./detailsPage";
  28. import dicSelect from "@/components/dicSelect/main";
  29. import _ from "lodash";
  30. export default {
  31. data() {
  32. return {
  33. isShow: true,
  34. form: {
  35. },
  36. query: {
  37. type: 1
  38. },
  39. loading: false,
  40. page: {
  41. pageSize: 10,
  42. currentPage: 1,
  43. total: 0
  44. },
  45. selectionList: [],
  46. option: {},
  47. optionBack: {
  48. height: 'auto',
  49. calcHeight: 30,
  50. menuWidth: 140,
  51. tip: false,
  52. searchShow: true,
  53. searchMenuSpan: 12,
  54. border: true,
  55. index: true,
  56. indexFixed:false,
  57. addBtn: false,
  58. viewBtn: false,
  59. editBtn: false,
  60. delBtn: false,
  61. selection: true,
  62. selectionFixed:false,
  63. searchIcon: true,
  64. align: 'center',
  65. searchIndex: 3,
  66. column: [
  67. {
  68. label: "业务类型",
  69. prop: "businessType",
  70. search: true,
  71. overHidden: true,
  72. type: 'select',
  73. dicData: [{
  74. value: 'SE',
  75. label: '海运出口'
  76. }, {
  77. value: 'SI',
  78. label: '海运进口'
  79. }, {
  80. value: 'AE',
  81. label: '空运出口'
  82. }, {
  83. value: 'AI',
  84. label: '空运进口'
  85. }, {
  86. value: 'BGSE',
  87. label: '海运报关出口'
  88. }, {
  89. value: 'BGSI',
  90. label: '海运报关进口'
  91. }, {
  92. value: 'BGAE',
  93. label: '空运报关出口'
  94. }, {
  95. value: 'BGAI',
  96. label: '空运报关进口'
  97. }],
  98. },
  99. {
  100. label: "创建日期",
  101. prop: "createTime",
  102. overHidden: true,
  103. },
  104. {
  105. label: "备注",
  106. prop: "remarks",
  107. overHidden: true
  108. }
  109. ]
  110. },
  111. data: []
  112. };
  113. },
  114. components: {
  115. detailsPage,
  116. dicSelect
  117. },
  118. async created() {
  119. this.option = await this.getColumnData(this.getColumnName(416), this.optionBack)
  120. },
  121. activated() {
  122. this.$nextTick(() => {
  123. this.$refs.crud.doLayout();
  124. });
  125. },
  126. methods: {
  127. addButton() {
  128. this.isShow = false
  129. this.detailData = {};
  130. },
  131. rowEdit(row) {
  132. this.detailData = {
  133. id: row.id
  134. };
  135. this.isShow = false
  136. },
  137. searchReset() {
  138. this.query = this.$options.data().query;
  139. this.onLoad(this.page);
  140. },
  141. // 搜索按钮点击
  142. searchChange(params, done) {
  143. this.page.currentPage = 1;
  144. this.onLoad(this.page, this.query);
  145. done();
  146. },
  147. selectionChange(list) {
  148. this.selectionList = list;
  149. },
  150. currentChange(currentPage) {
  151. this.page.currentPage = currentPage;
  152. },
  153. sizeChange(pageSize) {
  154. this.page.pageSize = pageSize;
  155. },
  156. refreshChange() {
  157. this.onLoad(this.page, this.query);
  158. },
  159. onLoad(page, params = {}) {
  160. let obj = {}
  161. obj = {
  162. ...Object.assign(params, this.query),
  163. }
  164. this.loading = true;
  165. getList(page.currentPage, page.pageSize, obj).then(res => {
  166. this.data = res.data.data.records;
  167. this.page.total = res.data.data.total;
  168. this.$nextTick(() => {
  169. this.$refs.crud.doLayout();
  170. this.$refs.crud.dicInit();
  171. });
  172. }).finally(() => {
  173. this.loading = false;
  174. })
  175. },
  176. // 删除
  177. rowDel(row) {
  178. this.$confirm("确定将选择数据删除?", {
  179. confirmButtonText: "确定",
  180. cancelButtonText: "取消",
  181. type: "warning"
  182. }).then(() => {
  183. remove({ ids: row.id }).then(res => {
  184. this.onLoad(this.page, this.query);
  185. this.$message.success("成功删除");
  186. })
  187. })
  188. },
  189. // 详情的返回列表
  190. goBack() {
  191. // 初始化数据
  192. if (JSON.stringify(this.$route.query) != "{}") {
  193. this.$router.$avueRouter.closeTag();
  194. this.$router.push({
  195. path: "/serviceConfiguration/modifyData/index"
  196. });
  197. }
  198. this.detailData = {}
  199. this.isShow = true;
  200. this.onLoad(this.page, this.query);
  201. },
  202. //自定义列保存
  203. async saveColumn(ref, option, optionBack, code) {
  204. /**
  205. * 已定义全局方法,直接使用,saveColumnData保存列数据方法,参数传值(表格名称,当前表格的option数据)
  206. * 已定义全局方法,直接使用,getColumnName方法用来获取枚举值,参数根据自己定义的code值获取中文名
  207. * 一定要执行异步操作,要等接口成功返回,才能执行下一行代码
  208. */
  209. const inSave = await this.saveColumnData(this.getColumnName(code), this[option]);
  210. if (inSave) {
  211. this.$message.success("保存成功");
  212. //关闭窗口
  213. this.$refs[ref].$refs.dialogColumn.columnBox = false;
  214. this.searchReset()
  215. }
  216. },
  217. //自定义列重置
  218. async resetColumn(ref, option, optionBack, code) {
  219. this[option] = this[optionBack];
  220. const inSave = await this.delColumnData(this.getColumnName(code), this[optionBack]);
  221. if (inSave) {
  222. this.$message.success("重置成功");
  223. this.$refs[ref].$refs.dialogColumn.columnBox = false;
  224. this.searchReset()
  225. }
  226. },
  227. // 更改表格颜色
  228. headerClassName(tab) {
  229. //颜色间隔
  230. let back = ""
  231. if (tab.columnIndex >= 0 && tab.column.level === 1) {
  232. if (tab.columnIndex % 2 === 0) {
  233. back = "back-one"
  234. } else if (tab.columnIndex % 2 === 1) {
  235. back = "back-two"
  236. }
  237. }
  238. return back;
  239. },
  240. }
  241. }
  242. </script>
  243. <style scoped>
  244. ::v-deep#out-table .back-one {
  245. background: #ecf5ff !important;
  246. text-align: center;
  247. }
  248. ::v-deep#out-table .back-two {
  249. background: #ecf5ff !important;
  250. text-align: center;
  251. }
  252. .pointerClick {
  253. cursor: pointer;
  254. color: #1e9fff;
  255. }
  256. ::v-deep .el-col-md-8 {
  257. width: 24.33333%;
  258. }
  259. </style>