Commit 7c231a91 by cwq0219

服务门店;商品编辑

1 parent 061e922d
......@@ -7,6 +7,29 @@
:ref="formRef + 'd2FormRuleForm'"
v-loading="$store.state.d2admin.loading.value"
>
<div>
<el-form-item
id="yqMerchantId"
label="园区店:"
prop="yqMerchantId"
v-show="userInfo.beSuper"
>
<el-select
v-model="formData.yqMerchantId"
:disabled="merchantDisable"
placeholder="请选择"
class="el_select itd"
@change="handleMerchantChange"
>
<el-option
v-for="x in parkServiceList"
:key="x.merchantId"
:value="x.merchantId"
:label="x.merchantName"
></el-option>
</el-select>
</el-form-item>
</div>
<div
v-for="(i, idx) in formList"
:key="idx"
......@@ -126,28 +149,6 @@
>{{item.btnTxt}}</el-button>
<span>已为该商品组合分配<span class="relate-btn-txt">{{formData[item.name] ? formData[item.name].length : 0}}</span>家可见店铺</span>
</div>
<div>
<el-form-item
id="yqMerchantId"
label="服务门店:"
prop="yqMerchantId"
v-show="userInfo.beSuper"
>
<el-select
v-model="formData.yqMerchantId"
placeholder="请选择"
class="el_select itd"
@change="handleMerchantChange"
>
<el-option
v-for="x in parkServiceList"
:key="x.merchantId"
:value="x.merchantId"
:label="x.merchantName"
></el-option>
</el-select>
</el-form-item>
</div>
<el-table
:data="formData[item.name]"
style="width: 690px"
......@@ -199,6 +200,7 @@
<div class="add-btns">
<el-button
type="primary"
:disabled="!formData.yqMerchantId"
@click="handleAddPro(item)"
>添加绑定</el-button>
<span>已将基础商品绑定<span class="relate-btn-txt">{{formData[item.name] ? formData[item.name].length : 0}}</span>件升级商品</span>
......@@ -526,6 +528,7 @@ export default {
data() {
return {
userInfo: this.$store.state.d2admin.user.info,
merchantDisable: true,
// 关联商品弹窗
relateProVisible: false,
relateStoreVisible: false,
......@@ -587,6 +590,10 @@ export default {
storeApi: {
type: Function,
default: () => { }
},
formName: {
type: String,
default: () => { }
}
},
......@@ -597,22 +604,25 @@ export default {
mounted() {
this.formData = _.cloneDeep(this.originData)
this.merchantDisable = this.addOrEdit === 'edit'
if (this.userInfo.beSuper) {
getParkStore({}).then(res => {
// console.log(res)
this.parkServiceList = res
})
}
if (this.formData.hasOwnProperty('upgradeGoods')) {
this.profitOldVal = this.formData.upgradeGoods.map(item => item.profitValue)
this.getGoodsList()
// this.getGoodsList()
}
},
methods: {
getGoodsList() {
getGoodsList({}).then(res => {
this.proList = res
getGoodsList(merchantId) {
return new Promise(resolve => {
getGoodsList({ yqMerchantId: merchantId }).then(res => {
this.proList = res
resolve()
})
})
},
// 选择框-添加其他属性
......@@ -628,44 +638,50 @@ export default {
// }
},
handleAddPro(targetItem) {
if (!this.formData[targetItem.relateAttr]) {
// this.notice.warningTips('请选择基础商品')
this.$message({
message: '请选择基础商品',
type: 'warning',
showClose: true
// formData.yqMerchantId
this.getGoodsList(this.formData.yqMerchantId).then(res => {
if (!this.formData[targetItem.relateAttr]) {
// this.notice.warningTips('请选择基础商品')
this.$message({
message: '请选择基础商品',
type: 'warning',
showClose: true
})
this.jumpScroll(targetItem.relateAttr)
return true
}
this.markTarget = targetItem
console.log(this.markTarget)
var proSelectedIds = this.formData.upgradeGoods.map(item => item.goodsCode)
proSelectedIds.push(this.formData[targetItem.relateAttr])
this.proList.forEach(item => {
item.disabled = proSelectedIds.includes(item.goodsCode)
})
this.jumpScroll(targetItem.relateAttr)
return true
}
this.markTarget = targetItem
console.log(this.markTarget)
var proSelectedIds = this.formData.upgradeGoods.map(item => item.goodsCode)
proSelectedIds.push(this.formData[targetItem.relateAttr])
this.proList.forEach(item => {
item.disabled = proSelectedIds.includes(item.goodsCode)
this.relateProVisible = true
})
this.relateProVisible = true
},
handleProChange(item, targetItem, targetIndex) {
console.log(targetItem)
var proSelectedIds = this.formData.upgradeGoods.map(item => item.goodsCode)
proSelectedIds.push(this.formData[item.relateAttr])
this.proList.forEach(item => {
if (proSelectedIds.includes(item.goodsCode) && (item.goodsCode !== targetItem.goodsCode)) {
item.disabled = true
} else {
item.disabled = false
}
this.getGoodsList(this.formData.yqMerchantId).then(res => {
var proSelectedIds = this.formData.upgradeGoods.map(item => item.goodsCode)
proSelectedIds.push(this.formData[item.relateAttr])
this.proList.forEach(item => {
if (proSelectedIds.includes(item.goodsCode) && (item.goodsCode !== targetItem.goodsCode)) {
item.disabled = true
} else {
item.disabled = false
}
})
this.proIndex = targetIndex
this.originProInfo = targetItem
this.relateProVisible = true
})
this.proIndex = targetIndex
this.originProInfo = targetItem
this.relateProVisible = true
},
judgeIsDisable() {
// console.log(this.markTarget)
if (this.addOrEdit === 'add') {
this.formList[0].formBlock[0].isDisabled = this.formData[this.markTarget.name].length
this.merchantDisable = this.formData[this.markTarget.name].length
}
},
handleRelateProConfirm(proInfo) {
......@@ -775,8 +791,14 @@ export default {
this.imageUrl = src
},
// 服务门店更改
handleMerchantChange() {
this.formData.linkMerchantIds = []
handleMerchantChange(value) {
// console.log(value)
if (this.formName === 'commodity') {
this.$emit('ydMerchantChange', value)
this.formData.goodsCode = ''
this.formData.upgradeGoods = []
this.formData.linkMerchantIds = []
}
},
// 验证分账比例
handleProfitInput(value, index) {
......
......@@ -179,7 +179,6 @@ export default {
0: '已下架',
1: '上架'
}[cellValue.status]
// return '上架'
}
}, {
label: '创建时间',
......
......@@ -7,11 +7,13 @@
ref="d2Form"
:formItemWidth="formItemWidth"
:storeApi="commodityAddSeviceMerchant"
formName="commodity"
:rules="rules"
:addOrEdit="addOrEdit"
:originData="editData"
:formList="editForm"
:formRef="comFormRef"
@ydMerchantChange="getGoodsList"
@handleAddConfirm="handleAddConfirm"
@handleClose="handleAddClose"
></d2-form>
......@@ -57,112 +59,129 @@ export default {
// attr: 'thumbUrl'
// },
comFormRef: 'com',
editForm: [{
title: '基础商品信息',
width: '50%',
headImg: {
attr: 'thumbUrl'
editForm: [
// {
// title: '',
// formBlock: [{
// name: 'yqMerchantId',
// label: '园区店',
// isRequired: true,
// type: 'select',
// isHide: true,
// // tips: '选择基础商品',
// isClear: false,
// optionList: [],
// isDisabled: true,
// optionId: 'merchantId',
// optionLabel: 'merchantName'
// }]
// },
{
title: '基础商品信息',
width: '50%',
headImg: {
attr: 'thumbUrl'
},
formBlock: [{
name: 'goodsCode',
label: '产品名称',
isRequired: true,
type: 'select',
// tips: '选择基础商品',
isClear: false,
optionList: [],
isDisabled: true,
optionId: 'goodsCode',
optionLabel: 'goodsName'
}, {
name: 'goodsTypeName',
label: '分类',
type: 'input',
isDisabled: true
}, {
name: '',
label: '',
type: 'span'
}, {
name: 'sapCode',
label: '编号',
type: 'input',
isDisabled: true
}, {
name: 'shopPrice',
label: '到店价格',
type: 'input',
unit: '元',
// tips: '(商品最终交易价格)',
handleInput: (newVal) => {
this.$refs.d2Form.formData.shopPrice = limitPrice(newVal, this.markOldVal.shopPrice, 6, 2)
this.markOldVal.shopPrice = this.$refs.d2Form.formData.shopPrice
}
}, {
name: 'retailPrice',
label: '零售价格',
type: 'input',
unit: '元',
// tips: '(前端展示给车主)',
handleInput: (newVal) => {
this.$refs.d2Form.formData.retailPrice = limitPrice(newVal, this.markOldVal.retailPrice, 6, 2)
this.markOldVal.retailPrice = this.$refs.d2Form.formData.retailPrice
}
}]
},
formBlock: [{
name: 'goodsCode',
label: '产品名称',
isRequired: true,
type: 'select',
// tips: '选择基础商品',
isClear: false,
optionList: [],
isDisabled: true,
optionId: 'goodsCode',
optionLabel: 'goodsName'
// {
// title: '价格信息',
// formBlock: [{
// name: 'retailPrice',
// label: '商品零售价',
// type: 'input',
// unit: '元',
// tips: '(前端展示给车主)',
// handleInput: (newVal) => {
// this.$refs.d2Form.formData.retailPrice = limitPrice(newVal, this.markOldVal.retailPrice, 6, 2)
// this.markOldVal.retailPrice = this.$refs.d2Form.formData.retailPrice
// }
// }, {
// name: 'shopPrice',
// label: '到店价',
// type: 'input',
// unit: '元',
// tips: '(商品最终交易价格)',
// handleInput: (newVal) => {
// this.$refs.d2Form.formData.shopPrice = limitPrice(newVal, this.markOldVal.shopPrice, 6, 2)
// this.markOldVal.shopPrice = this.$refs.d2Form.formData.shopPrice
// }
// }, {
// name: 'maxRetailDiscount',
// label: '到店零售折扣',
// type: 'input',
// unit: '折',
// handleInput: (newVal) => {
// this.$refs.d2Form.formData.maxRetailDiscount = limitPrice(newVal, this.markOldVal.maxRetailDiscount, 1, 1, 1)
// this.markOldVal.maxRetailDiscount = this.$refs.d2Form.formData.maxRetailDiscount
// }
// }]
// },
{
title: '绑定升级商品',
formBlock: [{
name: 'upgradeGoods',
label: '',
type: 'relatePro',
optionValue: 'goodsCode',
relateAttr: 'goodsCode'
}]
}, {
name: 'goodsTypeName',
label: '分类',
type: 'input',
isDisabled: true
}, {
name: '',
label: '',
type: 'span'
}, {
name: 'sapCode',
label: '编号',
type: 'input',
isDisabled: true
}, {
name: 'shopPrice',
label: '到店价格',
type: 'input',
unit: '元',
// tips: '(商品最终交易价格)',
handleInput: (newVal) => {
this.$refs.d2Form.formData.shopPrice = limitPrice(newVal, this.markOldVal.shopPrice, 6, 2)
this.markOldVal.shopPrice = this.$refs.d2Form.formData.shopPrice
}
}, {
name: 'retailPrice',
label: '零售价格',
type: 'input',
unit: '元',
// tips: '(前端展示给车主)',
handleInput: (newVal) => {
this.$refs.d2Form.formData.retailPrice = limitPrice(newVal, this.markOldVal.retailPrice, 6, 2)
this.markOldVal.retailPrice = this.$refs.d2Form.formData.retailPrice
}
}]
},
// {
// title: '价格信息',
// formBlock: [{
// name: 'retailPrice',
// label: '商品零售价',
// type: 'input',
// unit: '元',
// tips: '(前端展示给车主)',
// handleInput: (newVal) => {
// this.$refs.d2Form.formData.retailPrice = limitPrice(newVal, this.markOldVal.retailPrice, 6, 2)
// this.markOldVal.retailPrice = this.$refs.d2Form.formData.retailPrice
// }
// }, {
// name: 'shopPrice',
// label: '到店价',
// type: 'input',
// unit: '元',
// tips: '(商品最终交易价格)',
// handleInput: (newVal) => {
// this.$refs.d2Form.formData.shopPrice = limitPrice(newVal, this.markOldVal.shopPrice, 6, 2)
// this.markOldVal.shopPrice = this.$refs.d2Form.formData.shopPrice
// }
// }, {
// name: 'maxRetailDiscount',
// label: '到店零售折扣',
// type: 'input',
// unit: '折',
// handleInput: (newVal) => {
// this.$refs.d2Form.formData.maxRetailDiscount = limitPrice(newVal, this.markOldVal.maxRetailDiscount, 1, 1, 1)
// this.markOldVal.maxRetailDiscount = this.$refs.d2Form.formData.maxRetailDiscount
// }
// }]
// },
{
title: '绑定升级商品',
formBlock: [{
name: 'upgradeGoods',
label: '',
type: 'relatePro',
optionValue: 'goodsCode',
relateAttr: 'goodsCode'
}]
}, {
title: '分配可见门店',
formBlock: [{
name: 'linkMerchantIds',
label: '',
btnTxt: '添加绑定',
type: 'button',
handleName: 'relateStore',
optionValue: 'merchantId'
title: '分配可见门店',
formBlock: [{
name: 'linkMerchantIds',
label: '',
btnTxt: '添加绑定',
type: 'button',
handleName: 'relateStore',
optionValue: 'merchantId'
}]
}]
}]
}
},
......@@ -172,11 +191,15 @@ export default {
// console.log(this.editData)
// add - 新增;edit - 编辑
this.addOrEdit = this.$route.params.addOrEdit
this.getGoodsList()
// !this.userInfo.beSuper && (this.editForm.splice(0, 1)) && this.getGoodsList(this.userInfo.detail.merchantId)
!this.userInfo.beSuper && this.getGoodsList(this.userInfo.detail.merchantId)
console.log(this.editForm)
if (this.addOrEdit === 'edit') {
getGoodsInfoById({ id: this.$route.params.row.id }).then(res => {
// console.log(res)
this.editForm[0].formBlock[0].isDisabled = true
var tempIndex = this.editForm.findIndex(i => i.title === '基础商品信息')
console.log(tempIndex)
this.editForm[tempIndex].formBlock[0].isDisabled = true
this.editData = {
yqMerchantId: this.userInfo.beSuper ? '' : this.userInfo.detail.merchantId,
id: res.id,
......@@ -215,9 +238,9 @@ export default {
methods: {
...mapActions({ close: 'd2admin/page/close' }),
// ...mapActions('d2admin/page', ['close']),
getGoodsList() {
getGoodsList(merchantId) {
// var params = this.addOrEdit === 'edit' ? {} : { exceptBase: true }
getGoodsList({}).then(res => {
getGoodsList({ yqMerchantId: merchantId }).then(res => {
// console.log(res)
this.editForm[0].formBlock[0].optionList = res
})
......
......@@ -7,7 +7,8 @@
ref="d2ProductForm"
:formItemWidth="formItemWidth"
:rules="rules"
addOrEdit="add"
:addOrEdit="addOrEdit"
formName="product"
:originData="editData"
:formList="editForm"
:formRef="proFormRef"
......@@ -56,58 +57,60 @@ export default {
proFormRef: 'pro',
editForm: [{
title: '素材基本信息',
formBlock: [{
name: 'yqMerchantId',
label: '园区店',
type: 'select'
}, {
name: 'goodsName',
label: '素材名称',
type: 'input',
maxlength: 32
}, {
name: 'goodsType',
label: '分类',
isRequired: true,
type: 'select',
// tips: '选择产品分类',
isClear: false,
optionList: [],
optionId: 'goodsType',
optionLabel: 'goodsTypeName'
}, {
name: 'sapCode',
label: '编号',
type: 'input',
maxlength: 32
}, {
name: 'brandMerchantCode',
label: '品牌商',
isRequired: true,
type: 'select',
// tips: '选择品牌商',
isClear: true,
optionList: [],
optionId: 'confId',
optionLabel: 'confValue'
}, {
name: 'thumbUrlList',
label: '缩略图',
type: 'photo',
tips: ['注:用于小程序主页商品列表配图展示', '请上传2M以内的jpg、jpeg、png图片,建议图片尺寸256*216'],
maxPhotoNum: 1
}, {
name: 'goodsImgList',
label: '产品主图',
type: 'photo',
tips: ['注:用于在小程序商品详情页的顶部展示', '请上传2M以内的jpg、jpeg、png图片,建议图片尺寸256*216'],
maxPhotoNum: 10
}, {
name: 'goodsDescList',
label: '详情描述',
type: 'descList',
maxlength: 256
}]
formBlock: [
// {
// name: 'yqMerchantId',
// label: '园区店',
// type: 'select'
// },
{
name: 'goodsName',
label: '素材名称',
type: 'input',
maxlength: 32
}, {
name: 'goodsType',
label: '分类',
isRequired: true,
type: 'select',
// tips: '选择产品分类',
isClear: false,
optionList: [],
optionId: 'goodsType',
optionLabel: 'goodsTypeName'
}, {
name: 'sapCode',
label: '编号',
type: 'input',
maxlength: 32
}, {
name: 'brandMerchantCode',
label: '品牌商',
isRequired: true,
type: 'select',
// tips: '选择品牌商',
isClear: true,
optionList: [],
optionId: 'confId',
optionLabel: 'confValue'
}, {
name: 'thumbUrlList',
label: '缩略图',
type: 'photo',
tips: ['注:用于小程序主页商品列表配图展示', '请上传2M以内的jpg、jpeg、png图片,建议图片尺寸256*216'],
maxPhotoNum: 1
}, {
name: 'goodsImgList',
label: '产品主图',
type: 'photo',
tips: ['注:用于在小程序商品详情页的顶部展示', '请上传2M以内的jpg、jpeg、png图片,建议图片尺寸256*216'],
maxPhotoNum: 10
}, {
name: 'goodsDescList',
label: '详情描述',
type: 'descList',
maxlength: 256
}]
}],
baseData: {
productType: []
......
......@@ -53,19 +53,46 @@
@handleRelateStoreClose="handleRelateStoreClose"
>
<el-row slot>
<el-col
class="service-search"
:span="6"
<el-form
:model="storeSearchForm"
:rules="rules"
ref="relate"
>
<el-select v-model="storeSearchForm.channelType">
<el-option
v-for="item in baseData.channelType"
:key="item.value"
:label="item.name"
:value="item.value"
></el-option>
</el-select>
</el-col>
<el-col>
<el-form-item
id="yqMerchantId"
label="园区店:"
prop="yqMerchantId"
v-show="userInfo.beSuper"
>
<el-select
v-model="storeSearchForm.yqMerchantId"
placeholder="请选择"
class="el_select itd"
>
<el-option
v-for="x in parkServiceList"
:key="x.merchantId"
:value="x.merchantId"
:label="x.merchantName"
></el-option>
</el-select>
</el-form-item>
</el-col>
<el-col
class="service-search"
:span="6"
>
<el-select v-model="storeSearchForm.channelType">
<el-option
v-for="item in baseData.channelType"
:key="item.value"
:label="item.name"
:value="item.value"
></el-option>
</el-select>
</el-col>
</el-form>
<el-col :span="8">
<el-input
v-model="storeSearchForm.merchantIdName"
......@@ -84,6 +111,7 @@
<script>
import { Util } from '@/common/util'
import { getParkStore } from '@api/editCustomer'
import { getList, deleteMerchant, serviceGetMerchantList, addServiceMerchant } from '@api/serviceStore'
import { mapActions } from 'vuex'
import { BaseData, userType, ghUserType } from '@/common/constants.js'
......@@ -91,9 +119,13 @@ export default {
name: 'serviceStore',
data() {
return {
userInfo: this.$store.state.d2admin.user.info,
searchForm: {
merchantName: ''
},
rules: {
yqMerchantId: [{ required: true, message: '请选择园区店', trigger: 'change' }]
},
showFormData: [{
label: '商户名称',
name: 'merchantName',
......@@ -177,7 +209,14 @@ export default {
this.getBaseData()
},
mounted() { },
mounted() {
// if (this.userInfo.beSuper) {
!this.userInfo.beSuper && (this.storeSearchForm.yqMerchantId = this.userInfo.detail.merchantId)
getParkStore({}).then(res => {
this.parkServiceList = res
})
// }
},
methods: {
...mapActions('d2admin/base', ['get']),
......@@ -187,6 +226,7 @@ export default {
resolve()
})
},
async getBaseData() {
this.baseData.channelType = await this.get(BaseData.channelType)
},
......@@ -208,24 +248,34 @@ export default {
},
handleRelateStoreConfirm(selectedData) {
// console.log(selectedData)
if (!selectedData.length) {
// this.notice.warningTips('请选择关联门店')
this.$message({
message: '请选择关联门店',
type: 'warning',
showClose: true
})
return true
}
if (selectedData.length > this.maxLength) {
this.$message.error(`一次只能选择${this.maxLength}个门店`)
return true
}
addServiceMerchant({ list: selectedData }).then(res => {
this.relateStoreVisible = false
this.$refs.serviceStoreTable.refreshTable()
this.notice.okTips()
this.relateCloseReset()
this.$refs.relate.validate(valid => {
console.log(valid)
if (valid) {
if (!selectedData.length) {
// this.notice.warningTips('请选择关联门店')
this.$message({
message: '请选择关联门店',
type: 'warning',
showClose: true
})
return true
}
if (selectedData.length > this.maxLength) {
this.$message.error(`一次只能选择${this.maxLength}个门店`)
return true
}
var merchantName = this.parkServiceList.find(item => item.merchantId === this.storeSearchForm.yqMerchantId).merchantName
selectedData.forEach(item => {
item.yqMerchantId = this.storeSearchForm.yqMerchantId
item.yqMerchantName = merchantName
})
addServiceMerchant({ list: selectedData }).then(res => {
this.relateStoreVisible = false
this.$refs.serviceStoreTable.refreshTable()
this.notice.okTips()
this.relateCloseReset()
})
}
})
},
handleRelateStoreClose() {
......@@ -235,6 +285,10 @@ export default {
handleSearchStore() {
this.$refs.relateStore.getSelectingList()
},
// handleMerchantChange(value) {
// this.storeSearchForm.yqMerchantId = value
// this.$refs.relateStore.getSelectingList()
// },
handleDelete(row) {
// console.log(row)
this.$confirm('是否要进行删除操作?', '提示', {
......
Markdown is supported
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!