UNPKG

@cdwx/system

Version:

成都文宣业务类服务模块组件库

269 lines (268 loc) 12.2 kB
/* empty css */ import "../workspace/code/cloud-frontend/node_modules/.pnpm/element-plus@2.9.1_vue@3.5.13_typescript@5.5.4_/node_modules/element-plus/theme-chalk/el-config-provider.css.js"; /* empty css */ /* empty css */ /* empty css */ /* empty css */ import "../workspace/code/cloud-frontend/node_modules/.pnpm/element-plus@2.9.1_vue@3.5.13_typescript@5.5.4_/node_modules/element-plus/theme-chalk/el-form-item.css.js"; /* empty css */ import { defineComponent as U, ref as m, reactive as $, onMounted as M, openBlock as r, createBlock as n, unref as i, withCtx as a, createElementVNode as f, toDisplayString as D, createElementBlock as q, createVNode as u, createCommentVNode as c, Fragment as S, renderList as j, createTextVNode as h } from "vue"; import { ElMessage as k } from "element-plus"; import z from "../workspace/code/cloud-frontend/node_modules/.pnpm/element-plus@2.9.1_vue@3.5.13_typescript@5.5.4_/node_modules/element-plus/es/locale/lang/zh-cn.js"; import { useRouter as A, useRoute as G } from "vue-router"; import { getData as H, updateData as O, saveData as J } from "../workspace/code/cloud-frontend/service-modules/system/src/api/api-role.js"; import { dataPermissionsType as K } from "../workspace/code/cloud-frontend/service-modules/system/src/config/local-data.js"; import Q from "./tree.vue.js"; import { ElInput as W } from "../workspace/code/cloud-frontend/node_modules/.pnpm/element-plus@2.9.1_vue@3.5.13_typescript@5.5.4_/node_modules/element-plus/es/components/input/index.js"; import { ElFormItem as X, ElForm as Y } from "../workspace/code/cloud-frontend/node_modules/.pnpm/element-plus@2.9.1_vue@3.5.13_typescript@5.5.4_/node_modules/element-plus/es/components/form/index.js"; import { ElRadio as Z, ElRadioGroup as ee } from "../workspace/code/cloud-frontend/node_modules/.pnpm/element-plus@2.9.1_vue@3.5.13_typescript@5.5.4_/node_modules/element-plus/es/components/radio/index.js"; import { ElButton as te } from "../workspace/code/cloud-frontend/node_modules/.pnpm/element-plus@2.9.1_vue@3.5.13_typescript@5.5.4_/node_modules/element-plus/es/components/button/index.js"; import { ElConfigProvider as oe } from "../workspace/code/cloud-frontend/node_modules/.pnpm/element-plus@2.9.1_vue@3.5.13_typescript@5.5.4_/node_modules/element-plus/es/components/config-provider/index.js"; const ae = { class: "app-box h-[calc(100%-150px)] bg-white" }, le = { class: "p-30" }, re = { class: "mb-10 flex text-20 color-[--el-text-color-primary] line-height-28" }, se = { style: { flex: "1" } }, ie = { class: "content-box pb-20" }, ne = { key: 0, class: "form-box" }, Ce = /* @__PURE__ */ U({ name: "RoleAdd", __name: "add", props: { search: {}, btn: {}, table: {}, addItem: {} }, setup(E) { const v = E, y = A(), d = G(), V = m(), t = m({ name: "", id: void 0, des: "", menuDtoList: void 0, dataPermissions: 0 }), P = $({ name: [ { required: !0, message: "请输入角色名称", trigger: "blur" } ], menuDtoList: [ { required: !0, message: "请选择角色权限", trigger: "change" } ], dataPermissions: [ { required: !0, message: "请选择角色数据权限", trigger: "change" } ] }), w = m([]), _ = m(!0); async function C() { _.value = !0; try { const { data: l } = await H(d.query.id); w.value = l.classifyMenuVoList, t.value = l; } catch { t.value = { name: "", id: void 0, des: "", menuDtoList: void 0, dataPermissions: 0 }; } _.value = !1; } const x = m(), p = m(!1); async function I() { t.value.menuDtoList = await x.value.getCheckedData(); let l = 0; if (t.value.menuDtoList && Object.values(t.value.menuDtoList).forEach((e) => { e.length > 0 && (l = l + 1); }), l <= 0) return k.error("请选择角色权限"); p.value = !0; try { t.value.id ? (await O(t.value), k.success("编辑成功"), p.value = !1, setTimeout(() => { y.replace("/system/role"); }, 1e3)) : (await J(t.value), k.success("新增成功"), p.value = !1, setTimeout(() => { y.replace("/system/role"); }, 1e3)); } catch { p.value = !1; } } async function L(l) { l && await l.validate((e, g) => { if (e) I(); else if (g) { const s = document.querySelector(".el-form-item.is-error"); s && s.scrollIntoView({ behavior: "smooth", block: "center" }); } }); } return M(async () => { d.query.id && await C(), _.value = !1; }), (l, e) => { const g = W, s = X, R = Z, F = ee, b = te, N = Y, B = oe; return r(), n(B, { locale: i(z) }, { default: a(() => [ f("div", ae, [ f("div", le, [ f("div", re, [ f("div", se, D(i(d).query.type === "show" ? "查看角色" : t.value.id ? "编辑角色" : "新增角色"), 1) ]), f("div", ie, [ _.value ? c("", !0) : (r(), q("div", ne, [ u(N, { ref_key: "formRef", ref: V, model: t.value, rules: P, "label-width": 120, class: "mt-15", "status-icon": "" }, { default: a(() => [ v.addItem.showName ? (r(), n(s, { key: 0, label: "角色名称", prop: "name" }, { default: a(() => [ u(g, { modelValue: t.value.name, "onUpdate:modelValue": e[0] || (e[0] = (o) => t.value.name = o), placeholder: "请输入角色名称", style: { width: "300px" }, maxlength: "24", clearable: !0, readonly: i(d).query.type === "show" }, null, 8, ["modelValue", "readonly"]) ]), _: 1 })) : c("", !0), v.addItem.showDes ? (r(), n(s, { key: 1, label: "角色备注" }, { default: a(() => [ u(g, { modelValue: t.value.des, "onUpdate:modelValue": e[1] || (e[1] = (o) => t.value.des = o), style: { width: "600px" }, rows: 2, type: "textarea", maxlength: "100", placeholder: "请输入角色备注信息", readonly: i(d).query.type === "show" }, null, 8, ["modelValue", "readonly"]) ]), _: 1 })) : c("", !0), v.addItem.showPermission ? (r(), n(s, { key: 2, label: "角色权限", required: "" }, { default: a(() => [ u(Q, { ref_key: "permissionRef", ref: x, modelValue: w.value, "onUpdate:modelValue": e[2] || (e[2] = (o) => w.value = o), disabled: i(d).query.type === "show" }, null, 8, ["modelValue", "disabled"]) ]), _: 1 })) : c("", !0), v.addItem.showDataPermission ? (r(), n(s, { key: 3, label: "角色数据权限", prop: "dataPermissions" }, { default: a(() => [ u(F, { modelValue: t.value.dataPermissions, "onUpdate:modelValue": e[3] || (e[3] = (o) => t.value.dataPermissions = o) }, { default: a(() => [ (r(!0), q(S, null, j(i(K), (o, T) => (r(), n(R, { key: T, value: o.value }, { default: a(() => [ h(D(o.label), 1) ]), _: 2 }, 1032, ["value"]))), 128)) ]), _: 1 }, 8, ["modelValue"]) ]), _: 1 })) : c("", !0), i(d).query.type === "show" ? (r(), n(s, { key: 4, class: "mt-10" }, { default: a(() => [ u(b, { class: "w-108 line-height-30", onClick: e[4] || (e[4] = (o) => i(y).go(-1)) }, { default: a(() => e[7] || (e[7] = [ h(" 返回 ") ])), _: 1 }) ]), _: 1 })) : (r(), n(s, { key: 5, class: "mt-10" }, { default: a(() => [ u(b, { type: "primary", class: "w-108 line-height-30", loading: p.value, onClick: e[5] || (e[5] = (o) => L(V.value)) }, { default: a(() => e[8] || (e[8] = [ h(" 保存 ") ])), _: 1 }, 8, ["loading"]), u(b, { class: "w-108 line-height-30", onClick: e[6] || (e[6] = (o) => i(y).go(-1)) }, { default: a(() => e[9] || (e[9] = [ h(" 取消 ") ])), _: 1 }) ]), _: 1 })) ]), _: 1 }, 8, ["model", "rules"]) ])) ]) ]) ]) ]), _: 1 }, 8, ["locale"]); }; } }); export { Ce as default };