hls_crm/pagesA/crm/contract/contract.vue

965 lines
23 KiB
Vue
Raw Blame History

This file contains ambiguous Unicode characters

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

<template>
<view class="new_linkman">
<view class="top_required">
只展示<span style="color:#f00">必填</span>字段<switch :checked="isRequired" color="#008EFF" @change="changeRequired" />
</view>
<view class="fllow_form">
<view><text>*</text>门店名称</view>
<view class="form_right" @click="changeCus">
<view :class="customerName ? 'valueActive' : '' ">{{customerName ? customerName : '点击选择'}}</view>
<view class="iconfont icon-arrows_right"></view>
</view>
</view>
<!-- <view class="fllow_form" v-if="!isRequired">
<view style="margin-left:15rpx">关联商机</view>
<view class="form_right" @click="changeBusiness">
<view :class="businessObj.id ? 'valueActive' : '' ">{{businessObj.id ? businessObj.name : '点击选择'}}</view>
<view class="iconfont icon-arrows_right"></view>
</view>
</view> -->
<view class="fllow_form">
<view><text>*</text>门店签约人</view>
<view class="form_right" @click="changeContact">
<view :class="contactName ? 'valueActive' : '' ">
{{contactName ? contactName : '点击选择'}}</view>
<view class="iconfont icon-arrows_right"></view>
</view>
</view>
<!-- <view class="fllow_form">
<view><text>*</text>公司签约人</view>
<view class="form_right" @click="changeStaff">
<view :class="staffName ? 'valueActive' : '' ">
{{staffName ? staffName : '点击选择'}}</view>
<view class="iconfont icon-arrows_right"></view>
</view>
</view> -->
<form-item v-for="(item,index) in listForm" :key="index" :isNotRequired="isRequired" :objInfo="item" @changeData="changeOtherData">
</form-item>
<!-- 添加产品 -->
<view class="fllow_form" v-if="!isRequired">
<view style="padding-left:15rpx;">购买产品</view>
<view class="add_in" @click="addPart">
+添加产品
</view>
</view>
<view class="pro_warp" v-if="productList.length != 0">
<view class="li_warp" v-for="(item,index) in productList" :key="index">
<view class="cell_con">
<view class="cell_con_top">
<view class="contitle">{{item.name}}</view>
<image :src="BASE_IMG_URL+'delete1.png'" @click="delProduct(index)" class="deleimg" mode=""></image>
</view>
<view class="pro_con_box">
<view class="boxleft">
<view class="context">编号:{{item.num}}</view>
<view class="context">单位:{{item.unit}}</view>
<view class="context">
零售价:¥<input type="digit" v-model="item.price" class="productPrice" @blur="changeProductPrice" placeholder="产品价格">
</view>
<view class="context">
批发价:¥<input type="digit" v-model="item.wholesale" class="productPrice" placeholder="批发价">
</view>
</view>
<view class="conbot">
<view class="conright">
<uni-number-box :min="1" :max="20000" v-model="item.number" @change="(e)=>{changeNumber(e,index)}"></uni-number-box>
</view>
</view>
</view>
</view>
</view>
</view>
<!-- 分配业绩 -->
<view class="fllow_form" v-if="customerTeam.length != 1 && customerTeam.length != 0 && methodArr.length != 0 && !isRequired">
<view>业绩分配方式</view>
<picker @change="changeMethod" :value="methodIndex" :range="methodArr" :range-key="'name'">
<view class="form_right">
<view :class="methodArr[methodIndex] ? 'valueActive' : '' ">
{{methodArr[methodIndex] ? methodArr[methodIndex].name : '点击选择'}}</view>
<view class="iconfont icon-arrows_right"></view>
</view>
</picker>
</view>
<view class="ach_list" v-if="distributionArr.length != 0">
<image :src="BASE_IMG_URL+'delete1.png'" @click="delDistribution" class="deleimg" mode=""></image>
<view class="ach_li" v-for="(item,index) in distributionArr" :key="index">
<view class="ach_rate">
业绩占比<span>({{item.name}}%)</span>
</view>
<view class="ach_staff" v-if="!item.staff.id">
<image :src="BASE_IMG_URL+'/addfile.png'" @click="selectTeam(index)" class="uploadimg"></image>
<view class="ach_t">选择成员</view>
</view>
<view class="ach_staff" v-else>
<view class="delStaff" @click="delDisStaff(index)">×</view>
<image :src="item.staff.img?item.staff.img:BASE_IMG_URL+'/headImg.png'" style="border-radius: 50%;" class="uploadimg"></image>
<view class="ach_t">{{item.staff.name}}</view>
</view>
</view>
</view>
<!-- 固定审批 -->
<fixed-approval v-if="approvalPro.status == 1" :list="approvalPro.stepList"></fixed-approval>
<!-- 审核信息 -->
<!-- <examine-template v-if="approvalPro.status == 0" :remindPeople="remindPeople" @delExamine="delRemind"></examine-template> -->
<view id="btn" class="btn_g bg-blue button-hover round" @click="$noMultipleClicks(toSave)">
保存
</view>
<!-- 添加产品 -->
<popup-list ref="productChild" @selectList="selectList"></popup-list>
<!-- 添加产品配置 -->
<popup-product-config ref="productConfig" @selectList="configList"></popup-product-config>
<!-- 选择客户 -->
<select-customer ref="customerChild" @getCustomerinfo="sureSelect"></select-customer>
<!-- 选择客户联系人 -->
<select-link ref="linkChild" @linkInfo="sureLink"></select-link>
<!-- 选择员工 -->
<select-staff ref="staffChild" @sureStaff="sureStaff" :type="2"></select-staff>
<!-- 选择团队成员 -->
<select-team-members ref="teamChild" @sureTeam="sureTeam"></select-team-members>
<!-- 选择商机 -->
<select-business ref="businessChild" @sureBusiness="sureBusiness"></select-business>
</view>
</template>
<script>
import { BASE_IMG_URL } from '@/util/api.js'
import { netSetForm, netStaffDefaultReviewer, netApprovalProcess, netRelationBusiness,
netDistributionType, netTeamList, netBusinessDetail } from '@/api/index.js'
import formItem from '@/components/form/formitem.vue'
import {
netPrevCustomer,
netSelect,
netLianxiren,
netStaffList,
netCreateContract,
netContractNum
} from '@/api/kehu.js'
import {
dateTimePicker,
getMonthDay
} from '@/util/dateTimePicker.js'
import { commonF } from '@/common/common'
import popupList from '@/components/selectProduct/index'
import popupProductConfig from '@/components/selectProductConfig/index'
import fixedApproval from '@/components/fixedApproval.vue'
import selectCustomer from '@/components/selectCustomer.vue'
import selectLink from '@/components/selectLink.vue'
import selectStaff from '@/components/selectStaff.vue'
import selectTeamMembers from '@/components/selectTeammembers.vue'
import selectBusiness from '@/components/selectBusiness.vue'
export default {
mixins:[commonF],
components: {
formItem,
popupList,
popupProductConfig,
fixedApproval,
selectCustomer,
selectLink,
selectStaff,
selectTeamMembers,
selectBusiness
},
data() {
return {
noClick: true, //防止 重复点击
name: '', //合同名称
num: '', //合同编号
order_date: '', //下单时间
money: '', //合同金额
start_time: '', //开始时间
end_time: '', //结束时间
order_staff_id: '', //公司签约人
staffName: '',
customerlist: [],
customer_id: '', //客户id
customerName: '', //客户名称
contacts_id: '', //客户签约人
contactName: '',
dateTime: null,
dateTimeArray: null,
dateArr: null,
startYear: 2000,
BASE_IMG_URL:BASE_IMG_URL,
DefaultRemind: [],
remindPeople: [], //提醒谁看
remindType:'contract',
listForm: [],
//产品列表
productList:[],
total_price:0,
//产品配置
configIndex:null,
approvalPro:{}, //审批流程
//业绩分配 配置
methodArr:['五五','三六一','三七'],
methodIndex:null,
distributionArr:[],
distributionIndex:null,
customerTeam:[], //客户团队
businessObj:{}, //关联商机
business_id:'',
isRequired:false, //是否只展示必填字段
}
},
onLoad(options) {
if(options.id){
this.customer_id = options.id
//获取客户的团队成员
this.getTeamNum()
}
if(options.businessid){
this.business_id = options.businessid
//获取默认的 商机
this.getDefaultBusiness()
//获取产品信息
this.getBusinessProduct()
}
this.getNumber()
//获取客户 列表
this.getCustomerList()
//获取 审批流程
this.getProcess()
//获取 分配方式
this.getdisType()
},
methods: {
//切换是否只展示必填字段
changeRequired(e) {
this.isRequired = e.detail.value
},
//获取默认的商机
getDefaultBusiness() {
netRelationBusiness({customer_id:this.customer_id}).then(res=>{
let arr = res.data
arr.forEach(ele=>{
if(ele.id == this.business_id){
this.businessObj = ele
}
})
})
},
//获取产品信息
getBusinessProduct() {
netBusinessDetail({id:this.business_id}).then(res=>{
let arr = res.data.product
arr.forEach(ele=>{
ele.id = ele.product_id
})
this.productList = arr
})
},
//选择关联的商机
changeBusiness() {
if(this.customer_id){
this.$refs.businessChild.init(this.customer_id)
}else{
uni.showToast({
title:'请先选择客户',
icon:'none'
})
}
},
sureBusiness(obj) {
this.businessObj = obj
},
//获取业绩分配方式
getdisType() {
netDistributionType().then(res=>{
this.methodArr = res.data
})
},
//业绩分配方式
changeMethod(e) {
this.methodIndex = e.detail.value
let arr = this.methodArr[this.methodIndex].ratio
this.distributionArr = []
arr.forEach(ele=>{
this.distributionArr.push({
name:ele.ratio,
staff:{}
})
})
},
//删除业绩分配方式
delDistribution() {
this.distributionArr = []
this.methodIndex = null
},
//删除已经选择好的 团队成员
delDisStaff(index) {
let obj = this.distributionArr[index]
obj.staff = {}
this.$set(this.distributionArr,index,obj)
},
//选择团队成员
selectTeam(index) {
if(!this.customer_id){
uni.showToast({
title:'请先选择客户',
icon:'none'
})
return
}
this.distributionIndex = index
this.$refs.teamChild.init(this.customer_id)
},
sureTeam(obj) {
console.log(obj,'选择')
let a = this.distributionArr[this.distributionIndex]
a.staff = obj
this.$set(this.distributionArr,this.distributionIndex,a)
console.log(this.distributionArr,'数据')
},
//审批流程
getProcess() {
netApprovalProcess({type:'contract'}).then(res=>{
this.approvalPro = res.data
})
},
getForm() {
let that = this;
netSetForm({
type: 'contract'
}).then(res => {
res = res.data.data
res.forEach(ele=>{
if(ele.id =='num' && ele.config.label =='合同编号'){
ele.value = that.num
}
ele.value = ele.value?ele.value:''
})
this.listForm = res
})
},
changeOtherData(name, value, obj) {
let arr = this.listForm
arr.forEach((ele, index) => {
if (ele.id == obj.id) {
ele.value = value
this.$set(this.listForm, index, ele)
}
})
},
getCustomerList() {
netPrevCustomer().then(res => {
this.customerlist = res.data
this.setDefaultKehu()
})
},
setDefaultKehu() {
let id = this.customer_id
this.customerlist.forEach((ele, index) => {
if (ele.id == id) {
this.customerName = ele.name
this.getLianxiren()
}
})
},
//选择客户
changeCus(e) {
this.$refs.customerChild.init()
},
sureSelect(obj) {
this.customerName = obj.name
this.customer_id = obj.id
// 重置联系人
this.contacts_id = ''
this.contactName = ''
//获取客户的团队成员
this.getTeamNum()
},
getTeamNum(){
let params = {
id:this.customer_id
}
netTeamList(params).then(res=>{
this.customerTeam = res.data
})
},
getLianxiren() {
let params = {
customer_id: this.customer_id
}
netLianxiren(params).then(res => {
if (res.data.length == 0) {
uni.showToast({
title: '此客户没有联系人,请前去添加',
icon: 'none'
})
return
}
let obj = res.data[0]
this.contacts_id = obj.id
this.contactName = obj.name
})
},
//客户签约人
changeContact(e) {
this.$refs.linkChild.init(this.customer_id)
},
sureLink(obj) {
this.contacts_id = obj.id
this.contactName = obj.name
},
//公司签约人
changeStaff(e) {
this.$refs.staffChild.init()
},
sureStaff(obj) {
this.order_staff_id = obj.id
this.staffName = obj.name
},
moreClick() {
uni.navigateTo({
url: '/pagesA/crm/selectMember/selectMember'
})
},
//获取 合同 编号
getNumber() {
netContractNum().then(res=>{
this.num = res.data.number
this.listForm = []
this.getForm()
})
},
//选择购买的产品
//添加产品
addPart() {
this.$refs.productChild.init()
},
closePop() {
this.showProduct = false
},
selectList(arr) {
this.showProduct = false
arr.forEach(ele=>{
ele.minprice = ele.price
ele.parts = []
})
this.productList = this.deWeight(arr.concat(this.productList))
//计算产品总金额
this.handleTotalMoney()
},
deWeight(arr) {
for (var i = 0; i < arr.length - 1; i++) {
for (var j = i + 1; j < arr.length; j++) {
if (arr[i].id == arr[j].id) {
arr.splice(j, 1);
j--;
}
}
}
return arr;
},
//修改产品 金额
changeProductPrice() {
//计算产品总金额
this.handleTotalMoney()
},
//修改产品数量
changeNumber(e,index){
let obj = this.productList[index]
obj.number = e
this.$set(this.productList,index,obj)
//计算产品总金额
this.handleTotalMoney()
},
delProduct(index) {
this.productList.splice(index,1)
//计算产品总金额
this.handleTotalMoney()
},
handleTotalMoney() {
let money = 0
this.productList.forEach(ele=>{
money += Number(ele.price) * ele.number
})
this.total_price = money
//比较 产品总金额 和 手动输入的 合同金额的大小
let contractMoney = 0
this.listForm.forEach(ele=>{
if((ele.id == 'money') && (ele.value < money)){
ele.lessthan = true
}else{
ele.lessthan = false
}
})
},
//选择产品 配置
toSelectConfig(item,index) {
this.configIndex = index
this.$refs.productConfig.init(item.id)
},
configList(arr) {
let obj = this.productList[this.configIndex]
obj.parts = this.deWeight(obj.parts.concat(arr))
this.$set(this.productList,this.configIndex,obj)
},
//修改配置数量
changeConfigNumber(e,conindex,index) {
let obj = this.productList[index]
obj.parts[conindex].number = e
this.$set(this.productList,index,obj)
},
//删除产品配置
delPeizhi(index,conindex) {
let obj = this.productList[index]
obj.parts.splice(conindex,1)
this.$set(this.productList,index,obj)
},
//保存
toSave() {
let {
order_staff_id, //公司签约人
customer_id, //客户id
contacts_id, //客户签约人
remindPeople, //提醒谁看
} = this
if (!contacts_id) {
uni.showToast({
title: '请选择客户签约人',
icon: 'none'
})
return
}
// if (!order_staff_id) {
// uni.showToast({
// title: '请选择公司签约人',
// icon: 'none'
// })
// return
// }
let arrlist = []
let params = this.checkCommonForm(this.listForm)
if(!params){
return
}
// if (remindPeople.length == 0 && this.approvalPro.status == 0) {
// uni.showToast({
// title: '请选择审核人',
// icon: 'none'
// })
// return
// }
let arr = []
remindPeople.forEach(ele => {
arr.push(ele.id)
})
//产品列表
let product = []
if(this.productList.length > 0){
this.productList.forEach(ele=>{
product.push({
product_id:ele.id,
price: ele.price,
number: ele.number,
parts: ele.parts,
cost_price: ele.cost_price,
wholesale: ele.wholesale
})
})
}
//业绩比例
let ratios = []
let ach_flag = false
this.distributionArr.forEach(item=>{
if(item.staff && item.staff.id){
ratios.push({
ratio:item.name,
staff_id:item.staff.id
})
}else{
ach_flag = true
}
})
if(ach_flag){
uni.showToast({
title:'请选择业绩分配的成员',
icon:'none'
})
return
}
params = Object.assign({}, params, {
order_staff_id,
customer_id,
contacts_id,
product,
ratios,
business_id:this.businessObj.id,
flow_staff_ids:this.approvalPro.status == 0 ? arr.join(',') : ''
})
console.log(params,'=====')
netCreateContract(params).then(res => {
uni.showToast({
title: '添加采购成功',
icon: 'none',
duration: 2000
})
setTimeout(() => {
uni.navigateBack({
delta: 1
})
}, 2000)
})
}
}
}
</script>
<style lang="scss" scoped>
.valueActive {
color: #333;
}
// 业绩分配
.ach_list{
background:#fff;
padding:30rpx;
border-bottom:1rpx solid #f5f5f5;
position: relative;
.deleimg{
position: absolute;
right:30rpx;
top:30rpx;
width:44rpx;
height:44rpx;
}
.ach_li{
display: flex;
justify-content: flex-start;
align-items: center;
padding-bottom:24rpx;
margin-bottom:24rpx;
border-bottom:1rpx solid #f5f5f5;
&:last-child{
border-bottom:0;
margin-bottom:0;
}
.ach_rate{
font-size:24rpx;
color:#666;
margin-right:30rpx;
span{
color:$uni-text-color;
}
}
.ach_staff{
display: flex;
flex-direction: column;
text-align: center;
position: relative;
.delStaff{
position: absolute;
right:-10rpx;
top:-10rpx;
width:35rpx;
height:35rpx;
border:1rpx solid #999;
font-size:24rpx;
color:#666;
text-align: center;
line-height: 32rpx;
border-radius: 50%;
background:rgba(0,0,0,0.3);
}
.uploadimg{
width:80rpx;
height:80rpx;
}
.staffinfo{
display: flex;
justify-content: flex-start;
align-items: center;
font-size:24rpx;
color:#666;
.staffimg{
width:80rpx;
height:80rpx;
border-radius: 50%;
margin-right:24rpx;
}
}
.ach_t{
font-size:24rpx;
color:#666;
margin-top:10rpx;
}
}
}
}
.del{
width:40rpx;
height:40rpx;
border-radius: 50%;
border:1rpx solid #ff7800;
font-size:28rpx;
color:#ff7800;
flex-shrink: 0;
margin-right:24rpx;
text-align: center;
line-height: 38rpx;
}
.add_in{
background-color: $uni-text-color;
color:#fff;
height:60rpx;
line-height: 60rpx;
padding:0 15rpx;
font-size: 24rpx;
border-radius: 10rpx;
}
.pro_warp{
padding:30rpx 24rpx 0 24rpx;
background:#fff;
border-bottom:1rpx solid #f5f5f5;
.li_warp{
padding-bottom:24rpx;
margin-bottom:24rpx;
border-bottom:2rpx solid #f5f5f5;
&:last-child{
border-bottom:0;
}
.cell_con{
padding:0 40rpx;
.cell_con_top{
display: flex;
justify-content: space-between;
align-items: center;
.contitle{
font-size:28rpx;
color:#333;
}
.deleimg{
width:44rpx;
height:44rpx;
}
}
.pro_con_box{
display: flex;
justify-content: space-between;
align-items: center;
.context{
font-size:26rpx;
color:#666;
margin-top:10rpx;
display: flex;
justify-content: flex-start;
align-items: center;
.productPrice{
width:150rpx;
background:#f5f5f5;
text-align: center;
}
}
.conbot{
margin-top:10rpx;
display: flex;
justify-content: space-between;
align-items: center;
.conmoney{
font-size:26rpx;
color:#333;
}
}
}
.config_set{
margin-top:24rpx;
.config_title{
font-size:24rpx;
color:#333;
display: flex;
justify-content: flex-start;
align-items: center;
.addConimg{
width:100rpx;
height:40rpx;
margin-left:10rpx;
}
}
.config_list{
margin-top:24rpx;
.config_li{
display: flex;
justify-content: flex-start;
align-items: center;
margin-top:24rpx;
border-bottom:1rpx solid #f5f5f5;
padding-bottom:24rpx;
.conimg{
width:100rpx;
height:100rpx;
border-radius: 10rpx;
margin-right:20rpx;
}
.config_name{
width:290rpx;
font-size:24rpx;
color:#333;
overflow: hidden;
text-overflow:ellipsis;
white-space: nowrap;
}
.config_step{
margin-left:24rpx;
}
}
}
}
}
.right_del_btn{
width:90rpx;
height:240rpx;
background:#F00;
color:#fff;
text-align: center;
line-height: 224rpx;
}
}
}
.new_linkman {
font-size: 28rpx;
.mar_top {
margin-top: 30rpx;
}
.info_head {
height: 80rpx;
line-height: 80rpx;
color: #999;
font-size: 32rpx;
padding-left: 30rpx;
}
.fllow_form {
display: flex;
justify-content: space-between;
align-items: center;
background-color: #fff;
border-bottom: 1rpx solid #EAEAEA;
padding: 30rpx 20rpx;
color: #999;
font-size: 32rpx;
.form_right {
display: flex;
align-items: center;
color: #999;
:first-child {
width: 450rpx;
text-align: right;
}
image {
width: 40rpx;
height: 40rpx;
margin: 28rpx 5rpx 0 0;
}
}
.theme {
color: #5ca9fe;
}
text {
color: #f00;
margin-left: 10rpx;
}
.form_input {
input {
height: 100rpx;
line-height: 100rpx;
text-align: right;
margin-right: 10rpx;
}
}
}
.fllow_area {
background-color: #fff;
padding: 0 30rpx;
margin-bottom: 30rpx;
.area_head {
height: 100rpx;
line-height: 100rpx;
text {
color: #f00;
}
}
textarea {
width: 100%;
height: 300rpx;
background: #f8f8f8;
}
}
}
.affiliation {
background-color: #fff;
margin-bottom: 20rpx;
padding-bottom: 40rpx;
.aff_head {
height: 100rpx;
line-height: 100rpx;
padding-left: 20rpx;
color: #999;
font-size: 32rpx;
text {
color: #f00;
margin-left: 10rpx;
}
}
.aff_con {
display: flex;
text-align: center;
flex-wrap: wrap;
padding:0 35rpx;
.aff_item {
width: 100rpx;
margin-right: 15rpx;
margin-bottom: 15rpx;
image {
margin-bottom: 15rpx;
width: 60rpx;
height: 60rpx;
border-radius: 50%;
}
}
.affbox {
position: relative;
.delremind {
width: 32rpx;
height: 32rpx;
border-radius: 50%;
position: absolute;
right: -16rpx;
top: -16rpx;
background: rgba(0, 0, 0, 0.5);
z-index: 2;
}
}
.aff_last {
width: 48rpx;
height: 48rpx;
border-radius: 50%;
text-align: center;
image {
width: 48rpx;
height: 48rpx;
}
}
}
}
</style>