1
This commit is contained in:
@@ -105,3 +105,47 @@ export function testUserInfo() {
|
||||
})
|
||||
}
|
||||
|
||||
// ==================== H-TF订单自动写入配置接口 ====================
|
||||
|
||||
// 获取自动写入配置
|
||||
export function getAutoWriteConfig() {
|
||||
return request({
|
||||
url: '/jarvis/tencentDoc/config',
|
||||
method: 'get'
|
||||
})
|
||||
}
|
||||
|
||||
// 更新自动写入配置
|
||||
export function updateAutoWriteConfig(data) {
|
||||
return request({
|
||||
url: '/jarvis/tencentDoc/config',
|
||||
method: 'post',
|
||||
data
|
||||
})
|
||||
}
|
||||
|
||||
// 测试配置是否有效
|
||||
export function testAutoWriteConfig() {
|
||||
return request({
|
||||
url: '/jarvis/tencentDoc/config/test',
|
||||
method: 'get'
|
||||
})
|
||||
}
|
||||
|
||||
// 清除自动写入配置
|
||||
export function clearAutoWriteConfig() {
|
||||
return request({
|
||||
url: '/jarvis/tencentDoc/config',
|
||||
method: 'delete'
|
||||
})
|
||||
}
|
||||
|
||||
// 获取文档的工作表列表
|
||||
export function getDocSheetList(fileId) {
|
||||
return request({
|
||||
url: '/jarvis/tencentDoc/config/sheets',
|
||||
method: 'get',
|
||||
params: { fileId }
|
||||
})
|
||||
}
|
||||
|
||||
|
||||
@@ -0,0 +1,350 @@
|
||||
<template>
|
||||
<el-dialog
|
||||
title="H-TF订单自动写入配置"
|
||||
:visible.sync="visible"
|
||||
width="600px"
|
||||
:close-on-click-modal="false"
|
||||
@close="handleClose"
|
||||
>
|
||||
<!-- 配置状态 -->
|
||||
<el-alert
|
||||
v-if="config.isConfigured"
|
||||
title="配置已完成"
|
||||
type="success"
|
||||
:description="config.hint"
|
||||
show-icon
|
||||
:closable="false"
|
||||
style="margin-bottom: 20px;"
|
||||
/>
|
||||
<el-alert
|
||||
v-else
|
||||
title="配置未完成"
|
||||
type="warning"
|
||||
:description="config.hint"
|
||||
show-icon
|
||||
:closable="false"
|
||||
style="margin-bottom: 20px;"
|
||||
/>
|
||||
|
||||
<!-- 授权状态 -->
|
||||
<el-card shadow="never" style="margin-bottom: 20px;">
|
||||
<div slot="header">
|
||||
<span>授权状态</span>
|
||||
</div>
|
||||
<el-form label-width="120px">
|
||||
<el-form-item label="授权状态:">
|
||||
<el-tag v-if="config.hasAccessToken" type="success">{{ config.accessTokenStatus }}</el-tag>
|
||||
<el-tag v-else type="danger">{{ config.accessTokenStatus }}</el-tag>
|
||||
<el-button
|
||||
v-if="!config.hasAccessToken"
|
||||
type="primary"
|
||||
size="mini"
|
||||
style="margin-left: 10px;"
|
||||
@click="handleAuth"
|
||||
>
|
||||
立即授权
|
||||
</el-button>
|
||||
</el-form-item>
|
||||
</el-form>
|
||||
</el-card>
|
||||
|
||||
<!-- 文档配置 -->
|
||||
<el-card shadow="never">
|
||||
<div slot="header">
|
||||
<span>目标文档配置</span>
|
||||
</div>
|
||||
<el-form ref="form" :model="form" :rules="rules" label-width="120px">
|
||||
<el-form-item label="文件ID:" prop="fileId">
|
||||
<el-input
|
||||
v-model="form.fileId"
|
||||
placeholder="请输入腾讯文档的文件ID"
|
||||
clearable
|
||||
>
|
||||
<el-button
|
||||
slot="append"
|
||||
icon="el-icon-search"
|
||||
@click="handleFetchSheets"
|
||||
:disabled="!form.fileId"
|
||||
>
|
||||
获取工作表
|
||||
</el-button>
|
||||
</el-input>
|
||||
<div style="font-size: 12px; color: #909399; margin-top: 5px;">
|
||||
例如:DUW50RUprWXh2TGJK(从腾讯文档URL中获取)
|
||||
</div>
|
||||
</el-form-item>
|
||||
|
||||
<el-form-item label="工作表ID:" prop="sheetId">
|
||||
<el-select
|
||||
v-if="sheetList.length > 0"
|
||||
v-model="form.sheetId"
|
||||
placeholder="请选择工作表"
|
||||
style="width: 100%;"
|
||||
clearable
|
||||
>
|
||||
<el-option
|
||||
v-for="sheet in sheetList"
|
||||
:key="sheet.sheetId"
|
||||
:label="sheet.title"
|
||||
:value="sheet.sheetId"
|
||||
/>
|
||||
</el-select>
|
||||
<el-input
|
||||
v-else
|
||||
v-model="form.sheetId"
|
||||
placeholder="请输入工作表ID或点击'获取工作表'按钮选择"
|
||||
clearable
|
||||
/>
|
||||
<div style="font-size: 12px; color: #909399; margin-top: 5px;">
|
||||
例如:BB08J2
|
||||
</div>
|
||||
</el-form-item>
|
||||
</el-form>
|
||||
</el-card>
|
||||
|
||||
<!-- 操作按钮 -->
|
||||
<div slot="footer">
|
||||
<el-button @click="handleTest" :loading="testLoading" icon="el-icon-setting">
|
||||
测试配置
|
||||
</el-button>
|
||||
<el-button @click="handleClear" :loading="clearLoading" type="danger" plain>
|
||||
清除配置
|
||||
</el-button>
|
||||
<el-button @click="handleClose">取消</el-button>
|
||||
<el-button type="primary" @click="handleSave" :loading="saveLoading">
|
||||
保存配置
|
||||
</el-button>
|
||||
</div>
|
||||
</el-dialog>
|
||||
</template>
|
||||
|
||||
<script>
|
||||
import {
|
||||
getAutoWriteConfig,
|
||||
updateAutoWriteConfig,
|
||||
testAutoWriteConfig,
|
||||
clearAutoWriteConfig,
|
||||
getDocSheetList,
|
||||
getTencentDocAuthUrl
|
||||
} from '@/api/jarvis/tendoc'
|
||||
|
||||
export default {
|
||||
name: 'TencentDocAutoWriteConfig',
|
||||
props: {
|
||||
value: {
|
||||
type: Boolean,
|
||||
default: false
|
||||
}
|
||||
},
|
||||
data() {
|
||||
return {
|
||||
visible: false,
|
||||
config: {
|
||||
hasAccessToken: false,
|
||||
accessTokenStatus: '未授权',
|
||||
fileId: '',
|
||||
sheetId: '',
|
||||
appId: '',
|
||||
apiBaseUrl: '',
|
||||
isConfigured: false,
|
||||
hint: ''
|
||||
},
|
||||
form: {
|
||||
fileId: '',
|
||||
sheetId: ''
|
||||
},
|
||||
rules: {
|
||||
fileId: [
|
||||
{ required: true, message: '请输入文件ID', trigger: 'blur' }
|
||||
],
|
||||
sheetId: [
|
||||
{ required: true, message: '请输入工作表ID', trigger: 'blur' }
|
||||
]
|
||||
},
|
||||
sheetList: [],
|
||||
saveLoading: false,
|
||||
testLoading: false,
|
||||
clearLoading: false
|
||||
}
|
||||
},
|
||||
watch: {
|
||||
value(val) {
|
||||
this.visible = val
|
||||
if (val) {
|
||||
this.loadConfig()
|
||||
}
|
||||
},
|
||||
visible(val) {
|
||||
this.$emit('input', val)
|
||||
}
|
||||
},
|
||||
methods: {
|
||||
/** 加载当前配置 */
|
||||
async loadConfig() {
|
||||
try {
|
||||
const res = await getAutoWriteConfig()
|
||||
if (res.code === 200 && res.data) {
|
||||
this.config = res.data
|
||||
this.form.fileId = res.data.fileId || ''
|
||||
this.form.sheetId = res.data.sheetId || ''
|
||||
}
|
||||
} catch (e) {
|
||||
this.$message.error('加载配置失败:' + (e.message || '未知错误'))
|
||||
}
|
||||
},
|
||||
|
||||
/** 打开授权页面 */
|
||||
async handleAuth() {
|
||||
try {
|
||||
const res = await getTencentDocAuthUrl()
|
||||
if (res.code !== 200 || !res.data) {
|
||||
this.$message.error('获取授权URL失败')
|
||||
return
|
||||
}
|
||||
|
||||
const authUrl = res.data
|
||||
const width = 600
|
||||
const height = 700
|
||||
const left = (window.screen.width - width) / 2
|
||||
const top = (window.screen.height - height) / 2
|
||||
|
||||
window.open(
|
||||
authUrl,
|
||||
'腾讯文档授权',
|
||||
`width=${width},height=${height},left=${left},top=${top},resizable=yes,scrollbars=yes`
|
||||
)
|
||||
|
||||
this.$message.success('授权页面已打开,请在新窗口中完成授权')
|
||||
|
||||
// 1秒后刷新配置状态
|
||||
setTimeout(() => {
|
||||
this.loadConfig()
|
||||
}, 1000)
|
||||
} catch (e) {
|
||||
this.$message.error('打开授权页面失败:' + (e.message || '未知错误'))
|
||||
}
|
||||
},
|
||||
|
||||
/** 获取工作表列表 */
|
||||
async handleFetchSheets() {
|
||||
if (!this.form.fileId) {
|
||||
this.$message.warning('请先输入文件ID')
|
||||
return
|
||||
}
|
||||
|
||||
try {
|
||||
this.$message.info('正在获取工作表列表...')
|
||||
const res = await getDocSheetList(this.form.fileId)
|
||||
|
||||
if (res.code === 200 && res.data && res.data.sheets) {
|
||||
this.sheetList = res.data.sheets
|
||||
this.$message.success(`获取成功,共 ${this.sheetList.length} 个工作表`)
|
||||
} else {
|
||||
this.$message.error('获取工作表列表失败:' + (res.msg || '未知错误'))
|
||||
}
|
||||
} catch (e) {
|
||||
this.$message.error('获取工作表列表失败:' + (e.message || '未知错误'))
|
||||
}
|
||||
},
|
||||
|
||||
/** 保存配置 */
|
||||
handleSave() {
|
||||
this.$refs.form.validate(async valid => {
|
||||
if (!valid) {
|
||||
return
|
||||
}
|
||||
|
||||
this.saveLoading = true
|
||||
try {
|
||||
const res = await updateAutoWriteConfig({
|
||||
fileId: this.form.fileId,
|
||||
sheetId: this.form.sheetId
|
||||
})
|
||||
|
||||
if (res.code === 200) {
|
||||
this.$message.success('配置保存成功')
|
||||
this.loadConfig() // 重新加载配置
|
||||
this.$emit('config-updated')
|
||||
} else {
|
||||
this.$message.error('保存失败:' + (res.msg || '未知错误'))
|
||||
}
|
||||
} catch (e) {
|
||||
this.$message.error('保存失败:' + (e.message || '未知错误'))
|
||||
} finally {
|
||||
this.saveLoading = false
|
||||
}
|
||||
})
|
||||
},
|
||||
|
||||
/** 测试配置 */
|
||||
async handleTest() {
|
||||
this.testLoading = true
|
||||
try {
|
||||
const res = await testAutoWriteConfig()
|
||||
|
||||
if (res.code === 200) {
|
||||
this.$alert(
|
||||
'<pre style="text-align: left; max-height: 400px; overflow: auto;">' +
|
||||
JSON.stringify(res.data, null, 2) +
|
||||
'</pre>',
|
||||
'测试成功',
|
||||
{
|
||||
dangerouslyUseHTMLString: true,
|
||||
confirmButtonText: '确定',
|
||||
type: 'success'
|
||||
}
|
||||
)
|
||||
} else {
|
||||
this.$message.error('测试失败:' + (res.msg || '未知错误'))
|
||||
}
|
||||
} catch (e) {
|
||||
this.$message.error('测试失败:' + (e.message || '未知错误'))
|
||||
} finally {
|
||||
this.testLoading = false
|
||||
}
|
||||
},
|
||||
|
||||
/** 清除配置 */
|
||||
async handleClear() {
|
||||
try {
|
||||
await this.$confirm('确定要清除配置吗?这不会清除授权令牌。', '提示', {
|
||||
type: 'warning'
|
||||
})
|
||||
|
||||
this.clearLoading = true
|
||||
const res = await clearAutoWriteConfig()
|
||||
|
||||
if (res.code === 200) {
|
||||
this.$message.success('配置已清除')
|
||||
this.form.fileId = ''
|
||||
this.form.sheetId = ''
|
||||
this.sheetList = []
|
||||
this.loadConfig()
|
||||
this.$emit('config-updated')
|
||||
} else {
|
||||
this.$message.error('清除失败:' + (res.msg || '未知错误'))
|
||||
}
|
||||
} catch (e) {
|
||||
if (e !== 'cancel') {
|
||||
this.$message.error('清除失败:' + (e.message || '未知错误'))
|
||||
}
|
||||
} finally {
|
||||
this.clearLoading = false
|
||||
}
|
||||
},
|
||||
|
||||
/** 关闭对话框 */
|
||||
handleClose() {
|
||||
this.visible = false
|
||||
this.sheetList = []
|
||||
}
|
||||
}
|
||||
}
|
||||
</script>
|
||||
|
||||
<style scoped>
|
||||
.el-card {
|
||||
border: 1px solid #EBEEF5;
|
||||
}
|
||||
</style>
|
||||
|
||||
@@ -44,6 +44,7 @@
|
||||
<el-button type="primary" size="small" icon="el-icon-search" @click="handleQuery">搜索</el-button>
|
||||
<el-button size="small" icon="el-icon-refresh" @click="resetQuery">重置</el-button>
|
||||
<el-button type="warning" size="small" icon="el-icon-download" @click="handleExport" v-hasPermi="['system:jdorder:export']">导出</el-button>
|
||||
<el-button type="success" size="small" icon="el-icon-setting" @click="showAutoWriteConfig = true" title="配置H-TF订单自动写入腾讯文档">H-TF自动写入配置</el-button>
|
||||
<el-button type="info" size="small" icon="el-icon-user" @click="handleTestUserInfo" title="测试腾讯文档用户信息接口">测试用户信息</el-button>
|
||||
</el-form-item>
|
||||
</el-form>
|
||||
@@ -347,6 +348,9 @@
|
||||
</el-button>
|
||||
</div>
|
||||
</el-dialog>
|
||||
|
||||
<!-- H-TF订单自动写入配置 -->
|
||||
<tencent-doc-auto-write-config v-model="showAutoWriteConfig" @config-updated="handleAutoConfigUpdated" />
|
||||
</div>
|
||||
</template>
|
||||
|
||||
@@ -354,11 +358,13 @@
|
||||
import { listJDOrders, updateJDOrder, delJDOrder, fetchLogisticsManually } from '@/api/system/jdorder'
|
||||
import { fillLogisticsByOrderNo, getTokenStatus, getTencentDocAuthUrl, testUserInfo } from '@/api/jarvis/tendoc'
|
||||
import ListLayout from '@/components/ListLayout'
|
||||
import TencentDocAutoWriteConfig from './components/TencentDocAutoWriteConfig'
|
||||
|
||||
export default {
|
||||
name: 'JDOrderList',
|
||||
components: {
|
||||
ListLayout
|
||||
ListLayout,
|
||||
TencentDocAutoWriteConfig
|
||||
},
|
||||
data() {
|
||||
return {
|
||||
@@ -396,6 +402,8 @@ export default {
|
||||
currentOrder: null,
|
||||
tokenValid: false,
|
||||
tokenStatusChecked: false,
|
||||
// H-TF订单自动写入配置
|
||||
showAutoWriteConfig: false,
|
||||
// 获取物流信息对话框
|
||||
fetchLogisticsDialogVisible: false,
|
||||
fetchLogisticsLoading: false,
|
||||
@@ -894,6 +902,11 @@ export default {
|
||||
|
||||
const resultText = JSON.stringify(this.fetchLogisticsResult, null, 2)
|
||||
this.copyToClipboard(resultText)
|
||||
},
|
||||
|
||||
/** H-TF订单自动写入配置更新后的回调 */
|
||||
handleAutoConfigUpdated() {
|
||||
this.$message.success('H-TF订单自动写入配置已更新')
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user