搜索组件 支持money类型

This commit is contained in:
Wang Kejun 2023-03-03 11:27:10 +08:00
parent f94b763aa4
commit d0fd8d6fca
7 changed files with 75 additions and 54 deletions

View File

@ -103,7 +103,8 @@ function createWechatQrCode(options, context) {
throw new Error('无法生成公众号-小程序二维码,服务号未正确配置'); throw new Error('无法生成公众号-小程序二维码,服务号未正确配置');
} }
selfMp = applications.find(function (ele) { return ele.type = 'wechatMp'; }); selfMp = applications.find(function (ele) { return ele.type = 'wechatMp'; });
if (!selfMp.config.qrCodePrefix) { if (!(selfMp && selfMp.config.appId &&
selfMp.config.appSecret)) {
throw new Error('无法生成公众号-小程序二维码,小程序未正确配置'); throw new Error('无法生成公众号-小程序二维码,小程序未正确配置');
} }
appId = self_4.id; appId = self_4.id;

View File

@ -3,6 +3,7 @@ Object.defineProperty(exports, "__esModule", { value: true });
var tslib_1 = require("tslib"); var tslib_1 = require("tslib");
var jsx_runtime_1 = require("react/jsx-runtime"); var jsx_runtime_1 = require("react/jsx-runtime");
var antd_1 = require("antd"); var antd_1 = require("antd");
var money_1 = require("oak-domain/lib/utils/money");
var Entity_1 = require("oak-domain/lib/types/Entity"); var Entity_1 = require("oak-domain/lib/types/Entity");
var dayjs_1 = tslib_1.__importDefault(require("dayjs")); var dayjs_1 = tslib_1.__importDefault(require("dayjs"));
var weekday_1 = tslib_1.__importDefault(require("dayjs/plugin/weekday")); var weekday_1 = tslib_1.__importDefault(require("dayjs/plugin/weekday"));
@ -75,15 +76,18 @@ function Render(props) {
} }
var _value = transformValue(column, filter); var _value = transformValue(column, filter);
switch (attrType) { switch (attrType) {
case 'money': {
var ops = ['$eq', '$ne', '$gt', '$gte', '$lt', '$lte'];
var moneyVal_1 = _value ? (0, money_1.ToYuan)(_value) : '';
V = ((0, jsx_runtime_1.jsx)(antd_1.Input, { placeholder: placeholder || t('placeholder.input'), value: moneyVal_1, onChange: function (e) {
var val = e.target.value;
var val2 = /^(-?[1-9]\d*(\.\d*[1-9])?)|(-?0\.\d*[1-9])$/.test(val) ? (0, money_1.ToCent)(val) : moneyVal_1;
setFilterAndResetFilter(val2);
}, allowClear: true, onPressEnter: function () { } }));
break;
}
case 'float': { case 'float': {
var ops = [ var ops = ['$eq', '$ne', '$gt', '$gte', '$lt', '$lte'];
'$eq',
'$ne',
'$gt',
'$gte',
'$lt',
'$lte',
];
V = ((0, jsx_runtime_1.jsx)(antd_1.Input, { placeholder: placeholder || t('placeholder.input'), value: _value, onChange: function (e) { V = ((0, jsx_runtime_1.jsx)(antd_1.Input, { placeholder: placeholder || t('placeholder.input'), value: _value, onChange: function (e) {
var val = e.target.value; var val = e.target.value;
setFilterAndResetFilter(val); setFilterAndResetFilter(val);
@ -92,14 +96,7 @@ function Render(props) {
} }
case 'integer': case 'integer':
case 'int': { case 'int': {
var ops = [ var ops = ['$eq', '$ne', '$gt', '$gte', '$lt', '$lte'];
'$eq',
'$ne',
'$gt',
'$gte',
'$lt',
'$lte',
];
if (op) { if (op) {
(0, assert_1.assert)(ops.includes(op), assertMessage(attr, attrType, op, ops)); (0, assert_1.assert)(ops.includes(op), assertMessage(attr, attrType, op, ops));
} }

View File

@ -104,7 +104,7 @@ function setUserUnsubscribed(openId, context) {
} }
function setUserSubscribed(openId, eventKey, context) { function setUserSubscribed(openId, eventKey, context) {
return tslib_1.__awaiter(this, void 0, void 0, function () { return tslib_1.__awaiter(this, void 0, void 0, function () {
var _a, applicationId, applicationType, list, now, data, doUpdate, sceneStr, wcqId, _b, wechatQrCode, application, _c, type, config, systemId, _d, appId, appSecret, wechatInstance, expired, entity, entityId, _e, _f, userEntityGrant, _g, id, granter, expired_1, entity2, qrCodeType, name_1, _h, domain, url, _j, appMp, config_1, appId_1, content; var _a, applicationId, applicationType, list, now, data, doUpdate, sceneStr, wcqId, _b, wechatQrCode, application, _c, type, config, systemId, _d, appId, appSecret, wechatInstance, expired, entity, entityId, _e, _f, userEntityGrant, _g, id, granter, expired_1, entity2, qrCodeType, name_1, _h, domain, url, _j, appMp, config_1, appId_1, url, content;
var _this = this; var _this = this;
return tslib_1.__generator(this, function (_k) { return tslib_1.__generator(this, function (_k) {
switch (_k.label) { switch (_k.label) {
@ -322,17 +322,18 @@ function setUserSubscribed(openId, eventKey, context) {
filter: { filter: {
systemId: systemId, systemId: systemId,
type: 'wechatMp', type: 'wechatMp',
} },
}, { dontCollect: true })]; }, { dontCollect: true })];
case 8: case 8:
_j = tslib_1.__read.apply(void 0, [_k.sent(), 1]), appMp = _j[0]; _j = tslib_1.__read.apply(void 0, [_k.sent(), 1]), appMp = _j[0];
(0, assert_1.default)(appMp, '公众号推送小程序码时找不到关联的小程序'); (0, assert_1.default)(appMp, '公众号推送小程序码时找不到关联的小程序');
config_1 = appMp.config; config_1 = appMp.config;
appId_1 = config_1.appId; appId_1 = config_1.appId;
content = "".concat(name_1, "\u4E3A\u60A8\u521B\u5EFA\u4E86\u4E00\u4E2A\u6388\u6743\uFF0C<a href=\"#\" data-miniprogram-appid=\"").concat(appId_1, "\" data-miniprogram-path=\"").concat((0, url_2.composeUrl)('/pages/wecharQrCode/scan', { url = (0, url_2.composeUrl)('/pages/wecharQrCode/scan', {
oakId: wcqId, oakId: wcqId,
time: "".concat(Date.now()), time: "".concat(Date.now()),
}), "\">\u8BF7\u70B9\u51FB\u9886\u53D6</a>"); });
content = "".concat(name_1, "\u4E3A\u60A8\u521B\u5EFA\u4E86\u4E00\u4E2A\u6388\u6743\uFF0C<a href='#' data-miniprogram-appid='").concat(appId_1, "' data-miniprogram-path='").concat(url, "'>\u8BF7\u70B9\u51FB\u9886\u53D6</a>");
(0, assert_1.default)(!expired_1); // 如果生成的wechatQrCode没过期userEntityGrant就不可能过期。 (0, assert_1.default)(!expired_1); // 如果生成的wechatQrCode没过期userEntityGrant就不可能过期。
wechatInstance.sendServeMessage({ wechatInstance.sendServeMessage({
openId: openId, openId: openId,

View File

@ -131,8 +131,15 @@ export async function createWechatQrCode<ED extends EntityDict, T extends keyof
throw new Error('无法生成公众号-小程序二维码,服务号未正确配置'); throw new Error('无法生成公众号-小程序二维码,服务号未正确配置');
} }
const selfMp = applications.find((ele) => ele.type = 'wechatMp'); const selfMp = applications.find((ele) => ele.type = 'wechatMp');
if (!(selfMp!.config as WechatMpConfig).qrCodePrefix) { if (
throw new Error('无法生成公众号-小程序二维码,小程序未正确配置'); !(
selfMp && (selfMp!.config as WechatMpConfig).appId &&
(selfMp!.config as WechatMpConfig).appSecret
)
) {
throw new Error(
'无法生成公众号-小程序二维码,小程序未正确配置'
);
} }
appId = self.id; appId = self.id;
appType = 'wechatPublic'; appType = 'wechatPublic';

View File

@ -18,7 +18,7 @@ export type Ops =
export type ColSpanType = 1 | 2 | 3 | 4; export type ColSpanType = 1 | 2 | 3 | 4;
export type ValueType = string | boolean | Array<Dayjs> | Dayjs; export type ValueType = string | boolean | number | Array<Dayjs> | Dayjs;
export type ColumnProps = { export type ColumnProps = {
attr: string; attr: string;

View File

@ -9,6 +9,7 @@ import {
InputNumber, InputNumber,
} from 'antd'; } from 'antd';
import { WebComponentProps } from 'oak-frontend-base'; import { WebComponentProps } from 'oak-frontend-base';
import { ToYuan, ToCent } from 'oak-domain/lib/utils/money';
import { EntityDict } from '../../../general-app-domain'; import { EntityDict } from '../../../general-app-domain';
import { initinctiveAttributes } from 'oak-domain/lib/types/Entity'; import { initinctiveAttributes } from 'oak-domain/lib/types/Entity';
import dayjs, { Dayjs } from 'dayjs'; import dayjs, { Dayjs } from 'dayjs';
@ -165,15 +166,29 @@ export default function Render(
const _value = transformValue(column, filter); const _value = transformValue(column, filter);
switch (attrType) { switch (attrType) {
case 'money': {
const ops: Ops[] = ['$eq', '$ne', '$gt', '$gte', '$lt', '$lte'];
const moneyVal = _value ? ToYuan(_value) : '';
V = (
<Input
placeholder={placeholder || t('placeholder.input')}
value={moneyVal}
onChange={(e) => {
const val = e.target.value;
const val2 =
/^(-?[1-9]\d*(\.\d*[1-9])?)|(-?0\.\d*[1-9])$/.test(
val
) ? ToCent(val) : moneyVal;
setFilterAndResetFilter(val2);
}}
allowClear
onPressEnter={() => {}}
/>
);
break;
}
case 'float': { case 'float': {
const ops: Ops[] = [ const ops: Ops[] = ['$eq', '$ne', '$gt', '$gte', '$lt', '$lte'];
'$eq',
'$ne',
'$gt',
'$gte',
'$lt',
'$lte',
];
V = ( V = (
<Input <Input
placeholder={placeholder || t('placeholder.input')} placeholder={placeholder || t('placeholder.input')}
@ -190,14 +205,7 @@ export default function Render(
} }
case 'integer': case 'integer':
case 'int': { case 'int': {
const ops: Ops[] = [ const ops: Ops[] = ['$eq', '$ne', '$gt', '$gte', '$lt', '$lte'];
'$eq',
'$ne',
'$gt',
'$gte',
'$lt',
'$lte',
];
if (op) { if (op) {
assert( assert(
ops.includes(op), ops.includes(op),
@ -472,7 +480,6 @@ export default function Render(
/> />
); );
break; break;
} }
default: { default: {

View File

@ -317,7 +317,9 @@ async function setUserSubscribed(openId: string, eventKey: string, context: BRC)
else { else {
assert(qrCodeType === 'wechatPublicForMp'); assert(qrCodeType === 'wechatPublicForMp');
// 找到相关的小程序 // 找到相关的小程序
const [ appMp ] = await context.select('application', { const [appMp] = await context.select(
'application',
{
data: { data: {
id: 1, id: 1,
config: 1, config: 1,
@ -325,17 +327,23 @@ async function setUserSubscribed(openId: string, eventKey: string, context: BRC)
filter: { filter: {
systemId, systemId,
type: 'wechatMp', type: 'wechatMp',
} },
}, { dontCollect: true }); },
{ dontCollect: true }
);
assert(appMp, '公众号推送小程序码时找不到关联的小程序'); assert(appMp, '公众号推送小程序码时找不到关联的小程序');
const { config } = appMp; const { config } = appMp;
const { appId } = config as WechatMpConfig; const { appId } = config as WechatMpConfig;
// 先试着发文字链接 const url = composeUrl(
const content = `${name}为您创建了一个授权,<a href="#" data-miniprogram-appid="${appId}" data-miniprogram-path="${composeUrl('/pages/wecharQrCode/scan', { '/pages/wecharQrCode/scan',
{
oakId: wcqId, oakId: wcqId,
time: `${Date.now()}`, time: `${Date.now()}`,
})}"></a>`; }
)
// 先试着发文字链接
const content = `${name}为您创建了一个授权,<a href='#' data-miniprogram-appid='${appId}' data-miniprogram-path='${url}'>请点击领取</a>`;
assert(!expired); // 如果生成的wechatQrCode没过期userEntityGrant就不可能过期。 assert(!expired); // 如果生成的wechatQrCode没过期userEntityGrant就不可能过期。
wechatInstance.sendServeMessage({ wechatInstance.sendServeMessage({