错误提示

This commit is contained in:
MustangDeng 2022-03-23 19:38:10 +08:00
parent ddbedca83b
commit c84976ce58
11 changed files with 208 additions and 39 deletions

View File

@ -2,7 +2,14 @@ import { WeaTools } from 'ecCom';
//薪资帐套列表
export const getLedgerList = params => {
return WeaTools.callApi('/api/bs/hrmsalary/salarysob/list', 'get', params);
return fetch('/api/bs/hrmsalary/salarysob/list', {
method: 'POST',
mode: 'cors',
headers: {
'Content-Type': 'application/json'
},
body: JSON.stringify(params)
}).then(res => res.json())
}
//启用/禁用薪资帐套
@ -12,7 +19,14 @@ export const changeLedgerStatus = params => {
//复制薪资帐套
export const duplicateLedger = params => {
return WeaTools.callApi('/api/bs/hrmsalary/salarysob/duplicate', 'POST', params);
return fetch('/api/bs/hrmsalary/salarysob/duplicate', {
method: 'POST',
mode: 'cors',
headers: {
'Content-Type': 'application/json'
},
body: JSON.stringify(params)
}).then(res => res.json())
}

View File

@ -1,4 +1,5 @@
import { WeaTools } from 'ecCom';
import { formPost } from '../util/request';
//个税扣缴义务人列表
@ -13,12 +14,13 @@ export const getTaxAgentForm = params => {
//新建个税扣缴义务人
export const saveTaxAgent = params => {
return WeaTools.callApi('/api/bs/hrmsalary/taxAgent/save', 'POST', params);
return formPost('/api/bs/hrmsalary/taxAgent/save', params)
// return WeaTools.callApi('/api/bs/hrmsalary/taxAgent/save', 'POST', params);
}
//编辑个税扣缴义务人
export const updateTaxAgent = params => {
return WeaTools.callApi('/api/bs/hrmsalary/taxAgent/update', 'POST', params);
return formPost('/api/bs/hrmsalary/taxAgent/update', params)
}
//删除个税扣缴义务人

View File

@ -3,6 +3,12 @@ import { Modal, Button, Row, Col } from 'antd'
import { WeaInput } from 'ecCom'
export default class CopyFormModal extends React.Component {
constructor(props) {
super(props)
this.state = {
name: ""
}
}
render() {
return (
<Modal
@ -10,12 +16,12 @@ export default class CopyFormModal extends React.Component {
visible={this.props.visible}
title="复制账套"
onCancel={() => this.props.onCancel()}
footer={<Button type="primary">保存</Button>}
footer={<Button type="primary" onClick={() => {this.props.onSave(this.state.name)}}>保存</Button>}
>
<Row>
<Col span={6}>账套名称</Col>
<Col span={18}>
<WeaInput style={{width: "200px"}}/>
<WeaInput style={{width: "200px"}} value={this.state.name} onChange={(value) => {this.setState({name: value})}} />
</Col>
</Row>
</Modal>

View File

@ -2,10 +2,10 @@ import React from 'react';
import { inject, observer } from 'mobx-react';
import { toJS } from 'mobx';
import { Button, Table, DatePicker } from 'antd';
import { WeaTop, WeaTab, WeaRightMenu, WeaRangePicker, WeaTable, WeaInputSearch, WeaSlideModal } from 'ecCom';
import { Button, Table, DatePicker, Switch } from 'antd';
import { WeaTop, WeaTab, WeaRightMenu, WeaRangePicker, WeaInputSearch, WeaSlideModal } from 'ecCom';
import { WeaTableNew } from "comsMobx"
import { renderNoright, getSearchs } from '../../util'; // 渲染form数据的方法因为多个页面都会使用所以抽的公共方法在util中
import CustomTab from '../../components/customTab';
import ContentWrapper from '../../components/contentWrapper';
@ -22,7 +22,9 @@ import CopyFormModal from './copyFormModal'
const { MonthPicker } = DatePicker;
@inject('baseTableStore')
const WeaTable = WeaTableNew.WeaTable;
@inject('ledgerStore')
@observer
export default class Ledger extends React.Component {
constructor(props) {
@ -35,6 +37,7 @@ export default class Ledger extends React.Component {
copyFormVisible: false,
currentStep: 4,
selectedTab: 0,
currentReocrd: {},
columns: columns.map(item => {
if(item.dataIndex == "cz") {
item.render = () => <div>
@ -61,9 +64,52 @@ export default class Ledger extends React.Component {
editSlideVisible: true
})
}
componentWillMount() {
const { ledgerStore : {doInit}} = this.props;
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 "disable":
return <Switch checked={text == 0}/>
default:
return <div dangerouslySetInnerHTML={{ __html: valueSpan }} />
}
}
return newColumn;
});
return newColumns;
}
onOperatesClick = (record, index, operate, flag) => {
switch(operate.index.toString()){
case '1': // 复制
this.setState({
copyFormVisible: true,
currentReocrd: record
})
break;
}
};
handleCopySave = (value) => {
const { ledgerStore: { doCopy}} = this.props
doCopy(this.state.currentReocrd.id, value)
}
render() {
const { baseTableStore } = this.props;
const { loading, hasRight, form, condition, tableStore, showSearchAd, getTableDatas, doSearch, setShowSearchAd } = baseTableStore;
const { ledgerStore } = this.props;
const { loading, hasRight, form, condition, tableStore, showSearchAd, getTableDatas, doSearch, setShowSearchAd } = ledgerStore;
const { currentStep, selectedTab } = this.state;
if (!hasRight && !loading) { // 无权限处理
return renderNoright();
@ -134,7 +180,6 @@ export default class Ledger extends React.Component {
dropMenuDatas={rightMenu} // 下拉菜单(和页面的右键菜单相同)
dropMenuProps={{ collectParams }} // 收藏功能: 配置之后显示 收藏、帮助、显示页面地址 这3个功能
>
<CustomTab
searchOperationItem={
renderRightOperation()
@ -143,7 +188,14 @@ export default class Ledger extends React.Component {
}}
/>
<WeaTable columns={columns} dataSource={dataSource}/>
<WeaTable // table内部做了loading加载处理页面就不需要再加了
comsWeaTableStore={tableStore} // table store
hasOrder={true} // 是否启用排序
needScroll={true} // 是否启用table内部列表滚动将自适应到父级高度
getColumns={this.getColumns}
onOperatesClick={this.onOperatesClick.bind(this)}
/>
{
this.state.stepSlideVisible && <StepSlide
visible={this.state.stepSlideVisible}
@ -241,7 +293,6 @@ export default class Ledger extends React.Component {
</div>}
onClose={() => this.setState({editSlideVisible: false})}
showMask={true}
closeMaskOnClick={() => this.setState({editSlideVisible: false})} />
}
@ -252,6 +303,7 @@ export default class Ledger extends React.Component {
this.state.copyFormVisible &&
<CopyFormModal
visible={this.state.copyFormVisible}
onSave={(value) => this.handleCopySave(value)}
onCancel={() => {this.setState({copyFormVisible: false})}}
/>
}

View File

@ -102,7 +102,7 @@ export class AttendanceStore {
this.condition = res.condition;
this.form.initFormFields(res.condition); // 渲染高级搜索form表单
} else {
message.error(res.msg || '接口调用失败!')
message.error(res.errormsg || '接口调用失败!')
}
}));
}
@ -118,7 +118,7 @@ export class AttendanceStore {
this.tableStore.getDatas(res.datas); // table 请求数据
this.hasRight = res.hasRight;
} else {
message.error(res.msg || '接口调用失败!')
message.error(res.errormsg || '接口调用失败!')
}
this.loading = false;
}));
@ -140,7 +140,7 @@ export class AttendanceStore {
if (res.status) { // 接口请求成功/失败处理
this.tableStore.getDatas(res.data.datas); // table 请求数据
} else {
message.error(res.msg || '接口调用失败!')
message.error(res.errormsg || '接口调用失败!')
}
this.loading = false;
})
@ -151,7 +151,7 @@ export class AttendanceStore {
if(res.status) {
message.success("保存成功")
} else {
message.error("保存失败")
message.error(res.errormsg ||"保存失败")
}
})
}
@ -161,7 +161,7 @@ export class AttendanceStore {
if(res.status) {
message.success("删除成功")
} else {
message.error("删除失败")
message.error(res.errormsg ||"删除失败")
}
})
}
@ -178,7 +178,7 @@ export class AttendanceStore {
if(res.status) {
message.success("删除成功")
} else {
message.error("删除失败")
message.error(res.errormsg || "删除失败")
}
})
}
@ -190,7 +190,7 @@ export class AttendanceStore {
if(res.status) {
message.success("修改成功")
} else {
message.error("修改失败")
message.error(res.errormsg || "修改失败")
}
})
}
@ -205,7 +205,7 @@ export class AttendanceStore {
resolve(true);
})
} else {
message.error("修改失败")
message.error( res.errormsg || "修改失败")
return new Promise((resolve, reject) => {
resolve(false);
})
@ -221,7 +221,7 @@ export class AttendanceStore {
if (res.status) { // 接口请求成功/失败处理
this.attendTableStore.getDatas(res.data.datas); // table 请求数据
} else {
message.error(res.msg || '接口调用失败!')
message.error(res.errormsg || '接口调用失败!')
}
this.loading = false;
})
@ -238,7 +238,7 @@ export class AttendanceStore {
this.requestFeildCustomList = res.data[1] ? res.data[1].items : []
this.fieldSettingCustomList = this.requestFeildCustomList;
} else {
message.error(res.msg || "接口调用失败!")
message.error(res.errormsg || "接口调用失败!")
}
this.loading = false;
})
@ -258,7 +258,7 @@ export class AttendanceStore {
if(res.status) {
message.success("保存成功")
} else {
message.error("保存失败")
message.error(res.errormsg || "保存失败")
}
})
}
@ -274,7 +274,7 @@ export class AttendanceStore {
this.requestFeildCustomList = res.data[1] ? res.data[1].items : []
this.fieldSettingCustomList = this.requestFeildCustomList;
} else {
message.error("获取数据失败")
message.error(res.errormsg || "获取数据失败")
}
})
}
@ -293,7 +293,7 @@ export class AttendanceStore {
if(res.status) {
message.success("设置成功")
} else {
message.error("设置失败")
message.error( res.errormsg || "设置失败")
}
})
}

View File

@ -10,6 +10,7 @@ import { CumSituationStore } from './cumSituation'
import { ProgrammeStore } from './programme'
import { AttendanceStore } from './attendanceStore';
import { SalaryItemStore } from './salaryItem'
import { LedgerStore } from './ledger'
module.exports = {
baseFormStore: new BaseFormStore(),
@ -22,6 +23,7 @@ module.exports = {
cumSituationStore: new CumSituationStore(),
programmeStore: new ProgrammeStore(),
attendanceStore: new AttendanceStore(),
salaryItemStore: new SalaryItemStore()
salaryItemStore: new SalaryItemStore(),
ledgerStore: new LedgerStore()
};

View File

@ -0,0 +1,72 @@
import { observable, action, toJS } from 'mobx';
import { message } from 'antd';
import { WeaForm, WeaTableNew } from 'comsMobx';
import * as API from '../apis/ledger'; // 引入API接口文件
const { TableStore } = WeaTableNew;
export class LedgerStore {
@observable tableStore = new TableStore(); // new table
@observable form = new WeaForm(); // nrew 一个form
@observable condition = []; // 存储后台得到的form数据
@observable hasRight = true; // 判断用户是有权限查看当前页面: 没有权限渲染无权限页面,有权限渲染数据
@observable showSearchAd = false; // 高级搜索面板显示
@observable loading = true; // 数据加载状态
// 初始化操作
@action
doInit = () => {
// this.getCondition();
this.getTableDatas({});
}
// 获得高级搜索表单数据
@action
getCondition = () => {
API.getCondition().then(action(res => {
if (res.api_status) { // 接口请求成功/失败处理
this.condition = res.condition;
this.form.initFormFields(res.condition); // 渲染高级搜索form表单
} else {
message.error(res.msg || '接口调用失败!')
}
}));
}
// 渲染table数据
@action
getTableDatas = (params) => {
this.loading = true;
API.getLedgerList(params).then(action(res => {
if (res.status) { // 接口请求成功/失败处理
this.tableStore.getDatas(res.data.datas); // table 请求数据
} else {
message.error(res.msg || '接口调用失败!')
}
this.loading = false;
}));
}
@action
setShowSearchAd = bool => this.showSearchAd = bool;
// 高级搜索 - 搜索
@action doSearch = () => {
this.getTableDatas();
this.showSearchAd = false;
}
// 复制
@action doCopy = (id, name) => {
API.duplicateLedger({id, name}).then(res => {
if(res.status) {
message.success("复制成功")
this.getTableDatas({});
} else {
message.error("复制失败")
}
})
}
}

View File

@ -71,7 +71,7 @@ export class ProgrammeStore {
if (res.status) { // 接口请求成功/失败处理
this.tableStore.getDatas(res.data.datas); // table 请求数据
} else {
message.error(res.msg || '接口调用失败!')
message.error(res.errormsg || '接口调用失败!')
}
this.loading = false;
}));
@ -89,7 +89,7 @@ export class ProgrammeStore {
if (res.status) { // 接口请求成功/失败处理
this.tableStore.getDatas(res.data.datas); // table 请求数据
} else {
message.error(res.msg || '接口调用失败!')
message.error(res.errormsg || '接口调用失败!')
}
this.loading = false;
}));
@ -127,6 +127,8 @@ export class ProgrammeStore {
if(res.status) {
message.success("新建成功");
this.getTableDatas();
} else {
message.error(res.errormsg || "新建失败")
}
})
}
@ -136,6 +138,8 @@ export class ProgrammeStore {
if(res.status) {
message.success("更新成功");
this.getTableDatas(this.selectedKey);
} else {
message.error(res.errormsg || "更新失败")
}
})
}
@ -145,6 +149,8 @@ export class ProgrammeStore {
if(res.status) {
message.success("复制成功")
this.getTableDatas(this.selectedKey);
} else {
message.error(res.errormsg || "复制失败")
}
})
}
@ -158,6 +164,8 @@ export class ProgrammeStore {
})
let fieldCondtion = items
this.formCondition = fieldCondtion;
} else {
message.error(res.errormsg || "获取失败")
}
})
}

