wbsinfo.vue 6.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273
  1. <template>
  2. <basic-container>
  3. <avue-crud
  4. :option="option"
  5. :table-loading="loading"
  6. :data="data"
  7. :page.sync="page"
  8. :permission="permissionList"
  9. :before-open="beforeOpen"
  10. v-model="form"
  11. ref="crud"
  12. @row-update="rowUpdate"
  13. @row-save="rowSave"
  14. @row-del="rowDel"
  15. @search-change="searchChange"
  16. @search-reset="searchReset"
  17. @selection-change="selectionChange"
  18. @current-change="currentChange"
  19. @size-change="sizeChange"
  20. @refresh-change="refreshChange"
  21. @on-load="onLoad"
  22. >
  23. <template slot="menuLeft">
  24. <el-button
  25. type="danger"
  26. size="small"
  27. icon="el-icon-delete"
  28. plain
  29. v-if="permission.wbsinfo_delete"
  30. @click="handleDelete"
  31. >删 除
  32. </el-button>
  33. </template>
  34. <template
  35. slot-scope="{row,index}"
  36. slot="menu"
  37. >
  38. <el-button
  39. type="text"
  40. icon="el-icon-edit"
  41. size="mini"
  42. v-if="permission.wbsinfo_tree_edit"
  43. @click="toEdit(row,index)"
  44. >编辑wbs库</el-button>
  45. </template>
  46. </avue-crud>
  47. </basic-container>
  48. </template>
  49. <script>
  50. import { getList, getDetail, add, update, remove } from "@/api/manager/wbsinfo";
  51. import { mapGetters } from "vuex";
  52. export default {
  53. data () {
  54. return {
  55. form: {},
  56. query: {},
  57. loading: true,
  58. page: {
  59. pageSize: 20,
  60. currentPage: 1,
  61. total: 0
  62. },
  63. selectionList: [],
  64. option: {
  65. menuWidth: 300,
  66. height: 'auto',
  67. calcHeight: 30,
  68. tip: false,
  69. searchShow: true,
  70. searchMenuSpan: 6,
  71. border: true,
  72. index: true,
  73. viewBtn: true,
  74. selection: true,
  75. dialogClickModal: false,
  76. column: [
  77. {
  78. label: "创建时间",
  79. prop: "createTime",
  80. editDetail: true,
  81. addDisabled: true,
  82. },
  83. {
  84. label: "wbs名称",
  85. prop: "wbsName",
  86. rules: [{
  87. required: true,
  88. message: "请输入wbs名称",
  89. trigger: "blur"
  90. }]
  91. },
  92. {
  93. label: "划分类型",
  94. type: "select",
  95. dicUrl: "/api/blade-system/dict/dictionary?code=wbs_type",
  96. props: {
  97. label: "dictValue",
  98. value: "dictKey"
  99. },
  100. dataType: "number",
  101. prop: "wbsType",
  102. rules: [{
  103. required: true,
  104. message: "请选择划分类型",
  105. trigger: "blur"
  106. }]
  107. },
  108. {
  109. label: "是否启用",
  110. prop: "status",
  111. rules: [{
  112. required: true,
  113. message: "是否启用",
  114. trigger: "blur"
  115. }],
  116. type: "radio",
  117. dicData: [
  118. {
  119. label: "否",
  120. value: 0
  121. },
  122. {
  123. label: "是",
  124. value: 1
  125. }
  126. ],
  127. },
  128. ]
  129. },
  130. data: [],
  131. };
  132. },
  133. computed: {
  134. ...mapGetters(["permission"]),
  135. permissionList () {
  136. return {
  137. addBtn: this.vaildData(this.permission.wbsinfo_add, false),
  138. viewBtn: this.vaildData(this.permission.wbsinfo_view, false),
  139. delBtn: this.vaildData(this.permission.wbsinfo_delete, false),
  140. editBtn: this.vaildData(this.permission.wbsinfo_edit, false)
  141. };
  142. },
  143. ids () {
  144. let ids = [];
  145. this.selectionList.forEach(ele => {
  146. ids.push(ele.id);
  147. });
  148. return ids.join(",");
  149. }
  150. },
  151. methods: {
  152. rowSave (row, done, loading) {
  153. add(row).then(() => {
  154. this.onLoad(this.page);
  155. this.$message({
  156. type: "success",
  157. message: "操作成功!"
  158. });
  159. done();
  160. }, error => {
  161. loading();
  162. window.console.log(error);
  163. });
  164. },
  165. rowUpdate (row, index, done, loading) {
  166. update(row).then(() => {
  167. this.onLoad(this.page);
  168. this.$message({
  169. type: "success",
  170. message: "操作成功!"
  171. });
  172. done();
  173. }, error => {
  174. loading();
  175. console.log(error);
  176. });
  177. },
  178. rowDel (row) {
  179. this.$confirm("确定将选择数据删除?", {
  180. confirmButtonText: "确定",
  181. cancelButtonText: "取消",
  182. type: "warning"
  183. })
  184. .then(() => {
  185. return remove(row.id);
  186. })
  187. .then(() => {
  188. this.onLoad(this.page);
  189. this.$message({
  190. type: "success",
  191. message: "操作成功!"
  192. });
  193. });
  194. },
  195. handleDelete () {
  196. if (this.selectionList.length === 0) {
  197. this.$message.warning("请选择至少一条数据");
  198. return;
  199. }
  200. this.$confirm("确定将选择数据删除?", {
  201. confirmButtonText: "确定",
  202. cancelButtonText: "取消",
  203. type: "warning"
  204. })
  205. .then(() => {
  206. return remove(this.ids);
  207. })
  208. .then(() => {
  209. this.onLoad(this.page);
  210. this.$message({
  211. type: "success",
  212. message: "操作成功!"
  213. });
  214. this.$refs.crud.toggleSelection();
  215. });
  216. },
  217. beforeOpen (done, type) {
  218. if (["edit", "view"].includes(type)) {
  219. getDetail(this.form.id).then(res => {
  220. this.form = res.data.data;
  221. });
  222. }
  223. done();
  224. },
  225. searchReset () {
  226. this.query = {};
  227. this.onLoad(this.page);
  228. },
  229. searchChange (params, done) {
  230. this.query = params;
  231. this.page.currentPage = 1;
  232. this.onLoad(this.page, params);
  233. done();
  234. },
  235. selectionChange (list) {
  236. this.selectionList = list;
  237. },
  238. selectionClear () {
  239. this.selectionList = [];
  240. this.$refs.crud.toggleSelection();
  241. },
  242. currentChange (currentPage) {
  243. this.page.currentPage = currentPage;
  244. },
  245. sizeChange (pageSize) {
  246. this.page.pageSize = pageSize;
  247. },
  248. refreshChange () {
  249. this.onLoad(this.page, this.query);
  250. },
  251. onLoad (page, params = {}) {
  252. this.loading = true;
  253. getList(page.currentPage, page.pageSize, Object.assign(params, this.query)).then(res => {
  254. const data = res.data.data;
  255. this.page.total = data.total;
  256. this.data = data.records;
  257. this.loading = false;
  258. this.selectionClear();
  259. });
  260. },
  261. toEdit (row) {
  262. //console.log(row,index);
  263. this.$router.push('/wbs/edit/' + row.id);
  264. }
  265. }
  266. };
  267. </script>
  268. <style>
  269. </style>