wbsinfo.vue 7.5 KB

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