salary-management-front/pc4mobx/hrmSalary/stores/ledger.js

754 lines
20 KiB
JavaScript
Raw Normal View History

2022-06-02 14:48:55 +08:00
import { observable, action, toJS } from "mobx";
import { message } from "antd";
import { WeaForm, WeaTableNew } from "comsMobx";
2022-03-23 19:38:10 +08:00
2022-06-02 14:48:55 +08:00
import * as API from "../apis/ledger"; // 引入API接口文件
import { notNull } from "../util/validate";
2022-12-14 15:37:55 +08:00
import { categoryConditions } from "../pages/ledgerPage/config";
2022-03-23 19:38:10 +08:00
const { TableStore } = WeaTableNew;
export class LedgerStore {
2022-12-08 15:48:46 +08:00
//重构薪资账套
2022-12-14 15:37:55 +08:00
@observable copyForm = new WeaForm(); // 复制form
@observable categoryForm = new WeaForm(); // 新增分类form
2022-12-08 15:48:46 +08:00
/*******************************************************/
2022-03-23 19:38:10 +08:00
@observable tableStore = new TableStore(); // new table
@observable form = new WeaForm(); // nrew 一个form
@observable condition = []; // 存储后台得到的form数据
@observable hasRight = true; // 判断用户是有权限查看当前页面: 没有权限渲染无权限页面,有权限渲染数据
@observable showSearchAd = false; // 高级搜索面板显示
@observable loading = false; // 数据加载状态
@observable saveLoading = false; // 数据保存loading状态
2022-03-25 16:41:59 +08:00
@observable salarySobId = "";
2022-06-02 14:48:55 +08:00
@observable includeType = 1; // 0排除、1包含
2022-03-25 16:41:59 +08:00
@observable userTableStore = {};
@observable addUserModalVisible = false;
2022-06-17 16:53:27 +08:00
@observable
itemGroups = [
2022-03-29 17:33:54 +08:00
{
2022-06-02 14:48:55 +08:00
id: "default",
2022-03-29 17:33:54 +08:00
name: "未分类",
2022-06-17 16:53:27 +08:00
items: []
}
2022-03-29 17:33:54 +08:00
];
@observable salaryItemTableStore = new TableStore();
2022-06-02 14:48:55 +08:00
@observable empBrowserList = [];
@observable empFields = [];
@observable excludeIds = [];
2022-03-29 17:33:54 +08:00
@observable addCategoryVisible = false; // 薪资项目-添加分类Modal
2022-03-30 20:04:34 +08:00
@observable ruleOptionList = []; // 第四步规则可选项目列表
@observable sobItemRuleDataSource = []; // 第四步规则列表
@observable ledgerRuleList = [];
@observable baseInfoRequest = {};
@observable userSelectedList = [];
2022-04-20 15:28:40 +08:00
// ** 薪资项目 **
// 添加薪资项目
@observable addSalaryItemColumns = [];
@observable addSalaryItemDataSource = [];
2022-04-27 19:27:23 +08:00
@observable addSalaryItemPageInfo = {}; // 分页信息
2022-04-20 15:28:40 +08:00
2022-03-30 20:04:34 +08:00
@action
initSlideData = () => {
this.salarySobId = "";
2022-06-02 14:48:55 +08:00
this.includeType = 1;
this.userTableStore = {};
this.addUserModalVisible = false;
2022-03-30 20:04:34 +08:00
this.itemGroups = [
{
2022-06-02 14:48:55 +08:00
id: "default",
2022-03-30 20:04:34 +08:00
name: "未分类",
2022-06-17 16:53:27 +08:00
items: []
}
2022-03-30 20:04:34 +08:00
];
2022-06-02 14:48:55 +08:00
this.empBrowserList = [];
this.empFields = [];
this.excludeIds = [];
this.ruleOptionList = [];
2022-03-30 20:04:34 +08:00
this.sobItemRuleDataSource = []; // 第四步规则列表
this.ledgerRuleList = [];
this.baseInfoRequest = {};
this.userSelectedList = [];
2022-06-02 14:48:55 +08:00
};
@observable columns = [];
@observable pageObj = {}; //列表数据
@observable dataSource = []; //列表数据
2022-06-17 16:53:27 +08:00
@action setColumns = columns => (this.columns = columns);
2022-06-02 14:48:55 +08:00
2022-06-17 16:53:27 +08:00
@action setPageObj = pageObj => (this.pageObj = pageObj);
2022-06-02 14:48:55 +08:00
2022-06-17 16:53:27 +08:00
@action setDataSource = dataSource => (this.dataSource = dataSource);
2022-03-30 20:04:34 +08:00
2022-04-27 19:27:23 +08:00
// 设置员工字段
2022-06-17 16:53:27 +08:00
@action setEmpFields = empFields => (this.empFields = empFields);
2022-04-27 19:27:23 +08:00
2022-03-30 20:04:34 +08:00
@action
2022-06-17 16:53:27 +08:00
setUserSelectedList = userSelectedList =>
2022-06-02 14:48:55 +08:00
(this.userSelectedList = userSelectedList);
2022-03-30 20:04:34 +08:00
@action
2022-06-17 16:53:27 +08:00
setBaseInfoRequest = baseInfoRequest =>
2022-06-02 14:48:55 +08:00
(this.baseInfoRequest = baseInfoRequest);
2022-03-30 20:04:34 +08:00
@action
2022-06-17 16:53:27 +08:00
setSobItemRuleDataSource = sobItemRuleDataSource =>
2022-06-02 14:48:55 +08:00
(this.sobItemRuleDataSource = sobItemRuleDataSource);
2022-03-29 17:33:54 +08:00
@action
2022-06-17 16:53:27 +08:00
setAddCategoryVisible = addCategoryVisible =>
2022-06-02 14:48:55 +08:00
(this.addCategoryVisible = addCategoryVisible);
2022-03-29 17:33:54 +08:00
2022-06-17 16:53:27 +08:00
@action setExcludeIds = excludeIds => (this.excludeIds = excludeIds);
2022-06-02 14:48:55 +08:00
2022-03-29 17:33:54 +08:00
@action
2022-06-17 16:53:27 +08:00
addExcludeIds = id => {
2022-06-02 14:48:55 +08:00
let excludeIds = [...this.excludeIds];
excludeIds.push(id);
this.excludeIds = excludeIds;
};
2022-03-29 17:33:54 +08:00
@action
2022-06-17 16:53:27 +08:00
addEmpFields = fieldId => {
2022-03-29 17:33:54 +08:00
let sortedIndex = 1;
2022-06-02 14:48:55 +08:00
if (this.empFields.length > 0) {
2022-06-17 16:53:27 +08:00
let lastSortedIndex = this.empFields[this.empFields.length - 1]
.sortedIndex;
2022-06-02 14:48:55 +08:00
sortedIndex = parseInt(lastSortedIndex) + 1;
2022-03-29 17:33:54 +08:00
}
let item = {
2022-10-10 15:02:46 +08:00
id: sortedIndex,
2022-03-29 17:33:54 +08:00
fieldId,
2022-05-07 14:47:14 +08:00
sortedIndex,
2022-06-17 16:53:27 +08:00
canDelete: true
2022-06-02 14:48:55 +08:00
};
let result = [...this.empFields];
result.push(item);
this.empFields = result;
2022-06-17 16:53:27 +08:00
this.userSelectedList = this.empFields.map(item => {
2022-06-02 14:48:55 +08:00
item = { ...item };
item.key = item.fieldId;
if (!item.showname || item.showname == "") {
2022-06-17 16:53:27 +08:00
this.empBrowserList.map(bitem => {
2022-06-02 14:48:55 +08:00
if (bitem.key == item.fieldId) {
item.showname = bitem.showname;
2022-04-27 19:27:23 +08:00
}
2022-06-02 14:48:55 +08:00
});
2022-04-27 19:27:23 +08:00
}
return item;
2022-06-02 14:48:55 +08:00
});
};
2022-03-29 17:33:54 +08:00
@action
2022-06-17 16:53:27 +08:00
setItemGroups = itemGroups => {
itemGroups = itemGroups ? [...itemGroups] : [];
itemGroups &&
itemGroups.map(item => {
if (item.items) {
item.items &&
item.items.map(i => {
i.key = i.id;
});
}
});
this.itemGroups = itemGroups;
2022-06-14 10:16:04 +08:00
};
2022-03-29 17:33:54 +08:00
@action
2022-06-17 16:53:27 +08:00
addItemGroup = name => {
2022-06-02 14:48:55 +08:00
if (!name || name == "" || name.trim() == "") {
message.warning("分类名称不能为空");
return;
2022-04-06 14:26:16 +08:00
}
2022-06-02 14:48:55 +08:00
let itemGroups = [...this.itemGroups];
2022-03-29 17:33:54 +08:00
let flag = false;
2022-06-17 16:53:27 +08:00
itemGroups.map(item => {
2022-06-02 14:48:55 +08:00
if (item.name == name) {
2022-03-29 17:33:54 +08:00
flag = true;
}
2022-06-02 14:48:55 +08:00
});
if (flag) {
message.warning("分类已存在");
return;
2022-03-29 17:33:54 +08:00
}
let item = { name, items: [], id: new Date().getTime().toString().substring(0, 13) };
2022-06-02 14:48:55 +08:00
itemGroups.unshift(item);
this.setItemGroups(itemGroups);
this.addCategoryVisible = false;
};
2022-03-29 17:33:54 +08:00
@action
addItemsToGroup = (title, list) => {
2022-06-02 14:48:55 +08:00
let itemGroups = [...this.itemGroups];
2022-06-17 16:53:27 +08:00
itemGroups.map(item => {
2022-06-02 14:48:55 +08:00
if (item.name == title) {
item.items = item.items ? item.items.concat(list) : list;
2022-03-29 17:33:54 +08:00
}
2022-06-02 14:48:55 +08:00
});
2022-04-20 15:28:40 +08:00
2022-03-29 17:33:54 +08:00
this.setItemGroups(itemGroups);
2022-06-02 14:48:55 +08:00
};
2022-03-29 17:33:54 +08:00
@action
2022-06-17 16:53:27 +08:00
addCategoryList = item => {
2022-06-02 14:48:55 +08:00
let list = [...this.categoryList];
list.push(item);
this.categoryList = list;
};
2022-03-29 17:33:54 +08:00
@action
2022-06-17 16:53:27 +08:00
removeCategoryList = item => {
2022-06-02 14:48:55 +08:00
let list = [...this.categoryList];
2022-06-17 16:53:27 +08:00
list.filter(i => item.name != i.name);
2022-03-29 17:33:54 +08:00
this.categoryList = list;
2022-06-02 14:48:55 +08:00
};
2022-03-25 16:41:59 +08:00
@action
2022-06-17 16:53:27 +08:00
setAddUserModalVisible = addUserModalVisible =>
2022-06-02 14:48:55 +08:00
(this.addUserModalVisible = addUserModalVisible);
2022-03-25 16:41:59 +08:00
@action
2022-06-17 16:53:27 +08:00
setUserTableStore = userTableStore => (this.userTableStore = userTableStore);
2022-03-25 16:41:59 +08:00
2022-06-17 16:53:27 +08:00
@action setIncludeType = includeType => (this.includeType = includeType);
2022-03-25 16:41:59 +08:00
2022-06-17 16:53:27 +08:00
@action setSalarySobId = salarySobId => (this.salarySobId = salarySobId);
2022-03-23 19:38:10 +08:00
// 初始化操作
@action
doInit = () => {
// this.getCondition();
this.getTableDatas({});
2022-03-30 20:04:34 +08:00
this.setBaseInfoRequest({
name: "",
taxableItems: "1",
2022-06-17 16:53:27 +08:00
salaryCycleType: "3",
2022-03-30 20:04:34 +08:00
salaryCycleFromDay: "1",
2022-06-17 16:53:27 +08:00
taxCycleType: "3",
attendCycleType: "3",
2022-03-30 20:04:34 +08:00
attendCycleFromDay: "1",
2022-06-17 16:53:27 +08:00
socialSecurityCycleType: "3",
description: ""
2022-06-02 14:48:55 +08:00
});
};
2022-03-23 19:38:10 +08:00
2022-03-31 21:03:17 +08:00
@action
initBaseInfoRequest = () => {
this.setBaseInfoRequest({
name: "",
taxableItems: "1",
2022-06-17 16:53:27 +08:00
salaryCycleType: "3",
2022-03-31 21:03:17 +08:00
salaryCycleFromDay: "1",
2022-06-17 16:53:27 +08:00
taxCycleType: "3",
attendCycleType: "3",
2022-03-31 21:03:17 +08:00
attendCycleFromDay: "1",
2022-06-17 16:53:27 +08:00
socialSecurityCycleType: "3",
description: ""
2022-06-02 14:48:55 +08:00
});
};
2022-03-31 21:03:17 +08:00
2022-03-23 19:38:10 +08:00
// 获得高级搜索表单数据
@action
getCondition = () => {
2022-06-02 14:48:55 +08:00
API.getCondition().then(
2022-06-17 16:53:27 +08:00
action(res => {
2022-06-02 14:48:55 +08:00
if (res.api_status) {
// 接口请求成功/失败处理
this.condition = res.condition;
this.form.initFormFields(res.condition); // 渲染高级搜索form表单
} else {
message.error(res.errormsg || "接口调用失败!");
}
})
);
};
2022-03-23 19:38:10 +08:00
// 渲染table数据
@action
2022-06-17 16:53:27 +08:00
getTableDatas = params => {
2022-03-23 19:38:10 +08:00
this.loading = true;
2022-06-02 14:48:55 +08:00
API.getLedgerList(params).then(
action(({ status, data, errormsg }) => {
this.loading = false;
if (status) {
// 接口请求成功/失败处理
const { columns, list, total, pageNum: current, pageSize } = data;
this.setColumns(columns);
this.setDataSource(list);
this.setPageObj({
total,
current,
2022-06-17 16:53:27 +08:00
pageSize
2022-06-02 14:48:55 +08:00
});
} else {
this.setDataSource([]);
this.setPageObj({
...this.pageObj,
2022-06-17 16:53:27 +08:00
total: 0
2022-06-02 14:48:55 +08:00
});
message.error(errormsg || "接口调用失败!");
}
})
);
};
2022-03-23 19:38:10 +08:00
2022-06-17 16:53:27 +08:00
@action setShowSearchAd = bool => (this.showSearchAd = bool);
2022-03-23 19:38:10 +08:00
// 高级搜索 - 搜索
2022-06-17 16:53:27 +08:00
@action
doSearch = () => {
2022-03-23 19:38:10 +08:00
this.getTableDatas();
this.showSearchAd = false;
2022-06-02 14:48:55 +08:00
};
2022-03-23 19:38:10 +08:00
// 复制
2022-06-17 16:53:27 +08:00
@action
doCopy = params => {
2022-05-13 15:25:21 +08:00
return new Promise((resolve, reject) => {
API.duplicateLedger({ ...params }).then(res => {
2022-06-02 14:48:55 +08:00
if (res.status) {
message.success("复制成功");
2022-05-13 15:25:21 +08:00
this.getTableDatas({});
resolve();
} else {
2022-06-02 14:48:55 +08:00
message.error(res.errormsg || "复制失败");
2022-05-13 15:25:21 +08:00
reject();
}
2022-06-02 14:48:55 +08:00
});
});
};
2022-03-24 10:32:14 +08:00
//启用/禁用薪资帐套
@action
changeLedgerStatus = (id, disable) => {
2022-06-17 16:53:27 +08:00
API.changeLedgerStatus({ id, disable }).then(res => {
2022-06-02 14:48:55 +08:00
if (res.status) {
2022-03-24 16:58:57 +08:00
this.getTableDatas({});
2022-06-02 14:48:55 +08:00
message.success("修改成功");
2022-03-24 10:32:14 +08:00
} else {
2022-06-02 14:48:55 +08:00
message.error(res.errormsg || "修改失败");
2022-03-24 10:32:14 +08:00
}
2022-06-02 14:48:55 +08:00
});
};
2022-03-24 10:32:14 +08:00
2022-04-06 14:26:16 +08:00
validateBaseFrom(params) {
2022-06-02 14:48:55 +08:00
if (!notNull(params.name)) {
2022-04-06 14:26:16 +08:00
message.warning("名称不能为空");
2022-06-02 14:48:55 +08:00
return false;
2022-04-06 14:26:16 +08:00
}
2022-06-02 14:48:55 +08:00
if (!notNull(params.taxableItems)) {
2022-04-06 14:26:16 +08:00
message.warning("薪资类型不能为空");
2022-06-02 14:48:55 +08:00
return false;
2022-04-06 14:26:16 +08:00
}
2022-06-02 14:48:55 +08:00
if (!notNull(params.salaryCycleType)) {
2022-04-06 14:26:16 +08:00
message.warning("薪资周期不能为空");
2022-06-02 14:48:55 +08:00
return false;
2022-04-06 14:26:16 +08:00
}
2022-06-02 14:48:55 +08:00
if (!notNull(params.salaryCycleFromDay)) {
2022-04-06 14:26:16 +08:00
message.warning("薪资周期不能为空");
2022-06-02 14:48:55 +08:00
return false;
2022-04-06 14:26:16 +08:00
}
2022-06-02 14:48:55 +08:00
if (!notNull(params.taxCycleType)) {
2022-04-06 14:26:16 +08:00
message.warning("税款所属期不能为空");
2022-06-02 14:48:55 +08:00
return false;
2022-04-06 14:26:16 +08:00
}
2022-06-02 14:48:55 +08:00
if (!notNull(params.attendCycleType)) {
2022-04-06 14:26:16 +08:00
message.warning("考勤周期不能为空");
2022-06-02 14:48:55 +08:00
return false;
2022-04-06 14:26:16 +08:00
}
2022-06-02 14:48:55 +08:00
if (!notNull(params.attendCycleFromDay)) {
2022-04-06 14:26:16 +08:00
message.warning("考勤周期不能为空");
2022-06-02 14:48:55 +08:00
return false;
2022-04-06 14:26:16 +08:00
}
2022-06-02 14:48:55 +08:00
if (!notNull(params.socialSecurityCycleType)) {
2022-04-06 14:26:16 +08:00
message.warning("福利台账月份不能为空");
2022-06-02 14:48:55 +08:00
return false;
2022-04-06 14:26:16 +08:00
}
2022-06-02 14:48:55 +08:00
return true;
2022-04-06 14:26:16 +08:00
}
2022-03-24 16:58:57 +08:00
//保存薪资帐套基本信息
@action
2022-06-17 16:53:27 +08:00
saveLedgerBasic = params => {
2022-03-30 20:04:34 +08:00
return new Promise((resolve, reject) => {
2022-07-20 10:33:23 +08:00
if (!this.validateBaseFrom(params)) {
reject("保存失败");
}
this.saveLoading= true;
2022-06-17 16:53:27 +08:00
API.saveLedgerBasic(params).then(res => {
this.saveLoading= false;
2022-06-02 14:48:55 +08:00
if (res.status) {
2022-03-30 20:04:34 +08:00
this.salarySobId = res.data;
2022-06-02 14:48:55 +08:00
resolve();
this.getTableDatas({});
message.success("保存成功");
2022-03-30 20:04:34 +08:00
} else {
2022-06-02 14:48:55 +08:00
reject(res.errormsg || "保存失败");
message.error(res.errormsg || "保存失败");
2022-03-30 20:04:34 +08:00
}
2022-06-02 14:48:55 +08:00
});
});
};
2022-03-24 16:58:57 +08:00
//删除薪资帐套
@action
2022-06-17 16:53:27 +08:00
deleteLedger = params => {
API.deleteLedger(params).then(res => {
2022-06-02 14:48:55 +08:00
if (res.status) {
message.success("删除成功");
2022-03-24 16:58:57 +08:00
this.getTableDatas({});
} else {
2022-06-02 14:48:55 +08:00
message.error(res.errormsg || "删除失败");
2022-03-24 16:58:57 +08:00
}
2022-06-02 14:48:55 +08:00
});
};
2022-03-24 10:32:14 +08:00
2022-04-06 14:26:16 +08:00
validateLedgerPersonRange(params) {
2022-06-02 14:48:55 +08:00
if (!notNull(params.includeType)) {
message.warning("对象类型不能为空");
return false;
2022-04-06 14:26:16 +08:00
}
2022-06-02 14:48:55 +08:00
if (!notNull(params.targetParams)) {
message.warning("对象类型不能为空");
return false;
2022-04-06 14:26:16 +08:00
}
2022-06-02 14:48:55 +08:00
if (!notNull(params.employeeStatus)) {
message.warning("选择员工状态不能为空");
return false;
2022-04-06 14:26:16 +08:00
}
if (_.every(params.targetParams, it => !notNull(it.targetId))) {
message.warning("对象类型不能为空");
return false;
}
2022-06-02 14:48:55 +08:00
return true;
2022-04-06 14:26:16 +08:00
}
2022-03-25 16:41:59 +08:00
//保存薪资帐套人员范围
@action
2022-06-17 16:53:27 +08:00
saveLedgerPersonRange = params => {
2022-06-02 14:48:55 +08:00
if (!this.validateLedgerPersonRange(params)) {
return;
2022-04-06 14:26:16 +08:00
}
2022-06-17 16:53:27 +08:00
API.saveLedgerPersonRange(params).then(res => {
2022-06-02 14:48:55 +08:00
if (res.status) {
if (this.includeType == 1) {
this.getLedgerPersonRangeInclude({ salarySobId: this.salarySobId });
2022-03-25 16:41:59 +08:00
} else {
2022-06-02 14:48:55 +08:00
this.getLedgerPersonRangeExclude({ salarySobId: this.salarySobId });
2022-03-25 16:41:59 +08:00
}
this.addUserModalVisible = false;
2022-06-02 14:48:55 +08:00
message.success("添加成功");
2022-03-25 16:41:59 +08:00
} else {
2022-06-02 14:48:55 +08:00
message.error(res.errormsg || "添加失败");
2022-03-25 16:41:59 +08:00
}
2022-06-02 14:48:55 +08:00
});
};
2022-03-25 16:41:59 +08:00
//薪资帐套人员范围(包含)列表
2022-06-17 16:53:27 +08:00
getLedgerPersonRangeInclude = params => {
2022-08-25 17:54:18 +08:00
this.loading= true;
2022-06-17 16:53:27 +08:00
API.getLedgerPersonRangeInclude(params).then(res => {
2022-08-25 17:54:18 +08:00
this.loading= false;
2022-06-02 14:48:55 +08:00
if (res.status) {
this.setUserTableStore(res.data);
2022-03-25 16:41:59 +08:00
} else {
2022-06-02 14:48:55 +08:00
message.error(res.errormsg || "获取失败");
2022-03-25 16:41:59 +08:00
}
2022-06-02 14:48:55 +08:00
});
};
2022-03-25 16:41:59 +08:00
//薪资帐套人员范围(排除)列表
2022-06-17 16:53:27 +08:00
getLedgerPersonRangeExclude = params => {
2022-08-25 17:54:18 +08:00
this.loading= true;
2022-06-17 16:53:27 +08:00
API.getLedgerPersonRangeExclude(params).then(res => {
2022-08-25 17:54:18 +08:00
this.loading= false;
2022-06-02 14:48:55 +08:00
if (res.status) {
this.setUserTableStore(res.data);
2022-03-25 16:41:59 +08:00
} else {
2022-06-02 14:48:55 +08:00
message.error(res.errormsg || "获取失败");
2022-03-25 16:41:59 +08:00
}
2022-06-02 14:48:55 +08:00
});
};
2022-03-25 16:41:59 +08:00
//删除薪资帐套人员范围
2022-06-17 16:53:27 +08:00
deleteLedgerPersonRange = params => {
API.deleteLedgerPersonRange(params).then(res => {
2022-06-02 14:48:55 +08:00
if (res.status) {
if (this.includeType == 1) {
this.getLedgerPersonRangeInclude({ salarySobId: this.salarySobId });
2022-03-25 16:41:59 +08:00
} else {
2022-06-02 14:48:55 +08:00
this.getLedgerPersonRangeExclude({ salarySobId: this.salarySobId });
2022-03-25 16:41:59 +08:00
}
2022-06-02 14:48:55 +08:00
message.success("删除成功");
2022-03-25 16:41:59 +08:00
} else {
2022-06-02 14:48:55 +08:00
message.error(res.errormsg || "删除失败");
2022-03-25 16:41:59 +08:00
}
2022-06-02 14:48:55 +08:00
});
};
2022-03-25 16:41:59 +08:00
2022-06-02 14:48:55 +08:00
// 薪资项目可选列表
2022-03-29 17:33:54 +08:00
@action
2022-04-27 19:27:23 +08:00
listSalaryItem = (searchValue = "", current = 1) => {
2022-06-02 14:48:55 +08:00
let excludeIds = [];
2022-06-17 16:53:27 +08:00
this.itemGroups &&
this.itemGroups.map(item => {
item.items &&
item.items.map(i => {
excludeIds.push(i.salaryItemId);
});
2022-06-02 14:48:55 +08:00
});
this.loading = true;
2022-06-17 16:53:27 +08:00
API.listSalaryItem({ name: searchValue, excludeIds, current }).then(res => {
if (res.status) {
if (res.data.list) {
this.addSalaryItemDataSource = res.data.list.map(item => {
item = { ...item };
item.key = item.id;
return item;
});
2022-05-10 15:31:13 +08:00
} else {
2022-06-17 16:53:27 +08:00
this.addSalaryItemDataSource = [];
2022-05-10 15:31:13 +08:00
}
2022-06-17 16:53:27 +08:00
this.addSalaryItemColumns = res.data.columns;
this.addSalaryItemPageInfo = res.data;
// this.salaryItemTableStore.getDatas(res.data.datas);
} else {
message.error(res.errormsg || "获取数据失败");
2022-03-29 17:33:54 +08:00
}
2022-06-17 16:53:27 +08:00
this.loading = false;
});
2022-06-02 14:48:55 +08:00
};
2022-03-29 17:33:54 +08:00
@action
empFieldList = () => {
2022-06-17 16:53:27 +08:00
API.empFieldList().then(res => {
2022-06-02 14:48:55 +08:00
if (res.status) {
2022-06-17 16:53:27 +08:00
this.empBrowserList = res.data.map(item => {
2022-06-02 14:48:55 +08:00
return { showname: item.name, key: item.id, selected: false };
});
2022-03-29 17:33:54 +08:00
} else {
2022-06-02 14:48:55 +08:00
message.error(res.errormsg || "获取失败");
2022-03-29 17:33:54 +08:00
}
2022-06-02 14:48:55 +08:00
});
};
2022-03-29 17:33:54 +08:00
@action
saveLedgerItem = () => {
2022-06-02 14:48:55 +08:00
let itemGroups = [...this.itemGroups];
itemGroups = itemGroups
2022-06-17 16:53:27 +08:00
.map(item => {
2022-06-02 14:48:55 +08:00
let result = { ...item };
if (result.items) {
result.items = result.items.map((i, index) => ({
canDelete: i.canDelete,
2022-05-10 15:31:13 +08:00
salaryItemId: i.salaryItemId,
sortedIndex: index + 1,
2022-08-25 17:54:18 +08:00
formulaId: i.formulaId,
itemHide: i.itemHide || "0",
2022-06-02 14:48:55 +08:00
}));
return result;
}
})
2022-06-17 16:53:27 +08:00
.filter(item => item);
2022-03-29 17:33:54 +08:00
let params = {
salarySobId: this.salarySobId,
empFields: _.map(this.userSelectedList, (it, idx) => ({...it, sortedIndex:idx })),
2022-06-17 16:53:27 +08:00
itemGroups: itemGroups.filter(item => item.id != "default"),
items: itemGroups.filter(item => item.id == "default")[0].items
2022-06-02 14:48:55 +08:00
};
2022-03-30 20:04:34 +08:00
return new Promise((resolve, reject) => {
this.saveLoading= true;
2022-06-17 16:53:27 +08:00
API.saveLedgerItem(params).then(res => {
this.saveLoading= false;
2022-06-02 14:48:55 +08:00
if (res.status) {
resolve();
2022-03-30 20:04:34 +08:00
message.success("保存成功");
} else {
2022-06-02 14:48:55 +08:00
reject();
message.error(res.errormsg || "保存失败");
2022-03-30 20:04:34 +08:00
}
2022-06-02 14:48:55 +08:00
});
});
};
2022-03-30 20:04:34 +08:00
// 调薪计薪规则可选的薪资项目列表
@action
listSalarySobItem = () => {
let params = {
salarySobId: this.salarySobId,
2022-06-02 14:48:55 +08:00
excludeSalaryItemIds: this.sobItemRuleDataSource.map(
2022-06-17 16:53:27 +08:00
item => item.salaryItemId
)
2022-06-02 14:48:55 +08:00
};
2022-03-31 21:03:17 +08:00
return new Promise((resolve, reject) => {
2022-06-17 16:53:27 +08:00
API.listSalarySobItem(params).then(res => {
2022-06-02 14:48:55 +08:00
if (res.status) {
2022-06-17 16:53:27 +08:00
this.ruleOptionList = res.data.map(item => {
2022-03-31 21:03:17 +08:00
return {
key: item.salaryItemId.toString(),
showname: item.salaryItemName,
2022-06-17 16:53:27 +08:00
selected: false
2022-06-02 14:48:55 +08:00
};
});
resolve();
2022-03-31 21:03:17 +08:00
} else {
2022-06-02 14:48:55 +08:00
reject();
message.error(res.errormsg || "获取失败");
2022-03-31 21:03:17 +08:00
}
2022-06-02 14:48:55 +08:00
});
});
};
2022-03-30 20:04:34 +08:00
// 调薪计薪规则保存
@action
saveAdjustmentRule = () => {
let params = {
2022-06-02 14:48:55 +08:00
salarySobId: this.salarySobId,
2022-06-17 16:53:27 +08:00
ruleParams: this.sobItemRuleDataSource
2022-06-02 14:48:55 +08:00
};
2022-03-30 20:04:34 +08:00
return new Promise((resolve, reject) => {
this.saveLoading= true;
2022-06-17 16:53:27 +08:00
API.saveAdjustmentRule(params).then(res => {
this.saveLoading= false;
2022-06-02 14:48:55 +08:00
if (res.status) {
resolve();
message.success("保存成功");
2022-03-30 20:04:34 +08:00
} else {
2022-06-02 14:48:55 +08:00
reject();
message.error(res.errormsg || "获取失败");
2022-03-30 20:04:34 +08:00
}
2022-06-02 14:48:55 +08:00
});
});
};
2022-03-30 20:04:34 +08:00
@action
listAdjustmentRule = () => {
let params = {
2022-06-17 16:53:27 +08:00
salarySobId: this.salarySobId
2022-06-02 14:48:55 +08:00
};
2022-06-17 16:53:27 +08:00
API.listAdjustmentRule(params).then(res => {
2022-06-02 14:48:55 +08:00
if (res.status) {
this.sobItemRuleDataSource = res.data;
2022-03-30 20:04:34 +08:00
}
2022-06-02 14:48:55 +08:00
});
};
2022-03-30 20:04:34 +08:00
// 保存薪资帐套校验规则
@action
2022-06-17 16:53:27 +08:00
saveLedgerRule = params => {
2022-03-30 20:04:34 +08:00
params.salarySobId = this.salarySobId;
2022-06-17 16:53:27 +08:00
API.saveLedgerRule(params).then(res => {
2022-06-02 14:48:55 +08:00
if (res.status) {
this.getLedgerRuleList();
message.success("保存成功");
2022-03-29 17:33:54 +08:00
} else {
2022-06-02 14:48:55 +08:00
message.error(res.errormsg || "保存失败");
2022-03-29 17:33:54 +08:00
}
2022-06-02 14:48:55 +08:00
});
};
2022-03-29 17:33:54 +08:00
2022-03-30 20:04:34 +08:00
//薪资帐套校验规则列表
@action
getLedgerRuleList = (name = "") => {
let params = {
salarySobId: this.salarySobId,
2022-06-17 16:53:27 +08:00
name
2022-06-02 14:48:55 +08:00
};
2022-06-17 16:53:27 +08:00
API.getLedgerRuleList(params).then(res => {
2022-06-02 14:48:55 +08:00
if (res.status) {
this.ledgerRuleList = res.data;
2022-03-30 20:04:34 +08:00
} else {
2022-06-02 14:48:55 +08:00
message.error(res.errormsg || "获取数据失败");
2022-03-30 20:04:34 +08:00
}
2022-06-02 14:48:55 +08:00
});
};
2022-03-30 20:04:34 +08:00
//删除薪资帐套校验规则
@action
2022-06-17 16:53:27 +08:00
deleteLedgerRule = ids => {
API.deleteLedgerRule(ids).then(res => {
2022-06-02 14:48:55 +08:00
if (res.status) {
message.success("删除成功");
2022-03-30 20:04:34 +08:00
this.getLedgerRuleList();
} else {
2022-06-02 14:48:55 +08:00
message.error(res.errormsg || "删除失败");
2022-03-30 20:04:34 +08:00
}
2022-06-02 14:48:55 +08:00
});
};
2022-03-30 20:04:34 +08:00
// 获取基本信息
@action
getLedgerBasicForm = () => {
2022-06-17 16:53:27 +08:00
API.getLedgerBasicForm({ id: this.salarySobId }).then(res => {
2022-06-02 14:48:55 +08:00
if (res.status) {
let basicForm = res.data.basicForm;
2022-06-17 16:53:27 +08:00
Object.keys(basicForm).map(key => {
if (basicForm[key] || typeof basicForm[key] === "boolean") {
2022-04-18 11:42:45 +08:00
basicForm[key] = basicForm[key].toString();
}
2022-06-02 14:48:55 +08:00
});
this.baseInfoRequest = basicForm;
2022-03-30 20:04:34 +08:00
} else {
2022-06-02 14:48:55 +08:00
message.error(res.errormsg || "获取失败");
2022-03-30 20:04:34 +08:00
}
2022-06-02 14:48:55 +08:00
});
};
2022-03-29 17:33:54 +08:00
2022-03-30 20:04:34 +08:00
//薪资帐套薪资项目详情
@action
getLedgerItemForm = () => {
2022-06-17 16:53:27 +08:00
API.getLedgerItemForm({ salarySobId: this.salarySobId }).then(res => {
2022-06-02 14:48:55 +08:00
if (res.status) {
this.empFields = res.data.empFields;
2022-06-14 10:16:04 +08:00
let itemGroups = res.data.itemGroups;
2022-03-30 20:04:34 +08:00
let defaultItems = {
2022-06-02 14:48:55 +08:00
id: "default",
2022-03-30 20:04:34 +08:00
name: "未分类",
2022-06-17 16:53:27 +08:00
items: res.data.items
2022-06-02 14:48:55 +08:00
};
2022-06-17 16:53:27 +08:00
itemGroups.push(defaultItems);
this.setItemGroups(itemGroups);
API.empFieldList().then(ires => {
2022-06-02 14:48:55 +08:00
if (res.status) {
2022-06-17 16:53:27 +08:00
this.empBrowserList = ires.data.map(item => {
2022-06-02 14:48:55 +08:00
return { showname: item.name, key: item.id, selected: false };
});
2022-06-17 16:53:27 +08:00
this.userSelectedList = this.empFields.map(item => {
2022-06-02 14:48:55 +08:00
item = { ...item };
item.key = item.fieldId;
2022-06-17 16:53:27 +08:00
this.empBrowserList.map(bitem => {
2022-06-02 14:48:55 +08:00
if (bitem.key == item.fieldId) {
item.showname = bitem.showname;
}
});
return item;
});
2022-03-30 20:04:34 +08:00
} else {
2022-06-02 14:48:55 +08:00
message.error(res.errormsg || "获取失败");
2022-03-30 20:04:34 +08:00
}
2022-06-02 14:48:55 +08:00
});
2022-03-30 20:04:34 +08:00
} else {
2022-06-02 14:48:55 +08:00
message.error(res.errormsg || "获取失败");
2022-03-30 20:04:34 +08:00
}
2022-06-02 14:48:55 +08:00
});
};
}