三方配置管理
This commit is contained in:
54
src/api/lb-third-integration-config.js
Normal file
54
src/api/lb-third-integration-config.js
Normal file
@@ -0,0 +1,54 @@
|
|||||||
|
import request from '@/utils/request'
|
||||||
|
|
||||||
|
export function getLbThirdIntegrationConfigList(params) {
|
||||||
|
return request({
|
||||||
|
url: '/lbThirdIntegrationConfig/list',
|
||||||
|
method: 'get',
|
||||||
|
params
|
||||||
|
})
|
||||||
|
}
|
||||||
|
|
||||||
|
export function getLbThirdIntegrationConfigById(id) {
|
||||||
|
return request({
|
||||||
|
url: `/lbThirdIntegrationConfig/get/${id}`,
|
||||||
|
method: 'get'
|
||||||
|
})
|
||||||
|
}
|
||||||
|
|
||||||
|
export function addLbThirdIntegrationConfig(data) {
|
||||||
|
return request({
|
||||||
|
url: '/lbThirdIntegrationConfig/add',
|
||||||
|
method: 'post',
|
||||||
|
data
|
||||||
|
})
|
||||||
|
}
|
||||||
|
|
||||||
|
export function updateLbThirdIntegrationConfig(data) {
|
||||||
|
return request({
|
||||||
|
url: '/lbThirdIntegrationConfig/update',
|
||||||
|
method: 'put',
|
||||||
|
data
|
||||||
|
})
|
||||||
|
}
|
||||||
|
|
||||||
|
export function deleteLbThirdIntegrationConfig(id) {
|
||||||
|
return request({
|
||||||
|
url: `/lbThirdIntegrationConfig/delete/${id}`,
|
||||||
|
method: 'delete'
|
||||||
|
})
|
||||||
|
}
|
||||||
|
|
||||||
|
export function getLbThirdIntegrationCredential(tenantId) {
|
||||||
|
return request({
|
||||||
|
url: `/lbThirdIntegrationConfig/credential/${tenantId}`,
|
||||||
|
method: 'get'
|
||||||
|
})
|
||||||
|
}
|
||||||
|
|
||||||
|
export function updateLbThirdIntegrationCredential(tenantId, data) {
|
||||||
|
return request({
|
||||||
|
url: `/lbThirdIntegrationConfig/credential/${tenantId}`,
|
||||||
|
method: 'post',
|
||||||
|
data
|
||||||
|
})
|
||||||
|
}
|
||||||
@@ -439,6 +439,12 @@ export const constantRoutes = [
|
|||||||
name: 'LbOrderAddStop',
|
name: 'LbOrderAddStop',
|
||||||
component: () => import('@/views/lb-business/order-add-stop/index'),
|
component: () => import('@/views/lb-business/order-add-stop/index'),
|
||||||
meta: { title: '加单停单', icon: 'el-icon-switch-button' }
|
meta: { title: '加单停单', icon: 'el-icon-switch-button' }
|
||||||
|
},
|
||||||
|
{
|
||||||
|
path: 'config-manage',
|
||||||
|
name: 'LbConfigManage',
|
||||||
|
component: () => import('@/views/lb-business/config-manage/index'),
|
||||||
|
meta: { title: '配置管理', icon: 'el-icon-setting' }
|
||||||
}
|
}
|
||||||
]
|
]
|
||||||
},
|
},
|
||||||
|
|||||||
774
src/views/lb-business/config-manage/index.vue
Normal file
774
src/views/lb-business/config-manage/index.vue
Normal file
@@ -0,0 +1,774 @@
|
|||||||
|
<template>
|
||||||
|
<div class="app-container">
|
||||||
|
<el-card class="filter-container" shadow="never">
|
||||||
|
<el-form :model="queryParams" :inline="true" label-width="90px">
|
||||||
|
<el-form-item label="租户ID">
|
||||||
|
<el-select
|
||||||
|
v-model="queryParams.tenantId"
|
||||||
|
filterable
|
||||||
|
clearable
|
||||||
|
placeholder="请选择租户"
|
||||||
|
style="width: 220px"
|
||||||
|
:loading="tenantLoading"
|
||||||
|
>
|
||||||
|
<el-option
|
||||||
|
v-for="item in tenantOptions"
|
||||||
|
:key="item.value"
|
||||||
|
:label="item.label"
|
||||||
|
:value="item.value"
|
||||||
|
/>
|
||||||
|
</el-select>
|
||||||
|
</el-form-item>
|
||||||
|
<el-form-item label="集成类型">
|
||||||
|
<el-input v-model="queryParams.providerCode" clearable placeholder="如 HXR_ADMIN" style="width: 160px" />
|
||||||
|
</el-form-item>
|
||||||
|
<el-form-item label="状态">
|
||||||
|
<el-select v-model="queryParams.enabled" clearable placeholder="全部" style="width: 120px">
|
||||||
|
<el-option label="启用" :value="1" />
|
||||||
|
<el-option label="禁用" :value="0" />
|
||||||
|
</el-select>
|
||||||
|
</el-form-item>
|
||||||
|
<el-form-item>
|
||||||
|
<el-button type="primary" icon="el-icon-search" @click="handleQuery">查询</el-button>
|
||||||
|
<el-button icon="el-icon-delete" @click="resetQuery">清空</el-button>
|
||||||
|
</el-form-item>
|
||||||
|
</el-form>
|
||||||
|
</el-card>
|
||||||
|
|
||||||
|
<el-card class="action-container" shadow="never">
|
||||||
|
<el-button type="primary" icon="el-icon-plus" @click="handleAdd">新增配置</el-button>
|
||||||
|
</el-card>
|
||||||
|
|
||||||
|
<el-card class="table-container" shadow="never">
|
||||||
|
<el-table v-loading="loading" :data="list" style="width: 100%">
|
||||||
|
<el-table-column label="租户ID" prop="tenantId" min-width="180" show-overflow-tooltip />
|
||||||
|
<el-table-column label="集成类型" prop="providerCode" min-width="120" show-overflow-tooltip />
|
||||||
|
<el-table-column label="状态" prop="enabled" width="80" align="center">
|
||||||
|
<template slot-scope="scope">
|
||||||
|
<el-tag :type="scope.row.enabled === 1 ? 'success' : 'info'" size="small">
|
||||||
|
{{ scope.row.enabled === 1 ? '启用' : '禁用' }}
|
||||||
|
</el-tag>
|
||||||
|
</template>
|
||||||
|
</el-table-column>
|
||||||
|
<el-table-column label="后台域名" prop="adminBaseUrl" min-width="160" show-overflow-tooltip />
|
||||||
|
<el-table-column label="Web域名" prop="webBaseUrl" min-width="160" show-overflow-tooltip />
|
||||||
|
<el-table-column label="凭证" min-width="200">
|
||||||
|
<template slot-scope="scope">
|
||||||
|
<el-tag v-if="scope.row.cookieConfigured" size="mini" type="success">Cookie</el-tag>
|
||||||
|
<el-tag v-if="scope.row.phpsidConfigured" size="mini" type="success">PHPSID</el-tag>
|
||||||
|
<el-tag v-if="scope.row.goodsApiTokenConfigured" size="mini" type="success">Token</el-tag>
|
||||||
|
<el-tag v-if="scope.row.goodsApiAppStrConfigured" size="mini" type="success">AppStr</el-tag>
|
||||||
|
<span v-if="!hasAnyCredential(scope.row)" class="text-muted">未配置</span>
|
||||||
|
</template>
|
||||||
|
</el-table-column>
|
||||||
|
<el-table-column label="最近探测" min-width="150">
|
||||||
|
<template slot-scope="scope">
|
||||||
|
<template v-if="scope.row.lastVerifiedTime">
|
||||||
|
<el-tag :type="scope.row.lastVerifiedOk === 1 ? 'success' : 'danger'" size="mini">
|
||||||
|
{{ scope.row.lastVerifiedOk === 1 ? '成功' : '失败' }}
|
||||||
|
</el-tag>
|
||||||
|
<span class="verify-time">{{ formatDateTime(scope.row.lastVerifiedTime) }}</span>
|
||||||
|
</template>
|
||||||
|
<span v-else class="text-muted">-</span>
|
||||||
|
</template>
|
||||||
|
</el-table-column>
|
||||||
|
<el-table-column label="更新时间" prop="updateTime" min-width="160">
|
||||||
|
<template slot-scope="scope">
|
||||||
|
{{ formatDateTime(scope.row.updateTime) }}
|
||||||
|
</template>
|
||||||
|
</el-table-column>
|
||||||
|
<el-table-column label="操作" fixed="right" width="220">
|
||||||
|
<template slot-scope="scope">
|
||||||
|
<el-button type="text" @click="handleEdit(scope.row)">编辑</el-button>
|
||||||
|
<el-button type="text" @click="handleCredential(scope.row)">凭证</el-button>
|
||||||
|
<el-button type="text" style="color:#F56C6C;" @click="handleDelete(scope.row)">删除</el-button>
|
||||||
|
</template>
|
||||||
|
</el-table-column>
|
||||||
|
</el-table>
|
||||||
|
|
||||||
|
<el-pagination
|
||||||
|
:current-page="queryParams.current"
|
||||||
|
:page-size="queryParams.size"
|
||||||
|
:page-sizes="[10, 20, 50, 100]"
|
||||||
|
:total="total"
|
||||||
|
layout="total, sizes, prev, pager, next, jumper"
|
||||||
|
@size-change="handleSizeChange"
|
||||||
|
@current-change="handleCurrentChange"
|
||||||
|
/>
|
||||||
|
</el-card>
|
||||||
|
|
||||||
|
<el-dialog
|
||||||
|
:title="dialogTitle"
|
||||||
|
:visible.sync="dialogVisible"
|
||||||
|
width="860px"
|
||||||
|
top="5vh"
|
||||||
|
@close="resetForm"
|
||||||
|
>
|
||||||
|
<el-form ref="dataForm" :model="form" :rules="formRules" label-width="130px">
|
||||||
|
<el-tabs v-model="activeTab">
|
||||||
|
<el-tab-pane label="基本信息" name="basic">
|
||||||
|
<el-form-item label="租户ID" prop="tenantId">
|
||||||
|
<el-select
|
||||||
|
v-model="form.tenantId"
|
||||||
|
filterable
|
||||||
|
clearable
|
||||||
|
placeholder="请选择租户"
|
||||||
|
style="width: 100%"
|
||||||
|
:disabled="isEdit"
|
||||||
|
:loading="tenantLoading"
|
||||||
|
>
|
||||||
|
<el-option
|
||||||
|
v-for="item in tenantOptions"
|
||||||
|
:key="item.value"
|
||||||
|
:label="item.label"
|
||||||
|
:value="item.value"
|
||||||
|
/>
|
||||||
|
</el-select>
|
||||||
|
</el-form-item>
|
||||||
|
<el-form-item label="集成类型" prop="providerCode">
|
||||||
|
<el-input v-model="form.providerCode" placeholder="如 HXR_ADMIN" />
|
||||||
|
</el-form-item>
|
||||||
|
<el-form-item label="总开关" prop="enabled">
|
||||||
|
<el-radio-group v-model="form.enabled">
|
||||||
|
<el-radio :label="1">启用</el-radio>
|
||||||
|
<el-radio :label="0">禁用</el-radio>
|
||||||
|
</el-radio-group>
|
||||||
|
</el-form-item>
|
||||||
|
<el-form-item label="鉴权类型">
|
||||||
|
<el-input v-model="form.authType" placeholder="Admin 鉴权类型" />
|
||||||
|
</el-form-item>
|
||||||
|
<el-form-item label="备注">
|
||||||
|
<el-input v-model="form.remark" type="textarea" :rows="2" placeholder="备注" />
|
||||||
|
</el-form-item>
|
||||||
|
</el-tab-pane>
|
||||||
|
|
||||||
|
<el-tab-pane label="域名与路径" name="urls">
|
||||||
|
<el-form-item label="后台管理域名">
|
||||||
|
<el-input v-model="form.adminBaseUrl" placeholder="https://admin.example.com" />
|
||||||
|
</el-form-item>
|
||||||
|
<el-form-item label="前端 Web 域名">
|
||||||
|
<el-input v-model="form.webBaseUrl" placeholder="https://web.example.com" />
|
||||||
|
</el-form-item>
|
||||||
|
<el-form-item label="订单列表 API">
|
||||||
|
<el-input v-model="form.orderSelectPath" placeholder="/api/order/select" />
|
||||||
|
</el-form-item>
|
||||||
|
<el-form-item label="用户列表 API">
|
||||||
|
<el-input v-model="form.userSelectPath" placeholder="/api/user/select" />
|
||||||
|
</el-form-item>
|
||||||
|
<el-form-item label="用户更新 API">
|
||||||
|
<el-input v-model="form.userUpdatePath" placeholder="/api/user/update" />
|
||||||
|
</el-form-item>
|
||||||
|
<el-form-item label="货品列表 API">
|
||||||
|
<el-input v-model="form.goodsApiPath" placeholder="/api/goods/list" />
|
||||||
|
</el-form-item>
|
||||||
|
<el-form-item label="抢购 API">
|
||||||
|
<el-input v-model="form.buyApiPath" placeholder="/api/goods/buy" />
|
||||||
|
</el-form-item>
|
||||||
|
</el-tab-pane>
|
||||||
|
|
||||||
|
<el-tab-pane label="分页与 Referer" name="limits">
|
||||||
|
<el-form-item label="订单分页 limit">
|
||||||
|
<el-input-number v-model="form.orderPageLimit" :min="1" :max="1000" controls-position="right" style="width: 100%" />
|
||||||
|
</el-form-item>
|
||||||
|
<el-form-item label="用户分页 limit">
|
||||||
|
<el-input-number v-model="form.userPageLimit" :min="1" :max="1000" controls-position="right" style="width: 100%" />
|
||||||
|
</el-form-item>
|
||||||
|
<el-form-item label="货品分页 limit">
|
||||||
|
<el-input-number v-model="form.goodsPageLimit" :min="1" :max="1000" controls-position="right" style="width: 100%" />
|
||||||
|
</el-form-item>
|
||||||
|
<el-form-item label="订单 Referer">
|
||||||
|
<el-input v-model="form.orderReferer" placeholder="订单 Referer" />
|
||||||
|
</el-form-item>
|
||||||
|
<el-form-item label="用户 Referer">
|
||||||
|
<el-input v-model="form.userReferer" placeholder="用户 Referer" />
|
||||||
|
</el-form-item>
|
||||||
|
<el-form-item label="货品 Origin">
|
||||||
|
<el-input v-model="form.goodsApiOrigin" placeholder="货品 Origin" />
|
||||||
|
</el-form-item>
|
||||||
|
<el-form-item label="货品 Referer">
|
||||||
|
<el-input v-model="form.goodsApiReferer" placeholder="货品 Referer" />
|
||||||
|
</el-form-item>
|
||||||
|
</el-tab-pane>
|
||||||
|
|
||||||
|
<el-tab-pane label="定时同步" name="sync">
|
||||||
|
<el-form-item label="同步未寄卖订单">
|
||||||
|
<el-radio-group v-model="form.syncOrderResellEnabled">
|
||||||
|
<el-radio :label="1">启用</el-radio>
|
||||||
|
<el-radio :label="0">禁用</el-radio>
|
||||||
|
</el-radio-group>
|
||||||
|
</el-form-item>
|
||||||
|
<el-form-item label="同步未支付订单">
|
||||||
|
<el-radio-group v-model="form.syncOrderUnpaidEnabled">
|
||||||
|
<el-radio :label="1">启用</el-radio>
|
||||||
|
<el-radio :label="0">禁用</el-radio>
|
||||||
|
</el-radio-group>
|
||||||
|
</el-form-item>
|
||||||
|
<el-form-item label="同步已支付订单">
|
||||||
|
<el-radio-group v-model="form.syncOrderPaidEnabled">
|
||||||
|
<el-radio :label="1">启用</el-radio>
|
||||||
|
<el-radio :label="0">禁用</el-radio>
|
||||||
|
</el-radio-group>
|
||||||
|
</el-form-item>
|
||||||
|
<el-form-item label="同步用户">
|
||||||
|
<el-radio-group v-model="form.syncUserEnabled">
|
||||||
|
<el-radio :label="1">启用</el-radio>
|
||||||
|
<el-radio :label="0">禁用</el-radio>
|
||||||
|
</el-radio-group>
|
||||||
|
</el-form-item>
|
||||||
|
</el-tab-pane>
|
||||||
|
|
||||||
|
<el-tab-pane label="凭证" name="credential">
|
||||||
|
<div v-loading="formCredentialLoading">
|
||||||
|
<el-alert
|
||||||
|
title="填写或修改凭证,明文保存;编辑时留空表示不修改该项"
|
||||||
|
type="info"
|
||||||
|
:closable="false"
|
||||||
|
show-icon
|
||||||
|
style="margin-bottom: 16px"
|
||||||
|
/>
|
||||||
|
<el-form-item v-if="isEdit && form.credentialExpireTime" label="凭证过期时间">
|
||||||
|
<span>{{ formatDateTime(form.credentialExpireTime) }}</span>
|
||||||
|
</el-form-item>
|
||||||
|
<el-form-item label="Cookie">
|
||||||
|
<el-input v-model="form.cookie" type="textarea" :rows="3" placeholder="完整 Cookie" />
|
||||||
|
<el-checkbox v-if="isEdit" v-model="form.clearCookie">清除 Cookie</el-checkbox>
|
||||||
|
</el-form-item>
|
||||||
|
<el-form-item label="PHPSID">
|
||||||
|
<el-input v-model="form.phpsid" placeholder="PHPSID" />
|
||||||
|
<el-checkbox v-if="isEdit" v-model="form.clearPhpsid">清除 PHPSID</el-checkbox>
|
||||||
|
</el-form-item>
|
||||||
|
<el-form-item label="货品 Token">
|
||||||
|
<el-input v-model="form.goodsApiToken" placeholder="货品/抢购 token" />
|
||||||
|
<el-checkbox v-if="isEdit" v-model="form.clearGoodsApiToken">清除 Token</el-checkbox>
|
||||||
|
</el-form-item>
|
||||||
|
<el-form-item label="AppStr">
|
||||||
|
<el-input v-model="form.goodsApiAppStr" placeholder="签名密钥 appStr" />
|
||||||
|
<el-checkbox v-if="isEdit" v-model="form.clearGoodsApiAppStr">清除 AppStr</el-checkbox>
|
||||||
|
</el-form-item>
|
||||||
|
</div>
|
||||||
|
</el-tab-pane>
|
||||||
|
|
||||||
|
<el-tab-pane label="扩展配置" name="extra">
|
||||||
|
<el-form-item label="扩展 JSON">
|
||||||
|
<el-input v-model="form.extraConfig" type="textarea" :rows="8" placeholder='{"key":"value"}' />
|
||||||
|
</el-form-item>
|
||||||
|
</el-tab-pane>
|
||||||
|
</el-tabs>
|
||||||
|
</el-form>
|
||||||
|
<div slot="footer" class="dialog-footer">
|
||||||
|
<el-button @click="dialogVisible = false">取消</el-button>
|
||||||
|
<el-button type="primary" :loading="submitLoading" @click="handleSubmit">确定</el-button>
|
||||||
|
</div>
|
||||||
|
</el-dialog>
|
||||||
|
|
||||||
|
<el-dialog
|
||||||
|
title="凭证管理"
|
||||||
|
:visible.sync="credentialDialogVisible"
|
||||||
|
width="720px"
|
||||||
|
@close="resetCredentialForm"
|
||||||
|
>
|
||||||
|
<div v-loading="credentialLoading">
|
||||||
|
<el-alert
|
||||||
|
v-if="credentialRow"
|
||||||
|
:title="`租户:${credentialRow.tenantId}`"
|
||||||
|
type="info"
|
||||||
|
:closable="false"
|
||||||
|
show-icon
|
||||||
|
style="margin-bottom: 16px"
|
||||||
|
/>
|
||||||
|
<el-form ref="credentialFormRef" :model="credentialForm" label-width="130px">
|
||||||
|
<el-form-item label="Cookie">
|
||||||
|
<el-input v-model="credentialForm.cookie" type="textarea" :rows="3" placeholder="留空则不修改" />
|
||||||
|
<el-checkbox v-model="credentialForm.clearCookie">清除 Cookie</el-checkbox>
|
||||||
|
</el-form-item>
|
||||||
|
<el-form-item label="PHPSID">
|
||||||
|
<el-input v-model="credentialForm.phpsid" placeholder="留空则不修改" />
|
||||||
|
<el-checkbox v-model="credentialForm.clearPhpsid">清除 PHPSID</el-checkbox>
|
||||||
|
</el-form-item>
|
||||||
|
<el-form-item label="货品 Token">
|
||||||
|
<el-input v-model="credentialForm.goodsApiToken" placeholder="留空则不修改" />
|
||||||
|
<el-checkbox v-model="credentialForm.clearGoodsApiToken">清除 Token</el-checkbox>
|
||||||
|
</el-form-item>
|
||||||
|
<el-form-item label="AppStr">
|
||||||
|
<el-input v-model="credentialForm.goodsApiAppStr" placeholder="留空则不修改" />
|
||||||
|
<el-checkbox v-model="credentialForm.clearGoodsApiAppStr">清除 AppStr</el-checkbox>
|
||||||
|
</el-form-item>
|
||||||
|
<el-form-item label="凭证过期时间">
|
||||||
|
<span>{{ formatDateTime(credentialForm.credentialExpireTime) }}</span>
|
||||||
|
</el-form-item>
|
||||||
|
</el-form>
|
||||||
|
</div>
|
||||||
|
<div slot="footer" class="dialog-footer">
|
||||||
|
<el-button @click="credentialDialogVisible = false">取消</el-button>
|
||||||
|
<el-button type="primary" :loading="credentialSubmitLoading" @click="handleCredentialSubmit">保存凭证</el-button>
|
||||||
|
</div>
|
||||||
|
</el-dialog>
|
||||||
|
</div>
|
||||||
|
</template>
|
||||||
|
|
||||||
|
<script>
|
||||||
|
import {
|
||||||
|
addLbThirdIntegrationConfig,
|
||||||
|
deleteLbThirdIntegrationConfig,
|
||||||
|
getLbThirdIntegrationConfigList,
|
||||||
|
getLbThirdIntegrationCredential,
|
||||||
|
updateLbThirdIntegrationConfig,
|
||||||
|
updateLbThirdIntegrationCredential
|
||||||
|
} from '@/api/lb-third-integration-config'
|
||||||
|
import { getAllTenantList } from '@/api/tenant'
|
||||||
|
import { getBusinessHeaders } from '@/utils/business-headers'
|
||||||
|
|
||||||
|
const DEFAULT_FORM = () => ({
|
||||||
|
id: '',
|
||||||
|
tenantId: '',
|
||||||
|
providerCode: 'HXR_ADMIN',
|
||||||
|
enabled: 1,
|
||||||
|
adminBaseUrl: '',
|
||||||
|
webBaseUrl: '',
|
||||||
|
orderSelectPath: '',
|
||||||
|
userSelectPath: '',
|
||||||
|
userUpdatePath: '',
|
||||||
|
goodsApiPath: '',
|
||||||
|
buyApiPath: '',
|
||||||
|
orderPageLimit: undefined,
|
||||||
|
userPageLimit: undefined,
|
||||||
|
goodsPageLimit: undefined,
|
||||||
|
orderReferer: '',
|
||||||
|
userReferer: '',
|
||||||
|
goodsApiOrigin: '',
|
||||||
|
goodsApiReferer: '',
|
||||||
|
authType: '',
|
||||||
|
syncOrderResellEnabled: 0,
|
||||||
|
syncOrderUnpaidEnabled: 0,
|
||||||
|
syncOrderPaidEnabled: 0,
|
||||||
|
syncUserEnabled: 0,
|
||||||
|
extraConfig: '',
|
||||||
|
remark: '',
|
||||||
|
cookie: '',
|
||||||
|
phpsid: '',
|
||||||
|
goodsApiToken: '',
|
||||||
|
goodsApiAppStr: '',
|
||||||
|
credentialExpireTime: '',
|
||||||
|
clearCookie: false,
|
||||||
|
clearPhpsid: false,
|
||||||
|
clearGoodsApiToken: false,
|
||||||
|
clearGoodsApiAppStr: false
|
||||||
|
})
|
||||||
|
|
||||||
|
export default {
|
||||||
|
name: 'LbConfigManage',
|
||||||
|
data() {
|
||||||
|
return {
|
||||||
|
loading: false,
|
||||||
|
submitLoading: false,
|
||||||
|
tenantLoading: false,
|
||||||
|
credentialLoading: false,
|
||||||
|
credentialSubmitLoading: false,
|
||||||
|
formCredentialLoading: false,
|
||||||
|
originalCredential: {
|
||||||
|
cookie: '',
|
||||||
|
phpsid: '',
|
||||||
|
goodsApiToken: '',
|
||||||
|
goodsApiAppStr: ''
|
||||||
|
},
|
||||||
|
list: [],
|
||||||
|
total: 0,
|
||||||
|
tenantOptions: [],
|
||||||
|
dialogVisible: false,
|
||||||
|
credentialDialogVisible: false,
|
||||||
|
dialogTitle: '',
|
||||||
|
isEdit: false,
|
||||||
|
activeTab: 'basic',
|
||||||
|
credentialRow: null,
|
||||||
|
queryParams: {
|
||||||
|
current: 1,
|
||||||
|
size: 10,
|
||||||
|
tenantId: '',
|
||||||
|
providerCode: '',
|
||||||
|
enabled: undefined
|
||||||
|
},
|
||||||
|
form: DEFAULT_FORM(),
|
||||||
|
credentialForm: {
|
||||||
|
credentialExpireTime: '',
|
||||||
|
cookie: '',
|
||||||
|
phpsid: '',
|
||||||
|
goodsApiToken: '',
|
||||||
|
goodsApiAppStr: '',
|
||||||
|
clearCookie: false,
|
||||||
|
clearPhpsid: false,
|
||||||
|
clearGoodsApiToken: false,
|
||||||
|
clearGoodsApiAppStr: false
|
||||||
|
},
|
||||||
|
formRules: {
|
||||||
|
tenantId: [{ required: true, message: '请选择租户', trigger: 'change' }],
|
||||||
|
providerCode: [{ required: true, message: '请输入集成类型', trigger: 'blur' }],
|
||||||
|
enabled: [{ required: true, message: '请选择状态', trigger: 'change' }]
|
||||||
|
}
|
||||||
|
}
|
||||||
|
},
|
||||||
|
created() {
|
||||||
|
this.getTenantOptions()
|
||||||
|
this.initDefaultTenantFilter()
|
||||||
|
this.fetchList()
|
||||||
|
},
|
||||||
|
methods: {
|
||||||
|
getTenantIdFromBusinessHeaders() {
|
||||||
|
const headers = getBusinessHeaders()
|
||||||
|
const value = headers && headers['X-Tenant-Id']
|
||||||
|
return value ? String(value).trim() : ''
|
||||||
|
},
|
||||||
|
initDefaultTenantFilter() {
|
||||||
|
const tenantId = this.getTenantIdFromBusinessHeaders()
|
||||||
|
if (tenantId) this.queryParams.tenantId = tenantId
|
||||||
|
},
|
||||||
|
getTenantOptions() {
|
||||||
|
this.tenantLoading = true
|
||||||
|
getAllTenantList()
|
||||||
|
.then((response) => {
|
||||||
|
if (response && (response.code === 20000 || response.code === 200)) {
|
||||||
|
const tenantList = Array.isArray(response.data) ? response.data : (response.data?.data || [])
|
||||||
|
this.tenantOptions = tenantList.map((item) => ({
|
||||||
|
value: item.id,
|
||||||
|
label: item.tenantName ? `${item.tenantName} (${item.tenantCode || '-'})` : (item.tenantCode || item.id)
|
||||||
|
}))
|
||||||
|
} else {
|
||||||
|
this.tenantOptions = []
|
||||||
|
}
|
||||||
|
})
|
||||||
|
.catch(() => {
|
||||||
|
this.tenantOptions = []
|
||||||
|
})
|
||||||
|
.finally(() => {
|
||||||
|
this.tenantLoading = false
|
||||||
|
})
|
||||||
|
},
|
||||||
|
hasAnyCredential(row) {
|
||||||
|
return row.cookieConfigured || row.phpsidConfigured || row.goodsApiTokenConfigured || row.goodsApiAppStrConfigured
|
||||||
|
},
|
||||||
|
fetchList() {
|
||||||
|
this.loading = true
|
||||||
|
getLbThirdIntegrationConfigList(this.buildListParams())
|
||||||
|
.then((res) => {
|
||||||
|
if (res && (res.code === 20000 || res.code === 200 || res.success === true)) {
|
||||||
|
this.list = Array.isArray(res.data) ? res.data : []
|
||||||
|
this.total = typeof res.total === 'number'
|
||||||
|
? res.total
|
||||||
|
: (res.page && typeof res.page.total === 'number' ? res.page.total : this.list.length)
|
||||||
|
} else {
|
||||||
|
this.list = []
|
||||||
|
this.total = 0
|
||||||
|
}
|
||||||
|
})
|
||||||
|
.catch(() => {
|
||||||
|
this.list = []
|
||||||
|
this.total = 0
|
||||||
|
})
|
||||||
|
.finally(() => {
|
||||||
|
this.loading = false
|
||||||
|
})
|
||||||
|
},
|
||||||
|
buildListParams() {
|
||||||
|
const params = {
|
||||||
|
current: this.queryParams.current,
|
||||||
|
size: this.queryParams.size,
|
||||||
|
tenantId: this.queryParams.tenantId || undefined,
|
||||||
|
providerCode: this.queryParams.providerCode || undefined,
|
||||||
|
enabled: this.queryParams.enabled
|
||||||
|
}
|
||||||
|
Object.keys(params).forEach((key) => {
|
||||||
|
if (params[key] === undefined || params[key] === '') delete params[key]
|
||||||
|
})
|
||||||
|
return params
|
||||||
|
},
|
||||||
|
handleQuery() {
|
||||||
|
this.queryParams.current = 1
|
||||||
|
this.fetchList()
|
||||||
|
},
|
||||||
|
resetQuery() {
|
||||||
|
this.queryParams = {
|
||||||
|
current: 1,
|
||||||
|
size: 10,
|
||||||
|
tenantId: '',
|
||||||
|
providerCode: '',
|
||||||
|
enabled: undefined
|
||||||
|
}
|
||||||
|
this.initDefaultTenantFilter()
|
||||||
|
this.fetchList()
|
||||||
|
},
|
||||||
|
handleSizeChange(size) {
|
||||||
|
this.queryParams.size = size
|
||||||
|
this.fetchList()
|
||||||
|
},
|
||||||
|
handleCurrentChange(current) {
|
||||||
|
this.queryParams.current = current
|
||||||
|
this.fetchList()
|
||||||
|
},
|
||||||
|
handleAdd() {
|
||||||
|
this.dialogTitle = '新增第三方集成配置'
|
||||||
|
this.isEdit = false
|
||||||
|
this.activeTab = 'basic'
|
||||||
|
this.resetFormData()
|
||||||
|
const tenantId = this.getTenantIdFromBusinessHeaders()
|
||||||
|
if (tenantId) this.form.tenantId = tenantId
|
||||||
|
this.dialogVisible = true
|
||||||
|
this.$nextTick(() => {
|
||||||
|
this.$refs.dataForm && this.$refs.dataForm.clearValidate()
|
||||||
|
})
|
||||||
|
},
|
||||||
|
handleEdit(row) {
|
||||||
|
this.dialogTitle = '编辑第三方集成配置'
|
||||||
|
this.isEdit = true
|
||||||
|
this.activeTab = 'basic'
|
||||||
|
this.form = {
|
||||||
|
...DEFAULT_FORM(),
|
||||||
|
...this.pickFormFields(row),
|
||||||
|
id: row.id
|
||||||
|
}
|
||||||
|
this.originalCredential = {
|
||||||
|
cookie: '',
|
||||||
|
phpsid: '',
|
||||||
|
goodsApiToken: '',
|
||||||
|
goodsApiAppStr: ''
|
||||||
|
}
|
||||||
|
this.dialogVisible = true
|
||||||
|
this.loadFormCredentials(row.tenantId)
|
||||||
|
this.$nextTick(() => {
|
||||||
|
this.$refs.dataForm && this.$refs.dataForm.clearValidate()
|
||||||
|
})
|
||||||
|
},
|
||||||
|
loadFormCredentials(tenantId) {
|
||||||
|
if (!tenantId) return
|
||||||
|
this.formCredentialLoading = true
|
||||||
|
getLbThirdIntegrationCredential(tenantId)
|
||||||
|
.then((res) => {
|
||||||
|
const data = (res && res.data) || {}
|
||||||
|
const cookie = data.cookie || data.cookiePlain || ''
|
||||||
|
const phpsid = data.phpsid || data.phpsidPlain || ''
|
||||||
|
const goodsApiToken = data.goodsApiToken || data.goodsApiTokenPlain || ''
|
||||||
|
const goodsApiAppStr = data.goodsApiAppStr || data.goodsApiAppStrPlain || ''
|
||||||
|
this.form.cookie = cookie
|
||||||
|
this.form.phpsid = phpsid
|
||||||
|
this.form.goodsApiToken = goodsApiToken
|
||||||
|
this.form.goodsApiAppStr = goodsApiAppStr
|
||||||
|
this.form.credentialExpireTime = data.credentialExpireTime || ''
|
||||||
|
this.originalCredential = {
|
||||||
|
cookie,
|
||||||
|
phpsid,
|
||||||
|
goodsApiToken,
|
||||||
|
goodsApiAppStr
|
||||||
|
}
|
||||||
|
})
|
||||||
|
.finally(() => {
|
||||||
|
this.formCredentialLoading = false
|
||||||
|
})
|
||||||
|
},
|
||||||
|
pickFormFields(row) {
|
||||||
|
const fields = DEFAULT_FORM()
|
||||||
|
Object.keys(fields).forEach((key) => {
|
||||||
|
if (key === 'id') return
|
||||||
|
if (row[key] !== undefined && row[key] !== null) {
|
||||||
|
fields[key] = row[key]
|
||||||
|
}
|
||||||
|
})
|
||||||
|
return fields
|
||||||
|
},
|
||||||
|
handleDelete(row) {
|
||||||
|
this.$confirm('确定删除该第三方集成配置吗?', '提示', {
|
||||||
|
confirmButtonText: '确定',
|
||||||
|
cancelButtonText: '取消',
|
||||||
|
type: 'warning'
|
||||||
|
}).then(() => deleteLbThirdIntegrationConfig(row.id))
|
||||||
|
.then((res) => {
|
||||||
|
this.$message.success((res && res.message) || '删除成功')
|
||||||
|
this.fetchList()
|
||||||
|
})
|
||||||
|
.catch(() => {})
|
||||||
|
},
|
||||||
|
handleSubmit() {
|
||||||
|
this.$refs.dataForm.validate((valid) => {
|
||||||
|
if (!valid) {
|
||||||
|
this.activeTab = 'basic'
|
||||||
|
return
|
||||||
|
}
|
||||||
|
const payload = this.buildPayload()
|
||||||
|
this.submitLoading = true
|
||||||
|
const configReq = this.isEdit ? updateLbThirdIntegrationConfig(payload) : addLbThirdIntegrationConfig(payload)
|
||||||
|
configReq
|
||||||
|
.then((res) => {
|
||||||
|
this.$message.success((res && res.message) || (this.isEdit ? '更新成功' : '新增成功'))
|
||||||
|
this.dialogVisible = false
|
||||||
|
this.fetchList()
|
||||||
|
})
|
||||||
|
.finally(() => {
|
||||||
|
this.submitLoading = false
|
||||||
|
})
|
||||||
|
})
|
||||||
|
},
|
||||||
|
buildPayload() {
|
||||||
|
const payload = { ...this.form }
|
||||||
|
const credentialKeys = [
|
||||||
|
'cookie', 'phpsid', 'goodsApiToken', 'goodsApiAppStr',
|
||||||
|
'credentialExpireTime',
|
||||||
|
'clearCookie', 'clearPhpsid', 'clearGoodsApiToken', 'clearGoodsApiAppStr'
|
||||||
|
]
|
||||||
|
credentialKeys.forEach((key) => delete payload[key])
|
||||||
|
|
||||||
|
this.appendChangedCredential(payload)
|
||||||
|
if (this.isEdit) {
|
||||||
|
if (this.form.clearCookie) payload.clearCookie = true
|
||||||
|
if (this.form.clearPhpsid) payload.clearPhpsid = true
|
||||||
|
if (this.form.clearGoodsApiToken) payload.clearGoodsApiToken = true
|
||||||
|
if (this.form.clearGoodsApiAppStr) payload.clearGoodsApiAppStr = true
|
||||||
|
}
|
||||||
|
|
||||||
|
Object.keys(payload).forEach((key) => {
|
||||||
|
if (payload[key] === undefined || payload[key] === '') delete payload[key]
|
||||||
|
})
|
||||||
|
return payload
|
||||||
|
},
|
||||||
|
appendChangedCredential(payload) {
|
||||||
|
const pairs = [
|
||||||
|
['cookie', this.form.cookie],
|
||||||
|
['phpsid', this.form.phpsid],
|
||||||
|
['goodsApiToken', this.form.goodsApiToken],
|
||||||
|
['goodsApiAppStr', this.form.goodsApiAppStr]
|
||||||
|
]
|
||||||
|
pairs.forEach(([key, value]) => {
|
||||||
|
if (!value) return
|
||||||
|
if (!this.isEdit || value !== this.originalCredential[key]) {
|
||||||
|
payload[key] = value
|
||||||
|
}
|
||||||
|
})
|
||||||
|
},
|
||||||
|
handleCredential(row) {
|
||||||
|
if (!row.tenantId) {
|
||||||
|
this.$message.warning('该记录缺少租户ID')
|
||||||
|
return
|
||||||
|
}
|
||||||
|
this.credentialRow = row
|
||||||
|
this.credentialDialogVisible = true
|
||||||
|
this.credentialLoading = true
|
||||||
|
getLbThirdIntegrationCredential(row.tenantId)
|
||||||
|
.then((res) => {
|
||||||
|
const data = (res && res.data) || {}
|
||||||
|
this.credentialForm = {
|
||||||
|
credentialExpireTime: data.credentialExpireTime || '',
|
||||||
|
cookie: data.cookie || data.cookiePlain || '',
|
||||||
|
phpsid: data.phpsid || data.phpsidPlain || '',
|
||||||
|
goodsApiToken: data.goodsApiToken || data.goodsApiTokenPlain || '',
|
||||||
|
goodsApiAppStr: data.goodsApiAppStr || data.goodsApiAppStrPlain || '',
|
||||||
|
clearCookie: false,
|
||||||
|
clearPhpsid: false,
|
||||||
|
clearGoodsApiToken: false,
|
||||||
|
clearGoodsApiAppStr: false
|
||||||
|
}
|
||||||
|
})
|
||||||
|
.catch(() => {
|
||||||
|
this.resetCredentialFormData()
|
||||||
|
})
|
||||||
|
.finally(() => {
|
||||||
|
this.credentialLoading = false
|
||||||
|
})
|
||||||
|
},
|
||||||
|
handleCredentialSubmit() {
|
||||||
|
if (!this.credentialRow || !this.credentialRow.tenantId) return
|
||||||
|
const payload = {}
|
||||||
|
if (this.credentialForm.cookie) payload.cookie = this.credentialForm.cookie
|
||||||
|
if (this.credentialForm.phpsid) payload.phpsid = this.credentialForm.phpsid
|
||||||
|
if (this.credentialForm.goodsApiToken) payload.goodsApiToken = this.credentialForm.goodsApiToken
|
||||||
|
if (this.credentialForm.goodsApiAppStr) payload.goodsApiAppStr = this.credentialForm.goodsApiAppStr
|
||||||
|
if (this.credentialForm.clearCookie) payload.clearCookie = true
|
||||||
|
if (this.credentialForm.clearPhpsid) payload.clearPhpsid = true
|
||||||
|
if (this.credentialForm.clearGoodsApiToken) payload.clearGoodsApiToken = true
|
||||||
|
if (this.credentialForm.clearGoodsApiAppStr) payload.clearGoodsApiAppStr = true
|
||||||
|
|
||||||
|
if (Object.keys(payload).length === 0) {
|
||||||
|
this.$message.warning('请至少填写一项凭证或勾选清除选项')
|
||||||
|
return
|
||||||
|
}
|
||||||
|
|
||||||
|
this.credentialSubmitLoading = true
|
||||||
|
updateLbThirdIntegrationCredential(this.credentialRow.tenantId, payload)
|
||||||
|
.then((res) => {
|
||||||
|
this.$message.success((res && res.message) || '凭证更新成功')
|
||||||
|
this.credentialDialogVisible = false
|
||||||
|
this.fetchList()
|
||||||
|
})
|
||||||
|
.finally(() => {
|
||||||
|
this.credentialSubmitLoading = false
|
||||||
|
})
|
||||||
|
},
|
||||||
|
resetForm() {
|
||||||
|
this.$refs.dataForm && this.$refs.dataForm.resetFields()
|
||||||
|
this.resetFormData()
|
||||||
|
},
|
||||||
|
resetFormData() {
|
||||||
|
this.form = DEFAULT_FORM()
|
||||||
|
},
|
||||||
|
resetCredentialForm() {
|
||||||
|
this.credentialRow = null
|
||||||
|
this.resetCredentialFormData()
|
||||||
|
},
|
||||||
|
resetCredentialFormData() {
|
||||||
|
this.credentialForm = {
|
||||||
|
credentialExpireTime: '',
|
||||||
|
cookie: '',
|
||||||
|
phpsid: '',
|
||||||
|
goodsApiToken: '',
|
||||||
|
goodsApiAppStr: '',
|
||||||
|
clearCookie: false,
|
||||||
|
clearPhpsid: false,
|
||||||
|
clearGoodsApiToken: false,
|
||||||
|
clearGoodsApiAppStr: false
|
||||||
|
}
|
||||||
|
},
|
||||||
|
formatDateTime(dateTime) {
|
||||||
|
if (!dateTime) return '-'
|
||||||
|
const date = new Date(String(dateTime).replace('T', ' '))
|
||||||
|
if (Number.isNaN(date.getTime())) return String(dateTime)
|
||||||
|
const year = date.getFullYear()
|
||||||
|
const month = String(date.getMonth() + 1).padStart(2, '0')
|
||||||
|
const day = String(date.getDate()).padStart(2, '0')
|
||||||
|
const hours = String(date.getHours()).padStart(2, '0')
|
||||||
|
const minutes = String(date.getMinutes()).padStart(2, '0')
|
||||||
|
const seconds = String(date.getSeconds()).padStart(2, '0')
|
||||||
|
return `${year}-${month}-${day} ${hours}:${minutes}:${seconds}`
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
</script>
|
||||||
|
|
||||||
|
<style lang="scss" scoped>
|
||||||
|
.app-container {
|
||||||
|
.filter-container,
|
||||||
|
.action-container {
|
||||||
|
margin-bottom: 20px;
|
||||||
|
}
|
||||||
|
|
||||||
|
.table-container {
|
||||||
|
.el-pagination {
|
||||||
|
margin-top: 20px;
|
||||||
|
text-align: right;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
.text-muted {
|
||||||
|
color: #909399;
|
||||||
|
font-size: 12px;
|
||||||
|
}
|
||||||
|
|
||||||
|
.verify-time {
|
||||||
|
margin-left: 6px;
|
||||||
|
font-size: 12px;
|
||||||
|
color: #606266;
|
||||||
|
}
|
||||||
|
|
||||||
|
.el-tag + .el-tag {
|
||||||
|
margin-left: 4px;
|
||||||
|
}
|
||||||
|
|
||||||
|
.el-checkbox {
|
||||||
|
margin-top: 6px;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
</style>
|
||||||
Reference in New Issue
Block a user