username@email.com
4 天以前 4008c7e22c9c01eb653b04f934990486df622654
Web/src/views/ADPenalty/aDPenalty/component/editDialog.vue
New file
@@ -0,0 +1,122 @@
<script lang="ts" name="aDPenalty" setup>
import { ref, reactive, onMounted } from "vue";
import { ElMessage } from "element-plus";
import type { FormRules } from "element-plus";
import { formatDate } from '/@/utils/formatTime';
import { useADPenaltyApi } from '/@/api/ADPenalty/aDPenalty';
//父级传递来的函数,用于回调
const emit = defineEmits(["reloadTable"]);
const aDPenaltyApi = useADPenaltyApi();
const ruleFormRef = ref();
const state = reactive({
   title: '',
   loading: false,
   showDialog: false,
   ruleForm: {} as any,
   stores: {},
   dropdownData: {} as any,
});
// 自行添加其他规则
const rules = ref<FormRules>({
  decisionDate: [{required: true, message: '请选择决定日期!', trigger: 'change',},],
});
// 页面加载时
onMounted(async () => {
});
// 打开弹窗
const openDialog = async (row: any, title: string) => {
   state.title = title;
   row = row ?? {  };
   state.ruleForm = row.id ? await aDPenaltyApi.detail(row.id).then(res => res.data.result) : JSON.parse(JSON.stringify(row));
   state.showDialog = true;
};
// 关闭弹窗
const closeDialog = () => {
   emit("reloadTable");
   state.showDialog = false;
};
// 提交
const submit = async () => {
   ruleFormRef.value.validate(async (isValid: boolean, fields?: any) => {
      if (isValid) {
         let values = state.ruleForm;
         await aDPenaltyApi[state.ruleForm.id ? 'update' : 'add'](values);
         closeDialog();
      } else {
         ElMessage({
            message: `表单有${Object.keys(fields).length}处验证失败,请修改后再提交`,
            type: "error",
         });
      }
   });
};
//将属性或者函数暴露给父组件
defineExpose({ openDialog });
</script>
<template>
   <div class="aDPenalty-container">
      <el-dialog v-model="state.showDialog" :width="800" draggable :close-on-click-modal="false">
         <template #header>
            <div style="color: #fff">
               <span>{{ state.title }}</span>
            </div>
         </template>
         <el-form :model="state.ruleForm" ref="ruleFormRef" label-width="auto" :rules="rules">
            <el-row :gutter="35">
               <el-form-item v-show="false">
                  <el-input v-model="state.ruleForm.id" />
               </el-form-item>
               <el-col :xs="24" :sm="12" :md="12" :lg="12" :xl="12" class="mb20" >
                  <el-form-item label="决定日期" prop="decisionDate">
                     <el-date-picker v-model="state.ruleForm.decisionDate" type="date" placeholder="决定日期" />
                  </el-form-item>
               </el-col>
               <el-col :xs="24" :sm="12" :md="12" :lg="12" :xl="12" class="mb20" >
                  <el-form-item label="当事人" prop="parties">
                     <el-input v-model="state.ruleForm.parties" placeholder="请输入当事人" maxlength="255" show-word-limit clearable />
                  </el-form-item>
               </el-col>
               <el-col :xs="24" :sm="24" :md="24" :lg="24" :xl="24" class="mb20" >
                  <el-form-item label="案由" prop="caseReason">
                     <el-input v-model="state.ruleForm.caseReason" placeholder="请输入案由" type="textarea" show-word-limit clearable />
                  </el-form-item>
               </el-col>
               <el-col :xs="24" :sm="24" :md="24" :lg="24" :xl="24" class="mb20" >
                  <el-form-item label="处理决定" prop="disposalDecision">
                     <el-input v-model="state.ruleForm.disposalDecision" type="textarea" placeholder="请输入处理决定" show-word-limit clearable />
                  </el-form-item>
               </el-col>
               <el-col :xs="24" :sm="12" :md="12" :lg="12" :xl="12" class="mb20" >
                  <el-form-item label="采购监督部门" prop="supervisionDepartment">
                     <el-input v-model="state.ruleForm.supervisionDepartment" placeholder="请输入采购监督部门" maxlength="255" show-word-limit clearable />
                  </el-form-item>
               </el-col>
                <el-col :xs="24" :sm="12" :md="12" :lg="12" :xl="12" class="mb20">
                  <el-form-item label="线上地址" prop="url">
                     <el-input v-model="state.ruleForm.url" placeholder="请输入线上地址" maxlength="255" show-word-limit clearable />
                  </el-form-item>
               </el-col>
            </el-row>
         </el-form>
         <template #footer>
            <span class="dialog-footer">
               <el-button @click="() => state.showDialog = false">取 消</el-button>
               <el-button @click="submit" type="primary" v-reclick="1000">确 定</el-button>
            </span>
         </template>
      </el-dialog>
   </div>
</template>
<style lang="scss" scoped>
:deep(.el-select), :deep(.el-input-number) {
  width: 100%;
}
</style>