| | |
| | | tabledata: null, |
| | | btnconfig: null, |
| | | loading: false, |
| | | disabled: false, |
| | | loadingNumber: '' |
| | | } |
| | | |
| | | UNSAFE_componentWillMount () { |
| | | const { btn, selectedData } = this.props |
| | | let disabled = false |
| | | |
| | | if (btn.controlField && selectedData && selectedData.length > 0) { // 表格中按钮隐藏控制 |
| | | selectedData.forEach(item => { |
| | | let s = item[btn.controlField] + '' |
| | | if (s === btn.controlVal || (btn.controlVal && btn.controlVal.split(',').includes(s))) { |
| | | disabled = true |
| | | } |
| | | }) |
| | | this.setState({disabled}) |
| | | } |
| | | } |
| | | |
| | | shouldComponentUpdate (nextProps, nextState) { |
| | |
| | | |
| | | if (position === 'toolbar') { |
| | | MKEmitter.addListener('triggerBtnId', this.actionTrigger) |
| | | } |
| | | } |
| | | |
| | | UNSAFE_componentWillReceiveProps (nextProps) { |
| | | const { btn, selectedData } = this.props |
| | | |
| | | if (btn.controlField && !is(fromJS(nextProps.selectedData || []), fromJS(selectedData || []))) { |
| | | let disabled = false |
| | | |
| | | if (nextProps.selectedData && nextProps.selectedData.length > 0) { // 表格中按钮隐藏控制 |
| | | nextProps.selectedData.forEach(item => { |
| | | let s = item[btn.controlField] + '' |
| | | if (s === btn.controlVal || (btn.controlVal && btn.controlVal.split(',').includes(s))) { |
| | | disabled = true |
| | | } |
| | | }) |
| | | } |
| | | this.setState({disabled}) |
| | | } |
| | | } |
| | | |
| | |
| | | * @description 触发按钮操作 |
| | | */ |
| | | actionTrigger = (triggerId, record) => { |
| | | const { setting, Tab, BID, btn, selectedData } = this.props |
| | | const { Tab, BID, btn, selectedData, setting } = this.props |
| | | const { loading } = this.state |
| | | |
| | | if ((triggerId && btn.uuid !== triggerId) || loading) return |
| | | |
| | | if (Tab && Tab.supMenu && !BID) { |
| | | if (((Tab && Tab.supMenu) || setting.supModule) && !BID) { |
| | | notification.warning({ |
| | | top: 92, |
| | | message: '需要上级主键值!', |
| | |
| | | notification.warning({ |
| | | top: 92, |
| | | message: this.state.dict['main.action.confirm.selectSingleLine'], |
| | | duration: 5 |
| | | }) |
| | | return |
| | | } else if (!setting.primaryKey) { |
| | | // 需要选择行时,校验是否设置主键 |
| | | notification.warning({ |
| | | top: 92, |
| | | message: '未设置主键!', |
| | | duration: 5 |
| | | }) |
| | | return |
| | |
| | | |
| | | let errorMsg = '' |
| | | let _temps = {} |
| | | let images = [] |
| | | |
| | | result.forEach(res => { |
| | | if (res.status && !errorMsg) { |
| | |
| | | status: false |
| | | } |
| | | } else { |
| | | images = [...images, ..._temp.imgs] |
| | | _temps[res.tempId] = _temp |
| | | } |
| | | } else if (!errorMsg) { |
| | |
| | | }) |
| | | |
| | | if (!errorMsg) { |
| | | if (images.length > 0) { |
| | | let errorUrls = [] |
| | | images.forEach(url => { |
| | | let img = new Image() |
| | | img.onerror = () => { |
| | | errorUrls.push(url) |
| | | } |
| | | img.src = url |
| | | }) |
| | | |
| | | setTimeout(() => { |
| | | if (errorUrls.length > 0) { |
| | | notification.warning({ |
| | | top: 92, |
| | | message: '模板中图片 ' + errorUrls.join(',') + ' 已失效!', |
| | | duration: 5 |
| | | }) |
| | | Object.keys(_temps).forEach(key => { |
| | | _temps[key].config.ReportHeader.Control = _temps[key].config.ReportHeader.Control.map(item => { |
| | | if (item.Type === 'image' && errorUrls.includes(item.Value)) { |
| | | item.Value = '' |
| | | } |
| | | return item |
| | | }) |
| | | }) |
| | | } |
| | | |
| | | this.execPrint(printlist, _temps, formdata) |
| | | }, 500) |
| | | } else { |
| | | this.execPrint(printlist, _temps, formdata) |
| | | } |
| | | } else { |
| | | this.execError(errorMsg) |
| | | } |
| | |
| | | let _param = { ...param, ...formdata } |
| | | params.push(_param) |
| | | } else if (btn.Ot === 'requiredSgl') { |
| | | if (setting.primaryKey) { |
| | | param[setting.primaryKey] = data[0][setting.primaryKey] |
| | | } |
| | | |
| | | let _param = { ...param, ...formdata } |
| | | |
| | | params.push(_param) |
| | | } else if (btn.Ot === 'requiredOnce') { |
| | | if (setting.primaryKey) { |
| | | let ids = data.map(d => { return d[setting.primaryKey]}) |
| | | ids = ids.filter(Boolean) |
| | | ids = ids.join(',') |
| | | |
| | | param[setting.primaryKey] = ids |
| | | } |
| | | |
| | | let _param = { ...param, ...formdata } |
| | | |
| | |
| | | } else if (btn.Ot === 'required') { |
| | | params = data.map((cell, index) => { |
| | | let _param = { ...param } |
| | | |
| | | if (setting.primaryKey) { |
| | | _param[setting.primaryKey] = cell[setting.primaryKey] |
| | | } |
| | | |
| | | formlist.forEach(_data => { |
| | | if (index !== 0 && _data.readin && cell.hasOwnProperty(_data.key)) { |
| | |
| | | let _configparam = '' // 打印配置信息 |
| | | let fields = [] // 模板中所需字段 |
| | | let nonEFields = [] // 非空字段 |
| | | let imgs = [] |
| | | |
| | | if (!res.ConfigParam) { |
| | | error = '未获取到打印模板信息!' |
| | |
| | | if (!configParam) { |
| | | error = '打印模板解析错误!' |
| | | } else { |
| | | |
| | | let control = configParam.elements.map(element => { |
| | | let _field = element.field |
| | | |
| | |
| | | item.ImageWidth = element.imgWidth |
| | | item.ImageHeight = element.imgHeight |
| | | item.Trimming = '' |
| | | if (element.productValue && window.GLOB.systemType === 'production') { |
| | | item.Value = element.productValue |
| | | imgs.push(item.Value) |
| | | } else if (item.Value) { |
| | | imgs.push(item.Value) |
| | | } |
| | | } else if (item.Type === 'text') { |
| | | item.FontFamily = element.fontFamily |
| | | item.FontSize = element.fontSize |
| | |
| | | error: error, |
| | | config: _configparam, |
| | | fields: fields, |
| | | nonEFields: nonEFields |
| | | nonEFields: nonEFields, |
| | | imgs: imgs |
| | | } |
| | | } |
| | | |
| | |
| | | |
| | | render() { |
| | | const { btn, show } = this.props |
| | | const { loadingNumber, loading } = this.state |
| | | const { loadingNumber, loading, disabled } = this.state |
| | | |
| | | if (show === 'actionList') { |
| | | return <div style={{display: 'inline-block'}} onClick={(e) => e.stopPropagation()}> |
| | | <Button |
| | | icon={btn.icon} |
| | | loading={loading} |
| | | disabled={disabled} |
| | | className={'mk-btn mk-' + btn.class} |
| | | onClick={() => {this.actionTrigger()}} |
| | | >{loadingNumber ? `(${loadingNumber})` : '' + btn.label}</Button> |
| | |
| | | type="link" |
| | | title={show === 'icon' ? btn.label : ''} |
| | | loading={loading} |
| | | style={btn.btnstyle} |
| | | disabled={disabled} |
| | | style={btn.style} |
| | | icon={show === 'text' ? '' : (btn.icon || '')} |
| | | onClick={() => {this.actionTrigger()}} |
| | | >{show === 'icon' && btn.icon ? '' : btn.label}</Button> |