punchClockDetail.vue 11.3 KB
Newer Older
godwithdh's avatar
godwithdh committed
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
<style lang="less">
#punchClockDetail{
    overflow-x: hidden;
    >img{
        width:100%;
    }
    >.list{
        background: #fff;
        margin: 10px 0;
        padding: 10px;
        font-size: 15px;
        .v-input--radio-group{
            margin-top: 0;
            margin-bottom: -15px;
            .v-input__control{
                width:100%;
                .v-input__slot{
                    margin:0;
                    .v-input--radio-group__input{
                        >div{
                            label{
                                padding:4px 0;
                                flex-grow: 1;
                                font-size: 14px;
                            }
                            >.v-radio{
                                display:flex;
                                >div{
                                    flex-shrink: 0;
                                }
                            }
                        }
                    }
                }
            }
        }
        >textarea{
            width:100%;
            min-height: 55px;
        }
godwithdh's avatar
godwithdh committed
41 42 43 44 45 46
        >.item{
            margin-top:6rpx;
            p{
                margin:0;
            }
        }
godwithdh's avatar
godwithdh committed
47 48 49 50 51 52 53 54 55 56 57 58 59 60 61
    }
    >button{
        width:calc(100% - 10px);
        margin: 0 5px;
        background:#5E9AFE;
        color:#fff;
        padding:10px 0;
        margin-bottom:5px;
    }
}
</style>
<template>
    <div id="punchClockDetail">
        <img src="./image/health.jpg" />
        <div class="list">
godwithdh's avatar
godwithdh committed
62 63
            <div class="tip"><span style="color:red;" v-if="status!=2">*</span>1. 目前健康状况</div>
            <v-radio-group v-model="value.sStatus" :disabled="status==2">
godwithdh's avatar
godwithdh committed
64 65 66 67 68
                <div><v-radio value="健康" label="健康"/></div>
                <div><v-radio value="有发烧、咳嗽等症状" label="有发烧、咳嗽等症状"/></div>
                <div><v-radio value="其他" label="其他"/></div>
            </v-radio-group>
        </div>
godwithdh's avatar
godwithdh committed
69 70
        <div class="list">
            <div class="tip"><span style="color:red;" v-if="status!=2">*</span>2. 目前所在城市</div>
godwithdh's avatar
godwithdh committed
71
            <x-address
godwithdh's avatar
godwithdh committed
72
                :disabled="status==2"
godwithdh's avatar
godwithdh committed
73 74 75 76 77 78 79
                @on-hide="logHide"
                @on-show="logShow"
                title=""
                v-model="address"
                :list="addressData" 
                @on-shadow-change="onShadowChange" 
                placeholder="请选择地址"
godwithdh's avatar
godwithdh committed
80
                :raw-value="true"
godwithdh's avatar
godwithdh committed
81 82 83
                value-text-align="left"
                :show.sync="showAddress"/>
        </div>
godwithdh's avatar
godwithdh committed
84 85
        <div class="list">
            <div class="tip">3. 详细地址</div>
godwithdh's avatar
godwithdh committed
86 87 88
            <span>{{value.sAddressFull}}</span>
        </div>
        <div class="list">
godwithdh's avatar
godwithdh committed
89
            <div class="tip"><span style="color:red;" v-if="status!=2">*</span>4. 是否接触过疑似或确诊的新型肺炎患者?</div>
godwithdh's avatar
godwithdh committed
90
            <v-radio-group v-model="value.bTouch" :disabled="status==2">
godwithdh's avatar
godwithdh committed
91 92 93
                <div><v-radio :value="0" label="否"/></div>
                <div><v-radio :value="1" label="是"/></div>
            </v-radio-group>
godwithdh's avatar
godwithdh committed
94 95 96 97 98 99 100 101 102
            <div class="item" v-if="value.bTouch">
                <datetime
                    :disabled="status==2"
                    title="接触日期"
                    format='YYYY-MM-DD'
                    placeholder="请选择"
                    :show.sync="isShowDate"
                    v-model="value.dTouchDate"/>
            </div>
godwithdh's avatar
godwithdh committed
103 104
        </div>
        <div class="list">
