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

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

View File

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