update:新增商品接口新加两个字段

fix:修复保存商品上下架开关显示失败
This commit is contained in:
lihaoyuan 2025-10-13 18:15:23 +08:00
parent bcf03fb591
commit be481b47f6
2 changed files with 184 additions and 93 deletions

View File

@ -21,7 +21,11 @@
clearable
filterable
:options="categoryOptions"
:props="{ label: 'category_name', value: 'category_id', children:'sub' }"
:props="{
label: 'category_name',
value: 'category_id',
children: 'sub',
}"
:style="{ width: '90%' }"
@change="onCategoryChange"
/>
@ -34,13 +38,22 @@
:style="{ width: '100%' }"
@change="radChange"
>
<el-radio :disabled="!row.category_virtual_enable" :label="1201">
<el-radio
:disabled="!row.category_virtual_enable"
:label="1201"
>
{{ __('实体商品') }}
</el-radio>
<el-radio :disabled="!row.category_virtual_enable" :label="1202">
<el-radio
:disabled="!row.category_virtual_enable"
:label="1202"
>
{{ __('虚拟商品(服务类商品)') }}
</el-radio>
<el-radio :disabled="!row.category_virtual_enable" :label="1203">
<el-radio
:disabled="!row.category_virtual_enable"
:label="1203"
>
{{ __('电子卡券') }}
</el-radio>
</el-radio-group>
@ -194,9 +207,7 @@
<el-form-item :label="__('上下架')">
<el-switch
v-model="batchObj.item_enable"
:active-value="1001"
:inactive-value="1002"
/>
</el-form-item>
@ -220,7 +231,7 @@
<el-table-column align="center" type="index" width="50" />
<el-table-column
v-for="item in specHead"
:align="item.property=='color_img' ? 'left' : 'center'"
:align="item.property == 'color_img' ? 'left' : 'center'"
:key="item.spec_item_id"
:label="item.label"
:property="item.property"
@ -228,12 +239,27 @@
>
<template slot="header" slot-scope="scope">
<!-- 这里是自定义表头内容 -->
<div v-if="scope.column.property === 'item_market_price' || scope.column.property === 'item_unit_price' || scope.column.property === 'item_advice_price' || scope.column.property === 'item_unit_points' || scope.column.property === 'item_quantity' || scope.column.property === 'item_weight'">
<span>{{scope.column.label}}</span>
<vab-icon :data-key="scope.column.property" icon="more-2-line" style="cursor:pointer;" :title="__('批量设置')" @click="batOper"/>
<div
v-if="
scope.column.property === 'item_market_price' ||
scope.column.property === 'item_unit_price' ||
scope.column.property === 'item_advice_price' ||
scope.column.property === 'item_unit_points' ||
scope.column.property === 'item_quantity' ||
scope.column.property === 'item_weight'
"
>
<span>{{ scope.column.label }}</span>
<vab-icon
:data-key="scope.column.property"
icon="more-2-line"
style="cursor: pointer"
:title="__('批量设置')"
@click="batOper"
/>
</div>
<div v-else>
<span>{{scope.column.label}}</span>
<span>{{ scope.column.label }}</span>
</div>
</template>
@ -269,11 +295,15 @@
<el-switch
v-else-if="scope.column.property === 'item_enable'"
v-model="scope.row.item_enable"
:active-value="1001"
:inactive-value="1002"
/>
<el-switch
v-else-if="scope.column.property === 'is_open_automatic'"
v-model="scope.row.is_open_automatic"
:active-value="1"
:inactive-value="0"
/>
<el-switch
v-else-if="scope.column.property === 'item_is_default'"
v-model="scope.row.item_is_default"
@ -908,7 +938,7 @@
data() {
return {
categoryOptions: [],
categoryId:null,
categoryId: null,
default_image: '',
params: {
authorization: '',
@ -1103,6 +1133,14 @@
label: this.__('库存'),
property: 'item_quantity',
},
{
label: this.__('是否开启次日补全'), //
property: 'is_open_automatic', //
},
{
label: this.__('次日补全值'), //
property: 'automatic', //
},
/*{
label: this.__('采购价'),
property: 'item_purchase_price',
@ -1136,7 +1174,7 @@
{
label: this.__('属性编号'),
property: 'item_number',
},/*
} /*
{
label: this.__('条形码'),
property: 'item_barcode',
@ -1144,7 +1182,7 @@
{
label: this.__('重量[kg]'),
property: 'item_weight',
},*/
},*/,
{
label: this.__('市场价'),
property: 'item_market_price',
@ -1160,6 +1198,14 @@
{
label: this.__('库存'),
property: 'item_quantity',
},
{
label: this.__('是否开启次日补全'), //
property: 'is_open_automatic', //
},
{
label: this.__('次日补全值'), //
property: 'automatic', //
},
/*{
label: this.__('采购价'),
@ -1237,10 +1283,9 @@
deep: true,
},
},
mounted() {
},
mounted() {},
async created() {
await this.getCategoryTree();
await this.getCategoryTree()
this.getStoreBase()
this.getxfz()
@ -1282,26 +1327,33 @@
}
},
getStoreBase() {
if (this.configs.config.supplier_market_enable && 2 == this.configs.store_type) {
const unitPriceIndex = this.expHead.findIndex(item => item.property === 'item_unit_price');
if (
this.configs.config.supplier_market_enable &&
2 == this.configs.store_type
) {
const unitPriceIndex = this.expHead.findIndex(
(item) => item.property === 'item_unit_price'
)
if (unitPriceIndex !== -1) {
this.expHead[unitPriceIndex].label = this.__('成本价');
this.expHead[unitPriceIndex].label = this.__('成本价')
this.expHead.splice(unitPriceIndex + 1, 0, {
label: this.__('建议零售价'),
property: 'item_advice_price',
});
})
}
const unitIndex = this.virtualHead.findIndex(item => item.property === 'item_unit_price');
const unitIndex = this.virtualHead.findIndex(
(item) => item.property === 'item_unit_price'
)
if (unitIndex !== -1) {
this.virtualHead[unitIndex].label = this.__('成本价');
this.virtualHead[unitIndex].label = this.__('成本价')
this.virtualHead.splice(unitIndex + 1, 0, {
label: this.__('建议零售价'),
property: 'item_advice_price',
});
})
}
}
},
@ -1663,6 +1715,9 @@
item_advice_price: undefined,
item_unit_points: undefined,
item_quantity: undefined,
//
is_open_automatic: '0', // 0
automatic: undefined, //
}
this.specData.push(obj)
return
@ -1765,7 +1820,6 @@
this.row = Object.assign({}, row)
if (row != null) {
this.categoryId = row.category_id
this.productForm.category_id = row.category_id
this.productForm.text_category_id = row.category_name
@ -1788,7 +1842,7 @@
async onCategoryChange(row) {
console.info(row)
if (row.length > 0) {
const category_id = row[row.length-1];
const category_id = row[row.length - 1]
const category = this.findTree(this.categoryOptions, category_id)
if (category != null) {
@ -1891,12 +1945,19 @@
const specData = this.specData
for (let i = 0; i < specData.length; i++) {
if (specData[i].item_unit_price <= 0 && specData[i].item_unit_points <= 0) {
if (
specData[i].item_unit_price <= 0 &&
specData[i].item_unit_points <= 0
) {
this.$baseMessage('商品零售价及积分不能同时为0', 'warning')
return
}
if (this.configs.config.supplier_market_enable && 2 == this.configs.store_type && specData[i].item_advice_price <= 0) {
if (
this.configs.config.supplier_market_enable &&
2 == this.configs.store_type &&
specData[i].item_advice_price <= 0
) {
this.$baseMessage('商品建议零售价不能为0', 'warning')
return
}
@ -1968,7 +2029,7 @@
},
async getType(type_id) {
const { data } = await get({ type_id: type_id })
if(data){
if (data) {
this.brands = data.brands
this.assists = data.assists
this.specs = data.specs
@ -1979,7 +2040,6 @@
this.initAssistArr(this.assists)
this.initCheckSpecArr(this.specs)
}
},
// vue assistArr
initAssistArr(assists) {
@ -2055,20 +2115,20 @@
async getCategoryTree() {
const { data } = await getCategoryTree()
const treeData = this.tree(data);
const treeData = this.tree(data)
console.info(treeData)
//null
this.categoryOptions = treeData;
this.categoryOptions = treeData
},
tree(data) {
for (let i = 0; i < data.length; i++) {
let item = data[i];
let item = data[i]
// item.sub undefined && item.sub.length 0
if (item.sub && item.sub.length > 0) {
item.sub = this.tree(item.sub);
item.sub = this.tree(item.sub)
} else {
delete item.sub;
delete item.sub
}
}
@ -2076,7 +2136,7 @@
},
findTree(data, idx) {
for (let i = 0; i < data.length; i++) {
let item = data[i];
let item = data[i]
if (item.category_id == idx) {
return item
@ -2084,9 +2144,9 @@
// item.sub undefined && item.sub.length 0
if (item.sub && item.sub.length > 0) {
const tmp = this.findTree(item.sub, idx);
const tmp = this.findTree(item.sub, idx)
if (tmp != null) {
return tmp;
return tmp
}
}
}
@ -2216,7 +2276,7 @@
},
//
getItemWidth (property) {
getItemWidth(property) {
let width = null
switch (property) {
@ -2251,21 +2311,21 @@
return width
},
batOper (e) {
const key = e.target.dataset.key;
let title = "";
if (key == "item_market_price") {
title = this.__('批量设置市场价');
} else if (key == "item_unit_price") {
title = this.__('批量设置价格');
} else if (key == "item_unit_points") {
title = this.__('批量设置积分');
} else if (key == "item_quantity") {
title = this.__('批量设置库存');
} else if (key == "item_weight") {
title = this.__('批量设置重量');
} else if (key == "item_advice_price") {
title = this.__('批量设置建议零售价');
batOper(e) {
const key = e.target.dataset.key
let title = ''
if (key == 'item_market_price') {
title = this.__('批量设置市场价')
} else if (key == 'item_unit_price') {
title = this.__('批量设置价格')
} else if (key == 'item_unit_points') {
title = this.__('批量设置积分')
} else if (key == 'item_quantity') {
title = this.__('批量设置库存')
} else if (key == 'item_weight') {
title = this.__('批量设置重量')
} else if (key == 'item_advice_price') {
title = this.__('批量设置建议零售价')
}
this.$prompt(title, {
@ -2284,7 +2344,7 @@
this.$forceUpdate()
})
.catch(() => {})
}
},
},
}
</script>
@ -2300,7 +2360,7 @@
}
::v-deep {
.el-dialog__body{
.el-dialog__body {
padding-top: 10px;
}
@ -2309,10 +2369,10 @@
margin: 0 5px;
}
.pic-upload-source{
.pic-upload-source {
padding: 0;
.pic-upload-source-box{
.pic-upload-source-box {
height: 50px;
line-height: 50px;
}

View File

@ -292,6 +292,12 @@
:active-value="1001"
:inactive-value="1002"
/>
<el-switch
v-else-if="scope.column.property === 'is_open_automatic'"
v-model="scope.row.is_open_automatic"
:active-value="1"
:inactive-value="0"
/>
<el-switch
v-else-if="scope.column.property === 'item_is_default'"
v-model="scope.row.item_is_default"
@ -306,6 +312,11 @@
v-model="scope.row[scope.column.property]"
@blur="(e) => handleInput(e, scope)"
/>
<el-input
v-else-if="scope.column.property === 'automatic'"
v-model="scope.row[scope.column.property]"
@blur="(e) => handleInput(e, scope)"
/>
<el-input
v-else-if="scope.column.property === 'item_advice_price'"
v-model="scope.row[scope.column.property]"
@ -1132,6 +1143,14 @@ export default {
label: this.__('库存'),
property: 'item_quantity',
},
{
label: this.__('是否开启次日补全'),
property: 'is_open_automatic',
},
{
label: this.__('次日补全值'),
property: 'automatic',
},
{
label: this.__('上下架'),
property: 'item_enable',
@ -1178,6 +1197,14 @@ export default {
label: this.__('库存'),
property: 'item_quantity',
},
{
label: this.__('是否开启次日补全'), //
property: 'is_open_automatic', //
},
{
label: this.__('次日补全值'), //
property: 'automatic', //
},
/*{
label: this.__('采购价'),
property: 'item_purchase_price',
@ -1759,6 +1786,8 @@ export default {
item_advice_price: undefined,
item_unit_points: undefined,
item_quantity: undefined,
is_open_automatic: 0,
automatic: undefined,
}
let spec_item_ids = []
@ -2005,11 +2034,13 @@ export default {
item_advice_price: productItem.item_advice_price,
item_unit_points: productItem.item_unit_points,
item_quantity: productItem.item_quantity,
item_enable: productItem.item_enable,
item_enable: Number(productItem.item_enable),
item_is_default: productItem.item_is_default == 1 ? true : false,
item_purchase_price: productItem.item_purchase_price,
item_purchase_rate: productItem.item_purchase_rate,
item_sales_rate: productItem.item_sales_rate,
is_open_automatic: Number(productItem.is_open_automatic) || 0, // 0
automatic: productItem.automatic || undefined, //
}
const strSpec = productItem.item_spec