[update] 删除国标,外标,AddForm组件的特殊判断,外部标准库lang中多余部分
This commit is contained in:
@@ -159,19 +159,14 @@ import UploadFile from '../UploadFile'
|
||||
import StandardSelection from '../selection/StandardSelection'
|
||||
import {
|
||||
FieldType,
|
||||
StandardGradeClassify,
|
||||
StandardProperty,
|
||||
IsTrial,
|
||||
EnterpriseStandardStatus,
|
||||
StandardSource,
|
||||
StandardStatus, EnterpriseStandardCode, EnterpriseNameCode
|
||||
StandardSource
|
||||
} from '../../enums/commonEnums'
|
||||
import JMultipleDatePicker from '../JMultipleDatePicker'
|
||||
import UserSelection from '../selection/UserSelection'
|
||||
import { getAction } from '../../api/manage.js'
|
||||
import { ajaxGetDictItems, getDictByCode, getFormDictTreeList } from '../../api/api.js'
|
||||
import { ajaxGetDictItems, getFormDictTreeList } from '../../api/api.js'
|
||||
import TreeSelection from '../selection/TreeSelection'
|
||||
import { getStandardGradeClassification } from '../../api/enterpriseStandardLibraryApi'
|
||||
import STreeSelect from '../STreeSelect'
|
||||
|
||||
export default {
|
||||
@@ -211,7 +206,7 @@ export default {
|
||||
}
|
||||
}
|
||||
},
|
||||
// 标准模块的区分:1,国内; 2,国外;3,企标
|
||||
// 标准模块的区分:1,外来标准;3,企标
|
||||
flag: {
|
||||
type: String,
|
||||
default: null
|
||||
@@ -303,16 +298,6 @@ export default {
|
||||
}
|
||||
}
|
||||
},
|
||||
mounted () {
|
||||
// 如果是企标就获取企标级别映射数据
|
||||
if (this.flag === StandardSource.ENTERPRISE.value) {
|
||||
getStandardGradeClassification().then(res => {
|
||||
if (res.success) {
|
||||
this.standardGradeClassification = res.result
|
||||
}
|
||||
})
|
||||
}
|
||||
},
|
||||
data () {
|
||||
return {
|
||||
FieldType,
|
||||
@@ -337,134 +322,18 @@ export default {
|
||||
}
|
||||
},
|
||||
watch: {
|
||||
// 国内的零部件分类、适用认证、适用车型和标准性质关联,准入标准必填,非准入标准不必填
|
||||
'formInline.standard_property' () {
|
||||
this.handleDomesticSpecialCheck()
|
||||
this.handleStatePropertyCheck()
|
||||
},
|
||||
// 标准等级分类改变后授权部门需要自动带出
|
||||
'formInline.grade_classification' (val) {
|
||||
if (val && this.flag === StandardSource.ENTERPRISE.value && !this.isEditSetData) {
|
||||
if (val === StandardGradeClassify.ZERO_LEVEL.value) {
|
||||
// 选的是0级,授权部门带出不可编辑
|
||||
this.formInline.auth_dept = this.standardGradeClassification.find(item => item.level + '' === '0').deptIds
|
||||
if (!this.innerDisabledField.includes('auth_dept')) {
|
||||
this.innerDisabledField.push('auth_dept')
|
||||
}
|
||||
} else if (val === StandardGradeClassify.ONE_LEVEL.value) {
|
||||
// 选的是1级
|
||||
// // 带出3级的部门:起草部门
|
||||
// this.formInline.auth_dept = this.standardGradeClassification.find(item => item.level + '' === '3').deptIds
|
||||
// 带出主起草单位
|
||||
this.formInline.auth_dept = this.formInline.main_drafting_unit
|
||||
// 设置可选择项
|
||||
this.departSelectRange = this.standardGradeClassification.find(item => item.level + '' === '1').deptIds.split(',')
|
||||
this.formInline = JSON.parse(JSON.stringify(this.formInline))
|
||||
// 设置授权部门可编辑
|
||||
if (this.innerDisabledField.includes('auth_dept')) {
|
||||
this.innerDisabledField = this.innerDisabledField.filter(item => item !== 'auth_dept')
|
||||
}
|
||||
} else if (val === StandardGradeClassify.TWO_LEVEL.value) {
|
||||
// 选的是2级
|
||||
// // 带出3级的部门:起草部门
|
||||
// this.formInline.auth_dept = this.standardGradeClassification.find(item => item.level + '' === '3').deptIds
|
||||
// 带出主起草单位
|
||||
this.formInline.auth_dept = this.formInline.main_drafting_unit
|
||||
// 设置可选择项
|
||||
this.departSelectRange = this.standardGradeClassification.find(item => item.level + '' === '2').deptIds.split(',')
|
||||
this.formInline = JSON.parse(JSON.stringify(this.formInline))
|
||||
// 设置授权部门可编辑
|
||||
if (this.innerDisabledField.includes('auth_dept')) {
|
||||
this.innerDisabledField = this.innerDisabledField.filter(item => item !== 'auth_dept')
|
||||
}
|
||||
} else if (val === StandardGradeClassify.THREE_LEVEL.value) {
|
||||
// // 选的是3级,授权部门带出不可编辑
|
||||
// this.formInline.auth_dept = this.standardGradeClassification.find(item => item.level + '' === '3').deptIds
|
||||
// 选的是3级,带出主起草单位
|
||||
this.formInline.auth_dept = this.formInline.main_drafting_unit
|
||||
if (!this.innerDisabledField.includes('auth_dept')) {
|
||||
this.innerDisabledField.push('auth_dept')
|
||||
}
|
||||
}
|
||||
} else if (val && this.flag === StandardSource.ENTERPRISE.value && this.isEditSetData) {
|
||||
if (val === StandardGradeClassify.ZERO_LEVEL.value) {
|
||||
// 选的是0级,授权部门带出不可编辑
|
||||
if (!this.innerDisabledField.includes('auth_dept')) {
|
||||
this.innerDisabledField.push('auth_dept')
|
||||
}
|
||||
} else if (val === StandardGradeClassify.ONE_LEVEL.value) {
|
||||
// 选的是1级
|
||||
// 设置可选择项
|
||||
this.departSelectRange = this.standardGradeClassification.find(item => item.level + '' === '1').deptIds.split(',')
|
||||
// 设置授权部门可编辑
|
||||
if (this.innerDisabledField.includes('auth_dept')) {
|
||||
this.innerDisabledField = this.innerDisabledField.filter(item => item !== 'auth_dept')
|
||||
}
|
||||
} else if (val === StandardGradeClassify.TWO_LEVEL.value) {
|
||||
// 选的是2级
|
||||
// 设置可选择项
|
||||
this.departSelectRange = this.standardGradeClassification.find(item => item.level + '' === '2').deptIds.split(',')
|
||||
// 设置授权部门可编辑
|
||||
if (this.innerDisabledField.includes('auth_dept')) {
|
||||
this.innerDisabledField = this.innerDisabledField.filter(item => item !== 'auth_dept')
|
||||
}
|
||||
} else if (val === StandardGradeClassify.THREE_LEVEL.value) {
|
||||
// 选的是3级,授权部门带出不可编辑
|
||||
if (!this.innerDisabledField.includes('auth_dept')) {
|
||||
this.innerDisabledField.push('auth_dept')
|
||||
}
|
||||
}
|
||||
} else if (!val && this.flag === StandardSource.ENTERPRISE.value && !this.isEditSetData) {
|
||||
// 清空授权部门的可选项
|
||||
this.departSelectRange = []
|
||||
// 设置授权部门可编辑
|
||||
if (this.innerDisabledField.includes('auth_dept')) {
|
||||
this.innerDisabledField = this.innerDisabledField.filter(item => item !== 'auth_dept')
|
||||
}
|
||||
// 清空授权部门
|
||||
this.formInline.auth_dept = ''
|
||||
}
|
||||
},
|
||||
// 主起草单位改变后,需要将选中的主起草单位增加到授权部门
|
||||
'formInline.main_drafting_unit' (val) {
|
||||
if (val) {
|
||||
if (this.formInline.grade_classification === StandardGradeClassify.ONE_LEVEL.value ||
|
||||
this.formInline.grade_classification === StandardGradeClassify.TWO_LEVEL.value) {
|
||||
// 标准等级分类是1级或者2级需要,把主起草单位追加到授权部门
|
||||
let authDeptArr = (this.formInline.auth_dept || '').split(',')
|
||||
// 把旧的主起草部门刨出去,否则每换一次主起草单位都会累计到授权部门
|
||||
authDeptArr = authDeptArr.filter(item => item !== this.oldMainDraftingUnit)
|
||||
authDeptArr.push(val)
|
||||
this.formInline.auth_dept = authDeptArr.join(',')
|
||||
} else if (this.formInline.grade_classification === StandardGradeClassify.THREE_LEVEL.value) {
|
||||
// 标准等级分类是3级,把授权部门替换成主起草单位
|
||||
this.formInline.auth_dept = val
|
||||
}
|
||||
this.oldMainDraftingUnit = val
|
||||
}
|
||||
},
|
||||
// 企标是否试行改变,标准状态需要跟着变,试行周期必填校验也跟着变
|
||||
// 企标是否试行改变,试行周期必填校验跟着变
|
||||
'formInline.try_flag' (val) {
|
||||
if (val && this.flag === StandardSource.ENTERPRISE.value && !this.isEditSetData) {
|
||||
if (val === IsTrial.YES.value) {
|
||||
// 试行,标准状态改为试运行,
|
||||
this.formInline.standard_state = EnterpriseStandardStatus.TRIAL_OPERATION.value
|
||||
// 试行周期给默认值24
|
||||
this.formInline.trial_period = '24'
|
||||
this.formInline.trial_period = '12'
|
||||
this.formInline = JSON.parse(JSON.stringify(this.formInline))
|
||||
// 试行,标准状态不可修改
|
||||
if (!this.innerDisabledField.includes('standard_state')) {
|
||||
this.innerDisabledField.push('standard_state')
|
||||
}
|
||||
// 试行,试行周期必填
|
||||
this.rules.trial_period[0].required = true
|
||||
} else {
|
||||
// 试行周期置空
|
||||
this.formInline.trial_period = undefined
|
||||
// 不试行,标准状态可修改
|
||||
if (this.innerDisabledField.includes('standard_state')) {
|
||||
this.innerDisabledField = this.innerDisabledField.filter(item => item !== 'standard_state')
|
||||
}
|
||||
// 不试行,试行周期非必填
|
||||
this.rules.trial_period[0].required = false
|
||||
}
|
||||
@@ -478,59 +347,6 @@ export default {
|
||||
this.rules.trial_period[0].required = false
|
||||
}
|
||||
}
|
||||
},
|
||||
// 编辑回显标准状态是废止,标准状态不可更改
|
||||
'formInline.standard_state' (val) {
|
||||
if (val && this.isEditSetData && (
|
||||
(this.flag === StandardSource.ENTERPRISE.value && val === EnterpriseStandardStatus.ABOLISH.value) ||
|
||||
(this.flag === StandardSource.DOMESTIC.value && val === StandardStatus.ABOLISH.value) ||
|
||||
(this.flag === StandardSource.OVERSEAS.value && val === StandardStatus.ABOLISH.value))) {
|
||||
// 状态是废止
|
||||
if (!this.innerDisabledField.includes('standard_state')) {
|
||||
this.innerDisabledField.push('standard_state')
|
||||
}
|
||||
} else if (this.formInline.try_flag === IsTrial.YES.value && this.flag === StandardSource.ENTERPRISE.value && this.isEditSetData) {
|
||||
// 企标,是否试行选的是,需要标准状态不可编辑
|
||||
if (!this.innerDisabledField.includes('standard_state')) {
|
||||
this.innerDisabledField.push('standard_state')
|
||||
}
|
||||
} else {
|
||||
// 状态不是废止
|
||||
if (this.innerDisabledField.includes('standard_state')) {
|
||||
this.innerDisabledField = this.innerDisabledField.filter(item => item !== 'standard_state')
|
||||
}
|
||||
}
|
||||
// 起草、征求依据、报批、废止状态时发布日期、实施日期不必填
|
||||
this.handleRequiredByState(val)
|
||||
this.handleStatePropertyCheck()
|
||||
},
|
||||
// 企标:企业标准代号选Q,企业名称代号只能选ZZ\ZR;标准代号选TS,企业名称代号只能选ZZ
|
||||
'formInline.standard_code' (val) {
|
||||
if (this.flag === StandardSource.ENTERPRISE.value && !this.isEditSetData) {
|
||||
if (val === EnterpriseStandardCode.Q.value) {
|
||||
// 选的Q,企业名称代号只能选ZZ\ZR
|
||||
this.optionsData.name_code.map(item => {
|
||||
if (![EnterpriseNameCode.ZZ.value, EnterpriseNameCode.ZR.value].includes(item.value)) {
|
||||
item.disabled = true
|
||||
} else {
|
||||
item.disabled = false
|
||||
}
|
||||
})
|
||||
} else if (val === EnterpriseStandardCode.TS.value) {
|
||||
// 选的TS,企业名称代号只能选ZZ
|
||||
this.optionsData.name_code.map(item => {
|
||||
if (![EnterpriseNameCode.ZZ.value].includes(item.value)) {
|
||||
item.disabled = true
|
||||
} else {
|
||||
item.disabled = false
|
||||
}
|
||||
})
|
||||
}
|
||||
if (this.formInline.name_code !== EnterpriseNameCode.ZZ.value) {
|
||||
this.formInline.name_code = undefined
|
||||
this.formInline = Object.assign({}, this.formInline)
|
||||
}
|
||||
}
|
||||
}
|
||||
},
|
||||
methods: {
|
||||
@@ -578,7 +394,6 @@ export default {
|
||||
|
||||
// 处理标准选择不能选自己
|
||||
this.excludeStandardNumbers = this.formInline[this.excludeStandardValFormFields]
|
||||
this.handleDomesticSpecialCheck()
|
||||
this.loading = false
|
||||
} else {
|
||||
this.loading = false
|
||||
@@ -681,16 +496,6 @@ export default {
|
||||
ajaxGetDictItems(item.dictField).then(res => {
|
||||
if (res.success) {
|
||||
const result = JSON.parse(JSON.stringify(res.result))
|
||||
if (item.dbFieldName === 'name_code') {
|
||||
for (const dictItem of result) {
|
||||
if ([EnterpriseNameCode.WQ.value, EnterpriseNameCode.JC.value, EnterpriseNameCode.JHK.value].includes(dictItem.value)) {
|
||||
dictItem.disabled = true
|
||||
} else {
|
||||
dictItem.disabled = false
|
||||
}
|
||||
}
|
||||
}
|
||||
console.log('获取企业名称代号下拉框数据成功了', result)
|
||||
this.$set(this.optionsData, item.dbFieldName, result)
|
||||
}
|
||||
})
|
||||
@@ -760,110 +565,12 @@ export default {
|
||||
clearValidate (fieldNameList) {
|
||||
this.$refs.ruleForm.clearValidate(fieldNameList)
|
||||
},
|
||||
/**
|
||||
* 标准性质是准入,状态为发布、即将实施和现行有效的时候 新车型实施日期和在产车的实施日期 都改成必填
|
||||
*/
|
||||
handleStatePropertyCheck () {
|
||||
const mustFillFields = ['new_model_implementation_date', 'on_the_production_date']
|
||||
const rules = JSON.parse(JSON.stringify(this.rules))
|
||||
if (this.formInline.standard_property === StandardProperty.admittance.value && (
|
||||
this.formInline.standard_state === StandardStatus.RELEASE.value ||
|
||||
this.formInline.standard_state === StandardStatus.BE_IMPLEMENTED_SOON.value ||
|
||||
this.formInline.standard_state === StandardStatus.CURRENTLY_EFFECTIVE.value)) {
|
||||
mustFillFields.forEach(key => {
|
||||
if (rules[key] && rules[key].length > 0) {
|
||||
rules[key][0].required = true
|
||||
const dataPart = Object.keys(this.dataList).find(tt => this.dataList[tt].some(item => item.dbFieldName === key))
|
||||
const index = this.dataList[dataPart].findIndex(tt => tt.dbFieldName === key)
|
||||
this.dataList[dataPart][index].fieldMustInput = '1'
|
||||
}
|
||||
})
|
||||
} else {
|
||||
mustFillFields.forEach(key => {
|
||||
if (rules[key] && rules[key].length > 0) {
|
||||
rules[key][0].required = false
|
||||
const dataPart = Object.keys(this.dataList).find(tt => this.dataList[tt].some(item => item.dbFieldName === key))
|
||||
const index = this.dataList[dataPart].findIndex(tt => tt.dbFieldName === key)
|
||||
this.dataList[dataPart][index].fieldMustInput = '0'
|
||||
}
|
||||
})
|
||||
}
|
||||
this.rules = Object.assign({}, rules)
|
||||
this.clearValidate(mustFillFields)
|
||||
},
|
||||
/**
|
||||
* 国内海外的特殊处理
|
||||
*/
|
||||
handleDomesticSpecialCheck () {
|
||||
if (this.domesticSpecialCheck) {
|
||||
const fieldNameList = ['part_name', 'applicable_certification', 'applicable_vehicle', 'responsible_department']
|
||||
const rules = JSON.parse(JSON.stringify(this.rules))
|
||||
if (this.formInline.standard_property === StandardProperty.admittance.value) {
|
||||
fieldNameList.forEach(key => {
|
||||
if (rules[key] && rules[key].length > 0) {
|
||||
rules[key][0].required = true
|
||||
const dataPart = Object.keys(this.dataList).find(tt => this.dataList[tt].some(item => item.dbFieldName === key))
|
||||
const index = this.dataList[dataPart].findIndex(tt => tt.dbFieldName === key)
|
||||
this.dataList[dataPart][index].fieldMustInput = '1'
|
||||
}
|
||||
})
|
||||
} else {
|
||||
fieldNameList.forEach(key => {
|
||||
if (rules[key] && rules[key].length > 0) {
|
||||
rules[key][0].required = false
|
||||
const dataPart = Object.keys(this.dataList).find(tt => this.dataList[tt].some(item => item.dbFieldName === key))
|
||||
const index = this.dataList[dataPart].findIndex(tt => tt.dbFieldName === key)
|
||||
this.dataList[dataPart][index].fieldMustInput = '0'
|
||||
}
|
||||
})
|
||||
}
|
||||
this.rules = Object.assign({}, rules)
|
||||
this.clearValidate(fieldNameList)
|
||||
}
|
||||
},
|
||||
getFlag (fieldName) {
|
||||
return this.flagByField[fieldName] || this.flag
|
||||
},
|
||||
filterTreeOption (input, option) {
|
||||
const text = option.componentOptions.propsData.title || option.componentOptions.propsData.label
|
||||
return text.toLowerCase().indexOf(input.toLowerCase()) >= 0
|
||||
},
|
||||
/**
|
||||
* 标准状态为起草、征求意见、报批等状态时发布日期、实施日期不应是必填项
|
||||
* @param val
|
||||
*/
|
||||
handleRequiredByState (val) {
|
||||
let notRequiredStatus = [], fields = []
|
||||
// 国内和海外的标准状态是同一个数据字典
|
||||
if (this.flag === StandardSource.DOMESTIC.value || this.flag === StandardSource.OVERSEAS.value) {
|
||||
notRequiredStatus = [StandardStatus.DRAFT.value, StandardStatus.SEEK_FOR_OPTIONS.value, StandardStatus.EXAMINE.value, StandardStatus.APPROVAL.value, StandardStatus.ABOLISH.value]
|
||||
fields = ['release_date', 'implementation_date']
|
||||
} else { // 处理企标
|
||||
notRequiredStatus = [EnterpriseStandardStatus.DRAFT.value, EnterpriseStandardStatus.SEEK_FOR_OPTIONS.value, EnterpriseStandardStatus.EXAMINE.value, EnterpriseStandardStatus.APPROVAL.value]
|
||||
fields = ['release_date', 'implementation_date']
|
||||
}
|
||||
const rules = JSON.parse(JSON.stringify(this.rules))
|
||||
if (notRequiredStatus.includes(val)) {
|
||||
fields.forEach(key => {
|
||||
if (rules[key] && rules[key].length > 0) {
|
||||
rules[key][0].required = false
|
||||
const dataPart = Object.keys(this.dataList).find(tt => this.dataList[tt].some(item => item.dbFieldName === key))
|
||||
const index = this.dataList[dataPart].findIndex(tt => tt.dbFieldName === key)
|
||||
this.dataList[dataPart][index].fieldMustInput = '0'
|
||||
}
|
||||
})
|
||||
} else {
|
||||
fields.forEach(key => {
|
||||
if (rules[key] && rules[key].length > 0) {
|
||||
rules[key][0].required = true
|
||||
const dataPart = Object.keys(this.dataList).find(tt => this.dataList[tt].some(item => item.dbFieldName === key))
|
||||
const index = this.dataList[dataPart].findIndex(tt => tt.dbFieldName === key)
|
||||
this.dataList[dataPart][index].fieldMustInput = '1'
|
||||
}
|
||||
})
|
||||
}
|
||||
this.rules = Object.assign({}, rules)
|
||||
this.clearValidate(fields)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user