<template>
|
<el-button icon="Plus" type="success" plain @click="openDialog"
|
>新建方案</el-button
|
>
|
<el-dialog
|
v-model="dialogShow"
|
width="600px"
|
:close-on-click-modal="false"
|
:close-on-press-escape="false"
|
destroy-on-close
|
>
|
<template #header>
|
<span> 新建方案</span>
|
</template>
|
<el-form
|
label-width="90px"
|
label-position="left"
|
:rules="rules"
|
:model="formObj"
|
ref="formRef"
|
>
|
<el-form-item label="方案名称" prop="gsName">
|
<el-input
|
style="width: 400px"
|
v-model="formObj.gsName"
|
placeholder="请输入方案名称"
|
></el-input>
|
</el-form-item>
|
<el-form-item label="方案描述" prop="gsDescription">
|
<el-input
|
v-model="formObj.gsDescription"
|
type="textarea"
|
placeholder="请输入方案描述"
|
></el-input>
|
</el-form-item>
|
<el-form-item label="创建人" prop="gsCreatorName">
|
<el-input
|
style="width: 200px"
|
v-model="formObj.gsCreatorName"
|
placeholder="请输入创建人"
|
></el-input>
|
</el-form-item>
|
</el-form>
|
<template #footer>
|
<el-button @click="onCancel">取消</el-button>
|
<el-button
|
:disabled="!edit"
|
type="primary"
|
:loading="loading"
|
@click="onSubmit"
|
>确定</el-button
|
>
|
</template>
|
</el-dialog>
|
</template>
|
|
<script setup>
|
import { reactive, ref, watch } from 'vue';
|
import { useFormConfirm } from '@/composables/formConfirm';
|
import gridSchemeApi from '@/api/grid/gridSchemeApi';
|
|
const emit = defineEmits(['created']);
|
|
const rules = reactive({
|
gsName: [
|
{
|
required: true,
|
message: '方案名称不能为空',
|
trigger: 'blur'
|
}
|
]
|
});
|
|
const { formObj, formRef, edit, onSubmit, onCancel } = useFormConfirm(
|
{
|
submit: {
|
do: submit
|
},
|
cancel: {
|
do: cancel
|
}
|
}
|
);
|
|
const dialogShow = ref(false);
|
function openDialog() {
|
dialogShow.value = true;
|
}
|
|
function submit() {
|
return gridSchemeApi.createScheme(formObj.value).then(() => {
|
// clear()
|
emit('created')
|
dialogShow.value = false;
|
});
|
}
|
|
function cancel() {
|
dialogShow.value = false;
|
}
|
</script>
|