examTeamApp/element/manuallyAdd/publicAdd.vue

223 lines
5.8 KiB
Vue
Raw Normal View History

2024-09-27 17:35:10 +08:00
<template>
<view class="wrapper" v-if="isPublicRecord">
2024-09-27 17:35:10 +08:00
<view class="bg" @click="onTap">
<view class="edit" @click.stop>
<view class="title">手动记录</view>
<view class="editem">
2024-09-27 17:35:10 +08:00
<view class="left">项目</view>
<view class="right">
{{labelName}}
2024-09-27 17:35:10 +08:00
</view>
</view>
<!-- -->
<view class="editem">
2024-09-27 17:35:10 +08:00
<view class="left">日期</view>
<view class="right">
2024-10-11 10:04:19 +08:00
<picker mode="date" :end="endDate" @change="changeLog" :fields="fields">
2024-09-27 17:35:10 +08:00
<view class="uni-input">{{regTime?regTime:'请选择'}}</view>
<icon class="iconfont icon-arrow-down-bold"></icon>
</picker>
</view>
</view>
<view class="editem" v-if="info&&info.list.length&&listType">
<view class="name">{{describe}}</view>
<view class="right" v-if="listType==4">
<picker mode="multiSelector" :range="timeList" :value="timesTndex" @change="bindTimeChange">
<view class="size16">{{time_m?time_m+':':'请选择'}}{{time_s?time_s:''}}</view>
</picker>
<uni-icons type="bottom" class="ml-10 c666"></uni-icons>
</view>
<view class="right" v-if="listType!=4">
<input :type="listType==1?'number':'digit'" v-model="number" placeholder="请输入">
{{unit}}
</view>
</view>
<view class="editem" v-if="info&&info.time">
<view class="name">时长</view>
<view class="right">
<picker mode="multiSelector" :range="timeList" :value="timesTndex" @change="bindTimeChange">
<view class="size16">{{time_m?time_m+':':'请选择'}}{{time_s?time_s:''}}</view>
</picker>
<uni-icons type="bottom" class="ml-15 c666"></uni-icons>
</view>
</view>
<view class="editem" v-if="info&&info.number">
<view class="name">个数</view>
<view class="right">
<input type="number" v-model="number" placeholder="请输入">
2024-09-27 17:35:10 +08:00
</view>
</view>
<view class="btn close" @click="onTap()">取消</view>
<view class="btn" @click="handleTarget">确定</view>
</view>
</view>
</view>
</template>
<script>
import {
mapState
} from "vuex";
export default {
data() {
return {
name: "",
regTime: "",
number: '',
timeList: [],
time_m: "",
time_s: "",
2024-10-11 10:04:19 +08:00
fields: "",
listType: null,
describe: "",
unit: "",
2024-09-27 17:35:10 +08:00
timesTndex: [1, 0],
lableTndex: 0,
labelName: "",
2024-09-27 17:35:10 +08:00
}
},
props: {
rtype: null,
active: {
type: Number,
default: 0
},
2024-09-27 17:35:10 +08:00
},
computed: {
...mapState(["PublicRecord", "isPublicRecord"]),
info() {
2024-09-27 17:35:10 +08:00
let that = this
let info = {
height: false,
weight: false,
number: false,
time: false,
list: []
}
if (that.PublicRecord.length) {
that.PublicRecord.forEach(ite => {
if (ite.id == that.rtype) {
info = ite
}
})
if (info && info.list.length) {
// console.log("8888888", that.PublicRecord, info, that.active)
that.labelName = info.list[that.active].name
that.listType = info.list[that.active].type
that.describe = info.list[that.active].describe
that.unit = info.list[that.active].unit
// console.log("手动内容", info, that.active)
2024-09-27 17:35:10 +08:00
}
}
return that.PublicRecord.length ? info : null
2024-09-27 17:35:10 +08:00
},
endDate() {
return this.$tools.getDate("start")
},
startDate() {
return this.$tools.GetDateStr(-90);
},
},
mounted() {
// console.log("999999", that.labelName, that.PublicRecord)
},
2024-09-27 17:35:10 +08:00
mounted() {
2024-10-11 10:04:19 +08:00
let that = this
that.timeList = this.$tools.gethms()
// #ifdef APP-PLUS
that.fields = "time"
// #endif
// #ifndef APP-PLUS
that.fields = "day"
// #endif
2024-09-27 17:35:10 +08:00
},
methods: {
bindTimeChange(e) {
let that = this
let m = e.target.value[0]
let s = e.target.value[1]
let time_m = Number(that.timeList[0][m].substring(0, 2)) * 60
let time_s = Number(that.timeList[1][s].substring(0, 2))
that.timesTndex = e.target.value
that.time_m = that.timeList[0][m].substring(0, 2)
that.time_s = that.timeList[1][s].substring(0, 2)
console.log("时长", that.time_m, that.time_s)
2024-09-27 17:35:10 +08:00
},
// 手动记录
handleTarget() {
let that = this
if (!that.regTime) {
that.$tools.msg("请选择日期")
return
}
if (that.listType == 4 && (!that.time_m || !that.time_s)) {
2024-09-27 17:35:10 +08:00
that.$tools.msg("请输入时长")
return
}
if (that.listType != 4 && !that.number) {
let msg = that.listType == 1 ? '请输入个数' : '请输入时长'
that.$tools.msg(msg)
return
}
let time_m = that.time_m + ':' + that.time_s
2024-09-27 17:35:10 +08:00
that.$model.getpublicmeasure({
acd_id: that.rtype,
name: that.labelName,
2024-09-27 17:35:10 +08:00
record_time: that.regTime,
data: that.listType == 4 ? time_m : that.number,
2024-09-27 17:35:10 +08:00
aud_id: uni.getStorageSync('userid')
}).then(res => {
if (res.code != 0) return
that.$tools.msg(res.msg)
that.$store.commit("changeRecord", false);
that.$store.dispatch("getUserInfo", {
aud_id: uni.getStorageSync('userid'),
})
that.$store.dispatch("getPublicContent", {
acd_id: that.rtype,
2024-09-27 17:35:10 +08:00
aud_id: uni.getStorageSync('userid')
})
that.onTap()
2024-09-27 17:35:10 +08:00
})
},
bindTimeChange(e) {
2024-09-27 17:35:10 +08:00
let that = this
let m = e.target.value[0]
let s = e.target.value[1]
that.timesTndex = e.target.value
let time_m = Number(that.timeList[0][m].substring(0, 2)) * 60
let time_s = Number(that.timeList[1][s].substring(0, 2))
that.time_m = that.timeList[0][m].substring(0, 2)
that.time_s = that.timeList[1][s].substring(0, 2)
2024-09-27 17:35:10 +08:00
},
//
changeLog(e) {
this.regTime = e.detail.value
},
onTap() {
this.regTime = ""
this.$store.commit("changePublicAdd", false);
2024-09-27 17:35:10 +08:00
},
}
}
</script>
<style scoped lang="scss">
.btn {
width: 40%;
float: right;
margin-top: 15px;
background: $maincolor !important;
}
.edit {
top: 20%
}
.close {
background: #fff !important;
float: left;
color: #333;
}
</style>