PermissionOrganization-ByhFVwBE.js 13 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404
  1. import j from './ContentContainer-BF98H707.js';
  2. import { _ as A, B as M } from './Modal-5FpMAvV9.js';
  3. import { T as Q } from './TreeParts-YNkYa4Hd.js';
  4. import {
  5. ab as x,
  6. c as $,
  7. o as B,
  8. g as P,
  9. w as l,
  10. f as a,
  11. j as u,
  12. x as E,
  13. A as b,
  14. r as S,
  15. b as G,
  16. m as H,
  17. ac as J,
  18. B as y,
  19. a1 as K,
  20. d as W,
  21. e as F,
  22. s as X,
  23. i as O,
  24. t as T
  25. } from './index-Q0E3WkDV.js';
  26. import { a as Y } from './common-C2h3Dl9G.js';
  27. import { _ as Z } from './_plugin-vue_export-helper-DlAUqK2U.js';
  28. const q = {
  29. __name: 'OrgForm',
  30. props: {
  31. org_form: {
  32. type: Object,
  33. required: !0,
  34. default: () => ({ parentName: '', status: 0, deptName: '', leader: '', phone: '', address: '' })
  35. }
  36. },
  37. emits: ['statusChange'],
  38. setup(r, { emit: _ }) {
  39. const m = _,
  40. I = r,
  41. { org_form: o } = x(I),
  42. e = (d) => {
  43. m('statusChange', d);
  44. };
  45. return (d, n) => {
  46. const g = $('a-input'),
  47. c = $('a-form-item'),
  48. U = $('a-switch'),
  49. D = $('a-space'),
  50. k = $('a-form');
  51. return (
  52. B(),
  53. P(
  54. k,
  55. { model: u(o), layout: 'horizontal', ref: 'formRef' },
  56. {
  57. default: l(() => [
  58. a(
  59. c,
  60. { field: 'parentName', label: d.$t('permission.org.parent_org'), disabled: '' },
  61. {
  62. default: l(() => [
  63. a(
  64. g,
  65. {
  66. modelValue: u(o).parentName,
  67. 'onUpdate:modelValue': n[0] || (n[0] = (i) => (u(o).parentName = i))
  68. },
  69. null,
  70. 8,
  71. ['modelValue']
  72. )
  73. ]),
  74. _: 1
  75. },
  76. 8,
  77. ['label']
  78. ),
  79. a(
  80. c,
  81. { field: 'status', label: d.$t('permission.org.status') },
  82. {
  83. default: l(() => [
  84. a(
  85. U,
  86. {
  87. modelValue: u(o).status,
  88. 'onUpdate:modelValue': n[1] || (n[1] = (i) => (u(o).status = i)),
  89. onChange: n[2] || (n[2] = (i) => e(u(o).status)),
  90. 'checked-value': '1',
  91. 'unchecked-value': '0'
  92. },
  93. null,
  94. 8,
  95. ['modelValue']
  96. )
  97. ]),
  98. _: 1
  99. },
  100. 8,
  101. ['label']
  102. ),
  103. a(
  104. c,
  105. {
  106. field: 'deptName',
  107. label: d.$t('permission.org.org_name'),
  108. rules: [
  109. { required: !0, message: '机构名称必填' },
  110. { maxLength: 50, message: '长度不超过50' }
  111. ]
  112. },
  113. {
  114. default: l(() => [
  115. a(
  116. g,
  117. {
  118. modelValue: u(o).deptName,
  119. 'onUpdate:modelValue': n[3] || (n[3] = (i) => (u(o).deptName = i))
  120. },
  121. null,
  122. 8,
  123. ['modelValue']
  124. )
  125. ]),
  126. _: 1
  127. },
  128. 8,
  129. ['label']
  130. ),
  131. a(
  132. c,
  133. {
  134. field: 'leader',
  135. label: d.$t('permission.org.leader'),
  136. rules: [
  137. { required: !0, message: '联系人必填' },
  138. { maxLength: 50, message: '长度不超过50' }
  139. ]
  140. },
  141. {
  142. default: l(() => [
  143. a(
  144. g,
  145. { modelValue: u(o).leader, 'onUpdate:modelValue': n[4] || (n[4] = (i) => (u(o).leader = i)) },
  146. null,
  147. 8,
  148. ['modelValue']
  149. )
  150. ]),
  151. _: 1
  152. },
  153. 8,
  154. ['label']
  155. ),
  156. a(
  157. c,
  158. {
  159. field: 'phone',
  160. label: d.$t('permission.org.phone'),
  161. rules: [
  162. { required: !0, message: '联系电话必填' },
  163. { maxLength: 50, message: '长度不超过50' }
  164. ]
  165. },
  166. {
  167. default: l(() => [
  168. a(
  169. g,
  170. { modelValue: u(o).phone, 'onUpdate:modelValue': n[5] || (n[5] = (i) => (u(o).phone = i)) },
  171. null,
  172. 8,
  173. ['modelValue']
  174. )
  175. ]),
  176. _: 1
  177. },
  178. 8,
  179. ['label']
  180. ),
  181. a(
  182. c,
  183. { field: 'address', label: d.$t('permission.org.address') },
  184. {
  185. default: l(() => [
  186. a(
  187. g,
  188. { modelValue: u(o).address, 'onUpdate:modelValue': n[6] || (n[6] = (i) => (u(o).address = i)) },
  189. null,
  190. 8,
  191. ['modelValue']
  192. )
  193. ]),
  194. _: 1
  195. },
  196. 8,
  197. ['label']
  198. ),
  199. a(c, null, {
  200. default: l(() => [a(D, null, { default: l(() => [E(d.$slots, 'actions')]), _: 3 })]),
  201. _: 3
  202. })
  203. ]),
  204. _: 3
  205. },
  206. 8,
  207. ['model']
  208. )
  209. );
  210. };
  211. }
  212. },
  213. V = '/api/dept';
  214. function ee(r) {
  215. return b({ url: `${V}/${r}`, method: 'get' });
  216. }
  217. function te(r) {
  218. return b({ url: `${V}/status`, method: 'put', data: r });
  219. }
  220. function ae(r) {
  221. return b({ url: `${V}/edit_dept`, method: 'put', data: r });
  222. }
  223. function se(r) {
  224. return b({ url: `${V}/dept_parent`, method: 'put', data: r });
  225. }
  226. function oe(r) {
  227. return b({ url: `${V}/add_dept`, method: 'post', data: r });
  228. }
  229. function ne(r) {
  230. return b({ url: `${V}/${r}`, method: 'delete' });
  231. }
  232. const re = { class: 'organization-container' },
  233. le = { class: 'left' },
  234. de = { class: 'right' },
  235. ie = {
  236. __name: 'index',
  237. setup(r) {
  238. const _ = S(!1),
  239. m = S(!0),
  240. I = S([]),
  241. o = { add_permission: 'system:dept:add', delete_permission: 'system:dept:delete' },
  242. e = G({ parentName: '', status: 0, deptName: '', leader: '', phone: '', address: '', orderNum: 0 }),
  243. d = async () => {
  244. const {
  245. code: t,
  246. data: { rows: s }
  247. } = await Y();
  248. t == 200 && (I.value = s);
  249. },
  250. n = async (t) => {
  251. const {
  252. data: { data: s }
  253. } = await ee(t);
  254. (e.deptId = t),
  255. (e.parentName = s.parentName),
  256. (e.status = s.status),
  257. (e.deptName = s.deptName),
  258. (e.leader = s.leader),
  259. (e.phone = s.phone),
  260. (e.address = s.address),
  261. (m.value = !0);
  262. },
  263. g = (t) => {
  264. (e.deptId = ''),
  265. (e.parentName = t.deptName),
  266. (e.parentId = t.deptId),
  267. (e.status = 0),
  268. (e.deptName = ''),
  269. (e.leader = ''),
  270. (e.phone = ''),
  271. (e.address = ''),
  272. (_.value = !0),
  273. (m.value = !1);
  274. },
  275. c = async ({ deptId: t }) => {
  276. const { code: s } = await ne(t);
  277. s === 200 && y.success({ title: '删除', content: '删除成功' }), d();
  278. },
  279. U = async (t) => {
  280. const s = { deptId: e.deptId[0], status: t },
  281. { code: f, msg: p } = await te(s);
  282. f === 200
  283. ? (y.success({ title: '状态更新', content: '状态更新成功' }), d())
  284. : (y.error({ title: '状态更新', content: p }), (e.status = '1'));
  285. },
  286. D = async () => {
  287. const t = { ...e, deptId: m.value && e.deptId ? e.deptId[0] : null },
  288. s = m.value ? ae : oe,
  289. { code: f } = await s(t);
  290. if (f === 200) {
  291. const p = m.value ? '编辑' : '新增';
  292. y.success({ title: `${p}用户`, content: `${p}成功` }), d(), (_.value = !1);
  293. }
  294. },
  295. k = () => {
  296. (e.deptId = null),
  297. (e.parentName = ''),
  298. (e.status = 0),
  299. (e.deptName = ''),
  300. (e.leader = ''),
  301. (e.phone = ''),
  302. (e.address = '');
  303. },
  304. i = () => {
  305. (m.value = !0), (_.value = !1);
  306. },
  307. z = async ({ dropNode: t, dragNode: s, dropPosition: f }) => {
  308. const p = I.value;
  309. se({ orderNum: '0', parentId: t.deptId, deptId: s.deptId });
  310. const N = (h, v, C) => {
  311. h.some((w, L, R) => (w.deptId === v ? (C(w, L, R), !0) : w.children ? N(w.children, v, C) : !1));
  312. };
  313. N(p, s.deptId, (h, v, C) => {
  314. C.splice(v, 1);
  315. }),
  316. f === 0
  317. ? N(p, t.deptId, (h) => {
  318. (h.children = h.children || []), h.children.push(s);
  319. })
  320. : N(p, t.deptId, (h, v, C) => {
  321. C.splice(f < 0 ? v : v + 1, 0, s);
  322. });
  323. };
  324. return (
  325. H(() => {
  326. J('system:dept:list') ? d() : y.error({ title: '权限不足', content: '抱歉,您没有权限查看该页面' });
  327. }),
  328. (t, s) => {
  329. const f = $('a-button'),
  330. p = $('a-card'),
  331. N = K('hasPerm');
  332. return (
  333. B(),
  334. W('div', re, [
  335. F('div', le, [
  336. a(
  337. Q,
  338. {
  339. treeData: I.value,
  340. title: t.$t('permission.org.organization'),
  341. showLock: !0,
  342. fieldNames: { key: 'deptId', title: 'deptName', children: 'children' },
  343. permission: o,
  344. onNodeClick: n,
  345. onAddBtnClick: g,
  346. onDeleteBtnClick: c,
  347. onDrop: z
  348. },
  349. null,
  350. 8,
  351. ['treeData', 'title']
  352. )
  353. ]),
  354. F('div', de, [
  355. a(
  356. p,
  357. { title: t.$t('permission.org.details'), style: { height: '100%' } },
  358. {
  359. default: l(() => [
  360. a(
  361. q,
  362. { org_form: e, onStatusChange: U, onSave: D, onReset: k },
  363. {
  364. actions: l(() => [
  365. X(
  366. (B(),
  367. P(f, { onClick: D }, { default: l(() => [O(T(t.$t('permission.org.save')), 1)]), _: 1 })),
  368. [[N, 'system:dept:edit']]
  369. ),
  370. a(f, { onClick: k }, { default: l(() => [O(T(t.$t('permission.org.reset')), 1)]), _: 1 })
  371. ]),
  372. _: 1
  373. },
  374. 8,
  375. ['org_form']
  376. )
  377. ]),
  378. _: 1
  379. },
  380. 8,
  381. ['title']
  382. )
  383. ]),
  384. a(
  385. A,
  386. { visible: _.value, onOk: D, onCancel: i, title: t.$t('permission.org.add') },
  387. { default: l(() => [a(q, { org_form: e }, null, 8, ['org_form'])]), _: 1 },
  388. 8,
  389. ['visible', 'title']
  390. )
  391. ])
  392. );
  393. }
  394. );
  395. }
  396. },
  397. ue = Z(ie, [['__scopeId', 'data-v-5fddc97d']]),
  398. he = {
  399. __name: 'PermissionOrganization',
  400. setup(r) {
  401. return (_, m) => (B(), P(j, null, { default: l(() => [a(M, { current_label: '机构' }), a(ue)]), _: 1 }));
  402. }
  403. };
  404. export { he as default };