UNPKG

@cdwx/system

Version:

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

382 lines (381 loc) 15.3 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 */ /* empty css */ /* empty css */ import { defineComponent as O, mergeModels as _, ref as f, useModel as R, computed as j, onMounted as P, reactive as z, openBlock as r, createBlock as u, withModifiers as G, withCtx as a, createVNode as n, createElementBlock as E, Fragment as L, renderList as U, unref as C, createCommentVNode as m, createElementVNode as H, createTextVNode as M } from "vue"; import { regular as J } from "../workspace/code/cloud-frontend/packages/config/src/regular.js"; import { ElMessage as I } from "element-plus"; import { getAll as K, updateData as Q, saveData as W } from "../workspace/code/cloud-frontend/service-modules/system/src/api/api-menu.js"; import { menuTypeList as X } from "../workspace/code/cloud-frontend/service-modules/system/src/config/local-data.js"; import { useDictList as Y } from "../workspace/code/cloud-frontend/service-modules/system/src/hooks/use-dict-list.js"; import { ElOption as Z, ElSelect 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/select/index.js"; import { ElFormItem as le, ElForm 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/form/index.js"; import { ElInput 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/input/index.js"; import { ElCascader as ae } 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/cascader/index.js"; import { ElSwitch as re } 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/switch/index.js"; import { ElButton as ue } 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 ne = { class: "flex flex-1 justify-end" }, Ae = /* @__PURE__ */ O({ name: "MenuAdd", __name: "add", props: /* @__PURE__ */ _({ rules: {} }, { modelValue: { required: !0 }, modelModifiers: {} }), emits: /* @__PURE__ */ _(["close"], ["update:modelValue"]), setup(y, { emit: S }) { const s = y, B = S, b = f(), t = f({ id: void 0, name: "", code: "", type: void 0, classify: "", level: void 0, icon: "", iconEnable: "", parentId: void 0, url: "", status: 1, sort: void 0, createdBy: void 0, remarks: "" }), V = R(y, "modelValue"); let v = []; if (s.rules.showClassify) { const { dictList: o } = Y("menuClassify"); v = o, console.log("classifyList", o), console.log("classifyLists", v); } const g = j({ get() { return V.value; }, set(o) { V.value = o; } }); P(() => { N(), g.value && (t.value = g.value); }); const D = z({ name: [ { required: !0, message: "请输入菜单名称", trigger: ["blur", "change"] } ], code: [ { required: !0, message: "请输入菜单编码", trigger: ["blur", "change"] }, { pattern: J.code.reg, message: "菜单编码只能输入英文和数字", trigger: ["blur", "change"], transform(o) { return o.trim(); } } ], sort: [ { required: !0, message: "请输入菜单排序", trigger: ["blur", "change"] } ] }), i = f(!1), k = f([]); async function N() { i.value = !0; try { const { data: o } = await K(); k.value = o; } catch (o) { console.log(o); } finally { i.value = !1; } } function q(o) { !o || i.value || o.validate((e) => { e && A(); }); } async function A() { i.value = !0; try { t.value.id ? (await Q(t.value), I.success("编辑成功")) : (await W(t.value), I.success("新增成功")), B("close"); } catch (o) { console.log(o); } finally { i.value = !1; } } return (o, e) => { const w = Z, x = ee, d = le, p = oe, F = ae, T = re, h = ue, $ = te; return r(), u($, { ref_key: "formRef", ref: b, "label-width": "100px", rules: D, model: t.value, onSubmit: e[13] || (e[13] = G(() => { }, ["prevent"])) }, { default: a(() => [ s.rules.showClassify ? (r(), u(d, { key: 0, label: "菜单分类", prop: "classify" }, { default: a(() => [ n(x, { modelValue: t.value.classify, "onUpdate:modelValue": e[0] || (e[0] = (l) => t.value.classify = l), placeholder: "请选择菜单分类" }, { default: a(() => [ (r(!0), E(L, null, U(C(v), (l, c) => (r(), u(w, { key: c, label: l.label, value: l.value }, null, 8, ["label", "value"]))), 128)) ]), _: 1 }, 8, ["modelValue"]) ]), _: 1 })) : m("", !0), s.rules.showName ? (r(), u(d, { key: 1, label: "菜单名称", prop: "name" }, { default: a(() => [ n(p, { modelValue: t.value.name, "onUpdate:modelValue": e[1] || (e[1] = (l) => t.value.name = l), placeholder: "请输入菜单名称", maxlength: "20", clearable: "" }, null, 8, ["modelValue"]) ]), _: 1 })) : m("", !0), s.rules.showCode ? (r(), u(d, { key: 2, label: "菜单编码", prop: "code" }, { default: a(() => [ n(p, { modelValue: t.value.code, "onUpdate:modelValue": e[2] || (e[2] = (l) => t.value.code = l), placeholder: "请输入菜单编码", maxlength: "50", clearable: "" }, null, 8, ["modelValue"]) ]), _: 1 })) : m("", !0), s.rules.showType ? (r(), u(d, { key: 3, label: "菜单类型", prop: "type" }, { default: a(() => [ n(x, { modelValue: t.value.type, "onUpdate:modelValue": e[3] || (e[3] = (l) => t.value.type = l), placeholder: "请选择菜单类型" }, { default: a(() => [ (r(!0), E(L, null, U(C(X), (l, c) => (r(), u(w, { key: c, label: l.label, value: l.value }, null, 8, ["label", "value"]))), 128)) ]), _: 1 }, 8, ["modelValue"]) ]), _: 1 })) : m("", !0), s.rules.showLevel ? (r(), u(d, { key: 4, label: "上级菜单", prop: "parentId" }, { default: a(() => [ n(F, { modelValue: t.value.parentId, "onUpdate:modelValue": e[4] || (e[4] = (l) => t.value.parentId = l), options: k.value, clearable: !0, separator: "-", filterable: !0, props: { // 选择任一级 checkStrictly: !0, expandTrigger: "hover", // 只返回选中值 emitPath: !1, label: "name", value: "id", children: "childMenuVoList" }, style: { width: "100%" }, placeholder: "请选择上级菜单" }, null, 8, ["modelValue", "options"]) ]), _: 1 })) : m("", !0), s.rules.showIcon ? (r(), u(d, { key: 5, label: "图标编码", prop: "icon" }, { default: a(() => [ n(p, { modelValue: t.value.icon, "onUpdate:modelValue": e[5] || (e[5] = (l) => t.value.icon = l), placeholder: "请输入图标编码", maxlength: "30", clearable: "" }, null, 8, ["modelValue"]) ]), _: 1 })) : m("", !0), s.rules.showActiveIcon ? (r(), u(d, { key: 6, label: "选中图标编码" }, { default: a(() => [ n(p, { modelValue: t.value.iconEnable, "onUpdate:modelValue": e[6] || (e[6] = (l) => t.value.iconEnable = l), placeholder: "请输入选中图标编码", maxlength: "30", clearable: "" }, null, 8, ["modelValue"]) ]), _: 1 })) : m("", !0), s.rules.showSort ? (r(), u(d, { key: 7, label: "排序", prop: "sort" }, { default: a(() => [ n(p, { modelValue: t.value.sort, "onUpdate:modelValue": e[7] || (e[7] = (l) => t.value.sort = l), modelModifiers: { number: !0 }, placeholder: "请输入排序号", maxlength: "10", clearable: "" }, null, 8, ["modelValue"]) ]), _: 1 })) : m("", !0), s.rules.showUrl ? (r(), u(d, { key: 8, label: "路由地址", prop: "url" }, { default: a(() => [ n(p, { modelValue: t.value.url, "onUpdate:modelValue": e[8] || (e[8] = (l) => t.value.url = l), placeholder: "请输入路由地址", maxlength: "100", clearable: "" }, null, 8, ["modelValue"]) ]), _: 1 })) : m("", !0), s.rules.showDes ? (r(), u(d, { key: 9, label: "菜单描述", prop: "remarks" }, { default: a(() => [ n(p, { modelValue: t.value.remarks, "onUpdate:modelValue": e[9] || (e[9] = (l) => t.value.remarks = l), placeholder: "请输入菜单描述", rows: 4, type: "textarea", maxlength: "100", clearable: "" }, null, 8, ["modelValue"]) ]), _: 1 })) : m("", !0), s.rules.showStatus ? (r(), u(d, { key: 10, label: "启用/禁用" }, { default: a(() => [ n(T, { modelValue: t.value.status, "onUpdate:modelValue": e[10] || (e[10] = (l) => t.value.status = l), "inline-prompt": "", "active-value": 1, "inactive-value": 0, "active-text": "启用", "inactive-text": "禁用" }, null, 8, ["modelValue"]) ]), _: 1 })) : m("", !0), n(d, null, { default: a(() => [ H("div", ne, [ n(h, { disabled: i.value, onClick: e[11] || (e[11] = (l) => o.$emit("close")) }, { default: a(() => e[14] || (e[14] = [ M(" 取消 ") ])), _: 1 }, 8, ["disabled"]), n(h, { type: "primary", loading: i.value, onClick: e[12] || (e[12] = (l) => q(b.value)) }, { default: a(() => e[15] || (e[15] = [ M(" 确定 ") ])), _: 1 }, 8, ["loading"]) ]) ]), _: 1 }) ]), _: 1 }, 8, ["rules", "model"]); }; } }); export { Ae as default };