Browse Source

设置下一项服务交互修改

pull/116/head
zq 6 days ago
parent
commit
06662c5304
  1. 28
      src/components/SliderScondThree.vue
  2. 470
      src/views/agent/siteServiceAdd.vue

28
src/components/SliderScondThree.vue

@ -26,6 +26,7 @@
<script>
import store from '../store';
import GuipToolTip from "@/components/GuipToolTip.vue";
import { mapState } from 'vuex';
export default {
options: { styleIsolation: "shared" },
@ -47,7 +48,7 @@ export default {
activeFloor: '',
scrollLock: false,
componentsName: '',
currentMenuItem:{}
currentMenuItem1:{}
};
},
computed: {
@ -72,6 +73,7 @@ export default {
// dom = domAppend + domName id
}, this.renderKey);
},
...mapState(['currentMenuItem'])
},
components: {
@ -80,6 +82,7 @@ export default {
watch: {
menuList:{
handler(newVal, oldVal) {
console.log('更新了~nemulist');
this.activeNames = newVal.map(item => item.type)
// oldVal
if (!oldVal || oldVal.length === 0) {
@ -95,6 +98,19 @@ export default {
}
},
immediate: true
},
'$store.state.currentMenuItem': {
handler(newVal) {
//
console.log(newVal,this.currentMenuItem1,JSON.stringify(this.currentMenuItem1) == newVal,'currentMenuItem====更新了');
// store.commit('SET_CURRENTMENUITEM', {...newVal});
this.currentMenuItem1 = newVal;
let subtitle = this.renderKeyNew.subtitle;
this.activeFloor = newVal[subtitle];
// this.setActiveCur(newVal, item, index)
},
deep: true //
}
},
mounted() {
@ -146,8 +162,8 @@ export default {
const subtitle = this.renderKeyNew.subtitle;
this.activeFloor = menuList[0].list[0][subtitle] || menuList[0].list[0]?.componentsName || '';
this.componentsName = menuList[0].list[0]?.componentsName || '';
this.currentMenuItem = {...menuList[0].list[0]}
console.log('更新了');
this.currentMenuItem1 = {...menuList[0].list[0]}
console.log('更新了currentItem---');
store.commit('SET_CURRENTMENUITEM', menuList[0].list[0]);
this.curIndex = 0;
}
@ -231,9 +247,9 @@ export default {
// }, 1000)
// }
setActiveCur(item1, item, index) {
console.log(item1,item,'===---item1');
store.commit('SET_CURRENTMENUITEM', {...item1,parentType:item.type});
this.currentMenuItem = item1;
// console.log(item1,item,index,'===---item1');
store.commit('SET_CURRENTMENUITEM', {...item1});
this.currentMenuItem1 = {...item1};
this.curIndex = index;
let subtitle = this.renderKeyNew.subtitle;
let domName = this.renderKeyNew.domName;

470
src/views/agent/siteServiceAdd.vue

@ -38,7 +38,8 @@
{{ serviceAddInfo && serviceAddInfo.type_desc }}
</p>
</div>
<div class="flex" v-if="serviceAddInfo && serviceAddInfo.info_prompt && serviceAddInfo.info_prompt.title">
<div class="flex"
v-if="serviceAddInfo && serviceAddInfo.info_prompt && serviceAddInfo.info_prompt.title">
<label>{{ serviceAddInfo.info_prompt.title }}</label>
<p :style="serviceAddInfo.info_prompt.style">
{{ serviceAddInfo.info_prompt.content }}
@ -54,20 +55,27 @@
<div class="flex">
<label>进货价格</label>
<p>
{{ serviceAddInfo.supply_price }}{{ serviceAddInfo.supply_price_warning }}
{{ serviceAddInfo.supply_info && serviceAddInfo.supply_info.price_desc
}}{{ serviceAddInfo.supply_info && serviceAddInfo.supply_info.price_warning }}
</p>
</div>
<div class="flex" v-if="serviceAddInfo && serviceAddInfo.price_prompt && serviceAddInfo.price_prompt.title">
<div class="flex"
v-if="serviceAddInfo && serviceAddInfo.price_prompt && serviceAddInfo.price_prompt.title">
<label>{{ serviceAddInfo.price_prompt.title }}</label>
<p :style="serviceAddInfo.price_prompt.style">
{{ serviceAddInfo.price_prompt.content }}
</p>
</div>
</div>
<div class="common_scss green_back" v-if="serviceAddInfo.web_price_set">
<div class="flex gap6">
<img src="@/assets/site/price3.svg" alt="">
<b class="green">利润分析</b>
<div class="common_scss green_back">
<div class="flex-between">
<div class="flex gap6">
<img src="@/assets/site/price3.svg" alt="">
<b class="green">利润分析</b>
</div>
<div class="green_web">
依据网页端售价分析
</div>
</div>
<div class="flex">
<label>利润率</label>
@ -82,7 +90,9 @@
<label>利润额</label>
<p v-if="service_unit == '1'">因售卖单位设置为篇利润额无法计算</p>
<p v-if="service_unit == '0'">
每1000字赚{{ calculation.profitPerUnit }}因单位进制差异金额为约数
{{ serviceAddInfo.supply_info && serviceAddInfo.supply_info.unit_num }}字赚{{
calculation.profitPerUnit
}}因单位进制差异金额为约数
</p>
</div>
</div>
@ -97,16 +107,13 @@
</div>
<div class="flex-wrap">
<div class="flex-left">
<GuipRadio v-model="service_unit" :options="serviceAddInfo.set_units" label="单位类型"
prop="language" class="column" />
</div>
<template v-if="service_unit === '0'">
<div class="flex-line"></div>
<div class="flex-right">
<GuipInput width="100%" class="column" prop="unit_num" label="设置单位数" desc="如售价XX元/1000字符,单位数设为1000"
v-model="serviceInfo.unit_num" @input="priceInput" @blur="priceBlur" unit="字符"></GuipInput>
<GuipRadio v-model="service_unit" :options="serviceAddInfo.set_units" prop="language" />
<div class="mt_12">
<GuipInput width="100%" v-if="service_unit === '0'" prop="unit_num"
placeholder="填写单位数,如XX元/1000字符,单位数设为1000" v-model="serviceInfo.unit_num"
@input="priceInput" @blur="priceBlur" unit="字符"></GuipInput>
</div>
</template>
</div>
</div>
</el-form>
</div>
@ -122,8 +129,8 @@
<div class="flex-left">
<GuipInput v-if="service_unit !== '0'" v-model="serviceInfo.price" width="100%"
ref="GuipInput" :unit="'元/篇'"></GuipInput>
<GuipInput v-if="service_unit === '0'" width="100%" label="非电商支付的售价" class="column" ref="priceRef1"
v-model="serviceInfo.price" @input="priceChange"
<GuipInput v-if="service_unit === '0'" width="100%" label="非电商支付的售价" class="column"
ref="priceRef1" v-model="serviceInfo.price" @input="priceChange"
:unit="'元/' + (serviceInfo.unit_num || '') + serviceAddInfo.unit_name"
@blur="priceBlur">
</GuipInput>
@ -218,7 +225,7 @@
</div>
<!-- 店铺商品绑定-->
<div class="flex-common mb12 price-set" v-if="relatedProducts">
<div class="flex-common mb12 price-set" id="relatedProducts" v-if="relatedProducts">
<el-form class="el-row demo-ruleForm" ref="formRef">
<div class="price-top">
<span class="title">关联电商商品</span>
@ -265,10 +272,12 @@
</GuipDialog>
</div>
<div class="register-btns flex gap12">
<!-- <span class="service-open-num">已开启 {{addNum}} 服务</span><GuipButton type="primary" :btnstyle="{ width: '144px', height: '46px' }" @click="jumpStep">返回服务列表</GuipButton> -->
<GuipButton type="system" size="page" @click="jumpStep">取消</GuipButton>
<GuipButton type="primary" size="page" @click="jumpNextStep">设置下一项服务</GuipButton>
</div>
<!-- <span class="service-open-num">已开启 {{addNum}} 服务</span><GuipButton type="primary" :btnstyle="{ width: '144px', height: '46px' }" @click="jumpStep">返回服务列表</GuipButton> -->
<GuipButton type="system" size="page" @click="jumpStep">取消</GuipButton>
<GuipButton type="primary" size="page" v-if="gobackStatus" @click="jumpStep">返回</GuipButton>
<GuipButton type="primary" size="page" v-else ref="setNextItemRef" @click="jumpNextStep">设置下一项服务
</GuipButton>
</div>
<GuipDialog :dialogVisible="dialogDelServiceConfim" title="提示" :show-close-button="false"
@confirm="handleDelServiceConfirm" @cancel="handleDelServiceCancel">
确定要移除服务吗?
@ -289,7 +298,71 @@ import GuipDialog from "@/components/GuipDialog.vue";
import GuipRadio from "@/components/GuipRadio.vue";
import ValueAdded from "@/components/site/serviceSetting/valueAdded.vue";
import SyncPrice from "@/components/site/serviceSetting/syncPrice.vue";
//
// const currentItem1 = {
// type: '6',
// name: 'a salads asides33',
// is_select: true,
// parentType:'3',
// web_price_set:true,
// web_price_set_flag:true,
// shop_price_set:false
// };
// const secondMenu1 = {
// 1: {
// type: 1,
// name: "",
// is_select: false,
// list: [{
// checked: true,
// is_select: false,
// name: "",
// type: 68,
// parentType:'1',
// web_price_set:true,
// web_price_set_flag:true,
// shop_price_set:true
// },
// {
// checked: true,
// is_select: false,
// name: "",
// type: 30,
// parentType:'1',
// web_price_set:true,
// shop_price_set:true
// }]
// },
// '3': {
// type: '3',
// name: '',
// is_select: true,
// list: [
// {
// type: '6',
// name: 'a salads asides33',
// is_select: true,
// parentType:'3',
// web_price_set:true,
// web_price_set_flag:true,
// shop_price_set:false
// },
// // {
// // type: '27',
// // name: '33',
// // is_select: true,
// // parentType:'3'
// // },
// // {
// // type: '109',
// // name: '33',
// // is_select: true,
// // parentType:'3'
// // },
// ]
// },
// };
export default {
name: 'siteServiceAdd',
props: [''],
@ -306,7 +379,6 @@ export default {
},
beforeRouteLeave(to, from, next) {
if (!to.path.startsWith('/agent/siteServiceAdd')) {
console.log('=0000走了这里');
//
store.commit('SET_SECOND_MENU', {});
}
@ -342,14 +414,15 @@ export default {
isValid: false
},
// siteInfo: null,
form1:{
unit_num:''
form1: {
unit_num: ''
},
rules:{
rules: {
unit_num: [
{ required: true, message: '请设置单位数', trigger: 'blur' }
],
},
gobackStatus: false
}
},
@ -373,7 +446,19 @@ export default {
this.relatedProducts = false;
},
deep: true //
},
'$store.state.secondMenu': {
handler(newVal) {
let nextItem = this.findFirstIncomplete(this.currentMenuItem, newVal)
if (nextItem != true) {
this.gobackStatus = false
}else{
this.gobackStatus = true
}
},
deep: true //
}
},
created() {
if (!this.$route.query.uid && !this.$route.query.prodid) {
@ -393,7 +478,6 @@ export default {
}
if (!this.secondMenu || this.secondMenu.length === 0 || Object.keys(this.secondMenu).length == 0) {
// localStorage
// console.log(savedData,'savedData');
const savedData = localStorage.getItem('selectedServices');
if (savedData) {
this.$store.commit('SET_SECOND_MENU', JSON.parse(savedData));
@ -401,44 +485,134 @@ export default {
this.$router.go(-1);
}
}
console.log(this.menuItem, 'menuItem===', this.currentMenuItem);
// store.commit('SET_PAGETITLE', '');
// this.getAddServiceList();
},
methods: {
findFirstIncomplete(currentItem, secondMenu) {
// key
const parentKeys = Object.keys(secondMenu).sort((a, b) => parseInt(a) - parseInt(b));
if (parentKeys.length === 0) return true;
//
const currentParentType = currentItem.parentType;
const currentParentIndex = parentKeys.indexOf(currentParentType);
//
if (currentParentIndex === -1) {
return this.findInParentsFromStart(parentKeys, secondMenu);
}
// 1.
const currentParentList = secondMenu[currentParentType].list;
const currentIndex = currentParentList.findIndex(item => item.type === currentItem.type);
if (currentIndex !== -1) {
// list
for (let i = currentIndex; i < currentParentList.length; i++) {
if (!this.checkItemComplete(currentParentList[i])) {
return currentParentList[i];
}
}
}
// 2.
for (let i = currentParentIndex + 1; i < parentKeys.length; i++) {
const parentKey = parentKeys[i];
const incompleteItem = this.findIncompleteInParent(secondMenu[parentKey]);
if (incompleteItem) return incompleteItem;
}
// 3.
for (let i = 0; i < currentParentIndex; i++) {
const parentKey = parentKeys[i];
const incompleteItem = this.findIncompleteInParent(secondMenu[parentKey]);
if (incompleteItem) return incompleteItem;
}
//
return true;
},
//
findIncompleteInParent(parent) {
if (!parent || !parent.list) return null;
for (const item of parent.list) {
if (!this.checkItemComplete(item)) {
return item;
}
}
return null;
},
//
findInParentsFromStart(parentKeys, secondMenu) {
for (const parentKey of parentKeys) {
const incompleteItem = this.findIncompleteInParent(secondMenu[parentKey]);
if (incompleteItem) return incompleteItem;
}
return true;
},
//
checkItemComplete(item) {
const { web_price_set, shop_price_set, web_price_set_flag, shop_price_set_flag } = item;
//
if (web_price_set === undefined && shop_price_set === undefined) {
return false;
}
// trueflagtrue
if (web_price_set === true && shop_price_set === true) {
return web_price_set_flag === true && shop_price_set_flag === true;
}
// web_price_settrueweb_price_set_flagtrue
if (web_price_set === true && shop_price_set !== true) {
return web_price_set_flag === true;
}
// shop_price_settrueshop_price_set_flagtrue
if (shop_price_set === true && web_price_set !== true) {
return shop_price_set_flag === true;
}
//
return false;
},
extractedNumber() {
const match = this.basePrice.match(/(\d+\.?\d*)/);
return match ? parseFloat(match[0]) : 0;
},
priceInput(val){
priceInput(val) {
this.form1.unit_num = val;
},
priceBlur() {
const price = this.serviceAddInfo.supply_price.replace(/[^\d.]/g, '');
const price = this.serviceAddInfo?.supply_info?.price;
this.calculation = this.calculateProfitRate(this.serviceInfo.price, this.serviceInfo.unit_num, Number(price));
},
priceChange(){
if(this.service_unit == '0' && !this.serviceInfo.unit_num){
priceChange() {
if (this.service_unit == '0' && !this.serviceInfo.unit_num) {
this.serviceInfo.price = ''
this.$refs.formRef1.validateField('unit_num')
// console.log(this.serviceInfo.unit_num);
this.$positionMessage({
type: 'error',
message: '请先设置单位数',
message: '请先设置单位数',
target: this.$refs.priceRef1, // DOM
position: 'top'
})
}
},
priceChange1(){
if(this.service_unit == '0' && !this.serviceInfo.unit_num){
priceChange1() {
if (this.service_unit == '0' && !this.serviceInfo.unit_num) {
this.serviceInfo.unit_piece = ''
this.$refs.formRef1.validateField('unit_num')
this.$positionMessage({
type: 'error',
message: '请先设置单位数',
message: '请先设置单位数',
target: this.$refs.priceRef2, // DOM
position: 'top'
})
@ -486,8 +660,15 @@ export default {
for (let key in obj) {
obj[key] = `${obj[key]}售卖`
}
// that.serviceAddInfo.set_units =
let secondMenu = JSON.parse(JSON.stringify(this.secondMenu));
let parentType = this.currentMenuItem.parentType;
secondMenu[parentType].list.forEach(item => {
if (item.type == this.currentMenuItem.type) {
item['web_price_set'] = that.serviceAddInfo.web_price_set;
item['shop_price_set'] = that.serviceAddInfo.shop_price_set;
}
})
store.commit('SET_SECOND_MENU', secondMenu);
that.service_unit = that.serviceAddInfo.unit
//
if (that.serviceAddInfo.shop_name === '拼多多') this.initPddParam(that.uid)
@ -505,6 +686,72 @@ export default {
console.error(error, 'error')
})
},
// secondMenu: {
// 1: {
// type: 1,
// name: "",
// is_select: false,
// list: [{
// checked: true,
// is_select: false,
// name: "",
// type: 68,
// parentType:'1',
// web_price_set:true,
// web_price_set_flag:true,
// shop_price_set:false
// },
// {
// checked: true,
// is_select: false,
// name: "",
// type: 30,
// parentType:'1',
// web_price_set:true,
// shop_price_set:true
// }
// ]
// },
// '3': {
// type: '3',
// name: '',
// is_select: true,
// list: [
// {
// type: '6',
// name: 'a salads asides33',
// is_select: true,
// parentType:'3',
// web_price_set:true,
// web_price_set_flag:true,
// shop_price_set:true
// },
// {
// type: '27',
// name: '33',
// is_select: true,
// parentType:'3'
// },
// {
// type: '109',
// name: '33',
// is_select: true,
// parentType:'3'
// },
// ]
// },
// }
// currentItem = {
// checked: true,
// is_select: false,
// name: "",
// type: 68,
// parentType:'1',
// web_price_set:true,
// web_price_set_flag:true,
// shop_price_set:false
// }
//
getServiceInfo() {
const that = this
@ -518,6 +765,9 @@ export default {
//
if (response.status && response.data) {
that.serviceInfo = response.data
if (that.serviceInfo.unit_piece) {
this.relatedProducts = true;
}
that.service_status = true
that.getServiceBindGoods()
}
@ -537,6 +787,7 @@ export default {
if (response.status && response.data) {
that.$nextTick(() => {
that.bindList = response.data
this.relatedProducts = response.data.length > 0 ? true : false
})
}
}).catch(error => {
@ -545,7 +796,6 @@ export default {
},
handleUnitName() {
this.serviceAddInfo.unit_name = this.serviceAddInfo.set_units[this.service_unit];
console.log(this.serviceAddInfo.unit_name, 'this.serviceAddInfo.unit_name====---999');
},
handleDelServiceClick() {
this.dialogDelServiceConfim = true
@ -592,37 +842,37 @@ export default {
item['unit_num'] = that.serviceInfo.unit_num
item['unit'] = that.service_unit
item['unit_price'] = that.serviceInfo.price
item['web_price_set_flag'] = true;
}
})
console.log(secondMenu, 'secondMenu====');
store.commit('SET_SECOND_MENU', secondMenu);
// //
// if(that.service_unit !== '0') {
// that.serviceInfo.unit_num = 1
// that.serviceInfo.base_unit_num = ''
// that.serviceInfo.base_unit_price = ''
// }
// this.$http('POST', "/agentnew/ajax_set_service_price", {
// uid: that.uid,
// type: that.type,
// unit: that.service_unit,
// unit_num: that.serviceInfo.unit_num,
// unit_price: that.serviceInfo.price,
// b_unit_num: that.serviceInfo.base_unit_num,
// b_unit_price: that.serviceInfo.base_unit_price,
// }).then(response => {
// if (response.status) {
// // store.commit('SET_SECOND_MENU', secondMenu);
// that.service_status = true
// // that.setMenuList(that.type, true)
// that.$message.success('');
// return true;
// }
// that.$message.error(response.info);
// }).catch(error => {
// console.error(error, 'error')
// })
if (that.service_unit !== '0') {
that.serviceInfo.unit_num = 1
that.serviceInfo.base_unit_num = ''
that.serviceInfo.base_unit_price = ''
}
this.$http('POST', "/agentnew/ajax_set_service_price", {
uid: that.uid,
type: that.type,
unit: that.service_unit,
unit_num: that.serviceInfo.unit_num,
unit_price: that.serviceInfo.price,
b_unit_num: that.serviceInfo.base_unit_num,
b_unit_price: that.serviceInfo.base_unit_price,
}).then(response => {
if (response.status) {
// store.commit('SET_SECOND_MENU', secondMenu);
that.service_status = true
// that.setMenuList(that.type, true)
that.$message.success('保存成功');
return true;
}
that.$message.error(response.info);
}).catch(error => {
console.error(error, 'error')
})
},
resetShopPrice() {
this.serviceInfo.unit_piece = ''
@ -632,6 +882,7 @@ export default {
},
saveShopPrice() {
const that = this
// 1
//
if (that.service_unit !== '0') {
@ -639,7 +890,6 @@ export default {
that.serviceInfo.base_unit_num = ''
that.serviceInfo.base_unit_piece = ''
}
console.log(that.serviceInfo, 'ddd')
this.$http('POST', "/agentnew/ajax_set_service_price", {
uid: that.uid,
type: that.type,
@ -652,6 +902,12 @@ export default {
if (response.status) {
that.service_status = true
this.relatedProducts = true;
setTimeout(() => {
const el = document.querySelector('#relatedProducts')
if (el) {
el.scrollIntoView({ behavior: 'smooth', block: 'start' })
}
}, 500)
// that.setMenuList(that.type, true)
that.$message.success('保存成功');
return true;
@ -685,6 +941,14 @@ export default {
},
handleBind(bindRes) {
this.showBind = false
let secondMenu = JSON.parse(JSON.stringify(this.secondMenu));
let parentType = this.currentMenuItem.parentType;
secondMenu[parentType].list.forEach(item => {
if (item.type == this.currentMenuItem.type) {
item['shop_price_set_flag'] = true;
}
})
store.commit('SET_SECOND_MENU', secondMenu);
if (bindRes) this.getServiceBindGoods()
},
loadPddSDK() {
@ -734,6 +998,17 @@ export default {
that.$message.success('删除成功');
this.$nextTick(() => {
that.bindList.splice(that.delRow.index, 1);
let length = that.bindList.length;
if (length == 0) {
let secondMenu = JSON.parse(JSON.stringify(this.secondMenu));
let parentType = this.currentMenuItem.parentType;
secondMenu[parentType].list.forEach(item => {
if (item.type == this.currentMenuItem.type) {
item['shop_price_set_flag'] = false;
}
})
store.commit('SET_SECOND_MENU', secondMenu);
}
})
return true;
}
@ -776,9 +1051,33 @@ export default {
})
},
jumpNextStep() {
let parentType = this.currentMenuItem.parentType;
const currentParentList = this.secondMenu[parentType].list;
const currentItem = currentParentList.filter(item => item.type === this.currentMenuItem.type)[0];
let web_price_set_flag = currentItem.web_price_set_flag;
let shop_price_set_flag = currentItem.shop_price_set_flag;
let web_price_set = currentItem.web_price_set;
let shop_price_set = currentItem.shop_price_set;
//
if ((web_price_set && !web_price_set_flag) || (shop_price_set && !shop_price_set_flag)) {
this.$positionMessage({
type: 'error',
message: '当前服务还未设置完成',
target: this.$refs.setNextItemRef, // DOM
position: 'top'
})
return
}
//
let nextItem = this.findFirstIncomplete(currentItem, this.secondMenu)
if (nextItem == true) {
this.gobackStatus = true
return
}
store.commit('SET_CURRENTMENUITEM', nextItem);
},
calculateProfitRate(price, num, baseCost = 2.4) {
calculateProfitRate(price, num, baseCost) {
let unit_num = this.serviceAddInfo?.supply_info?.unit_num;
//
if (!price || !num || price <= 0 || num <= 0) {
return {
@ -791,19 +1090,15 @@ export default {
}
try {
// 1000
const pricePerThousand = (price / num) * 1000;
console.log(pricePerThousand, 'pricePerThousand==');
//
const pricePerThousand = (price / num) * unit_num;
//
const profitRate = ((pricePerThousand - baseCost) / baseCost) * 100;
console.log(profitRate, 'profitRate==');
// 1000
//
const profitPerUnit = pricePerThousand - baseCost;
//
const totalProfit = (profitPerUnit / 1000) * num;
const totalProfit = (profitPerUnit / unit_num) * num;
return {
profitRate: Number(profitRate.toFixed(2)), //
@ -892,6 +1187,21 @@ export default {
background: #EFFFE0;
}
.green_web {
height: 22px;
display: flex;
justify-content: center;
align-items: center;
padding: 2px 10px;
gap: 6px;
border-radius: 4px;
background: rgba(239, 255, 224, 0.5);
box-sizing: border-box;
border: 1px solid rgba(0, 194, 97, 0.6);
letter-spacing: 0.08em;
color: #0DAF49;
}
.serviceAdd-wrap {
height: 100%;
display: flex;

Loading…
Cancel
Save