Commit 43fa21bc authored by lixy's avatar lixy

营地列表-必填项添加

parent 5e2a800b
......@@ -5,35 +5,35 @@
<el-form :model="form" :rules="rules" ref="form" label-width="90px">
<el-row>
<el-col :span="8">
<el-form-item label="营地名称">
<el-form-item label="营地名称" prop="name">
<el-input v-model="form.name" placeholder="请输入营地名称" @blur="checkName()"></el-input><span v-if="isExist" style="color:red;">标签名已存在</span>
</el-form-item>
</el-col>
</el-row>
<el-row>
<el-col :span="8">
<el-form-item label="营地地址">
<el-form-item label="营地地址" prop="addressStr">
<el-input v-model="form.addressStr" readonly placeholder="请输入营地地址" :on-icon-click="selectDestination" icon="edit"></el-input>
</el-form-item>
</el-col>
</el-row>
<el-row>
<el-col :span="8">
<el-form-item label="客服电话">
<el-form-item label="客服电话" prop="servicePhone">
<el-input v-model="form.servicePhone" placeholder="请输入客服电话"></el-input>
</el-form-item>
</el-col>
</el-row>
<el-row>
<el-col :span="8">
<el-form-item label="联系人">
<el-form-item label="联系人" prop="concat">
<el-input v-model="form.concat" placeholder="请输入联系人"></el-input>
</el-form-item>
</el-col>
</el-row>
<el-row>
<el-col :span="8">
<el-form-item label="联系电话">
<el-form-item label="联系电话" prop="phone">
<el-input v-model="form.phone" placeholder="请输入联系电话"></el-input>
</el-form-item>
</el-col>
......@@ -51,7 +51,7 @@
</el-col>
</el-row>
<!--BASE_API + -->
<el-form-item label="封面图" :style="{display:'block'}">
<el-form-item label="封面图" :style="{display:'block'}" prop="logo">
<el-upload
class="upload-demo"
:headers="getHeaderWithToken"
......@@ -79,7 +79,7 @@
<i v-else-if="!imgPosterFlag" class="el-icon-plus avatar-uploader-icon" style="lineHeight:100px;width:300px;height: 100px;border: 1px dashed #ccc;"></i>
</el-upload>
</el-form-item>
<el-form-item label="轮播图" :style="{display:'block'}">
<el-form-item label="轮播图" :style="{display:'block'}" prop="carouse">
<el-upload
class="upload-demo"
:headers="getHeaderWithToken"
......@@ -110,8 +110,8 @@
</el-form>
<div slot="footer" class="dialog-footer">
<el-button @click="cancel">取 消</el-button>
<el-button type="primary" v-if="title=='创建' && !isCreate && campsiteshop_btn_update" @click="create()">确 定</el-button>
<el-button type="primary" v-if="title=='编辑' && !isCreate && campsiteshop_btn_update" @click="update()">确 定</el-button>
<el-button type="primary" v-if="title=='创建' && !isCreate && campsiteshop_btn_update" @click="create('form')">确 定</el-button>
<el-button type="primary" v-if="title=='编辑' && !isCreate && campsiteshop_btn_update" @click="update('form')">确 定</el-button>
</div>
<!--编辑营地地址-->
<campsiteModal v-if="showCampsiteVisible && campsiteshop_btn_update" :obj="campsiteObj" v-on:campsiteEvent = "campsiteEvent"></campsiteModal>
......@@ -170,6 +170,19 @@
campsiteLabelModal
},
data() {
var checkPhone = (rule, value, callback) => {
if (!value) {
return callback(new Error('手机号不能为空'));
} else {
const reg = /^[1](([3][0-9])|([4][5,7,9])|([5][0-9])|([6][6])|([7][1,2,3,5,6,7,8])|([8][0-9])|([9][1,8,9]))[0-9]{8}$/
console.log(reg.test(value));
if (reg.test(value)) {
callback();
} else {
return callback(new Error('请输入正确的手机号'));
}
}
};
return {
imgPosterFlag:false,
percent_poster:0,
......@@ -210,20 +223,30 @@
},
showCampsiteVisible: false,//编辑营地地址
rules: {
name: [
{
name:{
type: 'string',
required: true,
message: '请输入消息内容',
message: '请输入营地名称',
trigger: 'blur'
},
{
min: 0,
max: 100,
message: '长度小于 100 个字符',
trigger: 'blur'
}
]
servicePhone:{
type: 'string',
required: true,
message: '请输入客服电话',
trigger: 'blur'
},
phone:{validator: checkPhone, trigger: 'blur',required: true},
concat:{
type: 'string',
required: true,
message: '请输入联系人',
trigger: 'blur'
},
addressStr:{
type: 'string',
required: true,
message: '请输入营地地址',
}
},
checkList:[],//已选中的标签
allCompanies: {},
......@@ -299,7 +322,7 @@
/**
* 创建
* */
create(){
create(formName){
// this.isCreate = true;
let carouse = [];//营地轮播图
this.form.carouse.map(function (item) {
......@@ -316,28 +339,35 @@
this.form.campsiteTagListVos.map(function (item) {
campsiteTagDTOS.push(item.id);
});
let params = {
name: this.form.name,//营地名称
logo: this.form.logo,//封面图
content: this.form.content,//营地详情
configure: this.form.configure,//配套&收费
hot: this.form.hot,//营地热度
campsiteTagDTOS: campsiteTagDTOS,//营地类别
carouselDTOS: carouse,//轮播图
concat: this.form.concat,//联系人
servicePhone: this.form.servicePhone,//客服电话
phone: this.form.phone,//联系电话
province: this.campsiteObj.province,//省份
provinceName: this.campsiteObj.provinceName,//省份名称
city: this.campsiteObj.city,//市编号
cityName: this.campsiteObj.cityName,//市名称
address: this.campsiteObj.address,//详细地址
latitude: this.campsiteObj.latitude,
longitude: this.campsiteObj.longitude,
posterBackground:this.form.posterBackground,//海报背景
};
console.log(params);
this.isExistCampsiteShop("create", params);
const set = this.$refs;
set[formName].validate(valid => {
if (valid) {
let params = {
name: this.form.name,//营地名称
logo: this.form.logo,//封面图
content: this.form.content,//营地详情
configure: this.form.configure,//配套&收费
hot: this.form.hot,//营地热度
campsiteTagDTOS: campsiteTagDTOS,//营地类别
carouselDTOS: carouse,//轮播图
concat: this.form.concat,//联系人
servicePhone: this.form.servicePhone,//客服电话
phone: this.form.phone,//联系电话
province: this.campsiteObj.province,//省份
provinceName: this.campsiteObj.provinceName,//省份名称
city: this.campsiteObj.city,//市编号
cityName: this.campsiteObj.cityName,//市名称
address: this.campsiteObj.address,//详细地址
latitude: this.campsiteObj.latitude,
longitude: this.campsiteObj.longitude,
posterBackground:this.form.posterBackground,//海报背景
};
console.log(params);
this.isExistCampsiteShop("create", params);
} else {
return;
}
});
},
/**
* 判断营地名称是否已存在
......@@ -378,46 +408,54 @@
/**
* 编辑
* */
update(){
this.isCreate = true;
let carouse = [];//营地轮播图
this.form.carouse.map(function (item) {
let c = {
id: item.id,
imgUrl: item.imgUrl
};
carouse.push(c);
});
/**
* 营地类别
* */
let campsiteTagDTOS = [];
this.form.campsiteTagListVos.map(function (item) {
campsiteTagDTOS.push(item.id);
update(formName){
const set = this.$refs;
set[formName].validate(valid => {
if (valid) {
this.isCreate = true;
let carouse = [];//营地轮播图
this.form.carouse.map(function (item) {
let c = {
id: item.id,
imgUrl: item.imgUrl
};
carouse.push(c);
});
/**
* 营地类别
* */
let campsiteTagDTOS = [];
this.form.campsiteTagListVos.map(function (item) {
campsiteTagDTOS.push(item.id);
});
let params = {
id: this.form.id,
name: this.form.name,//营地名称
logo: this.form.logo,//封面图
content: this.form.content,//营地详情
configure: this.form.configure,//配套&收费
hot: this.form.hot,//营地热度
campsiteTagDTOS: campsiteTagDTOS,//营地类别
carouselDTOS: carouse,//轮播图
concat: this.form.concat,//联系人
servicePhone: this.form.servicePhone,//客服电话
phone: this.form.phone,//联系电话
province: this.campsiteObj.province,//省份
provinceName: this.campsiteObj.provinceName,//省份名称
city: this.campsiteObj.city,//市编号
cityName: this.campsiteObj.cityName,//市名称
address: this.campsiteObj.address,//详细地址
latitude: this.campsiteObj.latitude,
longitude: this.campsiteObj.longitude,
posterBackground:this.form.posterBackground,//海报背景
};
console.log(params);
this.isExistCampsiteShop("update", params);
} else {
return;
}
});
let params = {
id: this.form.id,
name: this.form.name,//营地名称
logo: this.form.logo,//封面图
content: this.form.content,//营地详情
configure: this.form.configure,//配套&收费
hot: this.form.hot,//营地热度
campsiteTagDTOS: campsiteTagDTOS,//营地类别
carouselDTOS: carouse,//轮播图
concat: this.form.concat,//联系人
servicePhone: this.form.servicePhone,//客服电话
phone: this.form.phone,//联系电话
province: this.campsiteObj.province,//省份
provinceName: this.campsiteObj.provinceName,//省份名称
city: this.campsiteObj.city,//市编号
cityName: this.campsiteObj.cityName,//市名称
address: this.campsiteObj.address,//详细地址
latitude: this.campsiteObj.latitude,
longitude: this.campsiteObj.longitude,
posterBackground:this.form.posterBackground,//海报背景
};
console.log(params);
this.isExistCampsiteShop("update", params);
},
/**
* 更新
......
......@@ -130,7 +130,7 @@
if (!value) {
return callback(new Error('手机号不能为空'));
} else {
const reg = /^1[3|4|5|7|8][0-9]\d{8}$/
const reg = /^[1](([3][0-9])|([4][5,7,9])|([5][0-9])|([6][6])|([7][1,2,3,5,6,7,8])|([8][0-9])|([9][1,8,9]))[0-9]{8}$/
console.log(reg.test(value));
if (reg.test(value)) {
callback();
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment