diff --git a/pc4mobx/hrmSalary/apis/taxAgent.js b/pc4mobx/hrmSalary/apis/taxAgent.js index 01b094a2..4debb9a6 100644 --- a/pc4mobx/hrmSalary/apis/taxAgent.js +++ b/pc4mobx/hrmSalary/apis/taxAgent.js @@ -1,8 +1,9 @@ import { WeaTools } from 'ecCom'; + //个税扣缴义务人列表 export const getTaxAgentList = params => { - return WeaTools.callApi('/api/bs/hrmsalary/taxAgent/list', 'POST', params); + return WeaTools.callApi('/api/bs/hrmsalary/taxAgent/list', 'GET', params); } //获取个税扣缴义务人表单 @@ -22,7 +23,14 @@ export const updateTaxAgent = params => { //删除个税扣缴义务人 export const deleteTaxAgent = params => { - return WeaTools.callApi('/api/bs/hrmsalary/taxAgent/delete', 'POST', params); + return fetch('/api/bs/hrmsalary/taxAgent/delete', { + method: 'POST', + mode: 'cors', + headers: { + 'Content-Type': 'application/json' + }, + body: JSON.stringify(params) + }) } //个税扣缴义务人下拉列表 diff --git a/pc4mobx/hrmSalary/pages/mySalary/index.js b/pc4mobx/hrmSalary/pages/mySalary/index.js index 5412aa46..71f37656 100644 --- a/pc4mobx/hrmSalary/pages/mySalary/index.js +++ b/pc4mobx/hrmSalary/pages/mySalary/index.js @@ -144,4 +144,4 @@ export default class MySalary extends React.Component { ) } -} +} \ No newline at end of file diff --git a/pc4mobx/hrmSalary/pages/taxAgent/editModal.js b/pc4mobx/hrmSalary/pages/taxAgent/editModal.js index 00158928..0592aab8 100644 --- a/pc4mobx/hrmSalary/pages/taxAgent/editModal.js +++ b/pc4mobx/hrmSalary/pages/taxAgent/editModal.js @@ -1,5 +1,5 @@ import React from 'react' -import { Button, Modal, Row, Col } from 'antd'; +import { Button, Modal, Row, Col, message } from 'antd'; import { WeaTextarea, WeaInput } from "ecCom"; import { logColumns, dataSource } from "../../common/columns" @@ -7,13 +7,44 @@ export default class EditModal extends React.Component { constructor(props) { super(props) this.state = { - value: "" + name: "", + remark: "" } } + + componentWillMount() { // 初始化渲染页面 + this.setState({ + name: this.props.name, + remark: this.props.remark + }) + } + + validate() { + if(this.state.name == "") { + message.warning("个税扣缴义务人名称不能为空"); + return false; + } + return true; + } + + submitAdd() { + if(this.validate) { + this.props.onSubmitAdd({name: this.state.name, description: this.state.remark}) + } + } + + submitUpdate() { + if(this.validate) { + this.props.onSubmitUpdate({id: this.props.currentId, name: this.state.name, description: this.state.remark}) + } + } + render() { return ( alert("ok")} onCancel={this.props.onCancel} + onOk={() => { + this.props.operate == "add" ? this.submitAdd() : this.submitUpdate(); + }} onCancel={this.props.onCancel} > @@ -22,16 +53,10 @@ export default class EditModal extends React.Component { { - console.log(value); - this.setState({ value }); - }} - customBlur={v => { - console.log("custom blur", v); - }} - onFocus={v => console.log("focus", v)} - onBlur={v => console.log("blur", v)} + value={this.state.name} + onChange={(v) => {this.setState({ + name: v + })}} /> @@ -41,7 +66,13 @@ export default class EditModal extends React.Component {
备注:
- { this.setState({ value }) }} /> + { + this.setState({ + remark: v + }) + } + } />
diff --git a/pc4mobx/hrmSalary/pages/taxAgent/index.js b/pc4mobx/hrmSalary/pages/taxAgent/index.js index c871f6ab..cad4246d 100644 --- a/pc4mobx/hrmSalary/pages/taxAgent/index.js +++ b/pc4mobx/hrmSalary/pages/taxAgent/index.js @@ -5,8 +5,11 @@ import { toJS } from 'mobx'; import { Button, Table, DatePicker, Row, Col, Modal, Form, Input } from 'antd'; const { TextArea } = Input; -import { WeaTop, WeaTab, WeaRightMenu, WeaRangePicker, WeaTable, WeaInputSearch, WeaInput, WeaTextarea } from 'ecCom'; +import { WeaTop, WeaTab, WeaRightMenu, WeaRangePicker, WeaInputSearch, WeaInput, WeaTextarea } from 'ecCom'; +import { WeaTableNew } from 'comsMobx'; + +const WeaTable = WeaTableNew.WeaTable; import { renderNoright, getSearchs } from '../../util'; // 渲染form数据的方法:因为多个页面都会使用,所以抽的公共方法在util中 import CustomTab from '../../components/customTab'; import ContentWrapper from '../../components/contentWrapper'; @@ -30,19 +33,87 @@ export default class TaxAgent extends React.Component { selectedKey: "0", searchValue: "", logViewVisiable: false, - modalVisiable: false + modalVisiable: false, + remarkValue: "", + nameValue: "", + title: "新增个税扣缴义务人", + currentOperate: "add", + currentId: "", } } + componentWillMount() { // 初始化渲染页面 + const { taxAgentStore: { doInit } } = this.props; + doInit(); + } + showLogView = () => { this.setState({logViewVisiable: true}) } + onEdit = (record) => { + this.setState({ + remarkValue: record.description, + nameValue: record.name, + title: "编辑个税扣缴义务人", + currentOperate: "update", + currentId: record.id + }) + const {taxAgentStore : { setModalVisiable }} = this.props + setModalVisiable(true) + } + + // 增加编辑功能,重写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 }} /> + case "operate": + return {this.onEdit(record)}}>编辑 + default: + return
+ } + } + return newColumn; + }); + columns.push( + { + title: "操作", + dataIndex: 'operate', + key: 'operate', + render: (text, record) => { + return {this.onEdit(record)}}> + } + } + ) + return newColumns; + } + + onOperatesClick = (record, index, operate, flag) => { + const {taxAgentStore : {doDelete}} = this.props; + switch(operate.index.toString()){ + case '0': // 删除 + Modal.confirm({ + title: "信息确认", + content: "薪资档案中有员工在用该个税扣缴义务人,清空后才可删除", + onOk() { + doDelete([record.id]) + }, + onCancel() {} + }); + } + }; + render() { const { taxAgentStore } = this.props; - const { loading, hasRight, form, tableStore, showSearchAd, getTableDatas, doSearch, setShowSearchAd } = taxAgentStore; - const { modelVisiable, setModelVisiable } = taxAgentStore; - // const { condition } = baseFormStore + const { loading, hasRight, form, tableStore, showSearchAd, getTableDatas, doSearch, setShowSearchAd, doInsert } = taxAgentStore; + const { modalVisiable, setModalVisiable, doUpdate } = taxAgentStore; const topTab = [ ]; @@ -61,26 +132,30 @@ export default class TaxAgent extends React.Component { onClick: this.showLogView }, ]; - const collectParams = { // 收藏功能配置 - favname: '个税扣缴义务人', - favouritetype: 1, - objid: 0, - link: 'wui/index.html#/ns_demo03/index', - importantlevel: 1, - }; - const adBtn = [ // 高级搜索内部按钮 - , - , - , - ]; + + const initEditModal = () => { + this.setState({ + nameValue: '', + remarkValue: "", + title: "新增个税扣缴义务人", + currentOperate: "add" + }) + } + + const showEditModal = () => { + + initEditModal(); + setModalVisiable(true) + } const renderSearchOperationItem = () => { return
- + {' '} doSearch(name)} />
} @@ -113,7 +188,6 @@ export default class TaxAgent extends React.Component { iconBgcolor='#F14A2D' // 左侧图标背景色 showDropIcon={true} // 是否显示下拉按钮 dropMenuDatas={rightMenu} // 下拉菜单(和页面的右键菜单相同) - dropMenuProps={{ collectParams }} // 收藏功能: 配置之后显示 收藏、帮助、显示页面地址 这3个功能 > - + - + {renderTipsLabel()} @@ -135,11 +215,19 @@ export default class TaxAgent extends React.Component { - {this.setState({modalVisiable: false})}} + { + modalVisiable && {setModalVisiable(false)}} + onSubmitAdd={(params) => {doInsert(params)}} + operate={this.state.currentOperate} + onSubmitUpdate={(params) => {doUpdate(params)}} + currentId={this.state.currentId} /> + } this.modalVisiable = visiable; + + @action + setColumns = columns => this.columns = columns; + + @action + setDataSource = dataSource => this.dataSource = dataSource; + // 初始化操作 @action doInit = () => { - this.getCondition(); this.getTableDatas(); } @@ -39,12 +56,12 @@ export class TaxAgentStore { @action getTableDatas = (params) => { this.loading = true; - const formParams = this.form.getFormParams() || {}; - params = params || formParams; - API.getTableDatas(params).then(action(res => { - if (res.api_status) { // 接口请求成功/失败处理 - this.tableStore.getDatas(res.datas); // table 请求数据 - this.hasRight = res.hasRight; + params = params || {}; + API.getTaxAgentList(params).then(action(res => { + if (res.status) { // 接口请求成功/失败处理 + let current = this.tableStore.current || 1; + let sortParams = this.tableStore.sortParams.toJS() || []; + this.tableStore.getDatas(res.data.datas) } else { message.error(res.msg || '接口调用失败!') } @@ -56,9 +73,50 @@ export class TaxAgentStore { setShowSearchAd = bool => this.showSearchAd = bool; // 高级搜索 - 搜索 - @action doSearch = () => { - this.getTableDatas(); + @action doSearch = (name) => { + this.getTableDatas({name}); this.showSearchAd = false; } + // 新增 + @action doInsert = (params) => { + API.saveTaxAgent(params).then(res => { + if(res.status) { + message.success("新增成功"); + this.setModalVisiable(false) + this.getTableDatas(); + this.showSearchAd = false; + } else { + message.error("新增失败"); + } + }) + } + + // 更新 + @action doUpdate = (params) => { + API.updateTaxAgent(params).then(res => { + if(res.status) { + message.success("更新成功"); + this.setModalVisiable(false) + this.getTableDatas(); + this.showSearchAd = false; + } else { + message.error("新增失败"); + } + }) + } + + @action doDelete = (params) => { + API.deleteTaxAgent(params).then(res => { + if(res.status) { + message.success("删除成功"); + this.setModalVisiable(false) + this.getTableDatas(); + this.showSearchAd = false; + } else { + message.error("删除失败"); + } + }) + } + } \ No newline at end of file