移除lib下components文件

This commit is contained in:
wkj 2024-11-06 18:48:15 +08:00
parent 32986ee518
commit 241fb97074
9 changed files with 1 additions and 570 deletions

View File

@ -1,4 +0,0 @@
declare const _default: (props: import("oak-frontend-base").ReactComponentProps<import("../../../oak-app-domain").EntityDict, "offlineAccount", true, {
systemId: string;
}>) => React.ReactElement;
export default _default;

View File

@ -1,50 +0,0 @@
"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
exports.default = OakComponent({
entity: 'offlineAccount',
isList: true,
projection: {
id: 1,
type: 1,
channel: 1,
name: 1,
qrCode: 1,
allowDeposit: 1,
allowPay: 1,
systemId: 1,
price: 1,
enabled: 1,
taxLossRatio: 1,
refundCompensateRatio: 1,
refundGapDays: 1,
allowWithdrawTransfer: 1,
withdrawTransferLossRatio: 1,
},
properties: {
systemId: '',
},
filters: [
{
filter() {
const { systemId } = this.props;
return {
systemId,
};
}
}
],
formData({ data, legalActions }) {
return {
accounts: data.map((ele) => {
const { type } = ele;
const color = this.features.style.getColor('offlineAccount', 'type', type);
return {
color,
...ele,
};
}),
canCreate: legalActions?.includes('create'),
};
},
actions: ['create', 'update', 'remove'],
});

View File

@ -1,12 +0,0 @@
import { EntityDict } from "../../../oak-app-domain";
import { EntityDict as BaseEntityDict } from 'oak-domain/lib/types/Entity';
import { StartPayRoutine, JudgeCanPay } from "../../../types/Pay";
export declare function registerFrontendPayRoutine<ED extends EntityDict & BaseEntityDict>(entity: keyof ED, routine: StartPayRoutine, projection: ED['pay']['Selection']['data'], judgeCanPay: JudgeCanPay): void;
declare const _default: (props: import("oak-frontend-base").ReactComponentProps<EntityDict, "pay", false, {
onClose: () => void;
onPaid: () => void;
onPayFailure: () => void;
disableAutoPay: boolean;
closeWhenFailure: boolean;
}>) => React.ReactElement;
export default _default;

View File

