| | |
| | | values.password = oripassword |
| | | } |
| | | |
| | | values.username = values.username.replace(/\t*|\v*|\s*/g, '') |
| | | values.password = values.password.replace(/\t*|\v*|\s*/g, '') |
| | | values.username = values.username.replace(/\t+|\v+|\s+/g, '') |
| | | values.password = values.password.replace(/\t+|\v+|\s+/g, '') |
| | | |
| | | resolve(values) |
| | | } else { |
| | |
| | | import React, {Component} from 'react' |
| | | import PropTypes from 'prop-types' |
| | | import { fromJS } from 'immutable' |
| | | import { Modal, Col } from 'antd' |
| | | import { Modal, Col, notification } from 'antd' |
| | | import { AntDesignOutlined } from '@ant-design/icons' |
| | | |
| | | import Utils from '@/utils/utils.js' |
| | |
| | | dataIndex: 'field', |
| | | width: '16%', |
| | | editable: true, |
| | | unique: true, |
| | | uniqueFunc: (data, item) => { |
| | | let index = data.findIndex(mark => mark.uuid !== item.uuid && mark.contrastValue === item.contrastValue && mark.match === item.match && mark.field.join('') === item.field.join('')) |
| | | |
| | | if (index > -1) { |
| | | notification.warning({ |
| | | top: 92, |
| | | message: '此标记已存在!', |
| | | duration: 5 |
| | | }) |
| | | return false |
| | | } |
| | | return true |
| | | }, |
| | | inputType: 'cascader', |
| | | options: [], |
| | | rules: [{ |
| | |
| | | markChange = (values) => { |
| | | let _marks = fromJS(this.state.marks).toJS() |
| | | |
| | | if (values.uuid) { |
| | | _marks = _marks.map(item => { |
| | | if (item.uuid === values.uuid) { |
| | | return values |
| | | } else { |
| | | return item |
| | | } |
| | | let has = false |
| | | _marks.forEach(mark => { |
| | | if (mark.contrastValue === values.contrastValue && mark.match === values.match && mark.field.join('') === values.field.join('')) { |
| | | has = true |
| | | } |
| | | }) |
| | | |
| | | if (has) { |
| | | notification.warning({ |
| | | top: 92, |
| | | message: '此标记已存在!', |
| | | duration: 5 |
| | | }) |
| | | } else { |
| | | values.uuid = Utils.getuuid() |
| | | _marks.push(values) |
| | | return |
| | | } |
| | | |
| | | values.uuid = Utils.getuuid() |
| | | _marks.push(values) |
| | | |
| | | this.setState({ |
| | | marks: _marks |
| | |
| | | item.fontColor = '' |
| | | } |
| | | } |
| | | |
| | | if (item.contrastValue) { |
| | | item.contrastValue = item.contrastValue.replace(/\t+|\v+|\s+/g, '') |
| | | } |
| | | |
| | | if (val && item.contrastValue === val) { |
| | | save = true |
| | | } |
| | |
| | | // 表单提交时检查输入值是否正确 |
| | | this.props.form.validateFieldsAndScroll((err, values) => { |
| | | if (!err) { |
| | | if (values.contrastValue) { |
| | | values.contrastValue = values.contrastValue.replace(/\t+|\v+|\s+/g, '') |
| | | } |
| | | this.props.markChange(values) |
| | | } |
| | | }) |
| | |
| | | |
| | | let xc = {label: { |
| | | formatter: (val) => { |
| | | if (!val || /^\s*$/.test(val)) return val |
| | | if (!val || /^\s+$/.test(val)) return val |
| | | let _val = `${val}` |
| | | if (_val.length <= limit) return val |
| | | return _val.substring(0, limit) + '...' |
| | |
| | | _item.fieldlen = item.decimal || 0 |
| | | } else if (['text', 'textarea', 'linkMain'].includes(_item.type)) { |
| | | _item.value = _item.value + '' |
| | | _item.value = _item.value.replace(/\t*|\v*/g, '') // 去除制表符 |
| | | _item.value = _item.value.replace(/\t+|\v+/g, '') // 去除制表符 |
| | | |
| | | if (item.interception !== 'false') { // 去除首尾空格 |
| | | _item.value = _item.value.replace(/(^\s*|\s*$)/g, '') |
| | |
| | | _item.fieldlen = item.decimal || 0 |
| | | } else if (['text', 'textarea', 'linkMain'].includes(_item.type)) { |
| | | _item.value = _item.value + '' |
| | | _item.value = _item.value.replace(/\t*|\v*/g, '') // 去除制表符 |
| | | _item.value = _item.value.replace(/\t+|\v+/g, '') // 去除制表符 |
| | | |
| | | if (item.interception !== 'false') { // 去除首尾空格 |
| | | _item.value = _item.value.replace(/(^\s*|\s*$)/g, '') |
| | |
| | | _item.fieldlen = item.decimal || 0 |
| | | } else if (['text', 'textarea', 'linkMain'].includes(item.type)) { |
| | | _item.value = _item.value + '' |
| | | _item.value = _item.value.replace(/\t*|\v*/g, '') // 去除制表符 |
| | | _item.value = _item.value.replace(/\t+|\v+/g, '') // 去除制表符 |
| | | |
| | | if (item.interception !== 'false') { // 去除首尾空格 |
| | | _item.value = _item.value.replace(/(^\s*|\s*$)/g, '') |
| | |
| | | |
| | | ['linkField', 'valueField', 'valueText', 'orderBy'].forEach(item => { |
| | | if (values[item]) { |
| | | values[item] = values[item].replace(/\s* | \t* | \v* | \r*/ig, '') |
| | | values[item] = values[item].replace(/\s+|\t+|\v+|\r+/ig, '') |
| | | } |
| | | }) |
| | | |
| | |
| | | columns.forEach(col => { |
| | | if (col.unique !== true || !unique) return |
| | | |
| | | if (col.strict) { |
| | | if (col.uniqueFunc) { |
| | | unique = col.uniqueFunc(data, res.data) |
| | | } else if (col.strict) { |
| | | let key = res.data[col.dataIndex].toLowerCase() |
| | | let _index = data.findIndex(item => key === item[col.dataIndex].toLowerCase()) |
| | | |
| | |
| | | columns.forEach(col => { |
| | | if (col.unique !== true || !unique) return |
| | | |
| | | if (col.strict) { |
| | | if (col.uniqueFunc) { |
| | | unique = col.uniqueFunc(data, cell) |
| | | } else if (col.strict) { |
| | | let _index = data.findIndex(item => cell[col.dataIndex].toLowerCase() === item[col.dataIndex].toLowerCase()) |
| | | |
| | | if (_index > -1) { |
| | |
| | | columns.forEach(col => { |
| | | if (col.unique !== true || !unique) return |
| | | |
| | | let _index = newData.findIndex(item => record.uuid !== item.uuid && record[col.dataIndex] === item[col.dataIndex]) |
| | | if (col.uniqueFunc) { |
| | | unique = col.uniqueFunc(newData, record) |
| | | return |
| | | } else if (col.strict) { |
| | | let key = record[col.dataIndex].toLowerCase() |
| | | let _index = newData.findIndex(item => key === item[col.dataIndex].toLowerCase()) |
| | | |
| | | if (_index > -1) { |
| | | notification.warning({ |
| | | top: 92, |
| | | message: col.title + '不可重复!', |
| | | duration: 5 |
| | | }) |
| | | unique = false |
| | | if (_index > -1) { |
| | | notification.warning({ |
| | | top: 92, |
| | | message: col.title + '不可重复!', |
| | | duration: 5 |
| | | }) |
| | | unique = false |
| | | } |
| | | } else { |
| | | let _index = newData.findIndex(item => record.uuid !== item.uuid && record[col.dataIndex] === item[col.dataIndex]) |
| | | |
| | | if (_index > -1) { |
| | | notification.warning({ |
| | | top: 92, |
| | | message: col.title + '不可重复!', |
| | | duration: 5 |
| | | }) |
| | | unique = false |
| | | } |
| | | } |
| | | }) |
| | | |
| | |
| | | } |
| | | const newData = [...this.state.data] |
| | | const index = newData.findIndex(item => uuid === item.uuid) |
| | | if (index > -1) { |
| | | row = {...newData[index], ...row} |
| | | } else { |
| | | row.uuid = uuid |
| | | } |
| | | |
| | | let unique = true |
| | | columns.forEach(col => { |
| | | if (col.unique !== true || !unique) return |
| | | |
| | | let _index = newData.findIndex(item => uuid !== item.uuid && row[col.dataIndex] === item[col.dataIndex]) |
| | | |
| | | if (_index > -1) { |
| | | notification.warning({ |
| | | top: 92, |
| | | message: col.title + '不可重复!', |
| | | duration: 5 |
| | | }) |
| | | unique = false |
| | | if (col.uniqueFunc) { |
| | | unique = col.uniqueFunc(newData, row) |
| | | return |
| | | } else if (col.strict) { |
| | | let key = row[col.dataIndex].toLowerCase() |
| | | let _index = newData.findIndex(item => key === item[col.dataIndex].toLowerCase()) |
| | | |
| | | if (_index > -1) { |
| | | notification.warning({ |
| | | top: 92, |
| | | message: col.title + '不可重复!', |
| | | duration: 5 |
| | | }) |
| | | unique = false |
| | | } |
| | | } else { |
| | | let _index = newData.findIndex(item => row.uuid !== item.uuid && row[col.dataIndex] === item[col.dataIndex]) |
| | | |
| | | if (_index > -1) { |
| | | notification.warning({ |
| | | top: 92, |
| | | message: col.title + '不可重复!', |
| | | duration: 5 |
| | | }) |
| | | unique = false |
| | | } |
| | | } |
| | | }) |
| | | |
| | | if (!unique) return |
| | | |
| | | if (index > -1) { |
| | | const item = newData[index] |
| | | newData.splice(index, 1, { |
| | | ...item, |
| | | ...row, |
| | | }) |
| | | newData.splice(index, 1, row) |
| | | this.setState({ data: newData, editingKey: '' }, () => { |
| | | this.props.onChange(newData) |
| | | }) |
| | |
| | | |
| | | ['linkField', 'valueField', 'valueText', 'orderBy'].forEach(item => { |
| | | if (values[item]) { |
| | | values[item] = values[item].replace(/\s*|\t*|\v*|\r*/ig, '') |
| | | values[item] = values[item].replace(/\s+|\t+|\v+|\r+/ig, '') |
| | | } |
| | | }) |
| | | |
| | |
| | | val = val.replace(/'/ig, '"') |
| | | } |
| | | |
| | | val = val.replace(/(^\s*$)|\t*|\v*/ig, '') |
| | | val = val.replace(/(^\s+$)|\t+|\v+/ig, '') |
| | | |
| | | if (!val && col.required === 'true') { // 必填校验 |
| | | errors.push(_position + '内容不可为空') |
| | |
| | | val = moment('19000101', 'YYYYMMDD').add(Math.floor(val - 2), 'days').format('YYYY-MM-DD') |
| | | } |
| | | } else if (typeof(val) === 'string') { |
| | | val = val.replace(/(^\s*$)|\t*|\v*/ig, '') |
| | | val = val.replace(/(^\s+$)|\t+|\v+/ig, '') |
| | | if (!val && col.required === 'true') { // 时间必填校验 |
| | | errors.push(_position + '内容不可为空') |
| | | } else if (val && !/^[1-9][0-9]{3}/.test(val)) { // 时间正则校验 |
| | |
| | | return new Promise((resolve, reject) => { |
| | | this.props.form.validateFieldsAndScroll((err, values) => { |
| | | if (!err) { |
| | | values.cloudusername = values.cloudusername.replace(/\t*|\v*|\s*/g, '') |
| | | values.cloudpassword = values.cloudpassword.replace(/\t*|\v*|\s*/g, '') |
| | | values.cloudusername = values.cloudusername.replace(/\t+|\v+|\s+/g, '') |
| | | values.cloudpassword = values.cloudpassword.replace(/\t+|\v+|\s+/g, '') |
| | | resolve(values) |
| | | } else { |
| | | reject(err) |
| | |
| | | this.props.form.validateFieldsAndScroll((err, values) => { |
| | | if (!err) { |
| | | if (activeKey === 'uname_pwd') { |
| | | values.username = values.username.replace(/\t*|\v*|\s*/g, '') |
| | | values.password = values.password.replace(/\t*|\v*|\s*/g, '') |
| | | values.username = values.username.replace(/\t+|\v+|\s+/g, '') |
| | | values.password = values.password.replace(/\t+|\v+|\s+/g, '') |
| | | } else if (activeKey === 'sms_vcode') { |
| | | values.phone = values.phone.replace(/\t*|\v*|\s*/g, '') |
| | | values.vercode = values.vercode.replace(/\t*|\v*|\s*/g, '') |
| | | values.phone = values.phone.replace(/\t+|\v+|\s+/g, '') |
| | | values.vercode = values.vercode.replace(/\t+|\v+|\s+/g, '') |
| | | } |
| | | resolve({type: activeKey, ...values}) |
| | | } else { |