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',
getStorePriceInfo: 'store/getStorePriceInfo',
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) {
return axios({
url: api.collector,

@ -95,7 +95,7 @@ export default {
'status', 'spec_type', 'deduct_stock_type', 'is_restrict', 'content',
'selling_point', 'serviceIds', 'sales_initial', 'is_points_gift',
'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)
return {

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

@ -244,6 +244,9 @@
<a href="javascript:;" @click="onReloadServiceList">刷新</a>
</div>
</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-input-number v-decorator="['sales_initial', { initialValue: 0 }]" />
</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>
<a-spin :spinning="isLoading">
<a-form :form="form" @submit="handleSubmit">
<a-form-item v-bind="formItemLayoutWithOutLabel">
<div class="msg">
<span>价格区间()</span>
<span>分销加价率%</span>
<span>利润空间()</span>
</div>
</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 style="width:1000px">
<a-form-item v-bind="formItemLayoutWithOutLabel">
<div class="msg">
<span>价格区间()</span>
<span>分销加价率%</span>
<span>利润空间()</span>
</div>
</div>
</a-modal>
<a-form-item v-bind="formItemLayoutWithOutLabel">
<a-button type="dashed" style="width: calc(43.5% + 8px); margin-right: 50px" @click="handleAddCondition">
<a-icon type="plus-circle" /> 新增分类模版 </a-button><a-button type="dashed" style="width: calc(44.5% + 8px)" @click="handleRemoveCondition">
<a-icon type="minus-circle-o" /> 删除分类模版
</a-button>
</a-form-item>
<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-tree-select style="width: 100%; margin-right: 8px; margin-top: 3px" placeholder="请选择商品分类" :dropdownStyle="{ maxHeight: '500px', overflow: 'auto' }" :treeData="formData.categoryList" treeCheckable allowClear treeCheckStrictly
@select="onSelect(index, $event)" @focus="handleSelectChange(index)" v-decorator="[`category${k.id}`]"></a-tree-select>
<div style="width: 100%">
<div class="fan" v-for="(m, index2) in k.price_list" :key="m.id">
<a-form-item style="margin-right: 15px; width: 33%; cursor: pointer">
<div class="inMax" @click="setPrice(index, index2,m.min,m.max)">
<span v-if="m.min && m.max">{{ m.min }} ~ {{ m.max }}</span><span style="color: #d9d9d9" v-else>利润值</span>
<div class="yuan"></div>
<div class="ruleText"><span class="ruleTitle">分销说明</span>A.当加价率生效后分销价高于市场价分销价统一自动按以下标准执行
市场价-成本价x_____% +成本价=分销价 _____%为此时的加价率
B.当加价率生效后分销价高于会员价分销价进一步统一自动按以下标准执行会员价-成本价x_____% +成本价=分销价 _____%为此时的加价率</div>
</a-form-item>
<a-form-item v-bind="formItemLayoutWithOutLabel">
<div style="width: 100%;">
<a-button type="dashed" style="width: 100%" @click="handleAddCondition">
<a-icon type="plus-circle" /> 新增分类模版 </a-button>
</div>
</a-form-item>
<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%;display: flex;align-items: center;justify-content: space-between">
<div style="width: 700px;">
<a-tree-select style="width: 100%; margin-right: 8px; margin-top: 3px" placeholder="请选择商品分类" :dropdownStyle="{ maxHeight: '500px', overflow: 'auto' }" :treeData="formData.categoryList" treeCheckable allowClear
treeCheckStrictly @select="onSelect(index, $event)" @focus="handleSelectChange(index)" v-decorator="[`category${k.id}`]"></a-tree-select>
<div style="width: 100%">
<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>
</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 style="width: 100%">
<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 type="dashed" style="width: 120px;margin-left: 20px;" @click="handleRemoveCondition(index)">
<a-icon type="minus-circle-o" /> 删除分类模版
</a-button>
</div>
</div>
</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-item>
<a-form-item :wrapperCol="{ span: wrapperCol.span, offset: labelCol.span }">
<a-button type="primary" html-type="submit">提交</a-button>
</a-form-item>
</div>
</a-form>
</a-spin>
</a-card>
@ -87,11 +87,6 @@ export default {
formItemLayoutWithOutLabel: {
wrapperCol: { span: 10, offset: 3 },
},
setPriceVisible: false,
index_1: '',
index_2: '',
mixPrice: '',
maxPrice: '',
}
},
//
@ -107,6 +102,50 @@ export default {
this.getDetail()
},
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) {
const { form } = this
@ -136,49 +175,6 @@ export default {
})
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) {
const { form, $nextTick } = this
const key = form.getFieldValue('list')
@ -198,7 +194,6 @@ export default {
let that = this
for (let i = 0; i < nodes.length; i++) {
nodes[i].disabled = false
console.log(nodes[i].value, ids)
if (ids.includes(nodes[i].value) == true) {
nodes[i].disabled = true
}
@ -222,7 +217,6 @@ export default {
}
$nextTick(() => {
this.formData.categoryList = this.deleteNodeById(this.formData.categoryList, category)
console.log(this.deleteNodeById(this.formData.categoryList, category))
this.formData = this.formData
this.$forceUpdate()
})
@ -231,11 +225,7 @@ export default {
handleRemoveCondition(index) {
const { form } = this
const keys = form.getFieldValue('list')
if (keys.length === 0) {
this.$message.warning('暂无可删除的分类模版', 1.5)
return
}
keys.pop()
keys.splice(index, 1) // 1
form.setFieldsValue({
list: keys,
})
@ -252,22 +242,12 @@ export default {
})
},
//
handleRemovePriceRate(index) {
handleRemovePriceRate(index1, index2) {
const { form } = this
const priceList = form.getFieldValue('list')[index].price_list
if (priceList.length === 0) {
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
}
})
const priceList = form.getFieldValue('list')
priceList[index1].price_list.splice(index2, 1) // 1
form.setFieldsValue({
list: conditionList,
list: priceList,
})
this.$forceUpdate()
},
@ -312,6 +292,12 @@ export default {
return { value: id }
})
},
convertToString(value) {
if (typeof value == 'number') {
return String(value);
}
return value;
},
//
setFieldsValue() {
const { record, form, $nextTick } = this
@ -322,10 +308,10 @@ export default {
return x
})
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}`)
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) => {
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))
@ -466,6 +452,9 @@ export default {
/deep/.ant-input-prefix {
font-weight: bold;
}
/deep/.ant-col-10 {
width: 80%;
}
.fan {
display: flex;
align-items: top;
@ -501,20 +490,20 @@ export default {
}
.setRule {
margin-top: 20px;
.ruleTitle {
font-size: 14px;
font-family: PingFang SC, PingFang SC;
font-weight: 500;
color: #303030;
}
.ruleText {
margin-top: 8px;
font-size: 14px;
font-family: PingFang SC, PingFang SC;
font-weight: 400;
color: #8b8b8b;
line-height: 32px;
}
}
.ruleTitle {
font-size: 14px;
font-family: PingFang SC, PingFang SC;
font-weight: 500;
color: #303030;
}
.ruleText {
margin-top: 8px;
font-size: 14px;
font-family: PingFang SC, PingFang SC;
font-weight: 400;
color: #8b8b8b;
line-height: 32px;
}
.inMax {
width: 100%;
@ -525,21 +514,35 @@ export default {
list-style: none;
display: inline-block;
width: 100%;
height: 30px;
padding: 4px 11px;
height: 32px;
padding: 0 26px 0 0;
color: rgba(0, 0, 0, 0.65);
font-size: 13px;
line-height: 1.8;
line-height: 32px;
background-color: #fff;
background-image: none;
border: 1px solid #d9d9d9;
border-radius: 2px;
-webkit-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 {
position: absolute;
right: 10px;
top: 2px;
top: 0px;
}
}
</style>

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

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

@ -239,6 +239,9 @@
<a href="javascript:;" @click="onReloadServiceList">刷新</a>
</div>
</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-input-number v-decorator="['sales_initial', { initialValue: 0 }]" />
</a-form-item>

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

@ -50,7 +50,7 @@
<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']" />
<SelectImage :defaultList="record.recovery_image ? record.recovery_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 }] }]">
@ -109,6 +109,12 @@ export default {
methods: {
//
edit(record) {
let list = []
list.push({
preview_url: record.recovery_image,
file_id: 9999
})
record.recovery_image = list
this.getCategoryList()
//
this.visible = true

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

@ -1,208 +1,178 @@
<template>
<a-modal
title="编辑服务"
:width="920"
:visible="visible"
:confirmLoading="confirmLoading"
:maskClosable="false"
:destroyOnClose="true"
@ok="handleSubmit"
@cancel="handleCancel"
>
<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">{{
<a-modal title="编辑服务" :width="920" :visible="visible" :confirmLoading="confirmLoading" :maskClosable="false" :destroyOnClose="true" @ok="handleSubmit" @cancel="handleCancel">
<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
}}</a-select-option>
</a-select>
</a-form-item>
<a-form-item label="服务价格" :labelCol="labelCol" :wrapperCol="wrapperCol">
<a-input-number
:min="0.01"
:precision="2"
v-decorator="['server_price', { initialValue: 1, rules: [{ required: true, message: '请输入服务价格' }] }]"
/>
<span class="ml-10"></span>
</a-form-item>
<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>
</a-form-item>
<a-form-item label="评论数量" :labelCol="labelCol" :wrapperCol="wrapperCol">
<a-input-number
:min="10"
:step="10"
v-decorator="['comment_num', { initialValue: 10, rules: [{ required: true, message: '请输入评论数量' }] }]"
/>
</a-form-item>
<a-form-item label="好评率" :labelCol="labelCol" :wrapperCol="wrapperCol">
<a-input-number
:min="90"
:step="1"
:max="100"
v-decorator="['comment_rate', { initialValue: 90, rules: [{ required: true, message: '请输入好评率' }] }]"
/>
<span class="ml-10">%</span>
</a-form-item>
<a-form-item label="销量" :labelCol="labelCol" :wrapperCol="wrapperCol">
<a-input-number
:min="100"
v-decorator="['sold', { initialValue: 100, rules: [{ required: true, message: '请输入销量价格' }] }]"
/>
<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>
</a-select>
</a-form-item>
<a-form-item label="服务价格" :labelCol="labelCol" :wrapperCol="wrapperCol">
<a-input-number :min="0.01" :precision="2" v-decorator="['server_price', { initialValue: 1, rules: [{ required: true, message: '请输入服务价格' }] }]" />
<span class="ml-10"></span>
</a-form-item>
<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>
</a-form-item>
<a-form-item label="评论数量" :labelCol="labelCol" :wrapperCol="wrapperCol">
<a-input-number :min="10" :step="10" v-decorator="['comment_num', { initialValue: 10, rules: [{ required: true, message: '请输入评论数量' }] }]" />
</a-form-item>
<a-form-item label="好评率" :labelCol="labelCol" :wrapperCol="wrapperCol">
<a-input-number :min="90" :step="1" :max="100" v-decorator="['comment_rate', { initialValue: 90, rules: [{ required: true, message: '请输入好评率' }] }]" />
<span class="ml-10">%</span>
</a-form-item>
<a-form-item label="销量" :labelCol="labelCol" :wrapperCol="wrapperCol">
<a-input-number :min="100" v-decorator="['sold', { initialValue: 100, rules: [{ required: true, message: '请输入销量价格' }] }]" />
<span class="ml-10"></span>
</a-form-item>
<a-form-item label="服务图片" :labelCol="labelCol" :wrapperCol="wrapperCol">
<SelectImage :defaultList="record.server_image ? record.server_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>
<script>
import * as Api from '@/api/server'
import { SelectImage, Ueditor } from '@/components'
export default {
components: {
SelectImage,
Ueditor
},
props: {
//
},
data () {
return {
categoryList: [],
//
title: '',
//
labelCol: {
span: 7
},
//
wrapperCol: {
span: 13
},
// modal()
visible: false,
// modal() loading
confirmLoading: false,
//
form: this.$form.createForm(this),
//
record: {}
}
},
methods: {
//
edit (record) {
this.getCategoryList()
//
this.visible = true
//
this.record = record
//
this.setFieldsValue()
},
//
getCategoryList () {
this.isLoading = true
Api.categoryList()
.then((result) => {
this.categoryList = result.data.list
})
.finally(() => (this.isLoading = false))
},
//
setFieldsValue () {
const {
form: { setFieldsValue }
} = this
//
this.$nextTick(() => {
setFieldsValue(
_.pick(this.record, [
'server_name',
'image_id',
'category_id',
'status',
'server_price',
'cost_price',
'sort',
'content',
'comment_rate',
'sold',
'comment_num'
])
)
})
},
//
handleSubmit (e) {
e.preventDefault()
//
const {
form: { validateFields }
} = this
validateFields((errors, values) => {
// api
if (!errors) {
this.onFormSubmit(values)
}
})
},
components: {
SelectImage,
Ueditor
},
props: {
//
},
data() {
return {
categoryList: [],
//
title: '',
//
labelCol: {
span: 7
},
//
wrapperCol: {
span: 13
},
// modal()
visible: false,
// modal() loading
confirmLoading: false,
//
form: this.$form.createForm(this),
//
record: {}
}
},
methods: {
//
edit(record) {
let list = []
list.push({
preview_url: record.server_image,
file_id: 9999
})
record.server_image = list
this.getCategoryList()
//
this.visible = true
//
this.record = record
//
this.setFieldsValue()
},
//
getCategoryList() {
this.isLoading = true
Api.categoryList()
.then((result) => {
this.categoryList = result.data.list
})
.finally(() => (this.isLoading = false))
},
//
setFieldsValue() {
const {
form: { setFieldsValue }
} = this
//
this.$nextTick(() => {
setFieldsValue(
_.pick(this.record, [
'server_name',
'image_id',
'category_id',
'status',
'server_price',
'cost_price',
'sort',
'content',
'comment_rate',
'sold',
'comment_num'
])
)
})
},
//
handleSubmit(e) {
e.preventDefault()
//
const {
form: { validateFields }
} = this
validateFields((errors, values) => {
// api
if (!errors) {
this.onFormSubmit(values)
}
})
},
//
handleCancel () {
this.visible = false
this.form.resetFields()
},
//
handleCancel() {
this.visible = false
this.form.resetFields()
},
// api
onFormSubmit (values) {
this.confirmLoading = true
Api.editServer({ serverId: this.record['server_id'], form: values })
.then((result) => {
//
this.$message.success(result.message, 1.5)
//
this.handleCancel()
//
this.$emit('handleSubmit', values)
})
.finally((result) => {
this.confirmLoading = false
})
}
}
// api
onFormSubmit(values) {
this.confirmLoading = true
Api.editServer({ serverId: this.record['server_id'], form: values })
.then((result) => {
//
this.$message.success(result.message, 1.5)
//
this.handleCancel()
//
this.$emit('handleSubmit', values)
})
.finally((result) => {
this.confirmLoading = false
})
}
}
}
</script>

@ -14,19 +14,19 @@
<a-form-item label="商城简介" :labelCol="labelCol" :wrapperCol="wrapperCol">
<a-textarea v-decorator="['describe']" />
</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']" />
</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']" />
</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']" />
</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']" />
</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']" />
</a-form-item>
<!-- <a-form-item

Loading…
Cancel
Save