From 1be21989c76f0eb9a43b9ebcab322d7171dbccd6 Mon Sep 17 00:00:00 2001
From: zhaojiale <631455805@qq.com>
Date: 星期四, 08 九月 2022 17:08:57 +0800
Subject: [PATCH] json转换取消

---
 src/views/contingencyManagement/contingency/component/openAdd.vue |  975 ++++++++++++++++++++++++++++++++------------------------
 1 files changed, 555 insertions(+), 420 deletions(-)

diff --git a/src/views/contingencyManagement/contingency/component/openAdd.vue b/src/views/contingencyManagement/contingency/component/openAdd.vue
index 7a3e369..2d9e986 100644
--- a/src/views/contingencyManagement/contingency/component/openAdd.vue
+++ b/src/views/contingencyManagement/contingency/component/openAdd.vue
@@ -1,434 +1,569 @@
 <template>
-  <div class="system-edit-user-container">
-    <el-dialog
-        :title="title"
-        v-model="isShowDialog"
-        width="769px"
-        draggable
-        :fullscreen="full"
-    >
-      <el-button @click="toggleFullscreen" size="small" class="pot" :icon="FullScreen"></el-button>
-      <el-form
-          ref="ruleFormRef"
-          :model="ruleForm"
-          size="default"
-          :rules="rules"
-          label-width="120px"
-      >
-        <el-row :gutter="35">
-          <el-col :xs="24" :sm="12" :md="12" :lg="12" :xl="12" class="mb20">
-            <el-form-item label="队伍名称" prop="teamName">
-              <el-input v-model="ruleForm.teamName" placeholder="请填写队伍名称"></el-input>
-            </el-form-item>
-          </el-col>
-          <el-col :xs="24" :sm="12" :md="12" :lg="12" :xl="12" class="mb20">
-            <el-form-item label="队伍级别" prop="teamLevel">
-              <el-select v-model="ruleForm.teamLevel" class="w100" placeholder="请选择">
-                <el-option label="公司" value="admin"></el-option>
-                <el-option label="分厂-车间" value="common"></el-option>
-                <el-option label="工序-班组等" value="shang"></el-option>
-              </el-select>
-            </el-form-item>
-          </el-col>
-          <el-col :xs="24" :sm="12" :md="12" :lg="12" :xl="12" class="mb20">
-            <el-form-item label="队伍负责人" prop="principalUid">
-              <el-input
-                  v-model="ruleForm.principalUid"
-                  placeholder="请选择"
-                  class="input-with-select"
-              >
-                <template #append>
-                  <el-button :icon="Search" @click="openUser"/>
-                </template>
-              </el-input>
-            </el-form-item>
-          </el-col>
-          <el-col :xs="24" :sm="12" :md="12" :lg="12" :xl="12" class="mb20">
-            <el-form-item label="负责人部门" prop="principalDepartmentId">
-              <el-tree-select
-                  v-model="ruleForm.principalDepartmentId"
-                  :data="data" class="w100"
-                  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="principalPhone">
-              <el-input v-model="ruleForm.principalPhone" placeholder="请填写负责人手机"></el-input>
-            </el-form-item>
-          </el-col>
-          <el-col :xs="24" :sm="12" :md="12" :lg="12" :xl="12" class="mb20">
-            <el-form-item label="固定电话" prop="telephoneNumber">
-              <el-input v-model="ruleForm.telephoneNumber" placeholder="请填写固定电话"></el-input>
-            </el-form-item>
-          </el-col>
-          <el-col :xs="24" :sm="24" :md="24" :lg="24" :xl="24" class="mb20">
-            <el-form-item label="队伍描述" prop="teamDesc">
-              <el-input
-                  class="textarea"
-                  v-model="ruleForm.teamDesc"
-                  type="textarea"
-                  maxlength="150"
-                  placeholder="请填写队伍描述"
-              ></el-input>
-            </el-form-item>
-          </el-col>
-          <el-col :xs="24" :sm="24" :md="24" :lg="24" :xl="24" class="mb20">
-            <el-form-item label="相关附件" prop="attachments">
-              <el-upload
-                  v-model:file-list="fileList"
-                  class="upload-demo"
-                  action="https://run.mocky.io/v3/9d059bf9-4660-45f2-925d-ce80ad6c4d15"
-                  :on-change="handleChange"
-              >
-                <el-button type="primary"
-                >点击上传</el-button>
-                <template #tip>
-                  <div class="el-upload__tip">
-                    添加相关附件
-                  </div>
-                </template>
-              </el-upload>
-            </el-form-item>
-          </el-col>
-          <el-col :xs="24" :sm="24" :md="24" :lg="24" :xl="24" class="mb20">
-            <el-tabs v-model="activeName" class="demo-tabs" @tab-click="handleClick">
-              <el-tab-pane label="应急队伍人员" name="first">
-                <el-button type="primary" size="default" @click="onAddEmergencyPersonnel">新增</el-button>
-                <el-table
-                    :data="tableData"
-                    style="width: 100%;margin-top: 15px;"
-                    ref="multipleTableRef"
-                    :header-cell-style="{background:'#f6f7fa',color:'#909399'}"
-                >
-                  <el-table-column prop="jobNo" label="人员工号" show-overflow-tooltip></el-table-column>
-                  <el-table-column prop="personnelName" label="人员名称" show-overflow-tooltip></el-table-column>
-                  <el-table-column prop="phone" label="手机号码" show-overflow-tooltip></el-table-column>
-                  <el-table-column prop="position" label="职位" show-overflow-tooltip></el-table-column>
-                  <el-table-column label="操作" width="200" align="center">
-                    <template #default="scope">
-                      <el-button disabled size="small" text="plain" >查看
-                      </el-button>
-                      <el-button disabled size="small" text="plain" style="margin-right: 5px;">编辑
-                      </el-button>
-                      <el-button disabled size="small" text="plain" style="margin-right: 5px;">删除
-                      </el-button>
-                    </template>
-                  </el-table-column>
-                </el-table>
-              </el-tab-pane>
-            </el-tabs>
-          </el-col>
-        </el-row>
-      </el-form>
-      <template #footer>
-    <span class="dialog-footer">
-     <el-button @click="isShowDialog = !isShowDialog"  size="default">关闭</el-button>
-          <el-button size="default" type="primary"  @click="onSubmit">确定</el-button>
-    </span>
-      </template>
-    </el-dialog>
-    <AddEmergencyPersonnel ref="addRef" />
-    <UserSelections ref="userRef"/>
-  </div>
+    <div class="system-edit-user-container">
+        <el-dialog :title="titles" v-model="isShowDialog" width="50%" draggable :fullscreen="full" @close="resetForm(ruleFormRef)">
+            <el-button @click="toggleFullscreen" size="small" class="pot" :icon="FullScreen"></el-button>
+            <el-form ref="ruleFormRef" :model="ruleForm" size="default" :rules="rules" label-width="120px"
+                     :disabled="disabled">
+                <el-row :gutter="35">
+                    <el-col :xs="24" :sm="12" :md="12" :lg="12" :xl="12" class="mb20">
+                        <el-form-item label="队伍名称" prop="teamName">
+                            <el-input v-model="ruleForm.teamName" placeholder="请填写队伍名称"></el-input>
+                        </el-form-item>
+                    </el-col>
+                    <el-col :xs="24" :sm="12" :md="12" :lg="12" :xl="12" class="mb20">
+                        <el-form-item label="队伍级别" prop="teamLevel">
+                            <el-select v-model="ruleForm.teamLevel" class="w100" placeholder="请选择">
+                                <el-option label="公司" value="1"></el-option>
+                                <el-option label="分厂-车间" value="2"></el-option>
+                                <el-option label="工序-班组等" value="3"></el-option>
+                            </el-select>
+                        </el-form-item>
+                    </el-col>
+                    <el-col :xs="24" :sm="12" :md="12" :lg="12" :xl="12" class="mb20">
+                        <el-form-item label="队伍负责人" prop="principalName">
+                            <el-input v-model="ruleForm.principalName" placeholder="请选择" class="input-with-select">
+                                <template #append>
+                                    <el-button :icon="Search" @click="openUser"/>
+                                </template>
+                            </el-input>
+                        </el-form-item>
+                    </el-col>
+                    <el-col :xs="24" :sm="12" :md="12" :lg="12" :xl="12" class="mb20">
+                        <el-form-item label="负责人部门" prop="principalDepartmentId">
+                            <el-tree-select v-model="ruleForm.principalDepartmentId" :data="newTreeList" class="w100"
+                                            :props="propse" clearable 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="principalPhone">
+                            <el-input v-model="ruleForm.principalPhone" placeholder="请填写负责人手机"></el-input>
+                        </el-form-item>
+                    </el-col>
+                    <el-col :xs="24" :sm="12" :md="12" :lg="12" :xl="12" class="mb20">
+                        <el-form-item label="固定电话" prop="telephoneNumber">
+                            <el-input v-model="ruleForm.telephoneNumber" placeholder="请填写固定电话"></el-input>
+                        </el-form-item>
+                    </el-col>
+                    <el-col :xs="24" :sm="24" :md="24" :lg="24" :xl="24" class="mb20">
+                        <el-form-item label="队伍描述" prop="teamDesc">
+                            <el-input class="textarea" v-model="ruleForm.teamDesc" type="textarea" maxlength="150"
+                                      placeholder="请填写队伍描述"></el-input>
+                        </el-form-item>
+                    </el-col>
+                    <el-col :xs="24" :sm="24" :md="24" :lg="24" :xl="24" class="mb20">
+                        <el-form-item label="相关附件" prop="fileList">
+                            <uploaderFile :fileList="fileList" :systemName="'EMERGENCY'" :disabled="disabled"
+                                          @successUploader="successUploader"></uploaderFile>
+                        </el-form-item>
+                    </el-col>
+                </el-row>
+            </el-form>
+            <el-row :gutter="35">
+                <el-col :xs="24" :sm="24" :md="24" :lg="24" :xl="24" class="mb20">
+                    <el-tabs v-model="activeName" class="demo-tabs" @tab-click="handleClick">
+                        <el-tab-pane label="应急队伍人员" name="first" >
+                            <el-button type="primary" size="default" @click="onAddEmergencyPersonnel(ruleFormRef)" :disabled="disabled">新增
+                            </el-button>
+                            <el-table
+                                    :data="tableData"
+                                    style="width: 100%; margin-top: 15px"
+                                    ref="multipleTableRef"
+                                    :header-cell-style="{ background: '#f6f7fa', color: '#909399' }"
+                                    :disabled="disabled"
+                            >
+                                <el-table-column prop="jobNumber" label="人员工号" show-overflow-tooltip></el-table-column>
+                                <el-table-column prop="name" label="人员名称" show-overflow-tooltip></el-table-column>
+                                <el-table-column prop="phone" label="手机号码" show-overflow-tooltip></el-table-column>
+                                <el-table-column prop="position" label="职位" show-overflow-tooltip></el-table-column>
+                                <el-table-column label="操作" width="250" align="center">
+                                    <template #default="scope">
+                                        <el-button :disabled="disabled" size="small" @click="onEdit('查看应急队伍人员',scope.row.id)">查看
+                                        </el-button>
+                                        <el-button :disabled="disabled" size="small" @click="onEdit('修改应急队伍人员',scope.row.id)"
+                                                   style="margin-right: 5px">编辑
+                                        </el-button>
+                                        <el-button :disabled="disabled" size="small" @click="onRowDel(scope.row.id)"
+                                                   style="margin-right: 5px">删除
+                                        </el-button>
+                                    </template>
+                                </el-table-column>
+                            </el-table>
+                        </el-tab-pane>
+                    </el-tabs>
+                </el-col>
+            </el-row>
+            <template #footer>
+				<span class="dialog-footer">
+					<el-button @click="resetForm(ruleFormRef)" size="default">关闭</el-button>
+					<el-button size="default" v-if="disabled == true ? false : true" type="primary"
+                               @click="onSubmit(titles, ruleFormRef)">确定</el-button>
+				</span>
+            </template>
+        </el-dialog>
+        <AddEmergencyPersonnel ref="addRef" @myAdd="onMyAdd"/>
+        <DailogSearchUserManger ref="userRef" @SearchUser="onUser"/>
+    </div>
 </template>
 
 <script lang="ts">
