Commit 5c216463 by 冒粤蓉

special shop

1 parent 2c8e4fb1
...@@ -21,7 +21,10 @@ const COMMON_API = { ...@@ -21,7 +21,10 @@ const COMMON_API = {
} }
// 特约店接口 // 特约店接口
const SPECIALSHOP_API = { const SPECIALSHOP_API = {
SHOP_SEARCH: '/trialdrive/specialshop/search' SHOP_SEARCH: '/trialdrive/specialshop/search',
GET_FENCE_DETAIL: '/trialdrive/specialshop/info',
SAVE_FENCE: '/trialdrive/specialshop/add',
UPDATE_FENCE: '/trialdrive/specialshop/edit'
} }
// 试驾报表 // 试驾报表
const REPORT_API = { const REPORT_API = {
......
...@@ -7,4 +7,19 @@ function getList (params) { ...@@ -7,4 +7,19 @@ function getList (params) {
return request(params, url) return request(params, url)
} }
export { getList } function getFenceDetailById (params) {
const url = SPECIALSHOP_API.GET_FENCE_DETAIL
return request(params, url)
}
function saveFence (params) {
const url = SPECIALSHOP_API.SAVE_FENCE
return request(params, url, 'post')
}
function updateFence (params) {
const url = SPECIALSHOP_API.UPDATE_FENCE
return request(params, url, 'post')
}
export { getList, getFenceDetailById, saveFence, updateFence }
...@@ -4,77 +4,96 @@ ...@@ -4,77 +4,96 @@
<el-divider></el-divider> <el-divider></el-divider>
<el-form <el-form
ref="shopForm" ref="shopForm"
:model="shopForm" :model="form"
label-width="120px" :rules="rules"
label-width="135px"
:inline="true" :inline="true"
> >
<el-form-item label="特约店名称:"> <el-form-item class="special-shop-input" label="特约店名称:" prop="specialShop">
<el-input <el-cascader
v-model="shopForm.shopName" ref="specialShopCascader"
:size="btn_size" v-model="form.specialShopId"
placeholder="请输入特约店名称" :value="form.specialShopName"
></el-input> placeholder="请选择特约店名称"
</el-form-item> :options="specialShopOptions"
:props="specialShopDefaultProps"
filterable
@change="handleSpecialShopChange"
size="small"
:disabled="readonlyStatus"
></el-cascader>
</el-form-item>
<el-form-item label="特约店编码:"> <el-form-item label="特约店编码:">
<el-input <el-input
v-model="shopForm.shopCode" v-model="form.specialShopId"
:size="btn_size" :size="btn_size"
Placeholder="请输入特约店编码" readonly
disabled
Placeholder="特约店编码"
></el-input> ></el-input>
</el-form-item> </el-form-item>
<el-form-item label="特约店级别:"> <el-form-item label="特约店级别:">
<el-radio-group v-model="shopForm.shopLevel"> <el-radio-group v-model="form.shopLevel">
<el-radio label="1">一级店</el-radio> <el-radio label="一级店" :disabled="readonlyStatus">一级店</el-radio>
<el-radio label="2">二级店</el-radio> <el-radio label="二级店" :disabled="readonlyStatus">二级店</el-radio>
</el-radio-group> </el-radio-group>
</el-form-item> </el-form-item>
</el-form>
<h2>特约店围栏配置</h2> <h2>特约店围栏配置</h2>
<el-divider></el-divider> <el-divider></el-divider>
<el-form <el-form-item label="特约店围栏名称:" prop="fenceName">
ref="configForm"
:model="configForm"
label-width="130px"
:inline="true"
>
<el-form-item label="特约店围栏名称:">
<el-input <el-input
v-model="shopForm.shopCode" v-model.trim="form.fenceName"
:size="btn_size" :size="btn_size"
Placeholder="请输入特约店编码" maxlength="200"
placeholder="请输入特约店围栏名称"
:disabled="readonlyStatus"
></el-input> ></el-input>
</el-form-item> </el-form-item>
<el-form-item label="特约店围栏名称:"> <el-form-item label="监控范围:" prop="radius">
<el-input <el-input
v-model="shopForm.shopCode" v-model="form.radius"
:size="btn_size" :size="btn_size"
Placeholder="请输入特约店编码" Placeholder="请输入半径"
></el-input> style="width:140px" maxlength="10"
:disabled="readonlyStatus"
>
<template slot="append">M</template>
</el-input>
</el-form-item> </el-form-item>
<el-form-item> <el-form-item>
<el-button <el-button
type="primary" type="primary"
:size="btn_size" :size="btn_size"
@click="updateFence"
:disabled="readonlyStatus"
>更新围栏</el-button> >更新围栏</el-button>
</el-form-item> </el-form-item>
<el-form-item label="经度:"> <div>
<el-input <el-form-item label="经度:" prop="lng">
v-model="shopForm.shopCode" <el-input
:size="btn_size" v-model="form.lng"
></el-input> size="small"
</el-form-item> :disabled="readonlyStatus"
<el-form-item label="纬度:"> ></el-input>
<el-input </el-form-item>
v-model="shopForm.shopCode" <el-form-item label="纬度:" prop="lat">
:size="btn_size" <el-input
></el-input> v-model="form.lat"
</el-form-item> size="small"
<el-form-item label="特约店详细地址:"> :disabled="readonlyStatus"
<el-input ></el-input>
v-model="shopForm.shopCode" </el-form-item>
:size="btn_size" <el-form-item label="特约店详细地址:" prop="analysisAddress">
></el-input> <el-input
</el-form-item> v-model="form.analysisAddress"
size="medium"
placeholder="自动生成"
readonly
disabled
style="width:350px"
></el-input>
</el-form-item>
</div>
</el-form> </el-form>
<div <div
class="ibox-content" class="ibox-content"
...@@ -87,119 +106,431 @@ ...@@ -87,119 +106,431 @@
> >
</fence-map> </fence-map>
</div> </div>
<div class="fenceModalfooter">
<el-button v-if="!readonlyStatus" type="primary" @click="saveFence" size="small" :loading="submitting">{{btnText}}</el-button>
<el-button @click="cancel" size="small">取消</el-button>
</div>
</div> </div>
</template> </template>
<script> <script>
import { getSpecialShopList } from 'services/vehicle'
import { getFenceDetailById, saveFence, updateFence } from 'services/specialshop'
import fenceMap from 'components/map/fenceMap.vue' import fenceMap from 'components/map/fenceMap.vue'
import mapService from 'utils/mapService.js'
export default { export default {
components: { fenceMap }, components: { fenceMap },
data() { data() {
let checkSpecialShop = (rule, vaule, cb)=>{
if(this.form.specialShopId == ""){
cb(new Error('请选择特约店'))
}else{
cb();
}
}
let checkLng = (rule, vaule, cb)=>{
if(this.form.shapeType == 1 && !/^(\+|-)?(?:180(?:(?:\.0{1,6})?)|(?:[0-9]|[1-9][0-9]|1[0-7][0-9])(?:(?:\.[0-9]{1,6})?))$/.test(this.form.lng)){
cb(new Error('请输入正确的格式'))
}else{
cb();
}
}
let checkLat = (rule, vaule, cb)=>{
if(this.form.shapeType == 1 && !/^(\+|-)?(?:90(?:(?:\.0{1,6})?)|(?:[0-9]|[1-8][0-9])(?:(?:\.[0-9]{1,6})?))$/.test(this.form.lat)){
cb(new Error('请输入正确的格式'))
}else{
cb();
}
}
let checkRadius = (rule, vaule, cb)=>{
if(this.form.shapeType == 1 && !/^\d+$/.test(this.form.radius)){console.log(this.form.radius)
cb(new Error('请输入正确的格式,不能输入小数点'))
}else{
cb();
}
}
let checkTransferAddr = (rule, vaule, cb)=>{
if(this.form.shapeType == 1){
if(this.transferError){
cb(new Error('所填经纬度不能正确解析地址,请重新输入'));
}else{
cb();
}
}else{
cb()
}
}
return { return {
shopForm: {}, btn_size: 'small',
configForm: {}, configForm: {},
mapData: [] mapData: [],
submitting: false,
btnText: '保存',
restainFenceName: '',
specialShopOptions: [],
specialShopDefaultProps: {
children: 'children',
label: 'label',
value: 'id'
},
readonlyStatus: false,
form: {
shopName: '',
shopCode: '',
shopLevel: '一级店',
fenceName: '',
lng: '',
lat: '',
radius: 1000,
bizFenceType: '12',
shapeType: 1,
specialShopId: '',
specialShopName: '',
// fenceNo: '',
electricFenceType: 1,
startTime: '',
endTime: '',
des: '',
areaCode: '',
analysisAddress: '',
status: 1,
transferError: false,
timeType:2,
electricTimeFenceType:'',
electricTimeFenceTypes: [
{
value: 1,
label: '1个月'
}, {
value: 2,
label: '2个月'
}, {
value: 3,
label: '3个月'
}, {
value: 4,
label: '4个月'
}, {
value: 5,
label: '5个月'
}, {
value: 6,
label: '6个月'
}
],
dateRange: [],
msgtel: ''
},
rules: {
specialShop: [
{required: true, validator: checkSpecialShop, trigger: 'change'}
],
fenceName: [
{required: true, message: '请输入特约店围栏名称', trigger: 'blur'},
{pattern: /^\S{2,200}$/, message: '至少2字', trigger: 'blur' },
],
radius: [
{validator: checkRadius, trigger: 'blur'}
],
lng: [
{required: true, validator: checkLng, trigger: 'blur'}
],
lat: [
{required: true, validator: checkLat, trigger: 'blur'}
],
analysisAddress: [
{validator: checkTransferAddr, trigger: 'change'}
],
}
} }
}, },
created() { created() {
this.getSpecialShopList();
},
mounted() {
this.init(); this.init();
}, },
methods: { methods: {
init() { init() {
this.fenceId = this.$route.query.id const { id, readonlyStatus } = this.$route.query;
if (typeof this.fenceId != 'undefined') { this.readonlyStatus = readonlyStatus || false;
this.getFenceDetail(this.fenceId); if (typeof id != 'undefined') {
this.getFenceSnsList(this.fenceId); this.getFenceDetail(id);
} else { } else {
// MONITOR_SERVICE.getNewFenceId().then((res)=>{ this.$refs.fenceMap.initFence({
// if(res.returnCode == 0){ fenceType: 'circle'
// this.form.fenceNo = res.data.fenceNo; });
this.restainFenceName = undefined;
// this.$refs.fenceMap.initFence({
// fenceType: 'circle'
// });
// }
// });
// this.restainFenceName = undefined;
} }
}, },
getFenceDetail(id) { getSpecialShopList() {
MONITOR_SERVICE.getFenceDetailById({ id: id }).then((res) => { getSpecialShopList().then(res => {
if (res.returnCode == 0) { const { code, data } = res;
const form = this.form; if(code == 200) {
const data = res.data; this.specialShopOptions = data;
for (let key in data) { }
form[key] = data[key] })
},
getFenceDetail(id){
getFenceDetailById({shopId: id}).then((res)=>{
if(res.code == 200){
const form = this.form;
const data = res.data;
if(!data) {
return;
} }
this.form.dateRange = [form.startTime, form.endTime]; for(let key in data){
this.areaCode = form.areaCode form[key] = data[key]
this.restainFenceName = form.electricFenceName; }
this.form.msgtel = data.telNumbers this.shopId = data.id;
this.form.dateRange = [form.startTime, form.endTime];
this.areaCode = form.areaCode
this.restainFenceName = form.fenceName;
this.form.fenceName = form.fenceName;
this.form.msgtel = data.telNumbers;
this.form.specialShopId = data.shopCode;
this.form.specialShopName = data.shopName;
if(form.shapeType === 1){
this.mapData = {
fenceType: 'circle',
lng: form.lng,
lat: form.lat,
radius: form.radius,
}
}else if(form.shapeType === 4){
this.mapData = {
fenceType: 'area',
areaCode: this.form.areaCode
}
}else if(form.shapeType === 3){
if(data.lnglat){
this.polygonPath = data.lnglat.split('|').map((item)=>{
return [item.split(',')[0], item.split(',')[1]]
})
}
if (form.shapeType === 2) { console.log(this.polygonPath)
this.mapData = { this.mapData = {
fenceType: 'circle', fenceType: 'polygon',
lng: form.lng, polygonPath: this.polygonPath
lat: form.lat, }
radius: form.radius, }
}
} else if (form.shapeType === 3) { this.$refs.fenceMap.initFence(this.mapData);
this.mapData = { }
fenceType: 'area', });
areaCode: this.form.areaCode },
} updateMapData(data) {
} else if (form.shapeType === 5) { if(data.radius){
if (data.lnglat) { this.form.radius = data.radius;
this.polygonPath = data.lnglat.split('|').map((item) => { }
return [item.split(',')[0], item.split(',')[1]] if(data.lng && data.lat){
}) this.form.lng = data.lng;
} this.form.lat = data.lat;
this.transfer()
console.log(this.polygonPath) }
this.mapData = {
fenceType: 'polygon', if(data.polygonPath && data.polygonPath.length){
polygonPath: this.polygonPath this.polygonPath = data.polygonPath
}
},
handleSpecialShopChange(val) {
// 特约店级联选项
if(val && val.length > 1) {
const thisNodes = this.$refs['specialShopCascader'].getCheckedNodes()[0];
this.form.specialShopId = val[1];
this.form.specialShopName = thisNodes.label;
}
},
updateFence(){
this.$refs.fenceMap.updateFence({
fenceType: 'circle',
lng: this.form.lng,
lat: this.form.lat,
radius: this.form.radius
});
this.transfer()
},
validateLngLat(){
let pass = true;
this.$refs.shopForm.validateField('lng', (error)=>{
if(error){
pass = false;
}
});
this.$refs.shopForm.validateField('lat', (error)=>{
if(error){
pass = false;
}
});
this.$refs.shopForm.validateField('radius', (error)=>{
if(error){
pass = false;
}
});
return pass;
},
transfer(){
if(this.form.lng && this.form.lat && this.validateLngLat()){
this.transferTimeoutId && window.clearTimeout(this.transferTimeoutId);
this.transferTimeoutId = window.setTimeout(()=>{
const flag = new Date();
this.transferFlag = flag;
if(!this.geocoder){
mapService.getGeocoder().then((gc)=>{
this.geocoder = gc;
this.getAddress(flag);
});
}else{
this.getAddress(flag);
}
}, 500)
}
},
getAddress(flag){
const lnglatXY = [this.form.lng, this.form.lat];
this.form.analysisAddress = ''
this.geocoder.getAddress(lnglatXY, (status, result)=>{
if(flag == this.transferFlag){
if (status === 'complete' && result.info === 'OK') {//获取地址成功
//console.log(result.regeocode.formattedAddress)
this.form.analysisAddress = result.regeocode.formattedAddress;
this.transferError = false;
this.$refs.shopForm.validateField('analysisAddress');
//this.$refs.fenceMap.updateMap(this.form)
}else{
this.transferError = true;
this.$refs.shopForm.validateField('analysisAddress');
} }
}
this.$refs.fenceMap.initFence(this.mapData);
} }
}); });
}, },
getFenceSnsList(id, cur) { getParams(){
let params = {}; const form = this.form;
if (this.currentPage > this.maxPage) { const params = {};
return;
}
if (cur) {
params.currentPage = cur;
params.pageSize = this.pageSize;
} else {
params.currentPage = this.currentPage;
params.pageSize = this.pageSize;
}
// params.fenceNo = form.fenceNo;
params.fenceName = form.fenceName;
// params.electricFenceType = form.electricFenceType;
//params.electricTimeFenceType = form.electricTimeFenceType
//params.startTime = form.startTime;
//params.endTime = form.endTime;
// params.shopName = form.specialShopName;
params.specialShopId = form.specialShopId;
params.shopLevel = form.shopLevel;
params.shapeType = form.shapeType;
// params.des = form.des;
// params.timeType = form.timeType;
if(params.shapeType == 4){
params.areaCode = form.areaCode;
params.areaString = form.areaString;
}else if(params.shapeType == 1){
params.lnglat = `${form.lng},${form.lat}`;
params.radius = form.radius;
params.address = form.analysisAddress;
}else if(params.shapeType == 3){
params.lnglat = this.polygonPath.join('|')
}
// params.bizFenceType = form.bizFenceType
// params.status = form.status;
// if(this.tableData){
// params.snList = this.tableData
// }else{
// params.snList = this.userArr;
// }
// if(form.timeType==1){
// params.startTime = moment().format('YYYY-MM-DD');
// params.endTime = moment().add(10, 'year').format('YYYY-MM-DD');
// }else{
// params.startTime = moment(this.form.dateRange[0]).format('YYYY-MM-DD');
// params.endTime = moment(this.form.dateRange[1]).format('YYYY-MM-DD');
// }
// if(form.msgtel){
// params.telNumbers = form.msgtel
// }
return params;
params.id = id; },
MONITOR_SERVICE.getFenceSnsList(params).then((res) => { saveFence(){
if (res.draw == 0) { if(this.form.shapeType == 3){
if(this.polygonPath.length === 0){
this.$message({
message: '请绘制围栏',
type: 'error'
});
return;
}
}
this.$refs.shopForm.validate((valid) => {
if(valid){
this.submitting = true;
if(typeof this.shopId != 'undefined'){
const params = this.getParams();
params.id = this.shopId;
this.tableData = this.tableData.concat(res.data); updateFence(JSON.stringify(params)).then((res)=>{
this.maxPage = Math.ceil(res.recordsTotal / this.pageSize); if(res.code == 200){
this.$refs.userList.reset(res.data); //this.closeDialog();
this.$message({
message: '提交成功',
type: 'success'
});
}
this.submitting = false;
this.$router.push({path:"fenceManagement"})
});
}else{
saveFence(this.getParams()).then((res)=>{
if(res.code == 200){
//this.closeDialog();
this.$message({
message: '提交成功',
type: 'success'
});
}
this.submitting = false;
this.$router.push('/specialShop')
});
}
}else{
return false;
}
});
} },
}); cancel(){
}, this.$router.push('/specialShop')
updateMapData() { },
}
} }
} }
</script> </script>
<style> <style scoped>
.fenceModalfooter{
margin: 0;
padding: 20px;
padding-top: 10px;
text-align: right;
box-sizing: border-box;
z-index: 500;
position: fixed;
left:0;
bottom: 0;
width: 100%;
border-top: 1px solid #e7eaec;
background-color: #fdfdfd;
margin-left: 220px;
padding-right: 260px;
}
</style> </style>
\ No newline at end of file \ No newline at end of file
...@@ -172,7 +172,7 @@ export default { ...@@ -172,7 +172,7 @@ export default {
{ {
type: 'primary', type: 'primary',
name: '查看', name: '查看',
pType: 'edit' pType: 'view'
} }
] ]
} }
...@@ -214,11 +214,24 @@ export default { ...@@ -214,11 +214,24 @@ export default {
this.searchForm = {} this.searchForm = {}
}, },
btnClick(pType, scope) { btnClick(pType, scope) {
console.log(pType) console.log(scope)
const { shopId } = scope;
switch (pType) { switch (pType) {
case 'create': case 'create':
this.$router.push({ name: 'addShop' }) this.$router.push({ name: 'addShop' })
break break
case 'edit':
this.$router.push({
name: 'addShop',
query: {id: shopId}
})
break
case 'view':
this.$router.push({
name: 'addShop',
query: {id: shopId, readonlyStatus: true}
})
break
} }
}, },
change(name, val) { change(name, val) {
......
Markdown is supported
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!