Przeglądaj źródła

试剂更换验证定量表单导入功能统一调整

wangxiaoyi 1 rok temu
rodzic
commit
37afa75fa2
1 zmienionych plików z 186 dodań i 40 usunięć
  1. 186 40
      src/views/component/reagent/reagentChange.vue

+ 186 - 40
src/views/component/reagent/reagentChange.vue

@@ -6,10 +6,12 @@
                     <div class="title">平行实验/留样再测</div>
                     <div v-if="nodeId === 'Activity_0xkc1ji' || readonly" />
                     <div v-else>
-                        <el-button type="primary" size="mini" icon="ibps-icon-edit" @click="openDialog">配置样品</el-button>
+                        <!-- <el-button type="primary" size="mini" icon="ibps-icon-edit" @click="openDialog">配置样品</el-button>
                         <el-button type="success" size="mini" icon="ibps-icon-refresh" @click="generateData">重置</el-button>
                         <el-button v-if="!disabled" type="danger" size="mini" icon="ibps-icon-calculator" @click="computedResult">计算结果</el-button>
-                        <el-button v-else type="danger" size="mini" icon="ibps-icon-edit" @click="disabled=false">编辑</el-button>
+                        <el-button v-else type="danger" size="mini" icon="ibps-icon-edit" @click="disabled=false">编辑</el-button> -->
+                        <el-button type="primary" size="mini" icon="ibps-icon-download" @click="handleDownload">模版下载</el-button>
+                        <el-button type="primary" size="mini" icon="ibps-icon-import" @click="handleImport">导入</el-button>
                     </div>
                 </el-col>
             </el-row>
@@ -20,6 +22,12 @@
                             label="检验项目"
                             prop="jyxm"
                         />
+                        <el-table-column label="浓度" prop="nd">
+                            <template slot-scope="{row}">
+                                <el-input v-if="!disabled" v-model="row.nd" size="mini" placeholder="请输入" />
+                                <span v-else>{{ row.nd|| '/' }}</span>
+                            </template>
+                        </el-table-column>
                         <el-table-column label="样品编号" prop="ypbh" />
                         <el-table-column label="旧试剂测得结果" prop="jsjcdjg">
                             <template slot-scope="{row}">
@@ -33,19 +41,20 @@
                                 <span v-else>{{ row.xsjcdjg|| '/' }}</span>
                             </template>
                         </el-table-column>
-                        <el-table-column label="偏倚" prop="pq" />
+                        <el-table-column label="实际差值" prop="sjcz" />
+                        <el-table-column label="实际偏倚" prop="pq" />
                         <el-table-column label="限定范围" prop="xdfw" />
+                        <el-table-column label="允许偏倚" prop="yxpq" />
                         <el-table-column label="是否相符" prop="sfxf">
                             <template slot-scope="{row}">
                                 <el-radio-group v-model="row.sfxf" disabled>
                                     <el-radio label="是">是</el-radio>
                                     <el-radio label="否">否</el-radio>
                                 </el-radio-group>
-                                <!-- <el-checkbox v-model="row.sfxf === '是'" disabled>是</el-checkbox>
-                                <el-checkbox v-model="row.sfxf === '否'" disabled>否</el-checkbox> -->
                             </template>
                         </el-table-column>
                         <el-table-column label="符合率" prop="fhl" />
+                        <el-table-column label="符合率可接受标准" prop="xmfhl" />
                         <el-table-column label="结论" prop="jl" />
                     </el-table>
                     <el-pagination
@@ -72,7 +81,7 @@
                 <span>样品编号{{ index+1 }}</span>
                 <div style="display: flex;align-items: center;">
                     <span style="color: red;margin-right: 3px;">*</span>
-                    <el-input v-model="item.number" required :min="0" type="number" style="flex:1;" />
+                    <el-input v-model="item.number" required :min="0" style="flex:1;" />
                 </div>
                 <div>
                     <el-button type="text" :style="{visibility: index === dialogData.length-1?'visible':'hidden'}" @click="addRow">添加</el-button>
@@ -84,10 +93,22 @@
                 <el-button type="primary" @click="dialogDataConfirm">确 定</el-button>
             </span>
         </el-dialog>
+        <import-table
+            :visible="importTableDialogVisible"
+            title="导入"
+            @close="(visible) => (importTableDialogVisible = visible)"
+            @action-event="handleImportTableActionEvent"
+        />
     </div>
 </template>
 <script>
