123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809 |
- <template>
- <span>
- <audit-form-top-banner
- :handel-save-form="saveForm"
- :form-data="mode"
- @handelSaveForm="saveForm"
- >
- <sd-detail-form
- ref="docform"
- page-id="risk/criteria/riskCriteria"
- :record-id="this.$route.query.record ? parseInt(this.$route.query.record) : null"
- :class="$style.form"
- :read-only="false"
- @close="close(true)"
- @saved="saved"
- >
- <template v-slot="{ model, fields }">
- <table>
- <tr>
- <td style="border: none">
- <audit-advanced-group
- :expand="expand"
- expand-str="expand"
- :group-label="'基本信息'"
- tablestyle="''"
- @changedClick="changedClick"
- ></audit-advanced-group>
- </td>
- </tr>
- </table>
- <table v-show="expand">
- <tr>
- <!-- 准则版本编号 -->
- <sd-form-item-td v-show="fnIni(model)" name="criteriaCode">
- <template v-slot:read-and-edit="{ editable }">
- {{ model.criteriaCode }}
- </template>
- </sd-form-item-td>
- <!-- id -->
- <sd-form-item-td name="id" :hidden="true"> </sd-form-item-td>
- <!-- 准则适用范围 -->
- <sd-form-item-td name="criteriaDeptOpt">
- <template v-slot:read-and-edit="{ editable }">
- <sd-group-picker
- v-if="editable"
- v-model="model.criteriaDeptOpt"
- :root-node="rootNode"
- @change="depChange"
- ></sd-group-picker>
- <div v-else>{{ model.criteriaDeptName }}</div>
- </template>
- </sd-form-item-td>
- <sd-form-item-td name="criteriaDeptId" :hidden="true"> </sd-form-item-td>
- <sd-form-item-td name="criteriaDeptCode" :hidden="true"> </sd-form-item-td>
- <sd-form-item-td name="criteriaDeptName" :hidden="true"> </sd-form-item-td>
- </tr>
- <tr>
- <!-- 状态 -->
- <sd-form-item-td name="state" :colspan="3"> </sd-form-item-td>
- </tr>
- <tr>
- <!-- 说明 -->
- <sd-form-item-td name="signify" :colspan="3">
- <template v-slot:read-and-edit="{ editable }">
- <a-textarea
- v-if="editable"
- v-model="model.signify"
- :auto-size="{ maxRows: 3, minRows: 3 }"
- ></a-textarea>
- <div v-else>
- {{ model.signify }}
- </div>
- </template>
- </sd-form-item-td>
- </tr>
- <tr>
- <!-- 创建人 -->
- <sd-form-item-td name="creatorName" label="创建人员" />
- <!-- 创建日期 -->
- <sd-form-item-td name="creationTime" label="创建日期" />
- </tr>
- </table>
- <table>
- <tr
- ><td :colspan="4">
- <sd-form-item name="riskPossibilityEntitys" :label="null">
- <template v-slot:read-and-edit="{ editable }">
- <audit-advanced-group
- :expand="possExpand"
- expand-str="possExpand"
- group-label="发生可能性(P)"
- @changedClick="changedClick"
- >
- <template>
- <xm-child-table
- ref="possTable"
- v-model="model.riskPossibilityEntitys"
- :class="$style.possChild"
- :label="null"
- :read-only="true"
- :addbuttonvisiable="false"
- :fields="
- [
- {
- caption: '序号',
- name: 'sortNum',
- dataType: 'number',
- },
- ].concat(Array.from(fields.riskPossibilityEntitys.attr.dync))
- "
- :columns="possColumns"
- >
- <!-- 定义 -->
- <template v-slot:definition="{ text, record, field, value, index }">
- <a-input v-if="editable" v-model="record.definition"></a-input>
- <div v-else>
- {{ record.definition }}
- </div>
- </template>
- <!-- 评率/可能性 -->
- <template v-slot:frequency="{ text, record, field, value, index }">
- <a-input v-if="editable" v-model="record.frequency"></a-input>
- <div v-else>
- {{ record.frequency }}
- </div>
- </template>
- </xm-child-table>
- </template>
- </audit-advanced-group>
- </template>
- </sd-form-item>
- </td>
- </tr>
- </table>
- <table>
- <tr
- ><td :colspan="4">
- <sd-form-item name="riskDegreeEntitys" :label="null">
- <template v-slot:read-and-edit="{ editable }">
- <audit-advanced-group
- :expand="degreeExpand"
- expand-str="degreeExpand"
- group-label="风险影响程度(C)"
- @changedClick="changedClick"
- >
- <template>
- <risk-criteria-child-table
- ref="dgreeTable"
- v-model="degreeData"
- :select-columns="selectColumnsLength"
- :class="$style.dgreeChild"
- :label="null"
- :read-only="!editable"
- :fields="degreeFields"
- :columns="degreeColumns"
- @addData="addData"
- @deleteData="deleteData"
- >
- <template
- v-for="fieldNum in 100"
- :slot="'field' + fieldNum"
- slot-scope="{ text, record, field, value, index }"
- >
- <span v-if="index === 0 && field.name === 'field1'" :key="fieldNum">
- {{ text }}
- </span>
- <span v-else :key="fieldNum" :class="$style.titleSpan">
- <a-checkbox
- v-if="index === 0"
- v-model="selectColumns[field.name]"
- :class="$style.titleCheckbox"
- />
- <a-input
- v-model="record['field' + fieldNum]"
- :class="{
- [$style.requireInputXm]:
- errorField['field' + fieldNum + '-' + index],
- }"
- @blur="inputChange($event, 'field' + fieldNum + '-' + index)"
- @change="inputChange($event, 'field' + fieldNum + '-' + index)"
- ></a-input>
- </span>
- </template>
- </risk-criteria-child-table>
- <div
- class="ant-form-explain"
- :class="{
- [$style.requireDivXm]: !canSumibt,
- [$style.requireDivNoneXm]: canSumibt,
- }"
- >风险影响程度内容不能为空</div
- >
- </template>
- </audit-advanced-group>
- </template>
- </sd-form-item>
- </td>
- </tr>
- </table>
- <table>
- <tr
- ><td :colspan="4">
- <sd-form-item name="riskLevelEntitys" :label="null">
- <template v-slot:read-and-edit="{ editable }">
- <audit-advanced-group
- :expand="levelExpand"
- expand-str="levelExpand"
- group-label="风险等级"
- @changedClick="changedClick"
- >
- <template>
- <xm-child-table
- ref="levelTable"
- v-model="model.riskLevelEntitys"
- :class="$style.levelChild"
- :label="null"
- :read-only="true"
- :fields="
- [
- {
- caption: '序号',
- name: 'sortNum',
- dataType: 'number',
- },
- ].concat(Array.from(fields.riskLevelEntitys.attr.dync))
- "
- :columns="levelColumns"
- >
- <!-- 最小值 -->
- <template v-slot:minNum="{ text, record, field, value, index }">
- <a-input-number
- v-if="editable"
- v-model="record.minNum"
- :min="0"
- :precision="1"
- ></a-input-number>
- <div v-else>
- {{ record.minNum }}
- </div>
- </template>
- <!-- 最大值 -->
- <template v-slot:maxNum="{ text, record, field, value, index }">
- <a-input-number
- v-if="editable"
- v-model="record.maxNum"
- :min="0"
- :precision="1"
- ></a-input-number>
- <div v-else>
- {{ record.maxNum }}
- </div>
- </template>
- </xm-child-table>
- </template>
- </audit-advanced-group>
- </template>
- </sd-form-item>
- </td>
- </tr>
- </table>
- </template>
- </sd-detail-form>
- </audit-form-top-banner>
- </span>
- </template>
- <script>
- import { getUserInfo } from '@/common/store-mixin'
- import { message, Modal } from '@/common/one-ui'
- import crossWindowWatcher from '@/common/services/cross-window-watcher'
- import auditFormTopBanner from '@product/iam/components/audit-form-top-banner'
- import auditAdvancedGroup from '@product/iam/components/audit-advanced-group.vue'
- import auditAdvancedGroupMixins from '@product/iam/components/audit-advanced-group-mixins'
- import riskCriteriaChildTable from './components/risk-criteria-child-table.vue'
- import riskCriteriaService from './risk-criteria-service'
- import components from './_import-components/risk-criteria-form-import'
- // 修改主子表的首行title名
- export default {
- name: 'RiskCriteriaForm',
- metaInfo: {
- title: '风险准则',
- },
- components: {
- ...components,
- auditAdvancedGroup,
- auditFormTopBanner,
- riskCriteriaChildTable,
- },
- mixins: [auditAdvancedGroupMixins],
- data() {
- return {
- rootNode: {},
- errorField: {},
- canSumibt: true,
- infoDataKey: 0,
- selectColumns: {},
- mode: null,
- childTableKey: 0, // 刷新子表组件
- inited: false,
- degreeExpand: true,
- possExpand: true,
- levelExpand: true,
- expand: true,
- planId: null,
- possColumns: [
- {
- title: '分值',
- dataIndex: 'sortNum',
- width: '100px',
- customRender: (text, record, index) => `${index + 1}`,
- },
- {
- dataIndex: 'definition',
- title: '定义',
- },
- { dataIndex: 'frequency', title: '频率/可能性' },
- { dataIndex: 'criteriaId', title: '风险准则ID', sdHidden: true },
- ],
- possData: [
- {
- definition: '很低',
- frequency: '每年发生一次或者几乎不发生,只特定时期发生',
- },
- {
- definition: '低',
- frequency: '每季度发生一次',
- },
- {
- definition: '一般',
- frequency: '每月发生一次',
- },
- {
- definition: '高',
- frequency: '每周发生一次',
- },
- {
- definition: '很高',
- frequency: '每天发生一次',
- },
- ],
- childTableId: {},
- degreeIndex: 2,
- degreeColumns: [
- {
- dataIndex: 'sortNum',
- title: '分值',
- width: '100px',
- customRender: (text, record, index) => {
- if (index === 0) return '分值'
- return index
- },
- },
- { dataIndex: 'field1', title: 'field1' },
- ],
- degreeFields: [
- {
- name: 'sortNum',
- caption: '序号',
- },
- {
- dataType: 'string',
- caption: 'field1',
- name: 'field1',
- },
- ],
- degreeData: [
- {
- field1: '影响',
- },
- {
- field1: '轻微',
- },
- {
- field1: '中等',
- },
- {
- field1: '重要',
- },
- {
- field1: '重大',
- },
- {
- field1: '灾难性',
- },
- ],
- levelColumns: [
- {
- title: '序号',
- dataIndex: 'sortNum',
- width: '100px',
- customRender: (text, record, index) => `${index + 1}`,
- },
- {
- dataIndex: 'riskLevel',
- title: '风险等级',
- },
- { dataIndex: 'maxNum', title: '最大值(含等于)' },
- { dataIndex: 'minNum', title: '最小值(含等于)' },
- { dataIndex: 'criteriaId', title: '风险准则ID', sdHidden: true },
- ],
- levelData: [
- {
- riskLevel: '高风险',
- minNum: null,
- maxNum: null,
- },
- {
- riskLevel: '中风险',
- minNum: null,
- maxNum: null,
- },
- {
- riskLevel: '低风险',
- minNum: null,
- maxNum: null,
- },
- ],
- expressions: [],
- isIni: false,
- }
- },
- computed: {
- selectColumnsLength() {
- let length = 0
- for (const checked in this.selectColumns) {
- if (this.selectColumns[checked]) {
- length++
- }
- }
- return length
- },
- },
- mounted() {
- this.getUserRootNode()
- // 重画表格表头
- const setHeader = setInterval(() => {
- if (document.querySelector('.level-child_risk-criteria-form_product table thead')) {
- clearInterval(setHeader)
- this.fnSetLevelTableHeader()
- }
- }, 200)
- },
- methods: {
- // 获取用户默认根节点机构
- getUserRootNode() {
- const userInfo = getUserInfo()
- const deptId = userInfo.deptId
- riskCriteriaService.getUserHavePermissionOrg().then((res) => {
- riskCriteriaService.findIamOrgId(deptId).then((data) => {
- const node = res.data.editNodes.find((item) => {
- return item.id === data.data
- })
- if (node) {
- this.rootNode = {
- code: node.props.orgId + '',
- name: node.text,
- }
- }
- })
- })
- },
- depChange(deptList) {
- const ids = []
- const codes = []
- const names = []
- deptList.forEach((item) => {
- ids.push(item.id)
- codes.push(item.code)
- names.push(item.name)
- })
- this.$refs.docform.setFieldValue('criteriaDeptId', ids.join(','))
- this.$refs.docform.setFieldValue('criteriaDeptCode', codes.join(','))
- this.$refs.docform.setFieldValue('criteriaDeptName', names.join(','))
- },
- // 动态增加列
- addData() {
- this.degreeColumns.push({
- dataIndex: 'field' + this.degreeIndex,
- title: 'field' + this.degreeIndex,
- })
- this.degreeFields.push({
- dataType: 'string',
- caption: 'field' + this.degreeIndex,
- name: 'field' + this.degreeIndex,
- required: true,
- })
- this.degreeData.forEach((item) => {
- item['field' + this.degreeIndex] = ''
- })
- this.degreeIndex++
- this.$refs.dgreeTable.fnupdate(this.degreeData)
- },
- // 删除列
- deleteData() {
- for (const fieldKey in this.selectColumns) {
- if (this.selectColumns[fieldKey]) {
- let colIndex
- this.degreeColumns.forEach((item, index) => {
- if (item.dataIndex === fieldKey) colIndex = index
- })
- this.degreeColumns.splice(colIndex, 1)
- let fieldIndex
- this.degreeFields.forEach((item, index) => {
- if (item.name === fieldKey) fieldIndex = index
- })
- this.degreeFields.splice(fieldIndex, 1)
- this.degreeData.forEach((item) => {
- delete item[fieldKey]
- })
- }
- }
- this.selectColumns = {}
- },
- fnIni(model) {
- if (this.isIni) return true
- this.isIni = true
- if (this.$route.query.record) {
- // 获取风险影响程度数据
- this.fnGetDegreeTableData(model)
- } else {
- // 发生可能行(P)
- model.riskPossibilityEntitys = this.possData
- // 风险影响程度
- model.riskDegreeEntitys = this.degreeData
- // 风险等级
- model.riskLevelEntitys = this.levelData
- }
- return true
- },
- close(flag) {
- crossWindowWatcher.notifyChange(this.$route.fullPath, flag)
- window.close()
- },
- saved() {
- message.success({ content: '保存成功!' }, 1).then(() => {
- this.close(true)
- })
- },
- // 保存
- saveForm() {
- // 保存前先将动态表格拆分为正常数据
- this.fnSetDegreeTableData()
- this.checkDegreeTableData()
- setTimeout(() => {
- this.$refs.docform.validateFields().then((valid) => {
- // 检查分值不能冲突
- if (valid && this.canSumibt && this.checkRiskLevelEntitys()) {
- // 如果是作废状态,则不判断是否有启用的文件
- // const isStart = this.$refs.docform.getFieldValue('state')
- // if (isStart === '1') {
- // 先注释掉判断重复启用的代码,以防后边还需要使用,暂时先不判断
- this.$refs.docform.saveBtnClick()
- // return
- // }
- // // 启用状态才继续判断是否有其他启用的准则
- // const errDep = []
- // // 判断组织是否存在启用的准则
- // const deptList = this.$refs.docform.getFieldValue('criteriaDeptOpt')
- // const promiseAll = []
- // const deptName = []
- // const id = this.$route.query.record || ''
- // deptList.forEach((item) => {
- // promiseAll.push(
- // riskCriteriaServices.checkDept({
- // criteriaDeptCode: item.code,
- // id: id,
- // })
- // )
- // deptName.push(item.name)
- // })
- // // 全部一起请求
- // let isErr = false
- // Promise.all(promiseAll)
- // .then((resAll) => {
- // for (let index = 0; index < resAll.length; index++) {
- // if (!resAll[index].data) {
- // errDep.push(deptName[index])
- // }
- // }
- // })
- // .catch((err) => {
- // isErr = true
- // message.error('判断启用准则接口请求错误,请联系管理员')
- // console.log(err)
- // })
- // .finally(() => {
- // // 如果存在已启动的
- // if (errDep.length > 0) {
- // message.warning(errDep.join(',') + '(单位)的风险准则已启用,请重新选择', 1)
- // } else {
- // if (!isErr) {
- // this.$refs.docform.saveBtnClick()
- // }
- // }
- // })
- }
- })
- }, 0)
- },
- checkDegreeTableData() {
- this.canSumibt = true
- this.errorField = []
- // 判断是否有未填项目
- this.degreeData.forEach((item, index) => {
- for (const key in item) {
- if (!item[key]) {
- this.errorField[key + '-' + index] = true
- } else {
- this.errorField[key + '-' + index] = false
- }
- }
- })
- for (const key in this.errorField) {
- if (this.errorField[key]) {
- this.canSumibt = false
- }
- }
- },
- // 检查分值不能冲突
- checkRiskLevelEntitys() {
- const levelData = this.$refs.docform.getFieldValue('riskLevelEntitys')
- const errorStr = []
- const firstMin = parseFloat(levelData[0].minNum)
- const firstMax = parseFloat(levelData[0].maxNum)
- const secondMin = parseFloat(levelData[1].minNum)
- const secondMax = parseFloat(levelData[1].maxNum)
- const threeMin = parseFloat(levelData[2].minNum)
- const threeMax = parseFloat(levelData[2].maxNum)
- if (firstMin > firstMax) {
- errorStr.push('高风险最小值不能大于最大值')
- }
- if (secondMin > secondMax) {
- errorStr.push('中风险最小值不能大于最大值')
- }
- if (threeMin > threeMax) {
- errorStr.push('低风险最小值不能大于最大值')
- }
- if (firstMin <= secondMax) {
- errorStr.push('高风险最小值不能小于或等于中风险最大值')
- }
- if (secondMin <= threeMax) {
- errorStr.push('中风险最小值不能小于或等于低风险最大值')
- }
- if (errorStr.length > 0) {
- Modal.warning({
- title: '风险等级分值',
- content: (h) => {
- const info = []
- errorStr.forEach((item, index) => {
- info.push(index + 1 + '.' + item)
- info.push(h('br'))
- })
- return h('div', null, info)
- },
- })
- return false
- }
- return true
- },
- inputChange(e, fieldName) {
- // 输入框变化时
- if ((e.currentTarget.value === '') | !e.currentTarget.value) {
- this.errorField[fieldName] = true
- } else {
- this.errorField[fieldName] = false
- }
- // this.checkDegreeTableData()
- },
- // 获取风险影响程度数据
- fnGetDegreeTableData(model) {
- const [sequence, score1, score2, score3, score4, score5] = this.degreeData
- const tableData = model.riskDegreeEntitys || []
- if (tableData.length > 0) {
- this.degreeIndex = 1
- }
- tableData.forEach((item) => {
- if (this.degreeIndex !== 1) {
- // 增加下标
- this.degreeColumns.push({
- dataIndex: 'field' + this.degreeIndex,
- title: 'field' + this.degreeIndex,
- })
- this.degreeFields.push({
- dataType: 'string',
- caption: 'field' + this.degreeIndex,
- name: 'field' + this.degreeIndex,
- required: true,
- })
- }
- this.childTableId['field' + this.degreeIndex] = item.id
- sequence['field' + this.degreeIndex] = item.sequence
- score1['field' + this.degreeIndex] = item.score1
- score2['field' + this.degreeIndex] = item.score2
- score3['field' + this.degreeIndex] = item.score3
- score4['field' + this.degreeIndex] = item.score4
- score5['field' + this.degreeIndex] = item.score5
- this.degreeIndex++
- })
- },
- // 设置风险影响程度数据
- fnSetDegreeTableData() {
- const [sequence, score1, score2, score3, score4, score5] = this.degreeData
- const submitTableData = []
- this.degreeColumns.forEach((item, index) => {
- if (index < 1) return
- submitTableData.push({
- sequence: sequence[item.dataIndex] ? sequence[item.dataIndex] : '',
- score1: score1[item.dataIndex] ? score1[item.dataIndex] : '',
- score2: score2[item.dataIndex] ? score2[item.dataIndex] : '',
- score3: score3[item.dataIndex] ? score3[item.dataIndex] : '',
- score4: score4[item.dataIndex] ? score4[item.dataIndex] : '',
- score5: score5[item.dataIndex] ? score5[item.dataIndex] : '',
- id: this.childTableId[item.dataIndex] ? this.childTableId[item.dataIndex] : null,
- criteriaId: this.$refs.docform.getFieldValue('id'),
- })
- })
- if (submitTableData.length > 0) {
- this.$refs.docform.setFieldValue('riskDegreeEntitys', submitTableData)
- } else {
- this.$refs.docform.setFieldValue('riskDegreeEntitys', [])
- }
- },
- // 重画表格表头
- fnSetLevelTableHeader() {
- document.querySelector('.level-child_risk-criteria-form_product table thead').innerHTML = `
- <tr>
- <th class="header-cell_sd-resizable-th_common ant-table-row-cell-break-word" rowspan="2" style="width:100px" key="score">序号</th>
- <th class="header-cell_sd-resizable-th_common ant-table-row-cell-break-word" rowspan="2" key="riskLevel">风险等级</th>
- <th class="header-cell_sd-resizable-th_common ant-table-row-cell-break-word" colspan="2">评估区间</th>
- </tr>
- <tr>
- <th class="header-cell_sd-resizable-th_common ant-table-row-cell-break-word"><label class="ant-form-item-required">最小值(含等于)</label></th>
- <th class="header-cell_sd-resizable-th_common ant-table-row-cell-break-word"><label class="ant-form-item-required">最大值(含等于)</label></th>
- </tr>
- `
- document.querySelector(
- '.level-child_risk-criteria-form_product table colgroup'
- ).innerHTML = `<col style="width: 100px; min-width: 100px;"><col style=""><col style=""><col style="">`
- },
- },
- }
- </script>
- <style module lang="scss">
- @use '@/common/design' as *;
- @import '@/webflow/sd-flow-form.scss';
- .btnselect {
- position: relative;
- top: 4px;
- right: 200px;
- float: right;
- .batchselect {
- z-index: 100;
- margin-left: 10px;
- }
- }
- .tablexm tr td {
- border: none !important;
- }
- .poss-child {
- :global(.header_xm-child-table_product) {
- display: none;
- }
- :global(.menu_sd-table-header_common) {
- display: none;
- }
- }
- .level-child {
- :global(.ant-input-number) {
- width: 100%;
- }
- }
- .dgree-child {
- tr:first-child {
- background: #fafafa;
- font-weight: bold;
- color: #000;
- td {
- border-top: none !important;
- border-right: none !important;
- border-left: none !important;
- }
- }
- .title-span {
- display: flex;
- .title-checkbox {
- margin-right: 10px;
- }
- }
- .require_input_xm {
- border: 1px solid #e02020;
- }
- }
- .require_div_xm {
- color: #e02020;
- }
- .require_div_none_xm {
- display: none;
- }
- </style>
|