专家库退订状态+修改列表页数据显示
This commit is contained in:
@@ -19,8 +19,8 @@ const service = axios.create({
|
||||
// baseURL: 'https://submission.tmrjournals.com/', //正式 记得切换
|
||||
// baseURL: 'http://www.tougao.com/', //测试本地 记得切换
|
||||
// baseURL: 'http://192.168.110.110/tougao/public/index.php/',
|
||||
baseURL: '/api', //本地
|
||||
// baseURL: '/', //正式
|
||||
// baseURL: '/api', //本地
|
||||
baseURL: '/', //正式
|
||||
|
||||
});
|
||||
|
||||
|
||||
@@ -310,7 +310,8 @@ const en = {
|
||||
baseInfo: 'Base Information',
|
||||
country: 'Country',
|
||||
affiliation: 'Affiliation',
|
||||
researchAreas: 'Research areas'
|
||||
researchAreas: 'Research areas',
|
||||
unsubscribeStatus: 'Subscription status'
|
||||
},
|
||||
emptyMark: '-',
|
||||
fields: {
|
||||
@@ -327,7 +328,14 @@ const en = {
|
||||
detailCellEmpty: 'N/A',
|
||||
noFieldDetail: 'No publication details for these fields',
|
||||
exportWarn: 'Please select a research area, enter a keyword, or enter a field before exporting.',
|
||||
exportFailed: 'Export failed'
|
||||
exportFailed: 'Export failed',
|
||||
unsubscribeNormal: 'Subscribed',
|
||||
unsubscribeUnsubscribed: 'Unsubscribed',
|
||||
unsubscribeSwitchOn: 'Unsub',
|
||||
unsubscribeSwitchOff: 'Subscribed',
|
||||
unsubscribeMissingId: 'Missing expert ID, unable to switch unsubscribe status',
|
||||
unsubscribeUpdateSuccess: 'Unsubscribe status updated',
|
||||
unsubscribeUpdateFailed: 'Failed to update unsubscribe status'
|
||||
},
|
||||
countryManagement: {
|
||||
title: 'Country Management',
|
||||
|
||||
@@ -299,7 +299,8 @@ const zh = {
|
||||
baseInfo: '基础信息',
|
||||
country: '国家',
|
||||
affiliation: '单位',
|
||||
researchAreas: '研究领域'
|
||||
researchAreas: '研究领域',
|
||||
unsubscribeStatus: '订阅状态'
|
||||
},
|
||||
emptyMark: '-',
|
||||
fields: {
|
||||
@@ -316,7 +317,14 @@ const zh = {
|
||||
detailCellEmpty: '暂无',
|
||||
noFieldDetail: '暂无领域对应的文献信息',
|
||||
exportWarn: '请选择研究领域或输入关键词或领域 field 后再导出。',
|
||||
exportFailed: '导出失败'
|
||||
exportFailed: '导出失败',
|
||||
unsubscribeNormal: '已订阅',
|
||||
unsubscribeUnsubscribed: '已退订',
|
||||
unsubscribeSwitchOn: '退订',
|
||||
unsubscribeSwitchOff: '已订阅',
|
||||
unsubscribeMissingId: '缺少专家 ID,无法切换退订状态',
|
||||
unsubscribeUpdateSuccess: '退订状态更新成功',
|
||||
unsubscribeUpdateFailed: '退订状态更新失败'
|
||||
},
|
||||
countryManagement: {
|
||||
title: '国家信息维护',
|
||||
|
||||
@@ -381,7 +381,7 @@ export default {
|
||||
selectedStyleName: '',
|
||||
|
||||
// 列表数据
|
||||
query: { keyword: '', state: 'all', pageIndex: 1, pageSize: 15 },
|
||||
query: { keyword: '', state: 'all', pageIndex: 1, pageSize: 10 },
|
||||
list: [],
|
||||
total: 0,
|
||||
|
||||
@@ -1035,7 +1035,7 @@ export default {
|
||||
journal_id: String(this.selectedJournalId || ''),
|
||||
factory_id: String(this.routePromotionFactoryId || ''),
|
||||
page: Number(this.query.pageIndex || 1),
|
||||
per_page: Number(this.query.pageSize || 15)
|
||||
per_page: Number(this.query.pageSize || 10)
|
||||
};
|
||||
if (this.query.state !== 'all' && this.query.state !== '' && this.query.state != null) {
|
||||
params.state = String(this.query.state);
|
||||
|
||||
@@ -77,6 +77,32 @@
|
||||
</el-table-column>
|
||||
<el-table-column prop="country" :label="$t('expertDatabase.columns.country')" min-width="100" />
|
||||
<el-table-column prop="affiliation" :label="$t('expertDatabase.columns.affiliation')" min-width="460" />
|
||||
<el-table-column :label="$t('expertDatabase.columns.unsubscribeStatus')" width="180" align="center">
|
||||
<template slot-scope="scope">
|
||||
<div class="unsubscribe-cell">
|
||||
<el-tag
|
||||
size="mini"
|
||||
:type="getUnsubscribeValue(scope.row) === 1 ? 'warning' : 'success'"
|
||||
effect="plain"
|
||||
class="unsubscribe-tag"
|
||||
>
|
||||
{{
|
||||
getUnsubscribeValue(scope.row) === 1
|
||||
? $t('expertDatabase.unsubscribeUnsubscribed')
|
||||
: $t('expertDatabase.unsubscribeNormal')
|
||||
}}
|
||||
</el-tag>
|
||||
<el-switch
|
||||
class="unsubscribe-switch"
|
||||
:value="getUnsubscribeValue(scope.row) === 0"
|
||||
active-color="#13ce66"
|
||||
inactive-color="#dcdfe6"
|
||||
:disabled="switchingExpertId === getExpertId(scope.row)"
|
||||
@change="(val) => handleUnsubscribeSwitch(scope.row, val)"
|
||||
/>
|
||||
</div>
|
||||
</template>
|
||||
</el-table-column>
|
||||
<el-table-column prop="fieldDisplay" :label="$t('expertDatabase.columns.researchAreas')" min-width="260">
|
||||
<template slot-scope="scope">
|
||||
<div v-for="(field, index) in scope.row.fields" :key="index">
|
||||
@@ -158,6 +184,7 @@ export default {
|
||||
total: 0,
|
||||
loading: false,
|
||||
exportLoading: false,
|
||||
switchingExpertId: '',
|
||||
fieldDetailVisible: false,
|
||||
fieldDetailExpert: null,
|
||||
fieldDetailRows: []
|
||||
@@ -223,8 +250,12 @@ export default {
|
||||
this.list = rawList.map((item) => {
|
||||
const fieldArray = item.fields || [];
|
||||
const fieldNames = fieldArray.map((f) => f.field).join(', ');
|
||||
const unsubscribed = this.normalizeUnsubscribeValue(item);
|
||||
return {
|
||||
...item,
|
||||
// 以 unsubscribed 作为页面主判断字段
|
||||
unsubscribed,
|
||||
unsubscribe: unsubscribed,
|
||||
fieldDisplay: fieldNames
|
||||
};
|
||||
});
|
||||
@@ -240,6 +271,57 @@ export default {
|
||||
this.loading = false;
|
||||
}
|
||||
},
|
||||
getExpertId(row) {
|
||||
if (!row) return '';
|
||||
return String(row.expert_id || row.id || row.user_id || row.uid || '').trim();
|
||||
},
|
||||
normalizeUnsubscribeValue(row) {
|
||||
const raw =
|
||||
row && row.unsubscribed != null
|
||||
? row.unsubscribed
|
||||
: row && row.unsubscribe != null
|
||||
? row.unsubscribe
|
||||
: row && row.is_unsubscribe != null
|
||||
? row.is_unsubscribe
|
||||
: 0;
|
||||
return Number(raw) === 1 ? 1 : 0;
|
||||
},
|
||||
getUnsubscribeValue(row) {
|
||||
return this.normalizeUnsubscribeValue(row);
|
||||
},
|
||||
async handleUnsubscribeSwitch(row, checked) {
|
||||
const expertId = this.getExpertId(row);
|
||||
if (!expertId) {
|
||||
this.$message.warning(this.$t('expertDatabase.unsubscribeMissingId'));
|
||||
return;
|
||||
}
|
||||
const oldValue = this.getUnsubscribeValue(row);
|
||||
// switch: ON(checked)=正常(0), OFF=退订(1)
|
||||
const nextValue = checked ? 0 : 1;
|
||||
if (oldValue === nextValue) return;
|
||||
row.unsubscribed = nextValue;
|
||||
row.unsubscribe = nextValue;
|
||||
this.switchingExpertId = expertId;
|
||||
try {
|
||||
const apiUrl = nextValue === 1 ? 'api/expert_manage/unsubscribe' : 'api/expert_manage/resubscribe';
|
||||
const res = await this.$api.post(apiUrl, {
|
||||
expert_ids: String(expertId)
|
||||
});
|
||||
if (res && Number(res.code) === 0) {
|
||||
this.$message.success(this.$t('expertDatabase.unsubscribeUpdateSuccess'));
|
||||
} else {
|
||||
row.unsubscribed = oldValue;
|
||||
row.unsubscribe = oldValue;
|
||||
this.$message.error((res && res.msg) || this.$t('expertDatabase.unsubscribeUpdateFailed'));
|
||||
}
|
||||
} catch (e) {
|
||||
row.unsubscribed = oldValue;
|
||||
row.unsubscribe = oldValue;
|
||||
this.$message.error(this.$t('expertDatabase.unsubscribeUpdateFailed'));
|
||||
} finally {
|
||||
this.switchingExpertId = '';
|
||||
}
|
||||
},
|
||||
handleSearch() {
|
||||
this.query.pageIndex = 1;
|
||||
this.fetchList();
|
||||
@@ -390,5 +472,24 @@ export default {
|
||||
color: #909399;
|
||||
font-size: 13px;
|
||||
}
|
||||
.unsubscribe-cell {
|
||||
width: 100%;
|
||||
display: flex;
|
||||
align-items: center;
|
||||
justify-content: space-between;
|
||||
gap: 10px;
|
||||
padding: 0 4px;
|
||||
}
|
||||
.unsubscribe-tag {
|
||||
min-width: 56px;
|
||||
height: 22px;
|
||||
line-height: 20px;
|
||||
text-align: center;
|
||||
border-radius: 12px;
|
||||
font-size: 12px;
|
||||
}
|
||||
.unsubscribe-switch {
|
||||
flex-shrink: 0;
|
||||
}
|
||||
</style>
|
||||
|
||||
|
||||
Reference in New Issue
Block a user