<template>
|
|
<a-spin :spinning="confirmLoading">
|
|
<j-form-container :disabled="formDisabled">
|
|
<a-form-model ref="form" :model="model" :rules="validatorRules" slot="detail">
|
|
<a-row>
|
|
<a-col :span="24">
|
|
<a-form-model-item label="项目名" :labelCol="labelCol" :wrapperCol="wrapperCol" prop="name">
|
|
<a-input v-model="model.name" placeholder="请输入项目名" ></a-input>
|
|
</a-form-model-item>
|
|
</a-col>
|
|
<a-col :span="24">
|
|
<a-form-model-item label="照片" :labelCol="labelCol" :wrapperCol="wrapperCol" prop="pic">
|
|
<j-image-upload isMultiple v-model="model.pic" ></j-image-upload>
|
|
</a-form-model-item>
|
|
</a-col>
|
|
<a-col :span="24">
|
|
<a-form-model-item label="打卡地址" :labelCol="labelCol" :wrapperCol="wrapperCol" prop="address">
|
|
<a-input v-model="model.address" placeholder="请输入打卡地址" ></a-input>
|
|
</a-form-model-item>
|
|
</a-col>
|
|
<a-col :span="24">
|
|
<a-form-model-item label="时区" :labelCol="labelCol" :wrapperCol="wrapperCol" prop="timeZone">
|
|
<j-dict-select-tag type="list" v-model="model.timeZone" dictCode="clock_in_time_zone,name,id,del_flag=0" placeholder="请选择时区" />
|
|
</a-form-model-item>
|
|
</a-col>
|
|
<a-col :span="24">
|
|
<a-form-model-item label="经度" :labelCol="labelCol" :wrapperCol="wrapperCol" prop="lon">
|
|
<a-input v-model="model.lon" placeholder="请输入经度" ></a-input>
|
|
|
|
</a-form-model-item>
|
|
</a-col>
|
|
<a-col :span="24">
|
|
<a-form-model-item label="纬度" :labelCol="labelCol" :wrapperCol="wrapperCol" prop="lat">
|
|
<a-input v-model="model.lat" placeholder="请输入纬度" ></a-input>
|
|
</a-form-model-item>
|
|
</a-col>
|
|
<a-col :span="24">
|
|
<a-form-model-item label="地图选择位置" :labelCol="labelCol" :wrapperCol="wrapperCol" >
|
|
<TencentMapPicker
|
|
:latitude="model.lat"
|
|
:longitude="model.lon"
|
|
@onLocationSelected="handleLocationSelected"
|
|
/>
|
|
</a-form-model-item>
|
|
</a-col>
|
|
<a-col :span="24">
|
|
<a-form-model-item label="打卡距离(单位米)" :labelCol="labelCol" :wrapperCol="wrapperCol" prop="distance">
|
|
<a-input v-model="model.distance" placeholder="请输入打卡距离(单位米)" />
|
|
</a-form-model-item>
|
|
</a-col>
|
|
<a-col :span="24">
|
|
<a-form-model-item label="团队编号" :labelCol="labelCol" :wrapperCol="wrapperCol" prop="teamId">
|
|
<j-dict-select-tag type="list" v-model="model.teamId" dictCode="clockin_team,name,id,del_flag=0" placeholder="请选择团队编号" />
|
|
</a-form-model-item>
|
|
</a-col>
|
|
<!-- <a-col :span="24">-->
|
|
<!-- <a-form-model-item label="是否删除" :labelCol="labelCol" :wrapperCol="wrapperCol" prop="delFlag">-->
|
|
<!-- <j-dict-select-tag type="radio" v-model="model.delFlag" dictCode="is_delete" placeholder="请选择是否删除" />-->
|
|
<!-- </a-form-model-item>-->
|
|
<!-- </a-col>-->
|
|
</a-row>
|
|
</a-form-model>
|
|
</j-form-container>
|
|
</a-spin>
|
|
</template>
|
|
|
|
<script>
|
|
|
|
import { httpAction, getAction } from '@/api/manage'
|
|
import { validateDuplicateValue } from '@/utils/util'
|
|
import TencentMapPicker from './TencentMapPicker.vue';
|
|
export default {
|
|
name: 'ClockInProjectForm',
|
|
components: {
|
|
TencentMapPicker
|
|
},
|
|
|
|
|
|
props: {
|
|
//表单禁用
|
|
disabled: {
|
|
type: Boolean,
|
|
default: false,
|
|
required: false
|
|
}
|
|
},
|
|
data () {
|
|
return {
|
|
model:{
|
|
delFlag:0,
|
|
lon: '',
|
|
lat: ''
|
|
},
|
|
labelCol: {
|
|
xs: { span: 24 },
|
|
sm: { span: 5 },
|
|
},
|
|
wrapperCol: {
|
|
xs: { span: 24 },
|
|
sm: { span: 16 },
|
|
},
|
|
confirmLoading: false,
|
|
validatorRules: {
|
|
},
|
|
url: {
|
|
add: "/clockInproject/clockInProject/add",
|
|
edit: "/clockInproject/clockInProject/edit",
|
|
queryById: "/clockInproject/clockInProject/queryById"
|
|
}
|
|
}
|
|
},
|
|
computed: {
|
|
formDisabled(){
|
|
return this.disabled
|
|
},
|
|
},
|
|
created () {
|
|
//备份model原始值
|
|
this.modelDefault = JSON.parse(JSON.stringify(this.model));
|
|
},
|
|
methods: {
|
|
handleLocationSelected({latitude, longitude}) {
|
|
console.log('event',latitude, longitude)
|
|
this.model.lat = latitude;
|
|
this.model.lon = longitude;
|
|
},
|
|
add () {
|
|
this.edit(this.modelDefault);
|
|
},
|
|
edit (record) {
|
|
this.model = Object.assign({}, record);
|
|
this.visible = true;
|
|
},
|
|
selLocation(location){
|
|
console.log(location)
|
|
},
|
|
submitForm () {
|
|
const that = this;
|
|
// 触发表单验证
|
|
this.$refs.form.validate(valid => {
|
|
if (valid) {
|
|
that.confirmLoading = true;
|
|
let httpurl = '';
|
|
let method = '';
|
|
if(!this.model.id){
|
|
httpurl+=this.url.add;
|
|
method = 'post';
|
|
}else{
|
|
httpurl+=this.url.edit;
|
|
method = 'put';
|
|
}
|
|
httpAction(httpurl,this.model,method).then((res)=>{
|
|
if(res.success){
|
|
that.$message.success(res.message);
|
|
that.$emit('ok');
|
|
}else{
|
|
that.$message.warning(res.message);
|
|
}
|
|
}).finally(() => {
|
|
that.confirmLoading = false;
|
|
})
|
|
}
|
|
|
|
})
|
|
},
|
|
}
|
|
}
|
|
</script>
|