index.vue 7.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257
  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" :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. search: true,
  89. prop: "createUserName",
  90. searchProp: "createUser",
  91. overHidden: true,
  92. width: 100,
  93. filterable: true,
  94. remote: true,
  95. type: "select",
  96. dicUrl: "/api/blade-user/page?size=20&current=1&account={{key}}",
  97. props: {
  98. label: "account",
  99. value: "id",
  100. res: 'data.records'
  101. }
  102. }, {
  103. label: "制单日期",
  104. search: true,
  105. prop: "createTime",
  106. searchProp: "createTimeList",
  107. type: "date",
  108. overHidden: true,
  109. width: 100,
  110. searchRange: true,
  111. searchDefaultTime: ["00:00:00", "23:59:59"],
  112. format: "yyyy-MM-dd",
  113. valueFormat: "yyyy-MM-dd HH:mm:ss"
  114. }, {
  115. label: "更新人",
  116. prop: "updateUserName",
  117. searchProp: "updateUser",
  118. overHidden: true,
  119. width: 100,
  120. filterable: true,
  121. remote: true,
  122. type: "select",
  123. dicUrl: "/api/blade-user/page?size=20&current=1&account={{key}}",
  124. props: {
  125. label: "account",
  126. value: "id",
  127. res: 'data.records'
  128. }
  129. }, {
  130. label: "更新日期",
  131. prop: "updateTime",
  132. searchProp: "updateTimeList",
  133. type: "date",
  134. overHidden: true,
  135. width: 100,
  136. searchRange: true,
  137. searchDefaultTime: ["00:00:00", "23:59:59"],
  138. format: "yyyy-MM-dd",
  139. valueFormat: "yyyy-MM-dd HH:mm:ss"
  140. }, {
  141. label: '是否启用',
  142. prop: "enableOrNot",
  143. search: false,
  144. overHidden: true,
  145. type: 'select',
  146. dicData: [{
  147. label: '否',
  148. value: 0
  149. }, {
  150. label: '是',
  151. value: 1
  152. }]
  153. }]
  154. }
  155. }
  156. },
  157. async created() {
  158. this.option = await this.getColumnData(this.getColumnName(272), this.optionList);
  159. this.key++
  160. let i = 0;
  161. this.option.column.forEach(item => {
  162. if (item.search) i++
  163. })
  164. if (i % 3 !== 0) {
  165. const num = 3 - Number(i % 3)
  166. this.option.searchMenuSpan = num * 8;
  167. this.option.searchMenuPosition = "right";
  168. }
  169. },
  170. methods: {
  171. check(row) {
  172. this.form = row
  173. this.detailsOpen = true
  174. },
  175. backToList(type) {
  176. this.form = {}
  177. this.detailsOpen = false
  178. if (type === 0) {
  179. this.detailData = {}
  180. }
  181. this.onLoad(this.page, this.search)
  182. },
  183. //刷新
  184. refreshChange() {
  185. this.onLoad(this.page, this.search)
  186. },
  187. rowDel(form, index) {
  188. this.$confirm('此操作将永久删除该行, 是否继续?', '提示', {
  189. confirmButtonText: '确定',
  190. cancelButtonText: '取消',
  191. type: 'warning'
  192. }).then(() => {
  193. remove(form.id).then(res => {
  194. this.$message({
  195. type: 'success',
  196. message: '删除成功!'
  197. });
  198. this.dataList.splice(index, 1);
  199. this.onLoad(this.page)
  200. })
  201. }).catch(() => {
  202. });
  203. },
  204. searchChange(params, done) {
  205. done();
  206. console.log(this.page)
  207. this.onLoad(this.page, params)
  208. },
  209. onLoad(page, params = {}) {
  210. params = {
  211. type : 'GN',
  212. ...params,
  213. current: page.currentPage,
  214. size: page.pageSize,
  215. ...Object.assign(params, this.search)
  216. }
  217. this.loading = true
  218. getList(params).then(res => {
  219. this.dataList = res.data.data.records
  220. this.page.total = res.data.data.total
  221. this.loading = false
  222. }).finally(() => {
  223. this.loading = false
  224. })
  225. },
  226. //自定义列保存
  227. async saveColumnTwo(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. }
  239. },
  240. //自定义列重置
  241. async resetColumnTwo(ref, option, optionBack, code) {
  242. this[option] = this[optionBack];
  243. const inSave = await this.delColumnData(this.getColumnName(code), this[optionBack]);
  244. if (inSave) {
  245. this.$message.success("重置成功");
  246. this.$refs[ref].$refs.dialogColumn.columnBox = false;
  247. }
  248. }
  249. }
  250. }
  251. </script>
  252. <style scoped>
  253. </style>