index.vue 5.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217
  1. <template>
  2. <div>
  3. <basic-container>
  4. <avue-crud
  5. :option="option"
  6. :data="dataList"
  7. ref="crud"
  8. v-model="form"
  9. :page.sync="page"
  10. :search.sync="search"
  11. @search-change="searchChange"
  12. @current-change="currentChange"
  13. @size-change="sizeChange"
  14. @refresh-change="refreshChange"
  15. @on-load="onLoad"
  16. @saveColumn="saveColumn"
  17. @resetColumn="resetColumn"
  18. :table-loading="loading"
  19. >
  20. <template slot="moudleNameSearch">
  21. <el-select
  22. v-model="search.moudleName"
  23. clearable
  24. filterable
  25. >
  26. <el-option
  27. v-for="(item, index) in moudleOption"
  28. :label="item.label"
  29. :value="item.value"
  30. :key="item.value"
  31. ></el-option>
  32. </el-select>
  33. </template>
  34. <template slot-scope="scope" slot="moudleName">
  35. <span>{{ scope.row.moudleName | moudleNameFormat(moudleOption) }}</span>
  36. </template>
  37. <template slot="menu" slot-scope="{ row, index }">
  38. <el-button
  39. type="text"
  40. icon="el-icon-unlock"
  41. size="small"
  42. @click="rowUnlock(row, index)"
  43. >解锁</el-button>
  44. </template>
  45. </avue-crud>
  46. </basic-container>
  47. </div>
  48. </template>
  49. <script>
  50. import option from "./config/mainList.json";
  51. import {lockList, lockRemove} from "@/api/lock/lock";
  52. export default {
  53. name: "index",
  54. data() {
  55. return {
  56. option: {},
  57. dataList: [],
  58. form: {},
  59. page: {
  60. pageSize: 10,
  61. pagerCount: 5,
  62. total: 0,
  63. },
  64. search: {},
  65. loading: false,
  66. moudleOption: [
  67. {
  68. label: '销售',
  69. value: 'xs'
  70. },
  71. {
  72. label: '采购',
  73. value: 'cg'
  74. },
  75. {
  76. label: '发货',
  77. value: 'fh'
  78. },
  79. {
  80. label: '收货',
  81. value: 'sh'
  82. },
  83. {
  84. label: '收费',
  85. value: 'sf'
  86. },
  87. {
  88. label: '付费',
  89. value: 'ff'
  90. },
  91. {
  92. label: '进项',
  93. value: 'jx'
  94. },
  95. {
  96. label: '销项',
  97. value: 'xx'
  98. },
  99. {
  100. label: '小学部',
  101. value: 'xxb'
  102. },
  103. ]
  104. }
  105. },
  106. async created() {
  107. this.option = await this.getColumnData(this.getColumnName(73), option);
  108. let i = 0;
  109. this.option.column.forEach(item => {
  110. if (item.search) i++
  111. })
  112. if (i % 3 !== 0){
  113. const num = 3 - Number(i % 3)
  114. this.option.searchMenuSpan = num * 8;
  115. this.option.searchMenuPosition = "right";
  116. }
  117. },
  118. filters: {
  119. moudleNameFormat(row, moudleOption) {
  120. let name;
  121. moudleOption.map((e) => {
  122. if (row == e.value) {
  123. name = e.label
  124. }
  125. });
  126. return name;
  127. },
  128. },
  129. methods: {
  130. searchChange(params, done) {
  131. this.onLoad(this.page, params);
  132. done();
  133. },
  134. currentChange(val) {
  135. this.page.currentPage = val;
  136. },
  137. sizeChange(val) {
  138. this.page.currentPage = 1;
  139. this.page.pageSize = val;
  140. },
  141. refreshChange() {
  142. this.dataList.forEach(item => {
  143. this.$refs.crud.toggleRowExpansion(item, false)
  144. })
  145. this.page.currentPage = 1;
  146. this.onLoad(this.page, this.search);
  147. },
  148. onLoad(page, params) {
  149. this.dataList.forEach(item => {
  150. this.$refs.crud.toggleRowExpansion(item, false)
  151. })
  152. this.loading = true;
  153. lockList(page.currentPage, page.pageSize, params)
  154. .then(res => {
  155. this.dataList = res.data.data.records ? res.data.data.records : [];
  156. this.page.total = res.data.data.total;
  157. if (this.page.total) {
  158. this.option.height = window.innerHeight - 260;
  159. }
  160. this.dataList.forEach(item => {
  161. this.$set(item,'insideList',[])
  162. this.$set(item,'loading', true)
  163. })
  164. })
  165. .finally(() => {
  166. this.loading = false;
  167. });
  168. },
  169. // 解锁
  170. rowUnlock(row, index) {
  171. this.$confirm('是否确认解锁?', '提示', {
  172. confirmButtonText: "确定",
  173. cancelButtonText: "取消",
  174. type: "warning"
  175. }).then(() => {
  176. return lockRemove({ids: row.id})
  177. }).then(() => {
  178. this.$message({
  179. type: "success",
  180. message: "操作成功!"
  181. });
  182. this.page.currentPage = 1;
  183. this.onLoad(this.page, {parentId: 0});
  184. })
  185. },
  186. async saveColumn() {
  187. const inSave = await this.saveColumnData(
  188. this.getColumnName(73),
  189. this.option
  190. );
  191. if (inSave) {
  192. this.$message.success("保存成功");
  193. //关闭窗口
  194. this.$refs.crud.$refs.dialogColumn.columnBox = false;
  195. }
  196. },
  197. async resetColumn() {
  198. this.option = option;
  199. const inSave = await this.delColumnData(
  200. this.getColumnName(73),
  201. option
  202. );
  203. if (inSave) {
  204. this.$message.success("重置成功");
  205. //关闭窗口
  206. this.$refs.crud.$refs.dialogColumn.columnBox = false;
  207. }
  208. },
  209. },
  210. }
  211. </script>
  212. <style scoped>
  213. </style>