| | |
| | | { |
| | | "appId": "201912040924165801464FF1788654BC5AC73", |
| | | "appkey": "20191106103859640976D6E924E464D029CF0", |
| | | "appId": "202108312122504607B107A83F55B40C98CCF", |
| | | "appkey": "20210831212235413F287EC3BF489424496C8", |
| | | "mainSystemApi": "http://sso.mk9h.cn/cloud/webapi/dostars", |
| | | "systemType": "", |
| | | "externalDatabase": "", |
| | | "lineColor": "", |
| | | "filter": "false", |
| | | "defaultApp": "mk", |
| | | "defaultApp": "mkindustry", |
| | | "defaultLang": "zh-CN", |
| | | "WXAppID": "wx4d8a34c8d4494872", |
| | | "WXAppID": "", |
| | | "WXminiAppID": "", |
| | | "nginx": "true", |
| | | "debugger": false, |
| | |
| | | "transfer": "false", |
| | | "keepPassword": "true", |
| | | "platforms": ["H5", "wechat", "android", "ios", "wxMiniProgram"], |
| | | "host": "http://qingqiumarket.cn", |
| | | "service": "MKWMS/" |
| | | "host": "http://demo.mk9h.cn", |
| | | "service": "erp_new/" |
| | | } |
| | |
| | | color: ['eleType', 'datatype', 'width', 'lenWidRadio', 'noValue', 'copyable'], |
| | | } |
| | | |
| | | class MainSearch extends Component { |
| | | class ElementEditForm extends Component { |
| | | static propTpyes = { |
| | | config: PropTypes.object, // 组件信息 |
| | | formlist: PropTypes.any, // 表单信息 |
| | |
| | | } |
| | | |
| | | state = { |
| | | formlist: null, // 表单信息 |
| | | eleType: '', |
| | | datatype: '', |
| | | showType: '', |
| | | showInfo: 'false', |
| | | fixStyle: '', |
| | | link: '' |
| | | formlist: null // 表单信息 |
| | | } |
| | | |
| | | record = null |
| | | |
| | | UNSAFE_componentWillMount () { |
| | | const { card, config, side } = this.props |
| | | let _options = this.getOptions(card.eleType, card.datatype, card.link, (card.showType || 'line'), card.showInfo, card.fixStyle || '', card.posterType || '') |
| | | const { card, config, side, formlist } = this.props |
| | | |
| | | this.record = {} |
| | | |
| | | formlist.forEach(item => { |
| | | this.record[item.key] = item.initVal |
| | | }) |
| | | |
| | | let _options = this.getOptions() |
| | | |
| | | this.setState({ |
| | | link: card.link, |
| | | eleType: card.eleType, |
| | | datatype: card.datatype, |
| | | showType: card.showType || 'line', |
| | | showInfo: card.showInfo || 'false', |
| | | fixStyle: card.fixStyle || '', |
| | | posterType: card.posterType || '', |
| | | formlist: this.props.formlist.map(item => { |
| | | formlist: formlist.map(item => { |
| | | item.hidden = !_options.includes(item.key) |
| | | |
| | | if (item.key === 'field' || item.key === 'linkurl' || item.key === 'bgImage' || item.key === 'posterField') { |
| | |
| | | }) |
| | | } |
| | | |
| | | getOptions = (eleType, datatype, link, showType, showInfo, fixStyle, posterType) => { |
| | | let _options = fromJS(cardTypeOptions[eleType]).toJS() // 选项列表 |
| | | getOptions = () => { |
| | | let _options = fromJS(cardTypeOptions[this.record.eleType]).toJS() // 选项列表 |
| | | |
| | | if (['text', 'number', 'picture', 'slider', 'barcode', 'qrcode', 'video', 'color'].includes(eleType)) { |
| | | if (datatype === 'dynamic') { |
| | | if (['text', 'number', 'picture', 'slider', 'barcode', 'qrcode', 'video', 'color'].includes(this.record.eleType)) { |
| | | if (this.record.datatype === 'dynamic') { |
| | | _options.push('field') |
| | | if (eleType === 'number') { |
| | | if (this.record.eleType === 'number') { |
| | | _options.push('decimal', 'format') |
| | | } |
| | | } else if (eleType === 'picture' || eleType === 'video') { |
| | | } else if (this.record.eleType === 'picture' || this.record.eleType === 'video') { |
| | | _options.push('url') |
| | | } else { |
| | | _options.push('value') |
| | | } |
| | | if (eleType === 'video' && posterType) { |
| | | if (posterType === 'dynamic') { |
| | | if (this.record.eleType === 'video' && this.record.posterType) { |
| | | if (this.record.posterType === 'dynamic') { |
| | | _options.push('posterField') |
| | | } else { |
| | | _options.push('posterUrl') |
| | | } |
| | | } |
| | | |
| | | if (['text', 'picture'].includes(eleType) && link) { |
| | | // if (link === 'dynamic' || link === 'static') { |
| | | if (['text', 'picture'].includes(this.record.eleType) && this.record.link) { |
| | | _options.push('linkurl', 'joint', 'linkType') |
| | | // } |
| | | } else if (eleType === 'picture' && !link) { |
| | | } else if (this.record.eleType === 'picture' && !this.record.link) { |
| | | _options.push('scale') |
| | | } else if (eleType === 'slider') { |
| | | if (showInfo === 'true') { |
| | | } else if (this.record.eleType === 'slider') { |
| | | if (this.record.showInfo === 'true') { |
| | | _options.push('infoColor') |
| | | } |
| | | if (showType !== 'line') { |
| | | if (this.record.showType !== 'line') { |
| | | _options.push('outlineWidth', 'textAlign') |
| | | } |
| | | } |
| | | } else if (eleType === 'icon') { |
| | | if (datatype === 'dynamic') { |
| | | } else if (this.record.eleType === 'icon') { |
| | | if (this.record.datatype === 'dynamic') { |
| | | _options.push('field', 'noValue') |
| | | } else { |
| | | _options.push('icon') |
| | | } |
| | | } else if (this.record.eleType === 'formula' && this.record.eval === 'true') { |
| | | _options.push('decimal') |
| | | } |
| | | if (_options.includes('fixStyle') && fixStyle === 'alone') { |
| | | if (_options.includes('fixStyle') && this.record.fixStyle === 'alone') { |
| | | _options.push('fixSize', 'fixColor', 'fixLeft', 'fixRight') |
| | | } |
| | | |
| | |
| | | * 3、切换标签类型,重置可选标签 |
| | | */ |
| | | selectChange = (key, value, option) => { |
| | | const { card, config, side } = this.props |
| | | const { datatype, eleType, showType, showInfo, fixStyle, posterType } = this.state |
| | | const { config, side } = this.props |
| | | |
| | | this.record[key] = value |
| | | |
| | | if (key === 'eleType') { |
| | | let _options = this.getOptions(value, datatype, '', showType, showInfo, fixStyle, posterType) |
| | | this.record.link = '' |
| | | let _options = this.getOptions() |
| | | |
| | | if (value === 'splitline') { |
| | | this.record.color = '#EBE9E9' |
| | | } else if (value === 'formula') { |
| | | this.record.decimal = '' |
| | | } |
| | | |
| | | let _formlist = this.state.formlist.map(item => { |
| | | item.initVal = this.record[item.key] |
| | | item.hidden = !_options.includes(item.key) |
| | | |
| | | if (item.key === 'field') { |
| | |
| | | } |
| | | } else if (item.key === 'url') { |
| | | item.required = value !== 'qrcode' |
| | | } else if (item.key === 'showInfo') { |
| | | item.initVal = showInfo |
| | | } else if (item.key === 'posterType') { |
| | | item.initVal = posterType |
| | | } else if (item.key === 'fixStyle') { |
| | | item.initVal = fixStyle |
| | | } else if (item.key === 'color') { |
| | | if (value === 'splitline') { |
| | | item.initVal = '#EBE9E9' |
| | | } |
| | | } |
| | | |
| | | return item |
| | |
| | | } |
| | | |
| | | this.setState({ |
| | | link: '', |
| | | eleType: value, |
| | | showType: card.showType || 'line', |
| | | formlist: _formlist |
| | | }, () => { |
| | | if (value === 'splitline') { |
| | |
| | | this.props.form.setFieldsValue({value: option.props.title}) |
| | | } |
| | | } else if (key === 'link') { |
| | | let _options = this.getOptions(eleType, datatype, value, showType, showInfo, fixStyle, posterType) |
| | | let _options = this.getOptions() |
| | | this.setState({ |
| | | link: value, |
| | | formlist: this.state.formlist.map(item => { |
| | | item.initVal = this.record[item.key] |
| | | item.hidden = !_options.includes(item.key) |
| | | |
| | | if (item.key === 'linkurl') { |
| | | item.type = value === 'dynamic' ? 'select' : 'textarea' |
| | | } |
| | | return item |
| | | }) |
| | | }) |
| | | } |
| | | } |
| | | |
| | | onChange = (e, key) => { |
| | | const { eleType, datatype, link, showType, showInfo, fixStyle, posterType } = this.state |
| | | let value = e.target.value |
| | | |
| | | if (key === 'datatype') { |
| | | let _options = this.getOptions(eleType, value, link, showType, showInfo, fixStyle, posterType) |
| | | } else if (['datatype', 'showInfo', 'showType', 'fixStyle', 'posterType', 'eval'].includes(key)) { |
| | | let _options = this.getOptions() |
| | | |
| | | this.setState({ |
| | | datatype: value, |
| | | formlist: this.state.formlist.map(item => { |
| | | item.initVal = this.record[item.key] |
| | | item.hidden = !_options.includes(item.key) |
| | | |
| | | return item |
| | | }) |
| | | }) |
| | | } else if (key === 'link') { |
| | | let _options = this.getOptions(eleType, datatype, value, showType, showInfo, fixStyle, posterType) |
| | | this.setState({ |
| | | link: value, |
| | | formlist: this.state.formlist.map(item => { |
| | | item.hidden = !_options.includes(item.key) |
| | | if (item.key === 'linkurl') { |
| | | item.type = value === 'dynamic' ? 'select' : 'textarea' |
| | | } |
| | | return item |
| | | }) |
| | | }) |
| | | } else if (key === 'showInfo') { |
| | | let _options = this.getOptions(eleType, datatype, link, showType, value, fixStyle, posterType) |
| | | this.setState({ |
| | | showInfo: value, |
| | | formlist: this.state.formlist.map(item => { |
| | | item.hidden = !_options.includes(item.key) |
| | | return item |
| | | }) |
| | | }) |
| | | } else if (key === 'showType') { |
| | | this.setState({ |
| | | showType: value |
| | | }, () => { |
| | | let _options = this.getOptions(eleType, datatype, link, value, showInfo, fixStyle, posterType) |
| | | this.setState({ |
| | | formlist: this.state.formlist.map(item => { |
| | | item.hidden = !_options.includes(item.key) |
| | | return item |
| | | }) |
| | | }) |
| | | }) |
| | | } else if (key === 'fixStyle') { |
| | | this.setState({ |
| | | fixStyle: value |
| | | }, () => { |
| | | let _options = this.getOptions(eleType, datatype, link, showType, showInfo, value, posterType) |
| | | this.setState({ |
| | | formlist: this.state.formlist.map(item => { |
| | | item.hidden = !_options.includes(item.key) |
| | | return item |
| | | }) |
| | | }) |
| | | }) |
| | | } else if (key === 'posterType') { |
| | | this.setState({ |
| | | posterType: value |
| | | }, () => { |
| | | let _options = this.getOptions(eleType, datatype, link, showType, showInfo, fixStyle, value) |
| | | this.setState({ |
| | | formlist: this.state.formlist.map(item => { |
| | | item.hidden = !_options.includes(item.key) |
| | | return item |
| | | }) |
| | | }) |
| | | }) |
| | | } |
| | |
| | | message: '请选择' + item.label + '!' |
| | | }] |
| | | })( |
| | | <Radio.Group onChange={(e) => {this.onChange(e, item.key)}} disabled={item.readonly}> |
| | | <Radio.Group onChange={(e) => {this.selectChange(item.key, e.target.value)}} disabled={item.readonly}> |
| | | {item.options.map(option => { |
| | | return ( |
| | | <Radio key={option.value} value={option.value}>{option.text}</Radio> |
| | |
| | | } |
| | | |
| | | handleConfirm = () => { |
| | | const { config } = this.props |
| | | |
| | | // 表单提交时检查输入值是否正确 |
| | | return new Promise((resolve, reject) => { |
| | | this.props.form.validateFieldsAndScroll((err, values) => { |
| | | if (!err) { |
| | | values.uuid = this.props.card.uuid |
| | | values.marks = this.props.card.marks || null |
| | | |
| | | // eslint-disable-next-line |
| | | if (values.eleType === 'formula' && values.eval !== 'false' && /^[\u4E00-\u9FA50-9a-zA-Z_\s@\+\-\*\/]*$/ig.test(values.formula) && /[\+\-\*\/]/ig.test(values.formula)) { |
| | | let cols = [] |
| | | config.subColumns && config.subColumns.forEach(col => { |
| | | if (/^(Int|Decimal)/ig.test(col.datatype)) { |
| | | cols.push({reg: new RegExp('@' + col.field + '@', 'ig'), value: `(@${col.field}@)`}) |
| | | } |
| | | }) |
| | | config.columns.forEach(col => { |
| | | if (/^(Int|Decimal)/ig.test(col.datatype)) { |
| | | cols.push({reg: new RegExp('@' + col.field + '@', 'ig'), value: `(@${col.field}@)`}) |
| | | } |
| | | }) |
| | | |
| | | cols.forEach(col => { |
| | | values.formula = values.formula.replace(col.reg, col.value) |
| | | }) |
| | | } |
| | | |
| | | resolve(values) |
| | | } else { |
| | |
| | | } |
| | | } |
| | | |
| | | export default Form.create()(MainSearch) |
| | | export default Form.create()(ElementEditForm) |
| | |
| | | required: true |
| | | }, |
| | | { |
| | | type: 'radio', |
| | | key: 'eval', |
| | | label: '解析', |
| | | initVal: card.eval || 'false', |
| | | tooltip: '当公式内容涉及计算时请选择“是”,当公式内容为字段拼接时请选择“否”。', |
| | | required: false, |
| | | options: [{ |
| | | value: 'true', |
| | | text: '是' |
| | | }, { |
| | | value: 'false', |
| | | text: '否' |
| | | }] |
| | | }, |
| | | { |
| | | type: 'number', |
| | | key: 'decimal', |
| | | min: 0, |
| | |
| | | key: 'joint', |
| | | label: '拼接参数', |
| | | initVal: card.joint || 'true', |
| | | required: false, |
| | | options: [{ |
| | | value: 'true', |
| | | text: '是' |
| | | }, { |
| | | value: 'false', |
| | | text: '否' |
| | | }] |
| | | }, |
| | | { |
| | | type: 'radio', |
| | | key: 'eval', |
| | | label: '解析', |
| | | initVal: card.eval || 'false', |
| | | tooltip: '当公式内容涉及计算时请选择“是”,当公式内容为字段拼接时请选择“否”。', |
| | | required: false, |
| | | options: [{ |
| | | value: 'true', |
| | |
| | | } |
| | | |
| | | dropButton = (id) => { |
| | | const { cards, cardCell } = this.props |
| | | const { cards } = this.props |
| | | |
| | | if (!cards.action) return |
| | | if (cardCell.type === 'custom') return |
| | | |
| | | let index = cards.action.findIndex(item => item.uuid === id) |
| | | |
| | |
| | | let _col = null |
| | | if (config.type === 'table') { |
| | | config.cols.forEach(col => { |
| | | if (col.type !== 'action') return |
| | | if (col.type !== 'custom') return |
| | | |
| | | col.elements = col.elements.filter(item => { |
| | | if (item.uuid === id) { |
| | |
| | | return cell |
| | | }) |
| | | |
| | | let loopCol = (col) => { |
| | | col.subcols = col.subcols.map(c => { |
| | | c.uuid = Utils.getuuid() |
| | | |
| | | if (c.type === 'colspan' && c.subcols) { |
| | | c = loopCol(c) |
| | | } else if (c.type === 'custom' && c.elements) { |
| | | c.elements = c.elements.map(cell => { |
| | | cell.uuid = Utils.getuuid() |
| | | return cell |
| | | }) |
| | | } |
| | | return c |
| | | }) |
| | | |
| | | return col |
| | | } |
| | | |
| | | res.cols = res.cols.map(col => { |
| | | let loopCol = (cols) => { |
| | | return cols.map(col => { |
| | | col.uuid = Utils.getuuid() |
| | | |
| | | if (col.type === 'action') { |
| | | col.type = 'custom' |
| | | } |
| | | |
| | | if (col.type === 'colspan' && col.subcols) { |
| | | col = loopCol(col) |
| | | col.subcols = loopCol(col.subcols) |
| | | } else if (col.type === 'custom' && col.elements) { |
| | | col.elements = col.elements.map(cell => { |
| | | cell.uuid = Utils.getuuid() |
| | | return cell |
| | | }) |
| | | } else if (col.type === 'action' && col.elements) { |
| | | col.elements = col.elements.map(cell => { |
| | | cell.uuid = Utils.getuuid() |
| | | return cell |
| | | }) |
| | | } |
| | | return col |
| | | }) |
| | | } |
| | | |
| | | res.cols = loopCol(res.cols) |
| | | |
| | | let oriUids = {} |
| | | res.action = res.action.map(cell => { |
| | |
| | | }) |
| | | } |
| | | } else if (item.copyType === 'cols') { |
| | | let loopCol = (col) => { |
| | | col.subcols = col.subcols.map(c => { |
| | | c.uuid = Utils.getuuid() |
| | | let loopCol = (cols) => { |
| | | return cols.map(col => { |
| | | col.uuid = Utils.getuuid() |
| | | |
| | | if (c.type === 'colspan' && c.subcols) { |
| | | c = loopCol(c) |
| | | } else if (c.type === 'custom' && c.elements) { |
| | | c.elements = c.elements.map(cell => { |
| | | if (col.type === 'action') { |
| | | col.type = 'custom' |
| | | } |
| | | |
| | | if (col.type === 'colspan' && col.subcols) { |
| | | col.subcols = loopCol(col.subcols) |
| | | } else if (col.type === 'custom' && col.elements) { |
| | | col.elements = col.elements.map(cell => { |
| | | cell.uuid = Utils.getuuid() |
| | | return cell |
| | | }) |
| | | } |
| | | return c |
| | | }) |
| | | |
| | | return col |
| | | }) |
| | | } |
| | | |
| | | item.cols = item.cols.map(_item => { |
| | | _item.uuid = Utils.getuuid() |
| | | if (_item.type === 'colspan' && _item.subcols) { |
| | | _item = loopCol(_item) |
| | | } else if (_item.type === 'custom' && _item.elements) { |
| | | _item.elements = _item.elements.map(cell => { |
| | | cell.uuid = Utils.getuuid() |
| | | return cell |
| | | }) |
| | | } else if (_item.type === 'action' && _item.elements) { |
| | | _item.elements = _item.elements.map(cell => { |
| | | cell.uuid = Utils.getuuid() |
| | | return cell |
| | | }) |
| | | } |
| | | return _item |
| | | }) |
| | | item.cols = loopCol(item.cols) |
| | | } |
| | | |
| | | return item |
| | |
| | | return item |
| | | }) |
| | | |
| | | _config.cols = _config.cols.map(col => { |
| | | let loopCol = (cols) => { |
| | | return cols.map(col => { |
| | | col.uuid = Utils.getuuid() |
| | | col.marks = null |
| | | |
| | | if (col.type === 'colspan' && col.subcols) { |
| | | col = this.loopCol(col) |
| | | col.subcols = loopCol(col.subcols) |
| | | } else if (col.type === 'custom' && col.elements) { |
| | | col.elements = col.elements.map(cell => this.resetElement(cell)) |
| | | } else if (col.type === 'action' && col.elements) { |
| | | col.elements = col.elements.map(cell => { |
| | | if (cell.eleType === 'button') { |
| | | cell.verify = null |
| | | } else { |
| | | cell = this.resetElement(cell) |
| | | } |
| | | return cell |
| | | }) |
| | | } |
| | | col.marks = null |
| | | return col |
| | | }) |
| | | } |
| | | |
| | | _config.cols = loopCol(_config.cols) |
| | | |
| | | return _config |
| | | } |
| | | |
| | | loopCol = (col) => { |
| | | col.subcols = col.subcols.map(c => { |
| | | if (c.type === 'colspan' && c.subcols) { |
| | | c = this.loopCol(c) |
| | | } else if (c.type === 'custom' && c.elements) { |
| | | c.elements = c.elements.map(cell => this.resetElement(cell)) |
| | | } |
| | | c.marks = null |
| | | return c |
| | | }) |
| | | |
| | | return col |
| | | } |
| | | |
| | | resetElement = (item) => { |
| | |
| | | text: '序号' |
| | | }] |
| | | |
| | | if (!card.isSub) { |
| | | options.push({ |
| | | value: 'action', |
| | | text: '操作' |
| | | }) |
| | | let decimal = card.decimal === undefined ? 0 : card.decimal |
| | | if (card.type === 'formula' && typeof(card.decimal) !== 'number') { |
| | | decimal = '' |
| | | } |
| | | |
| | | return [ |
| | |
| | | key: 'label', |
| | | label: '列头文字', |
| | | initVal: card.label, |
| | | required: true |
| | | required: true, |
| | | rules: [{ |
| | | max: 100, |
| | | message: '最多100个字符。' |
| | | }] |
| | | }, |
| | | { |
| | | type: 'select', |
| | |
| | | label: '字段', |
| | | initVal: card.field, |
| | | required: true, |
| | | options: card.isSub ? fields : [] |
| | | options: card.isSub ? fields : [], |
| | | rules: [{ |
| | | pattern: /^[\u4E00-\u9FA50-9a-zA-Z_]*$/ig, |
| | | message: '字段名只允许包含数字、字母、汉字以及_' |
| | | }, { |
| | | max: 100, |
| | | message: '最多100个字符。' |
| | | }] |
| | | }, |
| | | { |
| | | type: 'text', |
| | | key: 'nameField', |
| | | label: '名称字段', |
| | | initVal: card.nameField || '', |
| | | required: false |
| | | required: false, |
| | | rules: [{ |
| | | max: 100, |
| | | message: '最多100个字符。' |
| | | }] |
| | | }, |
| | | { |
| | | type: 'number', |
| | |
| | | value: 'false', |
| | | text: '否' |
| | | }] |
| | | }, |
| | | { |
| | | type: 'radio', |
| | | key: 'eval', |
| | | label: '解析', |
| | | initVal: card.eval || 'false', |
| | | tooltip: '当公式内容涉及计算时请选择“是”,当公式内容为字段拼接时请选择“否”。', |
| | | required: false, |
| | | options: [ |
| | | { value: 'true', text: '是' }, |
| | | { value: 'false', text: '否' } |
| | | ] |
| | | }, |
| | | { |
| | | type: 'radio', |
| | |
| | | max: 18, |
| | | decimal: 0, |
| | | label: '小数位', |
| | | initVal: card.decimal === undefined ? 0 : card.decimal, |
| | | initVal: decimal, |
| | | required: !card.isSub |
| | | }, |
| | | { |
| | |
| | | label: '前缀', |
| | | initVal: card.prefix || '', |
| | | required: false, |
| | | readonly: false |
| | | readonly: false, |
| | | rules: [{ |
| | | max: 100, |
| | | message: '最多100个字符。' |
| | | }] |
| | | }, |
| | | { |
| | | type: 'text', |
| | |
| | | label: '后缀', |
| | | initVal: card.postfix || '', |
| | | required: false, |
| | | readonly: false |
| | | readonly: false, |
| | | rules: [{ |
| | | max: 100, |
| | | message: '最多100个字符。' |
| | | }] |
| | | }, |
| | | { |
| | | type: 'number', |
| | |
| | | initVal: card.linkfields || [], |
| | | required: false, |
| | | options: fields, |
| | | }, |
| | | { |
| | | type: 'radio', |
| | | key: 'eval', |
| | | label: '解析', |
| | | initVal: card.eval || 'false', |
| | | tooltip: '当公式内容涉及计算时请选择“是”,当公式内容为字段拼接时请选择“否”。', |
| | | required: false, |
| | | options: [ |
| | | { value: 'true', text: '是' }, |
| | | { value: 'false', text: '否' } |
| | | ] |
| | | }, |
| | | { |
| | | type: 'textarea', |
| | |
| | | import React, {Component} from 'react' |
| | | import PropTypes from 'prop-types' |
| | | import { is, fromJS } from 'immutable' |
| | | import { Form, Row, Col, Input, Select, InputNumber, Radio, Tooltip, Cascader, Modal, Checkbox } from 'antd' |
| | | import { Form, Row, Col, Input, Select, InputNumber, Radio, Tooltip, Cascader, Modal, Checkbox, Popover } from 'antd' |
| | | import { QuestionCircleOutlined } from '@ant-design/icons' |
| | | |
| | | import { getColumnForm } from './formconfig' |
| | | import { formRule } from '@/utils/option.js' |
| | | import './index.scss' |
| | | |
| | | const { TextArea } = Input |
| | |
| | | |
| | | class NormalTableColumn extends Component { |
| | | static propTpyes = { |
| | | visible: PropTypes.bool, |
| | | column: PropTypes.object, |
| | | fields: PropTypes.array, |
| | | submitCol: PropTypes.func, // 提交事件 |
| | |
| | | visible: false, |
| | | formlist: null |
| | | } |
| | | |
| | | record = null |
| | | |
| | | UNSAFE_componentWillReceiveProps (nextProps) { |
| | | if (nextProps.column && !is(fromJS(this.props.column), fromJS(nextProps.column))) { |
| | |
| | | }) |
| | | |
| | | let formlist = getColumnForm(column, fields) |
| | | let _options = fromJS(columnTypeOptions[column.type]).toJS() |
| | | if (column.type === 'text' || column.type === 'number') { |
| | | if (column.perspective === 'linkmenu') { |
| | | _options.push('linkmenu', 'linkfields', 'open') |
| | | } else if (column.perspective === 'linkurl') { |
| | | _options.push('linkurl', 'linkfields', 'open') |
| | | } |
| | | } |
| | | |
| | | this.record = {} |
| | | |
| | | formlist.forEach(item => { |
| | | this.record[item.key] = item.initVal |
| | | }) |
| | | |
| | | let _options = this.getOptions() |
| | | |
| | | this.setState({ |
| | | visible: true, |
| | | type: column.type, |
| | | formlist: formlist.map(item => { |
| | | item.hidden = !_options.includes(item.key) |
| | | |
| | | if (item.key === 'formula') { |
| | | item.fields = this.props.fields.map(col => col.field) |
| | | item.fields = item.fields.join(', ') |
| | | } else if (this.record.type === 'formula' && item.key === 'decimal') { |
| | | item.required = false |
| | | } |
| | | |
| | | return item |
| | | }) |
| | |
| | | } |
| | | } |
| | | |
| | | getOptions = () => { |
| | | let _options = fromJS(columnTypeOptions[this.record.type]).toJS() |
| | | |
| | | if (this.record.type === 'text' || this.record.type === 'number') { |
| | | if (this.record.perspective === 'linkmenu') { |
| | | _options.push('linkmenu', 'linkfields', 'open') |
| | | } else if (this.record.perspective === 'linkurl') { |
| | | _options.push('linkurl', 'linkfields', 'open') |
| | | } |
| | | } |
| | | |
| | | if (this.record.type === 'formula' && this.record.eval === 'true') { |
| | | _options.push('decimal') |
| | | } |
| | | |
| | | return _options |
| | | } |
| | | |
| | | typeChange = (key, value, option) => { |
| | | const { column } = this.props |
| | | this.record[key] = value |
| | | |
| | | if (key === 'type') { |
| | | let _options = fromJS(columnTypeOptions[value]).toJS() |
| | | let _options = this.getOptions() |
| | | |
| | | this.setState({ |
| | | type: value, |
| | | formlist: this.state.formlist.map(item => { |
| | | if (item.key === 'decimal') { |
| | | item.required = !(column.isSub || value === 'formula') |
| | | if (value === 'formula') { |
| | | this.record.decimal = '' |
| | | } |
| | | } |
| | | |
| | | item.initVal = this.record[item.key] |
| | | item.hidden = !_options.includes(item.key) |
| | | |
| | | return item |
| | |
| | | this.props.form.setFieldsValue({perspective: ''}) |
| | | } else if (value === 'colspan') { |
| | | this.props.form.setFieldsValue({Align: 'center'}) |
| | | } else if (value === 'action') { |
| | | this.props.form.setFieldsValue({Align: 'center', label: '操作'}) |
| | | } else if (value === 'index') { |
| | | this.props.form.setFieldsValue({label: '序号'}) |
| | | } |
| | |
| | | values.type = 'text' |
| | | } |
| | | |
| | | if (values.type !== this.state.type) { |
| | | let _type = this.record.type |
| | | this.record.type = values.type |
| | | |
| | | if (values.type !== _type) { |
| | | values.perspective = '' |
| | | let _options = fromJS(columnTypeOptions[values.type]).toJS() |
| | | this.record.perspective = '' |
| | | |
| | | let _options = this.getOptions() |
| | | |
| | | this.setState({ |
| | | type: values.type, |
| | | formlist: this.state.formlist.map(item => { |
| | | item.initVal = this.record[item.key] |
| | | item.hidden = !_options.includes(item.key) |
| | | |
| | | return item |
| | |
| | | } |
| | | } else if (key === 'format' && value === 'percent') { |
| | | this.props.form.setFieldsValue({postfix: '%'}) |
| | | } |
| | | } |
| | | |
| | | changeRadio = (key, value) => { |
| | | if (key === 'perspective') { |
| | | let _options = fromJS(columnTypeOptions[this.state.type]).toJS() |
| | | |
| | | if (value === 'linkmenu') { |
| | | _options.push('linkmenu', 'linkfields', 'open') |
| | | } else if (value === 'linkurl') { |
| | | _options.push('linkurl', 'linkfields', 'open') |
| | | } |
| | | } else if (['perspective', 'eval'].includes(key)) { |
| | | let _options = this.getOptions() |
| | | |
| | | this.setState({ |
| | | formlist: this.state.formlist.map(item => { |
| | | item.initVal = this.record[item.key] |
| | | item.hidden = !_options.includes(item.key) |
| | | |
| | | return item |
| | |
| | | if (item.hidden || item.forbid) return |
| | | |
| | | if (item.type === 'text') { |
| | | let rules = [] |
| | | if (item.key === 'field') { |
| | | rules = [{ |
| | | pattern: /^[\u4E00-\u9FA50-9a-zA-Z_]*$/ig, |
| | | message: '字段名只允许包含数字、字母、汉字以及_' |
| | | }, { |
| | | max: formRule.input.max, |
| | | message: formRule.input.message |
| | | }] |
| | | } else if (item.key !== 'linkurl') { |
| | | rules = [{ |
| | | max: formRule.input.max, |
| | | message: formRule.input.message |
| | | }] |
| | | } |
| | | fields.push( |
| | | <Col span={12} key={index}> |
| | | <Form.Item label={item.tooltip ? |
| | |
| | | required: !!item.required, |
| | | message: '请输入' + item.label + '!' |
| | | }, |
| | | ...rules |
| | | ...item.rules |
| | | ] |
| | | })(<Input placeholder="" autoComplete="off" disabled={item.readonly} onPressEnter={this.handleSubmit} />)} |
| | | </Form.Item> |
| | |
| | | } |
| | | ] |
| | | })( |
| | | <Radio.Group onChange={(e) => {this.changeRadio(item.key, e.target.value)}}> |
| | | { |
| | | item.options.map(option => { |
| | | return ( |
| | | <Radio key={option.value} value={option.value}>{option.text}</Radio> |
| | | ) |
| | | }) |
| | | } |
| | | <Radio.Group onChange={(e) => {this.typeChange(item.key, e.target.value)}}> |
| | | {item.options.map(option => { |
| | | return (<Radio key={option.value} value={option.value}>{option.text}</Radio>) |
| | | })} |
| | | </Radio.Group> |
| | | )} |
| | | </Form.Item> |
| | |
| | | </Col> |
| | | ) |
| | | } else if (item.type === 'textarea') { |
| | | if (item.key === 'formula') { |
| | | fields.push( |
| | | <Col span={24} className="textarea" 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: '请输入' + item.label + '!' |
| | | } |
| | | ] |
| | | })(<TextArea autoSize={{minRows: 2}} disabled={item.readonly} placeholder={item.placeholder || ''} />)} |
| | | </Form.Item> |
| | | <Popover overlayClassName="formula-fields" placement="topLeft" title="" content={<div>{item.fields}</div>} trigger="click"> |
| | | <span className="formula-icon">字段集</span> |
| | | </Popover> |
| | | </Col> |
| | | ) |
| | | } else { |
| | | fields.push( |
| | | <Col span={24} key={index} className="textarea"> |
| | | <Form.Item label={item.tooltip ? |
| | |
| | | </Col> |
| | | ) |
| | | } |
| | | } |
| | | }) |
| | | return fields |
| | | } |
| | | |
| | | handleSubmit = () => { |
| | | const { fields } = this.props |
| | | // 表单提交时检查输入值是否正确 |
| | | this.props.form.validateFieldsAndScroll((err, values) => { |
| | | if (!err) { |
| | | // eslint-disable-next-line |
| | | if (values.type === 'formula' && values.eval !== 'false' && /^[\u4E00-\u9FA50-9a-zA-Z_\s@\+\-\*\/]*$/ig.test(values.formula) && /[\+\-\*\/]/ig.test(values.formula)) { |
| | | let cols = [] |
| | | fields.forEach(col => { |
| | | if (/^(Int|Decimal)/ig.test(col.datatype)) { |
| | | cols.push({reg: new RegExp('@' + col.field + '@', 'ig'), value: `(@${col.field}@)`}) |
| | | } |
| | | }) |
| | | |
| | | cols.forEach(col => { |
| | | values.formula = values.formula.replace(col.reg, col.value) |
| | | }) |
| | | } |
| | | |
| | | this.props.submitCol(values, () => { |
| | | this.setState({visible: false, formlist: null}) |
| | | }) |
| | |
| | | width: 88%; |
| | | } |
| | | } |
| | | .formula-icon { |
| | | position: absolute; |
| | | bottom: 5px; |
| | | right: 15px; |
| | | cursor: pointer; |
| | | font-size: 12px; |
| | | color: #1890ff; |
| | | } |
| | | >.ant-row >.ant-col { |
| | | display: inline-block; |
| | | vertical-align: top; |
| | | float: none; |
| | | } |
| | | } |
| | | .formula-fields { |
| | | z-index: 1200!important; |
| | | |
| | | .ant-popover-inner-content { |
| | | div { |
| | | max-width: 750px; |
| | | word-break: break-all; |
| | | } |
| | | } |
| | | } |
| | |
| | | import { is, fromJS } from 'immutable' |
| | | import { DndProvider, DragSource, DropTarget } from 'react-dnd' |
| | | import { Table, Popover, Modal, message, notification } from 'antd' |
| | | import { PlusOutlined, EditOutlined, CopyOutlined, DeleteOutlined, FontColorsOutlined, CloseCircleOutlined, AntDesignOutlined, InfoOutlined } from '@ant-design/icons' |
| | | import { PlusOutlined, PlusSquareOutlined, EditOutlined, CopyOutlined, DeleteOutlined, FontColorsOutlined, CloseCircleOutlined, AntDesignOutlined, InfoOutlined } from '@ant-design/icons' |
| | | |
| | | import asyncComponent from '@/utils/asyncComponent' |
| | | import asyncIconComponent from '@/utils/asyncIconComponent' |
| | |
| | | render() { |
| | | const { connectDragSource, connectDropTarget, moveCol, addElement, dropCol, updateCol, editColumn, pasteCell, changeStyle, deleteCol, index, column, align, fields, children, ...restProps } = this.props |
| | | |
| | | if (index !== undefined) { |
| | | if (index !== undefined && column) { |
| | | let style = {cursor: 'move', textAlign: align} |
| | | if (column.Width) { |
| | | style.width = column.Width |
| | |
| | | } |
| | | |
| | | return connectDragSource( |
| | | connectDropTarget(<th {...restProps} index={index} style={style} onDoubleClick={() => column && this.props.editColumn(column)}> |
| | | connectDropTarget(<th {...restProps} index={index} style={style} onDoubleClick={() => this.props.editColumn(column)}> |
| | | <Popover overlayClassName="mk-popover-control-wrap" mouseLeaveDelay={0.2} mouseEnterDelay={0.2} content={ |
| | | <div className="mk-popover-control" onDoubleClick={(e) => e.stopPropagation()}> |
| | | {column && ['custom', 'colspan', 'action'].includes(column.type) ? |
| | | <PlusOutlined className="plus" title="添加" onClick={() => this.props.addElement(column)} /> : null |
| | | } |
| | | {column.type === 'colspan' ? <PlusOutlined className="plus" title="添加列" onClick={() => this.props.addElement(column)} /> : null} |
| | | {column.type === 'custom' ? <PlusOutlined className="plus" title="添加元素" onClick={() => this.props.addElement(column)} /> : null} |
| | | {column.type === 'custom' ? <PlusSquareOutlined className="plus" title="添加按钮" onClick={() => this.props.addElement(column, 'button')} /> : null} |
| | | <EditOutlined className="edit" title="编辑" onClick={() => this.props.editColumn(column)} /> |
| | | {column && column.type === 'custom' ? <PasteComponent options={['customCardElement']} updateConfig={(res, resolve) => this.props.pasteCell(column, res, resolve)} /> : null} |
| | | {column && (column.type === 'custom' || column.type === 'action') ? <FontColorsOutlined className="style" title="调整样式" onClick={() => this.props.changeStyle(column)}/> : null} |
| | | {column.type === 'custom' ? <PasteComponent options={['customCardElement', 'action']} updateConfig={(res, resolve) => this.props.pasteCell(column, res, resolve)} /> : null} |
| | | {column.type === 'custom' ? <FontColorsOutlined className="style" title="调整样式" onClick={() => this.props.changeStyle(column)}/> : null} |
| | | <DeleteOutlined className="close" title="删除" onClick={this.deleteCol} /> |
| | | {column && ['text', 'number', 'formula'].includes(column.type) ? <MarkColumn field={column.field || ''} columns={fields} marks={column.marks} onSubmit={this.updateMarks} /> : null } |
| | | {['text', 'number', 'formula'].includes(column.type) ? <MarkColumn field={column.field || ''} columns={fields} marks={column.marks} onSubmit={this.updateMarks} /> : null } |
| | | </div> |
| | | } trigger="hover"> |
| | | {children} |
| | |
| | | <th {...restProps} style={style} key={column.uuid} onDoubleClick={() => this.props.editColumn(column)}> |
| | | <Popover overlayClassName="mk-popover-control-wrap" mouseLeaveDelay={0.2} mouseEnterDelay={0.2} content={ |
| | | <div className="mk-popover-control" onDoubleClick={(e) => e.stopPropagation()}> |
| | | {column && ['custom', 'colspan'].includes(column.type) ? |
| | | <PlusOutlined className="plus" title="添加" onClick={() => this.props.addElement(column)} /> : null |
| | | } |
| | | {column.type === 'colspan' ? <PlusOutlined className="plus" title="添加列" onClick={() => this.props.addElement(column)} /> : null} |
| | | {column.type === 'custom' ? <PlusOutlined className="plus" title="添加元素" onClick={() => this.props.addElement(column)} /> : null} |
| | | {column.type === 'custom' ? <PlusSquareOutlined className="plus" title="添加按钮" onClick={() => this.props.addElement(column, 'button')} /> : null} |
| | | <EditOutlined className="edit" title="编辑" onClick={() => this.props.editColumn(column)} /> |
| | | {column.type === 'custom' ? <PasteComponent options={['customCardElement']} updateConfig={(res, resolve) => this.props.pasteCell(column, res, resolve)} /> : null} |
| | | {column.type === 'custom' ? <PasteComponent options={['customCardElement', 'action']} updateConfig={(res, resolve) => this.props.pasteCell(column, res, resolve)} /> : null} |
| | | <DeleteOutlined className="close" title="删除" onClick={this.deleteCol} /> |
| | | {column && ['text', 'number', 'formula'].includes(column.type) ? <MarkColumn field={column.field || ''} columns={fields} marks={column.marks} onSubmit={this.updateMarks} /> : null } |
| | | {['text', 'number', 'formula'].includes(column.type) ? <MarkColumn field={column.field || ''} columns={fields} marks={column.marks} onSubmit={this.updateMarks} /> : null } |
| | | </div> |
| | | } trigger="hover"> |
| | | {children} |
| | |
| | | if (column && column.type === 'custom') { |
| | | return ( |
| | | <td style={{padding: 0, ...(column.style || {})}} className={className}> |
| | | <CardCellComponent cards={config} cardCell={column} elements={column.elements} updateElement={this.updateCard}/> |
| | | </td> |
| | | ) |
| | | } else if (column && column.type === 'action') { |
| | | return ( |
| | | <td style={{padding: 0, textAlign: column.Align, ...(column.style || {})}} className={'action-column ' + className}> |
| | | <CardCellComponent cards={config} cardCell={column} elements={column.elements} updateElement={this.updateCard}/> |
| | | </td> |
| | | ) |
| | |
| | | dropCol = (item, hoverIndex) => { |
| | | let _columns = fromJS(this.state.columns).toJS() |
| | | |
| | | let col = { focus: true, uuid: Utils.getuuid(), label: 'label', field: '', type: item.subType, elements: [] } |
| | | let col = { focus: true, uuid: Utils.getuuid(), Width: 120, label: 'label', field: '', type: item.subType, elements: [] } |
| | | if (col.type === 'colspan') { |
| | | col.subcols = [] |
| | | } else if (col.type === 'action') { |
| | | col.label = '操作' |
| | | } else if (col.type === 'index') { |
| | | col.label = '序号' |
| | | } |
| | |
| | | pasteCell = (col, cell, resolve) => { |
| | | resolve({status: true}) |
| | | |
| | | delete cell.copyType |
| | | cell.uuid = Utils.getuuid() |
| | | cell.focus = true |
| | | |
| | | if (!cell.eleType) { |
| | | if (cell.copyType === 'action') { |
| | | cell.eleType = 'button' |
| | | cell.width = cell.width || 12 |
| | | } else { |
| | | cell.eleType = 'text' |
| | | } |
| | | } |
| | | delete cell.copyType |
| | | |
| | | MKEmitter.emit('cardAddElement', col.uuid, cell) |
| | | } |
| | | |
| | | addElement = (col) => { |
| | | addElement = (col, type) => { |
| | | let column = fromJS(col).toJS() |
| | | |
| | | if (column.type === 'colspan') { |
| | |
| | | }) |
| | | this.updateCol(column) |
| | | } else if (column.type === 'custom') { |
| | | let newcard = {uuid: Utils.getuuid(), focus: true, width: 24, eleType: 'text', datatype: 'dynamic', style: {paddingLeft: '4px'}} |
| | | |
| | | // 注册事件-添加元素 |
| | | MKEmitter.emit('cardAddElement', column.uuid, newcard) |
| | | } else if (column.type === 'action') { |
| | | if (type === 'button') { |
| | | let newcard = { |
| | | uuid: Utils.getuuid(), |
| | | focus: true, |
| | |
| | | |
| | | // 注册事件-添加元素 |
| | | MKEmitter.emit('cardAddElement', column.uuid, newcard) |
| | | } else { |
| | | let newcard = {uuid: Utils.getuuid(), focus: true, width: 24, eleType: 'text', datatype: 'dynamic', style: {paddingLeft: '4px'}} |
| | | |
| | | // 注册事件-添加元素 |
| | | MKEmitter.emit('cardAddElement', column.uuid, newcard) |
| | | } |
| | | } |
| | | } |
| | | |
| | |
| | | } else if (col.type === 'custom') { |
| | | col.style = card.style || {} |
| | | col.elements = card.type === 'custom' ? (card.elements || []) : [] |
| | | } else if (col.type === 'action') { |
| | | col.style = card.style || {} |
| | | col.elements = card.type === 'action' ? (card.elements || []) : [] |
| | | } |
| | | |
| | | if (!col.field || col.isSub) { |
| | |
| | | } |
| | | } |
| | | } |
| | | .action-column { |
| | | .card-detail-row:empty { |
| | | min-height: 40px; |
| | | } |
| | | } |
| | | tr:hover td { |
| | | background: #ffffff!important; |
| | | } |
| | |
| | | MKEmitter.removeListener('completeSave', this.completeSave) |
| | | } |
| | | |
| | | // updateFix = (card) => { |
| | | // let fixs = {} |
| | | |
| | | // card.cols.forEach(col => { |
| | | // if (!col.field) return |
| | | // if (col.postfix || col.prefix) { |
| | | // fixs[col.field] = col |
| | | // } |
| | | // }) |
| | | |
| | | // card.cols.forEach(col => { |
| | | // if (col.type === 'custom') { |
| | | // col.elements.forEach(cell => { |
| | | // if (cell.datatype === 'dynamic') { |
| | | // cell.height = '' |
| | | // cell.innerHeight = 'auto' |
| | | |
| | | // if (fixs[cell.field]) { |
| | | // if (!cell.prefix && fixs[cell.field].prefix) { |
| | | // cell.prefix = fixs[cell.field].prefix |
| | | // } |
| | | // if (!cell.postfix && fixs[cell.field].postfix) { |
| | | // cell.postfix = fixs[cell.field].postfix |
| | | // } |
| | | // } |
| | | // } |
| | | // }) |
| | | // } |
| | | // }) |
| | | |
| | | // return card |
| | | // } |
| | | |
| | | completeSave = () => { |
| | | const { card } = this.state |
| | | |
| | |
| | | let _actions = [...action] |
| | | |
| | | cols.forEach(col => { |
| | | if (col.type !== 'action') return |
| | | _actions.push(...col.elements) |
| | | if (col.type === 'custom') { |
| | | col.elements.forEach(cell => { |
| | | if (cell.eleType !== 'button') return |
| | | |
| | | _actions.push(cell) |
| | | }) |
| | | } |
| | | }) |
| | | |
| | | return getWrapForm(wrap, _actions, columns) |
| | |
| | | roleList = [] |
| | | } |
| | | |
| | | // if (['picture', 'link', 'colspan'].includes(card.type)) { |
| | | if (['picture', 'link'].includes(card.type)) { |
| | | card.type = 'text' |
| | | } |
| | |
| | | }, { |
| | | value: 'colspan', |
| | | text: '合并列' |
| | | // }, { |
| | | // value: 'action', |
| | | // text: '操作' |
| | | }, { |
| | | value: 'formula', |
| | | text: '公式' |
| | |
| | | value: 'index', |
| | | text: '序号' |
| | | }] |
| | | |
| | | if (!card.isSub) { |
| | | options.push({ |
| | | value: 'action', |
| | | text: '操作' |
| | | }) |
| | | } |
| | | |
| | | let editCols = [ |
| | | { |
| | |
| | | }, |
| | | { |
| | | type: 'radio', |
| | | key: 'eval', |
| | | label: '解析', |
| | | initVal: card.eval || 'false', |
| | | tooltip: '当公式内容涉及计算时请选择“是”,当公式内容为字段拼接时请选择“否”。', |
| | | required: false, |
| | | options: [ |
| | | { value: 'true', text: '是' }, |
| | | { value: 'false', text: '否' } |
| | | ] |
| | | }, |
| | | { |
| | | type: 'radio', |
| | | key: 'Align', |
| | | label: '对齐方式', |
| | | initVal: card.Align || 'left', |
| | |
| | | text: '右对齐' |
| | | }] |
| | | }, |
| | | // { |
| | | // type: 'radio', |
| | | // key: 'sum', |
| | | // label: '显示合计', |
| | | // initVal: card.sum || 'false', |
| | | // tooltip: '合计信息只在使用系统数据源时有效。', |
| | | // required: false, |
| | | // options: [{ |
| | | // value: 'true', |
| | | // text: '是' |
| | | // }, { |
| | | // value: 'false', |
| | | // text: '否' |
| | | // }] |
| | | // }, |
| | | { |
| | | type: 'radio', |
| | | key: 'editable', |
| | |
| | | text: '数据源' |
| | | }] |
| | | }, |
| | | // { |
| | | // type: 'select', |
| | | // key: 'editField', |
| | | // label: '编辑字段', |
| | | // initVal: card.editField || '', |
| | | // tooltip: '当值与提示文字不同时,可额外添加编辑字段,作为实际值的录入字段。', |
| | | // allowClear: true, |
| | | // required: false, |
| | | // options: fields |
| | | // }, |
| | | { |
| | | type: 'options', |
| | | key: 'options', |
| | |
| | | tooltip: '多个值用逗号分隔。', |
| | | required: false |
| | | }, |
| | | // { |
| | | // type: 'radio', |
| | | // key: 'footEnter', |
| | | // label: '末行回车', |
| | | // initVal: card.footEnter || 'false', |
| | | // tooltip: '新增功能仅在表格可新增时有效。', |
| | | // options: [{ |
| | | // value: 'sub', |
| | | // text: '提交' |
| | | // }, { |
| | | // value: 'add', |
| | | // text: '新增' |
| | | // }, { |
| | | // value: 'false', |
| | | // text: '无动作' |
| | | // }] |
| | | // }, |
| | | { |
| | | type: 'number', |
| | | key: 'decimal', |
| | |
| | | max: 18, |
| | | precision: 0, |
| | | label: '小数位', |
| | | initVal: card.decimal || 0, |
| | | initVal: card.decimal, |
| | | required: false |
| | | }, |
| | | { |
| | |
| | | label: '后缀', |
| | | initVal: card.postfix || '', |
| | | required: false, |
| | | }, |
| | | { |
| | | type: 'radio', |
| | | key: 'eval', |
| | | label: '解析', |
| | | initVal: card.eval || 'false', |
| | | tooltip: '当公式内容涉及计算时请选择“是”,当公式内容为字段拼接时请选择“否”。', |
| | | required: false, |
| | | options: [ |
| | | { value: 'true', text: '是' }, |
| | | { value: 'false', text: '否' } |
| | | ] |
| | | }, |
| | | { |
| | | type: 'textarea', |
| | |
| | | const { TextArea } = Input |
| | | const columnTypeOptions = { |
| | | text: ['label', 'field', 'type', 'Align', 'Hide', 'IsSort', 'Width', 'prefix', 'postfix', 'textFormat', 'editable', 'initval', 'blacklist'], |
| | | number: ['label', 'field', 'type', 'Align', 'Hide', 'IsSort', 'Width', 'decimal', 'format', 'prefix', 'postfix', 'editable', 'initval', 'sum', 'blacklist', 'noValue'], |
| | | number: ['label', 'field', 'type', 'Align', 'Hide', 'IsSort', 'Width', 'decimal', 'format', 'prefix', 'postfix', 'editable', 'initval', 'sum', 'blacklist'], |
| | | textarea: ['label', 'field', 'type', 'Align', 'Hide', 'Width', 'prefix', 'initval', 'postfix', 'blacklist'], |
| | | custom: ['label', 'type', 'Align', 'Width', 'blacklist'], |
| | | colspan: ['label', 'type', 'Align', 'Hide', 'blacklist'], |
| | | action: ['label', 'type', 'Align', 'Width'], |
| | | formula: ['label', 'type', 'Align', 'Hide', 'Width', 'prefix', 'postfix', 'eval', 'formula', 'blacklist', 'noValue'], |
| | | formula: ['label', 'type', 'Align', 'Hide', 'Width', 'prefix', 'postfix', 'eval', 'formula', 'blacklist'], |
| | | index: ['label', 'type', 'Align', 'Width'] |
| | | } |
| | | |
| | | class EdiTableColumn extends Component { |
| | | static propTpyes = { |
| | | visible: PropTypes.bool, |
| | | column: PropTypes.object, |
| | | columns: PropTypes.array, |
| | | fields: PropTypes.array, |
| | |
| | | transfield: {} |
| | | } |
| | | |
| | | column = null |
| | | record = null |
| | | |
| | | UNSAFE_componentWillMount() { |
| | | let transfield = {} |
| | |
| | | } |
| | | |
| | | getOptions = () => { |
| | | let _options = fromJS(columnTypeOptions[this.column.type]).toJS() |
| | | let _options = fromJS(columnTypeOptions[this.record.type]).toJS() |
| | | |
| | | if (this.column.editable === 'true') { |
| | | if (['number', 'text'].includes(this.record.type) && this.record.editable === 'true') { |
| | | _options.push('ctrlField') |
| | | if (this.column.ctrlField) { |
| | | if (this.record.ctrlField) { |
| | | _options.push('ctrlValue') |
| | | } |
| | | if (this.column.type === 'text') { |
| | | if (this.record.type === 'text') { |
| | | _options.push('editType') |
| | | |
| | | if (this.column.editType === 'switch') { |
| | | if (this.record.editType === 'switch') { |
| | | _options.push('enter', 'openVal', 'closeVal', 'openText', 'closeText', 'editField') |
| | | } else if (this.column.editType === 'select') { |
| | | } else if (this.record.editType === 'select') { |
| | | _options.push('required', 'enter', 'resourceType', 'linkSubField', 'editField', 'dropdown') |
| | | |
| | | if (this.column.resourceType === '0') { |
| | | if (this.record.resourceType === '0') { |
| | | _options.push('options') |
| | | } else { |
| | | _options.push('dataSource', 'valueField', 'valueText', 'orderBy', 'orderType', 'disableField', 'database') |
| | |
| | | } else { |
| | | _options.push('required', 'enter') |
| | | } |
| | | } else if (this.column.type === 'number') { |
| | | } else if (this.record.type === 'number') { |
| | | _options.push('max', 'min', 'enter') |
| | | } |
| | | } |
| | | if (this.record.type === 'formula' && this.record.eval === 'true') { |
| | | _options.push('decimal') |
| | | } |
| | | if (['number', 'formula'].includes(this.record.type) && this.record.Hide !== 'true') { |
| | | _options.push('noValue') |
| | | } |
| | | |
| | | return _options |
| | |
| | | }) |
| | | |
| | | let formlist = getColumnForm(column, fields, this.props.columns) |
| | | this.record = {} |
| | | |
| | | this.column = fromJS(column).toJS() |
| | | this.column.editType = this.column.editType || 'text' |
| | | this.column.resourceType = this.column.resourceType || '0' |
| | | formlist.forEach(item => { |
| | | this.record[item.key] = item.initVal |
| | | }) |
| | | |
| | | let _options = this.getOptions() |
| | | |
| | |
| | | } |
| | | |
| | | typeChange = (key, value, option) => { |
| | | this.column[key] = value |
| | | this.record[key] = value |
| | | |
| | | if (key === 'type') { |
| | | let _options = this.getOptions() |
| | |
| | | |
| | | this.setState({ |
| | | formlist: this.state.formlist.map(item => { |
| | | item.initVal = this.column[item.key] || item.initVal |
| | | if (item.key === 'decimal' && value === 'formula') { |
| | | this.record.decimal = '' |
| | | } |
| | | |
| | | item.initVal = this.record[item.key] |
| | | item.hidden = !_options.includes(item.key) |
| | | |
| | | return item |
| | |
| | | this.props.form.setFieldsValue({Align: 'center'}) |
| | | } else if (value === 'formula' && _field) { |
| | | this.props.form.setFieldsValue({formula: '@' + _field + '@'}) |
| | | } else if (value === 'action') { |
| | | this.props.form.setFieldsValue({Align: 'center', label: '操作'}) |
| | | } else if (value === 'index') { |
| | | this.props.form.setFieldsValue({label: '序号'}) |
| | | } |
| | |
| | | values.type = 'text' |
| | | } |
| | | |
| | | let _type = this.column.type |
| | | this.column.type = values.type |
| | | let _type = this.record.type |
| | | this.record.type = values.type |
| | | |
| | | if (values.type !== _type) { |
| | | let _options = this.getOptions() |
| | | |
| | | this.setState({ |
| | | formlist: this.state.formlist.map(item => { |
| | | item.initVal = this.column[item.key] || item.initVal |
| | | item.initVal = this.record[item.key] |
| | | item.hidden = !_options.includes(item.key) |
| | | |
| | | return item |
| | |
| | | } |
| | | } else if (key === 'format' && value === 'percent') { |
| | | this.props.form.setFieldsValue({postfix: '%'}) |
| | | } else if (key === 'editable' || key === 'editType' || key === 'resourceType' || key === 'ctrlField') { |
| | | } else if (['editable', 'editType', 'resourceType', 'ctrlField', 'eval', 'Hide'].includes(key)) { |
| | | let _options = this.getOptions() |
| | | |
| | | this.setState({ |
| | | formlist: this.state.formlist.map(item => { |
| | | item.initVal = this.column[item.key] || item.initVal |
| | | item.initVal = this.record[item.key] |
| | | item.hidden = !_options.includes(item.key) |
| | | |
| | | return item |
| | |
| | | multiselectChange = (key, value) => { |
| | | if (key !== 'linkSubField') return |
| | | |
| | | this.column[key] = value |
| | | this.record[key] = value |
| | | } |
| | | |
| | | handleEmpty = () => { |
| | |
| | | } |
| | | |
| | | changeOptions = (data) => { |
| | | this.column.options = data || [] |
| | | this.record.options = data || [] |
| | | } |
| | | |
| | | getFields() { |
| | |
| | | span = 24 |
| | | className = 'text-area' |
| | | |
| | | let linkSubFields = this.column.linkSubField || [] |
| | | let linkSubFields = this.record.linkSubField || [] |
| | | |
| | | content = <EditTable type={'select'} module="form" transfield={transfield} linkSubFields={linkSubFields} onChange={this.changeOptions}/> |
| | | } |
| | |
| | | } |
| | | |
| | | handleSubmit = () => { |
| | | const { fields } = this.props |
| | | // 表单提交时检查输入值是否正确 |
| | | this.props.form.validateFieldsAndScroll((err, values) => { |
| | | if (!err) { |
| | |
| | | }) |
| | | return |
| | | } |
| | | // eslint-disable-next-line |
| | | } else if (values.type === 'formula' && values.eval !== 'false' && /^[\u4E00-\u9FA50-9a-zA-Z_\s@\+\-\*\/]*$/ig.test(values.formula) && /[\+\-\*\/]/ig.test(values.formula)) { |
| | | let cols = [] |
| | | fields.forEach(col => { |
| | | if (/^(Int|Decimal)/ig.test(col.datatype)) { |
| | | cols.push({reg: new RegExp('@' + col.field + '@', 'ig'), value: `(@${col.field}@)`}) |
| | | } |
| | | }) |
| | | |
| | | cols.forEach(col => { |
| | | values.formula = values.formula.replace(col.reg, col.value) |
| | | }) |
| | | } |
| | | |
| | | if (values.dataSource && /\s/.test(values.dataSource)) { |
| | |
| | | if (result.status) { |
| | | this.setState({visible: false, loading: false, formlist: null}) |
| | | this.props.submitCol(values) |
| | | this.column = null |
| | | this.record = null |
| | | } else { |
| | | this.setState({loading: false}) |
| | | Modal.error({ |
| | |
| | | } else { |
| | | this.setState({visible: false, formlist: null}) |
| | | this.props.submitCol(values) |
| | | this.column = null |
| | | this.record = null |
| | | } |
| | | } |
| | | }) |
| | |
| | | import { is, fromJS } from 'immutable' |
| | | import { DndProvider, DragSource, DropTarget } from 'react-dnd' |
| | | import { Table, Popover, Modal, message, Button, Typography } from 'antd' |
| | | import { PlusOutlined, FileSyncOutlined, EditOutlined, CopyOutlined, DeleteOutlined, FontColorsOutlined, CloseCircleOutlined, AntDesignOutlined } from '@ant-design/icons' |
| | | import { PlusOutlined, PlusSquareOutlined, FileSyncOutlined, EditOutlined, CopyOutlined, DeleteOutlined, FontColorsOutlined, CloseCircleOutlined, AntDesignOutlined } from '@ant-design/icons' |
| | | |
| | | import asyncComponent from '@/utils/asyncComponent' |
| | | import asyncIconComponent from '@/utils/asyncIconComponent' |
| | |
| | | connectDropTarget(<th {...restProps} index={index} style={style} onDoubleClick={() => this.props.editColumn(column)}> |
| | | <Popover overlayClassName="mk-popover-control-wrap" mouseLeaveDelay={0.2} mouseEnterDelay={0.2} content={ |
| | | <div className="mk-popover-control" onDoubleClick={(e) => e.stopPropagation()}> |
| | | {['custom', 'colspan', 'action'].includes(column.type) ? |
| | | <PlusOutlined className="plus" title="添加" onClick={() => this.props.addElement(column)} /> : null |
| | | } |
| | | {column.type === 'colspan' ? <PlusOutlined className="plus" title="添加列" onClick={() => this.props.addElement(column)} /> : null} |
| | | {column.type === 'custom' ? <PlusOutlined className="plus" title="添加元素" onClick={() => this.props.addElement(column)} /> : null} |
| | | {column.type === 'custom' ? <PlusSquareOutlined className="plus" title="添加按钮" onClick={() => this.props.addElement(column, 'button')} /> : null} |
| | | <EditOutlined className="edit" title="编辑" onClick={() => this.props.editColumn(column)} /> |
| | | {column.type === 'custom' ? <PasteComponent options={['customCardElement']} updateConfig={(res, resolve) => this.props.pasteCell(column, res, resolve)} /> : null} |
| | | {column.type === 'action' ? <PasteComponent options={['action']} updateConfig={(res, resolve) => this.props.pasteCell(column, res, resolve)} /> : null} |
| | | {column.type === 'custom' || column.type === 'action' ? <FontColorsOutlined className="style" title="调整样式" onClick={() => this.props.changeStyle(column)}/> : null} |
| | | {column.type === 'custom' ? <PasteComponent options={['customCardElement', 'action']} updateConfig={(res, resolve) => this.props.pasteCell(column, res, resolve)} /> : null} |
| | | {column.type === 'custom' ? <FontColorsOutlined className="style" title="调整样式" onClick={() => this.props.changeStyle(column)}/> : null} |
| | | <DeleteOutlined className="close" title="删除" onClick={this.deleteCol} /> |
| | | {['text', 'number', 'formula'].includes(column.type) ? <MarkColumn field={column.field || ''} columns={fields} marks={column.marks} onSubmit={this.updateMarks} /> : null } |
| | | </div> |
| | |
| | | <th {...restProps} style={style} key={column.uuid} onDoubleClick={() => this.props.editColumn(column)}> |
| | | <Popover overlayClassName="mk-popover-control-wrap" mouseLeaveDelay={0.2} mouseEnterDelay={0.2} content={ |
| | | <div className="mk-popover-control" onDoubleClick={(e) => e.stopPropagation()}> |
| | | {['custom', 'colspan'].includes(column.type) ? |
| | | <PlusOutlined className="plus" title="添加" onClick={() => this.props.addElement(column)} /> : null |
| | | } |
| | | {column.type === 'colspan' ? <PlusOutlined className="plus" title="添加列" onClick={() => this.props.addElement(column)} /> : null} |
| | | {column.type === 'custom' ? <PlusOutlined className="plus" title="添加元素" onClick={() => this.props.addElement(column)} /> : null} |
| | | {column.type === 'custom' ? <PlusSquareOutlined className="plus" title="添加按钮" onClick={() => this.props.addElement(column, 'button')} /> : null} |
| | | <EditOutlined className="edit" title="编辑" onClick={() => this.props.editColumn(column)} /> |
| | | {column.type === 'custom' ? <PasteComponent options={['customCardElement']} updateConfig={(res, resolve) => this.props.pasteCell(column, res, resolve)} /> : null} |
| | | {column.type === 'custom' ? <PasteComponent options={['customCardElement', 'action']} updateConfig={(res, resolve) => this.props.pasteCell(column, res, resolve)} /> : null} |
| | | <DeleteOutlined className="close" title="删除" onClick={this.deleteCol} /> |
| | | {column && ['text', 'number', 'formula'].includes(column.type) ? <MarkColumn field={column.field || ''} columns={fields} marks={column.marks} onSubmit={this.updateMarks} /> : null } |
| | | {['text', 'number', 'formula'].includes(column.type) ? <MarkColumn field={column.field || ''} columns={fields} marks={column.marks} onSubmit={this.updateMarks} /> : null } |
| | | </div> |
| | | } trigger="hover"> |
| | | {children} |
| | |
| | | if (column && column.type === 'custom') { |
| | | return ( |
| | | <td style={{padding: 0, ...(column.style || {})}} className={className}> |
| | | <CardCellComponent cards={config} cardCell={column} elements={column.elements} updateElement={this.updateCard}/> |
| | | </td> |
| | | ) |
| | | } else if (column && column.type === 'action') { |
| | | return ( |
| | | <td style={{padding: 0, textAlign: column.Align, ...(column.style || {})}} className={'action-column ' + className}> |
| | | <CardCellComponent cards={config} cardCell={column} elements={column.elements} updateElement={this.updateCard}/> |
| | | </td> |
| | | ) |
| | |
| | | let _columns = fromJS(this.state.columns).toJS() |
| | | let type = item.subType |
| | | |
| | | if (!['text', 'number', 'textarea', 'custom', 'action', 'formula', 'index', 'colspan'].includes(item.subType)) { |
| | | if (!['text', 'number', 'textarea', 'custom', 'formula', 'index', 'colspan'].includes(item.subType)) { |
| | | type = 'text' |
| | | } |
| | | |
| | | let col = { focus: true, uuid: Utils.getuuid(), label: 'label', field: '', type: type, elements: [] } |
| | | let col = { focus: true, uuid: Utils.getuuid(), Width: 120, label: 'label', field: '', type: type, elements: [] } |
| | | if (col.type === 'colspan') { |
| | | col.subcols = [] |
| | | } else if (col.type === 'action') { |
| | | col.label = '操作' |
| | | } else if (col.type === 'index') { |
| | | col.label = '序号' |
| | | } |
| | |
| | | pasteCell = (col, cell, resolve) => { |
| | | resolve({status: true}) |
| | | |
| | | delete cell.copyType |
| | | cell.uuid = Utils.getuuid() |
| | | cell.focus = true |
| | | |
| | | if (!cell.eleType) { |
| | | if (cell.copyType === 'action') { |
| | | cell.eleType = 'button' |
| | | cell.width = cell.width || 12 |
| | | } else { |
| | | cell.eleType = 'text' |
| | | } |
| | | } |
| | | delete cell.copyType |
| | | |
| | | MKEmitter.emit('cardAddElement', col.uuid, cell) |
| | | } |
| | | |
| | | addElement = (col) => { |
| | | addElement = (col, type) => { |
| | | let column = fromJS(col).toJS() |
| | | |
| | | if (column.type === 'colspan') { |
| | |
| | | }) |
| | | this.updateCol(column) |
| | | } else if (column.type === 'custom') { |
| | | let newcard = {uuid: Utils.getuuid(), focus: true, width: 24, eleType: 'text', datatype: 'dynamic', style: {paddingLeft: '4px'}} |
| | | |
| | | // 注册事件-添加元素 |
| | | MKEmitter.emit('cardAddElement', column.uuid, newcard) |
| | | } else if (column.type === 'action') { |
| | | if (type === 'button') { |
| | | let newcard = { |
| | | uuid: Utils.getuuid(), |
| | | focus: true, |
| | |
| | | |
| | | // 注册事件-添加元素 |
| | | MKEmitter.emit('cardAddElement', column.uuid, newcard) |
| | | } else { |
| | | let newcard = {uuid: Utils.getuuid(), focus: true, width: 24, eleType: 'text', datatype: 'dynamic', style: {paddingLeft: '4px'}} |
| | | |
| | | // 注册事件-添加元素 |
| | | MKEmitter.emit('cardAddElement', column.uuid, newcard) |
| | | } |
| | | } |
| | | } |
| | | |
| | |
| | | } else if (col.type === 'custom') { |
| | | col.style = card.style || {} |
| | | col.elements = card.type === 'custom' ? (card.elements || []) : [] |
| | | } else if (col.type === 'action') { |
| | | col.style = card.style || {} |
| | | col.elements = card.type === 'action' ? (card.elements || []) : [] |
| | | } |
| | | |
| | | window.GLOB.precolumnId = window.GLOB.columnId || '' |
| | |
| | | } |
| | | } |
| | | } |
| | | .action-column { |
| | | .card-detail-row:empty { |
| | | min-height: 40px; |
| | | } |
| | | } |
| | | tr:hover td { |
| | | background: #ffffff!important; |
| | | } |
| | |
| | | } |
| | | |
| | | edit = (record) => { |
| | | const { type } = this.props |
| | | |
| | | this.setState({ |
| | | editItem: record |
| | | }) |
| | | |
| | | if (type === 'fullscreen') { |
| | | this.props.form.setFieldsValue({ |
| | | sql: record.sql |
| | | }) |
| | | } else { |
| | | this.props.form.setFieldsValue({ |
| | | sql: record.sql, |
| | | position: record.position || 'back' |
| | | }) |
| | | } |
| | | } |
| | | |
| | | handleConfirm = () => { |
| | | const { type } = this.props |
| | | const { editItem } = this.state |
| | | // 表单提交时检查输入值是否正确 |
| | | this.props.form.validateFieldsAndScroll((err, values) => { |
| | | if (type === 'fullscreen' && err) { |
| | | notification.warning({ |
| | | top: 92, |
| | | message: '请输入sql!', |
| | | duration: 5 |
| | | }) |
| | | return |
| | | } |
| | | if (!err) { |
| | | if (/^[\s\n]+$/.test(values.sql)) { |
| | | notification.warning({ |
| | |
| | | } |
| | | |
| | | values.uuid = this.state.editItem ? this.state.editItem.uuid : '' |
| | | |
| | | if (type === 'fullscreen' && editItem) { |
| | | values.status = editItem.status || 'true' |
| | | } |
| | | |
| | | let _quot = values.sql.match(/'{1}/g) |
| | | let _lparen = values.sql.match(/\({1}/g) |
| | |
| | | } |
| | | |
| | | render() { |
| | | const { systemScripts, btn } = this.props |
| | | const { usefulfields } = this.state |
| | | const { systemScripts, btn, type } = this.props |
| | | const { usefulfields, editItem } = this.state |
| | | const { getFieldDecorator } = this.props.form |
| | | const formItemLayout = { |
| | | labelCol: { |
| | |
| | | } |
| | | } |
| | | |
| | | let _type = type || '' |
| | | |
| | | return ( |
| | | <Form {...formItemLayout} className="verify-form" id="verify-excelin-custom-scripts"> |
| | | <Row gutter={24}> |
| | | {btn.sheet ? <Col span={8}> |
| | | {!_type && btn.sheet ? <Col span={8}> |
| | | <Form.Item label={'表名'} style={{whiteSpace: 'nowrap', margin: 0}}> |
| | | {btn.sheet} |
| | | </Form.Item> |
| | | </Col> : null} |
| | | <Col span={10}> |
| | | {!_type ? <Col span={10}> |
| | | <Form.Item label={'报错字段'} style={{margin: 0, whiteSpace: 'nowrap'}}> |
| | | ErrorCode(增加后缀NT表示数据不回滚,如ENT、NNT、FNT、NMNT), retmsg |
| | | </Form.Item> |
| | | </Col> |
| | | {usefulfields ? <Col span={24} className="sqlfield"> |
| | | </Col> : null} |
| | | {!_type ? <Col span={24} className="sqlfield"> |
| | | <Form.Item label={'可用字段'}> |
| | | <Tooltip mouseLeaveDelay={0.3} mouseEnterDelay={0.3} placement="top" title={'公共值,请按照@xxx@格式使用。'}><span style={{color: '#1890ff'}}>BID, ID, LoginUID, SessionUid, UserID, Appkey, time_id</span></Tooltip>, |
| | | <Tooltip mouseLeaveDelay={0.3} mouseEnterDelay={0.3} placement="top" title={'系统变量,系统会定义变量并赋值。'}><span style={{color: '#fa8c16'}}>UserName, FullName, RoleID, mk_departmentcode, mk_organization, mk_user_type, mk_nation, mk_province, mk_city, mk_district, mk_address</span></Tooltip>, |
| | | {usefulfields},data_type(注:jskey为主键值,新增时前端生成;data_type为操作类型,新增 - add、修改 - upt、删除 - del) |
| | | </Form.Item> |
| | | </Col> : null} |
| | | <Col span={8} style={{whiteSpace: 'nowrap'}}> |
| | | {!_type ? <Col span={8} style={{whiteSpace: 'nowrap'}}> |
| | | <Form.Item style={{marginBottom: 0}} label={ |
| | | <Tooltip placement="bottomLeft" title={'自定义脚本与默认sql位置关系。'}> |
| | | <QuestionCircleOutlined className="mk-form-tip" /> |
| | |
| | | </Radio.Group> |
| | | )} |
| | | </Form.Item> |
| | | </Col> |
| | | <Col span={10}> |
| | | </Col> : null} |
| | | {!_type ? <Col span={10}> |
| | | <Form.Item style={{marginBottom: 0}} label={'快捷添加'}> |
| | | <Select |
| | | showSearch |
| | |
| | | )} |
| | | </Select> |
| | | </Form.Item> |
| | | </Col> |
| | | </Col> : null} |
| | | <Col span={6} className="add"> |
| | | <Button onClick={this.handleConfirm} loading={this.state.loading} className="mk-green" style={{marginBottom: 15, marginLeft: 40}}> |
| | | 保存 |
| | | {_type === 'fullscreen' && !editItem ? '添加' : '保存'} |
| | | </Button> |
| | | <Button onClick={this.handleCancel} style={{marginBottom: 15, marginLeft: 10}}> |
| | | 取消 |
| | |
| | | import PropTypes from 'prop-types' |
| | | import { fromJS } from 'immutable' |
| | | import { Form, Tabs, Row, Col, Input, Button, Popconfirm, notification, Modal, message, InputNumber, Radio, Typography } from 'antd' |
| | | import { StopTwoTone, CheckCircleTwoTone, EditOutlined, SwapOutlined, DeleteOutlined } from '@ant-design/icons' |
| | | import { StopTwoTone, CheckCircleTwoTone, EditOutlined, SwapOutlined, DeleteOutlined, BorderOutlined, CheckCircleOutlined, StopOutlined } from '@ant-design/icons' |
| | | import moment from 'moment' |
| | | |
| | | import Api from '@/api' |
| | | import Utils from '@/utils/utils.js' |
| | | |
| | | import MKEmitter from '@/utils/events.js' |
| | | import UniqueForm from './uniqueform' |
| | | import CustomScript from './customscript' |
| | | import MinView from '@/assets/img/minview.png' |
| | | import asyncComponent from '@/utils/asyncComponent' |
| | | import './index.scss' |
| | | |
| | |
| | | } |
| | | |
| | | state = { |
| | | visible: false, |
| | | scriptId: '', |
| | | verify: {}, |
| | | fields: [], |
| | | fieldLabel: {}, |
| | |
| | | dataIndex: 'position', |
| | | width: '10%', |
| | | render: (text, record) => { |
| | | let _text = '' |
| | | if (record.position === 'front') { |
| | | _text = 'sql前' |
| | | } else if (record.position === 'init') { |
| | | _text = '初始化' |
| | | if (record.position === 'init') { |
| | | return <span style={{color: 'orange'}}>初始化</span> |
| | | } else if (record.position === 'front') { |
| | | return <span style={{color: '#26C281'}}>sql前</span> |
| | | } else { |
| | | _text = 'sql后' |
| | | return <span style={{color: '#1890ff'}}>sql后</span> |
| | | } |
| | | return _text |
| | | } |
| | | }, |
| | | { |
| | |
| | | verify.scripts.push(values) |
| | | } |
| | | |
| | | MKEmitter.emit('editLineId', values.uuid) |
| | | |
| | | this.setState({ |
| | | verify: verify |
| | | }) |
| | |
| | | } |
| | | |
| | | render() { |
| | | const { verify, scriptsColumns, uniqueColumns, activeKey, fields } = this.state |
| | | const { verify, scriptsColumns, uniqueColumns, activeKey, fields, visible } = this.state |
| | | const formItemLayout = { |
| | | labelCol: { |
| | | xs: { span: 24 }, |
| | |
| | | {verify.scripts.length ? <span className="count-tip">{verify.scripts.length}</span> : null} |
| | | </span> |
| | | } key="scripts"> |
| | | <BorderOutlined className="full-scripts" onClick={() => { |
| | | if (this.scriptsForm && (this.scriptsForm.state.editItem || (this.scriptsForm.props.form.getFieldValue('sql') && !/^\s+$/.test(this.scriptsForm.props.form.getFieldValue('sql'))))) { |
| | | notification.warning({ |
| | | top: 92, |
| | | message: '请保存自定义脚本!', |
| | | duration: 5 |
| | | }) |
| | | return |
| | | } |
| | | this.setState({visible: true, scriptId: ''}) |
| | | }}/> |
| | | <CustomScript |
| | | btn={verify} |
| | | usefulfields={fields} |
| | |
| | | </Form> |
| | | </TabPane> |
| | | </Tabs> |
| | | <Modal |
| | | wrapClassName="model-custom-scripts-modal" |
| | | title="自定义脚本" |
| | | visible={visible} |
| | | width={'95vw'} |
| | | maskClosable={false} |
| | | destroyOnClose |
| | | > |
| | | <img className="unfull-scripts" src={MinView} onClick={() => this.setState({visible: false, scriptId: ''})} alt=""/> |
| | | <div className="script-table-wrap"> |
| | | {verify.scripts.map(item => { |
| | | let title = item.sql.match(/^\s*\/\*.+\*\//) |
| | | title = title && title[0] ? title[0] : '' |
| | | let _text = title ? item.sql.replace(title, '') : item.sql |
| | | |
| | | let position = null |
| | | if (item.position === 'init') { |
| | | position = <span style={{color: 'orange'}}>初始化</span> |
| | | } else if (item.position === 'front') { |
| | | position = <span style={{color: '#26C281'}}>sql前</span> |
| | | } else { |
| | | position = <span style={{color: '#1890ff'}}>sql后</span> |
| | | } |
| | | |
| | | if (item.status === 'false') { |
| | | return ( |
| | | <div className="script-item" key={item.uuid}> |
| | | <div style={{cursor: 'not-allowed'}}> |
| | | {title ? <div style={{color: '#a50', whiteSpace: 'nowrap', overflow: 'hidden', textOverflow: 'ellipsis'}}>{title}</div> : null} |
| | | <Paragraph copyable={{ text: item.sql }} ellipsis={{ rows: 4 }}>{_text}</Paragraph> |
| | | <div>{position} |
| | | <span style={{color: '#ff4d4f', marginLeft: '20px'}}> |
| | | 禁用 |
| | | <StopOutlined style={{marginLeft: '5px'}} /> |
| | | </span> |
| | | </div> |
| | | </div> |
| | | <div style={{height: '24px'}}></div> |
| | | </div> |
| | | ) |
| | | } else { |
| | | return ( |
| | | <div className={'script-item ' + (this.state.scriptId === item.uuid ? 'active' : '') } key={item.uuid}> |
| | | <div style={{cursor: 'pointer'}} onClick={() => { |
| | | this.scriptsFullForm.edit(item) |
| | | this.setState({scriptId: item.uuid}) |
| | | }}> |
| | | {title ? <div style={{color: '#a50', whiteSpace: 'nowrap', overflow: 'hidden', textOverflow: 'ellipsis'}}>{title}</div> : null} |
| | | <Paragraph copyable={{ text: item.sql }} ellipsis={{ rows: 4 }}>{_text}</Paragraph> |
| | | <div>{position} |
| | | <span style={{color: '#26C281', marginLeft: '20px'}}> |
| | | 启用 |
| | | <CheckCircleOutlined style={{marginLeft: '5px'}}/> |
| | | </span> |
| | | </div> |
| | | </div> |
| | | <div style={{textAlign: 'right'}}> |
| | | <span className="operation-btn" onClick={() => this.handleStatus(item, 'scripts')} style={{color: '#8E44AD'}}><SwapOutlined /></span> |
| | | <Popconfirm |
| | | overlayClassName="popover-confirm" |
| | | title="确定删除吗?" |
| | | onConfirm={() => this.handleDelete(item, 'scripts') |
| | | }> |
| | | <span className="operation-btn" style={{color: '#ff4d4f'}}><DeleteOutlined /></span> |
| | | </Popconfirm> |
| | | </div> |
| | | </div> |
| | | ) |
| | | } |
| | | })} |
| | | </div> |
| | | <CustomScript |
| | | type="fullscreen" |
| | | btn={verify} |
| | | usefulfields={fields} |
| | | scripts={verify.scripts} |
| | | systemScripts={this.state.systemScripts} |
| | | scriptsChange={this.scriptsChange} |
| | | wrappedComponentRef={(inst) => this.scriptsFullForm = inst} |
| | | /> |
| | | </Modal> |
| | | </div> |
| | | ) |
| | | } |
| | |
| | | z-index: 1; |
| | | } |
| | | } |
| | | .full-scripts { |
| | | position: absolute; |
| | | right: 24px; |
| | | top: 0px; |
| | | font-size: 16px; |
| | | color: #1890ff; |
| | | z-index: 1; |
| | | } |
| | | } |
| | | .model-custom-scripts-modal { |
| | | .ant-modal { |
| | | top: 30px; |
| | | .ant-modal-header { |
| | | padding: 10px 24px; |
| | | } |
| | | .ant-modal-footer { |
| | | display: none; |
| | | } |
| | | .ant-modal-close { |
| | | display: none; |
| | | } |
| | | .ant-modal-body { |
| | | padding: 0; |
| | | height: calc(100vh - 100px); |
| | | overflow: hidden; |
| | | display: flex; |
| | | |
| | | .script-table-wrap { |
| | | width: 240px; |
| | | overflow-y: auto; |
| | | overflow-x: hidden; |
| | | height: calc(100vh - 100px); |
| | | |
| | | .operation-btn { |
| | | display: inline-block; |
| | | font-size: 16px; |
| | | padding: 0 5px; |
| | | cursor: pointer; |
| | | margin-left: 5px; |
| | | } |
| | | |
| | | .script-item { |
| | | border-bottom: 1px solid #eeeeee; |
| | | padding: 15px 10px 5px; |
| | | } |
| | | .script-item.active { |
| | | background-color: #bae7ff; |
| | | } |
| | | .ant-typography { |
| | | margin-bottom: 5px; |
| | | } |
| | | } |
| | | |
| | | .script-table-wrap::-webkit-scrollbar { |
| | | width: 7px; |
| | | } |
| | | .script-table-wrap::-webkit-scrollbar-thumb { |
| | | border-radius: 5px; |
| | | box-shadow: inset 0 0 5px rgba(0, 0, 0, 0.13); |
| | | background: rgba(0, 0, 0, 0.13); |
| | | } |
| | | .script-table-wrap::-webkit-scrollbar-track { |
| | | box-shadow: inset 0 0 5px rgba(0, 0, 0, 0.05); |
| | | border-radius: 3px; |
| | | border: 1px solid rgba(0, 0, 0, 0.07); |
| | | background: rgba(0, 0, 0, 0); |
| | | } |
| | | |
| | | .unfull-scripts { |
| | | position: absolute; |
| | | right: 20px; |
| | | z-index: 2; |
| | | top: 10px; |
| | | color: #1890ff; |
| | | width: 26px; |
| | | cursor: pointer; |
| | | padding: 5px; |
| | | |
| | | } |
| | | |
| | | .verify-form { |
| | | flex: 1; |
| | | >.ant-row { |
| | | margin: 0!important; |
| | | position: unset; |
| | | } |
| | | .sql { |
| | | padding: 0!important; |
| | | .ant-form-item-label { |
| | | display: none; |
| | | } |
| | | .ant-form-item-control-wrapper { |
| | | width: 100%; |
| | | } |
| | | .CodeMirror { |
| | | height: calc(100vh - 100px); |
| | | border-radius: 0; |
| | | } |
| | | .code-mirror-area { |
| | | border-radius: 0; |
| | | width: calc(95vw - 240px); |
| | | } |
| | | } |
| | | .sqlfield { |
| | | .ant-form-item { |
| | | margin-bottom: 5px; |
| | | } |
| | | .ant-form-item-control { |
| | | line-height: 24px; |
| | | } |
| | | .ant-form-item-label { |
| | | line-height: 25px; |
| | | } |
| | | .ant-form-item-children { |
| | | line-height: 22px; |
| | | } |
| | | .ant-col-sm-8 { |
| | | width: 10.5%; |
| | | } |
| | | .ant-col-sm-16 { |
| | | width: 89.5%; |
| | | } |
| | | } |
| | | .add { |
| | | position: absolute; |
| | | top: 10px; |
| | | z-index: 1; |
| | | .ant-btn { |
| | | height: 28px; |
| | | } |
| | | .mk-green { |
| | | margin-left: 0!important; |
| | | margin-right: 10px; |
| | | } |
| | | } |
| | | } |
| | | } |
| | | } |
| | | } |
| | |
| | | cell.uuid = Utils.getuuid() |
| | | return cell |
| | | }) |
| | | } else if (col.type === 'action' && col.elements) { |
| | | col.elements = col.elements.map(cell => { |
| | | cell.uuid = Utils.getuuid() |
| | | return cell |
| | | }) |
| | | } |
| | | return col |
| | | }) |
| | |
| | | addColumns = () => { |
| | | let card = fromJS(this.state.card).toJS() |
| | | |
| | | card.cols.push({ focus: true, uuid: Utils.getuuid(), label: 'label', field: '', type: 'text' }) |
| | | card.cols.push({ focus: true, Width: 120, uuid: Utils.getuuid(), label: 'label', field: '', type: 'text' }) |
| | | |
| | | this.setState({card}) |
| | | } |
| | |
| | | text: '序号' |
| | | }] |
| | | |
| | | if (!card.isSub) { |
| | | options.push({ |
| | | value: 'action', |
| | | text: '操作' |
| | | }) |
| | | } |
| | | |
| | | if (!card.linkurl && (!card.linkmenu || card.linkmenu.length === 0)) { |
| | | card.perspective = '' |
| | | } |
| | |
| | | value: 'false', |
| | | text: '否' |
| | | }] |
| | | }, |
| | | { |
| | | type: 'radio', |
| | | key: 'eval', |
| | | label: '解析', |
| | | initVal: card.eval || 'false', |
| | | tooltip: '当公式内容涉及计算时请选择“是”,当公式内容为字段拼接时请选择“否”。', |
| | | required: false, |
| | | options: [ |
| | | { value: 'true', text: '是' }, |
| | | { value: 'false', text: '否' } |
| | | ] |
| | | }, |
| | | { |
| | | type: 'radio', |
| | |
| | | options: [ |
| | | { value: 'blank', text: '新窗口' }, |
| | | { value: 'self', text: '当前窗口' } |
| | | ] |
| | | }, |
| | | { |
| | | type: 'radio', |
| | | key: 'eval', |
| | | label: '解析', |
| | | initVal: card.eval || 'false', |
| | | tooltip: '当公式内容涉及计算时请选择“是”,当公式内容为字段拼接时请选择“否”。', |
| | | required: false, |
| | | options: [ |
| | | { value: 'true', text: '是' }, |
| | | { value: 'false', text: '否' } |
| | | ] |
| | | }, |
| | | { |
| | |
| | | |
| | | class NormalTableColumn extends Component { |
| | | static propTpyes = { |
| | | visible: PropTypes.bool, |
| | | column: PropTypes.object, |
| | | fields: PropTypes.array, |
| | | submitCol: PropTypes.func, // 提交事件 |
| | |
| | | visible: false, |
| | | formlist: null |
| | | } |
| | | |
| | | record = null |
| | | |
| | | UNSAFE_componentWillReceiveProps (nextProps) { |
| | | if (nextProps.column && !is(fromJS(this.props.column), fromJS(nextProps.column))) { |
| | |
| | | }) |
| | | |
| | | let formlist = getColumnForm(column, fields) |
| | | let _options = fromJS(columnTypeOptions[column.type]).toJS() |
| | | if (column.type === 'text' || column.type === 'number') { |
| | | if (column.perspective === 'linkmenu') { |
| | | _options.push('linkmenu', 'linkfields', 'open') |
| | | } else if (column.perspective === 'linkurl') { |
| | | _options.push('linkurl', 'linkfields', 'open') |
| | | } |
| | | } |
| | | this.record = {} |
| | | |
| | | formlist.forEach(item => { |
| | | this.record[item.key] = item.initVal |
| | | }) |
| | | |
| | | let _options = this.getOptions() |
| | | |
| | | this.setState({ |
| | | visible: true, |
| | | type: column.type, |
| | | formlist: formlist.map(item => { |
| | | item.hidden = !_options.includes(item.key) |
| | | |
| | |
| | | } |
| | | } |
| | | |
| | | getOptions = () => { |
| | | let _options = fromJS(columnTypeOptions[this.record.type]).toJS() |
| | | |
| | | if (this.record.type === 'text' || this.record.type === 'number') { |
| | | if (this.record.perspective === 'linkmenu') { |
| | | _options.push('linkmenu', 'linkfields', 'open') |
| | | } else if (this.record.perspective === 'linkurl') { |
| | | _options.push('linkurl', 'linkfields', 'open') |
| | | } |
| | | } |
| | | |
| | | if (this.record.type === 'formula' && this.record.eval === 'true') { |
| | | _options.push('decimal') |
| | | } |
| | | |
| | | return _options |
| | | } |
| | | |
| | | typeChange = (key, value, option) => { |
| | | this.record[key] = value |
| | | |
| | | if (key === 'type') { |
| | | let _options = fromJS(columnTypeOptions[value]).toJS() |
| | | let _options = this.getOptions() |
| | | |
| | | let _field = '' |
| | | if (value === 'formula') { |
| | |
| | | } |
| | | |
| | | this.setState({ |
| | | type: value, |
| | | formlist: this.state.formlist.map(item => { |
| | | if (item.key === 'decimal' && value === 'formula') { |
| | | this.record.decimal = '' |
| | | } |
| | | |
| | | item.initVal = this.record[item.key] |
| | | item.hidden = !_options.includes(item.key) |
| | | |
| | | return item |
| | |
| | | this.props.form.setFieldsValue({Align: 'center'}) |
| | | } else if (value === 'formula' && _field) { |
| | | this.props.form.setFieldsValue({formula: '@' + _field + '@'}) |
| | | } else if (value === 'action') { |
| | | this.props.form.setFieldsValue({Align: 'center', label: '操作'}) |
| | | } else if (value === 'index') { |
| | | this.props.form.setFieldsValue({label: '序号'}) |
| | | } |
| | |
| | | values.type = 'text' |
| | | } |
| | | |
| | | if (values.type !== this.state.type) { |
| | | let _type = this.record.type |
| | | this.record.type = values.type |
| | | |
| | | if (values.type !== _type) { |
| | | values.perspective = '' |
| | | let _options = fromJS(columnTypeOptions[values.type]).toJS() |
| | | this.record.perspective = '' |
| | | |
| | | let _options = this.getOptions() |
| | | |
| | | this.setState({ |
| | | type: values.type, |
| | | formlist: this.state.formlist.map(item => { |
| | | item.initVal = this.record[item.key] |
| | | item.hidden = !_options.includes(item.key) |
| | | |
| | | return item |
| | |
| | | } |
| | | } else if (key === 'format' && value === 'percent') { |
| | | this.props.form.setFieldsValue({postfix: '%'}) |
| | | } |
| | | } |
| | | |
| | | changeRadio = (key, value) => { |
| | | if (key === 'perspective') { |
| | | let _options = fromJS(columnTypeOptions[this.state.type]).toJS() |
| | | |
| | | if (value === 'linkmenu') { |
| | | _options.push('linkmenu', 'linkfields', 'open') |
| | | } else if (value === 'linkurl') { |
| | | _options.push('linkurl', 'linkfields', 'open') |
| | | } |
| | | } else if (['perspective', 'eval'].includes(key)) { |
| | | let _options = this.getOptions() |
| | | |
| | | this.setState({ |
| | | formlist: this.state.formlist.map(item => { |
| | | item.initVal = this.record[item.key] |
| | | item.hidden = !_options.includes(item.key) |
| | | |
| | | return item |
| | |
| | | } |
| | | ] |
| | | })( |
| | | <Radio.Group onChange={(e) => {this.changeRadio(item.key, e.target.value)}}> |
| | | { |
| | | item.options.map(option => { |
| | | return ( |
| | | <Radio key={option.value} value={option.value}>{option.text}</Radio> |
| | | ) |
| | | }) |
| | | } |
| | | <Radio.Group onChange={(e) => {this.typeChange(item.key, e.target.value)}}> |
| | | {item.options.map(option => { |
| | | return (<Radio key={option.value} value={option.value}>{option.text}</Radio>) |
| | | })} |
| | | </Radio.Group> |
| | | )} |
| | | </Form.Item> |
| | |
| | | } |
| | | |
| | | handleSubmit = () => { |
| | | const { fields } = this.props |
| | | // 表单提交时检查输入值是否正确 |
| | | this.props.form.validateFieldsAndScroll((err, values) => { |
| | | if (!err) { |
| | | // eslint-disable-next-line |
| | | if (values.type === 'formula' && values.eval !== 'false' && /^[\u4E00-\u9FA50-9a-zA-Z_\s@\+\-\*\/]*$/ig.test(values.formula) && /[\+\-\*\/]/ig.test(values.formula)) { |
| | | let cols = [] |
| | | fields.forEach(col => { |
| | | if (/^(Int|Decimal)/ig.test(col.datatype)) { |
| | | cols.push({reg: new RegExp('@' + col.field + '@', 'ig'), value: `(@${col.field}@)`}) |
| | | } |
| | | }) |
| | | |
| | | cols.forEach(col => { |
| | | values.formula = values.formula.replace(col.reg, col.value) |
| | | }) |
| | | } |
| | | this.setState({visible: false, formlist: null}) |
| | | this.props.submitCol(values) |
| | | } |
| | |
| | | import { is, fromJS } from 'immutable' |
| | | import { DndProvider, DragSource, DropTarget } from 'react-dnd' |
| | | import { Table, Popover, Modal, message, Typography } from 'antd' |
| | | import { PlusOutlined, FileSyncOutlined, EditOutlined, CopyOutlined, DeleteOutlined, FontColorsOutlined, CloseCircleOutlined, AntDesignOutlined } from '@ant-design/icons' |
| | | import { PlusOutlined, PlusSquareOutlined, FileSyncOutlined, EditOutlined, CopyOutlined, DeleteOutlined, FontColorsOutlined, CloseCircleOutlined, AntDesignOutlined } from '@ant-design/icons' |
| | | |
| | | import asyncComponent from '@/utils/asyncComponent' |
| | | import asyncIconComponent from '@/utils/asyncIconComponent' |
| | |
| | | render() { |
| | | const { connectDragSource, connectDropTarget, moveCol, dropCol, addElement, updateCol, editColumn, pasteCell, changeStyle, deleteCol, index, column, align, fields, children, ...restProps } = this.props |
| | | |
| | | if (index !== undefined) { |
| | | if (index !== undefined && column) { |
| | | let style = {cursor: 'move', textAlign: align} |
| | | if (column.Width) { |
| | | style.width = column.Width |
| | |
| | | } |
| | | |
| | | return connectDragSource( |
| | | connectDropTarget(<th {...restProps} index={index} style={style} onDoubleClick={() => column && this.props.editColumn(column)}> |
| | | connectDropTarget(<th {...restProps} index={index} style={style} onDoubleClick={() => this.props.editColumn(column)}> |
| | | <Popover overlayClassName="mk-popover-control-wrap" mouseLeaveDelay={0.2} mouseEnterDelay={0.2} content={ |
| | | <div className="mk-popover-control" onDoubleClick={(e) => e.stopPropagation()}> |
| | | {column && ['custom', 'colspan', 'action'].includes(column.type) ? |
| | | <PlusOutlined className="plus" title="添加" onClick={() => this.props.addElement(column)} /> : null |
| | | } |
| | | {column.type === 'colspan' ? <PlusOutlined className="plus" title="添加列" onClick={() => this.props.addElement(column)} /> : null} |
| | | {column.type === 'custom' ? <PlusOutlined className="plus" title="添加元素" onClick={() => this.props.addElement(column)} /> : null} |
| | | {column.type === 'custom' ? <PlusSquareOutlined className="plus" title="添加按钮" onClick={() => this.props.addElement(column, 'button')} /> : null} |
| | | <EditOutlined className="edit" title="编辑" onClick={() => this.props.editColumn(column)} /> |
| | | {column && column.type === 'custom' ? <PasteComponent options={['customCardElement']} updateConfig={(res, resolve) => this.props.pasteCell(column, res, resolve)} /> : null} |
| | | {column && column.type === 'action' ? <PasteComponent options={['action']} updateConfig={(res, resolve) => this.props.pasteCell(column, res, resolve)} /> : null} |
| | | {column && (column.type === 'custom' || column.type === 'action') ? <FontColorsOutlined className="style" title="调整样式" onClick={() => this.props.changeStyle(column)}/> : null} |
| | | {column.type === 'custom' ? <PasteComponent options={['customCardElement', 'action']} updateConfig={(res, resolve) => this.props.pasteCell(column, res, resolve)} /> : null} |
| | | {column.type === 'custom' ? <FontColorsOutlined className="style" title="调整样式" onClick={() => this.props.changeStyle(column)}/> : null} |
| | | <DeleteOutlined className="close" title="删除" onClick={this.deleteCol} /> |
| | | {column && ['text', 'number', 'formula'].includes(column.type) ? <MarkColumn field={column.field || ''} columns={fields} marks={column.marks} onSubmit={this.updateMarks} /> : null } |
| | | {['text', 'number', 'formula'].includes(column.type) ? <MarkColumn field={column.field || ''} columns={fields} marks={column.marks} onSubmit={this.updateMarks} /> : null } |
| | | </div> |
| | | } trigger="hover"> |
| | | {children} |
| | |
| | | <th {...restProps} style={style} key={column.uuid} onDoubleClick={() => this.props.editColumn(column)}> |
| | | <Popover overlayClassName="mk-popover-control-wrap" mouseLeaveDelay={0.2} mouseEnterDelay={0.2} content={ |
| | | <div className="mk-popover-control" onDoubleClick={(e) => e.stopPropagation()}> |
| | | {column && ['custom', 'colspan'].includes(column.type) ? |
| | | <PlusOutlined className="plus" title="添加" onClick={() => this.props.addElement(column)} /> : null |
| | | } |
| | | {column.type === 'colspan' ? <PlusOutlined className="plus" title="添加列" onClick={() => this.props.addElement(column)} /> : null} |
| | | {column.type === 'custom' ? <PlusOutlined className="plus" title="添加元素" onClick={() => this.props.addElement(column)} /> : null} |
| | | {column.type === 'custom' ? <PlusSquareOutlined className="plus" title="添加按钮" onClick={() => this.props.addElement(column, 'button')} /> : null} |
| | | <EditOutlined className="edit" title="编辑" onClick={() => this.props.editColumn(column)} /> |
| | | {column.type === 'custom' ? <PasteComponent options={['customCardElement']} updateConfig={(res, resolve) => this.props.pasteCell(column, res, resolve)} /> : null} |
| | | {column.type === 'custom' ? <PasteComponent options={['customCardElement', 'action']} updateConfig={(res, resolve) => this.props.pasteCell(column, res, resolve)} /> : null} |
| | | <DeleteOutlined className="close" title="删除" onClick={this.deleteCol} /> |
| | | {column && ['text', 'number', 'formula'].includes(column.type) ? <MarkColumn field={column.field || ''} columns={fields} marks={column.marks} onSubmit={this.updateMarks} /> : null } |
| | | {['text', 'number', 'formula'].includes(column.type) ? <MarkColumn field={column.field || ''} columns={fields} marks={column.marks} onSubmit={this.updateMarks} /> : null } |
| | | </div> |
| | | } trigger="hover"> |
| | | {children} |
| | |
| | | if (column && column.type === 'custom') { |
| | | return ( |
| | | <td style={{padding: 0, ...(column.style || {})}} className={className}> |
| | | <CardCellComponent cards={config} cardCell={column} elements={column.elements} updateElement={this.updateCard}/> |
| | | </td> |
| | | ) |
| | | } else if (column && column.type === 'action') { |
| | | return ( |
| | | <td style={{padding: 0, textAlign: column.Align, ...(column.style || {})}} className={'action-column ' + className}> |
| | | <CardCellComponent cards={config} cardCell={column} elements={column.elements} updateElement={this.updateCard}/> |
| | | </td> |
| | | ) |
| | |
| | | let col = { focus: true, uuid: Utils.getuuid(), label: 'label', field: '', type: item.subType, elements: [] } |
| | | if (col.type === 'colspan') { |
| | | col.subcols = [] |
| | | } else if (col.type === 'action') { |
| | | col.label = '操作' |
| | | } else if (col.type === 'index') { |
| | | col.label = '序号' |
| | | } |
| | |
| | | |
| | | pasteCell = (col, cell, resolve) => { |
| | | resolve({status: true}) |
| | | |
| | | cell.uuid = Utils.getuuid() |
| | | cell.focus = true |
| | | |
| | | if (!cell.eleType) { |
| | | if (cell.copyType === 'action') { |
| | | cell.eleType = 'button' |
| | | cell.width = cell.width || 12 |
| | | } else { |
| | | cell.eleType = 'text' |
| | | } |
| | | } |
| | | |
| | | delete cell.copyType |
| | | cell.uuid = Utils.getuuid() |
| | | cell.focus = true |
| | | |
| | | MKEmitter.emit('cardAddElement', col.uuid, cell) |
| | | } |
| | | |
| | | addElement = (col) => { |
| | | addElement = (col, type) => { |
| | | let column = fromJS(col).toJS() |
| | | |
| | | if (column.type === 'colspan') { |
| | |
| | | }) |
| | | this.updateCol(column) |
| | | } else if (column.type === 'custom') { |
| | | let newcard = {uuid: Utils.getuuid(), focus: true, width: 24, eleType: 'text', datatype: 'dynamic', style: {paddingLeft: '4px'}} |
| | | |
| | | // 注册事件-添加元素 |
| | | MKEmitter.emit('cardAddElement', column.uuid, newcard) |
| | | } else if (column.type === 'action') { |
| | | if (type === 'button') { |
| | | let newcard = { |
| | | uuid: Utils.getuuid(), |
| | | focus: true, |
| | |
| | | |
| | | // 注册事件-添加元素 |
| | | MKEmitter.emit('cardAddElement', column.uuid, newcard) |
| | | } else { |
| | | let newcard = {uuid: Utils.getuuid(), focus: true, width: 24, eleType: 'text', datatype: 'dynamic', style: {paddingLeft: '4px'}} |
| | | |
| | | // 注册事件-添加元素 |
| | | MKEmitter.emit('cardAddElement', column.uuid, newcard) |
| | | } |
| | | } |
| | | } |
| | | |
| | |
| | | } else if (col.type === 'custom') { |
| | | col.style = card.style || {} |
| | | col.elements = card.type === 'custom' ? (card.elements || []) : [] |
| | | } else if (col.type === 'action') { |
| | | col.style = card.style || {} |
| | | col.elements = card.type === 'action' ? (card.elements || []) : [] |
| | | } |
| | | |
| | | window.GLOB.precolumnId = window.GLOB.columnId || '' |
| | |
| | | } |
| | | } |
| | | } |
| | | .action-column { |
| | | .card-detail-row:empty { |
| | | min-height: 40px; |
| | | } |
| | | } |
| | | tr:hover td { |
| | | background: #ffffff!important; |
| | | } |
| | |
| | | cell.uuid = Utils.getuuid() |
| | | return cell |
| | | }) |
| | | } else if (col.type === 'action' && col.elements) { |
| | | col.elements = col.elements.map(cell => { |
| | | cell.uuid = Utils.getuuid() |
| | | return cell |
| | | }) |
| | | } |
| | | return col |
| | | }) |
| | |
| | | let _actions = [...action] |
| | | |
| | | cols.forEach(col => { |
| | | if (col.type !== 'action') return |
| | | _actions.push(...col.elements) |
| | | if (col.type === 'custom') { |
| | | col.elements.forEach(cell => { |
| | | if (cell.eleType !== 'button') return |
| | | |
| | | _actions.push(cell) |
| | | }) |
| | | } |
| | | }) |
| | | |
| | | return getWrapForm(wrap, _actions, columns) |
| | |
| | | { subType: 'custom', text: '自定义列', type: 'col', $init: true }, |
| | | { subType: 'colspan', text: '合并列', type: 'col', $init: true }, |
| | | { subType: 'formula', text: '公式', type: 'col', $init: true }, |
| | | { subType: 'index', text: '序号', type: 'col', $init: true }, |
| | | { subType: 'action', text: '操作', type: 'col', $init: true } |
| | | { subType: 'index', text: '序号', type: 'col', $init: true } |
| | | ] |
| | | } |
| | | ] |
| | |
| | | import mindmap from '@/assets/mobimg/mindmap.png' |
| | | import indent from '@/assets/mobimg/indent.jfif' |
| | | import kapmap from '@/assets/mobimg/kapmap.jfif' |
| | | import xflow from '@/assets/mobimg/xflow.png' |
| | | // import xflow from '@/assets/mobimg/xflow.png' |
| | | import Voucher from '@/assets/mobimg/voucher.png' |
| | | import Account from '@/assets/mobimg/account.png' |
| | | |
| | |
| | | { type: 'menu', url: mindmap, component: 'antvG6', subtype: 'mindmap', title: '思维导图', width: 24 }, |
| | | { type: 'menu', url: indent, component: 'antvG6', subtype: 'indentTree', title: '缩进文件树', width: 24 }, |
| | | { type: 'menu', url: kapmap, component: 'antvG6', subtype: 'kapmap', title: '知识图谱树', width: 24 }, |
| | | { type: 'menu', url: xflow, component: 'antvX6', subtype: 'xflow', title: '流程图', width: 24 }, |
| | | // { type: 'menu', url: xflow, component: 'antvX6', subtype: 'xflow', title: '流程图', width: 24 }, |
| | | { type: 'menu', url: chart, component: 'chart', subtype: 'custom', title: '自定义图表', width: 24, forbid: ['billPrint'] }, |
| | | { type: 'menu', url: Editor, component: 'editor', subtype: 'brafteditor', title: '富文本', width: 24 }, |
| | | { type: 'menu', url: SandBox, component: 'code', subtype: 'sandbox', title: '自定义', width: 24 }, |
| | |
| | | if (item.cols) { |
| | | let _update = (cols) => { |
| | | return cols.map(col => { |
| | | if (col.type === 'action' && col.elements) { |
| | | if (col.type === 'custom' && col.elements) { |
| | | col.elements = col.elements.map(m => { |
| | | if (m.eleType === 'button') { |
| | | if (m.modal && m.modal.fields) { |
| | | m.modal.fields = m.modal.fields.map(col => { |
| | | if (col.field && map[col.field.toLowerCase()]) { |
| | |
| | | if (m.config && m.config.components) { |
| | | m.config.components = _replace(m.config.components) |
| | | } |
| | | |
| | | return m |
| | | }) |
| | | } else if (col.type === 'custom' && col.elements) { |
| | | col.elements = col.elements.map(m => { |
| | | } else { |
| | | if (m.datatype === 'dynamic' && map[m.field.toLowerCase()]) { |
| | | m.field = map[m.field.toLowerCase()].FieldName |
| | | } |
| | | } |
| | | |
| | | return m |
| | |
| | | if (item.cols) { |
| | | let _update = (cols) => { |
| | | return cols.map(col => { |
| | | if (col.type === 'action' && col.elements) { |
| | | if (col.type === 'custom' && col.elements) { |
| | | col.elements = col.elements.map(m => { |
| | | if (m.eleType === 'button') { |
| | | if (m.modal && m.modal.fields) { |
| | | m.modal.fields = m.modal.fields.map(col => { |
| | | if (col.field && map[col.field.toLowerCase()]) { |
| | |
| | | if (m.config && m.config.components) { |
| | | m.config.components = _replace(m.config.components) |
| | | } |
| | | } |
| | | |
| | | return m |
| | | }) |
| | |
| | | }) |
| | | tab.components[0].cols = tab.components[0].cols.filter(col => !(col.field && col.Hide === 'true')) |
| | | tab.components[0].cols.forEach(col => { |
| | | if (col.type !== 'action') return |
| | | if (col.type !== 'custom') return |
| | | col.elements.forEach(btn => { |
| | | if (btn.OpenType === 'popview' && btn.config) { |
| | | btn.config.Template = 'CustomPage' |
| | |
| | | }) |
| | | item.cols = item.cols.filter(col => !(col.field && col.Hide === 'true')) |
| | | item.cols.forEach(col => { |
| | | if (col.type !== 'action') return |
| | | if (col.type !== 'custom') return |
| | | col.elements.forEach(btn => { |
| | | if (btn.OpenType === 'popview' && btn.config) { |
| | | btn.config.Template = 'CustomPage' |
| | |
| | | return false |
| | | } else if (col.Hide === 'true') { |
| | | return false |
| | | } else if (col.type === 'action') { |
| | | col.type = 'custom' |
| | | } |
| | | |
| | | if (col.type === 'number') { |
| | |
| | | return false |
| | | } |
| | | } else if (col.type === 'custom') { |
| | | col.elements = col.elements.map(cell => { |
| | | if (['text', 'number', 'formula'].includes(cell.eleType)) { |
| | | col.elements = col.elements.filter(cell => { |
| | | if (cell.eleType === 'button') { |
| | | if (cell.hidden === 'true') return false |
| | | |
| | | cell.logLabel = item.$menuname + '-' + cell.label |
| | | cell.Ot = cell.Ot || 'requiredSgl' |
| | | cell.ContainerId = this.state.ContainerId |
| | | cell.syncComponentId = cell.syncComponent ? (cell.syncComponent.pop() || '') : '' |
| | | cell.$menuId = item.uuid |
| | | cell.$MenuID = this.props.MenuID |
| | | cell.$view = 'popview' |
| | | |
| | | if (cell.syncComponentId === item.setting.supModule) { |
| | | cell.syncComponentId = '' |
| | | if (cell.execSuccess === 'line' || cell.execSuccess === 'grid') { |
| | | cell.execSuccess = 'mainline' |
| | | } |
| | | } |
| | | |
| | | if (cell.OpenType === 'funcbutton' && cell.funcType === 'print' && cell.verify) { // 打印机设置 |
| | | cell = this.getPrinter(cell, item.uuid) |
| | | } |
| | | |
| | | if (cell.controlField) { |
| | | if (/,/ig.test(cell.controlVal)) { |
| | | cell.controlVals = cell.controlVal.split(',') |
| | | } else { |
| | | cell.controlVals = [(cell.controlVal || '')] |
| | | } |
| | | } |
| | | |
| | | return skip || permAction[cell.uuid] |
| | | } else if (['text', 'number', 'formula'].includes(cell.eleType)) { |
| | | if (!cell.height) { |
| | | cell.innerHeight = 'auto' |
| | | } |
| | |
| | | } |
| | | } |
| | | } |
| | | return cell |
| | | return true |
| | | }) |
| | | |
| | | if (col.elements.length === 0) { |
| | | return false |
| | | } |
| | | } |
| | | |
| | | if (col.linkmenu && col.linkmenu.length > 0) { |
| | |
| | | return skip || permAction[cell.uuid] |
| | | }) |
| | | } |
| | | |
| | | item.cols = item.cols.filter(col => { |
| | | if (col.type !== 'action') return true |
| | | col.elements = col.elements.filter(cell => { |
| | | if (cell.hidden === 'true') return false |
| | | |
| | | cell.logLabel = item.$menuname + '-' + cell.label |
| | | cell.Ot = cell.Ot || 'requiredSgl' |
| | | cell.ContainerId = this.state.ContainerId |
| | | cell.syncComponentId = cell.syncComponent ? (cell.syncComponent.pop() || '') : '' |
| | | cell.$menuId = item.uuid |
| | | cell.$MenuID = this.props.MenuID |
| | | cell.$view = 'popview' |
| | | |
| | | if (cell.syncComponentId === item.setting.supModule) { |
| | | cell.syncComponentId = '' |
| | | if (cell.execSuccess === 'line' || cell.execSuccess === 'grid') { |
| | | cell.execSuccess = 'mainline' |
| | | } |
| | | } |
| | | |
| | | if (cell.OpenType === 'funcbutton' && cell.funcType === 'print' && cell.verify) { // 打印机设置 |
| | | cell = this.getPrinter(cell, item.uuid) |
| | | } |
| | | |
| | | if (cell.controlField) { |
| | | if (/,/ig.test(cell.controlVal)) { |
| | | cell.controlVals = cell.controlVal.split(',') |
| | | } else { |
| | | cell.controlVals = [(cell.controlVal || '')] |
| | | } |
| | | } |
| | | |
| | | return skip || permAction[cell.uuid] |
| | | }) |
| | | return col.elements.length !== 0 |
| | | }) |
| | | |
| | | return true |
| | | }) |
| | |
| | | // eslint-disable-next-line |
| | | _val = eval(_val) |
| | | } catch (e) { |
| | | if (window.debugger) { |
| | | console.info(_val) |
| | | console.warn(e) |
| | | } |
| | | _val = 0 |
| | | } |
| | | } |
| | |
| | | // eslint-disable-next-line |
| | | _val = eval(_val) |
| | | } catch (e) { |
| | | if (window.debugger) { |
| | | console.info(_val) |
| | | console.warn(e) |
| | | } |
| | | _val = '' |
| | | } |
| | | } |
| | |
| | | return null |
| | | } |
| | | |
| | | if (card.round && typeof(val) === 'number') { |
| | | val = Math.round(val * card.round) / card.round |
| | | val = val.toFixed(card.decimal) |
| | | } |
| | | |
| | | if (val !== '') { |
| | | if (val && typeof(val) === 'string') { |
| | | val = val.replace(/\n/ig, '<br/>') |
| | |
| | | sup_data.push(`'${n.uuid}','${item.subject_voucher_code || ''}','${item.voucher_lp || ''}','${n.voucher_sup_lp || ''}','${item.subject_code}','${item.subject_name}','${n.sup_voucher_text || ''}','${direct}',${item.debit || item.credit},'${n.customercode || ''}','${n.customername || ''}','${n.suppliercode || ''}','${n.suppliername || ''}','${n.co_pro_code || ''}','${n.co_pro_name || ''}','${n.workercode || ''}','${n.workername || ''}','${n.project_code || ''}','${n.project_name || ''}','${n.productcode || ''}','${n.productname || ''}','${n.cash_flow_code || ''}','${n.cash_flow_name || ''}','${n.sup_acc_code || ''}','${n.sup_acc_name || ''}','${n.sup_acc_type || ''}','${item.uuid}',0,'${n.lessor_code || ''}','${n.lessor_name || ''}','${n.logistics_code || ''}','${n.logistics_name || ''}'`) |
| | | }) |
| | | } |
| | | return `'${item.uuid}','${item.subject_voucher_code || ''}','${item.voucher_lp || ''}','${item.subject_code}','${item.subject_name}','${item.subject_voucher_text || ''}',${count ? item.fcc_count || 0 : 0},${count ? item.net_unitprice || 0 : 0},'${item.unit}',${item.debit || item.credit},'${direct}','${curr ? item.exratecode : '01010001'}','${curr ? item.exratename : 'CNY'}',${curr ? item.unitratio || 0 : 0},'${item.sup_accounting}',${item.debit ? 1 : -1},${curr ? item.foreign_amount || 0 : 0},0,'${item.local_currency || ''}','${count ? 'Y' : ''}','${curr ? 'Y' : ''}'` |
| | | return `'${item.uuid}','${item.subject_voucher_code || ''}','${item.voucher_lp || ''}','${item.subject_code}','${item.subject_name}','${item.subject_voucher_text || ''}',${count ? item.fcc_count || 0 : 0},${count ? item.net_unitprice || 0 : 0},'${item.unit}',${item.debit || item.credit},'${direct}','${curr ? item.exratecode : '01010001'}','${curr ? item.exratename : 'CNY'}',${curr ? item.unitratio || 0 : 0},'${item.sup_accounting}',${item.debit ? 1 : -1},${curr ? item.foreign_amount || 0 : 0},0,'${item.local_currency || ''}','${count ? 'Y' : ''}','${curr ? 'Y' : ''}','${item.closing_foreign_exchange || ''}'` |
| | | }) |
| | | |
| | | if (type === 'createVoucher') { |
| | |
| | | let curr = item.foreign_currency_type === 'Y' |
| | | let direct = item.debit ? 'debit' : 'credit' |
| | | |
| | | subject_data.push(`'${item.uuid}','${item.subject_voucher_code || ''}','${item.voucher_lp || ''}','${item.subject_code}','${item.subject_name}','${item.subject_voucher_text || ''}',${count ? item.fcc_count || 0 : 0},${count ? item.net_unitprice || 0 : 0},'${item.unit}',${item.debit || item.credit},'${direct}','${curr ? item.exratecode : '01010001'}','${curr ? item.exratename : 'CNY'}',${curr ? item.unitratio || 0 : 0},'${item.sup_accounting}',${item.debit ? 1 : -1},${curr ? item.foreign_amount || 0 : 0},1,'${item.local_currency || ''}','${count ? 'Y' : ''}','${curr ? 'Y' : ''}'`) |
| | | subject_data.push(`'${item.uuid}','${item.subject_voucher_code || ''}','${item.voucher_lp || ''}','${item.subject_code}','${item.subject_name}','${item.subject_voucher_text || ''}',${count ? item.fcc_count || 0 : 0},${count ? item.net_unitprice || 0 : 0},'${item.unit}',${item.debit || item.credit},'${direct}','${curr ? item.exratecode : '01010001'}','${curr ? item.exratename : 'CNY'}',${curr ? item.unitratio || 0 : 0},'${item.sup_accounting}',${item.debit ? 1 : -1},${curr ? item.foreign_amount || 0 : 0},1,'${item.local_currency || ''}','${count ? 'Y' : ''}','${curr ? 'Y' : ''}','${item.closing_foreign_exchange || ''}'`) |
| | | }) |
| | | |
| | | supMap.forEach(n => { |
| | |
| | | sup_data.push(`'${n.uuid}','${item.subject_voucher_code || ''}','${item.voucher_lp || ''}','${n.voucher_sup_lp || ''}','${item.subject_code}','${item.subject_name}','${n.sup_voucher_text || ''}','${direct}',${item.debit || item.credit || 0},'${n.customercode || ''}','${n.customername || ''}','${n.suppliercode || ''}','${n.suppliername || ''}','${n.co_pro_code || ''}','${n.co_pro_name || ''}','${n.workercode || ''}','${n.workername || ''}','${n.project_code || ''}','${n.project_name || ''}','${n.productcode || ''}','${n.productname || ''}','${n.cash_flow_code || ''}','${n.cash_flow_name || ''}','${n.sup_acc_code || ''}','${n.sup_acc_name || ''}','${n.sup_acc_type || ''}','${item.uuid}',0,'${n.lessor_code || ''}','${n.lessor_name || ''}','${n.logistics_code || ''}','${n.logistics_name || ''}'`) |
| | | }) |
| | | } |
| | | return `'${item.uuid}','${item.subject_voucher_code || ''}','${item.voucher_lp || ''}','${item.subject_code}','${item.subject_name}','${item.subject_voucher_text || ''}',${count ? item.fcc_count || 0 : 0},${count ? item.net_unitprice || 0 : 0},'${item.unit}',${item.debit || item.credit || 0},'${direct}','${curr ? item.exratecode : '01010001'}','${curr ? item.exratename : 'CNY'}',${curr ? item.unitratio || 0 : 0},'${item.sup_accounting}',${item.direct ? 1 : -1},${curr ? item.foreign_amount || 0 : 0},0,'${item.local_currency || ''}','${count ? 'Y' : ''}','${curr ? 'Y' : ''}'` |
| | | return `'${item.uuid}','${item.subject_voucher_code || ''}','${item.voucher_lp || ''}','${item.subject_code}','${item.subject_name}','${item.subject_voucher_text || ''}',${count ? item.fcc_count || 0 : 0},${count ? item.net_unitprice || 0 : 0},'${item.unit}',${item.debit || item.credit || 0},'${direct}','${curr ? item.exratecode : '01010001'}','${curr ? item.exratename : 'CNY'}',${curr ? item.unitratio || 0 : 0},'${item.sup_accounting}',${item.direct ? 1 : -1},${curr ? item.foreign_amount || 0 : 0},0,'${item.local_currency || ''}','${count ? 'Y' : ''}','${curr ? 'Y' : ''}','${item.closing_foreign_exchange || ''}'` |
| | | }) |
| | | |
| | | voucherMap.forEach(item => { |
| | |
| | | let curr = item.foreign_currency_type === 'Y' |
| | | let direct = !item.credit ? 'debit' : 'credit' |
| | | |
| | | subject_data.push(`'${item.uuid}','${item.subject_voucher_code || ''}','${item.voucher_lp || ''}','${item.subject_code}','${item.subject_name}','${item.subject_voucher_text || ''}',${count ? item.fcc_count || 0 : 0},${count ? item.net_unitprice || 0 : 0},'${item.unit}',${item.debit || item.credit || 0},'${direct}','${curr ? item.exratecode : '01010001'}','${curr ? item.exratename : 'CNY'}',${curr ? item.unitratio || 0 : 0},'${item.sup_accounting}',${item.direct ? 1 : -1},${curr ? item.foreign_amount || 0 : 0},1,'${item.local_currency || ''}','${count ? 'Y' : ''}','${curr ? 'Y' : ''}'`) |
| | | subject_data.push(`'${item.uuid}','${item.subject_voucher_code || ''}','${item.voucher_lp || ''}','${item.subject_code}','${item.subject_name}','${item.subject_voucher_text || ''}',${count ? item.fcc_count || 0 : 0},${count ? item.net_unitprice || 0 : 0},'${item.unit}',${item.debit || item.credit || 0},'${direct}','${curr ? item.exratecode : '01010001'}','${curr ? item.exratename : 'CNY'}',${curr ? item.unitratio || 0 : 0},'${item.sup_accounting}',${item.direct ? 1 : -1},${curr ? item.foreign_amount || 0 : 0},1,'${item.local_currency || ''}','${count ? 'Y' : ''}','${curr ? 'Y' : ''}','${item.closing_foreign_exchange || ''}'`) |
| | | }) |
| | | |
| | | supMap.forEach(n => { |
| | |
| | | // eslint-disable-next-line |
| | | content = eval(content) |
| | | } catch (e) { |
| | | if (window.debugger) { |
| | | console.info(content) |
| | | console.warn(e) |
| | | } |
| | | content = '' |
| | | } |
| | | |
| | | if (col.round && typeof(content) === 'number') { |
| | | content = Math.round(content * col.round) / col.round |
| | | content = content.toFixed(col.decimal) |
| | | } |
| | | } |
| | | |
| | |
| | | style = {...style, ...col.style} |
| | | } |
| | | |
| | | resProps.children = ( |
| | | <CardCellComponent data={record} cards={config} elements={col.elements}/> |
| | | ) |
| | | } else if (col.type === 'action') { |
| | | style.padding = '0px' |
| | | if (col.style) { |
| | | style = {...style, ...col.style} |
| | | } |
| | | resProps.children = ( |
| | | <CardCellComponent data={record} cards={config} elements={col.elements}/> |
| | | ) |
| | |
| | | onCell: record => ({ |
| | | record, |
| | | col: item, |
| | | config: item.type === 'custom' || item.type === 'action' ? {setting, columns: fields} : null, |
| | | config: item.type === 'custom' ? {setting, columns: fields} : null, |
| | | triggerLink: this.triggerLink |
| | | }) |
| | | } |
| | |
| | | if (item.subcols.length === 0) { |
| | | return false |
| | | } |
| | | } else if (item.type === 'action') { |
| | | } else if (item.type === 'custom') { |
| | | item.elements.forEach(btn => { |
| | | if (btn.eleType !== 'button') return |
| | | if (btn.funcType === 'addline') { |
| | | setting.addable = true |
| | | } |
| | |
| | | val = '' |
| | | } |
| | | return (<td className="editing_table_cell"> |
| | | <InputNumber className={err ? 'has-error' : ''} title={err} id={col.uuid + record.$$uuid} defaultValue={val} onChange={(val) => this.onChange(val)} onPressEnter={this.enterPress} onBlur={this.onBlur}/> |
| | | <InputNumber className={err ? 'has-error' : ''} precision={col.decimal || 0} title={err} id={col.uuid + record.$$uuid} defaultValue={val} onChange={(val) => this.onChange(val)} onPressEnter={this.enterPress} onBlur={this.onBlur}/> |
| | | </td>) |
| | | } else { |
| | | return (<td className={className + ' pointer'} style={style}> |
| | |
| | | // eslint-disable-next-line |
| | | content = eval(content) |
| | | } catch (e) { |
| | | if (window.debugger) { |
| | | console.info(content) |
| | | console.warn(e) |
| | | } |
| | | content = '' |
| | | } |
| | | } |
| | |
| | | |
| | | if (col.noValue === 'hide' && content === 0) { |
| | | content = '' |
| | | } |
| | | |
| | | if (col.round && typeof(content) === 'number') { |
| | | content = Math.round(content * col.round) / col.round |
| | | content = content.toFixed(col.decimal) |
| | | } |
| | | |
| | | if (content !== '') { |
| | |
| | | style = {...style, ...col.style} |
| | | } |
| | | |
| | | children = ( |
| | | <CardCellComponent data={record} cards={config} elements={col.elements}/> |
| | | ) |
| | | } else if (col.type === 'action') { |
| | | style.padding = '0px' |
| | | if (col.style) { |
| | | style = {...style, ...col.style} |
| | | } |
| | | children = ( |
| | | <CardCellComponent data={record} cards={config} elements={col.elements}/> |
| | | ) |
| | |
| | | } |
| | | |
| | | children = (<> |
| | | <InputNumber className={err ? 'has-error' : ''} title={err} id={col.uuid + record.$$uuid} defaultValue={_value} onChange={(val) => this.onChange(val)} onPressEnter={this.enterPress} onBlur={this.onBlur}/> |
| | | <InputNumber className={err ? 'has-error' : ''} title={err} precision={col.decimal || 0} id={col.uuid + record.$$uuid} defaultValue={_value} onChange={(val) => this.onChange(val)} onPressEnter={this.enterPress} onBlur={this.onBlur}/> |
| | | </>) |
| | | } else { |
| | | let content = '' |
| | |
| | | // eslint-disable-next-line |
| | | content = eval(content) |
| | | } catch (e) { |
| | | if (window.debugger) { |
| | | console.info(content) |
| | | console.warn(e) |
| | | } |
| | | content = '' |
| | | } |
| | | } |
| | |
| | | |
| | | if (col.noValue === 'hide' && content === 0) { |
| | | content = '' |
| | | } |
| | | |
| | | if (col.round && typeof(content) === 'number') { |
| | | content = Math.round(content * col.round) / col.round |
| | | content = content.toFixed(col.decimal) |
| | | } |
| | | |
| | | if (content !== '') { |
| | |
| | | style = {...style, ...col.style} |
| | | } |
| | | |
| | | children = ( |
| | | <CardCellComponent data={record} cards={config} elements={col.elements}/> |
| | | ) |
| | | } else if (col.type === 'action') { |
| | | style.padding = '0px' |
| | | if (col.style) { |
| | | style = {...style, ...col.style} |
| | | } |
| | | children = ( |
| | | <CardCellComponent data={record} cards={config} elements={col.elements}/> |
| | | ) |
| | |
| | | onCell: record => ({ |
| | | record, |
| | | col: item, |
| | | config: item.type === 'custom' || item.type === 'action' ? {setting, columns: fields} : null, |
| | | config: item.type === 'custom' ? {setting, columns: fields} : null, |
| | | }) |
| | | } |
| | | } |
| | |
| | | item.search = Utils.initSearchVal(item.search) |
| | | } |
| | | |
| | | if (item.type === 'table') { |
| | | let statFields = [] |
| | | let getCols = (cols) => { |
| | | return cols.filter(col => { |
| | | if (col.blacklist && col.blacklist.filter(v => roleId.indexOf(v) > -1).length > 0) { |
| | | return false |
| | | } else if (col.Hide === 'true') { |
| | | return false |
| | | } |
| | | |
| | | if (col.type === 'number') { |
| | | if (col.sum === 'true' && !statFields.includes(col.field)) { |
| | | statFields.push(col) |
| | | } |
| | | if (typeof(col.decimal) === 'number') { |
| | | col.round = Math.pow(10, col.decimal) |
| | | if (col.format === 'percent') { |
| | | col.decimal = col.decimal > 2 ? col.decimal - 2 : 0 |
| | | } |
| | | } |
| | | } else if (col.type === 'colspan') { |
| | | col.subcols = getCols(col.subcols || []) |
| | | if (col.subcols.length === 0) { |
| | | return false |
| | | } |
| | | } else if (col.type === 'custom') { |
| | | col.elements = col.elements.map(cell => { |
| | | cell = this.resetElement(cell) |
| | | return cell |
| | | }) |
| | | } |
| | | |
| | | if (col.linkmenu && col.linkmenu.length > 0) { |
| | | let menu_id = col.linkmenu.pop() |
| | | col.linkThdMenu = window.GLOB.mkThdMenus.filter(m => m.MenuID === menu_id)[0] || '' |
| | | } else { |
| | | col.linkThdMenu = '' |
| | | } |
| | | |
| | | return true |
| | | }) |
| | | } |
| | | |
| | | item.cols = getCols(item.cols) |
| | | item.statFields = statFields |
| | | } |
| | | |
| | | let mutil = false |
| | | if (item.wrap && item.wrap.supType === 'multi') { // 数据卡多上级组件 |
| | | mutil = true |
| | |
| | | }) |
| | | } |
| | | |
| | | if (item.type === 'card' || item.type === 'carousel' || item.type === 'timeline') { |
| | | if (item.type === 'table') { |
| | | let statFields = [] |
| | | let getCols = (cols) => { |
| | | return cols.filter(col => { |
| | | if (col.blacklist && col.blacklist.filter(v => roleId.indexOf(v) > -1).length > 0) { |
| | | return false |
| | | } else if (col.Hide === 'true') { |
| | | return false |
| | | } else if (col.type === 'action') { |
| | | col.type = 'custom' |
| | | } |
| | | |
| | | if (col.type === 'number') { |
| | | if (col.sum === 'true' && !statFields.includes(col.field)) { |
| | | statFields.push(col) |
| | | } |
| | | if (typeof(col.decimal) === 'number') { |
| | | col.round = Math.pow(10, col.decimal) |
| | | if (col.format === 'percent') { |
| | | col.decimal = col.decimal > 2 ? col.decimal - 2 : 0 |
| | | } |
| | | } |
| | | } else if (col.type === 'formula') { |
| | | if (typeof(col.decimal) === 'number') { |
| | | col.round = Math.pow(10, col.decimal) |
| | | } |
| | | } else if (col.type === 'colspan') { |
| | | col.subcols = getCols(col.subcols || []) |
| | | if (col.subcols.length === 0) { |
| | | return false |
| | | } |
| | | } else if (col.type === 'custom') { |
| | | col.elements = col.elements.filter(cell => { |
| | | if (cell.eleType === 'button') { |
| | | if (cell.hidden === 'true') return false |
| | | |
| | | cell = this.resetButton(item, cell, popview) |
| | | |
| | | if (cell.syncComponentId === item.setting.supModule) { |
| | | cell.syncComponentId = '' |
| | | if (cell.execSuccess === 'line' || cell.execSuccess === 'grid') { |
| | | cell.execSuccess = 'mainline' |
| | | } |
| | | } |
| | | |
| | | if (cell.OpenType === 'funcbutton' && cell.funcType === 'print' && cell.verify) { // 打印机设置 |
| | | cell = this.getPrinter(cell, item.uuid) |
| | | } |
| | | |
| | | return skip || permAction[cell.uuid] |
| | | } else { |
| | | cell = this.resetElement(cell) |
| | | } |
| | | return true |
| | | }) |
| | | |
| | | if (col.elements.length === 0) { |
| | | return false |
| | | } |
| | | } |
| | | |
| | | if (col.linkmenu && col.linkmenu.length > 0) { |
| | | let menu_id = col.linkmenu.pop() |
| | | col.linkThdMenu = window.GLOB.mkThdMenus.filter(m => m.MenuID === menu_id)[0] || '' |
| | | } else { |
| | | col.linkThdMenu = '' |
| | | } |
| | | |
| | | return true |
| | | }) |
| | | } |
| | | |
| | | item.cols = getCols(item.cols) |
| | | item.statFields = statFields |
| | | |
| | | if (item.subtype === 'editable') { |
| | | item.submit.logLabel = item.$menuname + '-提交' |
| | | item.submit.$menuId = item.uuid |
| | | } |
| | | } else if (item.type === 'card' || item.type === 'carousel' || item.type === 'timeline') { |
| | | item.subcards && item.subcards.forEach(card => { |
| | | if (card.style.boxShadow) { |
| | | delete card.style.hShadow |
| | |
| | | |
| | | return cell.eleType !== 'button' || skip || permAction[cell.uuid] |
| | | }) |
| | | } else if (item.type === 'table') { |
| | | item.cols = item.cols.filter(col => { |
| | | if (col.type !== 'action') return true |
| | | col.elements = col.elements.filter(cell => { |
| | | if (cell.hidden === 'true') return false |
| | | |
| | | cell = this.resetButton(item, cell, popview) |
| | | |
| | | if (cell.syncComponentId === item.setting.supModule) { |
| | | cell.syncComponentId = '' |
| | | if (cell.execSuccess === 'line' || cell.execSuccess === 'grid') { |
| | | cell.execSuccess = 'mainline' |
| | | } |
| | | } |
| | | |
| | | if (cell.OpenType === 'funcbutton' && cell.funcType === 'print' && cell.verify) { // 打印机设置 |
| | | cell = this.getPrinter(cell, item.uuid) |
| | | } |
| | | |
| | | return skip || permAction[cell.uuid] |
| | | }) |
| | | return col.elements.length !== 0 |
| | | }) |
| | | |
| | | if (item.subtype === 'editable') { |
| | | item.submit.logLabel = item.$menuname + '-提交' |
| | | item.submit.$menuId = item.uuid |
| | | } |
| | | } else if (item.type === 'form') { |
| | | item.subcards = item.subcards.map(group => { |
| | | group.subButton.uuid = group.uuid |
| | |
| | | if (cell.format === 'percent') { |
| | | cell.decimal = cell.decimal > 2 ? cell.decimal - 2 : 0 |
| | | } |
| | | } else if (cell.eleType === 'formula' && typeof(cell.decimal) === 'number') { |
| | | cell.round = Math.pow(10, cell.decimal) |
| | | } |
| | | } else if (cell.eleType === 'icon') { |
| | | if (!cell.innerHeight) { // 兼容 |
| | |
| | | item.search = Utils.initSearchVal(item.search) |
| | | } |
| | | |
| | | if (item.type === 'table') { |
| | | let statFields = [] |
| | | let getCols = (cols) => { |
| | | return cols.filter(col => { |
| | | if (col.blacklist && col.blacklist.filter(v => roleId.indexOf(v) > -1).length > 0) { |
| | | return false |
| | | } else if (col.Hide === 'true') { |
| | | return false |
| | | } |
| | | |
| | | if (col.type === 'number') { |
| | | if (col.sum === 'true' && !statFields.includes(col.field)) { |
| | | statFields.push(col) |
| | | } |
| | | if (typeof(col.decimal) === 'number') { |
| | | col.round = Math.pow(10, col.decimal) |
| | | if (col.format === 'percent') { |
| | | col.decimal = col.decimal > 2 ? col.decimal - 2 : 0 |
| | | } |
| | | } |
| | | } else if (col.type === 'colspan') { |
| | | col.subcols = getCols(col.subcols || []) |
| | | if (col.subcols.length === 0) { |
| | | return false |
| | | } |
| | | } else if (col.type === 'custom') { |
| | | col.elements = col.elements.map(cell => { |
| | | cell = this.resetElement(cell) |
| | | return cell |
| | | }) |
| | | } |
| | | |
| | | if (col.linkmenu && col.linkmenu.length > 0) { |
| | | let menu_id = col.linkmenu.pop() |
| | | col.linkThdMenu = window.GLOB.mkThdMenus.filter(m => m.MenuID === menu_id)[0] || '' |
| | | } else { |
| | | col.linkThdMenu = '' |
| | | } |
| | | |
| | | return true |
| | | }) |
| | | } |
| | | |
| | | item.cols = getCols(item.cols) |
| | | item.statFields = statFields |
| | | } |
| | | |
| | | let mutil = false |
| | | if (item.wrap && item.wrap.supType === 'multi') { // 数据卡多上级组件 |
| | | mutil = true |
| | |
| | | }) |
| | | } |
| | | |
| | | if (item.type === 'card' || item.type === 'carousel' || item.type === 'timeline') { |
| | | if (item.type === 'table') { |
| | | let statFields = [] |
| | | let getCols = (cols) => { |
| | | return cols.filter(col => { |
| | | if (col.blacklist && col.blacklist.filter(v => roleId.indexOf(v) > -1).length > 0) { |
| | | return false |
| | | } else if (col.Hide === 'true') { |
| | | return false |
| | | } else if (col.type === 'action') { |
| | | col.type = 'custom' |
| | | } |
| | | |
| | | if (col.type === 'number') { |
| | | if (col.sum === 'true' && !statFields.includes(col.field)) { |
| | | statFields.push(col) |
| | | } |
| | | if (typeof(col.decimal) === 'number') { |
| | | col.round = Math.pow(10, col.decimal) |
| | | if (col.format === 'percent') { |
| | | col.decimal = col.decimal > 2 ? col.decimal - 2 : 0 |
| | | } |
| | | } |
| | | } else if (col.type === 'formula') { |
| | | if (typeof(col.decimal) === 'number') { |
| | | col.round = Math.pow(10, col.decimal) |
| | | } |
| | | } else if (col.type === 'colspan') { |
| | | col.subcols = getCols(col.subcols || []) |
| | | if (col.subcols.length === 0) { |
| | | return false |
| | | } |
| | | } else if (col.type === 'custom') { |
| | | col.elements = col.elements.filter(cell => { |
| | | if (cell.eleType === 'button') { |
| | | if (cell.hidden === 'true' || cell.OpenType === 'popview') return false |
| | | |
| | | cell = this.resetButton(item, cell, Tab) |
| | | |
| | | if (cell.syncComponentId === item.setting.supModule) { |
| | | cell.syncComponentId = '' |
| | | if (cell.execSuccess === 'line' || cell.execSuccess === 'grid') { |
| | | cell.execSuccess = 'mainline' |
| | | } |
| | | } |
| | | } else { |
| | | cell = this.resetElement(cell) |
| | | } |
| | | |
| | | return true |
| | | }) |
| | | |
| | | if (col.elements.length === 0) { |
| | | return false |
| | | } |
| | | } |
| | | |
| | | if (col.linkmenu && col.linkmenu.length > 0) { |
| | | let menu_id = col.linkmenu.pop() |
| | | col.linkThdMenu = window.GLOB.mkThdMenus.filter(m => m.MenuID === menu_id)[0] || '' |
| | | } else { |
| | | col.linkThdMenu = '' |
| | | } |
| | | |
| | | return true |
| | | }) |
| | | } |
| | | |
| | | item.cols = getCols(item.cols) |
| | | item.statFields = statFields |
| | | |
| | | if (item.subtype === 'editable') { |
| | | item.submit.logLabel = item.$menuname + '-提交' |
| | | item.submit.$menuId = item.uuid |
| | | } |
| | | } else if (item.type === 'card' || item.type === 'carousel' || item.type === 'timeline') { |
| | | item.subcards && item.subcards.forEach(card => { |
| | | if (card.style.boxShadow) { |
| | | delete card.style.hShadow |
| | |
| | | |
| | | return true |
| | | }) |
| | | } else if (item.type === 'table') { |
| | | item.cols = item.cols.filter(col => { |
| | | if (col.type !== 'action') return true |
| | | col.elements = col.elements.filter(cell => { |
| | | if (cell.hidden === 'true' || cell.OpenType === 'popview') return false |
| | | |
| | | cell = this.resetButton(item, cell, Tab) |
| | | |
| | | if (cell.syncComponentId === item.setting.supModule) { |
| | | cell.syncComponentId = '' |
| | | if (cell.execSuccess === 'line' || cell.execSuccess === 'grid') { |
| | | cell.execSuccess = 'mainline' |
| | | } |
| | | } |
| | | |
| | | return true |
| | | }) |
| | | return col.elements.length !== 0 |
| | | }) |
| | | |
| | | if (item.subtype === 'editable') { |
| | | item.submit.logLabel = item.$menuname + '-提交' |
| | | item.submit.$menuId = item.uuid |
| | | } |
| | | } else if (item.type === 'form') { |
| | | item.subcards = item.subcards.map(group => { |
| | | group.subButton.uuid = group.uuid |
| | |
| | | if (cell.format === 'percent') { |
| | | cell.decimal = cell.decimal > 2 ? cell.decimal - 2 : 0 |
| | | } |
| | | } else if (cell.type === 'formula' && typeof(cell.decimal) === 'number') { |
| | | cell.round = Math.pow(10, cell.decimal) |
| | | } |
| | | } else if (cell.eleType === 'icon') { |
| | | if (!cell.innerHeight) { // 兼容 |
| | |
| | | param.secretkey = Utils.encrypt(param.LText, param.timestamp) |
| | | |
| | | Api.genericInterface(param).then(res => { |
| | | // res.send_data = [{openid: 'o2E7gvoSFvQRG7I8_gZxf4y3ONkQ', send_id: '222333344', first: '您的缴费信息如下', keyword1: '010000000001', keyword2: '2022年07月03日', keyword3: '供暖缴费', keyword4: '20元', keyword5: '成功', remark: '感谢您的使用!'}] |
| | | // res.send_data = [{openid: 'o2E7gvoSFvQRG7I8_gZxf4y3ONkQ', send_id: '245dd33344', first: '您的缴费信息如下', p1: '010000000001', p2: '2022年07月03日', p3: '供暖缴费', p4: '20元', p5: '成功', remark: '感谢您的使用!'}] |
| | | if (!res.status) { |
| | | notification.warning({ |
| | | top: 92, |
| | |
| | | } |
| | | |
| | | verify.wxNoteKeys.forEach(item => { |
| | | _param.data[item.key] = {value: '', color: item.color} |
| | | _param.data[item.key] = {value: '', color: '#000000'} |
| | | }) |
| | | |
| | | let params = sends.map(item => { |
| | |
| | | }) |
| | | }) |
| | | } else if (item.type === 'table') { |
| | | item.cols && item.cols.forEach(col => { |
| | | if (col.type !== 'action') return |
| | | col.elements && col.elements.forEach(cell => { |
| | | let loopCol = (cols) => { |
| | | cols.forEach(col => { |
| | | if (col.type === 'colspan') { |
| | | loopCol(col.subcols) |
| | | } else if (col.type === 'custom') { |
| | | col.elements.forEach(cell => { |
| | | if (cell.eleType !== 'button') return |
| | | cell.$expanded = false |
| | | if (cell.OpenType === 'funcbutton' && cell.funcType === 'print') { |
| | | |
| | |
| | | |
| | | _comp.action.push({...cell, $line: true, ...(userConfig[cell.uuid] || {})}) |
| | | }) |
| | | } |
| | | }) |
| | | } |
| | | loopCol(item.cols) |
| | | } |
| | | |
| | | if (_comp.action.length > 0) { |
| | | _components.push(_comp) |
| | |
| | | } |
| | | }) |
| | | tab.components[0].cols.forEach(col => { |
| | | if (col.type !== 'action') return |
| | | if (col.type !== 'custom') return |
| | | col.elements.forEach(btn => { |
| | | if (btn.eleType !== 'button') return |
| | | if (btn.OpenType === 'popview') { |
| | | if (menus[btn.uuid]) { |
| | | let mainTb = {name: '主表', uuid: Utils.getuuid(), useMSearch: 'false'} |
| | |
| | | } |
| | | }) |
| | | item.cols.forEach(col => { |
| | | if (col.type !== 'action') return |
| | | if (col.type !== 'custom') return |
| | | col.elements.forEach(btn => { |
| | | if (btn.eleType !== 'button') return |
| | | if (btn.OpenType === 'popview') { |
| | | if (menus[btn.uuid]) { |
| | | let mainTb = {name: '主表', uuid: Utils.getuuid(), useMSearch: 'false'} |
| | |
| | | } |
| | | }) |
| | | tab.components[0].cols.forEach(col => { |
| | | if (col.type !== 'action') return |
| | | if (col.type !== 'custom') return |
| | | col.elements.forEach(btn => { |
| | | if (btn.eleType !== 'button') return |
| | | if (btn.OpenType === 'popview' && btn.config && btn.config.components[0]) { |
| | | this.setTbForm(btn.config.components[0], menus, errors, tab.components[0].name + '-' + btn.label) |
| | | } else if (btn.OpenType === 'pop' || (btn.OpenType === 'funcbutton' && btn.funcType === 'print' && btn.execMode === 'pop')) { |
| | |
| | | } |
| | | }) |
| | | item.cols.forEach(col => { |
| | | if (col.type !== 'action') return |
| | | if (col.type !== 'custom') return |
| | | col.elements.forEach(btn => { |
| | | if (btn.eleType !== 'button') return |
| | | if (btn.OpenType === 'popview' && btn.config && btn.config.components[0]) { |
| | | this.setTbForm(btn.config.components[0], menus, errors, item.name + '-' + btn.label) |
| | | } else if (btn.OpenType === 'pop' || (btn.OpenType === 'funcbutton' && btn.funcType === 'print' && btn.execMode === 'pop')) { |
| | |
| | | } |
| | | }) |
| | | item.cols.forEach(col => { |
| | | if (col.type !== 'action') return |
| | | if (col.type !== 'custom') return |
| | | col.elements.forEach(btn => { |
| | | if (btn.eleType !== 'button') return |
| | | if (btn.OpenType === 'pop' || (btn.OpenType === 'funcbutton' && btn.funcType === 'print' && btn.execMode === 'pop')) { |
| | | if (menus[btn.uuid]) { |
| | | btn.modal = { |
| | |
| | | } |
| | | }) |
| | | tab.components[0].cols.forEach(col => { |
| | | if (col.type !== 'action') return |
| | | if (col.type !== 'custom') return |
| | | col.elements.forEach(btn => { |
| | | if (btn.eleType !== 'button') return |
| | | if (btn.OpenType === 'popview' && btn.config) { |
| | | btn.config.$tables = getTables(btn.config.components[0]) |
| | | } |
| | |
| | | } |
| | | }) |
| | | item.cols.forEach(col => { |
| | | if (col.type !== 'action') return |
| | | if (col.type !== 'custom') return |
| | | col.elements.forEach(btn => { |
| | | if (btn.eleType !== 'button') return |
| | | if (btn.OpenType === 'popview' && btn.config) { |
| | | btn.config.$tables = getTables(btn.config.components[0]) |
| | | } |
| | |
| | | marks: [], |
| | | isSub: false, |
| | | uuid: Utils.getuuid(), |
| | | type: 'action', |
| | | type: 'custom', |
| | | Width: 120, |
| | | elements: colbtns, |
| | | style: {paddingTop: '12px', paddingLeft: '8px', paddingBottom: '12px', paddingRight: '8px'} |
| | |
| | | }) |
| | | |
| | | _card.cols.forEach(col => { |
| | | if (col.type !== 'action') return |
| | | if (col.type !== 'custom') return |
| | | |
| | | col.elements.forEach(cell => { |
| | | if (cell.hidden === 'true') return |
| | | if (cell.hidden === 'true' || cell.eleType !== 'button') return |
| | | if (cell.OpenType === 'pop' || (cell.OpenType === 'funcbutton' && cell.execMode === 'pop')) { |
| | | if (!cell.modal || cell.modal.fields.length === 0) { |
| | | _card.errors.push({ level: 0, detail: `按钮“${cell.label}”中表单尚未添加`}) |
| | |
| | | bottom: 20px; |
| | | } |
| | | } |
| | | .model-custom-scripts-modal .code-mirror-wrap:not(.mk-fullscreen), .model-custom-view-scripts-modal .code-mirror-wrap:not(.mk-fullscreen) { |
| | | .anticon-swap { |
| | | position: absolute; |
| | | z-index: 11; |
| | | left: auto; |
| | | right: 10px; |
| | | top: auto; |
| | | bottom: 20px; |
| | | } |
| | | } |
| | | .mk-mirror-font { |
| | | z-index: 1200!important; |
| | | } |
| | |
| | | import { QuestionCircleOutlined } from '@ant-design/icons' |
| | | |
| | | import Api from '@/api' |
| | | import asyncComponent from '@/utils/asyncComponent' |
| | | import './index.scss' |
| | | |
| | | const ColorSketch = asyncComponent(() => import('@/mob/colorsketch')) |
| | | |
| | | class BillCodeForm extends Component { |
| | | static propTpyes = { |
| | |
| | | } |
| | | |
| | | componentDidMount() { |
| | | const { verify } = this.props |
| | | let wxTemps = sessionStorage.getItem('wxTemplates') |
| | | |
| | | if (window.GLOB.WXAppID && window.GLOB.nginx && !wxTemps) { |
| | |
| | | Api.wxNginxRequest(`cgi-bin/template/get_all_private_template?access_token=${wxtoken}`, 'get').then(res => { |
| | | let temps = [] |
| | | if (res.template_list) { |
| | | temps = res.template_list.filter(item => item.primary_industry) |
| | | let selectTemp = temps.filter(item => item.template_id === verify.wxTemplateId)[0] |
| | | |
| | | if (selectTemp) { |
| | | selectTemp.content = selectTemp.content.replace(/\r\n|\n/g, '<br/>') |
| | | selectTemp.example = selectTemp.example.replace(/\r\n|\n/g, '<br/>') |
| | | temps = res.template_list.filter(item => { |
| | | if (!item.primary_industry) return false |
| | | if (item.content) { |
| | | item.content = item.content.replace('{{first.DATA}}\n', '').replace('\n{{remark.DATA}}', '') |
| | | } |
| | | |
| | | this.setState({wxTemps: temps, selectTemp}) |
| | | return true |
| | | }) |
| | | } |
| | | |
| | | sessionStorage.setItem('wxTemplates', JSON.stringify(temps)) |
| | | localStorage.setItem('wxTemplates', JSON.stringify(temps)) |
| | | |
| | | localStorage.removeItem('wxTemplates') |
| | | |
| | | this.resetTemps(temps) |
| | | }) |
| | | } else { |
| | | sessionStorage.setItem('wxTemplates', JSON.stringify([])) |
| | |
| | | } else if (wxTemps) { |
| | | wxTemps = JSON.parse(wxTemps) |
| | | |
| | | let selectTemp = wxTemps.filter(item => item.template_id === verify.wxTemplateId)[0] |
| | | this.resetTemps(wxTemps) |
| | | } |
| | | } |
| | | |
| | | resetTemps = (wxTemps) => { |
| | | const { verify } = this.props |
| | | |
| | | let sysTemps = [{"template_id":"UdGBwbjFKnIBzW2TalsdJkwZ9R2LvaAozWZ-yo2Dn00","title":"缴费通知","primary_industry":"IT科技","deputy_industry":"IT软件与服务","content":"{{first.DATA}}\n受理编号:{{keyword1.DATA}}\n缴费时间:{{keyword2.DATA}}\n缴费类别:{{keyword3.DATA}}\n缴费金额:{{keyword4.DATA}}\n缴费结果:{{keyword5.DATA}}\n{{remark.DATA}}","example":"您的缴费信息如下\r\n受理编号:010000000001\r\n缴费时间:2018年07月23日\r\n缴费类别:供暖缴费\r\n缴费金额:20元\r\n缴费结果:成功\r\n感谢您的使用!"}] |
| | | |
| | | sysTemps = [] |
| | | |
| | | let _wxTemps = [...wxTemps, ...sysTemps] |
| | | |
| | | let selectTemp = _wxTemps.filter(item => item.template_id === verify.wxTemplateId)[0] |
| | | |
| | | if (selectTemp) { |
| | | selectTemp.content = selectTemp.content.replace(/\r\n|\n/g, '<br/>') |
| | | selectTemp.example = selectTemp.example.replace(/\r\n|\n/g, '<br/>') |
| | | } |
| | | |
| | | this.setState({wxTemps, selectTemp}) |
| | | } |
| | | this.setState({wxTemps: _wxTemps, selectTemp}) |
| | | } |
| | | |
| | | handleConfirm = () => { |
| | |
| | | |
| | | let index = 1 |
| | | _verify.wxNoteKeys = keys.map(key => { |
| | | let item = { |
| | | key: key, |
| | | color: '#000000', |
| | | readonly: false |
| | | } |
| | | if (key === 'first') { |
| | | item.value = 'first' |
| | | item.readonly = true |
| | | } else if (key === 'remark') { |
| | | item.value = 'remark' |
| | | item.readonly = true |
| | | } else { |
| | | let item = { key: key } |
| | | |
| | | item.value = 'p' + index |
| | | index++ |
| | | } |
| | | |
| | | return item |
| | | }) |
| | |
| | | _verify.wxNoteKeys = _verify.wxNoteKeys.map(m => { |
| | | if (m.key === key) { |
| | | m.value = val |
| | | } |
| | | |
| | | return m |
| | | }) |
| | | |
| | | this.props.onChange(_verify) |
| | | } |
| | | |
| | | onWxNoteColorChange = (key, val) => { |
| | | let _verify = fromJS(this.props.verify).toJS() |
| | | |
| | | _verify.wxNoteKeys = _verify.wxNoteKeys.map(m => { |
| | | if (m.key === key) { |
| | | m.color = val |
| | | } |
| | | |
| | | return m |
| | |
| | | <Input placeholder="" autoComplete="off" value={verify.wxNoteLinkMenuId || ''} onChange={(e) => {this.onOptionChange(e.target.value, 'wxNoteLinkMenuId')}}/> |
| | | </Form.Item> |
| | | </Col> : null} |
| | | {verify.wxNote === 'true' && verify.wxNoteKeys ? verify.wxNoteKeys.map(item => <Col span={8} key={item.key}> |
| | | <Form.Item className="mk-note-keyword" label={item.key} required> |
| | | <Select value={item.value} disabled={item.readonly} onSelect={(val) => this.onWxNoteKeyChange(item.key, val)}> |
| | | {verify.wxNote === 'true' && verify.wxNoteKeys ? verify.wxNoteKeys.map((item, index) => <Col span={8} key={'mk' + index}> |
| | | <Form.Item label={item.key} required> |
| | | <Select value={item.value} onSelect={(val) => this.onWxNoteKeyChange(item.key, val)}> |
| | | <Select.Option value="p1">p1</Select.Option> |
| | | <Select.Option value="p2">p2</Select.Option> |
| | | <Select.Option value="p3">p3</Select.Option> |
| | |
| | | <Select.Option value="p9">p9</Select.Option> |
| | | <Select.Option value="p10">p10</Select.Option> |
| | | </Select> |
| | | <ColorSketch value={item.color || '#ffffff'} onChange={(val, hex) => {this.onWxNoteColorChange(item.key, hex)}} /> |
| | | </Form.Item> |
| | | </Col>) : null} |
| | | {selectTemp && verify.wxNoteKeys ? <Col span={24} className="wx-note"> |
| | |
| | | <div> |
| | | <p>openid: "接收者openid",</p> |
| | | <p>send_id: "防重入id",</p> |
| | | {verify.wxNoteKeys.map(item => <p>{item.value}: "=> {item.key}",</p>)} |
| | | {verify.wxNoteKeys.map((item, i) => <p key={'index' + i}>{item.value}: "=> {item.key}",</p>)} |
| | | <p>bid: "跳转小程序时,可作为BID。"</p> |
| | | </div> |
| | | </div> |
| | |
| | | .mk-note-keyword { |
| | | .ant-select { |
| | | width: 50%; |
| | | .ant-select-selection { |
| | | border-radius: 4px 0px 0px 4px; |
| | | } |
| | | } |
| | | .color-sketch-block { |
| | | width: 50%; |
| | | display: inline-block; |
| | | vertical-align: top; |
| | | position: relative; |
| | | top: 4px; |
| | | .color-sketch-block-box { |
| | | width: calc(100% - 75px); |
| | | height: 32px; |
| | | border-radius: 0px 4px 4px 0px; |
| | | .color-sketch-block-inner { |
| | | border-radius: 0px 4px 4px 0px; |
| | | } |
| | | } |
| | | .color-sketch-value { |
| | | width: 75px; |
| | | } |
| | | } |
| | | } |
| | | .wx-note { |
| | | display: flex; |
| | | .note-wrap { |
| | |
| | | }) |
| | | } |
| | | } else if (item.type === 'table' && item.cols) { |
| | | let loopCol = (col) => { |
| | | col.subcols = col.subcols.map(c => { |
| | | c.uuid = md5(commonId + c.uuid) |
| | | let loopCol = (cols) => { |
| | | return cols.map(col => { |
| | | if (col.type === 'action') { |
| | | col.type = 'custom' |
| | | } |
| | | |
| | | if (c.type === 'colspan' && c.subcols) { |
| | | c = loopCol(c) |
| | | } else if (c.type === 'custom' && c.elements) { |
| | | c.elements = c.elements.map(cell => { |
| | | cell.uuid = this.getuuid() |
| | | col.uuid = md5(commonId + col.uuid) |
| | | |
| | | return cell |
| | | }) |
| | | } else if (c.type === 'action' && c.elements) { |
| | | c.elements = c.elements.map(cell => { |
| | | if (col.type === 'colspan' && col.subcols) { |
| | | col.subcols = loopCol(col.subcols) |
| | | } else if (col.type === 'custom' && col.elements) { |
| | | col.elements = col.elements.map(cell => { |
| | | cell.uuid = md5(commonId + cell.uuid) |
| | | |
| | | if (cell.eleType === 'button') { |
| | | if (clear && cell.pageTemplate === 'linkpage' && cell.linkmenu) { |
| | | cell.pageTemplate = '' |
| | | cell.linkmenu = '' |
| | | } |
| | | |
| | | this.resetBtn(cell, commonId) |
| | | } |
| | | |
| | | return cell |
| | | }) |
| | | } |
| | | return c |
| | | }) |
| | | |
| | | return col |
| | | } |
| | | |
| | | item.cols = item.cols.map(col => { |
| | | col.uuid = md5(commonId + col.uuid) |
| | | |
| | | if (col.type === 'colspan' && col.subcols) { |
| | | col = loopCol(col) |
| | | } else if (col.type === 'custom' && col.elements) { |
| | | col.elements = col.elements.map(cell => { |
| | | cell.uuid = this.getuuid() |
| | | return cell |
| | | }) |
| | | } else if (col.type === 'action' && col.elements) { |
| | | col.elements = col.elements.map(cell => { |
| | | cell.uuid = md5(commonId + cell.uuid) |
| | | this.resetBtn(cell, commonId) |
| | | return cell |
| | | }) |
| | | } |
| | | return col |
| | | }) |
| | | |
| | | if (item.subtype === 'editable') { |
| | | item.cols = item.cols.map(col => { |
| | | if (col.editable === 'true' && col.enter) { |
| | | } else if (col.editable === 'true' && col.enter) { |
| | | col.enter = md5(commonId + col.enter) |
| | | } else if (col.type === 'colspan' && col.subcols) { |
| | | col.subcols = col.subcols.map(c => { |
| | | if (c.editable === 'true' && c.enter) { |
| | | c.enter = md5(commonId + c.enter) |
| | | } |
| | | return c |
| | | }) |
| | | } |
| | | |
| | | return col |
| | | }) |
| | | } |
| | | |
| | | item.cols = loopCol(item.cols) |
| | | } else if (item.type === 'form') { |
| | | item.subcards = item.subcards.map(cell => { |
| | | cell.uuid = this.getuuid() |
| | |
| | | }) |
| | | } |
| | | } else if (item.type === 'table' && item.cols) { |
| | | let loopCol = (col) => { |
| | | col.subcols = col.subcols.map(c => { |
| | | c.uuid = this.getuuid() |
| | | |
| | | if (c.type === 'colspan' && c.subcols) { |
| | | c = loopCol(c) |
| | | } else if (c.type === 'custom' && c.elements) { |
| | | c.elements = c.elements.map(cell => { |
| | | cell.uuid = this.getuuid() |
| | | return cell |
| | | }) |
| | | } |
| | | return c |
| | | }) |
| | | |
| | | return col |
| | | let loopCol = (cols) => { |
| | | return cols.map(col => { |
| | | if (col.type === 'action') { |
| | | col.type = 'custom' |
| | | } |
| | | |
| | | item.cols = item.cols.map(col => { |
| | | col.uuid = md5(commonId + col.uuid) |
| | | |
| | | if (col.type === 'colspan' && col.subcols) { |
| | | col = loopCol(col) |
| | | col.subcols = loopCol(col.subcols) |
| | | } else if (col.type === 'custom' && col.elements) { |
| | | col.elements = col.elements.map(cell => { |
| | | cell.uuid = this.getuuid() |
| | | return cell |
| | | }) |
| | | } else if (col.type === 'action' && col.elements) { |
| | | if (sessionStorage.getItem('editMenuType') === 'popview') { |
| | | col.elements = col.elements.filter(c => c.OpenType !== 'popview' && c.OpenType !== 'funcbutton') |
| | | col.elements = col.elements.filter(c => c.eleType !== 'button' || (c.OpenType !== 'popview' && c.OpenType !== 'funcbutton')) |
| | | } |
| | | col.elements = col.elements.map(cell => { |
| | | cell.uuid = md5(commonId + cell.uuid) |
| | | if (cell.eleType === 'button') { |
| | | if (cell.OpenType === 'pop' || (cell.OpenType === 'funcbutton' && cell.execMode === 'pop')) { |
| | | if (cell.modal && cell.modal.fields.length > 0) { |
| | | cell.modal.fields = cell.modal.fields.map(m => { |
| | |
| | | }) |
| | | } |
| | | } |
| | | |
| | | } |
| | | return cell |
| | | }) |
| | | } |
| | | return col |
| | | }) |
| | | |
| | | if (item.subtype === 'editable') { |
| | | item.cols = item.cols.map(col => { |
| | | if (col.editable === 'true' && col.enter) { |
| | | } else if (col.editable === 'true' && col.enter) { // 可编辑表 |
| | | col.enter = md5(commonId + col.enter) |
| | | } |
| | | |
| | | return col |
| | | }) |
| | | } |
| | | |
| | | item.cols = loopCol(item.cols) |
| | | } else if (item.type === 'form') { |
| | | item.subcards = item.subcards.map(cell => { |
| | | cell.uuid = this.getuuid() |
| | |
| | | }) |
| | | } |
| | | |
| | | config.cols && config.cols.forEach(col => { |
| | | if (col.type === 'action') { |
| | | if (config.cols) { |
| | | let loopCol = (cols) => { |
| | | cols.forEach(col => { |
| | | if (col.type === 'colspan') { |
| | | loopCol(col.subcols) |
| | | } else if (col.type === 'custom') { |
| | | col.elements.forEach(cell => { |
| | | if (cell.eleType !== 'button') return |
| | | if (['form', 'pop', 'prompt', 'exec', 'excelIn', 'excelOut'].includes(cell.OpenType)) { |
| | | action.push(cell) |
| | | } else if (cell.OpenType === 'funcbutton' && cell.funcType === 'print' && cell.verify) { |
| | |
| | | }) |
| | | } |
| | | }) |
| | | } |
| | | loopCol(config.cols) |
| | | } |
| | | |
| | | config.elements && config.elements.forEach(cell => { |
| | | if (cell.eleType !== 'button') return |
| | |
| | | |
| | | if (card.$c_cl) { |
| | | card.cols.forEach(col => { |
| | | if (col.type === 'action') { |
| | | if (col.type === 'custom') { |
| | | col.elements.forEach(cell => { |
| | | if (cell.eleType === 'button') { |
| | | if (cell.hidden === 'true') return |
| | | if (cell.OpenType === 'pop' || (cell.OpenType === 'funcbutton' && cell.execMode === 'pop')) { |
| | | if (!cell.modal || cell.modal.fields.length === 0) { |
| | |
| | | if (doubleClick === cell.uuid) { |
| | | doubleClick = '' |
| | | } |
| | | }) |
| | | } else if (col.type === 'custom') { |
| | | col.elements.forEach(cell => { |
| | | } else { |
| | | if (cell.datatype === 'dynamic' && cell.field && !columns.includes(cell.field)) { |
| | | errors.push({ level: 1, detail: `显示列“${col.label}”中动态字段“${cell.field}”无效`}) |
| | | } |
| | | } |
| | | }) |
| | | } else if (col.field && !columns.includes(col.field)) { |
| | | errors.push({ level: 1, detail: `显示列“${col.label}”中字段“${col.field}”无效`}) |
| | |
| | | |
| | | if (component.type === 'table') { |
| | | let getColumns = (cols) => { |
| | | return cols.map(item => { |
| | | return cols.filter(item => { |
| | | if (item.type === 'colspan') { |
| | | item.subcols = getColumns(item.subcols) |
| | | if (item.subcols.length === 0) { |
| | | return false |
| | | } |
| | | } else if (item.type === 'custom') { |
| | | item.elements = item.elements.map(cell => { |
| | | item.elements = item.elements.filter(cell => { |
| | | if (cell.eleType === 'button') return false |
| | | |
| | | cell = this.resetElement(cell) |
| | | return cell |
| | | }) |
| | | if (item.elements.length === 0) { |
| | | return false |
| | | } |
| | | } else { |
| | | item.IsSort = 'false' |
| | | } |
| | | |
| | | return item |
| | | return true |
| | | }) |
| | | } |
| | | component.cols = getColumns(component.cols) |
| | |
| | | _btn.config.MenuID = _btn.uuid |
| | | _btn.config.ParentId = card.uuid |
| | | _btn.config.MenuName = _btn.label |
| | | |
| | | _btn.config.components = this.updateComponents(_btn.config.components || []) |
| | | } else { |
| | | _btn.config = { |
| | | uuid: _btn.uuid, |
| | |
| | | }) |
| | | this.updatePage(config) |
| | | } else { |
| | | config.components = this.updateComponents(config.components) |
| | | this.setState({ |
| | | oriConfig: fromJS(config).toJS(), |
| | | config: config |
| | |
| | | duration: 5 |
| | | }) |
| | | } |
| | | }) |
| | | } |
| | | |
| | | updateComponents = (components) => { // 兼容性升级 table |
| | | return components.map(item => { |
| | | if (item.type === 'tabs') { |
| | | item.subtabs.forEach(tab => { |
| | | tab.components = this.updateComponents(tab.components) |
| | | }) |
| | | } else if (item.type === 'group') { |
| | | item.components = this.updateComponents(item.components) |
| | | } else if (item.type === 'table') { |
| | | item.cols = item.cols.map(col => { |
| | | if (col.type === 'action') { |
| | | col.type = 'custom' |
| | | } |
| | | return col |
| | | }) |
| | | } |
| | | |
| | | return item |
| | | }) |
| | | } |
| | | |
| | |
| | | |
| | | if (item.subtype === 'tablecard') { // 兼容 |
| | | item.type = 'card' |
| | | } else if (item.type === 'table') { |
| | | item.cols = item.cols.map(col => { |
| | | if (col.type === 'action') { |
| | | col.type = 'custom' |
| | | } |
| | | return col |
| | | }) |
| | | } |
| | | |
| | | delete item.tabId |
| | |
| | | }) |
| | | }) |
| | | |
| | | config.cols && config.cols.forEach(col => { |
| | | if (col.type === 'action') { |
| | | if (config.cols) { |
| | | let loopCol = (cols) => { |
| | | cols.forEach(col => { |
| | | if (col.type === 'colspan') { |
| | | loopCol(col.subcols) |
| | | } else if (col.type === 'custom') { |
| | | col.elements.forEach(cell => { |
| | | if (cell.eleType !== 'button') return |
| | | if (cell.OpenType === 'popview' && popbtns[cell.uuid]) { |
| | | cell.config = popbtns[cell.uuid] |
| | | } |
| | | }) |
| | | } |
| | | }) |
| | | } |
| | | loopCol(config.cols) |
| | | } |
| | | |
| | | config.elements && config.elements.forEach(cell => { |
| | | if (cell.eleType !== 'button') return |
| | |
| | | _sort++ |
| | | }) |
| | | } else if (item.type === 'table') { |
| | | item.cols && item.cols.forEach(col => { |
| | | if (col.type !== 'action') return |
| | | col.elements.forEach(btn => { |
| | | if (btn.hidden === 'true') return |
| | | buttons.push(`select '${btn.uuid}' as menuid, '${item.name + '-' + btn.label}' as menuname, '${_sort * 10}' as Sort, '${config.uuid}' as parentid, 40 as Type`) |
| | | let loopCol = (cols) => { |
| | | cols.forEach(col => { |
| | | if (col.type === 'colspan') { |
| | | loopCol(col.subcols) |
| | | } else if (col.type === 'custom') { |
| | | col.elements.forEach(cell => { |
| | | if (cell.eleType !== 'button' || cell.hidden === 'true') return |
| | | buttons.push(`select '${cell.uuid}' as menuid, '${item.name + '-' + cell.label}' as menuname, '${_sort * 10}' as Sort, '${config.uuid}' as parentid, 40 as Type`) |
| | | _sort++ |
| | | }) |
| | | } |
| | | }) |
| | | } |
| | | loopCol(item.cols) |
| | | } |
| | | }) |
| | | } |
| | | |
| | |
| | | _btn.config.MenuID = _btn.uuid |
| | | _btn.config.ParentId = card.uuid |
| | | _btn.config.MenuName = _btn.label |
| | | |
| | | _btn.config.components = this.updateComponents(_btn.config.components || []) |
| | | } else { |
| | | _btn.config = { |
| | | uuid: _btn.uuid, |
| | |
| | | }) |
| | | }) |
| | | |
| | | config.cols && config.cols.forEach(col => { |
| | | if (col.type === 'action') { |
| | | if (config.cols) { |
| | | let loopCol = (cols) => { |
| | | cols.forEach(col => { |
| | | if (col.type === 'colspan') { |
| | | loopCol(col.subcols) |
| | | } else if (col.type === 'custom') { |
| | | col.elements.forEach(cell => { |
| | | if (cell.eleType !== 'button') return |
| | | if (cell.OpenType === 'popview' && popbtns[cell.uuid]) { |
| | | cell.config = popbtns[cell.uuid] |
| | | } |
| | | }) |
| | | } |
| | | }) |
| | | } |
| | | loopCol(config.cols) |
| | | } |
| | | |
| | | config.elements && config.elements.forEach(cell => { |
| | | if (cell.eleType !== 'button') return |
| | |
| | | this.setState({ |
| | | needUpdate: true |
| | | }) |
| | | } else { |
| | | config.components = this.updateComponents(config.components) |
| | | } |
| | | |
| | | let navItem = null |
| | |
| | | this.setState({ |
| | | needUpdate: true |
| | | }) |
| | | } else { |
| | | config.components = this.updateComponents(config.components) |
| | | } |
| | | |
| | | config.enabled = false |
| | |
| | | }) |
| | | } |
| | | |
| | | updateComponents = (components) => { // 兼容性升级 table |
| | | return components.map(item => { |
| | | if (item.type === 'tabs') { |
| | | item.subtabs.forEach(tab => { |
| | | tab.components = this.updateComponents(tab.components) |
| | | }) |
| | | } else if (item.type === 'group') { |
| | | item.components = this.updateComponents(item.components) |
| | | } else if (item.type === 'table') { |
| | | item.cols = item.cols.map(col => { |
| | | if (col.type === 'action') { |
| | | col.type = 'custom' |
| | | } |
| | | return col |
| | | }) |
| | | } |
| | | |
| | | return item |
| | | }) |
| | | } |
| | | |
| | | collectTB = (components) => { |
| | | return components.map(item => { |
| | | if (item.type === 'tabs') { |
| | |
| | | |
| | | if (item.subtype === 'tablecard') { // 兼容 |
| | | item.type = 'card' |
| | | } else if (item.type === 'table') { |
| | | item.cols = item.cols.map(col => { |
| | | if (col.type === 'action') { |
| | | col.type = 'custom' |
| | | } |
| | | return col |
| | | }) |
| | | } |
| | | |
| | | delete item.tabId |
| | |
| | | title: btn.label, |
| | | }) |
| | | }) |
| | | item.cols && item.cols.forEach(col => { |
| | | if (col.type !== 'action') return |
| | | col.elements.forEach(btn => { |
| | | if (btn.hidden === 'true') return |
| | | |
| | | let loopCol = (cols) => { |
| | | cols.forEach(col => { |
| | | if (col.type === 'colspan') { |
| | | loopCol(col.subcols) |
| | | } else if (col.type === 'custom') { |
| | | col.elements.forEach(cell => { |
| | | if (cell.eleType !== 'button' || cell.hidden === 'true') return |
| | | m.children.push({ |
| | | key: btn.uuid, |
| | | title: btn.label, |
| | | key: cell.uuid, |
| | | title: cell.label, |
| | | }) |
| | | }) |
| | | } |
| | | }) |
| | | } |
| | | loopCol(item.cols) |
| | | } |
| | | |
| | | list.push(m) |
| | |
| | | menus.push(menuObj[btn.openmenu]) |
| | | } |
| | | }) |
| | | item.cols && item.cols.forEach(col => { |
| | | if (col.type !== 'action') return |
| | | col.elements.forEach(btn => { |
| | | if (btn.linkmenu && menuObj[btn.linkmenu]) { |
| | | menus.push(menuObj[btn.linkmenu]) |
| | | } else if (btn.openmenu && menuObj[btn.openmenu]) { |
| | | menus.push(menuObj[btn.openmenu]) |
| | | let loopCol = (cols) => { |
| | | cols.forEach(col => { |
| | | if (col.type === 'colspan') { |
| | | loopCol(col.subcols) |
| | | } else if (col.type === 'custom') { |
| | | col.elements.forEach(cell => { |
| | | if (cell.eleType !== 'button') return |
| | | if (cell.linkmenu && menuObj[cell.linkmenu]) { |
| | | menus.push(menuObj[cell.linkmenu]) |
| | | } else if (cell.openmenu && menuObj[cell.openmenu]) { |
| | | menus.push(menuObj[cell.openmenu]) |
| | | } |
| | | }) |
| | | } |
| | | }) |
| | | } |
| | | loopCol(item.cols) |
| | | } |
| | | }) |
| | | } |
| | |
| | | return cols.map(col => { |
| | | if (col.type === 'colspan') { |
| | | col.subcols = getCols(col.subcols || []) |
| | | } else if (col.type === 'custom' || col.type === 'action') { |
| | | } else if (col.type === 'custom') { |
| | | col.elements = col.elements.map(cell => { |
| | | cell.miniStyle = this.transferStyle(cell.style) |
| | | return cell |
| | |
| | | _btn.config.MenuID = _btn.uuid |
| | | _btn.config.ParentId = card.uuid |
| | | _btn.config.MenuName = _btn.label |
| | | |
| | | _btn.config.components = this.updateComponents(_btn.config.components || []) |
| | | } else { |
| | | _btn.config = { |
| | | uuid: _btn.uuid, |
| | |
| | | }) |
| | | }) |
| | | |
| | | config.cols && config.cols.forEach(col => { |
| | | if (col.type === 'action') { |
| | | if (config.cols) { |
| | | let loopCol = (cols) => { |
| | | cols.forEach(col => { |
| | | if (col.type === 'colspan') { |
| | | loopCol(col.subcols) |
| | | } else if (col.type === 'custom') { |
| | | col.elements.forEach(cell => { |
| | | if (cell.eleType !== 'button') return |
| | | if (cell.OpenType === 'popview' && popbtns[cell.uuid]) { |
| | | cell.config = popbtns[cell.uuid] |
| | | } |
| | | }) |
| | | } |
| | | }) |
| | | } |
| | | loopCol(config.cols) |
| | | } |
| | | |
| | | config.elements && config.elements.forEach(cell => { |
| | | if (cell.eleType !== 'button') return |
| | |
| | | this.setState({ |
| | | needUpdate: true |
| | | }) |
| | | } else { |
| | | config.components = this.updateComponents(config.components) |
| | | } |
| | | |
| | | let navItem = null |
| | |
| | | this.getAppMenus() |
| | | } |
| | | |
| | | updateComponents = (components) => { // 兼容性升级 table |
| | | return components.map(item => { |
| | | if (item.type === 'tabs') { |
| | | item.subtabs.forEach(tab => { |
| | | tab.components = this.updateComponents(tab.components) |
| | | }) |
| | | } else if (item.type === 'group') { |
| | | item.components = this.updateComponents(item.components) |
| | | } else if (item.type === 'table') { |
| | | item.cols = item.cols.map(col => { |
| | | if (col.type === 'action') { |
| | | col.type = 'custom' |
| | | } |
| | | return col |
| | | }) |
| | | } |
| | | |
| | | return item |
| | | }) |
| | | } |
| | | |
| | | collectTB = (components) => { |
| | | return components.map(item => { |
| | | if (item.type === 'tabs') { |
| | |
| | | |
| | | if (item.subtype === 'tablecard') { // 兼容 |
| | | item.type = 'card' |
| | | } else if (item.type === 'table') { |
| | | item.cols = item.cols.map(col => { |
| | | if (col.type === 'action') { |
| | | col.type = 'custom' |
| | | } |
| | | return col |
| | | }) |
| | | } |
| | | |
| | | delete item.tabId |
| | |
| | | title: btn.label, |
| | | }) |
| | | }) |
| | | item.cols.forEach(col => { |
| | | if (col.type !== 'action') return |
| | | col.elements.forEach(btn => { |
| | | if (btn.hidden === 'true') return |
| | | |
| | | let loopCol = (cols) => { |
| | | cols.forEach(col => { |
| | | if (col.type === 'colspan') { |
| | | loopCol(col.subcols) |
| | | } else if (col.type === 'custom') { |
| | | col.elements.forEach(cell => { |
| | | if (cell.eleType !== 'button' || cell.hidden === 'true') return |
| | | m.children.push({ |
| | | key: btn.uuid, |
| | | title: btn.label, |
| | | key: cell.uuid, |
| | | title: cell.label, |
| | | }) |
| | | }) |
| | | } |
| | | }) |
| | | } |
| | | loopCol(item.cols) |
| | | } |
| | | |
| | | list.push(m) |
| | |
| | | menus.push(menuObj[btn.openmenu]) |
| | | } |
| | | }) |
| | | item.cols && item.cols.forEach(col => { |
| | | if (col.type !== 'action') return |
| | | col.elements.forEach(btn => { |
| | | if (btn.linkmenu && menuObj[btn.linkmenu]) { |
| | | menus.push(menuObj[btn.linkmenu]) |
| | | } else if (btn.openmenu && menuObj[btn.openmenu]) { |
| | | menus.push(menuObj[btn.openmenu]) |
| | | let loopCol = (cols) => { |
| | | cols.forEach(col => { |
| | | if (col.type === 'colspan') { |
| | | loopCol(col.subcols) |
| | | } else if (col.type === 'custom') { |
| | | col.elements.forEach(cell => { |
| | | if (cell.eleType !== 'button') return |
| | | if (cell.linkmenu && menuObj[cell.linkmenu]) { |
| | | menus.push(menuObj[cell.linkmenu]) |
| | | } else if (cell.openmenu && menuObj[cell.openmenu]) { |
| | | menus.push(menuObj[cell.openmenu]) |
| | | } |
| | | }) |
| | | } |
| | | }) |
| | | } |
| | | loopCol(item.cols) |
| | | } |
| | | }) |
| | | } |
| | | |
| | |
| | | _btn.config.MenuID = _btn.uuid |
| | | _btn.config.ParentId = card.uuid |
| | | _btn.config.MenuName = _btn.label |
| | | _btn.config.components = _btn.config.components || [] |
| | | _btn.config.components.forEach(item => { |
| | | if (item.type === 'tabs') { |
| | | item.subtabs.forEach(tab => { |
| | | tab.components[0].cols = tab.components[0].cols.map(col => { |
| | | if (col.type === 'action') { |
| | | col.type = 'custom' |
| | | } |
| | | return col |
| | | }) |
| | | }) |
| | | } else if (item.cols) { |
| | | item.cols = item.cols.map(col => { |
| | | if (col.type === 'action') { |
| | | col.type = 'custom' |
| | | } |
| | | return col |
| | | }) |
| | | } |
| | | }) |
| | | } else { |
| | | _btn.config = { |
| | | uuid: _btn.uuid, |
| | |
| | | submitPopConfig = (btnconfig) => { |
| | | let config = fromJS(this.state.config).toJS() |
| | | |
| | | let loopCol = (cols) => { |
| | | cols.forEach(col => { |
| | | if (col.type === 'colspan') { |
| | | loopCol(col.subcols) |
| | | } else if (col.type === 'custom') { |
| | | col.elements.forEach(cell => { |
| | | if (cell.eleType !== 'button') return |
| | | if (cell.OpenType === 'popview' && cell.uuid === btnconfig.uuid) { |
| | | cell.config = btnconfig |
| | | } |
| | | }) |
| | | } |
| | | }) |
| | | } |
| | | |
| | | config.components.forEach(item => { |
| | | if (item.type === 'tabs') { |
| | | item.subtabs.forEach(tab => { |
| | |
| | | btn.config = btnconfig |
| | | } |
| | | }) |
| | | tab.components[0].cols.forEach(col => { |
| | | if (col.type !== 'action') return |
| | | col.elements.forEach(btn => { |
| | | if (btn.OpenType === 'popview' && btn.uuid === btnconfig.uuid) { |
| | | btn.config = btnconfig |
| | | } |
| | | }) |
| | | }) |
| | | |
| | | loopCol(tab.components[0].cols) |
| | | |
| | | tab.components[0].$tables = getTables(tab.components[0]) |
| | | }) |
| | |
| | | btn.config = btnconfig |
| | | } |
| | | }) |
| | | item.cols.forEach(col => { |
| | | if (col.type !== 'action') return |
| | | col.elements.forEach(btn => { |
| | | if (btn.OpenType === 'popview' && btn.uuid === btnconfig.uuid) { |
| | | btn.config = btnconfig |
| | | } |
| | | }) |
| | | }) |
| | | |
| | | loopCol(item.cols) |
| | | |
| | | item.$tables = getTables(item) |
| | | } |
| | |
| | | if (item.type === 'tabs') { |
| | | item.subtabs.forEach(tab => { |
| | | tab.components[0].name = tab.label |
| | | tab.components[0].cols = tab.components[0].cols.map(col => { |
| | | if (col.type === 'action') { |
| | | col.type = 'custom' |
| | | } |
| | | return col |
| | | }) |
| | | }) |
| | | } else { |
| | | item.cols = item.cols.map(col => { |
| | | if (col.type === 'action') { |
| | | col.type = 'custom' |
| | | } |
| | | return col |
| | | }) |
| | | item.name = '主表' |
| | | } |
| | | }) |
| | |
| | | buttons.push(`select '${btn.uuid}' as menuid, '${btn.label}' as menuname, '${_s * 10}' as Sort, '${tab.components[0].uuid}' as parentid, 60 as Type`) |
| | | _s++ |
| | | }) |
| | | tab.components[0].cols.forEach(col => { |
| | | if (col.type !== 'action') return |
| | | col.elements.forEach(btn => { |
| | | if (btn.hidden === 'true') return |
| | | |
| | | buttons.push(`select '${btn.uuid}' as menuid, '${btn.label}' as menuname, '${_s * 10}' as Sort, '${tab.components[0].uuid}' as parentid, 60 as Type`) |
| | | let loopCol = (cols) => { |
| | | cols.forEach(col => { |
| | | if (col.type === 'colspan') { |
| | | loopCol(col.subcols) |
| | | } else if (col.type === 'custom') { |
| | | col.elements.forEach(cell => { |
| | | if (cell.eleType !== 'button' || cell.hidden === 'true') return |
| | | buttons.push(`select '${cell.uuid}' as menuid, '${cell.label}' as menuname, '${_s * 10}' as Sort, '${tab.components[0].uuid}' as parentid, 60 as Type`) |
| | | _s++ |
| | | }) |
| | | } |
| | | }) |
| | | } |
| | | |
| | | loopCol(tab.components[0].cols) |
| | | }) |
| | | } else { |
| | | if (item.$tables) { |
| | |
| | | buttons.push(`select '${btn.uuid}' as menuid, '${btn.label}' as menuname, '${_sort * 10}' as Sort, '${config.uuid}' as parentid, 40 as Type`) |
| | | _sort++ |
| | | }) |
| | | item.cols.forEach(col => { |
| | | if (col.type !== 'action') return |
| | | col.elements.forEach(btn => { |
| | | if (btn.hidden === 'true') return |
| | | |
| | | buttons.push(`select '${btn.uuid}' as menuid, '${btn.label}' as menuname, '${_sort * 10}' as Sort, '${config.uuid}' as parentid, 40 as Type`) |
| | | let loopCol = (cols) => { |
| | | cols.forEach(col => { |
| | | if (col.type === 'colspan') { |
| | | loopCol(col.subcols) |
| | | } else if (col.type === 'custom') { |
| | | col.elements.forEach(cell => { |
| | | if (cell.eleType !== 'button' || cell.hidden === 'true') return |
| | | buttons.push(`select '${cell.uuid}' as menuid, '${cell.label}' as menuname, '${_sort * 10}' as Sort, '${config.uuid}' as parentid, 40 as Type`) |
| | | _sort++ |
| | | }) |
| | | } |
| | | }) |
| | | } |
| | | |
| | | loopCol(item.cols) |
| | | } |
| | | }) |
| | | |
| | | return buttons |
| | |
| | | label: '序号', |
| | | subType: 'index', |
| | | $init: true |
| | | }, |
| | | { |
| | | type: 'col', |
| | | label: '操作', |
| | | subType: 'action', |
| | | $init: true |
| | | } |
| | | ], |
| | | tabItems: [ |