wbsinfo.vue 6.6 KB

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