companydept.vue 7.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252
  1. <!--
  2. * @Title:
  3. * @Description: 运维公司机构管理
  4. * @Author: swp
  5. * @Date: 2022-08-24 10:49:21
  6. * @LastEditors:
  7. * @LastEditTime: 2022-08-24 10:49:21
  8. -->
  9. <template>
  10. <div>
  11. <el-row>
  12. <el-col :span="24">
  13. <basic-container>
  14. <avue-crud :option="option" :table-loading="loading" :data="data" :page.sync="page"
  15. :before-open="beforeOpen" ref="crud" v-model="form" :permission="permissionList" @row-del="rowDel"
  16. @row-update="rowUpdate" @row-save="rowSave" @search-change="searchChange"
  17. @search-reset="searchReset" @selection-change="selectionChange" @current-change="currentChange"
  18. @size-change="sizeChange" @refresh-change="refreshChange" @on-load="onLoad"
  19. @before-open="beforeOpen" @select-change="selectChange">
  20. </avue-crud>
  21. </basic-container>
  22. </el-col>
  23. </el-row>
  24. </div>
  25. </template>
  26. <script>
  27. import { getPage, getDetail, add, update, remove } from "@/api/baseinfo/org.js";
  28. export default {
  29. components: {
  30. },
  31. data() {
  32. return {
  33. id: "",
  34. editForm: {},
  35. editDialog: false,
  36. form: {},
  37. selectionList: [],
  38. query: {},
  39. loading: true,
  40. page: {
  41. pageSize: 10,
  42. currentPage: 1,
  43. total: 0,
  44. },
  45. option: {
  46. labelWidth: 140,
  47. viewLabelWidth: 140,
  48. searchLabelWidth: 140,
  49. height: "auto",
  50. calcHeight: 80,
  51. align: "center",
  52. headerAlign: "center",
  53. tip: false,
  54. simplePage: true,
  55. searchShow: true,
  56. searchMenuSpan: 6,
  57. border: true,
  58. index: true,
  59. selection: false,
  60. viewBtn: false,
  61. viewTitle: "运维人员信息",
  62. editBtn: true,
  63. delBtn: true,
  64. menuWidth: 220,
  65. dialogType: "drawer",
  66. dialogClickModal: false,
  67. columnBtn: false,
  68. addBtnText: "新增运维单位",
  69. column: [
  70. {
  71. label: "运维单位全称",
  72. prop: "deptName",
  73. span: 24,
  74. search: true,
  75. rules: [
  76. {
  77. required: true,
  78. message: "请录入运维单位全称",
  79. trigger: "click",
  80. },
  81. ],
  82. },
  83. {
  84. label: "运维行政区划",
  85. prop: "adnm",
  86. span: 24,
  87. editDisabled: true,
  88. addDisplay: false,
  89. },
  90. {
  91. label: "备注说明",
  92. prop: "remark",
  93. span: 24,
  94. type: "textarea",
  95. },
  96. ],
  97. },
  98. data: [],
  99. };
  100. },
  101. computed: {
  102. // ...mapGetters(["userInfo", "permission"]),
  103. permissionList() {
  104. return {
  105. // addBtn: this.vaildData(this.permission.docCategory_add, false),
  106. // viewBtn: this.vaildData(this.permission.docCategory_view, false),
  107. // delBtn: this.vaildData(this.permission.docCategory_delete, false),
  108. // editBtn: this.vaildData(this.permission.docCategory_edit, false),
  109. };
  110. },
  111. ids() {
  112. let ids = [];
  113. this.selectionList.forEach((ele) => {
  114. ids.push(ele.id);
  115. });
  116. return ids.join(",");
  117. },
  118. },
  119. mounted() { },
  120. created() {
  121. },
  122. methods: {
  123. rowSave(row, done, loading) {
  124. add(row).then(
  125. () => {
  126. this.onLoad(this.page);
  127. this.$message({
  128. type: "success",
  129. message: "操作成功!",
  130. });
  131. done();
  132. },
  133. (error) => {
  134. window.console.log(error);
  135. loading();
  136. }
  137. );
  138. },
  139. rowUpdate(row, index, done, loading) {
  140. update(row).then(
  141. () => {
  142. this.onLoad(this.page);
  143. this.$message({
  144. type: "success",
  145. message: "操作成功!",
  146. });
  147. done();
  148. },
  149. (error) => {
  150. window.console.log(error);
  151. loading();
  152. }
  153. );
  154. },
  155. rowDel(row) {
  156. this.$confirm("确定将选择数据删除?", {
  157. confirmButtonText: "确定",
  158. cancelButtonText: "取消",
  159. type: "warning",
  160. })
  161. .then(() => {
  162. return remove(row.id);
  163. })
  164. .then(() => {
  165. this.onLoad(this.page);
  166. this.$message({
  167. type: "success",
  168. message: "操作成功!",
  169. });
  170. });
  171. },
  172. searchReset() {
  173. this.query = {};
  174. this.onLoad(this.page);
  175. },
  176. searchChange(params, done) {
  177. this.query = params;
  178. this.page.currentPage = 1;
  179. this.onLoad(this.page, params);
  180. done();
  181. },
  182. selectionChange(list) {
  183. this.selectionList = list;
  184. },
  185. selectChange(item) {
  186. console.log(item)
  187. },
  188. selectionClear() {
  189. this.selectionList = [];
  190. this.$refs.crud.toggleSelection();
  191. },
  192. handleDelete() {
  193. if (this.selectionList.length === 0) {
  194. this.$message.warning("请选择至少一条数据");
  195. return;
  196. }
  197. this.$confirm("确定将选择数据删除?", {
  198. confirmButtonText: "确定",
  199. cancelButtonText: "取消",
  200. type: "warning",
  201. })
  202. .then(() => {
  203. return remove(this.ids);
  204. })
  205. .then(() => {
  206. this.onLoad(this.page);
  207. this.$message({
  208. type: "success",
  209. message: "操作成功!",
  210. });
  211. this.$refs.crud.toggleSelection();
  212. });
  213. },
  214. beforeOpen(done, type) {
  215. if (["edit", "view"].includes(type)) {
  216. getDetail(this.form.id).then((res) => {
  217. this.form = res.data.data;
  218. });
  219. }
  220. done();
  221. },
  222. currentChange(currentPage) {
  223. this.page.currentPage = currentPage;
  224. },
  225. sizeChange(pageSize) {
  226. this.page.pageSize = pageSize;
  227. },
  228. refreshChange() {
  229. this.onLoad(this.page, this.query);
  230. },
  231. onLoad(page, params = {}) {
  232. this.loading = true;
  233. getPage(
  234. page.currentPage,
  235. page.pageSize,
  236. Object.assign(params, this.query)
  237. ).then((res) => {
  238. const data = res.data.data;
  239. this.page.total = data.total;
  240. this.data = data.records;
  241. this.loading = false;
  242. this.selectionClear();
  243. });
  244. },
  245. },
  246. };
  247. </script>