diff --git a/lib/aspects/wechatQrCode.js b/lib/aspects/wechatQrCode.js index 65569376c..db4d2a517 100644 --- a/lib/aspects/wechatQrCode.js +++ b/lib/aspects/wechatQrCode.js @@ -103,7 +103,8 @@ function createWechatQrCode(options, context) { throw new Error('无法生成公众号-小程序二维码,服务号未正确配置'); } selfMp = applications.find(function (ele) { return ele.type = 'wechatMp'; }); - if (!selfMp.config.qrCodePrefix) { + if (!(selfMp && selfMp.config.appId && + selfMp.config.appSecret)) { throw new Error('无法生成公众号-小程序二维码,小程序未正确配置'); } appId = self_4.id; diff --git a/lib/components/func/query/web.js b/lib/components/func/query/web.js index 25afd0a7d..118ddfc21 100644 --- a/lib/components/func/query/web.js +++ b/lib/components/func/query/web.js @@ -3,6 +3,7 @@ Object.defineProperty(exports, "__esModule", { value: true }); var tslib_1 = require("tslib"); var jsx_runtime_1 = require("react/jsx-runtime"); var antd_1 = require("antd"); +var money_1 = require("oak-domain/lib/utils/money"); var Entity_1 = require("oak-domain/lib/types/Entity"); var dayjs_1 = tslib_1.__importDefault(require("dayjs")); var weekday_1 = tslib_1.__importDefault(require("dayjs/plugin/weekday")); @@ -75,15 +76,18 @@ function Render(props) { } var _value = transformValue(column, filter); 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': { - var ops = [ - '$eq', - '$ne', - '$gt', - '$gte', - '$lt', - '$lte', - ]; + var ops = ['$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) { var val = e.target.value; setFilterAndResetFilter(val); @@ -92,14 +96,7 @@ function Render(props) { } case 'integer': case 'int': { - var ops = [ - '$eq', - '$ne', - '$gt', - '$gte', - '$lt', - '$lte', - ]; + var ops = ['$eq', '$ne', '$gt', '$gte', '$lt', '$lte']; if (op) { (0, assert_1.assert)(ops.includes(op), assertMessage(attr, attrType, op, ops)); } diff --git a/lib/endpoints/wechat.js b/lib/endpoints/wechat.js index d4c182610..2f133c773 100644 --- a/lib/endpoints/wechat.js +++ b/lib/endpoints/wechat.js @@ -104,7 +104,7 @@ function setUserUnsubscribed(openId, context) { } function setUserSubscribed(openId, eventKey, context) { 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; return tslib_1.__generator(this, function (_k) { switch (_k.label) { @@ -322,17 +322,18 @@ function setUserSubscribed(openId, eventKey, context) { filter: { systemId: systemId, type: 'wechatMp', - } + }, }, { dontCollect: true })]; case 8: _j = tslib_1.__read.apply(void 0, [_k.sent(), 1]), appMp = _j[0]; (0, assert_1.default)(appMp, '公众号推送小程序码时找不到关联的小程序'); config_1 = appMp.config; appId_1 = config_1.appId; - content = "".concat(name_1, "\u4E3A\u60A8\u521B\u5EFA\u4E86\u4E00\u4E2A\u6388\u6743\uFF0C\u8BF7\u70B9\u51FB\u9886\u53D6"); + }); + content = "".concat(name_1, "\u4E3A\u60A8\u521B\u5EFA\u4E86\u4E00\u4E2A\u6388\u6743\uFF0C\u8BF7\u70B9\u51FB\u9886\u53D6"); (0, assert_1.default)(!expired_1); // 如果生成的wechatQrCode没过期,userEntityGrant就不可能过期。 wechatInstance.sendServeMessage({ openId: openId, diff --git a/src/aspects/wechatQrCode.ts b/src/aspects/wechatQrCode.ts index d65e4445c..4b43f5a9a 100644 --- a/src/aspects/wechatQrCode.ts +++ b/src/aspects/wechatQrCode.ts @@ -131,8 +131,15 @@ export async function createWechatQrCode ele.type = 'wechatMp'); - if (!(selfMp!.config as WechatMpConfig).qrCodePrefix) { - throw new Error('无法生成公众号-小程序二维码,小程序未正确配置'); + if ( + !( + selfMp && (selfMp!.config as WechatMpConfig).appId && + (selfMp!.config as WechatMpConfig).appSecret + ) + ) { + throw new Error( + '无法生成公众号-小程序二维码,小程序未正确配置' + ); } appId = self.id; appType = 'wechatPublic'; diff --git a/src/components/func/query/column.d.ts b/src/components/func/query/column.d.ts index 6709d3756..6d0403819 100644 --- a/src/components/func/query/column.d.ts +++ b/src/components/func/query/column.d.ts @@ -18,7 +18,7 @@ export type Ops = export type ColSpanType = 1 | 2 | 3 | 4; -export type ValueType = string | boolean | Array | Dayjs; +export type ValueType = string | boolean | number | Array | Dayjs; export type ColumnProps = { attr: string; diff --git a/src/components/func/query/web.tsx b/src/components/func/query/web.tsx index 98b63a787..bede4680a 100644 --- a/src/components/func/query/web.tsx +++ b/src/components/func/query/web.tsx @@ -9,6 +9,7 @@ import { InputNumber, } from 'antd'; import { WebComponentProps } from 'oak-frontend-base'; +import { ToYuan, ToCent } from 'oak-domain/lib/utils/money'; import { EntityDict } from '../../../general-app-domain'; import { initinctiveAttributes } from 'oak-domain/lib/types/Entity'; import dayjs, { Dayjs } from 'dayjs'; @@ -165,15 +166,29 @@ export default function Render( const _value = transformValue(column, filter); switch (attrType) { + case 'money': { + const ops: Ops[] = ['$eq', '$ne', '$gt', '$gte', '$lt', '$lte']; + const moneyVal = _value ? ToYuan(_value) : ''; + V = ( + { + 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': { - const ops: Ops[] = [ - '$eq', - '$ne', - '$gt', - '$gte', - '$lt', - '$lte', - ]; + const ops: Ops[] = ['$eq', '$ne', '$gt', '$gte', '$lt', '$lte']; V = ( ); - break; } diff --git a/src/endpoints/wechat.ts b/src/endpoints/wechat.ts index 2d51dcf06..92c367419 100644 --- a/src/endpoints/wechat.ts +++ b/src/endpoints/wechat.ts @@ -317,25 +317,33 @@ async function setUserSubscribed(openId: string, eventKey: string, context: BRC) else { assert(qrCodeType === 'wechatPublicForMp'); // 找到相关的小程序 - const [ appMp ] = await context.select('application', { - data: { - id: 1, - config: 1, + const [appMp] = await context.select( + 'application', + { + data: { + id: 1, + config: 1, + }, + filter: { + systemId, + type: 'wechatMp', + }, }, - filter: { - systemId, - type: 'wechatMp', - } - }, { dontCollect: true }); + { dontCollect: true } + ); assert(appMp, '公众号推送小程序码时找不到关联的小程序'); const { config } = appMp; const { appId } = config as WechatMpConfig; + const url = composeUrl( + '/pages/wecharQrCode/scan', + { + oakId: wcqId, + time: `${Date.now()}`, + } + ) // 先试着发文字链接 - const content = `${name}为您创建了一个授权,请点击领取`; + const content = `${name}为您创建了一个授权,请点击领取`; assert(!expired); // 如果生成的wechatQrCode没过期,userEntityGrant就不可能过期。 wechatInstance.sendServeMessage({