@ -1,326 +0,0 @@
"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
exports.registerFrontendPayRoutine = void 0;
const tslib_1 = require("tslib");
const money_1 = require("oak-domain/lib/utils/money");
const constants_1 = require("../../../config/constants");
const assert_1 = tslib_1.__importDefault(require("assert"));
const utils_1 = require("oak-frontend-base/es/utils/utils");
const lodash_1 = require("oak-domain/lib/utils/lodash");
const wpProductFrontend_1 = require("../../../utils/wpProductFrontend");
const uuid_1 = require("oak-domain/lib/utils/uuid");
const Exception_1 = require("../../../types/Exception");
const PayRoutineDict = {
wpProduct: {
projection: {
wpProduct: {
id: 1,
type: 1,
},
},
routine: async (pay, features) => {
const { iState, wpProduct, meta } = pay;
switch (wpProduct.type) {
case 'mp': {
if (process.env.OAK_PLATFORM === 'wechatMp') {
const { prepayMeta } = meta;
if (prepayMeta) {
try {
const result = await wx.requestPayment(prepayMeta);
process.env.NODE_ENV === 'development' && console.log(result);
}
catch (err) {
throw new Exception_1.StartPayFailure(err.errMsg.includes('cancel')
? features.locales.t('startPayError.userCancel')
: features.locales.t('startPayError.unknown'));
}
}
else {
throw new Exception_1.StartPayFailure(features.locales.t('startPayError.illegalPrepayData'));
}
}
else {
throw new Exception_1.StartPayFailure(features.locales.t('startPayError.falseEnv', { env: 'wechatMp' }));
}
return;
}
case 'jsapi': {
if (process.env.OAK_PLATFORM === 'web' && utils_1.isWeiXin) {
const { prepayMeta } = meta;
if (prepayMeta) {
const { timeStamp, ...rest } = prepayMeta;
// chooseWXPay文档都找不到了网上查出来这里timestamp的s要小写吐血了
await features.wechatSdk.loadWxAPi('chooseWXPay', {
timestamp: timeStamp,
...rest,
});
}
else {
throw new Exception_1.StartPayFailure(features.locales.t('startPayError.illegalPrepayData'));
}
}
}
default: {
(0, assert_1.default)('尚未实现');
}
}
},
judgeCanPay: wpProductFrontend_1.canStartPay,
}
};
function registerFrontendPayRoutine(entity, routine, projection, judgeCanPay) {
PayRoutineDict[entity] = {
routine,
projection,
judgeCanPay,
};
}
exports.registerFrontendPayRoutine = registerFrontendPayRoutine;
exports.default = OakComponent({
entity: 'pay',
isList: false,
projection: () => {
const baseProjection = {
id: 1,
applicationId: 1,
price: 1,
meta: 1,
iState: 1,
paid: 1,
refunded: 1,
timeoutAt: 1,
forbidRefundAt: 1,
externalId: 1,
orderId: 1,
depositId: 1,
deposit: {
id: 1,
accountId: 1,
price: 1,
loss: 1,
},
order: {
id: 1,
creatorId: 1,
},
entity: 1,
entityId: 1,
creatorId: 1,
phantom3: 1,
};
for (const k in PayRoutineDict) {
(0, lodash_1.merge)(baseProjection, PayRoutineDict[k].projection);
}
return baseProjection;
},
properties: {
onClose: () => undefined,
onPaid: () => undefined,
onPayFailure: () => undefined,
disableAutoPay: false,
closeWhenFailure: false,
},
data: {
showCloseConfirmMp: false,
showChannelSelectMp: false,
unsub: undefined,
},
formData({ data }) {
const application = this.features.application.getApplication();
const iState = data?.iState;
const iStateColor = iState && this.features.style.getColor('pay', 'iState', iState);
const startPayable = iState === 'paying' && !['account', 'offlineAccount'].includes(data.entity) && (PayRoutineDict[data.entity] && PayRoutineDict[data.entity].judgeCanPay(data, this.features));
const payChannels = this.features.pay.getPayChannels();
const offlines = this.features.cache.get('offlineAccount', {
data: {
id: 1,
type: 1,
channel: 1,
name: 1,
qrCode: 1,
},
filter: {
systemId: this.features.application.getApplication().systemId,
}
}).map(ele => {
const color = this.features.style.getColor('offlineAccount', 'type', ele.type);
return {
color,
...ele,
};
});
const offline = offlines?.find(ele => ele.id === data.entityId);
return {
type: data?.orderId ? 'order' : 'deposit',
pay: data,
application,
iStateColor,
closable: !!(data?.["#oakLegalActions"]?.includes('close')),
startPayable,
offline,
offlines,
notSameApp: data && data.applicationId !== application.id && data.entity !== 'offlineAccount',
priceStr: data?.price && (0, money_1.CentToString)(data.price, 2),
};
},
features: [{
feature: 'application',
callback() {
this.refreshOfflineAccounts();
}
}],
actions: ['close', 'startPaying', {
action: 'update',
attrs: ['entityId'],
}],
methods: {
refreshOfflineAccounts() {
const { entity } = this.state.pay || {};
if (entity === 'offlineAccount') {
this.features.cache.refresh('offlineAccount', {
data: {
id: 1,
channel: 1,
name: 1,
type: 1,
qrCode: 1,
},
filter: {
systemId: this.features.application.getApplication().systemId,
}
});
}
},
executeMp() {
return this.execute();
},
resetMp() {
return this.clean();
},
closeMp() {
this.setState({
showCloseConfirmMp: true,
});
},
cancelCloseMp() {
this.setState({
showCloseConfirmMp: false,
});
},
async confirmCloseMp() {
await this.execute('close');
this.cancelCloseMp();
const { onClose } = this.props;
onClose && onClose();
},
goBack() {
this.navigateBack();
},
async startPay() {
const { onPaid, onClose, onPayFailure } = this.props;
const { pay } = this.state;
try {
await PayRoutineDict[pay.entity].routine(pay, this.features);
onPaid && onPaid();
}
catch (err) {
if (this.props.closeWhenFailure) {
await this.execute(undefined, undefined, undefined, [
{
entity: 'pay',
operation: {
id: await (0, uuid_1.generateNewIdAsync)(),
action: 'close',
data: {},
filter: {
id: this.props.oakId,
},
},
}
]);
onClose && onClose();
}
else {
onPayFailure && onPayFailure();
}
this.features.message.setMessage({
type: 'warning',
content: err.message,
});
}
},
openChannelSelectMp() {
this.setState({
showChannelSelectMp: true,
});
},
closeChannelSelectMp() {
this.setState({
showChannelSelectMp: false,
});
},
async updateOfflineIdMp(touch) {
const { detail } = touch;
const { currentKey } = detail;
const { oakId } = this.props;
if (currentKey) {
await this.execute(undefined, undefined, undefined, [
{
entity: 'pay',
operation: {
id: await (0, uuid_1.generateNewIdAsync)(),
action: 'update',
data: {
entity: 'offlineAccount',
entityId: currentKey,
},
filter: {
id: oakId,
},
}
}
]);
this.setState({
showChannelSelectMp: false,
});
}
},
updateExternalIdMp(input) {
const { detail } = input;
this.update({
externalId: detail.value,
});
},
clearExternalIdMp() {
this.update({
externalId: null,
});
}
},
lifetimes: {
async ready() {
const { oakId } = this.props;
(0, assert_1.default)(typeof oakId === 'string');
const unsub = await this.subDataEvents([`${constants_1.DATA_SUBSCRIBER_KEYS.payStateChanged}-${oakId}`]);
this.setState({
unsub,
});
},
detached() {
const { unsub } = this.state;
unsub && unsub();
}
},
listeners: {
startPayable(prev, next) {
if (next.startPayable && !this.props.disableAutoPay) {
this.startPay();
}
},
pay(prev, next) {
if (!prev.pay && next.pay) {
this.refreshOfflineAccounts();
}
}
},
});

