From 9c57f58212451512ecfa4e42cbfa08e84dec93ad Mon Sep 17 00:00:00 2001 From: MustangDeng <670124965@qq.com> Date: Tue, 22 Mar 2022 18:53:05 +0800 Subject: [PATCH] =?UTF-8?q?=E8=80=83=E5=8B=A4=E5=AD=97=E6=AE=B5?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- pc4mobx/hrmSalary/apis/attendance.js | 18 ++- .../pages/dataAcquisition/attendance/index.js | 100 +++++++++++---- .../attendance/itemMangeFormModal.js | 115 ++++++++++++------ .../socialSecurityBenefits/programme/index.js | 34 ++++++ pc4mobx/hrmSalary/stores/attendanceStore.js | 25 +++- pc4mobx/hrmSalary/util/index.js | 1 - 6 files changed, 232 insertions(+), 61 deletions(-) diff --git a/pc4mobx/hrmSalary/apis/attendance.js b/pc4mobx/hrmSalary/apis/attendance.js index b36a4b30..85a8f932 100644 --- a/pc4mobx/hrmSalary/apis/attendance.js +++ b/pc4mobx/hrmSalary/apis/attendance.js @@ -52,7 +52,14 @@ export const exportForTemplate = params => { //数据采集-考勤引用-考勤字段管理列表 export const getAttendanceFieldList = params => { - return WeaTools.callApi('/api/bs/hrmsalary/attendQuote/fieldList', 'POST', params); + return fetch('/api/bs/hrmsalary/attendQuote/fieldList', { + method: 'POST', + mode: 'cors', + headers: { + 'Content-Type': 'application/json' + }, + body: JSON.stringify(params) + }).then(res => res.json()) } @@ -63,7 +70,14 @@ export const getAttendanceFieldForm = params => { //数据采集-考勤引用-新建考勤字段 export const saveAttendanceField = params => { - return WeaTools.callApi('/api/bs/hrmsalary/attendQuote/saveField', 'POST', params); + return fetch('/api/bs/hrmsalary/attendQuote/saveField', { + method: 'POST', + mode: 'cors', + headers: { + 'Content-Type': 'application/json' + }, + body: JSON.stringify(params) + }).then(res => res.json()) } //数据采集-考勤引用-修改考勤字段 diff --git a/pc4mobx/hrmSalary/pages/dataAcquisition/attendance/index.js b/pc4mobx/hrmSalary/pages/dataAcquisition/attendance/index.js index de54ca0f..eb1686d2 100644 --- a/pc4mobx/hrmSalary/pages/dataAcquisition/attendance/index.js +++ b/pc4mobx/hrmSalary/pages/dataAcquisition/attendance/index.js @@ -1,10 +1,11 @@ import React from 'react'; import { inject, observer } from 'mobx-react'; import { toJS } from 'mobx'; +import { WeaTableNew } from "comsMobx" -import { Button, Table, DatePicker, Row, Col, Menu, Dropdown } from 'antd'; +import { Button, Table, DatePicker, Row, Col, Menu, Dropdown, Switch } from 'antd'; -import { WeaInputSearch, WeaSlideModal, WeaHelpfulTip, WeaCheckbox, WeaDatePicker, WeaTop, WeaTab, WeaRightMenu, WeaRangePicker, WeaTable, WeaSelect } from 'ecCom'; +import { WeaInputSearch, WeaSlideModal, WeaHelpfulTip, WeaCheckbox, WeaDatePicker, WeaTop, WeaTab, WeaRightMenu, WeaRangePicker, WeaSelect } from 'ecCom'; import { renderNoright, getSearchs } from '../../../util'; // 渲染form数据的方法:因为多个页面都会使用,所以抽的公共方法在util中 import CustomTab from '../../../components/customTab'; @@ -25,11 +26,23 @@ import ItemMangeFormModal from './itemMangeFormModal' const { MonthPicker } = DatePicker; +const WeaTable = WeaTableNew.WeaTable; + @inject('attendanceStore') @observer export default class Attendance extends React.Component { constructor(props) { super(props); + columns.map(item => { + if(item.key == "cz") { + item.render = (text, record) => { + return (
+ this.onShowSlide()}>查看 + this.onDelete()} style={{marginLeft: "10px"}}>删除 +
) + } + } + }) this.state = { value: "", selectedKey: "0", @@ -40,17 +53,7 @@ export default class Attendance extends React.Component { selectItemVisible: false, refereAttendFormVisible: false, tabSelectedKey: "0", - itemMangeVisible: false, - columns: columns.map(item => { - if(item.key == "cz") { - item.render = (text, record) => { - return (
- this.onShowSlide()}>查看 - this.onDelete()} style={{marginLeft: "10px"}}>删除 -
) - } - } - }) + itemMangeVisible: false } } @@ -181,6 +184,50 @@ export default class Attendance extends React.Component { ); + const handleTabChange = (v) => { + const { attendanceStore: { getAttendanceFieldList }} = this.props; + this.setState({ + tabSelectedKey: v + }) + + if(v == "1") { + getAttendanceFieldList({}) + } + } + + // 字段Columns + const getFieldColumns = (columns) => { + let newColumns = ''; + newColumns = columns.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)}} + dangerouslySetInnerHTML={{ __html: valueSpan }} /> + case "enableStatus": + return + case "operate": + return {this.onEdit(record)}}>查看明细 + default: + return
+ } + } + return newColumn; + }); + return newColumns; + } + + // 保存回调 + const handleItemMangeSave = (value) => { + const { attendanceStore: { saveAttendanceField, getAttendanceFieldList }} = this.props; + value.fieldType = value.fieldType == "1" ? "NUMBER" : "TEXT" + saveAttendanceField(value) + getAttendanceFieldList({}) + } + + return (
{ - this.setState({ - tabSelectedKey: v - }) + handleTabChange(v) }} /> - +
:
@@ -233,7 +285,14 @@ export default class Attendance extends React.Component { /> + } rightContent={ this.setState({refereAttendFormVisible: false})}/> - {this.setState({itemMangeVisible: false})}}/> + handleItemMangeSave(value)} onCancel={() => {this.setState({itemMangeVisible: false})}}/> { slideVisiable && setSlideVisiable(false)} /> }
- - - ) } } diff --git a/pc4mobx/hrmSalary/pages/dataAcquisition/attendance/itemMangeFormModal.js b/pc4mobx/hrmSalary/pages/dataAcquisition/attendance/itemMangeFormModal.js index a526c734..399e32bd 100644 --- a/pc4mobx/hrmSalary/pages/dataAcquisition/attendance/itemMangeFormModal.js +++ b/pc4mobx/hrmSalary/pages/dataAcquisition/attendance/itemMangeFormModal.js @@ -1,48 +1,93 @@ import React from 'react' -import { Modal, Row, Col, Button,Switch } from 'antd' +import { Modal, Row, Col, Button,Switch, Select } from 'antd' import { WeaInput, WeaSelect } from 'ecCom' import SelectItemModal, { items } from '../../../components/selectItemsModal/selectItemsWrapper'; export default class ItemMangeFormModal extends React.Component { + constructor(props) { + super(props) + this.state = { + request: { + fieldName: "", + fieldType: "1", + enableStatus: 0, + description: '' + } + } + } + + handleChange(params) { + const { request } = this.state + let result = {...request, ...params} + this.setState({request: result}) + } + render() { + const options = [ + { + key: "1", + selected: true, + showname: "数值" + }, + { + key: "2", + selected: false, + showname: "文本" + } + ] + const { request } = this.state; + const {fieldName, fieldType, enableStatus, description} = request return ( - 保存 + }> - - - 字段名称 - - - - - - - - 类型 - - - - - - - - 是否启用 - - - - - - - - 备注 - - - - - +
+ + + 字段名称 + + + {this.handleChange({fieldName: v})}}/> + + + + + 类型 + + + this.handleChange({fieldType: v})} + /> + + + + + 是否启用 + + + { + let enableStatus = 0 + if(value) { + enableStatus = 1 + } + this.handleChange({enableStatus}) + }}/> + + + + + 备注 + + + { + this.handleChange({description: v}) + }}/> + + +
+
) } diff --git a/pc4mobx/hrmSalary/pages/socialSecurityBenefits/programme/index.js b/pc4mobx/hrmSalary/pages/socialSecurityBenefits/programme/index.js index 3461ee76..54da9821 100644 --- a/pc4mobx/hrmSalary/pages/socialSecurityBenefits/programme/index.js +++ b/pc4mobx/hrmSalary/pages/socialSecurityBenefits/programme/index.js @@ -73,6 +73,24 @@ export default class Programme extends React.Component { return newColumns; } + getCustomColumns = (columns) => { + let newColumns = ''; + newColumns = columns.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 "operate": + return {this.onCustomEdit(record)}}>编辑 + default: + return
+ } + } + return newColumn; + }); + return newColumns; + } + onEdit(record) { let id = record.id; const { programmeStore } = this.props @@ -102,6 +120,20 @@ export default class Programme extends React.Component { } } + onCustomOperatesClick(record, index, operate, flag) { + switch(operate.text.toString()){ + case '编辑': // 编辑 + this.onCustomEdit(record); + break; + } + } + + onCustomEdit(record) { + this.setState({customNewVisible: true}) + const { programmeStore: {getCustomForm}} = this.props; + getCustomForm({id: record.id}) + } + render() { const { programmeStore } = this.props; const { loading, hasRight, form, condition, tableStore, showSearchAd, getTableDatas, doSearch, setShowSearchAd } = programmeStore; @@ -278,6 +310,8 @@ export default class Programme extends React.Component { comsWeaTableStore={tableStore} // table store hasOrder={true} // 是否启用排序 needScroll={true} // 是否启用table内部列表滚动,将自适应到父级高度 + getColumns={this.getCustomColumns} + onOperatesClick={this.onCustomOperatesClick.bind(this)} /> } rightContent={ diff --git a/pc4mobx/hrmSalary/stores/attendanceStore.js b/pc4mobx/hrmSalary/stores/attendanceStore.js index 7440f909..46a22503 100644 --- a/pc4mobx/hrmSalary/stores/attendanceStore.js +++ b/pc4mobx/hrmSalary/stores/attendanceStore.js @@ -2,7 +2,7 @@ import { observable, action, toJS } from 'mobx'; import { message } from 'antd'; import { WeaForm, WeaTableNew } from 'comsMobx'; -import * as API from '../apis'; // 引入API接口文件 +import * as API from '../apis/attendance'; // 引入API接口文件 const { TableStore } = WeaTableNew; @@ -72,4 +72,27 @@ export class AttendanceStore { this.showSearchAd = false; } + // 字段列表 + @action getAttendanceFieldList = (params) => { + this.loading = true; + API.getAttendanceFieldList(params).then(res => { + if (res.status) { // 接口请求成功/失败处理 + this.tableStore.getDatas(res.data.datas); // table 请求数据 + } else { + message.error(res.msg || '接口调用失败!') + } + this.loading = false; + }) + } + + @action saveAttendanceField = (params) => { + API.saveAttendanceField(params).then(res => { + if(res.status) { + message.success("保存成功") + } else { + message.error("保存失败") + } + }) + } + } \ No newline at end of file diff --git a/pc4mobx/hrmSalary/util/index.js b/pc4mobx/hrmSalary/util/index.js index f1a8f4c9..6bd93f85 100644 --- a/pc4mobx/hrmSalary/util/index.js +++ b/pc4mobx/hrmSalary/util/index.js @@ -51,7 +51,6 @@ export const getSearchs = (form, condition, col, isCenter) => { const { isFormInit } = form; const formParams = form.getFormParams(); let group = []; - alert("isFormInit: " + isFormInit) isFormInit && condition && condition.map(c =>{ let items = []; c.items.map(fields => {