马宇豪
2023-04-14 36e71978a92ee64375b2c339e5e05d47b6b23fba
src/views/analyse/plan/index.vue
@@ -70,7 +70,9 @@
                                <el-button v-if="scope.row.planSellStatus === 1" size="small" text type="primary" :icon="Edit" @click="openPlanDialog('修改', scope.row)">编辑</el-button>
                                <el-button v-if="scope.row.identificationUserId == planState.user" size="small" text type="primary" :icon="Edit" @click="refuseIdentify(scope.row)">拒绝辨识</el-button>
                                <el-button v-if="scope.row.evaluateUserId == planState.user" size="small" text type="primary" :icon="Edit" @click="refuseEvaluate(scope.row)">拒绝评价</el-button>
                                <el-button v-if="scope.row.sceneUserId == planState.user" size="small" text type="primary" :icon="Edit" @click="refuseScene(scope.row)">拒绝现场</el-button>
<!--                                <el-button v-if="scope.row.sceneUserId == planState.user" size="small" text type="primary" :icon="Edit" @click="refuseScene(scope.row)">拒绝现场</el-button>-->
                                <el-button v-if="scope.row.identificationUserId == null" size="small" text type="primary" :icon="Edit" @click="reSendJob(scope.row,'identification')">重新指派辨识</el-button>
                                <el-button v-if="scope.row.evaluateUserId == null" size="small" text type="primary" :icon="Edit" @click="reSendJob(scope.row,'evaluate')">重新指派评价</el-button>
                                <el-button v-if="scope.row.planSellStatus === 1" size="small" text type="danger" :icon="Delete" @click="onDelPlan(scope.row)">删除</el-button>
                            </template>
                        </el-table-column>
@@ -82,19 +84,42 @@
            </div>
        </div>
        <plan-dialog ref="planDialogRef" @refresh="getPlanData"></plan-dialog>
        <el-dialog :title="planState.reSendTitle" v-model="planState.reSendDialogVisible" width="50%">
          <el-form ref="ruleFormRef" :rules="planState.rules" :model="planState.reSendForm" label-width="120px">
            <el-form-item v-if="planState.reSendTitle == '指派辨识专家'" label="选择辨识专家" prop="identificationUserId">
              <el-select v-model="planState.reSendForm.identificationUserId" style="width:100%"  placeholder="辨识专家" clearable>
                <el-option v-for="item in planState.personList" :key="item.id" :label="item.realName" :value="item.id"></el-option>
              </el-select>
            </el-form-item>
            <el-form-item v-if="planState.reSendTitle == '指派评价专家'" label="选择评价专家" prop="evaluateUserId">
              <el-select v-model="planState.reSendForm.evaluateUserId" style="width:100%"  placeholder="评价专家" clearable>
                <el-option v-for="item in planState.personList" :key="item.id" :label="item.realName" :value="item.id"></el-option>
              </el-select>
            </el-form-item>
          </el-form>
          <template #footer>
                <span class="dialog-footer" style="padding-top:10px;text-align: center !important;">
                  <el-button @click="planState.reSendDialogVisible = !planState.reSendDialogVisible" size="default">取 消</el-button>
                  <el-button type="primary" @click="onSubmitReSend(ruleFormRef)" size="default">确认指派</el-button>
                </span>
          </template>
        </el-dialog>
    </div>
</template>
<script setup lang="ts">
import {defineAsyncComponent, onMounted, reactive, ref} from "vue";
import {planApi} from "/@/api/analyse/plan";
import {ElMessage, ElMessageBox} from "element-plus";
import {ElMessage, ElMessageBox, FormInstance} from "element-plus";
import { Edit, View, Plus, Delete } from '@element-plus/icons-vue';
import {riskUnitApi} from "/@/api/analyse/riskUnit";
import {personApi} from "/@/api/basic/person";
import {useUserInfo} from "/@/stores/userInfo";
import { storeToRefs } from 'pinia';
import {userApi} from "/@/api/systemManage/user";
import {assessApplyApi} from "/@/api/analyse/assessApply";
const PlanDialog = defineAsyncComponent(() => import('./components/planDialog.vue'));
@@ -102,7 +127,7 @@
const planDialogRef = ref();
const userInfo = useUserInfo();
const { userInfos } = storeToRefs(userInfo);
const ruleFormRef = ref<FormInstance>()
const planState = reactive<PlanStateType>({
    planData: [],
    user: null,
@@ -117,18 +142,29 @@
    ],
    personList: [],
    identificationMethodList: [
    {id:1, name: 'PHA'},
    {id:2, name: 'JHA'},
    {id:3, name: 'SCL'},
    {id:4, name: 'HAZOP'},
    {id:5, name: '类比法'},
],
    evaluateMethodList: [
    {id:1, name: 'LEC'},
    {id:2, name: 'LS'},
    {id:3, name: 'MES'},
    {id:4, name: 'RS'},
]
        {id:1, name: 'PHA'},
        {id:2, name: 'JHA'},
        {id:3, name: 'SCL'},
        {id:4, name: 'HAZOP'},
        {id:5, name: '类比法'},
    ],
        evaluateMethodList: [
        {id:1, name: 'LEC'},
        {id:2, name: 'LS'},
        {id:3, name: 'MES'},
        {id:4, name: 'RS'},
    ],
    reSendTitle:'',
    reSendDialogVisible: false,
    reSendForm: {
      id: null,
      identificationUserId: null,
      evaluateUserId: null
    },
    rules: {
      identificationUserId: [{ required: true, message: '请选择辨识专家', trigger: 'blur' }],
      evaluateUserId: [{ required: true, message: '请选择评价专家', trigger: 'blur' }]
    }
    // deviceUnitList: [
    //     {id:1, name: '台'},
    //     {id:2, name: '个'},
