| | |
| | | import React from 'react' |
| | | import { useDrag, useDrop } from 'react-dnd' |
| | | import { Icon, Button, Popover, Switch, Checkbox, Form } from 'antd' |
| | | import { Icon, Button, Popover, Switch, Checkbox, Form, Rate } from 'antd' |
| | | import moment from 'moment' |
| | | |
| | | import asyncComponent from '@/utils/asyncComponent' |
| | |
| | | </div> |
| | | </div> |
| | | </div>) |
| | | } else if (card.type === 'rate') { |
| | | formItem = (<div className={'am-list-item ' + (card.place || '')}><div className="am-list-line"><div className="am-input-label">{card.label}</div><div style={{textAlign: 'left'}} className={'am-input-control ' + (card.place === 'up_down' ? 'left' : '')}> |
| | | <Rate value={card.initval || 0} count={card.rateCount || 5} character={card.character ? <Icon type={card.character}/> : <Icon type="star" theme="filled"/>} allowHalf={card.allowHalf === 'true'} /> |
| | | </div></div></div>) |
| | | } else if (card.type === 'fileupload') { |
| | | formItem = ( |
| | | <div className="am-list-item checkbox"> |
| | |
| | | }, |
| | | { |
| | | type: 'form', |
| | | label: '评分', |
| | | subType: 'rate', |
| | | url: '' |
| | | }, |
| | | { |
| | | type: 'form', |
| | | label: CommonDict['header.form.funcvar'], |
| | | subType: 'funcvar', |
| | | url: '' |
| | |
| | | logMap.set(val, true) |
| | | if (pval === config.wrap.mark) { |
| | | parentNodes.push({ |
| | | // ...item, |
| | | ...item, |
| | | $title: item[config.wrap.labelField] || '', |
| | | $key: val, |
| | | $parentId: '' |
| | | }) |
| | | } else if (pval) { |
| | | _options.push({ |
| | | // ...item, |
| | | ...item, |
| | | $title: item[config.wrap.labelField] || '', |
| | | $key: val, |
| | | $parentId: pval |
| | |
| | | } |
| | | |
| | | if (selected) { |
| | | delete _data.children |
| | | MKEmitter.emit('resetSelectLine', config.uuid, (_data ? _data.$key : ''), _data) |
| | | } |
| | | |
| | |
| | | |
| | | if (['date', 'datemonth', 'datetime'].includes(_type) && item.declareType === 'nvarchar(50)') { |
| | | _type = 'text' |
| | | } else if (item.type === 'rate') { |
| | | item.rateCount = item.rateCount || 5 |
| | | let allowHalf = item.allowHalf === 'true' |
| | | |
| | | if (allowHalf) { |
| | | _initval = parseFloat(_initval) |
| | | if (_initval % 0.5 !== 0) { |
| | | _initval = parseInt(_initval) |
| | | } |
| | | } else { |
| | | _initval = parseInt(_initval) |
| | | } |
| | | |
| | | if (isNaN(_initval) || _initval < 0) { |
| | | _initval = 0 |
| | | } else if (_initval > item.rateCount) { |
| | | _initval = item.rateCount |
| | | } |
| | | } |
| | | |
| | | result.push({ |
| | |
| | | _fieldlen = item.fieldlength || 512 |
| | | } else if (item.type === 'number') { |
| | | _fieldlen = item.decimal ? item.decimal : 0 |
| | | } else if (item.type === 'rate') { |
| | | item.rateCount = item.rateCount || 5 |
| | | let allowHalf = item.allowHalf === 'true' |
| | | |
| | | if (allowHalf) { |
| | | _initval = parseFloat(_initval) |
| | | if (_initval % 0.5 !== 0) { |
| | | _initval = parseInt(_initval) |
| | | } |
| | | } else { |
| | | _initval = parseInt(_initval) |
| | | } |
| | | |
| | | if (isNaN(_initval) || _initval < 0) { |
| | | _initval = 0 |
| | | } else if (_initval > item.rateCount) { |
| | | _initval = item.rateCount |
| | | } |
| | | } |
| | | |
| | | if (_initval === undefined) { |
| | |
| | | import React, {Component} from 'react' |
| | | import PropTypes from 'prop-types' |
| | | import { fromJS } from 'immutable' |
| | | import { Form, Row, Col, notification, Tooltip } from 'antd' |
| | | import { Form, Row, Col, notification, Tooltip, Icon, Rate } from 'antd' |
| | | import { QuestionCircleOutlined } from '@ant-design/icons' |
| | | import moment from 'moment' |
| | | |
| | |
| | | |
| | | if (item.type === 'split' || item.type === 'hint') return true |
| | | |
| | | if (!item.field || !['text', 'number', 'switch', 'select', 'link', 'linkMain', 'funcvar', 'date', 'datemonth', 'datetime', 'radio', 'checkbox', 'checkcard', 'fileupload', 'textarea', 'multiselect', 'brafteditor', 'color'].includes(item.type)) return false |
| | | if (!item.field || !['text', 'number', 'switch', 'rate', 'select', 'link', 'linkMain', 'funcvar', 'date', 'datemonth', 'datetime', 'radio', 'checkbox', 'checkcard', 'fileupload', 'textarea', 'multiselect', 'brafteditor', 'color'].includes(item.type)) return false |
| | | |
| | | // 数据自动填充 |
| | | let readin = item.readin !== 'false' |
| | |
| | | |
| | | if (['select', 'link', 'radio', 'checkbox', 'checkcard', 'multiselect'].includes(item.type) && item.resourceType === '1') { |
| | | deForms.push(item) |
| | | } else if (item.type === 'rate') { |
| | | item.rateCount = item.rateCount || 5 |
| | | item.allowHalf = item.allowHalf === 'true' |
| | | |
| | | if (item.allowHalf) { |
| | | item.initval = parseFloat(item.initval) |
| | | if (item.initval % 0.5 !== 0) { |
| | | item.initval = parseInt(item.initval) |
| | | } |
| | | } else { |
| | | item.initval = parseInt(item.initval) |
| | | } |
| | | |
| | | if (isNaN(item.initval) || item.initval < 0) { |
| | | item.initval = 0 |
| | | } else if (item.initval > item.rateCount) { |
| | | item.initval = item.rateCount |
| | | } |
| | | } |
| | | |
| | | if (item.type === 'text') { |
| | |
| | | content = (<MKFileUpload config={item} onChange={(val) => this.recordChange({[item.field]: val})} />) |
| | | } else if (item.type === 'textarea') { |
| | | content = (<MKTextArea config={item} onChange={(val, defer) => !defer && this.recordChange({[item.field]: val})}/>) |
| | | } else if (item.type === 'rate') { |
| | | content = (<Rate count={item.rateCount} disabled={item.readonly} onChange={(val) => this.recordChange({[item.field]: val})} character={item.character ? <Icon type={item.character}/> : <Icon type="star" theme="filled"/>} allowHalf={item.allowHalf}/>) |
| | | } else if (item.type === 'brafteditor') { |
| | | content = (<MKEditor config={item} onChange={(val) => this.recordChange({[item.field]: val})}/>) |
| | | label = item.hidelabel !== 'true' ? label : '' |
| | |
| | | import React from 'react' |
| | | import { useDrag, useDrop } from 'react-dnd' |
| | | import { Select, DatePicker, Input, InputNumber, Button, Popover, Switch, Radio, Checkbox, Form } from 'antd' |
| | | import { Select, DatePicker, Input, InputNumber, Button, Popover, Switch, Radio, Checkbox, Form, Rate, Icon } from 'antd' |
| | | import { QuestionCircleOutlined, UploadOutlined, EditOutlined, CopyOutlined, CloseOutlined } from '@ant-design/icons' |
| | | import moment from 'moment' |
| | | |
| | |
| | | formItem = (<Input style={{marginTop: '4px'}} value={card.linkfield} />) |
| | | } else if (card.type === 'linkMain') { |
| | | formItem = (<Input style={{marginTop: '4px'}} />) |
| | | } else if (card.type === 'rate') { |
| | | formItem = (<Rate value={card.initval || 0} count={card.rateCount || 5} character={card.character ? <Icon type={card.character}/> : <Icon type="star" theme="filled"/>} allowHalf={card.allowHalf === 'true'} />) |
| | | } else if (card.type === 'switch') { |
| | | formItem = (<Switch checkedChildren={card.openText || ''} unCheckedChildren={card.closeText || ''} style={{marginTop: '8px'}} checked={card.initval}/>) |
| | | } else if (card.type === 'radio') { |
| | |
| | | }, |
| | | { |
| | | type: 'form', |
| | | label: '评分', |
| | | subType: 'rate', |
| | | }, |
| | | { |
| | | type: 'form', |
| | | label: CommonDict['model.form.color'], |
| | | subType: 'color', |
| | | }, |
| | |
| | | if (lastItem && lastItem.span) { |
| | | span = lastItem.span |
| | | } |
| | | |
| | | selectCards.forEach(item => { // 循环添加新增字段 |
| | | let newcard = { |
| | | uuid: Utils.getuuid(), |
| | | label: item.label, |
| | | field: item.field, |
| | | initval: '', |
| | | initval: item.type === 'number' ? 0 : '', |
| | | type: item.type, |
| | | resourceType: '0', |
| | | setAll: 'false', |
| | |
| | | _fieldtype = 'datetime' |
| | | } else if (_field.type === 'number') { |
| | | _fieldtype = `decimal(18,${_fieldlen})` |
| | | } else if (_field.type === 'rate') { |
| | | _fieldtype = `decimal(18,2)` |
| | | } |
| | | |
| | | _field.fieldtype = _fieldtype |
| | |
| | | _type = 'datetime' |
| | | } else if (form.type === 'number') { |
| | | _type = `decimal(18,${form.fieldlen})` |
| | | } else if (form.type === 'rate') { |
| | | _type = `decimal(18,2)` |
| | | } |
| | | |
| | | _declarefields.push(`@${_key} ${_type}`) |
| | |
| | | value: 'textarea', |
| | | text: Formdict['model.form.textarea'] |
| | | }, { |
| | | value: 'rate', |
| | | text: '评分' |
| | | }, { |
| | | value: 'color', |
| | | text: Formdict['model.form.color'] |
| | | }, { |
| | |
| | | }, { |
| | | value: 'textarea', |
| | | text: Formdict['model.form.textarea'] |
| | | }, { |
| | | value: 'rate', |
| | | text: '评分' |
| | | }, { |
| | | value: 'funcvar', |
| | | text: Formdict['header.form.funcvar'] |
| | |
| | | }, |
| | | { |
| | | type: 'radio', |
| | | key: 'allowHalf', |
| | | label: '半选', |
| | | initVal: card.allowHalf || 'false', |
| | | options: [{ |
| | | value: 'true', |
| | | text: '支持' |
| | | }, { |
| | | value: 'false', |
| | | text: '不支持' |
| | | }] |
| | | }, |
| | | { |
| | | type: 'radio', |
| | | key: 'readonly', |
| | | label: Formdict['header.form.readonly'], |
| | | initVal: card.readonly || 'false', |
| | |
| | | }] |
| | | }, |
| | | { |
| | | type: 'number', |
| | | min: 1, |
| | | max: 100, |
| | | precision: 0, |
| | | key: 'rateCount', |
| | | label: '总数', |
| | | initVal: card.rateCount || 5, |
| | | tooltip: '默认值为5。', |
| | | required: false |
| | | }, |
| | | { |
| | | type: 'icon', |
| | | key: 'character', |
| | | label: '自定义图标', |
| | | initVal: card.character || '', |
| | | required: false |
| | | }, |
| | | { |
| | | type: 'radio', |
| | | key: 'dropdown', |
| | | label: '下拉框', |
| | |
| | | // forbid: appType !== 'mob' |
| | | // }, |
| | | { |
| | | type: 'number', |
| | | key: 'span', |
| | | min: 1, |
| | | max: 24, |
| | | precision: 0, |
| | | label: '表单宽度', |
| | | initVal: card.span || (['textarea', 'hint', 'checkcard', 'brafteditor'].includes(card.type) ? 24 : 12), |
| | | tooltip: '栅格布局整行24等分。', |
| | | required: true, |
| | | forbid: appType === 'mob' |
| | | }, |
| | | { |
| | | type: 'number', |
| | | key: 'labelwidth', |
| | | min: 1, |
| | | max: 100, |
| | | precision: 1, |
| | | label: '名称宽度', |
| | | initVal: card.labelwidth || 33.3, |
| | | tooltip: '名称占据表单宽度的百分比。注:存在多列表单时,当前表单如果想要占据整行可参照以下比例,两列(16.2)、三列(10.5)、四列(7.7)', |
| | | required: true, |
| | | forbid: appType === 'mob' |
| | | }, |
| | | { |
| | | type: 'radio', |
| | | key: 'compress', |
| | | label: '压缩', |
| | | initVal: card.compress || 'false', |
| | | tooltip: '文件压缩必须为图片,图片格式为jpg、png、gif 或 jpeg', |
| | | options: [{ |
| | | value: 'true', |
| | | text: Formdict['model.true'] |
| | | }, { |
| | | value: 'false', |
| | | text: Formdict['model.false'] |
| | | }] |
| | | }, |
| | | { |
| | | type: 'number', |
| | | key: 'limit', |
| | | min: 0.01, |
| | | max: 1000, |
| | | precision: 2, |
| | | label: '起点(M)', |
| | | initVal: card.limit || 2, |
| | | tooltip: '压缩起点,小于起点值的文件不进行压缩。', |
| | | required: true |
| | | }, |
| | | { |
| | | type: 'textarea', |
| | | key: 'rduri', |
| | | label: '转存接口', |
| | | rows: 1, |
| | | initVal: card.rduri || '', |
| | | tooltip: '图片转存在同一单点服务器下的其他业务系统。', |
| | | required: false, |
| | | readonly: false |
| | | }, |
| | | { |
| | | type: 'textarea', |
| | | key: 'proRduri', |
| | | label: '正式接口', |
| | | rows: 1, |
| | | initVal: card.proRduri || '', |
| | | tooltip: '正式系统转存接口,图片转存在同一单点服务器下的其他业务系统。', |
| | | required: false, |
| | | readonly: false |
| | | }, |
| | | { |
| | | type: 'text', |
| | | key: 'suffix', |
| | | label: '后缀名', |
| | | tooltip: '可以上传文件的后缀名,多个类型用逗号分隔,空值时不校验。', |
| | | initVal: card.suffix || '', |
| | | required: false, |
| | | readonly: false |
| | | }, |
| | | { |
| | | type: 'radio', |
| | | key: 'encryption', |
| | | label: '加密传输', |
| | |
| | | forbid: appType !== 'mob' |
| | | }, |
| | | { |
| | | type: 'radio', |
| | | key: 'compress', |
| | | label: '压缩', |
| | | initVal: card.compress || 'false', |
| | | tooltip: '文件压缩必须为图片,图片格式为jpg、png、gif 或 jpeg', |
| | | options: [{ |
| | | value: 'true', |
| | | text: Formdict['model.true'] |
| | | }, { |
| | | value: 'false', |
| | | text: Formdict['model.false'] |
| | | }] |
| | | }, |
| | | { |
| | | type: 'number', |
| | | key: 'limit', |
| | | min: 0.01, |
| | | max: 1000, |
| | | precision: 2, |
| | | label: '起点(M)', |
| | | initVal: card.limit || 2, |
| | | tooltip: '压缩起点,小于起点值的文件不进行压缩。', |
| | | required: true |
| | | }, |
| | | { |
| | | type: 'number', |
| | | key: 'span', |
| | | min: 1, |
| | | max: 24, |
| | | precision: 0, |
| | | label: '表单宽度', |
| | | initVal: card.span || (['textarea', 'hint', 'checkcard', 'brafteditor'].includes(card.type) ? 24 : 12), |
| | | tooltip: '栅格布局整行24等分。', |
| | | required: true, |
| | | forbid: appType === 'mob' |
| | | }, |
| | | { |
| | | type: 'number', |
| | | key: 'labelwidth', |
| | | min: 1, |
| | | max: 100, |
| | | precision: 1, |
| | | label: '名称宽度', |
| | | initVal: card.labelwidth || 33.3, |
| | | tooltip: '名称占据表单宽度的百分比。注:存在多列表单时,当前表单如果想要占据整行可参照以下比例,两列(16.2)、三列(10.5)、四列(7.7)', |
| | | required: true, |
| | | forbid: appType === 'mob' |
| | | }, |
| | | { |
| | | type: 'textarea', |
| | | key: 'rduri', |
| | | label: '转存接口', |
| | | rows: 1, |
| | | initVal: card.rduri || '', |
| | | tooltip: '图片转存在同一单点服务器下的其他业务系统。', |
| | | required: false, |
| | | readonly: false |
| | | }, |
| | | { |
| | | type: 'textarea', |
| | | key: 'proRduri', |
| | | label: '正式接口', |
| | | rows: 1, |
| | | initVal: card.proRduri || '', |
| | | tooltip: '正式系统转存接口,图片转存在同一单点服务器下的其他业务系统。', |
| | | required: false, |
| | | readonly: false |
| | | }, |
| | | { |
| | | type: 'text', |
| | | key: 'suffix', |
| | | label: '后缀名', |
| | | tooltip: '可以上传文件的后缀名,多个类型用逗号分隔,空值时不校验。', |
| | | initVal: card.suffix || '', |
| | | required: false, |
| | | readonly: false |
| | | }, |
| | | |
| | | { |
| | | type: 'select', |
| | | key: 'supField', |
| | | label: '上级表单', |
| | |
| | | import React, {Component} from 'react' |
| | | import PropTypes from 'prop-types' |
| | | import { fromJS } from 'immutable' |
| | | import { Form, Row, Col, Input, Select, Icon, Radio, notification, InputNumber, Tooltip } from 'antd' |
| | | import { Form, Row, Col, Input, Select, Radio, notification, InputNumber, Tooltip } from 'antd' |
| | | import { QuestionCircleOutlined } from '@ant-design/icons' |
| | | |
| | | import { formRule } from '@/utils/option.js' |
| | |
| | | const ColorSketch = asyncComponent(() => import('@/mob/colorsketch')) |
| | | const FieldsTable = asyncComponent(() => import('./fieldtable')) |
| | | const DataTable = asyncComponent(() => import('./datatable')) |
| | | const MkIcon = asyncComponent(() => import('@/components/mkIcon')) |
| | | |
| | | const modalTypeOptions = { |
| | | text: ['initval', 'readonly', 'required', 'hidden', 'readin', 'fieldlength', 'regular', 'interception', 'span', 'labelwidth', 'tooltip', 'extra', 'enter', 'cursor', 'scan', 'splitline', 'placeholder', 'place', 'marginTop', 'marginBottom'], |
| | |
| | | datetime: ['initval', 'readonly', 'required', 'hidden', 'readin', 'span', 'labelwidth', 'tooltip', 'extra', 'declareType', 'mode', 'splitline', 'marginTop', 'marginBottom', 'minDate', 'maxDate'], |
| | | textarea: ['initval', 'readonly', 'required', 'hidden', 'readin', 'fieldlength', 'span', 'labelwidth', 'maxRows', 'encryption', 'interception', 'tooltip', 'extra', 'count', 'placeholder', 'marginTop', 'marginBottom'], |
| | | color: ['initval', 'readonly', 'required', 'hidden', 'readin', 'span', 'labelwidth', 'tooltip', 'extra', 'marginTop', 'marginBottom'], |
| | | rate: ['initval', 'readonly', 'required', 'hidden', 'readin', 'span', 'labelwidth', 'splitline', 'tooltip', 'extra', 'marginTop', 'marginBottom', 'allowHalf', 'rateCount', 'character', 'place'], |
| | | hint: ['label', 'type', 'blacklist', 'message', 'span', 'labelwidth', 'splitline', 'marginTop', 'marginBottom'], |
| | | split: ['label', 'type', 'marginTop', 'marginBottom'], |
| | | brafteditor: ['required', 'hidelabel', 'hidden', 'readin', 'fieldlength', 'readonly', 'span', 'labelwidth', 'tooltip', 'extra', 'encryption', 'marginTop', 'marginBottom'], |
| | |
| | | resourceType: resourceType, |
| | | linkSubFields: linkSubFields, |
| | | formlist: formlist.map(form => { |
| | | if (dateOptions.hasOwnProperty(type) && form.key === 'initval') { |
| | | form.options = dateOptions[type] |
| | | form.type = 'select' |
| | | } else if (type === 'switch' && form.key === 'initval') { |
| | | form.initVal = !!form.initVal |
| | | form.options = [ |
| | | {value: true, text: '开'}, |
| | | {value: false, text: '关'} |
| | | ] |
| | | form.type = 'radio' |
| | | } else if (type === 'number' && form.key === 'initval') { |
| | | form.type = 'number' |
| | | form.initVal = form.initVal || 0 |
| | | form.required = true |
| | | if (form.key === 'initval') { |
| | | if (dateOptions.hasOwnProperty(type)) { |
| | | form.options = dateOptions[type] |
| | | form.type = 'select' |
| | | } else if (type === 'switch') { |
| | | form.initVal = !!form.initVal |
| | | form.options = [ |
| | | {value: true, text: '开'}, |
| | | {value: false, text: '关'} |
| | | ] |
| | | form.type = 'radio' |
| | | } |
| | | if (type === 'number') { |
| | | form.type = 'number' |
| | | form.initVal = form.initVal || 0 |
| | | form.required = true |
| | | } else if (type === 'rate') { |
| | | form.type = 'number' |
| | | form.initVal = form.initVal || 0 |
| | | form.required = false |
| | | } |
| | | } else if (form.key === 'label') { |
| | | form.required = true |
| | | if (type === 'hint') { |
| | |
| | | } else if (value === 'number') { |
| | | form.type = 'number' |
| | | form.required = true |
| | | form.initVal = 0 |
| | | } else if (value === 'rate') { |
| | | form.type = 'number' |
| | | form.required = false |
| | | form.initVal = 0 |
| | | } else { |
| | | form.type = 'text' |
| | |
| | | > |
| | | {item.options.map((option, i) => |
| | | <Select.Option key={`${i}`} value={option.value || option.field || ''}> |
| | | {item.key === 'icon' && <Icon type={option.text} />} {option.text || option.label} |
| | | {option.text || option.label} |
| | | </Select.Option> |
| | | )} |
| | | </Select> |
| | |
| | | </Form.Item> |
| | | </Col> |
| | | ) |
| | | } else if (item.type === 'icon') { |
| | | fields.push( |
| | | <Col span={12} key={index}> |
| | | <Form.Item label={item.tooltip ? |
| | | <Tooltip placement="topLeft" title={item.tooltip}> |
| | | <QuestionCircleOutlined className="mk-form-tip" /> |
| | | {item.label} |
| | | </Tooltip> : item.label |
| | | }> |
| | | {getFieldDecorator(item.key, { |
| | | initialValue: item.initVal || '', |
| | | rules: [{ |
| | | required: !!item.required, |
| | | message: this.props.dict['form.required.select'] + item.label + '!' |
| | | }] |
| | | })( |
| | | <MkIcon allowClear /> |
| | | )} |
| | | </Form.Item> |
| | | </Col> |
| | | ) |
| | | } |
| | | }) |
| | | |
| | |
| | | } else if (_f.type === 'number') { |
| | | _type = `decimal(18,${_fieldlen})` |
| | | _select.push(`@${_f.field}=0`) |
| | | } else if (_f.type === 'rate') { |
| | | _type = `decimal(18,2)` |
| | | _select.push(`@${_f.field}=0`) |
| | | } else { |
| | | _select.push(`@${_f.field}=''`) |
| | | } |
| | |
| | | if (!_initvars.includes(_key)) { |
| | | _initvars.push(_key) |
| | | |
| | | if (form.type === 'number') { |
| | | if (form.type === 'number' || form.type === 'rate') { |
| | | let val = form.value |
| | | if (typeof(val) !== 'number') { |
| | | val = parseFloat(val) |
| | |
| | | _type = 'datetime' |
| | | } else if (form.type === 'number') { |
| | | _type = `decimal(18,${form.fieldlen})` |
| | | } else if (form.type === 'rate') { |
| | | _type = `decimal(18,2)` |
| | | } |
| | | |
| | | _declarefields.push(`@${_key} ${_type}`) |
| | |
| | | type = 'datetime=null' |
| | | } else if (item.type === 'number') { |
| | | type = `decimal(18,${item.decimal})=0` |
| | | } else if (item.type === 'rate') { |
| | | type = `decimal(18,2)=0` |
| | | } else { |
| | | type = 'nvarchar(50)=\'\'' |
| | | } |