From 191e2daab12f365990b24a5f47c2fac8474167dc Mon Sep 17 00:00:00 2001
From: 13937891274 <kxc0822>
Date: 星期四, 28 七月 2022 18:04:14 +0800
Subject: [PATCH] 数据对接

---
 src/views/contingencyManagement/panManagement/component/openAdd.vue |  198 +++++++++++++++++++++++++------------------------
 1 files changed, 100 insertions(+), 98 deletions(-)

diff --git a/src/views/contingencyManagement/panManagement/component/openAdd.vue b/src/views/contingencyManagement/panManagement/component/openAdd.vue
index 181d212..7a6d302 100644
--- a/src/views/contingencyManagement/panManagement/component/openAdd.vue
+++ b/src/views/contingencyManagement/panManagement/component/openAdd.vue
@@ -1,7 +1,7 @@
 <template>
   <div class="system-edit-user-container">
     <el-dialog
-        :title="title"
+        :title="titles"
         v-model="isShowDialog"
         width="769px"
         draggable
@@ -13,6 +13,7 @@
           :model="ruleForm"
           size="default"
           label-width="120px"
+          :disabled="disabled"
       >
         <el-row :gutter="35">
           <el-col :xs="24" :sm="12" :md="12" :lg="12" :xl="12" class="mb20">
@@ -45,8 +46,8 @@
           <el-col :xs="24" :sm="12" :md="12" :lg="12" :xl="12" class="mb20">
             <el-form-item label="危险源关联" prop="associatedDanger">
               <el-select v-model="ruleForm.associatedDanger" class="w100" placeholder="请选择">
-                <el-option label="是" value="admin"></el-option>
-                <el-option label="否" value="common"></el-option>
+                <el-option label="是" value="0"></el-option>
+                <el-option label="否" value="1"></el-option>
               </el-select>
             </el-form-item>
           </el-col>
@@ -88,13 +89,14 @@
                   type="datetime"
                   class="w100"
                   placeholder="选择日期时间"
+                  value-format="YYYY-MM-DD HH:mm:ss"
               />
             </el-form-item>
           </el-col>
           <el-col :xs="24" :sm="12" :md="12" :lg="12" :xl="12" class="mb20">
-            <el-form-item label="应急队伍" prop="telephone" @click="daiInpt" >
+            <el-form-item label="应急队伍" prop="emergencyTeam" @click="daiInpt" >
               <el-input
-                  v-model="ruleForm.teamLeader"
+                  v-model="ruleForm.emergencyTeam"
                   placeholder="请选择"
                   class="input-with-select"
               >
@@ -123,9 +125,9 @@
             </el-form-item>
           </el-col>
           <el-col :xs="24" :sm="12" :md="12" :lg="12" :xl="12" class="mb20">
-            <el-form-item label="区域名称" prop="telephone">
+            <el-form-item label="区域名称" prop="areaName">
               <el-input
-                  v-model="ruleForm.teamLeader"
+                  v-model="ruleForm.areaName"
                   placeholder="请选择"
                   class="input-with-select"
               >
@@ -139,20 +141,19 @@
       </el-form>
       <template #footer>
 				<span class="dialog-footer">
-					<el-button @click="onCancel" size="default">关闭</el-button>
-          <el-button size="default" type="primary" @click="submitForm(ruleFormRef)">确定</el-button>
+					<el-button @click="resetForm(ruleFormRef)" size="default">关闭</el-button>
+          <el-button size="default" type="primary" v-if="disabled == true ? false : true" @click="submitForm(titles, ruleFormRef)">确定</el-button>
 				</span>
       </template>
     </el-dialog>
     <CheckTemplate ref="Shows"/>
-    <userSelections ref="userRef"/>
+    <DailogSearchUser ref="userRef" @SearchUser="onUser"/>
     <RegionsDialog ref="openRef"/>
   </div>
 </template>
 
 <script lang="ts">
 import {
-  reactive,
   ref,
   defineComponent
 } from 'vue';
@@ -160,32 +161,28 @@
 import type {
   UploadUserFile,
   FormInstance,
-  // FormRules,
 } from 'element-plus'
-
+import { ElMessage } from 'element-plus';
 import {
   Search,
   FullScreen
 } from '@element-plus/icons-vue'
-import UserSelections from "/@/components/userSelections/index.vue"
+import DailogSearchUser from "/@/components/DailogSearchUser/index.vue"
 import CheckTemplate from '/@/components/checkTemplate/index.vue'
 import RegionsDialog from '/@/components/regionsDialog/index.vue'
