@cdwx/system
Version:
成都文宣业务类服务模块组件库
218 lines (217 loc) • 8.18 kB
JavaScript
/* 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 S, mergeModels as w, ref as v, useModel as T, computed as U, onMounted as D, reactive as $, openBlock as n, createBlock as m, withModifiers as q, withCtx as a, createVNode as u, createCommentVNode as f, createElementVNode as B, createTextVNode as y } from "vue";
import { ElMessage as x } from "element-plus";
import { saveItemData as F } from "../workspace/code/cloud-frontend/service-modules/system/src/api/api-dictionary.js";
import { ElInput as I } 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 h, ElForm as R } 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 { ElSwitch as j } 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 O } 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 z = { class: "flex flex-1 justify-end" }, te = /* @__PURE__ */ S({
name: "Dict",
__name: "dict",
props: /* @__PURE__ */ w({
rules: {}
}, {
modelValue: { required: !0 },
modelModifiers: {}
}),
emits: /* @__PURE__ */ w(["close"], ["update:modelValue"]),
setup(c, { emit: _ }) {
const s = c, k = _, b = v(), l = v({
enable: !0,
dictLabel: "",
dictValue: "",
code: "",
description: "",
id: void 0,
sort: void 0
}), V = T(c, "modelValue"), i = U({
get() {
return V.value;
},
set(o) {
V.value = o;
}
});
D(() => {
i.value ? (i.value.createTime && delete i.value.createTime, i.value.updateTime && delete i.value.updateTime, l.value = i.value, l.value.id ? l.value.enable = i.value.enable || !0 : l.value.enable = !0) : l.value.enable = !0;
});
const E = $({
dictLabel: [
{
required: !0,
message: "请输入字典项名称",
trigger: ["blur", "change"]
}
],
dictValue: [
{
required: !0,
message: "请输入字典项值",
trigger: ["blur", "change"]
}
],
sort: [
{
validator: (o, e, r) => {
if (e === void 0 || e === "") {
r();
return;
}
/^[1-9]\d*$/.test(String(e)) ? r() : r(new Error("请输入正整数"));
},
trigger: "blur"
}
]
}), p = v(!1);
function M(o) {
!o || p.value || o.validate((e) => {
e && L();
});
}
async function L() {
p.value = !0;
try {
await F(l.value), l.value.id ? x.success("编辑成功") : x.success("新增成功"), k("close");
} catch (o) {
console.log(o);
} finally {
p.value = !1;
}
}
return (o, e) => {
const r = I, d = h, C = j, g = O, N = R;
return n(), m(N, {
ref_key: "formRef",
ref: b,
"label-width": "100px",
rules: E,
model: l.value,
onSubmit: e[7] || (e[7] = q(() => {
}, ["prevent"]))
}, {
default: a(() => [
s.rules.showName ? (n(), m(d, {
key: 0,
label: "字典项名称",
prop: "dictLabel"
}, {
default: a(() => [
u(r, {
modelValue: l.value.dictLabel,
"onUpdate:modelValue": e[0] || (e[0] = (t) => l.value.dictLabel = t),
placeholder: "请输入字典项名称",
maxlength: "10",
clearable: ""
}, null, 8, ["modelValue"])
]),
_: 1
})) : f("", !0),
s.rules.showValue ? (n(), m(d, {
key: 1,
label: "字典项值",
prop: "dictValue"
}, {
default: a(() => [
u(r, {
modelValue: l.value.dictValue,
"onUpdate:modelValue": e[1] || (e[1] = (t) => l.value.dictValue = t),
placeholder: "请输入字典项值",
maxlength: "30",
clearable: ""
}, null, 8, ["modelValue"])
]),
_: 1
})) : f("", !0),
s.rules.showDes ? (n(), m(d, {
key: 2,
label: "描述",
prop: "description"
}, {
default: a(() => [
u(r, {
modelValue: l.value.description,
"onUpdate:modelValue": e[2] || (e[2] = (t) => l.value.description = t),
placeholder: "请输入描述信息",
rows: 4,
type: "textarea",
maxlength: "200",
clearable: ""
}, null, 8, ["modelValue"])
]),
_: 1
})) : f("", !0),
s.rules.showSort ? (n(), m(d, {
key: 3,
prop: "sort",
label: "排序"
}, {
default: a(() => [
u(r, {
modelValue: l.value.sort,
"onUpdate:modelValue": e[3] || (e[3] = (t) => l.value.sort = t),
modelModifiers: { number: !0 },
placeholder: "请输入排序",
clearable: ""
}, null, 8, ["modelValue"])
]),
_: 1
})) : f("", !0),
s.rules.showStatus ? (n(), m(d, {
key: 4,
prop: "enable",
label: "是否启用"
}, {
default: a(() => [
u(C, {
modelValue: l.value.enable,
"onUpdate:modelValue": e[4] || (e[4] = (t) => l.value.enable = t),
"inline-prompt": "",
"active-value": !0,
"inactive-value": !1,
"active-text": "启用",
"inactive-text": "禁用"
}, null, 8, ["modelValue"])
]),
_: 1
})) : f("", !0),
u(d, null, {
default: a(() => [
B("div", z, [
u(g, {
disabled: p.value,
onClick: e[5] || (e[5] = (t) => o.$emit("close"))
}, {
default: a(() => e[8] || (e[8] = [
y(" 取消 ")
])),
_: 1
}, 8, ["disabled"]),
u(g, {
type: "primary",
loading: p.value,
onClick: e[6] || (e[6] = (t) => M(b.value))
}, {
default: a(() => e[9] || (e[9] = [
y(" 确定 ")
])),
_: 1
}, 8, ["loading"])
])
]),
_: 1
})
]),
_: 1
}, 8, ["rules", "model"]);
};
}
});
export {
te as default
};