#feature: some update

This commit is contained in:
2026-08-12 18:00:09 +08:00
parent ba916f5ce1
commit 103340536b
39 changed files with 2916 additions and 227 deletions
@@ -6,7 +6,7 @@
<h3 class="text-lg font-bold text-gray-800">系统设置</h3>
<p class="text-sm text-gray-500">管理本地偏好与服务端全局配置</p>
</div>
<div v-if="jira.loading || configs.loading" class="text-sm text-blue-600 animate-pulse">
<div v-if="jira.loading || configs.loading || erpRequestReport.loading" class="text-sm text-blue-600 animate-pulse">
数据同步中...
</div>
</div>
@@ -86,6 +86,46 @@
</div>
</div>
</div>
<div v-if="isAdmin" class="bg-white rounded-lg shadow-sm border border-gray-200 overflow-hidden">
<div class="bg-gray-50 px-4 py-3 border-b border-gray-200">
<h4 class="font-semibold text-gray-700 text-sm">ERP 请求日报</h4>
</div>
<div class="p-4 space-y-3">
<div>
<label class="block text-sm font-medium text-gray-600 mb-1">钉钉机器人 Token</label>
<input
v-model="erpRequestReport.dingtalkToken"
type="password"
autocomplete="new-password"
class="w-full px-3 py-2 text-sm font-mono border border-gray-300 rounded focus:ring-1 focus:ring-blue-500 focus:border-blue-500"
placeholder="输入新的 access_token"
/>
<p class="mt-1 text-xs text-gray-400">Token 仅用于保存不会在页面中回显保存后需到定时任务启用 ERP 请求日报</p>
</div>
<div class="flex items-center justify-between gap-3">
<span :class="erpRequestReport.configured ? 'text-green-600' : 'text-yellow-600'" class="text-xs">
{{ erpRequestReport.configured ? '已配置 Token' : '未配置 Token' }}
</span>
<button
@click="saveErpRequestReportConfig"
:disabled="erpRequestReport.saving || !erpRequestReport.dingtalkToken.trim()"
class="px-3 py-2 bg-blue-600 text-white text-sm font-medium rounded hover:bg-blue-700 disabled:opacity-50 transition-colors"
>
{{ erpRequestReport.saving ? '保存中...' : '保存 Token' }}
</button>
</div>
<div v-if="erpRequestReport.message" class="text-sm text-green-600 bg-green-50 px-3 py-2 rounded border border-green-100">
{{ erpRequestReport.message }}
</div>
<div v-if="erpRequestReport.error" class="text-sm text-red-600 bg-red-50 px-3 py-2 rounded border border-red-100">
{{ erpRequestReport.error }}
</div>
</div>
</div>
</div>
<!-- Right Column: Database Configs -->
@@ -276,6 +316,15 @@ export default {
description: '',
valueText: ''
}
},
erpRequestReport: {
loading: false,
saving: false,
loadedOnce: false,
configured: false,
dingtalkToken: '',
message: '',
error: ''
}
};
},
@@ -290,13 +339,18 @@ export default {
this.jira.localDefaultQueryUserSaved = savedOverride;
await this.loadServerConfig();
if (this.isAdmin) {
await this.loadConfigs();
await Promise.all([this.loadConfigs(), this.loadErpRequestReportConfig()]);
}
},
watch: {
isAdmin(value) {
if (value && !this.configs.loadedOnce) {
this.loadConfigs();
if (value) {
if (!this.configs.loadedOnce) {
this.loadConfigs();
}
if (!this.erpRequestReport.loadedOnce) {
this.loadErpRequestReportConfig();
}
}
}
},
@@ -397,6 +451,69 @@ export default {
this.configs.loading = false;
}
},
async loadErpRequestReportConfig() {
if (!this.isAdmin) {
return;
}
this.erpRequestReport.loading = true;
this.erpRequestReport.error = '';
try {
const response = await fetch('/api/admin/erp-request-report/config', {
headers: { Accept: 'application/json' }
});
const data = await this.parseJsonResponse(response);
if (!response.ok || !data.success) {
this.erpRequestReport.error = this.getErrorMessage(data, '加载 ERP 请求日报配置失败');
return;
}
this.erpRequestReport.configured = Boolean(data.data.dingtalk_token_configured);
this.erpRequestReport.loadedOnce = true;
} catch (error) {
this.erpRequestReport.error = error.message;
} finally {
this.erpRequestReport.loading = false;
}
},
async saveErpRequestReportConfig() {
if (!this.erpRequestReport.dingtalkToken.trim()) {
return;
}
this.erpRequestReport.saving = true;
this.erpRequestReport.error = '';
this.erpRequestReport.message = '';
try {
const response = await fetch('/api/admin/erp-request-report/config', {
method: 'PUT',
headers: {
'Content-Type': 'application/json',
Accept: 'application/json'
},
body: JSON.stringify({
dingtalk_token: this.erpRequestReport.dingtalkToken.trim()
})
});
const data = await this.parseJsonResponse(response);
if (!response.ok || !data.success) {
this.erpRequestReport.error = this.getErrorMessage(data, '保存 ERP 请求日报配置失败');
return;
}
this.erpRequestReport.configured = Boolean(data.data.dingtalk_token_configured);
this.erpRequestReport.dingtalkToken = '';
this.erpRequestReport.message = data.message || 'Token 已保存';
} catch (error) {
this.erpRequestReport.error = error.message;
} finally {
this.erpRequestReport.saving = false;
}
},
async createConfig() {
if (!this.configs.newConfig.key.trim()) {
this.configs.error = 'key 不能为空';