View File

@ -1,14 +0,0 @@
import React from 'react';
import { RowWithActions, WebComponentProps } from 'oak-frontend-base';
import { EntityDict as BaseEntityDict } from 'oak-domain/lib/types/Entity';
import { EntityDict } from '../../../oak-app-domain';
export declare function registerPayChannelComponent<ED extends EntityDict & BaseEntityDict, T extends keyof ED>(entity: T, component: (option: {
oakPath: string;
systemId: string;
}) => React.ReactElement): void;
export default function render(props: WebComponentProps<EntityDict, 'system', false, {
system: RowWithActions<EntityDict, 'system'>;
operation?: EntityDict['system']['Update'];
serverUrl?: string;
canUpdate?: boolean;
}>): import("react/jsx-runtime").JSX.Element | null;

View File

@ -1,122 +0,0 @@
"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
exports.registerPayChannelComponent = void 0;
const tslib_1 = require("tslib");
const jsx_runtime_1 = require("react/jsx-runtime");
const antd_1 = require("antd");
const web_pc_module_less_1 = tslib_1.__importDefault(require("./web.pc.module.less"));
const config_1 = tslib_1.__importDefault(require("../../offlineAccount/config"));
const config_2 = tslib_1.__importDefault(require("../../wpAccount/config"));
const PayChannelConfigDict = {
'wpAccount': config_2.default,
};
function registerPayChannelComponent(entity, component) {
PayChannelConfigDict[entity] = component;
}
exports.registerPayChannelComponent = registerPayChannelComponent;
function PayConfig(props) {
const { payConfig, update, t } = props;
const withdrawLoss = payConfig?.withdrawLoss;
const depositLoss = payConfig?.depositLoss;
const updateDepositLoss = (data) => {
update && update({
depositLoss: {
...depositLoss,
...data,
},
withdrawLoss: withdrawLoss || {
conservative: false,
},
});
};
const updateWithdrawLoss = (data) => {
update && update({
depositLoss: depositLoss || {},
withdrawLoss: {
conservative: !!(withdrawLoss?.conservative),
...withdrawLoss,
...data,
},
});
};
return ((0, jsx_runtime_1.jsxs)(antd_1.Flex, { gap: "middle", children: [(0, jsx_runtime_1.jsx)(antd_1.Card, { title: t('payConfig.label.depositLoss'), extra: (0, jsx_runtime_1.jsx)(antd_1.Popover, { content: t("payConfig.help.depositLoss"), children: (0, jsx_runtime_1.jsx)("span", { className: web_pc_module_less_1.default.help, children: t("help") }) }), children: (0, jsx_runtime_1.jsxs)(antd_1.Form, { labelCol: { span: 8 }, wrapperCol: { span: 18 }, layout: "horizontal", style: { width: '100%' }, children: [(0, jsx_runtime_1.jsx)(antd_1.Form.Item, { label: t('payConfig.label.ratio'), children: (0, jsx_runtime_1.jsx)(antd_1.InputNumber, { value: depositLoss?.ratio, max: 20, min: 0.01, addonAfter: "%", step: 0.01, precision: 2, disabled: !update, onChange: (value) => {
const ratio = value;
updateDepositLoss({
ratio: ratio || 0
});
} }) }), (0, jsx_runtime_1.jsx)(antd_1.Form.Item, { label: t('payConfig.label.highest'), children: (0, jsx_runtime_1.jsx)(antd_1.InputNumber, { value: depositLoss?.highest, min: 0, step: 1, disabled: !update, onChange: (value) => {
const highest = value;
updateDepositLoss({
highest: highest || undefined
});
return;
} }) }), (0, jsx_runtime_1.jsx)(antd_1.Form.Item, { label: t('payConfig.label.lowest'), children: (0, jsx_runtime_1.jsx)(antd_1.InputNumber, { value: depositLoss?.lowest, min: 0, step: 1, disabled: !update, onChange: (value) => {
const lowest = value;
updateDepositLoss({
lowest: lowest || undefined
});
return;
} }) })] }) }), (0, jsx_runtime_1.jsx)(antd_1.Card, { title: t('payConfig.label.withdrawLoss'), extra: (0, jsx_runtime_1.jsx)(antd_1.Popover, { content: t('payConfig.help.withdrawLoss'), children: (0, jsx_runtime_1.jsx)("span", { className: web_pc_module_less_1.default.help, children: t("help") }) }), children: (0, jsx_runtime_1.jsxs)(antd_1.Form, { labelCol: { span: 8 }, wrapperCol: { span: 18 }, layout: "horizontal", style: { width: '100%' }, children: [(0, jsx_runtime_1.jsx)(antd_1.Form.Item, { label: t('payConfig.label.conservative'), children: (0, jsx_runtime_1.jsx)(antd_1.Switch, { disabled: !update, value: withdrawLoss?.conservative, onChange: (conservative) => {
updateWithdrawLoss({ conservative });
} }) }), (0, jsx_runtime_1.jsx)(antd_1.Form.Item, { label: t('payConfig.label.ratio'), children: (0, jsx_runtime_1.jsx)(antd_1.InputNumber, { disabled: !!withdrawLoss?.conservative || !update, value: withdrawLoss?.ratio, max: 20, min: 0.01, addonAfter: "%", step: 0.01, precision: 2, onChange: (value) => {
const ratio = value;
updateWithdrawLoss({
ratio: ratio || 0
});
} }) }), (0, jsx_runtime_1.jsx)(antd_1.Form.Item, { label: t('payConfig.label.highest'), children: (0, jsx_runtime_1.jsx)(antd_1.InputNumber, { disabled: !!withdrawLoss?.conservative || !update, value: withdrawLoss?.highest, min: 0, step: 1, onChange: (value) => {
const highest = value;
updateWithdrawLoss({
highest: highest || undefined
});
return;
} }) }), (0, jsx_runtime_1.jsx)(antd_1.Form.Item, { label: t('payConfig.label.lowest'), children: (0, jsx_runtime_1.jsx)(antd_1.InputNumber, { disabled: !!withdrawLoss?.conservative || !update, value: withdrawLoss?.lowest, min: 0, step: 1, onChange: (value) => {
const lowest = value;
updateWithdrawLoss({
lowest: lowest || undefined
});
return;
} }) }), (0, jsx_runtime_1.jsx)(antd_1.Form.Item, { label: t('payConfig.label.trim'), children: (0, jsx_runtime_1.jsx)(antd_1.Radio.Group, { disabled: !!withdrawLoss?.conservative || !update, options: [
{
label: t('payConfig.label.jiao'),
value: 'jiao',
},
{
label: t('payConfig.label.yuan'),
value: 'yuan',
},
{
label: t('payConfig.label.null'),
value: '',
}
], value: withdrawLoss?.trim, onChange: ({ target }) => updateWithdrawLoss({
trim: target.value,
}) }) })] }) })] }));
}
function render(props) {
const { system, oakFullpath, operation, oakDirty, serverUrl, oakExecutable, canUpdate } = props.data;
const { t, update, clean, execute } = props.methods;
if (system && oakFullpath) {
return ((0, jsx_runtime_1.jsx)("div", { className: web_pc_module_less_1.default.container, children: (0, jsx_runtime_1.jsx)(antd_1.Tabs, { className: web_pc_module_less_1.default.tabs, tabPosition: "left", items: [
{
label: ((0, jsx_runtime_1.jsx)("div", { className: web_pc_module_less_1.default.systemLabel, children: t('system') })),
key: 'system',
children: ((0, jsx_runtime_1.jsxs)(antd_1.Flex, { vertical: true, children: [(0, jsx_runtime_1.jsx)(PayConfig, { payConfig: system.payConfig, update: canUpdate ? (payConfig) => update({ payConfig }) : undefined, t: t }), (0, jsx_runtime_1.jsxs)(antd_1.Flex, { gap: "middle", justify: 'end', children: [(0, jsx_runtime_1.jsx)(antd_1.Button, { type: "primary", disabled: oakExecutable !== true, onClick: () => execute(), children: t('common::confirm') }), (0, jsx_runtime_1.jsx)(antd_1.Button, { disabled: !oakDirty, onClick: () => clean(), children: t('common::reset') })] })] })),
},
{
label: ((0, jsx_runtime_1.jsx)("div", { className: web_pc_module_less_1.default.systemLabel, children: t('offlineAccount:name') })),
key: 'offlineAccount',
children: ((0, jsx_runtime_1.jsx)(config_1.default, { oakPath: `${oakFullpath}.offlineAccount$system`, systemId: system.id })),
},
...Object.keys(PayChannelConfigDict).map((ele) => {
const C = PayChannelConfigDict[ele];
return {
label: ((0, jsx_runtime_1.jsx)("div", { className: web_pc_module_less_1.default.systemLabel, children: t(`${ele}:name`) })),
key: 'ele',
children: (0, jsx_runtime_1.jsx)(C, { oakPath: `${oakFullpath}.${ele}$system`, systemId: system.id })
};
})
] }) }));
}
return null;
}
exports.default = render;

