260616
This commit is contained in:
@@ -130,3 +130,19 @@ export async function importShopGoods(file: File) {
|
||||
}
|
||||
return Promise.reject(new Error(res.data.message));
|
||||
}
|
||||
|
||||
/**
|
||||
* 导入商品图片
|
||||
*/
|
||||
export async function importShopGoodsImages(file: File) {
|
||||
const formData = new FormData();
|
||||
formData.append('file', file);
|
||||
const res = await request.post<ApiResult<unknown>>(
|
||||
MODULES_API_URL + '/shop/shop-goods/import/images',
|
||||
formData
|
||||
);
|
||||
if (res.data.code === 0) {
|
||||
return res.data.message;
|
||||
}
|
||||
return Promise.reject(new Error(res.data.message));
|
||||
}
|
||||
|
||||
@@ -14,6 +14,8 @@ export interface ShopGoodsCategory {
|
||||
type?: number;
|
||||
// 分类图片
|
||||
image?: string;
|
||||
// 广告图
|
||||
adImage?: string;
|
||||
// 上级分类ID
|
||||
parentId?: number;
|
||||
// 路由/链接地址
|
||||
|
||||
@@ -20,6 +20,10 @@ export interface Payment {
|
||||
appId?: string;
|
||||
// 商户号
|
||||
mchId?: string;
|
||||
// 子商户应用ID
|
||||
subAppId?: string;
|
||||
// 子商户号
|
||||
subMchId?: string;
|
||||
// 设置APIv3密钥
|
||||
apiKey?: string;
|
||||
// 证书文件 (CERT)
|
||||
|
||||
@@ -8,7 +8,7 @@ export const APP_SECRET = import.meta.env.VITE_APP_SECRET || '';
|
||||
export const domain = import.meta.env.VITE_DOMAIN || 'https://your-domain.com';
|
||||
// 主节点
|
||||
export const SERVER_API_URL =
|
||||
import.meta.env.VITE_SERVER_API_URL || 'https://your-api.com/api';
|
||||
import.meta.env.VITE_SERVER_API_URL || 'https://server.websoft.top/api';
|
||||
// 模块节点
|
||||
export const MODULES_API_URL =
|
||||
localStorage.getItem('ApiUrl') || import.meta.env.VITE_API_URL;
|
||||
@@ -74,7 +74,7 @@ export const MAP_KEY = import.meta.env.VITE_MAP_KEY || '';
|
||||
// 高德地图 安全密钥
|
||||
export const MAP_CODE = import.meta.env.VITE_MAP_CODE || '';
|
||||
// WebSoftAdmin 授权码, 自带的只能用于演示, 正式项目请更换为自己的授权码
|
||||
export const LICENSE_CODE = import.meta.env.VITE_LICENSE_CODE || '';
|
||||
export const LICENSE_CODE = 'dk9mcwJyetRWQlxWRiojIzJCLi8mcQ5Wa4ojI0NWZqJWd6ICZpJCL0kjNvdjbE5WQ2AjIvl2cyVmdiwiIiETMuEjI6IibQf0NW==';
|
||||
// 缩略图前缀
|
||||
export const FILE_THUMBNAIL = FILE_SERVER + '/thumbnail';
|
||||
// 文件下载前缀
|
||||
|
||||
@@ -25,6 +25,12 @@
|
||||
</template>
|
||||
<span>导入</span>
|
||||
</a-button>
|
||||
<a-button type="dashed" class="ele-btn-icon" @click="openImageImport">
|
||||
<template #icon>
|
||||
<UploadOutlined />
|
||||
</template>
|
||||
<span>导入图片</span>
|
||||
</a-button>
|
||||
<a-button type="dashed" class="ele-btn-icon" @click="handleExport">
|
||||
导出xls
|
||||
</a-button>
|
||||
@@ -105,6 +111,7 @@
|
||||
(e: 'remove'): void;
|
||||
(e: 'batchMove'): void;
|
||||
(e: 'import'): void;
|
||||
(e: 'imageImport'): void;
|
||||
(e: 'export'): void;
|
||||
}>();
|
||||
|
||||
@@ -123,6 +130,10 @@
|
||||
emit('import');
|
||||
};
|
||||
|
||||
const openImageImport = () => {
|
||||
emit('imageImport');
|
||||
};
|
||||
|
||||
// 导出
|
||||
const handleExport = () => {
|
||||
emit('export');
|
||||
|
||||
@@ -23,6 +23,7 @@
|
||||
@remove="removeBatch"
|
||||
@batchMove="openMove"
|
||||
@import="openImport"
|
||||
@imageImport="openImageImport"
|
||||
@export="handleExport"
|
||||
/>
|
||||
</template>
|
||||
@@ -85,6 +86,11 @@
|
||||
v-model:visible="showImport"
|
||||
@done="reload"
|
||||
/>
|
||||
|
||||
<ShopGoodsImageImport
|
||||
v-model:visible="showImageImport"
|
||||
@done="reload"
|
||||
/>
|
||||
</a-page-header>
|
||||
</template>
|
||||
|
||||
@@ -107,6 +113,7 @@
|
||||
import ShopGoodsEdit from './components/shopGoodsEdit.vue';
|
||||
import Extra from '@/views/shop/shopGoods/components/extra.vue';
|
||||
import ShopGoodsImport from './components/shop-goods-import.vue';
|
||||
import ShopGoodsImageImport from './components/shop-goods-image-import.vue';
|
||||
import { listShopGoods, pageShopGoods, removeShopGoods, removeBatchShopGoods, updateShopGoods } from '@/api/shop/shopGoods';
|
||||
import type { ShopGoods, ShopGoodsParam } from '@/api/shop/shopGoods/model';
|
||||
import { getPageTitle } from '@/utils/common';
|
||||
@@ -128,6 +135,8 @@
|
||||
const showEdit = ref(false);
|
||||
// 是否显示导入弹窗
|
||||
const showImport = ref(false);
|
||||
// 是否显示图片导入弹窗
|
||||
const showImageImport = ref(false);
|
||||
// 是否显示批量移动弹窗
|
||||
const showMove = ref(false);
|
||||
// 加载状态
|
||||
@@ -259,6 +268,11 @@
|
||||
showImport.value = true;
|
||||
};
|
||||
|
||||
/* 打开图片导入弹窗 */
|
||||
const openImageImport = () => {
|
||||
showImageImport.value = true;
|
||||
};
|
||||
|
||||
/* 导出商品列表 */
|
||||
const handleExport = async () => {
|
||||
if (loading.value) {
|
||||
|
||||
@@ -57,6 +57,22 @@
|
||||
</div>
|
||||
</a-upload>
|
||||
</a-form-item>
|
||||
<a-form-item label="广告图" name="adImage">
|
||||
<a-upload
|
||||
:before-upload="handleAdImageUpload"
|
||||
:show-upload-list="false"
|
||||
accept="image/*"
|
||||
>
|
||||
<a-button v-if="!form.adImage">
|
||||
<template #icon><UploadOutlined /></template>
|
||||
上传广告图
|
||||
</a-button>
|
||||
<div v-else class="flex items-center gap-2">
|
||||
<img :src="form.adImage" style="width: 120px; height: 60px; object-fit: cover; border-radius: 4px; border: 1px solid #d9d9d9;" />
|
||||
<a-button type="text" danger size="small" @click.stop="form.adImage = undefined">删除</a-button>
|
||||
</div>
|
||||
</a-upload>
|
||||
</a-form-item>
|
||||
<a-form-item label="排序号" name="sortNumber">
|
||||
<a-input-number
|
||||
:min="0"
|
||||
@@ -124,6 +140,7 @@
|
||||
title: undefined,
|
||||
type: 0,
|
||||
image: undefined,
|
||||
adImage: undefined,
|
||||
parentId: undefined,
|
||||
path: undefined,
|
||||
component: undefined,
|
||||
@@ -235,6 +252,23 @@
|
||||
return false; // 阻止默认上传
|
||||
};
|
||||
|
||||
const handleAdImageUpload = async (file: File) => {
|
||||
const isImage = file.type?.startsWith('image/');
|
||||
if (!isImage) {
|
||||
message.error('只能上传图片文件');
|
||||
return false;
|
||||
}
|
||||
try {
|
||||
const res = await uploadFile(file);
|
||||
if (res?.path) {
|
||||
form.adImage = res.path;
|
||||
}
|
||||
} catch (e: any) {
|
||||
message.error(e.message || '上传失败');
|
||||
}
|
||||
return false;
|
||||
};
|
||||
|
||||
watch(
|
||||
() => props.visible,
|
||||
(visible) => {
|
||||
@@ -250,6 +284,7 @@
|
||||
title: undefined,
|
||||
type: 0,
|
||||
image: undefined,
|
||||
adImage: undefined,
|
||||
parentId: undefined,
|
||||
sortNumber: 100,
|
||||
comments: undefined,
|
||||
|
||||
@@ -33,6 +33,14 @@
|
||||
{{ record.type === 0 ? '商城分类' : '外卖分类' }}
|
||||
</a-tag>
|
||||
</template>
|
||||
<template v-if="column.key === 'adImage'">
|
||||
<img
|
||||
v-if="record.adImage"
|
||||
:src="record.adImage"
|
||||
style="width: 72px; height: 40px; object-fit: cover; border-radius: 4px;"
|
||||
/>
|
||||
<span v-else>-</span>
|
||||
</template>
|
||||
<template v-if="column.key === 'parentId'">
|
||||
{{ getParentName(record.parentId) }}
|
||||
</template>
|
||||
@@ -164,6 +172,13 @@
|
||||
align: 'center',
|
||||
width: 100
|
||||
},
|
||||
{
|
||||
title: '广告图',
|
||||
dataIndex: 'adImage',
|
||||
key: 'adImage',
|
||||
align: 'center',
|
||||
width: 110
|
||||
},
|
||||
{
|
||||
title: '上级分类',
|
||||
dataIndex: 'parentId',
|
||||
|
||||
@@ -51,6 +51,22 @@
|
||||
v-model:value="form.mchId"
|
||||
/>
|
||||
</a-form-item>
|
||||
<template v-if="form.wechatType === 1">
|
||||
<a-form-item label="子商户APPID" name="subAppId">
|
||||
<a-input
|
||||
allow-clear
|
||||
placeholder="请输入子商户APPID"
|
||||
v-model:value="form.subAppId"
|
||||
/>
|
||||
</a-form-item>
|
||||
<a-form-item label="子商户号" name="subMchId">
|
||||
<a-input
|
||||
allow-clear
|
||||
placeholder="请输入子商户号"
|
||||
v-model:value="form.subMchId"
|
||||
/>
|
||||
</a-form-item>
|
||||
</template>
|
||||
<a-form-item label="设置APIv3密钥" name="apiKey">
|
||||
<a-input-password
|
||||
allow-clear
|
||||
@@ -176,6 +192,8 @@
|
||||
wechatType: 0,
|
||||
appId: '',
|
||||
mchId: '',
|
||||
subAppId: '',
|
||||
subMchId: '',
|
||||
apiKey: '',
|
||||
pubKey: '',
|
||||
pubKeyId: '',
|
||||
@@ -221,6 +239,34 @@
|
||||
trigger: 'blur'
|
||||
}
|
||||
],
|
||||
subAppId: [
|
||||
{
|
||||
required: true,
|
||||
type: 'string',
|
||||
message: '请填写子商户APPID',
|
||||
trigger: 'blur',
|
||||
validator: async (_rule, value: string) => {
|
||||
if (form.code === '1' && form.wechatType === 1 && !value) {
|
||||
return Promise.reject('请填写子商户APPID');
|
||||
}
|
||||
return Promise.resolve();
|
||||
}
|
||||
}
|
||||
],
|
||||
subMchId: [
|
||||
{
|
||||
required: true,
|
||||
type: 'string',
|
||||
message: '请填写子商户号',
|
||||
trigger: 'blur',
|
||||
validator: async (_rule, value: string) => {
|
||||
if (form.code === '1' && form.wechatType === 1 && !value) {
|
||||
return Promise.reject('请填写子商户号');
|
||||
}
|
||||
return Promise.resolve();
|
||||
}
|
||||
}
|
||||
],
|
||||
wechatType: [
|
||||
{
|
||||
required: true,
|
||||
@@ -268,14 +314,6 @@
|
||||
message: '请填写支付通知地址',
|
||||
trigger: 'blur'
|
||||
}
|
||||
],
|
||||
merchantSerialNumber: [
|
||||
{
|
||||
required: true,
|
||||
type: 'string',
|
||||
message: '请填写商户证书序列号',
|
||||
trigger: 'blur'
|
||||
}
|
||||
]
|
||||
});
|
||||
|
||||
@@ -325,6 +363,10 @@
|
||||
const formData = {
|
||||
...form
|
||||
};
|
||||
if (!(formData.code === '1' && formData.wechatType === 1)) {
|
||||
formData.subAppId = '';
|
||||
formData.subMchId = '';
|
||||
}
|
||||
console.log(form);
|
||||
const saveOrUpdate = isUpdate.value ? updatePayment : addPayment;
|
||||
saveOrUpdate(formData)
|
||||
|
||||
Reference in New Issue
Block a user