From 8bf8b580654b7bc04acfcd1b4920629bd772de6e Mon Sep 17 00:00:00 2001 From: MustangDeng <670124965@qq.com> Date: Fri, 22 Apr 2022 17:00:10 +0800 Subject: [PATCH 1/2] =?UTF-8?q?=E8=80=83=E5=8B=A4=E5=AD=97=E6=AE=B5?= =?UTF-8?q?=E5=88=97=E8=A1=A8?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- pc4mobx/hrmSalary/apis/welfareScheme.js | 10 ++- .../pages/dataAcquisition/attendance/index.js | 77 +++++++++++++------ pc4mobx/hrmSalary/pages/payroll/index.js | 1 - .../socialSecurityBenefits/programme/index.js | 76 ++++++++++++------ pc4mobx/hrmSalary/stores/attendanceStore.js | 8 +- pc4mobx/hrmSalary/stores/programme.js | 12 ++- 6 files changed, 134 insertions(+), 50 deletions(-) diff --git a/pc4mobx/hrmSalary/apis/welfareScheme.js b/pc4mobx/hrmSalary/apis/welfareScheme.js index d7adb154..11ce1976 100644 --- a/pc4mobx/hrmSalary/apis/welfareScheme.js +++ b/pc4mobx/hrmSalary/apis/welfareScheme.js @@ -4,7 +4,15 @@ export const getForm = params => { return WeaTools.callApi('/api/bs/hrmsalary/scheme/getForm', 'get', params); }; export const getTable = params => { - return WeaTools.callApi('/api/bs/hrmsalary/scheme/getTable', 'get', params); + // return WeaTools.callApi('/api/bs/hrmsalary/scheme/getTable', 'get', params); + return fetch('/api/bs/hrmsalary/scheme/getTable', { + method: 'POST', + mode: 'cors', + headers: { + 'Content-Type': 'application/json' + }, + body: JSON.stringify(params) + }).then(res => res.json()) }; export const createScheme = params => { return fetch('/api/bs/hrmsalary/scheme/insert', { diff --git a/pc4mobx/hrmSalary/pages/dataAcquisition/attendance/index.js b/pc4mobx/hrmSalary/pages/dataAcquisition/attendance/index.js index a490b830..f5c2c8f8 100644 --- a/pc4mobx/hrmSalary/pages/dataAcquisition/attendance/index.js +++ b/pc4mobx/hrmSalary/pages/dataAcquisition/attendance/index.js @@ -5,7 +5,7 @@ import { WeaTableNew } from "comsMobx" import { Button, Table, DatePicker, Row, Col, Menu, Dropdown, Switch } from 'antd'; -import { WeaInputSearch, WeaSlideModal, WeaHelpfulTip, WeaCheckbox, WeaDatePicker, WeaTop, WeaTab, WeaRightMenu, WeaRangePicker, WeaSelect } from 'ecCom'; +import { WeaInputSearch, WeaSlideModal, WeaHelpfulTip, WeaCheckbox, WeaDatePicker, WeaTop, WeaTab, WeaRightMenu, WeaRangePicker, WeaSelect, WeaTable } from 'ecCom'; import { renderNoright, getSearchs } from '../../../util'; // 渲染form数据的方法:因为多个页面都会使用,所以抽的公共方法在util中 import CustomTab from '../../../components/customTab'; @@ -26,7 +26,6 @@ import ItemMangeFormModal from './itemMangeFormModal' const { MonthPicker } = DatePicker; -const WeaTable = WeaTableNew.WeaTable; @inject('attendanceStore') @observer @@ -56,8 +55,10 @@ export default class Attendance extends React.Component { itemMangeVisible: false, itemMangeValue: {}, fieldName: "", - fieldSettingSearchValue: "" + fieldSettingSearchValue: "", + fieldCurrent: 1 } + this.fieldSearch = {} } componentWillMount() { @@ -88,18 +89,28 @@ export default class Attendance extends React.Component { setCurrentItem(record) } + // 字段列表分页 + handleFieldPageChange(value) { + this.setState({fieldCurrent: value}) + const { attendanceStore: {getAttendanceFieldList} } = this.props; + this.fieldSearch.current = value + getAttendanceFieldList(this.fieldSearch) + } + render() { const { attendanceStore } = this.props; const { loading, hasRight, form, condition, tableStore, showSearchAd, getTableDatas, doSearch, setShowSearchAd } = attendanceStore; const { step, setStep, setSlideVisiable, slideVisiable, doBatchDelete, attendTableStore, fieldSettingAttendList, fieldSettingCustomList, setFieldSettingAttendList, setFieldSettingCustomList, searchFieldSettingList } = attendanceStore; - const { getAttendanceFieldSettingList, saveAttendanceFieldSetting } = attendanceStore + const { getAttendanceFieldSettingList, saveAttendanceFieldSetting, fieldDataSource, fieldTableStore, fieldPageInfo} = attendanceStore const selectedRowKeys = toJS(tableStore.selectedRowKeys) || []; // tableStore 右侧选中数组 + if (!hasRight && !loading) { // 无权限处理 return renderNoright(); } const batchDelete = () => { doBatchDelete() + this.fieldSearch = {fieldName: this.state.fieldName} getAttendanceFieldList({fieldName: this.state.fieldName}) } @@ -229,7 +240,8 @@ export default class Attendance extends React.Component { const handleItemSearch = (value) => { const { attendanceStore: {getAttendanceFieldList}} = this.props; - getAttendanceFieldList({fieldName: value}) + this.fieldSearch = {fieldName: value} + getAttendanceFieldList(this.fieldSearch) } const handleNewClick = () => { @@ -263,7 +275,8 @@ export default class Attendance extends React.Component { }) if(v == "1") { - getAttendanceFieldList({fieldName: this.state.fieldName}) + this.fieldSearch = {fieldName: this.state.fieldName} + getAttendanceFieldList(this.fieldSearch) } else if(v == "0") { getAttendanceList({}) } @@ -276,32 +289,40 @@ export default class Attendance extends React.Component { enableStatus: value } updateAttendanceFieldStatus(request).then(result => { - getAttendanceFieldList({fieldName: this.state.fieldName}) + this.fieldSearch = {fieldName: this.state.fieldName} + getAttendanceFieldList(this.fieldSearch) }) } // 字段Columns const getFieldColumns = (columns) => { - let newColumns = ''; - newColumns = columns.map(column => { + let newColumns = columns.filter(item => item.hide == "false") + newColumns = newColumns.map(column => { let newColumn = column; newColumn.render = (text, record, index) => { //前端元素转义 let valueSpan = record[newColumn.dataIndex + "span"] !== undefined ? record[newColumn.dataIndex + "span"] : record[newColumn.dataIndex]; switch(newColumn.dataIndex) { case "username": - return {this.onEdit(record)}} + return {this.onItemEdit(record)}} dangerouslySetInnerHTML={{ __html: valueSpan }} /> case "enableStatus": return {handleSwitchItemChange(record, value)}}/> - case "operate": - return {this.onEdit(record)}}>查看明细 default: return
} } return newColumn; }); + newColumns.push({ + title: "操作", + dataIndex: "operate", + render: (text, record) => { + return ( + {this.onItemEdit(record)}}>查看明细 + ) + } + }) return newColumns; } @@ -310,7 +331,8 @@ export default class Attendance extends React.Component { const { attendanceStore: { saveAttendanceField, getAttendanceFieldList }} = this.props; value.fieldType = value.fieldType == "1" ? "NUMBER" : "TEXT" saveAttendanceField(value) - getAttendanceFieldList({fieldName: this.state.fieldName}) + this.fieldSearch = {fieldName: this.state.fieldName} + getAttendanceFieldList(this.fieldSearch) this.setState({itemMangeVisible: false}) } @@ -319,7 +341,8 @@ export default class Attendance extends React.Component { // alert(JSON.stringify(value)); value.fieldType = value.fieldType == "1" ? "NUMBER" : "TEXT" updateAttendanceField(value) - getAttendanceFieldList({fieldName: this.state.fieldName}) + this.fieldSearch = {fieldName: this.state.fieldName} + getAttendanceFieldList(this.fieldSearch) this.setState({itemMangeVisible: false}) } @@ -384,13 +407,13 @@ export default class Attendance extends React.Component { }} /> - + /> */}
:
@@ -406,13 +429,23 @@ export default class Attendance extends React.Component { /> + + {this.handleFieldPageChange(value)}, + total: fieldPageInfo.total, + current: this.state.fieldCurrent + }} /> } rightContent={ diff --git a/pc4mobx/hrmSalary/pages/payroll/index.js b/pc4mobx/hrmSalary/pages/payroll/index.js index bcc5aaa4..f9dcc14d 100644 --- a/pc4mobx/hrmSalary/pages/payroll/index.js +++ b/pc4mobx/hrmSalary/pages/payroll/index.js @@ -360,7 +360,6 @@ export default class Payroll extends React.Component { onDelete={(record)=> this.handleTemplateListDelete(record)} /> } - diff --git a/pc4mobx/hrmSalary/pages/socialSecurityBenefits/programme/index.js b/pc4mobx/hrmSalary/pages/socialSecurityBenefits/programme/index.js index a7097026..6b3645ea 100644 --- a/pc4mobx/hrmSalary/pages/socialSecurityBenefits/programme/index.js +++ b/pc4mobx/hrmSalary/pages/socialSecurityBenefits/programme/index.js @@ -2,14 +2,14 @@ import React from 'react'; import { inject, observer } from 'mobx-react'; import { toJS } from 'mobx'; -import { Button, Table, DatePicker, Row, Col, Switch, Modal } from 'antd'; +import { Button, Table, DatePicker, Row, Col, Switch, Modal, Dropdown, Menu } from 'antd'; -import { WeaTop, WeaTab, WeaRightMenu, WeaRangePicker, WeaInputSearch, WeaSlideModal, WeaSelect } from 'ecCom'; +import { WeaTop, WeaTab, WeaRightMenu, WeaRangePicker, WeaInputSearch, WeaSlideModal, WeaSelect, WeaTable } from 'ecCom'; import { WeaTableNew } from "comsMobx" import "./index.less"; -const WeaTable = WeaTableNew.WeaTable; +const WeaMobxTable = WeaTableNew.WeaTable; import { renderNoright, getSearchs } from '../../../util'; // 渲染form数据的方法:因为多个页面都会使用,所以抽的公共方法在util中 import CustomTab from '../../../components/customTab'; @@ -58,11 +58,14 @@ export default class Programme extends React.Component { // 增加编辑功能,重写columns绑定事件 getColumns = (columns) => { - let newColumns = ''; - newColumns = columns.map(column => { + let newColumns = columns.filter(item => item.dataIndex !== "id" && item.dataIndex !== "paymentArea") + newColumns = newColumns.map(column => { let newColumn = column; newColumn.render = (text, record, index) => { //前端元素转义 let valueSpan = record[newColumn.dataIndex + "span"] !== undefined ? record[newColumn.dataIndex + "span"] : record[newColumn.dataIndex]; + if(newColumn.dataIndex == "id") { + newColumn.display = false + } switch(newColumn.dataIndex) { case "operate": return {this.onEdit(record)}}>编辑 @@ -72,6 +75,34 @@ export default class Programme extends React.Component { } return newColumn; }); + + newColumns.push({ + title: "操作", + dataIndex: "operate", + render: (text, record) => { + return {this.onEdit(record)}}>编辑 + } + }) + newColumns.push( + { + title : '', + key: "moreOperate", + dataIndex: "moreOperate", + render: (text, record) => { + return ( + + + { + this.onCopy(record); + }}>复制 + + }> + + + + ); + } + }) return newColumns; } @@ -127,17 +158,6 @@ export default class Programme extends React.Component { }) } - onOperatesClick(record, index, operate, flag) { - switch(operate.text.toString()){ - case '编辑': // 编辑 - this.onEdit(record); - break; - case "复制": // 复制 - this.onCopy(record); - break; - } - } - onCustomOperatesClick(record, index, operate, flag) { switch(operate.text.toString()){ case '编辑': // 编辑 @@ -167,7 +187,7 @@ export default class Programme extends React.Component { const { loading, hasRight, form, condition, tableStore, showSearchAd, getTableDatas, doSearch, setShowSearchAd } = programmeStore; const { selectedKey, setSelectedKey, getCustomCategoryList, customTableStore, customSelectkey, setCustomSelectkey, requestParams, setRequestParams, formCondition, - setCustomNewVisible, customNewVisible } = programmeStore; + setCustomNewVisible, customNewVisible, tableDataSource, tableColumns } = programmeStore; if (!hasRight && !loading) { // 无权限处理 return renderNoright(); } @@ -349,7 +369,7 @@ export default class Programme extends React.Component { selectedKey == "custom" ? : + // + + } diff --git a/pc4mobx/hrmSalary/stores/attendanceStore.js b/pc4mobx/hrmSalary/stores/attendanceStore.js index 6f7e2a8f..13ddfdf7 100644 --- a/pc4mobx/hrmSalary/stores/attendanceStore.js +++ b/pc4mobx/hrmSalary/stores/attendanceStore.js @@ -25,6 +25,10 @@ export class AttendanceStore { requestFeildAttendList = []; // 请求数据 requestFeildCustomList = []; // 请求数据 + // 考勤字段 + @observable fieldDataSource = []; // 字段列表 + @observable fieldTableStore = new TableStore(); // new Table + @observable fieldPageInfo = {}; @action searchFieldSettingList = (value) => { @@ -138,7 +142,9 @@ export class AttendanceStore { this.loading = true; API.getAttendanceFieldList(params).then(res => { if (res.status) { // 接口请求成功/失败处理 - this.tableStore.getDatas(res.data.datas); // table 请求数据 + this.fieldTableStore.getDatas(res.data.dataKey.datas); // table 请求数据 + this.fieldDataSource = res.data.pageInfo.list + this.fieldPageInfo = res.data.pageInfo } else { message.error(res.errormsg || '接口调用失败!') } diff --git a/pc4mobx/hrmSalary/stores/programme.js b/pc4mobx/hrmSalary/stores/programme.js index 35ddd247..a6e48ba9 100644 --- a/pc4mobx/hrmSalary/stores/programme.js +++ b/pc4mobx/hrmSalary/stores/programme.js @@ -25,9 +25,13 @@ export class ProgrammeStore { } @observable form = new WeaForm(); @observable formCondition = []; // 存储后台得到的form数据 - @observable customNewVisible = false; +@observable customNewVisible = false; @observable customRequest = {} + // 福利方案列表 + @observable tableDataSource = []; + @observable tableColumns = []; + @action setCustomRequest = customRequest => this.customRequest = customRequest @@ -89,7 +93,11 @@ export class ProgrammeStore { params.welfareTypeEnum = selectKey API.getTable(params).then(action(res => { if (res.status) { // 接口请求成功/失败处理 - this.tableStore.getDatas(res.data.datas); // table 请求数据 + // this.tableStore.getDatas(res.data.datas); // table 请求数据 + this.tableDataSource = res.data.list ? res.data.list : []; + this.tableColumns = res.data.columns; + console.log("this.tableColumns", this.tableColumns); + console.log("this.tableDataSource", this.tableDataSource); } else { message.error(res.errormsg || '接口调用失败!') } From 08ce3de56426f505c83c2c9ba59ff34a74844313 Mon Sep 17 00:00:00 2001 From: MustangDeng <670124965@qq.com> Date: Fri, 22 Apr 2022 18:12:16 +0800 Subject: [PATCH 2/2] =?UTF-8?q?=E8=B4=A6=E5=A5=97=E5=88=A0=E9=99=A4?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../pages/dataAcquisition/attendance/index.js | 40 ++++++++++++++----- pc4mobx/hrmSalary/pages/ledger/index.js | 2 +- pc4mobx/hrmSalary/stores/attendanceStore.js | 10 ++++- 3 files changed, 40 insertions(+), 12 deletions(-) diff --git a/pc4mobx/hrmSalary/pages/dataAcquisition/attendance/index.js b/pc4mobx/hrmSalary/pages/dataAcquisition/attendance/index.js index f5c2c8f8..7472495f 100644 --- a/pc4mobx/hrmSalary/pages/dataAcquisition/attendance/index.js +++ b/pc4mobx/hrmSalary/pages/dataAcquisition/attendance/index.js @@ -59,6 +59,7 @@ export default class Attendance extends React.Component { fieldCurrent: 1 } this.fieldSearch = {} + this.listSearch = {} } componentWillMount() { @@ -91,17 +92,23 @@ export default class Attendance extends React.Component { // 字段列表分页 handleFieldPageChange(value) { - this.setState({fieldCurrent: value}) const { attendanceStore: {getAttendanceFieldList} } = this.props; this.fieldSearch.current = value getAttendanceFieldList(this.fieldSearch) } + // 列表 + handleDataPageChange(value) { + const { attendanceStore: { getAttendanceList }} = this.props; + this.listSearch.current = value + getAttendanceList(this.listSearch) + } + render() { const { attendanceStore } = this.props; const { loading, hasRight, form, condition, tableStore, showSearchAd, getTableDatas, doSearch, setShowSearchAd } = attendanceStore; const { step, setStep, setSlideVisiable, slideVisiable, doBatchDelete, attendTableStore, fieldSettingAttendList, fieldSettingCustomList, setFieldSettingAttendList, setFieldSettingCustomList, searchFieldSettingList } = attendanceStore; - const { getAttendanceFieldSettingList, saveAttendanceFieldSetting, fieldDataSource, fieldTableStore, fieldPageInfo} = attendanceStore + const { getAttendanceFieldSettingList, saveAttendanceFieldSetting, fieldDataSource, fieldTableStore, fieldPageInfo, attendanceDataSource, attendanceColumns} = attendanceStore const selectedRowKeys = toJS(tableStore.selectedRowKeys) || []; // tableStore 右侧选中数组 if (!hasRight && !loading) { // 无权限处理 @@ -167,20 +174,20 @@ export default class Attendance extends React.Component { this.setState({ startDate: value }) - - getAttendanceList({ + this.listSearch = { salaryYearMonth: [value, this.state.endDate] - }) + } + getAttendanceList(this.listSearch) }} onEndDateChange={(value) => { this.setState({ endDate: value }) - getAttendanceList({ + this.listSearch = { salaryYearMonth: [this.state.startDate, value] - }) - + } + getAttendanceList(this.listSearch) }} /> } @@ -278,7 +285,8 @@ export default class Attendance extends React.Component { this.fieldSearch = {fieldName: this.state.fieldName} getAttendanceFieldList(this.fieldSearch) } else if(v == "0") { - getAttendanceList({}) + this.listSearch = {} + getAttendanceList(this.listSearch) } } @@ -414,6 +422,18 @@ export default class Attendance extends React.Component { // getColumns={this.getColumns} // onOperatesClick={this.onOperatesClick.bind(this)} /> */} + + {this.handleDataPageChange(value)}, + total: attendancePageInfo.total, + current: attendancePageInfo.pageNum + }} + />
:
@@ -444,7 +464,7 @@ export default class Attendance extends React.Component { pagination={{ onChange: (value) => {this.handleFieldPageChange(value)}, total: fieldPageInfo.total, - current: this.state.fieldCurrent + current: fieldPageInfo.pageNum }} /> } diff --git a/pc4mobx/hrmSalary/pages/ledger/index.js b/pc4mobx/hrmSalary/pages/ledger/index.js index ae951f4c..70c80ef0 100644 --- a/pc4mobx/hrmSalary/pages/ledger/index.js +++ b/pc4mobx/hrmSalary/pages/ledger/index.js @@ -135,7 +135,7 @@ export default class Ledger extends React.Component { case "3": // 关联人员 this.handleItemClick(record, 1) case "4": // 删除 - ({ + Modal.confirm({ title: '信息确认', content: '确认删除', onOk:() => { diff --git a/pc4mobx/hrmSalary/stores/attendanceStore.js b/pc4mobx/hrmSalary/stores/attendanceStore.js index 13ddfdf7..ce0073f8 100644 --- a/pc4mobx/hrmSalary/stores/attendanceStore.js +++ b/pc4mobx/hrmSalary/stores/attendanceStore.js @@ -30,6 +30,11 @@ export class AttendanceStore { @observable fieldTableStore = new TableStore(); // new Table @observable fieldPageInfo = {}; + // 考勤数据列表 + @observable attendanceDataSource = []; + @observable attendancePageInfo = {}; + @observable attendanceColumns = []; + @action searchFieldSettingList = (value) => { if(value != "") { @@ -225,7 +230,10 @@ export class AttendanceStore { this.loading = true; API.getAttendanceList(params).then(res => { if (res.status) { // 接口请求成功/失败处理 - this.attendTableStore.getDatas(res.data.datas); // table 请求数据 + // this.attendTableStore.getDatas(res.data.datas); // table 请求数据 + this.attendanceDataSource = res.data.list; + this.attendancePageInfo = res.data; + this.attendanceColumns = res.data.columns } else { message.error(res.errormsg || '接口调用失败!') }