npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2024 – Pkg Stats / Ryan Hefner

@anmed/flex-business-form

v0.0.6

Published

## 动态卡片

Downloads

17

Readme

动态表单公共库

动态卡片

字段定义

每个字段包括以下属性

| 名称 | 说明 | 类型和默认值 | |-------|------------------------------|---------------------| | name | 字段名称 | 字符型 | | label | 标签文字 | 字符型 | | code | 字段编码,备用的关联对象的属性值 | 字符型 | | mdmCode | 标准编码,关联的数据值,如果不存在,将使用code值关联 | 字符型 | | required | 必填 | 布尔,默认为false | | type | 类型 | 枚举型,系统支持的各种类型 | | colSpan | 跨列数 | 整数,默认为1 | | visibility | 展示方式 | 枚举,参考枚举值 Visibility | | readonly | 只读 | 布尔型,默认为false | | enable | 是否可用 | 布尔型,默认为true | | onChange | 值变化的处理函数名 | 字符型 | | attrs | 字段的其他属性 | 字符型 |

布局

卡片的布局,支持3中,分别为:

  • 0 - 行列布局(暂时不支持)
  • 1 - 流动布局
  • 2 - 网格布局(暂时不支持)

流动布局

字段布局属性

| 名称 | 说明 | 类型和默认值 | |-----|-----|--------| | - | - | - |

流动布局示意

{
  "mode": 1,
  "layouts": [
    {
      "name": "证件类型",
      "label": "证件类型",
      "code": "idCardType",
      "mdmCode": "A00005",
      "required": true,
      "type": "OptionsSelector",
      "colSpan": 3,
      "visibility": 2,
      "readonly": false,
      "enable": true,
      "onChange": "onCardTypeChange",
      "attrs": {
        "options": "ops-card-type"
      }
    },
    {
      "name": "证件号码",
      "label": "证件号码",
      "code": "idCardNo",
      "mdmCode": "A00002",
      "required": true,
      "type": "TextEditor",
      "colSpan": 3,
      "visibility": 2,
      "readonly": false,
      "enable": true,
      "onChange": "onCardNoChange",
      "attrs": {
        "options": "ops-card-type"
      }
    },
    {
      "name": "性别",
      "label": "性别",
      "code": "gender",
      "mdmCode": "A00006",
      "required": true,
      "type": "OptionsSelector",
      "colSpan": 3,
      "visibility": 2,
      "readonly": false,
      "enable": true,
      "attrs": {
        "options": [
          {
            "code": "M",
            "text": "男性"
          },
          {
            "code": "F",
            "text": "女性"
          }
        ]
      }
    },
    {
      "name": "出生日期",
      "label": "生日",
      "code": "dob",
      "mdmCode": "A00008",
      "required": true,
      "type": "DateInput",
      "colSpan": 3,
      "visibility": 2,
      "readonly": false,
      "enable": true,
      "attrs": {
        
      }
    },
    {
      "name": "年龄",
      "label": "年龄",
      "code": "age",
      "mdmCode": "A00007",
      "required": true,
      "type": "NumberInput",
      "colSpan": 3,
      "visibility": 2,
      "readonly": true,
      "enable": true,
      "attrs": {
        
      }
    }
  ]
}

脚本


const NaIDCard = 1; // 身份证类型的编码

class PatientInfoCard extends BaseCard {
    constructor (data, form) {
        super(layouts, form);
        this.data = data;
    }

    /**
     * 当卡片类型发生变化的时候,根据类型设置生日和性别为只读或可编辑
     * @param value
     */
    onCardTypeChange(value) {
        if (value == NaIDCard) {
            this.card['dob'].readonly = true;
            this.card['gender'].readonly = true;
            this.data.dob = utils.parseDobFromCardNo(this.data.cardNo);
            this.data.gender = utils.parseGenderFromCardNo(this.data.cardNo);
            this.data.age = utils.calculateAge(this.data.dob);
        } else {
            this.card['dob'].readonly = false;
            this.card['gender'].readonly = false;
        }
    }
    
    onCardNoChange(value) {
        if (this.card.idCardType == NaIDCard) {
            this.data.dob = utils.parseDobFromCardNo(this.data.cardNo);
            this.data.gender = utils.parseGenderFromCardNo(this.data.cardNo);
            this.data.age = utils.calculateAge(this.data.dob);
        }
    }
    
    onDobChange(value) {
        this.data.age = utils.calculateAge(this.data.dob);
    }
    
    onNumOfBabiesChange(value) {
        if (numOfBabies > this.formData.babies) {
            for (let i = this.formData.babies.length; i<numOfBabies; i++) {
                let newborn = {};
                this.formData.babies.push(newborn);
                this.newbornCards.push(new ctx.NewbornCard(newborn), this);
            }
        } else if (numOfBabies < this.formData.babies) {
            this.formData.babies.splice(numOfBabies);
            this.newbornCard.splice(numOfBabies);
        }
    }
}

register('PatientInfoCard', PatientInfoCard);

动态表单

表单脚本


require(['PatientInfoCard', 'PatientHistoryCard', 'PatientContactCard', 'NewbornCard']);

class PatientForm extends BaseForm {
    
    constructor(formData) {
        super(formData);
        this.infoCard = new ctx.PatientInfoCard(formData.baseInfo, this);
        this.historyCard = new ctx.PatientHistoryCard(formData.history, this);
        this.contactInfoCard = new ctx.PatientContactCard(formData.contactInfo, this);
        this.newbornCards = this.buildNewbornCards(formData.babies);
    }
    
    getFormCards() {
        return [
            {
                title: '基本信息',
                cards: [this.infoCard, this.historyCard]
            },
            {
                title: '病史',
                cards: [this.historyCard]
            },
            {
                title: '新生儿信息',
                cards: [...this.newbornCards]
            }
        ]
    }
    
}

API接口

读取动态表单脚本

  • URL: /flex-business-form/api/script?code=${your-form-code}&auxCode={your-aux-code}
  • 返回数据
class PatientInfoCard extends BaseCard {
  
}

class PatientHistoryCard extends BaseCard {
  
}

class PatientContactCard extends BaseCard {
    
}

class NewbornCard extends BaseCard {
    
}

class QCStrokeForm extends BaseForm {
    
}

return QCStrokeForm;

读取动态表单布局

  • URL: /flex-business-form/api/layouts?code=${your-form-code}&auxCode={your-aux-code}
  • 返回数据
{
  "PatientInfoCard": "{\"mode\":\"0\"}",
  "PatientHistoryCard": "{\"mode\": \"0\"}"
}