From ae3af8e59e287d3fa7548531d59496d5ef3c27b5 Mon Sep 17 00:00:00 2001 From: liyongshun <971387674@qq.com> Date: Wed, 3 Aug 2022 17:54:47 +0800 Subject: [PATCH] =?UTF-8?q?=E8=96=AA=E8=B5=84=E9=A1=B9=E7=9B=AE=E7=AE=A1?= =?UTF-8?q?=E7=90=86=E9=A1=B5=E9=9D=A2=E6=B7=BB=E5=8A=A0sql=E9=A1=B9?= =?UTF-8?q?=E7=9A=84=E6=95=B0=E6=8D=AE=E6=BA=90=E9=80=89=E9=A1=B9?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- pc4mobx/hrmSalary/apis/item.js | 25 +- .../components/customPaginationTable/index.js | 14 +- .../hrmSalary/components/importModal/index.js | 258 ++++----- .../components/importModal/modalStep1.js | 287 +++++---- .../importModal/acctResultImportModal.js | 334 ++++++----- .../pages/calculateDetail/salaryDetail.js | 54 +- .../pages/salaryItem/formalFormModal.js | 546 ++++++++++-------- pc4mobx/hrmSalary/pages/salaryItem/index.js | 3 - pc4mobx/hrmSalary/pages/salaryItem/index.less | 22 +- pc4mobx/hrmSalary/stores/calculate.js | 32 +- pc4mobx/hrmSalary/stores/salaryItem.js | 32 +- 11 files changed, 850 insertions(+), 757 deletions(-) diff --git a/pc4mobx/hrmSalary/apis/item.js b/pc4mobx/hrmSalary/apis/item.js index 7859e16f..5ad36dbc 100644 --- a/pc4mobx/hrmSalary/apis/item.js +++ b/pc4mobx/hrmSalary/apis/item.js @@ -12,7 +12,7 @@ export const getItemList = params => { mode: 'cors', headers: { 'Content-Type': 'application/json' - }, + }, body: JSON.stringify(params) }).then(res => res.json()) }; @@ -22,6 +22,11 @@ export const getSaCondition = params => { return WeaTools.callApi('/api/bs/hrmsalary/salaryitem/getSearchCondition', 'GET', params); }; +//数据源列表字典项 +export const formulaDatasourceList = params => { + return WeaTools.callApi('/api/bs/hrmsalary/formula/datasource/list', 'GET', params); +}; + //薪资项目-系统薪资项目列表 export const getSysItemList = params => { return fetch('/api/bs/hrmsalary/salaryitem/sysList', { @@ -29,7 +34,7 @@ export const getSysItemList = params => { mode: 'cors', headers: { 'Content-Type': 'application/json' - }, + }, body: JSON.stringify(params) }).then(res => res.json()) }; @@ -46,7 +51,7 @@ export const deleteItem = params => { mode: 'cors', headers: { 'Content-Type': 'application/json' - }, + }, body: JSON.stringify(params) }).then(res => res.json()) } @@ -58,7 +63,7 @@ export const deleteItemList = params => { mode: 'cors', headers: { 'Content-Type': 'application/json' - }, + }, body: JSON.stringify(params) }).then(res => res.json()) } @@ -70,7 +75,7 @@ export const saveItem = params => { mode: 'cors', headers: { 'Content-Type': 'application/json' - }, + }, body: JSON.stringify(params) }).then(res => res.json()) } @@ -92,7 +97,7 @@ export const saveSysItem = params => { mode: 'cors', headers: { 'Content-Type': 'application/json' - }, + }, body: JSON.stringify(params) }).then(res => res.json()) } @@ -110,7 +115,7 @@ export const formualSearchGroup = params => { mode: 'cors', headers: { 'Content-Type': 'application/json' - }, + }, body: JSON.stringify(params) }).then(res => res.json()) } @@ -122,7 +127,7 @@ export const formualSearchField = params => { mode: 'cors', headers: { 'Content-Type': 'application/json' - }, + }, body: JSON.stringify(params) }).then(res => res.json()) } @@ -135,7 +140,7 @@ export const saveFormual = params => { mode: 'cors', headers: { 'Content-Type': 'application/json' - }, + }, body: JSON.stringify(params) }).then(res => res.json()) } @@ -156,7 +161,7 @@ export const listCanDelete = params => { mode: 'cors', headers: { 'Content-Type': 'application/json' - }, + }, body: JSON.stringify(params) }).then(res => res.json()) } diff --git a/pc4mobx/hrmSalary/components/customPaginationTable/index.js b/pc4mobx/hrmSalary/components/customPaginationTable/index.js index b903f388..c7192db2 100644 --- a/pc4mobx/hrmSalary/components/customPaginationTable/index.js +++ b/pc4mobx/hrmSalary/components/customPaginationTable/index.js @@ -1,8 +1,12 @@ -import React from "react"; -import { WeaTable } from "ecCom"; +import React, { PureComponent } from "react"; import CustomTable from "../../components/customTable"; -export default class CustomPaginationTable extends React.Component { +class CustomPaginationTable extends PureComponent { + shouldComponentUpdate(nextProps, nextState, nextContext) { + if (nextProps.columnIndex && this.props.columnIndex !== nextProps.columnIndex) return false; + return true; + } + render() { return ( { this.props.onShowSizeChange && - this.props.onShowSizeChange(current, pageSize); + this.props.onShowSizeChange(current, pageSize); } }} /> ); } } + +export default CustomPaginationTable; diff --git a/pc4mobx/hrmSalary/components/importModal/index.js b/pc4mobx/hrmSalary/components/importModal/index.js index a956edb5..0adb3bcd 100644 --- a/pc4mobx/hrmSalary/components/importModal/index.js +++ b/pc4mobx/hrmSalary/components/importModal/index.js @@ -1,12 +1,12 @@ -import React from 'react'; -import { WeaSteps, WeaDatePicker, WeaInput, WeaSelect } from 'ecCom'; -import { Upload, Icon, Modal, Row, Col, Button, message } from "antd"; -import { inject, observer } from 'mobx-react'; -import { toJS } from 'mobx'; +import React from "react"; +import { WeaSteps } from "ecCom"; +import { message, Modal, Upload } from "antd"; +import { inject, observer } from "mobx-react"; +import { toJS } from "mobx"; -import ModalStep1 from './modalStep1' -import ModalStep2 from './modalStep2' -import ModalStep3 from './modalStep3' +import ModalStep1 from "./modalStep1"; +import ModalStep2 from "./modalStep2"; +import ModalStep3 from "./modalStep3"; const Dragger = Upload.Dragger; @@ -15,127 +15,127 @@ const Step = WeaSteps.Step; @inject("taxAgentStore") @observer export default class ImportModal extends React.Component { - constructor(props) { - super(props) - this.state = { - fileId: "" + constructor(props) { + super(props); + this.state = { + fileId: "" + }; + + this.props.init && this.props.init(); + } + + componentWillMount() { // 初始化渲染页面 + // const { taxAgentStore: {fetchTaxAgentOption} } = this.props; + // fetchTaxAgentOption(); + } + + nextStep() { + const { step } = this.props; + this.props.setStep(step + 1); + } + + preStep() { + const { step } = this.props; + this.props.setStep(step - 1); + } + + validateDate() { + const { params } = this.props; + let flag = true; + try { + params && Object.keys(params).forEach((key) => { + if (!params[key] || params[key] == "") { + message.warning("请完善导入选项"); + throw new Error("请完善导入选项"); + } + }); + } catch (e) { + flag = false; + } + + return flag; + } + + handleStep1Next() { + if (!this.validateDate()) { + return; + } + if (this.state.fileId) { + this.props.setStep(1); + } else { + message.warning("请上传文件"); + } + + } + + handlePreviewDate() { + const { fileId } = this.state; + const { params } = this.props; + this.props.previewImport({ + ...params, + imageId: fileId + }); + } + + hanleImportData() { + const { fileId } = this.state; + const { params } = this.props; + this.props.importFile({ + ...params, + imageId: fileId + }); + } + + render() { + const { step, slideDataSource, isInit } = this.props; + return ( + +
+ + + + + +
+ { + this.props.step == 0 && ( { + this.setState({ fileId }); + }} + onStep1Next={() => { + this.handleStep1Next(); + }}/>) + } + { + this.props.step == 1 && ( this.handlePreviewDate()} + dataSource={slideDataSource} + columns={this.props.columns} + onStep2Next={() => { + this.nextStep(); + this.hanleImportData(); + }} onStep2Pre={() => { + this.preStep(); + }}/>) + } + { + this.props.step == 2 && ( this.hanleImportData()} + importResult={toJS(this.props.importResult)} + onFinish={() => { + this.props.onFinish(); + }}/>) } - this.props.init && this.props.init() - } - - componentWillMount() { // 初始化渲染页面 - // const { taxAgentStore: {fetchTaxAgentOption} } = this.props; - // fetchTaxAgentOption(); - } - - nextStep() { - const { step } = this.props; - this.props.setStep(step + 1) - } - - preStep() { - const { step } = this.props; - this.props.setStep(step - 1); - } - - validateDate() { - const { params } = this.props; - let flag = true - try { - params && Object.keys(params).forEach((key) => { - if(!params[key] || params[key] == "") { - message.warning("请完善导入选项"); - throw new Error("请完善导入选项") - } - }) - } catch(e) { - flag = false - } - - return flag; - } - - handleStep1Next() { - if(!this.validateDate()) { - return - } - if(this.state.fileId) { - this.props.setStep(1) - } else { - message.warning("请上传文件") - } - - } - - handlePreviewDate() { - const { fileId } = this.state; - const { params } = this.props; - this.props.previewImport({ - ...params, - imageId: fileId - }) - } - - hanleImportData() { - const { fileId } = this.state; - const { params } = this.props; - this.props.importFile({ - ...params, - imageId: fileId, - }) - } - - render() { - const { step, slideDataSource, isInit } = this.props; - return ( - -
- - - - - -
- { - this.props.step == 0 && ( { -this.setState({fileId}) -}} - onStep1Next={() => { - this.handleStep1Next(); - }}/>) - } - { - this.props.step == 1 && ( this.handlePreviewDate()} - dataSource={slideDataSource} - columns={this.props.columns} - onStep2Next={() => { - this.nextStep(); - this.hanleImportData() - }} onStep2Pre={() => { -this.preStep() -}}/>) - } - { - this.props.step == 2 && ( this.hanleImportData()} - importResult={toJS(this.props.importResult)} - onFinish={() => { -this.props.onFinish() -}}/>) - } - -
- ) - } +
+ ); + } } diff --git a/pc4mobx/hrmSalary/components/importModal/modalStep1.js b/pc4mobx/hrmSalary/components/importModal/modalStep1.js index e7036926..30d046f6 100644 --- a/pc4mobx/hrmSalary/components/importModal/modalStep1.js +++ b/pc4mobx/hrmSalary/components/importModal/modalStep1.js @@ -1,158 +1,157 @@ -import React from 'react' -import { WeaSteps, WeaDatePicker, WeaInput, WeaSelect, message, WeaCheckbox } from 'ecCom'; -import { inject, observer } from 'mobx-react'; -import { Upload, Icon, Row, Col, Button } from "antd"; -import uploadImg from './upload.svg' +import React from "react"; +import { WeaCheckbox } from "ecCom"; +import { inject, observer } from "mobx-react"; +import { Button, Icon, Upload } from "antd"; const Dragger = Upload.Dragger; @inject("taxAgentStore") @observer export default class ModalStep1 extends React.Component { - constructor(props) { - super(props) - this.state = { - datetime: "", - taxAgentId: "", - hasData: "0", - fileList: [] - } - } + constructor(props) { + super(props); + this.state = { + datetime: "", + taxAgentId: "", + hasData: "0", + fileList: [] + }; + } - componentWillMount() { // 初始化渲染页面 - // const { taxAgentStore: {fetchTaxAgentOption} } = this.props; - // fetchTaxAgentOption(); - } + componentWillMount() { // 初始化渲染页面 + // const { taxAgentStore: {fetchTaxAgentOption} } = this.props; + // fetchTaxAgentOption(); + } - handleChange(info) { - let fileList = info.fileList; + handleChange(info) { + let fileList = info.fileList; - // 1. 上传列表数量的限制 - // 只显示最近上传的一个,旧的会被新的顶掉 - fileList = fileList.slice(-1); - // 2. 读取远程路径并显示链接 - fileList = fileList.map((file) => { - if (file.response) { - // 组件会将 file.url 作为链接进行展示 - file.url = file.response.url; - } - return file; - }); - - // 3. 按照服务器返回信息筛选成功上传的文件 - fileList = fileList.filter((file) => { - if (file.response) { - return file.response.status === 1; - } - return true; - }); - - if(fileList && fileList.length > 0 && fileList[0].response && fileList[0].response.status === 1) { - this.props.onFileIdChange(fileList[0].response.data.fileid) - } - - this.setState({ fileList }); + // 1. 上传列表数量的限制 + // 只显示最近上传的一个,旧的会被新的顶掉 + fileList = fileList.slice(-1); + // 2. 读取远程路径并显示链接 + fileList = fileList.map((file) => { + if (file.response) { + // 组件会将 file.url 作为链接进行展示 + file.url = file.response.url; } + return file; + }); - render() { - const { datetime, taxAgentId, hasData } = this.state - const { taxAgentStore: {taxAgentOption}, isInit } = this.props; - let downloadExtra= ''; - if(isInit){ - downloadExtra= hasData === '1' ? `&hasData=true` : `&hasData=false`; - } - const dragger = { - accept: ".xlsx", - name: 'file', - multiple: false, - action: "/api/doc/upload/uploadFile", //上传地址 - onChange: (info) => { - this.handleChange(info) - }, - }; - return ( -
-
- { - this.props.formComponent &&
-
- 导入选项 -
-
- {this.props.formComponent} -
-
- } + // 3. 按照服务器返回信息筛选成功上传的文件 + fileList = fileList.filter((file) => { + if (file.response) { + return file.response.status === 1; + } + return true; + }); -
-
- 导入Excel -
-
- -
-

- -

-

点击或将文件拖拽到此区域上传

-

支持单个或批量上传,严禁上传公司内部资料及其他违禁文件

-
-
-
- -
- -
-
- 操作步骤 -
- -
-

1. 第一步,请选择导出的Excel文件或 - { - (typeof this.props.templateLink) == "string" ? - 点击这里下载模板 - : - { -this.props.templateLink(hasData === '1' ? `true` : `false`) -}}>点击这里下载模板 - } - - {this.props.headerSetCompoent && this.props.headerSetCompoent }; - { - this.props.isInit && - this.setState({hasData})} - /> - } -