@@ -183,55 +219,117 @@
};
const refuseIdentify = async(val: PlanType)=>{
  let res = await planApi().refuseIdentify({ id: val.id });
  if (res.data.code === 100) {
    ElMessage({
      type: 'success',
      duration: 2000,
      message: '拒绝成功'
    });
    await getPlanData();
  } else {
    ElMessage({
      type: 'warning',
      message: res.data.msg
    });
  ElMessageBox.confirm(`此操作将拒绝作为该计划:“${val.assessPlanName}”的辨识专家,是否继续?`, '提示', {
    confirmButtonText: '确认',
    cancelButtonText: '取消',
    type: 'warning'
  })
      .then(async () => {
        let res = await planApi().refuseIdentify({ id: val.id });
        if (res.data.code === 100) {
          ElMessage({
            type: 'success',
            duration: 2000,
            message: '拒绝成功'
          });
          await getPlanData();
        } else {
          ElMessage({
            type: 'warning',
            message: res.data.msg
          });
        }
      })
      .catch((error) => {
      });
}
const reSendJob= async(val: PlanType,type:string)=>{
  planState.reSendForm = {
    id: val.id,
    identificationUserId: null,
    evaluateUserId: null
  }
  if(type=='identification'){
    planState.reSendTitle = '指派辨识专家'
  }else{
    planState.reSendTitle = '指派评价专家'
  }
  planState.reSendDialogVisible = true
}
const onSubmitReSend = async (formEl: FormInstance | undefined) => {
  if (!formEl) return
  await formEl.validate(async(valid, fields) => {
    if (valid) {
      let res = await planApi().reSendJob(planState.reSendForm);
      if(res.data.code === 100){
        ElMessage({
          type: 'success',
          message: '重新指派成功'
        });
      }else{
        ElMessage({
          type: 'warning',
          message: res.data.msg
        });
      }
      planState.reSendForm = {
        id: null,
        identificationUserId: null,
        evaluateUserId: null
      },
      planState.reSendDialogVisible = false
      getPlanData()
    } else {
      console.log('error submit!', fields)
    }
  })
}
const refuseEvaluate = async(val: PlanType)=>{
  let res = await planApi().refuseEvaluate({ id: val.id });
  if (res.data.code === 100) {
    ElMessage({
      type: 'success',
      duration: 2000,
      message: '拒绝成功'
    });
    await getPlanData();
  } else {
    ElMessage({
      type: 'warning',
      message: res.data.msg
    });
  }
  ElMessageBox.confirm(`此操作将拒绝作为该计划:“${val.assessPlanName}”的评价专家,是否继续?`, '提示', {
    confirmButtonText: '确认',
    cancelButtonText: '取消',
    type: 'warning'
  })
      .then(async () => {
        let res = await planApi().refuseEvaluate({ id: val.id });
        if (res.data.code === 100) {
          ElMessage({
            type: 'success',
            duration: 2000,
            message: '拒绝成功'
          });
          await getPlanData();
        } else {
          ElMessage({
            type: 'warning',
            message: res.data.msg
          });
        }
      })
      .catch((error) => {
      });
}
const refuseScene = async(val: PlanType)=>{
  let res = await planApi().refuseScene({ id: val.id });
  if (res.data.code === 100) {
    ElMessage({
      type: 'success',
      duration: 2000,
      message: '拒绝成功'
    });
    await getPlanData();
  } else {
    ElMessage({
      type: 'warning',
      message: res.data.msg
    });
  }
}
// const refuseScene = async(val: PlanType)=>{
//   let res = await planApi().refuseScene({ id: val.id });
//   if (res.data.code === 100) {
//     ElMessage({
//       type: 'success',
//       duration: 2000,
//       message: '拒绝成功'
//     });
//     await getPlanData();
//   } else {
//     ElMessage({
//       type: 'warning',
//       message: res.data.msg
//     });
//   }
// }
const onDelPlan = (val: PlanType) => {
    ElMessageBox.confirm(`此操作将永久删除该计划:“${val.assessPlanName}”,是否继续?`, '提示', {