From c00ddd2df26afcd10298003df21c481149eab445 Mon Sep 17 00:00:00 2001 From: king <18310653075@163.com> Date: 星期日, 27 六月 2021 21:31:21 +0800 Subject: [PATCH] 2021-06-27 --- /dev/null | 76 -------------------------------------- 1 files changed, 0 insertions(+), 76 deletions(-) diff --git a/src/tabviews/zshare/topSearch copy/advanceform/index.jsx b/src/tabviews/zshare/topSearch copy/advanceform/index.jsx deleted file mode 100644 index 8c47589..0000000 --- a/src/tabviews/zshare/topSearch copy/advanceform/index.jsx +++ /dev/null @@ -1,306 +0,0 @@ -import React, {Component} from 'react' -import PropTypes from 'prop-types' -import { fromJS } from 'immutable' -import { Form, Row, Col, Input, Select, DatePicker } from 'antd' - -import asyncComponent from '@/utils/asyncComponent' -import Utils from '@/utils/utils.js' -import './index.scss' - -const { MonthPicker, WeekPicker, RangePicker } = DatePicker -const CheckCard = asyncComponent(() => import('@/tabviews/zshare/mutilform/checkCard')) - -class AdvanceSearch extends Component { - static propTpyes = { - dict: PropTypes.object, // 瀛楀吀 - searchValues: PropTypes.object, // 鎼滅储鏉′欢鍊� - searchlist: PropTypes.array, // 鎼滅储鏉′欢鍒楄〃 - handleSearch: PropTypes.func // 鎼滅储鏉′欢鎻愪氦 - } - - state = { - dict: this.props.dict, - formId: Utils.getuuid(), // 鎼滅储琛ㄥ崟Id - searchlist: fromJS(this.props.searchlist).toJS() - } - - resetform = (formlist, supfields, index, fieldsvalue) => { - index++ - let subfields = [] - - supfields.forEach(supfield => { - formlist = formlist.map(item => { - if (item.type === 'link' && item.linkField === supfield.field) { - item.options = item.oriOptions.filter(option => option.ParentID === supfield.initval || option.Value === '') - item.initval = item.options[0] ? item.options[0].Value : '' - - if (this.props.form.getFieldValue(item.field) !== undefined) { - fieldsvalue[item.field] = item.initval - } - - subfields.push(item) - } - return item - }) - }) - - if (subfields.length === 0 || index > 6) { - return formlist - } else { - return this.resetform(formlist, subfields, index, fieldsvalue) - } - } - - selectChange = (_field, value) => { - let formlist = fromJS(this.state.searchlist).toJS() - - let subfields = [] - let fieldsvalue = {} - formlist = formlist.map(item => { - if (item.type === 'link' && item.linkField === _field.field) { - item.options = item.oriOptions.filter(option => option.ParentID === value || option.Value === '') - item.initval = item.options[0] ? item.options[0].Value : '' - - if (this.props.form.getFieldValue(item.field) !== undefined) { - fieldsvalue[item.field] = item.initval - } - - subfields.push(item) - } - return item - }) - - if (subfields.length === 0) { - return - } - - formlist = this.resetform(formlist, subfields, 0, fieldsvalue) - - if (Object.keys(fieldsvalue).length > 0) { - this.props.form.setFieldsValue(fieldsvalue) - } - - this.setState({ - searchlist: formlist - }) - } - - getFields() { - const { getFieldDecorator } = this.props.form - const { searchValues } = this.props - const { dict, formId } = this.state - const fields = [] - - this.state.searchlist.forEach((item, index) => { - if (item.advanced !== 'true' || item.Hide === 'true') return - - let initval = searchValues[item.field] || '' - if (item.type === 'text') { // 鏂囨湰鎼滅储 - fields.push( - <Col span={item.ratio || 6} key={index}> - <Form.Item label={item.labelShow !== 'false' ? item.label : ''}> - {getFieldDecorator(item.field, { - initialValue: initval, - rules: [ - { - required: item.required, - message: dict['form.required.input'] + item.label + '!' - } - ] - })(<Input placeholder={item.labelShow === 'false' ? item.label : ''} autoComplete="off" onPressEnter={this.props.handleSearch} />)} - </Form.Item> - </Col> - ) - } else if (item.type === 'select' || item.type === 'link') { // 涓嬫媺鎼滅储 - fields.push( - <Col span={item.ratio || 6} key={index}> - <Form.Item label={item.labelShow !== 'false' ? item.label : ''}> - {getFieldDecorator(item.field, { - initialValue: initval, - rules: [ - { - required: item.required, - message: dict['form.required.select'] + item.label + '!' - } - ] - })( - <Select - showSearch - onChange={(value) => {this.selectChange(item, value)}} - filterOption={(input, option) => option.props.children.toLowerCase().indexOf(input.toLowerCase()) >= 0 || option.props.value.toLowerCase().indexOf(input.toLowerCase()) >= 0} - getPopupContainer={() => formId ? document.getElementById(formId) : document.body} - > - {item.options.map((option, i) => - <Select.Option id={`${i}`} title={option.Text} key={`${i}`} value={option.Value}>{option.Text}</Select.Option> - )} - </Select> - )} - </Form.Item> - </Col> - ) - } else if (item.type === 'multiselect') { // 涓嬫媺澶氶�� - fields.push( - <Col span={item.ratio || 6} key={index}> - <Form.Item label={item.labelShow !== 'false' ? item.label : ''}> - {getFieldDecorator(item.field, { - initialValue: initval, - rules: [ - { - required: item.required, - message: dict['form.required.select'] + item.label + '!' - } - ] - })( - <Select - showSearch - mode="multiple" - filterOption={(input, option) => option.props.children.toLowerCase().indexOf(input.toLowerCase()) >= 0} - getPopupContainer={() => formId ? document.getElementById(formId) : document.body} - > - {item.options.map((option, i) => - <Select.Option id={`${i}`} title={option.Text} key={`${i}`} value={option.Value}>{option.Text}</Select.Option> - )} - </Select> - )} - </Form.Item> - </Col> - ) - } else if (item.type === 'date') { // 鏃堕棿鎼滅储 - fields.push( - <Col span={item.ratio || 6} key={index}> - <Form.Item label={item.labelShow !== 'false' ? item.label : ''}> - {getFieldDecorator(item.field, { - initialValue: initval || null, - rules: [ - { - required: item.required, - message: dict['form.required.select'] + item.label + '!' - } - ] - })( - <DatePicker getCalendarContainer={() => formId ? document.getElementById(formId) : document.body} /> - )} - </Form.Item> - </Col> - ) - } else if (item.type === 'datemonth') { - fields.push( - <Col span={item.ratio || 6} key={index}> - <Form.Item label={item.labelShow !== 'false' ? item.label : ''}> - {getFieldDecorator(item.field, { - initialValue: initval || null, - rules: [ - { - required: item.required, - message: dict['form.required.select'] + item.label + '!' - } - ] - })( - <MonthPicker getCalendarContainer={() => formId ? document.getElementById(formId) : document.body} /> - )} - </Form.Item> - </Col> - ) - } else if (item.type === 'dateweek') { - fields.push( - <Col span={item.ratio || 6} key={index}> - <Form.Item label={item.labelShow !== 'false' ? item.label : ''}> - {getFieldDecorator(item.field, { - initialValue: initval || null, - rules: [ - { - required: item.required, - message: dict['form.required.select'] + item.label + '!' - } - ] - })( - <WeekPicker getCalendarContainer={() => formId ? document.getElementById(formId) : document.body} /> - )} - </Form.Item> - </Col> - ) - } else if (item.type === 'daterange') { - let _defaultValue = initval - - if (!initval) { - _defaultValue = [null, null] - } - - fields.push( - <Col className="daterange" span={item.ratio || 6} key={index}> - <Form.Item label={item.labelShow !== 'false' ? item.label : ''}> - {getFieldDecorator(item.field, - { - initialValue: _defaultValue, - rules: [ - { - required: item.required, - message: dict['form.required.select'] + item.label + '!' - } - ] - })( - <RangePicker - placeholder={['寮�濮嬫棩鏈�', '缁撴潫鏃ユ湡']} - renderExtraFooter={() => 'extra footer'} - getCalendarContainer={() => formId ? document.getElementById(formId) : document.body} - /> - )} - </Form.Item> - </Col> - ) - } else if (item.type === 'checkcard') { // 澶氶�夋 - fields.push( - <Col span={item.ratio || 6} key={index}> - <Form.Item label={item.labelShow !== 'false' ? item.label : ''}> - {getFieldDecorator(item.field, { - initialValue: item.initval, - rules: [ - { - required: item.required, - message: dict['form.required.select'] + item.label + '!' - } - ] - })( - <CheckCard card={item} /> - )} - </Form.Item> - </Col> - ) - } - }) - - return fields - } - - handleConfirm = () => { - // 鍥炶溅鎴栫偣鍑绘悳绱� - return new Promise((resolve, reject) => { - this.props.form.validateFields((err, values) => { - if (!err) { - resolve(values) - } - }) - }) - } - - render() { - const formItemLayout = { - labelCol: { - xs: { span: 24 }, - sm: { span: 8 } - }, - wrapperCol: { - xs: { span: 24 }, - sm: { span: 16 } - } - } - - return ( - <Form {...formItemLayout} className="advance-search" id={this.state.formId}> - <Row gutter={24}>{this.getFields()}</Row> - </Form> - ) - } -} - -export default Form.create()(AdvanceSearch) \ No newline at end of file diff --git a/src/tabviews/zshare/topSearch copy/advanceform/index.scss b/src/tabviews/zshare/topSearch copy/advanceform/index.scss deleted file mode 100644 index 4cde22e..0000000 --- a/src/tabviews/zshare/topSearch copy/advanceform/index.scss +++ /dev/null @@ -1,31 +0,0 @@ -.advance-search { - background: #ffffff; - .ant-form-item { - display: flex; - margin-bottom: 0px; - min-height: 60px; - .ant-form-explain { - white-space: nowrap; - } - } - .ant-form-item-control-wrapper { - flex: 1; - width: calc(100% - 100px); - } - .ant-form-item-label { - text-overflow: ellipsis; - } - .daterange .ant-calendar-picker-input { - padding: 4px 20px 4px 5px; - font-size: 13px; - } - .ant-select-dropdown { - z-index: 10 !important; - } - .ant-calendar-picker-container { - z-index: 10 !important; - } - .check-card-form-box { - margin-top: 5px; - } -} \ No newline at end of file diff --git a/src/tabviews/zshare/topSearch copy/index.jsx b/src/tabviews/zshare/topSearch copy/index.jsx deleted file mode 100644 index 9acc92b..0000000 --- a/src/tabviews/zshare/topSearch copy/index.jsx +++ /dev/null @@ -1,1043 +0,0 @@ -import React, {Component} from 'react' -import PropTypes from 'prop-types' -import { fromJS } from 'immutable' -import { Form, Row, Col, Input, Button, Select, DatePicker, notification, Modal, Icon } from 'antd' -import moment from 'moment' - -import Api from '@/api' -import options from '@/store/options.js' -import DateGroup from '@/tabviews/zshare/dategroup' -import asyncComponent from '@/utils/asyncComponent' -import asyncSpinComponent from '@/utils/asyncSpinComponent' -import Utils from '@/utils/utils.js' -import zhCN from '@/locales/zh-CN/main.js' -import enUS from '@/locales/en-US/main.js' -import './index.scss' - -const { MonthPicker, WeekPicker, RangePicker } = DatePicker -const { Search } = Input - -const MutilForm = asyncSpinComponent(() => import('./advanceform')) -const CheckCard = asyncComponent(() => import('@/tabviews/zshare/mutilform/checkCard')) - -class MainSearch extends Component { - static propTpyes = { - BID: PropTypes.any, // 鐖剁骇Id锛岀敤浜庢煡璇笅鎷夐�夋嫨椤� - menuType: PropTypes.any, // 鑿滃崟鏉冮檺锛屾槸鍚︿负HS - searchlist: PropTypes.array, // 鎼滅储鏉′欢鍒楄〃 - config: PropTypes.object, // 缁勪欢閰嶇疆淇℃伅(鑷畾涔夐〉闈�) - setting: PropTypes.object, // 缁勪欢閰嶇疆淇℃伅(鑷畾涔夐〉闈�) - refreshdata: PropTypes.func // 鍒锋柊鏁版嵁 - } - - state = { - dict: sessionStorage.getItem('lang') !== 'en-US' ? zhCN : enUS, - oriId: Utils.getuuid(), // 鎼滅储琛ㄥ崟Id - formId: '', // 鎼滅储琛ㄥ崟Id - searchlist: null, // 鎼滅储椤� - reset: true, // 鎺у埗缁勫悎鎼滅储椤归噸缃� - float: '', // 娴姩 - showButton: true, // 鏄惁鏄剧ず鎼滅储鎸夐挳 - showAdvanced: false, // 鏄惁鏄剧ず楂樼骇鎼滅储 - searchStyle: null, // 鎼滅储鏉′欢鏍峰紡 - searchValues: {}, // 鎼滅储鏉′欢淇濆瓨鍊� - advanceValues: [], // 楂樼骇鎼滅储鏉′欢淇濆瓨鍊� - visible: false, - adModelWidth: '1000px', - } - - UNSAFE_componentWillMount () { - const { config, menuType, searchlist, setting } = this.props - - let _searchlist = [] - let _list = [] - let fieldMap = new Map() - let mainItems = [] // 浜戠鎴栧崟鐐规暟鎹� - let localItems = [] // 鏈湴鏁版嵁 - let deForms = [] // 娴嬭瘯绯荤粺锛屽崟涓姹� - let float = '' - let showButton = true - let searchStyle = null - let searchValues = {} - let advanceValues = [] - let showAdvanced = false - let adModelWidth = 1000 - let formId = Utils.getuuid() - - if (setting && setting.advanceWidth) { - adModelWidth = setting.advanceWidth - } else if (config && config.wrap && config.wrap.advanceWidth) { - adModelWidth = config.wrap.advanceWidth - } - - if (adModelWidth < 100) { - adModelWidth = adModelWidth + 'vw' - } else { - adModelWidth = adModelWidth + 'px' - } - - if (searchlist) { - _searchlist = fromJS(searchlist).toJS() - } else if (config) { - _searchlist = fromJS(config.search).toJS() - if (config.type === 'search' && config.subtype === 'mainsearch') { - float = config.wrap.float - showButton = config.wrap.show !== 'false' - searchStyle = config.style - } else { - formId = '' - showButton = false - float = 'right' - } - } - - _searchlist.forEach(item => { - if (fieldMap.has(item.field)) { - item.field = item.field + '@tail@' - } - fieldMap.set(item.field, item) - - item.required = item.required === 'true' - - if (['select', 'link', 'multiselect', 'checkcard'].includes(item.type)) { - if (item.setAll === 'true' && ['select', 'link'].includes(item.type)) { - item.options.unshift({ - key: Utils.getuuid(), - Value: '', - Text: this.state.dict['main.all'] - }) - } - - // 鏁版嵁婧愭煡璇㈣鍙� - if (item.resourceType === '1' && item.dataSource) { - let _option = Utils.getSelectQueryOptions(item) - - // 娴嬭瘯绯荤粺鍗曚釜璇锋眰 - if (menuType !== 'HS' && options.sysType === 'local' && !window.GLOB.systemType) { - deForms.push({ - ...item, - arr_field: _option.field, - data_sql: Utils.formatOptions(_option.sql) - }) - } else { // 鍚堝苟璇锋眰锛屽尯鍒嗘湰鍦板強绯荤粺 - // 澶栬仈鏁版嵁搴撴浛鎹� - if (window.GLOB.externalDatabase !== null) { - _option.sql = _option.sql.replace(/@db@/ig, window.GLOB.externalDatabase) - } - if (item.database === 'sso') { - mainItems.push(`select '${item.field}' as obj_name,'${_option.field}' as arr_field,'${window.btoa(window.encodeURIComponent(_option.sql))}' as LText`) - } else { - localItems.push(`select '${item.field}' as obj_name,'${_option.field}' as arr_field,'${window.btoa(window.encodeURIComponent(_option.sql))}' as LText`) - } - } - } - item.oriOptions = fromJS(item.options).toJS() - } - - _list.push(item) - }) - - _list = _list.map(item => { - if (item.Hide === 'true') { - searchValues[item.field] = this.getInitValue(item) - } else if (showButton && item.advanced === 'true') { - showAdvanced = true - let _value = this.getInitValue(item) - searchValues[item.field] = _value - - let _val = this.getAdvanceValue(item, _value) - if (_val) { - advanceValues.push({field: item.field, type: item.type, label: item.label, value: _val}) - } - } else if (item.type === 'group') { - searchValues[item.datefield] = this.getInitValue(item) - searchValues[item.field] = item.initval && item.initval[0] ? item.initval[0] : '' - } - - if (item.type === 'link') { - let supItem = fieldMap.get(item.linkField) - - if (!supItem) { - notification.warning({ - top: 92, - message: '鏈煡璇㈠埌鎼滅储鏉′欢銆�' + item.label + '銆嬪叧鑱斿瓧娈碉紒', - duration: 5 - }) - item.supInitVal = '' - } else { - item.supInitVal = supItem.initval - item.options = item.oriOptions.filter(option => option.ParentID === supItem.initval || option.Value === '') - } - } - - return item - }) - - this.setState({ - float, - formId, - showButton, - searchStyle, - searchValues, - showAdvanced, - adModelWidth, - advanceValues, - searchlist: _list - }, () => { - if (menuType !== 'HS' && options.sysType === 'local' && !window.GLOB.systemType) { - this.improveSimpleSearch(deForms) - } else { - this.improveSearch(mainItems, localItems) - } - }) - } - - getInitValue = (item) => { - let value = item.initval || '' - - if (item.type === 'multiselect') { // 涓嬫媺澶氶�� - value = item.initval ? item.initval.split(',').filter(Boolean) : [] - } else if (item.type === 'date') { // 鏃堕棿鎼滅储 - value = item.initval ? moment().subtract(item.initval, 'days') : '' - } else if (item.type === 'datemonth') { - value = item.initval ? moment().subtract(item.initval, 'month') : '' - } else if (item.type === 'dateweek') { - value = item.initval ? moment().subtract(item.initval * 7, 'days') : '' - } else if (item.type === 'daterange') { - if (item.initval) { - try { - let _initval = JSON.parse(item.initval) - value = [moment().subtract(_initval[0], 'days'), moment().subtract(_initval[1], 'days')] - } catch { - value = '' - } - } - } else if (item.type === 'group' && item.initval && item.initval.length > 0) { - let _type = item.initval[0] - let _val = item.initval[1] - - if (_type === 'day') { - value = [moment().subtract(_val, 'days').format('YYYY-MM-DD'), moment().subtract(_val, 'days').format('YYYY-MM-DD')] - } else if (_type === 'week') { - value = [moment().subtract(_val * 7, 'days').startOf('week').format('YYYY-MM-DD'), moment().subtract(_val * 7, 'days').endOf('week').format('YYYY-MM-DD')] - } else if (_type === 'month') { - value = [moment().subtract(_val, 'month').startOf('month').format('YYYY-MM-DD'), moment().subtract(_val, 'month').endOf('month').format('YYYY-MM-DD')] - } else if (_type === 'quarter') { - let _differ = parseInt(moment().format('MM')) % 3 - let _pdiffer = 0 - let _ndiffer = 0 - - // 宸�艰绠� - switch(_differ) { - case 0: - _pdiffer = 2 - _ndiffer = 0 - break - case 1: - _pdiffer = 0 - _ndiffer = -2 - break - case 2: - _pdiffer = 1 - _ndiffer = -1 - break - default: - } - - value = [moment().subtract(_pdiffer + _val * 3, 'month').startOf('month').format('YYYY-MM-DD'), moment().subtract(_ndiffer + _val * 3, 'month').endOf('month').format('YYYY-MM-DD')] - } else if (_type === 'year') { - let _year = parseInt(moment().format('YYYY')) - _val - value = [_year + '-01-01', _year + '-12-31'] - } else if (_type === 'customized') { - try { - _val = JSON.parse(_val) - } catch { - _val = [0, 0] - } - value = [moment().subtract(_val[0], 'days').format('YYYY-MM-DD'), moment().subtract(_val[1], 'days').format('YYYY-MM-DD')] - } - } - - return value - } - - getAdvanceValue = (item, value) => { - if (!value || (Array.isArray(value) && value.length === 0)) return '' - - let val = '' - if (item.type === 'multiselect') { - val = value.join(', ') - } else if (item.type === 'daterange') { - if (value[0] && value[1]) { - val = `${moment(value[0]).format('YYYY-MM-DD')} ~ ${moment(value[1]).format('YYYY-MM-DD')}` - } - } else if (item.type === 'dateweek') { - val = `${moment(value).startOf('week').format('YYYY-MM-DD')} ~ ${moment(value).endOf('week').format('YYYY-MM-DD')}` - } else if (item.type === 'date') { - val = moment(value).format('YYYY-MM-DD') - } else if (item.type === 'datemonth') { - val = moment(value).format('YYYY-MM') - } else { - val = value.replace(/(^\s*|\s*$)/ig, '') - } - - return val - } - - // 鏌ヨ涓嬫媺鑿滃崟 - improveSearch = (mainItems, localItems) => { - const { menuType, BID } = this.props - let deffers = [] - - if (menuType !== 'HS' && window.GLOB.systemType !== 'production') { - localItems = [...localItems, ...mainItems] - mainItems = [] - } - - // 鏈湴璇锋眰 - let param = { - func: 'sPC_Get_SelectedList', - LText: localItems.join(' union all '), - obj_name: '', - arr_field: '', - table_type: 'Y' - } - - if (BID) { - param.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) - - if (menuType === 'HS') { // 浜戠鏁版嵁楠岃瘉 - param.open_key = Utils.encryptOpenKey(param.secretkey, param.timestamp) - } - - deffers.push( - new Promise(resolve => { - Api.getSystemCacheConfig(param).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' - } - - if (BID) { - mainparam.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 (menuType === 'HS') { // 浜戠鏁版嵁楠岃瘉 - mainparam.open_key = Utils.encryptOpenKey(mainparam.secretkey, mainparam.timestamp) - if (options.cloudServiceApi) { - mainparam.rduri = options.cloudServiceApi - mainparam.userid = sessionStorage.getItem('CloudUserID') || '' - mainparam.LoginUID = sessionStorage.getItem('CloudLoginUID') || '' - } - } else if (window.GLOB.mainSystemApi) { - mainparam.rduri = window.GLOB.mainSystemApi - } - - deffers.push( - new Promise(resolve => { - Api.getSystemCacheConfig(mainparam).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.resetSearch(result) - }) - } - - resetSearch = (result) => { - let _searchlist = this.state.searchlist.map(item => { - if (['select', 'link', 'multiselect', 'checkcard'].includes(item.type) && result[item.field] && result[item.field].length > 0) { - let options = result[item.field].map(cell => { - let _item = { - key: Utils.getuuid() - } - - if (item.type !== 'checkcard') { - _item.Value = cell[item.valueField] - _item.Text = cell[item.valueText] - } else { - _item.$value = cell[item.cardValField] - _item = {..._item, ...cell} - } - - if (item.type === 'link') { - _item.ParentID = cell[item.linkField] - } - - return _item - }) - - item.oriOptions = [...item.oriOptions, ...options] - } - return item - }) - - this.setState({ - searchlist: _searchlist.map(item => { - if (item.type === 'link') { - if (item.supInitVal) { - item.options = item.oriOptions.filter(option => option.ParentID === item.supInitVal || option.Value === '') - } else { - item.options = item.oriOptions - } - } else if (item.type === 'select' || item.type === 'multiselect' || item.type === 'checkcard') { - item.options = item.oriOptions - } - - return item - }) - }) - } - - // 娴嬭瘯绯荤粺鍗曚釜璇锋眰涓嬫媺閫夐」 - improveSimpleSearch = (deForms) => { - if (deForms.length === 0) return - - let deffers = deForms.map(item => { - let param = { - func: 'sPC_Get_SelectedList', - LText: item.data_sql, - obj_name: item.field, - arr_field: item.arr_field - } - - if (this.props.BID) { - param.BID = this.props.BID - } - - param.timestamp = moment().format('YYYY-MM-DD HH:mm:ss') - param.secretkey = Utils.encrypt(param.LText, param.timestamp) - - return ( - new Promise(resolve => { - Api.getSystemCacheConfig(param).then(res => { - if (!res.status) { - notification.warning({ - top: 92, - message: res.message, - duration: 5 - }) - } - resolve(res) - }) - }) - ) - }) - - Promise.all(deffers).then(response => { - let result = {} - - response.forEach(res => { - result = {...result, ...res} - }) - - delete result.ErrCode - delete result.ErrMesg - delete result.message - delete result.status - - this.resetSearch(result) - }) - } - - resetform = (formlist, supfields, index, fieldsvalue) => { - index++ - let subfields = [] - - supfields.forEach(supfield => { - formlist = formlist.map(item => { - if (item.type === 'link' && item.linkField === supfield.field) { - item.options = item.oriOptions.filter(option => option.ParentID === supfield.initval || option.Value === '') - item.initval = item.options[0] ? item.options[0].Value : '' - - if (this.props.form.getFieldValue(item.field) !== undefined) { - fieldsvalue[item.field] = item.initval - } - - subfields.push(item) - } - return item - }) - }) - - if (subfields.length === 0 || index > 6) { - return formlist - } else { - return this.resetform(formlist, subfields, index, fieldsvalue) - } - } - - selectChange = (_field, value) => { - let formlist = fromJS(this.state.searchlist).toJS() - - let subfields = [] - let fieldsvalue = {} - formlist = formlist.map(item => { - if (item.type === 'link' && item.linkField === _field.field) { - item.options = item.oriOptions.filter(option => option.ParentID === value || option.Value === '') - item.initval = item.options[0] ? item.options[0].Value : '' - - if (this.props.form.getFieldValue(item.field) !== undefined) { - fieldsvalue[item.field] = item.initval - } - - subfields.push(item) - } - return item - }) - - if (subfields.length === 0) { - this.searchChange() - return - } - - formlist = this.resetform(formlist, subfields, 0, fieldsvalue) - - if (Object.keys(fieldsvalue).length > 0) { - this.props.form.setFieldsValue(fieldsvalue) - } - - this.setState({ - searchlist: formlist - }, () => { - this.searchChange() - }) - } - - getFields() { - const { getFieldDecorator } = this.props.form - const { dict, showButton, formId, showAdvanced, float } = this.state - const fields = [] - - this.state.searchlist.forEach((item, index) => { - if (item.Hide === 'true' || (showAdvanced && item.advanced === 'true')) return - - if (item.type === 'text') { // 鏂囨湰鎼滅储 - fields.push( - <Col span={item.ratio || 6} key={index}> - <Form.Item label={item.labelShow !== 'false' ? item.label : ''}> - {getFieldDecorator(item.field, { - initialValue: item.initval, - rules: [ - { - required: item.required, - message: dict['form.required.input'] + item.label + '!' - } - ] - })(item.inputType === 'search' ? - <Search placeholder={item.labelShow === 'false' ? item.label : ''} autoComplete="off" onSearch={this.handleSearch} enterButton/> : - <Input placeholder={item.labelShow === 'false' ? item.label : ''} autoComplete="off" onPressEnter={this.handleSearch} />)} - </Form.Item> - </Col> - ) - } else if (item.type === 'select' || item.type === 'link') { // 涓嬫媺鎼滅储 - fields.push( - <Col span={item.ratio || 6} key={index}> - <Form.Item label={item.labelShow !== 'false' ? item.label : ''}> - {getFieldDecorator(item.field, { - initialValue: item.initval, - rules: [ - { - required: item.required, - message: dict['form.required.select'] + item.label + '!' - } - ] - })( - <Select - showSearch - onChange={(value) => {this.selectChange(item, value)}} - filterOption={(input, option) => option.props.children.toLowerCase().indexOf(input.toLowerCase()) >= 0 || option.props.value.toLowerCase().indexOf(input.toLowerCase()) >= 0} - getPopupContainer={() => formId ? document.getElementById(formId) : document.body} - > - {item.options.map((option, i) => - <Select.Option id={`${i}`} title={option.Text} key={`${i}`} value={option.Value}>{option.Text}</Select.Option> - )} - </Select> - )} - </Form.Item> - </Col> - ) - } else if (item.type === 'multiselect') { // 涓嬫媺澶氶�� - let _initval = item.initval ? item.initval.split(',').filter(Boolean) : [] - fields.push( - <Col span={item.ratio || 6} key={index}> - <Form.Item label={item.labelShow !== 'false' ? item.label : ''}> - {getFieldDecorator(item.field, { - initialValue: _initval, - rules: [ - { - required: item.required, - message: dict['form.required.select'] + item.label + '!' - } - ] - })( - <Select - showSearch - mode="multiple" - onChange={this.searchChange} - filterOption={(input, option) => option.props.children.toLowerCase().indexOf(input.toLowerCase()) >= 0} - getPopupContainer={() => formId ? document.getElementById(formId) : document.body} - > - {item.options.map((option, i) => - <Select.Option id={`${i}`} title={option.Text} key={`${i}`} value={option.Value}>{option.Text}</Select.Option> - )} - </Select> - )} - </Form.Item> - </Col> - ) - } else if (item.type === 'date') { // 鏃堕棿鎼滅储 - fields.push( - <Col span={item.ratio || 6} key={index}> - <Form.Item label={item.labelShow !== 'false' ? item.label : ''}> - {getFieldDecorator(item.field, { - initialValue: item.initval ? moment().subtract(item.initval, 'days') : null, - rules: [ - { - required: item.required, - message: dict['form.required.select'] + item.label + '!' - } - ] - })( - <DatePicker onChange={this.searchChange} getCalendarContainer={() => formId ? document.getElementById(formId) : document.body} /> - )} - </Form.Item> - </Col> - ) - } else if (item.type === 'datemonth') { - fields.push( - <Col span={item.ratio || 6} key={index}> - <Form.Item label={item.labelShow !== 'false' ? item.label : ''}> - {getFieldDecorator(item.field, { - initialValue: item.initval ? moment().subtract(item.initval, 'month') : null, - rules: [ - { - required: item.required, - message: dict['form.required.select'] + item.label + '!' - } - ] - })( - <MonthPicker onChange={this.searchChange} getCalendarContainer={() => formId ? document.getElementById(formId) : document.body} /> - )} - </Form.Item> - </Col> - ) - } else if (item.type === 'dateweek') { - fields.push( - <Col span={item.ratio || 6} key={index}> - <Form.Item label={item.labelShow !== 'false' ? item.label : ''}> - {getFieldDecorator(item.field, { - initialValue: item.initval ? moment().subtract(item.initval * 7, 'days') : null, - rules: [ - { - required: item.required, - message: dict['form.required.select'] + item.label + '!' - } - ] - })( - <WeekPicker onChange={this.searchChange} getCalendarContainer={() => formId ? document.getElementById(formId) : document.body} /> - )} - </Form.Item> - </Col> - ) - } else if (item.type === 'daterange') { - let _defaultValue = [null, null] - - if (item.initval) { - try { - let _initval = JSON.parse(item.initval) - _defaultValue = [moment().subtract(_initval[0], 'days'), moment().subtract(_initval[1], 'days')] - } catch { - _defaultValue = [null, null] - } - } - - fields.push( - <Col className="daterange" span={item.ratio || 6} key={index}> - <Form.Item label={item.labelShow !== 'false' ? item.label : ''}> - {getFieldDecorator(item.field, - { - initialValue: _defaultValue, - rules: [ - { - required: item.required, - message: dict['form.required.select'] + item.label + '!' - } - ] - })( - <RangePicker - placeholder={['寮�濮嬫棩鏈�', '缁撴潫鏃ユ湡']} - renderExtraFooter={() => 'extra footer'} - onChange={this.searchChange} - getCalendarContainer={() => formId ? document.getElementById(formId) : document.body} - /> - )} - </Form.Item> - </Col> - ) - } else if (item.type === 'group') { - fields.push( - <Col span={item.ratio || 6} key={index}> - <Form.Item label={item.labelShow !== 'false' ? item.label : ''} className={item.required ? 'group-required' : ''}> - <DateGroup reset={this.state.reset} position={index} card={item} onGroupChange={this.onGroupChange} /> - </Form.Item> - </Col> - ) - } else if (item.type === 'checkcard') { - fields.push( - <Col span={item.ratio || 6} key={index}> - <Form.Item label={item.labelShow !== 'false' ? item.label : ''}> - {getFieldDecorator(item.field, { - initialValue: item.initval, - rules: [ - { - required: item.required, - message: dict['form.required.select'] + item.label + '!' - } - ] - })( - <CheckCard card={item} onChange={this.searchChange} /> - )} - </Form.Item> - </Col> - ) - } - }) - - if (showButton) { - let action = ( - <Col span={6} style={{ whiteSpace: 'nowrap' }} className="search-button" key="actions"> - <Form.Item label={' '} colon={false} style={{ minHeight: '40px' }}> - <Button type="primary" onClick={this.handleSearch}> - {dict['main.search']} - </Button> - <Button style={{ marginLeft: 8 }} onClick={this.handleReset}> - {dict['main.reset']} - </Button> - {showAdvanced ? <Button type="link" onClick={this.handleAdvance}> - 楂樼骇 - </Button> : null} - </Form.Item> - </Col> - ) - if (float === 'right') { - fields.unshift(action) - } else { - fields.push(action) - } - } - - return fields - } - - handleAdvance = () => { - this.setState({visible: true}) - } - - handleSearch = () => { - // 鍥炶溅鎴栫偣鍑绘悳绱� - this.props.form.validateFields((err, values) => { - if (!err) { - let searches = this.getFieldsValues(values) - - let requireFields = searches.filter(item => item.required && (!item.value || item.value.length === 0)) - if (requireFields.length > 0) { - let labels = requireFields.map(item => item.label) - labels = Array.from(new Set(labels)) - - notification.warning({ - top: 92, - message: this.state.dict['form.required.input'] + labels.join('銆�') + ' !', - duration: 3 - }) - return - } - - this.props.refreshdata(searches) - } - }) - } - - onGroupChange = (values) => { - const { searchValues } = this.state - - this.setState({ - searchValues: {...searchValues, ...values} - }) - this.searchChange() - } - - searchChange = () => { - this.setState({}, () => { - this.props.form.validateFields((err, values) => { - if (!err) { - let searches = this.getFieldsValues(values) - - let requireFields = searches.filter(item => item.required && (!item.value || item.value.length === 0)) - if (requireFields.length > 0) { - return - } - - this.props.refreshdata(searches) - } - }) - }) - } - - /** - * @description 鎼滅储鏉′欢閲嶇疆 - */ - handleReset = () => { - const { showAdvanced } = this.state - - let searchValues = {} - let advanceValues = [] - let searchlist = this.state.searchlist.map(item => { - item.initval = item.oriInitval - - if (item.Hide === 'true') { - searchValues[item.field] = this.getInitValue(item) - } else if (showAdvanced && item.advanced === 'true') { - let _value = this.getInitValue(item) - searchValues[item.field] = _value - - let _val = this.getAdvanceValue(item, _value) - if (_val) { - advanceValues.push({field: item.field, type: item.type, label: item.label, value: _val}) - } - } else if (item.type === 'group') { - searchValues[item.datefield] = this.getInitValue(item) - searchValues[item.field] = item.initval && item.initval[0] ? item.initval[0] : '' - } - return item - }) - - this.setState({searchlist, searchValues, advanceValues, reset: !this.state.reset}, () => { - this.props.form.resetFields() - this.props.form.validateFields((err, values) => { - if (!err) { - let searches = this.getFieldsValues(values) - - let requireFields = searches.filter(item => item.required && (!item.value || item.value.length === 0)) - if (requireFields.length > 0) { - let labels = requireFields.map(item => item.label) - labels = Array.from(new Set(labels)) - - notification.warning({ - top: 92, - message: this.state.dict['form.required.input'] + labels.join('銆�') + ' !', - duration: 3 - }) - return - } - - this.props.refreshdata(searches) - } - }) - }) - } - - getFieldsValues = (values) => { - const { searchValues, searchlist } = this.state - // 鑾峰彇鎼滅储鏉′欢鍊� - let search = [] - searchlist.forEach(item => { - let cell = { - type: item.type, - key: item.field.replace(/@tail@$/, ''), - label: item.label, - match: item.match || '=', - required: item.required, - value: '' - } - if ((item.Hide === 'true' || item.advanced === 'true')) { - cell.value = searchValues[item.field] || '' - } - - if (item.type === 'group') { - cell.type = 'daterange' - cell.key = item.datefield - cell.value = searchValues[item.datefield] || '' - cell.match = 'between' - - search.push(cell) - - let copy = fromJS(cell).toJS() - copy.type = 'group' - copy.key = item.field.replace(/@tail@$/, '') - copy.value = searchValues[item.field] || '' - copy.match = '=' - copy.forbid = true - search.push(copy) - } else { - let _value = values[item.field] || cell.value || '' - if (!_value) { - if (item.type === 'multiselect') { - cell.value = [] - } - search.push(cell) - } else { - if (item.type === 'daterange') { - if (_value[0] && _value[1]) { - _value = [moment(_value[0]).format('YYYY-MM-DD'), moment(_value[1]).format('YYYY-MM-DD')] - } else { - _value = '' - } - } else if (item.type === 'dateweek') { - _value = [moment(_value).startOf('week').format('YYYY-MM-DD'), moment(_value).endOf('week').format('YYYY-MM-DD')] - } else if (item.type === 'date') { - _value = moment(_value).format('YYYY-MM-DD') - } else if (item.type === 'datemonth') { - _value = moment(_value).format('YYYY-MM') - } else if (item.type === 'multiselect') { - - } else { - _value = _value.replace(/(^\s*|\s*$)/ig, '') - } - - cell.value = _value - search.push(cell) - } - } - }) - - return search - } - - handleOk = () => { - const { searchValues, searchlist } = this.state - - this.formRef.handleConfirm().then(res => { - let values = {} - let advanceValues = [] - searchlist.forEach(item => { - if (item.advanced === 'true' && item.Hide !== 'true') { - let _value = res[item.field] || '' - - if (!_value && item.type === 'multiselect') { - _value = [] - } else if (typeof(_value) === 'string') { - _value = _value.replace(/(^\s*|\s*$)/ig, '') - } - values[item.field] = _value - - let _val = this.getAdvanceValue(item, _value) - if (_val) { - advanceValues.push({field: item.field, type: item.type, label: item.label, value: _val}) - } - } - }) - this.setState({searchValues: {...searchValues, ...values}, advanceValues, visible: false}, () => { - this.handleSearch() - }) - }) - } - - closeAdvanceForm = (cell) => { - const { searchValues, advanceValues } = this.state - - this.setState({searchValues: {...searchValues, [cell.field]: ''}, advanceValues: advanceValues.filter(item => item.field !== cell.field)}, () => { - this.handleSearch() - }) - } - - render() { - const { float, searchStyle, visible, searchlist, searchValues, showAdvanced, advanceValues, adModelWidth } = this.state - const formItemLayout = { - labelCol: { - xs: { span: 24 }, - sm: { span: 8 } - }, - wrapperCol: { - xs: { span: 24 }, - sm: { span: 16 } - } - } - - return ( - <> - <Form {...formItemLayout} className={`top-search ${float}`} style={searchStyle} id={this.state.formId || this.state.oriId}> - <Row gutter={24}>{this.getFields()}</Row> - <Row gutter={24}> - {showAdvanced ? <div className="advanced-list"> - {advanceValues.map((item, index) => { - return ( - <div key={index}> - <span>{item.label}: </span> - <span className="advance-value">{item.value}</span> - <Icon type="close" onClick={() => this.closeAdvanceForm(item)} /> - </div>) - })} - </div> : null} - </Row> - </Form> - <Modal - title="楂樼骇鎼滅储" - maskClosable={false} - visible={visible} - width={adModelWidth} - closable={false} - onOk={this.handleOk} - cancelText={'鍏抽棴'} - onCancel={() => this.setState({visible: false})} - destroyOnClose - > - <MutilForm - dict={this.state.dict} - searchlist={searchlist} - searchValues={searchValues} - handleSearch={this.handleOk} - wrappedComponentRef={(inst) => this.formRef = inst} - /> - </Modal> - </> - ) - } -} - -export default Form.create()(MainSearch) \ No newline at end of file diff --git a/src/tabviews/zshare/topSearch copy/index.scss b/src/tabviews/zshare/topSearch copy/index.scss deleted file mode 100644 index 40b4ede..0000000 --- a/src/tabviews/zshare/topSearch copy/index.scss +++ /dev/null @@ -1,76 +0,0 @@ -.top-search { - background: #ffffff; - .ant-form-item { - display: flex; - margin-bottom: 0px; - min-height: 60px; - .ant-form-explain { - white-space: nowrap; - } - } - .ant-form-item-control-wrapper { - flex: 1; - width: calc(100% - 100px); - } - .ant-form-item-label { - text-overflow: ellipsis; - } - .daterange .ant-calendar-picker-input { - padding: 4px 20px 4px 5px; - font-size: 13px; - } - .ant-select-dropdown { - z-index: 10 !important; - } - .ant-calendar-picker-container { - z-index: 10 !important; - } - .group-required { - label::before { - display: inline-block; - margin-right: 4px; - color: #f5222d; - font-size: 14px; - font-family: SimSun, sans-serif; - line-height: 1; - content: '*'; - } - } - .search-button { - .ant-btn-link, .ant-btn-link:hover, .ant-btn-link:active{ - border-color: transparent; - span { - position: relative; - top: 5px; - } - } - } - .advanced-list { - font-size: 13px; - > div { - display: inline-block; - margin-right: 10px; - border: 1px solid #dddddd; - padding: 0 4px 0 4px; - background: rgba(0, 0, 0, 0.02); - - .anticon-close { - margin-left: 5px; - cursor: pointer; - color: #bcbcbc; - font-size: 12px; - padding: 2px; - } - } - } - .check-card-form-box { - margin-top: 5px; - } -} -.top-search.right { - >.ant-row { - >.ant-col { - float: right; - } - } -} -- Gitblit v1.8.0