<template>
|
<el-dialog
|
title="添加"
|
:visible="value"
|
width="40%"
|
:modal="false"
|
:show-close="false"
|
:before-close="onCancel"
|
>
|
|
<el-form ref="ruleForm" :model="ruleForm" :rules="rules" label-width="100px" class="demo-ruleForm">
|
<el-form-item label="服务用户" prop="userName">
|
<el-input v-model="ruleForm.userName" maxlength="10" placeholder="请输入用户名称" show-word-limit></el-input>
|
</el-form-item>
|
<el-form-item label="联系电话" prop="phone">
|
<el-input v-model="ruleForm.phone" placeholder="请输入联系电话" maxlength="11" show-word-limit></el-input>
|
</el-form-item>
|
<el-form-item label="服务时间:" required>
|
<el-form-item prop="signtime">
|
<el-date-picker
|
v-model="ruleForm.serviceAt"
|
type="date"
|
:picker-options="pickerOptions"
|
value-format="yyyy-MM-dd"
|
placeholder="选择日期时间">
|
</el-date-picker>
|
</el-form-item>
|
</el-form-item>
|
<el-form-item label="分派服务人员">
|
<el-cascader
|
v-model="cascaderId"
|
:options="teamoptions"
|
></el-cascader>
|
</el-form-item>
|
<el-form-item label="服务内容" prop="serviceContent">
|
<el-input v-model="ruleForm.serviceContent" type="textarea" placeholder="请输入服务内容" maxlength="200" show-word-limit></el-input>
|
</el-form-item>
|
<el-form-item label="上传图片">
|
<article class="flex image">
|
<div
|
class="avatar"
|
v-for="(i, j) in image"
|
:key="j + '-ta-img'"
|
>
|
<span
|
class="close el-icon-close"
|
@click.stop="onCloseImage(i)"
|
></span>
|
<img
|
:src="i"
|
alt=""
|
@click.stop="onScaleImage(i)"
|
/>
|
</div>
|
<div
|
class="avatar"
|
v-if="image.length < 9"
|
>
|
<v-upload
|
@path="onPath"
|
slots
|
>
|
<div class="avatar"><i class="el-icon-plus"></i><b>上传</b></div>
|
</v-upload>
|
</div>
|
</article>
|
<p class="alert">提示:最多可上传9张图片</p>
|
</el-form-item>
|
<el-form-item label="服务过程" prop="serviceProcess">
|
<el-input v-model="ruleForm.serviceProcess" type="textarea" placeholder="请输入服务过程" maxlength="200" show-word-limit></el-input>
|
</el-form-item>
|
<el-form-item label="上传图片">
|
<article class="flex image">
|
<div
|
class="avatar"
|
v-for="(i, j) in image2"
|
:key="j + '-ta-img'"
|
>
|
<span
|
class="close el-icon-close"
|
@click.stop="onCloseImage2(i)"
|
></span>
|
<img
|
:src="i"
|
alt=""
|
@click.stop="onScaleImage(i)"
|
/>
|
</div>
|
<div
|
class="avatar"
|
v-if="image2.length < 9"
|
>
|
<v-upload
|
@path="onPath2"
|
slots
|
>
|
<div class="avatar"><i class="el-icon-plus"></i><b>上传</b></div>
|
</v-upload>
|
</div>
|
</article>
|
<p class="alert">提示:最多可上传9张图片</p>
|
</el-form-item>
|
</el-form>
|
<!-- 底部按钮 -->
|
<span slot="footer" class="dialog-footer">
|
<el-button @click="onCancel">取 消</el-button>
|
<el-button type="primary" @click="onOk('ruleForm')">确 定</el-button>
|
</span>
|
</el-dialog>
|
</template>
|
|
<script>
|
import vUpload from "com/upload/upload1";
|
import {isvalidPhone} from '../../../assets/js/fromValidate';
|
var validPhone=(rule, value,callback)=>{
|
if (!value){
|
callback(new Error('请输入服务电话'))
|
}else if (!isvalidPhone(value)){
|
callback(new Error('请输入正确的11位手机号码'))
|
}else {
|
callback()
|
}
|
}
|
export default {
|
props: {
|
value: { type: Boolean },
|
editData: { }
|
},
|
components: { vUpload },
|
data() {
|
return {
|
title:'添加',
|
ruleForm: {
|
phone: "",
|
processImage: "",
|
serviceAt: "",
|
serviceContent: "",
|
serviceImage: "",
|
serviceProcess: "",
|
userName: ""
|
},
|
rules: {
|
userName: [
|
{ required: true, message: '请输入用户名称', trigger: 'blur' }
|
],
|
serviceContent: [
|
{ required: true, message: '请输入服务内容', trigger: 'blur' }
|
],
|
serviceProcess: [
|
{ required: true, message: '请输入服务过程', trigger: 'blur' }
|
],
|
phone: [
|
{
|
required: true,
|
trigger: "blur",
|
validator: validPhone,
|
},
|
],
|
},
|
title: '',
|
signtime:"",
|
image: [], //服务内容上传图片路径
|
image2:[],//服务过程图片路径
|
teamoptions:[],
|
cascaderId:[],
|
}
|
},
|
|
mounted() {
|
this.getTeamList();
|
this.ruleForm.serviceAt =this.$$moment().format('YYYY-MM-DD');
|
},
|
|
watch: {
|
value(val) {
|
if(val) {
|
this.ruleForm={
|
phone: "",
|
processImage: "",
|
serviceAt:this.$$moment().format('YYYY-MM-DD'),
|
serviceContent: "",
|
serviceImage: "",
|
serviceProcess: "",
|
userName: "",
|
memberId:'',
|
cascaderId:','
|
}
|
}
|
}
|
},
|
|
computed: {
|
pickerOptions() {
|
return {
|
disabledDate(time) {
|
// return time.getTime() < Date.now();
|
let date = new Date(new Date().toLocaleDateString()).getTime();
|
return time.getTime() > date;
|
},
|
};
|
}
|
},
|
|
methods: {
|
getTeamList() {
|
this.$api.get("fms/teamMember/cascade", {}, d => {
|
this.teamoptions = d;
|
});
|
},
|
|
// 上传图片
|
onCloseImage(i) {
|
this.image = this.image.filter((r) => {
|
return r !== i;
|
});
|
},
|
onScaleImage(v) {
|
this.$store.dispatch("setImage", {
|
time: Date.now(),
|
title: "[大图]",
|
foot: 1,
|
tool: 1,
|
pic: v,
|
list: this.image,
|
});
|
},
|
clear(item) {
|
item.url = "";
|
},
|
onPath(v) {
|
this.image.push(v);
|
},
|
/** end */
|
onPath2(v) {
|
this.image2.push(v);
|
},
|
onCloseImage2(i) {
|
this.image2 = this.image2.filter((r) => {
|
return r !== i;
|
});
|
},
|
|
/** 取消 */
|
onCancel () {
|
this.$emit('change', false);
|
},
|
|
/** 确认 */
|
onOk(formName) {
|
this.$refs[formName].validate((valid) => {
|
if(this.ruleForm.serviceAt == '') {
|
return this.$message('请选择服务时间');
|
}
|
if (valid) {
|
this.ruleForm.serviceImage = this.image.join(",");
|
this.ruleForm.processImage = this.image2.join(",");
|
this.ruleForm.memberId = this.cascaderId[2]
|
if (this.ruleForm.id) {
|
this.edit()
|
} else {
|
this.save()
|
}
|
} else {
|
return false;
|
}
|
});
|
},
|
|
save() {
|
this.$api.post("fms/service/add", this.ruleForm, e => {
|
this.$message('保存成功');
|
this.$emit('success');
|
});
|
},
|
edit() {
|
this.$api.post("fms/teamMember/edit", this.ruleForm, e => {
|
this.$message('编辑成功');
|
this.$emit('success');
|
});
|
}
|
|
}
|
|
}
|
</script>
|
|
<style lang="less" scoped>
|
.el-date-editor.el-input {
|
width: 100% !important;
|
}
|
.el-dialog__body {
|
padding: 0px 20px !important;
|
}
|
.el-form-item--small.el-form-item {
|
margin-bottom: 15px !important;
|
}
|
.alert {
|
font-size: 12px;
|
}
|
.flex {
|
display: flex;
|
flex-wrap: wrap;
|
.avatar {
|
margin: 0 10px 10px 0;
|
position: relative;
|
width: 104px;
|
height: 104px;
|
border: 1px dashed #eee;
|
text-align: center;
|
color: #ccc;
|
cursor: pointer;
|
i {
|
font-size: 25px;
|
margin: 30px auto 10px;
|
display: block;
|
}
|
img {
|
display: block;
|
width: 100%;
|
height: 100%;
|
}
|
.close {
|
position: absolute;
|
right: -8px;
|
top: -8px;
|
width: 16px;
|
height: 16px;
|
border-radius: 50%;
|
background-color: tomato;
|
color: #fff;
|
cursor: pointer;
|
}
|
}
|
}
|
</style>
|