4 changed files with 151 additions and 20 deletions
@ -0,0 +1,113 @@ |
|||
<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="定位" 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> |
|||
<u-button type="primary" @click="onFormSubmit">保存</u-button> |
|||
</view> |
|||
</view> |
|||
</template> |
|||
|
|||
<script> |
|||
import amap from '../../../common/ossutil/amap-wx.130.js' |
|||
export default { |
|||
data() { |
|||
return { |
|||
addForm: { |
|||
startTime: '06:00', |
|||
endTime: '14:00', |
|||
latitude:'', |
|||
longitude:'' |
|||
} |
|||
} |
|||
}, |
|||
onLoad() { |
|||
|
|||
}, |
|||
methods: { |
|||
bindTimeChange(e) { |
|||
this.time = e.detail.value; |
|||
}, |
|||
clockPosi(){ |
|||
const amapObject = new amap.AMapWX({ key: 'f06653d65bcefa97e94ab08917389842' }) |
|||
amapObject.getRegeo({ |
|||
success: (res) => { |
|||
this.addForm.latitude = res[0].latitude |
|||
this.addForm.longitude = res[0].longitude |
|||
}, |
|||
fail: (err) => { |
|||
console.log(err) |
|||
} |
|||
}) |
|||
}, |
|||
onFormSubmit() { |
|||
console.log('submit') |
|||
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() |
|||
console.log(res) |
|||
} else { |
|||
this.tui.toast(res.message) |
|||
} |
|||
}, (reason) => { |
|||
console.log(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; |
|||
} |
|||
</style> |
|||
Loading…
Reference in new issue