mirror of
https://gitee.com/yudaocode/yudao-ui-admin-vben.git
synced 2025-12-30 10:32:25 +00:00
Merge remote-tracking branch 'yudao/dev' into dev
This commit is contained in:
@@ -3,7 +3,7 @@ import type { PageParam, PageResult } from '@vben/request';
|
||||
import { requestClient } from '#/api/request';
|
||||
|
||||
export namespace ErpAccountApi {
|
||||
/** ERP 结算账户信息 */
|
||||
/** 结算账户信息 */
|
||||
export interface Account {
|
||||
id?: number; // 结算账户编号
|
||||
no: string; // 账户编码
|
||||
@@ -13,17 +13,10 @@ export namespace ErpAccountApi {
|
||||
defaultStatus: boolean; // 是否默认
|
||||
name: string; // 账户名称
|
||||
}
|
||||
|
||||
/** 结算账户分页查询参数 */
|
||||
export interface AccountPageParam extends PageParam {
|
||||
name?: string;
|
||||
no?: string;
|
||||
status?: number;
|
||||
}
|
||||
}
|
||||
|
||||
/** 查询结算账户分页 */
|
||||
export function getAccountPage(params: ErpAccountApi.AccountPageParam) {
|
||||
export function getAccountPage(params: PageParam) {
|
||||
return requestClient.get<PageResult<ErpAccountApi.Account>>(
|
||||
'/erp/account/page',
|
||||
{ params },
|
||||
|
||||
@@ -3,19 +3,6 @@ import type { PageParam, PageResult } from '@vben/request';
|
||||
import { requestClient } from '#/api/request';
|
||||
|
||||
export namespace ErpFinancePaymentApi {
|
||||
/** 付款单项 */
|
||||
export interface FinancePaymentItem {
|
||||
id?: number;
|
||||
row_id?: number; // 前端使用的临时ID
|
||||
bizId: number; // 业务ID
|
||||
bizType: number; // 业务类型
|
||||
bizNo: string; // 业务编号
|
||||
totalPrice: number; // 应付金额
|
||||
paidPrice: number; // 已付金额
|
||||
paymentPrice: number; // 本次付款
|
||||
remark?: string; // 备注
|
||||
}
|
||||
|
||||
/** 付款单信息 */
|
||||
export interface FinancePayment {
|
||||
id?: number; // 付款单编号
|
||||
@@ -39,24 +26,22 @@ export namespace ErpFinancePaymentApi {
|
||||
bizNo?: string; // 业务单号
|
||||
}
|
||||
|
||||
/** 付款单分页查询参数 */
|
||||
export interface FinancePaymentPageParams extends PageParam {
|
||||
no?: string;
|
||||
paymentTime?: [string, string];
|
||||
supplierId?: number;
|
||||
creator?: string;
|
||||
financeUserId?: number;
|
||||
accountId?: number;
|
||||
status?: number;
|
||||
remark?: string;
|
||||
bizNo?: string;
|
||||
/** 付款单项 */
|
||||
export interface FinancePaymentItem {
|
||||
id?: number;
|
||||
row_id?: number; // 前端使用的临时 ID
|
||||
bizId: number; // 业务ID
|
||||
bizType: number; // 业务类型
|
||||
bizNo: string; // 业务编号
|
||||
totalPrice: number; // 应付金额
|
||||
paidPrice: number; // 已付金额
|
||||
paymentPrice: number; // 本次付款
|
||||
remark?: string; // 备注
|
||||
}
|
||||
}
|
||||
|
||||
/** 查询付款单分页 */
|
||||
export function getFinancePaymentPage(
|
||||
params: ErpFinancePaymentApi.FinancePaymentPageParams,
|
||||
) {
|
||||
export function getFinancePaymentPage(params: PageParam) {
|
||||
return requestClient.get<PageResult<ErpFinancePaymentApi.FinancePayment>>(
|
||||
'/erp/finance-payment/page',
|
||||
{
|
||||
@@ -103,9 +88,7 @@ export function deleteFinancePayment(ids: number[]) {
|
||||
}
|
||||
|
||||
/** 导出付款单 Excel */
|
||||
export function exportFinancePayment(
|
||||
params: ErpFinancePaymentApi.FinancePaymentPageParams,
|
||||
) {
|
||||
export function exportFinancePayment(params: any) {
|
||||
return requestClient.download('/erp/finance-payment/export-excel', {
|
||||
params,
|
||||
});
|
||||
|
||||
@@ -6,7 +6,7 @@ export namespace ErpFinanceReceiptApi {
|
||||
/** 收款单项 */
|
||||
export interface FinanceReceiptItem {
|
||||
id?: number;
|
||||
row_id?: number; // 前端使用的临时ID
|
||||
row_id?: number; // 前端使用的临时 ID
|
||||
bizId: number; // 业务ID
|
||||
bizType: number; // 业务类型
|
||||
bizNo: string; // 业务编号
|
||||
@@ -38,25 +38,10 @@ export namespace ErpFinanceReceiptApi {
|
||||
items?: FinanceReceiptItem[]; // 收款明细
|
||||
bizNo?: string; // 业务单号
|
||||
}
|
||||
|
||||
/** 收款单分页查询参数 */
|
||||
export interface FinanceReceiptPageParams extends PageParam {
|
||||
no?: string;
|
||||
receiptTime?: [string, string];
|
||||
customerId?: number;
|
||||
creator?: string;
|
||||
financeUserId?: number;
|
||||
accountId?: number;
|
||||
status?: number;
|
||||
remark?: string;
|
||||
bizNo?: string;
|
||||
}
|
||||
}
|
||||
|
||||
/** 查询收款单分页 */
|
||||
export function getFinanceReceiptPage(
|
||||
params: ErpFinanceReceiptApi.FinanceReceiptPageParams,
|
||||
) {
|
||||
export function getFinanceReceiptPage(params: PageParam) {
|
||||
return requestClient.get<PageResult<ErpFinanceReceiptApi.FinanceReceipt>>(
|
||||
'/erp/finance-receipt/page',
|
||||
{
|
||||
@@ -103,9 +88,7 @@ export function deleteFinanceReceipt(ids: number[]) {
|
||||
}
|
||||
|
||||
/** 导出收款单 Excel */
|
||||
export function exportFinanceReceipt(
|
||||
params: ErpFinanceReceiptApi.FinanceReceiptPageParams,
|
||||
) {
|
||||
export function exportFinanceReceipt(params: any) {
|
||||
return requestClient.download('/erp/finance-receipt/export-excel', {
|
||||
params,
|
||||
});
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
import { requestClient } from '#/api/request';
|
||||
|
||||
export namespace ErpProductCategoryApi {
|
||||
/** ERP 产品分类信息 */
|
||||
/** 产品分类信息 */
|
||||
export interface ProductCategory {
|
||||
id?: number; // 分类编号
|
||||
parentId?: number; // 父分类编号
|
||||
|
||||
@@ -3,7 +3,7 @@ import type { PageParam, PageResult } from '@vben/request';
|
||||
import { requestClient } from '#/api/request';
|
||||
|
||||
export namespace ErpProductApi {
|
||||
/** ERP 产品信息 */
|
||||
/** 产品信息 */
|
||||
export interface Product {
|
||||
id?: number; // 产品编号
|
||||
name: string; // 产品名称
|
||||
|
||||
@@ -3,24 +3,16 @@ import type { PageParam, PageResult } from '@vben/request';
|
||||
import { requestClient } from '#/api/request';
|
||||
|
||||
export namespace ErpProductUnitApi {
|
||||
/** ERP 产品单位信息 */
|
||||
/** 产品单位信息 */
|
||||
export interface ProductUnit {
|
||||
id?: number; // 单位编号
|
||||
name: string; // 单位名字
|
||||
status: number; // 单位状态
|
||||
}
|
||||
|
||||
/** 产品单位分页查询参数 */
|
||||
export interface ProductUnitPageParam extends PageParam {
|
||||
name?: string;
|
||||
status?: number;
|
||||
}
|
||||
}
|
||||
|
||||
/** 查询产品单位分页 */
|
||||
export function getProductUnitPage(
|
||||
params: ErpProductUnitApi.ProductUnitPageParam,
|
||||
) {
|
||||
export function getProductUnitPage(params: PageParam) {
|
||||
return requestClient.get<PageResult<ErpProductUnitApi.ProductUnit>>(
|
||||
'/erp/product-unit/page',
|
||||
{ params },
|
||||
|
||||
@@ -23,6 +23,8 @@ export namespace ErpPurchaseInApi {
|
||||
taxPrice?: number; // 合计税额
|
||||
items?: PurchaseInItem[]; // 采购入库明细
|
||||
}
|
||||
|
||||
/** 采购项信息 */
|
||||
export interface PurchaseInItem {
|
||||
count?: number;
|
||||
id?: number;
|
||||
@@ -42,21 +44,10 @@ export namespace ErpPurchaseInApi {
|
||||
warehouseId?: number;
|
||||
inCount?: number;
|
||||
}
|
||||
|
||||
/** 采购入库分页查询参数 */
|
||||
export interface PurchaseInPageParams extends PageParam {
|
||||
no?: string;
|
||||
supplierId?: number;
|
||||
status?: number;
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* 查询采购入库分页
|
||||
*/
|
||||
export function getPurchaseInPage(
|
||||
params: ErpPurchaseInApi.PurchaseInPageParams,
|
||||
) {
|
||||
/** 查询采购入库分页 */
|
||||
export function getPurchaseInPage(params: PageParam) {
|
||||
return requestClient.get<PageResult<ErpPurchaseInApi.PurchaseIn>>(
|
||||
'/erp/purchase-in/page',
|
||||
{
|
||||
@@ -65,32 +56,24 @@ export function getPurchaseInPage(
|
||||
);
|
||||
}
|
||||
|
||||
/**
|
||||
* 查询采购入库详情
|
||||
*/
|
||||
/** 查询采购入库详情 */
|
||||
export function getPurchaseIn(id: number) {
|
||||
return requestClient.get<ErpPurchaseInApi.PurchaseIn>(
|
||||
`/erp/purchase-in/get?id=${id}`,
|
||||
);
|
||||
}
|
||||
|
||||
/**
|
||||
* 新增采购入库
|
||||
*/
|
||||
/** 新增采购入库 */
|
||||
export function createPurchaseIn(data: ErpPurchaseInApi.PurchaseIn) {
|
||||
return requestClient.post('/erp/purchase-in/create', data);
|
||||
}
|
||||
|
||||
/**
|
||||
* 修改采购入库
|
||||
*/
|
||||
/** 修改采购入库 */
|
||||
export function updatePurchaseIn(data: ErpPurchaseInApi.PurchaseIn) {
|
||||
return requestClient.put('/erp/purchase-in/update', data);
|
||||
}
|
||||
|
||||
/**
|
||||
* 更新采购入库的状态
|
||||
*/
|
||||
/** 更新采购入库的状态 */
|
||||
export function updatePurchaseInStatus(id: number, status: number) {
|
||||
return requestClient.put('/erp/purchase-in/update-status', null, {
|
||||
params: {
|
||||
@@ -100,9 +83,7 @@ export function updatePurchaseInStatus(id: number, status: number) {
|
||||
});
|
||||
}
|
||||
|
||||
/**
|
||||
* 删除采购入库
|
||||
*/
|
||||
/** 删除采购入库 */
|
||||
export function deletePurchaseIn(ids: number[]) {
|
||||
return requestClient.delete('/erp/purchase-in/delete', {
|
||||
params: {
|
||||
@@ -111,12 +92,8 @@ export function deletePurchaseIn(ids: number[]) {
|
||||
});
|
||||
}
|
||||
|
||||
/**
|
||||
* 导出采购入库 Excel
|
||||
*/
|
||||
export function exportPurchaseIn(
|
||||
params: ErpPurchaseInApi.PurchaseInPageParams,
|
||||
) {
|
||||
/** 导出采购入库 Excel */
|
||||
export function exportPurchaseIn(params: any) {
|
||||
return requestClient.download('/erp/purchase-in/export-excel', {
|
||||
params,
|
||||
});
|
||||
|
||||
@@ -3,27 +3,7 @@ import type { PageParam, PageResult } from '@vben/request';
|
||||
import { requestClient } from '#/api/request';
|
||||
|
||||
export namespace ErpPurchaseOrderApi {
|
||||
/** ERP 采购订单项信息 */
|
||||
export interface PurchaseOrderItem {
|
||||
id?: number; // 订单项编号
|
||||
orderId?: number; // 采购订单编号
|
||||
productId?: number; // 产品编号
|
||||
productName?: string; // 产品名称
|
||||
productBarCode?: string; // 产品条码
|
||||
productUnitId?: number; // 产品单位编号
|
||||
productUnitName?: string; // 产品单位名称
|
||||
productPrice?: number; // 产品单价,单位:元
|
||||
totalProductPrice?: number; // 产品总价,单位:元
|
||||
count?: number; // 数量
|
||||
totalPrice?: number; // 总价,单位:元
|
||||
taxPercent?: number; // 税率,百分比
|
||||
taxPrice?: number; // 税额,单位:元
|
||||
totalTaxPrice?: number; // 含税总价,单位:元
|
||||
remark?: string; // 备注
|
||||
stockCount?: number; // 库存数量(显示字段)
|
||||
}
|
||||
|
||||
/** ERP 采购订单信息 */
|
||||
/** 采购订单信息 */
|
||||
export interface PurchaseOrder {
|
||||
id?: number; // 订单工单编号
|
||||
no?: string; // 采购订单号
|
||||
@@ -51,24 +31,29 @@ export namespace ErpPurchaseOrderApi {
|
||||
items?: PurchaseOrderItem[]; // 订单项列表
|
||||
}
|
||||
|
||||
/** 采购订单分页查询参数 */
|
||||
export interface PurchaseOrderPageParam extends PageParam {
|
||||
no?: string;
|
||||
supplierId?: number;
|
||||
productId?: number;
|
||||
orderTime?: string[];
|
||||
status?: number;
|
||||
remark?: string;
|
||||
creator?: string;
|
||||
inStatus?: number;
|
||||
returnStatus?: number;
|
||||
/** 采购订单项信息 */
|
||||
export interface PurchaseOrderItem {
|
||||
id?: number; // 订单项编号
|
||||
orderId?: number; // 采购订单编号
|
||||
productId?: number; // 产品编号
|
||||
productName?: string; // 产品名称
|
||||
productBarCode?: string; // 产品条码
|
||||
productUnitId?: number; // 产品单位编号
|
||||
productUnitName?: string; // 产品单位名称
|
||||
productPrice?: number; // 产品单价,单位:元
|
||||
totalProductPrice?: number; // 产品总价,单位:元
|
||||
count?: number; // 数量
|
||||
totalPrice?: number; // 总价,单位:元
|
||||
taxPercent?: number; // 税率,百分比
|
||||
taxPrice?: number; // 税额,单位:元
|
||||
totalTaxPrice?: number; // 含税总价,单位:元
|
||||
remark?: string; // 备注
|
||||
stockCount?: number; // 库存数量(显示字段)
|
||||
}
|
||||
}
|
||||
|
||||
/** 查询采购订单分页 */
|
||||
export function getPurchaseOrderPage(
|
||||
params: ErpPurchaseOrderApi.PurchaseOrderPageParam,
|
||||
) {
|
||||
export function getPurchaseOrderPage(params: PageParam) {
|
||||
return requestClient.get<PageResult<ErpPurchaseOrderApi.PurchaseOrder>>(
|
||||
'/erp/purchase-order/page',
|
||||
{ params },
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
import type { PageParam, PageResult } from '@vben/request';
|
||||
import type { PageResult } from '@vben/request';
|
||||
|
||||
import { requestClient } from '#/api/request';
|
||||
|
||||
@@ -19,6 +19,8 @@ export namespace ErpPurchaseReturnApi {
|
||||
otherPrice?: number; // 其他费用
|
||||
items?: PurchaseReturnItem[];
|
||||
}
|
||||
|
||||
/** 采购退货项 */
|
||||
export interface PurchaseReturnItem {
|
||||
count?: number;
|
||||
id?: number;
|
||||
@@ -37,27 +39,10 @@ export namespace ErpPurchaseReturnApi {
|
||||
totalPrice?: number;
|
||||
warehouseId?: number;
|
||||
}
|
||||
|
||||
/** 采购退货分页查询参数 */
|
||||
export interface PurchaseReturnPageParams extends PageParam {
|
||||
no?: string;
|
||||
supplierId?: number;
|
||||
status?: number;
|
||||
}
|
||||
|
||||
/** 采购退货状态更新参数 */
|
||||
export interface PurchaseReturnStatusParams {
|
||||
id: number;
|
||||
status: number;
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* 查询采购退货分页
|
||||
*/
|
||||
export function getPurchaseReturnPage(
|
||||
params: ErpPurchaseReturnApi.PurchaseReturnPageParams,
|
||||
) {
|
||||
/** 查询采购退货分页 */
|
||||
export function getPurchaseReturnPage(params: any) {
|
||||
return requestClient.get<PageResult<ErpPurchaseReturnApi.PurchaseReturn>>(
|
||||
'/erp/purchase-return/page',
|
||||
{
|
||||
@@ -66,45 +51,35 @@ export function getPurchaseReturnPage(
|
||||
);
|
||||
}
|
||||
|
||||
/**
|
||||
* 查询采购退货详情
|
||||
*/
|
||||
/** 查询采购退货详情 */
|
||||
export function getPurchaseReturn(id: number) {
|
||||
return requestClient.get<ErpPurchaseReturnApi.PurchaseReturn>(
|
||||
`/erp/purchase-return/get?id=${id}`,
|
||||
);
|
||||
}
|
||||
|
||||
/**
|
||||
* 新增采购退货
|
||||
*/
|
||||
/** 新增采购退货 */
|
||||
export function createPurchaseReturn(
|
||||
data: ErpPurchaseReturnApi.PurchaseReturn,
|
||||
) {
|
||||
return requestClient.post('/erp/purchase-return/create', data);
|
||||
}
|
||||
|
||||
/**
|
||||
* 修改采购退货
|
||||
*/
|
||||
/** 修改采购退货 */
|
||||
export function updatePurchaseReturn(
|
||||
data: ErpPurchaseReturnApi.PurchaseReturn,
|
||||
) {
|
||||
return requestClient.put('/erp/purchase-return/update', data);
|
||||
}
|
||||
|
||||
/**
|
||||
* 更新采购退货的状态
|
||||
*/
|
||||
/** 更新采购退货的状态 */
|
||||
export function updatePurchaseReturnStatus(id: number, status: number) {
|
||||
return requestClient.put('/erp/purchase-return/update-status', null, {
|
||||
params: { id, status },
|
||||
});
|
||||
}
|
||||
|
||||
/**
|
||||
* 删除采购退货
|
||||
*/
|
||||
/** 删除采购退货 */
|
||||
export function deletePurchaseReturn(ids: number[]) {
|
||||
return requestClient.delete('/erp/purchase-return/delete', {
|
||||
params: {
|
||||
@@ -113,12 +88,8 @@ export function deletePurchaseReturn(ids: number[]) {
|
||||
});
|
||||
}
|
||||
|
||||
/**
|
||||
* 导出采购退货 Excel
|
||||
*/
|
||||
export function exportPurchaseReturn(
|
||||
params: ErpPurchaseReturnApi.PurchaseReturnPageParams,
|
||||
) {
|
||||
/** 导出采购退货 Excel */
|
||||
export function exportPurchaseReturn(params: any) {
|
||||
return requestClient.download('/erp/purchase-return/export-excel', {
|
||||
params,
|
||||
});
|
||||
|
||||
@@ -3,7 +3,7 @@ import type { PageParam, PageResult } from '@vben/request';
|
||||
import { requestClient } from '#/api/request';
|
||||
|
||||
export namespace ErpSupplierApi {
|
||||
/** ERP 供应商信息 */
|
||||
/** 供应商信息 */
|
||||
export interface Supplier {
|
||||
id?: number; // 供应商编号
|
||||
name: string; // 供应商名称
|
||||
@@ -21,17 +21,10 @@ export namespace ErpSupplierApi {
|
||||
bankAccount: string; // 开户账号
|
||||
bankAddress: string; // 开户地址
|
||||
}
|
||||
|
||||
/** 供应商分页查询参数 */
|
||||
export interface SupplierPageParam extends PageParam {
|
||||
name?: string;
|
||||
mobile?: string;
|
||||
status?: number;
|
||||
}
|
||||
}
|
||||
|
||||
/** 查询供应商分页 */
|
||||
export function getSupplierPage(params: ErpSupplierApi.SupplierPageParam) {
|
||||
export function getSupplierPage(params: PageParam) {
|
||||
return requestClient.get<PageResult<ErpSupplierApi.Supplier>>(
|
||||
'/erp/supplier/page',
|
||||
{ params },
|
||||
|
||||
@@ -3,7 +3,7 @@ import type { PageParam, PageResult } from '@vben/request';
|
||||
import { requestClient } from '#/api/request';
|
||||
|
||||
export namespace ErpCustomerApi {
|
||||
/** ERP 客户信息 */
|
||||
/** 客户信息 */
|
||||
export interface Customer {
|
||||
id?: number; // 客户编号
|
||||
name: string; // 客户名称
|
||||
@@ -21,17 +21,10 @@ export namespace ErpCustomerApi {
|
||||
bankAccount: string; // 开户账号
|
||||
bankAddress: string; // 开户地址
|
||||
}
|
||||
|
||||
/** 客户分页查询参数 */
|
||||
export interface CustomerPageParam extends PageParam {
|
||||
name?: string;
|
||||
mobile?: string;
|
||||
status?: number;
|
||||
}
|
||||
}
|
||||
|
||||
/** 查询客户分页 */
|
||||
export function getCustomerPage(params: ErpCustomerApi.CustomerPageParam) {
|
||||
export function getCustomerPage(params: PageParam) {
|
||||
return requestClient.get<PageResult<ErpCustomerApi.Customer>>(
|
||||
'/erp/customer/page',
|
||||
{ params },
|
||||
|
||||
@@ -3,7 +3,7 @@ import type { PageParam, PageResult } from '@vben/request';
|
||||
import { requestClient } from '#/api/request';
|
||||
|
||||
export namespace ErpSaleOrderApi {
|
||||
/** ERP 销售订单信息 */
|
||||
/** 销售订单信息 */
|
||||
export interface SaleOrder {
|
||||
id?: number; // 订单工单编号
|
||||
no: string; // 销售订单号
|
||||
@@ -25,6 +25,7 @@ export namespace ErpSaleOrderApi {
|
||||
items?: SaleOrderItem[]; // 销售订单产品明细列表
|
||||
}
|
||||
|
||||
/** 销售订单项 */
|
||||
export interface SaleOrderItem {
|
||||
id?: number; // 订单项编号
|
||||
orderId?: number; // 采购订单编号
|
||||
@@ -43,17 +44,10 @@ export namespace ErpSaleOrderApi {
|
||||
remark?: string; // 备注
|
||||
stockCount?: number; // 库存数量(显示字段)
|
||||
}
|
||||
|
||||
/** 销售订单分页查询参数 */
|
||||
export interface SaleOrderPageParam extends PageParam {
|
||||
no?: string;
|
||||
customerId?: number;
|
||||
status?: number;
|
||||
}
|
||||
}
|
||||
|
||||
/** 查询销售订单分页 */
|
||||
export function getSaleOrderPage(params: ErpSaleOrderApi.SaleOrderPageParam) {
|
||||
export function getSaleOrderPage(params: PageParam) {
|
||||
return requestClient.get<PageResult<ErpSaleOrderApi.SaleOrder>>(
|
||||
'/erp/sale-order/page',
|
||||
{ params },
|
||||
|
||||
@@ -24,6 +24,7 @@ export namespace ErpSaleOutApi {
|
||||
items?: SaleOutItem[];
|
||||
}
|
||||
|
||||
/** 销售出库项 */
|
||||
export interface SaleOutItem {
|
||||
count?: number;
|
||||
id?: number;
|
||||
@@ -43,17 +44,10 @@ export namespace ErpSaleOutApi {
|
||||
warehouseId?: number;
|
||||
outCount?: number;
|
||||
}
|
||||
|
||||
/** 销售出库分页查询参数 */
|
||||
export interface SaleOutPageParams extends PageParam {
|
||||
no?: string;
|
||||
customerId?: number;
|
||||
status?: number;
|
||||
}
|
||||
}
|
||||
|
||||
/** 查询销售出库分页 */
|
||||
export function getSaleOutPage(params: ErpSaleOutApi.SaleOutPageParams) {
|
||||
export function getSaleOutPage(params: PageParam) {
|
||||
return requestClient.get<PageResult<ErpSaleOutApi.SaleOut>>(
|
||||
'/erp/sale-out/page',
|
||||
{
|
||||
@@ -94,7 +88,7 @@ export function deleteSaleOut(ids: number[]) {
|
||||
}
|
||||
|
||||
/** 导出销售出库 Excel */
|
||||
export function exportSaleOut(params: ErpSaleOutApi.SaleOutPageParams) {
|
||||
export function exportSaleOut(params: any) {
|
||||
return requestClient.download('/erp/sale-out/export-excel', {
|
||||
params,
|
||||
});
|
||||
|
||||
@@ -23,6 +23,7 @@ export namespace ErpSaleReturnApi {
|
||||
items?: SaleReturnItem[];
|
||||
}
|
||||
|
||||
/** 销售退货项 */
|
||||
export interface SaleReturnItem {
|
||||
count?: number;
|
||||
id?: number;
|
||||
@@ -42,21 +43,10 @@ export namespace ErpSaleReturnApi {
|
||||
warehouseId?: number;
|
||||
returnCount?: number;
|
||||
}
|
||||
|
||||
/** 销售退货分页查询参数 */
|
||||
export interface SaleReturnPageParams extends PageParam {
|
||||
no?: string;
|
||||
customerId?: number;
|
||||
status?: number;
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* 查询销售退货分页
|
||||
*/
|
||||
export function getSaleReturnPage(
|
||||
params: ErpSaleReturnApi.SaleReturnPageParams,
|
||||
) {
|
||||
/** 查询销售退货分页 */
|
||||
export function getSaleReturnPage(params: PageParam) {
|
||||
return requestClient.get<PageResult<ErpSaleReturnApi.SaleReturn>>(
|
||||
'/erp/sale-return/page',
|
||||
{
|
||||
@@ -65,41 +55,31 @@ export function getSaleReturnPage(
|
||||
);
|
||||
}
|
||||
|
||||
/**
|
||||
* 查询销售退货详情
|
||||
*/
|
||||
/** 查询销售退货详情 */
|
||||
export function getSaleReturn(id: number) {
|
||||
return requestClient.get<ErpSaleReturnApi.SaleReturn>(
|
||||
`/erp/sale-return/get?id=${id}`,
|
||||
);
|
||||
}
|
||||
|
||||
/**
|
||||
* 新增销售退货
|
||||
*/
|
||||
/** 新增销售退货 */
|
||||
export function createSaleReturn(data: ErpSaleReturnApi.SaleReturn) {
|
||||
return requestClient.post('/erp/sale-return/create', data);
|
||||
}
|
||||
|
||||
/**
|
||||
* 修改销售退货
|
||||
*/
|
||||
/** 修改销售退货 */
|
||||
export function updateSaleReturn(data: ErpSaleReturnApi.SaleReturn) {
|
||||
return requestClient.put('/erp/sale-return/update', data);
|
||||
}
|
||||
|
||||
/**
|
||||
* 更新销售退货的状态
|
||||
*/
|
||||
/** 更新销售退货的状态 */
|
||||
export function updateSaleReturnStatus(id: number, status: number) {
|
||||
return requestClient.put('/erp/sale-return/update-status', null, {
|
||||
params: { id, status },
|
||||
});
|
||||
}
|
||||
|
||||
/**
|
||||
* 删除销售退货
|
||||
*/
|
||||
/** 删除销售退货 */
|
||||
export function deleteSaleReturn(ids: number[]) {
|
||||
return requestClient.delete('/erp/sale-return/delete', {
|
||||
params: {
|
||||
@@ -108,12 +88,8 @@ export function deleteSaleReturn(ids: number[]) {
|
||||
});
|
||||
}
|
||||
|
||||
/**
|
||||
* 导出销售退货 Excel
|
||||
*/
|
||||
export function exportSaleReturn(
|
||||
params: ErpSaleReturnApi.SaleReturnPageParams,
|
||||
) {
|
||||
/** 导出销售退货 Excel */
|
||||
export function exportSaleReturn(params: any) {
|
||||
return requestClient.download('/erp/sale-return/export-excel', {
|
||||
params,
|
||||
});
|
||||
|
||||
@@ -1,16 +1,16 @@
|
||||
import { requestClient } from '#/api/request';
|
||||
|
||||
export namespace ErpPurchaseStatisticsApi {
|
||||
/** ERP 采购全局统计 */
|
||||
export interface PurchaseSummary {
|
||||
/** 采购全局统计 */
|
||||
export interface PurchaseSummaryRespVO {
|
||||
todayPrice: number; // 今日采购金额
|
||||
yesterdayPrice: number; // 昨日采购金额
|
||||
monthPrice: number; // 本月采购金额
|
||||
yearPrice: number; // 今年采购金额
|
||||
}
|
||||
|
||||
/** ERP 采购时间段统计 */
|
||||
export interface PurchaseTimeSummary {
|
||||
/** 采购时间段统计 */
|
||||
export interface PurchaseTimeSummaryRespVO {
|
||||
time: string; // 时间
|
||||
price: number; // 采购金额
|
||||
}
|
||||
@@ -18,14 +18,14 @@ export namespace ErpPurchaseStatisticsApi {
|
||||
|
||||
/** 获得采购统计 */
|
||||
export function getPurchaseSummary() {
|
||||
return requestClient.get<ErpPurchaseStatisticsApi.PurchaseSummary>(
|
||||
return requestClient.get<ErpPurchaseStatisticsApi.PurchaseSummaryRespVO>(
|
||||
'/erp/purchase-statistics/summary',
|
||||
);
|
||||
}
|
||||
|
||||
/** 获得采购时间段统计 */
|
||||
export function getPurchaseTimeSummary() {
|
||||
return requestClient.get<ErpPurchaseStatisticsApi.PurchaseTimeSummary[]>(
|
||||
'/erp/purchase-statistics/time-summary',
|
||||
);
|
||||
return requestClient.get<
|
||||
ErpPurchaseStatisticsApi.PurchaseTimeSummaryRespVO[]
|
||||
>('/erp/purchase-statistics/time-summary');
|
||||
}
|
||||
|
||||
@@ -1,16 +1,16 @@
|
||||
import { requestClient } from '#/api/request';
|
||||
|
||||
export namespace ErpSaleStatisticsApi {
|
||||
/** ERP 销售全局统计 */
|
||||
export interface SaleSummary {
|
||||
/** 销售全局统计 */
|
||||
export interface SaleSummaryRespVO {
|
||||
todayPrice: number; // 今日销售金额
|
||||
yesterdayPrice: number; // 昨日销售金额
|
||||
monthPrice: number; // 本月销售金额
|
||||
yearPrice: number; // 今年销售金额
|
||||
}
|
||||
|
||||
/** ERP 销售时间段统计 */
|
||||
export interface SaleTimeSummary {
|
||||
/** 销售时间段统计 */
|
||||
export interface SaleTimeSummaryRespVO {
|
||||
time: string; // 时间
|
||||
price: number; // 销售金额
|
||||
}
|
||||
@@ -18,14 +18,14 @@ export namespace ErpSaleStatisticsApi {
|
||||
|
||||
/** 获得销售统计 */
|
||||
export function getSaleSummary() {
|
||||
return requestClient.get<ErpSaleStatisticsApi.SaleSummary>(
|
||||
return requestClient.get<ErpSaleStatisticsApi.SaleSummaryRespVO>(
|
||||
'/erp/sale-statistics/summary',
|
||||
);
|
||||
}
|
||||
|
||||
/** 获得销售时间段统计 */
|
||||
export function getSaleTimeSummary() {
|
||||
return requestClient.get<ErpSaleStatisticsApi.SaleTimeSummary[]>(
|
||||
return requestClient.get<ErpSaleStatisticsApi.SaleTimeSummaryRespVO[]>(
|
||||
'/erp/sale-statistics/time-summary',
|
||||
);
|
||||
}
|
||||
|
||||
@@ -18,6 +18,7 @@ export namespace ErpStockCheckApi {
|
||||
items?: StockCheckItem[]; // 盘点产品清单
|
||||
}
|
||||
|
||||
/** 库存盘点项 */
|
||||
export interface StockCheckItem {
|
||||
id?: number; // 编号
|
||||
warehouseId?: number; // 仓库编号
|
||||
@@ -33,20 +34,10 @@ export namespace ErpStockCheckApi {
|
||||
stockCount?: number; // 账面库存
|
||||
remark?: string; // 备注
|
||||
}
|
||||
|
||||
/** 库存盘点单分页查询参数 */
|
||||
export interface StockCheckPageParams extends PageParam {
|
||||
no?: string;
|
||||
status?: number;
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* 查询库存盘点单分页
|
||||
*/
|
||||
export function getStockCheckPage(
|
||||
params: ErpStockCheckApi.StockCheckPageParams,
|
||||
) {
|
||||
/** 查询库存盘点单分页 */
|
||||
export function getStockCheckPage(params: PageParam) {
|
||||
return requestClient.get<PageResult<ErpStockCheckApi.StockCheck>>(
|
||||
'/erp/stock-check/page',
|
||||
{
|
||||
@@ -55,41 +46,31 @@ export function getStockCheckPage(
|
||||
);
|
||||
}
|
||||
|
||||
/**
|
||||
* 查询库存盘点单详情
|
||||
*/
|
||||
/** 查询库存盘点单详情 */
|
||||
export function getStockCheck(id: number) {
|
||||
return requestClient.get<ErpStockCheckApi.StockCheck>(
|
||||
`/erp/stock-check/get?id=${id}`,
|
||||
);
|
||||
}
|
||||
|
||||
/**
|
||||
* 新增库存盘点单
|
||||
*/
|
||||
/** 新增库存盘点单 */
|
||||
export function createStockCheck(data: ErpStockCheckApi.StockCheck) {
|
||||
return requestClient.post('/erp/stock-check/create', data);
|
||||
}
|
||||
|
||||
/**
|
||||
* 修改库存盘点单
|
||||
*/
|
||||
/** 修改库存盘点单 */
|
||||
export function updateStockCheck(data: ErpStockCheckApi.StockCheck) {
|
||||
return requestClient.put('/erp/stock-check/update', data);
|
||||
}
|
||||
|
||||
/**
|
||||
* 更新库存盘点单的状态
|
||||
*/
|
||||
/** 更新库存盘点单的状态 */
|
||||
export function updateStockCheckStatus(id: number, status: number) {
|
||||
return requestClient.put('/erp/stock-check/update-status', null, {
|
||||
params: { id, status },
|
||||
});
|
||||
}
|
||||
|
||||
/**
|
||||
* 删除库存盘点单
|
||||
*/
|
||||
/** 删除库存盘点 */
|
||||
export function deleteStockCheck(ids: number[]) {
|
||||
return requestClient.delete('/erp/stock-check/delete', {
|
||||
params: {
|
||||
@@ -98,12 +79,8 @@ export function deleteStockCheck(ids: number[]) {
|
||||
});
|
||||
}
|
||||
|
||||
/**
|
||||
* 导出库存盘点单 Excel
|
||||
*/
|
||||
export function exportStockCheck(
|
||||
params: ErpStockCheckApi.StockCheckPageParams,
|
||||
) {
|
||||
/** 导出库存盘点单 Excel */
|
||||
export function exportStockCheck(params: any) {
|
||||
return requestClient.download('/erp/stock-check/export-excel', {
|
||||
params,
|
||||
});
|
||||
|
||||
@@ -35,19 +35,10 @@ export namespace ErpStockInApi {
|
||||
stockCount?: number; // 库存数量
|
||||
remark?: string; // 备注
|
||||
}
|
||||
|
||||
/** 其它入库单分页查询参数 */
|
||||
export interface StockInPageParams extends PageParam {
|
||||
no?: string;
|
||||
supplierId?: number;
|
||||
status?: number;
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* 查询其它入库单分页
|
||||
*/
|
||||
export function getStockInPage(params: ErpStockInApi.StockInPageParams) {
|
||||
/** 查询其它入库单分页 */
|
||||
export function getStockInPage(params: PageParam) {
|
||||
return requestClient.get<PageResult<ErpStockInApi.StockIn>>(
|
||||
'/erp/stock-in/page',
|
||||
{
|
||||
@@ -56,39 +47,29 @@ export function getStockInPage(params: ErpStockInApi.StockInPageParams) {
|
||||
);
|
||||
}
|
||||
|
||||
/**
|
||||
* 查询其它入库单详情
|
||||
*/
|
||||
/** 查询其它入库单详情 */
|
||||
export function getStockIn(id: number) {
|
||||
return requestClient.get<ErpStockInApi.StockIn>(`/erp/stock-in/get?id=${id}`);
|
||||
}
|
||||
|
||||
/**
|
||||
* 新增其它入库单
|
||||
*/
|
||||
/** 新增其它入库单 */
|
||||
export function createStockIn(data: ErpStockInApi.StockIn) {
|
||||
return requestClient.post('/erp/stock-in/create', data);
|
||||
}
|
||||
|
||||
/**
|
||||
* 修改其它入库单
|
||||
*/
|
||||
/** 修改其它入库单 */
|
||||
export function updateStockIn(data: ErpStockInApi.StockIn) {
|
||||
return requestClient.put('/erp/stock-in/update', data);
|
||||
}
|
||||
|
||||
/**
|
||||
* 更新其它入库单的状态
|
||||
*/
|
||||
/** 更新其它入库单的状态 */
|
||||
export function updateStockInStatus(id: number, status: number) {
|
||||
return requestClient.put('/erp/stock-in/update-status', null, {
|
||||
params: { id, status },
|
||||
});
|
||||
}
|
||||
|
||||
/**
|
||||
* 删除其它入库单
|
||||
*/
|
||||
/** 删除其它入库单 */
|
||||
export function deleteStockIn(ids: number[]) {
|
||||
return requestClient.delete('/erp/stock-in/delete', {
|
||||
params: {
|
||||
@@ -97,10 +78,8 @@ export function deleteStockIn(ids: number[]) {
|
||||
});
|
||||
}
|
||||
|
||||
/**
|
||||
* 导出其它入库单 Excel
|
||||
*/
|
||||
export function exportStockIn(params: ErpStockInApi.StockInPageParams) {
|
||||
/** 导出其它入库单 Excel */
|
||||
export function exportStockIn(params: any) {
|
||||
return requestClient.download('/erp/stock-in/export-excel', {
|
||||
params,
|
||||
});
|
||||
|
||||
@@ -36,18 +36,10 @@ export namespace ErpStockMoveApi {
|
||||
toWarehouseId?: number; // 目标仓库ID
|
||||
totalPrice?: number; // 总价
|
||||
}
|
||||
|
||||
/** 库存调拨单分页查询参数 */
|
||||
export interface StockMovePageParams extends PageParam {
|
||||
no?: string;
|
||||
status?: number;
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* 查询库存调拨单分页
|
||||
*/
|
||||
export function getStockMovePage(params: ErpStockMoveApi.StockMovePageParams) {
|
||||
/** 查询库存调拨单分页 */
|
||||
export function getStockMovePage(params: PageParam) {
|
||||
return requestClient.get<PageResult<ErpStockMoveApi.StockMove>>(
|
||||
'/erp/stock-move/page',
|
||||
{
|
||||
@@ -56,41 +48,31 @@ export function getStockMovePage(params: ErpStockMoveApi.StockMovePageParams) {
|
||||
);
|
||||
}
|
||||
|
||||
/**
|
||||
* 查询库存调拨单详情
|
||||
*/
|
||||
/** 查询库存调拨单详情 */
|
||||
export function getStockMove(id: number) {
|
||||
return requestClient.get<ErpStockMoveApi.StockMove>(
|
||||
`/erp/stock-move/get?id=${id}`,
|
||||
);
|
||||
}
|
||||
|
||||
/**
|
||||
* 新增库存调拨单
|
||||
*/
|
||||
/** 新增库存调拨单 */
|
||||
export function createStockMove(data: ErpStockMoveApi.StockMove) {
|
||||
return requestClient.post('/erp/stock-move/create', data);
|
||||
}
|
||||
|
||||
/**
|
||||
* 修改库存调拨单
|
||||
*/
|
||||
/** 修改库存调拨单 */
|
||||
export function updateStockMove(data: ErpStockMoveApi.StockMove) {
|
||||
return requestClient.put('/erp/stock-move/update', data);
|
||||
}
|
||||
|
||||
/**
|
||||
* 更新库存调拨单的状态
|
||||
*/
|
||||
/** 更新库存调拨单的状态 */
|
||||
export function updateStockMoveStatus(id: number, status: number) {
|
||||
return requestClient.put('/erp/stock-move/update-status', null, {
|
||||
params: { id, status },
|
||||
});
|
||||
}
|
||||
|
||||
/**
|
||||
* 删除库存调拨单
|
||||
*/
|
||||
/** 删除库存调拨单 */
|
||||
export function deleteStockMove(ids: number[]) {
|
||||
return requestClient.delete('/erp/stock-move/delete', {
|
||||
params: {
|
||||
@@ -99,9 +81,7 @@ export function deleteStockMove(ids: number[]) {
|
||||
});
|
||||
}
|
||||
|
||||
/**
|
||||
* 导出库存调拨单 Excel
|
||||
*/
|
||||
export function exportStockMove(params: ErpStockMoveApi.StockMovePageParams) {
|
||||
/** 导出库存调拨单 Excel */
|
||||
export function exportStockMove(params: any) {
|
||||
return requestClient.download('/erp/stock-move/export-excel', { params });
|
||||
}
|
||||
|
||||
@@ -32,19 +32,10 @@ export namespace ErpStockOutApi {
|
||||
stockCount?: number; // 库存数量
|
||||
remark?: string; // 备注
|
||||
}
|
||||
|
||||
/** 其它出库单分页查询参数 */
|
||||
export interface StockOutPageParams extends PageParam {
|
||||
no?: string;
|
||||
customerId?: number;
|
||||
status?: number;
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* 查询其它出库单分页
|
||||
*/
|
||||
export function getStockOutPage(params: ErpStockOutApi.StockOutPageParams) {
|
||||
/** 查询其它出库单分页 */
|
||||
export function getStockOutPage(params: PageParam) {
|
||||
return requestClient.get<PageResult<ErpStockOutApi.StockOut>>(
|
||||
'/erp/stock-out/page',
|
||||
{
|
||||
@@ -53,41 +44,31 @@ export function getStockOutPage(params: ErpStockOutApi.StockOutPageParams) {
|
||||
);
|
||||
}
|
||||
|
||||
/**
|
||||
* 查询其它出库单详情
|
||||
*/
|
||||
/** 查询其它出库单详情 */
|
||||
export function getStockOut(id: number) {
|
||||
return requestClient.get<ErpStockOutApi.StockOut>(
|
||||
`/erp/stock-out/get?id=${id}`,
|
||||
);
|
||||
}
|
||||
|
||||
/**
|
||||
* 新增其它出库单
|
||||
*/
|
||||
/** 新增其它出库单 */
|
||||
export function createStockOut(data: ErpStockOutApi.StockOut) {
|
||||
return requestClient.post('/erp/stock-out/create', data);
|
||||
}
|
||||
|
||||
/**
|
||||
* 修改其它出库单
|
||||
*/
|
||||
/** 修改其它出库单 */
|
||||
export function updateStockOut(data: ErpStockOutApi.StockOut) {
|
||||
return requestClient.put('/erp/stock-out/update', data);
|
||||
}
|
||||
|
||||
/**
|
||||
* 更新其它出库单的状态
|
||||
*/
|
||||
/** 更新其它出库单的状态 */
|
||||
export function updateStockOutStatus(id: number, status: number) {
|
||||
return requestClient.put('/erp/stock-out/update-status', null, {
|
||||
params: { id, status },
|
||||
});
|
||||
}
|
||||
|
||||
/**
|
||||
* 删除其它出库单
|
||||
*/
|
||||
/** 删除其它出库单 */
|
||||
export function deleteStockOut(ids: number[]) {
|
||||
return requestClient.delete('/erp/stock-out/delete', {
|
||||
params: {
|
||||
@@ -96,10 +77,8 @@ export function deleteStockOut(ids: number[]) {
|
||||
});
|
||||
}
|
||||
|
||||
/**
|
||||
* 导出其它出库单 Excel
|
||||
*/
|
||||
export function exportStockOut(params: ErpStockOutApi.StockOutPageParams) {
|
||||
/** 导出其它出库单 Excel */
|
||||
export function exportStockOut(params: any) {
|
||||
return requestClient.download('/erp/stock-out/export-excel', {
|
||||
params,
|
||||
});
|
||||
|
||||
@@ -3,7 +3,7 @@ import type { PageParam, PageResult } from '@vben/request';
|
||||
import { requestClient } from '#/api/request';
|
||||
|
||||
export namespace ErpStockRecordApi {
|
||||
/** ERP 产品库存明细 */
|
||||
/** 产品库存明细 */
|
||||
export interface StockRecord {
|
||||
id?: number; // 编号
|
||||
productId: number; // 产品编号
|
||||
@@ -15,32 +15,16 @@ export namespace ErpStockRecordApi {
|
||||
bizItemId: number; // 业务项编号
|
||||
bizNo: string; // 业务单号
|
||||
}
|
||||
|
||||
/** 库存记录分页查询参数 */
|
||||
export interface StockRecordPageParam extends PageParam {
|
||||
productId?: number;
|
||||
warehouseId?: number;
|
||||
bizType?: number;
|
||||
}
|
||||
}
|
||||
|
||||
/** 查询产品库存明细分页 */
|
||||
export function getStockRecordPage(
|
||||
params: ErpStockRecordApi.StockRecordPageParam,
|
||||
) {
|
||||
export function getStockRecordPage(params: PageParam) {
|
||||
return requestClient.get<PageResult<ErpStockRecordApi.StockRecord>>(
|
||||
'/erp/stock-record/page',
|
||||
{ params },
|
||||
);
|
||||
}
|
||||
|
||||
/** 查询产品库存明细详情 */
|
||||
export function getStockRecord(id: number) {
|
||||
return requestClient.get<ErpStockRecordApi.StockRecord>(
|
||||
`/erp/stock-record/get?id=${id}`,
|
||||
);
|
||||
}
|
||||
|
||||
/** 导出产品库存明细 Excel */
|
||||
export function exportStockRecord(params: any) {
|
||||
return requestClient.download('/erp/stock-record/export-excel', { params });
|
||||
|
||||
@@ -11,49 +11,21 @@ export namespace ErpStockApi {
|
||||
count: number; // 库存数量
|
||||
}
|
||||
|
||||
/** 产品库存分页查询参数 */
|
||||
export interface StockPageParams extends PageParam {
|
||||
productId?: number;
|
||||
warehouseId?: number;
|
||||
}
|
||||
|
||||
/** 产品库存查询参数 */
|
||||
export interface StockQueryParams {
|
||||
export interface StockQueryReqVO {
|
||||
productId: number;
|
||||
warehouseId: number;
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* 查询产品库存分页
|
||||
*/
|
||||
export function getStockPage(params: ErpStockApi.StockPageParams) {
|
||||
/** 查询产品库存分页 */
|
||||
export function getStockPage(params: PageParam) {
|
||||
return requestClient.get<PageResult<ErpStockApi.Stock>>('/erp/stock/page', {
|
||||
params,
|
||||
});
|
||||
}
|
||||
|
||||
/**
|
||||
* 查询产品库存详情
|
||||
*/
|
||||
export function getStock(id: number) {
|
||||
return requestClient.get<ErpStockApi.Stock>(`/erp/stock/get?id=${id}`);
|
||||
}
|
||||
|
||||
/**
|
||||
* 根据产品和仓库查询库存详情
|
||||
*/
|
||||
export function getStockByProductAndWarehouse(
|
||||
params: ErpStockApi.StockQueryParams,
|
||||
) {
|
||||
return requestClient.get<ErpStockApi.Stock>('/erp/stock/get', {
|
||||
params,
|
||||
});
|
||||
}
|
||||
|
||||
/**
|
||||
* 获得产品库存数量
|
||||
*/
|
||||
/** 获得产品库存数量 */
|
||||
export function getStockCount(productId: number, warehouseId?: number) {
|
||||
const params: any = { productId };
|
||||
if (warehouseId !== undefined) {
|
||||
@@ -64,19 +36,15 @@ export function getStockCount(productId: number, warehouseId?: number) {
|
||||
});
|
||||
}
|
||||
|
||||
/**
|
||||
* 导出产品库存 Excel
|
||||
*/
|
||||
export function exportStock(params: ErpStockApi.StockPageParams) {
|
||||
/** 导出产品库存 Excel */
|
||||
export function exportStock(params: any) {
|
||||
return requestClient.download('/erp/stock/export-excel', {
|
||||
params,
|
||||
});
|
||||
}
|
||||
|
||||
/**
|
||||
* 获取库存数量
|
||||
*/
|
||||
export function getWarehouseStockCount(params: ErpStockApi.StockQueryParams) {
|
||||
/** 获取库存数量 */
|
||||
export function getWarehouseStockCount(params: ErpStockApi.StockQueryReqVO) {
|
||||
return requestClient.get<number>('/erp/stock/get-count', {
|
||||
params,
|
||||
});
|
||||
|
||||
@@ -3,7 +3,7 @@ import type { PageParam, PageResult } from '@vben/request';
|
||||
import { requestClient } from '#/api/request';
|
||||
|
||||
export namespace ErpWarehouseApi {
|
||||
/** ERP 仓库信息 */
|
||||
/** 仓库信息 */
|
||||
export interface Warehouse {
|
||||
id?: number; // 仓库编号
|
||||
name: string; // 仓库名称
|
||||
@@ -16,16 +16,10 @@ export namespace ErpWarehouseApi {
|
||||
status: number; // 开启状态
|
||||
defaultStatus: boolean; // 是否默认
|
||||
}
|
||||
|
||||
/** 仓库分页查询参数 */
|
||||
export interface WarehousePageParam extends PageParam {
|
||||
name?: string;
|
||||
status?: number;
|
||||
}
|
||||
}
|
||||
|
||||
/** 查询仓库分页 */
|
||||
export function getWarehousePage(params: ErpWarehouseApi.WarehousePageParam) {
|
||||
export function getWarehousePage(params: PageParam) {
|
||||
return requestClient.get<PageResult<ErpWarehouseApi.Warehouse>>(
|
||||
'/erp/warehouse/page',
|
||||
{ params },
|
||||
|
||||
@@ -50,13 +50,9 @@ export function updateDraft(
|
||||
mediaId: string,
|
||||
articles: MpDraftApi.Article[],
|
||||
) {
|
||||
return requestClient.put(
|
||||
'/mp/draft/update',
|
||||
{ articles },
|
||||
{
|
||||
params: { accountId, mediaId },
|
||||
},
|
||||
);
|
||||
return requestClient.put('/mp/draft/update', articles, {
|
||||
params: { accountId, mediaId },
|
||||
});
|
||||
}
|
||||
|
||||
/** 删除草稿 */
|
||||
|
||||
@@ -12,4 +12,5 @@ export const ACTION_ICON = {
|
||||
COPY: 'lucide:copy',
|
||||
CLOSE: 'lucide:x',
|
||||
BOOK: 'lucide:book',
|
||||
AUDIT: 'lucide:file-check',
|
||||
};
|
||||
|
||||
@@ -75,6 +75,7 @@ async function handleDefaultStatusChange(
|
||||
await updateAccountDefaultStatus(row.id!, newStatus);
|
||||
// 提示并返回成功
|
||||
message.success(`${text}默认成功`);
|
||||
handleRefresh();
|
||||
resolve(true);
|
||||
})
|
||||
.catch(() => {
|
||||
|
||||
@@ -170,7 +170,9 @@ export function useFormSchema(formType: string): VbenFormSchema[] {
|
||||
}
|
||||
|
||||
/** 表单的明细表格列 */
|
||||
export function useFormItemColumns(): VxeTableGridOptions['columns'] {
|
||||
export function useFormItemColumns(
|
||||
disabled: boolean,
|
||||
): VxeTableGridOptions['columns'] {
|
||||
return [
|
||||
{ type: 'seq', title: '序号', minWidth: 50, fixed: 'left' },
|
||||
{
|
||||
@@ -208,6 +210,7 @@ export function useFormItemColumns(): VxeTableGridOptions['columns'] {
|
||||
width: 50,
|
||||
fixed: 'right',
|
||||
slots: { default: 'actions' },
|
||||
visible: !disabled,
|
||||
},
|
||||
];
|
||||
}
|
||||
@@ -385,7 +388,7 @@ export function useGridColumns(): VxeTableGridOptions['columns'] {
|
||||
},
|
||||
{
|
||||
title: '操作',
|
||||
width: 220,
|
||||
width: 260,
|
||||
fixed: 'right',
|
||||
slots: { default: 'actions' },
|
||||
},
|
||||
|
||||
@@ -196,6 +196,7 @@ const [Grid, gridApi] = useVbenVxeGrid({
|
||||
{
|
||||
label: row.status === 10 ? '审批' : '反审批',
|
||||
type: 'link',
|
||||
icon: ACTION_ICON.AUDIT,
|
||||
auth: ['erp:finance-payment:update-status'],
|
||||
popConfirm: {
|
||||
title: `确认${row.status === 10 ? '审批' : '反审批'}${row.no}吗?`,
|
||||
@@ -210,7 +211,7 @@ const [Grid, gridApi] = useVbenVxeGrid({
|
||||
label: $t('common.delete'),
|
||||
type: 'link',
|
||||
danger: true,
|
||||
color: 'error',
|
||||
icon: ACTION_ICON.DELETE,
|
||||
auth: ['erp:finance-payment:delete'],
|
||||
popConfirm: {
|
||||
title: $t('ui.actionMessage.deleteConfirm', [row.no]),
|
||||
|
||||
@@ -187,6 +187,7 @@ const [Modal, modalApi] = useVbenModal({
|
||||
@update:items="handleUpdateItems"
|
||||
@update:total-price="handleUpdateTotalPrice"
|
||||
@update:payment-price="handleUpdatePaymentPrice"
|
||||
class="w-full"
|
||||
/>
|
||||
</template>
|
||||
</Form>
|
||||
|
||||
@@ -59,7 +59,7 @@ const summaries = computed(() => {
|
||||
/** 表格配置 */
|
||||
const [Grid, gridApi] = useVbenVxeGrid({
|
||||
gridOptions: {
|
||||
columns: useFormItemColumns(),
|
||||
columns: useFormItemColumns(props.disabled),
|
||||
data: tableData.value,
|
||||
minHeight: 250,
|
||||
autoResize: true,
|
||||
@@ -234,7 +234,6 @@ defineExpose({ validate });
|
||||
</template>
|
||||
<template #actions="{ row }">
|
||||
<TableAction
|
||||
v-if="!disabled"
|
||||
:actions="[
|
||||
{
|
||||
label: '删除',
|
||||
|
||||
@@ -15,7 +15,7 @@ const emit = defineEmits<{
|
||||
success: [rows: ErpPurchaseInApi.PurchaseIn[]];
|
||||
}>();
|
||||
|
||||
const supplierId = ref<number>(); // 供应商ID
|
||||
const supplierId = ref<number>(); // 供应商 ID
|
||||
const open = ref<boolean>(false); // 弹窗是否打开
|
||||
const selectedRows = ref<ErpPurchaseInApi.PurchaseIn[]>([]); // 选中的行
|
||||
|
||||
|
||||
@@ -15,7 +15,7 @@ const emit = defineEmits<{
|
||||
success: [rows: ErpPurchaseReturnApi.PurchaseReturn[]];
|
||||
}>();
|
||||
|
||||
const supplierId = ref<number>(); // 供应商ID
|
||||
const supplierId = ref<number>(); // 供应商 ID
|
||||
const open = ref<boolean>(false); // 弹窗是否打开
|
||||
const selectedRows = ref<ErpPurchaseReturnApi.PurchaseReturn[]>([]); // 选中的行
|
||||
|
||||
|
||||
@@ -170,7 +170,9 @@ export function useFormSchema(formType: string): VbenFormSchema[] {
|
||||
}
|
||||
|
||||
/** 表单的明细表格列 */
|
||||
export function useFormItemColumns(): VxeTableGridOptions['columns'] {
|
||||
export function useFormItemColumns(
|
||||
disabled: boolean,
|
||||
): VxeTableGridOptions['columns'] {
|
||||
return [
|
||||
{ type: 'seq', title: '序号', minWidth: 50, fixed: 'left' },
|
||||
{
|
||||
@@ -208,6 +210,7 @@ export function useFormItemColumns(): VxeTableGridOptions['columns'] {
|
||||
width: 50,
|
||||
fixed: 'right',
|
||||
slots: { default: 'actions' },
|
||||
visible: !disabled,
|
||||
},
|
||||
];
|
||||
}
|
||||
@@ -385,7 +388,7 @@ export function useGridColumns(): VxeTableGridOptions['columns'] {
|
||||
},
|
||||
{
|
||||
title: '操作',
|
||||
width: 220,
|
||||
width: 260,
|
||||
fixed: 'right',
|
||||
slots: { default: 'actions' },
|
||||
},
|
||||
|
||||
@@ -196,6 +196,7 @@ const [Grid, gridApi] = useVbenVxeGrid({
|
||||
{
|
||||
label: row.status === 10 ? '审批' : '反审批',
|
||||
type: 'link',
|
||||
icon: ACTION_ICON.AUDIT,
|
||||
auth: ['erp:finance-receipt:update-status'],
|
||||
popConfirm: {
|
||||
title: `确认${row.status === 10 ? '审批' : '反审批'}${row.no}吗?`,
|
||||
@@ -210,7 +211,7 @@ const [Grid, gridApi] = useVbenVxeGrid({
|
||||
label: $t('common.delete'),
|
||||
type: 'link',
|
||||
danger: true,
|
||||
color: 'error',
|
||||
icon: ACTION_ICON.DELETE,
|
||||
auth: ['erp:finance-receipt:delete'],
|
||||
popConfirm: {
|
||||
title: $t('ui.actionMessage.deleteConfirm', [row.no]),
|
||||
|
||||
@@ -201,6 +201,7 @@ const [Modal, modalApi] = useVbenModal({
|
||||
@update:items="handleUpdateItems"
|
||||
@update:total-price="handleUpdateTotalPrice"
|
||||
@update:receipt-price="handleUpdateReceiptPrice"
|
||||
class="w-full"
|
||||
/>
|
||||
</template>
|
||||
</Form>
|
||||
|
||||
@@ -59,7 +59,7 @@ const summaries = computed(() => {
|
||||
/** 表格配置 */
|
||||
const [Grid, gridApi] = useVbenVxeGrid({
|
||||
gridOptions: {
|
||||
columns: useFormItemColumns(),
|
||||
columns: useFormItemColumns(props.disabled),
|
||||
data: tableData.value,
|
||||
minHeight: 250,
|
||||
autoResize: true,
|
||||
@@ -234,7 +234,6 @@ defineExpose({ validate });
|
||||
</template>
|
||||
<template #actions="{ row }">
|
||||
<TableAction
|
||||
v-if="!disabled"
|
||||
:actions="[
|
||||
{
|
||||
label: '删除',
|
||||
|
||||
@@ -5,10 +5,10 @@ import { DocAlert, Page } from '@vben/common-ui';
|
||||
|
||||
import { Col, Row, Spin } from 'ant-design-vue';
|
||||
|
||||
import SummaryCard from './modules/SummaryCard.vue';
|
||||
import TimeSummaryChart from './modules/TimeSummaryChart.vue';
|
||||
import SummaryCard from './modules/summary-card.vue';
|
||||
import TimeSummaryChart from './modules/time-summary-chart.vue';
|
||||
|
||||
/** ERP首页 */
|
||||
/** ERP 首页 */
|
||||
defineOptions({ name: 'ErpHome' });
|
||||
|
||||
const loading = ref(false); // 加载中
|
||||
|
||||
@@ -26,17 +26,17 @@ const props = withDefaults(defineProps<Props>(), {
|
||||
});
|
||||
|
||||
/** 销售统计数据 */
|
||||
const saleSummary = ref<ErpSaleStatisticsApi.SaleSummary>(); // 销售概况统计
|
||||
const saleTimeSummaryList = ref<ErpSaleStatisticsApi.SaleTimeSummary[]>(); // 销售时段统计
|
||||
const saleSummary = ref<ErpSaleStatisticsApi.SaleSummaryRespVO>(); // 销售概况统计
|
||||
const saleTimeSummaryList = ref<ErpSaleStatisticsApi.SaleTimeSummaryRespVO[]>(); // 销售时段统计
|
||||
const getSaleStatistics = async () => {
|
||||
saleSummary.value = await getSaleSummary();
|
||||
saleTimeSummaryList.value = await getSaleTimeSummary();
|
||||
};
|
||||
|
||||
/** 采购统计数据 */
|
||||
const purchaseSummary = ref<ErpPurchaseStatisticsApi.PurchaseSummary>(); // 采购概况统计
|
||||
const purchaseSummary = ref<ErpPurchaseStatisticsApi.PurchaseSummaryRespVO>(); // 采购概况统计
|
||||
const purchaseTimeSummaryList =
|
||||
ref<ErpPurchaseStatisticsApi.PurchaseTimeSummary[]>(); // 采购时段统计
|
||||
ref<ErpPurchaseStatisticsApi.PurchaseTimeSummaryRespVO[]>(); // 采购时段统计
|
||||
const getPurchaseStatistics = async () => {
|
||||
purchaseSummary.value = await getPurchaseSummary();
|
||||
purchaseTimeSummaryList.value = await getPurchaseTimeSummary();
|
||||
@@ -196,6 +196,7 @@ export function useFormSchema(formType: string): VbenFormSchema[] {
|
||||
/** 表单的明细表格列 */
|
||||
export function useFormItemColumns(
|
||||
formData?: any[],
|
||||
disabled?: boolean,
|
||||
): VxeTableGridOptions['columns'] {
|
||||
return [
|
||||
{ type: 'seq', title: '序号', minWidth: 50, fixed: 'left' },
|
||||
@@ -295,6 +296,7 @@ export function useFormItemColumns(
|
||||
width: 50,
|
||||
fixed: 'right',
|
||||
slots: { default: 'actions' },
|
||||
visible: !disabled,
|
||||
},
|
||||
];
|
||||
}
|
||||
@@ -503,7 +505,7 @@ export function useGridColumns(): VxeTableGridOptions['columns'] {
|
||||
},
|
||||
{
|
||||
title: '操作',
|
||||
width: 220,
|
||||
width: 260,
|
||||
fixed: 'right',
|
||||
slots: { default: 'actions' },
|
||||
},
|
||||
|
||||
@@ -196,6 +196,7 @@ const [Grid, gridApi] = useVbenVxeGrid({
|
||||
{
|
||||
label: row.status === 10 ? '审批' : '反审批',
|
||||
type: 'link',
|
||||
icon: ACTION_ICON.AUDIT,
|
||||
auth: ['erp:purchase-in:update-status'],
|
||||
popConfirm: {
|
||||
title: `确认${row.status === 10 ? '审批' : '反审批'}${row.no}吗?`,
|
||||
@@ -210,7 +211,7 @@ const [Grid, gridApi] = useVbenVxeGrid({
|
||||
label: $t('common.delete'),
|
||||
type: 'link',
|
||||
danger: true,
|
||||
color: 'error',
|
||||
icon: ACTION_ICON.DELETE,
|
||||
auth: ['erp:purchase-in:delete'],
|
||||
popConfirm: {
|
||||
title: $t('ui.actionMessage.deleteConfirm', [row.no]),
|
||||
|
||||
@@ -65,7 +65,7 @@ const summaries = computed(() => {
|
||||
/** 表格配置 */
|
||||
const [Grid, gridApi] = useVbenVxeGrid({
|
||||
gridOptions: {
|
||||
columns: useFormItemColumns(tableData.value),
|
||||
columns: useFormItemColumns(tableData.value, props.disabled),
|
||||
data: tableData.value,
|
||||
minHeight: 250,
|
||||
autoResize: true,
|
||||
@@ -95,7 +95,7 @@ watch(
|
||||
await nextTick(); // 特殊:保证 gridApi 已经初始化
|
||||
await gridApi.grid.reloadData(tableData.value);
|
||||
// 更新表格列配置(目的:原数量、已入库动态列)
|
||||
const columns = useFormItemColumns(tableData.value);
|
||||
const columns = useFormItemColumns(tableData.value, props.disabled);
|
||||
await gridApi.grid.reloadColumn(columns || []);
|
||||
},
|
||||
{
|
||||
@@ -258,7 +258,6 @@ onMounted(async () => {
|
||||
</template>
|
||||
<template #actions="{ row }">
|
||||
<TableAction
|
||||
v-if="!disabled"
|
||||
:actions="[
|
||||
{
|
||||
label: '删除',
|
||||
|
||||
@@ -160,7 +160,9 @@ export function useFormSchema(formType: string): VbenFormSchema[] {
|
||||
}
|
||||
|
||||
/** 表单的明细表格列 */
|
||||
export function useFormItemColumns(): VxeTableGridOptions['columns'] {
|
||||
export function useFormItemColumns(
|
||||
disabled: boolean,
|
||||
): VxeTableGridOptions['columns'] {
|
||||
return [
|
||||
{ type: 'seq', title: '序号', minWidth: 50, fixed: 'left' },
|
||||
{
|
||||
@@ -237,6 +239,7 @@ export function useFormItemColumns(): VxeTableGridOptions['columns'] {
|
||||
width: 50,
|
||||
fixed: 'right',
|
||||
slots: { default: 'actions' },
|
||||
visible: !disabled,
|
||||
},
|
||||
];
|
||||
}
|
||||
@@ -434,7 +437,7 @@ export function useGridColumns(): VxeTableGridOptions['columns'] {
|
||||
},
|
||||
{
|
||||
title: '操作',
|
||||
width: 220,
|
||||
width: 260,
|
||||
fixed: 'right',
|
||||
slots: { default: 'actions' },
|
||||
},
|
||||
|
||||
@@ -196,6 +196,7 @@ const [Grid, gridApi] = useVbenVxeGrid({
|
||||
{
|
||||
label: row.status === 10 ? '审批' : '反审批',
|
||||
type: 'link',
|
||||
icon: ACTION_ICON.AUDIT,
|
||||
auth: ['erp:purchase-order:update-status'],
|
||||
popConfirm: {
|
||||
title: `确认${row.status === 10 ? '审批' : '反审批'}${row.no}吗?`,
|
||||
@@ -210,7 +211,7 @@ const [Grid, gridApi] = useVbenVxeGrid({
|
||||
label: $t('common.delete'),
|
||||
type: 'link',
|
||||
danger: true,
|
||||
color: 'error',
|
||||
icon: ACTION_ICON.DELETE,
|
||||
auth: ['erp:purchase-order:delete'],
|
||||
popConfirm: {
|
||||
title: $t('ui.actionMessage.deleteConfirm', [row.no]),
|
||||
|
||||
@@ -61,7 +61,7 @@ const summaries = computed(() => {
|
||||
/** 表格配置 */
|
||||
const [Grid, gridApi] = useVbenVxeGrid({
|
||||
gridOptions: {
|
||||
columns: useFormItemColumns(),
|
||||
columns: useFormItemColumns(props.disabled),
|
||||
data: tableData.value,
|
||||
minHeight: 250,
|
||||
autoResize: true,
|
||||
@@ -270,7 +270,6 @@ onMounted(async () => {
|
||||
</template>
|
||||
<template #actions="{ row }">
|
||||
<TableAction
|
||||
v-if="!disabled"
|
||||
:actions="[
|
||||
{
|
||||
label: '删除',
|
||||
|
||||
@@ -195,6 +195,7 @@ export function useFormSchema(formType: string): VbenFormSchema[] {
|
||||
/** 表单的明细表格列 */
|
||||
export function useFormItemColumns(
|
||||
formData?: any[],
|
||||
disabled?: boolean,
|
||||
): VxeTableGridOptions['columns'] {
|
||||
return [
|
||||
{ type: 'seq', title: '序号', minWidth: 50, fixed: 'left' },
|
||||
@@ -295,6 +296,7 @@ export function useFormItemColumns(
|
||||
width: 50,
|
||||
fixed: 'right',
|
||||
slots: { default: 'actions' },
|
||||
visible: !disabled,
|
||||
},
|
||||
];
|
||||
}
|
||||
@@ -490,12 +492,13 @@ export function useGridColumns(): VxeTableGridOptions['columns'] {
|
||||
},
|
||||
{
|
||||
title: '操作',
|
||||
width: 220,
|
||||
width: 260,
|
||||
fixed: 'right',
|
||||
slots: { default: 'actions' },
|
||||
},
|
||||
];
|
||||
}
|
||||
|
||||
/** 列表的搜索表单 */
|
||||
export function useOrderGridFormSchema(): VbenFormSchema[] {
|
||||
return [
|
||||
|
||||
@@ -196,6 +196,7 @@ const [Grid, gridApi] = useVbenVxeGrid({
|
||||
{
|
||||
label: row.status === 10 ? '审批' : '反审批',
|
||||
type: 'link',
|
||||
icon: ACTION_ICON.AUDIT,
|
||||
auth: ['erp:purchase-return:update-status'],
|
||||
popConfirm: {
|
||||
title: `确认${row.status === 10 ? '审批' : '反审批'}${row.no}吗?`,
|
||||
@@ -210,7 +211,7 @@ const [Grid, gridApi] = useVbenVxeGrid({
|
||||
label: $t('common.delete'),
|
||||
type: 'link',
|
||||
danger: true,
|
||||
color: 'error',
|
||||
icon: ACTION_ICON.DELETE,
|
||||
auth: ['erp:purchase-return:delete'],
|
||||
popConfirm: {
|
||||
title: $t('ui.actionMessage.deleteConfirm', [row.no]),
|
||||
|
||||
@@ -65,7 +65,7 @@ const summaries = computed(() => {
|
||||
/** 表格配置 */
|
||||
const [Grid, gridApi] = useVbenVxeGrid({
|
||||
gridOptions: {
|
||||
columns: useFormItemColumns(tableData.value),
|
||||
columns: useFormItemColumns(tableData.value, props.disabled),
|
||||
data: tableData.value,
|
||||
minHeight: 250,
|
||||
autoResize: true,
|
||||
@@ -95,7 +95,7 @@ watch(
|
||||
await nextTick(); // 特殊:保证 gridApi 已经初始化
|
||||
await gridApi.grid.reloadData(tableData.value);
|
||||
// 更新表格列配置(目的:已入库、已退货动态列)
|
||||
const columns = useFormItemColumns(tableData.value);
|
||||
const columns = useFormItemColumns(tableData.value, props.disabled);
|
||||
await gridApi.grid.reloadColumn(columns || []);
|
||||
},
|
||||
{
|
||||
@@ -260,7 +260,6 @@ onMounted(async () => {
|
||||
</template>
|
||||
<template #actions="{ row }">
|
||||
<TableAction
|
||||
v-if="!disabled"
|
||||
:actions="[
|
||||
{
|
||||
label: '删除',
|
||||
|
||||
@@ -124,7 +124,6 @@ const [Grid, gridApi] = useVbenVxeGrid({
|
||||
]"
|
||||
/>
|
||||
</template>
|
||||
|
||||
<template #actions="{ row }">
|
||||
<TableAction
|
||||
:actions="[
|
||||
|
||||
@@ -173,7 +173,9 @@ export function useFormSchema(formType: string): VbenFormSchema[] {
|
||||
}
|
||||
|
||||
/** 表单的明细表格列 */
|
||||
export function useFormItemColumns(): VxeTableGridOptions['columns'] {
|
||||
export function useFormItemColumns(
|
||||
disabled: boolean,
|
||||
): VxeTableGridOptions['columns'] {
|
||||
return [
|
||||
{ type: 'seq', title: '序号', minWidth: 50, fixed: 'left' },
|
||||
{
|
||||
@@ -251,6 +253,7 @@ export function useFormItemColumns(): VxeTableGridOptions['columns'] {
|
||||
width: 50,
|
||||
fixed: 'right',
|
||||
slots: { default: 'actions' },
|
||||
visible: !disabled,
|
||||
},
|
||||
];
|
||||
}
|
||||
@@ -448,7 +451,7 @@ export function useGridColumns(): VxeTableGridOptions['columns'] {
|
||||
},
|
||||
{
|
||||
title: '操作',
|
||||
width: 220,
|
||||
width: 260,
|
||||
fixed: 'right',
|
||||
slots: { default: 'actions' },
|
||||
},
|
||||
|
||||
@@ -196,6 +196,7 @@ const [Grid, gridApi] = useVbenVxeGrid({
|
||||
{
|
||||
label: row.status === 10 ? '审批' : '反审批',
|
||||
type: 'link',
|
||||
icon: ACTION_ICON.AUDIT,
|
||||
auth: ['erp:sale-order:update-status'],
|
||||
popConfirm: {
|
||||
title: `确认${row.status === 10 ? '审批' : '反审批'}${row.no}吗?`,
|
||||
@@ -210,7 +211,7 @@ const [Grid, gridApi] = useVbenVxeGrid({
|
||||
label: $t('common.delete'),
|
||||
type: 'link',
|
||||
danger: true,
|
||||
color: 'error',
|
||||
icon: ACTION_ICON.DELETE,
|
||||
auth: ['erp:sale-order:delete'],
|
||||
popConfirm: {
|
||||
title: $t('ui.actionMessage.deleteConfirm', [row.no]),
|
||||
|
||||
@@ -61,7 +61,7 @@ const summaries = computed(() => {
|
||||
/** 表格配置 */
|
||||
const [Grid, gridApi] = useVbenVxeGrid({
|
||||
gridOptions: {
|
||||
columns: useFormItemColumns(),
|
||||
columns: useFormItemColumns(props.disabled),
|
||||
data: tableData.value,
|
||||
minHeight: 250,
|
||||
autoResize: true,
|
||||
@@ -270,7 +270,6 @@ onMounted(async () => {
|
||||
</template>
|
||||
<template #actions="{ row }">
|
||||
<TableAction
|
||||
v-if="!disabled"
|
||||
:actions="[
|
||||
{
|
||||
label: '删除',
|
||||
|
||||
@@ -216,6 +216,7 @@ export function useFormSchema(formType: string): VbenFormSchema[] {
|
||||
/** 表单的明细表格列 */
|
||||
export function useFormItemColumns(
|
||||
formData?: any[],
|
||||
disabled?: boolean,
|
||||
): VxeTableGridOptions['columns'] {
|
||||
return [
|
||||
{ type: 'seq', title: '序号', minWidth: 50, fixed: 'left' },
|
||||
@@ -316,6 +317,7 @@ export function useFormItemColumns(
|
||||
width: 50,
|
||||
fixed: 'right',
|
||||
slots: { default: 'actions' },
|
||||
visible: !disabled,
|
||||
},
|
||||
];
|
||||
}
|
||||
@@ -517,7 +519,7 @@ export function useGridColumns(): VxeTableGridOptions['columns'] {
|
||||
},
|
||||
{
|
||||
title: '操作',
|
||||
width: 220,
|
||||
width: 260,
|
||||
fixed: 'right',
|
||||
slots: { default: 'actions' },
|
||||
},
|
||||
|
||||
@@ -193,6 +193,7 @@ const [Grid, gridApi] = useVbenVxeGrid({
|
||||
{
|
||||
label: row.status === 10 ? '审批' : '反审批',
|
||||
type: 'link',
|
||||
icon: ACTION_ICON.AUDIT,
|
||||
auth: ['erp:sale-out:update-status'],
|
||||
popConfirm: {
|
||||
title: `确认${row.status === 10 ? '审批' : '反审批'}${row.no}吗?`,
|
||||
@@ -207,7 +208,7 @@ const [Grid, gridApi] = useVbenVxeGrid({
|
||||
label: $t('common.delete'),
|
||||
type: 'link',
|
||||
danger: true,
|
||||
color: 'error',
|
||||
icon: ACTION_ICON.DELETE,
|
||||
auth: ['erp:sale-out:delete'],
|
||||
popConfirm: {
|
||||
title: $t('ui.actionMessage.deleteConfirm', [row.no]),
|
||||
|
||||
@@ -65,7 +65,7 @@ const summaries = computed(() => {
|
||||
/** 表格配置 */
|
||||
const [Grid, gridApi] = useVbenVxeGrid({
|
||||
gridOptions: {
|
||||
columns: useFormItemColumns(),
|
||||
columns: useFormItemColumns(tableData.value, props.disabled),
|
||||
data: tableData.value,
|
||||
minHeight: 250,
|
||||
autoResize: true,
|
||||
@@ -95,7 +95,7 @@ watch(
|
||||
await nextTick(); // 特殊:保证 gridApi 已经初始化
|
||||
await gridApi.grid.reloadData(tableData.value);
|
||||
// 更新表格列配置(目的:原数量、已出库动态列)
|
||||
const columns = useFormItemColumns(tableData.value);
|
||||
const columns = useFormItemColumns(tableData.value, props.disabled);
|
||||
await gridApi.grid.reloadColumn(columns || []);
|
||||
},
|
||||
{
|
||||
@@ -258,7 +258,6 @@ onMounted(async () => {
|
||||
</template>
|
||||
<template #actions="{ row }">
|
||||
<TableAction
|
||||
v-if="!disabled"
|
||||
:actions="[
|
||||
{
|
||||
label: '删除',
|
||||
|
||||
@@ -209,6 +209,7 @@ export function useFormSchema(formType: string): VbenFormSchema[] {
|
||||
/** 表单的明细表格列 */
|
||||
export function useFormItemColumns(
|
||||
formData?: any[],
|
||||
disabled?: boolean,
|
||||
): VxeTableGridOptions['columns'] {
|
||||
return [
|
||||
{ type: 'seq', title: '序号', minWidth: 50, fixed: 'left' },
|
||||
@@ -309,6 +310,7 @@ export function useFormItemColumns(
|
||||
width: 50,
|
||||
fixed: 'right',
|
||||
slots: { default: 'actions' },
|
||||
visible: !disabled,
|
||||
},
|
||||
];
|
||||
}
|
||||
@@ -504,7 +506,7 @@ export function useGridColumns(): VxeTableGridOptions['columns'] {
|
||||
},
|
||||
{
|
||||
title: '操作',
|
||||
width: 220,
|
||||
width: 260,
|
||||
fixed: 'right',
|
||||
slots: { default: 'actions' },
|
||||
},
|
||||
|
||||
@@ -196,6 +196,7 @@ const [Grid, gridApi] = useVbenVxeGrid({
|
||||
{
|
||||
label: row.status === 10 ? '审批' : '反审批',
|
||||
type: 'link',
|
||||
icon: ACTION_ICON.AUDIT,
|
||||
auth: ['erp:sale-return:update-status'],
|
||||
popConfirm: {
|
||||
title: `确认${row.status === 10 ? '审批' : '反审批'}${row.no}吗?`,
|
||||
@@ -210,7 +211,7 @@ const [Grid, gridApi] = useVbenVxeGrid({
|
||||
label: $t('common.delete'),
|
||||
type: 'link',
|
||||
danger: true,
|
||||
color: 'error',
|
||||
icon: ACTION_ICON.DELETE,
|
||||
auth: ['erp:sale-return:delete'],
|
||||
popConfirm: {
|
||||
title: $t('ui.actionMessage.deleteConfirm', [row.no]),
|
||||
|
||||
@@ -65,7 +65,7 @@ const summaries = computed(() => {
|
||||
/** 表格配置 */
|
||||
const [Grid, gridApi] = useVbenVxeGrid({
|
||||
gridOptions: {
|
||||
columns: useFormItemColumns(tableData.value),
|
||||
columns: useFormItemColumns(tableData.value, props.disabled),
|
||||
data: tableData.value,
|
||||
minHeight: 250,
|
||||
autoResize: true,
|
||||
@@ -95,7 +95,7 @@ watch(
|
||||
await nextTick(); // 特殊:保证 gridApi 已经初始化
|
||||
await gridApi.grid.reloadData(tableData.value);
|
||||
// 更新表格列配置(目的:已出库、已出库动态列)
|
||||
const columns = useFormItemColumns(tableData.value);
|
||||
const columns = useFormItemColumns(tableData.value, props.disabled);
|
||||
await gridApi.grid.reloadColumn(columns || []);
|
||||
},
|
||||
{
|
||||
@@ -258,7 +258,6 @@ onMounted(async () => {
|
||||
</template>
|
||||
<template #actions="{ row }">
|
||||
<TableAction
|
||||
v-if="!disabled"
|
||||
:actions="[
|
||||
{
|
||||
label: '删除',
|
||||
|
||||
@@ -85,7 +85,9 @@ export function useFormSchema(formType: string): VbenFormSchema[] {
|
||||
}
|
||||
|
||||
/** 表单的明细表格列 */
|
||||
export function useFormItemColumns(): VxeTableGridOptions['columns'] {
|
||||
export function useFormItemColumns(
|
||||
disabled: boolean,
|
||||
): VxeTableGridOptions['columns'] {
|
||||
return [
|
||||
{ type: 'seq', title: '序号', minWidth: 50, fixed: 'left' },
|
||||
{
|
||||
@@ -156,6 +158,7 @@ export function useFormItemColumns(): VxeTableGridOptions['columns'] {
|
||||
width: 50,
|
||||
fixed: 'right',
|
||||
slots: { default: 'actions' },
|
||||
visible: !disabled,
|
||||
},
|
||||
];
|
||||
}
|
||||
@@ -296,7 +299,7 @@ export function useGridColumns(): VxeTableGridOptions['columns'] {
|
||||
},
|
||||
{
|
||||
title: '操作',
|
||||
width: 220,
|
||||
width: 260,
|
||||
fixed: 'right',
|
||||
slots: { default: 'actions' },
|
||||
},
|
||||
|
||||
@@ -196,6 +196,7 @@ const [Grid, gridApi] = useVbenVxeGrid({
|
||||
{
|
||||
label: row.status === 10 ? '审批' : '反审批',
|
||||
type: 'link',
|
||||
icon: ACTION_ICON.AUDIT,
|
||||
auth: ['erp:stock-check:update-status'],
|
||||
popConfirm: {
|
||||
title: `确认${row.status === 10 ? '审批' : '反审批'}${row.no}吗?`,
|
||||
@@ -210,7 +211,7 @@ const [Grid, gridApi] = useVbenVxeGrid({
|
||||
label: $t('common.delete'),
|
||||
type: 'link',
|
||||
danger: true,
|
||||
color: 'error',
|
||||
icon: ACTION_ICON.DELETE,
|
||||
auth: ['erp:stock-check:delete'],
|
||||
popConfirm: {
|
||||
title: $t('ui.actionMessage.deleteConfirm', [row.no]),
|
||||
|
||||
@@ -49,7 +49,7 @@ const summaries = computed(() => {
|
||||
/** 表格配置 */
|
||||
const [Grid, gridApi] = useVbenVxeGrid({
|
||||
gridOptions: {
|
||||
columns: useFormItemColumns(),
|
||||
columns: useFormItemColumns(props.disabled),
|
||||
data: tableData.value,
|
||||
minHeight: 250,
|
||||
autoResize: true,
|
||||
@@ -265,7 +265,6 @@ onMounted(async () => {
|
||||
</template>
|
||||
<template #actions="{ row }">
|
||||
<TableAction
|
||||
v-if="!disabled"
|
||||
:actions="[
|
||||
{
|
||||
label: '删除',
|
||||
|
||||
@@ -100,7 +100,9 @@ export function useFormSchema(formType: string): VbenFormSchema[] {
|
||||
}
|
||||
|
||||
/** 表单的明细表格列 */
|
||||
export function useFormItemColumns(): VxeTableGridOptions['columns'] {
|
||||
export function useFormItemColumns(
|
||||
disabled: boolean,
|
||||
): VxeTableGridOptions['columns'] {
|
||||
return [
|
||||
{ type: 'seq', title: '序号', minWidth: 50, fixed: 'left' },
|
||||
{
|
||||
@@ -163,6 +165,7 @@ export function useFormItemColumns(): VxeTableGridOptions['columns'] {
|
||||
width: 50,
|
||||
fixed: 'right',
|
||||
slots: { default: 'actions' },
|
||||
visible: !disabled,
|
||||
},
|
||||
];
|
||||
}
|
||||
|
||||
@@ -193,6 +193,7 @@ const [Grid, gridApi] = useVbenVxeGrid({
|
||||
{
|
||||
label: row.status === 10 ? '审批' : '反审批',
|
||||
type: 'link',
|
||||
icon: ACTION_ICON.AUDIT,
|
||||
auth: ['erp:stock-in:update-status'],
|
||||
popConfirm: {
|
||||
title: `确认${row.status === 10 ? '审批' : '反审批'}${row.no}吗?`,
|
||||
@@ -207,7 +208,7 @@ const [Grid, gridApi] = useVbenVxeGrid({
|
||||
label: $t('common.delete'),
|
||||
type: 'link',
|
||||
danger: true,
|
||||
color: 'error',
|
||||
icon: ACTION_ICON.DELETE,
|
||||
auth: ['erp:stock-in:delete'],
|
||||
popConfirm: {
|
||||
title: $t('ui.actionMessage.deleteConfirm', [row.no]),
|
||||
|
||||
@@ -49,7 +49,7 @@ const summaries = computed(() => {
|
||||
/** 表格配置 */
|
||||
const [Grid, gridApi] = useVbenVxeGrid({
|
||||
gridOptions: {
|
||||
columns: useFormItemColumns(),
|
||||
columns: useFormItemColumns(props.disabled),
|
||||
data: tableData.value,
|
||||
minHeight: 250,
|
||||
autoResize: true,
|
||||
@@ -254,7 +254,6 @@ onMounted(async () => {
|
||||
</template>
|
||||
<template #actions="{ row }">
|
||||
<TableAction
|
||||
v-if="!disabled"
|
||||
:actions="[
|
||||
{
|
||||
label: '删除',
|
||||
|
||||
@@ -85,7 +85,9 @@ export function useFormSchema(formType: string): VbenFormSchema[] {
|
||||
}
|
||||
|
||||
/** 表单的明细表格列 */
|
||||
export function useFormItemColumns(): VxeTableGridOptions['columns'] {
|
||||
export function useFormItemColumns(
|
||||
disabled: boolean,
|
||||
): VxeTableGridOptions['columns'] {
|
||||
return [
|
||||
{ type: 'seq', title: '序号', minWidth: 50, fixed: 'left' },
|
||||
{
|
||||
@@ -154,6 +156,7 @@ export function useFormItemColumns(): VxeTableGridOptions['columns'] {
|
||||
width: 50,
|
||||
fixed: 'right',
|
||||
slots: { default: 'actions' },
|
||||
visible: !disabled,
|
||||
},
|
||||
];
|
||||
}
|
||||
@@ -307,7 +310,7 @@ export function useGridColumns(): VxeTableGridOptions['columns'] {
|
||||
},
|
||||
{
|
||||
title: '操作',
|
||||
width: 220,
|
||||
width: 260,
|
||||
fixed: 'right',
|
||||
slots: { default: 'actions' },
|
||||
},
|
||||
|
||||
@@ -196,6 +196,7 @@ const [Grid, gridApi] = useVbenVxeGrid({
|
||||
{
|
||||
label: row.status === 10 ? '审批' : '反审批',
|
||||
type: 'link',
|
||||
icon: ACTION_ICON.AUDIT,
|
||||
auth: ['erp:stock-move:update-status'],
|
||||
popConfirm: {
|
||||
title: `确认${row.status === 10 ? '审批' : '反审批'}${row.no}吗?`,
|
||||
@@ -210,7 +211,7 @@ const [Grid, gridApi] = useVbenVxeGrid({
|
||||
label: $t('common.delete'),
|
||||
type: 'link',
|
||||
danger: true,
|
||||
color: 'error',
|
||||
icon: ACTION_ICON.DELETE,
|
||||
auth: ['erp:stock-move:delete'],
|
||||
popConfirm: {
|
||||
title: $t('ui.actionMessage.deleteConfirm', [row.no]),
|
||||
|
||||
@@ -49,7 +49,7 @@ const summaries = computed(() => {
|
||||
/** 表格配置 */
|
||||
const [Grid, gridApi] = useVbenVxeGrid({
|
||||
gridOptions: {
|
||||
columns: useFormItemColumns(),
|
||||
columns: useFormItemColumns(props.disabled),
|
||||
data: tableData.value,
|
||||
minHeight: 250,
|
||||
autoResize: true,
|
||||
@@ -275,7 +275,6 @@ onMounted(async () => {
|
||||
</template>
|
||||
<template #actions="{ row }">
|
||||
<TableAction
|
||||
v-if="!disabled"
|
||||
:actions="[
|
||||
{
|
||||
label: '删除',
|
||||
|
||||
@@ -102,7 +102,9 @@ export function useFormSchema(formType: string): VbenFormSchema[] {
|
||||
}
|
||||
|
||||
/** 表单的明细表格列 */
|
||||
export function useFormItemColumns(): VxeTableGridOptions['columns'] {
|
||||
export function useFormItemColumns(
|
||||
disabled: boolean,
|
||||
): VxeTableGridOptions['columns'] {
|
||||
return [
|
||||
{ type: 'seq', title: '序号', minWidth: 50, fixed: 'left' },
|
||||
{
|
||||
@@ -165,6 +167,7 @@ export function useFormItemColumns(): VxeTableGridOptions['columns'] {
|
||||
width: 50,
|
||||
fixed: 'right',
|
||||
slots: { default: 'actions' },
|
||||
visible: !disabled,
|
||||
},
|
||||
];
|
||||
}
|
||||
@@ -331,7 +334,7 @@ export function useGridColumns(): VxeTableGridOptions['columns'] {
|
||||
},
|
||||
{
|
||||
title: '操作',
|
||||
width: 220,
|
||||
width: 260,
|
||||
fixed: 'right',
|
||||
slots: { default: 'actions' },
|
||||
},
|
||||
|
||||
@@ -196,6 +196,7 @@ const [Grid, gridApi] = useVbenVxeGrid({
|
||||
{
|
||||
label: row.status === 10 ? '审批' : '反审批',
|
||||
type: 'link',
|
||||
icon: ACTION_ICON.AUDIT,
|
||||
auth: ['erp:stock-out:update-status'],
|
||||
popConfirm: {
|
||||
title: `确认${row.status === 10 ? '审批' : '反审批'}${row.no}吗?`,
|
||||
@@ -210,7 +211,7 @@ const [Grid, gridApi] = useVbenVxeGrid({
|
||||
label: $t('common.delete'),
|
||||
type: 'link',
|
||||
danger: true,
|
||||
color: 'error',
|
||||
icon: ACTION_ICON.DELETE,
|
||||
auth: ['erp:stock-out:delete'],
|
||||
popConfirm: {
|
||||
title: $t('ui.actionMessage.deleteConfirm', [row.no]),
|
||||
|
||||
@@ -49,7 +49,7 @@ const summaries = computed(() => {
|
||||
/** 表格配置 */
|
||||
const [Grid, gridApi] = useVbenVxeGrid({
|
||||
gridOptions: {
|
||||
columns: useFormItemColumns(),
|
||||
columns: useFormItemColumns(props.disabled),
|
||||
data: tableData.value,
|
||||
minHeight: 250,
|
||||
autoResize: true,
|
||||
@@ -252,7 +252,6 @@ onMounted(async () => {
|
||||
</template>
|
||||
<template #actions="{ row }">
|
||||
<TableAction
|
||||
v-if="!disabled"
|
||||
:actions="[
|
||||
{
|
||||
label: '删除',
|
||||
|
||||
@@ -73,6 +73,7 @@ async function handleDefaultStatusChange(
|
||||
await updateWarehouseDefaultStatus(row.id!, newStatus);
|
||||
// 提示并返回成功
|
||||
message.success(`${text}默认成功`);
|
||||
handleRefresh();
|
||||
resolve(true);
|
||||
})
|
||||
.catch(() => {
|
||||
|
||||
@@ -1,2 +1 @@
|
||||
export { default as CombinationShowcase } from './showcase.vue';
|
||||
|
||||
|
||||
@@ -143,4 +143,3 @@ function emitActivityChange() {
|
||||
@change="handleActivitySelected"
|
||||
/>
|
||||
</template>
|
||||
|
||||
|
||||
@@ -1,3 +1,5 @@
|
||||
/* eslint-disable vue/one-component-per-file */
|
||||
// TODO @YunaiV eslint检测了
|
||||
import type { MallCouponTemplateApi } from '#/api/mall/promotion/coupon/couponTemplate';
|
||||
|
||||
import { defineComponent } from 'vue';
|
||||
|
||||
@@ -1,138 +0,0 @@
|
||||
<script lang="ts" setup>
|
||||
import type { Rule } from 'ant-design-vue/es/form';
|
||||
|
||||
import type { Reply } from '#/views/mp/components';
|
||||
|
||||
import { computed, ref } from 'vue';
|
||||
|
||||
import { DICT_TYPE } from '@vben/constants';
|
||||
import { getDictOptions } from '@vben/hooks';
|
||||
|
||||
import { Form, FormItem, Input, Select, SelectOption } from 'ant-design-vue';
|
||||
|
||||
import { WxReply } from '#/views/mp/components';
|
||||
|
||||
import { MsgType } from './types';
|
||||
|
||||
defineOptions({ name: 'ReplyForm' });
|
||||
|
||||
const props = defineProps<{
|
||||
modelValue: any;
|
||||
msgType: MsgType;
|
||||
reply: Reply;
|
||||
}>();
|
||||
|
||||
const emit = defineEmits<{
|
||||
(e: 'update:reply', v: Reply): void;
|
||||
(e: 'update:modelValue', v: any): void;
|
||||
}>();
|
||||
|
||||
const reply = computed<Reply>({
|
||||
get: () => props.reply,
|
||||
set: (val) => emit('update:reply', val),
|
||||
});
|
||||
|
||||
const replyForm = computed<any>({
|
||||
get: () => props.modelValue,
|
||||
set: (val) => emit('update:modelValue', val),
|
||||
});
|
||||
|
||||
const formRef = ref(); // 表单 ref
|
||||
|
||||
const RequestMessageTypes = [
|
||||
'text',
|
||||
'image',
|
||||
'voice',
|
||||
'video',
|
||||
'shortvideo',
|
||||
'location',
|
||||
'link',
|
||||
]; // 允许选择的请求消息类型
|
||||
|
||||
// 表单校验规则
|
||||
const rules = {
|
||||
requestKeyword: [
|
||||
{ required: true, message: '请求的关键字不能为空', trigger: 'blur' },
|
||||
] as Rule[],
|
||||
requestMatch: [
|
||||
{ required: true, message: '请求的关键字的匹配不能为空', trigger: 'blur' },
|
||||
] as Rule[],
|
||||
} as Record<string, Rule[]>;
|
||||
|
||||
defineExpose({
|
||||
resetFields: () => formRef.value?.resetFields(),
|
||||
validate: async () => {
|
||||
await formRef.value?.validate();
|
||||
},
|
||||
});
|
||||
</script>
|
||||
|
||||
<template>
|
||||
<!-- TODO @hw:可以使用 <Form class="mx-4" /> 这种组件形式么? 融合到 /Users/yunai/Java/yudao-ui-admin-vben-v5/apps/web-antd/src/views/mp/autoReply/modules/form.vue -->
|
||||
<div>
|
||||
<Form
|
||||
ref="formRef"
|
||||
:model="replyForm"
|
||||
:rules="rules"
|
||||
:label-col="{ span: 6 }"
|
||||
:wrapper-col="{ span: 18 }"
|
||||
>
|
||||
<FormItem
|
||||
label="消息类型"
|
||||
name="requestMessageType"
|
||||
v-if="msgType === MsgType.Message"
|
||||
>
|
||||
<Select
|
||||
v-model:value="replyForm.requestMessageType"
|
||||
placeholder="请选择"
|
||||
>
|
||||
<SelectOption
|
||||
v-for="dict in getDictOptions(DICT_TYPE.MP_MESSAGE_TYPE).filter(
|
||||
(d) => RequestMessageTypes.includes(d.value as string),
|
||||
)"
|
||||
:key="dict.value"
|
||||
:value="dict.value"
|
||||
>
|
||||
{{ dict.label }}
|
||||
</SelectOption>
|
||||
</Select>
|
||||
</FormItem>
|
||||
<FormItem
|
||||
label="匹配类型"
|
||||
name="requestMatch"
|
||||
v-if="msgType === MsgType.Keyword"
|
||||
>
|
||||
<Select
|
||||
v-model:value="replyForm.requestMatch"
|
||||
placeholder="请选择匹配类型"
|
||||
allow-clear
|
||||
>
|
||||
<SelectOption
|
||||
v-for="dict in getDictOptions(
|
||||
DICT_TYPE.MP_AUTO_REPLY_REQUEST_MATCH,
|
||||
'number',
|
||||
)"
|
||||
:key="String(dict.value)"
|
||||
:value="dict.value"
|
||||
>
|
||||
{{ dict.label }}
|
||||
</SelectOption>
|
||||
</Select>
|
||||
</FormItem>
|
||||
<FormItem
|
||||
label="关键词"
|
||||
name="requestKeyword"
|
||||
v-if="msgType === MsgType.Keyword"
|
||||
>
|
||||
<Input
|
||||
v-model:value="replyForm.requestKeyword"
|
||||
placeholder="请输入内容"
|
||||
allow-clear
|
||||
/>
|
||||
</FormItem>
|
||||
<FormItem label="回复消息">
|
||||
<WxReply v-model="reply" />
|
||||
</FormItem>
|
||||
</Form>
|
||||
</div>
|
||||
</template>
|
||||
@@ -1,13 +1,30 @@
|
||||
import type { VbenFormSchema } from '#/adapter/form';
|
||||
import type { VxeGridPropTypes } from '#/adapter/vxe-table';
|
||||
import type { MpAccountApi } from '#/api/mp/account';
|
||||
|
||||
import { markRaw } from 'vue';
|
||||
|
||||
import { DICT_TYPE } from '@vben/constants';
|
||||
import { getDictOptions } from '@vben/hooks';
|
||||
|
||||
import { WxAccountSelect } from '#/views/mp/components';
|
||||
import { getSimpleAccountList } from '#/api/mp/account';
|
||||
import { WxReply } from '#/views/mp/components';
|
||||
|
||||
import { MsgType } from './components/types';
|
||||
import { MsgType } from './types';
|
||||
|
||||
/** 关联数据 */
|
||||
let accountList: MpAccountApi.AccountSimple[] = [];
|
||||
getSimpleAccountList().then((data) => (accountList = data));
|
||||
|
||||
const RequestMessageTypes = new Set([
|
||||
'image',
|
||||
'link',
|
||||
'location',
|
||||
'shortvideo',
|
||||
'text',
|
||||
'video',
|
||||
'voice',
|
||||
]); // 允许选择的请求消息类型
|
||||
|
||||
/** 获取表格列配置 */
|
||||
export function useGridColumns(msgType: MsgType): VxeGridPropTypes.Columns {
|
||||
@@ -76,13 +93,84 @@ export function useGridColumns(msgType: MsgType): VxeGridPropTypes.Columns {
|
||||
return columns;
|
||||
}
|
||||
|
||||
/** 新增/修改的表单 */
|
||||
export function useFormSchema(msgType: MsgType): VbenFormSchema[] {
|
||||
const schema: VbenFormSchema[] = [];
|
||||
|
||||
// 消息类型(仅消息回复显示)
|
||||
if (msgType === MsgType.Message) {
|
||||
schema.push({
|
||||
fieldName: 'requestMessageType',
|
||||
label: '消息类型',
|
||||
component: 'Select',
|
||||
componentProps: {
|
||||
placeholder: '请选择',
|
||||
options: getDictOptions(DICT_TYPE.MP_MESSAGE_TYPE).filter((d) =>
|
||||
RequestMessageTypes.has(d.value as string),
|
||||
),
|
||||
},
|
||||
});
|
||||
}
|
||||
|
||||
// 匹配类型(仅关键词回复显示)
|
||||
if (msgType === MsgType.Keyword) {
|
||||
schema.push({
|
||||
fieldName: 'requestMatch',
|
||||
label: '匹配类型',
|
||||
component: 'Select',
|
||||
componentProps: {
|
||||
placeholder: '请选择匹配类型',
|
||||
allowClear: true,
|
||||
options: getDictOptions(
|
||||
DICT_TYPE.MP_AUTO_REPLY_REQUEST_MATCH,
|
||||
'number',
|
||||
),
|
||||
},
|
||||
rules: 'required',
|
||||
});
|
||||
}
|
||||
|
||||
// 关键词(仅关键词回复显示)
|
||||
if (msgType === MsgType.Keyword) {
|
||||
schema.push({
|
||||
fieldName: 'requestKeyword',
|
||||
label: '关键词',
|
||||
component: 'Input',
|
||||
componentProps: {
|
||||
placeholder: '请输入内容',
|
||||
allowClear: true,
|
||||
},
|
||||
rules: 'required',
|
||||
});
|
||||
}
|
||||
// 回复消息
|
||||
schema.push({
|
||||
fieldName: 'reply',
|
||||
label: '回复消息',
|
||||
component: markRaw(WxReply),
|
||||
// componentProps: {
|
||||
// modelValue: { type: 'video', content: '12456' },
|
||||
// },
|
||||
modelPropName: 'modelValue',
|
||||
});
|
||||
return schema;
|
||||
}
|
||||
|
||||
/** 列表的搜索表单 */
|
||||
export function useGridFormSchema(): VbenFormSchema[] {
|
||||
return [
|
||||
{
|
||||
fieldName: 'accountId',
|
||||
label: '公众号',
|
||||
component: markRaw(WxAccountSelect),
|
||||
component: 'ApiSelect',
|
||||
componentProps: {
|
||||
options: accountList.map((item) => ({
|
||||
label: item.name,
|
||||
value: item.id,
|
||||
})),
|
||||
placeholder: '请选择公众号',
|
||||
},
|
||||
defaultValue: accountList[0]?.id,
|
||||
},
|
||||
];
|
||||
}
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
<script lang="ts" setup>
|
||||
import type { VxeTableGridOptions } from '#/adapter/vxe-table';
|
||||
|
||||
import { computed, nextTick, onMounted, ref } from 'vue';
|
||||
import { computed, nextTick, ref } from 'vue';
|
||||
|
||||
import { confirm, DocAlert, Page, useVbenModal } from '@vben/common-ui';
|
||||
import { IconifyIcon } from '@vben/icons';
|
||||
@@ -16,20 +16,13 @@ import {
|
||||
} from '#/api/mp/autoReply';
|
||||
import { $t } from '#/locales';
|
||||
|
||||
import ReplyContentCell from './components/ReplyTable.vue';
|
||||
import { MsgType } from './components/types';
|
||||
import { useGridColumns, useGridFormSchema } from './data';
|
||||
import ReplyContentCell from './modules/content.vue';
|
||||
import Form from './modules/form.vue';
|
||||
import { MsgType } from './types';
|
||||
|
||||
defineOptions({ name: 'MpAutoReply' });
|
||||
|
||||
/** 刷新表格 */
|
||||
function handleRefresh() {
|
||||
gridApi.query().then(() => {
|
||||
updateTableDataLength();
|
||||
});
|
||||
}
|
||||
|
||||
const msgType = ref<string>(String(MsgType.Keyword)); // 消息类型
|
||||
|
||||
/** 切换回复类型 */
|
||||
@@ -46,7 +39,6 @@ async function onTabChange(tabName: any) {
|
||||
}
|
||||
// 查询数据
|
||||
await gridApi.query();
|
||||
updateTableDataLength();
|
||||
}
|
||||
|
||||
/** 新增按钮操作 */
|
||||
@@ -54,7 +46,6 @@ async function handleCreate() {
|
||||
const formValues = await gridApi.formApi.getValues();
|
||||
formModalApi
|
||||
.setData({
|
||||
isCreating: true,
|
||||
msgType: Number(msgType.value) as MsgType,
|
||||
accountId: formValues.accountId,
|
||||
})
|
||||
@@ -66,8 +57,8 @@ async function handleEdit(row: any) {
|
||||
const data = (await getAutoReply(row.id)) as any;
|
||||
formModalApi
|
||||
.setData({
|
||||
isCreating: false,
|
||||
msgType: Number(msgType.value) as MsgType,
|
||||
accountId: row.accountId,
|
||||
row: data,
|
||||
})
|
||||
.open();
|
||||
@@ -83,9 +74,7 @@ async function handleDelete(row: any) {
|
||||
try {
|
||||
await deleteAutoReply(row.id);
|
||||
message.success('删除成功');
|
||||
await gridApi.query();
|
||||
// 查询完成后更新数据长度
|
||||
updateTableDataLength();
|
||||
handleRefresh();
|
||||
} finally {
|
||||
hideLoading();
|
||||
}
|
||||
@@ -116,7 +105,6 @@ const [Grid, gridApi] = useVbenVxeGrid({
|
||||
});
|
||||
},
|
||||
},
|
||||
autoLoad: false, // 禁用自动加载,等表单初始化完成后再加载
|
||||
},
|
||||
rowConfig: {
|
||||
keyField: 'id',
|
||||
@@ -129,49 +117,25 @@ const [Grid, gridApi] = useVbenVxeGrid({
|
||||
} as VxeTableGridOptions<any>,
|
||||
});
|
||||
|
||||
// TODO @hw:按道理说,不太需呀哦这个?可以微信讨论下哈;
|
||||
const tableDataLength = ref(0); // 表格数据长度,用于判断是否显示新增按钮
|
||||
|
||||
/** 更新表格数据长度(避免在模板中直接调用 getTableData 导致响应式循环) */
|
||||
function updateTableDataLength() {
|
||||
try {
|
||||
if (!gridApi.grid) {
|
||||
return;
|
||||
}
|
||||
const tableData = gridApi.grid.getTableData();
|
||||
tableDataLength.value = tableData?.tableData?.length || 0;
|
||||
} catch {
|
||||
tableDataLength.value = 0;
|
||||
}
|
||||
/** 刷新表格 */
|
||||
function handleRefresh() {
|
||||
gridApi.query();
|
||||
}
|
||||
|
||||
// TODO @hw:这个要不改成,直接 tableaction 那判断;
|
||||
// 计算是否显示新增按钮:关注时回复类型只有在没有数据时才显示
|
||||
const showCreateButton = computed(() => {
|
||||
if (Number(msgType.value) !== MsgType.Follow) {
|
||||
return true;
|
||||
}
|
||||
return tableDataLength.value <= 0;
|
||||
try {
|
||||
const tableData = gridApi.grid?.getTableData();
|
||||
return (tableData?.tableData?.length || 0) <= 0;
|
||||
} catch {
|
||||
return true;
|
||||
}
|
||||
});
|
||||
|
||||
// TODO @hw:看看能不能参考 tag/index.vue 简化下
|
||||
/** 页面挂载后,等待表单初始化完成再加载数据 */
|
||||
onMounted(async () => {
|
||||
// 等待 WxAccountSelect 组件加载并设置默认值
|
||||
await nextTick();
|
||||
if (!gridApi.formApi) {
|
||||
return;
|
||||
}
|
||||
const formValues = await gridApi.formApi.getValues();
|
||||
// 如果 accountId 有值,说明已经准备好了
|
||||
if (formValues.accountId) {
|
||||
// 设置为最新提交的值
|
||||
gridApi.formApi.setLatestSubmissionValues(formValues);
|
||||
// 触发首次查询
|
||||
await gridApi.query();
|
||||
updateTableDataLength();
|
||||
}
|
||||
});
|
||||
// DONE @hw:看看能不能参考 tag/index.vue 简化下
|
||||
</script>
|
||||
|
||||
<template>
|
||||
@@ -181,23 +145,26 @@ onMounted(async () => {
|
||||
</template>
|
||||
|
||||
<FormModal @success="handleRefresh" />
|
||||
|
||||
<Grid>
|
||||
<Grid table-title="自动回复列表">
|
||||
<!-- 第一层:公众号选择(在表单中) -->
|
||||
<!-- 第二层:tab 切换 -->
|
||||
<template #toolbar-actions>
|
||||
<!-- tab 切换 -->
|
||||
<Tabs v-model:active-key="msgType" class="w-full" @change="onTabChange">
|
||||
<!-- tab 项 -->
|
||||
<Tabs
|
||||
v-model:active-key="msgType"
|
||||
class="w-full"
|
||||
@change="(activeKey) => onTabChange(activeKey as string)"
|
||||
>
|
||||
<Tabs.TabPane :key="String(MsgType.Follow)">
|
||||
<template #tab>
|
||||
<Row align="middle">
|
||||
<IconifyIcon icon="lucide:star" class="mr-2px" /> 关注时回复
|
||||
<IconifyIcon icon="ep:star" class="mr-2px" /> 关注时回复
|
||||
</Row>
|
||||
</template>
|
||||
</Tabs.TabPane>
|
||||
<Tabs.TabPane :key="String(MsgType.Message)">
|
||||
<template #tab>
|
||||
<Row align="middle">
|
||||
<IconifyIcon icon="lucide:message-circle" class="mr-2px" />
|
||||
<IconifyIcon icon="ep:chat-line-round" class="mr-2px" />
|
||||
消息回复
|
||||
</Row>
|
||||
</template>
|
||||
@@ -205,13 +172,13 @@ onMounted(async () => {
|
||||
<Tabs.TabPane :key="String(MsgType.Keyword)">
|
||||
<template #tab>
|
||||
<Row align="middle">
|
||||
<IconifyIcon icon="lucide:newspaper" class="mr-2px" />
|
||||
关键词回复
|
||||
<IconifyIcon icon="fa:newspaper-o" class="mr-2px" /> 关键词回复
|
||||
</Row>
|
||||
</template>
|
||||
</Tabs.TabPane>
|
||||
</Tabs>
|
||||
</template>
|
||||
<!-- 第三层:table -->
|
||||
<template #toolbar-tools>
|
||||
<TableAction
|
||||
v-if="showCreateButton"
|
||||
|
||||
@@ -5,7 +5,7 @@ import {
|
||||
WxVideoPlayer,
|
||||
WxVoicePlayer,
|
||||
} from '#/views/mp/components';
|
||||
// TODO @hw:迁移到 /Users/yunai/Java/yudao-ui-admin-vben-v5/apps/web-antd/src/views/mp/autoReply/modules 里;组件名可能要换一个,= = 之前写的不太好;类似 content.vue ?本质是内容~
|
||||
|
||||
defineOptions({ name: 'ReplyContentCell' });
|
||||
|
||||
const props = defineProps<{
|
||||
@@ -1,56 +1,84 @@
|
||||
<script lang="ts" setup>
|
||||
import type { Reply } from '#/views/mp/components';
|
||||
|
||||
import { computed, ref } from 'vue';
|
||||
import { computed, nextTick, ref } from 'vue';
|
||||
|
||||
import { useVbenModal } from '@vben/common-ui';
|
||||
|
||||
import { message } from 'ant-design-vue';
|
||||
|
||||
import { useVbenForm } from '#/adapter/form';
|
||||
import { createAutoReply, updateAutoReply } from '#/api/mp/autoReply';
|
||||
import { $t } from '#/locales';
|
||||
import { ReplyType } from '#/views/mp/components';
|
||||
import { ReplyType } from '#/views/mp/components/constants';
|
||||
|
||||
import ReplyForm from '../components/ReplyForm.vue';
|
||||
import { MsgType } from '../components/types';
|
||||
import { useFormSchema } from '../data';
|
||||
import { MsgType } from '../types';
|
||||
|
||||
const emit = defineEmits(['success']);
|
||||
|
||||
const formRef = ref<InstanceType<typeof ReplyForm> | null>(null);
|
||||
|
||||
const formData = ref<{ isCreating: boolean; msgType: MsgType; row?: any }>();
|
||||
const replyForm = ref<any>({});
|
||||
const reply = ref<Reply>({
|
||||
type: ReplyType.Text,
|
||||
accountId: -1,
|
||||
});
|
||||
const formData = ref<{
|
||||
accountId?: number;
|
||||
msgType: MsgType;
|
||||
row?: any;
|
||||
}>();
|
||||
const getTitle = computed(() => {
|
||||
return formData.value?.isCreating
|
||||
? $t('ui.actionTitle.create', ['自动回复'])
|
||||
: $t('ui.actionTitle.edit', ['自动回复']);
|
||||
return formData.value?.row?.id
|
||||
? $t('ui.actionTitle.edit', ['自动回复'])
|
||||
: $t('ui.actionTitle.create', ['自动回复']);
|
||||
});
|
||||
|
||||
const [Form, formApi] = useVbenForm({
|
||||
commonConfig: {
|
||||
componentProps: {
|
||||
class: 'w-full',
|
||||
},
|
||||
formItemClass: 'col-span-2',
|
||||
labelWidth: 100,
|
||||
},
|
||||
layout: 'horizontal',
|
||||
schema: useFormSchema(MsgType.Keyword),
|
||||
showDefaultActions: false,
|
||||
});
|
||||
|
||||
// 注意:schema 的更新现在在 onOpenChange 中手动处理,避免时序问题
|
||||
|
||||
const [Modal, modalApi] = useVbenModal({
|
||||
async onConfirm() {
|
||||
await formRef.value?.validate();
|
||||
const { valid } = await formApi.validate();
|
||||
if (!valid) {
|
||||
return;
|
||||
}
|
||||
|
||||
// 处理回复消息
|
||||
const submitForm: any = { ...replyForm.value };
|
||||
submitForm.responseMessageType = reply.value.type;
|
||||
submitForm.responseContent = reply.value.content;
|
||||
submitForm.responseMediaId = reply.value.mediaId;
|
||||
submitForm.responseMediaUrl = reply.value.url;
|
||||
submitForm.responseTitle = reply.value.title;
|
||||
submitForm.responseDescription = reply.value.description;
|
||||
submitForm.responseThumbMediaId = reply.value.thumbMediaId;
|
||||
submitForm.responseThumbMediaUrl = reply.value.thumbMediaUrl;
|
||||
submitForm.responseArticles = reply.value.articles;
|
||||
submitForm.responseMusicUrl = reply.value.musicUrl;
|
||||
submitForm.responseHqMusicUrl = reply.value.hqMusicUrl;
|
||||
const submitForm: any = await formApi.getValues();
|
||||
// 确保 type 字段使用当前选中的 tab 值
|
||||
submitForm.type = formData.value?.msgType;
|
||||
// 确保 accountId 字段存在
|
||||
submitForm.accountId = formData.value?.accountId;
|
||||
// 编辑模式下,确保 id 字段存在(从 row 中获取,因为表单 schema 中没有 id 字段)
|
||||
if (formData.value?.row?.id && !submitForm.id) {
|
||||
submitForm.id = formData.value.row.id;
|
||||
}
|
||||
const reply = submitForm.reply as Reply;
|
||||
if (reply) {
|
||||
submitForm.responseMessageType = reply.type;
|
||||
submitForm.responseContent = reply.content;
|
||||
submitForm.responseMediaId = reply.mediaId;
|
||||
submitForm.responseMediaUrl = reply.url;
|
||||
submitForm.responseTitle = reply.title;
|
||||
submitForm.responseDescription = reply.description;
|
||||
submitForm.responseThumbMediaId = reply.thumbMediaId;
|
||||
submitForm.responseThumbMediaUrl = reply.thumbMediaUrl;
|
||||
submitForm.responseArticles = reply.articles;
|
||||
submitForm.responseMusicUrl = reply.musicUrl;
|
||||
submitForm.responseHqMusicUrl = reply.hqMusicUrl;
|
||||
}
|
||||
delete submitForm.reply;
|
||||
|
||||
modalApi.lock();
|
||||
try {
|
||||
if (replyForm.value.id === undefined) {
|
||||
if (submitForm.id === undefined) {
|
||||
await createAutoReply(submitForm);
|
||||
message.success('新增成功');
|
||||
} else {
|
||||
@@ -66,50 +94,34 @@ const [Modal, modalApi] = useVbenModal({
|
||||
async onOpenChange(isOpen: boolean) {
|
||||
if (!isOpen) {
|
||||
formData.value = undefined;
|
||||
replyForm.value = {};
|
||||
reply.value = {
|
||||
type: ReplyType.Text,
|
||||
accountId: -1,
|
||||
};
|
||||
return;
|
||||
}
|
||||
// 加载数据
|
||||
const data = modalApi.getData<{
|
||||
accountId?: number;
|
||||
isCreating: boolean;
|
||||
msgType: MsgType;
|
||||
row?: any;
|
||||
}>();
|
||||
if (!data) {
|
||||
return;
|
||||
}
|
||||
formData.value = data;
|
||||
// 先更新 schema,确保表单字段正确
|
||||
formApi.setState({ schema: useFormSchema(data.msgType) });
|
||||
// 等待 schema 更新完成
|
||||
await nextTick();
|
||||
|
||||
if (data.isCreating) {
|
||||
// 新建:初始化表单
|
||||
replyForm.value = {
|
||||
id: undefined,
|
||||
accountId: data.accountId || -1,
|
||||
type: data.msgType,
|
||||
requestKeyword: undefined,
|
||||
requestMatch: data.msgType === MsgType.Keyword ? 1 : undefined,
|
||||
requestMessageType: undefined,
|
||||
};
|
||||
reply.value = {
|
||||
type: ReplyType.Text,
|
||||
accountId: data.accountId || -1,
|
||||
};
|
||||
} else if (data.row) {
|
||||
formData.value = data;
|
||||
if (data.row?.id) {
|
||||
// 编辑:加载数据
|
||||
const rowData = data.row;
|
||||
replyForm.value = { ...rowData };
|
||||
delete replyForm.value.responseMessageType;
|
||||
delete replyForm.value.responseContent;
|
||||
delete replyForm.value.responseMediaId;
|
||||
delete replyForm.value.responseMediaUrl;
|
||||
delete replyForm.value.responseDescription;
|
||||
delete replyForm.value.responseArticles;
|
||||
reply.value = {
|
||||
const formValues: any = { ...rowData };
|
||||
// delete formValues.responseMessageType;
|
||||
// delete formValues.responseContent;
|
||||
// delete formValues.responseMediaId;
|
||||
// delete formValues.responseMediaUrl;
|
||||
// delete formValues.responseDescription;
|
||||
// delete formValues.responseArticles;
|
||||
formValues.reply = {
|
||||
type: rowData.responseMessageType,
|
||||
accountId: data.accountId || -1,
|
||||
content: rowData.responseContent,
|
||||
@@ -123,20 +135,29 @@ const [Modal, modalApi] = useVbenModal({
|
||||
musicUrl: rowData.responseMusicUrl,
|
||||
hqMusicUrl: rowData.responseHqMusicUrl,
|
||||
};
|
||||
await formApi.setValues(formValues);
|
||||
} else {
|
||||
// 新建:初始化表单
|
||||
const initialValues: any = {
|
||||
id: undefined,
|
||||
accountId: data.accountId || -1,
|
||||
type: data.msgType,
|
||||
requestKeyword: undefined,
|
||||
requestMatch: data.msgType === MsgType.Keyword ? 1 : undefined,
|
||||
requestMessageType: undefined,
|
||||
reply: {
|
||||
type: ReplyType.Text,
|
||||
accountId: data.accountId || -1,
|
||||
},
|
||||
};
|
||||
await formApi.setValues(initialValues);
|
||||
}
|
||||
},
|
||||
});
|
||||
</script>
|
||||
|
||||
<template>
|
||||
<!-- TODO @hw:可以使用 <Form class="mx-4" /> 这种组件形式么? -->
|
||||
<Modal :title="getTitle" class="w-4/5">
|
||||
<ReplyForm
|
||||
v-if="formData"
|
||||
v-model="replyForm"
|
||||
v-model:reply="reply"
|
||||
:msg-type="formData.msgType"
|
||||
ref="formRef"
|
||||
/>
|
||||
<Form class="mx-4" />
|
||||
</Modal>
|
||||
</template>
|
||||
|
||||
@@ -35,17 +35,41 @@ const emit = defineEmits<{
|
||||
}>();
|
||||
|
||||
interface Props {
|
||||
modelValue: Reply;
|
||||
modelValue: Reply | undefined;
|
||||
newsType?: NewsType;
|
||||
}
|
||||
|
||||
// 提供一个默认的 Reply 对象,避免 undefined 导致的错误
|
||||
const defaultReply: Reply = {
|
||||
accountId: -1,
|
||||
type: ReplyType.Text,
|
||||
};
|
||||
|
||||
const reply = computed<Reply>({
|
||||
get: () => props.modelValue,
|
||||
get: () => props.modelValue || defaultReply,
|
||||
set: (val) => emit('update:modelValue', val),
|
||||
});
|
||||
|
||||
const tabCache = new Map<ReplyType, Reply>(); // 作为多个标签保存各自 Reply 的缓存
|
||||
const currentTab = ref<ReplyType>(props.modelValue.type || ReplyType.Text); // 采用独立的 ref 来保存当前 tab,避免在 watch 标签变化,对 reply 进行赋值会产生了循环调用
|
||||
const currentTab = ref<ReplyType>(props.modelValue?.type || ReplyType.Text); // 采用独立的 ref 来保存当前 tab,避免在 watch 标签变化,对 reply 进行赋值会产生了循环调用
|
||||
|
||||
// 监听 modelValue 变化,同步更新 currentTab 和缓存
|
||||
watch(
|
||||
() => props.modelValue,
|
||||
(newValue) => {
|
||||
if (newValue?.type) {
|
||||
// 如果类型变化,更新 currentTab
|
||||
if (newValue.type !== currentTab.value) {
|
||||
currentTab.value = newValue.type;
|
||||
}
|
||||
// 如果 modelValue 有数据,更新对应 tab 的缓存
|
||||
if (newValue.type) {
|
||||
tabCache.set(newValue.type, { ...newValue });
|
||||
}
|
||||
}
|
||||
},
|
||||
{ immediate: true, deep: true },
|
||||
);
|
||||
|
||||
watch(
|
||||
currentTab,
|
||||
@@ -56,16 +80,30 @@ watch(
|
||||
return;
|
||||
}
|
||||
|
||||
tabCache.set(oldTab, unref(reply));
|
||||
// 保存旧tab的数据到缓存
|
||||
const oldReply = unref(reply);
|
||||
// 只有当旧tab的reply有实际数据时才缓存(避免缓存空数据)
|
||||
if (oldReply && oldTab === oldReply.type) {
|
||||
tabCache.set(oldTab, oldReply);
|
||||
}
|
||||
|
||||
// 从缓存里面取出新tab内容,有则覆盖Reply,没有则创建空Reply
|
||||
const temp = tabCache.get(newTab);
|
||||
if (temp) {
|
||||
reply.value = temp;
|
||||
} else {
|
||||
const newData = createEmptyReply(reply);
|
||||
newData.type = newTab;
|
||||
reply.value = newData;
|
||||
// 如果当前reply的类型就是新tab的类型,说明这是从外部传入的数据,应该保留
|
||||
const currentReply = unref(reply);
|
||||
if (currentReply && currentReply.type === newTab) {
|
||||
// 这是从外部传入的数据,直接缓存并使用
|
||||
tabCache.set(newTab, currentReply);
|
||||
// 不需要修改reply.value,因为它已经是正确的了
|
||||
} else {
|
||||
// 创建新的空reply
|
||||
const newData = createEmptyReply(reply);
|
||||
newData.type = newTab;
|
||||
reply.value = newData;
|
||||
}
|
||||
}
|
||||
},
|
||||
{
|
||||
|
||||
@@ -1,9 +1,12 @@
|
||||
import type { VbenFormSchema } from '#/adapter/form';
|
||||
import type { VxeTableGridOptions } from '#/adapter/vxe-table';
|
||||
import type { MpAccountApi } from '#/api/mp/account';
|
||||
|
||||
import { markRaw } from 'vue';
|
||||
import { getSimpleAccountList } from '#/api/mp/account';
|
||||
|
||||
import { WxAccountSelect } from '#/views/mp/components';
|
||||
/** 关联数据 */
|
||||
let accountList: MpAccountApi.AccountSimple[] = [];
|
||||
getSimpleAccountList().then((data) => (accountList = data));
|
||||
|
||||
/** 获取表格列配置 */
|
||||
export function useGridColumns(): VxeTableGridOptions['columns'] {
|
||||
@@ -14,12 +17,6 @@ export function useGridColumns(): VxeTableGridOptions['columns'] {
|
||||
minWidth: 300,
|
||||
slots: { default: 'content' },
|
||||
},
|
||||
{
|
||||
field: 'updateTime',
|
||||
title: '更新时间',
|
||||
minWidth: 180,
|
||||
formatter: 'formatDateTime',
|
||||
},
|
||||
{
|
||||
title: '操作',
|
||||
width: 200,
|
||||
@@ -30,13 +27,21 @@ export function useGridColumns(): VxeTableGridOptions['columns'] {
|
||||
}
|
||||
|
||||
/** 列表的搜索表单 */
|
||||
// TODO @hw:这里的公众号选择,要改参考 /Users/yunai/Java/yudao-ui-admin-vben-v5/apps/web-antd/src/views/mp/tag/data.ts;相关联的代码还简单点~
|
||||
// DONE @hw:这里的公众号选择,要改参考 /apps/web-antd/src/views/mp/tag/data.ts;相关联的代码还简单点~
|
||||
export function useGridFormSchema(): VbenFormSchema[] {
|
||||
return [
|
||||
{
|
||||
fieldName: 'accountId',
|
||||
label: '公众号',
|
||||
component: markRaw(WxAccountSelect),
|
||||
component: 'ApiSelect',
|
||||
componentProps: {
|
||||
options: accountList.map((item) => ({
|
||||
label: item.name,
|
||||
value: item.id,
|
||||
})),
|
||||
placeholder: '请选择公众号',
|
||||
},
|
||||
defaultValue: accountList[0]?.id,
|
||||
},
|
||||
];
|
||||
}
|
||||
|
||||
@@ -1,10 +1,8 @@
|
||||
<script lang="ts" setup>
|
||||
import type { Article } from './components/types';
|
||||
import type { Article } from './modules/types';
|
||||
|
||||
import type { VxeTableGridOptions } from '#/adapter/vxe-table';
|
||||
|
||||
import { nextTick, onMounted, provide, ref, watch } from 'vue';
|
||||
|
||||
import { confirm, DocAlert, Page, useVbenModal } from '@vben/common-ui';
|
||||
import { $t } from '@vben/locales';
|
||||
|
||||
@@ -12,13 +10,16 @@ import { message } from 'ant-design-vue';
|
||||
|
||||
import { ACTION_ICON, TableAction, useVbenVxeGrid } from '#/adapter/vxe-table';
|
||||
import { deleteDraft, getDraftPage } from '#/api/mp/draft';
|
||||
// DONE @hw:MpFreePublishApi 去掉,直接 import;参考别的模块哈;
|
||||
import { submitFreePublish } from '#/api/mp/freePublish';
|
||||
import { createEmptyNewsItem } from '#/views/mp/draft/components/types';
|
||||
import { createEmptyNewsItem } from '#/views/mp/draft/modules/types';
|
||||
|
||||
import DraftTableCell from './components/draft-table.vue';
|
||||
import { useGridColumns, useGridFormSchema } from './data';
|
||||
import DraftTableCell from './modules/draft-table.vue';
|
||||
import Form from './modules/form.vue';
|
||||
|
||||
// DONE @hw:参考 tag/index.vue 放到 formValues.accountId;
|
||||
// DONE @hw:看看这个 watch、provide 能不能简化掉;
|
||||
defineOptions({ name: 'MpDraft' });
|
||||
|
||||
/** 刷新表格 */
|
||||
@@ -31,120 +32,11 @@ const [FormModal, formModalApi] = useVbenModal({
|
||||
destroyOnClose: true,
|
||||
});
|
||||
|
||||
// TODO @hw:下面的方法,放到这个前面,和别的保持一致;
|
||||
const [Grid, gridApi] = useVbenVxeGrid({
|
||||
formOptions: {
|
||||
schema: useGridFormSchema(),
|
||||
submitOnChange: true,
|
||||
},
|
||||
gridOptions: {
|
||||
columns: useGridColumns(),
|
||||
height: 'auto',
|
||||
keepSource: true,
|
||||
proxyConfig: {
|
||||
ajax: {
|
||||
query: async ({ page }, formValues) => {
|
||||
// 更新 accountId
|
||||
if (formValues?.accountId) {
|
||||
accountId.value = formValues.accountId;
|
||||
}
|
||||
const drafts = await getDraftPage({
|
||||
pageNo: page.currentPage,
|
||||
pageSize: page.pageSize,
|
||||
...formValues,
|
||||
});
|
||||
// 处理 API 返回的数据,兼容不同的数据结构
|
||||
// TODO @wx:看 yudao-ui-admin-vue3/src/views/mp/draft/index.vue 项目里,转换没这么复杂。。。是不是这里有办法简化下?
|
||||
const formattedList: Article[] = drafts.list.map((draft: any) => {
|
||||
// 如果已经是 content.newsItem 格式,直接使用
|
||||
if (draft.content?.newsItem) {
|
||||
const newsItem = draft.content.newsItem.map((item: any) => ({
|
||||
...item,
|
||||
picUrl: item.thumbUrl || item.picUrl,
|
||||
}));
|
||||
return {
|
||||
mediaId: draft.mediaId,
|
||||
content: {
|
||||
newsItem,
|
||||
},
|
||||
updateTime:
|
||||
draft.updateTime ||
|
||||
(draft.createTime
|
||||
? new Date(draft.createTime).getTime()
|
||||
: Date.now()),
|
||||
};
|
||||
}
|
||||
// 如果是 articles 格式,转换为 content.newsItem 格式
|
||||
if (draft.articles) {
|
||||
const newsItem = draft.articles.map((article: any) => ({
|
||||
...article,
|
||||
thumbUrl: article.thumbUrl || article.thumbMediaId,
|
||||
picUrl: article.thumbUrl || article.thumbMediaId,
|
||||
}));
|
||||
return {
|
||||
mediaId: draft.mediaId,
|
||||
content: {
|
||||
newsItem,
|
||||
},
|
||||
updateTime:
|
||||
draft.updateTime ||
|
||||
(draft.createTime
|
||||
? new Date(draft.createTime).getTime()
|
||||
: Date.now()),
|
||||
};
|
||||
}
|
||||
// 默认返回空结构
|
||||
return {
|
||||
mediaId: draft.mediaId || '',
|
||||
content: {
|
||||
newsItem: [],
|
||||
},
|
||||
updateTime: draft.updateTime || Date.now(),
|
||||
};
|
||||
});
|
||||
return {
|
||||
page: {
|
||||
total: drafts.total,
|
||||
},
|
||||
result: formattedList,
|
||||
};
|
||||
},
|
||||
},
|
||||
autoLoad: false,
|
||||
},
|
||||
rowConfig: {
|
||||
keyField: 'mediaId',
|
||||
isHover: true,
|
||||
},
|
||||
toolbarConfig: {
|
||||
refresh: true,
|
||||
search: true,
|
||||
},
|
||||
} as VxeTableGridOptions<Article>,
|
||||
});
|
||||
|
||||
// 提供 accountId 给子组件
|
||||
// TODO @hw:参考 tag/index.vue 放到 formValues.accountId;
|
||||
const accountId = ref<number>(-1);
|
||||
|
||||
// 监听表单提交,更新 accountId
|
||||
// TODO @hw:看看这个 watch、provide 能不能简化掉;
|
||||
watch(
|
||||
() => gridApi.formApi?.getLatestSubmissionValues?.()?.accountId,
|
||||
(newAccountId) => {
|
||||
if (newAccountId !== undefined) {
|
||||
accountId.value = newAccountId;
|
||||
}
|
||||
},
|
||||
);
|
||||
|
||||
provide('accountId', accountId);
|
||||
|
||||
/** 新增按钮操作 */
|
||||
async function handleCreate() {
|
||||
const formValues = await gridApi.formApi.getValues();
|
||||
const accountId = formValues.accountId;
|
||||
if (!accountId || accountId === -1) {
|
||||
if (!accountId) {
|
||||
message.warning('请先选择公众号');
|
||||
return;
|
||||
}
|
||||
@@ -161,7 +53,7 @@ async function handleCreate() {
|
||||
async function handleEdit(row: Article) {
|
||||
const formValues = await gridApi.formApi.getValues();
|
||||
const accountId = formValues.accountId;
|
||||
if (!accountId || accountId === -1) {
|
||||
if (!accountId) {
|
||||
message.warning('请先选择公众号');
|
||||
return;
|
||||
}
|
||||
@@ -170,7 +62,7 @@ async function handleEdit(row: Article) {
|
||||
isCreating: false,
|
||||
accountId,
|
||||
mediaId: row.mediaId,
|
||||
newsList: structuredClone(row.content.newsItem),
|
||||
newsList: row.content.newsItem,
|
||||
})
|
||||
.open();
|
||||
}
|
||||
@@ -179,8 +71,8 @@ async function handleEdit(row: Article) {
|
||||
async function handlePublish(row: Article) {
|
||||
const formValues = await gridApi.formApi.getValues();
|
||||
const accountId = formValues.accountId;
|
||||
// TODO @hw:看看能不能去掉 -1 的判断哈?
|
||||
if (!accountId || accountId === -1) {
|
||||
// DONE @hw:看看能不能去掉 -1 的判断哈?
|
||||
if (!accountId) {
|
||||
message.warning('请先选择公众号');
|
||||
return;
|
||||
}
|
||||
@@ -193,11 +85,10 @@ async function handlePublish(row: Article) {
|
||||
content: '发布中...',
|
||||
duration: 0,
|
||||
});
|
||||
// TODO @hw:MpFreePublishApi 去掉,直接 import;参考别的模块哈;
|
||||
try {
|
||||
await submitFreePublish(accountId, row.mediaId);
|
||||
message.success('发布成功');
|
||||
await gridApi.query();
|
||||
handleRefresh();
|
||||
} finally {
|
||||
hideLoading();
|
||||
}
|
||||
@@ -207,7 +98,7 @@ async function handlePublish(row: Article) {
|
||||
async function handleDelete(row: Article) {
|
||||
const formValues = await gridApi.formApi.getValues();
|
||||
const accountId = formValues.accountId;
|
||||
if (!accountId || accountId === -1) {
|
||||
if (!accountId) {
|
||||
message.warning('请先选择公众号');
|
||||
return;
|
||||
}
|
||||
@@ -219,25 +110,57 @@ async function handleDelete(row: Article) {
|
||||
try {
|
||||
await deleteDraft(accountId, row.mediaId);
|
||||
message.success('删除成功');
|
||||
await gridApi.query();
|
||||
handleRefresh();
|
||||
} finally {
|
||||
hideLoading();
|
||||
}
|
||||
}
|
||||
|
||||
// TODO @hw:看看能不能参考 tag/index.vue 简化下
|
||||
// 页面挂载后,等待表单初始化完成再加载数据
|
||||
onMounted(async () => {
|
||||
await nextTick();
|
||||
if (gridApi.formApi) {
|
||||
const formValues = await gridApi.formApi.getValues();
|
||||
if (formValues.accountId) {
|
||||
accountId.value = formValues.accountId;
|
||||
gridApi.formApi.setLatestSubmissionValues(formValues);
|
||||
await gridApi.query();
|
||||
}
|
||||
}
|
||||
const [Grid, gridApi] = useVbenVxeGrid({
|
||||
formOptions: {
|
||||
schema: useGridFormSchema(),
|
||||
submitOnChange: true,
|
||||
},
|
||||
gridOptions: {
|
||||
columns: useGridColumns(),
|
||||
height: 'auto',
|
||||
keepSource: true,
|
||||
proxyConfig: {
|
||||
ajax: {
|
||||
query: async ({ page }, formValues) => {
|
||||
const drafts = await getDraftPage({
|
||||
pageNo: page.currentPage,
|
||||
pageSize: page.pageSize,
|
||||
...formValues,
|
||||
});
|
||||
// 将 thumbUrl 转成 picUrl,保证 wx-news 组件可以预览封面
|
||||
drafts.list.forEach((draft: any) => {
|
||||
const newsList = draft.content?.newsItem;
|
||||
if (newsList) {
|
||||
newsList.forEach((item: any) => {
|
||||
item.picUrl = item.thumbUrl || item.picUrl;
|
||||
});
|
||||
}
|
||||
});
|
||||
return {
|
||||
list: drafts.list as unknown as Article[],
|
||||
total: drafts.total,
|
||||
};
|
||||
},
|
||||
},
|
||||
},
|
||||
rowConfig: {
|
||||
keyField: 'mediaId',
|
||||
isHover: true,
|
||||
},
|
||||
toolbarConfig: {
|
||||
refresh: true,
|
||||
search: true,
|
||||
},
|
||||
} as VxeTableGridOptions<Article>,
|
||||
});
|
||||
|
||||
// DONE @hw:看看能不能参考 tag/index.vue 简化下
|
||||
</script>
|
||||
|
||||
<template>
|
||||
@@ -305,7 +228,12 @@ onMounted(async () => {
|
||||
.vxe-table--body {
|
||||
.vxe-body--column {
|
||||
.vxe-cell {
|
||||
height: auto !important;
|
||||
padding: 0;
|
||||
|
||||
img {
|
||||
width: 300px !important;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -11,7 +11,6 @@ import { useAccessStore } from '@vben/stores';
|
||||
import { Button, Image, message, Modal, Upload } from 'ant-design-vue';
|
||||
|
||||
import { UploadType, useBeforeUpload } from '#/utils/useUpload';
|
||||
import { WxMaterialSelect } from '#/views/mp/components';
|
||||
|
||||
const props = defineProps<{
|
||||
isFirst: boolean;
|
||||
@@ -33,8 +32,9 @@ const newsItem = computed<NewsItem>({
|
||||
},
|
||||
});
|
||||
|
||||
const dialogVisible = ref(false);
|
||||
|
||||
const accountId = inject<number>('accountId');
|
||||
const showImageDialog = ref(false);
|
||||
|
||||
const fileList = ref<UploadFile[]>([]);
|
||||
interface UploadData {
|
||||
@@ -46,27 +46,31 @@ const uploadData: UploadData = reactive({
|
||||
accountId: accountId!,
|
||||
});
|
||||
|
||||
/** 素材选择完成事件*/
|
||||
function handleOpenDialog() {
|
||||
dialogVisible.value = true;
|
||||
}
|
||||
|
||||
/** 素材选择完成事件 */
|
||||
function onMaterialSelected(item: any) {
|
||||
showImageDialog.value = false;
|
||||
dialogVisible.value = false;
|
||||
newsItem.value.thumbMediaId = item.mediaId;
|
||||
newsItem.value.thumbUrl = item.url;
|
||||
}
|
||||
// TODO @hw:注释都补充下哈;
|
||||
function onBeforeUpload(file: UploadFile) {
|
||||
return useBeforeUpload(UploadType.Image, 2)(file as any);
|
||||
}
|
||||
// DONE @hw:注释都补充下哈;
|
||||
/** 上传前校验 */
|
||||
const onBeforeUpload = (file: UploadFile) =>
|
||||
useBeforeUpload(UploadType.Image, 2)(file as any);
|
||||
|
||||
// TODO @hw:注释都补充下哈;
|
||||
// DONE @hw:注释都补充下哈;
|
||||
/** 上传错误处理 */
|
||||
function onUploadChange(info: any) {
|
||||
if (info.file.status === 'done') {
|
||||
onUploadSuccess(info.file.response || info.file);
|
||||
} else if (info.file.status === 'error') {
|
||||
if (info.file.status === 'error') {
|
||||
onUploadError(info.file.error || new Error('上传失败'));
|
||||
}
|
||||
}
|
||||
|
||||
// TODO @hw:注释都补充下哈;
|
||||
// DONE @hw:注释都补充下哈;
|
||||
/** 上传成功处理 */
|
||||
function onUploadSuccess(res: any) {
|
||||
if (res.code !== 0) {
|
||||
message.error(`上传出错:${res.msg}`);
|
||||
@@ -80,7 +84,8 @@ function onUploadSuccess(res: any) {
|
||||
newsItem.value.thumbUrl = res.data.url;
|
||||
}
|
||||
|
||||
// TODO @hw:注释都补充下哈;
|
||||
// DONE @hw:注释都补充下哈;
|
||||
/** 上传失败处理 */
|
||||
function onUploadError(err: Error) {
|
||||
message.error(`上传失败: ${err.message}`);
|
||||
}
|
||||
@@ -89,21 +94,22 @@ function onUploadError(err: Error) {
|
||||
<template>
|
||||
<div>
|
||||
<p>封面:</p>
|
||||
<!-- TODO @hw:我貌似上传不成功。不确定是不是我这边的问题;;;可以微信沟通下哈。 -->
|
||||
<div class="thumb-div">
|
||||
<!-- DONE @hw:我貌似上传不成功。不确定是不是我这边的问题;;;可以微信沟通下哈。 -->
|
||||
<!-- DONE @hw:尽量使用 tindwind 替代。ps:如果多个组件复用,那就不用调整 -->
|
||||
<div class="flex w-full flex-col items-center justify-center text-center">
|
||||
<Image
|
||||
v-if="newsItem.thumbUrl"
|
||||
style="width: 300px; max-height: 300px"
|
||||
class="max-h-[300px] w-[300px]"
|
||||
:src="newsItem.thumbUrl"
|
||||
:preview="false"
|
||||
/>
|
||||
<IconifyIcon
|
||||
v-else
|
||||
icon="lucide:plus"
|
||||
class="avatar-uploader-icon"
|
||||
:class="isFirst ? 'avatar' : 'avatar1'"
|
||||
class="border border-[#d9d9d9] text-center text-[28px] leading-[120px] text-[#8c939d]"
|
||||
:class="isFirst ? 'h-[120px] w-[230px]' : 'h-[120px] w-[120px]'"
|
||||
/>
|
||||
<div class="thumb-but">
|
||||
<div class="m-[5px]">
|
||||
<div class="flex items-center justify-center">
|
||||
<Upload
|
||||
:action="UPLOAD_URL"
|
||||
@@ -111,35 +117,35 @@ function onUploadError(err: Error) {
|
||||
:file-list="fileList"
|
||||
:data="{ ...uploadData }"
|
||||
:before-upload="onBeforeUpload"
|
||||
@success="onUploadSuccess"
|
||||
@change="onUploadChange"
|
||||
>
|
||||
<template #default>
|
||||
<Button size="small" type="primary">本地上传</Button>
|
||||
</template>
|
||||
</Upload>
|
||||
<!-- TODO @hw:tindwind -->
|
||||
<Button
|
||||
size="small"
|
||||
type="primary"
|
||||
@click="showImageDialog = true"
|
||||
style="margin-left: 5px"
|
||||
class="ml-[5px]"
|
||||
@click="handleOpenDialog"
|
||||
>
|
||||
素材库选择
|
||||
</Button>
|
||||
</div>
|
||||
|
||||
<div class="upload-tip">
|
||||
<div class="ml-[5px] mt-[5px] text-xs text-[#999]">
|
||||
支持 bmp/png/jpeg/jpg/gif 格式,大小不超过 2M
|
||||
</div>
|
||||
</div>
|
||||
<!-- TODO @hw:是不是使用 vben 自带的 Modal 哈;这样 ele 通用性更好点。其它模块,涉及到 Modal 也按照这个调整噢 -->
|
||||
<!-- DONE @hw:是不是使用 vben 自带的 Modal 哈;这样 ele 通用性更好点。其它模块,涉及到 Modal 也按照这个调整噢 -->
|
||||
<Modal
|
||||
title="选择图片"
|
||||
v-model:open="showImageDialog"
|
||||
width="80%"
|
||||
destroy-on-close
|
||||
v-model:open="dialogVisible"
|
||||
title="图片选择"
|
||||
width="65%"
|
||||
:footer="null"
|
||||
>
|
||||
<WxMaterialSelect
|
||||
<MaterialSelect
|
||||
type="image"
|
||||
:account-id="accountId!"
|
||||
@select-material="onMaterialSelected"
|
||||
@@ -148,47 +154,3 @@ function onUploadError(err: Error) {
|
||||
</div>
|
||||
</div>
|
||||
</template>
|
||||
|
||||
<style lang="scss" scoped>
|
||||
/** TODO @hw:尽量使用 tindwind 替代。ps:如果多个组件复用,那就不用调整 */
|
||||
.upload-tip {
|
||||
margin-top: 5px;
|
||||
margin-left: 5px;
|
||||
font-size: 12px;
|
||||
color: #999;
|
||||
}
|
||||
|
||||
.thumb-div {
|
||||
display: inline-block;
|
||||
display: flex;
|
||||
flex-direction: column;
|
||||
align-items: center;
|
||||
justify-content: center;
|
||||
width: 100%;
|
||||
text-align: center;
|
||||
|
||||
.avatar-uploader-icon {
|
||||
width: 120px;
|
||||
height: 120px;
|
||||
font-size: 28px;
|
||||
line-height: 120px;
|
||||
color: #8c939d;
|
||||
text-align: center;
|
||||
border: 1px solid #d9d9d9;
|
||||
}
|
||||
|
||||
.avatar {
|
||||
width: 230px;
|
||||
height: 120px;
|
||||
}
|
||||
|
||||
.avatar1 {
|
||||
width: 120px;
|
||||
height: 120px;
|
||||
}
|
||||
|
||||
.thumb-but {
|
||||
margin: 5px;
|
||||
}
|
||||
}
|
||||
</style>
|
||||
@@ -1,35 +1,38 @@
|
||||
<script lang="ts" setup>
|
||||
import type { NewsItem } from '../components/types';
|
||||
import type { NewsItem } from './types';
|
||||
|
||||
import { computed, ref } from 'vue';
|
||||
import { computed, provide, ref } from 'vue';
|
||||
|
||||
import { confirm, useVbenModal } from '@vben/common-ui';
|
||||
import { useVbenModal } from '@vben/common-ui';
|
||||
|
||||
import { message, Spin } from 'ant-design-vue';
|
||||
|
||||
import { createDraft, updateDraft } from '#/api/mp/draft';
|
||||
|
||||
import NewsForm from '../components/news-form.vue';
|
||||
import NewsForm from './news-form.vue';
|
||||
|
||||
const emit = defineEmits(['success']);
|
||||
|
||||
// DONE @hw:是不是通过 id 字段判断是否为新增?类似 /Users/yunai/Java/yudao-ui-admin-vben-v5/apps/web-antd/src/views/system/user/modules/form.vue
|
||||
const formData = ref<{
|
||||
accountId: number;
|
||||
// TODO @hw:是不是通过 id 字段判断是否为新增?类似 /Users/yunai/Java/yudao-ui-admin-vben-v5/apps/web-antd/src/views/system/user/modules/form.vue
|
||||
isCreating: boolean;
|
||||
mediaId?: string;
|
||||
newsList?: NewsItem[];
|
||||
}>();
|
||||
const newsList = ref<NewsItem[]>([]);
|
||||
// TODO @hw:不需要 isSave,通过 modal 去 lock 就好啦。
|
||||
// DONE @hw:不需要 isSave,通过 modal 去 lock 就好啦。
|
||||
const isSubmitting = ref(false);
|
||||
// TODO @hw:不需要 isSave,通过 modal 去 lock 就好啦。
|
||||
const isSaved = ref(false);
|
||||
|
||||
const getTitle = computed(() => {
|
||||
return formData.value?.isCreating ? '新建图文' : '修改图文';
|
||||
return formData.value?.mediaId ? '修改图文' : '新建图文';
|
||||
});
|
||||
|
||||
// 提供 accountId 给子组件
|
||||
provide(
|
||||
'accountId',
|
||||
computed(() => formData.value?.accountId),
|
||||
);
|
||||
|
||||
const [Modal, modalApi] = useVbenModal({
|
||||
async onConfirm() {
|
||||
if (!formData.value) {
|
||||
@@ -39,18 +42,17 @@ const [Modal, modalApi] = useVbenModal({
|
||||
isSubmitting.value = true;
|
||||
modalApi.lock();
|
||||
try {
|
||||
if (formData.value.isCreating) {
|
||||
await createDraft(formData.value.accountId, newsList.value);
|
||||
message.success('新增成功');
|
||||
} else if (formData.value.mediaId) {
|
||||
if (formData.value.mediaId) {
|
||||
await updateDraft(
|
||||
formData.value.accountId,
|
||||
formData.value.mediaId,
|
||||
newsList.value,
|
||||
);
|
||||
message.success('更新成功');
|
||||
} else {
|
||||
await createDraft(formData.value.accountId, newsList.value);
|
||||
message.success('新增成功');
|
||||
}
|
||||
isSaved.value = true;
|
||||
await modalApi.close();
|
||||
emit('success');
|
||||
} finally {
|
||||
@@ -58,26 +60,12 @@ const [Modal, modalApi] = useVbenModal({
|
||||
modalApi.unlock();
|
||||
}
|
||||
},
|
||||
async onBeforeClose() {
|
||||
// 如果已经成功保存,直接关闭,不显示提示
|
||||
if (isSaved.value) {
|
||||
return true;
|
||||
}
|
||||
try {
|
||||
await confirm('修改内容可能还未保存,确定关闭吗?');
|
||||
return true;
|
||||
} catch {
|
||||
return false;
|
||||
}
|
||||
},
|
||||
async onOpenChange(isOpen: boolean) {
|
||||
if (!isOpen) {
|
||||
formData.value = undefined;
|
||||
newsList.value = [];
|
||||
isSaved.value = false;
|
||||
return;
|
||||
}
|
||||
isSaved.value = false;
|
||||
const data = modalApi.getData<{
|
||||
accountId: number;
|
||||
isCreating: boolean;
|
||||
@@ -87,7 +75,11 @@ const [Modal, modalApi] = useVbenModal({
|
||||
if (!data) {
|
||||
return;
|
||||
}
|
||||
formData.value = data;
|
||||
formData.value = {
|
||||
accountId: data.accountId,
|
||||
mediaId: data.mediaId,
|
||||
newsList: data.newsList,
|
||||
};
|
||||
newsList.value = data.newsList || [];
|
||||
},
|
||||
});
|
||||
@@ -99,7 +91,7 @@ const [Modal, modalApi] = useVbenModal({
|
||||
<NewsForm
|
||||
v-if="formData"
|
||||
v-model="newsList"
|
||||
:is-creating="formData.isCreating"
|
||||
:is-creating="!formData.mediaId"
|
||||
/>
|
||||
</Spin>
|
||||
</Modal>
|
||||
|
||||
@@ -44,8 +44,8 @@ const activeNewsItem = computed(() => {
|
||||
return item;
|
||||
});
|
||||
|
||||
// TODO @hw:注释使用 /** */
|
||||
// 将图文向下移动
|
||||
// DONE @hw:注释使用 /** */
|
||||
/** 将图文向下移动 */
|
||||
function moveDownNews(index: number) {
|
||||
const current = newsList.value[index];
|
||||
const next = newsList.value[index + 1];
|
||||
@@ -56,7 +56,7 @@ function moveDownNews(index: number) {
|
||||
}
|
||||
}
|
||||
|
||||
// 将图文向上移动
|
||||
/** 将图文向上移动 */
|
||||
function moveUpNews(index: number) {
|
||||
const current = newsList.value[index];
|
||||
const prev = newsList.value[index - 1];
|
||||
@@ -67,7 +67,7 @@ function moveUpNews(index: number) {
|
||||
}
|
||||
}
|
||||
|
||||
// 删除指定 index 的图文
|
||||
/** 删除指定 index 的图文 */
|
||||
async function removeNews(index: number) {
|
||||
await confirm('确定删除该图文吗?');
|
||||
newsList.value.splice(index, 1);
|
||||
@@ -76,7 +76,7 @@ async function removeNews(index: number) {
|
||||
}
|
||||
}
|
||||
|
||||
// 添加一个图文
|
||||
/** 添加一个图文 */
|
||||
function plusNews() {
|
||||
newsList.value.push(createEmptyNewsItem());
|
||||
activeNewsIndex.value = newsList.value.length - 1;
|
||||
@@ -86,19 +86,29 @@ function plusNews() {
|
||||
<template>
|
||||
<Layout>
|
||||
<Layout.Sider width="40%" theme="light">
|
||||
<div class="select-item">
|
||||
<!-- DONE @hw:尽量使用 tindwind 替代。ps:如果多个组件复用,那就不用调整 -->
|
||||
<div class="mx-auto mb-[10px] w-[60%] border border-[#eaeaea] p-[10px]">
|
||||
<div v-for="(news, index) in newsList" :key="index">
|
||||
<div
|
||||
class="news-main father"
|
||||
class="group relative mx-auto h-[120px] w-full cursor-pointer bg-white"
|
||||
v-if="index === 0"
|
||||
:class="{ activeAddNews: activeNewsIndex === index }"
|
||||
:class="{
|
||||
'border-[5px] border-[#2bb673]': activeNewsIndex === index,
|
||||
}"
|
||||
@click="activeNewsIndex = index"
|
||||
>
|
||||
<div class="news-content">
|
||||
<img class="material-img" :src="news.thumbUrl" />
|
||||
<div class="news-content-title">{{ news.title }}</div>
|
||||
<div class="relative h-[120px] w-full bg-[#acadae]">
|
||||
<img class="h-full w-full" :src="news.thumbUrl" />
|
||||
<div
|
||||
class="absolute bottom-0 left-0 inline-block h-[25px] w-[98%] overflow-hidden text-ellipsis whitespace-nowrap bg-black p-[1%] text-[15px] text-white opacity-65"
|
||||
>
|
||||
{{ news.title }}
|
||||
</div>
|
||||
</div>
|
||||
<div class="child" v-if="newsList.length > 1">
|
||||
<div
|
||||
class="relative -bottom-[25px] hidden text-center group-hover:block"
|
||||
v-if="newsList.length > 1"
|
||||
>
|
||||
<Button
|
||||
type="default"
|
||||
shape="circle"
|
||||
@@ -120,18 +130,22 @@ function plusNews() {
|
||||
</div>
|
||||
</div>
|
||||
<div
|
||||
class="news-main-item father"
|
||||
class="group relative mx-auto w-full cursor-pointer border-t border-[#eaeaea] bg-white py-[5px]"
|
||||
v-if="index > 0"
|
||||
:class="{ activeAddNews: activeNewsIndex === index }"
|
||||
:class="{
|
||||
'border-[5px] border-[#2bb673]': activeNewsIndex === index,
|
||||
}"
|
||||
@click="activeNewsIndex = index"
|
||||
>
|
||||
<div class="news-content-item">
|
||||
<div class="news-content-item-title">{{ news.title }}</div>
|
||||
<div class="news-content-item-img">
|
||||
<img class="material-img" :src="news.thumbUrl" width="100%" />
|
||||
<div class="relative -ml-[3px]">
|
||||
<div class="inline-block w-[70%] text-xs">{{ news.title }}</div>
|
||||
<div class="inline-block w-[25%] bg-[#acadae]">
|
||||
<img class="h-full w-full" :src="news.thumbUrl" />
|
||||
</div>
|
||||
</div>
|
||||
<div class="child">
|
||||
<div
|
||||
class="relative -bottom-[25px] hidden text-center group-hover:block"
|
||||
>
|
||||
<Button
|
||||
v-if="newsList.length > index + 1"
|
||||
shape="circle"
|
||||
@@ -163,7 +177,10 @@ function plusNews() {
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
<Row justify="center" class="ope-row">
|
||||
<Row
|
||||
justify="center"
|
||||
class="mt-[5px] border-t border-[#eaeaea] pt-[5px] text-center"
|
||||
>
|
||||
<Button
|
||||
type="primary"
|
||||
shape="circle"
|
||||
@@ -175,7 +192,7 @@ function plusNews() {
|
||||
</Row>
|
||||
</div>
|
||||
</Layout.Sider>
|
||||
<Layout.Content :style="{ backgroundColor: '#fff' }">
|
||||
<Layout.Content class="bg-white">
|
||||
<div v-if="newsList.length > 0 && activeNewsItem">
|
||||
<!-- 标题、作者、原文地址 -->
|
||||
<Row :gutter="20">
|
||||
@@ -185,13 +202,13 @@ function plusNews() {
|
||||
placeholder="请输入标题(必填)"
|
||||
/>
|
||||
</Col>
|
||||
<Col :span="24" style="margin-top: 5px">
|
||||
<Col :span="24" class="mt-[5px]">
|
||||
<Input
|
||||
v-model:value="activeNewsItem.author"
|
||||
placeholder="请输入作者"
|
||||
/>
|
||||
</Col>
|
||||
<Col :span="24" style="margin-top: 5px">
|
||||
<Col :span="24" class="mt-[5px]">
|
||||
<Input
|
||||
v-model:value="activeNewsItem.contentSourceUrl"
|
||||
placeholder="请输入原文地址"
|
||||
@@ -212,7 +229,7 @@ function plusNews() {
|
||||
:rows="8"
|
||||
v-model:value="activeNewsItem.digest"
|
||||
placeholder="请输入摘要"
|
||||
class="digest"
|
||||
class="inline-block w-full align-top"
|
||||
:maxlength="120"
|
||||
:show-count="true"
|
||||
/>
|
||||
@@ -230,14 +247,6 @@ function plusNews() {
|
||||
</template>
|
||||
|
||||
<style lang="scss" scoped>
|
||||
/** TODO @hw:尽量使用 tindwind 替代。ps:如果多个组件复用,那就不用调整 */
|
||||
.ope-row {
|
||||
padding-top: 5px;
|
||||
margin-top: 5px;
|
||||
text-align: center;
|
||||
border-top: 1px solid #eaeaea;
|
||||
}
|
||||
|
||||
:deep(.ant-row) {
|
||||
margin-bottom: 20px;
|
||||
}
|
||||
@@ -245,94 +254,4 @@ function plusNews() {
|
||||
:deep(.ant-row:last-child) {
|
||||
margin-bottom: 0;
|
||||
}
|
||||
|
||||
.digest {
|
||||
display: inline-block;
|
||||
width: 100%;
|
||||
vertical-align: top;
|
||||
}
|
||||
|
||||
/* 新增图文 */
|
||||
.news-main {
|
||||
width: 100%;
|
||||
height: 120px;
|
||||
margin: auto;
|
||||
background-color: #fff;
|
||||
}
|
||||
|
||||
.news-content {
|
||||
position: relative;
|
||||
width: 100%;
|
||||
height: 120px;
|
||||
background-color: #acadae;
|
||||
}
|
||||
|
||||
.news-content-title {
|
||||
position: absolute;
|
||||
bottom: 0;
|
||||
left: 0;
|
||||
display: inline-block;
|
||||
width: 98%;
|
||||
height: 25px;
|
||||
padding: 1%;
|
||||
overflow: hidden;
|
||||
text-overflow: ellipsis;
|
||||
font-size: 15px;
|
||||
color: #fff;
|
||||
white-space: nowrap;
|
||||
background-color: black;
|
||||
opacity: 0.65;
|
||||
}
|
||||
|
||||
.news-main-item {
|
||||
width: 100%;
|
||||
padding: 5px 0;
|
||||
margin: auto;
|
||||
background-color: #fff;
|
||||
border-top: 1px solid #eaeaea;
|
||||
}
|
||||
|
||||
.news-content-item {
|
||||
position: relative;
|
||||
margin-left: -3px;
|
||||
}
|
||||
|
||||
.news-content-item-title {
|
||||
display: inline-block;
|
||||
width: 70%;
|
||||
font-size: 12px;
|
||||
}
|
||||
|
||||
.news-content-item-img {
|
||||
display: inline-block;
|
||||
width: 25%;
|
||||
background-color: #acadae;
|
||||
}
|
||||
|
||||
.select-item {
|
||||
width: 60%;
|
||||
padding: 10px;
|
||||
margin: 0 auto 10px;
|
||||
border: 1px solid #eaeaea;
|
||||
|
||||
.activeAddNews {
|
||||
border: 5px solid #2bb673;
|
||||
}
|
||||
}
|
||||
|
||||
.father .child {
|
||||
position: relative;
|
||||
bottom: 25px;
|
||||
display: none;
|
||||
text-align: center;
|
||||
}
|
||||
|
||||
.father:hover .child {
|
||||
display: block;
|
||||
}
|
||||
|
||||
.material-img {
|
||||
width: 100%;
|
||||
height: 100%;
|
||||
}
|
||||
</style>
|
||||
@@ -1,4 +1,4 @@
|
||||
// TODO @hw:要不把 components 里的部分,拿到 modules 里。
|
||||
// DONE @hw:要不把 components 里的部分,拿到 modules 里。
|
||||
interface NewsItem {
|
||||
title: string;
|
||||
thumbMediaId: string;
|
||||
@@ -1,5 +0,0 @@
|
||||
// TODO @hw:如果只有自己组件里用,一般是 modules,所以这个目录要改成 modules 哈(自己模块的一部分);如果要给外部的组件用,可以叫 components;
|
||||
export { default as MenuEditor } from './menu-editor.vue';
|
||||
export { default as MenuPreviewer } from './menu-previewer.vue';
|
||||
export * from './menuOptions';
|
||||
export type * from './types';
|
||||
@@ -1,43 +0,0 @@
|
||||
// TODO @hw:这个要不合并到 types 里;
|
||||
export default [
|
||||
{
|
||||
value: 'view',
|
||||
label: '跳转网页',
|
||||
},
|
||||
{
|
||||
value: 'miniprogram',
|
||||
label: '跳转小程序',
|
||||
},
|
||||
{
|
||||
value: 'click',
|
||||
label: '点击回复',
|
||||
},
|
||||
{
|
||||
value: 'article_view_limited',
|
||||
label: '跳转图文消息',
|
||||
},
|
||||
{
|
||||
value: 'scancode_push',
|
||||
label: '扫码直接返回结果',
|
||||
},
|
||||
{
|
||||
value: 'scancode_waitmsg',
|
||||
label: '扫码回复',
|
||||
},
|
||||
{
|
||||
value: 'pic_sysphoto',
|
||||
label: '系统拍照发图',
|
||||
},
|
||||
{
|
||||
value: 'pic_photo_or_album',
|
||||
label: '拍照或者相册',
|
||||
},
|
||||
{
|
||||
value: 'pic_weixin',
|
||||
label: '微信相册',
|
||||
},
|
||||
{
|
||||
value: 'location_select',
|
||||
label: '选择地理位置',
|
||||
},
|
||||
];
|
||||
@@ -1,3 +1,7 @@
|
||||
import type { VbenFormSchema } from '#/adapter/form';
|
||||
|
||||
import { getSimpleAccountList } from '#/api/mp/account';
|
||||
|
||||
/** 菜单未选中标识 */
|
||||
export const MENU_NOT_SELECTED = '__MENU_NOT_SELECTED__';
|
||||
|
||||
@@ -7,3 +11,21 @@ export enum Level {
|
||||
Parent = '1',
|
||||
Undefined = '0',
|
||||
}
|
||||
|
||||
/** 列表的搜索表单 */
|
||||
export function useGridFormSchema(): VbenFormSchema[] {
|
||||
return [
|
||||
{
|
||||
fieldName: 'accountId',
|
||||
label: '公众号',
|
||||
component: 'ApiSelect',
|
||||
componentProps: {
|
||||
api: getSimpleAccountList,
|
||||
labelField: 'name',
|
||||
valueField: 'id',
|
||||
autoSelect: 'first',
|
||||
placeholder: '请选择公众号',
|
||||
},
|
||||
},
|
||||
];
|
||||
}
|
||||
|
||||
@@ -1,17 +1,26 @@
|
||||
<script lang="ts" setup>
|
||||
import type { Menu, RawMenu } from './components/types';
|
||||
import type { Menu, RawMenu } from './modules/types';
|
||||
|
||||
import { ref } from 'vue';
|
||||
import { nextTick, onMounted, ref } from 'vue';
|
||||
|
||||
import { confirm, ContentWrap, DocAlert, Page } from '@vben/common-ui';
|
||||
import { handleTree } from '@vben/utils';
|
||||
|
||||
import { Button, Form, message } from 'ant-design-vue';
|
||||
import { Button, message } from 'ant-design-vue';
|
||||
|
||||
import { useVbenForm } from '#/adapter/form';
|
||||
import { getSimpleAccountList } from '#/api/mp/account';
|
||||
import { deleteMenu, getMenuList, saveMenu } from '#/api/mp/menu';
|
||||
import { WxAccountSelect } from '#/views/mp/components';
|
||||
import { MenuEditor, MenuPreviewer } from '#/views/mp/menu/components';
|
||||
import { Level, MENU_NOT_SELECTED } from '#/views/mp/menu/data';
|
||||
import {
|
||||
Level,
|
||||
MENU_NOT_SELECTED,
|
||||
useGridFormSchema,
|
||||
} from '#/views/mp/menu/data';
|
||||
import { MenuEditor, MenuPreviewer } from '#/views/mp/menu/modules';
|
||||
|
||||
import iphoneBackImg from './modules/assets/iphone_backImg.png';
|
||||
import menuFootImg from './modules/assets/menu_foot.png';
|
||||
import menuHeadImg from './modules/assets/menu_head.png';
|
||||
|
||||
defineOptions({ name: 'MpMenu' });
|
||||
|
||||
@@ -21,6 +30,25 @@ const accountId = ref(-1);
|
||||
const accountName = ref<string>('');
|
||||
const menuList = ref<Menu[]>([]);
|
||||
|
||||
// 创建表单
|
||||
const [AccountForm, accountFormApi] = useVbenForm({
|
||||
commonConfig: {
|
||||
componentProps: {
|
||||
class: 'w-[240px]',
|
||||
},
|
||||
},
|
||||
layout: 'horizontal',
|
||||
schema: useGridFormSchema(),
|
||||
wrapperClass: 'grid-cols-1',
|
||||
showDefaultActions: false,
|
||||
handleValuesChange: async (values, changedFields) => {
|
||||
// 当 accountId 字段变化时(包括 autoSelect 自动选择),同步更新 accountId
|
||||
if (changedFields.includes('accountId') && values.accountId) {
|
||||
await onAccountChanged(values);
|
||||
}
|
||||
},
|
||||
});
|
||||
|
||||
// ======================== 菜单操作 ========================
|
||||
// 当前选中菜单编码:
|
||||
// * 一级('x')
|
||||
@@ -50,12 +78,36 @@ const tempSelfObj = ref<{
|
||||
const dialogNewsVisible = ref(false); // 跳转图文时的素材选择弹窗
|
||||
|
||||
/** 侦听公众号变化 */
|
||||
function onAccountChanged(id: number, name: string) {
|
||||
accountId.value = id;
|
||||
accountName.value = name;
|
||||
async function onAccountChanged(values: Record<string, any>) {
|
||||
accountId.value = values.accountId;
|
||||
// 从 API 获取公众号列表并查找对应的公众号名称
|
||||
const accountList = await getSimpleAccountList();
|
||||
const account = accountList.find((item) => item.id === values.accountId);
|
||||
accountName.value = account?.name || '';
|
||||
getList();
|
||||
}
|
||||
|
||||
/** 初始化账号ID - 作为备用方案,防止 handleValuesChange 未触发 */
|
||||
async function initAccountId() {
|
||||
// 等待表单初始化完成
|
||||
await nextTick();
|
||||
try {
|
||||
const values = await accountFormApi.getValues();
|
||||
if (values?.accountId && accountId.value === -1) {
|
||||
// 如果表单有值但 accountId 还是初始值,则手动触发一次
|
||||
await onAccountChanged(values);
|
||||
}
|
||||
} catch {
|
||||
// 忽略错误
|
||||
}
|
||||
}
|
||||
|
||||
// 组件挂载时初始化账号ID
|
||||
onMounted(async () => {
|
||||
await nextTick();
|
||||
await initAccountId();
|
||||
});
|
||||
|
||||
/** 查询并转换菜单 */
|
||||
async function getList() {
|
||||
loading.value = true;
|
||||
@@ -249,21 +301,37 @@ function menuToBackend(menu: any) {
|
||||
<DocAlert title="公众号菜单" url="https://doc.iocoder.cn/mp/menu/" />
|
||||
</template>
|
||||
|
||||
<ContentWrap>
|
||||
<!-- 搜索工作栏 -->
|
||||
<Form class="mb-10 w-full">
|
||||
<Form.Item label="公众号" prop="accountId" class="w-60">
|
||||
<WxAccountSelect @change="onAccountChanged" />
|
||||
</Form.Item>
|
||||
</Form>
|
||||
<!-- 搜索工作栏 -->
|
||||
<!-- <ContentWrap> -->
|
||||
<AccountForm class="-mb-15px w-240px" @values-change="onAccountChanged" />
|
||||
<!-- </ContentWrap> -->
|
||||
|
||||
<div class="clearfix public-account-management mt-10" v-loading="loading">
|
||||
<!-- DONE @hw:貌似高度高了点。就是手机下面部分,空了一大块。 -->
|
||||
<ContentWrap>
|
||||
<!-- DONE @hw:尽量使用 tindwind 替代。ps:如果多个组件复用,那就不用调整 -->
|
||||
<div
|
||||
class="mx-auto w-[1200px] after:clear-both after:table after:content-['']"
|
||||
v-loading="loading"
|
||||
>
|
||||
<!--左边配置菜单-->
|
||||
<div class="left">
|
||||
<div class="weixin-hd">
|
||||
<div class="weixin-title">{{ accountName }}</div>
|
||||
<div
|
||||
class="relative float-left box-border block h-[715px] w-[350px] bg-[length:100%_auto] bg-no-repeat p-[518px_25px_88px]"
|
||||
:style="{ backgroundImage: `url(${iphoneBackImg})` }"
|
||||
>
|
||||
<div
|
||||
class="relative bottom-[426px] left-0 h-[64px] w-[300px] bg-[length:100%] bg-[position:0_0] bg-no-repeat text-center text-white"
|
||||
:style="{ backgroundImage: `url(${menuHeadImg})` }"
|
||||
>
|
||||
<div
|
||||
class="absolute left-0 top-[33px] w-full text-center text-sm text-white"
|
||||
>
|
||||
{{ accountName }}
|
||||
</div>
|
||||
</div>
|
||||
<div class="clearfix weixin-menu">
|
||||
<div
|
||||
class="bg-[position:0_0] bg-no-repeat pl-[43px] text-xs after:clear-both after:table after:content-['']"
|
||||
:style="{ backgroundImage: `url(${menuFootImg})` }"
|
||||
>
|
||||
<MenuPreviewer
|
||||
v-model="menuList"
|
||||
:account-id="accountId"
|
||||
@@ -273,27 +341,25 @@ function menuToBackend(menu: any) {
|
||||
@submenu-clicked="(child, x, y) => subMenuClicked(child, x, y)"
|
||||
/>
|
||||
</div>
|
||||
<div class="save-div">
|
||||
<!-- DONE @hw:尽量使用 tindwind 替代。ps:如果多个组件复用,那就不用调整 -->
|
||||
<div class="mt-[15px] flex items-center justify-center gap-[10px]">
|
||||
<Button
|
||||
class="save-btn"
|
||||
type="primary"
|
||||
@click="onSave"
|
||||
v-access:code="['mp:menu:save']"
|
||||
>
|
||||
保存并发布菜单
|
||||
</Button>
|
||||
<Button
|
||||
class="save-btn"
|
||||
danger
|
||||
@click="onClear"
|
||||
v-access:code="['mp:menu:delete']"
|
||||
>
|
||||
<Button danger @click="onClear" v-access:code="['mp:menu:delete']">
|
||||
清空菜单
|
||||
</Button>
|
||||
</div>
|
||||
</div>
|
||||
<!--右边配置-->
|
||||
<div class="right" v-if="showRightPanel">
|
||||
<div
|
||||
class="float-left ml-5 box-border w-[63%] bg-[#e8e7e7] p-5"
|
||||
v-if="showRightPanel"
|
||||
>
|
||||
<MenuEditor
|
||||
:account-id="accountId"
|
||||
:is-parent="isParent"
|
||||
@@ -302,94 +368,10 @@ function menuToBackend(menu: any) {
|
||||
/>
|
||||
</div>
|
||||
<!-- 一进页面就显示的默认页面,当点击左边按钮的时候,就不显示了-->
|
||||
<div v-else class="right">
|
||||
<div v-else class="float-left ml-5 box-border w-[63%] bg-[#e8e7e7] p-5">
|
||||
<p>请选择菜单配置</p>
|
||||
</div>
|
||||
</div>
|
||||
</ContentWrap>
|
||||
</Page>
|
||||
</template>
|
||||
|
||||
<style lang="scss" scoped>
|
||||
/** TODO @hw:尽量使用 tindwind 替代。ps:如果多个组件复用,那就不用调整 */
|
||||
|
||||
/* 公共颜色变量 */
|
||||
.clearfix {
|
||||
*zoom: 1;
|
||||
}
|
||||
|
||||
.clearfix::after {
|
||||
clear: both;
|
||||
display: table;
|
||||
content: '';
|
||||
}
|
||||
|
||||
div {
|
||||
text-align: left;
|
||||
}
|
||||
|
||||
.weixin-hd {
|
||||
position: relative;
|
||||
bottom: 426px;
|
||||
left: 0;
|
||||
width: 300px;
|
||||
height: 64px;
|
||||
color: #fff;
|
||||
text-align: center;
|
||||
background: transparent url('./components/assets/menu_head.png') no-repeat 0 0;
|
||||
background-position: 0 0;
|
||||
background-size: 100%;
|
||||
}
|
||||
|
||||
.weixin-title {
|
||||
position: absolute;
|
||||
top: 33px;
|
||||
left: 0;
|
||||
width: 100%;
|
||||
font-size: 14px;
|
||||
color: #fff;
|
||||
text-align: center;
|
||||
}
|
||||
|
||||
.weixin-menu {
|
||||
padding-left: 43px;
|
||||
font-size: 12px;
|
||||
background: transparent url('./components/assets/menu_foot.png') no-repeat 0 0;
|
||||
}
|
||||
|
||||
.public-account-management {
|
||||
width: 1200px;
|
||||
// min-width: 1200px;
|
||||
margin: 0 auto;
|
||||
|
||||
.left {
|
||||
position: relative;
|
||||
float: left;
|
||||
box-sizing: border-box;
|
||||
display: block;
|
||||
width: 350px;
|
||||
height: 715px;
|
||||
padding: 518px 25px 88px;
|
||||
background: url('./components/assets/iphone_backImg.png') no-repeat;
|
||||
background-size: 100% auto;
|
||||
|
||||
.save-div {
|
||||
display: flex;
|
||||
gap: 10px;
|
||||
align-items: center;
|
||||
justify-content: center;
|
||||
margin-top: 15px;
|
||||
}
|
||||
}
|
||||
|
||||
/* 右边菜单内容 */
|
||||
.right {
|
||||
float: left;
|
||||
box-sizing: border-box;
|
||||
width: 63%;
|
||||
padding: 20px;
|
||||
margin-left: 20px;
|
||||
background-color: #e8e7e7;
|
||||
}
|
||||
}
|
||||
</style>
|
||||
|
||||
|
Before Width: | Height: | Size: 34 KiB After Width: | Height: | Size: 34 KiB |
|
Before Width: | Height: | Size: 1.3 KiB After Width: | Height: | Size: 1.3 KiB |
|
Before Width: | Height: | Size: 12 KiB After Width: | Height: | Size: 12 KiB |
@@ -1,5 +1,5 @@
|
||||
<script lang="ts" setup>
|
||||
// TODO @hw:名字可以缩写成 editor.vue,文件名
|
||||
// DONE @hw:名字可以缩写成 editor.vue,文件名
|
||||
import { computed, nextTick, ref, watch } from 'vue';
|
||||
|
||||
import { IconifyIcon } from '@vben/icons';
|
||||
@@ -16,7 +16,7 @@ import {
|
||||
|
||||
import { WxMaterialSelect, WxNews, WxReply } from '#/views/mp/components';
|
||||
|
||||
import menuOptions from './menuOptions';
|
||||
import { menuOptions } from './types';
|
||||
|
||||
const props = defineProps<{
|
||||
accountId: number;
|
||||
@@ -38,13 +38,13 @@ const menu = computed({
|
||||
},
|
||||
});
|
||||
const showNewsDialog = ref(false);
|
||||
const hackResetWxReplySelect = ref(false);
|
||||
const hackResetReplySelect = ref(false);
|
||||
const isLeave = computed<boolean>(() => !(menu.value.children?.length > 0));
|
||||
|
||||
watch(menu, () => {
|
||||
hackResetWxReplySelect.value = false; // 销毁组件
|
||||
hackResetReplySelect.value = false; // 销毁组件
|
||||
nextTick(() => {
|
||||
hackResetWxReplySelect.value = true; // 重建组件
|
||||
hackResetReplySelect.value = true; // 重建组件
|
||||
});
|
||||
});
|
||||
|
||||
@@ -81,8 +81,9 @@ function deleteMaterial() {
|
||||
|
||||
<template>
|
||||
<div>
|
||||
<div class="configure-page">
|
||||
<div class="delete-btn">
|
||||
<!-- DONE @hw:尽量使用 tindwind 替代。ps:如果多个组件复用,那就不用调整 -->
|
||||
<div>
|
||||
<div class="mb-[15px] text-right">
|
||||
<Button type="primary" danger @click="emit('delete')">
|
||||
<IconifyIcon icon="lucide:trash-2" />
|
||||
删除当前菜单
|
||||
@@ -91,7 +92,7 @@ function deleteMaterial() {
|
||||
<div>
|
||||
<span>菜单名称:</span>
|
||||
<Input
|
||||
class="input-width"
|
||||
class="mr-[2%] w-[240px]"
|
||||
v-model:value="menu.name"
|
||||
placeholder="请输入菜单名称"
|
||||
:maxlength="isParent ? 4 : 7"
|
||||
@@ -99,21 +100,21 @@ function deleteMaterial() {
|
||||
/>
|
||||
</div>
|
||||
<div v-if="isLeave">
|
||||
<div class="menu-content">
|
||||
<div class="mt-5">
|
||||
<span>菜单标识:</span>
|
||||
<Input
|
||||
class="input-width"
|
||||
class="mr-[2%] w-[240px]"
|
||||
v-model:value="menu.menuKey"
|
||||
placeholder="请输入菜单 KEY"
|
||||
allow-clear
|
||||
/>
|
||||
</div>
|
||||
<div class="menu-content">
|
||||
<div class="mt-5">
|
||||
<span>菜单内容:</span>
|
||||
<Select
|
||||
v-model:value="menu.type"
|
||||
placeholder="请选择"
|
||||
class="input-width"
|
||||
class="mr-[2%] w-[240px]"
|
||||
allow-clear
|
||||
>
|
||||
<Select.Option
|
||||
@@ -126,56 +127,69 @@ function deleteMaterial() {
|
||||
</Select.Option>
|
||||
</Select>
|
||||
</div>
|
||||
<div class="configur-content" v-if="menu.type === 'view'">
|
||||
<div
|
||||
class="mt-5 rounded-[5px] bg-white p-[20px_10px]"
|
||||
v-if="menu.type === 'view'"
|
||||
>
|
||||
<span>跳转链接:</span>
|
||||
<Input
|
||||
class="input-width"
|
||||
class="mr-[2%] w-[240px]"
|
||||
v-model:value="menu.url"
|
||||
placeholder="请输入链接"
|
||||
allow-clear
|
||||
/>
|
||||
</div>
|
||||
<!-- TODO @hw:1)左侧 filed 宽度,看看要不要统一;2)右侧的 input 宽度也处理下; -->
|
||||
<div class="configur-content" v-if="menu.type === 'miniprogram'">
|
||||
<div class="applet">
|
||||
<span>小程序的 appid :</span>
|
||||
<!-- DONE @hw:1)左侧 filed 宽度,看看要不要统一;2)右侧的 input 宽度也处理下; -->
|
||||
<div
|
||||
class="mt-5 rounded-[5px] bg-white p-[20px_10px]"
|
||||
v-if="menu.type === 'miniprogram'"
|
||||
>
|
||||
<div class="mb-5 flex items-center">
|
||||
<div class="w-[20%]">小程序的 appid :</div>
|
||||
<Input
|
||||
class="input-width"
|
||||
class="mr-[2%] flex-1"
|
||||
v-model:value="menu.miniProgramAppId"
|
||||
placeholder="请输入小程序的appid"
|
||||
allow-clear
|
||||
/>
|
||||
</div>
|
||||
<div class="applet">
|
||||
<span>小程序的页面路径:</span>
|
||||
<div class="mb-5 flex items-center">
|
||||
<div class="w-[20%]">小程序的页面路径:</div>
|
||||
<Input
|
||||
class="input-width"
|
||||
class="mr-[2%] flex-1"
|
||||
v-model:value="menu.miniProgramPagePath"
|
||||
placeholder="请输入小程序的页面路径,如:pages/index"
|
||||
allow-clear
|
||||
/>
|
||||
</div>
|
||||
<div class="applet">
|
||||
<span>小程序的备用网页:</span>
|
||||
<div class="mb-5 flex items-center">
|
||||
<div class="w-[20%]">小程序的备用网页:</div>
|
||||
<Input
|
||||
class="input-width"
|
||||
class="mr-[2%] flex-1"
|
||||
v-model:value="menu.url"
|
||||
placeholder="不支持小程序的老版本客户端将打开本网页"
|
||||
allow-clear
|
||||
/>
|
||||
</div>
|
||||
<p class="blue">
|
||||
<p class="mt-[10px] text-[#29b6f6]">
|
||||
tips:需要和公众号进行关联才可以把小程序绑定带微信菜单上哟!
|
||||
</p>
|
||||
</div>
|
||||
<div
|
||||
class="configur-content"
|
||||
class="mt-5 rounded-[5px] bg-white p-[20px_10px]"
|
||||
v-if="menu.type === 'article_view_limited'"
|
||||
>
|
||||
<Row>
|
||||
<div class="select-item" v-if="menu && menu.replyArticles">
|
||||
<div
|
||||
class="mx-auto mb-[10px] w-[280px] border border-[#eaeaea] p-[10px]"
|
||||
v-if="menu && menu.replyArticles"
|
||||
>
|
||||
<WxNews :articles="menu.replyArticles" />
|
||||
<Row class="ope-row" justify="center" align="middle">
|
||||
<Row
|
||||
class="pt-[10px] text-center"
|
||||
justify="center"
|
||||
align="middle"
|
||||
>
|
||||
<Button
|
||||
type="primary"
|
||||
danger
|
||||
@@ -188,8 +202,8 @@ function deleteMaterial() {
|
||||
</div>
|
||||
<div v-else>
|
||||
<Row justify="center">
|
||||
<!-- TODO @hw:html 标签里的 style 要用 tindwind 替代下; -->
|
||||
<Col :span="24" style="text-align: center">
|
||||
<!-- DONE @hw:html 标签里的 style 要用 tindwind 替代下; -->
|
||||
<Col :span="24" class="text-center">
|
||||
<Button type="primary" @click="showNewsDialog = true">
|
||||
素材库选择
|
||||
<IconifyIcon icon="lucide:circle-check" />
|
||||
@@ -211,80 +225,13 @@ function deleteMaterial() {
|
||||
</Modal>
|
||||
</Row>
|
||||
</div>
|
||||
<!-- TODO @hw:貌似这个组件出不来 -->
|
||||
<div
|
||||
class="configur-content"
|
||||
class="configur-content mt-5"
|
||||
v-if="menu.type === 'click' || menu.type === 'scancode_waitmsg'"
|
||||
>
|
||||
<WxReply v-if="hackResetWxReplySelect" v-model="menu.reply" />
|
||||
<WxReply v-model="menu.reply" />
|
||||
</div>
|
||||
<!-- TODO @hw:扫码回复,这个帮忙看看,是不是有点问题。= = 好像 vue3 + element-plus 就有点问题; -->
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</template>
|
||||
|
||||
<style lang="scss" scoped>
|
||||
/** TODO @hw:尽量使用 tindwind 替代。ps:如果多个组件复用,那就不用调整 */
|
||||
:deep(.ant-input) {
|
||||
// width: 70%;
|
||||
margin-right: 2%;
|
||||
}
|
||||
|
||||
.configure-page {
|
||||
.delete-btn {
|
||||
margin-bottom: 15px;
|
||||
text-align: right;
|
||||
}
|
||||
|
||||
.menu-content {
|
||||
margin-top: 20px;
|
||||
}
|
||||
|
||||
.configur-content {
|
||||
padding: 20px 10px;
|
||||
margin-top: 20px;
|
||||
background-color: #fff;
|
||||
border-radius: 5px;
|
||||
|
||||
.select-item {
|
||||
width: 280px;
|
||||
padding: 10px;
|
||||
margin: 0 auto 10px;
|
||||
border: 1px solid #eaeaea;
|
||||
|
||||
.ope-row {
|
||||
padding-top: 10px;
|
||||
text-align: center;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
.blue {
|
||||
margin-top: 10px;
|
||||
color: #29b6f6;
|
||||
}
|
||||
|
||||
.applet {
|
||||
margin-bottom: 20px;
|
||||
|
||||
span {
|
||||
width: 20%;
|
||||
}
|
||||
}
|
||||
|
||||
.input-width {
|
||||
width: 240px;
|
||||
}
|
||||
|
||||
.material {
|
||||
.input-width {
|
||||
width: 30%;
|
||||
}
|
||||
|
||||
:deep(.ant-input) {
|
||||
width: 80%;
|
||||
}
|
||||
}
|
||||
}
|
||||
</style>
|
||||
5
apps/web-antd/src/views/mp/menu/modules/index.ts
Normal file
5
apps/web-antd/src/views/mp/menu/modules/index.ts
Normal file
@@ -0,0 +1,5 @@
|
||||
// DONE @hw:如果只有自己组件里用,一般是 modules,所以这个目录要改成 modules 哈(自己模块的一部分);如果要给外部的组件用,可以叫 components;
|
||||
export { default as MenuEditor } from './editor.vue';
|
||||
export { default as MenuPreviewer } from './previewer.vue';
|
||||
export type * from './types';
|
||||
export * from './types';
|
||||
@@ -1,5 +1,5 @@
|
||||
<script lang="ts" setup>
|
||||
// TODO @hw:名字可以缩写成 previewer.vue,文件名
|
||||
// DONE @hw:名字可以缩写成 previewer.vue,文件名
|
||||
import type { Menu } from './types';
|
||||
|
||||
import { computed } from 'vue';
|
||||
@@ -44,9 +44,8 @@ function addMenu() {
|
||||
|
||||
/** 添加横向二级菜单;parent 表示要操作的父菜单 */
|
||||
function addSubMenu(i: number, parent: any) {
|
||||
const subMenuKeyLength = parent.children.length; // 获取二级菜单 key 长度
|
||||
// TODO @hw:可以 inline 掉。idea 或者 vscode 的一些告警,处理掉会更干净一些。
|
||||
const addButton = {
|
||||
// DONE @hw:可以 inline 掉。idea 或者 vscode 的一些告警,处理掉会更干净一些。
|
||||
parent.children[parent.children.length] = {
|
||||
name: '子菜单名称',
|
||||
reply: {
|
||||
// 用于存储回复内容
|
||||
@@ -54,8 +53,11 @@ function addSubMenu(i: number, parent: any) {
|
||||
accountId: props.accountId, // 保证组件里,可以使用到对应的公众号
|
||||
},
|
||||
};
|
||||
parent.children[subMenuKeyLength] = addButton;
|
||||
subMenuClicked(parent.children[subMenuKeyLength], i, subMenuKeyLength);
|
||||
subMenuClicked(
|
||||
parent.children[parent.children.length - 1],
|
||||
i,
|
||||
parent.children.length - 1,
|
||||
);
|
||||
}
|
||||
|
||||
/** 一级菜单点击 */
|
||||
@@ -129,18 +131,23 @@ function onChildDragEnd({ newIndex }: { newIndex: number }) {
|
||||
@end="onParentDragEnd"
|
||||
>
|
||||
<template #item="{ element: parent, index: x }">
|
||||
<div class="menu-bottom">
|
||||
<div
|
||||
class="relative float-left box-border block w-[85.5px] cursor-pointer border border-[#ebedee] bg-white text-center"
|
||||
>
|
||||
<!-- 一级菜单 -->
|
||||
<div
|
||||
@click="menuClicked(parent, x)"
|
||||
class="menu-item"
|
||||
:class="{ active: props.activeIndex === `${x}` }"
|
||||
class="box-border flex h-[44px] w-full items-center justify-center leading-[44px]"
|
||||
:class="{ 'border border-[#2bb673]': props.activeIndex === `${x}` }"
|
||||
>
|
||||
<IconifyIcon icon="lucide:panel-right-open" color="black" />
|
||||
{{ parent.name }}
|
||||
</div>
|
||||
<!-- 以下为二级菜单-->
|
||||
<div class="submenu" v-if="props.parentIndex === x && parent.children">
|
||||
<div
|
||||
class="absolute bottom-[45px] left-0 w-[85.5px]"
|
||||
v-if="props.parentIndex === x && parent.children"
|
||||
>
|
||||
<draggable
|
||||
v-model="parent.children"
|
||||
item-key="id"
|
||||
@@ -149,11 +156,15 @@ function onChildDragEnd({ newIndex }: { newIndex: number }) {
|
||||
@end="onChildDragEnd"
|
||||
>
|
||||
<template #item="{ element: child, index: y }">
|
||||
<div class="menu-bottom subtitle">
|
||||
<div
|
||||
class="relative float-left box-border block w-[85.5px] cursor-pointer border border-[#ebedee] bg-white text-center"
|
||||
>
|
||||
<div
|
||||
class="menu-sub-item"
|
||||
v-if="parent.children"
|
||||
:class="{ active: props.activeIndex === `${x}-${y}` }"
|
||||
class="box-border h-[44px] text-center leading-[44px]"
|
||||
:class="{
|
||||
'border border-[#2bb673]':
|
||||
props.activeIndex === `${x}-${y}`,
|
||||
}"
|
||||
@click="subMenuClicked(child, x, y)"
|
||||
>
|
||||
{{ child.name }}
|
||||
@@ -161,13 +172,12 @@ function onChildDragEnd({ newIndex }: { newIndex: number }) {
|
||||
</div>
|
||||
</template>
|
||||
</draggable>
|
||||
<!-- 二级菜单加号, 当长度 小于 5 才显示二级菜单的加号 -->
|
||||
<div
|
||||
class="menu-bottom menu-addicon"
|
||||
class="relative float-left box-border block flex h-[46px] w-[85.5px] cursor-pointer items-center justify-center border border-[#ebedee] bg-white text-center leading-[46px]"
|
||||
v-if="!parent.children || parent.children.length < 5"
|
||||
@click="addSubMenu(x, parent)"
|
||||
>
|
||||
<IconifyIcon icon="lucide:plus" class="plus" />
|
||||
<IconifyIcon icon="lucide:plus" class="text-[#2bb673]" />
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
@@ -176,78 +186,15 @@ function onChildDragEnd({ newIndex }: { newIndex: number }) {
|
||||
|
||||
<!-- 一级菜单加号 -->
|
||||
<div
|
||||
class="menu-bottom menu-addicon"
|
||||
class="relative float-left box-border block flex h-[46px] w-[85.5px] cursor-pointer items-center justify-center border border-[#ebedee] bg-white text-center leading-[46px]"
|
||||
v-if="menuList.length < 3"
|
||||
@click="addMenu"
|
||||
>
|
||||
<IconifyIcon icon="lucide:plus" class="plus" />
|
||||
<IconifyIcon icon="lucide:plus" class="text-[#2bb673]" />
|
||||
</div>
|
||||
</template>
|
||||
|
||||
<style lang="scss" scoped>
|
||||
/** TODO @hw:尽量使用 tindwind 替代。ps:如果多个组件复用,那就不用调整 */
|
||||
.menu-bottom {
|
||||
position: relative;
|
||||
float: left;
|
||||
box-sizing: border-box;
|
||||
display: block;
|
||||
width: 85.5px;
|
||||
text-align: center;
|
||||
cursor: pointer;
|
||||
background-color: #fff;
|
||||
border: 1px solid #ebedee;
|
||||
|
||||
&.menu-addicon {
|
||||
display: flex;
|
||||
align-items: center;
|
||||
justify-content: center;
|
||||
height: 46px;
|
||||
line-height: 46px;
|
||||
|
||||
.plus {
|
||||
color: #2bb673;
|
||||
}
|
||||
}
|
||||
|
||||
.menu-item {
|
||||
// text-align: center;
|
||||
box-sizing: border-box;
|
||||
display: flex;
|
||||
align-items: center;
|
||||
justify-content: center;
|
||||
width: 100%;
|
||||
height: 44px;
|
||||
line-height: 44px;
|
||||
|
||||
&.active {
|
||||
border: 1px solid #2bb673;
|
||||
}
|
||||
}
|
||||
|
||||
.menu-sub-item {
|
||||
box-sizing: border-box;
|
||||
height: 44px;
|
||||
line-height: 44px;
|
||||
text-align: center;
|
||||
|
||||
&.active {
|
||||
border: 1px solid #2bb673;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/* 第二级菜单 */
|
||||
.submenu {
|
||||
position: absolute;
|
||||
bottom: 45px;
|
||||
width: 85.5px;
|
||||
|
||||
.subtitle {
|
||||
box-sizing: border-box;
|
||||
background-color: #fff;
|
||||
}
|
||||
}
|
||||
|
||||
.draggable-ghost {
|
||||
background: #f7fafc;
|
||||
border: 1px solid #4299e1;
|
||||
@@ -71,3 +71,47 @@ interface _Menu extends RawMenu {
|
||||
}
|
||||
|
||||
export type Menu = Partial<_Menu>;
|
||||
|
||||
// DONE @hw:这个要不合并到 types 里;
|
||||
export const menuOptions = [
|
||||
{
|
||||
value: 'view',
|
||||
label: '跳转网页',
|
||||
},
|
||||
{
|
||||
value: 'miniprogram',
|
||||
label: '跳转小程序',
|
||||
},
|
||||
{
|
||||
value: 'click',
|
||||
label: '点击回复',
|
||||
},
|
||||
{
|
||||
value: 'article_view_limited',
|
||||
label: '跳转图文消息',
|
||||
},
|
||||
{
|
||||
value: 'scancode_push',
|
||||
label: '扫码直接返回结果',
|
||||
},
|
||||
{
|
||||
value: 'scancode_waitmsg',
|
||||
label: '扫码回复',
|
||||
},
|
||||
{
|
||||
value: 'pic_sysphoto',
|
||||
label: '系统拍照发图',
|
||||
},
|
||||
{
|
||||
value: 'pic_photo_or_album',
|
||||
label: '拍照或者相册',
|
||||
},
|
||||
{
|
||||
value: 'pic_weixin',
|
||||
label: '微信相册',
|
||||
},
|
||||
{
|
||||
value: 'location_select',
|
||||
label: '选择地理位置',
|
||||
},
|
||||
] as const;
|
||||
@@ -41,6 +41,7 @@ export function useFormSchema(): VbenFormSchema[] {
|
||||
}
|
||||
|
||||
/** 列表的搜索表单 */
|
||||
// TODO @YunaiV 这种方式获取刷新浏览器会导致空白
|
||||
export function useGridFormSchema(): VbenFormSchema[] {
|
||||
return [
|
||||
{
|
||||
|
||||
Some files were not shown because too many files have changed in this diff Show More
Reference in New Issue
Block a user