-
-
+import {emergencyPlanApi} from "/@/api/emergencyPlan";
 
 export default defineComponent({
   name: 'openAdd',
   components: {
     CheckTemplate,
-    UserSelections,
+    DailogSearchUser,
     RegionsDialog,
   },
-  setup() {
-    const isShowDialog = ref(false)
-
-    const ruleFormRef = ref<FormInstance>()
-    //定义表单
-    const ruleForm = reactive({
+  setup(prop, {emit}) {
+    const isShowDialog = ref(false);
+    const ruleFormRef = ref<FormInstance>();
+    const ruleForm = ref({
       name: '', // 预案名称
       type: '', //预案类型
       associatedDanger: '', // 危险源关联
@@ -193,20 +190,38 @@
       authorId: '', // 编写人
       authorDeptId: '', // 编写部门
       releaseDate: '', // 发布实施日期
-      // telephone: '', // 应急队伍
-    });
+      fileList: [
+        {
+          fileUrl: 'url',
+          fileName: 'name',
+        }
+      ],
+      emergencyTeam: '', //应急队伍
+      areaList: [
+        {
+          areaId: '',
+        }
+      ],  //区域列表
+      areaName: '',  //区域名称
+      teamList: [
+        {
+          teamId: '',
+        }
+      ],
+      deptList: [
+        {
+          departmentId: '',
+        }
+      ]
+    })
+    const titles = ref();
+    const disabled = ref();
+
     // 打开弹窗
-    const openDialog = () => {
-      // state.ruleForm = row;
+    const openDialog = (title: string, id: number, type: boolean) => {
       isShowDialog.value = true;
-    };
-    // 关闭弹窗
-    const closeDialog = () => {
-      isShowDialog.value = false;
-    };
-    // 取消
-    const onCancel = () => {
-      closeDialog();
+      titles.value = title;
+      disabled.value = type;
     };
     //日期选择器
     const releaseDate = ref('')
@@ -331,62 +346,44 @@
         ],
       },
     ]
-    // 必填项提示
-    // const rules = reactive<FormRules>({
-    //   teamName: [
-    //     {
-    //       required: true,
-    //       message: '队伍名称不能为空',
-    //       trigger: 'change',
-    //     },
-    //   ],
-    //   teamLevel: [
-    //     {
-    //       required: true,
-    //       message: '队伍级别不能为空',
-    //       trigger: 'change',
-    //     },
-    //   ],
-    //   teamLeader: [
-    //     {
-    //       required: true,
-    //       message: '队伍负责人不能为空',
-    //       trigger: 'change',
-    //     },
-    //   ],
-    //   responsibleDepartment: [
-    //     {
-    //       required: true,
-    //       message: '负责人部门不能为空',
-    //       trigger: 'change',
-    //     },
-    //   ],
-    //   teamPhone: [
-    //     {
-    //       required: true,
-    //       message: '负责人手机不能为空',
-    //       trigger: 'change',
-    //     },
-    //   ],
-    //   telephone: [
-    //     {
-    //       required: true,
-    //       message: '固定电话不能为空',
-    //       trigger: 'change',
-    //     },
-    //   ],
-    // })
-    // 表单提交验证必填项
-    const submitForm = async (formEl: FormInstance | undefined) => {
-      if (!formEl) return
-      await formEl.validate((valid, fields) => {
-        if (valid) {
-          console.log('submit!')
-        } else {
-          console.log('error submit!', fields)
-        }
-      })
-    }
+
+    const submitForm = async (title: string, formEl: FormInstance | undefined) => {
+      if (title == '新建应急预案管理') {
+        if (!formEl) return;
+        await formEl.validate((valid, fields) => {
+          if (valid) {
+            isShowDialog.value = false;
+            emergencyPlanApi()
+              .addEmergencyPlan(ruleForm.value)
+              .then((res) => {
+                if (res.data.code == 200) {
+                  ElMessage({
+                    showClose: true,
+                    message: res.data.msg,
+                    type: 'success',
+                  });
+                  emit('myAdd', true);
+                } else {
+                  ElMessage({
+                    showClose: true,
+                    message: res.data.msg,
+                    type: 'error',
+                  });
+                  emit('myAdd', true);
+                }
+                formEl.resetFields();
+              });
+          } else {
+            console.log('error submit!', fields);
+          }
+        })
+      }
+    };
+    const resetForm = (formEl: FormInstance | undefined) => {
+      isShowDialog.value = false;
+      if (!formEl) return;
+      formEl.resetFields();
+    };
     // 应急队伍弹窗
     const Shows=ref()
     const daiInpt=()=>{
@@ -400,7 +397,10 @@
     // 打开用户选择弹窗
     const userRef = ref();
     const openUser = () => {
-      userRef.value.openDialog();
+      userRef.value.openDailog();
+    };
+    const onUser = (e:any) => {
+      ruleForm.value.authorId=e.id
     };
     //全屏
     const full = ref(false);
@@ -413,22 +413,16 @@
     };
     return {
       openDialog,
-      closeDialog,
-      isShowDialog,
-      onCancel,
       fileList,
       responsibleDepartment,
       data,
       Search,
-      ruleForm,
       releaseDate,
       treeSelect,
       tree,
       daiInpt,
       Shows,
-      ruleFormRef,
       submitForm,
-      // rules,
       openUser,
       userRef,
       regionsDialog,
@@ -436,6 +430,14 @@
       toggleFullscreen,
       FullScreen,
       full,
+      titles,
+      disabled,
+      emit,
+      isShowDialog,
+      ruleFormRef,
+      ruleForm,
+      resetForm,
+      onUser,
     };
   },
 });

--
Gitblit v1.9.2