ReedawFoodApp/components/cardIndex/record.vue

175 lines
4.7 KiB
Vue

<template>
<view class="wrapper" v-if="isPublicRecord">
<view class="bg" @click="onTap">
<view class="edit" @click.stop>
<view class="title">添加记录</view>
<view class="editem">
<view class="left">选择项目</view>
<view class="right">
<picker mode="selector" @change="bindPickerChange" :value="index" :range="publicRecordInfo"
range-key="name">
<view class="uni-input">{{index!=-1?publicRecordInfo[index].name:'请选择'}}</view>
<icon class="iconfont icon-arrow-down-bold"></icon>
</picker>
</view>
</view>
<!-- 项目内容 -->
<view class="editem" v-for="(ite,ind) in RecordList">
<view class="left">{{ite.name}}</view>
<!-- 日期选择器 -->
<view class="right" v-if="ite.type == 'date'">
<picker mode="date" :end="endDate" @change="changeLog($event,ind)" :fields="fields"
:value="RecordList[ind].value">
<view class="uni-input">
{{RecordList[ind].value?RecordList[ind].value:'请选择'}}
</view>
<icon class="iconfont icon-arrow-down-bold"></icon>
</picker>
</view>
<!-- 分秒选择器 -->
<view class="right" v-if="ite.type == 'multiSelector'">
<picker mode="multiSelector" :value="timesTndex" :range="timeList"
@change="bindTimeChange($event,ind)">
<view class="size16">
{{RecordList[ind].value?RecordList[ind].value:'请选择'}}{{ite.unit}}
</view>
</picker>
<uni-icons type="bottom" class="ml-15 c666"></uni-icons>
</view>
<!-- 数字输入框 -->
<view class="right" v-if="ite.type == 'number'">
<input type="number" v-model="ite.value" placeholder="请输入">{{ite.unit}}
</view>
<!-- 小数输入框 -->
<view class="right" v-if="ite.type == 'digit'">
<input type="digit" v-model="ite.value" placeholder="请输入">{{ite.unit}}
</view>
<!-- 文本输入框 -->
<view class="right" v-if="ite.type == 'text'">
<input type="text" v-model="ite.value" placeholder="请输入">{{ite.unit}}
</view>
</view>
<view class="btn close" @click="onTap()">取消</view>
<view class="btn" @click="handlepublicmeasure">确定</view>
</view>
</view>
</view>
</template>
<script>
import {
mapState
} from "vuex";
export default {
data() {
return {
//
fields: "",
index: 0,
timeList: [],
RecordList: [],
timesTndex: [1, 0],
}
},
computed: {
...mapState(["user", "isPublicRecord", "PublicRecord"]),
userInfo() {
return this.user
},
publicRecordInfo() {
let that = this
return that.PublicRecord
},
endDate() {
return this.$tools.getDate("start")
},
startDate() {
return this.$tools.GetDateStr(-90);
},
},
mounted() {
let that = this
that.timeList = that.$tools.gethms()
that.RecordList = that.PublicRecord[that.index].list
// #ifdef APP-PLUS
that.fields = "time"
// #endif
// #ifndef APP-PLUS
that.fields = "day"
// #endif
},
methods: {
bindPickerChange(e) {
let that = this
for (let i = 0; i < that.RecordList.length; i++) {
that.RecordList[i].value = ""
}
that.index = e.detail.value
that.RecordList = that.publicRecordInfo[that.index].list
},
changeLog(e, ind) {
let that = this
that.RecordList[ind].value = e.detail.value
},
bindTimeChange(e, ind) {
let that = this
let m = e.target.value[0]
let s = e.target.value[1]
that.timesTndex = e.target.value
that.RecordList[ind].value = that.timeList[0][m].substring(0, 2) + ':' + that.timeList[1][s].substring(0,
2)
},
handlepublicmeasure() {
let that = this
if (that.index == -1) {
that.$tools.msg("请选择项目")
return
}
for (let i = 0; i < that.RecordList.length; i++) {
if (that.RecordList[i].value == "") {
that.$tools.msg("请输入正确信息")
break;
}
break;
}
that.$model.getpublicmeasure({
aud_id: that.user.aud_id,
type: that.publicRecordInfo[that.index].key_word,
data: that.RecordList
}).then(res => {
if (res.code != 0) return
that.$tools.msg(res.msg)
that.onTap()
})
},
onTap() {
let that = this
that.index = 0
that.RecordList = that.publicRecordInfo[that.index].list
for (let i = 0; i < that.RecordList.length; i++) {
that.RecordList[i].value = ""
}
that.$store.commit("changeTsPublicRecord", false);
},
}
}
</script>
<style scoped lang="scss">
.btn {
width: 40%;
float: right;
margin-top: 15px;
background: $maincolor !important;
}
.close {
background: #dfdfdf !important;
float: left;
}
picker {
font-size: 32rpx !important;
}
</style>