You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
141 lines
3.3 KiB
141 lines
3.3 KiB
|
2 months ago
|
<template>
|
||
|
|
<view>
|
||
|
|
<view class="popup-height">
|
||
|
|
<uni-forms :modelValue="addForm" ref="addForm" validateTrigger="bind" :rules="rules" label-width="160rpx"
|
||
|
|
label-align="right">
|
||
|
|
<uni-forms-item label="上班时间" required>
|
||
|
|
<picker mode="time" :value="addForm.startTime" start="00:00" end="23:59" @change="start">
|
||
|
|
<view class="uni-input">{{addForm.startTime}}</view>
|
||
|
|
</picker>
|
||
|
|
</uni-forms-item>
|
||
|
|
<uni-forms-item label="下班时间" required>
|
||
|
|
<picker mode="time" :value="addForm.endTime" start="00:00" end="23:59" @change="end">
|
||
|
|
<view class="uni-input">{{addForm.endTime}}</view>
|
||
|
|
</picker>
|
||
|
|
</uni-forms-item>
|
||
|
|
<uni-forms-item label="定位" name="latitude" required>
|
||
|
|
<input type="text" v-model="addForm.latitude + ','+addForm.longitude" style="text-align:center;width:70%;border: 1px solid #eee;height: 72rpx;line-height: 72rpx !important;" disabled placeholder="获取位置用于员工打卡">
|
||
|
|
<view class="dw-btn" @tap="clockPosi">一键定位</view>
|
||
|
|
</uni-forms-item>
|
||
|
|
<uni-forms-item label="打卡范围" name="categoryId" required>
|
||
|
|
<uni-data-select class="uni-data-select" :localdata="categoryList" v-model="formData.categoryId"
|
||
|
|
placeholder="请选择打卡范围"></uni-data-select>
|
||
|
|
</uni-forms-item>
|
||
|
|
</uni-forms>
|
||
|
|
<u-button type="primary" @click="onFormSubmit">保存</u-button>
|
||
|
|
</view>
|
||
|
|
</view>
|
||
|
|
</template>
|
||
|
|
|
||
|
|
<script>
|
||
|
|
export default {
|
||
|
|
data() {
|
||
|
|
return {
|
||
|
|
addForm: {
|
||
|
|
startTime: '06:00',
|
||
|
|
endTime: '14:00',
|
||
|
|
latitude:'',
|
||
|
|
longitude:'',
|
||
|
|
categoryId: '',
|
||
|
|
},
|
||
|
|
categoryList: [{
|
||
|
|
value: 1,
|
||
|
|
text: '100米'
|
||
|
|
},{
|
||
|
|
value: 2,
|
||
|
|
text: '200米'
|
||
|
|
},{
|
||
|
|
value: 3,
|
||
|
|
text: '500米'
|
||
|
|
}],
|
||
|
|
rules: {
|
||
|
|
categoryId: {
|
||
|
|
rules: [{
|
||
|
|
required: true,
|
||
|
|
errorMessage: '请选择打卡范围',
|
||
|
|
}],
|
||
|
|
},
|
||
|
|
latitude: {
|
||
|
|
rules: [{
|
||
|
|
required: true,
|
||
|
|
errorMessage: '请定位店铺位置',
|
||
|
|
}],
|
||
|
|
}
|
||
|
|
}
|
||
|
|
}
|
||
|
|
},
|
||
|
|
onLoad() {
|
||
|
|
|
||
|
|
},
|
||
|
|
methods: {
|
||
|
|
bindTimeChange(e) {
|
||
|
|
this.time = e.detail.value;
|
||
|
|
},
|
||
|
|
clockPosi(){
|
||
|
|
let that = this;
|
||
|
|
uni.getLocation({
|
||
|
|
type: 'wgs84',
|
||
|
|
isHighAccuracy:true,
|
||
|
|
accuracy:'best',
|
||
|
|
success: function (res) {
|
||
|
|
that.addForm.latitude = res.latitude
|
||
|
|
that.addForm.longitude = res.longitude
|
||
|
|
}
|
||
|
|
});
|
||
|
|
},
|
||
|
|
onFormSubmit() {
|
||
|
|
this.$refs.addForm.validate().then(async () => {
|
||
|
|
let url;
|
||
|
|
if (this.type == 'edit') {
|
||
|
|
url = '/app/common/user/edit'
|
||
|
|
this.addForm.id = this.id
|
||
|
|
} else {
|
||
|
|
url = '/app/common/user/add'
|
||
|
|
}
|
||
|
|
const res = await this.tui.request(url, 'post', this.addForm, false,
|
||
|
|
true, false)
|
||
|
|
if (res.code == 200) {
|
||
|
|
uni.navigateBack()
|
||
|
|
} else {
|
||
|
|
this.tui.toast(res.message)
|
||
|
|
}
|
||
|
|
}, (reason) => {
|
||
|
|
})
|
||
|
|
},
|
||
|
|
start(e) {
|
||
|
|
this.addForm.startTime = e.detail.value
|
||
|
|
},
|
||
|
|
end(e) {
|
||
|
|
this.addForm.endTime = e.detail.value
|
||
|
|
}
|
||
|
|
}
|
||
|
|
}
|
||
|
|
</script>
|
||
|
|
|
||
|
|
<style lang="scss" scoped>
|
||
|
|
.popup-height {
|
||
|
|
padding: 0 25upx;
|
||
|
|
background-color: #fff;
|
||
|
|
}
|
||
|
|
|
||
|
|
.uni-date__input {
|
||
|
|
height: 40px;
|
||
|
|
width: 100%;
|
||
|
|
line-height: 40px;
|
||
|
|
font-size: 14px;
|
||
|
|
}
|
||
|
|
|
||
|
|
.text-center {
|
||
|
|
text-align: center;
|
||
|
|
}
|
||
|
|
.dw-btn{
|
||
|
|
width: 30%;
|
||
|
|
line-height: 72rpx;
|
||
|
|
text-align: center;
|
||
|
|
background: #088FEB;
|
||
|
|
color: #fff;
|
||
|
|
}
|
||
|
|
.uni-data-select {
|
||
|
|
width: 100%;
|
||
|
|
}
|
||
|
|
</style>
|