diff --git a/src/utils/String.ts b/src/utils/String.ts index 7ee7c1e..97289bb 100644 --- a/src/utils/String.ts +++ b/src/utils/String.ts @@ -15,6 +15,10 @@ string = (!isNaN(str) && typeof str === 'number' ? String(str) : str ? String(str) : '').replace(Exp, '') return string } +// 去除字符串中的字母 +export function removeLetters(str: string) { + return str.replace(/[a-zA-Z]/g, '') +} export const clearSymbolStart = (str: string) => { // const string = '' // 替换字符串中的所有特殊字符(包含空格) diff --git a/src/utils/String.ts b/src/utils/String.ts index 7ee7c1e..97289bb 100644 --- a/src/utils/String.ts +++ b/src/utils/String.ts @@ -15,6 +15,10 @@ string = (!isNaN(str) && typeof str === 'number' ? String(str) : str ? String(str) : '').replace(Exp, '') return string } +// 去除字符串中的字母 +export function removeLetters(str: string) { + return str.replace(/[a-zA-Z]/g, '') +} export const clearSymbolStart = (str: string) => { // const string = '' // 替换字符串中的所有特殊字符(包含空格) diff --git a/src/views/business/measure/item/components/seventh/templateDetail.vue b/src/views/business/measure/item/components/seventh/templateDetail.vue index 6d5c502..bf198f5 100644 --- a/src/views/business/measure/item/components/seventh/templateDetail.vue +++ b/src/views/business/measure/item/components/seventh/templateDetail.vue @@ -38,24 +38,24 @@ const checkoutList = ref([]) // 多选 // ------------------------------------------表头------------------------------------------------------------- const columns = ref([]) as any // 表头数据 -const columns_mechanical = ref([ // 机械式温湿度仪表 +const columns_mechanical = ref([ // 机械式温湿度仪表 1 { text: '检定项目', value: 'params', align: 'center', required: true, type: 'text' }, - { text: '类型', value: 'type', align: 'center', required: true, type: 'select' }, - { text: '温度点/湿度点', value: 'ponint', align: 'center', required: true, type: 'number' }, - { text: '单位', value: 'unit', align: 'center', required: false, type: 'text' }, - { text: '最大允许误差', value: 'allowMaximum', align: 'center', required: true, type: 'number' }, + { text: '类型', value: 'typeDesc', align: 'center', required: true, type: 'select' }, + { text: '温度点/湿度点', value: 'dimensionPoint', align: 'center', required: true, type: 'number' }, + { text: '单位', value: 'dimensionPointUnit', align: 'center', required: false, type: 'text' }, + { text: '最大允许误差', value: 'maximumError', align: 'center', required: true, type: 'number' }, ]) -const columns_digital = ref([ // 数字式/外置探头式温湿度仪表 +const columns_digital = ref([ // 数字式/外置探头式温湿度仪表2 { text: '检定项目', value: 'params', align: 'center', required: true, type: 'text' }, - { text: '类型', value: 'type', align: 'center', required: true, type: 'select' }, - { text: '温度点/湿度点', value: 'ponint', align: 'center', required: true, type: 'number' }, - { text: '单位', value: 'unit', align: 'center', required: false, type: 'text' }, + { text: '类型', value: 'typeDesc', align: 'center', required: true, type: 'select' }, + { text: '温度点/湿度点', value: 'dimensionPoint', align: 'center', required: true, type: 'number' }, + { text: '单位', value: 'dimensionPointUnit', align: 'center', required: false, type: 'text' }, { text: '不确定度', value: 'urel', align: 'center', required: true, type: 'number' }, - { text: '最大允许误差', value: 'allowMaximum', align: 'center', required: true, type: 'number' }, + { text: '最大允许误差', value: 'maximumError', align: 'center', required: true, type: 'number' }, ]) const form = ref({ - szcs: 1, - appearance: 1, + indicationError: 1, + appearanceFunctionCheck: 1, }) // --------------------------------------------钩子---------------------------------------------------- watch(() => props.itemCategoryName, (newValue) => { @@ -73,11 +73,15 @@ watch(() => props.list, (newVal) => { // 检定项表格 if (newVal) { - list.value = [...newVal] + list.value = [] + list.value = [...newVal].map((item: any) => ({ + ...item, + params: '示值测试', + })).filter((item: any) => item.dataType === (props.itemCategoryName === '机械式温湿度仪表' ? '1' : '2')) } }) -defineExpose({ list }) +// defineExpose({ list }) // --------------------------------表格操作--------------------------------------------------- const addRow = (list1: IList[], title: string, index: string) => { if (useCheckList(list1, columns.value, `${title}表格`)) { @@ -87,13 +91,13 @@ data = { id: '', params: '示值测试', - nominalValue: '', - unit: '', editable: true, - type: '', - ponint: '', + dataType: props.itemCategoryName === '机械式温湿度仪表' ? '1' : '2', + typeDesc: '', + dimensionPoint: '', + dimensionPointUnit: '', urel: '', - allowMaximum: '', + maximumError: '', } list.value.length ? list.value.push(JSON.parse(JSON.stringify(list.value[list.value.length - 1]))) : list.value.push(data) break @@ -121,27 +125,25 @@ } // ---------------------------------------------校验--------------------------------------------------- // 校验表格(点击保存的时候用、生成标准器示值) -function checkList(list: any[], columns: any[], title: string) { - if (form.value.szcs) { +function checkList() { + console.log(form.value) + if (!Number(form.value.indicationError)! && Number(form.value.appearanceFunctionCheck)) { + ElMessage.warning('检定项不能为空') + return false + } + if (form.value.indicationError) { if (!list.value.length) { ElMessage.warning('示值测试列表不能为空') return false } - return useCheckList(list, columns, title) + return useCheckList(list.value, columns.value, '示值测试') } else { return true } } -function checkAllList() { - // if (!list.value.length) { - // ElMessage.warning('鉴定项列表不能为空') - // return false - // } - return checkList(list.value, columns.value, '示值测试') -} // 每个table对应的下拉框内容 字典 -const tableDict = ref<{ [key: string]: { value: string;name: string;id: string }[] }>({}) +const tableDict = ref<{ [key: string]: { value: string; name: string; id: string }[] }>({}) tableDict.value = { 类型: [ { @@ -159,29 +161,47 @@ const changeLoadSituationa = (value: any, index: number, text: string, type: string, list: any[], item: string) => { if (item === '示值测试') { if (text === '类型') { - list[index].unit = value === '温度示值' ? '℃' : value === '湿度示值' ? '%RH' : '' + list[index].dimensionPointUnit = value === '温度示值' ? '℃' : value === '湿度示值' ? '%RH' : '' } } } +watch(() => props.pageType, (newVal) => { // 检定项表格 + console.log(newVal, 'newValnewValnewVal') + if (newVal === 'detail') { + list.value.forEach((item: any) => { + item.editable = false + }) + } + else { + list.value.forEach((item: any) => { + item.editable = true + }) + } +}) +defineExpose({ list, checkList, form }) +// 表格下拉框等内容是否禁用 +const disabled = ({ scope, column }, fun) => { + fun(props.pageType === 'detail') +}