godwithdh's avatar
godwithdh committed
105
            <div class="tip"><span style="color:red;" v-if="status!=2">*</span>5. 体温</div>
godwithdh's avatar
godwithdh committed
106 107
            <xInput
                title=""
godwithdh's avatar
godwithdh committed
108
                :disabled="status==2"
godwithdh's avatar
godwithdh committed
109 110
                placeholder="输入体温"
                v-model="value.nTemperature"
godwithdh's avatar
godwithdh committed
111 112
                @on-change="inputNum('nTemperature')"
                type="number"/>
godwithdh's avatar
godwithdh committed
113 114
        </div>
        <div class="list">
godwithdh's avatar
godwithdh committed
115
            <div class="tip"><span style="color:red;" v-if="status!=2">*</span>6. 是否自我隔离?</div>
godwithdh's avatar
godwithdh committed
116
            <v-radio-group v-model="value.bQuarantine" :disabled="status==2">
godwithdh's avatar
godwithdh committed
117 118 119 120 121
                <div><v-radio :value="0" label="否"/></div>
                <div><v-radio :value="1" label="是"/></div>
            </v-radio-group>
        </div>
        <div class="list">
godwithdh's avatar
godwithdh committed
122
            <div class="tip"><span style="color:red;" v-if="status!=2">*</span>7. 是否就医?</div>
godwithdh's avatar
godwithdh committed
123
            <v-radio-group v-model="value.bHospital" :disabled="status==2">
godwithdh's avatar
godwithdh committed
124 125 126 127 128
                <div><v-radio :value="0" label="否"/></div>
                <div><v-radio :value="1" label="是"/></div>
            </v-radio-group>
        </div>
        <div class="list">
godwithdh's avatar
godwithdh committed
129
            <div class="tip"><span style="color:red;" v-if="status!=2">*</span>8. 自2020年1月18日至今,是否去过重点疫区【湖北、温州、台州(温岭、黄岩)】等地有过停留史?</div>
godwithdh's avatar
godwithdh committed
130
            <v-radio-group v-model="value.bHaveBeen" :disabled="status==2">
godwithdh's avatar
godwithdh committed
131 132 133 134 135
                <div><v-radio :value="0" label="否"/></div>
                <div><v-radio :value="1" label="是"/></div>
            </v-radio-group>
        </div>
        <div class="list">
godwithdh's avatar
godwithdh committed
136
            <div class="tip">9. 出行明细</div>
godwithdh's avatar
godwithdh committed
137
            <textarea :placeholder="status==2 ? '' : '请输入'" :disabled="status==2" autoHeight="true" v-model="value.sHaveBeenDetail"/>
godwithdh's avatar
godwithdh committed
138 139
        </div>
        <div class="list">
godwithdh's avatar
godwithdh committed
140
            <div class="tip">10. 其他情况</div>
godwithdh's avatar
godwithdh committed
141
            <textarea :placeholder="status==2 ? '' : '请输入'" :disabled="status==2" autoHeight="true" v-model="value.sRemark"/>
godwithdh's avatar
godwithdh committed
142
        </div>
godwithdh's avatar
godwithdh committed
143
        <button @click="upData" v-if="status!=2">{{btnName}}</button>
godwithdh's avatar
godwithdh committed
144 145 146 147

        <confirm v-model="isShowConfirm"
            title="提示"
            @on-confirm="onConfirm">
godwithdh's avatar
godwithdh committed
148
            <p style="text-align:center;">{{status==1?'修改数据会覆盖原来的数据':'补卡后不能再修改'}},是否继续?</p>
godwithdh's avatar
godwithdh committed
149
        </confirm>
godwithdh's avatar
godwithdh committed
150 151 152 153 154
    </div>
</template>

<script>
import util from "@/libs/util.js"
张锡奇's avatar
张锡奇 committed
155
import {mapState} from 'vuex';
godwithdh's avatar
godwithdh committed
156
import { XAddress,ChinaAddressV4Data,Datetime,XInput,Confirm } from 'vux'
godwithdh's avatar
godwithdh committed
157