-import {
-  reactive,
-  ref,
-  defineComponent,
-  toRefs,
-} from 'vue';
-import { ElMessage } from 'element-plus';
-import type {
-  UploadUserFile,
-  TabsPaneContext,
-  // FormInstance,
-  FormRules,
-} from 'element-plus'
+    import {
+        reactive,
+        ref,
+        defineComponent,
+        onMounted,
+        // toRefs,
+    } from 'vue';
+    import {
+        ElMessage,
+        ElMessageBox,
+    } from 'element-plus';
 
-import {
-  Search,
-  FullScreen
-} from '@element-plus/icons-vue'
-import AddEmergencyPersonnel from "/@/views/contingencyManagement/contingency/component/addEmergencyPersonnel.vue";
-import UserSelections from "/@/components/userSelections/index.vue"
-import {contingencyApi} from "/@/api/contingency";
-// 定义表格数据类型
-interface User {
-  personnelName: string
-  jobNo: string
-  phone: string;
-  position: string;
-}
+    import type {
+        UploadUserFile,
+        TabsPaneContext,
+        FormInstance,
+        FormRules,
+    } from 'element-plus'
+
+    import {
+        Search,
+        FullScreen
+    } from '@element-plus/icons-vue'
+    import AddEmergencyPersonnel from "/@/views/contingencyManagement/contingency/component/addEmergencyPersonnel.vue";
+    import DailogSearchUserManger from "/@/components/DailogSearchUserManger/index.vue"
+    import {contingencyApi} from "/@/api/contingencyManagement/contingency";
+    import {goalManagementApi} from "/@/api/goalManagement";
+    import uploaderFile from '/@/components/uploaderFile/index.vue';
+    // import {releaseDrillPlanApi} from "/@/api/releaseDrillPlan";
+
+
+    export default defineComponent({
+        name: 'openAdd',
+        components: {
+            AddEmergencyPersonnel,
+            DailogSearchUserManger,
+            uploaderFile
+        },
+        setup(prop, {emit}) {
+            const isShowDialog = ref(false);
+            const ruleFormRef = ref<FormInstance>();
+            const ruleForm = ref({
+                teamName: '', // 队伍名称
+                teamLevel: '', // 队伍级别
+                principalUid: '', // 队伍负责人
+                principalName: '',
+                principalDepartmentId: '',  //负责人部门
+                principalPhone: '', // 负责人手机
+                telephoneNumber: '', // 固定电话
+                teamDesc: '',  //队伍描述
+                fileList: [],
+                memberList: []
+            });
+            const titles = ref();
+            const disabled = ref();
+            const teamId = ref()
+            // 打开弹窗
+            const openDialog = (title: string, id: number, type: boolean) => {
+                isShowDialog.value = true;
+                titles.value = title;
+                disabled.value = type;
+                teamId.value = id
+                if (title == '查看应急队伍管理' || title == '修改应急队伍管理') {
+                    contingencyApi()
+                        .seeEmergencyTeam(id)
+                        .then((res) => {
+                            if (res.data.code == 200) {
+                                ruleForm.value = res.data.data;
+                                fileList.value = (res.data.data.fileList?res.data.data.fileList:[])
+                                initFileListData()
+                                listApi()
+                            }
+                        });
+                }
+            }
+            // 上传附件
+            const fileList = ref([])
+            const initFileListData = async () => {
+                for(var a = 0;a<fileList.value.length;a++){
+                    fileList.value[a].name = fileList.value[a].fileName
+                }
+            }
+            // 上传成功组装数据
+            const successUploader = (list) =>{
+                fileList.value = list
+                const formFileList = []
+                for(var a = 0;a<fileList.value.length;a++){
+                    formFileList.push(
+                        {
+                            fileName:fileList.value[a].fileName,
+                            fileUrl:''
+                        }
+                    )
+                }
+                ruleForm.value.fileList = formFileList
+            }
+            //定义树形下拉框
+            const principalDepartmentId = ref()
+            const data = ref()
+
+
+
+            //el-tree-select回显
+            const propse = {
+                label: 'depName',
+                children: 'children',
+            };
+            const newTreeList = [];
+            //得到部门树
+            const department = async () => {
+                await goalManagementApi()
+                    .getTreedepartment()
+                    .then((res) => {
+                        if (res.data.code == 200) {
+                            data.value = res.data.data;
+                            getTreeList(res.data.data, newTreeList);
+                        } else {
+                            ElMessage.error(res.data.msg);
+                        }
+                    });
+            };
+            // 递归树状数据且修改字段名
+            const getTreeList = (treeList, newTreeList) => {
+                treeList.map((c) => {
+                    let tempData = {
+                        depName: c.depName,
+                        value: c.depId,
+                        children: [],
+                    };
+                    if (c.children && c.children.length > 0) {
+                        tempData.children = [];
+                        getTreeList(c.children, tempData.children);
+                    }
+                    newTreeList.push(tempData);
+                });
+            };
+            onMounted(() => {
+                department();
+            });
 
 
 
 
-// 定义接口来定义对象的类型
-interface MenuDataTree {
-  id: number;
-  label: string;
-  children?: MenuDataTree[];
-}
-interface RoleState {
-  title:string,
-  // buttonName:string,
-  isShowDialog: boolean;
-  ruleForm: {
-    teamName: string;
-    teamLevel: string;
-    principalUid: number;
-    principalDepartmentId: number;
-    principalPhone: string;
-    telephoneNumber: string;
-    teamDesc: string;
-  };
-  menuData: Array<MenuDataTree>;
-}
-export default defineComponent({
-  name: 'openAdd',
-  components: {
-    AddEmergencyPersonnel,
-    UserSelections,
-  },
-  setup(prop,context) {
-    const state = reactive<RoleState>({
-      isShowDialog: false,
-      title:'',
-      // buttonName:'',
-      ruleForm: {
-        teamName: '', // 队伍名称
-        teamLevel: '', // 队伍级别
-        principalUid: 1, // 队伍负责人
-        principalDepartmentId: 2,  //负责人部门
-        principalPhone: '', // 负责人手机
-        telephoneNumber: '', // 固定电话
-        teamDesc: '',  //队伍描述
-      },
-      menuData: [],
+            // 打开用户选择弹窗
+            const userRef = ref();
+            const openUser = () => {
+                userRef.value.openDailog();
+            };
+            const onUser = (e: any) => {
+                ruleForm.value.principalUid = e[0].uid
+                ruleForm.value.principalName = e[0].realName
+            };
+            //定义tabs切换
+            const activeName = ref('first')
+            const handleClick = (tab: TabsPaneContext, event: Event) => {
+                console.log(tab, event)
+            }
+
+            // 必填项提示
+            const rules = reactive<FormRules>({
+                teamName: [
+                    {
+                        required: true,
+                        message: '队伍名称不能为空',
+                        trigger: 'change',
+                    },
+                ],
+                teamLevel: [
+                    {
+                        required: true,
+                        message: '队伍级别不能为空',
+                        trigger: 'change',
+                    },
+                ],
+                principalUid: [
+                    {
+                        required: true,
+                        message: '队伍负责人不能为空',
+                        trigger: 'change',
+                    },
+                ],
+                principalDepartmentId: [
+                    {
+                        required: true,
+                        message: '负责人部门不能为空',
+                        trigger: 'change',
+                    },
+                ],
+                principalPhone: [
+                    {
+                        required: true,
+                        message: '负责人手机不能为空',
+                        trigger: 'change',
+                    },
+                ],
+                telephoneNumber: [
+                    {
+                        required: true,
+                        message: '固定电话不能为空',
+                        trigger: 'change',
+                    },
+                ],
+            })
+            //全屏
+            const full = ref(false);
+            const toggleFullscreen = () => {
+                if (full.value == false) {
+                    full.value = true;
+                } else {
+                    full.value = false;
+                }
+            };
+            const onSubmit = async (title: string, formEl: FormInstance | undefined) => {
+                if(!ruleForm.value.fileList){
+                    ruleForm.value.fileList = []
+                }
+                if (title == '新建应急队伍管理') {
+                    if (!formEl) return;
+                    await formEl.validate((valid, fields) => {
+                        if (valid) {
+                            isShowDialog.value = false;
+                            if(teamId.value==null||teamId.value==''){
+                                contingencyApi()
+                                    .addEmergencyTeam(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 {
+                                ElMessage({
+                                    showClose: true,
+                                    message: '添加成功',
+                                    type: 'success',
+                                });
+                                emit('myAdd', true);
+                            }
+                        } else {
+                            console.log('error submit!', fields);
+                        }
+                    });
+                } else if (title == '修改应急队伍管理') {
+                    if (!formEl) return;
+                    await formEl.validate((valid, fields) => {
+                        if (valid) {
+                            isShowDialog.value = false;
+                            contingencyApi()
+                                .editEmergencyTeam(ruleForm.value)
+                                .then((res) => {
+                                    if (res.data.code == 200) {
+                                        ElMessage({
+                                            showClose: true,
+                                            message: '修改成功',
+                                            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);
+                        }
+                    });
+                    formEl.resetFields();
+                    ruleForm.value = {
+                        teamName: '', // 队伍名称
+                        teamLevel: '', // 队伍级别
+                        principalUid: '', // 队伍负责人
+                        principalDepartmentId: '',  //负责人部门
+                        principalPhone: '', // 负责人手机
+                        telephoneNumber: '', // 固定电话
+                        teamDesc: '',  //队伍描述
+                        fileList: [],
+                        memberList: []
+                    };
+                }
+            };
+            const resetForm = (formEl: FormInstance | undefined) => {
+                isShowDialog.value = false;
+                if (!formEl) return;
+                formEl.resetFields();
+                fileList.value = []
+                tableData.value=[]
+                ruleForm.value = {}
+            };
+            // 定义表格数据
+            const tableData = ref([]);
+            //添加队伍负责人弹窗
+            const addRef = ref();
+            const onAddEmergencyPersonnel = async (formEl: FormInstance | undefined) => {
+                if(!ruleForm.value.fileList){
+                    ruleForm.value.fileList = []
+                }
+                if (!formEl) return;
+                await formEl.validate((valid, fields) => {
+                    if (valid) {
+                        // isShowDialog.value = false;
+                        if(teamId.value == ''||teamId.value==null){
+                            ElMessageBox.confirm('确认添加此应急队伍?', '提示', {
+                                confirmButtonText: '确定',
+                                cancelButtonText: '取消',
+                                type: 'warning',
+                            })
+                                .then(() => {
+                                    contingencyApi()
+                                        .addEmergencyTeam(ruleForm.value)
+                                        .then((res) => {
+                                            if (res.data.code == 200) {
+                                                ElMessage({
+                                                    showClose: true,
+                                                    message: res.data.msg,
+                                                    type: 'success',
+                                                });
+                                                teamId.value = res.data.data.id
+                                                addRef.value.openDialog('新建应急队伍人员','',teamId.value);
+                                            } else {
+                                                ElMessage({
+                                                    showClose: true,
+                                                    message: res.data.msg,
+                                                    type: 'error',
+                                                });
+                                            }
+                                        });
+                                })
+                                .catch(() => {});
+
+                        }else {
+                            addRef.value.openDialog('新建应急队伍人员','',teamId.value);
+                        }
+
+
+                    } else {
+                        console.log('error submit!', fields);
+                    }
+                });
+            };
+            // 请求列表数据
+            const listApi = async () => {
+                let res = await contingencyApi().getEmergencyTeamPersonnelList(teamId.value);
+                if (res.data.code == 200) {
+                    tableData.value = res.data.data;
+                } else {
+                    ElMessage.error(res.data.msg);
+                }
+            };
+            // 新增后刷新
+            const onMyAdd = (e: object) => {
+                listApi();
+            };
+            // 打开修改弹窗
+            const onEdit = (val: string, row: object) => {
+                if (val == '查看应急队伍人员') {
+                    addRef.value.openDialog('查看应急队伍人员', row,teamId.value, true);
+                } else {
+                    addRef.value.openDialog('修改应急队伍人员', row,teamId.value, false);
+                }
+            };
+            // 删除
+            const onRowDel = (data: any) => {
+                ElMessageBox.confirm('确定删除所选项吗?', '提示', {
+                    confirmButtonText: '确认',
+                    cancelButtonText: '取消',
+                    type: 'warning',
+                }).then(() => {
+                    contingencyApi()
+                        .deleteEmergencyTeamPersonnel(data)
+                        .then((res) => {
+                            if (res.data.code == 200) {
+                                ElMessage({
+                                    showClose: true,
+                                    message: res.data.msg,
+                                    type: 'success',
+                                });
+                                listApi()
+                            } else {
+                                ElMessage({
+                                    showClose: true,
+                                    message: res.data.msg,
+                                    type: 'error',
+                                });
+                                listApi()
+                            }
+                        });
+                })
+                    .catch(() => {
+                    });
+            };
+            return {
+                openDialog,
+                fileList,
+                principalDepartmentId,
+                data,
+                activeName,
+                handleClick,
+                tableData,
+                Search,
+                resetForm,
+                isShowDialog,
+                ruleFormRef,
+                ruleForm,
+                rules,
+                addRef,
+                userRef,
+                titles,
+                disabled,
+                propse,
+                emit,
+                onSubmit,
+                openUser,
+                onAddEmergencyPersonnel,
+                toggleFullscreen,
+                FullScreen,
+                full,
+                onUser,
+                onMyAdd,
+                listApi,
+                onEdit,
+                onRowDel,
+                department,
+                teamId,
+                newTreeList,
+                successUploader,
+                initFileListData
+            };
+        },
     });
-    // 打开弹窗
-    const openDialog = (type: string, value: any) => {
-      state.isShowDialog = true;
-      if(type === '新建'){
-        state.title = '新建应急队伍管理'
-        // state.buttonName = '新增'
-        state.ruleForm = {
-          teamName: '', // 队伍名称
-          teamLevel: '', // 队伍级别
-          principalUid: 1, // 队伍负责人
-          principalDepartmentId: 2,  //负责人部门
-          principalPhone: '', // 负责人手机
-          telephoneNumber: '', // 固定电话
-          teamDesc: '',  //队伍描述
-        }
-      }else{
-        state.title = '修改应急队伍管理'
-        // state.buttonName = '确定'
-        state.ruleForm = JSON.parse(JSON.stringify(value))
-      }
-    };
-    // 上传附件
-    const fileList = ref<UploadUserFile[]>([])
-
-    //定义树形下拉框
-    const principalDepartmentId = ref()
-    const data = [
-      {
-        value: '1',
-        label: '广汇能源综合物流发展有限责任公司',
-        children: [
-          {
-            value: '1-1',
-            label: '经营班子',
-            children: [],
-          },
-        ],
-      },
-      {
-        value: '2',
-        label: '生产运行部',
-        children: [
-          {
-            value: '2-1',
-            label: '灌装一班',
-            children: []
-          },
-          {
-            value: '2-2',
-            label: '工艺四班',
-            children: [],
-          },
-        ],
-      },
-      {
-        value: '3',
-        label: '设备部',
-        children: [
-          {
-            value: '3-1',
-            label: '仪表班',
-            children: [],
-          },
-          {
-            value: '3-2',
-            label: '机修班',
-            children: [],
-          },
-        ],
-      },
-    ]
-    // 打开用户选择弹窗
-    const userRef = ref();
-    const openUser = () => {
-      userRef.value.openDialog();
-    };
-    //定义tabs切换
-    const activeName = ref('first')
-
-    const handleClick = (tab: TabsPaneContext, event: Event) => {
-      console.log(tab, event)
-    }
-
-    //定义表格数据
-    const multipleSelection = ref<User[]>([])
-    const tableData: User[] = []
-
-    //添加队伍负责人弹窗
-    const addRef = ref();
-    const onAddEmergencyPersonnel = () => {
-      addRef.value.openDialog();
-    };
-    // 必填项提示
-    const rules = reactive<FormRules>({
-      teamName: [
-        {
-          required: true,
-          message: '队伍名称不能为空',
-          trigger: 'change',
-        },
-      ],
-      teamLevel: [
-        {
-          required: true,
-          message: '队伍级别不能为空',
-          trigger: 'change',
-        },
-      ],
-      principalUid: [
-        {
-          required: true,
-          message: '队伍负责人不能为空',
-          trigger: 'change',
-        },
-      ],
-      principalDepartmentId: [
-        {
-          required: true,
-          message: '负责人部门不能为空',
-          trigger: 'change',
-        },
-      ],
-      principalPhone: [
-        {
-          required: true,
-          message: '负责人手机不能为空',
-          trigger: 'change',
-        },
-      ],
-      telephoneNumber: [
-        {
-          required: true,
-          message: '固定电话不能为空',
-          trigger: 'change',
-        },
-      ],
-    })
-    //全屏
-    const full = ref(false);
-    const toggleFullscreen = () => {
-      if (full.value == false) {
-        full.value = true;
-      } else {
-        full.value = false;
-      }
-    };
-    // 新增
-    const onSubmit = async () => {
-      if(state.title === '新建应急队伍管理'){
-        let res = await contingencyApi().addEmergencyTeam(state.ruleForm)
-        if(res.data.code === '200'){
-          ElMessage({
-            type:'success',
-            message:'队伍新增成功',
-            // duration:2000
-          })
-          state.isShowDialog = false
-          context.emit('refreshRoleList')
-        }else{
-          ElMessage({
-            type:'warning',
-            message:res.data.msg
-          })
-        }
-      }
-    else{
-        let res = await contingencyApi().editEmergencyTeam(state.ruleForm)
-        if(res.data.code === '200'){
-          ElMessage({
-            type:'success',
-            message:'队伍修改成功',
-            // duration:2000
-          })
-          state.isShowDialog = false
-          context.emit('refreshRoleList')
-        }else{
-          ElMessage({
-            type:'warning',
-            message:res.data.msg
-          })
-        }
-      }
-    };
-    return {
-      openDialog,
-      // closeDialog,
-      // isShowDialog,
-      // onCancel,
-      fileList,
-      principalDepartmentId,
-      data,
-      activeName,
-      handleClick,
-      tableData,
-      multipleSelection,
-      Search,
-      onSubmit,
-      // ruleForm,
-      // ruleFormRef,
-      rules,
-      addRef,
-      userRef,
-      openUser,
-      onAddEmergencyPersonnel,
-      toggleFullscreen,
-      FullScreen,
-      full,
-      ...toRefs(state),
-    };
-  },
-});
 </script>
 <style scoped lang="scss">
-.textarea{
-  height: 168px!important;
-}
-.textarea ::v-deep .el-textarea__inner{
-  height: 168px!important;
-}
-::v-deep .el-table__cell {
-  font-weight: 400;
-}
+    .textarea {
+        height: 168px !important;
+    }
+
+    .textarea ::v-deep .el-textarea__inner {
+        height: 168px !important;
+    }
+
+    ::v-deep .el-table__cell {
+        font-weight: 400;
+    }
 </style>
 

--
Gitblit v1.9.2