Compare commits

...

6 Commits

Author SHA1 Message Date
5b4f5c393e fix(config): 更新AI API配置以支持生产环境HTTPS访问
- 将生产环境AI API URL从 http://127.0.0.1:11434/api/v1 修改为 https://ai-api.websoft.top/api/v1
- 在ai组件中移除硬编码的本地地址,统一使用HTTPS反向代理URL
- 添加重要注释说明浏览器生产环境中不应使用127.0.0.1地址
- 更新示例环境变量配置,将VITE_AI_API_URL和VITE_OLLAMA_API_URL设置为同源反向代理路径
- 解决浏览器混合内容安全策略导致的API调用失败问题
2026-02-28 02:07:02 +08:00
ac9712819a fix(config): 更新AI代理配置为本地Ollama服务
- 将AI代理目标从远程服务器改为本地127.0.1:11434
- 更新Nginx配置中的代理地址和Host头部设置
- 修改AI_API_URL默认值指向本地Ollama服务
- 调整AI视图组件中的基础URL配置逻辑
- 更新环境变量示例文件中的默认API地址
- 修正Vite开发服务器代理配置指向本地服务
2026-02-28 01:42:18 +08:00
91708315f3 style(ai): 格式化 AI API 错误消息和调整 AI 视图布局
- 格式化 Ollama 和 OpenAI API 的错误消息字符串以提高可读性
- 移除 AI 视图中的 BaseURL 输入字段并硬编码为固定端点
- 简化 AI 视图中 API 调用的基础 URL 配置逻辑
- 修复多个组件中的代码格式和空格缩进问题
- 清理经销商订单视图中的多余注释和代码结构
- 调整表单组件的标签和布局格式以提升用户体验
2026-02-28 00:53:26 +08:00
cc01095107 refactor(ai): 移除 OpenAI 支持并优化 Ollama 集成
- 移除了 OpenAI 相关的 API 导入和类型定义
- 删除了 provider 切换逻辑和相关的条件分支代码
- 简化了模型列表加载逻辑,仅保留 Ollama 模型获取
- 移除了聊天消息发送中的 provider 分支判断
- 删除了历史消息 JSON 计算属性
- 移除了 API Key 输入字段和相关错误处理
- 统一使用 Ollama API 类型定义替代 OpenAI 类型
- 移除了 provider 监听器和切换功能组件
2026-02-28 00:38:19 +08:00
096e78da4c feat(ai): 更新 AI 服务配置和 API 网关设置
- 移除 AI_API_URL 配置项,统一使用直接 OpenAI 兼容网关地址
- 添加强制调用托管 OpenAI 兼容网关的配置选项
- 更新 BaseURL 初始值逻辑,支持 OpenAI 和 Ollama 两种提供商
- 修改 API 密钥认证错误提示信息,增加本地代理配置说明
- 更新模型加载和聊天请求的 API 调用基础 URL 配置
- 添加 OpenAI API 网关 Nginx 代理配置文件
- 配置 HTTPS 重定向和 SSL 安全设置
- 设置 CORS 跨域资源共享策略,支持 websoft.top 域名访问
2026-02-28 00:17:20 +08:00
2afd831d11 fix(config): 统一使用代理地址避免混合内容问题
- 移除生产环境中的硬编码HTTP API地址
- 统一使用/proxy路径进行API调用
- 避免HTTPS站点调用HTTP资源的混合内容安全问题
- 确保开发和生产环境的一致性配置
2026-02-27 23:58:19 +08:00
23 changed files with 986 additions and 947 deletions

View File

@@ -9,12 +9,12 @@ VITE_FILE_SERVER=https://your-file-server.com
# AI 网关(OpenAI兼容)
# - 开发环境推荐走同源反代VITE_AI_API_URL=/ai-proxy配合 vite.config.ts
# - 生产环境可直连(需 AI 服务允许 CORS或在 Nginx 里配置 /ai-proxy 反代
VITE_AI_API_URL=https://ai-api.websoft.top/api/v1
VITE_AI_API_URL=/ai-proxy
# Ollama 原生接口(默认端口 11434
# - 开发环境推荐走同源反代VITE_OLLAMA_API_URL=/proxy配合 vite.config.ts
# - 生产环境不要直接用 http会混合内容被拦截建议 Nginx 反代成同源 https
VITE_OLLAMA_API_URL=http://47.119.165.234:11434
VITE_OLLAMA_API_URL=/proxy
# 仅用于本地开发反代注入vite.config.ts 会读取并注入到 /ai-proxy 请求头)
# 不要加 VITE_ 前缀,避免被打包到前端产物里

View File

