1
This commit is contained in:
11
.env
Normal file
11
.env
Normal file
@@ -0,0 +1,11 @@
|
|||||||
|
# 租户配置(必填)
|
||||||
|
VITE_TENANT_ID=10606
|
||||||
|
|
||||||
|
# 租户名称
|
||||||
|
VITE_TENANT_NAME=桂礼序
|
||||||
|
|
||||||
|
# WebSoftAdmin 授权码 (必填-请联系官方获取)
|
||||||
|
VITE_LICENSE_CODE=dk9mcwJyetRWQlxWRiojIzJCLi8mcQ5Wa4ojI0NWZqJWd6ICZpJCL0kjNvdjbE5WQ2AjIvl2cyVmdiwiIiETMuEjI6IibQf0NW==
|
||||||
|
|
||||||
|
# 服务端 API 配置(可选)
|
||||||
|
VITE_SERVER_API_URL=https://server.websoft.top/api
|
||||||
7
.env.development
Normal file
7
.env.development
Normal file
@@ -0,0 +1,7 @@
|
|||||||
|
VITE_APP_NAME=后台管理(开发环境)
|
||||||
|
#VITE_API_URL=http://127.0.0.1:9200/api
|
||||||
|
#VITE_SERVER_API_URL=http://127.0.0.1:8000/api
|
||||||
|
|
||||||
|
#
|
||||||
|
VITE_API_URL=https://guilixu-api.websoft.top/api
|
||||||
|
#VITE_SERVER_API_URL=http://47.107.249.41:8000/api
|
||||||
6
.env.production
Normal file
6
.env.production
Normal file
@@ -0,0 +1,6 @@
|
|||||||
|
# 服务端 API 配置(可选)
|
||||||
|
VITE_SERVER_API_URL=https://server.websoft.top/api
|
||||||
|
# API 配置(必填)
|
||||||
|
VITE_API_URL=https://guilixu-api.websoft.top/api
|
||||||
|
# WebSoftAdmin 授权码 (必填-请联系官方获取)
|
||||||
|
VITE_LICENSE_CODE=dk9mcwJyetRWQlxWRiojIzJCLi8mcQ5Wa4ojI0NWZqJWd6ICZpJCL0kjNvdjbE5WQ2AjIvl2cyVmdiwiIiETMuEjI6IibQf0NW==
|
||||||
@@ -1,6 +1,6 @@
|
|||||||
import request from '@/utils/request';
|
import request from '@/utils/request';
|
||||||
import type { ApiResult, PageResult } from '@/api';
|
import type { ApiResult, PageResult } from '@/api';
|
||||||
import type { ShopGoods, ShopGoodsParam } from './model';
|
import type { ShopGoods, ShopGoodsCollectParam, ShopGoodsParam } from './model';
|
||||||
import { MODULES_API_URL } from '@/config/setting';
|
import { MODULES_API_URL } from '@/config/setting';
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -130,3 +130,17 @@ export async function importShopGoods(file: File) {
|
|||||||
}
|
}
|
||||||
return Promise.reject(new Error(res.data.message));
|
return Promise.reject(new Error(res.data.message));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 通过商品链接采集入库
|
||||||
|
*/
|
||||||
|
export async function collectShopGoods(data: ShopGoodsCollectParam) {
|
||||||
|
const res = await request.post<ApiResult<unknown>>(
|
||||||
|
MODULES_API_URL + '/shop/shop-goods/collect',
|
||||||
|
data
|
||||||
|
);
|
||||||
|
if (res.data.code === 0) {
|
||||||
|
return res.data.message;
|
||||||
|
}
|
||||||
|
return Promise.reject(new Error(res.data.message));
|
||||||
|
}
|
||||||
|
|||||||
@@ -152,6 +152,16 @@ export interface BathSet {
|
|||||||
skuNo?: string;
|
skuNo?: string;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 商品链接采集参数
|
||||||
|
*/
|
||||||
|
export interface ShopGoodsCollectParam {
|
||||||
|
url: string;
|
||||||
|
categoryId?: number;
|
||||||
|
status?: number;
|
||||||
|
merchantId?: number;
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 商品记录表搜索条件
|
* 商品记录表搜索条件
|
||||||
*/
|
*/
|
||||||
|
|||||||
@@ -25,6 +25,12 @@
|
|||||||
</template>
|
</template>
|
||||||
<span>导入</span>
|
<span>导入</span>
|
||||||
</a-button>
|
</a-button>
|
||||||
|
<a-button type="dashed" class="ele-btn-icon" @click="openCollect">
|
||||||
|
<template #icon>
|
||||||
|
<LinkOutlined />
|
||||||
|
</template>
|
||||||
|
<span>采集</span>
|
||||||
|
</a-button>
|
||||||
<a-button type="dashed" class="ele-btn-icon" @click="handleExport">
|
<a-button type="dashed" class="ele-btn-icon" @click="handleExport">
|
||||||
导出xls
|
导出xls
|
||||||
</a-button>
|
</a-button>
|
||||||
@@ -64,10 +70,10 @@
|
|||||||
</template>
|
</template>
|
||||||
|
|
||||||
<script lang="ts" setup>
|
<script lang="ts" setup>
|
||||||
import { PlusOutlined, DeleteOutlined, UploadOutlined } from '@ant-design/icons-vue';
|
import { PlusOutlined, DeleteOutlined, UploadOutlined, LinkOutlined } from '@ant-design/icons-vue';
|
||||||
import { ref, watch } from 'vue';
|
import { ref, watch } from 'vue';
|
||||||
import { getCount } from '@/api/shop/shopGoods';
|
import { getCount } from '@/api/shop/shopGoods';
|
||||||
import type { GoodsCount, ShopGoodsParam } from '@/api/shop/shopGoods/model';
|
import type { GoodsCount, ShopGoods, ShopGoodsParam } from '@/api/shop/shopGoods/model';
|
||||||
import useSearch from '@/utils/use-search';
|
import useSearch from '@/utils/use-search';
|
||||||
import { getMerchantId } from '@/utils/merchant';
|
import { getMerchantId } from '@/utils/merchant';
|
||||||
import { ShopGoodsCategory } from '@/api/shop/shopGoodsCategory/model';
|
import { ShopGoodsCategory } from '@/api/shop/shopGoodsCategory/model';
|
||||||
@@ -75,7 +81,7 @@
|
|||||||
const props = withDefaults(
|
const props = withDefaults(
|
||||||
defineProps<{
|
defineProps<{
|
||||||
// 选中的角色
|
// 选中的角色
|
||||||
selection?: [];
|
selection?: ShopGoods[];
|
||||||
merchantId?: number;
|
merchantId?: number;
|
||||||
navigationList?: ShopGoodsCategory[];
|
navigationList?: ShopGoodsCategory[];
|
||||||
}>(),
|
}>(),
|
||||||
@@ -105,6 +111,7 @@
|
|||||||
(e: 'remove'): void;
|
(e: 'remove'): void;
|
||||||
(e: 'batchMove'): void;
|
(e: 'batchMove'): void;
|
||||||
(e: 'import'): void;
|
(e: 'import'): void;
|
||||||
|
(e: 'collect'): void;
|
||||||
(e: 'export'): void;
|
(e: 'export'): void;
|
||||||
}>();
|
}>();
|
||||||
|
|
||||||
@@ -123,12 +130,17 @@
|
|||||||
emit('import');
|
emit('import');
|
||||||
};
|
};
|
||||||
|
|
||||||
|
// 打开链接采集
|
||||||
|
const openCollect = () => {
|
||||||
|
emit('collect');
|
||||||
|
};
|
||||||
|
|
||||||
// 导出
|
// 导出
|
||||||
const handleExport = () => {
|
const handleExport = () => {
|
||||||
emit('export');
|
emit('export');
|
||||||
};
|
};
|
||||||
|
|
||||||
const handleSearch = (e) => {
|
const handleSearch = (e: any) => {
|
||||||
const text = e.target.value;
|
const text = e.target.value;
|
||||||
resetFields();
|
resetFields();
|
||||||
if (text === '出售中') {
|
if (text === '出售中') {
|
||||||
|
|||||||
154
src/views/shop/shopGoods/components/shop-goods-collect.vue
Normal file
154
src/views/shop/shopGoods/components/shop-goods-collect.vue
Normal file
@@ -0,0 +1,154 @@
|
|||||||
|
<template>
|
||||||
|
<ele-modal
|
||||||
|
:width="620"
|
||||||
|
title="商品链接采集"
|
||||||
|
:visible="visible"
|
||||||
|
:confirm-loading="loading"
|
||||||
|
@update:visible="updateVisible"
|
||||||
|
>
|
||||||
|
<a-form
|
||||||
|
ref="formRef"
|
||||||
|
:model="form"
|
||||||
|
:rules="rules"
|
||||||
|
:label-col="{ flex: '90px' }"
|
||||||
|
:wrapper-col="{ flex: '1' }"
|
||||||
|
>
|
||||||
|
<a-form-item label="商品链接" name="url">
|
||||||
|
<a-input
|
||||||
|
v-model:value="form.url"
|
||||||
|
allow-clear
|
||||||
|
placeholder="请输入商品详情页链接"
|
||||||
|
/>
|
||||||
|
</a-form-item>
|
||||||
|
<a-form-item label="商品分类" name="categoryId">
|
||||||
|
<a-tree-select
|
||||||
|
v-model:value="form.categoryId"
|
||||||
|
allow-clear
|
||||||
|
:tree-data="navigationList"
|
||||||
|
tree-default-expand-all
|
||||||
|
:listHeight="600"
|
||||||
|
placeholder="请选择分类"
|
||||||
|
:dropdown-style="{ overflow: 'auto' }"
|
||||||
|
/>
|
||||||
|
</a-form-item>
|
||||||
|
<a-form-item label="入库状态" name="status">
|
||||||
|
<a-radio-group v-model:value="form.status">
|
||||||
|
<a-radio :value="1">待上架</a-radio>
|
||||||
|
<a-radio :value="0">直接上架</a-radio>
|
||||||
|
</a-radio-group>
|
||||||
|
</a-form-item>
|
||||||
|
</a-form>
|
||||||
|
<template #footer>
|
||||||
|
<a-space>
|
||||||
|
<a-button @click="updateVisible(false)">取消</a-button>
|
||||||
|
<a-button type="primary" :loading="loading" @click="submit">
|
||||||
|
开始采集
|
||||||
|
</a-button>
|
||||||
|
</a-space>
|
||||||
|
</template>
|
||||||
|
</ele-modal>
|
||||||
|
</template>
|
||||||
|
|
||||||
|
<script lang="ts" setup>
|
||||||
|
import { reactive, ref, watch } from 'vue';
|
||||||
|
import { message } from 'ant-design-vue';
|
||||||
|
import type { FormInstance, RuleObject } from 'ant-design-vue/es/form';
|
||||||
|
import { collectShopGoods } from '@/api/shop/shopGoods';
|
||||||
|
import type { ShopGoodsCollectParam } from '@/api/shop/shopGoods/model';
|
||||||
|
import type { ShopGoodsCategory } from '@/api/shop/shopGoodsCategory/model';
|
||||||
|
import { getMerchantId } from '@/utils/merchant';
|
||||||
|
|
||||||
|
const props = defineProps<{
|
||||||
|
visible: boolean;
|
||||||
|
navigationList?: ShopGoodsCategory[];
|
||||||
|
}>();
|
||||||
|
|
||||||
|
const emit = defineEmits<{
|
||||||
|
(e: 'done'): void;
|
||||||
|
(e: 'update:visible', visible: boolean): void;
|
||||||
|
}>();
|
||||||
|
|
||||||
|
const formRef = ref<FormInstance | null>(null);
|
||||||
|
const loading = ref(false);
|
||||||
|
|
||||||
|
const form = reactive<ShopGoodsCollectParam>({
|
||||||
|
url: '',
|
||||||
|
categoryId: undefined,
|
||||||
|
status: 1,
|
||||||
|
merchantId: getMerchantId() || undefined
|
||||||
|
});
|
||||||
|
|
||||||
|
const validateUrl = async (_rule: RuleObject, value?: string) => {
|
||||||
|
if (!value) {
|
||||||
|
return Promise.reject('请输入商品链接');
|
||||||
|
}
|
||||||
|
try {
|
||||||
|
const parsed = new URL(value);
|
||||||
|
if (!['http:', 'https:'].includes(parsed.protocol)) {
|
||||||
|
return Promise.reject('请输入正确的商品链接');
|
||||||
|
}
|
||||||
|
return Promise.resolve();
|
||||||
|
} catch (_) {
|
||||||
|
return Promise.reject('请输入正确的商品链接');
|
||||||
|
}
|
||||||
|
};
|
||||||
|
|
||||||
|
const rules = reactive<Record<string, RuleObject[]>>({
|
||||||
|
url: [
|
||||||
|
{
|
||||||
|
required: true,
|
||||||
|
validator: validateUrl,
|
||||||
|
trigger: 'blur'
|
||||||
|
}
|
||||||
|
]
|
||||||
|
});
|
||||||
|
|
||||||
|
const updateVisible = (value: boolean) => {
|
||||||
|
emit('update:visible', value);
|
||||||
|
};
|
||||||
|
|
||||||
|
const resetForm = () => {
|
||||||
|
form.url = '';
|
||||||
|
form.categoryId = undefined;
|
||||||
|
form.status = 1;
|
||||||
|
form.merchantId = getMerchantId() || undefined;
|
||||||
|
formRef.value?.clearValidate();
|
||||||
|
};
|
||||||
|
|
||||||
|
const submit = () => {
|
||||||
|
if (!formRef.value) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
formRef.value
|
||||||
|
.validate()
|
||||||
|
.then(() => {
|
||||||
|
loading.value = true;
|
||||||
|
collectShopGoods({
|
||||||
|
...form,
|
||||||
|
url: form.url.trim()
|
||||||
|
})
|
||||||
|
.then((msg) => {
|
||||||
|
loading.value = false;
|
||||||
|
message.success(msg);
|
||||||
|
updateVisible(false);
|
||||||
|
emit('done');
|
||||||
|
})
|
||||||
|
.catch((e) => {
|
||||||
|
loading.value = false;
|
||||||
|
message.error(e.message);
|
||||||
|
});
|
||||||
|
})
|
||||||
|
.catch(() => {});
|
||||||
|
};
|
||||||
|
|
||||||
|
watch(
|
||||||
|
() => props.visible,
|
||||||
|
(visible) => {
|
||||||
|
if (visible) {
|
||||||
|
form.merchantId = getMerchantId() || undefined;
|
||||||
|
} else {
|
||||||
|
resetForm();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
);
|
||||||
|
</script>
|
||||||
@@ -1,5 +1,5 @@
|
|||||||
<template>
|
<template>
|
||||||
<a-page-header :title="getPageTitle()" @back="() => $router.go(-1)">
|
<a-page-header :title="String(getPageTitle())" @back="goBack">
|
||||||
<template #extra>
|
<template #extra>
|
||||||
<Extra />
|
<Extra />
|
||||||
</template>
|
</template>
|
||||||
@@ -23,6 +23,7 @@
|
|||||||
@remove="removeBatch"
|
@remove="removeBatch"
|
||||||
@batchMove="openMove"
|
@batchMove="openMove"
|
||||||
@import="openImport"
|
@import="openImport"
|
||||||
|
@collect="openCollect"
|
||||||
@export="handleExport"
|
@export="handleExport"
|
||||||
/>
|
/>
|
||||||
</template>
|
</template>
|
||||||
@@ -85,11 +86,19 @@
|
|||||||
v-model:visible="showImport"
|
v-model:visible="showImport"
|
||||||
@done="reload"
|
@done="reload"
|
||||||
/>
|
/>
|
||||||
|
|
||||||
|
<!-- 链接采集弹窗 -->
|
||||||
|
<ShopGoodsCollect
|
||||||
|
v-model:visible="showCollect"
|
||||||
|
:navigationList="navigationList"
|
||||||
|
@done="reload"
|
||||||
|
/>
|
||||||
</a-page-header>
|
</a-page-header>
|
||||||
</template>
|
</template>
|
||||||
|
|
||||||
<script lang="ts" setup>
|
<script lang="ts" setup>
|
||||||
import { createVNode, ref } from 'vue';
|
import { createVNode, ref } from 'vue';
|
||||||
|
import { useRouter } from 'vue-router';
|
||||||
import { message, Modal } from 'ant-design-vue';
|
import { message, Modal } from 'ant-design-vue';
|
||||||
import {
|
import {
|
||||||
ExclamationCircleOutlined,
|
ExclamationCircleOutlined,
|
||||||
@@ -107,6 +116,7 @@
|
|||||||
import ShopGoodsEdit from './components/shopGoodsEdit.vue';
|
import ShopGoodsEdit from './components/shopGoodsEdit.vue';
|
||||||
import Extra from '@/views/shop/shopGoods/components/extra.vue';
|
import Extra from '@/views/shop/shopGoods/components/extra.vue';
|
||||||
import ShopGoodsImport from './components/shop-goods-import.vue';
|
import ShopGoodsImport from './components/shop-goods-import.vue';
|
||||||
|
import ShopGoodsCollect from './components/shop-goods-collect.vue';
|
||||||
import { listShopGoods, pageShopGoods, removeShopGoods, removeBatchShopGoods, updateShopGoods } from '@/api/shop/shopGoods';
|
import { listShopGoods, pageShopGoods, removeShopGoods, removeBatchShopGoods, updateShopGoods } from '@/api/shop/shopGoods';
|
||||||
import type { ShopGoods, ShopGoodsParam } from '@/api/shop/shopGoods/model';
|
import type { ShopGoods, ShopGoodsParam } from '@/api/shop/shopGoods/model';
|
||||||
import { getPageTitle } from '@/utils/common';
|
import { getPageTitle } from '@/utils/common';
|
||||||
@@ -117,6 +127,7 @@
|
|||||||
|
|
||||||
// 表格实例
|
// 表格实例
|
||||||
const tableRef = ref<InstanceType<typeof EleProTable> | null>(null);
|
const tableRef = ref<InstanceType<typeof EleProTable> | null>(null);
|
||||||
|
const router = useRouter();
|
||||||
|
|
||||||
// 表格选中数据
|
// 表格选中数据
|
||||||
const selection = ref<ShopGoods[]>([]);
|
const selection = ref<ShopGoods[]>([]);
|
||||||
@@ -128,11 +139,17 @@
|
|||||||
const showEdit = ref(false);
|
const showEdit = ref(false);
|
||||||
// 是否显示导入弹窗
|
// 是否显示导入弹窗
|
||||||
const showImport = ref(false);
|
const showImport = ref(false);
|
||||||
|
// 是否显示链接采集弹窗
|
||||||
|
const showCollect = ref(false);
|
||||||
// 是否显示批量移动弹窗
|
// 是否显示批量移动弹窗
|
||||||
const showMove = ref(false);
|
const showMove = ref(false);
|
||||||
// 加载状态
|
// 加载状态
|
||||||
const loading = ref(true);
|
const loading = ref(true);
|
||||||
|
|
||||||
|
const goBack = () => {
|
||||||
|
router.go(-1);
|
||||||
|
};
|
||||||
|
|
||||||
// 表格数据源
|
// 表格数据源
|
||||||
const datasource: DatasourceFunction = ({
|
const datasource: DatasourceFunction = ({
|
||||||
page,
|
page,
|
||||||
@@ -259,6 +276,11 @@
|
|||||||
showImport.value = true;
|
showImport.value = true;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
// 打开链接采集
|
||||||
|
const openCollect = () => {
|
||||||
|
showCollect.value = true;
|
||||||
|
};
|
||||||
|
|
||||||
/* 导出商品列表 */
|
/* 导出商品列表 */
|
||||||
const handleExport = async () => {
|
const handleExport = async () => {
|
||||||
if (loading.value) {
|
if (loading.value) {
|
||||||
@@ -302,7 +324,7 @@
|
|||||||
});
|
});
|
||||||
|
|
||||||
const sheetName = `商品列表${dayjs(new Date()).format('YYYYMMDD')}`;
|
const sheetName = `商品列表${dayjs(new Date()).format('YYYYMMDD')}`;
|
||||||
const workbook = {
|
const workbook: { SheetNames: string[]; Sheets: Record<string, any> } = {
|
||||||
SheetNames: [sheetName],
|
SheetNames: [sheetName],
|
||||||
Sheets: {}
|
Sheets: {}
|
||||||
};
|
};
|
||||||
|
|||||||
Reference in New Issue
Block a user