index.vue 7.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261
  1. <template>
  2. <div>
  3. <basic-container v-show="!detailsOpen">
  4. <avue-crud
  5. :option="option"
  6. :search.sync="search"
  7. v-model="form"
  8. :table-loading="loading"
  9. :data="dataList"
  10. ref="crud"
  11. :key="key"
  12. @on-load="onLoad"
  13. @search-change="searchChange"
  14. @row-del="rowDel"
  15. @refresh-change="refreshChange"
  16. @resetColumn="resetColumnTwo('crud','option','optionList',272)"
  17. @saveColumn="saveColumnTwo('crud','option','optionList',272)"
  18. :page.sync="page">
  19. <template slot-scope="{type,size,row,index}" slot="menu">
  20. <!-- <el-button :size="size" :type="type" @click="check(row)">查看</el-button> -->
  21. <el-button :size="size" :type="type" :disabled="row.enableOrNot" @click="$refs.crud.rowDel(row,index)">删除
  22. </el-button>
  23. </template>
  24. <template slot-scope="{ row, index }" slot="cname">
  25. <span style="color: #409EFF;cursor: pointer" @click.stop="check(row)">{{ row.cname }}</span>
  26. </template>
  27. <template slot="corpNameSearch">
  28. <crop-select v-model="search.corpId" corpType="KH" :refresh="false"></crop-select>
  29. </template>
  30. <template slot-scope="{type,size,row,$index}" slot="menuLeft">
  31. <el-button icon="el-icon-plus" type="primary" :disabled="dataList.length > 0" :size="size" @click="detailsOpen = true">新增</el-button>
  32. </template>
  33. </avue-crud>
  34. </basic-container>
  35. <detailsPage v-if="detailsOpen" :onLoad="form" :detailData="detailData" @backToList="backToList"></detailsPage>
  36. </div>
  37. </template>
  38. <script>
  39. // import {getList, remove} from "@/api/oceanShipping/maritimeExport";
  40. import {getList, remove} from "@/api/tirePartsMall/basicData/brandPage";
  41. import detailsPage from "./detailsPage.vue"
  42. export default {
  43. name: "index",
  44. components: {
  45. detailsPage
  46. },
  47. data() {
  48. return {
  49. detailsOpen: false,
  50. loading: false,
  51. search: {},
  52. form: {},
  53. dataList: [],
  54. detailData: {},
  55. page: {
  56. pageSize: 20,
  57. currentPage: 1,
  58. total: 0,
  59. pageSizes: [10, 20, 30, 40, 50, 100, 200, 300, 400, 500]
  60. },
  61. key: 0,
  62. option: {},
  63. optionList: {
  64. viewBtn: false,
  65. editBtn: false,
  66. delBtn: false,
  67. addBtn: false,
  68. index: true,
  69. span: 8,
  70. border: true,
  71. height: "auto",
  72. searchMenuPosition: "right",
  73. align: "center",
  74. size: "small",
  75. menuWidth: 50,
  76. searchSpan: 8,
  77. searchIcon: true,
  78. searchIndex: 2,
  79. highlightCurrentRow: true,
  80. dialogWidth: "70%",
  81. column: [{
  82. label: '名称',
  83. prop: "cname",
  84. search: true,
  85. overHidden: true,
  86. }, {
  87. label: '排序',
  88. prop: "sort",
  89. type:'number'
  90. }, {
  91. label: "制单人",
  92. search: true,
  93. prop: "createUserName",
  94. searchProp: "createUser",
  95. overHidden: true,
  96. width: 100,
  97. filterable: true,
  98. remote: true,
  99. type: "select",
  100. dicUrl: "/api/blade-user/page?size=20&current=1&account={{key}}",
  101. props: {
  102. label: "account",
  103. value: "id",
  104. res: 'data.records'
  105. }
  106. }, {
  107. label: "制单日期",
  108. search: true,
  109. prop: "createTime",
  110. searchProp: "createTimeList",
  111. type: "date",
  112. overHidden: true,
  113. width: 100,
  114. searchRange: true,
  115. searchDefaultTime: ["00:00:00", "23:59:59"],
  116. format: "yyyy-MM-dd",
  117. valueFormat: "yyyy-MM-dd HH:mm:ss"
  118. }, {
  119. label: "更新人",
  120. prop: "updateUserName",
  121. searchProp: "updateUser",
  122. overHidden: true,
  123. width: 100,
  124. filterable: true,
  125. remote: true,
  126. type: "select",
  127. dicUrl: "/api/blade-user/page?size=20&current=1&account={{key}}",
  128. props: {
  129. label: "account",
  130. value: "id",
  131. res: 'data.records'
  132. }
  133. }, {
  134. label: "更新日期",
  135. prop: "updateTime",
  136. searchProp: "updateTimeList",
  137. type: "date",
  138. overHidden: true,
  139. width: 100,
  140. searchRange: true,
  141. searchDefaultTime: ["00:00:00", "23:59:59"],
  142. format: "yyyy-MM-dd",
  143. valueFormat: "yyyy-MM-dd HH:mm:ss"
  144. }, {
  145. label: '是否启用',
  146. prop: "enableOrNot",
  147. search: false,
  148. overHidden: true,
  149. type: 'select',
  150. dicData: [{
  151. label: '否',
  152. value: 0
  153. }, {
  154. label: '是',
  155. value: 1
  156. }]
  157. }]
  158. }
  159. }
  160. },
  161. async created() {
  162. this.option = await this.getColumnData(this.getColumnName(272), this.optionList);
  163. this.key++
  164. let i = 0;
  165. this.option.column.forEach(item => {
  166. if (item.search) i++
  167. })
  168. if (i % 3 !== 0) {
  169. const num = 3 - Number(i % 3)
  170. this.option.searchMenuSpan = num * 8;
  171. this.option.searchMenuPosition = "right";
  172. }
  173. },
  174. methods: {
  175. check(row) {
  176. this.form = row
  177. this.detailsOpen = true
  178. },
  179. backToList(type) {
  180. this.form = {}
  181. this.detailsOpen = false
  182. if (type === 0) {
  183. this.detailData = {}
  184. }
  185. this.onLoad(this.page, this.search)
  186. },
  187. //刷新
  188. refreshChange() {
  189. this.onLoad(this.page, this.search)
  190. },
  191. rowDel(form, index) {
  192. this.$confirm('此操作将永久删除该行, 是否继续?', '提示', {
  193. confirmButtonText: '确定',
  194. cancelButtonText: '取消',
  195. type: 'warning'
  196. }).then(() => {
  197. remove(form.id).then(res => {
  198. this.$message({
  199. type: 'success',
  200. message: '删除成功!'
  201. });
  202. this.dataList.splice(index, 1);
  203. this.onLoad(this.page)
  204. })
  205. }).catch(() => {
  206. });
  207. },
  208. searchChange(params, done) {
  209. done();
  210. console.log(this.page)
  211. this.onLoad(this.page, params)
  212. },
  213. onLoad(page, params = {}) {
  214. params = {
  215. type : 'LBT',
  216. ...params,
  217. current: page.currentPage,
  218. size: page.pageSize,
  219. ...Object.assign(params, this.search)
  220. }
  221. this.loading = true
  222. getList(params).then(res => {
  223. this.dataList = res.data.data.records
  224. this.page.total = res.data.data.total
  225. this.loading = false
  226. }).finally(() => {
  227. this.loading = false
  228. })
  229. },
  230. //自定义列保存
  231. async saveColumnTwo(ref, option, optionBack, code) {
  232. /**
  233. * 已定义全局方法,直接使用,saveColumnData保存列数据方法,参数传值(表格名称,当前表格的option数据)
  234. * 已定义全局方法,直接使用,getColumnName方法用来获取枚举值,参数根据自己定义的code值获取中文名
  235. * 一定要执行异步操作,要等接口成功返回,才能执行下一行代码
  236. */
  237. const inSave = await this.saveColumnData(this.getColumnName(code), this[option]);
  238. if (inSave) {
  239. this.$message.success("保存成功");
  240. //关闭窗口
  241. this.$refs[ref].$refs.dialogColumn.columnBox = false;
  242. }
  243. },
  244. //自定义列重置
  245. async resetColumnTwo(ref, option, optionBack, code) {
  246. this[option] = this[optionBack];
  247. const inSave = await this.delColumnData(this.getColumnName(code), this[optionBack]);
  248. if (inSave) {
  249. this.$message.success("重置成功");
  250. this.$refs[ref].$refs.dialogColumn.columnBox = false;
  251. }
  252. }
  253. }
  254. }
  255. </script>
  256. <style scoped>
  257. </style>