@cdwx/system
Version:
成都文宣业务类服务模块组件库
184 lines (183 loc) • 6.7 kB
JavaScript
/* 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 T, mergeModels as y, ref as v, useModel as D, computed as U, onMounted as q, reactive as B, openBlock as n, createBlock as i, withModifiers as F, withCtx as a, createVNode as r, createCommentVNode as f, createElementVNode as $, createTextVNode as x } from "vue";
import { ElMessage as k } from "element-plus";
import { saveData as I } from "../workspace/code/cloud-frontend/service-modules/system/src/api/api-dictionary.js";
import { ElInput 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/input/index.js";
import { ElFormItem as S, ElForm as h } 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 { ElButton 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/button/index.js";
const A = { class: "flex flex-1 justify-end" }, Y = /* @__PURE__ */ T({
name: "AddDict",
__name: "add",
props: /* @__PURE__ */ y({
rules: {}
}, {
modelValue: { required: !0 },
modelModifiers: {}
}),
emits: /* @__PURE__ */ y(["close"], ["update:modelValue"]),
setup(c, { emit: w }) {
const s = c, _ = w, V = v(), l = v({
name: "",
code: "",
description: "",
id: void 0,
sort: void 0
}), b = D(c, "modelValue"), u = U({
get() {
return b.value;
},
set(t) {
b.value = t;
}
});
q(() => {
u.value && (u.value.createTime && delete u.value.createTime, u.value.updateTime && delete u.value.updateTime, l.value = u.value);
});
const M = B({
name: [
{
required: !0,
message: "请输入类型名称",
trigger: ["blur", "change"]
}
],
code: [
{
required: !0,
message: "请输入类型编码",
trigger: ["blur", "change"]
}
]
}), d = v(!1);
function C(t) {
!t || d.value || t.validate((e) => {
e && E();
});
}
async function E() {
d.value = !0;
try {
await I(l.value), l.value.id ? k.success("编辑成功") : k.success("新增成功"), _("close");
} catch (t) {
console.log(t);
} finally {
d.value = !1;
}
}
return (t, e) => {
const p = R, m = S, g = j, N = h;
return n(), i(N, {
ref_key: "formRef",
ref: V,
"label-width": "80px",
rules: M,
model: l.value,
onSubmit: e[6] || (e[6] = F(() => {
}, ["prevent"]))
}, {
default: a(() => [
s.rules.showName ? (n(), i(m, {
key: 0,
label: "类型名称",
prop: "name"
}, {
default: a(() => [
r(p, {
modelValue: l.value.name,
"onUpdate:modelValue": e[0] || (e[0] = (o) => l.value.name = o),
placeholder: "请输入类型名称",
maxlength: "10",
clearable: ""
}, null, 8, ["modelValue"])
]),
_: 1
})) : f("", !0),
s.rules.showCode ? (n(), i(m, {
key: 1,
label: "类型编码",
prop: "code"
}, {
default: a(() => [
r(p, {
modelValue: l.value.code,
"onUpdate:modelValue": e[1] || (e[1] = (o) => l.value.code = o),
placeholder: "请输入类型编码",
maxlength: "30",
clearable: ""
}, null, 8, ["modelValue"])
]),
_: 1
})) : f("", !0),
s.rules.showDes ? (n(), i(m, {
key: 2,
label: "描述",
prop: "description"
}, {
default: a(() => [
r(p, {
modelValue: l.value.description,
"onUpdate:modelValue": e[2] || (e[2] = (o) => l.value.description = o),
placeholder: "请输入描述信息",
rows: 4,
type: "textarea",
maxlength: "200",
clearable: ""
}, null, 8, ["modelValue"])
]),
_: 1
})) : f("", !0),
s.rules.showSort ? (n(), i(m, {
key: 3,
prop: "sort",
label: "排序"
}, {
default: a(() => [
r(p, {
modelValue: l.value.sort,
"onUpdate:modelValue": e[3] || (e[3] = (o) => l.value.sort = o),
modelModifiers: { number: !0 },
placeholder: "请输入排序",
clearable: ""
}, null, 8, ["modelValue"])
]),
_: 1
})) : f("", !0),
r(m, null, {
default: a(() => [
$("div", A, [
r(g, {
disabled: d.value,
onClick: e[4] || (e[4] = (o) => t.$emit("close"))
}, {
default: a(() => e[7] || (e[7] = [
x(" 取消 ")
])),
_: 1
}, 8, ["disabled"]),
r(g, {
type: "primary",
loading: d.value,
onClick: e[5] || (e[5] = (o) => C(V.value))
}, {
default: a(() => e[8] || (e[8] = [
x(" 确定 ")
])),
_: 1
}, 8, ["loading"])
])
]),
_: 1
})
]),
_: 1
}, 8, ["rules", "model"]);
};
}
});
export {
Y as default
};