cyy пре 4 дана
родитељ
комит
993b429ff5
2 измењених фајлова са 415 додато и 144 уклоњено
  1. 368 128
      src/views/platform/risk/riskDetail.vue
  2. 47 16
      src/views/platform/risk/riskV2.vue

+ 368 - 128
src/views/platform/risk/riskDetail.vue

@@ -236,13 +236,19 @@
               <template slot-scope="{ row }">
                 <el-select
                   v-model="row.yan_zhong_cheng_d"
-                  placeholder="请选择"
-                  :disabled="readonly"
+                  :placeholder="
+                    isMultiType && !row.feng_xian_lei_xin
+                      ? '请先选择风险类型'
+                      : '请选择'
+                  "
+                  :disabled="
+                    readonly || (isMultiType && !row.feng_xian_lei_xin)
+                  "
                   size="mini"
                   @change="culRate(row)"
                 >
                   <el-option
-                    v-for="item in yan_zhong_cheng_d_List"
+                    v-for="item in getRowDegreeList(row)"
                     :key="item"
                     :label="item"
                     :value="item"
@@ -258,13 +264,19 @@
               <template slot-scope="{ row }">
                 <el-select
                   v-model="row.fa_sheng_pin_du_"
-                  placeholder="请选择"
-                  :disabled="readonly"
+                  :placeholder="
+                    isMultiType && !row.feng_xian_lei_xin
+                      ? '请先选择风险类型'
+                      : '请选择'
+                  "
+                  :disabled="
+                    readonly || (isMultiType && !row.feng_xian_lei_xin)
+                  "
                   size="mini"
                   @change="culRate(row)"
                 >
                   <el-option
-                    v-for="item in fa_sheng_pin_du_List"
+                    v-for="item in getRowGailvList(row)"
                     :key="item"
                     :label="item"
                     :value="item"
@@ -281,13 +293,19 @@
               <template slot-scope="{ row }">
                 <el-select
                   v-model="row.ke_jian_ce_du_"
-                  placeholder="请选择"
-                  :disabled="readonly"
+                  :placeholder="
+                    isMultiType && !row.feng_xian_lei_xin
+                      ? '请先选择风险类型'
+                      : '请选择'
+                  "
+                  :disabled="
+                    readonly || (isMultiType && !row.feng_xian_lei_xin)
+                  "
                   size="mini"
                   @change="culRate(row)"
                 >
                   <el-option
-                    v-for="item in ke_jian_ce_du_List"
+                    v-for="item in getRowJianceList(row)"
                     :key="item"
                     :label="item"
                     :value="item"
@@ -300,6 +318,28 @@
               label="风险系数"
               width="70"
             />
+            <el-table-column
+              v-if="isMultiType"
+              prop="feng_xian_lei_xin"
+              label="风险类型"
+              width="180"
+            >
+              <template slot-scope="{ row }">
+                <el-radio-group
+                  v-model="row.feng_xian_lei_xin"
+                  size="mini"
+                  :disabled="readonly"
+                  @change="handleRowTypeChange(row)"
+                >
+                  <el-radio
+                    v-for="item in typeList"
+                    :key="item"
+                    :label="item"
+                    >{{ item }}</el-radio
+                  >
+                </el-radio-group>
+              </template>
+            </el-table-column>
             <el-table-column
               prop="feng_xian_deng_ji"
               label="风险等级"
@@ -534,6 +574,7 @@ export default {
       tableList: [],
       Ids: [],
       fengXianJiSuan: [],
+      configByType: {},
       muban: '2',
       leixing: '安全',
       riskResponse: ['风险降低', '风险接受', '风险回避'],
@@ -601,6 +642,36 @@ export default {
           return false
         }
       }