@@ -6,7 +6,7 @@
项目已在 `vite.config.ts` 配置(默认目标可通过 `AI_PROXY_TARGET` 调整):
- `/ai-proxy/*` -> `https://ai-api.websoft.top/api/v1/*`
- `/ai-proxy/*` -> `http://127.0.0.1:11434/api/v1/*`
配合 `.env.development`
@@ -20,7 +20,7 @@ VITE_AI_API_URL=/ai-proxy
```nginx
location /ai-proxy/ {
proxy_pass https://ai-api.websoft.top/api/v1/;
proxy_pass http://127.0.0.1:11434/api/v1/;
proxy_http_version 1.1;
proxy_set_header Host ai-api.websoft.top;
proxy_set_header X-Real-IP $remote_addr;
@@ -48,9 +48,9 @@ VITE_AI_API_URL=/ai-proxy
```nginx
location /proxy/ {
proxy_pass http://47.119.165.234:11434/;
proxy_pass http://127.0.0.1:11434/;
proxy_http_version 1.1;
proxy_set_header Host 47.119.165.234;
proxy_set_header Host 127.0.0.1;
proxy_set_header X-Real-IP $remote_addr;
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
proxy_set_header X-Forwarded-Proto $scheme;

52
proxy.conf Normal file
View File

@@ -0,0 +1,52 @@
server {
listen 80 ;
listen 443 ssl ;
server_name ai-api.websoft.top;
index index.php index.html index.htm default.php default.htm default.html;
access_log /www/sites/ai-api.websoft.top/log/access.log main;
error_log /www/sites/ai-api.websoft.top/log/error.log;
location ~ ^/(\.user.ini|\.htaccess|\.git|\.env|\.svn|\.project|LICENSE|README.md) {
return 404;
}
location ^~ /.well-known/acme-challenge {
allow all;
root /usr/share/nginx/html;
}
if ( $uri ~ "^/\.well-known/.*\.(php|jsp|py|js|css|lua|ts|go|zip|tar\.gz|rar|7z|sql|bak)$" ) {
return 403;
}
http2 on;
if ($scheme = http) {
return 301 https://$host$request_uri;
}
ssl_certificate /www/sites/ai-api.websoft.top/ssl/fullchain.pem;
ssl_certificate_key /www/sites/ai-api.websoft.top/ssl/privkey.pem;
ssl_protocols TLSv1.3 TLSv1.2;
ssl_ciphers ECDHE-ECDSA-AES256-GCM-SHA384:ECDHE-RSA-AES256-GCM-SHA384:ECDHE-ECDSA-CHACHA20-POLY1305:ECDHE-RSA-CHACHA20-POLY1305:ECDHE-ECDSA-AES128-GCM-SHA256:ECDHE-RSA-AES128-GCM-SHA256:DHE-RSA-AES256-GCM-SHA384:DHE-RSA-AES128-GCM-SHA256:ECDHE-RSA-AES256-SHA384:ECDHE-RSA-AES128-SHA256:!aNULL:!eNULL:!EXPORT:!DSS:!DES:!RC4:!3DES:!MD5:!PSK:!KRB5:!SRP:!CAMELLIA:!SEED;
ssl_prefer_server_ciphers off;
ssl_session_cache shared:SSL:10m;
ssl_session_timeout 10m;
error_page 497 https://$host$request_uri;
proxy_set_header X-Forwarded-Proto https;
add_header Strict-Transport-Security "max-age=31536000; includeSubDomains";
# CORS: allow any *.websoft.top (and websoft.top) Origin; echo Origin for credentialed requests.
# Keep wildcard for non-websoft origins without credentials.
set $cors_origin "*";
set $cors_credentials "false";
if ($http_origin ~* '^https?://([a-z0-9-]+\.)*websoft\.top(?::[0-9]+)?$') {
set $cors_origin $http_origin;
set $cors_credentials "true";
}
add_header Access-Control-Allow-Origin $cors_origin always;
add_header Access-Control-Allow-Credentials $cors_credentials always;
add_header Access-Control-Allow-Methods "GET,POST,PUT,PATCH,DELETE,OPTIONS" always;
add_header Access-Control-Allow-Headers "$http_access_control_request_headers" always;
add_header Vary "Origin" always;
if ($request_method = OPTIONS) {
add_header Content-Length 0;
add_header Content-Type text/plain;
return 204;
}
include /www/sites/ai-api.websoft.top/proxy/*.conf;
}

35
proxy_.conf Normal file
View File

@@ -0,0 +1,35 @@
server {
listen 80 ;
listen 443 ssl ;
server_name ai-api.websoft.top;
index index.php index.html index.htm default.php default.htm default.html;
access_log /www/sites/ai-api.websoft.top/log/access.log main;
error_log /www/sites/ai-api.websoft.top/log/error.log;
location ~ ^/(\.user.ini|\.htaccess|\.git|\.env|\.svn|\.project|LICENSE|README.md) {
return 404;
}
location ^~ /.well-known/acme-challenge {
allow all;
root /usr/share/nginx/html;
}
if ( $uri ~ "^/\.well-known/.*\.(php|jsp|py|js|css|lua|ts|go|zip|tar\.gz|rar|7z|sql|bak)$" ) {
return 403;
}
http2 on;
if ($scheme = http) {
return 301 https://$host$request_uri;
}
ssl_certificate /www/sites/ai-api.websoft.top/ssl/fullchain.pem;
ssl_certificate_key /www/sites/ai-api.websoft.top/ssl/privkey.pem;
ssl_protocols TLSv1.3 TLSv1.2;
ssl_ciphers ECDHE-ECDSA-AES256-GCM-SHA384:ECDHE-RSA-AES256-GCM-SHA384:ECDHE-ECDSA-CHACHA20-POLY1305:ECDHE-RSA-CHACHA20-POLY1305:ECDHE-ECDSA-AES128-GCM-SHA256:ECDHE-RSA-AES128-GCM-SHA256:DHE-RSA-AES256-GCM-SHA384:DHE-RSA-AES128-GCM-SHA256:ECDHE-RSA-AES256-SHA384:ECDHE-RSA-AES128-SHA256:!aNULL:!eNULL:!EXPORT:!DSS:!DES:!RC4:!3DES:!MD5:!PSK:!KRB5:!SRP:!CAMELLIA:!SEED;
ssl_prefer_server_ciphers off;
ssl_session_cache shared:SSL:10m;
ssl_session_timeout 10m;
error_page 497 https://$host$request_uri;
proxy_set_header X-Forwarded-Proto https;
add_header Strict-Transport-Security "max-age=31536000; includeSubDomains";
add_header Access-Control-Allow-Origin "*" always;
include /www/sites/ai-api.websoft.top/proxy/*.conf;
}

View File

@@ -48,7 +48,9 @@ export async function listOllamaModels(opts?: { baseURL?: string }) {
if (!res.ok) {
const text = await res.text().catch(() => '');
throw new Error(
`listOllamaModels failed: ${res.status} ${res.statusText}${text ? ` - ${text}` : ''}`
`listOllamaModels failed: ${res.status} ${res.statusText}${
text ? ` - ${text}` : ''
}`
);
}
return (await res.json()) as OllamaTagsResponse;
@@ -68,7 +70,9 @@ export async function ollamaChat(
if (!res.ok) {
const text = await res.text().catch(() => '');
throw new Error(
`ollamaChat failed: ${res.status} ${res.statusText}${text ? ` - ${text}` : ''}`
`ollamaChat failed: ${res.status} ${res.statusText}${
text ? ` - ${text}` : ''
}`
);
}
return (await res.json()) as OllamaChatResponseChunk;
@@ -97,7 +101,9 @@ export async function ollamaChatStream(
if (!res.ok || !res.body) {
const text = await res.text().catch(() => '');
throw new Error(
`ollamaChatStream failed: ${res.status} ${res.statusText}${text ? ` - ${text}` : ''}`
`ollamaChatStream failed: ${res.status} ${res.statusText}${
text ? ` - ${text}` : ''
}`
);
}
@@ -143,4 +149,3 @@ export async function ollamaChatStream(
opts.onDone?.();
}

View File

@@ -71,7 +71,9 @@ export async function listModels(opts?: { apiKey?: string; baseURL?: string }) {
if (!res.ok) {
const text = await res.text().catch(() => '');
throw new Error(
`listModels failed: ${res.status} ${res.statusText}${text ? ` - ${text}` : ''}`
`listModels failed: ${res.status} ${res.statusText}${
text ? ` - ${text}` : ''
}`
);
}
return (await res.json()) as OpenAIListModelsResponse;
@@ -91,7 +93,9 @@ export async function chatCompletions(
if (!res.ok) {
const text = await res.text().catch(() => '');
throw new Error(
`chatCompletions failed: ${res.status} ${res.statusText}${text ? ` - ${text}` : ''}`
`chatCompletions failed: ${res.status} ${res.statusText}${
text ? ` - ${text}` : ''
}`
);
}
return (await res.json()) as OpenAIChatCompletionResponse;
@@ -124,7 +128,9 @@ export async function chatCompletionsStream(
if (!res.ok || !res.body) {
const text = await res.text().catch(() => '');
throw new Error(
`chatCompletionsStream failed: ${res.status} ${res.statusText}${text ? ` - ${text}` : ''}`
`chatCompletionsStream failed: ${res.status} ${res.statusText}${
text ? ` - ${text}` : ''
}`
);
}

View File

@@ -26,7 +26,8 @@ export const AI_API_URL =
// Note: browsers cannot call http from an https site (mixed-content); prefer same-origin proxy.
export const OLLAMA_API_URL =
import.meta.env.VITE_OLLAMA_API_URL ||
(import.meta.env.DEV ? '/proxy' : 'http://47.119.165.234:11434');
// Prefer same-origin reverse proxy in production too (avoid https mixed-content).
'/proxy';
/**
* 以下配置一般不需要修改

View File

@@ -1,14 +1,6 @@
<script setup lang="ts">
import { computed, onBeforeUnmount, ref, watch } from 'vue';
import { computed, onBeforeUnmount, ref } from 'vue';
import { message } from 'ant-design-vue';
import {
chatCompletions,
chatCompletionsStream,
listModels,
type OpenAIChatMessage,
type OpenAIModel
} from '@/api/ai/openai';
import { AI_API_URL, OLLAMA_API_URL } from '@/config/setting';
import {
listOllamaModels,
ollamaChat,
@@ -16,17 +8,19 @@
type OllamaChatMessage
} from '@/api/ai/ollama';
type Msg = OpenAIChatMessage;
type Msg = OllamaChatMessage;
type Provider = 'openai' | 'ollama';
const provider = ref<Provider>('ollama');
// Default to Ollama native API when provider is ollama.
const baseURL = ref(provider.value === OLLAMA_API_URL);
const apiKey = ref<string>('');
// Hardcode endpoint to avoid going through mp.websoft.top `/proxy`.
// The API methods append `/api/*` paths.
//
// IMPORTANT: do not use `127.0.0.1` in browser production builds:
// it points to the visitor's machine, not your server.
// If you want to use server-local Ollama (`127.0.0.1:11434`), put it behind an HTTPS reverse proxy
// (e.g. `https://ai-api.websoft.top` or same-origin `/proxy`).
const BASE_URL = 'https://ai-api.websoft.top';
const modelLoading = ref(false);
const models = ref<OpenAIModel[]>([]);
const models = ref<Array<{ id: string; name?: string }>>([]);
const modelId = ref<string>('');
const systemPrompt = ref<string>('你是一个有帮助的助手。');
@@ -40,7 +34,6 @@
const errorText = ref<string>('');
const history = ref<Msg[]>([]);
const historyJson = computed(() => JSON.stringify(history.value, null, 2));
const canSend = computed(() => {
return !!modelId.value && !!userPrompt.value.trim() && !sending.value;
@@ -58,46 +51,19 @@
modelLoading.value = true;
errorText.value = '';
try {
if (provider.value === 'openai') {
if (!baseURL.value.trim()) {
baseURL.value = AI_API_URL;
}
const res = await listModels({
baseURL: baseURL.value.trim() || AI_API_URL,
apiKey: apiKey.value.trim() || undefined
});
models.value = res.data ?? [];
if (!modelId.value && models.value.length) {
modelId.value = models.value[0].id;
}
} else {
if (!baseURL.value.trim()) {
baseURL.value = OLLAMA_API_URL;
}
const res = await listOllamaModels({
baseURL: baseURL.value.trim() || OLLAMA_API_URL
});
models.value = (res.models ?? []).map((m) => ({
id: m.name,
name: m.name,
object: 'model'
}));
if (!modelId.value && models.value.length) {
modelId.value = models.value[0].id;
}
const res = await listOllamaModels({
baseURL: BASE_URL
});
models.value = (res.models ?? []).map((m) => ({
id: m.name,
name: m.name
}));
if (!modelId.value && models.value.length) {
modelId.value = models.value[0].id;
}
} catch (e: any) {
errorText.value = e?.message ?? String(e);
if (
provider.value === 'openai' &&
String(errorText.value).includes('401')
) {
message.error(
'未认证(401):请填写 API Key或在本地用 AI_API_KEY 通过 /ai-proxy 注入'
);
} else {
message.error('加载模型列表失败');
}
message.error('加载模型列表失败');
} finally {
modelLoading.value = false;
}
@@ -128,72 +94,34 @@
abortController.value = controller;
try {
if (provider.value === 'openai') {
if (stream.value) {
await chatCompletionsStream(
{
model: modelId.value,
messages,
temperature: temperature.value
},
{
baseURL: baseURL.value.trim() || AI_API_URL,
apiKey: apiKey.value.trim() || undefined,
signal: controller.signal,
onDelta: (t) => {
assistantText.value += t;
}
if (stream.value) {
await ollamaChatStream(
{
model: modelId.value,
messages,
options: { temperature: temperature.value }
},
{
baseURL: BASE_URL,
signal: controller.signal,
onDelta: (t) => {
assistantText.value += t;
}
);
} else {
const res = await chatCompletions(
{
model: modelId.value,
messages,
temperature: temperature.value
},
{
baseURL: baseURL.value.trim() || AI_API_URL,
apiKey: apiKey.value.trim() || undefined,
signal: controller.signal
}
);
assistantText.value = res.choices?.[0]?.message?.content ?? '';
}
}
);
} else {
const ollamaMessages: OllamaChatMessage[] = messages.map((m) => ({
role: m.role as any,
content: m.content
}));
if (stream.value) {
await ollamaChatStream(
{
model: modelId.value,
messages: ollamaMessages,
options: { temperature: temperature.value }
},
{
baseURL: baseURL.value.trim() || OLLAMA_API_URL,
signal: controller.signal,
onDelta: (t) => {
assistantText.value += t;
}
}
);
} else {
const res = await ollamaChat(
{
model: modelId.value,
messages: ollamaMessages,
options: { temperature: temperature.value }
},
{
baseURL: baseURL.value.trim() || OLLAMA_API_URL,
signal: controller.signal
}
);
assistantText.value = res.message?.content ?? '';
}
const res = await ollamaChat(
{
model: modelId.value,
messages,
options: { temperature: temperature.value }
},
{
baseURL: BASE_URL,
signal: controller.signal
}
);
assistantText.value = res.message?.content ?? '';
}
history.value = [
@@ -223,19 +151,6 @@
// Load once for convenience; if the gateway blocks CORS you can still paste output from curl.
loadModels();
watch(
() => provider.value,
(p) => {
stop();
clearChat();
models.value = [];
modelId.value = '';
errorText.value = '';
baseURL.value = p === 'openai' ? AI_API_URL : OLLAMA_API_URL;
loadModels();
}
);
onBeforeUnmount(() => {
stop();
});
@@ -252,33 +167,6 @@
description="支持Qwen3.5、DeepSeek、Gemini3等主流的开源大模型免费使用"
/>
<a-row :gutter="12">
<a-col :xs="24" :md="6">
<a-select
v-model:value="provider"
:options="[
{ label: 'OpenAI兼容(/v1)', value: 'openai' },
{ label: 'Ollama原生(/api)', value: 'ollama' }
]"
style="width: 100%"
/>
</a-col>
<a-col :xs="24" :md="12">
<a-input
v-model:value="baseURL"
addon-before="BaseURL"
placeholder="https://ai-api.websoft.top/api/v1"
/>
</a-col>
<a-col :xs="24" :md="12" v-if="provider === 'openai'">
<a-input-password
v-model:value="apiKey"
addon-before="API Key"
placeholder="可选(不建议在前端保存)"
/>
</a-col>
</a-row>
<a-row :gutter="12">
<a-col :xs="24" :md="12">
<a-select

View File

@@ -62,9 +62,9 @@
<div class="text-gray-400"
>{{ record.thirdNickname || '-' }} {{ record.thirdMoney }}</div
>
<!-- <div class="text-gray-400" v-if="record.thirdNickname"-->
<!-- >{{ record.thirdNickname }} {{ record.thirdMoney }}</div-->
<!-- >-->
<!-- <div class="text-gray-400" v-if="record.thirdNickname"-->
<!-- >{{ record.thirdNickname }} {{ record.thirdMoney }}</div-->
<!-- >-->
</template>
<template v-if="column.key === 'dealerInfo'">

View File

@@ -56,15 +56,7 @@
// 导出
const handleExport = async () => {
const array: (string | number)[][] = [
[
'订单号',
'用户',
'收益类型',
'金额',
'描述',
'创建时间',
'租户ID'
]
['订单号', '用户', '收益类型', '金额', '描述', '创建时间', '租户ID']
];
// 按搜索结果导出

View File

@@ -91,7 +91,8 @@
? `\n${d.nickname ?? '-'}(${d.userId ?? '-'})`
: '');
const firstDividendUserName = (d as any)?.firstDividendUserName ?? '-';
const firstDividendUserName =
(d as any)?.firstDividendUserName ?? '-';
const firstDividend = (d as any)?.firstDividend ?? 0;
const secondDividendUserName =
(d as any)?.secondDividendUserName ?? '-';

View File

@@ -11,9 +11,7 @@
class="sys-org-table"
>
<template #toolbar>
<search
@search="reload"
/>
<search @search="reload" />
</template>
<template #bodyCell="{ column, record }">
<template v-if="column.key === 'title'">
@@ -55,16 +53,16 @@
<template v-if="column.key === 'firstDividendUserName'">
<div>{{ record.firstDividend }}</div>
<div class="text-gray-400"
>{{ record.firstDividendUserName || '-' }}</div
>
<div class="text-gray-400">{{
record.firstDividendUserName || '-'
}}</div>
</template>
<template v-if="column.key === 'secondDividendUserName'">
<div>{{ record.secondDividend }}</div>
<div class="text-gray-400"
>{{ record.secondDividendUserName || '-' }}</div
>
<div class="text-gray-400">{{
record.secondDividendUserName || '-'
}}</div>
</template>
<template v-if="column.key === 'dealerInfo'">
@@ -175,9 +173,7 @@
ShopDealerOrder,
ShopDealerOrderParam
} from '@/api/shop/shopDealerOrder/model';
import {
updateShopDealerOrder
} from '@/api/shop/shopDealerOrder';
import { updateShopDealerOrder } from '@/api/shop/shopDealerOrder';
// 表格实例
const tableRef = ref<InstanceType<typeof EleProTable> | null>(null);

View File

@@ -15,7 +15,7 @@
style="padding: 24px 0; margin-bottom: 16px"
>
<p class="ant-upload-drag-icon">
<cloud-upload-outlined/>
<cloud-upload-outlined />
</p>
<p class="ant-upload-hint">将文件拖到此处或点击上传</p>
</a-upload-dragger>
@@ -24,56 +24,56 @@
</template>
<script lang="ts" setup>
import {ref} from 'vue';
import {message} from 'ant-design-vue/es';
import {CloudUploadOutlined} from '@ant-design/icons-vue';
import {importSdyDealerOrder} from "@/api/sdy/sdyDealerOrder";
import { ref } from 'vue';
import { message } from 'ant-design-vue/es';
import { CloudUploadOutlined } from '@ant-design/icons-vue';
import { importSdyDealerOrder } from '@/api/sdy/sdyDealerOrder';
const emit = defineEmits<{
(e: 'done'): void;
(e: 'update:visible', visible: boolean): void;
}>();
const emit = defineEmits<{
(e: 'done'): void;
(e: 'update:visible', visible: boolean): void;
}>();
defineProps<{
// 是否打开弹窗
visible: boolean;
}>();
defineProps<{
// 是否打开弹窗
visible: boolean;
}>();
// 导入请求状态
const loading = ref(false);
// 导入请求状态
const loading = ref(false);
/* 上传 */
const doUpload = ({file}) => {
if (
![
'application/vnd.ms-excel',
'application/vnd.openxmlformats-officedocument.spreadsheetml.sheet'
].includes(file.type)
) {
message.error('只能选择 excel 文件');
/* 上传 */
const doUpload = ({ file }) => {
if (
![
'application/vnd.ms-excel',
'application/vnd.openxmlformats-officedocument.spreadsheetml.sheet'
].includes(file.type)
) {
message.error('只能选择 excel 文件');
return false;
}
if (file.size / 1024 / 1024 > 10) {
message.error('大小不能超过 10MB');
return false;
}
loading.value = true;
importSdyDealerOrder(file)
.then((msg) => {
loading.value = false;
message.success(msg);
updateVisible(false);
emit('done');
})
.catch((e) => {
loading.value = false;
message.error(e.message);
});
return false;
}
if (file.size / 1024 / 1024 > 10) {
message.error('大小不能超过 10MB');
return false;
}
loading.value = true;
importSdyDealerOrder(file)
.then((msg) => {
loading.value = false;
message.success(msg);
updateVisible(false);
emit('done');
})
.catch((e) => {
loading.value = false;
message.error(e.message);
});
return false;
};
};
/* 更新 visible */
const updateVisible = (value: boolean) => {
emit('update:visible', value);
};
/* 更新 visible */
const updateVisible = (value: boolean) => {
emit('update:visible', value);
};
</script>

View File

@@ -14,14 +14,17 @@
<script lang="ts" setup>
import type { GradeParam } from '@/api/user/grade/model';
import {ref, watch} from 'vue';
import {utils, writeFile} from 'xlsx';
import {message} from 'ant-design-vue';
import {ShopDealerCapital} from "@/api/shop/shopDealerCapital/model";
import {getTenantId} from "@/utils/domain";
import useSearch from "@/utils/use-search";
import {ShopDealerOrder, ShopDealerOrderParam} from "@/api/sdy/sdyDealerOrder/model";
import {pageShopDealerOrder} from "@/api/shop/shopDealerOrder";
import { ref, watch } from 'vue';
import { utils, writeFile } from 'xlsx';
import { message } from 'ant-design-vue';
import { ShopDealerCapital } from '@/api/shop/shopDealerCapital/model';
import { getTenantId } from '@/utils/domain';
import useSearch from '@/utils/use-search';
import {
ShopDealerOrder,
ShopDealerOrderParam
} from '@/api/sdy/sdyDealerOrder/model';
import { pageShopDealerOrder } from '@/api/shop/shopDealerOrder';
const props = withDefaults(
defineProps<{
@@ -43,7 +46,7 @@
};
// 表单数据
const {where} = useSearch<ShopDealerOrderParam>({
const { where } = useSearch<ShopDealerOrderParam>({
keywords: '',
userId: undefined,
orderNo: undefined,
@@ -114,27 +117,23 @@
workbook.Sheets[sheetName] = sheet;
// 设置列宽
sheet['!cols'] = [
{wch: 10},
{wch: 20},
{wch: 20},
{wch: 15},
{wch: 10},
{wch: 10},
{wch: 20}
{ wch: 10 },
{ wch: 20 },
{ wch: 20 },
{ wch: 15 },
{ wch: 10 },
{ wch: 10 },
{ wch: 20 }
];
message.loading('正在导出...');
setTimeout(() => {
writeFile(
workbook,
`${sheetName}.xlsx`
);
writeFile(workbook, `${sheetName}.xlsx`);
}, 1000);
})
.catch((msg) => {
message.error(msg);
})
.finally(() => {
});
.finally(() => {});
};
watch(

View File

@@ -20,7 +20,7 @@
>
<!-- 订单基本信息 -->
<a-divider orientation="left">
<span style="color: #1890ff; font-weight: 600;">基本信息</span>
<span style="color: #1890ff; font-weight: 600">基本信息</span>
</a-divider>
<a-row :gutter="16">
@@ -68,13 +68,25 @@
<div class="font-bold text-gray-400 bg-gray-50">开发调试</div>
<div class="text-gray-400 bg-gray-50">
<div>业务员({{ form.userId }}){{ form.nickname }}</div>
<div>一级分销商({{ form.firstUserId }}){{ form.firstNickname }}一级佣金30%{{ form.firstMoney }}</div>
<div>级分销商({{ form.secondUserId }}){{ form.secondNickname }}二级佣金10%{{ form.secondMoney }}</div>
<div>三级分销商({{ form.thirdUserId }}){{ form.thirdNickname }}三级佣金60%{{ form.thirdMoney }}</div>
<div
>级分销商({{ form.firstUserId }}){{
form.firstNickname
}}一级佣金30%{{ form.firstMoney }}</div
>
<div
>二级分销商({{ form.secondUserId }}){{
form.secondNickname
}}二级佣金10%{{ form.secondMoney }}</div
>
<div
>三级分销商({{ form.thirdUserId }}){{
form.thirdNickname
}}三级佣金60%{{ form.thirdMoney }}</div
>
</div>
<!-- 分销商信息 -->
<a-divider orientation="left">
<span style="color: #1890ff; font-weight: 600;">收益计算</span>
<span style="color: #1890ff; font-weight: 600">收益计算</span>
</a-divider>
<!-- 一级分销商 -->
@@ -117,9 +129,7 @@
</a-form-item>
</a-col>
<a-col :span="12">
<a-form-item label="占比" name="rate">
10%
</a-form-item>
<a-form-item label="占比" name="rate"> 10% </a-form-item>
<a-form-item label="获取收益" name="firstMoney">
{{ form.secondMoney }}
</a-form-item>
@@ -152,201 +162,202 @@
</a-row>
</div>
<a-form-item label="结算时间" name="settleTime" v-if="form.isSettled === 1">
<a-form-item
label="结算时间"
name="settleTime"
v-if="form.isSettled === 1"
>
{{ form.settleTime }}
</a-form-item>
</a-form>
</ele-modal>
</template>
<script lang="ts" setup>
import {ref, reactive, watch} from 'vue';
import {Form, message} from 'ant-design-vue';
import {assignObject} from 'ele-admin-pro';
import {ShopDealerOrder} from '@/api/shop/shopDealerOrder/model';
import {FormInstance} from 'ant-design-vue/es/form';
import {updateSdyDealerOrder} from "@/api/sdy/sdyDealerOrder";
import { ref, reactive, watch } from 'vue';
import { Form, message } from 'ant-design-vue';
import { assignObject } from 'ele-admin-pro';
import { ShopDealerOrder } from '@/api/shop/shopDealerOrder/model';
import { FormInstance } from 'ant-design-vue/es/form';
import { updateSdyDealerOrder } from '@/api/sdy/sdyDealerOrder';
// 是否是修改
const isUpdate = ref(false);
const useForm = Form.useForm;
// 是否是修改
const isUpdate = ref(false);
const useForm = Form.useForm;
const props = defineProps<{
// 弹窗是否打开
visible: boolean;
// 修改回显的数据
data?: ShopDealerOrder | null;
}>();
const props = defineProps<{
// 弹窗是否打开
visible: boolean;
// 修改回显的数据
data?: ShopDealerOrder | null;
}>();
const emit = defineEmits<{
(e: 'done'): void;
(e: 'update:visible', visible: boolean): void;
}>();
const emit = defineEmits<{
(e: 'done'): void;
(e: 'update:visible', visible: boolean): void;
}>();
// 提交状态
const loading = ref(false);
// 是否显示最大化切换按钮
const maxable = ref(true);
// 表格选中数据
const formRef = ref<FormInstance | null>(null);
// 提交状态
const loading = ref(false);
// 是否显示最大化切换按钮
const maxable = ref(true);
// 表格选中数据
const formRef = ref<FormInstance | null>(null);
// 表单数据
const form = reactive<ShopDealerOrder>({
id: undefined,
userId: undefined,
nickname: undefined,
orderNo: undefined,
title: undefined,
orderPrice: undefined,
settledPrice: undefined,
degreePrice: undefined,
price: undefined,
month: undefined,
payPrice: undefined,
firstUserId: undefined,
secondUserId: undefined,
thirdUserId: undefined,
firstMoney: undefined,
secondMoney: undefined,
thirdMoney: undefined,
firstNickname: undefined,
secondNickname: undefined,
thirdNickname: undefined,
rate: undefined,
comments: undefined,
isInvalid: 0,
isSettled: 0,
settleTime: undefined,
tenantId: undefined,
createTime: undefined,
updateTime: undefined
});
// 表单数据
const form = reactive<ShopDealerOrder>({
id: undefined,
userId: undefined,
nickname: undefined,
orderNo: undefined,
title: undefined,
orderPrice: undefined,
settledPrice: undefined,
degreePrice: undefined,
price: undefined,
month: undefined,
payPrice: undefined,
firstUserId: undefined,
secondUserId: undefined,
thirdUserId: undefined,
firstMoney: undefined,
secondMoney: undefined,
thirdMoney: undefined,
firstNickname: undefined,
secondNickname: undefined,
thirdNickname: undefined,
rate: undefined,
comments: undefined,
isInvalid: 0,
isSettled: 0,
settleTime: undefined,
tenantId: undefined,
createTime: undefined,
updateTime: undefined
});
/* 更新visible */
const updateVisible = (value: boolean) => {
emit('update:visible', value);
};
/* 更新visible */
const updateVisible = (value: boolean) => {
emit('update:visible', value);
};
// 表单验证规则
const rules = reactive({
userId: [
{
required: true,
message: '请选择用户ID',
trigger: 'blur'
}
],
});
const {resetFields} = useForm(form, rules);
/* 保存编辑 */
const save = () => {
if (!formRef.value) {
return;
}
if (form.isSettled == 1) {
message.error('请勿重复结算');
return;
}
if (form.userId == 0) {
message.error('未签约');
return;
}
formRef.value
.validate()
.then(() => {
loading.value = true;
const formData = {
...form,
isSettled: 1
};
updateSdyDealerOrder(formData)
.then((msg) => {
loading.value = false;
message.success(msg);
updateVisible(false);
emit('done');
})
.catch((e) => {
loading.value = false;
message.error(e.message);
});
})
.catch(() => {
});
};
console.log(localStorage.getItem(''))
watch(
() => props.visible,
(visible) => {
if (visible) {
if (props.data) {
assignObject(form, props.data);
isUpdate.value = true;
} else {
// 重置为默认值
Object.assign(form, {
id: undefined,
userId: undefined,
orderNo: undefined,
orderPrice: undefined,
firstUserId: undefined,
secondUserId: undefined,
thirdUserId: undefined,
firstMoney: undefined,
secondMoney: undefined,
thirdMoney: undefined,
isInvalid: 0,
isSettled: 0,
settleTime: undefined
});
isUpdate.value = false;
// 表单验证规则
const rules = reactive({
userId: [
{
required: true,
message: '请选择用户ID',
trigger: 'blur'
}
} else {
resetFields();
]
});
const { resetFields } = useForm(form, rules);
/* 保存编辑 */
const save = () => {
if (!formRef.value) {
return;
}
},
{immediate: true}
);
if (form.isSettled == 1) {
message.error('请勿重复结算');
return;
}
if (form.userId == 0) {
message.error('未签约');
return;
}
formRef.value
.validate()
.then(() => {
loading.value = true;
const formData = {
...form,
isSettled: 1
};
updateSdyDealerOrder(formData)
.then((msg) => {
loading.value = false;
message.success(msg);
updateVisible(false);
emit('done');
})
.catch((e) => {
loading.value = false;
message.error(e.message);
});
})
.catch(() => {});
};
console.log(localStorage.getItem(''));
watch(
() => props.visible,
(visible) => {
if (visible) {
if (props.data) {
assignObject(form, props.data);
isUpdate.value = true;
} else {
// 重置为默认值
Object.assign(form, {
id: undefined,
userId: undefined,
orderNo: undefined,
orderPrice: undefined,
firstUserId: undefined,
secondUserId: undefined,
thirdUserId: undefined,
firstMoney: undefined,
secondMoney: undefined,
thirdMoney: undefined,
isInvalid: 0,
isSettled: 0,
settleTime: undefined
});
isUpdate.value = false;
}
} else {
resetFields();
}
},
{ immediate: true }
);
</script>
<style lang="less" scoped>
.dealer-section {
margin-bottom: 24px;
padding: 16px;
background: #fafafa;
border-radius: 6px;
border-left: 3px solid #1890ff;
.dealer-section {
margin-bottom: 24px;
padding: 16px;
background: #fafafa;
border-radius: 6px;
border-left: 3px solid #1890ff;
.dealer-title {
margin: 0 0 16px 0;
font-size: 14px;
font-weight: 600;
color: #333;
.dealer-title {
margin: 0 0 16px 0;
font-size: 14px;
font-weight: 600;
color: #333;
.ant-tag {
margin-right: 8px;
.ant-tag {
margin-right: 8px;
}
}
}
}
:deep(.ant-divider-horizontal.ant-divider-with-text-left) {
margin: 24px 0 16px 0;
:deep(.ant-divider-horizontal.ant-divider-with-text-left) {
margin: 24px 0 16px 0;
.ant-divider-inner-text {
padding: 0 16px 0 0;
.ant-divider-inner-text {
padding: 0 16px 0 0;
}
}
}
:deep(.ant-form-item) {
margin-bottom: 16px;
}
:deep(.ant-form-item) {
margin-bottom: 16px;
}
:deep(.ant-input-number) {
width: 100%;
}
:deep(.ant-input-number) {
width: 100%;
}
</style>

View File

@@ -21,7 +21,6 @@
/>
</template>
<template #bodyCell="{ column, record }">
<template v-if="column.key === 'title'">
<div>{{ record.title }}</div>
<div class="text-gray-400">业务员{{ record.userId }}</div>
@@ -51,15 +50,21 @@
<div class="dealer-info">
<div v-if="record.firstUserId" class="dealer-level">
<a-tag color="red">一级</a-tag>
用户{{ record.firstUserId }} - ¥{{ parseFloat(record.firstMoney || '0').toFixed(2) }}
用户{{ record.firstUserId }} - ¥{{
parseFloat(record.firstMoney || '0').toFixed(2)
}}
</div>
<div v-if="record.secondUserId" class="dealer-level">
<a-tag color="orange">二级</a-tag>
用户{{ record.secondUserId }} - ¥{{ parseFloat(record.secondMoney || '0').toFixed(2) }}
用户{{ record.secondUserId }} - ¥{{
parseFloat(record.secondMoney || '0').toFixed(2)
}}
</div>
<div v-if="record.thirdUserId" class="dealer-level">
<a-tag color="gold">三级</a-tag>
用户{{ record.thirdUserId }} - ¥{{ parseFloat(record.thirdMoney || '0').toFixed(2) }}
用户{{ record.thirdUserId }} - ¥{{
parseFloat(record.thirdMoney || '0').toFixed(2)
}}
</div>
</div>
</template>
@@ -90,28 +95,26 @@
<a @click="settleOrder(record)" class="ele-text-success">
结算
</a>
<a-divider type="vertical"/>
<a-divider type="vertical" />
</template>
<!-- <template v-if="record.isInvalid === 0">-->
<!-- <a-popconfirm-->
<!-- title="确定要标记此订单为失效吗?"-->
<!-- @confirm="invalidateOrder(record)"-->
<!-- placement="topRight"-->
<!-- >-->
<!-- <a class="text-purple-500">-->
<!-- 验证-->
<!-- </a>-->
<!-- </a-popconfirm>-->
<!-- </template>-->
<!-- <template v-if="record.isInvalid === 0">-->
<!-- <a-popconfirm-->
<!-- title="确定要标记此订单为失效吗?"-->
<!-- @confirm="invalidateOrder(record)"-->
<!-- placement="topRight"-->
<!-- >-->
<!-- <a class="text-purple-500">-->
<!-- 验证-->
<!-- </a>-->
<!-- </a-popconfirm>-->
<!-- </template>-->
<a-popconfirm
v-if="record.isSettled === 0"
title="确定要删除吗?"
@confirm="remove(record)"
placement="topRight"
>
<a class="text-red-500">
删除
</a>
<a class="text-red-500"> 删除 </a>
</a-popconfirm>
</template>
</template>
@@ -119,363 +122,384 @@
</a-card>
<!-- 编辑弹窗 -->
<ShopDealerOrderEdit v-model:visible="showEdit" :data="current" @done="reload"/>
<ShopDealerOrderEdit
v-model:visible="showEdit"
:data="current"
@done="reload"
/>
</a-page-header>
</template>
<script lang="ts" setup>
import {createVNode, ref} from 'vue';
import {message, Modal} from 'ant-design-vue';
import {
ExclamationCircleOutlined,
DollarOutlined,
} from '@ant-design/icons-vue';
import type {EleProTable} from 'ele-admin-pro';
import type {
DatasourceFunction,
ColumnItem
} from 'ele-admin-pro/es/ele-pro-table/types';
import Search from './components/search.vue';
import {getPageTitle} from '@/utils/common';
import ShopDealerOrderEdit from './components/shopDealerOrderEdit.vue';
import {pageShopDealerOrder, removeShopDealerOrder, removeBatchShopDealerOrder} from '@/api/shop/shopDealerOrder';
import type {ShopDealerOrder, ShopDealerOrderParam} from '@/api/shop/shopDealerOrder/model';
import {exportSdyDealerOrder, updateSdyDealerOrder} from "@/api/sdy/sdyDealerOrder";
import { createVNode, ref } from 'vue';
import { message, Modal } from 'ant-design-vue';
import {
ExclamationCircleOutlined,
DollarOutlined
} from '@ant-design/icons-vue';
import type { EleProTable } from 'ele-admin-pro';
import type {
DatasourceFunction,
ColumnItem
} from 'ele-admin-pro/es/ele-pro-table/types';
import Search from './components/search.vue';
import { getPageTitle } from '@/utils/common';
import ShopDealerOrderEdit from './components/shopDealerOrderEdit.vue';
import {
pageShopDealerOrder,
removeShopDealerOrder,
removeBatchShopDealerOrder
} from '@/api/shop/shopDealerOrder';
import type {
ShopDealerOrder,
ShopDealerOrderParam
} from '@/api/shop/shopDealerOrder/model';
import {
exportSdyDealerOrder,
updateSdyDealerOrder
} from '@/api/sdy/sdyDealerOrder';
// 表格实例
const tableRef = ref<InstanceType<typeof EleProTable> | null>(null);
// 表格实例
const tableRef = ref<InstanceType<typeof EleProTable> | null>(null);
// 表格选中数据
const selection = ref<ShopDealerOrder[]>([]);
// 当前编辑数据
const current = ref<ShopDealerOrder | null>(null);
// 是否显示编辑弹窗
const showEdit = ref(false);
// 加载状态
const loading = ref(true);
// 表格选中数据
const selection = ref<ShopDealerOrder[]>([]);
// 当前编辑数据
const current = ref<ShopDealerOrder | null>(null);
// 是否显示编辑弹窗
const showEdit = ref(false);
// 加载状态
const loading = ref(true);
// 当前搜索条件
const currentWhere = ref<ShopDealerOrderParam>({});
// 当前搜索条件
const currentWhere = ref<ShopDealerOrderParam>({});
// 表格数据源
const datasource: DatasourceFunction = ({
page,
limit,
where,
orders,
filters
}) => {
if (filters) {
where.status = filters.status;
}
// 保存当前搜索条件用于导出
currentWhere.value = {...where};
// 已结算订单
where.isSettled = 1;
return pageShopDealerOrder({
...where,
...orders,
// 表格数据源
const datasource: DatasourceFunction = ({
page,
limit
});
};
// 表格列配置
const columns = ref<ColumnItem[]>([
{
key: 'index',
width: 48,
align: 'center',
fixed: 'left',
hideInSetting: true,
customRender: ({index}) => index + (tableRef.value?.tableIndex ?? 0)
},
{
title: '客户名称',
dataIndex: 'title',
key: 'title',
width: 150
},
{
title: '订单编号',
dataIndex: 'orderNo',
key: 'orderNo',
align: 'center'
},
{
title: '结算电量',
dataIndex: 'orderPrice',
key: 'orderPrice',
align: 'center'
},
{
title: '换算成度',
dataIndex: 'degreePrice',
key: 'degreePrice',
align: 'center'
},
{
title: '结算单价',
dataIndex: 'price',
key: 'price',
align: 'center'
},
{
title: '结算金额',
dataIndex: 'settledPrice',
key: 'settledPrice',
align: 'center'
},
{
title: '税费',
dataIndex: 'rate',
key: 'rate',
align: 'center'
},
{
title: '实发金额',
dataIndex: 'payPrice',
key: 'payPrice',
align: 'center'
},
{
title: '签约状态',
dataIndex: 'isInvalid',
key: 'isInvalid',
align: 'center',
width: 100
},
{
title: '月份',
dataIndex: 'month',
key: 'month',
align: 'center',
width: 100
},
{
title: '结算状态',
dataIndex: 'isSettled',
key: 'isSettled',
align: 'center',
width: 100
},
{
title: '创建时间',
dataIndex: 'createTime',
key: 'createTime',
align: 'center'
}
// {
// title: '操作',
// key: 'action',
// width: 180,
// fixed: 'right',
// align: 'center',
// hideInSetting: true
// }
]);
/* 搜索 */
const reload = (where?: ShopDealerOrderParam) => {
selection.value = [];
tableRef?.value?.reload({where: where});
};
/* 结算单个订单 */
const settleOrder = (row: ShopDealerOrder) => {
const totalCommission = (parseFloat(row.firstMoney || '0') +
parseFloat(row.secondMoney || '0') +
parseFloat(row.thirdMoney || '0')).toFixed(2);
Modal.confirm({
title: '确认结算',
content: `确定要结算此订单吗?总佣金金额:¥${totalCommission}`,
icon: createVNode(DollarOutlined),
okText: '确认结算',
okType: 'primary',
cancelText: '取消',
onOk: () => {
const hide = message.loading('正在结算...', 0);
// 这里调用结算API
updateSdyDealerOrder({
...row,
isSettled: 1
})
setTimeout(() => {
hide();
message.success('结算成功');
reload();
}, 1000);
limit,
where,
orders,
filters
}) => {
if (filters) {
where.status = filters.status;
}
});
};
/* 批量结算 */
const batchSettle = () => {
if (!selection.value.length) {
message.error('请至少选择一条数据');
return;
}
const validOrders = selection.value.filter(order =>
order.isSettled === 0 && order.isInvalid === 0
);
if (!validOrders.length) {
message.error('所选订单中没有可结算的订单');
return;
}
const totalCommission = validOrders.reduce((sum, order) => {
return sum + parseFloat(order.firstMoney || '0') +
parseFloat(order.secondMoney || '0') +
parseFloat(order.thirdMoney || '0');
}, 0).toFixed(2);
Modal.confirm({
title: '批量结算确认',
content: `确定要结算选中的 ${validOrders.length} 个订单吗?总佣金金额:¥${totalCommission}`,
icon: createVNode(ExclamationCircleOutlined),
okText: '确认结算',
okType: 'primary',
cancelText: '取消',
onOk: () => {
const hide = message.loading('正在批量结算...', 0);
// 这里调用批量结算API
setTimeout(() => {
hide();
message.success(`成功结算 ${validOrders.length} 个订单`);
reload();
}, 1500);
}
});
};
/* 导出数据 */
const handleExport = () => {
// 调用导出API传入当前搜索条件
exportSdyDealerOrder(currentWhere.value);
};
/* 打开编辑弹窗 */
const openEdit = (row?: ShopDealerOrder) => {
current.value = row ?? null;
showEdit.value = true;
};
/* 删除单个 */
const remove = (row: ShopDealerOrder) => {
const hide = message.loading('请求中..', 0);
removeShopDealerOrder(row.id)
.then((msg) => {
hide();
message.success(msg);
reload();
})
.catch((e) => {
hide();
message.error(e.message);
// 保存当前搜索条件用于导出
currentWhere.value = { ...where };
// 已结算订单
where.isSettled = 1;
return pageShopDealerOrder({
...where,
...orders,
page,
limit
});
};
/* 批量删除 */
const removeBatch = () => {
if (!selection.value.length) {
message.error('请至少选择一条数据');
return;
}
Modal.confirm({
title: '提示',
content: '确定要删除选中的记录吗?',
icon: createVNode(ExclamationCircleOutlined),
maskClosable: true,
onOk: () => {
const hide = message.loading('请求中..', 0);
removeBatchShopDealerOrder(selection.value.map((d) => d.id))
.then((msg) => {
hide();
message.success(msg);
reload();
})
.catch((e) => {
hide();
message.error(e.message);
});
}
});
};
/* 查询 */
const query = () => {
loading.value = true;
};
/* 自定义行属性 */
const customRow = (record: ShopDealerOrder) => {
return {
// 行点击事件
onClick: () => {
// console.log(record);
},
// 行双击事件
onDblclick: () => {
openEdit(record);
}
};
};
query();
// 表格列配置
const columns = ref<ColumnItem[]>([
{
key: 'index',
width: 48,
align: 'center',
fixed: 'left',
hideInSetting: true,
customRender: ({ index }) => index + (tableRef.value?.tableIndex ?? 0)
},
{
title: '客户名称',
dataIndex: 'title',
key: 'title',
width: 150
},
{
title: '订单编号',
dataIndex: 'orderNo',
key: 'orderNo',
align: 'center'
},
{
title: '结算电量',
dataIndex: 'orderPrice',
key: 'orderPrice',
align: 'center'
},
{
title: '换算成度',
dataIndex: 'degreePrice',
key: 'degreePrice',
align: 'center'
},
{
title: '结算单价',
dataIndex: 'price',
key: 'price',
align: 'center'
},
{
title: '结算金额',
dataIndex: 'settledPrice',
key: 'settledPrice',
align: 'center'
},
{
title: '税费',
dataIndex: 'rate',
key: 'rate',
align: 'center'
},
{
title: '实发金额',
dataIndex: 'payPrice',
key: 'payPrice',
align: 'center'
},
{
title: '签约状态',
dataIndex: 'isInvalid',
key: 'isInvalid',
align: 'center',
width: 100
},
{
title: '月份',
dataIndex: 'month',
key: 'month',
align: 'center',
width: 100
},
{
title: '结算状态',
dataIndex: 'isSettled',
key: 'isSettled',
align: 'center',
width: 100
},
{
title: '创建时间',
dataIndex: 'createTime',
key: 'createTime',
align: 'center'
}
// {
// title: '操作',
// key: 'action',
// width: 180,
// fixed: 'right',
// align: 'center',
// hideInSetting: true
// }
]);
/* 搜索 */
const reload = (where?: ShopDealerOrderParam) => {
selection.value = [];
tableRef?.value?.reload({ where: where });
};
/* 结算单个订单 */
const settleOrder = (row: ShopDealerOrder) => {
const totalCommission = (
parseFloat(row.firstMoney || '0') +
parseFloat(row.secondMoney || '0') +
parseFloat(row.thirdMoney || '0')
).toFixed(2);
Modal.confirm({
title: '确认结算',
content: `确定要结算此订单吗?总佣金金额:¥${totalCommission}`,
icon: createVNode(DollarOutlined),
okText: '确认结算',
okType: 'primary',
cancelText: '取消',
onOk: () => {
const hide = message.loading('正在结算...', 0);
// 这里调用结算API
updateSdyDealerOrder({
...row,
isSettled: 1
});
setTimeout(() => {
hide();
message.success('结算成功');
reload();
}, 1000);
}
});
};
/* 批量结算 */
const batchSettle = () => {
if (!selection.value.length) {
message.error('请至少选择一条数据');
return;
}
const validOrders = selection.value.filter(
(order) => order.isSettled === 0 && order.isInvalid === 0
);
if (!validOrders.length) {
message.error('所选订单中没有可结算的订单');
return;
}
const totalCommission = validOrders
.reduce((sum, order) => {
return (
sum +
parseFloat(order.firstMoney || '0') +
parseFloat(order.secondMoney || '0') +
parseFloat(order.thirdMoney || '0')
);
}, 0)
.toFixed(2);
Modal.confirm({
title: '批量结算确认',
content: `确定要结算选中的 ${validOrders.length} 个订单吗?总佣金金额:¥${totalCommission}`,
icon: createVNode(ExclamationCircleOutlined),
okText: '确认结算',
okType: 'primary',
cancelText: '取消',
onOk: () => {
const hide = message.loading('正在批量结算...', 0);
// 这里调用批量结算API
setTimeout(() => {
hide();
message.success(`成功结算 ${validOrders.length} 个订单`);
reload();
}, 1500);
}
});
};
/* 导出数据 */
const handleExport = () => {
// 调用导出API传入当前搜索条件
exportSdyDealerOrder(currentWhere.value);
};
/* 打开编辑弹窗 */
const openEdit = (row?: ShopDealerOrder) => {
current.value = row ?? null;
showEdit.value = true;
};
/* 删除单个 */
const remove = (row: ShopDealerOrder) => {
const hide = message.loading('请求中..', 0);
removeShopDealerOrder(row.id)
.then((msg) => {
hide();
message.success(msg);
reload();
})
.catch((e) => {
hide();
message.error(e.message);
});
};
/* 批量删除 */
const removeBatch = () => {
if (!selection.value.length) {
message.error('请至少选择一条数据');
return;
}
Modal.confirm({
title: '提示',
content: '确定要删除选中的记录吗?',
icon: createVNode(ExclamationCircleOutlined),
maskClosable: true,
onOk: () => {
const hide = message.loading('请求中..', 0);
removeBatchShopDealerOrder(selection.value.map((d) => d.id))
.then((msg) => {
hide();
message.success(msg);
reload();
})
.catch((e) => {
hide();
message.error(e.message);
});
}
});
};
/* 查询 */
const query = () => {
loading.value = true;
};
/* 自定义行属性 */
const customRow = (record: ShopDealerOrder) => {
return {
// 行点击事件
onClick: () => {
// console.log(record);
},
// 行双击事件
onDblclick: () => {
openEdit(record);
}
};
};
query();
</script>
<script lang="ts">
export default {
name: 'ShopDealerOrder'
};
export default {
name: 'ShopDealerOrder'
};
</script>
<style lang="less" scoped>
.order-info {
.order-id {
font-weight: 500;
color: #333;
margin-bottom: 4px;
}
.order-info {
.order-id {
font-weight: 500;
color: #333;
margin-bottom: 4px;
}
.order-price {
color: #ff4d4f;
font-weight: 600;
}
}
.dealer-info {
.dealer-level {
margin-bottom: 6px;
font-size: 12px;
&:last-child {
margin-bottom: 0;
.order-price {
color: #ff4d4f;
font-weight: 600;
}
}
}
:deep(.detail-section) {
h4 {
color: #1890ff;
margin-bottom: 12px;
border-bottom: 1px solid #f0f0f0;
padding-bottom: 8px;
.dealer-info {
.dealer-level {
margin-bottom: 6px;
font-size: 12px;
&:last-child {
margin-bottom: 0;
}
}
}
p {
margin: 4px 0;
line-height: 1.5;
:deep(.detail-section) {
h4 {
color: #1890ff;
margin-bottom: 12px;
border-bottom: 1px solid #f0f0f0;
padding-bottom: 8px;
}
p {
margin: 4px 0;
line-height: 1.5;
}
}
}
:deep(.ant-table-tbody > tr > td) {
vertical-align: top;
}
:deep(.ant-table-tbody > tr > td) {
vertical-align: top;
}
:deep(.ant-tag) {
margin: 2px 4px 2px 0;
}
:deep(.ant-tag) {
margin: 2px 4px 2px 0;
}
</style>

View File

@@ -40,7 +40,7 @@
<a-select v-model:value="form.type" placeholder="请选择类型">
<a-select-option :value="0">经销商</a-select-option>
<a-select-option :value="1">门店</a-select-option>
<!-- <a-select-option :value="2">集团</a-select-option>-->
<!-- <a-select-option :value="2">集团</a-select-option>-->
</a-select>
</a-form-item>
</a-col>
@@ -65,20 +65,20 @@
/>
</a-form-item>
</a-col>
<!-- <a-col :span="12">-->
<!-- <a-form-item-->
<!-- label="支付密码"-->
<!-- name="payPassword"-->
<!-- :help="isUpdate ? '留空表示不修改' : undefined"-->
<!-- >-->
<!-- <a-input-password-->
<!-- allow-clear-->
<!-- :maxlength="20"-->
<!-- placeholder="请输入支付密码"-->
<!-- v-model:value="form.payPassword"-->
<!-- />-->
<!-- </a-form-item>-->
<!-- </a-col>-->
<!-- <a-col :span="12">-->
<!-- <a-form-item-->
<!-- label="支付密码"-->
<!-- name="payPassword"-->
<!-- :help="isUpdate ? '留空表示不修改' : undefined"-->
<!-- >-->
<!-- <a-input-password-->
<!-- allow-clear-->
<!-- :maxlength="20"-->
<!-- placeholder="请输入支付密码"-->
<!-- v-model:value="form.payPassword"-->
<!-- />-->
<!-- </a-form-item>-->
<!-- </a-col>-->
<a-col :span="12">
<a-form-item label="头像" name="image">
<a-image :src="form.avatar" :width="50" :preview="false" />
@@ -144,44 +144,44 @@
/>
</a-form-item>
</a-col>
<!-- <a-col :span="12">-->
<!-- <a-form-item label="单价" name="price">-->
<!-- <a-input-number-->
<!-- class="ele-fluid"-->
<!-- :min="0"-->
<!-- :precision="2"-->
<!-- stringMode-->
<!-- placeholder="0.00"-->
<!-- v-model:value="form.price"-->
<!-- />-->
<!-- </a-form-item>-->
<!-- </a-col>-->
<!-- <a-col :span="12">-->
<!-- <a-form-item label="单价" name="price">-->
<!-- <a-input-number-->
<!-- class="ele-fluid"-->
<!-- :min="0"-->
<!-- :precision="2"-->
<!-- stringMode-->
<!-- placeholder="0.00"-->
<!-- v-model:value="form.price"-->
<!-- />-->
<!-- </a-form-item>-->
<!-- </a-col>-->
</a-row>
<!-- <a-row :gutter="16">-->
<!-- <a-col :span="12">-->
<!-- <a-form-item label="排序号" name="sortNumber">-->
<!-- <a-input-number-->
<!-- :min="0"-->
<!-- :max="9999"-->
<!-- class="ele-fluid"-->
<!-- placeholder="请输入排序号"-->
<!-- v-model:value="form.sortNumber"-->
<!-- />-->
<!-- </a-form-item>-->
<!-- </a-col>-->
<!-- <a-col :span="12">-->
<!-- <a-form-item label="备注" name="comments">-->
<!-- <a-textarea-->
<!-- :rows="3"-->
<!-- :maxlength="200"-->
<!-- show-count-->
<!-- placeholder="请输入备注"-->
<!-- v-model:value="form.comments"-->
<!-- />-->
<!-- </a-form-item>-->
<!-- </a-col>-->
<!-- </a-row>-->
<!-- <a-row :gutter="16">-->
<!-- <a-col :span="12">-->
<!-- <a-form-item label="排序号" name="sortNumber">-->
<!-- <a-input-number-->
<!-- :min="0"-->
<!-- :max="9999"-->
<!-- class="ele-fluid"-->
<!-- placeholder="请输入排序号"-->
<!-- v-model:value="form.sortNumber"-->
<!-- />-->
<!-- </a-form-item>-->
<!-- </a-col>-->
<!-- <a-col :span="12">-->
<!-- <a-form-item label="备注" name="comments">-->
<!-- <a-textarea-->
<!-- :rows="3"-->
<!-- :maxlength="200"-->
<!-- show-count-->
<!-- placeholder="请输入备注"-->
<!-- v-model:value="form.comments"-->
<!-- />-->
<!-- </a-form-item>-->
<!-- </a-col>-->
<!-- </a-row>-->
</a-form>
</ele-modal>
</template>
@@ -190,7 +190,10 @@
import { computed, ref, reactive, watch } from 'vue';
import { Form, message } from 'ant-design-vue';
import { assignObject, toDateString, uuid } from 'ele-admin-pro';
import { addShopDealerUser, updateShopDealerUser } from '@/api/shop/shopDealerUser';
import {
addShopDealerUser,
updateShopDealerUser
} from '@/api/shop/shopDealerUser';
import { ShopDealerUser } from '@/api/shop/shopDealerUser/model';
import { useThemeStore } from '@/store/modules/theme';
import { storeToRefs } from 'pinia';
@@ -260,11 +263,15 @@
};
const createTimeText = computed(() => {
return form.createTime ? toDateString(form.createTime, 'yyyy-MM-dd HH:mm:ss') : '';
return form.createTime
? toDateString(form.createTime, 'yyyy-MM-dd HH:mm:ss')
: '';
});
const updateTimeText = computed(() => {
return form.updateTime ? toDateString(form.updateTime, 'yyyy-MM-dd HH:mm:ss') : '';
return form.updateTime
? toDateString(form.updateTime, 'yyyy-MM-dd HH:mm:ss')
: '';
});
const selectedUserText = ref<string>('');
@@ -369,13 +376,7 @@
.then(() => {
loading.value = true;
// 不在弹窗里编辑的字段不提交避免误更新如自增ID、删除标识等
const {
isDelete,
tenantId,
createTime,
updateTime,
...rest
} = form;
const { isDelete, tenantId, createTime, updateTime, ...rest } = form;
const formData: ShopDealerUser = { ...rest };
// userId 新增需要,编辑不允许修改
if (isUpdate.value) {
@@ -385,7 +386,9 @@
if (isUpdate.value && !formData.payPassword) {
delete formData.payPassword;
}
const saveOrUpdate = isUpdate.value ? updateShopDealerUser : addShopDealerUser;
const saveOrUpdate = isUpdate.value
? updateShopDealerUser
: addShopDealerUser;
saveOrUpdate(formData)
.then((msg) => {
loading.value = false;
@@ -412,12 +415,12 @@
// 不回显密码,避免误操作
form.payPassword = '';
selectedUserText.value = '';
if(props.data.image){
if (props.data.image) {
images.value.push({
uid: uuid(),
url: props.data.image,
status: 'done'
})
});
}
isUpdate.value = true;
} else {

View File

@@ -1,85 +1,100 @@
<template>
<a-page-header :title="getPageTitle()" @back="() => $router.go(-1)">
<a-card :bordered="false" :body-style="{ padding: '16px' }">
<ele-pro-table
ref="tableRef"
row-key="id"
:columns="columns"
:datasource="datasource"
:customRow="customRow"
tool-class="ele-toolbar-form"
class="sys-org-table"
>
<template #toolbar>
<search
@search="reload"
:selection="selection"
@add="openEdit"
@remove="removeBatch"
@batchMove="openMove"
<a-card :bordered="false" :body-style="{ padding: '16px' }">
<ele-pro-table
ref="tableRef"
row-key="id"
:columns="columns"
:datasource="datasource"
:customRow="customRow"
tool-class="ele-toolbar-form"
class="sys-org-table"
>
<template #toolbar>
<search
@search="reload"
:selection="selection"
@add="openEdit"
@remove="removeBatch"
@batchMove="openMove"
/>
</template>
<template #bodyCell="{ column, record }">
<template v-if="column.key === 'image'">
<a-image :src="record.image" :width="50" />
</template>
<template v-if="column.key === 'type'">
<a-tag v-if="record.type === 0">经销商</a-tag>
<a-tag v-if="record.type === 1" color="orange">门店</a-tag>
<!-- <a-tag v-if="record.type === 2" color="purple">集团</a-tag>-->
</template>
<template v-if="column.key === 'qrcode'">
<QrcodeOutlined
:style="{ fontSize: '24px' }"
@click="openQrCode(record)"
/>
</template>
<template #bodyCell="{ column, record }">
<template v-if="column.key === 'image'">
<a-image :src="record.image" :width="50" />
</template>
<template v-if="column.key === 'type'">
<a-tag v-if="record.type === 0">经销商</a-tag>
<a-tag v-if="record.type === 1" color="orange">门店</a-tag>
<!-- <a-tag v-if="record.type === 2" color="purple">集团</a-tag>-->
</template>
<template v-if="column.key === 'qrcode'">
<QrcodeOutlined :style="{fontSize: '24px'}" @click="openQrCode(record)" />
</template>
<template v-if="column.key === 'status'">
<a-tag v-if="record.status === 0" color="green">显示</a-tag>
<a-tag v-if="record.status === 1" color="red">隐藏</a-tag>
</template>
<template v-if="column.key === 'action'">
<a-space>
<a @click="openEdit(record)">修改</a>
<a-divider type="vertical" />
<a-popconfirm
title="确定要删除此记录吗?"
@confirm="remove(record)"
>
<a class="ele-text-danger">删除</a>
</a-popconfirm>
</a-space>
</template>
<template v-if="column.key === 'status'">
<a-tag v-if="record.status === 0" color="green">显示</a-tag>
<a-tag v-if="record.status === 1" color="red">隐藏</a-tag>
</template>
</ele-pro-table>
</a-card>
<template v-if="column.key === 'action'">
<a-space>
<a @click="openEdit(record)">修改</a>
<a-divider type="vertical" />
<a-popconfirm
title="确定要删除此记录吗?"
@confirm="remove(record)"
>
<a class="ele-text-danger">删除</a>
</a-popconfirm>
</a-space>
</template>
</template>
</ele-pro-table>
</a-card>
<!-- 编辑弹窗 -->
<ShopDealerUserEdit v-model:visible="showEdit" :data="current" @done="reload" />
<!-- 编辑弹窗 -->
<ShopDealerUserEdit
v-model:visible="showEdit"
:data="current"
@done="reload"
/>
<!-- 二维码预览 -->
<a-modal
v-model:visible="showQrModal"
:title="qrModalTitle"
:footer="null"
:width="380"
centered
destroy-on-close
>
<div style="display: flex; justify-content: center">
<a-image v-if="qrModalUrl" :src="qrModalUrl" :width="280" :preview="false" />
</div>
<div style="display: flex; justify-content: center; margin-top: 12px">
<a-space>
<a-button @click="copyQrUrl">复制链接</a-button>
<a-button type="primary" @click="openQrInNewTab">打开原图</a-button>
</a-space>
</div>
</a-modal>
<!-- 二维码预览 -->
<a-modal
v-model:visible="showQrModal"
:title="qrModalTitle"
:footer="null"
:width="380"
centered
destroy-on-close
>
<div style="display: flex; justify-content: center">
<a-image
v-if="qrModalUrl"
:src="qrModalUrl"
:width="280"
:preview="false"
/>
</div>
<div style="display: flex; justify-content: center; margin-top: 12px">
<a-space>
<a-button @click="copyQrUrl">复制链接</a-button>
<a-button type="primary" @click="openQrInNewTab">打开原图</a-button>
</a-space>
</div>
</a-modal>
</a-page-header>
</template>
<script lang="ts" setup>
import { createVNode, ref, computed } from 'vue';
import { message, Modal } from 'ant-design-vue';
import { ExclamationCircleOutlined, QrcodeOutlined } from '@ant-design/icons-vue';
import {
ExclamationCircleOutlined,
QrcodeOutlined
} from '@ant-design/icons-vue';
import type { EleProTable } from 'ele-admin-pro';
import { toDateString } from 'ele-admin-pro';
import type {
@@ -87,10 +102,17 @@
ColumnItem
} from 'ele-admin-pro/es/ele-pro-table/types';
import Search from './components/search.vue';
import {getPageTitle} from '@/utils/common';
import { getPageTitle } from '@/utils/common';
import ShopDealerUserEdit from './components/shopDealerUserEdit.vue';
import { pageShopDealerUser, removeShopDealerUser, removeBatchShopDealerUser } from '@/api/shop/shopDealerUser';
import type { ShopDealerUser, ShopDealerUserParam } from '@/api/shop/shopDealerUser/model';
import {
pageShopDealerUser,
removeShopDealerUser,
removeBatchShopDealerUser
} from '@/api/shop/shopDealerUser';
import type {
ShopDealerUser,
ShopDealerUserParam
} from '@/api/shop/shopDealerUser/model';
// 表格实例
const tableRef = ref<InstanceType<typeof EleProTable> | null>(null);
@@ -111,7 +133,9 @@
const loading = ref(true);
const getQrCodeUrl = (userId?: number) => {
return `https://mp-api.websoft.top/api/wx-login/getOrderQRCodeUnlimited/uid_${userId ?? ''}`;
return `https://mp-api.websoft.top/api/wx-login/getOrderQRCodeUnlimited/uid_${
userId ?? ''
}`;
};
const openQrCode = (row: ShopDealerUser) => {
@@ -120,7 +144,9 @@
return;
}
qrModalUrl.value = getQrCodeUrl(row.userId);
qrModalTitle.value = row.realName ? `${row.realName} 的二维码` : `UID_${row.userId} 二维码`;
qrModalTitle.value = row.realName
? `${row.realName} 的二维码`
: `UID_${row.userId} 二维码`;
showQrModal.value = true;
};
@@ -168,7 +194,7 @@
title: '用户ID',
dataIndex: 'userId',
key: 'userId',
width: 90,
width: 90
},
{
title: '类型',

View File

@@ -128,8 +128,8 @@
const normalized: any = Array.isArray(data)
? data.find((d) => d?.settingKey === settingKey) ?? data[0]
: (data as any).data && typeof (data as any).data === 'object'
? (data as any).data
: data;
? (data as any).data
: data;
let parsedContent: any | undefined;
const rawContent = (normalized as any).content;

View File

@@ -172,8 +172,8 @@
const normalized: any = Array.isArray(data)
? data.find((d) => d?.settingKey === settingKey.value) ?? data[0]
: (data as any).data && typeof (data as any).data === 'object'
? (data as any).data
: data;
? (data as any).data
: data;
let parsedContent: any | undefined;
const rawContent = (normalized as any).content;

View File

@@ -210,8 +210,8 @@
const normalized: any = Array.isArray(data)
? data.find((d) => d?.settingKey === settingKey.value) ?? data[0]
: (data as any).data && typeof (data as any).data === 'object'
? (data as any).data
: data;
? (data as any).data
: data;
let parsedContent: any | undefined;
const rawContent = (normalized as any).content;

View File

@@ -5,9 +5,9 @@
:body-style="{ paddingTop: '0px', minHeight: '800px' }"
>
<a-tabs v-model:active-key="active">
<!-- <a-tab-pane tab="网站设置" key="website">-->
<!-- <Website v-model:value="active" :data="data" />-->
<!-- </a-tab-pane>-->
<!-- <a-tab-pane tab="网站设置" key="website">-->
<!-- <Website v-model:value="active" :data="data" />-->
<!-- </a-tab-pane>-->
<a-tab-pane tab="上传设置" key="upload">
<Upload v-model:value="active" :data="data" />
</a-tab-pane>

View File

@@ -101,7 +101,7 @@ export default defineConfig(({ command, mode }) => {
// GET /ai-proxy/models -> https://ai.websoft.top/api/v1/models
// POST /ai-proxy/chat/completions -> https://ai.websoft.top/api/v1/chat/completions
'/ai-proxy': {
target: env.AI_PROXY_TARGET || 'https://ai-api.websoft.top',
target: env.AI_PROXY_TARGET || 'http://127.0.0.1:11434',
changeOrigin: true,
secure: false,
rewrite: (path) =>
@@ -124,10 +124,10 @@ export default defineConfig(({ command, mode }) => {
}
},
// Ollama native API reverse proxy (dev only).
// GET /proxy/api/tags -> http://47.119.165.234:11434/api/tags
// POST /proxy/api/chat -> http://47.119.165.234:11434/api/chat
// GET /proxy/api/tags -> http://127.0.0.1:11434/api/tags
// POST /proxy/api/chat -> http://127.0.0.1:11434/api/chat
'/proxy': {
target: 'http://47.119.165.234:11434',
target: 'http://127.0.0.1:11434',
changeOrigin: true,
secure: false,
rewrite: (path) => path.replace(/^\/proxy/, '')