From c84976ce586d593f98588863145bfb48bf91388a Mon Sep 17 00:00:00 2001
From: MustangDeng <670124965@qq.com>
Date: Wed, 23 Mar 2022 19:38:10 +0800
Subject: [PATCH] =?UTF-8?q?=E9=94=99=E8=AF=AF=E6=8F=90=E7=A4=BA?=
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit
---
pc4mobx/hrmSalary/apis/ledger.js | 18 ++++-
pc4mobx/hrmSalary/apis/taxAgent.js | 6 +-
.../hrmSalary/pages/ledger/copyFormModal.js | 10 ++-
pc4mobx/hrmSalary/pages/ledger/index.js | 70 +++++++++++++++---
pc4mobx/hrmSalary/stores/attendanceStore.js | 26 +++----
pc4mobx/hrmSalary/stores/index.js | 4 +-
pc4mobx/hrmSalary/stores/ledger.js | 72 +++++++++++++++++++
pc4mobx/hrmSalary/stores/programme.js | 12 +++-
pc4mobx/hrmSalary/stores/taxAgent.js | 6 +-
pc4mobx/hrmSalary/stores/taxRate.js | 10 +--
pc4mobx/hrmSalary/util/request.js | 13 ++++
11 files changed, 208 insertions(+), 39 deletions(-)
create mode 100644 pc4mobx/hrmSalary/stores/ledger.js
create mode 100644 pc4mobx/hrmSalary/util/request.js
diff --git a/pc4mobx/hrmSalary/apis/ledger.js b/pc4mobx/hrmSalary/apis/ledger.js
index 849e31fc..1a24ff6c 100644
--- a/pc4mobx/hrmSalary/apis/ledger.js
+++ b/pc4mobx/hrmSalary/apis/ledger.js
@@ -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())
}
diff --git a/pc4mobx/hrmSalary/apis/taxAgent.js b/pc4mobx/hrmSalary/apis/taxAgent.js
index b475c216..3b2fda39 100644
--- a/pc4mobx/hrmSalary/apis/taxAgent.js
+++ b/pc4mobx/hrmSalary/apis/taxAgent.js
@@ -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)
}
//删除个税扣缴义务人
diff --git a/pc4mobx/hrmSalary/pages/ledger/copyFormModal.js b/pc4mobx/hrmSalary/pages/ledger/copyFormModal.js
index 59200b3e..c74667e7 100644
--- a/pc4mobx/hrmSalary/pages/ledger/copyFormModal.js
+++ b/pc4mobx/hrmSalary/pages/ledger/copyFormModal.js
@@ -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 (
this.props.onCancel()}
- footer={}
+ footer={}
>
账套名称
-
+ {this.setState({name: value})}} />
diff --git a/pc4mobx/hrmSalary/pages/ledger/index.js b/pc4mobx/hrmSalary/pages/ledger/index.js
index 7bed7936..a449d3fb 100644
--- a/pc4mobx/hrmSalary/pages/ledger/index.js
+++ b/pc4mobx/hrmSalary/pages/ledger/index.js
@@ -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 = () =>
@@ -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
+ default:
+ return
+ }
+ }
+ 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个功能
>
-
-
+
{
this.state.stepSlideVisible && }
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 &&
this.handleCopySave(value)}
onCancel={() => {this.setState({copyFormVisible: false})}}
/>
}
diff --git a/pc4mobx/hrmSalary/stores/attendanceStore.js b/pc4mobx/hrmSalary/stores/attendanceStore.js
index 8da6214c..6f7e2a8f 100644
--- a/pc4mobx/hrmSalary/stores/attendanceStore.js
+++ b/pc4mobx/hrmSalary/stores/attendanceStore.js
@@ -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 || "设置失败")
}
})
}
diff --git a/pc4mobx/hrmSalary/stores/index.js b/pc4mobx/hrmSalary/stores/index.js
index ed9a4ac5..41fcb730 100644
--- a/pc4mobx/hrmSalary/stores/index.js
+++ b/pc4mobx/hrmSalary/stores/index.js
@@ -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()
};
diff --git a/pc4mobx/hrmSalary/stores/ledger.js b/pc4mobx/hrmSalary/stores/ledger.js
new file mode 100644
index 00000000..5ac7305e
--- /dev/null
+++ b/pc4mobx/hrmSalary/stores/ledger.js
@@ -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("复制失败")
+ }
+ })
+ }
+
+}
\ No newline at end of file
diff --git a/pc4mobx/hrmSalary/stores/programme.js b/pc4mobx/hrmSalary/stores/programme.js
index 1695f80b..502e15bc 100644
--- a/pc4mobx/hrmSalary/stores/programme.js
+++ b/pc4mobx/hrmSalary/stores/programme.js
@@ -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 || "获取失败")
}
})
}
diff --git a/pc4mobx/hrmSalary/stores/taxAgent.js b/pc4mobx/hrmSalary/stores/taxAgent.js
index c0a26995..efd1adb9 100644
--- a/pc4mobx/hrmSalary/stores/taxAgent.js
+++ b/pc4mobx/hrmSalary/stores/taxAgent.js
@@ -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 || "删除失败");
}
})
}
diff --git a/pc4mobx/hrmSalary/stores/taxRate.js b/pc4mobx/hrmSalary/stores/taxRate.js
index 9cbf3fd7..b83b6f35 100644
--- a/pc4mobx/hrmSalary/stores/taxRate.js
+++ b/pc4mobx/hrmSalary/stores/taxRate.js
@@ -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: "");
}
})
}
diff --git a/pc4mobx/hrmSalary/util/request.js b/pc4mobx/hrmSalary/util/request.js
new file mode 100644
index 00000000..2c6d6d3c
--- /dev/null
+++ b/pc4mobx/hrmSalary/util/request.js
@@ -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())
+}
\ No newline at end of file