| | |
| | | text: '数据源' |
| | | }] |
| | | }, |
| | | { |
| | | type: 'select', |
| | | key: 'editField', |
| | | label: '编辑字段', |
| | | initVal: card.editField || '', |
| | | tooltip: '当值与提示文字不同时,可额外添加编辑字段,作为实际值的录入字段。', |
| | | allowClear: true, |
| | | required: false, |
| | | options: fields |
| | | }, |
| | | // { |
| | | // type: 'select', |
| | | // key: 'editField', |
| | | // label: '编辑字段', |
| | | // initVal: card.editField || '', |
| | | // tooltip: '当值与提示文字不同时,可额外添加编辑字段,作为实际值的录入字段。', |
| | | // allowClear: true, |
| | | // required: false, |
| | | // options: fields |
| | | // }, |
| | | { |
| | | type: 'options', |
| | | key: 'options', |
| | |
| | | import React, {Component} from 'react' |
| | | import PropTypes from 'prop-types' |
| | | import { fromJS } from 'immutable' |
| | | import { Form, Tabs, Row, Col, Input, Button, Table, Popconfirm, notification, Modal, message, InputNumber, Radio, Typography } from 'antd' |
| | | import { StopTwoTone, CheckCircleTwoTone, EditOutlined, ArrowUpOutlined, ArrowDownOutlined, SwapOutlined, DeleteOutlined } from '@ant-design/icons' |
| | | 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 moment from 'moment' |
| | | |
| | | import Api from '@/api' |
| | |
| | | width: '20%', |
| | | dataIndex: 'operation', |
| | | render: (text, record) => |
| | | (<div> |
| | | (<div style={{textAlign: 'center'}}> |
| | | <span className="operation-btn" onClick={() => this.handleEdit(record, 'scripts')} style={{color: '#1890ff'}}><EditOutlined /></span> |
| | | <span className="operation-btn" onClick={() => this.handleUpDown(record, 'scripts', 'up')} style={{color: '#1890ff'}}><ArrowUpOutlined /></span> |
| | | <span className="operation-btn" onClick={() => this.handleUpDown(record, 'scripts', 'down')} style={{color: '#ff4d4f'}}><ArrowDownOutlined /></span> |
| | | <span className="operation-btn" title="状态切换" onClick={() => this.handleStatus(record, 'scripts')} style={{color: '#8E44AD'}}><SwapOutlined /></span> |
| | | <Popconfirm |
| | | overlayClassName="popover-confirm" |
| | |
| | | }) |
| | | } |
| | | |
| | | handleUpDown = (record, type, direction) => { |
| | | let verify = JSON.parse(JSON.stringify(this.state.verify)) |
| | | let index = 0 |
| | | |
| | | if (type === 'unique') { |
| | | verify.uniques = verify.uniques.filter((item, i) => { |
| | | if (item.uuid === record.uuid) { |
| | | index = i |
| | | } |
| | | |
| | | return item.uuid !== record.uuid |
| | | }) |
| | | if ((index === 0 && direction === 'up') || (index === verify.uniques.length && direction === 'down')) { |
| | | return |
| | | } |
| | | |
| | | if (direction === 'up') { |
| | | verify.uniques.splice(index - 1, 0, record) |
| | | } else { |
| | | verify.uniques.splice(index + 1, 0, record) |
| | | } |
| | | } else if (type === 'scripts') { |
| | | verify.scripts = verify.scripts.filter((item, i) => { |
| | | if (item.uuid === record.uuid) { |
| | | index = i |
| | | } |
| | | |
| | | return item.uuid !== record.uuid |
| | | }) |
| | | if ((index === 0 && direction === 'up') || (index === verify.scripts.length && direction === 'down')) { |
| | | return |
| | | } |
| | | |
| | | if (direction === 'up') { |
| | | verify.scripts.splice(index - 1, 0, record) |
| | | } else { |
| | | verify.scripts.splice(index + 1, 0, record) |
| | | } |
| | | } |
| | | |
| | | this.setState({ |
| | | verify: verify |
| | | }) |
| | | } |
| | | |
| | | handleConfirm = () => { |
| | | const { verify } = this.state |
| | | |
| | |
| | | scriptsChange={this.scriptsChange} |
| | | wrappedComponentRef={(inst) => this.scriptsForm = inst} |
| | | /> |
| | | <Table |
| | | bordered |
| | | rowKey="uuid" |
| | | className="custom-table" |
| | | dataSource={verify.scripts} |
| | | columns={scriptsColumns} |
| | | pagination={false} |
| | | /> |
| | | <EditTable actions={['move']} data={verify.scripts} columns={scriptsColumns} onChange={(scripts) => {this.setState({verify: {...verify, scripts}})}}/> |
| | | </TabPane> |
| | | <TabPane tab="信息提示" key="tip"> |
| | | <Form {...formItemLayout}> |
| | |
| | | }, 50) |
| | | |
| | | let values = {} |
| | | if (col.editField) { |
| | | values[col.field] = label |
| | | values[col.editField] = val |
| | | } else { |
| | | // if (col.editField) { |
| | | // values[col.field] = label |
| | | // values[col.editField] = val |
| | | // } else { |
| | | values[col.field] = val |
| | | } |
| | | // } |
| | | |
| | | MKEmitter.emit('changeRecord', col.tableId, {...record, ...values}) |
| | | } |
| | |
| | | }) |
| | | } |
| | | |
| | | if (col.editField) { |
| | | values[col.field] = _option.label |
| | | values[col.editField] = val |
| | | } else { |
| | | // if (col.editField) { |
| | | // values[col.field] = _option.label |
| | | // values[col.editField] = val |
| | | // } else { |
| | | values[col.field] = val |
| | | } |
| | | // } |
| | | } |
| | | |
| | | this.setState({editing: false}) |
| | |
| | | content = `${record[col.field]}` |
| | | } |
| | | |
| | | if (col.editType === 'select' && col.options.length > 0) { |
| | | content = col.map.get(content) || content |
| | | } |
| | | |
| | | if (content !== '') { |
| | | if (col.textFormat === 'YYYY-MM-DD' && /^[1-9]\d{3}(-|\/)(0[1-9]|1[0-2])(-|\/)(0[1-9]|[1-2][0-9]|3[0-1])/.test(content)) { |
| | | content = `${content.substr(0, 4)}-${content.substr(5, 2)}-${content.substr(8, 2)}` |
| | |
| | | </td>) |
| | | } else if (col.editType === 'switch') { |
| | | let _value = '' |
| | | if (col.editField) { |
| | | _value = record[col.editField] !== undefined ? record[col.editField] : '' |
| | | } else { |
| | | // if (col.editField) { |
| | | // _value = record[col.editField] !== undefined ? record[col.editField] : '' |
| | | // } else { |
| | | _value = record[col.field] !== undefined ? record[col.field] : '' |
| | | } |
| | | // } |
| | | return (<td className="editing_table_cell"> |
| | | <CusSwitch config={col} defaultValue={_value} autoFocus={true} onChange={this.onSwitchChange} onBlur={this.switchBlur}/> |
| | | </td>) |
| | | } else { |
| | | let _value = '' |
| | | if (col.editField) { |
| | | _value = record[col.editField] !== undefined ? record[col.editField] : '' |
| | | } else { |
| | | // if (col.editField) { |
| | | // _value = record[col.editField] !== undefined ? record[col.editField] : '' |
| | | // } else { |
| | | _value = record[col.field] !== undefined ? record[col.field] : '' |
| | | } |
| | | // } |
| | | return (<td className="editing_table_cell"> |
| | | <Select |
| | | showSearch |
| | |
| | | }, 50) |
| | | |
| | | let values = {} |
| | | if (col.editField) { |
| | | values[col.field] = label |
| | | values[col.editField] = val |
| | | } else { |
| | | // if (col.editField) { |
| | | // values[col.field] = label |
| | | // values[col.editField] = val |
| | | // } else { |
| | | values[col.field] = val |
| | | } |
| | | // } |
| | | |
| | | MKEmitter.emit('changeRecord', col.tableId, {...record, ...values}) |
| | | } |
| | |
| | | }) |
| | | } |
| | | |
| | | if (col.editField) { |
| | | values[col.field] = _option.label |
| | | values[col.editField] = val |
| | | } else { |
| | | // if (col.editField) { |
| | | // values[col.field] = _option.label |
| | | // values[col.editField] = val |
| | | // } else { |
| | | values[col.field] = val |
| | | } |
| | | // } |
| | | } |
| | | |
| | | setTimeout(() => { |
| | |
| | | if (col.type === 'text') { |
| | | if (col.editable === 'true' && !disabled) { |
| | | let _value = '' |
| | | if (col.editField) { |
| | | _value = record[col.editField] !== undefined ? record[col.editField] : '' |
| | | } else { |
| | | // if (col.editField) { |
| | | // _value = record[col.editField] !== undefined ? record[col.editField] : '' |
| | | // } else { |
| | | _value = record[col.field] !== undefined ? record[col.field] : '' |
| | | } |
| | | // } |
| | | |
| | | if (!col.editType || col.editType === 'text') { |
| | | children = (<> |
| | |
| | | let content = '' |
| | | if (record[col.field] !== undefined) { |
| | | content = `${record[col.field]}` |
| | | } |
| | | |
| | | if (col.editType === 'select' && col.options.length > 0) { |
| | | content = col.map.get(content) || content |
| | | } |
| | | |
| | | if (content !== '') { |
| | |
| | | item.ctrlValue = item.ctrlValue.split(',') |
| | | } |
| | | |
| | | if (item.type === 'text' && item.editType === 'select' && item.resourceType === '1') { |
| | | let _option = Utils.getSelectQueryOptions(item) |
| | | |
| | | if (/@BID@/ig.test(_option.sql)) { |
| | | hasBid = true |
| | | if (item.type === 'text' && item.editType === 'select') { |
| | | item.map = new Map() |
| | | if (item.resourceType === '1') { |
| | | let _option = Utils.getSelectQueryOptions(item) |
| | | |
| | | if (/@BID@/ig.test(_option.sql)) { |
| | | hasBid = true |
| | | } |
| | | |
| | | item.base_sql = _option.sql |
| | | item.arr_field = _option.field |
| | | |
| | | deForms.push(item) |
| | | } else { |
| | | item.options.forEach(cell => { |
| | | item.map.set(cell.value, cell.label) |
| | | }) |
| | | } |
| | | |
| | | item.base_sql = _option.sql |
| | | item.arr_field = _option.field |
| | | |
| | | deForms.push(item) |
| | | } |
| | | } |
| | | |
| | |
| | | } |
| | | |
| | | resetFormList = (result) => { |
| | | const { columns } = this.state |
| | | const { columns, edData } = this.state |
| | | |
| | | let _edColumns = [] |
| | | |
| | |
| | | this.props.columns.forEach(item => { |
| | | if (item.resourceType === '1' && result[item.uuid] && result[item.uuid].length > 0) { |
| | | let options = [] |
| | | let _map = new Map() |
| | | let all = false |
| | | result[item.uuid].forEach(cell => { |
| | | let _cell = {key: Utils.getuuid()} |
| | |
| | | } |
| | | } |
| | | |
| | | if (_map.has(_cell.value)) return |
| | | _map.set(_cell.value, 0) |
| | | if (item.map.has(_cell.value)) return |
| | | item.map.set(_cell.value, _cell.label) |
| | | |
| | | if (item.linkSubField) { |
| | | item.linkSubField.forEach(m => { |
| | |
| | | |
| | | item.options = options |
| | | |
| | | reCols[item.uuid] = item |
| | | reCols[item.uuid] = fromJS(item).toJS() |
| | | } |
| | | }) |
| | | |
| | |
| | | return item |
| | | }) |
| | | |
| | | this.setState({columns: []}, () => { |
| | | this.setState({columns: _edColumns}) |
| | | this.setState({columns: [], edData: []}, () => { |
| | | this.setState({columns: _edColumns, edData: edData}) |
| | | }) |
| | | } |
| | | |
| | |
| | | } |
| | | if (['select', 'radio', 'link', 'checkcard'].includes(item.type) && item.linkSubField && item.linkSubField.length > 0) { |
| | | arrfield.push(...item.linkSubField) |
| | | } else if (item.type === 'text' && item.editType === 'select' && item.linkSubField && item.linkSubField.length > 0) { // 可编辑表 |
| | | arrfield.push(...item.linkSubField) |
| | | } |
| | | if (item.disableField) { |
| | | arrfield.push(item.disableField) |