-

2. 第二步,请一定要确定Excel文档中的格式是模板中的格式,没有被修改掉;

-

3. 第三步,选择填写好的Excel文档,点击“下一步”按钮进行数据预览;

-

4. 第四步,如果以上步骤和Excel文档正确的话,数据会被正确导入,导入成功会有提示。如果有问题,则会提示Excel文档的错误之处。

-
- -
- -
-
- Excel文件说明 -
- -
- 1. 后缀名为xls或者xlsx;
- 2. 数据请勿放在合并的单元格中;
-
- -
-
-
- -
-
- ) + if (fileList && fileList.length > 0 && fileList[0].response && fileList[0].response.status === 1) { + this.props.onFileIdChange(fileList[0].response.data.fileid); } + + this.setState({ fileList }); + } + + render() { + const { datetime, taxAgentId, hasData } = this.state; + const { taxAgentStore: { taxAgentOption }, isInit } = this.props; + let downloadExtra = ""; + if (isInit) { + downloadExtra = hasData === "1" ? `&hasData=true` : `&hasData=false`; + } + const dragger = { + accept: ".xlsx", + name: "file", + multiple: false, + action: "/api/doc/upload/uploadFile", //上传地址 + onChange: (info) => { + this.handleChange(info); + } + }; + return ( +
+
+ { + this.props.formComponent &&
+
+ 导入选项 +
+
+ {this.props.formComponent} +
+
+ } + +
+
+ 导入Excel +
+
+ +
+

+ +

+

点击或将文件拖拽到此区域上传

+

支持单个或批量上传,严禁上传公司内部资料及其他违禁文件

+
+
+
+ +
+ +
+
+ 操作步骤 +
+ +
+

1. 第一步,请选择导出的Excel文件或 + { + (typeof this.props.templateLink) == "string" ? + 点击这里下载模板 + : + { + this.props.templateLink(hasData === "1" ? `true` : `false`); + }}>点击这里下载模板 + } + + {this.props.headerSetCompoent && this.props.headerSetCompoent}; + { + this.props.isInit && + this.setState({ hasData })} + /> + } +

