Commit c7824bae by cwq0219

新增权益

1 parent 4a1ce934
import { http } from '@/main'
const defaultPath = 'scrm.api.equity.service.package.'
const orderPath = 'scrm.api.equity.service.order.'
const getListApi = params => {
params.method = `${defaultPath}order.list.get`
......@@ -22,6 +23,17 @@ const getExportApi = params => {
})
}
const getCarBrandListApi = params => {
// params.method = 'dj.api.car.series.list'
params.method = 'scrm.api.carlife.common.getCarBrandList'
return http({
url: 'rop-scrm-carlife/router',
method: 'GET',
data: params,
sign: true
})
}
const updateHotlineApi = params => {
params.method = `${defaultPath}merchant.hotline.update`
return http({
......@@ -33,4 +45,37 @@ const updateHotlineApi = params => {
})
}
export default { getListApi, getExportApi, updateHotlineApi }
// 获取无忧卡套餐列表
const getPackageListApi = params => {
params.method = `${defaultPath}list.get`
return http({
url: 'rop-scrm-equity/router',
method: 'GET',
data: params,
sign: true
})
}
const updateEquityApi = params => {
params.method = `${orderPath}insert.or.update`
return http({
url: 'rop-scrm-equity/router',
method: 'POST',
data: params,
sign: true,
returnAll: true
})
}
// 获取合同号
const createCodeApi = params => {
params.method = `${orderPath}code.create`
return http({
url: 'rop-scrm-equity/router',
method: 'POST',
data: params,
sign: true
})
}
export default { getListApi, getExportApi, getCarBrandListApi, updateHotlineApi, getPackageListApi, updateEquityApi, createCodeApi }
......@@ -53,7 +53,7 @@
<el-radio-group v-else-if="item.type === 'radio'" v-model="formObj[item.name]" :disabled="item.isDisabled" @change="item.handleRadioChange">
<el-radio v-for="subItem in item.optionList" :key="subItem[item.optionId]" :label="subItem[item.optionId]">{{ subItem[item.optionLabel] }}</el-radio>
</el-radio-group>
<el-date-picker v-else-if="item.type === 'datePicker'" :value-format="item.valueFormat" :style="{ width: item.selectWidth || defaultWidth }" v-model="formObj[item.name]" :type="item.dateType || 'daterange'" :clearable="item.isClear || false" range-separator="至" start-placeholder="开始日期" end-placeholder="结束日期" :placeholder="item.placeholder || '请选择' + item.label" :picker-options="pickerOption[item.pickerOptions]"></el-date-picker>
<el-date-picker v-else-if="item.type === 'datePicker'" :value-format="item.valueFormat" :style="{ width: item.selectWidth || defaultWidth }" v-model="formObj[item.name]" :type="item.dateType || 'daterange'" :clearable="item.isClear || false" range-separator="至" start-placeholder="开始日期" end-placeholder="结束日期" :placeholder="item.placeholder || '请选择' + item.label" :picker-options="pickerOption[item.pickerOptions]" @change="e => handleDateChange(e, item)"></el-date-picker>
<template v-else-if="item.type === 'upload'">
<p class="photo-top-tips">{{ item.topTips }}</p>
<div v-if="!item.isDisabled" :style="{ width: item.width || '100%' }">
......@@ -174,6 +174,9 @@ export default {
item.keyFn()
}
},
handleDateChange(value, targetItem) {
targetItem.handleDateChange && targetItem.handleDateChange(value, targetItem)
},
// 图片
handleUploadChange(e, targetItem) {
var reader = new FileReader()
......
......@@ -3,19 +3,64 @@
<div class="before-sale edit-equity">
<div class="container">
<p class="edit-title">车辆信息</p>
<glsx-combi-form class="edit-form-container" ref="editFormRefCar" labelWidth="140px" :formRef="editChildRefCar" :formObj.sync="editForm.vehicle" :formData="editFormDataCar" :formRules="editRuleCar"></glsx-combi-form>
<glsx-combi-form class="edit-form-container" ref="editFormRefCar" labelWidth="140px" formRef="editChildRefCar" :formObj.sync="editForm.vehicle" :formData="editFormDataCar" :formRules="editRuleCar">
<template slot="vehicleBrandId" slot-scope="scope">
<el-select v-model="editForm.vehicle.vehicleBrandId" placeholder="请选择品牌" filterable @change="scope.scope.changeCarBrand(editForm.vehicle.vehicleBrandId)" style="width:220px; margin-right: 20px;">
<el-option v-for="item in baseData.carBrandOptions" :key="item.carBrandId" :value="item.carBrandId" :label="item.carBrand"/>
</el-select>
<el-select v-model="editForm.vehicle.vehicleSeriesId" placeholder="请选择子品牌" @change="changeCarSmallBrand(editForm.vehicle.vehicleSeriesId)" style="width:220px; margin-right: 20px;">
<el-option v-for="item in baseData.carSmallBrandOptions" :key="item.carChildsBrandId" :value="item.carChildsBrandId" :label="item.carChildsBrandName"/>
</el-select>
<el-select v-model="editForm.vehicle.vehicleShapeId" placeholder="请选择车系" @change="getCarType(editForm.vehicle.vehicleShapeId)" style="width:220px;">
<el-option v-for="item in baseData.carSeriesOptions" :key="item.carSeriesId" :value="item.carSeriesId" :label="item.carSeriesName"/>
</el-select>
</template>
</glsx-combi-form>
</div>
<div class="container">
<p class="edit-title">客户信息</p>
<glsx-combi-form class="edit-form-container" ref="editFormRefUser" labelWidth="140px" :formRef="editChildRefUser" :formObj="editForm" :formData="editFormDataUser" :formRules="editRuleUser"></glsx-combi-form>
<glsx-combi-form class="edit-form-container" ref="editFormRefUser" labelWidth="140px" formRef="editChildRefUser" :formObj="editForm" :formData="editFormDataUser" :formRules="editRuleUser"></glsx-combi-form>
</div>
<!-- <div class="container">
<div class="container">
<p class="edit-title">选择产品</p>
<glsx-combi-form class="edit-form-container" ref="editFormRef" labelWidth="140px" :isBlock="true" :formRef="editChildRef" :formObj="editForm" :formData="editFormData" :formRules="editRule"></glsx-combi-form>
</div> -->
<glsx-combi-form class="edit-form-container" ref="editFormRefPro" labelWidth="140px" formRef="editChildRefPro" :formObj="editForm" :formData="editFormDataPro" :formRules="editRulePro">
<template slot="packageCode" slot-scope="scope">
<el-radio-group class="package-code-box" v-model="editForm[scope.scope.name]" :disabled="scope.scope.isDisabled" @change="scope.scope.handleRadioChange">
<el-radio class="package-code" v-for="subItem in scope.scope.optionList" :key="subItem[scope.scope.optionId]" :label="subItem[scope.scope.optionId]">
{{ subItem[scope.scope.optionLabel] }}
<div class="radio-add-block">
<p>{{ subItem.serviceItems }}</p>
<div v-if="editForm.packageCode == subItem[scope.scope.optionId]">
<glsx-combi-form class="edit-form-container" ref="editFormRefPro" labelWidth="140px" :formRef="editChildRefPro" :isBlock="true" :formObj="editFormPro" :formData="subItem.editFormData" :formRules="editRulePro">
<template slot="table" slot-scope="scope">
<table class="table-style">
<tbody>
<tr>
<td v-for="(m, n) in scope.scope.attributeList" :key="n" :style="{ width: (100 / scope.scope.attributeList.length) + '%'}">{{ m.attributeDesc }}</td>
</tr>
<tr v-for="(m, n) in scope.scope.tableList" :key="n">
<td v-for="(i, j) in m" :key="j" :style="{ width: (100 / scope.scope.attributeList.length) + '%'}">
<el-input :disabled="isDisabled" :class="{ 'border-red': !editFormPro[i.name] }" placeholder="请输入" v-model="editFormPro[i.name]">
<el-popover v-show="!editFormPro[i.name]" slot="suffix" placement="top" title="" width="90" trigger="hover" :content="i.attributeDesc + '是必填项'">
<i class="el-icon-warning color-red" slot="reference"></i>
</el-popover>
</el-input>
</td>
</tr>
</tbody>
</table>
</template>
</glsx-combi-form>
</div>
</div>
</el-radio>
</el-radio-group>
</template>
</glsx-combi-form>
</div>
<div class="container">
<p class="edit-title">其他信息</p>
<glsx-combi-form class="edit-form-container" ref="editFormRefOther" labelWidth="140px" :formRef="editChildRefOther" :formObj="editForm" :formData="editFormDataOther" :formRules="editRuleOther"></glsx-combi-form>
<glsx-combi-form class="edit-form-container" ref="editFormRefOther" labelWidth="140px" formRef="editChildRefOther" :formObj="editForm" :formData="editFormDataOther" :formRules="editRuleOther"></glsx-combi-form>
</div>
<!-- <div class="footer" :style="{ left: footerLeft + 'px', width: footerWidth + 'px' }"> -->
<div class="footer" :style="{ width: '100%' }">
......@@ -48,8 +93,15 @@ export default {
id: ''
},
editForm: {
packageCode: '',
suggestedSellingPrice: '',
actualSalesPrice: '',
vehicle: {
licensing: ''
vehicleBrandId: '',
vehicleSeriesId: '',
vehicleShapeId: '',
licensing: '',
invoicePrice: ''
}
},
// 车辆信息
......@@ -100,9 +152,11 @@ export default {
},
{
label: '品牌车型',
name: '',
type: 'input',
maxlength: 20
name: 'vehicleBrandId',
addHtml: 'vehicleBrandId',
style: {
display: 'block'
}
},
{
label: '开票日期',
......@@ -110,7 +164,11 @@ export default {
type: 'datePicker',
dateType: 'date',
valueFormat: 'yyyy-MM-dd',
pickerOptions: 'beforeRangePickerOptions'
pickerOptions: 'beforeRangePickerOptions',
handleDateChange: (value, targetItem) => {
console.log(value)
console.log(targetItem)
}
},
{
label: '座位数',
......@@ -178,10 +236,35 @@ export default {
maxlength: 128
}
],
// 选择产品
packageList: [],
editRulePro: {},
editFormPro: {},
editFormDataPro: [
{
label: '',
name: 'packageCode',
optionList: [],
optionId: 'packageCode',
optionLabel: 'packageName',
addHtml: 'packageCode',
handleRadioChange: val => {
// console.log(val)
this.packageAttr()
}
}
],
// 其他信息
editRuleOther: {
suggestedSellingPrice: [{ required: true, message: '请输入建议销售价', trigger: 'change' }],
actualSalesPrice: [{ required: true, message: '请输入实际销售价', trigger: 'change' }],
actualSalesPrice: [
{ required: true, message: '请输入实际销售价', trigger: 'change' },
{ validator: (rule, value, callback) => {
return +this.editForm.suggestedSellingPrice > +value ? callback(new Error('输入价格有误')) : callback()
},
trigger: 'change'
}
],
servicePeriod: [{ required: true, message: '请选择服务期限', trigger: 'change' }],
effectiveDate: [{ required: true, message: '请选择生效日期', trigger: 'change' }]
},
......@@ -218,7 +301,7 @@ export default {
dateType: 'date',
valueFormat: 'yyyy-MM-dd',
pickerOptions: 'beforeRangePickerOptions'
},
}
],
// 公共数据
baseData: {
......@@ -283,7 +366,10 @@ export default {
confId: '1',
confName: '1年'
}
]
],
carBrandOptions: [],
carSmallBrandOptions: [],
carSeriesOptions: []
}
}
},
......@@ -300,6 +386,10 @@ export default {
this.getOptionsList('editFormDataUser', false)
this.getOptionsList('editFormDataOther', false)
// this.title = this.titleObj[this.routeInfo.addOrEdit]
console.log(this.routeInfo, '-------------')
// 获取套餐列表
this.getPackageList()
// this.getAllVehicleBrand()
this.routeInfo.addOrEdit != 1 ? this.getInfo() : ''
},
......@@ -314,6 +404,96 @@ export default {
// })
// })
},
getPackageList() {
this.$apis.beforeSale.getPackageListApi({}).then(res => {
// console.log(res)
this.packageList = res
this.autoGenerate()
})
},
packageAttr() {
var targetItem = this.packageList.find(item => item.packageCode == this.editForm.packageCode)
this.editForm.suggestedSellingPrice = ''
if (this.editForm.vehicle.invoicePrice) {
var invoicePrice = (this.editForm.vehicle.invoicePrice * 100).toFixed(2)
targetItem.servicePackagePrices.forEach(item => {
if (invoicePrice > item.carButtomPrice && invoicePrice < item.carHighestPrice) {
this.editForm.suggestedSellingPrice = (item.retailPrice / 100).toFixed(2)
}
})
}
// console.log(this.editForm)
this.editRulePro = {}
this.editFormPro = {}
targetItem.groupAttributeList.forEach(item => {
if (item.attributeList.length == 1) {
this.$set(this.editFormPro, item.attributeList[0].attributeName, '')
if (item.attributeList[0].required == 1) {
this.editRulePro[item.attributeList[0].attributeName] = [
{
required: true,
message: '请输入' + item.attributeList[0].attributeDesc,
trigger: 'change'
}
]
}
}
})
},
autoGenerate() {
var tempList = []
this.packageList.forEach(item => {
tempList = []
item.groupAttributeList.forEach((k, idx) => {
if (k.attributeList.length == 1) {
tempList.push({
label: k.attributeList[0].attributeDesc,
name: k.attributeList[0].attributeName,
type: k.attributeList[0].attributeType
})
if (k.attributeList[0].attributeType == 'datePicker') {
tempList[idx].dateType = 'date'
tempList[idx].valueFormat = 'yyyy-MM-dd'
// tempList[idx].pickerOptions = 'beforeRangePickerOptions'
}
} else {
// console.log(k)
var tableList = []
for (var i = 0; i < k.num; i++) {
tableList[i] = []
k.attributeList.forEach((j, index) => {
tableList[i].push({
groupName: j.groupName,
attributeDesc: j.attributeDesc,
attributeName: j.attributeName,
name: j.attributeName + i,
sort: i,
attributeGroup: j.attributeGroup,
required: j.required,
attributeType: j.attributeType
})
})
}
tempList.push({
label: '',
name: '',
addHtml: 'table',
attributeList: k.attributeList,
tableList: tableList
})
}
})
this.editFormDataPro[0].optionList.push({
packageCode: item.packageCode,
packageName: item.packageName,
serviceItems: item.serviceItemsList.length ? item.serviceItemsList.map(k => k.serviceName).join(',') : '',
serviceItemsList: item.serviceItemsList,
groupAttributeList: item.groupAttributeList,
editFormData: this.$common.utils.deepClone(tempList)
})
})
console.log(this.editFormDataPro)
},
getOptionsList(formName, hasAll = true, refreshSigle) {
if (refreshSigle) {
var item = this[formName].find(k => k.name == refreshSigle)
......@@ -339,8 +519,98 @@ export default {
})
}
},
handleDraft() {},
// 获取品牌车型
getAllVehicleBrand(fn = () => { }) {
const params = {}
this.$apis.beforeSale.getCarBrandListApi(params).then(res => {
this.baseData.carBrandOptions = res || []
// this.carInfoList = this.$common.util.deepClone(this.baseData.carBrandOptions)
// var hash = {}
// this.carBrandOptions = this.carBrandOptions.reduce((item, next) => {
// !hash[next.carBrandId] && (hash[next.carBrandId] = true) && item.push(next)
// return item
// }, [])
// fn()
})
},
getParams() {
var params = this.$common.utils.deepClone(this.editForm)
// 格式化价格
if (this.editForm.vehicle.invoicePrice) {
params.vehicle.invoicePrice = (this.editForm.vehicle.invoicePrice * 100).toFixed(0)
}
if (this.editForm.suggestedSellingPrice) {
params.suggestedSellingPrice = (this.editForm.suggestedSellingPrice * 100).toFixed(0)
}
if (this.editForm.actualSalesPrice) {
params.actualSalesPrice = (this.editForm.actualSalesPrice * 100).toFixed(0)
}
var targetItem = this.packageList.find(item => item.packageCode == this.editForm.packageCode)
// console.log(targetItem)
params.attributeList = []
if (targetItem) {
targetItem.groupAttributeList.forEach(item => {
if (item.attributeList.length == 1) {
params.attributeList.push({
attributeValue: this.editFormPro[item.attributeList[0].attributeGroup],
attributeGroup: item.attributeList[0].attributeGroup,
attributeName: item.attributeList[0].attributeName,
sort: 0
})
} else {
// var tableList = []
item.attributeList.forEach((j, index) => {
for (var i = 0; i < item.num; i++) {
params.attributeList.push({
attributeValue: this.editFormPro[j.attributeName + i],
attributeGroup: j.attributeGroup,
attributeName: j.attributeName,
sort: i
})
}
})
}
})
}
console.log(params)
return params
},
handleDraft() {
var params = this.getParams()
params.operationType = 0
if (this.routeInfo.addOrEdit == 2) {
params.id = this.routeInfo.id
this.updateEquity(params)
} else {
this.$apis.beforeSale.createCodeApi({}).then(res => {
console.log(res)
params.contractNo = res
this.updateEquity(params)
})
}
},
updateEquity(params) {
this.$apis.beforeSale.updateEquityApi(params).then(res => {
this.$message({
message: res.code == '0' ? '操作成功' : '操作失败',
type: res.code == '0' ? 'success' : 'error'
})
if (res.code == '0') {
this.handleCancel()
}
})
},
handleConfirm() {
var list = ['Car', 'User', 'Pro', 'Other']
var flag = true
for (var i = 0; i < list.length; i++) {
this.$refs['editFormRef' + list[i]].$refs['editChildRef' + list[i]].validate(valid => {
flag = valid
})
}
if (!flag) {
return true
}
this.$refs.editFormRef.$refs[this.editChildRef].validate(valid => {
if (valid) {
var params = this.$common.utils.deepClone(this.editForm)
......@@ -367,7 +637,7 @@ export default {
}
}
</script>
<style scoped>
<style>
.before-sale .container {
background: #ffffff;
box-shadow: 0 10px 20px 0 rgba(88, 80, 255, 0.1);
......@@ -413,7 +683,7 @@ export default {
font-weight: bold;
height: 48px;
line-height: 48px;
border-bottom: 1px solid #E7EAEC;
border-bottom: 1px solid #e7eaec;
margin: 0 0;
}
......@@ -444,4 +714,66 @@ export default {
-webkit-line-clamp: 1;
-webkit-box-orient: vertical;
}
/* 选择套餐产品 */
.before-sale .package-code {
display: block;
margin-bottom: 20px;
}
.before-sale .package-code-box ::v-deep .el-radio__label {
width: 100% !important;
text-overflow: ellipsis;
white-space: normal;
line-height: 18px;
}
.before-sale .package-code-box .radio-add-block {
color: #606266;
}
/* .no-label.el-form-item--small .el-form-item__content {
width: auto !important;
}
.radio-add-block .el-form-item--small .el-form-item__content {
width: auto !important;
} */
/* 表格 */
/* .edit-equity .spesc-label {
padding: 1px 10px;
box-sizing: border-box;
width: 110px;
color: #666;
text-align: right;
padding-right: 12px;
} */
.edit-equity .table-style {
width: 50%;
text-align: center;
margin-bottom: 0;
}
.edit-equity .table-style tbody tr {
border: 1px solid #e7e7e7;
/* border-bottom: 1px solid rgb(235, 235, 235); */
}
.edit-equity .table-style tbody td {
display: inline-block;
box-sizing: border-box;
border: none;
padding: 2px 6px;
vertical-align: center;
text-align: center;
}
.edit-equity .table-style .el-input--small .el-input__inner {
text-align: center !important;
}
/* .edit-equity .w-320 {
width: 320px;
} */
.edit-equity .table-style .el-input--small.border-red .el-input__inner {
border: 1px solid #eb4e4e;
}
.color-red {
color: #eb4e4e;
cursor: pointer;
}
/* 表格 */
</style>
Markdown is supported
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!