xy 11 months ago
parent 3fbfb4ce34
commit 6971cc0b9e

@ -4,7 +4,7 @@ NODE_ENV = production
ENV = 'staging'
# base api
VUE_APP_BASE_API='https://cz-hjjc.115.langye.net'
VUE_APP_UPLOAD_API='https://cz-hjjc.115.langye.net/api/upload-file'
VUE_APP_BASE_API=''
VUE_APP_UPLOAD_API='/api/upload-file'
VUE_APP_PREVIEW=//view.langye.net/preview/onlinePreview
VUE_APP_MODULE_NAME=oa

@ -18,6 +18,23 @@ export function sign(params,isLoading = true) {
})
}
export function signIp(params,isLoading = true) {
return request({
method: 'get',
url: '/api/oa/attendance/sign-ip',
params,
isLoading
})
}
export function preIp(params, isLoading = false) {
return request({
method: 'get',
url: '/api/oa/attendance/pre-ip',
params,
isLoading
})
}
export function statistics(params,isLoading= true) {
return request({
method: 'get',

@ -8,10 +8,13 @@
</button>
<div class="sign-info">
<div class="sign-statue">
<div>打卡状态 <el-tag size="small" effect="dark" type="primary">{{ isGetLocation ? isOutSign ? '外勤打卡' : '可打卡' : '不可打卡' }}</el-tag></div>
<div>当前位 <span v-if="isGetLocation">
<div>打卡状态 <el-tag size="small" effect="dark" type="primary">{{ (isGetLocation || isIpSign) ? (isOutSign ? '外勤打卡' : '可打卡') : '不可打卡' }}</el-tag></div>
<div v-if="!isIpSign"> <span v-if="isGetLocation">
<el-tag size="small" type="primary" effect="dark">{{pos.address}}</el-tag>
{{pos.lng}},{{pos.lat}}</span></div>
<div v-if="isIpSign">
<el-tag size="small" type="primary" effect="dark">ip打卡</el-tag>
</div>
<div>当前距离{{ nowDistance }}千米</div>
<div>最大打卡范围{{ maxDistance }}千米</div>
</div>
@ -62,7 +65,7 @@
<script>
import { index, save } from '@/api/onDutySchedules'
import { sign, preDistance } from '@/api/attendance'
import { sign, preDistance, preIp, signIp } from '@/api/attendance'
import { throttle, formatFileSize } from '@/utils'
import { getToken } from '@/utils/auth'
import MonthStatics from './components/MonthStatics'
@ -87,6 +90,7 @@ export default {
imageId: '',
remark: '',
// end
isIpSign: true,
isGetLocation: false,
isOutSign: false,
pos: {
@ -146,12 +150,19 @@ export default {
await this.uploadFile(this.fileList[0].file)
}
const res = await sign({
location: `${this.pos.lng},${this.pos.lat}`,
address: this.pos.address,
image_id: this.imageId,
remark: this.remark
})
if (this.isIpSign) {
const res = await signIp({
image_id: this.imageId,
remark: this.remark
})
} else {
const res = await sign({
location: `${this.pos.lng},${this.pos.lat}`,
address: this.pos.address,
image_id: this.imageId,
remark: this.remark
})
}
this.$message.success('打卡成功')
this.loading = false
this.isShow = false
@ -164,9 +175,11 @@ export default {
}, 1000, true),
clockIn: throttle(async function() {
try {
if (!this.isInUni) {
if (!this.isInUni && !this.isIpSign) {
await this.getLocation()
} else {
} else if (this.isIpSign) {
await this.preIp()
} else if (this.isInUni) {
uni.postMessage({
data: {
action: 'getLocation'
@ -174,18 +187,21 @@ export default {
});
return
}
if(!this.isGetLocation) return
if(!this.isGetLocation && !this.isIpSign) return
if(this.isOutSign) {
this.isShow = true
return
}
const res = await sign({
location: `${this.pos.lng},${this.pos.lat}`,
address: this.pos.address
})
if (this.isIpSign) {
const res = await signIp()
} else {
const res = await sign({
location: `${this.pos.lng},${this.pos.lat}`,
address: this.pos.address
})
}
this.$message.success('打卡成功')
await this.$refs['MonthStatics'].getData()
console.log(res)
} catch (err) {
console.error(err)
}
@ -195,6 +211,8 @@ export default {
if(!navigator.geolocation) {
this.isGetLocation = false
this.$msgbox.alert("您的浏览器不支持获取定位", "提示")
this.isIpSign = true
this.preIp()
} else {
this.getLocation()
}
@ -235,6 +253,14 @@ export default {
}
},
async preIp() {
try {
const res = await preIp()
this.isOutSign = false
} catch (err) {
this.isOutSign = true
}
},
async pos2Address(lat, lng) {
try {
const res = await this.$jsonp('https://apis.map.qq.com/ws/geocoder/v1/',{
@ -253,6 +279,7 @@ export default {
try {
this.pos.lng = longitude
this.pos.lat = latitude
this.isIpSign = false
this.isGetLocation = true
if(this.pos.lat && this.pos.lng && this.isGetLocation) {
await this.pos2Address(this.pos.lat, this.pos.lng)
@ -293,6 +320,7 @@ export default {
} else {
navigator.geolocation.getCurrentPosition((pos) => {
this.isGetLocation = true
this.isIpSign = false
console.log('经度', pos.coords.latitude);
console.log('纬度', pos.coords.longitude);
this.pos.lng = pos.coords.longitude
@ -310,6 +338,8 @@ export default {
}
}, (error) => {
console.log(error)
this.isIpSign = true
this.preIp()
reject(error)
if (error.code) {
switch (error.code) {

@ -157,7 +157,7 @@ export default {
...this.form,
file_id: i.response?.data?.id
})))
// await save(this.form)
await save(this.form)
this.$message.success('新增成功')
this.$emit('refresh')
this.$emit('update:isShow', false)

Loading…
Cancel
Save