123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869 |
- <template>
- <el-dialog title="新增外呼任务模板" v-model="state.dialogVisible" width="800px" draggable @close="close">
- <el-form :model="state.ruleForm" ref="ruleFormRef" label-width="100px">
- <el-form-item label="模板名称" prop="name" :rules="[{ required: true, message: '请输入模板名称', trigger: 'blur' }]">
- <el-input v-model="state.ruleForm.name" placeholder="请输入模板名称" clearable></el-input>
- </el-form-item>
- <el-form-item label="模板内容" prop="content" :rules="[{ required: true, message: '请输入模板内容', trigger: 'blur' }]">
- <el-input v-model="state.ruleForm.content" placeholder="请输入模板内容" type="textarea" :autosize="{ minRows: 4, maxRows: 8 }"></el-input>
- </el-form-item>
- </el-form>
- <template #footer>
- <span class="dialog-footer">
- <el-button @click="closeDialog" class="default-button">取 消</el-button>
- <el-button type="primary" @click="onSubmit(ruleFormRef)" :loading="state.loading">确 定 </el-button>
- </span>
- </template>
- </el-dialog>
- </template>
- <script setup lang="ts" name="qualityLexiconAdd">
- import { reactive, ref } from 'vue';
- import { ElInput, ElMessage, ElMessageBox, FormInstance } from 'element-plus';
- // 定义子组件向父组件传值/事件
- const emit = defineEmits(['updateList']);
- // 定义变量内容
- const ruleFormRef = ref<FormInstance>();
- const state = reactive<any>({
- dialogVisible: false, // 弹窗显示隐藏
- ruleForm: {
- name: '', // 模板名称
- content: '', // 模板内容
- },
- loading: false, // 确定按钮loading
- });
- // 打开弹窗
- const openDialog = async () => {
- try {
- state.dialogVisible = true;
- } catch (e) {
- console.log(e);
- }
- };
- // 关闭弹窗
- const closeDialog = () => {
- state.dialogVisible = false;
- };
- const close = () => {
- ruleFormRef.value?.clearValidate();
- ruleFormRef.value?.resetFields();
- };
- // 保存
- const onSubmit = (formEl: FormInstance | undefined) => {
- if (!formEl) return;
- formEl.validate((valid: boolean) => {
- if (!valid) return;
- state.loading = true;
- const request = {
- ...state.ruleForm,
- };
- });
- };
- // 暴露变量
- defineExpose({
- openDialog,
- closeDialog,
- });
- </script>
|