diff --git a/pc4mobx/organization/apis/qtxConfig.js b/pc4mobx/organization/apis/qtxConfig.js new file mode 100644 index 0000000..0424d9c --- /dev/null +++ b/pc4mobx/organization/apis/qtxConfig.js @@ -0,0 +1,9 @@ +import { WeaTools } from 'ecCom'; + + +export const getQtxConfigInfo = (params) => { + return WeaTools.callApi('/api/bs/hrmorganization/config/selectConfigInfo', 'GET', params); +} +export const saveQtxConfigInfo = (params) => { + return WeaTools.callApi('/api/bs/hrmorganization/config/saveConfigInfo', 'POST', params); + } \ No newline at end of file diff --git a/pc4mobx/organization/apis/quickSearch.js b/pc4mobx/organization/apis/quickSearch.js new file mode 100644 index 0000000..7c5e5fb --- /dev/null +++ b/pc4mobx/organization/apis/quickSearch.js @@ -0,0 +1,16 @@ +import { + WeaTools +} from 'ecCom'; + +export const saveQuickSearchInfo = (params) => { + return WeaTools.callApi(`/api/bs/hrmorganization/quicksearch/saveQuickSearchInfo`, 'POST', params); +} + +export const saveQuickSearchDetailInfo = (params) => { + return WeaTools.callApi(`/api/bs/hrmorganization/quicksearch/saveQuickSearchDetailInfo`, 'POST', params); +} + +export const getQuickSearchInfo = (params) => WeaTools.callApi(`/api/bs/hrmorganization/quicksearch/getQuickSearchInfo`, 'GET', params); + +export const getQuickSearchDetailInfo = (params) => WeaTools.callApi(`/api/bs/hrmorganization/quicksearch/getQuickSearchDetailInfo`, 'GET', params); + diff --git a/pc4mobx/organization/apis/resource.js b/pc4mobx/organization/apis/resource.js index f4c16ee..d8a8aeb 100644 --- a/pc4mobx/organization/apis/resource.js +++ b/pc4mobx/organization/apis/resource.js @@ -31,6 +31,11 @@ export const getHasRight = (params) => { return WeaTools.callApi('/api/bs/hrmorganization/hrmresource/getHasRight', 'GET', params); } +export const getQuickSearchCondition = (params) => { + return WeaTools.callApi('/api/bs/hrmorganization/quicksearch/getQuickSearchCondition', 'GET', params); +} + + export const editResource = (params) => { return WeaTools.callApi('/api/bs/hrmorganization/hrmresource/updateForm', 'POST', params); } diff --git a/pc4mobx/organization/components/company/CompanyExtend.js b/pc4mobx/organization/components/company/CompanyExtend.js index 9ae029f..ab0ccab 100644 --- a/pc4mobx/organization/components/company/CompanyExtend.js +++ b/pc4mobx/organization/components/company/CompanyExtend.js @@ -1,7 +1,7 @@ /** * @Author: 程亮 * @Date: 2022-05-18 14:52:39 - * @LastEditTime: 2023-07-26 18:59:02 + * @LastEditTime: 2023-08-04 16:52:47 * @Description: * @FilePath: /trunk/src4js/pc4mobx/organization/components/company/CompanyExtend.js */ @@ -28,11 +28,16 @@ import AttachToNumberField from "../NewNumberField"; export default class CompanyExtend extends React.Component { componentDidMount() { - this.init(); + this.handleHashChange(); + window.addEventListener('hashchange', this.handleHashChange); } - init = () => { + + componentWillUnmount() { + window.removeEventListener('hashchange', this.handleHashChange); + } + + handleHashChange = () => { const { companyExtend, company } = this.props; - //const {id} = company; let { hash } = window.location; hash = hash.split("?")[0]; let id = hash.match("[^/]+(?=/$|$)")[0]; @@ -129,7 +134,7 @@ export default class CompanyExtend extends React.Component { labelCol={{ span: `${field.labelcol}` }} wrapperCol={{ span: `${field.fieldcol}` }}> - {field.domkey[0] == 'subcompanycode' && } + {field.domkey[0] == 'subcompanycode' && isEditor &&} ), colSpan: 1 }); @@ -231,7 +236,7 @@ export default class CompanyExtend extends React.Component { } backCard = () => { - this.init(); + this.handleHashChange(); } view = () => { diff --git a/pc4mobx/organization/components/company/company.js b/pc4mobx/organization/components/company/company.js index 6ea1f48..3cf53da 100644 --- a/pc4mobx/organization/components/company/company.js +++ b/pc4mobx/organization/components/company/company.js @@ -1,7 +1,7 @@ /** * @Author: 程亮 * @Date: 2022-05-18 16:23:32 - * @LastEditTime: 2023-07-26 18:41:11 + * @LastEditTime: 2023-08-08 11:23:40 * @Description: * @FilePath: /trunk/src4js/pc4mobx/organization/components/company/company.js */ @@ -26,7 +26,7 @@ import { Button, message, Switch, - Menu, Dropdown, Icon,Tooltip + Menu, Dropdown, Icon, Tooltip } from 'antd' import { WeaSwitch, @@ -43,7 +43,7 @@ import NewAndEditDialog from '../NewAndEditDialog'; import NewWeaTable from '../NewWeaTableDialog'; import { renderNoright } from '../../util'; import { - CompanyExtendStore + CompanyExtendStore } from '../../stores/companyextend'; const companyExtend = new CompanyExtendStore(); @@ -343,9 +343,9 @@ export default class Company extends React.Component { c.className = "wea-table-indent" c.render = function (text, record) { return { - window.open(`/spa/organization/static/index.html#/main/organization/companyExtend/${record.id}`, "_blank") - }}>{text} - + window.open(`/spa/organization/static/index.html#/main/organization/companyExtend/${record.id}`, "_blank") + }}>{text} + } } if (c.dataIndex == 'operate') { @@ -354,25 +354,25 @@ export default class Company extends React.Component { c.render = function (text, record) { const menu = ( - + { - _this.doDel(record.id) -}}>删除 + _this.doDel(record.id) + }}>删除 { - _this.select(record.id) -}}>联查部门 + _this.select(record.id) + }}>联查部门 { - _this.view(record.id) -}}>查看 + _this.view(record.id) + }}>查看 { - _this.transfer(record.id) -}}>转移 + _this.transfer(record.id) + }}>转移 {/* { _this.version(record) }}>另存为版本 @@ -431,7 +431,7 @@ export default class Company extends React.Component { } = this.props; company.setSaveAndSetting(true); company.save(); - + } getTabBtn() { @@ -444,8 +444,8 @@ export default class Company extends React.Component { const btn = [ (), + company.setCurrent(1); company.setPageSize(10); company.getTableInfo(); company.setPanelStatus(false) + }}>{i18n.button.search()}), (), (), ]; @@ -519,7 +519,7 @@ export default class Company extends React.Component { const { isPanelShow, companyName, conditionNum, visible, condition, form, tableStore, dataSource, columns, loading, date, nEdialogTitle, dialogLoading, - form1, isEdit, newVisible, deptDataSource, deptColumns, selectedRowKeys, total, current, pageSize, init,hasRight + form1, isEdit, newVisible, deptDataSource, deptColumns, selectedRowKeys, total, current, pageSize, init, hasRight } = company; if (hasRight === false) { @@ -527,7 +527,7 @@ export default class Company extends React.Component { } const rowSelection = { - selectedRowKeys:selectedRowKeys, + selectedRowKeys: selectedRowKeys, type: "checkbox", onChange(selectedRowKeys, selectedRows) { company.setSelectedRowKeys(selectedRowKeys); @@ -629,7 +629,7 @@ export default class Company extends React.Component { conditionLen={1} save={() => this.handleSave()} onCancel={() => company.setNewVisible(false)} - saveAndSetting = {() => this.handleSaveAndSetting()} + saveAndSetting={() => this.handleSaveAndSetting()} /> ) diff --git a/pc4mobx/organization/components/department/departmentExtend.js b/pc4mobx/organization/components/department/departmentExtend.js index c230801..3dc6f6f 100644 --- a/pc4mobx/organization/components/department/departmentExtend.js +++ b/pc4mobx/organization/components/department/departmentExtend.js @@ -1,7 +1,7 @@ /** * @Author: 程亮 * @Date: 2022-06-02 09:20:03 - * @LastEditTime: 2023-07-26 18:59:14 + * @LastEditTime: 2023-08-04 16:51:56 * @Description: * @FilePath: /trunk/src4js/pc4mobx/organization/components/department/departmentExtend.js */ @@ -29,9 +29,15 @@ import '../../style/common.less'; export default class DepartmentExtendStore extends React.Component { componentDidMount() { - this.init(); + this.handleHashChange(); + window.addEventListener('hashchange', this.handleHashChange); } - init = () => { + + componentWillUnmount() { + window.removeEventListener('hashchange', this.handleHashChange); + } + + handleHashChange = () => { const { departmentExtend, department } = this.props; let { hash } = window.location; hash = hash.split("?")[0]; @@ -242,7 +248,7 @@ export default class DepartmentExtendStore extends React.Component { } backCard = () => { - this.init(); + this.handleHashChange(); } changeData(key) { diff --git a/pc4mobx/organization/components/fieldDefinedSet/FieldDef.js b/pc4mobx/organization/components/fieldDefinedSet/FieldDef.js index ffb3bd2..38f3576 100644 --- a/pc4mobx/organization/components/fieldDefinedSet/FieldDef.js +++ b/pc4mobx/organization/components/fieldDefinedSet/FieldDef.js @@ -105,9 +105,9 @@ export default class FieldDef extends Component { } const rMenu = [...rightMenu, ...store.getBasicMenus(this.props.logSmallType, this.props.targetId)] return ( -
{ - this.tabDom = dom -}}> +
{ + this.tabDom = dom + }}> setEditTable(editTable, 'fieldDef')} diff --git a/pc4mobx/organization/components/fieldDefinedSet/QtxConfig.js b/pc4mobx/organization/components/fieldDefinedSet/QtxConfig.js new file mode 100644 index 0000000..42ffc21 --- /dev/null +++ b/pc4mobx/organization/components/fieldDefinedSet/QtxConfig.js @@ -0,0 +1,178 @@ +import React from 'react' +import * as mobx from 'mobx' +import { + inject, + observer +} from 'mobx-react' +import { + WeaTop, WeaFormItem, WeaTable, WeaRightMenu, WeaHelpfulTip, + WeaNewScroll, WeaSearchGroup, WeaLocaleProvider, WeaTab, WeaTableEdit +} from 'ecCom' +import { + Row, Col, Button, Modal, message, Input, Dropdown, Icon, Menu +} from 'antd' +import { WeaSwitch } from 'comsMobx' +import { + i18n +} from '../../public/i18n'; +const getLabel = WeaLocaleProvider.getLabel; + +const toJS = mobx.toJS; +const confirm = Modal.confirm; + + + +@inject('qtxConfig') +@observer +export default class QtxConfig extends React.Component { + constructor(props) { + super(props); + } + + componentWillMount() { + } + + componentDidMount() { + const { + qtxConfig + } = this.props; + qtxConfig.initList(); + } + + componentWillUnmount() { + } + + + componentWillReceiveProps(nextProps) { + const { + qtxConfig + } = this.props; + + if (this.props.location.key !== nextProps.location.key) { + qtxConfig.initList(); + } + } + + getDropMenuDatas() { + const { + qtxConfig + } = this.props, { + rightMenu + } = qtxConfig + + let menus = []; + toJS(rightMenu).map((item, index) => { + let obj = { + key: item.menuFun, + icon: , + content: item.menuName, + } + menus.push(obj); + }) + return menus; + } + + getTopMenuBtns() { + const { + qtxConfig + } = this.props, { + topMenu + } = qtxConfig + + let btns = []; + topMenu.map((item, i) => { + btns.push(); + }); + return btns; + } + + save = () => { + const { + qtxConfig + } = this.props; + let result = this.tableEdit.refs.edit.doRequiredCheck(); + result.pass && qtxConfig.saveQtxConfigInfo(); + } + + login = () => { + window.open("/api/bs/hrmorganization/config/ssoLogin", "_blank") + } + + + + + getFormItems = () => { + const { qtxConfig } = this.props; + const { configFields, configForm } = qtxConfig; + const arr = []; + const formParams = configForm.getFormParams(); + const { isFormInit } = configForm; + isFormInit && configFields.map((field, index) => { + arr.push( +
+ + {} + {} + +
+ ) + }) + + return {arr} + } + + + + render() { + const { qtxConfig: store } = this.props; + const { editTableData } = store, { + datas, columns, selectedData, loading + } = editTableData; + + return ( +
+ { this[key] && this[key]() }} + > + } + iconBgcolor='#217346' + loading={true} + buttons={this.getTopMenuBtns()} + showDropIcon={true} + dropMenuDatas={this.getDropMenuDatas()} + onDropMenuClick={(key) => { this[key] && this[key]() }} + > + + + {this.getFormItems()} + + + {this.tableEdit = el}} + draggable + deleteConfirm + showCopy={false} + title="" + columns={toJS(columns)} + datas={toJS(datas)} + selectedData={!loading && toJS(selectedData)} + onChange={e => store.setTableEditDatas(e)} + /> + + + + +
+ ) + } +} \ No newline at end of file diff --git a/pc4mobx/organization/components/fieldDefinedSet/QuickSearch.js b/pc4mobx/organization/components/fieldDefinedSet/QuickSearch.js new file mode 100644 index 0000000..3f01cf5 --- /dev/null +++ b/pc4mobx/organization/components/fieldDefinedSet/QuickSearch.js @@ -0,0 +1,262 @@ +import React from 'react' +import * as mobx from 'mobx' +import { + inject, + observer +} from 'mobx-react' +import { + WeaTop, WeaFormItem, WeaTable, WeaRightMenu, + WeaNewScroll, WeaSearchGroup, WeaLocaleProvider, WeaTab +} from 'ecCom' +import { + Row, Col, Button, Modal, message, Input, Dropdown, Icon, Menu +} from 'antd' +import { WeaSwitch } from 'comsMobx' +import { + i18n +} from '../../public/i18n'; +import QuickSearchTableEdit from './QuickSearchTableEdit'; +import QuickSearchDetail from './QuickSearchDetail'; +const getLabel = WeaLocaleProvider.getLabel; + +const toJS = mobx.toJS; +const confirm = Modal.confirm; + + + +@inject('quickSearch') +@observer +export default class QuickSearch extends React.Component { + constructor(props) { + super(props); + } + + componentWillMount() { + } + + componentDidMount() { + const { + quickSearch + } = this.props; + quickSearch.initList(); + } + + componentWillUnmount() { + } + + + componentWillReceiveProps(nextProps) { + const { + quickSearch + } = this.props; + + if (this.props.location.key !== nextProps.location.key) { + quickSearch.initList(); + } + } + + getDropMenuDatas() { + const { + quickSearch + } = this.props,{ + rightMenu + } = quickSearch + + let menus = []; + toJS(rightMenu).map((item, index) => { + let obj = { + key: item.menuFun, + icon: , + content: item.menuName, + } + menus.push(obj); + }) + return menus; + } + + getTopMenuBtns() { + const { + quickSearch + } = this.props,{ + topMenu + } = quickSearch + + let btns = []; + topMenu.map((item, i) => { + btns.push(); + }); + return btns; + } + + save = () => { + const { + quickSearch + } = this.props; + quickSearch.saveQuickSearchInfo(); + } + + + getFormItems = () => { + const { quickSearch } = this.props; + const { quickSearchFields, quickSearchForm } = quickSearch; + const arr = []; + const formParams = quickSearchForm.getFormParams(); + const { isFormInit } = quickSearchForm; + isFormInit && quickSearchFields.map((field, index) => { + arr.push( +
+ + {} + +
+ ) + }) + + return {arr} + } + + getSearchButton = () => { + return [ + (), + + ] + } + + addRow = () => { + const { quickSearch } = this.props; + let { quickSearchData } = quickSearch; + let datas = quickSearchData.datas; + if(datas.length>=8){ + message.error(getLabel('387795',"最多只能添加8项")); + return; + } + let time = new Date().getTime(); + let type = quickSearchData.options.length > 0 ? quickSearchData.options[0].type : '2'; + let fieldid = quickSearchData.options.length > 0 ? quickSearchData.options[0].key : ''; + let customname = quickSearchData.options.length > 0 ? quickSearchData.options[0].showname : ''; + let isdetailtable = quickSearchData.options.length > 0 ? quickSearchData.options[0].isdetailtable : '0'; + let obj = { + key: "new_" + time, + fieldid: fieldid, + customname: customname, + range: type == '1' ? getLabel('387636', "内容自定义") : getLabel('387637', "字段本身值"), + condition: type == '1' ? getLabel('68', "设置") : '', + orderid: 0, + type: type, + isdetailtable: isdetailtable + } + datas = toJS(datas); + datas.push(obj); + quickSearch.setQuickSearchData(datas); + } + + delRow = () => { + const { quickSearch } = this.props; + let { qcSelectedRowKeys } = quickSearch; + if (qcSelectedRowKeys.length <= 0) { + message.error(getLabel(22346, '请选择要删除的信息', 'label')); + return; + } + const that = this; + Modal.confirm({ + title: getLabel(83601, '您确认要删除选中的记录吗?'), + onOk() { + let { datas } = quickSearch.quickSearchData; + datas = toJS(datas); + datas = that.delFromArray(datas, qcSelectedRowKeys); + quickSearch.qcSelectedRowKeys = []; + quickSearch.setQuickSearchData(datas); + }, + onCancel() {}, + }); + } + + delFromArray = (array, selectRowIds) => { + for (let i = 0; i < selectRowIds.length; i++) { + let key = selectRowIds[i]; + for (let j = 0; j < array.length; j++) { + if (array[j]["key"] == key) { + array.splice(j, 1); + break; + } + } + } + return array; + } + + onSelectChange = (keys, rows) => { + let keyarr = []; + rows.map(row => { + keyarr.push(row.key); + }); + const { quickSearch } = this.props; + quickSearch.qcSelectedRowKeys = keyarr; + } + + + onChange = (data) => { + const { quickSearch } = this.props; + quickSearch.setQuickSearchData(data); + } + + + + render() { + + const { quickSearch: store } = this.props; + const { qcSelectedRowKeys } = store; + const rowSelection = { + selectedRowKeys: qcSelectedRowKeys, + onChange: this.onSelectChange, + } + + return ( +
+ {this[key] && this[key]()}} + > + } + iconBgcolor='#217346' + loading={true} + buttons={this.getTopMenuBtns()} + showDropIcon={true} + dropMenuDatas={this.getDropMenuDatas()} + onDropMenuClick={(key) => {this[key] && this[key]()}} + > + + + + {this.getFormItems()} + + + + + + + + + + +
+ ) + } +} \ No newline at end of file diff --git a/pc4mobx/organization/components/fieldDefinedSet/QuickSearchDetail.js b/pc4mobx/organization/components/fieldDefinedSet/QuickSearchDetail.js new file mode 100644 index 0000000..b98697e --- /dev/null +++ b/pc4mobx/organization/components/fieldDefinedSet/QuickSearchDetail.js @@ -0,0 +1,280 @@ +import React from 'react'; +import { observer } from 'mobx-react'; +import { WeaDialog, WeaNewScroll, WeaLocaleProvider, WeaRightMenu } from 'ecCom'; +import { WeaScope, WeaInput, WeaInputNumber, WeaSearchGroup, WeaTab, WeaError, WeaHelpfulTip } from 'ecCom'; +const getLabel = WeaLocaleProvider.getLabel; +import { Button, Table, Modal, message } from 'antd'; +import { observable, toJS, } from "mobx"; +import { WeaForm } from 'comsMobx'; +import $ from 'jquery'; + +@observer +export default class QuickSearchDetail extends React.Component { + constructor(props) { + super(props); + } + + + onSelectChange = (keys, rows) => { + let keyarr = []; + rows.map(row => { + keyarr.push(row.key); + }); + const { quickSearch } = this.props; + quickSearch.qcDetailRowKeys = keyarr; + } + + save = () => { + const { quickSearch } = this.props; + quickSearch.saveQuickSearchDetailInfo(); + } + + closeDialog = () => { + const { quickSearch } = this.props; + quickSearch.quickSearchDetailVisable = false; + } + + onChange = (data) => { + const { quickSearch } = this.props; + quickSearch.setQuickSearchDetailData(data); + } + + getSearchButton = () => { + const { quickSearch } = this.props; + const buttons = new Array(); + buttons.push(); + buttons.push(); + + return buttons; + } + + addRow = () => { + const { quickSearch } = this.props; + let { quickSearchDetailData } = quickSearch; + let datas = quickSearchDetailData; + let time = new Date().getTime(); + let obj = { + key: "new_" + time, + customname: '', + orderid: 0, + minnum: '', + maxnum: '', + type: quickSearch.qcData.qcType, + fieldid: quickSearch.qcData.fieldid, + customid: quickSearch.customid + } + datas = toJS(datas); + datas.push(obj); + quickSearch.setQuickSearchDetailData(datas); + } + + delRow = () => { + const { quickSearch } = this.props; + let { qcDetailRowKeys } = quickSearch; + if (qcDetailRowKeys.length <= 0) { + message.error(getLabel(22346, '请选择要删除的信息', 'label')); + return; + } + const that = this; + Modal.confirm({ + title: getLabel(83601, '您确认要删除选中的记录吗?'), + onOk() { + let datas = quickSearch.quickSearchDetailData; + datas = toJS(datas); + datas = that.delFromArray(datas, qcDetailRowKeys); + quickSearch.qcDetailRowKeys = []; + quickSearch.setQuickSearchDetailData(datas); + }, + onCancel() { }, + }); + } + + delFromArray = (array, selectRowIds) => { + for (let i = 0; i < selectRowIds.length; i++) { + let key = selectRowIds[i]; + for (let j = 0; j < array.length; j++) { + if (array[j]["key"] == key) { + array.splice(j, 1); + break; + } + } + } + return array; + } + + render() { + const { quickSearch: store } = this.props, { + qcDetailRowKeys + } = store; + const rowSelection = { + qcDetailRowKeys, + onChange: this.onSelectChange, + } + const Height = $(".wea-dialog-body")[0] && $(".wea-dialog-body")[0].style.height; + const buttons = [ + , + + ] + return ( + + + + + + + + + + ) + } + + +} + +@observer +class QuickSearchTableEdit extends React.Component{ + + getColumns = () => { + let columnArray = [ + { + title: getLabel(195, "名称"), dataIndex: "customname", key: "customname", width: "40%", + com: [{ label: '', type: 'INPUT', key: 'customname', viewAttr: 3, otherParams: { isBase64: true, inputType: "multilang" } }] + }, + { + title:
+ {getLabel(387588, "内容自定义条件")}  + +
, dataIndex: "condition", key: "condition", width: "40%", + com: [{ label: '', type: 'SCOP', key: 'condition', viewAttr: 3 }] + }, + { + title: getLabel(88, "顺序"), dataIndex: "orderid", key: "orderid", width: "20%", + com: [{ label: '', type: 'INPUTNUMBER', key: 'orderid', viewAttr: 2, otherParams: { max: 999, step: 1 } }] + } + ]; + columnArray = columnArray.map((col) => { + let _col = { ...col }; + _col.render = (text, record, index) => { + return this.getColRender(_col, text, record, index); + } + return _col + }); + return columnArray; + } + + getColRender = (_col, text, record, index) => { + const { datas } = this.props; + const { quickSearch: { quickSearchRefObj } } = this.props.ListProps; + const { com, } = _col; + let _com = []; + com.map((c) => { + if (typeof c.props === 'object') { + _com.push(); + } else { + const { key, viewAttr = 2, type = 'INPUT', width, otherParams = {} } = c; + const _type = type.toUpperCase(); + _com.push( + + { + _type === 'INPUT' && + quickSearchRefObj[`error_${key}_${index}`] = ref} + > + this.onEdit(record, index, key, value)} + {...otherParams} + /> + + } + { + _type === 'SCOP' && + quickSearchRefObj[`error_${key}_${index}`] = ref} + > +
+ this.onEdit(record, index, key, value)} + /> +
+
+ } + { + _type === 'INPUTNUMBER' && + this.onEdit(record, index, key, value1)} + {...otherParams} + /> + } +
+ ) + } + }); + return ( +
+ {_com} +
+ ) + } + + onEdit = (record, index, key, value) => { + const { datas } = this.props; + let _datas = [...datas]; + _datas[index][key] = value; + if (key == 'condition') { + _datas[index].minnum = value[0] === undefined ? "" : value[0]; + _datas[index].maxnum = value[1] === undefined ? "" : value[1]; + } + typeof this.props.onChange === 'function' && this.props.onChange(_datas); + } + + render() { + const { datas, rowSelection } = this.props; + return ( +
+ + + ) + } +} diff --git a/pc4mobx/organization/components/fieldDefinedSet/QuickSearchTableEdit.js b/pc4mobx/organization/components/fieldDefinedSet/QuickSearchTableEdit.js new file mode 100644 index 0000000..914d31b --- /dev/null +++ b/pc4mobx/organization/components/fieldDefinedSet/QuickSearchTableEdit.js @@ -0,0 +1,233 @@ +import React from 'react' +import * as mobx from 'mobx' +import { + inject, + observer +} from 'mobx-react' +import { + WeaTable, WeaLocaleProvider, WeaSelect, WeaInput, WeaInputNumber +} from 'ecCom' +import { + Row, Col, Button, Modal, message, Input, Dropdown, Icon, Menu +} from 'antd' +import { + i18n +} from '../../public/i18n'; +const getLabel = WeaLocaleProvider.getLabel; +import jQuery from "jquery"; +const toJS = mobx.toJS; + +export default class QuickSearchTableEdit extends React.Component { + + + /**========================table字段类型=====================*/ + getColumns = () => { + let columnArray = [ + { + title: getLabel(261, "字段"), dataIndex: "fieldid", key: "fieldid", width: "18%", + com: [{ label: '', type: 'SELECT', isLink: true, key: 'fieldid', options: [] }] + }, + { + title: getLabel(195, "名称"), dataIndex: "customname", key: "customname", width: "18%", + com: [{ + label: '', type: 'INPUT', key: 'customname', viewAttr: 2, otherParams: { isBase64: true, inputType: "multilang" } + }] + }, + { + title: getLabel(389518, "查询范围"), dataIndex: "range", key: "range", width: "8%", + com: [{ label: '', type: 'INPUT', key: 'range', viewAttr: 1 }] + }, + { + title: getLabel(387588, "内容自定义条件"), dataIndex: "condition", key: "condition", width: "15%", + com: [{ label: '', type: 'BUTTON', key: 'condition', viewAttr: 1 }] + }, { + title: getLabel(21657, "显示模式"), dataIndex: "showmodel", key: "showmodel", width: "15%", + com: [{ + label: '', + type: 'SELECT', + key: 'showmodel', + viewAttr: 1, + options: [ { key: '0', showname: getLabel(19852, '平铺') },] + }] + } + ]; + columnArray = columnArray.map((col) => { + let _col = { ...col }; + _col.render = (text, record, index) => { + return this.getColRender(_col, text, record, index); + } + return _col + }); + return columnArray; + } + + getColRender = (_col, text, record, index) => { + const { + quickSearch: store + } = this.props; + const { com } = _col; + let _com = []; + com.map((c, idn) => { + if (typeof c.props === 'object') { + _com.push(); + } else { + const { key, isLink = false, viewAttr = 2, type = 'INPUT', width, otherParams = {}, detailtype = 1, options = [] } = c; + const _type = type.toUpperCase(); + record.range = record.type == '1' ? getLabel('387636', "内容自定义") : getLabel('387637', "字段本身值"); + record.condition = record.type == '1' ? getLabel('68', "设置") : ''; + if (_type === 'INPUT') { + _com.push( this.onEdit(record, index, key, value)} + {...otherParams} + length={100} + />) + } else if (_type === 'BUTTON') { + _com.push( this.onClick(record)} + style={{ width, display: 'inline-block' }}>{record[key]}); + } else if (_type === 'INPUTNUMBER') { + _com.push( this.onEdit(record, index, key, value)} + {...otherParams} + />) + } else if (_type === 'SELECT') { + if (isLink) { + _com.push( { + this.onEdit(record, index, key, value) + }} + showSearch + filterOption={(inputValue, option) => this.selectFilterOption(inputValue, option)} + />); + }else if (key === 'showmodel') {//可以设置平铺的类型 + const opt = this.props.options.filter(item => item.fieldid === record.fieldid); + const isShowModel = opt[0] ? opt[0].isShowModel : false; + if (isShowModel) { + if (!record[key]) { + record[key] = '0' + } + _com.push( { + this.onEdit(record, index, key, value) + }} + filterOption={(inputValue, option) => selectFilterOption(inputValue, option)} + />); + } + } + + + } + } + }); + return ( +
{_com}
+ ) + }; + + onDropChange = (data) => { + typeof this.props.onChange === 'function' && this.props.onChange(data); + } + + onClick = (record) => { + const { ListProps } = this.props; + const { quickSearch } = ListProps; + let key = record.key; + if (key.indexOf("new") >= 0 || record.fieldid != record.orifieldid) { + message.error(getLabel(82228, "请先保存再设置条件")); + return; + } + quickSearch.openQuickSearchDetail(record); + }; + + onEdit = (record, index, key, value, name, data) => { + const { datas } = this.props; + let _datas = [...datas]; + _datas[index][key] = value; + if (key == 'fieldid') { + let opt = this.getType(value); + if (opt != null) { + _datas[index].type = opt['type']; + _datas[index].customname = opt['showname']; + _datas[index].range = _datas[index].type == '1' ? getLabel('387636', "内容自定义") : getLabel('387637', "字段本身值"); + _datas[index].condition = _datas[index].type == '1' ? getLabel('68', "设置") : ''; + _datas[index].isdetailtable = opt['isdetailtable']; + } + } + typeof this.props.onChange === 'function' && this.props.onChange(_datas); + } + + getType = (key) => { + let option = null; + this.props.options.map(f => { + if (f.key == key) { + option = f; + } + }); + return option; + } + + /** + * 根据选择框的名称,搜索过滤选项 + * @param inputValue + * @param option + */ + selectFilterOption = (inputValue, option) => { + if (inputValue != "") { + const { children } = option["props"]; + if (children) { + if ((typeof children) == "string") { + return children.toLowerCase().indexOf(inputValue.toLowerCase()) != -1; + } else if ((typeof children) == "object" && children.length > 0) { + const childrenNew = children[0]["props"]["children"]; + if (childrenNew) { + return childrenNew.toLowerCase().indexOf(inputValue.toLowerCase()) != -1; + } else { + return false; + } + } else { + const childrenNew = children["props"]["children"]; + if (childrenNew) { + return childrenNew.toLowerCase().indexOf(inputValue.toLowerCase()) != -1; + } else { + return false; + } + } + } else { + return false; + } + } + return true; + } + + + render() { + const { datas, rowSelection } = this.props; + return ( +
+ +
+ ) + } +} \ No newline at end of file diff --git a/pc4mobx/organization/components/job/Job.js b/pc4mobx/organization/components/job/Job.js index e15d141..f6cd5cd 100644 --- a/pc4mobx/organization/components/job/Job.js +++ b/pc4mobx/organization/components/job/Job.js @@ -1,7 +1,7 @@ /** * @Author: 程亮 * @Date: 2022-05-26 14:05:59 - * @LastEditTime: 2023-08-02 17:09:24 + * @LastEditTime: 2023-08-14 11:39:45 * @Description: * @FilePath: /trunk/src4js/pc4mobx/organization/components/job/Job.js */ diff --git a/pc4mobx/organization/components/postionrank/RankScheme.js b/pc4mobx/organization/components/postionrank/RankScheme.js index 0ff4370..2c13a40 100644 --- a/pc4mobx/organization/components/postionrank/RankScheme.js +++ b/pc4mobx/organization/components/postionrank/RankScheme.js @@ -51,7 +51,7 @@ export default class RankScheme extends React.Component { } componentDidMount() { - this.init(); + this.init(); } componentWillUnmount() { @@ -201,8 +201,8 @@ export default class RankScheme extends React.Component { const btn = [ (), + rankScheme.getTableInfo(); rankScheme.setPanelStatus(false) + }}>{i18n.button.search()}), (), (), ]; @@ -260,7 +260,7 @@ export default class RankScheme extends React.Component { return false; }, }); - + } onOperatesClick(record, rowIndex, operate) { @@ -383,11 +383,11 @@ export default class RankScheme extends React.Component { } = rankScheme; if (hasRight === false) { - return renderNoright(); + return renderNoright(); } return ( - hasRight &&
+ hasRight &&
this.handleMenuClick(key)} @@ -438,6 +438,6 @@ export default class RankScheme extends React.Component { onCancel={() => rankScheme.setVisible(false)} />
- ) + ) } } \ No newline at end of file diff --git a/pc4mobx/organization/components/resource/GroupList.js b/pc4mobx/organization/components/resource/GroupList.js new file mode 100644 index 0000000..1f0ba93 --- /dev/null +++ b/pc4mobx/organization/components/resource/GroupList.js @@ -0,0 +1,39 @@ +import React, {Component} from 'react'; +import {observer} from 'mobx-react'; +import {WeaRadioGroup, WeaLocaleProvider} from 'ecCom'; +import classnames from 'classnames'; + + +@observer +export default class GroupList extends Component{ + render(){ + const {store} = this.props; + const {setDomRef,radioGroupConfig, showRadioGroup} = store; + const displayClassName = classnames({ + radioGroupShow: true, + radioGroupHide: !showRadioGroup + }) + const iconClassName = classnames({ + 'icon-coms-down-001': !showRadioGroup, + 'icon-coms-up-001': showRadioGroup + }) + + const label = showRadioGroup ? '隐藏条件' : '显示条件'; + + return ( +
setDomRef(dom, 'tab')}> +
+
store.showRadioGroup = !showRadioGroup}> + {label} + + + +
+
+ +
+
+
+ ) + } +} \ No newline at end of file diff --git a/pc4mobx/organization/components/resource/resource.js b/pc4mobx/organization/components/resource/resource.js index f7b94aa..56a3ed3 100644 --- a/pc4mobx/organization/components/resource/resource.js +++ b/pc4mobx/organization/components/resource/resource.js @@ -36,12 +36,14 @@ import { } from '../../public/i18n'; //import '../../style/common.less'; +import '../../style/resource.less'; import NewAndEditDialog from '../NewAndEditDialog'; import { renderNoright } from '../../util'; import DatasImport from '../import/datasImport'; import SearchCustomDialog from './SearchCustomDialog'; import NewWeaTableEditDialog from '../NewWeaTableEditDialog'; +import GroupList from './GroupList'; @@ -80,6 +82,7 @@ export default class Resource extends React.Component { resource } = this.props; resource.getHasRight(); + resource.getQuickSearchCondition(); let { hash } = window.location; hash = hash.split("?")[1].split("&"); if (hash.length >= 2) { @@ -301,7 +304,7 @@ export default class Resource extends React.Component { confirm({ title: "存为模板", - content: + content: { - resource.getTableInfo(); resource.setPanelStatus(false) -}}>{i18n.button.search()}), + resource.getTableInfo(); resource.setPanelStatus(false) + }}>{i18n.button.search()}), (), (), (), @@ -501,13 +504,12 @@ export default class Resource extends React.Component { render() { const { - resource, resource: store } = this.props; const { isPanelShow, form2, lastName, conditionNum, tableStore, nEdialogTitle, visible, condition, - form, dialogLoading, isEdit, date, hasRight, defaultShowLeft - } = resource; + form, dialogLoading, isEdit, date, hasRight, defaultShowLeft,enable + } = store; if (hasRight === false) { return renderNoright(); @@ -535,15 +537,16 @@ export default class Resource extends React.Component { showSearchAd={isPanelShow} searchsBaseValue={this.isEmptyObject(form2.getFormParams()) ? lastName : form2.getFormParams().lastName} searchsBasePlaceHolder='请输入姓名' - setShowSearchAd={bool => resource.setPanelStatus(bool)} - hideSearchAd={() => resource.setPanelStatus(false)} + setShowSearchAd={bool => store.setPanelStatus(bool)} + hideSearchAd={() => store.setPanelStatus(false)} searchsAd={isPanelShow ? this.getPanelComponents() :
} advanceHeight={Math.ceil(conditionNum / 2) * 52 + 20} hasMask={false} buttonsAd={this.getTabBtn()} - onSearch={() => resource.getTableInfo()} + onSearch={() => {store.hideRadioGroup();store.getTableInfo();}} onSearchChange={val => this.onSearchChange(val)} /> + {enable && } + store={store} /> + store={store} />
) } diff --git a/pc4mobx/organization/index.js b/pc4mobx/organization/index.js index e73f6ed..444140a 100644 --- a/pc4mobx/organization/index.js +++ b/pc4mobx/organization/index.js @@ -32,11 +32,19 @@ import ResourceBasicInfo from "./components/resource/ResourceBasicInfo"; import ResourceCard from "./components/resource/ResourceCard"; import ManagerDetach from "./components/detach/ManagerDetach"; import ColumnSetting from "./components/columnSetting"; -import PersonnelResume from "./components/resource/PersonnelResume" +import PersonnelResume from "./components/resource/PersonnelResume"; +import QuickSearch from "./components/fieldDefinedSet/QuickSearch"; +import QtxConfig from "./components/fieldDefinedSet/QtxConfig"; import stores from "./stores"; import "./style/index"; +// 全局配置 +message.config({ + duration: 0.8, // 默认持续时间为 3 秒 + maxCount: 1, // 全局最大显示数量为 3 +}); + // 读取系统多语言配置 let getLocaleLabel = WeaLocaleProvider.getLocaleLabel.bind( this, @@ -98,7 +106,8 @@ const Routes = ( - + + ); diff --git a/pc4mobx/organization/stores/index.js b/pc4mobx/organization/stores/index.js index e0d8271..c0f3814 100644 --- a/pc4mobx/organization/stores/index.js +++ b/pc4mobx/organization/stores/index.js @@ -26,7 +26,9 @@ import {ImportDialogStore} from "./importDialog"; import {ResourceCardStore} from "./resourceCard"; import {ManagerDetachStore} from "./managerDetach"; import {ColumnSetting} from './columnSetting'; -import {PersonnelResumeStore} from './personnelResume' +import {PersonnelResumeStore} from './personnelResume'; +import { QuickSearchStore } from "./quickSearch"; +import { QtxConfigStore } from "./qtxConfig"; module.exports = { @@ -58,5 +60,7 @@ module.exports = { resourceCard:new ResourceCardStore(), managerDetach: new ManagerDetachStore(), columnSetting: new ColumnSetting(), - personnelResume:new PersonnelResumeStore() + personnelResume:new PersonnelResumeStore(), + quickSearch:new QuickSearchStore(), + qtxConfig: new QtxConfigStore() }; diff --git a/pc4mobx/organization/stores/qtxConfig.js b/pc4mobx/organization/stores/qtxConfig.js new file mode 100644 index 0000000..fe0bd2e --- /dev/null +++ b/pc4mobx/organization/stores/qtxConfig.js @@ -0,0 +1,159 @@ +import { + observable, + action, + computed, extendObservable +} from 'mobx'; +import * as mobx from 'mobx'; +import * as API from '../apis/qtxConfig'; +import { + WeaForm +} from 'comsMobx'; +import { + Modal, + message, +} from 'antd' +import { + i18n +} from '../public/i18n'; +import { WeaLocaleProvider } from 'ecCom'; + +const toJS = mobx.toJS; +const getLabel = WeaLocaleProvider.getLabel; + + +export class QtxConfigStore { + + @observable configForm = new WeaForm(); + @observable editTableData = { + datas: [], + columns: [], + loading: true, + selectedData: {} + }; + + @observable configFields = [ + { + domkey: ['isopenconfig'], + conditionType: 'SWITCH', + label: getLabel('-1', "是否开启数据库配置"), + labelcol: 5, + fieldcol: 19, + viewAttr: 3, + } + ] + + @action("初始化页面") initList = () => { + this.configForm.initFormFields([{ items: this.configFields.slice() }]); + this.getQtxConfigInfo(); + } + + @action clearConfigData = () => { + this.editTableData.datas = []; + this.editTableData.columns = []; + this.editTableData.loading = true; + + } + + @action("数据获取") getQtxConfigInfo = () => { + this.clearConfigData(); + API.getQtxConfigInfo().then(action(({ code, data, msg }) => { + if (code == 200) { + const { columns, datas } = data; + extendObservable(this.editTableData, { + datas: datas, + columns: columns, + loading: false + }); + this.configForm.updateFields({ + isopenconfig: data.isopenconfig, + }); + } else { + message.error(`[${getLabel(127353, "错误") + code}]:${msg}`); + } + })); + } + + setTableEditDatas = (e) => { + if(e.length > 1) { + e.pop(); + message.error("默认只能添加一条配置数据!!!") + } + extendObservable(this.editTableData, { + datas: e + }); + } + + @action("保存页面") saveQtxConfigInfo = () => { + if(this.editTableData.datas.length == 0) { + return message.error("至少保存一条配置数据!!") + } + let editTable = JSON.stringify(this.editTableData.datas[0]); + API.saveQtxConfigInfo({ + ...this.configForm.getFormParams(), + editTable, + }).then(({ code, data, msg }) => { + if (code == 200) { + message.success(getLabel(83551, '保存成功!')); + this.getQtxConfigInfo(); + } else { + message.error(`[${getLabel(127353, "错误") + code}]:${msg}`); + } + }); + } + + arrToJson = (arr) => { + let json = {}; + const _rows = isEmpty(arr) ? [] : rows; + _rows && _rows.map(index => { + arr[index][rowKey] = "1"; + }); + arr.map((item, index) => { + if (!item[rowKey]) item[rowKey] = "0"; + for (let key in item) { + json[key + "_" + index] = item[key]; + } + }); + + return json; + } + + + /**===========================buttons=========================== */ + rightMenu = [ + { + "isBatch": "0", + "isTop": "1", + "menuFun": "save", + "menuIcon": "icon-coms-Preservation", + "menuName": "保存", + "type": "BTN_save" + }, + { + "isBatch": "0", + "isTop": "0", + "menuFun": "login", + "menuIcon": "icon-coms-link", + "menuName": "单点登录", + "type": "BTN_link" + } + ]; + topMenu = [ + { + "isBatch": "1", + "isTop": "1", + "menuFun": "save", + "menuIcon": "icon-coms-Preservation", + "menuName": "保存", + "type": "BTN_save" + }, + { + "isBatch": "1", + "isTop": "1", + "menuFun": "login", + "menuIcon": "icon-coms-link", + "menuName": "单点登录", + "type": "BTN_link" + } + ] + +} \ No newline at end of file diff --git a/pc4mobx/organization/stores/quickSearch.js b/pc4mobx/organization/stores/quickSearch.js new file mode 100644 index 0000000..328b76e --- /dev/null +++ b/pc4mobx/organization/stores/quickSearch.js @@ -0,0 +1,232 @@ +import { + observable, + action +} from 'mobx'; +import * as mobx from 'mobx'; +import * as API from '../apis/quickSearch'; +import { + WeaForm +} from 'comsMobx'; +import { + Modal, + message, +} from 'antd' +import { + i18n +} from '../public/i18n'; +import { WeaLocaleProvider } from 'ecCom'; + +const toJS = mobx.toJS; +const getLabel = WeaLocaleProvider.getLabel; +const formatMultiLang = WeaLocaleProvider.formatMultiLang; + + +export class QuickSearchStore { + + @observable quickSearchForm = new WeaForm(); + @observable qcSelectedRowKeys = []; + @observable quickSearchData = { + datas: [],//表格记录record + setting: {}, + options: [], + }; + @observable quickSearchDetailVisable = false; + @observable qcData = { qcType: '', cid: '', fieldid: '' };//快速查询明细type + @observable quickSearchDetailData = []; + @observable precision = 0; + @observable qcDetailRowKeys = []; + quickSearchRefObj = {}; + + /**** ==============quickSearchForm ===============*/ + @observable quickSearchFields = [ + { + domkey: ['isquicksearch'], + conditionType: 'SWITCH', + label: getLabel('387493', "快捷搜索条件"), + labelcol: 5, + fieldcol: 19, + viewAttr: 3, + } + ] + + + @action("初始化页面") initList = () => { + this.quickSearchForm.initFormFields([{ items: this.quickSearchFields.slice() }]); + this.getQuickSearchInfo(); + } + + @action clearQuciSearchData = () => { + this.quickSearchData.setting = {}; + this.quickSearchData.datas = []; + this.quickSearchData.options = []; + } + + @action("数据获取") getQuickSearchInfo = () => { + this.clearQuciSearchData(); + API.getQuickSearchInfo().then(action(({ code, data, msg }) => { + if (code == 200) { + this.quickSearchData.setting = data.setting; + this.quickSearchData.datas = data.datas.map(d => { + return { ...d, visible: false } + }); + this.quickSearchData.groupidOptions = data.groupidOptions; + this.quickSearchData.options = data.options; + this.quickSearchForm.updateFields({ + isquicksearch: data.setting.isquicksearch, + }); + } else { + message.error(`[${getLabel(127353, "错误") + code}]:${msg}`); + } + })); + } + + + + @action("保存页面") saveQuickSearchInfo = () => { + let datas = this.quickSearchData.datas; + datas.map((data, index) => { + data.orderid = index + }); + + let formparm = this.quickSearchForm.getFormParams(); + if (!this.checkQuickSearchData()) { + message.error(getLabel('387954', "条件字段不能重复")); + return; + } + let id = this.quickSearchData.setting.id; + if (id == null) { + return; + } + API.saveQuickSearchInfo({ + id: id, + data: JSON.stringify(datas), ...formparm + }).then(({ code, data, msg }) => { + if (code == 200) { + message.success(getLabel(83551, '保存成功!')); + this.qcSelectedRowKeys = []; + this.getQuickSearchInfo(); + } else { + message.error(`[${getLabel(127353, "错误") + code}]:${msg}`); + } + }); + this.quickSearchData.setting.id = null; + } + + + checkQuickSearchData = () => { + let map = new Map(); + let result = true; + this.quickSearchData.datas.map(data => { + if (map.has(data.fieldid)) { + result = false; + } + map.set(data.fieldid, data.customname); + }); + return result; + } + + @action setQuickSearchData = (datas) => { + this.quickSearchData.datas = datas; + } + + /**============================quickdetail===================== */ + @action("设置") openQuickSearchDetail = (record) => { + this.quickSearchDetailVisable = true; + this.qcData.qcType = record.type; + this.qcData.cid = record.cid; + this.qcData.fieldid = record.fieldid; + this.getQuickSearchDetailInfo(record.cid); + } + + @action getQuickSearchDetailInfo = (cid) => { + API.getQuickSearchDetailInfo({ cid: cid }).then(({ code, data, msg }) => { + if (code == 200) { + this.quickSearchDetailData = data.datas; + this.precision = data.precision; + } else { + message.error(`[${getLabel(127353, "错误") + code}]:${msg}`); + } + }); + } + @action("明细保存") saveQuickSearchDetailInfo = () => { + let datas = this.quickSearchDetailData; + if (!this.checkQuickSearchDetailData()) { + return; + } + API.saveQuickSearchDetailInfo({ + cid: this.qcData.cid, + data: JSON.stringify(datas) + }).then(({ code, data, msg }) => { + if (code == 200) { + message.success(getLabel(83551, '保存成功!')); + this.qcDetailRowKeys = []; + this.getQuickSearchDetailInfo(this.qcData.cid); + } else { + message.error(`[${getLabel(127353, "错误") + code}]:${msg}`); + } + }); + } + + @action setQuickSearchDetailData = (datas) => { + this.quickSearchDetailData = datas; + } + + checkQuickSearchDetailData = () => { + let result = true; + for (let i = 0; i < this.quickSearchDetailData.length; i++) { + let data = this.quickSearchDetailData[i]; + if (_.trim(formatMultiLang(data.customname)) == '') { + this.quickSearchRefObj[`error_customname_${i}`].showError(); + result = false; + break; + } + let minnum = data.minnum + ''; + let maxnum = data.maxnum + ''; + if ((_.trim(formatMultiLang(minnum)) == '' || minnum == undefined) && (_.trim(formatMultiLang(maxnum)) == '' || maxnum == undefined)) { + this.quickSearchRefObj[`error_condition_${i}`].showError(); + result = false; + return; + } + if ((minnum != '' && minnum != undefined) + && (maxnum != '' && maxnum != undefined) + && (parseFloat(minnum) > parseFloat(maxnum))) { + message.error(getLabel('382783', "请填写正确的区间")); + result = false; + return; + } + } + return result; + } + + + /**===========================buttons=========================== */ + rightMenu = [ + { + "isBatch": "0", + "isTop": "1", + "menuFun": "save", + "menuIcon": "icon-coms-Preservation", + "menuName": "保存", + "type": "BTN_save" + }, + // { + // "isBatch": "0", + // "isTop": "0", + // "menuFun": "log", + // "menuIcon": "icon-coms-Print-log", + // "menuName": "日志", + // "type": "BTN_log" + // } + ]; + topMenu = [ + { + "isBatch": "1", + "isTop": "1", + "menuFun": "save", + "menuIcon": "icon-coms-Preservation", + "menuName": "保存", + "type": "BTN_save" + } + ] + +} \ No newline at end of file diff --git a/pc4mobx/organization/stores/resource.js b/pc4mobx/organization/stores/resource.js index 5e9078e..27da720 100644 --- a/pc4mobx/organization/stores/resource.js +++ b/pc4mobx/organization/stores/resource.js @@ -23,7 +23,7 @@ import { i18n } from '../public/i18n'; import { getSecondPath } from '../util/index' -import {cloneDeep,isEmpty,trim} from 'lodash'; +import { cloneDeep, isEmpty, trim } from 'lodash'; const toJS = mobx.toJS; const { @@ -59,21 +59,81 @@ export class ResourceStore { @observable selectTreeNodeInfo; + @observable enable = false; + @observable _showRadioGroup = true; + @computed get showRadioGroup() { return this._showRadioGroup } + set showRadioGroup(v) { + this._showRadioGroup = v; + setTimeout(() => { + this.reCalculateTableHeight = new Date().getTime(); + }, 0) + } + + domRef = {}; + @observable _reCalculateTableHeight = new Date().getTime(); + @computed get reCalculateTableHeight() { return this._reCalculateTableHeight } + set reCalculateTableHeight(v) { this._reCalculateTableHeight = v } + @computed get tableHeihgt() { + this.reCalculateTableHeight; + const topHeight = this.domRef.top && this.domRef.top.refs.content ? this.domRef.top.refs.content.clientHeight : 0; + const tabHeight = this.domRef.tab ? $(this.domRef.tab)[0].clientHeight : 0; + const h = topHeight - tabHeight; + return h <= 0 ? 0 : h; + } + + @action setDomRef = (dom, type) => { + dom && Object.assign(this.domRef, { [type]: dom }) && setTimeout(() => this.reCalculateTableHeight = new Date().getTime(), 500); + } + + @observable rangeConditions = []; + @observable radioParams = {}; + + @observable refreshRadioGroup = new Date().getTime(); + @computed get radioGroupConfig(){ + this.refreshRadioGroup; + return { + config: [ + ...this.rangeConditions + ], + key: new Date().getTime(), + onChange: this.onRadioGroupChangeHandle + } + } + + @action onRadioGroupChangeHandle = params => { + this.radioParams = params; + this.getTableInfo(); + } + @action("列表") getTableInfo() { - let params; this.tableStore = new TableStore(); - if (this.isEmptyObject(this.form2.getFormParams())) { + let params = {}; + debugger; + if(this.isEmptyObject(this.radioParams)) { params = { ...this.selectTreeNodeInfo, - lastName: this.lastName - }; - } else { + isQuickSearch:false + } + if (this.isEmptyObject(this.form2.getFormParams())) { + params = { + ...params, + lastName: this.lastName, + }; + } else { + params = { + ...params, + ...this.form2.getFormParams() + }; + } + }else { params = { + ...this.radioParams, ...this.selectTreeNodeInfo, - ...this.form2.getFormParams() - }; + isQuickSearch:true + } } + this.form2.resetForm(); Api.getSearchList(params).then(res => { if (res.code === 200) { res.data.datas && this.tableStore.getDatas(res.data.datas, 1); @@ -87,6 +147,7 @@ export class ResourceStore { @action("nodetree事件") doSearch(params) { this.selectTreeNodeInfo = params; + this.showRadioGroup = true; this.getTableInfo(); } @@ -100,7 +161,7 @@ export class ResourceStore { return response.json() }).then(data => { if (data.code === 200) { - message.success(data.msg); + message.success(data.msg,1); this.getTableInfo(); this.setVisible(false); } else { @@ -159,6 +220,18 @@ export class ResourceStore { }) } + @action("快捷搜索") getQuickSearchCondition() { + Api.getQuickSearchCondition().then(res => { + if (res.code === 200) { + this.rangeConditions = res.data.rangeConditions; + this.enable = res.data.enable; + } else { + message.warning(res.msg); + } + }, error => { + message.warning(error.msg); + }) + } @action("顶部按钮") getHasRight() { Api.getHasRight().then(res => { @@ -250,24 +323,24 @@ export class ResourceStore { } @action("列定制保存") saveCustomDefine = () => { - if(this.customTemplateId == '-1') { + if (this.customTemplateId == '-1') { message.error("默认模板不能修改,将返回默认模板列"); } - + const params = { - columns:this.transfer.transferKeys, - templateId:this.customTemplateId + columns: this.transfer.transferKeys, + templateId: this.customTemplateId } Api.saveColumnsCustomTemplate(params).then(res => { if (res.code === 200) { this.searchDialog.visible = false; this.getTableInfo(); - } + } }, error => { message.warning(error.msg); }) - - + + } @action("高级搜索模板切换") changeSearchTemplate(v) { @@ -315,7 +388,7 @@ export class ResourceStore { } @action("常用条件定制模板切换") getTemplateSelectKeys = v => { - if(!this.search){ + if (!this.search) { this.customTemplateId = v; } @@ -515,7 +588,7 @@ export class ResourceStore { @action("模板") getSearchTemplate = (bool) => { Api.getSearchTemplate({ type: bool ? 'search' : 'custom' }).then(res => { if (res.code === 200) { - if(res.data.templateId) { + if (res.data.templateId) { this.customTemplateId = res.data.templateId; } bool ? this.setTemplates(res.data.templates) : this.setCustomTemplates(res.data.templates); @@ -595,218 +668,221 @@ export class ResourceStore { }).catch(error => { message.error(error); }); -} - -@action("列定制") getCustomTransferData() { - Api.getCustomTransferData(this.customTemplateId).then(result => { - if (result.code === 200) { - const { transferDatas, transferKeys, transferOptions } = result.data; - this.transfer.transferDatas = transferDatas; - this.transfer.transferKeys = transferKeys; - this.transfer.transferOptions = transferOptions; - this.searchDialog.visible = true; - this.searchDialog.loading = false; - } else { - message.warning(result.msg); - } - }, error => { - message.warning(error.msg); - }) -} - - - - -@action updateTransferleftIptVal = (v) => { - this.transfer.transferleftIptVal = v; -} - -@action updateTransferSelectedKey = (v) => { - this.transfer.transferSelectedKey = v; -} - -@action updateTransferKeys = (v) => { - this.transfer.transferKeys = v; -} - - -@action updateTransferRightptVal = (v) => { - this.transfer.transferRightIptVal = v; -} - - - -@action openSearchDialog = (bool) => { - this.search = bool; - this.searchDialog.loading = false; - this.formatTransfer(); -} - -@action openCustomDialog = (bool) => { - this.search = bool; - this.searchDialog.loading = true; - this.getSearchTemplate(bool); - this.getCustomTransferData(); - -} - -@action closeSearchDialog = () => { - this.searchDialog.visible = false; -} - -@action closeTemlateManageDialog = () => { - this.temlateManageDialog.visible = false; -} - -setTableEditDatas(e) { - e.map(item => { - for (let key in item) { - if (key == "undefined") { - delete item[key]; - } - if (!item["isused"]) { - item["isused"] = ""; - } - } - }); - extendObservable(this.relatedData, { - datas: e - }); -} - -setEnableRows(e) { - extendObservable(this.relatedData, { - selectedData: { - isused: e - } - }); -} - - - -updateFields(val) { - this.form2.updateFields({ - lastname: { - value: val - } - }); -} - -setSearchCondition(condition) { - this.searchCondition = condition; -} - -setDefaultCondition(defaultcondition) { - this.defaultCondition = defaultcondition; -} - -setTemplates(datas) { - this.templates = datas; -} - -setCustomTemplates(datas) { - this.customTemplates = datas; -} - -setScLoadingStatus(bool) { - this.searchConditionLoading = bool; -} - -setPanelStatus(bool) { - this.isPanelShow = bool; - this.search = true; - this.searchDialog.loading = true; - this.getSearchTemplate(bool); - bool && this.getSearchCondition(); - if (!bool) { - this.scLoadingReset(); } -} -arrToJson(arr, rows, rowKey = "isused") { - let json = {}; - const _rows = isEmpty(arr) ? [] : rows; - _rows && _rows.map(index => { - arr[index][rowKey] = "1"; - }); - arr.map((item, index) => { - if (!item[rowKey]) item[rowKey] = "0"; - for (let key in item) { - json[key + "_" + index] = item[key]; - } - }); - - return json; -} - -setLastName(val) { - this.lastName = val; -} - -isEmptyObject(obj) { - for (let key in obj) { - return false; + @action("列定制") getCustomTransferData() { + Api.getCustomTransferData(this.customTemplateId).then(result => { + if (result.code === 200) { + const { transferDatas, transferKeys, transferOptions } = result.data; + this.transfer.transferDatas = transferDatas; + this.transfer.transferKeys = transferKeys; + this.transfer.transferOptions = transferOptions; + this.searchDialog.visible = true; + this.searchDialog.loading = false; + } else { + message.warning(result.msg); + } + }, error => { + message.warning(error.msg); + }) } - return true; -} - -setIds(ids) { - this.ids = ids; -} - -scLoadingReset() { - this.searchConditionLoading = true; -} -formReset() { - this.form = new WeaForm(); -} -dialogLoadingReset() { - this.dialogLoading = true; -} -setVisible(bool) { - this.visible = bool; - this.formReset(); - !bool && this.dialogLoadingReset(); -} + @action updateTransferleftIptVal = (v) => { + this.transfer.transferleftIptVal = v; + } -setDialogLoadingStatus(bool) { - this.dialogLoading = bool; -} + @action updateTransferSelectedKey = (v) => { + this.transfer.transferSelectedKey = v; + } -setNeDialogTitle(title) { - this.nEdialogTitle = title; -} + @action updateTransferKeys = (v) => { + this.transfer.transferKeys = v; + } -setIsNew(bool) { - this.isNew = bool; -} -setCondition(condition) { - this.condition = condition; -} + @action updateTransferRightptVal = (v) => { + this.transfer.transferRightIptVal = v; + } -setUserId(userId) { - this.userId = userId; -} -setDate(date) { - this.date = date; -} -setTopMenu(topMenu) { - this.topMenu = topMenu; -} + @action openSearchDialog = (bool) => { + this.search = bool; + this.searchDialog.loading = false; + this.formatTransfer(); + } -setRightMenu(rightMenu) { - this.rightMenu = rightMenu; -} + @action openCustomDialog = (bool) => { + this.search = bool; + this.searchDialog.loading = true; + this.getSearchTemplate(bool); + this.getCustomTransferData(); -setHasRight(bool) { - this.hasRight = bool; -} + } + + @action closeSearchDialog = () => { + this.searchDialog.visible = false; + } + + @action closeTemlateManageDialog = () => { + this.temlateManageDialog.visible = false; + } + + setTableEditDatas(e) { + e.map(item => { + for (let key in item) { + if (key == "undefined") { + delete item[key]; + } + if (!item["isused"]) { + item["isused"] = ""; + } + } + }); + extendObservable(this.relatedData, { + datas: e + }); + } + + setEnableRows(e) { + extendObservable(this.relatedData, { + selectedData: { + isused: e + } + }); + } + + updateFields(val) { + this.form2.updateFields({ + lastname: { + value: val + } + }); + } + + hideRadioGroup() { + this.radioParams = {}; + this.showRadioGroup = false; + } + + setSearchCondition(condition) { + this.searchCondition = condition; + } + + setDefaultCondition(defaultcondition) { + this.defaultCondition = defaultcondition; + } + + setTemplates(datas) { + this.templates = datas; + } + + setCustomTemplates(datas) { + this.customTemplates = datas; + } + + setScLoadingStatus(bool) { + this.searchConditionLoading = bool; + } + + setPanelStatus(bool) { + this.isPanelShow = bool; + this.search = true; + this.searchDialog.loading = true; + this.getSearchTemplate(bool); + bool && this.getSearchCondition(); + if (!bool) { + this.scLoadingReset(); + } + } + + arrToJson(arr, rows, rowKey = "isused") { + let json = {}; + const _rows = isEmpty(arr) ? [] : rows; + _rows && _rows.map(index => { + arr[index][rowKey] = "1"; + }); + arr.map((item, index) => { + if (!item[rowKey]) item[rowKey] = "0"; + for (let key in item) { + json[key + "_" + index] = item[key]; + } + }); + + return json; + } + + setLastName(val) { + this.lastName = val; + } + + isEmptyObject(obj) { + for (let key in obj) { + return false; + } + return true; + } + + setIds(ids) { + this.ids = ids; + } + + scLoadingReset() { + this.searchConditionLoading = true; + } + + + formReset() { + this.form = new WeaForm(); + } + + dialogLoadingReset() { + this.dialogLoading = true; + } + + setVisible(bool) { + this.visible = bool; + this.formReset(); + !bool && this.dialogLoadingReset(); + } + + setDialogLoadingStatus(bool) { + this.dialogLoading = bool; + } + + setNeDialogTitle(title) { + this.nEdialogTitle = title; + } + + setIsNew(bool) { + this.isNew = bool; + } + + setCondition(condition) { + this.condition = condition; + } + + setUserId(userId) { + this.userId = userId; + } + + setDate(date) { + this.date = date; + } + + setTopMenu(topMenu) { + this.topMenu = topMenu; + } + + setRightMenu(rightMenu) { + this.rightMenu = rightMenu; + } + + setHasRight(bool) { + this.hasRight = bool; + } } \ No newline at end of file diff --git a/pc4mobx/organization/style/resource.less b/pc4mobx/organization/style/resource.less new file mode 100644 index 0000000..ae78a6a --- /dev/null +++ b/pc4mobx/organization/style/resource.less @@ -0,0 +1,18 @@ + +.searchGroup { + width: 100%; + padding: 8px 20px; + + .radioGroupShow{ + text-align: center; + line-height: 30px; + margin-bottom: 8px; + background-color: #f4f4f4; + color: #333; + + span{ + padding: 3px; + cursor: pointer; + } + } +} \ No newline at end of file