UNPKG

@cdwx/system

Version:

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

303 lines (302 loc) 12.6 kB
/* empty css */ /* empty css */ /* empty css */ /* empty css */ /* empty css */ /* empty css */ /* empty css */ /* empty css */ /* 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 q, mergeModels as k, ref as f, useModel as O, computed as R, onMounted as x, reactive as j, openBlock as r, createBlock as u, withModifiers as z, withCtx as s, createVNode as n, createCommentVNode as i, createElementBlock as T, Fragment as E, renderList as N, createElementVNode as G, createTextVNode as U, toDisplayString as H } from "vue"; import { regular as J } from "../workspace/code/cloud-frontend/packages/config/src/regular.js"; import { ElMessage as C } from "element-plus"; import { getAllUser as K } from "../workspace/code/cloud-frontend/service-modules/system/src/api/api-account.js"; import { getAll as Q, updateData as W, saveData as X } from "../workspace/code/cloud-frontend/service-modules/system/src/api/api-department.js"; import { ElInput 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/input/index.js"; import { ElFormItem as Z, ElForm 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/form/index.js"; import { ElTreeSelect as le } 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/tree-select/index.js"; import { ElOption as ae, ElSelect 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/select/index.js"; import { ElButton 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/button/index.js"; const re = { class: "flex flex-1 justify-end" }, Ce = /* @__PURE__ */ q({ name: "Add", __name: "add", props: /* @__PURE__ */ k({ rules: {}, dialogType: {} }, { modelValue: { required: !0 }, modelModifiers: {} }), emits: /* @__PURE__ */ k(["close"], ["update:modelValue"]), setup(y, { emit: L }) { const o = y, A = L, b = f(), l = f({ des: "", masterIds: [], id: void 0, parentId: void 0, phone: "", name: "" }), h = O(y, "modelValue"), d = R({ get() { return h.value; }, set(a) { h.value = a; } }); x(() => { d.value && (l.value = d.value); }); const D = j({ name: [ { required: !0, message: `请输入${o.rules.customName || "部门"}名称`, trigger: ["blur", "change"] } ], masterIds: [ { required: !0, message: "请选择负责人", trigger: ["blur", "change"] } ], phone: [ { pattern: J.tel.reg, message: "请输入正确的固话号码", trigger: ["blur", "change"], transform(a) { return a.trim(); } } ] }), V = f([]), v = f([]); async function M() { try { const { data: a } = await Q(); V.value = a; } catch (a) { console.log(a); } } async function $() { try { const { data: a } = await K(sessionStorage.getItem("siteCode") || ""); v.value = a; } catch (a) { console.log(a); } } const p = f(!1); function P(a) { !a || p.value || a.validate((e) => { e && S(); }); } async function S() { p.value = !0; try { Array.isArray(l.value.masterIds) || (l.value.masterIds = l.value.masterIds === void 0 ? [] : [l.value.masterIds]), l.value.id ? (await W(l.value), C.success("编辑成功")) : (await X(l.value), C.success("新增成功")), A("close"); } catch (a) { console.log(a); } finally { p.value = !1; } } return x(async () => { if (await M(), await $(), d.value) { const a = []; if (d.value.deptUserVoList && d.value.deptUserVoList.forEach((e) => { a.push(e.userId); }), o.rules.showChargePhone) d.value.masterIds = a; else { const [e] = a; d.value.masterIds = e; } l.value = d.value; } }), (a, e) => { const c = Y, m = Z, B = le, w = ae, I = te, _ = oe, F = ee; return r(), u(F, { ref_key: "formRef", ref: b, "label-width": "80px", rules: D, model: l.value, onSubmit: e[8] || (e[8] = z(() => { }, ["prevent"])) }, { default: s(() => [ o.rules.showName ? (r(), u(m, { key: 0, label: `${o.rules.customName || "部门"}名称`, prop: "name" }, { default: s(() => [ n(c, { modelValue: l.value.name, "onUpdate:modelValue": e[0] || (e[0] = (t) => l.value.name = t), placeholder: `请输入${o.rules.customName || "部门"}名称`, maxlength: "30", clearable: "", readonly: o.dialogType === "show" }, null, 8, ["modelValue", "placeholder", "readonly"]) ]), _: 1 }, 8, ["label"])) : i("", !0), o.rules.showParentId ? (r(), u(m, { key: 1, label: "上级组织" }, { default: s(() => [ n(B, { modelValue: l.value.parentId, "onUpdate:modelValue": e[1] || (e[1] = (t) => l.value.parentId = t), data: V.value, props: { label: "name", value: "id", children: "subList" }, "value-key": "id", clearable: "", "check-strictly": "", placeholder: "请选择", "render-after-expand": !1, disabled: o.dialogType === "show" }, null, 8, ["modelValue", "data", "disabled"]) ]), _: 1 })) : i("", !0), o.rules.showChargePhone ? (r(), u(m, { key: 2, label: "负责人" }, { default: s(() => [ n(I, { modelValue: l.value.masterIds, "onUpdate:modelValue": e[2] || (e[2] = (t) => l.value.masterIds = t), filterable: "", multiple: "", "multiple-limit": 3, placeholder: "请选择负责人", disabled: o.dialogType === "show" }, { default: s(() => [ (r(!0), T(E, null, N(v.value, (t, g) => (r(), u(w, { key: g, label: t.realName, value: t.id }, null, 8, ["label", "value"]))), 128)) ]), _: 1 }, 8, ["modelValue", "disabled"]) ]), _: 1 })) : i("", !0), o.rules.showPhone ? (r(), u(m, { key: 3, label: "负责人" }, { default: s(() => [ n(I, { modelValue: l.value.masterIds, "onUpdate:modelValue": e[3] || (e[3] = (t) => l.value.masterIds = t), filterable: "", placeholder: "请选择负责人", disabled: o.dialogType === "show" }, { default: s(() => [ (r(!0), T(E, null, N(v.value, (t, g) => (r(), u(w, { key: g, label: t.realName, value: t.id }, null, 8, ["label", "value"]))), 128)) ]), _: 1 }, 8, ["modelValue", "disabled"]) ]), _: 1 })) : i("", !0), o.rules.showPhone ? (r(), u(m, { key: 4, label: "办公电话", prop: "phone" }, { default: s(() => [ n(c, { modelValue: l.value.phone, "onUpdate:modelValue": e[4] || (e[4] = (t) => l.value.phone = t), placeholder: "请输入办公电话", type: "text", maxlength: "11", "auto-complete": "false", clearable: "", readonly: o.dialogType === "show" }, null, 8, ["modelValue", "readonly"]) ]), _: 1 })) : i("", !0), o.rules.showDes ? (r(), u(m, { key: 5, label: "描述", prop: "des" }, { default: s(() => [ n(c, { modelValue: l.value.des, "onUpdate:modelValue": e[5] || (e[5] = (t) => l.value.des = t), placeholder: "请输入描述信息", rows: 4, type: "textarea", maxlength: "100", clearable: "", readonly: o.dialogType === "show" }, null, 8, ["modelValue", "readonly"]) ]), _: 1 })) : i("", !0), n(m, null, { default: s(() => [ G("div", re, [ n(_, { disabled: p.value, onClick: e[6] || (e[6] = (t) => a.$emit("close")) }, { default: s(() => [ U(H(o.dialogType === "show" ? "关闭" : "取消"), 1) ]), _: 1 }, 8, ["disabled"]), o.dialogType !== "show" ? (r(), u(_, { key: 0, type: "primary", loading: p.value, onClick: e[7] || (e[7] = (t) => P(b.value)) }, { default: s(() => e[9] || (e[9] = [ U(" 确定 ") ])), _: 1 }, 8, ["loading"])) : i("", !0) ]) ]), _: 1 }) ]), _: 1 }, 8, ["rules", "model"]); }; } }); export { Ce as default };