diff --git a/pc4mobx/hrmSalary/apis/taxAgent.js b/pc4mobx/hrmSalary/apis/taxAgent.js index 4debb9a6..6849dae8 100644 --- a/pc4mobx/hrmSalary/apis/taxAgent.js +++ b/pc4mobx/hrmSalary/apis/taxAgent.js @@ -30,7 +30,7 @@ export const deleteTaxAgent = params => { 'Content-Type': 'application/json' }, body: JSON.stringify(params) - }) + }).then(res => res.json()) } //个税扣缴义务人下拉列表 diff --git a/pc4mobx/hrmSalary/apis/taxrate.js b/pc4mobx/hrmSalary/apis/taxrate.js index 4a39ea8d..6be047c0 100644 --- a/pc4mobx/hrmSalary/apis/taxrate.js +++ b/pc4mobx/hrmSalary/apis/taxrate.js @@ -25,7 +25,7 @@ export const saveTaxRate = params => { 'Content-Type': 'application/json' }, body: JSON.stringify(params) - }) + }).then(res => res.json()) } //编辑税率表 diff --git a/pc4mobx/hrmSalary/components/EditTable/index.js b/pc4mobx/hrmSalary/components/EditTable/index.js index a8f1229b..761c519a 100644 --- a/pc4mobx/hrmSalary/components/EditTable/index.js +++ b/pc4mobx/hrmSalary/components/EditTable/index.js @@ -39,7 +39,7 @@ export default class EditableTable extends React.Component { ) } @@ -63,7 +63,7 @@ export default class EditableTable extends React.Component { child.render = (text, record) => ( ) } @@ -73,10 +73,10 @@ export default class EditableTable extends React.Component { }) } - onCellChange = (key, dataIndex) => { + onCellChange = (indexNum, dataIndex) => { return (value) => { const dataSource = [...this.props.dataSource]; - const target = dataSource.find(item => item.key === key); + const target = dataSource.find(item => item.indexNum === indexNum); if (target) { target[dataIndex] = value; this.props.onDataSourceChange(dataSource) diff --git a/pc4mobx/hrmSalary/pages/taxAgent/index.js b/pc4mobx/hrmSalary/pages/taxAgent/index.js index cad4246d..9773056f 100644 --- a/pc4mobx/hrmSalary/pages/taxAgent/index.js +++ b/pc4mobx/hrmSalary/pages/taxAgent/index.js @@ -82,16 +82,6 @@ export default class TaxAgent extends React.Component { } return newColumn; }); - columns.push( - { - title: "操作", - dataIndex: 'operate', - key: 'operate', - render: (text, record) => { - return {this.onEdit(record)}}> - } - } - ) return newColumns; } diff --git a/pc4mobx/hrmSalary/pages/taxRate/columns.js b/pc4mobx/hrmSalary/pages/taxRate/columns.js index 1cad5eb7..46edcae7 100644 --- a/pc4mobx/hrmSalary/pages/taxRate/columns.js +++ b/pc4mobx/hrmSalary/pages/taxRate/columns.js @@ -84,14 +84,14 @@ export const slideColumns = [ children: [ { title: '下限(不含)', - dataIndex: 'taxableIncomeLLimit', - key: 'taxableIncomeLLimit', + dataIndex: 'taxableIncomeLl', + key: 'taxableIncomeLl', editable: true }, { title: '上限(含)', - dataIndex: 'taxableIncomeULimit', - key: 'taxableIncomeULimit', + dataIndex: 'taxableIncomeUl', + key: 'taxableIncomeUl', editable: true }, ], diff --git a/pc4mobx/hrmSalary/pages/taxRate/editSlideContent.js b/pc4mobx/hrmSalary/pages/taxRate/editSlideContent.js index d532664e..47641c3a 100644 --- a/pc4mobx/hrmSalary/pages/taxRate/editSlideContent.js +++ b/pc4mobx/hrmSalary/pages/taxRate/editSlideContent.js @@ -10,8 +10,8 @@ let emptyItem = { incomeUpperLimit: "0.00", dutyFreeValue: "0.00", dutyFreeRate: "0.00", - taxableIncomeLLimit: "0.00", - taxableIncomeULimit: "0.00", + taxableIncomeLl: "0.00", + taxableIncomeUl: "0.00", taxRate: "0.00", taxDeduction: "0.00" } diff --git a/pc4mobx/hrmSalary/pages/taxRate/index.js b/pc4mobx/hrmSalary/pages/taxRate/index.js index d8966827..cec1c81e 100644 --- a/pc4mobx/hrmSalary/pages/taxRate/index.js +++ b/pc4mobx/hrmSalary/pages/taxRate/index.js @@ -35,10 +35,37 @@ export default class TaxRate extends React.Component { doInit(); } + // 增加编辑功能,重写columns绑定事件 + getColumns = (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 "name": + return {this.onEdit(record)}} + dangerouslySetInnerHTML={{ __html: valueSpan }} /> + default: + return
+ } + } + return newColumn; + }); + return newColumns; + } + + onEdit = (record) => { + const {taxRateStore: {setSlideVisiable, emptyForm, getItemInform }} = this.props; + emptyForm(); + setSlideVisiable(true); + getItemInform(record.id) + } + render() { const { taxRateStore } = this.props; const { loading, hasRight, form, condition, tableStore, showSearchAd, getTableDatas, doSearch, setShowSearchAd } = taxRateStore; - const { doSave, slideVisiable, setSlideVisiable } = taxRateStore + const { doSave, slideVisiable, setSlideVisiable, emptyForm } = taxRateStore if (!hasRight && !loading) { // 无权限处理 return renderNoright(); } @@ -69,11 +96,15 @@ export default class TaxRate extends React.Component { const renderSearchOperationItem = () => { return
- + {' '} {doSearch({name})}} + />
@@ -106,12 +137,13 @@ export default class TaxRate extends React.Component { comsWeaTableStore={tableStore} // table store hasOrder={true} // 是否启用排序 needScroll={true} // 是否启用table内部列表滚动,将自适应到父级高度 - + getColumns={this.getColumns} /> - setSlideVisiable(false)} showMask={true} closeMaskOnClick={() => setSlideVisiable(false)} /> + }
) } diff --git a/pc4mobx/hrmSalary/stores/taxRate.js b/pc4mobx/hrmSalary/stores/taxRate.js index 6586327c..e0f3c22b 100644 --- a/pc4mobx/hrmSalary/stores/taxRate.js +++ b/pc4mobx/hrmSalary/stores/taxRate.js @@ -75,7 +75,28 @@ export class taxRateStore { this.showSearchAd = false; this.setSlideVisiable(false); } else { - message.error("保存失败"); + message.warning("保存失败: " + res.errormsg ? res.errormsg: ""); + } + }) + } + + @action emptyForm = () => { + this.setDataSource([]); + this.setNameValue(""); + this.setRemarkValue(""); + } + + // 获取表单数据 + @action getItemInform = (id) => { + API.getTaxRateForm({id}).then(res => { + + if(res.status) { + let { taxRateBatch, taxRateRecords } = res.data.form + this.setNameValue(taxRateBatch.name); + this.setRemarkValue(taxRateBatch.description); + this.setDataSource(taxRateRecords) + } else { + message.error("获取数据失败"); } }) }