View File

@ -87,7 +87,7 @@ export class TaxAgentStore {
this.getTableDatas();
this.showSearchAd = false;
} else {
message.error("新增失败");
message.error( res.errormsg || "新增失败");
}
})
}
@ -101,7 +101,7 @@ export class TaxAgentStore {
this.getTableDatas();
this.showSearchAd = false;
} else {
message.error("新增失败");
message.error(res.errormsg || "新增失败");
}
})
}
@ -114,7 +114,7 @@ export class TaxAgentStore {
this.getTableDatas();
this.showSearchAd = false;
} else {
message.error("删除失败");
message.error( res.errormsg || "删除失败");
}
})
}

View File

@ -46,7 +46,7 @@ export class taxRateStore {
if (res.status) { // 接口请求成功/失败处理
this.tableStore.getDatas(res.data.datas); // table 请求数据
} else {
message.error(res.msg || '接口调用失败!')
message.error(res.errormsg || '接口调用失败!')
}
this.loading = false;
}));
@ -77,7 +77,7 @@ export class taxRateStore {
this.showSearchAd = false;
this.setSlideVisiable(false);
} else {
message.warning("保存失败: " + res.errormsg ? res.errormsg: "");
message.error(res.errormsg || "保存失败");
}
})
}
@ -98,7 +98,7 @@ export class taxRateStore {
this.setRemarkValue(taxRateBatch.description);
this.setDataSource(taxRateRecords)
} else {
message.error("获取数据失败");
message.error(res.errormsg || "获取数据失败");
}
})
}
@ -119,7 +119,7 @@ export class taxRateStore {
this.showSearchAd = false;
this.setSlideVisiable(false);
} else {
message.warning("保存失败: " + res.errormsg ? res.errormsg: "");
message.error(res.errormsg || "保存失败");
}
})
}
@ -131,7 +131,7 @@ export class taxRateStore {
this.getTableDatas();
this.showSearchAd = false;
} else {
message.warning("删除失败: " + res.errormsg ? res.errormsg: "");
message.error("删除失败: " + res.errormsg ? res.errormsg: "");
}
})
}

View File

@ -0,0 +1,13 @@
export const formPost = (url, params) => {
let formdata = new URLSearchParams();
Object.keys(params).map(key => {
formdata.append(key, params[key])
})
return fetch(url, {
method:"POST",
headers:{
"Content-Type":'application/x-www-form-urlencoded'
},
body:formdata
}).then(res => res.json())
}