|
|
@@ -137,7 +137,7 @@
|
|
|
</template>
|
|
|
</el-table-column>
|
|
|
<el-table-column label="商品名称" align="center" prop="productName" show-overflow-tooltip width="150px"/>
|
|
|
- <el-table-column label="店铺" align="center" prop="storeName" width="150px"/>
|
|
|
+ <el-table-column label="店铺" align="center" prop="storeName" show-overflow-tooltip min-width="150px"/>
|
|
|
<el-table-column label="分类" align="center" prop="cateName" />
|
|
|
<el-table-column label="商品价格" align="center" prop="price" />
|
|
|
<el-table-column label="市场价" align="center" prop="otPrice" />
|
|
|
@@ -250,15 +250,24 @@
|
|
|
</el-form-item>
|
|
|
</el-col>
|
|
|
<el-col :span="12">
|
|
|
- <el-form-item label="所属店铺" prop="storeId">
|
|
|
- <el-select v-model="form.storeId" placeholder="状态" clearable size="small">
|
|
|
- <el-option
|
|
|
- v-for="dict in storeOPtions"
|
|
|
- :key="dict.dictValue"
|
|
|
- :label="dict.dictLabel"
|
|
|
- :value="dict.dictValue"
|
|
|
- />
|
|
|
- </el-select>
|
|
|
+ <el-form-item label="所属店铺" prop="storeIdList">
|
|
|
+ <el-select
|
|
|
+ v-model="form.storeIdList"
|
|
|
+ placeholder="请选择所属店铺"
|
|
|
+ clearable
|
|
|
+ filterable
|
|
|
+ multiple
|
|
|
+ collapse-tags
|
|
|
+ size="small"
|
|
|
+ style="width: 100%"
|
|
|
+ >
|
|
|
+ <el-option
|
|
|
+ v-for="dict in storeOPtions"
|
|
|
+ :key="dict.dictValue"
|
|
|
+ :label="dict.dictLabel"
|
|
|
+ :value="dict.dictValue"
|
|
|
+ />
|
|
|
+ </el-select>
|
|
|
</el-form-item>
|
|
|
</el-col>
|
|
|
</el-row>
|
|
|
@@ -1096,9 +1105,55 @@ export default {
|
|
|
},
|
|
|
getstoreList() {
|
|
|
listStore().then(response => {
|
|
|
- this.storeOPtions = response.rows;
|
|
|
+ this.storeOPtions = (response.rows || []).map(item => ({
|
|
|
+ ...item,
|
|
|
+ dictValue: item.dictValue != null ? Number(item.dictValue) : item.dictValue
|
|
|
+ }));
|
|
|
});
|
|
|
},
|
|
|
+ /** storeId 单店 / brandStoreIds 大品牌归属 → 表单多选回显 */
|
|
|
+ resolveStoreIdList(product) {
|
|
|
+ if (!product) {
|
|
|
+ return [];
|
|
|
+ }
|
|
|
+ // 大品牌归属优先:即使只有一个店,也按 brandStoreIds 回显,不能当成 storeId
|
|
|
+ if (product.brandStoreIds) {
|
|
|
+ return String(product.brandStoreIds)
|
|
|
+ .split(',')
|
|
|
+ .map(id => id && String(id).trim())
|
|
|
+ .filter(Boolean)
|
|
|
+ .map(id => Number(id))
|
|
|
+ .filter(id => !Number.isNaN(id));
|
|
|
+ }
|
|
|
+ if (product.storeId != null && product.storeId !== '') {
|
|
|
+ return [Number(product.storeId)];
|
|
|
+ }
|
|
|
+ return [];
|
|
|
+ },
|
|
|
+ /**
|
|
|
+ * 多选店铺写回:
|
|
|
+ * - 来自大品牌归属(brandStoreIds)的,始终写回 brandStoreIds(哪怕只选 1 个店)
|
|
|
+ * - 来自单店 storeId 的,单选写 storeId;改成多选则升为 brandStoreIds
|
|
|
+ * - 新建:1 个店 → storeId;多个 → brandStoreIds
|
|
|
+ */
|
|
|
+ applyStoreIdListToForm() {
|
|
|
+ const ids = Array.isArray(this.form.storeIdList)
|
|
|
+ ? this.form.storeIdList.map(id => Number(id)).filter(id => !Number.isNaN(id))
|
|
|
+ : [];
|
|
|
+ const fromBrand = !!this.form.storeAttrFromBrand;
|
|
|
+ if (ids.length === 0) {
|
|
|
+ this.form.storeId = null;
|
|
|
+ this.form.brandStoreIds = null;
|
|
|
+ return;
|
|
|
+ }
|
|
|
+ if (fromBrand || ids.length > 1) {
|
|
|
+ this.form.storeId = null;
|
|
|
+ this.form.brandStoreIds = ids.join(',');
|
|
|
+ return;
|
|
|
+ }
|
|
|
+ this.form.storeId = ids[0];
|
|
|
+ this.form.brandStoreIds = null;
|
|
|
+ },
|
|
|
handleAvatarSuccess(res, file) {
|
|
|
if(res.code==200){
|
|
|
this.form.imgUrl=res.url;
|
|
|
@@ -1129,6 +1184,9 @@ export default {
|
|
|
this.form = {
|
|
|
productId: null,
|
|
|
storeId: null,
|
|
|
+ brandStoreIds: null,
|
|
|
+ storeIdList: [],
|
|
|
+ storeAttrFromBrand: false,
|
|
|
doctorBrokerage:null,
|
|
|
imgUrl: null,
|
|
|
images: null,
|
|
|
@@ -1228,6 +1286,9 @@ export default {
|
|
|
this.form = response.data;
|
|
|
this.open = true;
|
|
|
this.title = "修改商品";
|
|
|
+ const fromBrand = !!this.form.brandStoreIds;
|
|
|
+ this.$set(this.form, 'storeAttrFromBrand', fromBrand);
|
|
|
+ this.$set(this.form, 'storeIdList', this.resolveStoreIdList(this.form));
|
|
|
this.form.isShow = String(this.form.isShow)
|
|
|
this.form.isHot = String(this.form.isHot)
|
|
|
this.form.isBenefit = String(this.form.isBenefit)
|
|
|
@@ -1333,6 +1394,7 @@ export default {
|
|
|
return this.$message.warning('请点击生成规格!');
|
|
|
}
|
|
|
|
|
|
+ this.applyStoreIdListToForm();
|
|
|
addOrEdit(this.form).then(response => {
|
|
|
if (response.code === 200) {
|
|
|
this.msgSuccess("操作成功");
|