This commit is contained in:
van
2026-11-14 16:32:28 +08:00
parent 7d4f06f3c1
commit 00c2003f8a
+27 -76
View File
@@ -55,7 +55,6 @@
<el-form-item v-if="!expanded">
<el-button type="primary" icon="el-icon-search" size="small" @click="handleJdQuery">搜索</el-button>
<el-button icon="el-icon-refresh" size="small" @click="resetJdQuery">重置</el-button>
<el-button type="warning" icon="el-icon-upload2" size="small" :loading="jdFetchLoading" @click="handleJdFetchComments">获取评论</el-button>
<el-button type="success" icon="el-icon-download" size="small" @click="handleJdExport">导出</el-button>
</el-form-item>
</el-form>
@@ -72,7 +71,6 @@
<!-- 桌面端按钮组 -->
<div class="desktop-action-buttons desktop-only">
<el-button type="warning" icon="el-icon-upload2" size="small" :loading="jdFetchLoading" @click="handleJdFetchComments">获取评论</el-button>
<el-button type="success" icon="el-icon-download" size="small" @click="handleJdExport">导出</el-button>
</div>
@@ -186,7 +184,6 @@
<el-form-item v-if="!expanded">
<el-button type="primary" icon="el-icon-search" size="small" @click="handleTbQuery">搜索</el-button>
<el-button icon="el-icon-refresh" size="small" @click="resetTbQuery">重置</el-button>
<el-button type="warning" icon="el-icon-upload2" size="small" :loading="tbFetchLoading" @click="handleTbFetchComments">获取评论</el-button>
<el-button type="success" icon="el-icon-download" size="small" @click="handleTbExport">导出</el-button>
</el-form-item>
</el-form>
@@ -203,7 +200,6 @@
<!-- 桌面端按钮组 -->
<div class="desktop-action-buttons desktop-only">
<el-button type="warning" icon="el-icon-upload2" size="small" :loading="tbFetchLoading" @click="handleTbFetchComments">获取评论</el-button>
<el-button type="success" icon="el-icon-download" size="small" @click="handleTbExport">导出</el-button>
</div>
@@ -314,19 +310,6 @@
/>
</template>
</el-table-column>
<el-table-column label="操作" width="120" align="center" fixed="right">
<template slot-scope="scope">
<el-button
v-if="scope.row.source === '京东评论'"
type="warning"
size="mini"
icon="el-icon-upload2"
:loading="statFetchLoading"
@click="handleStatFetchComments(scope.row)"
>获取评论</el-button>
<span v-else>-</span>
</template>
</el-table-column>
</el-table>
</div>
</el-tab-pane>
@@ -360,8 +343,15 @@
<el-table :data="mapTableRows" border>
<el-table-column :label="mapKeyLabel" prop="key" min-width="220" />
<el-table-column :label="mapValueLabel" prop="value" min-width="220" />
<el-table-column label="操作" align="center" width="180" fixed="right">
<el-table-column label="操作" align="center" width="260" fixed="right">
<template slot-scope="scope">
<el-button
size="mini"
type="warning"
icon="el-icon-upload2"
:loading="mapFetchKey === mapSource + ':' + scope.row.key"
@click="handleMapFetchComments(scope.row)"
>获取评论</el-button>
<el-button size="mini" type="primary" @click="openMapDialog(scope.row)">编辑</el-button>
<el-button size="mini" type="danger" @click="handleMapDelete(scope.row)">删除</el-button>
</template>
@@ -459,12 +449,9 @@ export default {
// 图片查看
imageDialogVisible: false,
imageList: [],
// 获取评论 loading
jdFetchLoading: false,
tbFetchLoading: false,
statFetchLoading: false,
// 商品ID映射
mapSource: 'jd',
mapFetchKey: '',
mapKeyword: '',
mapDialogVisible: false,
mapDialogTitle: '新增商品ID',
@@ -489,13 +476,11 @@ export default {
},
jdActionButtons() {
return [
{ key: 'fetchComments', label: '获取评论', type: 'warning', icon: 'el-icon-upload2', handler: () => this.handleJdFetchComments(), disabled: this.jdFetchLoading },
{ key: 'export', label: '导出', type: 'success', icon: 'el-icon-download', handler: () => this.handleJdExport(), disabled: false }
]
},
tbActionButtons() {
return [
{ key: 'fetchComments', label: '获取评论', type: 'warning', icon: 'el-icon-upload2', handler: () => this.handleTbFetchComments(), disabled: this.tbFetchLoading },
{ key: 'export', label: '导出', type: 'success', icon: 'el-icon-download', handler: () => this.handleTbExport(), disabled: false }
]
},
@@ -571,41 +556,6 @@ export default {
...this.jdQueryParams
}, `jd_comment_${new Date().getTime()}.xlsx`)
},
/** 统计信息表格:仅京东商品可点击,用该行商品ID 调用获取评论 */
handleStatFetchComments(row) {
if (row.source !== '京东评论') return
const productId = (row.productId || '').toString().trim()
if (!productId) {
this.$modal.msgWarning('商品ID为空')
return
}
this.statFetchLoading = true
fetchComments(productId).then(() => {
this.$modal.msgSuccess('获取评论请求已发送')
this.getStatistics()
}).catch(e => {
this.$modal.msgError(e && (e.message || e.msg) || '获取评论失败')
}).finally(() => {
this.statFetchLoading = false
})
},
/** 京东:调用获取评论接口,使用商品ID(SKU) 作为 product_id */
handleJdFetchComments() {
const productId = (this.jdQueryParams.productId || '').toString().trim()
if (!productId) {
this.$modal.msgWarning('请先输入商品ID(SKU)')
return
}
this.jdFetchLoading = true
fetchComments(productId).then(() => {
this.$modal.msgSuccess('获取评论请求已发送')
this.getJdList()
}).catch(e => {
this.$modal.msgError(e && (e.message || e.msg) || '获取评论失败')
}).finally(() => {
this.jdFetchLoading = false
})
},
// 淘宝评论相关
getTbList() {
this.tbLoading = true
@@ -647,23 +597,6 @@ export default {
...this.tbQueryParams
}, `tb_comment_${new Date().getTime()}.xlsx`)
},
/** 淘宝:调用获取评论接口,使用商品ID(SKU) 作为 product_id */
handleTbFetchComments() {
const productId = (this.tbQueryParams.productId || '').toString().trim()
if (!productId) {
this.$modal.msgWarning('请先输入商品ID(SKU)')
return
}
this.tbFetchLoading = true
fetchComments(productId).then(() => {
this.$modal.msgSuccess('获取评论请求已发送')
this.getTbList()
}).catch(e => {
this.$modal.msgError(e && (e.message || e.msg) || '获取评论失败')
}).finally(() => {
this.tbFetchLoading = false
})
},
// 统计信息相关
getStatistics() {
this.statLoading = true
@@ -736,6 +669,24 @@ export default {
})
})
},
handleMapFetchComments(row) {
const productId = (row.value || '').toString().trim()
if (!productId) {
this.$modal.msgWarning(this.mapValueLabel + '为空')
return
}
const loadingKey = this.mapSource + ':' + row.key
this.mapFetchKey = loadingKey
fetchComments(productId).then(() => {
this.$modal.msgSuccess('获取评论请求已发送')
}).catch(e => {
this.$modal.msgError(e && (e.message || e.msg) || '获取评论失败')
}).finally(() => {
if (this.mapFetchKey === loadingKey) {
this.mapFetchKey = ''
}
})
},
handleMapDelete(row) {
const label = this.mapKeyLabel + '「' + row.key + '」'
this.$modal.confirm('是否确认删除' + label + '?').then(() => {