wangdong 8 months ago
commit f32d01281c
  1. 21692
      package-lock.json
  2. 59
      src/api/goods/index.js
  3. 2
      src/common/model/goods/Index.js
  4. 4
      src/config/router.config.js
  5. 3
      src/views/goods/Create.vue
  6. 1159
      src/views/goods/Index.vue
  7. 281
      src/views/goods/distributionPrice/Index.vue
  8. 622
      src/views/goods/filter/Index.vue
  9. 281
      src/views/goods/memberPrice/Index.vue
  10. 3
      src/views/goods/modules/Update.vue
  11. 4
      src/views/recovery/Index.vue
  12. 8
      src/views/recovery/modules/Edit.vue
  13. 4
      src/views/server/Index.vue
  14. 360
      src/views/server/modules/Edit.vue
  15. 10
      src/views/store/Setting.vue

21692
package-lock.json generated

File diff suppressed because it is too large Load Diff

@ -15,9 +15,64 @@ const api = {
setStorePrice: 'store/setStorePrice', setStorePrice: 'store/setStorePrice',
getStorePriceInfo: 'store/getStorePriceInfo', getStorePriceInfo: 'store/getStorePriceInfo',
pool: '/goods/pool', pool: '/goods/pool',
collector:'/goods/collector' collector:'/goods/collector',
category: '/goods/category',
}
/**
* 归类
* @param {*} data
*/
export function category (data) {
return axios({
url: api.category,
method: 'post',
data: data
})
}
/**
* 大牌
* @param {*} data
*/
export function setBrand (data) {
return axios({
url: '/goods/setBrand',
method: 'post',
data: data
})
}
/**
* 新品
* @param {*} data
*/
export function setNew (data) {
return axios({
url: '/goods/setNew',
method: 'post',
data: data
})
}
/**
* 是否店内
* @param {*} data
*/
export function setInstore (data) {
return axios({
url: '/goods/setInstore',
method: 'post',
data: data
})
}
/**
* 是否店内
* @param {*} data
*/
export function setRank (data) {
return axios({
url: '/goods/setRank',
method: 'post',
data: data
})
} }
export function getCollector (params) { export function getCollector (params) {
return axios({ return axios({
url: api.collector, url: api.collector,

@ -95,7 +95,7 @@ export default {
'status', 'spec_type', 'deduct_stock_type', 'is_restrict', 'content', 'status', 'spec_type', 'deduct_stock_type', 'is_restrict', 'content',
'selling_point', 'serviceIds', 'sales_initial', 'is_points_gift', 'selling_point', 'serviceIds', 'sales_initial', 'is_points_gift',
'is_points_discount', 'is_enable_grade', 'is_alone_grade', 'is_ind_dealer', 'is_points_discount', 'is_enable_grade', 'is_alone_grade', 'is_ind_dealer',
'dealer_money_type', 'first_money', 'second_money', 'third_money', 'cmmdty_model','is_check','goods_source','delivery_time','is_in_store' 'dealer_money_type', 'first_money', 'second_money', 'third_money', 'cmmdty_model','is_check','goods_source','delivery_time','is_in_store','remark'
]) ])
console.log(goodsFormData, 100) console.log(goodsFormData, 100)
return { return {

@ -361,8 +361,8 @@ export const asyncRouterMap = [
path: '/goods/filter/index', path: '/goods/filter/index',
component: () => import(/* webpackChunkName: "goods" */ '@/views/goods/filter/Index'), component: () => import(/* webpackChunkName: "goods" */ '@/views/goods/filter/Index'),
meta: { meta: {
title: '数据过滤', title: '数据渠道',
pageTitle: '数据过滤', pageTitle: '数据渠道',
keepAlive: false, keepAlive: false,
permission: ['/goods/filter/index'], permission: ['/goods/filter/index'],
}, },

@ -244,6 +244,9 @@
<a href="javascript:;" @click="onReloadServiceList">刷新</a> <a href="javascript:;" @click="onReloadServiceList">刷新</a>
</div> </div>
</a-form-item> </a-form-item>
<a-form-item label="下单须知" :labelCol="labelCol" :wrapperCol="wrapperCol">
<a-input placeholder="请输入下单须知" v-decorator="['remark']" />
</a-form-item>
<a-form-item label="初始销量" :labelCol="labelCol" :wrapperCol="wrapperCol" extra="用户端展示的销量 = 初始销量 + 实际销量"> <a-form-item label="初始销量" :labelCol="labelCol" :wrapperCol="wrapperCol" extra="用户端展示的销量 = 初始销量 + 实际销量">
<a-input-number v-decorator="['sales_initial', { initialValue: 0 }]" /> <a-input-number v-decorator="['sales_initial', { initialValue: 0 }]" />
</a-form-item> </a-form-item>

File diff suppressed because it is too large Load Diff

@ -3,61 +3,61 @@
<div class="card-title">{{ $route.meta.title }}</div> <div class="card-title">{{ $route.meta.title }}</div>
<a-spin :spinning="isLoading"> <a-spin :spinning="isLoading">
<a-form :form="form" @submit="handleSubmit"> <a-form :form="form" @submit="handleSubmit">
<a-form-item v-bind="formItemLayoutWithOutLabel"> <div style="width:1000px">
<div class="msg"> <a-form-item v-bind="formItemLayoutWithOutLabel">
<span>价格区间()</span> <div class="msg">
<span>分销加价率%</span> <span>价格区间()</span>
<span>利润空间()</span> <span>分销加价率%</span>
</div> <span>利润空间()</span>
</a-form-item>
<a-modal v-model:visible="setPriceVisible" width="450px" title="利润值" @ok="handleBatchPrice(index_1, index_2, mixPrice, maxPrice)">
<div class="fen" style="margin-top: -10px">
<input placeholder="最大利润值" style="margin-right: 25px" v-model="mixPrice" class="input" type="text" />
<input placeholder="最小利润值" v-model="maxPrice" class="input" type="text" />
</div>
<div class="setRule">
<div class="ruleTitle">设置规则</div>
<div class="ruleText">
A.当加价率生效后会员价高于市场价会员价统一自动按以下标准执行 市场价-成本价x_____% +成本价=会员价
_____%为此时的加价率 利润低于_____元的商品不展示在商城里
</div> </div>
</div> <div class="ruleText"><span class="ruleTitle">分销说明</span>A.当加价率生效后分销价高于市场价分销价统一自动按以下标准执行
</a-modal> 市场价-成本价x_____% +成本价=分销价 _____%为此时的加价率
<a-form-item v-bind="formItemLayoutWithOutLabel"> B.当加价率生效后分销价高于会员价分销价进一步统一自动按以下标准执行会员价-成本价x_____% +成本价=分销价 _____%为此时的加价率</div>
<a-button type="dashed" style="width: calc(43.5% + 8px); margin-right: 50px" @click="handleAddCondition"> </a-form-item>
<a-icon type="plus-circle" /> 新增分类模版 </a-button><a-button type="dashed" style="width: calc(44.5% + 8px)" @click="handleRemoveCondition"> <a-form-item v-bind="formItemLayoutWithOutLabel">
<a-icon type="minus-circle-o" /> 删除分类模版 <div style="width: 100%;">
</a-button> <a-button type="dashed" style="width: 100%" @click="handleAddCondition">
</a-form-item> <a-icon type="plus-circle" /> 新增分类模版 </a-button>
<a-form-item v-for="(k, index) in form.getFieldValue('list')" :key="k.id" :label="index === 0 ? '分销模版' : ''" :labelCol="labelCol" v-bind="index === 0 ? { wrapperCol } : formItemLayoutWithOutLabel" required> </div>
<a-tree-select style="width: 100%; margin-right: 8px; margin-top: 3px" placeholder="请选择商品分类" :dropdownStyle="{ maxHeight: '500px', overflow: 'auto' }" :treeData="formData.categoryList" treeCheckable allowClear treeCheckStrictly </a-form-item>
@select="onSelect(index, $event)" @focus="handleSelectChange(index)" v-decorator="[`category${k.id}`]"></a-tree-select> <a-form-item v-for="(k, index) in form.getFieldValue('list')" :key="k.id" :label="index === 0 ? '分销模版' : ''" :labelCol="labelCol" v-bind="index === 0 ? { wrapperCol } : formItemLayoutWithOutLabel" required>
<div style="width: 100%"> <div style="width: 100%;display: flex;align-items: center;justify-content: space-between">
<div class="fan" v-for="(m, index2) in k.price_list" :key="m.id"> <div style="width: 700px;">
<a-form-item style="margin-right: 15px; width: 33%; cursor: pointer"> <a-tree-select style="width: 100%; margin-right: 8px; margin-top: 3px" placeholder="请选择商品分类" :dropdownStyle="{ maxHeight: '500px', overflow: 'auto' }" :treeData="formData.categoryList" treeCheckable allowClear
<div class="inMax" @click="setPrice(index, index2,m.min,m.max)"> treeCheckStrictly @select="onSelect(index, $event)" @focus="handleSelectChange(index)" v-decorator="[`category${k.id}`]"></a-tree-select>
<span v-if="m.min && m.max">{{ m.min }} ~ {{ m.max }}</span><span style="color: #d9d9d9" v-else>利润值</span> <div style="width: 100%">
<div class="yuan"></div> <div class="fan" v-for="(m, index2) in k.price_list" :key="m.id">
<a-form-item style="margin-right: 15px; width: 47%; cursor: pointer">
<div class="inMax">
<input placeholder="最小利润值" @blur="onPrice($event, index, index2)" v-model="m.min" class="input" type="text" />
~<input placeholder="最大利润值" @blur="onPrice($event, index, index2)" v-model="m.max" class="input" type="text" />
<div class="yuan"></div>
</div>
</a-form-item>
<a-form-item style="margin-right: 15px; width: 23%">
<a-input placeholder="利润率" @input="onRate($event, index, index2)" suffix="%" v-model="m.add_price_rate" style="width: 100%; margin-right: 8px; text-align: center" />
</a-form-item>
<div style="width: 30%; text-align: center">
<span>{{ m.startProfit }}</span> ~ <span>{{ m.endProfit }}</span>
</div>
<a-button type="dashed" style="width: 120px" @click="handleRemovePriceRate(index,index2)">
<a-icon type="minus-circle-o" /> 删除价格区间</a-button>
</div>
<div style="width: 100%">
<a-button type="dashed" style="width: 100%; margin-right: 50px" @click="handleAddPriceRate(index)">
<a-icon type="plus-circle" /> 新增价格区间 </a-button>
</div>
</div> </div>
</a-form-item>
<a-form-item style="margin-right: 15px; width: 33%">
<a-input placeholder="利润率" @input="onRate($event, index, index2)" suffix="%" v-model="m.add_price_rate" style="width: 100%; margin-right: 8px; text-align: center" />
</a-form-item>
<div style="width: 33%; text-align: center">
<span>{{ m.startProfit }}</span> ~ <span>{{ m.endProfit }}</span>
</div> </div>
</div> <a-button type="dashed" style="width: 120px;margin-left: 20px;" @click="handleRemoveCondition(index)">
<div style="width: 100%"> <a-icon type="minus-circle-o" /> 删除分类模版
<a-button type="dashed" style="width: calc(40% + 8px); margin-right: 50px" @click="handleAddPriceRate(index)">
<a-icon type="plus-circle" /> 新增价格区间 </a-button><a-button type="dashed" style="width: calc(40% + 8px)" @click="handleRemovePriceRate(index)">
<a-icon type="minus-circle-o" /> 删除价格区间
</a-button> </a-button>
</div> </div>
</div> </a-form-item>
</a-form-item> <a-form-item :wrapperCol="{ span: wrapperCol.span, offset: labelCol.span }">
<a-form-item :wrapperCol="{ span: wrapperCol.span, offset: labelCol.span }"> <a-button type="primary" html-type="submit">提交</a-button>
<a-button type="primary" html-type="submit">提交</a-button> </a-form-item>
</a-form-item> </div>
</a-form> </a-form>
</a-spin> </a-spin>
</a-card> </a-card>
@ -87,11 +87,6 @@ export default {
formItemLayoutWithOutLabel: { formItemLayoutWithOutLabel: {
wrapperCol: { span: 10, offset: 3 }, wrapperCol: { span: 10, offset: 3 },
}, },
setPriceVisible: false,
index_1: '',
index_2: '',
mixPrice: '',
maxPrice: '',
} }
}, },
// //
@ -107,6 +102,50 @@ export default {
this.getDetail() this.getDetail()
}, },
methods: { methods: {
onPrice(e, index_1, index_2, type) {
const { form } = this
const list = form.getFieldValue('list')
if (0 >= list[index_1].price_list[index_2].min) {
list[index_1].price_list[index_2].min = null
this.$message.warning('最小利润值必须大于0', 1.5)
list[index_1].price_list[index_2].startProfit = 0
list[index_1].price_list[index_2].endProfit = 0
return
}
if (0 >= list[index_1].price_list[index_2].max) {
list[index_1].price_list[index_2].max = null
this.$message.warning('最大利润值必须大于0', 1.5)
list[index_1].price_list[index_2].startProfit = 0
list[index_1].price_list[index_2].endProfit = 0
return
}
if (list[index_1].price_list[index_2].min > list[index_1].price_list[index_2].max) {
list[index_1].price_list[index_2].max = null
this.$message.warning('最大利润值不能低于最小利润值', 1.5)
list[index_1].price_list[index_2].startProfit = 0
list[index_1].price_list[index_2].endProfit = 0
return
}
if (!list[index_1].price_list[index_2].min || !list[index_1].price_list[index_2].max || !list[index_1].price_list[index_2].add_price_rate) {
list[index_1].price_list[index_2].startProfit = 0
list[index_1].price_list[index_2].endProfit = 0
return
}
if (list[index_1].price_list[index_2].min && list[index_1].price_list[index_2].max) {
let rate = Number(list[index_1].price_list[index_2].add_price_rate)
list[index_1].price_list[index_2].startProfit = Number(
(list[index_1].price_list[index_2].min * (rate / 100)).toFixed(2)
)
list[index_1].price_list[index_2].endProfit = Number(
(list[index_1].price_list[index_2].max * (rate / 100)).toFixed(2)
)
list[index_1].price_list[index_2].add_price_rate = rate
form.setFieldsValue({
list: list,
})
this.$forceUpdate()
}
},
// //
onRate(e, index_1, index_2) { onRate(e, index_1, index_2) {
const { form } = this const { form } = this
@ -136,49 +175,6 @@ export default {
}) })
this.$forceUpdate() this.$forceUpdate()
}, },
handleBatchPrice(index1, index2, min, max) {
const { form } = this
if (!this.mixPrice) {
this.$message.warning('请输入最低价格', 1.5)
} else if (!this.maxPrice) {
this.$message.warning('请输入最高价格', 1.5)
} else if (0 >= this.mixPrice) {
this.mixPrice = null
this.$message.warning('最低价格必须大于0', 1.5)
} else if (0 >= this.maxPrice) {
this.maxPrice = null
this.$message.warning('最高价格必须大于0', 1.5)
} else if (this.mixPrice > this.maxPrice) {
this.maxPrice = null
this.$message.warning('最高价格不能低于最低价格', 1.5)
} else {
const condition = form.getFieldValue('list')
condition.forEach(function (item, k) {
if (k == index1) {
item.price_list.forEach(function (item1, j) {
if (j == index2) {
item1.min = min
item1.max = max
}
})
}
})
form.setFieldsValue({
list: condition,
})
this.$forceUpdate()
this.setPriceVisible = false;
this.mixPrice = '';
this.maxPrice = ''
}
},
setPrice(index1, index2, min, max) {
this.index_1 = index1
this.index_2 = index2
this.mixPrice = min;
this.maxPrice = max
this.setPriceVisible = true
},
onSelect(index, event) { onSelect(index, event) {
const { form, $nextTick } = this const { form, $nextTick } = this
const key = form.getFieldValue('list') const key = form.getFieldValue('list')
@ -198,7 +194,6 @@ export default {
let that = this let that = this
for (let i = 0; i < nodes.length; i++) { for (let i = 0; i < nodes.length; i++) {
nodes[i].disabled = false nodes[i].disabled = false
console.log(nodes[i].value, ids)
if (ids.includes(nodes[i].value) == true) { if (ids.includes(nodes[i].value) == true) {
nodes[i].disabled = true nodes[i].disabled = true
} }
@ -222,7 +217,6 @@ export default {
} }
$nextTick(() => { $nextTick(() => {
this.formData.categoryList = this.deleteNodeById(this.formData.categoryList, category) this.formData.categoryList = this.deleteNodeById(this.formData.categoryList, category)
console.log(this.deleteNodeById(this.formData.categoryList, category))
this.formData = this.formData this.formData = this.formData
this.$forceUpdate() this.$forceUpdate()
}) })
@ -231,11 +225,7 @@ export default {
handleRemoveCondition(index) { handleRemoveCondition(index) {
const { form } = this const { form } = this
const keys = form.getFieldValue('list') const keys = form.getFieldValue('list')
if (keys.length === 0) { keys.splice(index, 1) // 1
this.$message.warning('暂无可删除的分类模版', 1.5)
return
}
keys.pop()
form.setFieldsValue({ form.setFieldsValue({
list: keys, list: keys,
}) })
@ -252,22 +242,12 @@ export default {
}) })
}, },
// //
handleRemovePriceRate(index) { handleRemovePriceRate(index1, index2) {
const { form } = this const { form } = this
const priceList = form.getFieldValue('list')[index].price_list const priceList = form.getFieldValue('list')
if (priceList.length === 0) { priceList[index1].price_list.splice(index2, 1) // 1
this.$message.warning('暂无可删除的价格区间', 1.5)
return
}
priceList.pop()
const conditionList = form.getFieldValue('list')
conditionList.forEach(function (item, mm) {
if (mm == index) {
item.price_list = priceList
}
})
form.setFieldsValue({ form.setFieldsValue({
list: conditionList, list: priceList,
}) })
this.$forceUpdate() this.$forceUpdate()
}, },
@ -312,6 +292,12 @@ export default {
return { value: id } return { value: id }
}) })
}, },
convertToString(value) {
if (typeof value == 'number') {
return String(value);
}
return value;
},
// //
setFieldsValue() { setFieldsValue() {
const { record, form, $nextTick } = this const { record, form, $nextTick } = this
@ -322,10 +308,10 @@ export default {
return x return x
}) })
record.list.forEach((x, i) => { record.list.forEach((x, i) => {
record[`category${x.id}`] = this.formatCategoryIds(x.category.split(',')) record[`category${x.id}`] = this.formatCategoryIds((this.convertToString(x.category)).split(','))
categoryAry.push(`category${x.id}`) categoryAry.push(`category${x.id}`)
this.form.getFieldDecorator(`category${x.id}`, { initialValue: '', preserve: true }) this.form.getFieldDecorator(`category${x.id}`, { initialValue: '', preserve: true })
x.category = x.category.split(',') x.category = (this.convertToString(x.category)).split(',')
x.price_list.forEach((m, j) => { x.price_list.forEach((m, j) => {
m.startProfit = Number((m.min * (Number(m.add_price_rate) / 100)).toFixed(2)) m.startProfit = Number((m.min * (Number(m.add_price_rate) / 100)).toFixed(2))
m.endProfit = Number((m.max * (Number(m.add_price_rate) / 100)).toFixed(2)) m.endProfit = Number((m.max * (Number(m.add_price_rate) / 100)).toFixed(2))
@ -466,6 +452,9 @@ export default {
/deep/.ant-input-prefix { /deep/.ant-input-prefix {
font-weight: bold; font-weight: bold;
} }
/deep/.ant-col-10 {
width: 80%;
}
.fan { .fan {
display: flex; display: flex;
align-items: top; align-items: top;
@ -501,20 +490,20 @@ export default {
} }
.setRule { .setRule {
margin-top: 20px; margin-top: 20px;
.ruleTitle { }
font-size: 14px; .ruleTitle {
font-family: PingFang SC, PingFang SC; font-size: 14px;
font-weight: 500; font-family: PingFang SC, PingFang SC;
color: #303030; font-weight: 500;
} color: #303030;
.ruleText { }
margin-top: 8px; .ruleText {
font-size: 14px; margin-top: 8px;
font-family: PingFang SC, PingFang SC; font-size: 14px;
font-weight: 400; font-family: PingFang SC, PingFang SC;
color: #8b8b8b; font-weight: 400;
line-height: 32px; color: #8b8b8b;
} line-height: 32px;
} }
.inMax { .inMax {
width: 100%; width: 100%;
@ -525,21 +514,35 @@ export default {
list-style: none; list-style: none;
display: inline-block; display: inline-block;
width: 100%; width: 100%;
height: 30px; height: 32px;
padding: 4px 11px; padding: 0 26px 0 0;
color: rgba(0, 0, 0, 0.65); color: rgba(0, 0, 0, 0.65);
font-size: 13px; font-size: 13px;
line-height: 1.8; line-height: 32px;
background-color: #fff; background-color: #fff;
background-image: none; background-image: none;
border: 1px solid #d9d9d9; border: 1px solid #d9d9d9;
border-radius: 2px; border-radius: 2px;
-webkit-transition: all 0.3s; -webkit-transition: all 0.3s;
transition: all 0.3s; transition: all 0.3s;
input {
border: none;
width: 45%;
margin: 0;
height: 100%;
text-align: center;
}
input:focus {
outline: none;
border: none;
}
input::-webkit-input-placeholder {
color: #bfbfbf;
}
.yuan { .yuan {
position: absolute; position: absolute;
right: 10px; right: 10px;
top: 2px; top: 0px;
} }
} }
</style> </style>

@ -1,88 +1,47 @@
<template> <template>
<a-card :bordered="false"> <a-card :bordered="false">
<div class="card-title">{{ $route.meta.title }}</div> <div class="card-title">{{ $route.meta.title }}</div>
<a-spin :spinning="isLoading"> <a-spin :spinning="isLoading">
<a-form :form="form" @submit="handleSubmit"> <a-form :form="form" @submit="handleSubmit">
<a-form-item label="数据渠道" :labelCol="labelCol" :wrapperCol="wrapperCol"> <a-form-item label="选择渠道" :labelCol="labelCol" :wrapperCol="wrapperCol">
<a-select <a-select v-decorator="[`open_channel`]" allowClear mode="multiple" @change="getChannel" placeholder="请选择渠道">
v-decorator="[`open_channel`]" <a-select-option :value="item.id" v-for="item in checkList" :key="item.id">
allowClear {{ item.name }}
mode="multiple" </a-select-option>
@change="getChannel" </a-select>
placeholder="请选择渠道" <div style="color: rgba(0, 0, 0, 0.45); font-size: 12.5px; line-height: 20px">
> 渠道未选择时则代表所有渠道
<a-select-option :value="item.id" v-for="item in checkList" :key="item.id"> </div>
{{ item.name }} </a-form-item>
</a-select-option> <!-- {{form.getFieldValue('fliter_condition')}} -->
</a-select> <a-form-item v-for="(k, index) in form.getFieldValue('fliter_condition')" :key="k.id" :label="index === 0 ? '筛选条件' : ''" :labelCol="labelCol" v-bind="index === 0 ? { wrapperCol } : formItemLayoutWithOutLabel" required>
<div style="color: rgba(0, 0, 0, 0.45); font-size: 12.5px; line-height: 20px"> <div class="fan">
数据渠道未选择时则代表所有渠道 <a-tree-select :key="k.id" style="width: 100%; margin-right: 8px; margin-top: 3px" placeholder="请选择商品分类" :dropdownStyle="{ maxHeight: '500px', overflow: 'auto' }" :treeData="formData.categoryList" treeCheckable checkStrictly
</div> allowClear showCheckedStrategy="SHOW_ALL" @change="onChange(k.id, $event)" @select="onSelect(index, $event)" @focus="handleSelectChange(index)"
</a-form-item> v-decorator="[`category${k.id}`, { rules: [{ required: true, message: '请至少选择1个商品分类' }] }]"></a-tree-select>
<!-- {{form.getFieldValue('fliter_condition')}} --> <a-form-item>
<a-form-item <a-input placeholder="利润值" prefix=">" suffix="元" v-decorator="[`profit${k.id}`, { rules: [{ required: true, message: '请输入利润值' }] }]" style="width: 94%; margin-right: 8px" />
v-for="(k, index) in form.getFieldValue('fliter_condition')" </a-form-item>
:key="k.id" <a-form-item>
:label="index === 0 ? '过滤数据' : ''" <a-input placeholder="利润率" prefix=">" suffix="%" v-decorator="[`profit_rate${k.id}`, { rules: [{ required: true, message: '请输入利润率' }] }]" style="width: 94%; margin-right: 8px" />
:labelCol="labelCol" </a-form-item>
v-bind="index === 0 ? { wrapperCol } : formItemLayoutWithOutLabel" <a-form-item>
required <a-icon style="margin-top: 30rpx" v-if="form.getFieldValue('fliter_condition').length > 0" class="dynamic-delete-button" type="minus-circle-o" :disabled="form.getFieldValue('fliter_condition').length === 1"
> @click="() => handleRemoveCondition(index)" />
<div class="fan"> </a-form-item>
<a-tree-select </div>
:key="k.id" </a-form-item>
style="width: 100%; margin-right: 8px; margin-top: 3px" <a-form-item v-bind="formItemLayoutWithOutLabel">
placeholder="请选择商品分类" <a-button type="dashed" style="width: calc(50% + 8px)" @click="handleAddCondition">
:dropdownStyle="{ maxHeight: '500px', overflow: 'auto' }" <a-icon type="plus" /> 新增筛选条件
:treeData="formData.categoryList" </a-button>
treeCheckable </a-form-item>
allowClear <a-form-item :wrapperCol="{ span: wrapperCol.span, offset: labelCol.span }">
treeCheckStrictly <a-button type="primary" html-type="submit">提交</a-button>
@select="onSelect(index, $event)" </a-form-item>
@focus="handleSelectChange(index)" </a-form>
v-decorator="[`category${k.id}`, { rules: [{ required: true, message: '请至少选择1个商品分类' }] }]" </a-spin>
></a-tree-select> </a-card>
<a-form-item>
<a-input
placeholder="利润值"
prefix=">"
suffix="元"
v-decorator="[`profit${k.id}`, { rules: [{ required: true, message: '请输入利润值' }] }]"
style="width: 94%; margin-right: 8px"
/>
</a-form-item>
<a-form-item>
<a-input
placeholder="利润率"
prefix=">"
suffix="%"
v-decorator="[`profit_rate${k.id}`, { rules: [{ required: true, message: '请输入利润率' }] }]"
style="width: 94%; margin-right: 8px"
/>
</a-form-item>
<a-form-item>
<a-icon
style="margin-top: 30rpx"
v-if="form.getFieldValue('fliter_condition').length > 0"
class="dynamic-delete-button"
type="minus-circle-o"
:disabled="form.getFieldValue('fliter_condition').length === 1"
@click="() => handleRemoveCondition(index)"
/>
</a-form-item>
</div>
</a-form-item>
<a-form-item v-bind="formItemLayoutWithOutLabel">
<a-button type="dashed" style="width: calc(50% + 8px)" @click="handleAddCondition">
<a-icon type="plus" /> 新增过滤数据
</a-button>
</a-form-item>
<a-form-item :wrapperCol="{ span: wrapperCol.span, offset: labelCol.span }">
<a-button type="primary" html-type="submit">提交</a-button>
</a-form-item>
</a-form>
</a-spin>
</a-card>
</template> </template>
<script> <script>
@ -92,258 +51,271 @@ import * as GoodsApi from '@/api/goods'
import GoodsModel from '@/common/model/goods/Index' import GoodsModel from '@/common/model/goods/Index'
import { isEmpty } from '@/utils/util' import { isEmpty } from '@/utils/util'
export default { export default {
data() { data() {
return { return {
// //
labelCol: { span: 3 }, labelCol: { span: 3 },
// //
wrapperCol: { span: 10 }, wrapperCol: { span: 10 },
// loading // loading
isLoading: false, isLoading: false,
// //
form: this.$form.createForm(this), form: this.$form.createForm(this),
// //
formData: GoodsModel.formData, formData: GoodsModel.formData,
record: {}, record: {},
checkList: [], checkList: [],
formItemLayoutWithOutLabel: { formItemLayoutWithOutLabel: {
wrapperCol: { span: 10, offset: 3 }, wrapperCol: { span: 10, offset: 3 },
}, },
} }
}, },
// //
created() { created() {
this.isLoading = true this.isLoading = true
// form // form
GoodsModel.getFromData().then(() => { GoodsModel.getFromData().then(() => {
this.isLoading = false this.isLoading = false
}) })
this.form.getFieldDecorator('fliter_condition', { initialValue: [], preserve: true }) this.form.getFieldDecorator('fliter_condition', { initialValue: [], preserve: true })
this.getDataList() // this.getDataList() //
// //
this.getDetail() this.getDetail()
}, },
methods: { methods: {
onSelect(index, event) { onChange(id, event) {
const { form, $nextTick } = this console.log(id, event)
const key = form.getFieldValue('fliter_condition') },
for (let i = 0; i < key.length; i++) { onSelect(index, event) {
if (i == index) { const { form, $nextTick } = this
key[i].category.push(event.value) const key = form.getFieldValue('fliter_condition')
} for (let i = 0; i < key.length; i++) {
} if (i == index) {
$nextTick(() => { key[i].category.push(event.value)
form.setFieldsValue({ }
fliter_condition: key, }
}) $nextTick(() => {
this.$forceUpdate() form.setFieldsValue({
}) fliter_condition: key,
}, })
deleteNodeById(nodes, ids) { this.$forceUpdate()
let that = this })
for (let i = 0; i < nodes.length; i++) { },
nodes[i].disabled = false deleteNodeById(nodes, ids) {
if (ids.includes(nodes[i].value) == true) { let that = this
nodes[i].disabled = true for (let i = 0; i < nodes.length; i++) {
} nodes[i].disabled = false
if (nodes[i].children && nodes[i].children.length > 0) { if (ids.includes(nodes[i].value) == true) {
that.deleteNodeById(nodes[i].children, ids) // nodes[i].disabled = true
} }
} if (nodes[i].children && nodes[i].children.length > 0) {
return nodes that.deleteNodeById(nodes[i].children, ids) //
}, }
handleSelectChange(index, event) { }
const { form, $nextTick } = this return nodes
const key = form.getFieldValue('fliter_condition') },
let category = [] handleSelectChange(index, event) {
for (let i = 0; i < key.length; i++) { const { form, $nextTick } = this
if (i !== index) { const key = form.getFieldValue('fliter_condition')
key[i].category.forEach((item) => { let category = []
//forEach for (let i = 0; i < key.length; i++) {
category.push(item) if (i !== index) {
}) key[i].category.forEach((item) => {
} //forEach
} category.push(item)
$nextTick(() => { })
this.formData.categoryList = this.deleteNodeById(this.formData.categoryList, category) }
this.formData = this.formData }
this.$forceUpdate() $nextTick(() => {
}) this.formData.categoryList = this.deleteNodeById(this.formData.categoryList, category)
}, this.formData = this.formData
// this.$forceUpdate()
handleRemoveCondition(index) { })
const { form, $nextTick } = this },
const keys = form.getFieldValue('fliter_condition') //
if (keys.length === 0) { handleRemoveCondition(index) {
return const { form, $nextTick } = this
} const keys = form.getFieldValue('fliter_condition')
keys.splice(index, 1) // 1 if (keys.length === 0) {
$nextTick(() => { return
form.setFieldsValue({ }
fliter_condition: keys keys.splice(index, 1) // 1
}) $nextTick(() => {
this.$forceUpdate() form.setFieldsValue({
}) fliter_condition: keys
}, })
handleAddCondition() { this.$forceUpdate()
const { form } = this })
const key = form.getFieldValue('fliter_condition') },
const keys = key ? key : [] handleAddCondition() {
const nextKeys = keys.concat([{ category: [], profit: '', profit_rate: '', id: this.generateRandomString(8) }]) const { form } = this
form.setFieldsValue({ const key = form.getFieldValue('fliter_condition')
fliter_condition: nextKeys, const keys = key ? key : []
}) const nextKeys = keys.concat([{ category: [], profit: '', profit_rate: '', id: this.generateRandomString(8) }])
}, form.setFieldsValue({
generateRandomString(length) { fliter_condition: nextKeys,
let result = '' })
const characters = 'ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789' },
const charactersLength = characters.length generateRandomString(length) {
for (let i = 0; i < length; i++) { let result = ''
result += characters.charAt(Math.floor(Math.random() * charactersLength)) const characters = 'ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789'
} const charactersLength = characters.length
return result for (let i = 0; i < length; i++) {
}, result += characters.charAt(Math.floor(Math.random() * charactersLength))
// }
getDataList() { return result
return GoodsApi.getDataList().then((result) => { },
const obj = result.data //
Object.keys(obj).forEach((item) => { getDataList() {
this.checkList.push({ id: item, name: obj[item] }) return GoodsApi.getDataList().then((result) => {
}) const obj = result.data
}) Object.keys(obj).forEach((item) => {
}, this.checkList.push({ id: item, name: obj[item] })
formatCategoryIds(categoryIds) { })
return categoryIds.map((id) => { })
return { value: id } },
}) formatCategoryIds(categoryIds) {
}, return categoryIds.map((id) => {
// return { value: id }
setFieldsValue() { })
const { record, form, $nextTick } = this },
const profitAry = [] //
const profitRateAry = [] setFieldsValue() {
const categoryAry = [] const { record, form, $nextTick } = this
if (record.fliter_condition) { const profitAry = []
record.fliter_condition = JSON.parse(record.fliter_condition) const profitRateAry = []
record.fliter_condition = record.fliter_condition.map((x) => { const categoryAry = []
x.id = this.generateRandomString(8) if (record.fliter_condition) {
return x record.fliter_condition = JSON.parse(record.fliter_condition)
}) record.fliter_condition = record.fliter_condition.map((x) => {
record.fliter_condition.forEach((x, i) => { x.id = this.generateRandomString(8)
record[`profit${x.id}`] = x.profit return x
record[`profit_rate${x.id}`] = x.profit_rate })
record[`category${x.id}`] = this.formatCategoryIds(x.category) record.fliter_condition.forEach((x, i) => {
categoryAry.push(`category${x.id}`) record[`profit${x.id}`] = x.profit
profitAry.push(`profit${x.id}`) record[`profit_rate${x.id}`] = x.profit_rate
profitRateAry.push(`profit_rate${x.id}`) record[`category${x.id}`] = x.category
this.form.getFieldDecorator(`category${x.id}`, { initialValue: '', preserve: true }) categoryAry.push(`category${x.id}`)
this.form.getFieldDecorator(`profit${x.id}`, { initialValue: '', preserve: true }) profitAry.push(`profit${x.id}`)
this.form.getFieldDecorator(`profit_rate${x.id}`, { initialValue: '', preserve: true }) profitRateAry.push(`profit_rate${x.id}`)
}) this.form.getFieldDecorator(`category${x.id}`, { initialValue: '', preserve: true })
} this.form.getFieldDecorator(`profit${x.id}`, { initialValue: '', preserve: true })
if (record.open_channel) { this.form.getFieldDecorator(`profit_rate${x.id}`, { initialValue: '', preserve: true })
const list = record.open_channel })
const channelAry = [] }
this.checkList.map((item) => { if (record.open_channel) {
if (list.indexOf(item.id) != -1) { const list = record.open_channel
channelAry.push(item.name) const channelAry = []
} this.checkList.map((item) => {
}) if (list.indexOf(item.id) != -1) {
this.form.open_channel = channelAry channelAry.push(item.name)
} }
// })
!isEmpty(form.getFieldsValue()) && this.form.open_channel = channelAry
$nextTick(() => { }
form.setFieldsValue( //
pick(record, ['open_channel', 'fliter_condition', ...profitAry, ...profitRateAry, ...categoryAry]) !isEmpty(form.getFieldsValue()) &&
) $nextTick(() => {
this.$forceUpdate() form.setFieldsValue(
}) pick(record, ['open_channel', 'fliter_condition', ...profitAry, ...profitRateAry, ...categoryAry])
}, )
formatCategoryIds(categoryIds) { this.$forceUpdate()
return categoryIds.map((id) => { })
return { value: id } },
}) formatCategoryIds(categoryIds) {
}, return categoryIds.map((id) => {
// return { value: id }
getDetail() { })
this.isLoading = true },
Api.info() convertToString(value) {
.then((result) => { if (typeof value == 'number') {
// return String(value);
result.data.storeInfo.open_channel = result.data.storeInfo.open_channel }
? result.data.storeInfo.open_channel.split(',') return value;
: undefined },
this.record = result.data.storeInfo //
// getDetail() {
this.setFieldsValue() this.isLoading = true
}) Api.info()
.finally(() => (this.isLoading = false)) .then((result) => {
}, //
getChannel(val) { result.data.storeInfo.open_channel = result.data.storeInfo.open_channel
this.form.open_channel = val ? this.convertToString(result.data.storeInfo.open_channel).split(',')
}, : undefined
// this.record = result.data.storeInfo
handleSubmit(e) { //
e.preventDefault() this.setFieldsValue()
// })
const { .finally(() => (this.isLoading = false))
form: { validateFields }, },
onFormSubmit, getChannel(val) {
} = this this.form.open_channel = val
validateFields((errors, values) => { },
!errors && onFormSubmit(values) //
}) handleSubmit(e) {
}, e.preventDefault()
//
const {
form: { validateFields },
onFormSubmit,
} = this
validateFields((errors, values) => {
!errors && onFormSubmit(values)
})
},
// api // api
onFormSubmit(values) { onFormSubmit(values) {
const params = {} const params = {}
params.fliter_condition = values.fliter_condition.map((x, i) => { if (values.fliter_condition) {
return { params.fliter_condition = values.fliter_condition.map((x, i) => {
category: values[`category${x.id}`], return {
profit: values[`profit${x.id}`], category: values[`category${x.id}`],
profit_rate: values[`profit_rate${x.id}`], profit: values[`profit${x.id}`],
} profit_rate: values[`profit_rate${x.id}`],
}) }
if (params.fliter_condition.length > 0) { })
params.fliter_condition.forEach((item) => { } else {
item.category = Array.from(item.category, ({ value }) => value) params.fliter_condition = []
}) }
} // if (params.fliter_condition.length > 0) {
params.open_channel = values.open_channel ? values.open_channel.join(',') : '' // params.fliter_condition.forEach((item) => {
params.fliter_condition = params.fliter_condition.length > 0 ? params.fliter_condition : [] // item.category = Array.from(item.category, ({ value }) => value)
this.isLoading = true // })
Api.update({ form: params }) // }
.then((result) => { params.open_channel = values.open_channel ? values.open_channel.join(',') : ''
// params.fliter_condition = params.fliter_condition.length > 0 ? params.fliter_condition : []
this.$message.success(result.message, 1.5) this.isLoading = true
this.getDetail() Api.update({ form: params })
}) .then((result) => {
.catch(() => { //
this.isLoading = false this.$message.success(result.message, 1.5)
}) this.getDetail()
.finally(() => (this.isLoading = false)) })
}, .catch(() => {
}, this.isLoading = false
})
.finally(() => (this.isLoading = false))
},
},
} }
</script> </script>
<style lang="less" scoped> <style lang="less" scoped>
/deep/.ant-form-item-control { /deep/.ant-form-item-control {
padding-left: 10px; padding-left: 10px;
.ant-form-item-control { .ant-form-item-control {
padding-left: 0; padding-left: 0;
} }
} }
/deep/.ant-input-prefix { /deep/.ant-input-prefix {
font-weight: bold; font-weight: bold;
} }
.fan { .fan {
display: flex; display: flex;
align-items: top; align-items: top;
} }
.fan /deep/ .ant-form-item { .fan /deep/ .ant-form-item {
margin-bottom: 0; margin-bottom: 0;
} }
// .fan /deep/ .ant-select-search__field__placeholder{ // .fan /deep/ .ant-select-search__field__placeholder{
// top: 30%; // top: 30%;

@ -3,61 +3,60 @@
<div class="card-title">{{ $route.meta.title }}</div> <div class="card-title">{{ $route.meta.title }}</div>
<a-spin :spinning="isLoading"> <a-spin :spinning="isLoading">
<a-form :form="form" @submit="handleSubmit"> <a-form :form="form" @submit="handleSubmit">
<a-form-item v-bind="formItemLayoutWithOutLabel"> <div style="width:1000px">
<div class="msg"> <a-form-item v-bind="formItemLayoutWithOutLabel">
<span>价格区间()</span> <div class="msg">
<span>会员加价率%</span> <span>价格区间()</span>
<span>利润空间()</span> <span>会员加价率%</span>
</div> <span>利润空间()</span>
</a-form-item>
<a-modal v-model:visible="setPriceVisible" width="450px" title="利润值" @ok="handleBatchPrice(index_1, index_2, mixPrice, maxPrice)">
<div class="fen" style="margin-top: -10px">
<input placeholder="最大利润值" style="margin-right: 25px" v-model="mixPrice" class="input" type="text" />
<input placeholder="最小利润值" v-model="maxPrice" class="input" type="text" />
</div>
<div class="setRule">
<div class="ruleTitle">设置规则</div>
<div class="ruleText">
A.当加价率生效后会员价高于市场价会员价统一自动按以下标准执行 市场价-成本价x_____% +成本价=会员价
_____%为此时的加价率 利润低于_____元的商品不展示在商城里
</div> </div>
</div> <div class="ruleText"><span class="ruleTitle">会员说明</span>A.当加价率生效后会员价高于市场价会员价统一自动按以下标准执行
</a-modal> 市场价-成本价x_____% +成本价=会员价 _____%为此时的加价率</div>
<a-form-item v-bind="formItemLayoutWithOutLabel"> </a-form-item>
<a-button type="dashed" style="width: calc(43.5% + 8px); margin-right: 50px" @click="handleAddCondition"> <a-form-item v-bind="formItemLayoutWithOutLabel">
<a-icon type="plus-circle" /> 新增分类模版 </a-button><a-button type="dashed" style="width: calc(44.5% + 8px)" @click="handleRemoveCondition"> <div style="width: 100%;">
<a-icon type="minus-circle-o" /> 删除分类模版 <a-button type="dashed" style="width: 100%" @click="handleAddCondition">
</a-button> <a-icon type="plus-circle" /> 新增分类模版 </a-button>
</a-form-item> </div>
<a-form-item v-for="(k, index) in form.getFieldValue('list')" :key="k.id" :label="index === 0 ? '会员模版' : ''" :labelCol="labelCol" v-bind="index === 0 ? { wrapperCol } : formItemLayoutWithOutLabel" required> </a-form-item>
<a-tree-select style="width: 100%; margin-right: 8px; margin-top: 3px" placeholder="请选择商品分类" :dropdownStyle="{ maxHeight: '500px', overflow: 'auto' }" :treeData="formData.categoryList" treeCheckable allowClear treeCheckStrictly <a-form-item v-for="(k, index) in form.getFieldValue('list')" :key="k.id" :label="index === 0 ? '会员模版' : ''" :labelCol="labelCol" v-bind="index === 0 ? { wrapperCol } : formItemLayoutWithOutLabel" required>
@select="onSelect(index, $event)" @focus="handleSelectChange(index)" v-decorator="[`category${k.id}`]"></a-tree-select> <div style="width: 100%;display: flex;align-items: center;justify-content: space-between">
<div style="width: 100%"> <div style="width: 700px;">
<div class="fan" v-for="(m, index2) in k.price_list" :key="m.id"> <a-tree-select style="width: 100%; margin-right: 8px; margin-top: 3px" placeholder="请选择商品分类" :dropdownStyle="{ maxHeight: '500px', overflow: 'auto' }" :treeData="formData.categoryList" treeCheckable allowClear
<a-form-item style="margin-right: 15px; width: 33%; cursor: pointer"> treeCheckStrictly @select="onSelect(index, $event)" @focus="handleSelectChange(index)" v-decorator="[`category${k.id}`]"></a-tree-select>
<div class="inMax" @click="setPrice(index, index2,m.min,m.max)"> <div style="width: 100%">
<span v-if="m.min && m.max">{{ m.min }} ~ {{ m.max }}</span><span style="color: #d9d9d9" v-else>利润值</span> <div class="fan" v-for="(m, index2) in k.price_list" :key="m.id">
<div class="yuan"></div> <a-form-item style="margin-right: 15px; width: 47%; cursor: pointer">
<div class="inMax">
<input placeholder="最小利润值" @blur="onPrice($event, index, index2)" v-model="m.min" class="input" type="text" />
~<input placeholder="最大利润值" @blur="onPrice($event, index, index2)" v-model="m.max" class="input" type="text" />
<div class="yuan"></div>
</div>
</a-form-item>
<a-form-item style="margin-right: 15px; width: 23%">
<a-input placeholder="利润率" @input="onRate($event, index, index2)" suffix="%" v-model="m.add_price_rate" style="width: 100%; margin-right: 8px; text-align: center" />
</a-form-item>
<div style="width: 30%; text-align: center">
<span>{{ m.startProfit }}</span> ~ <span>{{ m.endProfit }}</span>
</div>
<a-button type="dashed" style="width: 120px" @click="handleRemovePriceRate(index,index2)">
<a-icon type="minus-circle-o" /> 删除价格区间</a-button>
</div>
<div style="width: 100%">
<a-button type="dashed" style="width: 100%; margin-right: 50px" @click="handleAddPriceRate(index)">
<a-icon type="plus-circle" /> 新增价格区间 </a-button>
</div>
</div> </div>
</a-form-item>
<a-form-item style="margin-right: 15px; width: 33%">
<a-input placeholder="利润率" @input="onRate($event, index, index2)" suffix="%" v-model="m.add_price_rate" style="width: 100%; margin-right: 8px; text-align: center" />
</a-form-item>
<div style="width: 33%; text-align: center">
<span>{{ m.startProfit }}</span> ~ <span>{{ m.endProfit }}</span>
</div> </div>
</div> <a-button type="dashed" style="width: 120px;margin-left: 20px;" @click="handleRemoveCondition(index)">
<div style="width: 100%"> <a-icon type="minus-circle-o" /> 删除分类模版
<a-button type="dashed" style="width: calc(40% + 8px); margin-right: 50px" @click="handleAddPriceRate(index)">
<a-icon type="plus-circle" /> 新增价格区间 </a-button><a-button type="dashed" style="width: calc(40% + 8px)" @click="handleRemovePriceRate(index)">
<a-icon type="minus-circle-o" /> 删除价格区间
</a-button> </a-button>
</div> </div>
</div> </a-form-item>
</a-form-item> <a-form-item :wrapperCol="{ span: wrapperCol.span, offset: labelCol.span }">
<a-form-item :wrapperCol="{ span: wrapperCol.span, offset: labelCol.span }"> <a-button type="primary" html-type="submit">提交</a-button>
<a-button type="primary" html-type="submit">提交</a-button> </a-form-item>
</a-form-item> </div>
</a-form> </a-form>
</a-spin> </a-spin>
</a-card> </a-card>
@ -87,11 +86,6 @@ export default {
formItemLayoutWithOutLabel: { formItemLayoutWithOutLabel: {
wrapperCol: { span: 10, offset: 3 }, wrapperCol: { span: 10, offset: 3 },
}, },
setPriceVisible: false,
index_1: '',
index_2: '',
mixPrice: '',
maxPrice: '',
} }
}, },
// //
@ -107,6 +101,50 @@ export default {
this.getDetail() this.getDetail()
}, },
methods: { methods: {
onPrice(e, index_1, index_2, type) {
const { form } = this
const list = form.getFieldValue('list')
if (0 >= list[index_1].price_list[index_2].min) {
list[index_1].price_list[index_2].min = null
this.$message.warning('最小利润值必须大于0', 1.5)
list[index_1].price_list[index_2].startProfit = 0
list[index_1].price_list[index_2].endProfit = 0
return
}
if (0 >= list[index_1].price_list[index_2].max) {
list[index_1].price_list[index_2].max = null
this.$message.warning('最大利润值必须大于0', 1.5)
list[index_1].price_list[index_2].startProfit = 0
list[index_1].price_list[index_2].endProfit = 0
return
}
if (list[index_1].price_list[index_2].min > list[index_1].price_list[index_2].max) {
list[index_1].price_list[index_2].max = null
this.$message.warning('最大利润值不能低于最小利润值', 1.5)
list[index_1].price_list[index_2].startProfit = 0
list[index_1].price_list[index_2].endProfit = 0
return
}
if (!list[index_1].price_list[index_2].min || !list[index_1].price_list[index_2].max || !list[index_1].price_list[index_2].add_price_rate) {
list[index_1].price_list[index_2].startProfit = 0
list[index_1].price_list[index_2].endProfit = 0
return
}
if (list[index_1].price_list[index_2].min && list[index_1].price_list[index_2].max) {
let rate = Number(list[index_1].price_list[index_2].add_price_rate)
list[index_1].price_list[index_2].startProfit = Number(
(list[index_1].price_list[index_2].min * (rate / 100)).toFixed(2)
)
list[index_1].price_list[index_2].endProfit = Number(
(list[index_1].price_list[index_2].max * (rate / 100)).toFixed(2)
)
list[index_1].price_list[index_2].add_price_rate = rate
form.setFieldsValue({
list: list,
})
this.$forceUpdate()
}
},
// //
onRate(e, index_1, index_2) { onRate(e, index_1, index_2) {
const { form } = this const { form } = this
@ -136,49 +174,6 @@ export default {
}) })
this.$forceUpdate() this.$forceUpdate()
}, },
handleBatchPrice(index1, index2, min, max) {
const { form } = this
if (!this.mixPrice) {
this.$message.warning('请输入最低价格', 1.5)
} else if (!this.maxPrice) {
this.$message.warning('请输入最高价格', 1.5)
} else if (0 >= this.mixPrice) {
this.mixPrice = null
this.$message.warning('最低价格必须大于0', 1.5)
} else if (0 >= this.maxPrice) {
this.maxPrice = null
this.$message.warning('最高价格必须大于0', 1.5)
} else if (this.mixPrice > this.maxPrice) {
this.maxPrice = null
this.$message.warning('最高价格不能低于最低价格', 1.5)
} else {
const condition = form.getFieldValue('list')
condition.forEach(function (item, k) {
if (k == index1) {
item.price_list.forEach(function (item1, j) {
if (j == index2) {
item1.min = min
item1.max = max
}
})
}
})
form.setFieldsValue({
list: condition,
})
this.$forceUpdate()
this.mixPrice = ''
this.maxPrice = ''
this.setPriceVisible = false
}
},
setPrice(index1, index2, min, max) {
this.index_1 = index1
this.index_2 = index2
this.mixPrice = min;
this.maxPrice = max
this.setPriceVisible = true
},
onSelect(index, event) { onSelect(index, event) {
const { form, $nextTick } = this const { form, $nextTick } = this
const key = form.getFieldValue('list') const key = form.getFieldValue('list')
@ -198,7 +193,6 @@ export default {
let that = this let that = this
for (let i = 0; i < nodes.length; i++) { for (let i = 0; i < nodes.length; i++) {
nodes[i].disabled = false nodes[i].disabled = false
console.log(nodes[i].value, ids)
if (ids.includes(nodes[i].value) == true) { if (ids.includes(nodes[i].value) == true) {
nodes[i].disabled = true nodes[i].disabled = true
} }
@ -220,10 +214,8 @@ export default {
}) })
} }
} }
console.log(key, category)
$nextTick(() => { $nextTick(() => {
this.formData.categoryList = this.deleteNodeById(this.formData.categoryList, category) this.formData.categoryList = this.deleteNodeById(this.formData.categoryList, category)
console.log(this.deleteNodeById(this.formData.categoryList, category))
this.formData = this.formData this.formData = this.formData
this.$forceUpdate() this.$forceUpdate()
}) })
@ -232,11 +224,7 @@ export default {
handleRemoveCondition(index) { handleRemoveCondition(index) {
const { form } = this const { form } = this
const keys = form.getFieldValue('list') const keys = form.getFieldValue('list')
if (keys.length === 0) { keys.splice(index, 1) // 1
this.$message.warning('暂无可删除的分类模版', 1.5)
return
}
keys.pop()
form.setFieldsValue({ form.setFieldsValue({
list: keys, list: keys,
}) })
@ -253,22 +241,12 @@ export default {
}) })
}, },
// //
handleRemovePriceRate(index) { handleRemovePriceRate(index1, index2) {
const { form } = this const { form } = this
const priceList = form.getFieldValue('list')[index].price_list const priceList = form.getFieldValue('list')
if (priceList.length === 0) { priceList[index1].price_list.splice(index2, 1) // 1
this.$message.warning('暂无可删除的价格区间', 1.5)
return
}
priceList.pop()
const conditionList = form.getFieldValue('list')
conditionList.forEach(function (item, mm) {
if (mm == index) {
item.price_list = priceList
}
})
form.setFieldsValue({ form.setFieldsValue({
list: conditionList, list: priceList,
}) })
this.$forceUpdate() this.$forceUpdate()
}, },
@ -313,6 +291,12 @@ export default {
return { value: id } return { value: id }
}) })
}, },
convertToString(value) {
if (typeof value == 'number') {
return String(value);
}
return value;
},
// //
setFieldsValue() { setFieldsValue() {
const { record, form, $nextTick } = this const { record, form, $nextTick } = this
@ -323,10 +307,10 @@ export default {
return x return x
}) })
record.list.forEach((x, i) => { record.list.forEach((x, i) => {
record[`category${x.id}`] = this.formatCategoryIds(x.category.split(',')) record[`category${x.id}`] = this.formatCategoryIds((this.convertToString(x.category)).split(','))
categoryAry.push(`category${x.id}`) categoryAry.push(`category${x.id}`)
this.form.getFieldDecorator(`category${x.id}`, { initialValue: '', preserve: true }) this.form.getFieldDecorator(`category${x.id}`, { initialValue: '', preserve: true })
x.category = x.category.split(',') x.category = (this.convertToString(x.category)).split(',')
x.price_list.forEach((m, j) => { x.price_list.forEach((m, j) => {
m.startProfit = Number((m.min * (Number(m.add_price_rate) / 100)).toFixed(2)) m.startProfit = Number((m.min * (Number(m.add_price_rate) / 100)).toFixed(2))
m.endProfit = Number((m.max * (Number(m.add_price_rate) / 100)).toFixed(2)) m.endProfit = Number((m.max * (Number(m.add_price_rate) / 100)).toFixed(2))
@ -467,6 +451,9 @@ export default {
/deep/.ant-input-prefix { /deep/.ant-input-prefix {
font-weight: bold; font-weight: bold;
} }
/deep/.ant-col-10 {
width: 80%;
}
.fan { .fan {
display: flex; display: flex;
align-items: top; align-items: top;
@ -502,20 +489,20 @@ export default {
} }
.setRule { .setRule {
margin-top: 20px; margin-top: 20px;
.ruleTitle { }
font-size: 14px; .ruleTitle {
font-family: PingFang SC, PingFang SC; font-size: 14px;
font-weight: 500; font-family: PingFang SC, PingFang SC;
color: #303030; font-weight: 500;
} color: #303030;
.ruleText { }
margin-top: 8px; .ruleText {
font-size: 14px; margin-top: 8px;
font-family: PingFang SC, PingFang SC; font-size: 14px;
font-weight: 400; font-family: PingFang SC, PingFang SC;
color: #8b8b8b; font-weight: 400;
line-height: 32px; color: #8b8b8b;
} line-height: 32px;
} }
.inMax { .inMax {
width: 100%; width: 100%;
@ -526,21 +513,35 @@ export default {
list-style: none; list-style: none;
display: inline-block; display: inline-block;
width: 100%; width: 100%;
height: 30px; height: 32px;
padding: 4px 11px; padding: 0 26px 0 0;
color: rgba(0, 0, 0, 0.65); color: rgba(0, 0, 0, 0.65);
font-size: 13px; font-size: 13px;
line-height: 1.8; line-height: 32px;
background-color: #fff; background-color: #fff;
background-image: none; background-image: none;
border: 1px solid #d9d9d9; border: 1px solid #d9d9d9;
border-radius: 2px; border-radius: 2px;
-webkit-transition: all 0.3s; -webkit-transition: all 0.3s;
transition: all 0.3s; transition: all 0.3s;
input {
border: none;
width: 45%;
margin: 0;
height: 100%;
text-align: center;
}
input:focus {
outline: none;
border: none;
}
input::-webkit-input-placeholder {
color: #bfbfbf;
}
.yuan { .yuan {
position: absolute; position: absolute;
right: 10px; right: 10px;
top: 2px; top: 0px;
} }
} }
</style> </style>

@ -239,6 +239,9 @@
<a href="javascript:;" @click="onReloadServiceList">刷新</a> <a href="javascript:;" @click="onReloadServiceList">刷新</a>
</div> </div>
</a-form-item> </a-form-item>
<a-form-item label="下单须知" :labelCol="labelCol" :wrapperCol="wrapperCol">
<a-input placeholder="请输入下单须知" v-decorator="['remark']" />
</a-form-item>
<a-form-item label="初始销量" :labelCol="labelCol" :wrapperCol="wrapperCol" extra="用户端展示的销量 = 初始销量 + 实际销量"> <a-form-item label="初始销量" :labelCol="labelCol" :wrapperCol="wrapperCol" extra="用户端展示的销量 = 初始销量 + 实际销量">
<a-input-number v-decorator="['sales_initial', { initialValue: 0 }]" /> <a-input-number v-decorator="['sales_initial', { initialValue: 0 }]" />
</a-form-item> </a-form-item>

@ -63,8 +63,8 @@
> >
<!-- 回收图片 --> <!-- 回收图片 -->
<span slot="recovery_image" slot-scope="text, item"> <span slot="recovery_image" slot-scope="text, item">
<a title="点击查看原图" :href="item.image.external_url" target="_blank"> <a title="点击查看原图" :href="item.recovery_image" target="_blank">
<img width="50" height="50" :src="item.image.external_url" alt="回收图片" /> <img width="50" height="50" :src="item.recovery_image" alt="回收图片" />
</a> </a>
</span> </span>
<!-- 回收名称 --> <!-- 回收名称 -->

@ -50,7 +50,7 @@
<span class="ml-10"></span> <span class="ml-10"></span>
</a-form-item> </a-form-item>
<a-form-item label="图片" :labelCol="labelCol" :wrapperCol="wrapperCol"> <a-form-item label="图片" :labelCol="labelCol" :wrapperCol="wrapperCol">
<SelectImage :defaultList="record.image ? [record.image] : []" v-decorator="['image_id']" /> <SelectImage :defaultList="record.recovery_image ? record.recovery_image : []" v-decorator="['image_id']" />
</a-form-item> </a-form-item>
<a-form-item label="状态" :labelCol="labelCol" :wrapperCol="wrapperCol"> <a-form-item label="状态" :labelCol="labelCol" :wrapperCol="wrapperCol">
<a-radio-group v-decorator="['status', { initialValue: 1, rules: [{ required: true }] }]"> <a-radio-group v-decorator="['status', { initialValue: 1, rules: [{ required: true }] }]">
@ -109,6 +109,12 @@ export default {
methods: { methods: {
// //
edit(record) { edit(record) {
let list = []
list.push({
preview_url: record.recovery_image,
file_id: 9999
})
record.recovery_image = list
this.getCategoryList() this.getCategoryList()
// //
this.visible = true this.visible = true

@ -63,8 +63,8 @@
> >
<!-- 服务图片 --> <!-- 服务图片 -->
<span slot="server_image" slot-scope="text, item"> <span slot="server_image" slot-scope="text, item">
<a title="点击查看原图" :href="item.image.external_url" target="_blank"> <a title="点击查看原图" :href="item.server_image" target="_blank">
<img width="50" height="50" :src="item.image.external_url" alt="服务图片" /> <img width="50" height="50" :src="item.server_image" alt="服务图片" />
</a> </a>
</span> </span>
<!-- 服务名称 --> <!-- 服务名称 -->

@ -1,208 +1,178 @@
<template> <template>
<a-modal <a-modal title="编辑服务" :width="920" :visible="visible" :confirmLoading="confirmLoading" :maskClosable="false" :destroyOnClose="true" @ok="handleSubmit" @cancel="handleCancel">
title="编辑服务" <a-spin :spinning="confirmLoading">
:width="920" <a-form :form="form">
:visible="visible" <a-form-item label="服务名称" :labelCol="labelCol" :wrapperCol="wrapperCol">
:confirmLoading="confirmLoading" <a-input v-decorator="['server_name', { rules: [{ required: true, min: 2, message: '请输入至少2个字符' }] }]" />
:maskClosable="false" </a-form-item>
:destroyOnClose="true" <a-form-item label="服务分类" :labelCol="labelCol" :wrapperCol="wrapperCol">
@ok="handleSubmit" <a-select v-decorator="['category_id', { initialValue: 0, rules: [{ required: true, message: '请选择分类' }] }]">
@cancel="handleCancel" <a-select-option :value="0">选择分类</a-select-option>
> <a-select-option v-for="(item, index) in categoryList" :key="index" :value="item.category_id">{{
<a-spin :spinning="confirmLoading">
<a-form :form="form">
<a-form-item label="服务名称" :labelCol="labelCol" :wrapperCol="wrapperCol">
<a-input
v-decorator="['server_name', { rules: [{ required: true, min: 2, message: '请输入至少2个字符' }] }]"
/>
</a-form-item>
<a-form-item label="服务分类" :labelCol="labelCol" :wrapperCol="wrapperCol">
<a-select
v-decorator="['category_id', { initialValue: 0, rules: [{ required: true, message: '请选择分类' }] }]"
>
<a-select-option :value="0">选择分类</a-select-option>
<a-select-option v-for="(item, index) in categoryList" :key="index" :value="item.category_id">{{
item.name item.name
}}</a-select-option> }}</a-select-option>
</a-select> </a-select>
</a-form-item> </a-form-item>
<a-form-item label="服务价格" :labelCol="labelCol" :wrapperCol="wrapperCol"> <a-form-item label="服务价格" :labelCol="labelCol" :wrapperCol="wrapperCol">
<a-input-number <a-input-number :min="0.01" :precision="2" v-decorator="['server_price', { initialValue: 1, rules: [{ required: true, message: '请输入服务价格' }] }]" />
:min="0.01" <span class="ml-10"></span>
:precision="2" </a-form-item>
v-decorator="['server_price', { initialValue: 1, rules: [{ required: true, message: '请输入服务价格' }] }]" <a-form-item label="划线价" :labelCol="labelCol" :wrapperCol="wrapperCol">
/> <a-input-number :min="0.01" :precision="2" v-decorator="['line_price', { initialValue: 1, rules: [{ required: true, message: '请输入划线价' }] }]" />
<span class="ml-10"></span> <span class="ml-10"></span>
</a-form-item> </a-form-item>
<a-form-item label="划线价" :labelCol="labelCol" :wrapperCol="wrapperCol"> <a-form-item label="评论数量" :labelCol="labelCol" :wrapperCol="wrapperCol">
<a-input-number <a-input-number :min="10" :step="10" v-decorator="['comment_num', { initialValue: 10, rules: [{ required: true, message: '请输入评论数量' }] }]" />
:min="0.01" </a-form-item>
:precision="2" <a-form-item label="好评率" :labelCol="labelCol" :wrapperCol="wrapperCol">
v-decorator="['line_price', { initialValue: 1, rules: [{ required: true, message: '请输入划线价' }] }]" <a-input-number :min="90" :step="1" :max="100" v-decorator="['comment_rate', { initialValue: 90, rules: [{ required: true, message: '请输入好评率' }] }]" />
/> <span class="ml-10">%</span>
<span class="ml-10"></span> </a-form-item>
</a-form-item> <a-form-item label="销量" :labelCol="labelCol" :wrapperCol="wrapperCol">
<a-form-item label="评论数量" :labelCol="labelCol" :wrapperCol="wrapperCol"> <a-input-number :min="100" v-decorator="['sold', { initialValue: 100, rules: [{ required: true, message: '请输入销量价格' }] }]" />
<a-input-number <span class="ml-10"></span>
:min="10" </a-form-item>
:step="10" <a-form-item label="服务图片" :labelCol="labelCol" :wrapperCol="wrapperCol">
v-decorator="['comment_num', { initialValue: 10, rules: [{ required: true, message: '请输入评论数量' }] }]" <SelectImage :defaultList="record.server_image ? record.server_image : []" v-decorator="['image_id']" />
/> </a-form-item>
</a-form-item> <a-form-item label="服务状态" :labelCol="labelCol" :wrapperCol="wrapperCol">
<a-form-item label="好评率" :labelCol="labelCol" :wrapperCol="wrapperCol"> <a-radio-group v-decorator="['status', { initialValue: 1, rules: [{ required: true }] }]">
<a-input-number <a-radio :value="1">上架</a-radio>
:min="90" <a-radio :value="2">下架</a-radio>
:step="1" </a-radio-group>
:max="100" </a-form-item>
v-decorator="['comment_rate', { initialValue: 90, rules: [{ required: true, message: '请输入好评率' }] }]" <a-form-item label="排序" :labelCol="labelCol" :wrapperCol="wrapperCol" extra="数字越小越靠前">
/> <a-input-number :min="0" v-decorator="['sort', { initialValue: 100, rules: [{ required: true, message: '请输入至少1个数字' }] }]" />
<span class="ml-10">%</span> </a-form-item>
</a-form-item> <a-form-item label="服务详情" :labelCol="labelCol" :wrapperCol="wrapperCol">
<a-form-item label="销量" :labelCol="labelCol" :wrapperCol="wrapperCol"> <Ueditor v-decorator="['content', { rules: [{ required: true, message: '服务详情不能为空' }] }]" />
<a-input-number </a-form-item>
:min="100" </a-form>
v-decorator="['sold', { initialValue: 100, rules: [{ required: true, message: '请输入销量价格' }] }]" </a-spin>
/> </a-modal>
<span class="ml-10"></span>
</a-form-item>
<a-form-item label="服务图片" :labelCol="labelCol" :wrapperCol="wrapperCol">
<SelectImage :defaultList="record.image ? [record.image] : []" v-decorator="['image_id']" />
</a-form-item>
<a-form-item label="服务状态" :labelCol="labelCol" :wrapperCol="wrapperCol">
<a-radio-group v-decorator="['status', { initialValue: 1, rules: [{ required: true }] }]">
<a-radio :value="1">上架</a-radio>
<a-radio :value="2">下架</a-radio>
</a-radio-group>
</a-form-item>
<a-form-item label="排序" :labelCol="labelCol" :wrapperCol="wrapperCol" extra="数字越小越靠前">
<a-input-number
:min="0"
v-decorator="['sort', { initialValue: 100, rules: [{ required: true, message: '请输入至少1个数字' }] }]"
/>
</a-form-item>
<a-form-item label="服务详情" :labelCol="labelCol" :wrapperCol="wrapperCol">
<Ueditor v-decorator="['content', { rules: [{ required: true, message: '服务详情不能为空' }] }]" />
</a-form-item>
</a-form>
</a-spin>
</a-modal>
</template> </template>
<script> <script>
import * as Api from '@/api/server' import * as Api from '@/api/server'
import { SelectImage, Ueditor } from '@/components' import { SelectImage, Ueditor } from '@/components'
export default { export default {
components: { components: {
SelectImage, SelectImage,
Ueditor Ueditor
}, },
props: { props: {
// //
}, },
data () { data() {
return { return {
categoryList: [], categoryList: [],
// //
title: '', title: '',
// //
labelCol: { labelCol: {
span: 7 span: 7
}, },
// //
wrapperCol: { wrapperCol: {
span: 13 span: 13
}, },
// modal() // modal()
visible: false, visible: false,
// modal() loading // modal() loading
confirmLoading: false, confirmLoading: false,
// //
form: this.$form.createForm(this), form: this.$form.createForm(this),
// //
record: {} record: {}
} }
}, },
methods: { methods: {
// //
edit (record) { edit(record) {
this.getCategoryList() let list = []
// list.push({
this.visible = true preview_url: record.server_image,
// file_id: 9999
this.record = record })
// record.server_image = list
this.setFieldsValue() this.getCategoryList()
}, //
// this.visible = true
getCategoryList () { //
this.isLoading = true this.record = record
Api.categoryList() //
.then((result) => { this.setFieldsValue()
this.categoryList = result.data.list },
}) //
.finally(() => (this.isLoading = false)) getCategoryList() {
}, this.isLoading = true
// Api.categoryList()
setFieldsValue () { .then((result) => {
const { this.categoryList = result.data.list
form: { setFieldsValue } })
} = this .finally(() => (this.isLoading = false))
// },
this.$nextTick(() => { //
setFieldsValue( setFieldsValue() {
_.pick(this.record, [ const {
'server_name', form: { setFieldsValue }
'image_id', } = this
'category_id', //
'status', this.$nextTick(() => {
'server_price', setFieldsValue(
'cost_price', _.pick(this.record, [
'sort', 'server_name',
'content', 'image_id',
'comment_rate', 'category_id',
'sold', 'status',
'comment_num' 'server_price',
]) 'cost_price',
) 'sort',
}) 'content',
}, 'comment_rate',
// 'sold',
handleSubmit (e) { 'comment_num'
e.preventDefault() ])
// )
const { })
form: { validateFields } },
} = this //
validateFields((errors, values) => { handleSubmit(e) {
// api e.preventDefault()
if (!errors) { //
this.onFormSubmit(values) const {
} form: { validateFields }
}) } = this
}, validateFields((errors, values) => {
// api
if (!errors) {
this.onFormSubmit(values)
}
})
},
// //
handleCancel () { handleCancel() {
this.visible = false this.visible = false
this.form.resetFields() this.form.resetFields()
}, },
// api // api
onFormSubmit (values) { onFormSubmit(values) {
this.confirmLoading = true this.confirmLoading = true
Api.editServer({ serverId: this.record['server_id'], form: values }) Api.editServer({ serverId: this.record['server_id'], form: values })
.then((result) => { .then((result) => {
// //
this.$message.success(result.message, 1.5) this.$message.success(result.message, 1.5)
// //
this.handleCancel() this.handleCancel()
// //
this.$emit('handleSubmit', values) this.$emit('handleSubmit', values)
}) })
.finally((result) => { .finally((result) => {
this.confirmLoading = false this.confirmLoading = false
}) })
} }
} }
} }
</script> </script>

@ -14,19 +14,19 @@
<a-form-item label="商城简介" :labelCol="labelCol" :wrapperCol="wrapperCol"> <a-form-item label="商城简介" :labelCol="labelCol" :wrapperCol="wrapperCol">
<a-textarea v-decorator="['describe']" /> <a-textarea v-decorator="['describe']" />
</a-form-item> </a-form-item>
<a-form-item label="商城Logo" :labelCol="labelCol" :wrapperCol="wrapperCol" extra="建议尺寸: 300*300"> <a-form-item label="商城Logo" :labelCol="labelCol" :wrapperCol="wrapperCol" extra="建议尺寸: 175*25,最大宽度175,最小高度25">
<SelectImage :defaultList="record.logoImage ? [record.logoImage] : []" v-decorator="['logo_image_id']" /> <SelectImage :defaultList="record.logoImage ? [record.logoImage] : []" v-decorator="['logo_image_id']" />
</a-form-item> </a-form-item>
<a-form-item label="登录Logo" :labelCol="labelCol" :wrapperCol="wrapperCol" extra="建议尺寸: 300*300,为正方形图片"> <a-form-item label="登录Logo" :labelCol="labelCol" :wrapperCol="wrapperCol" extra="建议尺寸: 132*132,请上传正方形图片">
<SelectImage :defaultList="record.loginImg ? [record.loginImg]: []" v-decorator="['login_img_id']" /> <SelectImage :defaultList="record.loginImg ? [record.loginImg]: []" v-decorator="['login_img_id']" />
</a-form-item> </a-form-item>
<a-form-item label="新品首发" :labelCol="labelCol" :wrapperCol="wrapperCol" extra="建议尺寸: 300*300"> <a-form-item label="新品首发" :labelCol="labelCol" :wrapperCol="wrapperCol" extra="建议尺寸: 375*326">
<SelectImage multiple :defaultList="record.newProductImg ? record.newProductImg : []" v-decorator="['new_product_img_id']" /> <SelectImage multiple :defaultList="record.newProductImg ? record.newProductImg : []" v-decorator="['new_product_img_id']" />
</a-form-item> </a-form-item>
<a-form-item label="大牌正品" :labelCol="labelCol" :wrapperCol="wrapperCol" extra="建议尺寸: 300*300"> <a-form-item label="大牌正品" :labelCol="labelCol" :wrapperCol="wrapperCol" extra="建议尺寸: 375*200">
<SelectImage :defaultList="record.bigBrandImg ? record.bigBrandImg : []" v-decorator="['big_brand_img_id']" /> <SelectImage :defaultList="record.bigBrandImg ? record.bigBrandImg : []" v-decorator="['big_brand_img_id']" />
</a-form-item> </a-form-item>
<a-form-item label="秒杀背景图" :labelCol="labelCol" :wrapperCol="wrapperCol" extra="建议尺寸: 300*300"> <a-form-item label="秒杀背景图" :labelCol="labelCol" :wrapperCol="wrapperCol" extra="建议尺寸: 375*275">
<SelectImage multiple :defaultList="record.flashSaleImg ? record.flashSaleImg : []" v-decorator="['flash_sale_img_id']" /> <SelectImage multiple :defaultList="record.flashSaleImg ? record.flashSaleImg : []" v-decorator="['flash_sale_img_id']" />
</a-form-item> </a-form-item>
<!-- <a-form-item <!-- <a-form-item

Loading…
Cancel
Save