View File

@ -1,4 +0,0 @@
declare const _default: (props: import("oak-frontend-base").ReactComponentProps<import("../../../oak-app-domain").EntityDict, "wpAccount", true, {
systemId: string;
}>) => React.ReactElement;
export default _default;

View File

@ -1,37 +0,0 @@
"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
exports.default = OakComponent({
entity: 'wpAccount',
isList: true,
projection: {
id: 1,
price: 1,
mchId: 1,
enabled: 1,
taxLossRatio: 1,
refundCompensateRatio: 1,
refundGapDays: 1,
allowWithdrawTransfer: 1,
withdrawTransferLossRatio: 1,
},
properties: {
systemId: '',
},
filters: [
{
filter() {
const { systemId } = this.props;
return {
systemId,
};
}
}
],
formData({ data, legalActions }) {
return {
accounts: data,
canCreate: legalActions?.includes('create') && !data?.find(ele => ele.enabled),
};
},
actions: ['create', 'update', 'remove'],
});

View File

@ -19,7 +19,7 @@
"copy-xml": "copyfiles -u 1 src/**/*.xml es/",
"copy-wxml": "copyfiles -u 1 src/**/*.wxml es/",
"prebuild": "npm run make:locale",
"build": "tsc -p tsconfig.lib.json && tsc -p tsconfig.es.json && tsc-alias -p tsconfig.lib.json && tsc-alias -p tsconfig.es.json && npm run copy-js && npm run copy-less && npm run copy-wxs && npm run copy-svg && npm run copy-xml && npm run copy-wxml",
"build": "tsc -p tsconfig.lib.json && tsc -p tsconfig.es.json && tsc-alias -p tsconfig.lib.json && tsc-alias -p tsconfig.es.json && npm run copy-js && npm run copy-less && npm run copy-wxs && npm run copy-svg && npm run copy-xml && npm run copy-wxml && rimraf lib/components/*",
"build:analyze": "tsc -p tsconfig.es.json --diagnostics",
"prepare": "rimraf node_modules/react & rimraf node_modules/react-native & rimraf node_modules/react-dom & rimraf node_modules/react-router & rimraf node_modules/react-router-dom"
},