NumberField length

本文介绍了一种重载Ext.js框架中NumberField组件的maxLength方法,限制输入框的字符长度为2,并实现初始化值的正确赋值。
function initMonthLengthValue(){
//重载maxLength方法,只判断NumberField。key:COSSP_JIRA_CS3_611_20091209
Ext.form.NumberField.prototype.size= 2; //要限制的长度
Ext.form.NumberField.prototype.initValue = function()
{
if(this.value !== undefined){
this.setValue(this.value);
}else if(this.el.dom.value.length > 0){
this.setValue(this.el.dom.value);
}
this.el.dom.size = this.size;
if (!isNaN(this.maxLength) && (this.maxLength *1) > 0 && (this.maxLength != Number.MAX_VALUE)) {
this.el.dom.maxLength = this.maxLength *1;
}
};
}
import React, { useCallback, useEffect, useMemo } from &#39;react&#39;; import {DataSet, Table, Modal, Form, Button, Select, TextField, NumberField} from &#39;choerodon-ui/pro&#39;; import { PageHeaderWrapper } from &#39;hzero-boot/lib/components/Page&#39;; import { getCurrentOrganizationId } from &#39;utils/utils&#39;; import intl from &#39;utils/intl&#39;; import {API_HOST, WMS_INV } from &#39;wmsUtils/config&#39;; import { Button as ButtonPermission } from &#39;components/Permission&#39;; import FieldUploadButton from &#39;comComponents/FileUpload&#39;; import ExcelExport from &#39;components/ExcelExport&#39;; import { handleReportPrint } from &#39;wms-front-common/src/components/ReportPrint&#39;; import { observer } from &#39;mobx-react-lite&#39;; import notification from &#39;utils/notification&#39;; import { tablePropsDs, formInDs, formOutDs } from &#39;./indexDs&#39;; import {handleDelete} from "./api"; export default function tablePage(props) { const tableDs = useMemo(() => new DataSet(tablePropsDs()), []); const columns = useMemo( () => [ { name: &#39;trackNumber&#39;, }, { name: &#39;goodsName&#39;, }, { name: &#39;qty&#39;, }, { name: &#39;weight&#39;, }, { name: &#39;place&#39;, }, { name: &#39;poNumber&#39;, }, { name: &#39;recipient&#39;, }, { name: &#39;realRecipient&#39;, }, { name: &#39;mobile&#39;, }, { name: &#39;department&#39;, }, { name: &#39;attribute1&#39;, }, { name: &#39;stockStatus&#39;, }, { name: &#39;receiveUser&#39;, }, { name: &#39;shippedUser&#39;, }, { name: &#39;placementDate&#39;, }, { name: &#39;takeDate&#39;, }, { header: intl.get(&#39;winv.common.table.column.option&#39;).d(&#39;操作&#39;), name: &#39;action&#39;, align: &#39;left&#39;, lock: &#39;right&#39;, renderer: ({ record }) => { return ( <div style={{display: &#39;flex&#39;, alignItems: &#39;center&#39;}}> <a style={{marginRight: &#39;10px&#39;}} onClick={() => { const data = record.toData(); if(data.stockStatus===&#39;NORMAL_OUT&#39;) { openModal(&#39;out&#39;,data) }else { openModal(&#39;In&#39;,data) } }} > 编辑 </a> <FieldUploadButton record={record} objectType=&#39;attachment&#39; /> </div> ); }, }, ], [] ); useEffect(() => { tableDs.query(); }, []); // 点击打开弹窗 const openModal = (type, record) =>{ let FormDs = type===&#39;In&#39;?new DataSet(formInDs(&#39;&#39;)) :new DataSet(formOutDs(&#39;&#39;)) let title = type===&#39;In&#39;?&#39;新建代收品入库&#39;:&#39;新建代收品出库&#39; if(record?.id){ FormDs = type===&#39;In&#39;?new DataSet(formInDs(record?.id)) :new DataSet(formOutDs(record?.id)) FormDs.query() title = type===&#39;In&#39;?&#39;编辑代收品入库&#39;:&#39;编辑代收品出库&#39; }else{ if(type===&#39;out&#39;){ const recordData = { trackNumber: record.trackNumber, goodsName: record.goodsName, poNumber: record.poNumber, place: record.place, qty: record.qty, recipient: record.recipient, attribute1: record.attribute1, } FormDs.create(recordData) }else{ FormDs.create(); } } Modal.open({ title, children: ( <Form dataSet={FormDs} labelWidth={120}> <TextField name=&#39;trackNumber&#39; /> <TextField name=&#39;goodsName&#39; /> <TextField name=&#39;poNumber&#39; /> <TextField name=&#39;place&#39; /> <NumberField name=&#39;qty&#39; /> <TextField name=&#39;recipient&#39; /> <TextField name=&#39;mobile&#39; /> <NumberField name=&#39;weight&#39; /> <TextField name=&#39;department&#39; /> <Select name=&#39;attribute1&#39; /> { type===&#39;out&#39;&&<NumberField name=&#39;outQty&#39; /> } { type===&#39;out&#39;&&<TextField name=&#39;realRecipient&#39; /> } </Form> ), onOk: async () => { if(type===&#39;out&#39;){ const data = FormDs.current?.toData(); if(Number(data.qty)<Number(data.outQty)){ notification.warning({ message: &#39;出库数量必须小于等于在库数量,请检查!&#39;, description: &#39;&#39;, }) return false } } await FormDs.submit().then(()=>{ tableDs.query(); }); // const isFlag = await FormDs.current?.validate(); // if(isFlag){ // // }else{ // return false // } }, }); } const getExportQueryParams = ()=> { const queryData = tableDs.queryDataSet?.toData()[0]; for (const item in queryData) { if (!queryData[item]) { delete queryData[item]; } } const idList = tableDs.currentSelected.map(item => item.get(&#39;id&#39;), ); return { idList, ...queryData, }; } const HeaderButtons = observer(propsr => { //@ts-ignore const { dataSet, name, url, handleFunction, icon, style, engName } = propsr const isDisabled = dataSet?.selected?.length === 0; return ( <> <ButtonPermission type="c7n-pro" key="create" color="primary" funcType="flat" icon="playlist_add" permissionList={[ { code: &#39;/winv/zx/collection-management/collectDetailInfoIn&#39;, type: &#39;button&#39;, meaning: &#39;入库单-新建行&#39;, }, ]} onClick={() => openModal(&#39;In&#39;,{}) } > 入库 </ButtonPermission> <ButtonPermission type="c7n-pro" key="create" color="primary" funcType="flat" disabled={isDisabled} onClick={() => handleReportPrint(tableDs, { reportCode: &#39;CUX.ZX.COLLECT_DETAIL_REPORT&#39;, idsKey:[&#39;id&#39;,&#39;ids&#39;] }) } permissionList={[ { code: &#39;/winv/zx/collection-management/reportPrint&#39;, type: &#39;button&#39;, meaning: &#39;入库单-新建行&#39;, }, ]} > 打印 </ButtonPermission> <ButtonPermission type="c7n-pro" key="create" color="primary" funcType="flat" icon="playlist_add" disabled={ dataSet?.selected?.length!==1} permissionList={[ { code: &#39;/winv/zx/collection-management/collectDetailInfoOut&#39;, type: &#39;button&#39;, meaning: &#39;入库单-新建行&#39;, }, ]} onClick={() =>{ const recordData = dataSet?.selected[0].toData() if(recordData.stockStatus===&#39;NORMAL_IN&#39; && recordData.qty>0){ openModal(&#39;out&#39;,{ trackNumber: recordData.trackNumber, goodsName: recordData.goodsName, poNumber: recordData.poNumber, place: recordData.place, qty: recordData.qty, recipient: recordData.recipient, attribute1: recordData.attribute1, }) }else{ notification.warning({ message: &#39;运单号状态、件数(数量)不满足要求,请检查!&#39;, description:&#39;&#39; }) } }} > 出库 </ButtonPermission> <ButtonPermission type="c7n-pro" key="delete" color="red" funcType="flat" icon="delete" disabled={isDisabled} onClick={()=>{ const recordData = dataSet?.selected.map((item)=>{ return item.toData(); }) Modal.confirm({ title: &#39;是否要删除,删除操作不可逆,是否删除&#39;, onOk: async () => { const res = await handleDelete(recordData) if(res&&res.message){ notification.error({ message: res.message, description: &#39;&#39;, }) }else{ await tableDs.query(); } }, }); }} permissionList={[ { code: &#39;/winv/zx/collectionManagement/delete&#39;, type: &#39;button&#39;, meaning: &#39;入库单-删除行&#39;, }, ]} > {intl.get(&#39;winv.common.button.delete&#39;).d(&#39;删除&#39;)} </ButtonPermission> </> ); }); // @ts-ignore const buttons = [<HeaderButtons dataSet={tableDs} />]; return ( <PageHeaderWrapper title="代收品管理" header={[ <ExcelExport requestUrl={`${API_HOST}${WMS_INV}/v1/${getCurrentOrganizationId()}/cux-collect-detail-infos/export`} queryParams={getExportQueryParams} otherButtonProps={{ className: &#39;label-btn&#39; }} exportAsync />, ]} > <Table dataSet={tableDs} columns={columns} buttons={buttons} customizedCode=&#39;ZX.COLLECTION.MANAGEMENT&#39; /> </PageHeaderWrapper> ); } 解释代码
08-29
欢迎使用“可调增益放大器 Multisim”设计资源包!本资源专为电子爱好者、学生以及工程师设计,旨在展示如何在著名的电路仿真软件Multisim环境下,实现一个具有创新性的数字控制增益放大器项目。 项目概述 在这个项目中,我们通过巧妙结合模拟电路与数字逻辑,设计出一款独特且实用的放大器。该放大器的特点在于其增益可以被精确调控,并非固定不变。用户可以通过控制键,轻松地改变放大器的增益状态,使其在1到8倍之间平滑切换。每一步增益的变化都直观地通过LED数码管显示出来,为观察和调试提供了极大的便利。 技术特点 数字控制: 使用数字输入来调整模拟放大器的增益,展示了数字信号对模拟电路控制的应用。 动态增益调整: 放大器支持8级增益调节(1x至8x),满足不同应用场景的需求。 可视化的增益指示: 利用LED数码管实时显示当前的放大倍数,增强项目的交互性和实用性。 Multisim仿真环境: 所有设计均在Multisim中完成,确保了设计的仿真准确性和学习的便捷性。 使用指南 软件准备: 确保您的计算机上已安装最新版本的Multisim软件。 打开项目: 导入提供的Multisim项目文件,开始查看或修改设计。 仿真体验: 在仿真模式下测试放大器的功能,观察增益变化及LED显示是否符合预期。 实验与调整: 根据需要调整电路参数以优化性能。 实物搭建 (选做): 参考设计图,在真实硬件上复现实验。
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值