+

2. 第二步,请一定要确定Excel文档中的格式是模板中的格式,没有被修改掉;

+

3. 第三步,选择填写好的Excel文档,点击“下一步”按钮进行数据预览;

+

4. 第四步,如果以上步骤和Excel文档正确的话,数据会被正确导入,导入成功会有提示。如果有问题,则会提示Excel文档的错误之处。

+
+ +
+ +
+
+ Excel文件说明 +
+ +
+ 1. 后缀名为xls或者xlsx;
+ 2. 数据请勿放在合并的单元格中;
+
+ +
+
+
+ +
+
+ ); + } } diff --git a/pc4mobx/hrmSalary/pages/calculateDetail/acctResult/importModal/acctResultImportModal.js b/pc4mobx/hrmSalary/pages/calculateDetail/acctResult/importModal/acctResultImportModal.js index fcf3469e..04c3dc23 100644 --- a/pc4mobx/hrmSalary/pages/calculateDetail/acctResult/importModal/acctResultImportModal.js +++ b/pc4mobx/hrmSalary/pages/calculateDetail/acctResult/importModal/acctResultImportModal.js @@ -1,164 +1,180 @@ -import React from 'react' -import ImportModal from '../../../../components/importModal' -import { Button } from 'antd' -import { inject, observer } from 'mobx-react'; -import SelectFieldModal from './selectFieldModal'; +import React from "react"; +import ImportModal from "../../../../components/importModal"; +import { Button, message } from "antd"; +import { inject, observer } from "mobx-react"; +import SelectFieldModal from "./selectFieldModal"; -@inject('calculateStore') +@inject("calculateStore") @observer export default class AcctResultImportModal extends React.Component { - constructor(props) { - super(props) - this.state = { - modalParam: { - salaryAcctRecordId: "", - salaryItemIds: "" - }, - step: 0, - selectFieldVisible: false + constructor(props) { + super(props); + this.state = { + modalParam: { + salaryAcctRecordId: "", + salaryItemIds: "" + }, + step: 0, + selectFieldVisible: false + }; + } + + componentWillMount() { + const { id } = this.props; + let modalParam = { ...this.state.modalParam }; + modalParam.salaryAcctRecordId = id; + this.setState({ + modalParam + }); + } + + // 获取模板 + handleAccResultTemplateLink() { + const { calculateStore: { getImportTemplate } } = this.props; + if (_.isEmpty(this.state.modalParam.salaryItemIds)) { + message.warning("请选择表单字段"); + return; + } + getImportTemplate(this.state.modalParam.salaryItemIds, this.state.modalParam.salaryAcctRecordId); + } + + // 设置步骤 + setStep(step) { + this.setState({ step }); + } + + // 完成 + handleFinish() { + this.setState({ step: 0 }); + this.props.onCancel(); + const { calculateStore: { acctResultList } } = this.props; + acctResultList(this.props.id); + } + + // 关闭 + handleCancel() { + this.setState({ + modalVisiable: false, + step: 0 + }); + } + + + // 渲染第一步表单 + renderFormComponent() { + return ; + } + + // 选择表单字段 + handleSelectedField() { + this.setState({ + selectFieldVisible: true + }); + } + + // 添加表头字段 + handleAdd(fieldDate) { + let salaryItemIdsList = []; + fieldDate.formulaItems.map(item => { + if (item.checked) { + salaryItemIdsList.push(item.salaryItemId); + } + }); + + fieldDate.inputItems.map(item => { + if (item.checked) { + salaryItemIdsList.push(item.salaryItemId); + } + }); + + let salaryItemIds = ""; + if (salaryItemIdsList.length > 0) { + salaryItemIds = salaryItemIdsList.join(","); + } + + let modalParam = { ...this.state.modalParam }; + modalParam.salaryItemIds = salaryItemIds; + this.setState({ + modalParam + }); + this.props.onAdd(fieldDate); + } + + // 初始化Import数据 + handleImportModalInit() { + const { + calculateStore: { + setPreviewAcctResultColumns, + setPreviewAcctResultDataSource, + setImportAcctResult + } + } = this.props; + setPreviewAcctResultColumns([]); + setPreviewAcctResultDataSource([]); + setImportAcctResult({}); + } + + render() { + const { calculateStore } = this.props; + const { + fetchPreviewAcctResult, + previewAcctResultColumns, + previewAcctResultDataSource, + importAcctResult, + fetchImportAcctResult + } = calculateStore; + const { step, selectFieldVisible, modalParam } = this.state; + const { visiable } = this.props; + return ( +
+ { + visiable && { + this.handleImportModalInit(); + }} + params={modalParam} + columns={previewAcctResultColumns} + step={step} + setStep={this.setStep.bind(this)} + slideDataSource={previewAcctResultDataSource} + importResult={importAcctResult} + onFinish={() => { + this.handleFinish(); + }} + previewImport={(params) => { + fetchPreviewAcctResult(params); + }} + importFile={(params) => { + fetchImportAcctResult(params); + }} + templateLink={() => { + this.handleAccResultTemplateLink(); + }} + renderFormComponent={() => this.renderFormComponent()} + visiable={visiable} + onCancel={() => { + this.props.onCancel(); + }} + /> } - } - - componentWillMount() { - const { id } = this.props; - let modalParam = { ...this.state.modalParam } - modalParam.salaryAcctRecordId = id - this.setState({ - modalParam - }) - } - - // 获取模板 - handleAccResultTemplateLink() { - const { calculateStore: { getImportTemplate }} = this.props; - getImportTemplate(this.state.modalParam.salaryItemIds, this.state.modalParam.salaryAcctRecordId) - } - - // 设置步骤 - setStep(step) { - this.setState({step}) - } - - // 完成 - handleFinish() { - this.setState({step: 0}) - this.props.onCancel() - const { calculateStore: { acctResultList } } = this.props; - acctResultList(this.props.id) - } - - // 关闭 - handleCancel() { - this.setState({ - modalVisiable: false, - step: 0 - }) - } - - - // 渲染第一步表单 - renderFormComponent() { - return - } - - // 选择表单字段 - handleSelectedField() { - this.setState({ - selectFieldVisible: true - }) - } - - // 添加表头字段 - handleAdd(fieldDate) { - let salaryItemIdsList = [] - fieldDate.formulaItems.map(item => { - if(item.checked) { - salaryItemIdsList.push(item.salaryItemId) - } - }) - - fieldDate.inputItems.map(item => { - if(item.checked) { - salaryItemIdsList.push(item.salaryItemId) - } - }) - - let salaryItemIds = "" - if(salaryItemIdsList.length > 0) { - salaryItemIds = salaryItemIdsList.join(",") + { + selectFieldVisible && { + this.handleAdd(fieldDate); + }} + onCancel={() => { + this.setState({ + selectFieldVisible: false + }); + }} + /> } - - let modalParam = { ...this.state.modalParam } - modalParam.salaryItemIds = salaryItemIds - this.setState({ - modalParam - }) - this.props.onAdd(fieldDate) - } - - // 初始化Import数据 - handleImportModalInit() { - const { calculateStore: {setPreviewAcctResultColumns, setPreviewAcctResultDataSource, setImportAcctResult}} = this.props; - setPreviewAcctResultColumns([]) - setPreviewAcctResultDataSource([]) - setImportAcctResult({}) - } - - render() { - const { calculateStore } = this.props; - const { fetchPreviewAcctResult, previewAcctResultColumns, previewAcctResultDataSource, importAcctResult, fetchImportAcctResult } = calculateStore - const { step, selectFieldVisible, modalParam } = this.state; - const { visiable } = this.props; - return ( -
- { - visiable && { - this.handleImportModalInit(); - }} - params={modalParam} - columns={previewAcctResultColumns} - step={step} - setStep={this.setStep.bind(this)} - slideDataSource={previewAcctResultDataSource} - importResult={importAcctResult} - onFinish={() => { - this.handleFinish() - }} - previewImport={(params) => { -fetchPreviewAcctResult(params) -}} - importFile={(params) => { -fetchImportAcctResult(params) -}} - templateLink={ () => { - this.handleAccResultTemplateLink() -}} - renderFormComponent={() => this.renderFormComponent()} - visiable={visiable} - onCancel={() => { - this.props.onCancel() -}} - /> - } - { - selectFieldVisible && { - this.handleAdd(fieldDate) - }} - onCancel={() => { - this.setState({ - selectFieldVisible: false - }) - }} - /> - } -
- ) - } -} \ No newline at end of file +
+ ); + } +} diff --git a/pc4mobx/hrmSalary/pages/calculateDetail/salaryDetail.js b/pc4mobx/hrmSalary/pages/calculateDetail/salaryDetail.js index 7661fcc3..6ece09f8 100644 --- a/pc4mobx/hrmSalary/pages/calculateDetail/salaryDetail.js +++ b/pc4mobx/hrmSalary/pages/calculateDetail/salaryDetail.js @@ -1,5 +1,4 @@ import React from "react"; -import { salaryDetailColumns } from "./columns"; import { WeaHelpfulTip, WeaSlideModal } from "ecCom"; import WarningModal from "./warningModal"; import "./index.less"; @@ -7,7 +6,7 @@ import EditSalaryDetail from "./editSalaryDetail"; import SlideModalTitle from "../../components/slideModalTitle"; import { getQueryString } from "../../util/url"; import { inject, observer } from "mobx-react"; -import { toJS } from 'mobx'; +import { toJS } from "mobx"; import CustomPaginationTable from "../../components/customPaginationTable"; @inject("calculateStore", "taxAgentStore") @@ -16,20 +15,10 @@ export default class SalaryDetail extends React.Component { constructor(props) { super(props); this.state = { - columnIndex:"", + columnIndex: "", visible: false, slideVisiable: false, - columns: salaryDetailColumns.map(item => { - if (item.dataIndex == "cz") { - item.render = () => { - return ( - { - this.setState({ slideVisiable: true }); - }}>编辑 - ); - }; - } - }) + columns: [] }; this.recordId = ""; this.id = ""; @@ -40,38 +29,26 @@ export default class SalaryDetail extends React.Component { let id = getQueryString("id"); this.id = id; const { calculateStore: { acctResultList, getSalarySobCycle } } = this.props; - acctResultList({ salaryAcctRecordId: id }); + acctResultList({ salaryAcctRecordId: id }).then(res => { + this.getColumns(res); + }); getSalarySobCycle(id); } - headerSetCompoent() { - return ( -
- - -
- ); - } - // 获取列表的列 - getColumns() { + getColumns = (column) => { const { calculateStore: { acctResultListColumns } } = this.props; - let columns = acctResultListColumns ? [...acctResultListColumns] : []; + let columns = toJS(acctResultListColumns) ? [...toJS(acctResultListColumns)] : [...column]; columns = columns.filter(item => item.hide == "FALSE").map(item => { let result = { ...item }; - result.title = this.setState({columnIndex: item.column})}>{item.text};; + result.title = this.setState({ columnIndex: item.column })}>{item.text}; result.dataIndex = item.column; result.oldWidth = result.width; result.width = "150px"; if (result.children) { result.width = (result.children.length * 150) + "px"; result.children.map(child => { - child.title = this.setState({columnIndex: child.column})}>{child.text}; + child.title = this.setState({ columnIndex: child.column })}>{child.text}; child.dataIndex = child.column; child.width = "150px"; }); @@ -97,8 +74,10 @@ export default class SalaryDetail extends React.Component { }}>编辑; } }); - return columns; - } + this.setState({ + columns + }); + }; // 编辑时间回调 handleEdit(record) { @@ -132,7 +111,7 @@ export default class SalaryDetail extends React.Component { } render() { - const { slideVisiable, columnIndex } = this.state; + const { slideVisiable, columnIndex, columns } = this.state; const { calculateStore, taxAgentStore: { showOperateBtn } } = this.props; const { acctResultListDateSource, @@ -170,9 +149,10 @@ export default class SalaryDetail extends React.Component {
{ - this.setState({ - value: data.formula - }) - this.parameters = data.parameters - this.referenceType = data.referenceType - this.extendParam = data.extendParam - if(this.extendParam && this.extendParam.length > 0) { - this.extendParam.replace("\'", "\"") - let extendParam = {} - try { - extendParam = JSON.parse(this.extendParam) - } catch (ex) { - - } - - this.setState({ - returnValue: extendParam.sqlReturnKey ? extendParam.sqlReturnKey : "" - }) - } - let groupParams = {} - if(this.referenceType == 'sql') { - groupParams = {'referenceType':'sql'} - } - salaryAcctImportTemplateParam(groupParams); - }) - } else { - let groupParams = {} - if(this.props.valueType == "3") { - groupParams = {'referenceType':'sql'} - } - salaryAcctImportTemplateParam(groupParams); - } - } - - // 多行文本编辑 - handleChange(value) { - if(value && value.trim() == "") { - this.parameters = [] - } + componentWillMount() { + const { salaryItemStore } = this.props; + const { salaryAcctImportTemplateParam, setSearchFields, detailFormual } = salaryItemStore; + setSearchFields([]); + if (this.props.formulaId) { + detailFormual(this.props.formulaId).then(data => { this.setState({ - value - }) - console.log("value: ", value); - } + value: data.formula + }); + this.parameters = data.parameters; + this.referenceType = data.referenceType; + this.extendParam = data.extendParam; + if (this.extendParam && this.extendParam.length > 0) { + let extendParam = {}; + try { + extendParam = JSON.parse(this.extendParam); + } catch (ex) { - // 获取光标位置 - getPositionForTextArea(ctrl) { - let CaretPos = { - start:0, - end:0 - }; - if (ctrl.selectionStart) {// Firefox support - CaretPos.start = ctrl.selectionStart; - } - if(ctrl.selectionEnd){ - CaretPos.end = ctrl.selectionEnd - } - return (CaretPos); - } - - - // 分组项被点击 - handleItemClick(item) { - const { salaryItemStore } = this.props; - const { formualSearchField } = salaryItemStore; - this.group = item; - let params = {} - if(this.props.valueType == '3' || this.referenceType == "sql") { - params = { - extendParam: { - 'referenceType':'sql' - } + } + this.setState({ + extendParam: { + sqlReturnKey: extendParam.sqlReturnKey, + datasource:{ + datasourceId: extendParam.datasource ? extendParam.datasource.datasourceId : '', + } } + }); } - formualSearchField(item.key, params) - } - - // 保存 - handleSave() { - const { salaryItemStore } = this.props; - const { saveFormual } = salaryItemStore - this.parameters = this.parameters.filter(item => this.state.value.indexOf(item.name) > -1) - // 去重 - let result = [] - this.parameters.map(item => { - let flag = false; - result.map(i => { - if(item.fieldId == i.fieldId) { - flag = true - } - }) - if(!flag) { - result.push(item) - } - }) - this.parameters = result; - let params = { - name:'公式1', - description:'备注', - module:'salary', - useFor:'salaryitem', - referenceType:'', - returnType:'number', - validateType:'number', - extendParam: this.state.returnValue && this.state.returnValue !== '' ? '{"sqlReturnKey":"'+this.state.returnValue+'"}' : "{}", - formula: this.state.value, - parameters: this.parameters, - referenceType: this.referenceType == "" ? this.props.valueType == "2" ? "formula" : this.props.valueType == "3" ? "sql" : "" : this.referenceType + let groupParams = {}; + if (this.referenceType == "sql") { + groupParams = { "referenceType": "sql" }; } - - saveFormual(params).then(data => { - this.props.onSaveFormal(data) - this.props.onCancel() - }) - } - - /** - * name: 获取文本框光标位置 - * param {*} obj - * param {*} str - * return {*} - */ - insertText = (obj,str) => { - if (document.selection) { - let sel = document.selection.createRange(); - sel.text = str; - } else if (typeof obj.selectionStart === 'number' && typeof obj.selectionEnd === 'number') { - let startPos = obj.selectionStart, - endPos = obj.selectionEnd, - cursorPos = startPos, - tmpStr = obj.value; - obj.value = tmpStr.substring(0, startPos) + str + tmpStr.substring(endPos, tmpStr.length); - cursorPos += str.length; - obj.selectionStart = obj.selectionEnd = cursorPos; - obj.focus(); - this.setState({value: obj.value}) - } else { - obj.value += str; + salaryAcctImportTemplateParam(groupParams); + }); + } else { + let groupParams = {}; + if (this.props.valueType == "3") { + groupParams = { "referenceType": "sql" }; } + salaryAcctImportTemplateParam(groupParams); } + } - // 字段点击回调 - handleFieldClick(item) { - this.field = item; - let fieldName = "{"+this.group.value+"."+this.field.name+"}" - - let parameterItem = { - name: item.name, - fieldId: item.fieldId, - fieldName: fieldName, - fieldType: item.fieldType, - source: item.source, - orderIndex: this.parameters.length + componentDidMount() { + this.formulaDatasourceList(); + } + + formulaDatasourceList = () => { + const { salaryItemStore } = this.props; + const { formulaDatasourceList } = salaryItemStore; + formulaDatasourceList().then(({ status, data }) => { + if (status) { + this.setState({ + formulaDatasourceList: [{ + key: "", + showname: "" + }, ..._.map(data, it => ({ key: it, showname: it }))] + }); + } + }); + + }; + + // 多行文本编辑 + handleChange(value) { + if (value && value.trim() == "") { + this.parameters = []; + } + this.setState({ + value + }); + } + + // 获取光标位置 + getPositionForTextArea(ctrl) { + let CaretPos = { + start: 0, + end: 0 + }; + if (ctrl.selectionStart) {// Firefox support + CaretPos.start = ctrl.selectionStart; + } + if (ctrl.selectionEnd) { + CaretPos.end = ctrl.selectionEnd; + } + return (CaretPos); + } + + + // 分组项被点击 + handleItemClick(item) { + const { salaryItemStore } = this.props; + const { formualSearchField } = salaryItemStore; + this.group = item; + let params = {}; + if (this.props.valueType == "3" || this.referenceType == "sql") { + params = { + extendParam: { + "referenceType": "sql" } - this.parameters.push(parameterItem) - let propsTextarea = this.contentProps.refs.textareaNormal.refs.input.refs.input; // 获取dom节点实例 - let position = this.insertText(propsTextarea,fieldName); // 光标的位置 + }; } + formualSearchField(item.key, params); + } - render() { - const {salaryItemStore} = this.props; - const { searchGroup, searchFields } = salaryItemStore - const { value } = this.state; - return ( - { -this.handleSave() -}}>保存 - } - onCancel={() => { -this.props.onCancel() -}}> - { - (this.props.valueType == "3" || this.referenceType == 'sql') &&
- 返回字段: { -this.setState({returnValue: value}) -}} /> -
- } -
- this.contentProps = input} - minRows={8} - maxRows={8} - value={value} onChange={(value) => this.handleChange(value)} - noResize={true} - style={{fontSize: "14px", lineHeight: 1.2}} - /> -
-
-
-
-
变量
-
- { - searchGroup && searchGroup.map(item => { - return
{ -this.handleItemClick(item) -}}> - {item.value} - - {item.value} 的字段 -
- }) - } -
-
-
-
- { - searchFields && searchFields.map(item => { - return ( -
{ -this.handleFieldClick(item) -}}> - {item.name} -
- ) - }) - } -
-
- -
- ) + // 保存 + handleSave() { + const { salaryItemStore } = this.props; + const { saveFormual } = salaryItemStore; + this.parameters = this.parameters.filter(item => this.state.value.indexOf(item.name) > -1); + // 去重 + let result = []; + this.parameters.map(item => { + let flag = false; + result.map(i => { + if (item.fieldId == i.fieldId) { + flag = true; + } + }); + if (!flag) { + result.push(item); + } + }); + this.parameters = result; + let params = { + name: "公式1", + description: "备注", + module: "salary", + useFor: "salaryitem", + returnType: "number", + validateType: "number", + extendParam: JSON.stringify(this.state.extendParam), + formula: this.state.value, + parameters: this.parameters, + referenceType: this.referenceType == "" ? this.props.valueType == "2" ? "formula" : this.props.valueType == "3" ? "sql" : "" : this.referenceType + }; + saveFormual(params).then(data => { + this.props.onSaveFormal(data); + this.props.onCancel(); + }); + } + + /** + * name: 获取文本框光标位置 + * param {*} obj + * param {*} str + * return {*} + */ + insertText = (obj, str) => { + if (document.selection) { + let sel = document.selection.createRange(); + sel.text = str; + } else if (typeof obj.selectionStart === "number" && typeof obj.selectionEnd === "number") { + let startPos = obj.selectionStart, + endPos = obj.selectionEnd, + cursorPos = startPos, + tmpStr = obj.value; + obj.value = tmpStr.substring(0, startPos) + str + tmpStr.substring(endPos, tmpStr.length); + cursorPos += str.length; + obj.selectionStart = obj.selectionEnd = cursorPos; + obj.focus(); + this.setState({ value: obj.value }); + } else { + obj.value += str; } -} \ No newline at end of file + }; + + // 字段点击回调 + handleFieldClick(item) { + this.field = item; + let fieldName = "{" + this.group.value + "." + this.field.name + "}"; + + let parameterItem = { + name: item.name, + fieldId: item.fieldId, + fieldName: fieldName, + fieldType: item.fieldType, + source: item.source, + orderIndex: this.parameters.length + }; + this.parameters.push(parameterItem); + let propsTextarea = this.contentProps.refs.textareaNormal.refs.input.refs.input; // 获取dom节点实例 + let position = this.insertText(propsTextarea, fieldName); // 光标的位置 + } + + render() { + const { salaryItemStore } = this.props; + const { searchGroup, searchFields } = salaryItemStore; + const { value, formulaDatasourceList, extendParam } = this.state; + return ( + { + this.handleSave(); + }}>保存 + } + onCancel={() => { + this.props.onCancel(); + }}> + { + (this.props.valueType == "3" || this.referenceType == "sql") && + + + + { + this.setState({ extendParam: {...extendParam, sqlReturnKey} }); + }}/> + + + + + { + this.setState({ extendParam: {...extendParam, datasource:{datasourceId}} }); + }} + /> + + + + } +
+ this.contentProps = input} + minRows={8} + maxRows={8} + value={value} onChange={(value) => this.handleChange(value)} + noResize={true} + style={{ fontSize: "14px", lineHeight: 1.2 }} + /> +
+
+
+
+
变量
+
+ { + searchGroup && searchGroup.map(item => { + return
{ + this.handleItemClick(item); + }}> + {item.value} + + {item.value} 的字段 +
; + }) + } +
+
+
+
+ { + searchFields && searchFields.map(item => { + return ( +
{ + this.handleFieldClick(item); + }}> + {item.name} +
+ ); + }) + } +
+
+ +
+ ); + } +} diff --git a/pc4mobx/hrmSalary/pages/salaryItem/index.js b/pc4mobx/hrmSalary/pages/salaryItem/index.js index 4da687e7..c0ee0fe9 100644 --- a/pc4mobx/hrmSalary/pages/salaryItem/index.js +++ b/pc4mobx/hrmSalary/pages/salaryItem/index.js @@ -1,10 +1,7 @@ import React from "react"; import { inject, observer } from "mobx-react"; - import { Button, DatePicker, Dropdown, Menu, Modal, Switch } from "antd"; -// import { WeaTableNew } from "comsMobx" import { WeaInputSearch, WeaRightMenu, WeaSlideModal, WeaTop } from "ecCom"; - import { renderNoright } from "../../util"; // 渲染form数据的方法:因为多个页面都会使用,所以抽的公共方法在util中 import CustomTab from "../../components/customTab"; import SystemSalaryItemModal from "./systemSalaryItemModal"; diff --git a/pc4mobx/hrmSalary/pages/salaryItem/index.less b/pc4mobx/hrmSalary/pages/salaryItem/index.less index be1aef12..cdeefa5c 100644 --- a/pc4mobx/hrmSalary/pages/salaryItem/index.less +++ b/pc4mobx/hrmSalary/pages/salaryItem/index.less @@ -1,6 +1,20 @@ .customSalaryItemSlide { - padding: 20px; - .formItem { - line-height: 40px; + padding: 20px; + + .formItem { + line-height: 40px; + } +} + +.dataList-wrapper { + .wea-select { + width: 100%; + .ant-select{ + width: 100%; + .ant-select-selection{ + border-radius: 0; + height: 30px; + } } -} \ No newline at end of file + } +} diff --git a/pc4mobx/hrmSalary/stores/calculate.js b/pc4mobx/hrmSalary/stores/calculate.js index 36a4318c..292aa2e2 100644 --- a/pc4mobx/hrmSalary/stores/calculate.js +++ b/pc4mobx/hrmSalary/stores/calculate.js @@ -331,20 +331,24 @@ export class calculateStore { delete params[key]; } } - API.acctResultList({ ...params }).then(res => { - if (res.status) { - let list = res.data.pageInfo.list ? res.data.pageInfo.list : []; - list.map(item => { - item.key = item.id; - }); - this.acctResultListDateSource = list; - this.acctResultListPageInfo = res.data.pageInfo; - this.acctResultListColumns = res.data.columns; - this.getColumnDesc({ salaryAcctRecordId: params.salaryAcctRecordId }); - } else { - message.error(res.errormsg || ""); - } - this.loading = false; + return new Promise((resolve,reject) => { + API.acctResultList({ ...params }).then(res => { + if (res.status) { + let list = res.data.pageInfo.list ? res.data.pageInfo.list : []; + list.map(item => { + item.key = item.id; + }); + this.acctResultListDateSource = list; + this.acctResultListPageInfo = res.data.pageInfo; + this.acctResultListColumns = res.data.columns; + this.getColumnDesc({ salaryAcctRecordId: params.salaryAcctRecordId }); + resolve(res.data.columns); + } else { + message.error(res.errormsg || ""); + reject(); + } + this.loading = false; + }); }); }; diff --git a/pc4mobx/hrmSalary/stores/salaryItem.js b/pc4mobx/hrmSalary/stores/salaryItem.js index 07e67a5f..9a50ffa7 100644 --- a/pc4mobx/hrmSalary/stores/salaryItem.js +++ b/pc4mobx/hrmSalary/stores/salaryItem.js @@ -34,11 +34,11 @@ export class SalaryItemStore { @observable tableDataSource = []; // 主列表 @observable tableColumns = []; // 主列表列 @observable pageInfo = {}; // 分页数据 - + // 可以删除的项目 @observable canDeleteList = [] - // ** 公式 ** + // ** 公式 ** // 类型列表 @observable searchGroup = []; // 字段列表 @@ -46,7 +46,7 @@ export class SalaryItemStore { // 公式详情 @observable formulaDetail = {}; - // Modal + // Modal @observable modalLoading = true; // 设置字段列表 @@ -91,7 +91,7 @@ export class SalaryItemStore { @action getTableDatas = (params) => { this.loading = true; - + API.getItemList(params).then(action(res => { if (res.status) { // 接口请求成功/失败处理 this.tableDataSource = res.data.list @@ -103,7 +103,7 @@ export class SalaryItemStore { } this.loading = false; })); - + } @action @@ -114,7 +114,13 @@ export class SalaryItemStore { this.getTableDatas(); this.showSearchAd = false; } - + + // 薪资项目-系统薪资项目列表 + @action + formulaDatasourceList = () => { + return API.formulaDatasourceList(); + } + // 薪资项目-系统薪资项目列表 @action getSysItemList = (params) => { @@ -125,7 +131,7 @@ export class SalaryItemStore { message.error(res.errormsg || '接口调用失败!') } }) - } + } //薪资项目-添加系统薪资项目 @action @@ -194,7 +200,7 @@ export class SalaryItemStore { return } this.deleteItemRequest(ids) - } + } @action deleteItemRequest = (ids) => { @@ -245,9 +251,9 @@ export class SalaryItemStore { //薪资项目-新增薪资项目 @action saveItem = (params, continueFlag, searchParams = {}) => { - + if(!this.validateForm(params)) { - return + return } API.saveItem(params).then(res => { if(res.status) { @@ -262,7 +268,7 @@ export class SalaryItemStore { } }) } - + // 获取公式变量类型 @action salaryAcctImportTemplateParam = (params = {}) => { @@ -301,7 +307,7 @@ export class SalaryItemStore { } }) }) - + } // 根据id获取formual @@ -342,4 +348,4 @@ export class SalaryItemStore { this.modalLoading = false; }) } -} \ No newline at end of file +}