sjz
2025-02-19 9790ff7ecc198ae3bbf10d5e3707a95d60ddab69
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
<template>
    <view>
        <view>
            <uni-card>
                <view style="font-size: 25px;">
                    <u-row customStyle="margin-top:5px;margin-bottom: 15px">
                        <u-col span="12">
                            <label>检验项目 : {{detail.FCHECK_ITEM}}</label>
                        </u-col>
                    </u-row>
                    <u-row customStyle="margin-bottom: 15px">
                        <u-col span="12">
                            <label>检验工具 : {{detail.FCHECK_TOOL}}</label>
                        </u-col>
                    </u-row>
                    <u-row customStyle="margin-bottom: 15px">
                        <u-col span="12">
                            <label style="line-height:30px">检验项目描述 : {{detail.FCHECK_ITEM_DESC}}</label>
                        </u-col>
                    </u-row>
                    <u-row customStyle="margin-bottom: 15px">
                        <u-col span="12">
                            <label>抽检数 : {{detail.CHECK_QYT}}</label>
                        </u-col>
                    </u-row>
                    <u-row customStyle="margin-bottom: 15px">
                        <u-col>
                            <label>上限 : {{detail.FUP_ALLOW}}</label>
                        </u-col>
                    </u-row>
                    <u-row customStyle="margin-bottom: 15px">
                        <u-col>
                            <label>标准值 : {{detail.FSTAND}}</label>
                        </u-col>
                    </u-row>
                    <u-row customStyle="margin-bottom: 15px">
                        <u-col>
                            <label>下限 : {{detail.FDOWN_ALLOW}}</label>
                        </u-col>
                    </u-row>
                </view>
            </uni-card>
        </view>
 
        <view>
            <uni-table border stripe emptyText="暂无更多数据" style="margin-left: 5px;margin-right: 5px;">
                <!-- 表头行 -->
                <uni-tr>
                    <uni-th align="center" width="60">项次</uni-th>
                    <uni-th align="center" width="220">典型值记录</uni-th>
                    <uni-th align="center" width="150">值是否在范围内</uni-th>
                </uni-tr>
                <!-- 表格数据行 -->
                <uni-tr v-for="(item,index) in table" style="height: 40px;">
                    <uni-td align="center" style="font-size: 25px;">{{item.IDX}} #</uni-td>
                    <uni-td align="center" style="font-size:25px;">
                        <input v-model="item.FCHECK_RESU" fontSize="28" input-align="center" :focus="item.FS"  :ref="`table${index}`"
                        @confirm="confirm(index)"  style="height: 40px;"></input>
                    </uni-td>
                    <uni-td align="center" style="font-size:25px;">
                        <div v-if="item.FCHECK_RESU ==null || item.FCHECK_RESU =='' "></div>
                        <div v-else-if="(parseFloat(item.FCHECK_RESU)<=parseFloat(detail.FUP_ALLOW) && parseFloat(item.FCHECK_RESU) >= parseFloat(detail.FDOWN_ALLOW))" style="color: #90BA87">√</div>
                        <div v-else style="color: #E47470">×</div>
                    </uni-td>
                </uni-tr>
            </uni-table>
        </view>
        
        <u-button text="保存" type="primary" style="margin-top: 20px;height: 55px;" @click="submit()"></u-button>
        <div style="height: 100px;"></div>
        <u-toast ref="uToast" />
    </view>
</template>
 
<script>
    import {getIqcSampleResult,saveIqcType} from '../../api/iqc'
    export default{
        data() {
            return {
                detail: {},
                table: [],
                name: '',
                value:''
            }
        },
        onLoad(option) {
            this.detail = JSON.parse(decodeURIComponent(option.detail))
            this.name = uni.getStorageSync('userInfo').username
            this.getSampleResult(this.detail.ID)
        },
        methods: {
            getSampleResult(mainId) {
                getIqcSampleResult(mainId).then(res => {
                    var lg=res.data.length
                    for (let item of res.data) {
                        if (item.IDX==1) {
                            item.FS = true
                        } else {
                            item.FS = false
                        }
 
                        this.table.push(item)
                    }
                    if (this.detail.CHECK_QYT-lg>0){
                        for (let i =1;i<=this.detail.CHECK_QYT-lg;i++){
                            if (lg+i==1){
                                this.table.push({"ID":"1","FCHECK_RESU":"","RELEASE_NO":this.detail.RELEASE_NO,"MAIN_ID":this.detail.ID,"IDX":lg+i,"FS":true})
                            }else{
                                this.table.push({"ID":"1","FCHECK_RESU":"","RELEASE_NO":this.detail.RELEASE_NO,"MAIN_ID":this.detail.ID,"IDX":lg+i,"FS":false})
                            }
                        }
                    }
                })
            },
            submit() {
                if(this.check()){
                    saveIqcType(this.detail.RELEASE_NO,this.detail.ID, this.table).then(res => {
                        console.log(res)
                        if (!res.result) {
                            this.$refs.uToast.show({
                                message: res.msg,
                                type: 'error'
                            })
                            return
                        } else {
                            let pages = getCurrentPages();
                            let beforePage = pages[pages.length - 2];
                            uni.navigateBack({
                                delta: 1, //返回的页面数,如果为1表示返回上一页
                                success: (event) => {
                                    beforePage.$vm.reload()
                                }
                            });
                        }
                    })
                }else{
                    this.$refs.uToast.show({
                        message: '典型值未录入完全!',
                        type: 'error'
                    })
                }
            },
            check() {
                try{
                    this.table.forEach(item=>{
                        if (item.FCHECK_RESU === null || item.FCHECK_RESU === '') {
                            throw new Error()
                        }
                    })
                    return true
                }catch(e){
                    return false
                }
            },
            confirm(index){
                // let nextInput = this.$refs[`table${index + 1}`];
                // if (nextInput) {
                //     console.log(nextInput[0].focus);
                //     this.table[index].FS='true'
                // }
                uni.hideKeyboard();
                if(this.table.length>index+1){
                    this.table[index].FS=false
                    this.table[index+1].FS=true    
                }
            }
        }
    }
</script>
 
<style>
    
</style>