fix: 更新API请求方法和参数处理,优化路由组件解析逻辑
- 将`updateAnchor`方法的请求方式改为PUT,`deleteAnchor`方法改为DELETE并使用params传递数据 - 在路由组件中添加`normalizeRouteComponent`和`resolveRouteComponent`函数,增强动态路由解析能力 - 更新多个组件中的ID处理逻辑,确保ID始终为字符串类型 - 修改样式以统一选择框的宽度
This commit is contained in:
1
.gitignore
vendored
1
.gitignore
vendored
@@ -1,6 +1,7 @@
|
|||||||
.DS_Store
|
.DS_Store
|
||||||
node_modules
|
node_modules
|
||||||
/dist
|
/dist
|
||||||
|
src/**/*.vue.js
|
||||||
|
|
||||||
|
|
||||||
# local env files
|
# local env files
|
||||||
|
|||||||
@@ -47,7 +47,7 @@ export function addAnchor(data: AnchorParams) {
|
|||||||
export function updateAnchor(data: AnchorParams) {
|
export function updateAnchor(data: AnchorParams) {
|
||||||
return request({
|
return request({
|
||||||
url: '/erp/anchor/controller/updateAnchor',
|
url: '/erp/anchor/controller/updateAnchor',
|
||||||
method: 'post',
|
method: 'put',
|
||||||
data: data,
|
data: data,
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
@@ -55,8 +55,8 @@ export function updateAnchor(data: AnchorParams) {
|
|||||||
export function deleteAnchor(data: { id: string }) {
|
export function deleteAnchor(data: { id: string }) {
|
||||||
return request({
|
return request({
|
||||||
url: '/erp/anchor/controller/deleteAnchor',
|
url: '/erp/anchor/controller/deleteAnchor',
|
||||||
method: 'post',
|
method: 'delete',
|
||||||
data: data,
|
params: data,
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
88
src/api/trade/operation/setting/live-account/index.ts
Normal file
88
src/api/trade/operation/setting/live-account/index.ts
Normal file
@@ -0,0 +1,88 @@
|
|||||||
|
import request from '/@/utils/request';
|
||||||
|
|
||||||
|
export interface LiveAccountParams {
|
||||||
|
pageNum: number;
|
||||||
|
pageSize: number;
|
||||||
|
platform?: string;
|
||||||
|
accountName?: string;
|
||||||
|
accountId?: string;
|
||||||
|
status?: number;
|
||||||
|
}
|
||||||
|
|
||||||
|
export interface LiveAccountSaveParams {
|
||||||
|
id?: string;
|
||||||
|
platform: string;
|
||||||
|
accountName: string;
|
||||||
|
accountId: string;
|
||||||
|
status?: number;
|
||||||
|
remark?: string;
|
||||||
|
}
|
||||||
|
|
||||||
|
export interface LiveAccount {
|
||||||
|
id: string;
|
||||||
|
platform: string;
|
||||||
|
accountName: string;
|
||||||
|
accountId: string;
|
||||||
|
status: number;
|
||||||
|
statusName: string;
|
||||||
|
remark: string;
|
||||||
|
createdAt: number;
|
||||||
|
updatedAt: number;
|
||||||
|
}
|
||||||
|
|
||||||
|
export interface LiveAccountListResult {
|
||||||
|
list: LiveAccount[];
|
||||||
|
total: number;
|
||||||
|
}
|
||||||
|
|
||||||
|
export interface LiveAccountListResponse {
|
||||||
|
code: number;
|
||||||
|
message: string;
|
||||||
|
data: LiveAccountListResult;
|
||||||
|
}
|
||||||
|
|
||||||
|
export interface LiveAccountDetailResponse {
|
||||||
|
code: number;
|
||||||
|
message: string;
|
||||||
|
data: LiveAccount;
|
||||||
|
}
|
||||||
|
|
||||||
|
export function getLiveAccountList(params: LiveAccountParams): Promise<LiveAccountListResponse> {
|
||||||
|
return request({
|
||||||
|
url: '/erp/live/account/controller/listLiveAccounts',
|
||||||
|
method: 'get',
|
||||||
|
params,
|
||||||
|
}) as Promise<LiveAccountListResponse>;
|
||||||
|
}
|
||||||
|
|
||||||
|
export function getLiveAccountDetail(params: { id: string }): Promise<LiveAccountDetailResponse> {
|
||||||
|
return request({
|
||||||
|
url: '/erp/live/account/controller/getLiveAccount',
|
||||||
|
method: 'get',
|
||||||
|
params,
|
||||||
|
}) as Promise<LiveAccountDetailResponse>;
|
||||||
|
}
|
||||||
|
|
||||||
|
export function createLiveAccount(data: LiveAccountSaveParams) {
|
||||||
|
return request({
|
||||||
|
url: '/erp/live/account/controller/createLiveAccount',
|
||||||
|
method: 'post',
|
||||||
|
data,
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
export function updateLiveAccount(data: LiveAccountSaveParams) {
|
||||||
|
return request({
|
||||||
|
url: '/erp/live/account/controller/updateLiveAccount',
|
||||||
|
method: 'put',
|
||||||
|
data,
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
export function deleteLiveAccount(params: { id: string }) {
|
||||||
|
return request({
|
||||||
|
url: '/erp/live/account/controller/deleteLiveAccount',
|
||||||
|
method: 'delete',
|
||||||
|
params,
|
||||||
|
});
|
||||||
|
}
|
||||||
114
src/api/trade/operation/setting/scheduling/index.ts
Normal file
114
src/api/trade/operation/setting/scheduling/index.ts
Normal file
@@ -0,0 +1,114 @@
|
|||||||
|
import request from '/@/utils/request';
|
||||||
|
|
||||||
|
export interface ScheduleListParams {
|
||||||
|
pageNum: number;
|
||||||
|
pageSize: number;
|
||||||
|
anchorId?: string;
|
||||||
|
accountId?: string;
|
||||||
|
status?: number;
|
||||||
|
}
|
||||||
|
|
||||||
|
export interface ScheduleSaveParams {
|
||||||
|
id?: string;
|
||||||
|
anchorId: string;
|
||||||
|
accountId: string;
|
||||||
|
productId?: number;
|
||||||
|
orderId?: number;
|
||||||
|
startTime: string;
|
||||||
|
endTime: string;
|
||||||
|
status?: number;
|
||||||
|
remark?: string;
|
||||||
|
}
|
||||||
|
|
||||||
|
export interface ScheduleItem {
|
||||||
|
id: string;
|
||||||
|
anchorId: string;
|
||||||
|
anchorName: string;
|
||||||
|
accountId: string;
|
||||||
|
accountName: string;
|
||||||
|
platform: string;
|
||||||
|
startTime: number;
|
||||||
|
endTime: number;
|
||||||
|
status: number;
|
||||||
|
statusName: string;
|
||||||
|
productId: number;
|
||||||
|
orderId: number;
|
||||||
|
remark: string;
|
||||||
|
createdAt: number;
|
||||||
|
updatedAt: number;
|
||||||
|
}
|
||||||
|
|
||||||
|
export interface ScheduleDetail {
|
||||||
|
id: string;
|
||||||
|
tenantId: number;
|
||||||
|
creator: string;
|
||||||
|
createdAt: string;
|
||||||
|
updater: string;
|
||||||
|
updatedAt: string;
|
||||||
|
deletedAt: string | null;
|
||||||
|
anchorId: string;
|
||||||
|
accountId: string;
|
||||||
|
startTime: string;
|
||||||
|
endTime: string;
|
||||||
|
status: number;
|
||||||
|
productId: number;
|
||||||
|
orderId: number;
|
||||||
|
remark: string;
|
||||||
|
}
|
||||||
|
|
||||||
|
export interface ScheduleListResult {
|
||||||
|
list: ScheduleItem[];
|
||||||
|
total: number;
|
||||||
|
}
|
||||||
|
|
||||||
|
export interface ScheduleListResponse {
|
||||||
|
code: number;
|
||||||
|
message: string;
|
||||||
|
data: ScheduleListResult;
|
||||||
|
}
|
||||||
|
|
||||||
|
export interface ScheduleDetailResponse {
|
||||||
|
code: number;
|
||||||
|
message: string;
|
||||||
|
data: ScheduleDetail;
|
||||||
|
}
|
||||||
|
|
||||||
|
export function getScheduleList(params: ScheduleListParams): Promise<ScheduleListResponse> {
|
||||||
|
return request({
|
||||||
|
url: '/erp/schedule/controller/listSchedules',
|
||||||
|
method: 'get',
|
||||||
|
params,
|
||||||
|
}) as Promise<ScheduleListResponse>;
|
||||||
|
}
|
||||||
|
|
||||||
|
export function getScheduleDetail(params: { id: string }): Promise<ScheduleDetailResponse> {
|
||||||
|
return request({
|
||||||
|
url: '/erp/schedule/controller/getSchedule',
|
||||||
|
method: 'get',
|
||||||
|
params,
|
||||||
|
}) as Promise<ScheduleDetailResponse>;
|
||||||
|
}
|
||||||
|
|
||||||
|
export function createSchedule(data: ScheduleSaveParams) {
|
||||||
|
return request({
|
||||||
|
url: '/erp/schedule/controller/createSchedule',
|
||||||
|
method: 'post',
|
||||||
|
data,
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
export function updateSchedule(data: ScheduleSaveParams) {
|
||||||
|
return request({
|
||||||
|
url: '/erp/schedule/controller/updateSchedule',
|
||||||
|
method: 'put',
|
||||||
|
data,
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
export function deleteSchedule(params: { id: string }) {
|
||||||
|
return request({
|
||||||
|
url: '/erp/schedule/controller/deleteSchedule',
|
||||||
|
method: 'delete',
|
||||||
|
params,
|
||||||
|
});
|
||||||
|
}
|
||||||
@@ -10,8 +10,17 @@ import { useRoutesList } from '/@/stores/routesList';
|
|||||||
import { useTagsViewRoutes } from '/@/stores/tagsViewRoutes';
|
import { useTagsViewRoutes } from '/@/stores/tagsViewRoutes';
|
||||||
import { getUserMenus } from '/@/api/system/menu/index';
|
import { getUserMenus } from '/@/api/system/menu/index';
|
||||||
|
|
||||||
|
// 扩展Window接口,添加nextLoading属性
|
||||||
|
declare global {
|
||||||
|
interface Window {
|
||||||
|
nextLoading?: boolean;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
const layouModules: any = import.meta.glob('../layout/routerView/*.{vue,tsx}');
|
const layouModules: any = import.meta.glob('../layout/routerView/*.{vue,tsx}');
|
||||||
const viewsModules: any = import.meta.glob('../views/**/*.{vue,tsx}');
|
const viewsModules: any = import.meta.glob('../views/**/*.{vue,tsx}');
|
||||||
|
const parentView = layouModules['../layout/routerView/parent.vue'];
|
||||||
|
const notFoundView = viewsModules['../views/error/404.vue'];
|
||||||
|
|
||||||
// 后端控制路由
|
// 后端控制路由
|
||||||
|
|
||||||
@@ -22,6 +31,57 @@ const viewsModules: any = import.meta.glob('../views/**/*.{vue,tsx}');
|
|||||||
*/
|
*/
|
||||||
const dynamicViewsModules: Record<string, Function> = Object.assign({}, { ...layouModules }, { ...viewsModules });
|
const dynamicViewsModules: Record<string, Function> = Object.assign({}, { ...layouModules }, { ...viewsModules });
|
||||||
|
|
||||||
|
const normalizeRouteComponent = (component?: string) => {
|
||||||
|
if (!component) return '';
|
||||||
|
return component
|
||||||
|
.trim()
|
||||||
|
.replace(/^\/@\//, '')
|
||||||
|
.replace(/^\//, '')
|
||||||
|
.replace(/^views\//, '')
|
||||||
|
.replace(/\.(vue|tsx)$/i, '')
|
||||||
|
.replace(/\/index$/i, '');
|
||||||
|
};
|
||||||
|
|
||||||
|
const resolveRouteComponent = (component?: string, path?: string, isParent = false) => {
|
||||||
|
const normalizedComponent = normalizeRouteComponent(component);
|
||||||
|
const normalizedPath = normalizeRouteComponent(path);
|
||||||
|
const candidates = [normalizedComponent, normalizedPath].filter(Boolean);
|
||||||
|
|
||||||
|
for (const candidate of candidates) {
|
||||||
|
const exactViewIndexVueKey = `../views/${candidate}/index.vue`;
|
||||||
|
if (dynamicViewsModules[exactViewIndexVueKey]) {
|
||||||
|
return dynamicViewsModules[exactViewIndexVueKey];
|
||||||
|
}
|
||||||
|
|
||||||
|
const exactViewVueKey = `../views/${candidate}.vue`;
|
||||||
|
if (dynamicViewsModules[exactViewVueKey]) {
|
||||||
|
return dynamicViewsModules[exactViewVueKey];
|
||||||
|
}
|
||||||
|
|
||||||
|
const exactViewTsxKey = `../views/${candidate}.tsx`;
|
||||||
|
if (dynamicViewsModules[exactViewTsxKey]) {
|
||||||
|
return dynamicViewsModules[exactViewTsxKey];
|
||||||
|
}
|
||||||
|
|
||||||
|
const exactLayoutVueKey = `../${candidate}.vue`;
|
||||||
|
if (dynamicViewsModules[exactLayoutVueKey]) {
|
||||||
|
return dynamicViewsModules[exactLayoutVueKey];
|
||||||
|
}
|
||||||
|
|
||||||
|
const exactLayoutTsxKey = `../${candidate}.tsx`;
|
||||||
|
if (dynamicViewsModules[exactLayoutTsxKey]) {
|
||||||
|
return dynamicViewsModules[exactLayoutTsxKey];
|
||||||
|
}
|
||||||
|
|
||||||
|
if (candidate === 'layout/routerView/parent') {
|
||||||
|
return parentView;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
if (isParent) return parentView;
|
||||||
|
return notFoundView || parentView;
|
||||||
|
};
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 后端控制路由:初始化方法,防止刷新时路由丢失
|
* 后端控制路由:初始化方法,防止刷新时路由丢失
|
||||||
* @method NextLoading 界面 loading 动画开始执行
|
* @method NextLoading 界面 loading 动画开始执行
|
||||||
@@ -31,25 +91,18 @@ const dynamicViewsModules: Record<string, Function> = Object.assign({}, { ...lay
|
|||||||
* @method setFilterMenuAndCacheTagsViewRoutes 设置路由到 vuex routesList 中(已处理成多级嵌套路由)及缓存多级嵌套数组处理后的一维数组
|
* @method setFilterMenuAndCacheTagsViewRoutes 设置路由到 vuex routesList 中(已处理成多级嵌套路由)及缓存多级嵌套数组处理后的一维数组
|
||||||
*/
|
*/
|
||||||
export async function initBackEndControlRoutes() {
|
export async function initBackEndControlRoutes() {
|
||||||
// 界面 loading 动画开始执行
|
|
||||||
if (window.nextLoading === undefined) NextLoading.start();
|
if (window.nextLoading === undefined) NextLoading.start();
|
||||||
// 无 token 停止执行下一步
|
|
||||||
if (!Session.get('token')) return false;
|
if (!Session.get('token')) return false;
|
||||||
// 触发初始化用户信息 pinia
|
|
||||||
// https://gitee.com/lyt-top/vue-next-admin/issues/I5F1HP
|
|
||||||
await useUserInfo().setUserInfos();
|
await useUserInfo().setUserInfos();
|
||||||
await useUserInfo().setPermissions();
|
await useUserInfo().setPermissions();
|
||||||
// 获取路由菜单数据
|
|
||||||
await getBackEndControlRoutes();
|
await getBackEndControlRoutes();
|
||||||
let menuRoute = Session.get('userMenu');
|
const menuRoute = Session.get('userMenu');
|
||||||
// 存储接口原始路由(未处理component),根据需求选择使用
|
|
||||||
useRequestOldRoutes().setRequestOldRoutes(JSON.parse(JSON.stringify(menuRoute)));
|
useRequestOldRoutes().setRequestOldRoutes(JSON.parse(JSON.stringify(menuRoute)));
|
||||||
// 处理路由(component),替换 dynamicRoutes(/@/router/route)第一个顶级 children 的路由
|
|
||||||
dynamicRoutes[0].children = [...defaultDynamicRouteChildren];
|
dynamicRoutes[0].children = [...defaultDynamicRouteChildren];
|
||||||
dynamicRoutes[0].children?.push(...(await backEndComponent(menuRoute)));
|
dynamicRoutes[0].children?.push(...(await backEndComponent(menuRoute)));
|
||||||
// 添加动态路由
|
|
||||||
await setAddRoute();
|
await setAddRoute();
|
||||||
// 设置路由到 vuex routesList 中(已处理成多级嵌套路由)及缓存多级嵌套数组处理后的一维数组
|
|
||||||
await setFilterMenuAndCacheTagsViewRoutes();
|
await setFilterMenuAndCacheTagsViewRoutes();
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -79,7 +132,7 @@ export function setCacheTagsViewRoutes() {
|
|||||||
* @returns 返回替换后的路由数组
|
* @returns 返回替换后的路由数组
|
||||||
*/
|
*/
|
||||||
export function setFilterRouteEnd() {
|
export function setFilterRouteEnd() {
|
||||||
let filterRouteEnd: any = formatTwoStageRoutes(formatFlatteningRoutes(dynamicRoutes));
|
const filterRouteEnd: any = formatTwoStageRoutes(formatFlatteningRoutes(dynamicRoutes));
|
||||||
filterRouteEnd[0].children = [...filterRouteEnd[0].children, ...notFoundAndNoPower];
|
filterRouteEnd[0].children = [...filterRouteEnd[0].children, ...notFoundAndNoPower];
|
||||||
return filterRouteEnd;
|
return filterRouteEnd;
|
||||||
}
|
}
|
||||||
@@ -103,8 +156,8 @@ export async function setAddRoute() {
|
|||||||
* @returns 返回后端路由菜单数据
|
* @returns 返回后端路由菜单数据
|
||||||
*/
|
*/
|
||||||
export async function getBackEndControlRoutes() {
|
export async function getBackEndControlRoutes() {
|
||||||
let menuRoute = Session.get('userMenu');
|
const menuRoute = Session.get('userMenu');
|
||||||
let permissions = Session.get('permissions');
|
const permissions = Session.get('permissions');
|
||||||
if (!menuRoute || !permissions) {
|
if (!menuRoute || !permissions) {
|
||||||
await refreshBackEndControlRoutes();
|
await refreshBackEndControlRoutes();
|
||||||
}
|
}
|
||||||
@@ -116,7 +169,6 @@ export async function getBackEndControlRoutes() {
|
|||||||
* @returns 返回后端路由菜单数据
|
* @returns 返回后端路由菜单数据
|
||||||
*/
|
*/
|
||||||
export async function refreshBackEndControlRoutes() {
|
export async function refreshBackEndControlRoutes() {
|
||||||
// 获取路由
|
|
||||||
await getUserMenus().then((res: any) => {
|
await getUserMenus().then((res: any) => {
|
||||||
Session.set('userMenu', res.data.menuList);
|
Session.set('userMenu', res.data.menuList);
|
||||||
Session.set('permissions', res.data.permissions);
|
Session.set('permissions', res.data.permissions);
|
||||||
@@ -141,51 +193,21 @@ export function setBackEndControlRefreshRoutes() {
|
|||||||
export function backEndComponent(routes: any) {
|
export function backEndComponent(routes: any) {
|
||||||
if (!routes) return [];
|
if (!routes) return [];
|
||||||
return routes.map((item: any) => {
|
return routes.map((item: any) => {
|
||||||
// 递归处理子路由
|
const hasChildren = Array.isArray(item.children) && item.children.length > 0;
|
||||||
if (item.children && item.children.length > 0) {
|
|
||||||
|
if (hasChildren) {
|
||||||
item.children = backEndComponent(item.children);
|
item.children = backEndComponent(item.children);
|
||||||
// 找到第一个非隐藏的子路由作为重定向
|
|
||||||
const firstVisibleChild = item.children.find((ci: any) => !ci.meta?.isHide);
|
const firstVisibleChild = item.children.find((ci: any) => !ci.meta?.isHide);
|
||||||
if (firstVisibleChild) {
|
if (firstVisibleChild) {
|
||||||
item.redirect = firstVisibleChild.path;
|
item.redirect = firstVisibleChild.path;
|
||||||
}
|
}
|
||||||
// 确保父级路由有component
|
|
||||||
if (!item.component || item.component === false) {
|
const routeComponent = resolveRouteComponent(item.component as string, item.path as string, false);
|
||||||
item.component = dynamicViewsModules['../layout/routerView/parent.vue'];
|
item.component = routeComponent === notFoundView ? parentView : routeComponent;
|
||||||
}
|
|
||||||
} else {
|
} else {
|
||||||
// 确保叶子路由有component
|
item.component = resolveRouteComponent(item.component as string, item.path as string, false);
|
||||||
let componentFound = false;
|
|
||||||
if (item.component && item.component !== false) {
|
|
||||||
const comp = dynamicImport(dynamicViewsModules, item.component as string);
|
|
||||||
if (comp) {
|
|
||||||
item.component = comp;
|
|
||||||
componentFound = true;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
if (!componentFound) {
|
|
||||||
// 尝试根据path生成component路径
|
|
||||||
const path = item.path.replace(/^\//, '');
|
|
||||||
let comp = dynamicImport(dynamicViewsModules, path);
|
|
||||||
if (!comp) {
|
|
||||||
comp = dynamicImport(dynamicViewsModules, path + '/index');
|
|
||||||
}
|
|
||||||
if (!comp) {
|
|
||||||
// 尝试直接拼接views路径
|
|
||||||
const viewsPath = 'views/' + path + '/index.vue';
|
|
||||||
const directKey = Object.keys(dynamicViewsModules).find((key) => key.includes(viewsPath));
|
|
||||||
if (directKey) {
|
|
||||||
comp = dynamicViewsModules[directKey];
|
|
||||||
}
|
|
||||||
}
|
|
||||||
if (comp) {
|
|
||||||
item.component = comp;
|
|
||||||
} else {
|
|
||||||
// 如果还是找不到,使用一个默认组件
|
|
||||||
item.component = dynamicViewsModules['../layout/routerView/parent.vue'];
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
return item;
|
return item;
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
@@ -197,43 +219,27 @@ export function backEndComponent(routes: any) {
|
|||||||
* @returns 返回处理成函数后的 component
|
* @returns 返回处理成函数后的 component
|
||||||
*/
|
*/
|
||||||
export function dynamicImport(dynamicViewsModules: Record<string, Function>, component: string) {
|
export function dynamicImport(dynamicViewsModules: Record<string, Function>, component: string) {
|
||||||
|
const normalizedComponent = normalizeRouteComponent(component);
|
||||||
|
if (!normalizedComponent) return false;
|
||||||
|
|
||||||
|
const directViewIndexVueKey = `../views/${normalizedComponent}/index.vue`;
|
||||||
|
if (dynamicViewsModules[directViewIndexVueKey]) return dynamicViewsModules[directViewIndexVueKey];
|
||||||
|
|
||||||
|
const directViewVueKey = `../views/${normalizedComponent}.vue`;
|
||||||
|
if (dynamicViewsModules[directViewVueKey]) return dynamicViewsModules[directViewVueKey];
|
||||||
|
|
||||||
|
const directViewTsxKey = `../views/${normalizedComponent}.tsx`;
|
||||||
|
if (dynamicViewsModules[directViewTsxKey]) return dynamicViewsModules[directViewTsxKey];
|
||||||
|
|
||||||
|
const directLayoutVueKey = `../${normalizedComponent}.vue`;
|
||||||
|
if (dynamicViewsModules[directLayoutVueKey]) return dynamicViewsModules[directLayoutVueKey];
|
||||||
|
|
||||||
|
const directLayoutTsxKey = `../${normalizedComponent}.tsx`;
|
||||||
|
if (dynamicViewsModules[directLayoutTsxKey]) return dynamicViewsModules[directLayoutTsxKey];
|
||||||
|
|
||||||
const keys = Object.keys(dynamicViewsModules);
|
const keys = Object.keys(dynamicViewsModules);
|
||||||
|
const fuzzyKey = keys.find((key) => key.includes(`/${normalizedComponent}/`) || key.includes(`/${normalizedComponent}.`));
|
||||||
// 尝试多种匹配方式
|
if (fuzzyKey) return dynamicViewsModules[fuzzyKey];
|
||||||
let matchKeys = keys.filter((key) => {
|
|
||||||
const k = key.replace(/..\/views|../, '');
|
|
||||||
return k.startsWith(`${component}`) || k.startsWith(`/${component}`);
|
|
||||||
});
|
|
||||||
|
|
||||||
// 如果没有匹配到,尝试带index的路径
|
|
||||||
if (matchKeys?.length === 0) {
|
|
||||||
matchKeys = keys.filter((key) => {
|
|
||||||
const k = key.replace(/..\/views|../, '');
|
|
||||||
return k.startsWith(`${component}/index`) || k.startsWith(`/${component}/index`);
|
|
||||||
});
|
|
||||||
}
|
|
||||||
|
|
||||||
// 尝试直接匹配完整路径
|
|
||||||
if (matchKeys?.length === 0) {
|
|
||||||
matchKeys = keys.filter((key) => {
|
|
||||||
return key.includes(component);
|
|
||||||
});
|
|
||||||
}
|
|
||||||
|
|
||||||
// 尝试更宽松的匹配方式
|
|
||||||
if (matchKeys?.length === 0) {
|
|
||||||
matchKeys = keys.filter((key) => {
|
|
||||||
return key.replace(/..\/views\//, '').includes(component.replace(/\//g, ''));
|
|
||||||
});
|
|
||||||
}
|
|
||||||
|
|
||||||
if (matchKeys?.length === 1) {
|
|
||||||
const matchKey = matchKeys[0];
|
|
||||||
return dynamicViewsModules[matchKey];
|
|
||||||
}
|
|
||||||
if (matchKeys?.length > 1) {
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
|
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -32,13 +32,7 @@
|
|||||||
|
|
||||||
<el-col :xs="24" :sm="24" :md="24" :lg="24" :xl="24" class="mb20">
|
<el-col :xs="24" :sm="24" :md="24" :lg="24" :xl="24" class="mb20">
|
||||||
<el-form-item label="备注" prop="remark">
|
<el-form-item label="备注" prop="remark">
|
||||||
<el-input
|
<el-input v-model="formData.remark" type="textarea" :rows="4" placeholder="请输入备注" clearable />
|
||||||
v-model="formData.remark"
|
|
||||||
type="textarea"
|
|
||||||
:rows="4"
|
|
||||||
placeholder="请输入备注"
|
|
||||||
clearable
|
|
||||||
/>
|
|
||||||
</el-form-item>
|
</el-form-item>
|
||||||
</el-col>
|
</el-col>
|
||||||
</el-row>
|
</el-row>
|
||||||
@@ -96,9 +90,7 @@ const rules: FormRules = {
|
|||||||
{ required: true, message: '联系电话不能为空', trigger: 'blur' },
|
{ required: true, message: '联系电话不能为空', trigger: 'blur' },
|
||||||
{ pattern: /^1[3-9]\d{9}$/, message: '请输入正确的手机号码', trigger: 'blur' },
|
{ pattern: /^1[3-9]\d{9}$/, message: '请输入正确的手机号码', trigger: 'blur' },
|
||||||
],
|
],
|
||||||
code: [
|
code: [{ required: true, message: '工号不能为空', trigger: 'blur' }],
|
||||||
{ required: true, message: '工号不能为空', trigger: 'blur' },
|
|
||||||
],
|
|
||||||
};
|
};
|
||||||
|
|
||||||
const formRef = ref<FormInstance>();
|
const formRef = ref<FormInstance>();
|
||||||
@@ -110,10 +102,10 @@ const openDialog = async (row?: DialogFormData) => {
|
|||||||
if (row && row.id) {
|
if (row && row.id) {
|
||||||
try {
|
try {
|
||||||
state.loading = true;
|
state.loading = true;
|
||||||
const res = await getAnchorOne({ id: row.id });
|
const res = await getAnchorOne({ id: String(row.id) });
|
||||||
if (res.data) {
|
if (res.data) {
|
||||||
state.formData = {
|
state.formData = {
|
||||||
id: res.data.id,
|
id: String(res.data.id),
|
||||||
name: res.data.name || '',
|
name: res.data.name || '',
|
||||||
phone: res.data.phone || '',
|
phone: res.data.phone || '',
|
||||||
code: res.data.code || '',
|
code: res.data.code || '',
|
||||||
@@ -122,7 +114,6 @@ const openDialog = async (row?: DialogFormData) => {
|
|||||||
};
|
};
|
||||||
}
|
}
|
||||||
} catch (error) {
|
} catch (error) {
|
||||||
console.error('获取主播详情失败:', error);
|
|
||||||
ElMessage.error('获取主播详情失败');
|
ElMessage.error('获取主播详情失败');
|
||||||
} finally {
|
} finally {
|
||||||
state.loading = false;
|
state.loading = false;
|
||||||
@@ -152,18 +143,23 @@ const onSubmit = async () => {
|
|||||||
|
|
||||||
state.loading = true;
|
state.loading = true;
|
||||||
|
|
||||||
if (state.formData.id) {
|
// 确保id是字符串类型
|
||||||
await updateAnchor(state.formData);
|
const submitData = {
|
||||||
|
...state.formData,
|
||||||
|
id: state.formData.id ? String(state.formData.id) : undefined,
|
||||||
|
};
|
||||||
|
|
||||||
|
if (submitData.id) {
|
||||||
|
await updateAnchor(submitData);
|
||||||
ElMessage.success('修改成功');
|
ElMessage.success('修改成功');
|
||||||
} else {
|
} else {
|
||||||
await addAnchor(state.formData);
|
await addAnchor(submitData);
|
||||||
ElMessage.success('添加成功');
|
ElMessage.success('添加成功');
|
||||||
}
|
}
|
||||||
|
|
||||||
closeDialog();
|
closeDialog();
|
||||||
emit('refresh');
|
emit('refresh');
|
||||||
} catch (error) {
|
} catch (error) {
|
||||||
console.error('操作失败:', error);
|
|
||||||
ElMessage.error('操作失败');
|
ElMessage.error('操作失败');
|
||||||
} finally {
|
} finally {
|
||||||
state.loading = false;
|
state.loading = false;
|
||||||
|
|||||||
@@ -12,7 +12,7 @@
|
|||||||
<el-input v-model="searchForm.code" placeholder="请输入工号" clearable />
|
<el-input v-model="searchForm.code" placeholder="请输入工号" clearable />
|
||||||
</el-form-item>
|
</el-form-item>
|
||||||
<el-form-item label="状态">
|
<el-form-item label="状态">
|
||||||
<el-select v-model="searchForm.status" placeholder="请选择状态" clearable>
|
<el-select v-model="searchForm.status" placeholder="请选择状态" clearable size="default" style="width: 160px">
|
||||||
<el-option label="正常" :value="1" />
|
<el-option label="正常" :value="1" />
|
||||||
<el-option label="停用" :value="0" />
|
<el-option label="停用" :value="0" />
|
||||||
</el-select>
|
</el-select>
|
||||||
@@ -159,11 +159,13 @@ const getList = async () => {
|
|||||||
status: searchForm.status,
|
status: searchForm.status,
|
||||||
});
|
});
|
||||||
if (res && res.data) {
|
if (res && res.data) {
|
||||||
tableData.data = res.data.list || [];
|
tableData.data = (res.data.list || []).map((item: any) => ({
|
||||||
|
...item,
|
||||||
|
id: String(item.id),
|
||||||
|
}));
|
||||||
tableData.total = res.data.total || 0;
|
tableData.total = res.data.total || 0;
|
||||||
}
|
}
|
||||||
} catch (error) {
|
} catch (error) {
|
||||||
console.error('获取主播列表失败:', error);
|
|
||||||
ElMessage.error('获取主播列表失败');
|
ElMessage.error('获取主播列表失败');
|
||||||
} finally {
|
} finally {
|
||||||
tableData.loading = false;
|
tableData.loading = false;
|
||||||
@@ -185,12 +187,11 @@ const handleDelete = async (row: TableDataItem) => {
|
|||||||
cancelButtonText: '取消',
|
cancelButtonText: '取消',
|
||||||
type: 'warning',
|
type: 'warning',
|
||||||
});
|
});
|
||||||
await deleteAnchor({ id: row.id });
|
await deleteAnchor({ id: String(row.id) });
|
||||||
ElMessage.success('删除成功');
|
ElMessage.success('删除成功');
|
||||||
getList();
|
getList();
|
||||||
} catch (error) {
|
} catch (error) {
|
||||||
if (error !== 'cancel') {
|
if (error !== 'cancel') {
|
||||||
console.error('删除失败:', error);
|
|
||||||
ElMessage.error('删除失败');
|
ElMessage.error('删除失败');
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -0,0 +1,159 @@
|
|||||||
|
<template>
|
||||||
|
<el-dialog v-model="dialogVisible" :title="isEdit ? '修改直播账号' : '新增直播账号'" width="500px">
|
||||||
|
<el-form ref="formRef" :model="formData" :rules="rules" label-width="80px">
|
||||||
|
<el-form-item label="平台" prop="platform">
|
||||||
|
<el-select v-model="formData.platform" placeholder="请选择平台" style="width: 100%">
|
||||||
|
<el-option label="抖音" value="抖音" />
|
||||||
|
<el-option label="快手" value="快手" />
|
||||||
|
<el-option label="视频号" value="视频号" />
|
||||||
|
</el-select>
|
||||||
|
</el-form-item>
|
||||||
|
<el-form-item label="账号名称" prop="accountName">
|
||||||
|
<el-input v-model="formData.accountName" placeholder="请输入账号名称" />
|
||||||
|
</el-form-item>
|
||||||
|
<el-form-item label="账号ID" prop="accountId">
|
||||||
|
<el-input v-model="formData.accountId" placeholder="请输入账号ID" />
|
||||||
|
</el-form-item>
|
||||||
|
<el-form-item label="状态" prop="status">
|
||||||
|
<el-select v-model="formData.status" placeholder="请选择状态" style="width: 100%">
|
||||||
|
<el-option label="正常" :value="1" />
|
||||||
|
<el-option label="停用" :value="0" />
|
||||||
|
</el-select>
|
||||||
|
</el-form-item>
|
||||||
|
<el-form-item label="备注" prop="remark">
|
||||||
|
<el-input v-model="formData.remark" placeholder="请输入备注" type="textarea" rows="3" />
|
||||||
|
</el-form-item>
|
||||||
|
</el-form>
|
||||||
|
<template #footer>
|
||||||
|
<span class="dialog-footer">
|
||||||
|
<el-button @click="dialogVisible = false">取消</el-button>
|
||||||
|
<el-button type="primary" @click="handleSubmit" :loading="loading">
|
||||||
|
{{ isEdit ? '修改' : '新增' }}
|
||||||
|
</el-button>
|
||||||
|
</span>
|
||||||
|
</template>
|
||||||
|
</el-dialog>
|
||||||
|
</template>
|
||||||
|
|
||||||
|
<script lang="ts" setup>
|
||||||
|
import { reactive, ref } from 'vue';
|
||||||
|
import { ElMessage, type FormInstance, type FormRules } from 'element-plus';
|
||||||
|
import {
|
||||||
|
createLiveAccount,
|
||||||
|
getLiveAccountDetail,
|
||||||
|
updateLiveAccount,
|
||||||
|
type LiveAccountSaveParams,
|
||||||
|
} from '/@/api/trade/operation/setting/live-account';
|
||||||
|
|
||||||
|
const emit = defineEmits<{
|
||||||
|
(e: 'refresh'): void;
|
||||||
|
}>();
|
||||||
|
|
||||||
|
interface LiveAccountFormData extends LiveAccountSaveParams {}
|
||||||
|
|
||||||
|
const dialogVisible = ref(false);
|
||||||
|
const formRef = ref<FormInstance>();
|
||||||
|
const loading = ref(false);
|
||||||
|
const isEdit = ref(false);
|
||||||
|
|
||||||
|
const formData = reactive<LiveAccountFormData>({
|
||||||
|
id: '',
|
||||||
|
platform: '',
|
||||||
|
accountName: '',
|
||||||
|
accountId: '',
|
||||||
|
status: 1,
|
||||||
|
remark: '',
|
||||||
|
});
|
||||||
|
|
||||||
|
const rules: FormRules = {
|
||||||
|
platform: [{ required: true, message: '请选择平台', trigger: 'change' }],
|
||||||
|
accountName: [{ required: true, message: '请输入账号名称', trigger: 'blur' }],
|
||||||
|
accountId: [{ required: true, message: '请输入账号ID', trigger: 'blur' }],
|
||||||
|
status: [{ required: true, message: '请选择状态', trigger: 'change' }],
|
||||||
|
};
|
||||||
|
|
||||||
|
const resetForm = () => {
|
||||||
|
formData.id = '';
|
||||||
|
formData.platform = '';
|
||||||
|
formData.accountName = '';
|
||||||
|
formData.accountId = '';
|
||||||
|
formData.status = 1;
|
||||||
|
formData.remark = '';
|
||||||
|
};
|
||||||
|
|
||||||
|
const fillForm = (data: Partial<LiveAccountFormData>) => {
|
||||||
|
formData.id = data.id ? String(data.id) : '';
|
||||||
|
formData.platform = data.platform || '';
|
||||||
|
formData.accountName = data.accountName || '';
|
||||||
|
formData.accountId = data.accountId || '';
|
||||||
|
formData.status = data.status ?? 1;
|
||||||
|
formData.remark = data.remark || '';
|
||||||
|
};
|
||||||
|
|
||||||
|
const openDialog = async (row?: { id?: string }) => {
|
||||||
|
resetForm();
|
||||||
|
isEdit.value = !!row?.id;
|
||||||
|
|
||||||
|
if (!row?.id) {
|
||||||
|
dialogVisible.value = true;
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
try {
|
||||||
|
loading.value = true;
|
||||||
|
const res = await getLiveAccountDetail({ id: String(row.id) });
|
||||||
|
if (res?.data) {
|
||||||
|
fillForm(res.data);
|
||||||
|
}
|
||||||
|
dialogVisible.value = true;
|
||||||
|
} catch (error) {
|
||||||
|
ElMessage.error('获取直播账号详情失败');
|
||||||
|
} finally {
|
||||||
|
loading.value = false;
|
||||||
|
}
|
||||||
|
};
|
||||||
|
|
||||||
|
const handleSubmit = async () => {
|
||||||
|
if (!formRef.value) return;
|
||||||
|
|
||||||
|
try {
|
||||||
|
await formRef.value.validate();
|
||||||
|
loading.value = true;
|
||||||
|
|
||||||
|
const payload: LiveAccountSaveParams = {
|
||||||
|
id: formData.id || undefined,
|
||||||
|
platform: formData.platform,
|
||||||
|
accountName: formData.accountName,
|
||||||
|
accountId: formData.accountId,
|
||||||
|
status: formData.status,
|
||||||
|
remark: formData.remark,
|
||||||
|
};
|
||||||
|
|
||||||
|
if (isEdit.value) {
|
||||||
|
await updateLiveAccount(payload);
|
||||||
|
ElMessage.success('修改成功');
|
||||||
|
} else {
|
||||||
|
await createLiveAccount(payload);
|
||||||
|
ElMessage.success('新增成功');
|
||||||
|
}
|
||||||
|
|
||||||
|
dialogVisible.value = false;
|
||||||
|
emit('refresh');
|
||||||
|
} catch (error) {
|
||||||
|
ElMessage.error(isEdit.value ? '修改失败' : '新增失败');
|
||||||
|
} finally {
|
||||||
|
loading.value = false;
|
||||||
|
}
|
||||||
|
};
|
||||||
|
|
||||||
|
defineExpose({
|
||||||
|
openDialog,
|
||||||
|
});
|
||||||
|
</script>
|
||||||
|
|
||||||
|
<style scoped>
|
||||||
|
.dialog-footer {
|
||||||
|
display: flex;
|
||||||
|
justify-content: flex-end;
|
||||||
|
}
|
||||||
|
</style>
|
||||||
247
src/views/trade/operation/setting/live-account/index.vue
Normal file
247
src/views/trade/operation/setting/live-account/index.vue
Normal file
@@ -0,0 +1,247 @@
|
|||||||
|
<template>
|
||||||
|
<div class="trade-operation-setting-live-account">
|
||||||
|
<el-card shadow="never" class="search-card">
|
||||||
|
<el-form :inline="true" :model="searchForm" class="mb20">
|
||||||
|
<el-form-item label="平台">
|
||||||
|
<el-select v-model="searchForm.platform" placeholder="请选择平台" clearable style="width: 120px">
|
||||||
|
<el-option label="抖音" :value="'抖音'" />
|
||||||
|
<el-option label="快手" :value="'快手'" />
|
||||||
|
<el-option label="视频号" :value="'视频号'" />
|
||||||
|
</el-select>
|
||||||
|
</el-form-item>
|
||||||
|
<el-form-item label="账号名称">
|
||||||
|
<el-input v-model="searchForm.accountName" placeholder="请输入账号名称" clearable style="width: 180px" />
|
||||||
|
</el-form-item>
|
||||||
|
<el-form-item label="账号ID">
|
||||||
|
<el-input v-model="searchForm.accountId" placeholder="请输入账号ID" clearable style="width: 180px" />
|
||||||
|
</el-form-item>
|
||||||
|
<el-form-item label="状态">
|
||||||
|
<el-select v-model="searchForm.status" placeholder="请选择状态" clearable 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" @click="handleSearch" :loading="tableData.loading" class="mr10">
|
||||||
|
<el-icon><Search /></el-icon>
|
||||||
|
查询
|
||||||
|
</el-button>
|
||||||
|
<el-button @click="handleReset" :disabled="tableData.loading" class="mr10">
|
||||||
|
<el-icon><Refresh /></el-icon>
|
||||||
|
重置
|
||||||
|
</el-button>
|
||||||
|
<el-button type="success" @click="onOpenAdd">
|
||||||
|
<el-icon><Plus /></el-icon>
|
||||||
|
新增
|
||||||
|
</el-button>
|
||||||
|
</el-form-item>
|
||||||
|
</el-form>
|
||||||
|
</el-card>
|
||||||
|
|
||||||
|
<el-card shadow="never" class="mt20">
|
||||||
|
<el-table v-loading="tableData.loading" :data="tableData.data" style="width: 100%" stripe border empty-text="暂无直播账号数据">
|
||||||
|
<el-table-column prop="id" label="ID" width="200" align="center" />
|
||||||
|
<el-table-column prop="platform" label="平台" min-width="100" />
|
||||||
|
<el-table-column prop="accountName" label="账号名称" min-width="150" />
|
||||||
|
<el-table-column prop="accountId" label="账号ID" min-width="150" />
|
||||||
|
<el-table-column prop="statusName" label="状态" width="100" align="center">
|
||||||
|
<template #default="{ row }">
|
||||||
|
<el-tag :type="row.status === 1 ? 'success' : 'info'">
|
||||||
|
{{ row.statusName }}
|
||||||
|
</el-tag>
|
||||||
|
</template>
|
||||||
|
</el-table-column>
|
||||||
|
<el-table-column prop="remark" label="备注" min-width="150" show-overflow-tooltip />
|
||||||
|
<el-table-column prop="createdAt" label="创建时间" width="180" align="center">
|
||||||
|
<template #default="{ row }">
|
||||||
|
{{ formatTimestamp(row.createdAt) }}
|
||||||
|
</template>
|
||||||
|
</el-table-column>
|
||||||
|
<el-table-column prop="updatedAt" label="更新时间" width="180" align="center">
|
||||||
|
<template #default="{ row }">
|
||||||
|
{{ formatTimestamp(row.updatedAt) }}
|
||||||
|
</template>
|
||||||
|
</el-table-column>
|
||||||
|
<el-table-column label="操作" width="180" fixed="right" align="center">
|
||||||
|
<template #default="{ row }">
|
||||||
|
<el-button size="small" type="primary" text @click="onOpenEdit(row)" class="mr5">
|
||||||
|
<el-icon><EditPen /></el-icon>修改
|
||||||
|
</el-button>
|
||||||
|
<el-button size="small" type="danger" text @click="handleDelete(row)">
|
||||||
|
<el-icon><Delete /></el-icon>删除
|
||||||
|
</el-button>
|
||||||
|
</template>
|
||||||
|
</el-table-column>
|
||||||
|
</el-table>
|
||||||
|
|
||||||
|
<el-pagination
|
||||||
|
v-model:current-page="tableData.param.pageNum"
|
||||||
|
v-model:page-size="tableData.param.pageSize"
|
||||||
|
:page-sizes="[10, 20, 30, 50]"
|
||||||
|
layout="total, sizes, prev, pager, next, jumper"
|
||||||
|
:total="tableData.total"
|
||||||
|
@size-change="handleSizeChange"
|
||||||
|
@current-change="handleCurrentChange"
|
||||||
|
class="mt20 flex justify-end"
|
||||||
|
/>
|
||||||
|
</el-card>
|
||||||
|
|
||||||
|
<EditLiveAccount ref="editLiveAccountRef" @refresh="getList" />
|
||||||
|
</div>
|
||||||
|
</template>
|
||||||
|
|
||||||
|
<script lang="ts" setup>
|
||||||
|
import { onMounted, reactive, ref } from 'vue';
|
||||||
|
import { ElMessage, ElMessageBox } from 'element-plus';
|
||||||
|
import { Search, Refresh, Plus, EditPen, Delete } from '@element-plus/icons-vue';
|
||||||
|
import { deleteLiveAccount, getLiveAccountList } from '/@/api/trade/operation/setting/live-account';
|
||||||
|
import EditLiveAccount from './component/editLiveAccount.vue';
|
||||||
|
|
||||||
|
interface LiveAccountItem {
|
||||||
|
id: string;
|
||||||
|
platform: string;
|
||||||
|
accountName: string;
|
||||||
|
accountId: string;
|
||||||
|
status: number;
|
||||||
|
statusName: string;
|
||||||
|
remark: string;
|
||||||
|
createdAt: number;
|
||||||
|
updatedAt: number;
|
||||||
|
}
|
||||||
|
|
||||||
|
const editLiveAccountRef = ref<InstanceType<typeof EditLiveAccount>>();
|
||||||
|
|
||||||
|
const searchForm = reactive({
|
||||||
|
platform: '',
|
||||||
|
accountName: '',
|
||||||
|
accountId: '',
|
||||||
|
status: undefined as number | undefined,
|
||||||
|
});
|
||||||
|
|
||||||
|
const tableData = reactive({
|
||||||
|
loading: false,
|
||||||
|
data: [] as LiveAccountItem[],
|
||||||
|
total: 0,
|
||||||
|
param: {
|
||||||
|
pageNum: 1,
|
||||||
|
pageSize: 10,
|
||||||
|
},
|
||||||
|
});
|
||||||
|
|
||||||
|
const getList = async () => {
|
||||||
|
try {
|
||||||
|
tableData.loading = true;
|
||||||
|
const res = await getLiveAccountList({
|
||||||
|
...tableData.param,
|
||||||
|
platform: searchForm.platform || undefined,
|
||||||
|
accountName: searchForm.accountName || undefined,
|
||||||
|
accountId: searchForm.accountId || undefined,
|
||||||
|
status: searchForm.status,
|
||||||
|
});
|
||||||
|
if (res && res.data) {
|
||||||
|
tableData.data = (res.data.list || []).map((item: any) => ({
|
||||||
|
...item,
|
||||||
|
id: String(item.id),
|
||||||
|
}));
|
||||||
|
tableData.total = res.data.total || 0;
|
||||||
|
}
|
||||||
|
} catch (error) {
|
||||||
|
ElMessage.error('获取直播账号列表失败');
|
||||||
|
} finally {
|
||||||
|
tableData.loading = false;
|
||||||
|
}
|
||||||
|
};
|
||||||
|
|
||||||
|
const handleSearch = () => {
|
||||||
|
tableData.param.pageNum = 1;
|
||||||
|
getList();
|
||||||
|
};
|
||||||
|
|
||||||
|
const handleReset = () => {
|
||||||
|
searchForm.platform = '';
|
||||||
|
searchForm.accountName = '';
|
||||||
|
searchForm.accountId = '';
|
||||||
|
searchForm.status = undefined;
|
||||||
|
tableData.param.pageNum = 1;
|
||||||
|
getList();
|
||||||
|
};
|
||||||
|
|
||||||
|
const handleSizeChange = (size: number) => {
|
||||||
|
tableData.param.pageSize = size;
|
||||||
|
getList();
|
||||||
|
};
|
||||||
|
|
||||||
|
const handleCurrentChange = (current: number) => {
|
||||||
|
tableData.param.pageNum = current;
|
||||||
|
getList();
|
||||||
|
};
|
||||||
|
|
||||||
|
const onOpenAdd = () => {
|
||||||
|
editLiveAccountRef.value?.openDialog();
|
||||||
|
};
|
||||||
|
|
||||||
|
const onOpenEdit = (row: LiveAccountItem) => {
|
||||||
|
editLiveAccountRef.value?.openDialog(row);
|
||||||
|
};
|
||||||
|
|
||||||
|
const handleDelete = async (row: LiveAccountItem) => {
|
||||||
|
try {
|
||||||
|
await ElMessageBox.confirm(`确定要删除直播账号「${row.accountName}」吗?`, '提示', {
|
||||||
|
confirmButtonText: '确定',
|
||||||
|
cancelButtonText: '取消',
|
||||||
|
type: 'warning',
|
||||||
|
});
|
||||||
|
await deleteLiveAccount({ id: row.id });
|
||||||
|
ElMessage.success('删除成功');
|
||||||
|
getList();
|
||||||
|
} catch (error) {
|
||||||
|
if (error !== 'cancel') {
|
||||||
|
ElMessage.error('删除失败');
|
||||||
|
}
|
||||||
|
}
|
||||||
|
};
|
||||||
|
|
||||||
|
const formatTimestamp = (timestamp: number) => {
|
||||||
|
if (!timestamp) return '';
|
||||||
|
const date = new Date(timestamp * 1000);
|
||||||
|
return date.toLocaleString('zh-CN');
|
||||||
|
};
|
||||||
|
|
||||||
|
onMounted(() => {
|
||||||
|
getList();
|
||||||
|
});
|
||||||
|
</script>
|
||||||
|
|
||||||
|
<style scoped lang="scss">
|
||||||
|
.trade-operation-setting-live-account {
|
||||||
|
padding: 20px;
|
||||||
|
}
|
||||||
|
|
||||||
|
.mb20 {
|
||||||
|
margin-bottom: 20px;
|
||||||
|
}
|
||||||
|
|
||||||
|
.mt20 {
|
||||||
|
margin-top: 20px;
|
||||||
|
}
|
||||||
|
|
||||||
|
.mr10 {
|
||||||
|
margin-right: 10px;
|
||||||
|
}
|
||||||
|
|
||||||
|
.mr5 {
|
||||||
|
margin-right: 5px;
|
||||||
|
}
|
||||||
|
|
||||||
|
.flex {
|
||||||
|
display: flex;
|
||||||
|
}
|
||||||
|
|
||||||
|
.justify-end {
|
||||||
|
justify-content: flex-end;
|
||||||
|
}
|
||||||
|
|
||||||
|
.search-card {
|
||||||
|
padding: 20px;
|
||||||
|
}
|
||||||
|
</style>
|
||||||
@@ -0,0 +1,225 @@
|
|||||||
|
<template>
|
||||||
|
<el-dialog v-model="dialogVisible" :title="isEdit ? '修改排班' : '新增排班'" width="680px">
|
||||||
|
<el-form ref="formRef" :model="formData" :rules="rules" label-width="100px">
|
||||||
|
<el-row :gutter="20">
|
||||||
|
<el-col :span="12">
|
||||||
|
<el-form-item label="主播" prop="anchorId">
|
||||||
|
<el-select v-model="formData.anchorId" placeholder="请选择主播" filterable style="width: 100%">
|
||||||
|
<el-option v-for="item in anchorOptions" :key="item.id" :label="item.name" :value="item.id" />
|
||||||
|
</el-select>
|
||||||
|
</el-form-item>
|
||||||
|
</el-col>
|
||||||
|
<el-col :span="12">
|
||||||
|
<el-form-item label="直播账号" prop="accountId">
|
||||||
|
<el-select v-model="formData.accountId" placeholder="请选择直播账号" filterable style="width: 100%">
|
||||||
|
<el-option
|
||||||
|
v-for="item in liveAccountOptions"
|
||||||
|
:key="item.id"
|
||||||
|
:label="`${item.platform} / ${item.accountName}`"
|
||||||
|
:value="item.id"
|
||||||
|
/>
|
||||||
|
</el-select>
|
||||||
|
</el-form-item>
|
||||||
|
</el-col>
|
||||||
|
<el-col :span="12">
|
||||||
|
<el-form-item label="开始时间" prop="startTime">
|
||||||
|
<el-date-picker v-model="formData.startTime" type="datetime" placeholder="请选择开始时间" style="width: 100%" />
|
||||||
|
</el-form-item>
|
||||||
|
</el-col>
|
||||||
|
<el-col :span="12">
|
||||||
|
<el-form-item label="结束时间" prop="endTime">
|
||||||
|
<el-date-picker v-model="formData.endTime" type="datetime" placeholder="请选择结束时间" style="width: 100%" />
|
||||||
|
</el-form-item>
|
||||||
|
</el-col>
|
||||||
|
<el-col :span="12">
|
||||||
|
<el-form-item label="状态" prop="status">
|
||||||
|
<el-select v-model="formData.status" placeholder="请选择状态" style="width: 100%">
|
||||||
|
<el-option label="待直播" :value="0" />
|
||||||
|
<el-option label="直播中" :value="1" />
|
||||||
|
<el-option label="已结束" :value="2" />
|
||||||
|
</el-select>
|
||||||
|
</el-form-item>
|
||||||
|
</el-col>
|
||||||
|
<el-col :span="12">
|
||||||
|
<el-form-item label="商品ID" prop="productId">
|
||||||
|
<el-input-number v-model="formData.productId" :min="0" controls-position="right" style="width: 100%" />
|
||||||
|
</el-form-item>
|
||||||
|
</el-col>
|
||||||
|
<el-col :span="12">
|
||||||
|
<el-form-item label="订单ID" prop="orderId">
|
||||||
|
<el-input-number v-model="formData.orderId" :min="0" controls-position="right" style="width: 100%" />
|
||||||
|
</el-form-item>
|
||||||
|
</el-col>
|
||||||
|
<el-col :span="24">
|
||||||
|
<el-form-item label="备注" prop="remark">
|
||||||
|
<el-input v-model="formData.remark" type="textarea" :rows="3" placeholder="请输入备注" />
|
||||||
|
</el-form-item>
|
||||||
|
</el-col>
|
||||||
|
</el-row>
|
||||||
|
</el-form>
|
||||||
|
<template #footer>
|
||||||
|
<span class="dialog-footer">
|
||||||
|
<el-button @click="dialogVisible = false">取消</el-button>
|
||||||
|
<el-button type="primary" :loading="loading" @click="handleSubmit">提交</el-button>
|
||||||
|
</span>
|
||||||
|
</template>
|
||||||
|
</el-dialog>
|
||||||
|
</template>
|
||||||
|
|
||||||
|
<script lang="ts" setup>
|
||||||
|
import { reactive, ref } from 'vue';
|
||||||
|
import { ElMessage, type FormInstance, type FormRules } from 'element-plus';
|
||||||
|
import { getAnchorList } from '/@/api/trade/operation/setting/anchor';
|
||||||
|
import { getLiveAccountList } from '/@/api/trade/operation/setting/live-account';
|
||||||
|
import { createSchedule, getScheduleDetail, updateSchedule, type ScheduleSaveParams } from '/@/api/trade/operation/setting/scheduling';
|
||||||
|
|
||||||
|
const emit = defineEmits<{
|
||||||
|
(e: 'refresh'): void;
|
||||||
|
}>();
|
||||||
|
|
||||||
|
interface AnchorOption {
|
||||||
|
id: string;
|
||||||
|
name: string;
|
||||||
|
}
|
||||||
|
|
||||||
|
interface LiveAccountOption {
|
||||||
|
id: string;
|
||||||
|
platform: string;
|
||||||
|
accountName: string;
|
||||||
|
}
|
||||||
|
|
||||||
|
const dialogVisible = ref(false);
|
||||||
|
const loading = ref(false);
|
||||||
|
const isEdit = ref(false);
|
||||||
|
const formRef = ref<FormInstance>();
|
||||||
|
const anchorOptions = ref<AnchorOption[]>([]);
|
||||||
|
const liveAccountOptions = ref<LiveAccountOption[]>([]);
|
||||||
|
|
||||||
|
const formData = reactive({
|
||||||
|
id: '',
|
||||||
|
anchorId: undefined as string | undefined,
|
||||||
|
accountId: undefined as string | undefined,
|
||||||
|
productId: 0,
|
||||||
|
orderId: 0,
|
||||||
|
startTime: undefined as Date | undefined,
|
||||||
|
endTime: undefined as Date | undefined,
|
||||||
|
status: 0,
|
||||||
|
remark: '',
|
||||||
|
});
|
||||||
|
|
||||||
|
const rules: FormRules = {
|
||||||
|
anchorId: [{ required: true, message: '请选择主播', trigger: 'change' }],
|
||||||
|
accountId: [{ required: true, message: '请选择直播账号', trigger: 'change' }],
|
||||||
|
startTime: [{ required: true, message: '请选择开始时间', trigger: 'change' }],
|
||||||
|
endTime: [{ required: true, message: '请选择结束时间', trigger: 'change' }],
|
||||||
|
};
|
||||||
|
|
||||||
|
const resetForm = () => {
|
||||||
|
formData.id = '';
|
||||||
|
formData.anchorId = undefined;
|
||||||
|
formData.accountId = undefined;
|
||||||
|
formData.productId = 0;
|
||||||
|
formData.orderId = 0;
|
||||||
|
formData.startTime = undefined;
|
||||||
|
formData.endTime = undefined;
|
||||||
|
formData.status = 0;
|
||||||
|
formData.remark = '';
|
||||||
|
};
|
||||||
|
|
||||||
|
const loadOptions = async () => {
|
||||||
|
const [anchorRes, liveAccountRes] = await Promise.all([
|
||||||
|
getAnchorList({ pageNum: 1, pageSize: 9999 }),
|
||||||
|
getLiveAccountList({ pageNum: 1, pageSize: 9999 }),
|
||||||
|
]);
|
||||||
|
|
||||||
|
anchorOptions.value = (anchorRes?.data?.list || []).map((item: any) => ({
|
||||||
|
id: String(item.id),
|
||||||
|
name: item.name || `主播${item.id}`,
|
||||||
|
}));
|
||||||
|
|
||||||
|
liveAccountOptions.value = (liveAccountRes?.data?.list || []).map((item: any) => ({
|
||||||
|
id: String(item.id),
|
||||||
|
platform: item.platform || '',
|
||||||
|
accountName: item.accountName || `账号${item.id}`,
|
||||||
|
}));
|
||||||
|
};
|
||||||
|
|
||||||
|
const openDialog = async (row?: { id?: string }) => {
|
||||||
|
resetForm();
|
||||||
|
isEdit.value = !!row?.id;
|
||||||
|
|
||||||
|
try {
|
||||||
|
loading.value = true;
|
||||||
|
await loadOptions();
|
||||||
|
|
||||||
|
if (row?.id) {
|
||||||
|
const res = await getScheduleDetail({ id: String(row.id) });
|
||||||
|
const detail = res?.data;
|
||||||
|
if (detail) {
|
||||||
|
formData.id = String(detail.id);
|
||||||
|
formData.anchorId = detail.anchorId ? String(detail.anchorId) : undefined;
|
||||||
|
formData.accountId = detail.accountId ? String(detail.accountId) : undefined;
|
||||||
|
formData.productId = detail.productId || 0;
|
||||||
|
formData.orderId = detail.orderId || 0;
|
||||||
|
formData.startTime = detail.startTime ? new Date(detail.startTime) : undefined;
|
||||||
|
formData.endTime = detail.endTime ? new Date(detail.endTime) : undefined;
|
||||||
|
formData.status = detail.status ?? 0;
|
||||||
|
formData.remark = detail.remark || '';
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
dialogVisible.value = true;
|
||||||
|
} catch (error) {
|
||||||
|
ElMessage.error(isEdit.value ? '获取排班详情失败' : '加载排班基础数据失败');
|
||||||
|
} finally {
|
||||||
|
loading.value = false;
|
||||||
|
}
|
||||||
|
};
|
||||||
|
|
||||||
|
const handleSubmit = async () => {
|
||||||
|
if (!formRef.value) return;
|
||||||
|
|
||||||
|
try {
|
||||||
|
await formRef.value.validate();
|
||||||
|
loading.value = true;
|
||||||
|
|
||||||
|
const payload: ScheduleSaveParams = {
|
||||||
|
id: formData.id || undefined,
|
||||||
|
anchorId: formData.anchorId as string,
|
||||||
|
accountId: formData.accountId as string,
|
||||||
|
productId: formData.productId || 0,
|
||||||
|
orderId: formData.orderId || 0,
|
||||||
|
startTime: (formData.startTime as Date).toISOString(),
|
||||||
|
endTime: (formData.endTime as Date).toISOString(),
|
||||||
|
status: formData.status,
|
||||||
|
remark: formData.remark,
|
||||||
|
};
|
||||||
|
|
||||||
|
if (isEdit.value) {
|
||||||
|
await updateSchedule(payload);
|
||||||
|
ElMessage.success('修改排班成功');
|
||||||
|
} else {
|
||||||
|
await createSchedule(payload);
|
||||||
|
ElMessage.success('新增排班成功');
|
||||||
|
}
|
||||||
|
|
||||||
|
dialogVisible.value = false;
|
||||||
|
emit('refresh');
|
||||||
|
} catch (error) {
|
||||||
|
ElMessage.error(isEdit.value ? '修改排班失败' : '新增排班失败');
|
||||||
|
} finally {
|
||||||
|
loading.value = false;
|
||||||
|
}
|
||||||
|
};
|
||||||
|
|
||||||
|
defineExpose({
|
||||||
|
openDialog,
|
||||||
|
});
|
||||||
|
</script>
|
||||||
|
|
||||||
|
<style scoped>
|
||||||
|
.dialog-footer {
|
||||||
|
display: flex;
|
||||||
|
justify-content: flex-end;
|
||||||
|
}
|
||||||
|
</style>
|
||||||
237
src/views/trade/operation/setting/scheduling/index.vue
Normal file
237
src/views/trade/operation/setting/scheduling/index.vue
Normal file
@@ -0,0 +1,237 @@
|
|||||||
|
<template>
|
||||||
|
<div class="trade-operation-setting-scheduling">
|
||||||
|
<el-card shadow="never" class="search-card">
|
||||||
|
<el-form :inline="true" :model="searchForm" class="mb20">
|
||||||
|
<el-form-item label="主播名">
|
||||||
|
<el-input v-model="searchForm.anchorName" placeholder="请输入主播名" clearable style="width: 160px" />
|
||||||
|
</el-form-item>
|
||||||
|
<el-form-item label="直播账号名">
|
||||||
|
<el-input v-model="searchForm.accountName" placeholder="请输入直播账号名" clearable style="width: 160px" />
|
||||||
|
</el-form-item>
|
||||||
|
<el-form-item label="状态">
|
||||||
|
<el-select v-model="searchForm.status" placeholder="请选择状态" clearable style="width: 140px">
|
||||||
|
<el-option label="待直播" :value="0" />
|
||||||
|
<el-option label="直播中" :value="1" />
|
||||||
|
<el-option label="已结束" :value="2" />
|
||||||
|
</el-select>
|
||||||
|
</el-form-item>
|
||||||
|
<el-form-item>
|
||||||
|
<el-button type="primary" @click="handleSearch" :loading="tableData.loading">
|
||||||
|
<el-icon><Search /></el-icon>
|
||||||
|
查询
|
||||||
|
</el-button>
|
||||||
|
<el-button @click="handleReset" :disabled="tableData.loading">
|
||||||
|
<el-icon><Refresh /></el-icon>
|
||||||
|
重置
|
||||||
|
</el-button>
|
||||||
|
<el-button type="success" @click="onOpenAdd">
|
||||||
|
<el-icon><Plus /></el-icon>
|
||||||
|
新增排班
|
||||||
|
</el-button>
|
||||||
|
</el-form-item>
|
||||||
|
</el-form>
|
||||||
|
</el-card>
|
||||||
|
|
||||||
|
<el-card shadow="never" class="mt20">
|
||||||
|
<el-table v-loading="tableData.loading" :data="tableData.data" style="width: 100%" stripe border>
|
||||||
|
<el-table-column label="排序" width="80" align="center">
|
||||||
|
<template #default="scope">
|
||||||
|
{{ (tableData.param.pageNum - 1) * tableData.param.pageSize + scope.$index + 1 }}
|
||||||
|
</template>
|
||||||
|
</el-table-column>
|
||||||
|
<el-table-column prop="anchorName" label="主播名" min-width="140" />
|
||||||
|
<el-table-column prop="accountName" label="直播账号名" min-width="160" />
|
||||||
|
<el-table-column prop="startTime" label="开始时间" width="180">
|
||||||
|
<template #default="{ row }">
|
||||||
|
{{ formatTimestamp(row.startTime) }}
|
||||||
|
</template>
|
||||||
|
</el-table-column>
|
||||||
|
<el-table-column prop="endTime" label="结束时间" width="180">
|
||||||
|
<template #default="{ row }">
|
||||||
|
{{ formatTimestamp(row.endTime) }}
|
||||||
|
</template>
|
||||||
|
</el-table-column>
|
||||||
|
<el-table-column prop="statusName" label="状态" width="100" align="center">
|
||||||
|
<template #default="{ row }">
|
||||||
|
<el-tag :type="getStatusTagType(row.status)">{{ row.statusName }}</el-tag>
|
||||||
|
</template>
|
||||||
|
</el-table-column>
|
||||||
|
<el-table-column prop="remark" label="备注" min-width="180" show-overflow-tooltip />
|
||||||
|
<el-table-column prop="createdAt" label="创建时间" width="180">
|
||||||
|
<template #default="{ row }">
|
||||||
|
{{ formatTimestamp(row.createdAt) }}
|
||||||
|
</template>
|
||||||
|
</el-table-column>
|
||||||
|
<el-table-column label="操作" width="150">
|
||||||
|
<template #default="{ row }">
|
||||||
|
<el-button size="small" type="primary" text @click="onOpenEdit(row)">
|
||||||
|
<el-icon><EditPen /></el-icon>修改
|
||||||
|
</el-button>
|
||||||
|
<el-button size="small" type="danger" text @click="handleDelete(row)">
|
||||||
|
<el-icon><Delete /></el-icon>删除
|
||||||
|
</el-button>
|
||||||
|
</template>
|
||||||
|
</el-table-column>
|
||||||
|
</el-table>
|
||||||
|
|
||||||
|
<el-pagination
|
||||||
|
v-model:current-page="tableData.param.pageNum"
|
||||||
|
v-model:page-size="tableData.param.pageSize"
|
||||||
|
:page-sizes="[10, 20, 30, 50]"
|
||||||
|
layout="total, sizes, prev, pager, next, jumper"
|
||||||
|
:total="tableData.total"
|
||||||
|
@size-change="handleSizeChange"
|
||||||
|
@current-change="handleCurrentChange"
|
||||||
|
class="mt20"
|
||||||
|
/>
|
||||||
|
</el-card>
|
||||||
|
|
||||||
|
<EditSchedule ref="editScheduleRef" @refresh="getList" />
|
||||||
|
</div>
|
||||||
|
</template>
|
||||||
|
|
||||||
|
<script lang="ts" setup>
|
||||||
|
import { onMounted, reactive, ref } from 'vue';
|
||||||
|
import { ElMessage, ElMessageBox } from 'element-plus';
|
||||||
|
import { Search, Refresh, Plus, EditPen, Delete } from '@element-plus/icons-vue';
|
||||||
|
import { deleteSchedule, getScheduleList } from '/@/api/trade/operation/setting/scheduling';
|
||||||
|
import EditSchedule from './component/editSchedule.vue';
|
||||||
|
|
||||||
|
interface ScheduleItem {
|
||||||
|
id: string;
|
||||||
|
anchorId: string;
|
||||||
|
anchorName: string;
|
||||||
|
accountId: string;
|
||||||
|
accountName: string;
|
||||||
|
startTime: number;
|
||||||
|
endTime: number;
|
||||||
|
status: number;
|
||||||
|
statusName: string;
|
||||||
|
remark: string;
|
||||||
|
createdAt: number;
|
||||||
|
updatedAt: number;
|
||||||
|
}
|
||||||
|
|
||||||
|
const editScheduleRef = ref<InstanceType<typeof EditSchedule>>();
|
||||||
|
|
||||||
|
const searchForm = reactive({
|
||||||
|
anchorName: '',
|
||||||
|
accountName: '',
|
||||||
|
status: undefined as number | undefined,
|
||||||
|
});
|
||||||
|
|
||||||
|
const tableData = reactive({
|
||||||
|
loading: false,
|
||||||
|
data: [] as ScheduleItem[],
|
||||||
|
total: 0,
|
||||||
|
param: {
|
||||||
|
pageNum: 1,
|
||||||
|
pageSize: 10,
|
||||||
|
},
|
||||||
|
});
|
||||||
|
|
||||||
|
const formatTimestamp = (timestamp: number) => {
|
||||||
|
if (!timestamp) return '';
|
||||||
|
return new Date(timestamp * 1000).toLocaleString('zh-CN');
|
||||||
|
};
|
||||||
|
|
||||||
|
const getStatusTagType = (status: number): 'success' | 'info' | 'warning' => {
|
||||||
|
if (status === 1) return 'success';
|
||||||
|
if (status === 2) return 'info';
|
||||||
|
return 'warning';
|
||||||
|
};
|
||||||
|
|
||||||
|
const getList = async () => {
|
||||||
|
try {
|
||||||
|
tableData.loading = true;
|
||||||
|
const res = await getScheduleList({
|
||||||
|
...tableData.param,
|
||||||
|
anchorName: searchForm.anchorName || undefined,
|
||||||
|
accountName: searchForm.accountName || undefined,
|
||||||
|
status: searchForm.status,
|
||||||
|
} as any);
|
||||||
|
const scheduleData = res?.data;
|
||||||
|
if (scheduleData) {
|
||||||
|
tableData.data = (scheduleData.list || []).map((item: any) => ({
|
||||||
|
...item,
|
||||||
|
id: String(item.id),
|
||||||
|
anchorId: String(item.anchorId),
|
||||||
|
anchorName: item.anchorName || '',
|
||||||
|
accountId: String(item.accountId),
|
||||||
|
accountName: item.accountName || '',
|
||||||
|
}));
|
||||||
|
tableData.total = scheduleData.total || 0;
|
||||||
|
}
|
||||||
|
} catch (error) {
|
||||||
|
ElMessage.error('获取排班列表失败');
|
||||||
|
} finally {
|
||||||
|
tableData.loading = false;
|
||||||
|
}
|
||||||
|
};
|
||||||
|
|
||||||
|
const handleSearch = () => {
|
||||||
|
tableData.param.pageNum = 1;
|
||||||
|
getList();
|
||||||
|
};
|
||||||
|
|
||||||
|
const handleReset = () => {
|
||||||
|
searchForm.anchorName = '';
|
||||||
|
searchForm.accountName = '';
|
||||||
|
searchForm.status = undefined;
|
||||||
|
tableData.param.pageNum = 1;
|
||||||
|
getList();
|
||||||
|
};
|
||||||
|
|
||||||
|
const handleSizeChange = (size: number) => {
|
||||||
|
tableData.param.pageSize = size;
|
||||||
|
getList();
|
||||||
|
};
|
||||||
|
|
||||||
|
const handleCurrentChange = (current: number) => {
|
||||||
|
tableData.param.pageNum = current;
|
||||||
|
getList();
|
||||||
|
};
|
||||||
|
|
||||||
|
const onOpenAdd = () => {
|
||||||
|
editScheduleRef.value?.openDialog();
|
||||||
|
};
|
||||||
|
|
||||||
|
const onOpenEdit = (row: ScheduleItem) => {
|
||||||
|
editScheduleRef.value?.openDialog(row);
|
||||||
|
};
|
||||||
|
|
||||||
|
const handleDelete = async (row: ScheduleItem) => {
|
||||||
|
try {
|
||||||
|
await ElMessageBox.confirm(`确定要删除排班「${row.id}」吗?`, '提示', {
|
||||||
|
confirmButtonText: '确定',
|
||||||
|
cancelButtonText: '取消',
|
||||||
|
type: 'warning',
|
||||||
|
});
|
||||||
|
await deleteSchedule({ id: row.id });
|
||||||
|
ElMessage.success('删除成功');
|
||||||
|
getList();
|
||||||
|
} catch (error) {
|
||||||
|
if (error !== 'cancel') {
|
||||||
|
ElMessage.error('删除失败');
|
||||||
|
}
|
||||||
|
}
|
||||||
|
};
|
||||||
|
|
||||||
|
onMounted(() => {
|
||||||
|
getList();
|
||||||
|
});
|
||||||
|
</script>
|
||||||
|
|
||||||
|
<style scoped lang="scss">
|
||||||
|
.trade-operation-setting-scheduling {
|
||||||
|
padding: 20px;
|
||||||
|
}
|
||||||
|
|
||||||
|
.mb20 {
|
||||||
|
margin-bottom: 20px;
|
||||||
|
}
|
||||||
|
|
||||||
|
.mt20 {
|
||||||
|
margin-top: 20px;
|
||||||
|
}
|
||||||
|
</style>
|
||||||
Reference in New Issue
Block a user