+    },
+    typeList() {
+      const val = this.params && this.params.feng_xian_lei_xin
+      if (!val) return []
+      const list = String(val)
+        .split(',')
+        .map((item) => item.trim())
+        .filter(Boolean)
+      const order = ['质量', '安全']
+      return order
+        .filter((item) => list.includes(item))
+        .concat(list.filter((item) => !order.includes(item)))
+    },
+    isMultiType() {
+      return this.typeList.length > 1
+    },
+    singleType() {
+      return this.typeList.length === 1 ? this.typeList[0] : ''
+    },
+    exportColumns() {
+      const cols = { ...this.tableCloumns }
+      if (!this.isMultiType) return cols
+      const result = {}
+      Object.keys(cols).forEach((key) => {
+        if (key === 'yan_zhong_cheng_d') {
+          result.feng_xian_lei_xin = '风险类型'
+        }
+        result[key] = cols[key]
+      })
+      return result
     }
   },
   watch: {
@@ -658,7 +729,8 @@ export default {
                     xian_xing_kong_zh: item.gong_zuo_miao_shu,
                     ni_cai_qu_cuo_shi: '',
                     zhi_ding_ren_: '',
-                    qian_zai_yuan_yin: ''
+                    qian_zai_yuan_yin: '',
+                    feng_xian_lei_xin: this.isMultiType ? '' : this.singleType
                   })
                 }
               }
