食材采购修改和样式优化
This commit is contained in:
1 parent
bee9fefa1d
commit
8b7617bb44
9 files changed
+166
-223
No files matched your search
@@ -23,8 +23,8 @@
|
||||
|
||||
<template #footer>
|
||||
<span class="dialog-footer">
|
||||
<el-button @click="visible = false">{{ $t('common.cancelButtonText') }}</el-button>
|
||||
<el-button @click="onSubmit" type="primary" :disabled="loading">{{ $t('common.confirmButtonText') }}</el-button>
|
||||
<el-button @click="visible = false">{{ $t("common.cancelButtonText") }}</el-button>
|
||||
<el-button @click="onSubmit" type="primary" :disabled="loading">{{ $t("common.confirmButtonText") }}</el-button>
|
||||
</span>
|
||||
</template>
|
||||
</el-dialog>
|
||||
@@ -32,86 +32,95 @@
|
||||
|
||||
<script lang="ts" name="GenTemplateDialog" setup>
|
||||
// 定义子组件向父组件传值/事件
|
||||
import { useMessage } from '/@/hooks/message';
|
||||
import { addObj, getObj, putObj } from '/@/api/gen/template';
|
||||
import { useI18n } from 'vue-i18n';
|
||||
import {rule} from "/@/utils/validate";
|
||||
import { useMessage } from "/@/hooks/message"
|
||||
import { addObj, getObj, putObj } from "/@/api/gen/template"
|
||||
import { useI18n } from "vue-i18n"
|
||||
import { rule } from "/@/utils/validate"
|
||||
|
||||
const CodeEditor = defineAsyncComponent(() => import('/@/components/CodeEditor/index.vue'));
|
||||
const emit = defineEmits(['refresh']);
|
||||
const CodeEditor = defineAsyncComponent(() => import("/@/components/CodeEditor/index.vue"))
|
||||
const emit = defineEmits(["refresh"])
|
||||
|
||||
const { t } = useI18n();
|
||||
const { t } = useI18n()
|
||||
|
||||
// 定义变量内容
|
||||
const dataFormRef = ref();
|
||||
const visible = ref(false);
|
||||
const loading = ref(false);
|
||||
const dataFormRef = ref()
|
||||
const visible = ref(false)
|
||||
const loading = ref(false)
|
||||
|
||||
// 定义字典
|
||||
|
||||
// 提交表单数据
|
||||
const form = reactive({
|
||||
id: '',
|
||||
templateName: '',
|
||||
generatorPath: '',
|
||||
templateDesc: '',
|
||||
templateCode: '',
|
||||
});
|
||||
id: "",
|
||||
templateName: "",
|
||||
generatorPath: "",
|
||||
templateDesc: "",
|
||||
templateCode: "",
|
||||
})
|
||||
|
||||
// 定义校验规则
|
||||
const dataRules = ref({
|
||||
templateName: [{ validator: rule.overLength, trigger: 'blur' },{ required: true, message: '模板名称不能为空', trigger: 'blur' }],
|
||||
generatorPath: [{ validator: rule.overLength, trigger: 'blur' },{ required: true, message: '模板路径不能为空', trigger: 'blur' }],
|
||||
templateDesc: [{ validator: rule.overLength, trigger: 'blur' },{ required: true, message: '模板描述不能为空', trigger: 'blur' }],
|
||||
});
|
||||
templateName: [
|
||||
{ validator: rule.overLength, trigger: "blur" },
|
||||
{ required: true, message: "模板名称不能为空", trigger: "blur" },
|
||||
],
|
||||
generatorPath: [
|
||||
{ validator: rule.overLength, trigger: "blur" },
|
||||
{ required: true, message: "模板路径不能为空", trigger: "blur" },
|
||||
],
|
||||
templateDesc: [
|
||||
{ validator: rule.overLength, trigger: "blur" },
|
||||
{ required: true, message: "模板描述不能为空", trigger: "blur" },
|
||||
],
|
||||
})
|
||||
|
||||
// 打开弹窗
|
||||
const openDialog = (id: string) => {
|
||||
visible.value = true;
|
||||
form.id = '';
|
||||
visible.value = true
|
||||
form.id = ""
|
||||
|
||||
// 重置表单数据
|
||||
nextTick(() => {
|
||||
dataFormRef.value?.resetFields();
|
||||
});
|
||||
dataFormRef.value?.resetFields()
|
||||
})
|
||||
// 获取genTemplate信息
|
||||
if (id) {
|
||||
form.id = id;
|
||||
getgenTemplateData(id);
|
||||
form.id = id
|
||||
getgenTemplateData(id)
|
||||
}
|
||||
};
|
||||
}
|
||||
|
||||
// 提交
|
||||
const onSubmit = async () => {
|
||||
const valid = await dataFormRef.value.validate().catch(() => {});
|
||||
if (!valid) return false;
|
||||
const valid = await dataFormRef.value.validate().catch(() => {})
|
||||
if (!valid) return false
|
||||
|
||||
// 校验模板是否为空
|
||||
|
||||
try {
|
||||
loading.value = true;
|
||||
form.id ? await putObj(form) : await addObj(form);
|
||||
useMessage().success(t(form.id ? 'common.editSuccessText' : 'common.addSuccessText'));
|
||||
visible.value = false;
|
||||
emit('refresh');
|
||||
loading.value = true
|
||||
form.id ? await putObj(form) : await addObj(form)
|
||||
useMessage().success(t(form.id ? "common.editSuccessText" : "common.addSuccessText"))
|
||||
visible.value = false
|
||||
emit("refresh")
|
||||
} catch (err: any) {
|
||||
useMessage().error(err.msg);
|
||||
useMessage().error(err.msg)
|
||||
} finally {
|
||||
loading.value = false;
|
||||
loading.value = false
|
||||
}
|
||||
};
|
||||
}
|
||||
// 初始化表单数据
|
||||
const getgenTemplateData = (id: string) => {
|
||||
// 获取数据
|
||||
getObj(id).then((res: any) => {
|
||||
Object.assign(form, res.data);
|
||||
});
|
||||
};
|
||||
Object.assign(form, res.data)
|
||||
})
|
||||
}
|
||||
|
||||
// 暴露变量
|
||||
defineExpose({
|
||||
openDialog,
|
||||
});
|
||||
})
|
||||
</script>
|
||||
|
||||
<style scoped>
|
||||
|
||||
Reference in new issue
Block a user