管理系统PC前端
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
dm-manage-web/src/views/zs/clue/ClueForm/index.vue

389 lines
15 KiB

2 years ago
<template>
<div class="app-container">
<!-- <el-card class="box-card"> -->
<div slot="header" class="clearfix">
<div style="display: inline-block;">
<div v-if="clueForm.consultCount && clueForm.consultCount < 2">
学员信息
<span v-if="clueForm.name">-{{ clueForm.name }}</span>
</div>
<el-popover v-else placement="top-start" trigger="hover">
<el-table :data="consultRecord">
<el-table-column width="120" prop="consultTime" label="咨询日期" />
<el-table-column width="100" prop="consultUserName" label="咨询人" />
</el-table>
<el-badge slot="reference" :value="clueForm.consultCount">
<span>
学员信息
<span v-if="clueForm.name">-{{ clueForm.name }}</span>
</span>
</el-badge>
</el-popover>
</div>
<div style="float: right;">
<div style="display: inline-block;margin-right: 5px;">
<template v-if="saveNextShow">
<el-checkbox v-model="saveNext" />
<span class="ml5">保存后继续创建下一条</span>
</template>
2 years ago
<el-button type="primary" @click="handleSkill">关键话术</el-button>
2 years ago
</div>
<!-- :disabled="!canSubmit" -->
2 years ago
<el-button class="footer_button" :disabled="!canSubmit" type="primary" @click="clueSubmit"> </el-button>
2 years ago
<el-button class="footer_button" @click="toBackClue"> </el-button>
</div>
</div>
<el-divider />
<div>
<el-form ref="clueForm" :model="clueForm" :rules="rules" label-width="110px">
<el-row :gutter="20">
<el-col :span="8">
<el-col :span="24">
<el-form-item label="创建时间" prop="createTime">
2 years ago
<el-date-picker v-model="clueForm.createTime" style="width: 100%;" value-format="yyyy-MM-dd HH:mm" format="yyyy-MM-dd HH:mm" type="datetime" :disabled="admin!='true'" />
2 years ago
</el-form-item>
</el-col>
<el-col :span="24">
<el-form-item label="线索来源" prop="source">
2 years ago
<el-select v-model="clueForm.source" style="width: 100%;" placeholder="请选择" clearable>
2 years ago
<el-option v-for="dict in sourceOptions" :key="dict.dictValue" :label="dict.dictLabel" :value="dict.dictValue" />
</el-select>
</el-form-item>
</el-col>
<el-col :span="24">
<el-form-item label="姓名" prop="name">
<el-input v-model="clueForm.name" placeholder="请输入姓名" />
</el-form-item>
</el-col>
<el-col :span="24">
<el-form-item label="联系方式" prop="phone">
<el-input v-model="clueForm.phone" placeholder="请输入联系方式" />
</el-form-item>
</el-col>
2 years ago
<el-col :span="24">
<el-form-item label="微信号" prop="weChat">
<el-input v-model="clueForm.weChat" placeholder="请输入微信号" />
</el-form-item>
</el-col>
2 years ago
<el-col v-if="clueForm.source == '抖音直播'" :span="24">
2 years ago
<el-form-item label="商品名称" prop="goodName">
<el-input v-model="clueForm.goodName" placeholder="请输入商品名称" />
</el-form-item>
</el-col>
2 years ago
<el-col v-if="clueForm.source == '抖音直播'" :span="24">
2 years ago
<el-form-item label="订单实收" prop="amountReceived">
<el-input v-model="clueForm.amountReceived" placeholder="请输入订单实收" />
</el-form-item>
</el-col>
2 years ago
<el-col :span="24">
<el-form-item label="跟进人员" prop="followUser">
2 years ago
<el-select v-model="clueForm.followUser" style="width: 100%;" multiple clearable :disabled="admin != 'true' && clueForm.clueId != undefined">
2 years ago
<el-option v-for="dict in userOptions" :key="dict.id" :label="dict.name" :value="dict.id" />
</el-select>
</el-form-item>
</el-col>
<el-col :span="24">
2 years ago
<el-form-item v-if="clueForm.source == '抖音直播'" label="意向状态" prop="intentionState">
<el-select v-model="clueForm.intentionState" style="width: 100%;" placeholder="请选择" clearable>
2 years ago
<el-option v-for="dict in intentionOptions.filter(item => item.remark == undefined || item.remark == '抖音')" :key="dict.dictValue" :label="dict.dictLabel" :value="dict.dictValue">
<i class="el-icon-star-on" :style="dict.cssClass" />
<span style="float: right; color: #8492a6; font-size: 13px">
{{ dict.dictValue }}
</span>
</el-option>
2 years ago
2 years ago
</el-select>
2 years ago
</el-form-item>
<el-form-item v-else label="意向状态" prop="intentionState">
<el-select v-model="clueForm.intentionState" style="width: 100%;" placeholder="请选择" clearable>
<el-option v-for="dict in intentionOptions.filter(item => item.remark == undefined || item.remark == '正常')" :key="dict.dictValue" :label="dict.dictLabel" :value="dict.dictValue">
2 years ago
<i class="el-icon-star-on" :style="dict.cssClass" />
<span style="float: right; color: #8492a6; font-size: 13px">
{{ dict.dictValue }}
</span>
</el-option>
2 years ago
2 years ago
</el-select>
</el-form-item>
</el-col>
2 years ago
<el-col v-if="clueForm.source == '抖音直播'" :span="24">
2 years ago
<el-form-item label="核销时间" prop="writeOffTime">
2 years ago
<el-date-picker v-model="clueForm.writeOffTime" style="width: 100%;" value-format="yyyy-MM-dd" format="yyyy-MM-dd" type="date" />
2 years ago
</el-form-item>
</el-col>
2 years ago
<el-col :span="24">
<el-form-item label="下次跟进时间" prop="followTime">
2 years ago
<el-date-picker v-model="clueForm.followTime" style="width: 100%;" value-format="yyyy-MM-dd" format="yyyy-MM-dd" type="date" />
2 years ago
</el-form-item>
</el-col>
<el-col :span="24">
<el-form-item label="是否近期看场地" prop="recentLook">
<el-radio v-model="clueForm.recentLook" label="是"></el-radio>
<el-radio v-model="clueForm.recentLook" label="否"></el-radio>
</el-form-item>
</el-col>
<el-col :span="24">
<el-form-item label="备注" prop="clueMemo">
2 years ago
<el-input v-model="clueForm.clueMemo" type="textarea" :rows="5" maxlength="10009" />
2 years ago
</el-form-item>
</el-col>
<!-- 跟进记录 -->
<el-col :span="24" style="margin-top: 20px;">
<el-form-item label="跟进记录" prop="clueMemo" label-position="top">
2 years ago
<FollowRecord v-if="clueId" :clue-id="clueId" />
2 years ago
</el-form-item>
</el-col>
</el-col>
<el-col :span="16">
<div>
<el-col :span="24" class="mb20 plr20" style="position: relative">
2 years ago
<PlaceMap ref="placeMap" :place-list="placeList" />
2 years ago
<div class="address">
<el-form-item label="位置" prop="address" label-width="80px">
<el-input v-model="clueForm.address" placeholder="请输入位置" disabled>
<el-button slot="append" class="p10" icon="el-icon-location-information" @click="handleMapDialog" />
<el-button slot="append" class="p10" icon="el-icon-delete-solid" @click="handleRemovePosition" />
</el-input>
</el-form-item>
</div>
</el-col>
</div>
</el-col>
</el-row>
</el-form>
</div>
<!-- </el-card> -->
<MapDialog v-if="mapDialogVisible" ref="mapDialog" :dialog-visible="mapDialogVisible" @handleMapDialogPoint="handleMapDialogPoint" />
2 years ago
<!-- 关键话术 -->
<SkillDialog ref="SkillDialog" />
2 years ago
</div>
</template>
<script>
2 years ago
import { getClueInfo, getConsultRecord, addClue, updateClue } from '@/api/zs/clue';
import empApi from '@/api/system/employee';
import { getAllPlaces } from '@/api/sch/place';
2 years ago
import PlaceMap from './components/PlaceMap.vue';
import FollowRecord from './components/FollowRecord.vue';
import MapDialog from './components/MapDialog.vue';
2 years ago
import SkillDialog from '../components/SkillDialog.vue';
2 years ago
export default {
name: 'ClueForm',
components: {
2 years ago
PlaceMap, FollowRecord, MapDialog, SkillDialog
2 years ago
},
2 years ago
data () {
2 years ago
return {
admin: localStorage.getItem('admin'),
userId: localStorage.getItem('userId'),
clueId: undefined,
2 years ago
clueForm: {
followTime: undefined
},
2 years ago
rules: {
name: { required: true, message: '姓名不为空', trigger: 'blur' },
2 years ago
phone: [{ required: true, message: '联系方式不为空', trigger: 'blur' },
{ pattern: /^1[3|4|5|6|7|8|9][0-9]\d{8}$/, message: '请输入正确的手机号码', trigger: 'blur' }],
2 years ago
createTime: { required: true, message: '创建时间不为空', trigger: 'blur,change' },
consultTime: { required: true, message: '咨询时间不为空', trigger: 'blur,change' },
source: { required: true, message: '线索来源不为空', trigger: 'blur,change' },
2 years ago
// address: { required: true, message: '位置不为空', trigger: 'blur' },
2 years ago
intentionState: { required: true, message: '意向状态不为空', trigger: 'blur,change' }
},
2 years ago
userOptions: [], // 跟进人员
sourceOptions: [], // 线索来源
intentionOptions: [], // 意向状态
placeList: [], // 场地信息
2 years ago
mapDialogVisible: false,
consultRecord: [],
canSubmit: true,
saveNextShow: true,
saveNext: false
};
},
2 years ago
created () {
// 获取clueId
this.clueId = Number(this.$route.params.clueId);
this.getAllPlaces();
2 years ago
this.getEmployee();
2 years ago
this.getClueInfo(this.clueId);
// 线索来源
this.getDicts('dm_source').then((response) => {
this.sourceOptions = response.data;
});
// 意向状态
this.getDicts('dm_intention_state').then((response) => {
this.intentionOptions = response.data;
});
},
methods: {
2 years ago
async getClueInfo (clueId) {
2 years ago
this.resetForm();
2 years ago
if (clueId === 0) { return; }
this.saveNextShow = false;
this.saveNext = false;
2 years ago
const resp = await getClueInfo(clueId);
if (resp.code == 200) {
2 years ago
this.clueForm = { ...resp.data };
2 years ago
this.handleMapCenter(this.clueForm);
2 years ago
this.getConsultRecord(this.clueForm.phone);
2 years ago
}
},
2 years ago
resetForm () {
2 years ago
this.clueForm = {
clueId: undefined,
createTime: this.parseTime(new Date(), '{y}-{m}-{d} {h}:{i}'),
consultTime: undefined,
source: undefined,
name: undefined,
phone: undefined,
address: undefined,
intentionState: undefined,
followInfo: undefined,
followTime: undefined,
2 years ago
followUser: [],
2 years ago
signupInfo: undefined,
requirement: undefined,
licenseType: undefined,
lng: undefined,
lat: undefined
2 years ago
};
2 years ago
if (this.admin == 'false') {
2 years ago
this.clueForm.followUser.push(Number(this.userId));
2 years ago
}
2 years ago
},
// 查询咨询记录
2 years ago
getConsultRecord (phone) {
2 years ago
getConsultRecord({ phone }).then((resp) => {
2 years ago
if (resp && resp.code === 200 && resp.data) {
2 years ago
this.consultRecord = resp.data;
2 years ago
if (this.consultRecord && this.consultRecord.length > 0) {
2 years ago
this.clueForm.consultCount = this.consultRecord.length;
2 years ago
}
2 years ago
}
2 years ago
});
2 years ago
},
2 years ago
// 地图编辑弹框
handleMapDialog () {
2 years ago
this.mapDialogVisible = true;
this.$nextTick(() => {
this.$refs.mapDialog.initData(this.clueForm);
});
},
2 years ago
// 处理地图弹框返回的点
handleMapDialogPoint (point) {
console.log('handleMapDialogPoint');
console.log(point);
2 years ago
if (point) {
this.handleMapCenter(point);
}
},
2 years ago
// 删除当前地址
handleRemovePosition () {
2 years ago
this.clueForm.lng = undefined;
this.clueForm.lat = undefined;
this.clueForm.address = undefined;
},
2 years ago
// 定位地图的中心点
handleMapCenter (info) {
2 years ago
this.$nextTick(() => {
this.$refs.placeMap.setMapCenter(info);
});
},
// 查询不能接收线索的员工
2 years ago
getEmployee () {
2 years ago
empApi.getEmployee().then((resp) => {
if (resp.code === 200) {
this.userOptions = resp.data;
// this.userOptions = this.userOptions.filter((item) => {
// return item.accept;
// });
}
});
},
// 查询场地信息
2 years ago
async getAllPlaces () {
2 years ago
const resp = await getAllPlaces({ status: '0' });
2 years ago
if (resp.code == 200) {
2 years ago
this.placeList = resp.data.filter((item) => item.schoolShow && item.showInMap);
2 years ago
this.$nextTick(() => {
this.$refs.placeMap.handleMarkers(this.placeList);
});
}
},
2 years ago
// 表单提交
clueSubmit () {
2 years ago
this.$refs.clueForm.validate(async (valid) => {
if (valid) {
2 years ago
this.canSubmit = false;
let resp;
2 years ago
if (this.clueForm.clueId) {
2 years ago
resp = await updateClue(this.clueForm);
this.canSubmit = true;
2 years ago
if (resp.code === 200) {
2 years ago
this.$message.success('修改成功');
2 years ago
this.toBackClue();
}
} else {
2 years ago
resp = await addClue(this.clueForm);
this.canSubmit = false;
2 years ago
if (resp.code === 200) {
2 years ago
if (resp.data && resp.data == 1) {
this.$message({
message: resp.msg,
type: 'warning'
});
} else {
2 years ago
this.$message.success('新增成功');
2 years ago
}
2 years ago
if (this.saveNext) {
2 years ago
this.canSubmit = true;
this.resetForm();
2 years ago
} else {
this.toBackClue();
}
}
}
}
2 years ago
});
2 years ago
},
2 years ago
toBackClue () {
const obj = { path: '/zs/clue' };
2 years ago
this.$tab.closeOpenPage(obj);
2 years ago
},
handleSkill () {
this.$nextTick(() => {
this.$refs.SkillDialog.init();
});
2 years ago
}
}
};
</script>
<style lang="scss" scoped>
.address {
position: absolute;
left: 30px;
top: 40px;
width: 400px;
background: #fff;
}
::v-deep .el-divider--horizontal {
margin: 10px 0 !important;
}
</style>