orgdept.vue 13 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368
  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. <template slot-scope="{ row, index }" slot="menu">
  21. <el-button type="text" size="small" @click="excludeRegion(row)" icon="el-icon-view">排除行政区划
  22. </el-button>
  23. <el-button type="text" size="small" @click="resetRegion(row)" icon="el-icon-view">重置行政区划
  24. </el-button>
  25. </template>
  26. </avue-crud>
  27. </basic-container>
  28. </el-col>
  29. </el-row>
  30. <el-dialog title="排除行政机构" :visible.sync="excludeRegionDialog" width="60%" height="60%" :close-on-click-modal="false"
  31. append-to-body v-if="excludeRegionDialog">
  32. <avue-form ref="excludeRegionRef" :option="excludeRegionOption" v-model="excludeRegionForm"
  33. @submit="addCheckOrder" />
  34. <span slot="footer" class="dialog-footer">
  35. <el-button @click="excludeRegionDialog = false" size="small">取 消</el-button>
  36. <el-button type="primary" @click="excludeRegionSubmit" size="small">提 交</el-button>
  37. </span>
  38. </el-dialog>
  39. </div>
  40. </template>
  41. <script>
  42. import { getPage, getDetail, add, update, remove } from "@/api/baseinfo/org.js";
  43. import { excludeRegion, resetRegion } from "@/api/baseinfo/region.js";
  44. export default {
  45. components: {
  46. },
  47. data() {
  48. return {
  49. id: "",
  50. editForm: {},
  51. editDialog: false,
  52. excludeRegionDialog: false,
  53. excludeRegionTreeData: [],
  54. excludeRegionForm: {
  55. deptId: 0,
  56. adcd: '',
  57. },
  58. excludeRegionOption: {
  59. labelWidth: 180,
  60. emptyBtn: false,
  61. submitBtn: false,
  62. column: [
  63. {
  64. label: "运维行政区划",
  65. prop: "adcd",
  66. span: 24,
  67. editDisplay: false,
  68. accordion: true,
  69. type: "tree",
  70. //dictData: [],
  71. //dicUrl: `./api/galaxy-business/baseinfo/region/original/tree/` + this.adCode,
  72. defaultExpandAll: true,
  73. props: {
  74. label: "title",
  75. value: "value",
  76. },
  77. rules: [
  78. {
  79. required: true,
  80. message: "请选择运维的行政区划",
  81. trigger: "click",
  82. },
  83. ],
  84. },
  85. ]
  86. },
  87. form: {},
  88. selectionList: [],
  89. query: {},
  90. loading: true,
  91. page: {
  92. pageSize: 10,
  93. currentPage: 1,
  94. total: 0,
  95. },
  96. option: {
  97. labelWidth: 140,
  98. viewLabelWidth: 140,
  99. searchlabelWidth: 140,
  100. height: "auto",
  101. calcHeight: 80,
  102. align: "center",
  103. headerAlign: "center",
  104. tip: false,
  105. simplePage: true,
  106. searchShow: true,
  107. searchMenuSpan: 6,
  108. border: true,
  109. index: true,
  110. selection: false,
  111. viewBtn: false,
  112. viewTitle: "运维人员信息",
  113. editBtn: true,
  114. delBtn: true,
  115. menuWidth: 300,
  116. dialogType: "drawer",
  117. dialogClickModal: false,
  118. columnBtn: false,
  119. addBtnText: "新增盟市",
  120. column: [
  121. {
  122. label: "盟市全称",
  123. prop: "deptName",
  124. span: 24,
  125. search: true,
  126. rules: [
  127. {
  128. required: true,
  129. message: "请录入盟市全称",
  130. trigger: "click",
  131. },
  132. ],
  133. },
  134. {
  135. label: "运维行政区划",
  136. prop: "adcd",
  137. span: 24,
  138. hide: true,
  139. editDisplay: false,
  140. accordion: true,
  141. type: "tree",
  142. dicUrl: `./api/galaxy-business/baseinfo/region/original/tree`,
  143. props: {
  144. label: "title",
  145. value: "value",
  146. },
  147. rules: [
  148. {
  149. required: true,
  150. message: "请选择运维的行政区划",
  151. trigger: "click",
  152. },
  153. ],
  154. },
  155. {
  156. label: "运维行政区划",
  157. prop: "adnm",
  158. span: 24,
  159. editDisabled: true,
  160. addDisplay: false,
  161. },
  162. {
  163. label: "备注说明",
  164. prop: "remark",
  165. span: 24,
  166. type: "textarea",
  167. },
  168. ],
  169. },
  170. data: [],
  171. };
  172. },
  173. computed: {
  174. // ...mapGetters(["userInfo", "permission"]),
  175. permissionList() {
  176. return {
  177. // addBtn: this.vaildData(this.permission.docCategory_add, false),
  178. // viewBtn: this.vaildData(this.permission.docCategory_view, false),
  179. // delBtn: this.vaildData(this.permission.docCategory_delete, false),
  180. // editBtn: this.vaildData(this.permission.docCategory_edit, false),
  181. };
  182. },
  183. ids() {
  184. let ids = [];
  185. this.selectionList.forEach((ele) => {
  186. ids.push(ele.id);
  187. });
  188. return ids.join(",");
  189. },
  190. },
  191. mounted() { },
  192. created() {
  193. },
  194. methods: {
  195. excludeRegion(row) {
  196. this.excludeRegionForm['deptId'] = row.id;
  197. let dicUrl = `./api/galaxy-business/baseinfo/region/original/tree/` + row.adcd;
  198. let column = this.findObject(this.excludeRegionOption.column, "adcd")
  199. column.value = ''
  200. column.dicUrl = dicUrl
  201. column.display = true;
  202. //this.excludeRegionTreeData = [];
  203. // getOriginalSubTree(row.adcd).then(res => {
  204. // console.log(JSON.stringify(res.data))
  205. // this.excludeRegionTreeData = res.data.data.map(item => {
  206. // return {
  207. // ...item,
  208. // leaf: !item.hasChildren
  209. // }
  210. // })
  211. // let column = this.findObject(this.excludeRegionOption.column, "adcd")
  212. // column.dictData = this.excludeRegionTreeData
  213. // column.display = true;
  214. // });
  215. this.excludeRegionDialog = true;
  216. },
  217. resetRegion(row) {
  218. resetRegion({ 'adcd': row.adcd, 'deptId': row.id }).then(res => {
  219. console.log(JSON.stringify(res))
  220. if (res.data.success) {
  221. this.$message({
  222. type: "success",
  223. message: "操作成功!",
  224. });
  225. }
  226. });
  227. },
  228. excludeRegionSubmit() {
  229. excludeRegion(this.excludeRegionForm).then(res => {
  230. console.log(JSON.stringify(res))
  231. this.excludeRegionDialog = false;
  232. this.$message({
  233. type: "success",
  234. message: "操作成功!",
  235. });
  236. });
  237. },
  238. rowSave(row, done, loading) {
  239. add(row).then(
  240. () => {
  241. this.onLoad(this.page);
  242. this.$message({
  243. type: "success",
  244. message: "操作成功!",
  245. });
  246. done();
  247. },
  248. (error) => {
  249. window.console.log(error);
  250. loading();
  251. }
  252. );
  253. },
  254. rowUpdate(row, index, done, loading) {
  255. update(row).then(
  256. () => {
  257. this.onLoad(this.page);
  258. this.$message({
  259. type: "success",
  260. message: "操作成功!",
  261. });
  262. done();
  263. },
  264. (error) => {
  265. window.console.log(error);
  266. loading();
  267. }
  268. );
  269. },
  270. rowDel(row) {
  271. this.$confirm("确定将选择数据删除?", {
  272. confirmButtonText: "确定",
  273. cancelButtonText: "取消",
  274. type: "warning",
  275. })
  276. .then(() => {
  277. return remove(row.id);
  278. })
  279. .then(() => {
  280. this.onLoad(this.page);
  281. this.$message({
  282. type: "success",
  283. message: "操作成功!",
  284. });
  285. });
  286. },
  287. searchReset() {
  288. this.query = {};
  289. this.onLoad(this.page);
  290. },
  291. searchChange(params, done) {
  292. this.query = params;
  293. this.page.currentPage = 1;
  294. this.onLoad(this.page, params);
  295. done();
  296. },
  297. selectionChange(list) {
  298. this.selectionList = list;
  299. },
  300. selectChange(item) {
  301. console.log(item)
  302. },
  303. selectionClear() {
  304. this.selectionList = [];
  305. this.$refs.crud.toggleSelection();
  306. },
  307. handleDelete() {
  308. if (this.selectionList.length === 0) {
  309. this.$message.warning("请选择至少一条数据");
  310. return;
  311. }
  312. this.$confirm("确定将选择数据删除?", {
  313. confirmButtonText: "确定",
  314. cancelButtonText: "取消",
  315. type: "warning",
  316. })
  317. .then(() => {
  318. return remove(this.ids);
  319. })
  320. .then(() => {
  321. this.onLoad(this.page);
  322. this.$message({
  323. type: "success",
  324. message: "操作成功!",
  325. });
  326. this.$refs.crud.toggleSelection();
  327. });
  328. },
  329. beforeOpen(done, type) {
  330. if (["edit", "view"].includes(type)) {
  331. getDetail(this.form.id).then((res) => {
  332. this.form = res.data.data;
  333. });
  334. }
  335. done();
  336. },
  337. currentChange(currentPage) {
  338. this.page.currentPage = currentPage;
  339. },
  340. sizeChange(pageSize) {
  341. this.page.pageSize = pageSize;
  342. },
  343. refreshChange() {
  344. this.onLoad(this.page, this.query);
  345. },
  346. onLoad(page, params = {}) {
  347. this.loading = true;
  348. getPage(
  349. page.currentPage,
  350. page.pageSize,
  351. Object.assign(params, this.query)
  352. ).then((res) => {
  353. const data = res.data.data;
  354. this.page.total = data.total;
  355. this.data = data.records;
  356. this.loading = false;
  357. this.selectionClear();
  358. });
  359. },
  360. },
  361. };
  362. </script>