drag-create-api/app/resources/view/jsVue/add.tpl
2023-06-25 08:51:24 +08:00

106 lines
2.0 KiB
Smarty

<template>
<el-dialog v-model="dialogVisible" title="添加${functionName}" width="900px" @closed="closeDialog" @open="openDialog">
<el-form ref="formRef" :model="formData" :rules="rules">
<el-row>
${col}
</el-row>
</el-form>
<template #footer>
<span class="dialog-footer">
<el-button type="primary" @click="handleAddClick(formRef)">添加</el-button>
<el-button @click="handleResetClick(formRef)">重置</el-button>
</span>
</template>
</el-dialog>
</template>
<script setup>
import { reactive, ref, watch } from "vue";
import { add${className} ${dictFunName} } from "~/service/${businessName}";
import { useLoginStore } from "~/store";
// --业务参数
${mapParm}
// --业务方法
${dictFun}
// --基础参数
const store = useLoginStore();
const headers = {
Accept: "application/json",
...store.headers,
};
const isBtnLod = ref(false);
const formRef = ref();
const labelWidth = 90;
const props = defineProps({
modelValue: Boolean,
done: Function,
});
const emits = defineEmits(["update:modelValue"]);
const dialogVisible = ref(props.modelValue);
const formData = reactive({});
const uoloadData = ref({
dirName: "${className}"
})
watch(props, (v) => {
dialogVisible.value = v.modelValue;
});
const rules = reactive({
${rules}
});
// --基础方法
// 打开弹窗时执行
const openDialog = () => {
${dictFunName2}
};
const closeDialog = () => {
handleResetClick(formRef.value);
dialogVisible.value = false;
emits("update:modelValue", false);
};
const handleAddClick = async (formEl) => {
if (!formEl) return;
formEl.validate(async (valid) => {
if (!valid) {
return;
}
isBtnLod.value = true;
${mapFun}
const { code } = await add${className}(formData);
if (code == 0) {
closeDialog();
props.done();
}
isBtnLod.value = flase;
});
};
const handleResetClick = async (formEl) => {
if (!formEl) return;
formEl.resetFields();
};
</script>
<style lang="less" scoped>
</style>