| | |
| | | } |
| | | |
| | | sessionStorage.clear() |
| | | sessionStorage.setItem('loginError', JSON.stringify({request: res.config ? res.config.data : '', response: JSON.stringify(res.data)})) |
| | | sessionStorage.setItem('loginError', JSON.stringify({url: res.config ? res.config.url : '', request: res.config ? res.config.data : '', response: JSON.stringify(res.data)})) |
| | | window.history.replaceState(null, null, window.location.href.split('#')[0] + '#/login') |
| | | window.location.reload() |
| | | } |
| | |
| | | if (window.debugger === true) { |
| | | response.data.ErrCode = 'E' |
| | | return Promise.resolve(response.data) |
| | | } else { |
| | | } else if (!sessionStorage.getItem('loginError')) { |
| | | setCurrentUrl(response) |
| | | } |
| | | } else { |
| | |
| | | const { getFieldDecorator } = this.props.form |
| | | const fields = [] |
| | | this.props.formlist.forEach((item, index) => { |
| | | if (item.type === 'text') { // 文本搜索 |
| | | if (item.type === 'text') { |
| | | fields.push( |
| | | <Col span={24 / this.props.cols} key={index}> |
| | | <Form.Item label={item.label}> |
| | |
| | | ) |
| | | } |
| | | |
| | | if (sessionStorage.getItem('loginError')) { |
| | | try { |
| | | let res = JSON.parse(sessionStorage.getItem('loginError')) |
| | | console.info(res.request) |
| | | console.info(res.response) |
| | | } catch (e) {} |
| | | } |
| | | sessionStorage.removeItem('isEditState') |
| | | sessionStorage.removeItem('loginError') |
| | | sessionStorage.setItem('role_id', sessionStorage.getItem('localRole_id') || '') |
| | | sessionStorage.setItem('dataM', sessionStorage.getItem('localDataM') || '') |
| | | |
| | |
| | | this.state.formlist.forEach((item, index) => { |
| | | if (item.hidden || item.forbid) return |
| | | |
| | | if (item.type === 'text') { // 文本搜索 |
| | | if (item.type === 'text') { |
| | | fields.push( |
| | | <Col span={12} key={index}> |
| | | <Form.Item label={item.tooltip ? |
| | |
| | | </Form.Item> |
| | | </Col> |
| | | ) |
| | | } else if (item.type === 'textarea') { // 文本搜索 |
| | | } else if (item.type === 'textarea') { |
| | | fields.push( |
| | | <Col span={24} className="textarea" key={index}> |
| | | <Form.Item label={item.tooltip ? |
| | |
| | | this.state.formlist.forEach((item, index) => { |
| | | if (item.hidden || item.forbid) return |
| | | |
| | | if (item.type === 'text') { // 文本搜索 |
| | | if (item.type === 'text') { |
| | | let _rules = [] |
| | | if (item.key === 'innerFunc') { |
| | | let str = '^(' + item.fields.join('|') + ')' |
| | |
| | | key: 'Width', |
| | | min: 20, |
| | | max: 1000, |
| | | decimal: 0, |
| | | precision: 0, |
| | | label: Formdict['model.form.columnWidth'], |
| | | initVal: card.Width || 120, |
| | | required: true |
| | |
| | | text: '是' |
| | | }] |
| | | }, |
| | | // { |
| | | // type: 'radio', |
| | | // key: 'editType', |
| | | // label: '编辑类型', |
| | | // initVal: card.editType || 'text', |
| | | // required: true, |
| | | // options: [{ |
| | | // value: 'text', |
| | | // text: '文本' |
| | | // }, { |
| | | // value: 'select', |
| | | // text: '下拉' |
| | | // }, { |
| | | // value: 'switch', |
| | | // text: '开关' |
| | | // }] |
| | | // }, |
| | | { |
| | | type: 'radio', |
| | | key: 'editType', |
| | | label: '编辑类型', |
| | | initVal: card.editType || 'text', |
| | | required: true, |
| | | options: [{ |
| | | value: 'text', |
| | | text: '文本' |
| | | }, { |
| | | value: 'select', |
| | | text: '下拉' |
| | | }, { |
| | | value: 'switch', |
| | | text: '开关' |
| | | }] |
| | | }, |
| | | { |
| | | type: 'text', |
| | | key: 'initval', |
| | | label: '默认值', |
| | | initVal: card.initval, |
| | | tooltip: '使用$copy时,表示新增时复制上一行信息。', |
| | | required: false |
| | | }, |
| | | { |
| | | type: 'text', |
| | | key: 'openVal', |
| | | label: '开启值', |
| | | initVal: card.openVal || '', |
| | | required: false |
| | | }, |
| | | { |
| | | type: 'text', |
| | | key: 'closeVal', |
| | | label: '关闭值', |
| | | initVal: card.closeVal || '', |
| | | required: false |
| | | }, |
| | | { |
| | | type: 'text', |
| | | key: 'openText', |
| | | label: '开启提示', |
| | | initVal: card.openText || '', |
| | | required: false |
| | | }, |
| | | { |
| | | type: 'text', |
| | | key: 'closeText', |
| | | label: '关闭提示', |
| | | initVal: card.closeText || '', |
| | | required: false |
| | | }, |
| | | { |
| | | type: 'radio', |
| | | key: 'resourceType', |
| | | label: '选项来源', |
| | | initVal: card.resourceType || '0', |
| | | required: true, |
| | | options: [{ |
| | | value: '0', |
| | | text: '自定义' |
| | | }, { |
| | | value: '1', |
| | | text: '数据源' |
| | | }] |
| | | }, |
| | | { |
| | | type: 'select', |
| | | key: 'editField', |
| | | label: '编辑字段', |
| | | initVal: card.editField || '', |
| | | tooltip: '当值与提示文字不同时,可额外添加编辑字段,作为实际值的录入字段。', |
| | | allowClear: true, |
| | | required: false, |
| | | options: fields |
| | | }, |
| | | { |
| | | type: 'options', |
| | | key: 'options', |
| | | label: '选项', |
| | | initVal: card.options || [], |
| | | required: true, |
| | | }, |
| | | { |
| | | type: 'codemirror', |
| | | key: 'dataSource', |
| | | label: '数据源', |
| | | initVal: card.dataSource || '', |
| | | required: true, |
| | | }, |
| | | { |
| | | type: 'text', |
| | | key: 'valueField', |
| | | label: '值·字段', |
| | | initVal: card.valueField || '', |
| | | required: true, |
| | | }, |
| | | { |
| | | type: 'text', |
| | | key: 'valueText', |
| | | label: '文本·字段', |
| | | initVal: card.valueText || '', |
| | | required: true, |
| | | }, |
| | | { |
| | | type: 'text', |
| | | key: 'orderBy', |
| | | label: '排序·字段', |
| | | initVal: card.orderBy || '', |
| | | required: false, |
| | | }, |
| | | { |
| | | type: 'select', |
| | | key: 'orderType', |
| | | label: '排序方式', |
| | | initVal: card.orderType || 'asc', |
| | | options: [{ |
| | | value: 'asc', |
| | | text: Formdict['header.form.asc'] |
| | | }, { |
| | | value: 'desc', |
| | | text: Formdict['header.form.desc'] |
| | | }] |
| | | }, |
| | | { |
| | | type: 'text', |
| | | key: 'disableField', |
| | | label: '禁用·字段', |
| | | initVal: card.disableField || '', |
| | | tooltip: '设置禁用字段,且字段值为true时,选项不可选。', |
| | | required: false, |
| | | }, |
| | | { |
| | | type: 'radio', |
| | | key: 'required', |
| | |
| | | }] |
| | | }, |
| | | { |
| | | type: 'text', |
| | | key: 'initval', |
| | | label: '默认值', |
| | | initVal: card.initval, |
| | | tooltip: '使用$copy时,表示新增时复制上一行信息。', |
| | | required: false |
| | | type: 'radio', |
| | | key: 'database', |
| | | label: '数据库', |
| | | initVal: card.database || 'local', |
| | | options: [{ |
| | | value: 'local', |
| | | text: '本地' |
| | | }, { |
| | | value: 'sso', |
| | | text: '系统' |
| | | }] |
| | | }, |
| | | { |
| | | type: 'select', |
| | | key: 'enter', |
| | | label: '回车切换', |
| | | initVal: card.enter || '$next', |
| | | tooltip: '包括文本或数值回车事件、下拉菜单选中事件、开关切换事件。', |
| | | options: editCols |
| | | }, |
| | | { |
| | |
| | | key: 'decimal', |
| | | min: 0, |
| | | max: 18, |
| | | decimal: 0, |
| | | precision: 0, |
| | | label: Formdict['header.form.decimal'], |
| | | initVal: card.decimal || 0, |
| | | required: true |
| | |
| | | label: Formdict['header.form.prefix'], |
| | | initVal: card.prefix || '', |
| | | required: false, |
| | | readonly: false |
| | | }, |
| | | { |
| | | type: 'text', |
| | |
| | | label: Formdict['header.form.postfix'], |
| | | initVal: card.postfix || '', |
| | | required: false, |
| | | readonly: false |
| | | }, |
| | | { |
| | | type: 'radio', |
| | |
| | | }, |
| | | { |
| | | type: 'multiselect', |
| | | key: 'linkSubField', |
| | | label: '填充表单', |
| | | tooltip: '在切换选项时会把信息自动填入关联的字段中。', |
| | | initVal: card.linkSubField || [], |
| | | options: fields |
| | | }, |
| | | { |
| | | type: 'multiselect', |
| | | key: 'blacklist', |
| | | label: Formdict['header.form.blacklist'], |
| | | initVal: card.blacklist || [], |
| | |
| | | |
| | | import { getColumnForm } from './formconfig' |
| | | import { formRule } from '@/utils/option.js' |
| | | import CodeMirror from '@/templates/zshare/codemirror' |
| | | import EditTable from '@/templates/zshare/modalform/modaleditable' |
| | | import './index.scss' |
| | | |
| | | |
| | | const { TextArea } = Input |
| | | const columnTypeOptions = { |
| | |
| | | state = { |
| | | visible: false, |
| | | formlist: null, |
| | | transfield: {} |
| | | } |
| | | |
| | | column = null |
| | | |
| | | UNSAFE_componentWillMount() { |
| | | let transfield = {} |
| | | this.props.columns.forEach(item => { |
| | | transfield[item.field] = item.label |
| | | }) |
| | | |
| | | this.setState({transfield}) |
| | | } |
| | | |
| | | UNSAFE_componentWillReceiveProps (nextProps) { |
| | | if (nextProps.column && !is(fromJS(this.props.column), fromJS(nextProps.column))) { |
| | |
| | | |
| | | if (this.column.editable === 'true') { |
| | | if (this.column.type === 'text') { |
| | | _options.push('editType', 'required', 'enter', 'footEnter') |
| | | _options.push('editType') |
| | | |
| | | if (this.column.editType === 'switch') { |
| | | _options.push('enter', 'footEnter', 'openVal', 'closeVal', 'openText', 'closeText') |
| | | } else if (this.column.editType === 'select') { |
| | | _options.push('required', 'enter', 'footEnter', 'resourceType', 'linkSubField', 'editField') |
| | | |
| | | if (this.column.resourceType === '0') { |
| | | _options.push('options') |
| | | } else { |
| | | _options.push('dataSource', 'valueField', 'valueText', 'orderBy', 'orderType', 'disableField', 'database') |
| | | } |
| | | } else { |
| | | _options.push('required', 'enter', 'footEnter') |
| | | } |
| | | } else if (this.column.type === 'number') { |
| | | _options.push('max', 'min', 'enter', 'footEnter') |
| | | } |
| | |
| | | let formlist = getColumnForm(column, this.props.fields, this.props.columns) |
| | | |
| | | this.column = fromJS(column).toJS() |
| | | this.column.editType = this.column.editType || 'text' |
| | | this.column.resourceType = this.column.resourceType || '0' |
| | | |
| | | let _options = this.getOptions() |
| | | |
| | |
| | | |
| | | this.setState({ |
| | | formlist: this.state.formlist.map(item => { |
| | | if (item.key === 'editable') { |
| | | item.initVal = this.column.editable || 'false' |
| | | } |
| | | item.initVal = this.column[item.key] || item.initVal |
| | | item.hidden = !_options.includes(item.key) |
| | | |
| | | return item |
| | |
| | | |
| | | this.setState({ |
| | | formlist: this.state.formlist.map(item => { |
| | | if (item.key === 'editable') { |
| | | item.initVal = this.column.editable || 'false' |
| | | } |
| | | item.initVal = this.column[item.key] || item.initVal |
| | | item.hidden = !_options.includes(item.key) |
| | | |
| | | return item |
| | |
| | | } |
| | | } else if (key === 'format' && value === 'percent') { |
| | | this.props.form.setFieldsValue({postfix: '%'}) |
| | | } else if (key === 'editable') { |
| | | } else if (key === 'editable' || key === 'editType' || key === 'resourceType') { |
| | | let _options = this.getOptions() |
| | | |
| | | this.setState({ |
| | | formlist: this.state.formlist.map(item => { |
| | | item.initVal = this.column[item.key] || item.initVal |
| | | item.hidden = !_options.includes(item.key) |
| | | |
| | | return item |
| | |
| | | } |
| | | } |
| | | |
| | | multiselectChange = (key, value) => { |
| | | if (key !== 'linkSubField') return |
| | | |
| | | this.column[key] = value |
| | | } |
| | | |
| | | handleEmpty = () => { |
| | | let field = this.props.form.getFieldValue('valueField') |
| | | |
| | | if (!field) { |
| | | notification.warning({ |
| | | top: 92, |
| | | message: '请填写值·字段。', |
| | | duration: 5 |
| | | }) |
| | | return |
| | | } |
| | | |
| | | let text = this.props.form.getFieldValue('valueText') |
| | | |
| | | if (!text) { |
| | | notification.warning({ |
| | | top: 92, |
| | | message: '请填写文本·字段。', |
| | | duration: 5 |
| | | }) |
| | | return |
| | | } |
| | | |
| | | let resource = this.props.form.getFieldValue('dataSource') || '' |
| | | |
| | | resource = `select '' as ${field},'全部' as ${text} union all \n${resource}` |
| | | |
| | | this.props.form.setFieldsValue({dataSource: resource}) |
| | | } |
| | | |
| | | changeOptions = (data) => { |
| | | this.column.options = data || [] |
| | | } |
| | | |
| | | getFields() { |
| | | const { dict } = this.props |
| | | const { getFieldDecorator } = this.props.form |
| | | const { formlist } = this.state |
| | | const { formlist, transfield } = this.state |
| | | const fields = [] |
| | | |
| | | if (!formlist) return null |
| | |
| | | formlist.forEach((item, index) => { |
| | | if (item.hidden || item.forbidden) return |
| | | |
| | | if (item.type === 'text') { // 文本搜索 |
| | | let rules = [] |
| | | if (item.key !== 'linkurl') { |
| | | rules = [{ |
| | | let span = 12 |
| | | let rules = [] |
| | | let className = '' |
| | | let content = null |
| | | let extra = null |
| | | let initVal = item.initVal || '' |
| | | |
| | | if (item.type === 'text') { |
| | | rules = [ |
| | | { required: item.required, message: dict['form.required.input'] + item.label + '!' }, |
| | | { |
| | | max: formRule.input.max, |
| | | message: formRule.input.message |
| | | }] |
| | | } |
| | | fields.push( |
| | | <Col span={12} key={index}> |
| | | <Form.Item label={item.tooltip ? |
| | | <Tooltip placement="topLeft" title={item.tooltip}> |
| | | <QuestionCircleOutlined className="mk-form-tip" /> |
| | | {item.label} |
| | | </Tooltip> : item.label |
| | | }> |
| | | {getFieldDecorator(item.key, { |
| | | initialValue: item.initVal || '', |
| | | rules: [ |
| | | { |
| | | required: !!item.required, |
| | | message: this.props.dict['form.required.input'] + item.label + '!' |
| | | }, |
| | | ...rules |
| | | ] |
| | | })(<Input placeholder="" autoComplete="off" disabled={item.readonly} onPressEnter={this.handleSubmit} />)} |
| | | </Form.Item> |
| | | </Col> |
| | | ) |
| | | } |
| | | ] |
| | | |
| | | content = <Input placeholder="" autoComplete="off" onPressEnter={this.handleSubmit} /> |
| | | } else if (item.type === 'number') { |
| | | fields.push( |
| | | <Col span={12} key={index}> |
| | | <Form.Item label={item.tooltip ? |
| | | <Tooltip placement="topLeft" title={item.tooltip}> |
| | | <QuestionCircleOutlined className="mk-form-tip" /> |
| | | {item.label} |
| | | </Tooltip> : item.label |
| | | }> |
| | | {getFieldDecorator(item.key, { |
| | | initialValue: item.initVal, |
| | | rules: [ |
| | | { |
| | | required: !!item.required, |
| | | message: this.props.dict['form.required.input'] + item.label + '!' |
| | | } |
| | | ] |
| | | })(item.unlimit ? <InputNumber onPressEnter={this.handleSubmit}/> : |
| | | <InputNumber min={item.min} max={item.max} precision={item.decimal} onPressEnter={this.handleSubmit}/>)} |
| | | </Form.Item> |
| | | </Col> |
| | | ) |
| | | rules = [ |
| | | { required: item.required, message: dict['form.required.input'] + item.label + '!' } |
| | | ] |
| | | initVal = item.initVal |
| | | |
| | | if (!item.unlimit) { |
| | | content = <InputNumber min={item.min} max={item.max} precision={item.precision} onPressEnter={this.handleSubmit}/> |
| | | } else { |
| | | content = <InputNumber onPressEnter={this.handleSubmit}/> |
| | | } |
| | | } else if (item.type === 'select') { |
| | | fields.push( |
| | | <Col span={12} key={index}> |
| | | <Form.Item label={item.label}> |
| | | {getFieldDecorator(item.key, { |
| | | initialValue: item.initVal || '', |
| | | rules: [ |
| | | { |
| | | required: !!item.required, |
| | | message: this.props.dict['form.required.select'] + item.label + '!' |
| | | } |
| | | ] |
| | | })( |
| | | <Select |
| | | showSearch |
| | | filterOption={(input, option) => option.props.children.toLowerCase().indexOf(input.toLowerCase()) >= 0} |
| | | onChange={(value, option) => {this.typeChange(item.key, value, option)}} |
| | | getPopupContainer={() => document.getElementById('columnwinter')} |
| | | > |
| | | {item.options.map((option, index) => |
| | | <Select.Option key={index} datatype={option.datatype || ''} value={(option.value || option.field || option.MenuID)}> |
| | | {(option.text || option.label || option.MenuName)} |
| | | </Select.Option> |
| | | )} |
| | | </Select> |
| | | )} |
| | | </Form.Item> |
| | | </Col> |
| | | ) |
| | | rules = [ |
| | | { required: item.required, message: dict['form.required.select'] + item.label + '!' } |
| | | ] |
| | | content = <Select |
| | | showSearch |
| | | allowClear={item.allowClear === true} |
| | | filterOption={(input, option) => option.props.children.toLowerCase().indexOf(input.toLowerCase()) >= 0} |
| | | onChange={(value, option) => {this.typeChange(item.key, value, option)}} |
| | | getPopupContainer={() => document.getElementById('edit-table-column-winter')} |
| | | > |
| | | {item.options.map((option, i) => |
| | | <Select.Option key={i} datatype={option.datatype || ''} value={(option.value || option.field || option.MenuID)}> |
| | | {(option.text || option.label || option.MenuName)} |
| | | </Select.Option> |
| | | )} |
| | | </Select> |
| | | } else if (item.type === 'radio') { |
| | | fields.push( |
| | | <Col span={12} key={index}> |
| | | <Form.Item label={item.tooltip ? |
| | | <Tooltip placement="topLeft" title={item.tooltip}> |
| | | <QuestionCircleOutlined className="mk-form-tip" /> |
| | | {item.label} |
| | | </Tooltip> : item.label |
| | | }> |
| | | {getFieldDecorator(item.key, { |
| | | initialValue: item.initVal, |
| | | rules: [ |
| | | { |
| | | required: !!item.required, |
| | | message: this.props.dict['form.required.select'] + item.label + '!' |
| | | } |
| | | ] |
| | | })( |
| | | <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> |
| | | ) |
| | | rules = [ |
| | | { required: item.required, message: dict['form.required.select'] + item.label + '!' } |
| | | ] |
| | | initVal = item.initVal |
| | | |
| | | content = <Radio.Group onChange={(e) => {this.typeChange(item.key, e.target.value)}}> |
| | | {item.options.map(option => <Radio key={option.value} value={option.value}>{option.text}</Radio>)} |
| | | </Radio.Group> |
| | | } else if (item.type === 'multiselect') { // 多选 |
| | | fields.push( |
| | | <Col span={12} key={index}> |
| | | <Form.Item label={item.label}> |
| | | {getFieldDecorator(item.key, { |
| | | initialValue: item.initVal || [] |
| | | })( |
| | | <Select |
| | | showSearch |
| | | mode="multiple" |
| | | filterOption={(input, option) => option.props.children.toLowerCase().indexOf(input.toLowerCase()) >= 0} |
| | | > |
| | | {item.options.map((option, i) => |
| | | <Select.Option id={i} key={i} value={option.value || option.field}>{option.text || option.label}</Select.Option> |
| | | )} |
| | | </Select> |
| | | )} |
| | | </Form.Item> |
| | | </Col> |
| | | ) |
| | | } else if (item.type === 'textarea') { // 文本搜索 |
| | | fields.push( |
| | | <Col span={24} key={index} className="textarea"> |
| | | <Form.Item label={item.tooltip ? |
| | | <Tooltip placement="topLeft" title={item.tooltip}> |
| | | <QuestionCircleOutlined className="mk-form-tip" /> |
| | | {item.label} |
| | | </Tooltip> : item.label |
| | | }> |
| | | {getFieldDecorator(item.key, { |
| | | initialValue: item.initVal || '', |
| | | rules: [ |
| | | { |
| | | required: !!item.required, |
| | | message: this.props.dict['form.required.input'] + item.label + '!' |
| | | } |
| | | ] |
| | | })(<TextArea rows={2} disabled={item.readonly} placeholder={item.placeholder || ''} />)} |
| | | </Form.Item> |
| | | </Col> |
| | | ) |
| | | content = <Select |
| | | showSearch |
| | | mode="multiple" |
| | | filterOption={(input, option) => option.props.children.toLowerCase().indexOf(input.toLowerCase()) >= 0} |
| | | onChange={(value) => this.multiselectChange(item.key, value)} |
| | | > |
| | | {item.options.map((option, i) => |
| | | <Select.Option key={i} value={option.value || option.field}>{option.text || option.label}</Select.Option> |
| | | )} |
| | | </Select> |
| | | } else if (item.type === 'textarea') { |
| | | span = 24 |
| | | className = 'text-area' |
| | | rules = [ |
| | | { required: item.required, message: dict['form.required.input'] + item.label + '!' } |
| | | ] |
| | | |
| | | content = <TextArea rows={item.rows || 2}/> |
| | | } else if (item.type === 'codemirror') { |
| | | rules = [ |
| | | { required: item.required, message: dict['form.required.input'] + item.label + '!' } |
| | | ] |
| | | span = 24 |
| | | className = 'text-area' |
| | | |
| | | extra = <span className="add-resource-empty" onClick={this.handleEmpty}>空</span> |
| | | |
| | | content = <CodeMirror /> |
| | | } else if (item.type === 'options') { |
| | | span = 24 |
| | | className = 'text-area' |
| | | |
| | | let linkSubFields = this.column.linkSubField || [] |
| | | |
| | | content = <EditTable type={'select'} module="form" transfield={transfield} linkSubFields={linkSubFields} onChange={this.changeOptions}/> |
| | | } |
| | | |
| | | fields.push( |
| | | <Col span={span} key={index}> |
| | | <Form.Item className={className} extra={extra} label={item.tooltip ? |
| | | <Tooltip placement="topLeft" title={item.tooltip}> |
| | | <QuestionCircleOutlined className="mk-form-tip" /> |
| | | {item.label} |
| | | </Tooltip> : item.label |
| | | }> |
| | | {getFieldDecorator(item.key, { |
| | | initialValue: initVal, |
| | | rules: rules |
| | | })(content)} |
| | | </Form.Item> |
| | | </Col> |
| | | ) |
| | | }) |
| | | return fields |
| | | } |
| | |
| | | } |
| | | this.setState({visible: false, formlist: null}) |
| | | this.props.submitCol(values) |
| | | |
| | | this.column = null |
| | | } |
| | | }) |
| | | } |
| | |
| | | <Modal |
| | | title="显示列编辑" |
| | | visible={visible} |
| | | width={800} |
| | | width={900} |
| | | maskClosable={false} |
| | | onOk={this.handleSubmit} |
| | | onCancel={this.editModalCancel} |
| | | destroyOnClose |
| | | > |
| | | <Form {...formItemLayout} className="commontable-column-form" id="columnwinter"> |
| | | <Form {...formItemLayout} className="commontable-column-form" id="edit-table-column-winter"> |
| | | <Row gutter={24}>{this.getFields()}</Row> |
| | | </Form> |
| | | </Modal> |
| | |
| | | padding-right: 3px; |
| | | } |
| | | } |
| | | .textarea { |
| | | .ant-form-item-label { |
| | | width: 12%; |
| | | } |
| | | .ant-form-item-control-wrapper { |
| | | .ant-form-item.text-area { |
| | | >.ant-form-item-control-wrapper { |
| | | width: 88%; |
| | | } |
| | | >.ant-form-item-label { |
| | | width: 12%; |
| | | } |
| | | .CodeMirror { |
| | | height: 150px; |
| | | } |
| | | } |
| | | .ant-form-extra { |
| | | padding-top: 0px; |
| | | min-height: 0px; |
| | | } |
| | | .add-resource-empty { |
| | | position: absolute; |
| | | right: 10px; |
| | | top: -25px; |
| | | color: #1890ff; |
| | | cursor: pointer; |
| | | font-size: 14px; |
| | | } |
| | | } |
| | |
| | | ] |
| | | }, |
| | | { |
| | | type: 'radio', |
| | | field: 'cache', |
| | | label: '缓存', |
| | | initval: wrap.cache || 'true', |
| | | tooltip: '对于使用数据源的下拉菜单,下拉选项是否缓存到本地。', |
| | | required: false, |
| | | options: [ |
| | | {value: 'true', label: '使用'}, |
| | | {value: 'false', label: '不使用'}, |
| | | ] |
| | | }, |
| | | { |
| | | type: 'color', |
| | | field: 'borderColor', |
| | | label: '边框颜色', |
| | |
| | | formlist.forEach((item, index) => { |
| | | if (item.hidden || item.forbidden) return |
| | | |
| | | if (item.type === 'text') { // 文本搜索 |
| | | if (item.type === 'text') { |
| | | let rules = [] |
| | | if (item.key !== 'linkurl') { |
| | | rules = [{ |
| | |
| | | </Form.Item> |
| | | </Col> |
| | | ) |
| | | } else if (item.type === 'textarea') { // 文本搜索 |
| | | } else if (item.type === 'textarea') { |
| | | fields.push( |
| | | <Col span={24} key={index} className="textarea"> |
| | | <Form.Item label={item.tooltip ? |
| | |
| | | import chart from '@/assets/mobimg/chart.png' |
| | | import tree from '@/assets/mobimg/tree.png' |
| | | import timeline from '@/assets/mobimg/timeline.png' |
| | | import Voucher from '@/assets/mobimg/voucher.jpg' |
| | | // import Voucher from '@/assets/mobimg/voucher.jpg' |
| | | |
| | | // 组件配置信息 |
| | | export const menuOptions = [ |
| | |
| | | { type: 'menu', url: Editor, component: 'editor', subtype: 'brafteditor', title: '富文本', width: 24, forbid: ['billPrint'] }, |
| | | { type: 'menu', url: SandBox, component: 'code', subtype: 'sandbox', title: '自定义', width: 24 }, |
| | | { type: 'menu', url: group, component: 'group', subtype: 'normalgroup', title: '分组', width: 24, forbid: ['billPrint'] }, |
| | | { type: 'menu', url: Voucher, component: 'module', subtype: 'voucher', title: '凭证', width: 24, forbid: ['billPrint'] }, |
| | | // { type: 'menu', url: Voucher, component: 'module', subtype: 'voucher', title: '凭证', width: 24, forbid: ['billPrint'] }, |
| | | ] |
| | |
| | | return col |
| | | }) |
| | | } |
| | | if (m.verify && m.verify.columns) { |
| | | m.verify.columns = m.verify.columns.map(col => { |
| | | if (col.Column && map[col.Column.toLowerCase()]) { |
| | | col.Column = map[col.Column.toLowerCase()].FieldName |
| | | } |
| | | return col |
| | | }) |
| | | } |
| | | }) |
| | | } |
| | | |
| | |
| | | return col |
| | | }) |
| | | } |
| | | if (m.verify && m.verify.columns) { |
| | | m.verify.columns = m.verify.columns.map(col => { |
| | | if (col.Column && map[col.Column.toLowerCase()]) { |
| | | col.Column = map[col.Column.toLowerCase()].FieldName |
| | | } |
| | | return col |
| | | }) |
| | | } |
| | | return m |
| | | }) |
| | | } |
| | |
| | | m.modal.fields = m.modal.fields.map(col => { |
| | | if (col.field && map[col.field.toLowerCase()]) { |
| | | col.field = map[col.field.toLowerCase()].FieldName |
| | | } |
| | | return col |
| | | }) |
| | | } |
| | | if (m.verify && m.verify.columns) { |
| | | m.verify.columns = m.verify.columns.map(col => { |
| | | if (col.Column && map[col.Column.toLowerCase()]) { |
| | | col.Column = map[col.Column.toLowerCase()].FieldName |
| | | } |
| | | return col |
| | | }) |
| | |
| | | m.modal.fields = m.modal.fields.map(col => { |
| | | if (col.field && map[col.field.toLowerCase()]) { |
| | | col.field = map[col.field.toLowerCase()].FieldName |
| | | } |
| | | return col |
| | | }) |
| | | } |
| | | if (m.verify && m.verify.columns) { |
| | | m.verify.columns = m.verify.columns.map(col => { |
| | | if (col.Column && map[col.Column.toLowerCase()]) { |
| | | col.Column = map[col.Column.toLowerCase()].FieldName |
| | | } |
| | | return col |
| | | }) |
| | |
| | | return col |
| | | }) |
| | | } |
| | | if (m.verify && m.verify.columns) { |
| | | m.verify.columns = m.verify.columns.map(col => { |
| | | if (col.Column && map[col.Column.toLowerCase()]) { |
| | | col.Column = map[col.Column.toLowerCase()].FieldName |
| | | } |
| | | return col |
| | | }) |
| | | } |
| | | |
| | | return m |
| | | }) |
| | |
| | | } |
| | | return col |
| | | }) |
| | | |
| | | config.search = config.search.map(col => { |
| | | if (col.field && map[col.field.toLowerCase()]) { |
| | | col.field = map[col.field.toLowerCase()].FieldName |
| | |
| | | col.datefield = map[col.datefield.toLowerCase()].FieldName |
| | | } |
| | | return col |
| | | }) |
| | | |
| | | config.action = config.action.map(m => { |
| | | if (m.verify && m.verify.columns) { |
| | | m.verify.columns = m.verify.columns.map(col => { |
| | | if (col.Column && map[col.Column.toLowerCase()]) { |
| | | col.Column = map[col.Column.toLowerCase()].FieldName |
| | | } |
| | | return col |
| | | }) |
| | | } |
| | | return m |
| | | }) |
| | | } else if (this.props.type === 'form') { |
| | | config.fields = config.fields.map(col => { |
| | |
| | | return col |
| | | }) |
| | | } |
| | | if (m.verify && m.verify.columns) { |
| | | m.verify.columns = m.verify.columns.map(col => { |
| | | if (col.Column && map[col.Column.toLowerCase()]) { |
| | | col.Text = map[col.Column.toLowerCase()].FieldDec |
| | | } |
| | | return col |
| | | }) |
| | | } |
| | | }) |
| | | } |
| | | |
| | |
| | | m.modal.fields = m.modal.fields.map(col => { |
| | | if (col.field && map[col.field.toLowerCase()]) { |
| | | col.label = map[col.field.toLowerCase()].FieldDec |
| | | } |
| | | return col |
| | | }) |
| | | } |
| | | if (m.verify && m.verify.columns) { |
| | | m.verify.columns = m.verify.columns.map(col => { |
| | | if (col.Column && map[col.Column.toLowerCase()]) { |
| | | col.Text = map[col.Column.toLowerCase()].FieldDec |
| | | } |
| | | return col |
| | | }) |
| | |
| | | } |
| | | return col |
| | | }) |
| | | |
| | | |
| | | config.search = config.search.map(col => { |
| | | if (col.field && map[col.field.toLowerCase()]) { |
| | | col.label = map[col.field.toLowerCase()].FieldDec |
| | | } |
| | | return col |
| | | }) |
| | | |
| | | config.action = config.action.map(m => { |
| | | if (m.verify && m.verify.columns) { |
| | | m.verify.columns = m.verify.columns.map(col => { |
| | | if (col.Column && map[col.Column.toLowerCase()]) { |
| | | col.Text = map[col.Column.toLowerCase()].FieldDec |
| | | } |
| | | return col |
| | | }) |
| | | } |
| | | return m |
| | | }) |
| | | } else if (this.props.type === 'form') { |
| | | config.fields = config.fields.map(col => { |
| | | if (col.field && map[col.field.toLowerCase()]) { |
| | |
| | | <div className="am-navbar-title">{group.setting.title}</div> |
| | | </div> : <div className="am-navbar"> |
| | | {/* <LeftOutlined /> */} |
| | | <div className="search-bar"><SearchOutlined /></div> |
| | | <div className="search-bar"><SearchOutlined style={{marginRight: '10px'}}/>{group.setting.label || ''}</div> |
| | | <Button >取消</Button> |
| | | </div>} |
| | | {group.floor === 1 ? <PlusOutlined className="plus-group" onClick={this.plusGroup} /> : null} |
| | |
| | | </Form.Item> |
| | | </Col> : null} |
| | | {type === 'search' ? <Col span={12}> |
| | | <Form.Item label="提示文字"> |
| | | {getFieldDecorator('label', { |
| | | initialValue: config.setting.label, |
| | | rules: [ |
| | | { |
| | | max: formRule.input.max, |
| | | message: formRule.input.message |
| | | } |
| | | ] |
| | | })(<Input placeholder="" autoComplete="off" onPressEnter={this.handleSubmit} />)} |
| | | </Form.Item> |
| | | </Col> : null} |
| | | {type === 'search' ? <Col span={12}> |
| | | <Form.Item label="匹配方式"> |
| | | {getFieldDecorator('match', { |
| | | initialValue: config.setting.match || 'like' |
| | |
| | | let _data = null |
| | | let _sync = _config.setting.sync === 'true' |
| | | let setting = {..._config.setting, ..._config.wrap, style: {}} |
| | | setting.tableId = Utils.getuuid() |
| | | |
| | | if (_config.setting.sync === 'true' && data) { |
| | | _data = data[_config.dataName] || [] |
| | |
| | | _cols.set(item.field, item) |
| | | }) |
| | | |
| | | let _columns = [] |
| | | // let signAdd = false |
| | | _config.cols.forEach(column => { |
| | | if (column.Hide === 'true') return |
| | | if (column.type === 'index') { |
| | | column.field = '$Index' |
| | | column.type = 'text' |
| | | } |
| | | |
| | | // if (setting.addable === 'true' && column.type !== 'action' && !signAdd) { |
| | | // column.addable = true |
| | | // signAdd = true |
| | | // } |
| | | |
| | | if (column.marks && column.marks.length === 0) { |
| | | column.marks = '' |
| | | } |
| | | |
| | | column.tableId = setting.tableId |
| | | |
| | | if (column.type === 'text' && column.editable === 'true' && column.editType === 'select') { |
| | | column.options = column.options || [] |
| | | column.options = column.options.filter(cell => { |
| | | cell.value = cell.Value |
| | | cell.label = cell.Text |
| | | |
| | | return !cell.Hide |
| | | }) |
| | | } |
| | | |
| | | if (column.type === 'custom') { |
| | | column.elements = column.elements.map(item => { |
| | | if (item.eleType === 'number' && item.field && _cols.has(item.field) && typeof(item.decimal) !== 'number') { |
| | |
| | | } else if (column.type === 'action') { |
| | | column.operations = column.elements |
| | | } |
| | | |
| | | _columns.push(column) |
| | | }) |
| | | |
| | | // if (setting.delable !== 'false') { |
| | | // if (_columns[_columns.length - 1] && _columns[_columns.length - 1].type !== 'action') { |
| | | // _columns[_columns.length - 1].delable = true |
| | | // } else if (_columns[_columns.length - 2] && _columns[_columns.length - 2].type !== 'action') { |
| | | // _columns[_columns.length - 2].delable = true |
| | | // } |
| | | // } |
| | | |
| | | if (setting.color) { |
| | | setting.style.color = setting.color |
| | |
| | | setting: setting, |
| | | searchlist: _config.search, |
| | | actions: _config.action, |
| | | columns: _config.cols, |
| | | columns: _columns, |
| | | arr_field: _config.columns.map(col => col.field).join(','), |
| | | search: Utils.initMainSearch(_config.search) // 搜索条件初始化(含有时间格式,需要转化) |
| | | }, () => { |
New file |
| | |
| | | import React, {Component} from 'react' |
| | | import PropTypes from 'prop-types' |
| | | // import { is, fromJS } from 'immutable' |
| | | import { Switch } from 'antd' |
| | | |
| | | import './index.scss' |
| | | |
| | | class ColorSketch extends Component { |
| | | static propTpyes = { |
| | | defaultValue: PropTypes.any, |
| | | config: PropTypes.object, |
| | | onChange: PropTypes.func |
| | | } |
| | | state = { |
| | | status: false |
| | | } |
| | | |
| | | UNSAFE_componentWillMount () { |
| | | const { defaultValue, config } = this.props |
| | | |
| | | let status = false |
| | | |
| | | if (defaultValue === config.openVal) { |
| | | status = true |
| | | } |
| | | |
| | | this.setState({status}) |
| | | } |
| | | |
| | | changeStatus = (val) => { |
| | | const { config } = this.props |
| | | this.setState({ status: val }, () => { |
| | | let _val = val ? config.openVal : config.closeVal |
| | | this.props.onChange(_val) |
| | | }) |
| | | } |
| | | |
| | | render() { |
| | | const { config } = this.props |
| | | const { status } = this.state |
| | | return ( |
| | | <Switch checkedChildren={config.openText} autoFocus={true} onBlur={this.props.onBlur} unCheckedChildren={config.closeText} checked={status} onChange={this.changeStatus} /> |
| | | ) |
| | | } |
| | | } |
| | | |
| | | export default ColorSketch |
New file |
| | |
| | | .color-sketch-block { |
| | | height: 25px; |
| | | width: 100%; |
| | | |
| | | .color-sketch-block-box { |
| | | display: inline-block; |
| | | width: calc(100% - 160px); |
| | | height: 100%; |
| | | border-radius: 2px; |
| | | background: #ffffff url('data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAABAAAAAQCAYAAAAf8/9hAAAAMUlEQVQ4T2NkYGAQYcAP3uCTZhw1gGGYhAGBZIA/nYDCgBDAm9BGDWAAJyRCgLaBCAAgXwixzAS0pgAAAABJRU5ErkJggg==') left center; |
| | | } |
| | | .color-sketch-block-inner { |
| | | display: inline-block; |
| | | cursor: pointer; |
| | | border-radius: 2px; |
| | | box-shadow: 0 0 0 1px rgba(0, 0, 0, .1); |
| | | width: 100%; |
| | | height: 100%; |
| | | } |
| | | .color-sketch-value { |
| | | display: inline-block; |
| | | width: 160px; |
| | | padding-left: 10px; |
| | | height: 25px; |
| | | line-height: 25px; |
| | | vertical-align: top; |
| | | white-space: nowrap; |
| | | overflow: visible; |
| | | } |
| | | } |
| | | |
| | | .color-sketch-popover { |
| | | z-index: 1090!important; |
| | | .ant-popover-inner-content { |
| | | padding: 0; |
| | | .sketch-picker { |
| | | width: 250px!important; |
| | | } |
| | | } |
| | | } |
| | |
| | | import React, {Component} from 'react' |
| | | import PropTypes from 'prop-types' |
| | | import { is, fromJS } from 'immutable' |
| | | import { Table, Typography, Switch, Modal, Input, InputNumber, Tooltip, Button, notification, message } from 'antd' |
| | | import { Table, Typography, Switch, Modal, Input, InputNumber, Tooltip, Button, notification, message, Select } from 'antd' |
| | | import { ExclamationCircleOutlined, EditOutlined, PlusOutlined } from '@ant-design/icons' |
| | | import moment from 'moment' |
| | | |
| | | import Api from '@/api' |
| | | import options from '@/store/options.js' |
| | | import asyncComponent from '@/utils/asyncComponent' |
| | | import Utils, { getEditTableSql, getMark } from '@/utils/utils.js' |
| | | import MkIcon from '@/components/mk-icon' |
| | | import MKEmitter from '@/utils/events.js' |
| | | import zhCN from '@/locales/zh-CN/main.js' |
| | | import enUS from '@/locales/en-US/main.js' |
| | | import CusSwitch from './cusSwitch' |
| | | import '@/assets/css/table.scss' |
| | | import './index.scss' |
| | | |
| | |
| | | focus = () => { |
| | | const { col, record } = this.props |
| | | |
| | | let err = null |
| | | let val = record[col.field] !== undefined ? record[col.field] : '' |
| | | |
| | | if (col.type === 'number') { |
| | | val = +val |
| | | if (isNaN(val)) { |
| | | val = 0 |
| | | if (col.editType === 'switch' || col.editType === 'select') { |
| | | this.setState({editing: true}, () => { |
| | | let node = document.getElementById(col.uuid + record.$Index) |
| | | node && node.click() |
| | | }) |
| | | } else { |
| | | let err = null |
| | | let val = record[col.field] !== undefined ? record[col.field] : '' |
| | | |
| | | if (col.type === 'number') { |
| | | val = +val |
| | | if (isNaN(val)) { |
| | | val = 0 |
| | | } |
| | | if (typeof(col.max) === 'number' && val > col.max) { |
| | | err = col.label + '最大为' + col.max |
| | | } else if (typeof(col.min) === 'number' && val < col.min) { |
| | | err = col.label + '最小为' + col.min |
| | | } |
| | | } else if (col.required === 'true' && !val) { |
| | | err = '请填写' + col.label |
| | | } |
| | | if (typeof(col.max) === 'number' && val > col.max) { |
| | | err = col.label + '最大为' + col.max |
| | | } else if (typeof(col.min) === 'number' && val < col.min) { |
| | | err = col.label + '最小为' + col.min |
| | | } |
| | | } else if (col.required === 'true' && !val) { |
| | | err = '请填写' + col.label |
| | | |
| | | this.setState({editing: true, value: val, err}, () => { |
| | | let node = document.getElementById(col.uuid + record.$Index) |
| | | node && node.select() |
| | | }) |
| | | } |
| | | |
| | | this.setState({editing: true, value: val, err}, () => { |
| | | let node = document.getElementById(col.uuid + record.$Index) |
| | | node && node.select() |
| | | }) |
| | | } |
| | | |
| | | onBlur = () => { |
| | |
| | | err = '请填写' + col.label |
| | | } |
| | | this.setState({value: val, err}) |
| | | } |
| | | |
| | | onSwitchChange = (val) => { |
| | | const { col, record } = this.props |
| | | |
| | | this.setState({editing: false}) |
| | | |
| | | setTimeout(() => { |
| | | if (col.enter === '$next') { |
| | | MKEmitter.emit('nextLine', col, record.$Index) |
| | | } else { |
| | | MKEmitter.emit('tdFocus', col.enter + record.$Index) |
| | | } |
| | | }, 50) |
| | | |
| | | MKEmitter.emit('changeRecord', col.tableId, {...record, [col.field]: val}) |
| | | } |
| | | |
| | | onSelectChange = (val, option) => { |
| | | const { col, record } = this.props |
| | | |
| | | let values = {} |
| | | let _option = col.options.filter(m => m.key === option.key)[0] |
| | | |
| | | if (_option) { |
| | | if (col.linkSubField) { |
| | | col.linkSubField.forEach(m => { |
| | | values[m] = _option[m] !== undefined ? _option[m] : '' |
| | | }) |
| | | } |
| | | |
| | | if (col.editField) { |
| | | values[col.field] = _option.label |
| | | values[col.editField] = val |
| | | } else { |
| | | values[col.field] = val |
| | | } |
| | | } |
| | | |
| | | this.setState({editing: false}) |
| | | |
| | | setTimeout(() => { |
| | | if (col.enter === '$next') { |
| | | MKEmitter.emit('nextLine', col, record.$Index) |
| | | } else { |
| | | MKEmitter.emit('tdFocus', col.enter + record.$Index) |
| | | } |
| | | }, 50) |
| | | |
| | | MKEmitter.emit('changeRecord', col.tableId, {...record, ...values}) |
| | | } |
| | | |
| | | switchBlur = () => { |
| | | setTimeout(() => { |
| | | this.setState({editing: false}) |
| | | }, 10) |
| | | } |
| | | |
| | | render() { |
| | |
| | | |
| | | if (col.editable === 'true') { |
| | | if (editing) { |
| | | return (<td className="editing_table_cell"> |
| | | <Input id={col.uuid + record.$Index} defaultValue={value} onChange={(e) => this.onChange(e.target.value)} onPressEnter={this.enterPress} onBlur={this.onBlur}/> |
| | | {err ? <Tooltip title={err}><ExclamationCircleOutlined /></Tooltip> : null} |
| | | </td>) |
| | | if (!col.editType || col.editType === 'text') { |
| | | return (<td className="editing_table_cell"> |
| | | <Input id={col.uuid + record.$Index} defaultValue={value} onChange={(e) => this.onChange(e.target.value)} onPressEnter={this.enterPress} onBlur={this.onBlur}/> |
| | | {err ? <Tooltip title={err}><ExclamationCircleOutlined /></Tooltip> : null} |
| | | </td>) |
| | | } else if (col.editType === 'switch') { |
| | | let _value = record[col.field] !== undefined ? record[col.field] : '' |
| | | return (<td className="editing_table_cell"> |
| | | <CusSwitch config={col} defaultValue={_value} onChange={this.onSwitchChange} onBlur={this.switchBlur}/> |
| | | </td>) |
| | | } else { |
| | | let _value = record[col.field] !== undefined ? record[col.field] : '' |
| | | return (<td className="editing_table_cell"> |
| | | <Select |
| | | showSearch |
| | | defaultValue={_value} |
| | | id={col.uuid + record.$Index} |
| | | onBlur={() => this.setState({editing: false})} |
| | | filterOption={(input, option) => option.props.children.toLowerCase().indexOf(input.toLowerCase()) >= 0} |
| | | onSelect={this.onSelectChange} |
| | | > |
| | | {col.options.map((item, i) => (<Select.Option key={item.key} disabled={item.$disabled} value={item.value}>{item.label}</Select.Option>))} |
| | | </Select> |
| | | </td>) |
| | | } |
| | | } else { |
| | | return (<td className={className + ' pointer'} style={style}><div className="mk-mask" onClick={this.focus}></div>{content}</td>) |
| | | } |
| | |
| | | ) |
| | | } |
| | | |
| | | // return (<td className={className} style={style}>{col.addable ? <PlusCircleOutlined className="mk-editable mk-plus"/> : null}{children}{col.delable ? <DeleteOutlined className="mk-editable mk-del"/> : null}</td>) |
| | | return (<td className={className} style={style}>{children}</td>) |
| | | } |
| | | } |
| | |
| | | let orderfields = {} |
| | | let initEditLine = null |
| | | let edColumns = [] |
| | | let tableId = (() => { |
| | | let uuid = [] |
| | | let _options = 'abcdefghigklmnopqrstuv' |
| | | for (let i = 0; i < 19; i++) { |
| | | uuid.push(_options.substr(Math.floor(Math.random() * 0x20), 1)) |
| | | } |
| | | return uuid.join('') |
| | | }) () |
| | | |
| | | let _columns = [] |
| | | let deForms = [] |
| | | columns.forEach(item => { |
| | | if (item.Hide === 'true') return |
| | | if (item.type === 'index') { |
| | | item.field = '$Index' |
| | | item.type = 'text' |
| | | } |
| | | |
| | | item.tableId = tableId |
| | | |
| | | if (!initEditLine && item.editable === 'true') { |
| | | initEditLine = item |
| | | } |
| | | |
| | | if (item.marks && item.marks.length === 0) { |
| | | item.marks = '' |
| | | if (item.type === 'text' && item.editable === 'true' && item.editType === 'select' && item.resourceType === '1') { |
| | | let _option = Utils.getSelectQueryOptions(item) |
| | | |
| | | item.base_sql = window.btoa(window.encodeURIComponent(_option.sql)) |
| | | item.arr_field = _option.field |
| | | |
| | | deForms.push(item) |
| | | } |
| | | |
| | | if (item.field) { |
| | |
| | | _columns.push(_item) |
| | | }) |
| | | |
| | | if (setting.delable !== 'false') { |
| | | edColumns.push({ |
| | | align: 'center', |
| | | dataIndex: 'mkoperation', |
| | | title: '操作', |
| | | sorter: false, |
| | | width: 100, |
| | | onCell: record => ({ |
| | | record, |
| | | col: {type: 'operation', tableId: tableId}, |
| | | }) |
| | | }) |
| | | } |
| | | // if (setting.delable !== 'false') { |
| | | // edColumns.push({ |
| | | // align: 'center', |
| | | // dataIndex: 'mkoperation', |
| | | // title: '操作', |
| | | // sorter: false, |
| | | // width: 100, |
| | | // onCell: record => ({ |
| | | // record, |
| | | // col: {type: 'operation', tableId: setting.tableId}, |
| | | // }) |
| | | // }) |
| | | // } |
| | | |
| | | if (setting.borderColor) { // 边框颜色 |
| | | let style = `#${tableId} table, #${tableId} tr, #${tableId} th, #${tableId} td {border-color: ${setting.borderColor}}` |
| | | let style = `#${setting.tableId} table, #${setting.tableId} tr, #${setting.tableId} th, #${setting.tableId} td {border-color: ${setting.borderColor}}` |
| | | let ele = document.createElement('style') |
| | | ele.innerHTML = style |
| | | document.getElementsByTagName('head')[0].appendChild(ele) |
| | |
| | | data, |
| | | columns: _columns, |
| | | edColumns, |
| | | tableId, |
| | | tableId: setting.tableId, |
| | | orderfields, |
| | | initEditLine, |
| | | editable: setting.editable |
| | | }, () => { |
| | | if (deForms.length > 0) { |
| | | this.improveActionForm(deForms) |
| | | } |
| | | }) |
| | | } |
| | | |
| | |
| | | componentDidMount () { |
| | | const { fields, setting } = this.props |
| | | const { data, editable } = this.state |
| | | |
| | | // let _fields = [] // 定义全部字段,不在从可编辑列中选取 |
| | | |
| | | // let fieldType = {} |
| | | // fields.forEach(item => { |
| | | // fieldType[item.field] = item.datatype |
| | | // }) |
| | | |
| | | // columns.forEach(col => { |
| | | // if (!col.field || col.type === 'index') return |
| | | |
| | | // _fields.push({...col, datatype: fieldType[col.field] || 'Nvarchar(50)'}) |
| | | // }) |
| | | |
| | | this.setState({ |
| | | fields: fields.filter(item => item.field !== setting.primaryKey), |
| | |
| | | } |
| | | } |
| | | } |
| | | |
| | | improveActionForm = (deForms) => { |
| | | const { BID, setting } = this.props |
| | | |
| | | let deffers = [] |
| | | let mainItems = [] // 云端或单点数据 |
| | | let localItems = [] // 本地数据 |
| | | let cache = setting.cache !== 'false' |
| | | |
| | | deForms.forEach(item => { |
| | | if (item.database === 'sso') { |
| | | mainItems.push(`select '${item.uuid}' as obj_name,'${item.arr_field}' as arr_field,'${item.base_sql}' as LText`) |
| | | } else { |
| | | localItems.push(`select '${item.uuid}' as obj_name,'${item.arr_field}' as arr_field,'${item.base_sql}' as LText`) |
| | | } |
| | | }) |
| | | |
| | | if (options.sysType !== 'local') { |
| | | localItems = [...localItems, ...mainItems] |
| | | mainItems = [] |
| | | } |
| | | |
| | | // 本地请求 |
| | | let param = { |
| | | func: 'sPC_Get_SelectedList', |
| | | LText: localItems.join(' union all '), |
| | | obj_name: '', |
| | | arr_field: '', |
| | | table_type: 'Y', |
| | | BID: BID || '' |
| | | } |
| | | |
| | | if (param.LText) { |
| | | param.LText = Utils.formatOptions(param.LText) |
| | | param.timestamp = moment().format('YYYY-MM-DD HH:mm:ss') |
| | | param.secretkey = Utils.encrypt(param.LText, param.timestamp) |
| | | |
| | | deffers.push( |
| | | new Promise(resolve => { |
| | | Api.getSystemCacheConfig(param, cache).then(res => { |
| | | if (!res.status) { |
| | | notification.warning({ |
| | | top: 92, |
| | | message: res.message, |
| | | duration: 5 |
| | | }) |
| | | } |
| | | resolve(res) |
| | | }) |
| | | }) |
| | | ) |
| | | } |
| | | |
| | | // 系统请求 |
| | | let mainparam = { |
| | | func: 'sPC_Get_SelectedList', |
| | | LText: mainItems.join(' union all '), |
| | | obj_name: '', |
| | | arr_field: '', |
| | | table_type: 'Y', |
| | | BID: BID || '' |
| | | } |
| | | |
| | | if (mainparam.LText) { |
| | | mainparam.LText = Utils.formatOptions(mainparam.LText) |
| | | mainparam.timestamp = moment().format('YYYY-MM-DD HH:mm:ss') |
| | | mainparam.secretkey = Utils.encrypt(mainparam.LText, mainparam.timestamp) |
| | | |
| | | if (window.GLOB.mainSystemApi) { |
| | | mainparam.rduri = window.GLOB.mainSystemApi |
| | | } |
| | | |
| | | deffers.push( |
| | | new Promise(resolve => { |
| | | Api.getSystemCacheConfig(mainparam, cache).then(res => { |
| | | if (!res.status) { |
| | | notification.warning({ |
| | | top: 92, |
| | | message: res.message, |
| | | duration: 5 |
| | | }) |
| | | } |
| | | resolve(res) |
| | | }) |
| | | }) |
| | | ) |
| | | } |
| | | |
| | | Promise.all(deffers).then(response => { |
| | | let result = {...response[0], ...(response[1] || {})} |
| | | |
| | | delete result.ErrCode |
| | | delete result.ErrMesg |
| | | delete result.message |
| | | delete result.status |
| | | |
| | | this.resetFormList(result) |
| | | }) |
| | | } |
| | | |
| | | resetFormList = (result) => { |
| | | const { columns } = this.props |
| | | const { edColumns } = this.state |
| | | |
| | | let _edColumns = [] |
| | | |
| | | let reCols = {} |
| | | columns.forEach(item => { |
| | | if (item.resourceType === '1' && result[item.uuid] && result[item.uuid].length > 0) { |
| | | let options = [] |
| | | let _map = new Map() |
| | | result[item.uuid].forEach(cell => { |
| | | let _cell = {key: Utils.getuuid()} |
| | | |
| | | _cell.value = cell[item.valueField] |
| | | _cell.label = cell[item.valueText] |
| | | |
| | | if (!_cell.label && _cell.label !== 0) return |
| | | |
| | | if (_map.has(_cell.value)) return |
| | | _map.set(_cell.value, true) |
| | | |
| | | if (item.linkSubField) { |
| | | item.linkSubField.forEach(m => { |
| | | _cell[m] = cell[m] === undefined ? '' : cell[m] |
| | | }) |
| | | } |
| | | |
| | | if (item.disableField && cell[item.disableField] && /^true$/ig.test(cell[item.disableField])) { |
| | | _cell.$disabled = true |
| | | } |
| | | |
| | | options.push(_cell) |
| | | }) |
| | | |
| | | item.options = options |
| | | |
| | | reCols[item.uuid] = item |
| | | } |
| | | }) |
| | | |
| | | _edColumns = edColumns.map(item => { |
| | | if (reCols[item.dataIndex]) { |
| | | item.onCell = record => ({ |
| | | record, |
| | | col: reCols[item.dataIndex] |
| | | }) |
| | | } |
| | | |
| | | return item |
| | | }) |
| | | |
| | | this.setState({edColumns: []}, () => { |
| | | this.setState({edColumns: _edColumns}) |
| | | }) |
| | | } |
| | | |
| | | nextLine = (col, index) => { |
| | | const { setting } = this.props |
| | |
| | | } |
| | | } |
| | | } |
| | | .fix-header { |
| | | .ant-table-body { |
| | | min-height: unset |
| | | } |
| | | .ant-table-placeholder { |
| | | display: none; |
| | | } |
| | | .ant-table-wrapper { |
| | | display: none; |
| | | } |
| | | .ant-affix .ant-table-wrapper { |
| | | display: block; |
| | | } |
| | | } |
| | | .ant-input { |
| | | border: none; |
| | | box-shadow: none!important; |
| | |
| | | bottom: 0px; |
| | | border: 1px solid #1890ff; |
| | | } |
| | | .ant-select { |
| | | padding: 0px; |
| | | position: absolute; |
| | | top: 0px; |
| | | left: 0px; |
| | | right: 0px; |
| | | bottom: 0px; |
| | | .ant-select-selection { |
| | | height: 100%; |
| | | border-radius: 0; |
| | | |
| | | .ant-select-arrow { |
| | | display: none; |
| | | } |
| | | } |
| | | } |
| | | .ant-input-number-input { |
| | | position: absolute; |
| | | top: 0px; |
| | |
| | | right: 0; |
| | | } |
| | | } |
| | | .mk-editable { |
| | | display: inline-block; |
| | | } |
| | | .mk-plus { |
| | | position: absolute; |
| | | top: 45%; |
| | | left: -20px; |
| | | color: #1890ff; |
| | | } |
| | | } |
| | | .edit-custom-table.editable { |
| | | td { |
| | |
| | | this.state.formlist.forEach((item, index) => { |
| | | if (item.hidden) return |
| | | |
| | | if (item.type === 'text') { // 文本搜索 |
| | | if (item.type === 'text') { |
| | | let _rules = [] |
| | | if (item.key === 'innerFunc') { |
| | | let str = '^(' + item.fields.join('|') + ')' |
| | |
| | | </Form.Item> |
| | | </Col> |
| | | ) |
| | | } else if (item.type === 'number') { // 文本搜索 |
| | | } else if (item.type === 'number') { |
| | | fields.push( |
| | | <Col span={12} key={index}> |
| | | <Form.Item label={item.tooltip ? |
| | |
| | | const { getFieldDecorator } = this.props.form |
| | | const fields = [] |
| | | this.props.formlist.forEach((item, index) => { |
| | | if (item.type === 'text') { // 文本搜索 |
| | | if (item.type === 'text') { |
| | | fields.push( |
| | | <Col span={24} key={index}> |
| | | <Form.Item label={item.label}> |
| | |
| | | this.state.formlist.forEach((item, index) => { |
| | | if (item.hidden) return |
| | | |
| | | if (item.type === 'text') { // 文本搜索 |
| | | if (item.type === 'text') { |
| | | fields.push( |
| | | <Col span={12} key={index}> |
| | | <Form.Item label={item.tooltip ? |
| | |
| | | this.state.formlist.forEach((item, index) => { |
| | | if (item.hidden) return |
| | | |
| | | if (item.type === 'text') { // 文本搜索 |
| | | if (item.type === 'text') { |
| | | let rules = [] |
| | | if (item.key === 'field' || item.key === 'nameField') { |
| | | rules = [{ |
| | |
| | | </Form.Item> |
| | | </Col> |
| | | ) |
| | | } else if (item.type === 'textarea') { // 文本搜索 |
| | | } else if (item.type === 'textarea') { |
| | | fields.push( |
| | | <Col span={24} key={index} className="textarea"> |
| | | <Form.Item label={item.tooltip ? |
| | |
| | | const { getFieldDecorator } = this.props.form |
| | | const fields = [] |
| | | this.state.formlist.forEach((item, index) => { |
| | | if (item.type === 'text') { // 文本搜索 |
| | | if (item.type === 'text') { |
| | | fields.push( |
| | | <Col span={12} key={index}> |
| | | <Form.Item label={item.label}> |
| | |
| | | </Form.Item> |
| | | </Col> |
| | | ) |
| | | } else if (item.type === 'number') { // 文本搜索 |
| | | } else if (item.type === 'number') { |
| | | fields.push( |
| | | <Col span={12} key={index}> |
| | | <Form.Item label={item.label}> |
| | |
| | | let extra = null |
| | | let initVal = item.initVal || '' |
| | | |
| | | if (item.type === 'text') { // 文本搜索 |
| | | if (item.type === 'text') { |
| | | let type = this.record.type |
| | | rules = [ |
| | | { required: item.required, message: dict['form.required.input'] + item.label + '!' } |
| | |
| | | className = 'text-area' |
| | | |
| | | if (this.record.type === 'select' || this.record.type === 'link') { |
| | | extra = <span className="add-row-empty" onClick={this.handleEmpty}>全部</span> |
| | | extra = <span className="add-resource-empty" onClick={this.handleEmpty}>全部</span> |
| | | } |
| | | |
| | | content = <CodeMirror /> |
| | |
| | | padding-top: 0px; |
| | | min-height: 0px; |
| | | } |
| | | .add-row-empty { |
| | | .add-resource-empty { |
| | | position: absolute; |
| | | right: 10px; |
| | | top: -25px; |
| | |
| | | const { getFieldDecorator } = this.props.form |
| | | const fields = [] |
| | | this.state.formlist.forEach((item, index) => { |
| | | if (item.type === 'text') { // 文本搜索 |
| | | if (item.type === 'text') { |
| | | fields.push( |
| | | <Col span={24} key={index}> |
| | | <Form.Item label={item.label}> |
| | |
| | | className = 'text-area' |
| | | |
| | | if (this.record.type === 'select' || this.record.type === 'link') { |
| | | extra = <span className="add-row-empty" onClick={this.handleEmpty}>空</span> |
| | | extra = <span className="add-resource-empty" onClick={this.handleEmpty}>空</span> |
| | | } |
| | | |
| | | content = <CodeMirror /> |
| | |
| | | padding-top: 0px; |
| | | min-height: 0px; |
| | | } |
| | | .add-row-empty { |
| | | .add-resource-empty { |
| | | position: absolute; |
| | | right: 10px; |
| | | top: -25px; |
| | |
| | | let icon = null |
| | | let color = null |
| | | let position = null |
| | | style = JSON.parse(JSON.stringify(style)) |
| | | |
| | | marks.some(mark => { |
| | | let originVal = record[mark.field[0]] + '' |
| | |
| | | // if (!res || !res.ip) return |
| | | // sessionStorage.setItem('ipAddress', res.ip) |
| | | // }) |
| | | if (sessionStorage.getItem('loginError')) { |
| | | try { |
| | | let res = JSON.parse(sessionStorage.getItem('loginError')) |
| | | console.info(res.url) |
| | | console.info(res.request) |
| | | console.info(res.response) |
| | | |
| | | let result = JSON.parse(res.response) |
| | | |
| | | notification.warning({ |
| | | top: 92, |
| | | message: result.message, |
| | | duration: 5 |
| | | }) |
| | | } catch (e) {} |
| | | |
| | | setTimeout(() => { |
| | | sessionStorage.removeItem('loginError') |
| | | }, 1500) |
| | | } |
| | | |
| | | const _addressUrl = window.location.href.split('#')[0] + 'queryAddress' |
| | | |
| | | if (localStorage.getItem(_addressUrl) !== 'true') { |