godwithdh's avatar
godwithdh committed
158 159
export default {
    name: 'punchClockDetail',
godwithdh's avatar
godwithdh committed
160
    components:{XAddress,Datetime,XInput,Confirm},
godwithdh's avatar
godwithdh committed
161 162 163 164 165 166
    data () {
        return {
            address:[],
            addressData:ChinaAddressV4Data,
            showAddress:false,
            isShowDate:false,
godwithdh's avatar
godwithdh committed
167
            isShowConfirm:false,
godwithdh's avatar
godwithdh committed
168 169 170 171 172 173 174
            value:{
                iEmploeeId:"",      //员工主键
                dCheckDate:"",      //打卡日期
                sStatus:"",         //状态
                nTemperature:'',    //体温
                sAddress:"",        //地址
                sAddressFull:"",    //详细地址
godwithdh's avatar
godwithdh committed
175
                bTouch:null,          //是否接触过
godwithdh's avatar
godwithdh committed
176
                dTouchDate:null,      //接触日期
godwithdh's avatar
godwithdh committed
177 178 179
                bQuarantine:null,     //是否自我隔离
                bHospital:null,       //是否自我就医
                bHaveBeen:null,       //是否去过疫区
godwithdh's avatar
godwithdh committed
180 181 182 183
                sHaveBeenDetail:"", //出行明细
                sRemark:"",         //其他情况
                tCreateTime:"",     //创建日期
                sCreateAppid:"",    //openID
godwithdh's avatar
godwithdh committed
184
                iStatus:1,
godwithdh's avatar
godwithdh committed
185
            },
godwithdh's avatar
godwithdh committed
186
            status:0,//0 新增,1 修改,2 只读,3 补卡
godwithdh's avatar
godwithdh committed
187 188
        }
    },
张锡奇's avatar
张锡奇 committed
189 190 191
    computed:{
        ...mapState({
            hdr:state => state.healthStatistics.hdr,
godwithdh's avatar
godwithdh committed
192 193
        }),
        btnName(){
godwithdh's avatar
godwithdh committed
194
            if(this.status==0)return "提交";
godwithdh's avatar
godwithdh committed
195 196 197
            else if(this.status==1)return "修改";
            else return "补卡"
        }
张锡奇's avatar
张锡奇 committed
198 199
    },
    async activated(){
godwithdh's avatar
godwithdh committed
200 201
        this.status = parseInt(this.$route.query.readOnly)||0

godwithdh's avatar
godwithdh committed
202
        this.value.sCreateAppid=this.$route.params.openId
godwithdh's avatar
godwithdh committed
203
        if(/^1$|^2$/.test(this.status)){
张锡奇's avatar
张锡奇 committed
204
            await this.getHealthDate();
godwithdh's avatar
godwithdh committed
205 206 207 208
        }else{
            this.value.iEmploeeId=this.$route.params.id
            this.value.sAddressFull=this.$route.params.address
        }
godwithdh's avatar
godwithdh committed
209
        this.value.dCheckDate=this.value.tCreateTime=util.dateFormat(new Date(),"yyyy-MM-dd hh:mm:ss")
godwithdh's avatar
godwithdh committed
210
        if(this.status==3){
godwithdh's avatar
godwithdh committed
211 212
            this.value.dCheckDate=util.dateFormat(new Date(Number(this.$route.query.dDate)),"yyyy-MM-dd")
        }
godwithdh's avatar
godwithdh committed
213 214
    },
    methods:{
godwithdh's avatar
godwithdh committed
215
        async getHealthDate(){
张锡奇's avatar
张锡奇 committed
216 217 218
            let res = await this.request('getStatisticalDetails',{
                data:[
                    {key:'url',value:'HealthLog'},
张锡奇's avatar
张锡奇 committed
219
                    {key:'dDate',value: util.dateFormat(new Date(Number(this.$route.query.dDate)),"yyyy-MM-dd")},
张锡奇's avatar
张锡奇 committed
220 221 222 223 224 225 226 227
                    {key:"openid",value:this.value.sCreateAppid}
                ],
                params:{},
            },'加载中',{});
            if(res && typeof(res) == 'object'){
                this.value = res[0];
                for(let x in this.value){
                    if(util.getType(this.value[x]) == 'boolean'){
godwithdh's avatar
godwithdh committed
228 229 230 231 232 233
                        // if(this.value[x]){
                        //     this.value[x] = 1;
                        // }else{
                        //     this.value[x] = 0;
                        // }
                        this.value[x]=this.value[x]?1:0
张锡奇's avatar
张锡奇 committed
234 235
                    }
                }
godwithdh's avatar
godwithdh committed
236
                this.address = this.value.sAddress.split(",");
张锡奇's avatar
张锡奇 committed
237
            }
godwithdh's avatar
godwithdh committed
238 239
        },

godwithdh's avatar
godwithdh committed
240 241 242
        inputNum(name){
            this.value[name]=parseFloat(this.value[name])
        },
godwithdh's avatar
godwithdh committed
243 244 245 246 247 248 249 250
        logHide(e){
            console.log(e)
        },
        logShow(e){
            console.log(e)
        },
        onShadowChange(e){
            console.log(e)
godwithdh's avatar
godwithdh committed
251
        },
godwithdh's avatar
godwithdh committed
252
        upData(){//保存数据
godwithdh's avatar
godwithdh committed
253
            if(this.checkData()){
godwithdh's avatar
godwithdh committed
254 255
                if(this.status>0){
                    this.isShowConfirm=true
godwithdh's avatar
godwithdh committed
256
                }else{
godwithdh's avatar
godwithdh committed
257
                    this.saveData()
godwithdh's avatar
godwithdh committed
258 259 260
                }
            }
        },
godwithdh's avatar
godwithdh committed
261 262 263 264
        onConfirm(){
            this.saveData()
        },
        async saveData(){
godwithdh's avatar
godwithdh committed
265
            this.value.iStatus=this.status==1?2:1
godwithdh's avatar
godwithdh committed
266 267 268 269 270 271
            var value=await this.request("saveHealth",{
                data:this.value,
            },"加载中",{})
            if(/^\d+$/.test(value)){
                wx.miniProgram.navigateBack()
            }else{
godwithdh's avatar
godwithdh committed
272
                this.$vux.toast.text(this.status==0?'保存':(this.status==1?'修改':'补卡')+'失败!', 'middle');
godwithdh's avatar
godwithdh committed
273 274
            }
        },
godwithdh's avatar
godwithdh committed
275 276 277 278 279 280 281
        checkData(){
            if(!this.value.sStatus){
                this.$vux.toast.text('健康状态必填!', 'middle');
                return false;
            }else if(this.address.length==0){
                this.$vux.toast.text('地址必填!', 'middle');
                return false;
godwithdh's avatar
godwithdh committed
282
            }else if(!(this.value.nTemperature>0)){
godwithdh's avatar
godwithdh committed
283 284
                this.$vux.toast.text('体温必填!', 'middle');
                return false;
godwithdh's avatar
godwithdh committed
285 286 287 288 289 290 291 292 293 294 295 296
            }else if(!/[01]/.test(this.value.bTouch)){
                this.$vux.toast.text('是否接触过!', 'middle');
                return false;
            }else if(!/[01]/.test(this.value.bQuarantine)){
                this.$vux.toast.text('是否自我隔离!', 'middle');
                return false;
            }else if(!/[01]/.test(this.value.bHospital)){
                this.$vux.toast.text('是否自我就医!', 'middle');
                return false;
            }else if(!/[01]/.test(this.value.bHaveBeen)){
                this.$vux.toast.text('是否去过疫区!', 'middle');
                return false;
godwithdh's avatar
godwithdh committed
297
            }
godwithdh's avatar
godwithdh committed
298
            this.value.nTemperature=parseFloat(this.value.nTemperature)
godwithdh's avatar
godwithdh committed
299 300 301 302 303 304
            this.value.sAddress=this.address.join(",")
            if(!this.value.bTouch){
                delete this.value.dTouchDate
            }
            return true;
        }
godwithdh's avatar
godwithdh committed
305 306 307
    },
}
</script>