indexF.vue 4.7 KB

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