index.vue 5.4 KB

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