This commit is contained in:
Leo
2025-11-13 23:43:29 +08:00
parent e99ce93bc1
commit 752b3ff1ca

View File

@@ -1,6 +1,23 @@
<template>
<div class="app-container">
<el-form :model="queryParams" ref="queryForm" size="small" :inline="true" v-show="showSearch" label-width="100px">
<el-form-item label="ERP账号" prop="appid" required>
<el-select
v-model="queryParams.appid"
placeholder="请选择ERP账号必选"
clearable
style="width: 200px"
@change="handleAccountChange"
>
<el-option
v-for="item in erpAccountList"
:key="item.value"
:label="item.label"
:value="item.value"
/>
</el-select>
<span style="color: #f56c6c; margin-left: 10px; font-size: 12px;">* 不同账号的商品列表和权限不同</span>
</el-form-item>
<el-form-item label="商品标题" prop="title">
<el-input
v-model="queryParams.title"
@@ -24,16 +41,6 @@
@keyup.enter.native="handleQuery"
/>
</el-form-item>
<el-form-item label="ERP应用" prop="appid">
<el-select v-model="queryParams.appid" placeholder="请选择" clearable>
<el-option
v-for="item in erpAccountList"
:key="item.value"
:label="item.label"
:value="item.value"
/>
</el-select>
</el-form-item>
<el-form-item>
<el-button type="primary" icon="el-icon-search" size="mini" @click="handleQuery">搜索</el-button>
<el-button icon="el-icon-refresh" size="mini" @click="resetQuery">重置</el-button>
@@ -367,6 +374,8 @@ export default {
// 查看对话框
viewDialogVisible: false,
viewForm: null,
// 账号切换提示
accountWarningShown: false,
// 批量上架对话框
publishDialogVisible: false,
publishForm: {
@@ -379,17 +388,25 @@ export default {
};
},
created() {
this.getList();
this.loadERPAccounts();
// 不自动加载列表,等用户选择账号后再加载
},
methods: {
/** 查询闲鱼商品列表 */
getList() {
// 如果没有选择账号,提示用户
if (!this.queryParams.appid) {
this.$modal.msgWarning("请先选择ERP账号");
this.loading = false;
return;
}
this.loading = true;
listErpProduct(this.queryParams).then(response => {
this.erpProductList = response.rows;
this.total = response.total;
this.loading = false;
}).catch(() => {
this.loading = false;
});
},
/** 加载ERP账号列表 */
@@ -404,8 +421,23 @@ export default {
this.usernameList = response.data || [];
});
},
/** 账号变更处理 */
handleAccountChange() {
// 账号切换时清空选中项
this.ids = [];
this.selectedProductIds = [];
this.multiple = true;
this.single = true;
// 重新加载列表
this.queryParams.pageNum = 1;
this.getList();
},
/** 搜索按钮操作 */
handleQuery() {
if (!this.queryParams.appid) {
this.$modal.msgWarning("请先选择ERP账号");
return;
}
this.queryParams.pageNum = 1;
this.getList();
},
@@ -423,9 +455,13 @@ export default {
},
/** 拉取商品按钮操作 */
handlePull() {
if (!this.queryParams.appid) {
this.$modal.msgWarning("请先选择ERP账号");
return;
}
this.pullDialogVisible = true;
this.pullForm = {
appid: this.queryParams.appid || (this.erpAccountList.length > 0 ? this.erpAccountList[0].value : null),
appid: this.queryParams.appid,
productStatus: null,
pageNo: 1,
pageSize: 50
@@ -453,6 +489,10 @@ export default {
},
/** 单个上架 */
handleSinglePublish(row) {
if (!row.appid) {
this.$modal.msgWarning("该商品缺少ERP账号信息无法上架");
return;
}
this.$prompt('请输入闲鱼会员名', '上架商品', {
confirmButtonText: '确定',
cancelButtonText: '取消',
@@ -481,6 +521,10 @@ export default {
},
/** 单个下架 */
handleSingleDownShelf(row) {
if (!row.appid) {
this.$modal.msgWarning("该商品缺少ERP账号信息无法下架");
return;
}
this.$confirm('确定要下架该商品吗?', '提示', {
confirmButtonText: '确定',
cancelButtonText: '取消',
@@ -502,8 +546,23 @@ export default {
this.$modal.msgWarning("请先选择要上架的商品");
return;
}
// 检查选中的商品是否属于同一个账号
const selectedProducts = this.erpProductList.filter(item => this.selectedProductIds.includes(item.productId));
const appids = [...new Set(selectedProducts.map(p => p.appid))];
if (appids.length > 1) {
this.$modal.msgWarning("选中的商品属于不同的ERP账号请分别操作");
return;
}
const accountAppid = appids[0] || this.queryParams.appid;
if (!accountAppid) {
this.$modal.msgWarning("请先选择ERP账号或确保选中的商品有关联的账号");
return;
}
this.publishForm = {
appid: this.queryParams.appid || (this.erpAccountList.length > 0 ? this.erpAccountList[0].value : null),
appid: accountAppid,
userName: null
};
this.publishDialogVisible = true;
@@ -535,6 +594,21 @@ export default {
this.$modal.msgWarning("请先选择要下架的商品");
return;
}
// 检查选中的商品是否属于同一个账号
const selectedProducts = this.erpProductList.filter(item => this.selectedProductIds.includes(item.productId));
const appids = [...new Set(selectedProducts.map(p => p.appid))];
if (appids.length > 1) {
this.$modal.msgWarning("选中的商品属于不同的ERP账号请分别操作");
return;
}
const accountAppid = appids[0] || this.queryParams.appid;
if (!accountAppid) {
this.$modal.msgWarning("请先选择ERP账号或确保选中的商品有关联的账号");
return;
}
this.$confirm('确定要批量下架选中的 ' + this.selectedProductIds.length + ' 个商品吗?', '提示', {
confirmButtonText: '确定',
cancelButtonText: '取消',
@@ -542,7 +616,7 @@ export default {
}).then(() => {
const data = {
productIds: this.selectedProductIds,
appid: this.queryParams.appid || (this.erpAccountList.length > 0 ? this.erpAccountList[0].value : null)
appid: accountAppid
};
batchDownShelf(data).then(response => {
this.$modal.msgSuccess(response.msg || "批量下架成功");
@@ -562,6 +636,10 @@ export default {
},
/** 导出按钮操作 */
handleExport() {
if (!this.queryParams.appid) {
this.$modal.msgWarning("请先选择ERP账号");
return;
}
this.download('jarvis/erpProduct/export', {
...this.queryParams
}, `erpProduct_${new Date().getTime()}.xlsx`)