+import importTable from '@/business/platform/form/formrender/dynamic-form/components/import-table'
+import IbpsImport from '@/plugins/import'
+import { downloadFile } from '@/business/platform/file/utils'
 export default {
+    components: {
+        importTable
+    },
     props: {
         formData: {
             type: Object,
@@ -124,7 +145,8 @@ export default {
             requestPage: {
                 limit: 20,
                 pageNo: 1
-            }
+            },
+            importTableDialogVisible: false
         }
     },
     computed: {
@@ -133,12 +155,12 @@ export default {
         }
     },
     watch: {
-        disabled: {
-            handler (val) {
-                this.$emit('change-data', 'zuJianShuJu', JSON.stringify([this.reagentData, this.copyDialogData.length, val]))
-            },
-            immediate: true
-        },
+        // disabled: {
+        //     handler (val) {
+        //         this.$emit('change-data', 'zuJianShuJu', JSON.stringify([this.reagentData, this.copyDialogData.length, val]))
+        //     },
+        //     immediate: true
+        // },
         'formData.sjghyzjlbxmcszb': {
             // 在表单中的任何操作都会触发子表的监听
             handler (val) {
@@ -151,19 +173,6 @@ export default {
                     }
                     this.ypData.push({ ...item })
                 })
-                // 处理表单”平行实验/留样再测“
-                // if (val.length && !this.ypFlag && this.copyDialogData.length && (this.params.nodeId === 'Activity_1bwqyf1' || this.params.nodeId === 'StartEvent_1fk5is7')) {
-                //     // 点完计算结果后再去编辑”平行实验/留样再测“表单,则给表格置空重新填写
-                //     // if (this.disabled && this.reagentData.length) {
-                //     //     this.copyDialogData = []
-                //     //     this.reagentData = []
-                //     //     this.disabled = false
-                //     //     return this.$message.error('请重新配置样品')
-                //     // }
-                //     // if (!this.disabled && this.reagentData.length) {
-                //     //     this.initData()
-                //     // }
-                // }
             },
             deep: true,
             immediate: true
@@ -172,11 +181,11 @@ export default {
             handler (val) {
                 if (this.formData.zuJianShuJu) {
                     const data = JSON.parse(this.formData.zuJianShuJu)
-                    this.spanLength = data[1]
+                    this.spanLength = data[1] || 0
                     if (val.length && this.reagentData.length <= 0) {
                         const arry = []
                         val.forEach(item => {
-                            arry.push({ jyxm: item.jianCeXiangMu, ypbh: item.biaoBenHao, jsjcdjg: item.jiuJieGuo, xsjcdjg: item.xinJieGuo, pq: item.jieGuo, fhl: item.biaoZhun, sfxf: item.xiangFu, jl: item.jieLun, xdfw: item.zuiXiaoFanWei })
+                            arry.push({ jyxm: item.jianCeXiangMu, nd: item.nongDu, ypbh: item.biaoBenHao, jsjcdjg: item.jiuJieGuo, xsjcdjg: item.xinJieGuo, pq: item.jieGuo, fhl: item.biaoZhun, sfxf: item.xiangFu, jl: item.jieLun, xdfw: item.zuiXiaoFanWei, xmfhl: item.xiangMuFuHeLv, sjcz: item.shiJiChaZhi, yxpq: item.yunXuPianYi })
                         })
                         setTimeout(() => {
                             this.reagentData = arry
@@ -198,11 +207,125 @@ export default {
     },
     mounted () {
         this.nodeId = this.params ? this.params.nodeId : ''
-        this.spanLength = this.params ? this.params.spanLength : ''
+        this.spanLength = this.params ? this.params.spanLength : 0
         this.disabled = this.readonly || this.nodeId === 'Activity_0xkc1ji'
         this.showAndHide(this.formData.fangAn)
     },
     methods: {
+        handleImport () {
+            this.importTableDialogVisible = true
+        },
+        handleDownload () {
+            downloadFile({ id: 'download_sjghdl', fileName: '试剂更换验证定量模板', ext: 'xlsx' })
+        },
+        getColumns () {
+            return [{
+                field_name: 'sfxf',
+                label: '是否相符',
+                name: 'sfxf'
+            },
+            {
+                field_name: 'jyxm',
+                label: '检验项目',
+                name: 'jyxm'
+            },
+            {
+                field_name: 'nd',
+                label: '浓度',
+                name: 'nd'
+            },
+            {
+                field_name: 'ypbh',
+                label: '样品编号',
+                name: 'ypbh'
+            },
+            {
+                field_name: 'jsjcdjg',
+                label: '旧试剂测得结果',
+                name: 'jsjcdjg'
+            },
+            {
+                field_name: 'xsjcdjg',
+                label: '新试剂测得结果',
+                name: 'xsjcdjg'
+            },
+            {
+                field_name: 'sjcz',
+                label: '实际差值',
+                name: 'sjcz'
+            },
+            {
+                field_name: 'pq',
+                label: '实际偏倚',
+                name: 'pq'
+            },
+            {
+                field_name: 'xdfw',
+                label: '限定范围',
+                name: 'xdfw'
+            },
+            {
+                field_name: 'yxpq',
+                label: '允许偏倚',
+                name: 'yxpq'
+            },
+            {
+                field_name: 'fhl',
+                label: '符合率',
+                name: 'fhl'
+            }, {
+                field_name: 'jl',
+                label: '结论',
+                name: 'jl'
+            },
+            {
+                field_name: 'xmfhl',
+                label: '符合率可接受标准',
+                name: 'xmfhl'
+            }]
+        },
+        getKeys (data) {
+            return Array.isArray(data) ? data.reduce((acc, item) => ({ ...acc, [item.label]: item.name }), {}) : {}
+        },
+        handleImportTableActionEvent (file, options) {
+            IbpsImport.xlsx(file, options).then(({ header, results }) => {
+                const list = []
+                const keys = this.getKeys(this.getColumns())
+                results.forEach(item => {
+                    const obj = {}
+                    Object.keys(item).forEach(key => {
+                        if (keys[key]) {
+                            obj[keys[key]] = item[key]
+                        }
+                    })
+                    list.push(obj)
+                })
+                const filteredArray = list.map(item => {
+                    if (item.jyxm && item.fhl && item.jl) {
+                        return item
+                    }
+                    return null
+                }).filter(item => item !== null)
+                filteredArray.forEach(item => {
+                    list.forEach(el => {
+                        if (el.jyxm === item.jyxm) {
+                            el.fhl = item.fhl
+                            el.jl = item.jl
+                            el.xmfhl = item.xmfhl
+                        }
+                    })
+                })
+                this.reagentData = list
+                this.disabled = true
+                setTimeout(() => {
+                    this.$nextTick(() => {
+                        this.$refs.reagent && this.$refs.reagent.$forceUpdate()
+                    })
+                })
+                this.importTableDialogVisible = false
+                this.$emit('change-data', 'zuJianShuJu', JSON.stringify([this.reagentData, this.copyDialogData.length, this.disabled]))
+            })
+        },
         // 当前页码改变
         handleCurrentChange (val) {
             this.requestPage.pageNo = val
@@ -278,6 +401,7 @@ export default {
                     })
                 })
                 this.disabled = true
+                this.$emit('change-data', 'zuJianShuJu', JSON.stringify([this.reagentData, this.copyDialogData.length, this.disabled]))
             } else {
                 this.$message.warning('试剂测得结果必须大于0且不能为空!')
             }
@@ -287,25 +411,47 @@ export default {
             this.reagentData = []
             this.ypData.forEach(item => {
                 this.copyDialogData.forEach(el => {
-                    this.reagentData.push({ jyxm: item.jianCeXiangMu, ypbh: el.number, jsjcdjg: '', xsjcdjg: '', pq: '', xdfw: item.xianDingFanWei + '%', sfxf: '', fhl: '', jl: '' })
+                    this.reagentData.push({ jyxm: item.jianCeXiangMu, nd: '', ypbh: el.number, jsjcdjg: '', xsjcdjg: '', pq: '', xdfw: item.xianDingFanWei + '%', sfxf: '', fhl: '', jl: '', xmfhl: item.xiangMuFuHeLv + '%', sjcz: '', yxpq: '' })
                 })
             })
             this.$refs.reagent.doLayout()
         },
         spanMethod ({ row, column, rowIndex, columnIndex }) {
-            const rowspan = this.copyDialogData.length || this.spanLength
-            if (columnIndex === 0 || columnIndex === 5 || columnIndex === 7 || columnIndex === 8) {
-                if (rowIndex % rowspan === 0) {
-                    return {
-                        rowspan,
-                        colspan: 1
-                    }
+            // const rowspan = this.copyDialogData.length || this.spanLength
+            if (columnIndex === 0 || columnIndex === 10 || columnIndex === 11 || columnIndex === 12) {
+                const currentValue = row[column.property]
+                const preRow = this.reagentData[rowIndex - 1]
+                // 上一行这一列的数据
+                const preValue = preRow ? preRow[column.property] : null
+                // 如果当前值和上一行的值相同,则将当前单元格隐藏
+                // 给第0,10,11,12列对数值相同且是同一个'jyxm'进行表格合并
+                if (currentValue === preValue && row['jyxm'] === preRow['jyxm']) {
+                    return { rowspan: 0, colspan: 0 }
                 } else {
-                    return {
-                        rowspan: 0,
-                        colspan: 0
+                    let rowspan = 1
+                    // 计算应该合并的行数
+                    for (let i = rowIndex + 1; i < this.reagentData.length; i++) {
+                        const nextRow = this.reagentData[i]
+                        const nextValue = nextRow[column.property]
+                        if (nextValue === currentValue && nextRow['jyxm'] === row['jyxm']) {
+                            rowspan++
+                        } else {
+                            break
+                        }
                     }
+                    return { rowspan, colspan: 1 }
                 }
+                // if (rowIndex % rowspan === 0) {
+                //     return {
+                //         rowspan,
+                //         colspan: 1
+                //     }
+                // } else {
+                //     return {
+                //         rowspan: 0,
+                //         colspan: 0
+                //     }
+                // }
             }
         },
         addRow () {