@@ -745,7 +817,10 @@ export default {
     async getTableData() {
       this.loading = true
       // console.log(this.params)
-      if (!this.params.id_) return
+      if (!this.params.id_) {
+        this.loading = false
+        return
+      }
       // const sql = `select * from t_fxsbpgb2 where parent_id_ = '${this.params.id_}' and find_in_set(bian_zhi_ren_, '${this.readonly ? this.rowParams.bian_zhi_ren_ : this.userId}')`
       const params = [
         this.params.id_,
@@ -791,120 +866,231 @@ export default {
       } else if (this.muban === '3') {
         this.content[3] = this.fengXianDengJi3
       }
-      // 获取风险等级相关
-      // const degreeSql = `select feng_xian_lei_xin,yan_zhong_cheng_d, fen_ji_, miao_shu_ FROM t_yzcdfjbzb WHERE zi_fen_lei_ ='严重程度' and di_dian_ = '${this.level}' and mo_ban_fen_lei_='${this.muban}' and feng_xian_lei_xin='${this.leixing}' ORDER BY fen_ji_ ASC`
-      // const gailvSql = `select feng_xian_lei_xin,yan_zhong_cheng_d, fen_ji_, miao_shu_ FROM t_yzcdfjbzb WHERE zi_fen_lei_ ='发生概率' and di_dian_ = '${this.level}' and mo_ban_fen_lei_='${this.muban}' and feng_xian_lei_xin='${this.leixing}' ORDER BY fen_ji_ ASC`
-      // const dengjiSql = `select feng_xian_lei_xin,yan_zhong_cheng_d, fen_ji_, miao_shu_ FROM t_yzcdfjbzb WHERE zi_fen_lei_ ='风险等级' and di_dian_ = '${this.level}' and mo_ban_fen_lei_='${this.muban}' and feng_xian_lei_xin='${this.leixing}'`
-      // const jianCeSql = `select feng_xian_lei_xin,yan_zhong_cheng_d, fen_ji_, miao_shu_ FROM t_yzcdfjbzb WHERE zi_fen_lei_ ='可检测度' and di_dian_ = '${this.level}' and mo_ban_fen_lei_='${this.muban}' and feng_xian_lei_xin='${this.leixing}' ORDER BY fen_ji_ ASC`
-      Promise.all([
+      if (this.muban === '1' || this.muban === '3') {
+        this.content[2].hide = true
+      } else {
+        this.content[2].hide = false
+      }
+      this.tableList.forEach((item) => {
+        if (!item.feng_xian_lei_xin) {
+          this.$set(
+            item,
+            'feng_xian_lei_xin',
+            this.isMultiType ? '' : this.singleType
+          )
+        }
+      })
+      try {
+        await this.loadRiskConfigs()
+      } catch (error) {
+        this.$message.warning(error.message)
+      } finally {
+        this.loading = false
+      }
+    },
+    pickQueryData(response) {
+      if (
+        response &&
+        response.variables != null &&
+        response.variables.data != null &&
+        response.variables.data.length > 0
+      ) {
+        return response.variables.data
+      }
+      return []
+    },
+    buildConfigWords(degreeData, gailvData, dengjiData, jianCeData) {
+      let degreeWord = ''
+      let gailvWord = ''
+      let dengjiWord = ''
+      let jianCeWord = ''
+      for (const el of degreeData) {
+        degreeWord += `${el.fen_ji_}级:${el.yan_zhong_cheng_d},${el.miao_shu_}\n`
+      }
+      for (const el of gailvData) {
+        gailvWord += `${el.fen_ji_}级:${el.yan_zhong_cheng_d},${el.miao_shu_}\n`
+      }
+      for (const el of dengjiData) {
+        if (this.muban === '1') {
+          dengjiWord += `${el.fen_ji_}:${el.miao_shu_}\n`
+        } else {
+          dengjiWord += `${el.fen_ji_}:${el.yan_zhong_cheng_d},${el.miao_shu_}\n`
+        }
+      }
+      for (const el of jianCeData) {
+        jianCeWord += `${el.fen_ji_}级:${el.yan_zhong_cheng_d},${el.miao_shu_}\n`
+      }
+      return { degreeWord, gailvWord, dengjiWord, jianCeWord }
+    },
+    async fetchTypeConfig(type) {
+      const responses = await Promise.all([
         this.$common.request('query', {
           key: 'getRiskConfigWithOrder',
-          params: ['严重程度', this.level, this.muban, this.leixing]
+          params: ['严重程度', this.level, this.muban, type]
         }),
         this.$common.request('query', {
           key: 'getRiskConfigWithOrder',
-          params: ['发生概率', this.level, this.muban, this.leixing]
+          params: ['发生概率', this.level, this.muban, type]
         }),
         this.$common.request('query', {
           key: 'getRiskConfig',
-          params: ['风险等级', this.level, this.muban, this.leixing]
+          params: ['风险等级', this.level, this.muban, type]
         }),
         this.$common.request('query', {
           key: 'getRiskConfigWithOrder',
-          params: ['可检测度', this.level, this.muban, this.leixing]
+          params: ['可检测度', this.level, this.muban, type]
         })
       ])
-        .then((responses) => {
-          let degreeData = []
-          let gailvData = []
-          let dengjiData = []
-          let jianCeData = []
-
-          if (
-            responses[0].variables != null &&
-            responses[0].variables.data != null &&
-            responses[0].variables.data.length > 0
-          ) {
-            degreeData = responses[0].variables.data
-          }
-          if (
-            responses[1].variables != null &&
-            responses[1].variables.data != null &&
-            responses[1].variables.data.length > 0
-          ) {
-            gailvData = responses[1].variables.data
-          }
-          if (
-            responses[2].variables != null &&
-            responses[2].variables.data != null &&
-            responses[2].variables.data.length > 0
-          ) {
-            dengjiData = responses[2].variables.data
-          }
-          if (
-            responses[3].variables != null &&
-            responses[3].variables.data != null &&
-            responses[3].variables.data.length > 0
-          ) {
-            jianCeData = responses[3].variables.data
-          }
-          ;(this.muban === '1' || this.muban === '3') &&
-            (this.content[2].hide = true)
-          if (
-            degreeData.length === 0 ||
-            gailvData.length === 0 ||
-            dengjiData.length === 0 ||
-            (this.muban === '2' && jianCeData.length === 0)
-          ) {
-            throw new Error(
-              `检测到风险类型为${this.leixing}且计算方式为'${
-                this.culWays[this.muban] || this.muban
-              }'的配置数据不完整,建议配置完成后再使用!`
-            )
-          }
-          let degreeWord = ''
-          let gailvWord = ''
-          let dengjiWord = ''
-          let jianCeWord = ''
-          for (const el of degreeData) {
-            degreeWord += `${el.fen_ji_}级:${el.yan_zhong_cheng_d},${el.miao_shu_}\n`
-          }
-          for (const el of gailvData) {
-            gailvWord += `${el.fen_ji_}级:${el.yan_zhong_cheng_d},${el.miao_shu_}\n`
-          }
-          for (const el of dengjiData) {
-            if (this.muban === '1') {
-              dengjiWord += `${el.fen_ji_}:${el.miao_shu_}\n`
-            } else {
-              dengjiWord += `${el.fen_ji_}:${el.yan_zhong_cheng_d},${el.miao_shu_}\n`
-            }
-          }
-          for (const el of jianCeData) {
-            jianCeWord += `${el.fen_ji_}级:${el.yan_zhong_cheng_d},${el.miao_shu_}\n`
-          }
-          if (degreeData.length > 0) {
-            this.content[0].value = degreeWord
-            this.yan_zhong_cheng_d_List = degreeData.map((item) => item.fen_ji_)
-          }
-          if (gailvData.length > 0) {
-            this.content[1].value = gailvWord
-            this.fa_sheng_pin_du_List = gailvData.map((item) => item.fen_ji_)
-          }
-          if (jianCeData.length > 0) {
-            this.content[2].value = jianCeWord
-            this.ke_jian_ce_du_List = jianCeData.map((item) => item.fen_ji_)
-          }
-          if (dengjiData.length > 0) {
-            this.content[3].value = dengjiWord
-          }
-          this.fengXianJiSuan = dengjiData
-          this.loading = false
-        })
-        .catch((error) => {
-          // 处理错误
-          this.$message.warning(error.message)
-          this.loading = false
-        })
+      const degreeData = this.pickQueryData(responses[0])
+      const gailvData = this.pickQueryData(responses[1])
+      const dengjiData = this.pickQueryData(responses[2])
+      const jianCeData = this.pickQueryData(responses[3])
+      const incomplete =
+        degreeData.length === 0 ||
+        gailvData.length === 0 ||
+        dengjiData.length === 0 ||
+        (this.muban === '2' && jianCeData.length === 0)
+      const words = this.buildConfigWords(
+        degreeData,
+        gailvData,
+        dengjiData,
+        jianCeData
+      )
+      return {
+        type,
+        incomplete,
+        degreeList: degreeData.map((item) => item.fen_ji_),
+        gailvList: gailvData.map((item) => item.fen_ji_),
+        jianCeList: jianCeData.map((item) => item.fen_ji_),
+        fengXianJiSuan: dengjiData,
+        ...words
+      }
+    },
+    async loadRiskConfigs() {
+      const types = this.typeList
+      this.configByType = {}
+      if (!types.length) {
+        throw new Error('未选择风险类型!')
+      }
+      const configs = await Promise.all(
+        types.map((type) => this.fetchTypeConfig(type))
+      )
+      const incomplete = configs.filter((item) => item.incomplete)
+      if (incomplete.length) {
+        const names = incomplete.map((item) => item.type).join('、')
+        throw new Error(
+          `检测到风险类型为${names}且计算方式为'${
+            this.culWays[this.muban] || this.muban
+          }'的配置数据不完整,建议配置完成后再使用!`
+        )
+      }
+      const configByType = {}
+      configs.forEach((item) => {
+        configByType[item.type] = item
+      })
+      this.configByType = configByType
+      if (this.isMultiType) {
+        const joinBlock = (key) =>
+          configs.map((item) => `【${item.type}】\n${item[key] || ''}`).join('\n')
+        this.content[0].value = joinBlock('degreeWord')
+        this.content[1].value = joinBlock('gailvWord')
+        this.content[2].value = joinBlock('jianCeWord')
+        this.content[3].value = joinBlock('dengjiWord')
+      } else {
+        const current = configs[0]
+        this.content[0].value = current.degreeWord
+        this.content[1].value = current.gailvWord
+        this.content[2].value = current.jianCeWord
+        this.content[3].value = current.dengjiWord
+        if (current.degreeList.length) {
+          this.yan_zhong_cheng_d_List = current.degreeList
+        }
+        if (current.gailvList.length) {
+          this.fa_sheng_pin_du_List = current.gailvList
+        }
+        if (current.jianCeList.length) {
+          this.ke_jian_ce_du_List = current.jianCeList
+        }
+        this.fengXianJiSuan = current.fengXianJiSuan
+      }
+    },
+    getRowTypeConfig(row) {
+      const type = this.getRowType(row)
+      return (type && this.configByType[type]) || null
+    },
+    getRowType(row) {
+      if (this.isMultiType) {
+        return row && row.feng_xian_lei_xin ? row.feng_xian_lei_xin : ''
+      }
+      return (
+        (row && row.feng_xian_lei_xin) ||
+        this.singleType ||
+        this.leixing ||
+        ''
+      )
+    },
+    getRowDegreeList(row) {
+      const config = this.getRowTypeConfig(row)
+      if (config) return config.degreeList || []
+      return this.isMultiType ? [] : this.yan_zhong_cheng_d_List
+    },
+    getRowGailvList(row) {
+      const config = this.getRowTypeConfig(row)
+      if (config) return config.gailvList || []
+      return this.isMultiType ? [] : this.fa_sheng_pin_du_List
+    },
+    getRowJianceList(row) {
+      const config = this.getRowTypeConfig(row)
+      if (config) return config.jianCeList || []
+      return this.isMultiType ? [] : this.ke_jian_ce_du_List
+    },
+    isTypeConfigReady(type) {
+      const config = this.configByType[type]
+      return !!(config && !config.incomplete)
+    },
+    handleRowTypeChange(row) {
+      if (!row.feng_xian_lei_xin) {
+        this.$set(row, 'yan_zhong_cheng_d', '')
+        this.$set(row, 'fa_sheng_pin_du_', '')
+        this.$set(row, 'ke_jian_ce_du_', '')
+        this.$set(row, 'feng_xian_zhi_shu', '')
+        this.$set(row, 'feng_xian_deng_ji', '')
+        return
+      }
+      const degreeList = this.getRowDegreeList(row)
+      const gailvList = this.getRowGailvList(row)
+      const jianceList = this.getRowJianceList(row)
+      let invalid = false
+      if (row.yan_zhong_cheng_d && !degreeList.includes(row.yan_zhong_cheng_d)) {
+        this.$set(row, 'yan_zhong_cheng_d', '')
+        invalid = true
+      }
+      if (row.fa_sheng_pin_du_ && !gailvList.includes(row.fa_sheng_pin_du_)) {
+        this.$set(row, 'fa_sheng_pin_du_', '')
+        invalid = true
+      }
+      if (row.ke_jian_ce_du_ && !jianceList.includes(row.ke_jian_ce_du_)) {
+        this.$set(row, 'ke_jian_ce_du_', '')
+        invalid = true
+      }
+      if (invalid) {
+        this.$set(row, 'feng_xian_zhi_shu', '')
+        this.$set(row, 'feng_xian_deng_ji', '')
+        this.$message.warning(
+          `风险类型已切换为「${row.feng_xian_lei_xin}」,部分评分选项不适用,请重新打分`
+        )
+        return
+      }
+      const keptYingDu = row.feng_xian_ying_du
+      this.culRate(row)
+      if (keptYingDu) {
+        this.$set(row, 'feng_xian_ying_du', keptYingDu)
+      }
+      if (row.feng_xian_zhi_shu) {
+        this.$message.success(
+          `已按「${row.feng_xian_lei_xin}」重新计算风险系数`
+        )
+      }
     },
     // 选择器切换
     onSelectorChange() {
@@ -950,12 +1136,21 @@ export default {
     // 计算风险指数
     culRate(row) {
       try {
+        const type = this.getRowType(row)
+        if (this.isMultiType && !type) {
+          return
+        }
+        const typeConfig = this.getRowTypeConfig(row)
+        const fengXianJiSuan =
+          (typeConfig && typeConfig.fengXianJiSuan) ||
+          this.fengXianJiSuan ||
+          []
         if (this.muban === '1') {
           if (row.yan_zhong_cheng_d && row.fa_sheng_pin_du_) {
             let degree = ''
             let rate = ''
             rate = +row.yan_zhong_cheng_d * +row.fa_sheng_pin_du_
-            if (this.fengXianJiSuan.length === 0) {
+            if (fengXianJiSuan.length === 0) {
               if (rate >= 1 && rate < 4) {
                 degree = '低'
               }
@@ -979,8 +1174,8 @@ export default {
                 }
               }
             } else {
-              for (let i = 0; i < this.fengXianJiSuan.length; i++) {
-                const item = this.fengXianJiSuan[i]
+              for (let i = 0; i < fengXianJiSuan.length; i++) {
+                const item = fengXianJiSuan[i]
                 if (item.yan_zhong_cheng_d) {
                   const arr = JSON.parse(item.yan_zhong_cheng_d) || []
                   for (let j = 0; j < arr.length; j++) {
@@ -1019,7 +1214,7 @@ export default {
               +row.yan_zhong_cheng_d *
               +row.fa_sheng_pin_du_ *
               +row.ke_jian_ce_du_
-            if (this.fengXianJiSuan.length === 0) {
+            if (fengXianJiSuan.length === 0) {
               if (rate >= 1 && rate <= 8) {
                 degree = '可忽略的'
               }
@@ -1036,8 +1231,8 @@ export default {
                 degree = '不可接受的'
               }
             } else {
-              for (let i = 0; i < this.fengXianJiSuan.length; i++) {
-                const item = this.fengXianJiSuan[i]
+              for (let i = 0; i < fengXianJiSuan.length; i++) {
+                const item = fengXianJiSuan[i]
                 if (item.yan_zhong_cheng_d) {
                   const [a, b] = item.yan_zhong_cheng_d.split('-')
                   if (a && b) {
@@ -1066,7 +1261,7 @@ export default {
             let degree = ''
             let rate = ''
             rate = +row.yan_zhong_cheng_d * +row.fa_sheng_pin_du_
-            if (this.fengXianJiSuan.length === 0) {
+            if (fengXianJiSuan.length === 0) {
               if (rate >= 1 && rate <= 4) {
                 degree = '低风险'
               }
@@ -1077,8 +1272,8 @@ export default {
                 degree = '高风险'
               }
             } else {
-              for (let i = 0; i < this.fengXianJiSuan.length; i++) {
-                const item = this.fengXianJiSuan[i]
+              for (let i = 0; i < fengXianJiSuan.length; i++) {
+                const item = fengXianJiSuan[i]
                 if (item.yan_zhong_cheng_d) {
                   const [a, b] = item.yan_zhong_cheng_d.split('-')
                   if (a && b) {
@@ -1114,6 +1309,21 @@ export default {
       }
       for (let i = 0; i < this.tableList.length; i++) {
         const item = this.tableList[i]
+        if (this.isMultiType) {
+          if (!item.feng_xian_lei_xin) {
+            throw new Error(`第${i + 1}行未选择风险类型!`)
+          }
+          if (!this.typeList.includes(item.feng_xian_lei_xin)) {
+            throw new Error(`第${i + 1}行风险类型不在主单范围内!`)
+          }
+          if (!this.isTypeConfigReady(item.feng_xian_lei_xin)) {
+            throw new Error(
+              `第${i + 1}行风险类型「${item.feng_xian_lei_xin}」的配置数据不完整!`
+            )
+          }
+        } else {
+          item.feng_xian_lei_xin = this.singleType || item.feng_xian_lei_xin || ''
+        }
         if (!item.feng_xian_zhi_shu) {
           throw new Error(`第${i + 1}行未计算风险指数,请填写相关数据!`)
         }
@@ -1227,6 +1437,12 @@ export default {
         // 保存去掉校验逻辑,直接保存数据
         // this.check()
         await this.getIsFinish()
+        this.tableList.forEach((item) => {
+          if (!this.isMultiType) {
+            item.feng_xian_lei_xin =
+              this.singleType || item.feng_xian_lei_xin || ''
+          }
+        })
         const curIds = this.tableList.map((item) => item.shi_bie_xiang_)
 
         // 计算需要增加项
@@ -1400,7 +1616,7 @@ export default {
       })
       console.log(exportData)
 
-      this.xlsx(exportData, this.tableCloumns, '风险项' + this.getTimeStamp())
+      this.xlsx(exportData, this.exportColumns, '风险项' + this.getTimeStamp())
       this.$message.success('风险项导出成功!')
     },
     importTableList() {
@@ -1416,7 +1632,7 @@ export default {
         })
         const workSheet = workBook.Sheets[workBook.SheetNames[0]]
         const data = xlsx.utils.sheet_to_json(workSheet)
-        const xlsxData = this.switchKey(data, this.tableCloumns)
+        const xlsxData = this.switchKey(data, this.exportColumns)
         const importData = this.switchImportData(xlsxData)
         if (importData) {
           this.tableList = importData
@@ -1463,15 +1679,33 @@ export default {
         )
 
         if (i) {
+          if (this.isMultiType) {
+            if (!i.feng_xian_lei_xin) {
+              message.push(`第${index + 1}行风险类型不能为空!`)
+              flag = false
+            } else if (!this.typeList.includes(i.feng_xian_lei_xin)) {
+              message.push(
+                `第${index + 1}行风险类型只能是${this.typeList.join('或')}!`
+              )
+              flag = false
+            } else {
+              item.feng_xian_lei_xin = i.feng_xian_lei_xin
+            }
+          } else {
+            item.feng_xian_lei_xin =
+              this.singleType || item.feng_xian_lei_xin || ''
+          }
+          const degreeList = this.getRowDegreeList(item)
+          const gailvList = this.getRowGailvList(item)
           if (i.yan_zhong_cheng_d) {
-            if (!this.yan_zhong_cheng_d_List.includes(i.yan_zhong_cheng_d)) {
-              message.push('严重程度请填写1-5数字!')
+            if (!degreeList.includes(i.yan_zhong_cheng_d)) {
+              message.push('严重程度请按对应风险类型配置填写!')
               flag = false
             }
           }
           if (i.fa_sheng_pin_du_) {
-            if (!this.fa_sheng_pin_du_List.includes(i.fa_sheng_pin_du_)) {
-              message.push('发生频度请填写1-5数字!')
+            if (!gailvList.includes(i.fa_sheng_pin_du_)) {
+              message.push('发生频度请按对应风险类型配置填写!')
               flag = false
             }
           }
@@ -1496,7 +1730,13 @@ export default {
             'userName',
             'userId'
           )
-          this.culRate(item)
+          if (
+            !this.isMultiType ||
+            (item.feng_xian_lei_xin &&
+              this.typeList.includes(item.feng_xian_lei_xin))
+          ) {
+            this.culRate(item)
+          }
         }
       })
 

+ 47 - 16
src/views/platform/risk/riskV2.vue

@@ -126,20 +126,14 @@
           </el-descriptions-item>
           <el-descriptions-item label="风险类型">
             <div>
-              <el-radio
-                v-model="infoFxssbData.feng_xian_lei_xin"
-                label="质量"
+              <el-checkbox-group
+                v-model="fengXianLeiXinList"
                 size="mini"
-                :disabled="isEdit"
-                >质量</el-radio
-              >
-              <el-radio
-                v-model="infoFxssbData.feng_xian_lei_xin"
-                label="安全"
-                size="mini"
-                :disabled="isEdit"
-                >安全</el-radio
+                @change="onFengXianLeiXinChange"
               >
+                <el-checkbox label="质量" :disabled="isEdit">质量</el-checkbox>
+                <el-checkbox label="安全" :disabled="isEdit">安全</el-checkbox>
+              </el-checkbox-group>
             </div>
           </el-descriptions-item>
           <el-descriptions-item label="时机" :span="1">
@@ -375,6 +369,7 @@ export default {
         }
       ],
       isFirst: true,
+      fengXianLeiXinList: [],
       userId: userId,
       position: position,
       level: level.second || level.first,
@@ -511,9 +506,11 @@ export default {
           if (this.isFirst) {
             this.isFirst = false
           } else {
-            this.infoFxssbData.fan_wei_ = `本实验室与${val}相关所有活动`
-            this.infoFxssbData.mu_di_ = `通过对实验室(${val}活动)进行风险评估,识别实验室在(${val}活动)方面存在的潜在风险,评估风险影响程度,制定风险管理策略,减少不利后果发生的概率和影响程度。`
-            this.infoFxssbData.shi_wu_shuo_ming_ = `年度:${this.infoFxssbData.nian_du_};组长:${this.infoFxssbData.zu_chang_};评估开始日期:${this.infoFxssbData.kai_shi_ri_qi_};风险类型:${val}`
+            const types = this.parseFengXianLeiXin(val)
+            const label = types.join('、')
+            this.infoFxssbData.fan_wei_ = `本实验室与${label}相关所有活动`
+            this.infoFxssbData.mu_di_ = `通过对实验室(${label}活动)进行风险评估,识别实验室在(${label}活动)方面存在的潜在风险,评估风险影响程度,制定风险管理策略,减少不利后果发生的概率和影响程度。`
+            this.infoFxssbData.shi_wu_shuo_ming_ = `年度:${this.infoFxssbData.nian_du_};组长:${this.infoFxssbData.zu_chang_};评估开始日期:${this.infoFxssbData.kai_shi_ri_qi_};风险类型:${types.join(',')}`
           }
         }
       }
@@ -635,7 +632,13 @@ export default {
                         shi_wu_shuo_ming_: this.infoFxssbData.shi_wu_shuo_ming_,
                         yuan_zhi_shu_: item.feng_xian_zhi_shu,
                         kong_zhi_fang_fa_: item.xian_xing_kong_zh,
-                        feng_xian_lei_xin: this.infoFxssbData.feng_xian_lei_xin,
+                        feng_xian_lei_xin:
+                          item.feng_xian_lei_xin ||
+                          (this.parseFengXianLeiXin(
+                            this.infoFxssbData.feng_xian_lei_xin
+                          ).length === 1
+                            ? this.infoFxssbData.feng_xian_lei_xin
+                            : ''),
                         qian_fu_jian_: this.infoFxssbData.yi_ju_wen_jian_id,
                         ji_hua_bian_hao_: this.infoFxssbData.ji_hua_bian_hao_,
                         ni_cai_qu_kong_zh: item.ni_cai_qu_cuo_shi,
@@ -876,6 +879,9 @@ export default {
       if (!this.infoFxssbData.bian_zhi_bu_men_) {
         throw new Error('请选择编制部门!')
       }
+      if (!this.infoFxssbData.feng_xian_lei_xin) {
+        throw new Error('请选择风险类型!')
+      }
       if (!this.infoFxssbData.ji_suan_fang_shi_) {
         throw new Error('请选择风险系数计算方式!')
       }
@@ -1065,10 +1071,34 @@ export default {
           })
       })
     },
+    parseFengXianLeiXin(val) {
+      if (!val) return []
+      const list = Array.isArray(val)
+        ? val.filter(Boolean)
+        : String(val)
+            .split(',')
+            .map((item) => item.trim())
+            .filter(Boolean)
+      const order = ['质量', '安全']
+      return order
+        .filter((item) => list.includes(item))
+        .concat(list.filter((item) => !order.includes(item)))
+    },
+    onFengXianLeiXinChange(list) {
+      const sorted = this.parseFengXianLeiXin(list)
+      this.fengXianLeiXinList = sorted
+      this.infoFxssbData.feng_xian_lei_xin = sorted.join(',')
+    },
+    syncFengXianLeiXinList() {
+      this.fengXianLeiXinList = this.parseFengXianLeiXin(
+        this.infoFxssbData.feng_xian_lei_xin
+      )
+    },
     async init() {
       this.isEdit = !!(this.params && this.params.id_)
       if (this.isEdit) {
         this.infoFxssbData = this.params
+        this.syncFengXianLeiXinList()
         console.log('infoFxssbData', this.infoFxssbData)
         this.preParams = JSON.parse(JSON.stringify(this.params))
         this.isPingGuRen =
@@ -1102,6 +1132,7 @@ export default {
         this.infoFxssbData.kai_shi_ri_qi_ = dayjs().format('YYYY-MM-DD')
         this.infoFxssbData.jie_shu_ri_qi_ = dayjs().format('YYYY-MM-DD')
         this.infoFxssbData.feng_xian_lei_xin = '质量'
+        this.syncFengXianLeiXinList()
         this.infoFxssbData.shi_ji_ = '定期评估'
         this.infoFxssbData.fan_wei_ = '本实验室与质量相关所有活动'
         this.infoFxssbData.fang_fa_ = '定量风险评估法'