基础信息
- 薪资账套
+ 薪资账套
-
+ {
+ this.state.inited && {this.hanldeChange({salarySob: value})}}/>
+ }
- 工资单模板名称
+ 工资单模板名称
-
+ this.hanldeChange({name: value})}/>
备注
-
+ this.hanldeChange({description: value})}/>
@@ -38,7 +76,7 @@ export default class BaseInformForm extends React.Component {
邮件
-
+ {this.hanldeChange({emailStatus: value})}}/>
@@ -46,7 +84,7 @@ export default class BaseInformForm extends React.Component {
发送地址
-
+ {this.hanldeChange({sendEmail: value})}}/>
@@ -56,7 +94,7 @@ export default class BaseInformForm extends React.Component {
消息中心
-
+ {this.hanldeChange({msgStatus: value})}}/>
diff --git a/pc4mobx/hrmSalary/pages/payroll/stepForm/index.less b/pc4mobx/hrmSalary/pages/payroll/stepForm/index.less
index 8ad0c6dc..afc1e5c4 100644
--- a/pc4mobx/hrmSalary/pages/payroll/stepForm/index.less
+++ b/pc4mobx/hrmSalary/pages/payroll/stepForm/index.less
@@ -32,6 +32,9 @@
line-height: 40px;
}
}
+ .themeFormalStr {
+ margin-right: 10px;
+ }
.settingItemWrapper {
margin-top: 10px;
.itemTitle {
diff --git a/pc4mobx/hrmSalary/pages/payroll/stepForm/showSettingForm.js b/pc4mobx/hrmSalary/pages/payroll/stepForm/showSettingForm.js
index 10b5e13d..ccf72587 100644
--- a/pc4mobx/hrmSalary/pages/payroll/stepForm/showSettingForm.js
+++ b/pc4mobx/hrmSalary/pages/payroll/stepForm/showSettingForm.js
@@ -1,15 +1,65 @@
import React from 'react'
import { Row, Col, Upload, Icon, Radio, Switch } from 'antd'
import { WeaInput } from 'ecCom'
+import { inject, observer } from 'mobx-react';
+import BackgroundUpload from '../components/backgroundUpload'
const Dragger = Upload.Dragger;
-
+@inject('payrollStore')
+@observer
export default class ShowSettingForm extends React.Component {
+
+ componentWillMount() {
+ const { payrollStore } = this.props;
+ const { initShowSettingForm } = payrollStore
+ initShowSettingForm(this.props.id)
+ }
+ // form 字段变化时的回调
+ handleChange(params) {
+ const { payrollStore: {salaryTemplateShowSet, setSalaryTemplateShowSet}} = this.props;
+ let request= {...salaryTemplateShowSet, ...params};
+ setSalaryTemplateShowSet(request);
+ // this.props.onChange && this.props.onChange(request);
+ }
+
+ // 工资单主题 插入变量
+ handleThemeNameCllck(param) {
+ const { payrollStore } = this.props;
+ const { salaryTemplateShowSet, setSalaryTemplateShowSet } = payrollStore;
+ let request= {...salaryTemplateShowSet};
+ request.theme = (request.theme ? request.theme : "") + param;
+ setSalaryTemplateShowSet(request);
+ }
+
render() {
+ const { payrollStore } = this.props;
+ const { salaryTemplateShowSet } = payrollStore;
+ const { salaryItemSet } = payrollStore
+ const { theme,
+ background,
+ textContent,
+ textContentPosition,
+ salaryItemNullStatus,
+ salaryItemZeroStatus
+ } = salaryTemplateShowSet
const dropProps = {
name: 'file',
- action: 'http://www.mocky.io/v2/5e0085b82f0000780013b4c7',
+ action: '/api/doc/upload/uploadFile',
+ onChange(info) {
+ const { status } = info.file;
+ if (status !== 'uploading') {
+ console.log(info.file, info.fileList);
+ }
+ if (status === 'done') {
+ message.success(`${info.file.name} file uploaded successfully.`);
+ } else if (status === 'error') {
+ message.error(`${info.file.name} file upload failed.`);
+ }
+ },
+ onDrop(e) {
+ console.log('Dropped files', e.dataTransfer.files);
+ },
};
return (
@@ -74,16 +129,18 @@ export default class ShowSettingForm extends React.Component {
薪资项目设置
-
-
-
-
月度固定薪酬
-
基本工资 岗位工资 工资薪金合计
-
-
+ {
+ salaryItemSet.map(group => (
+
+
{group.groupName}
+
+ {group.items.map(item => (
+ {item.name}
+ ))}
+
+
+ ))
+ }
diff --git a/pc4mobx/hrmSalary/pages/payroll/templateSettingList.js b/pc4mobx/hrmSalary/pages/payroll/templateSettingList.js
new file mode 100644
index 00000000..4f723ea7
--- /dev/null
+++ b/pc4mobx/hrmSalary/pages/payroll/templateSettingList.js
@@ -0,0 +1,29 @@
+import React from 'react'
+import { inject, observer } from 'mobx-react';
+import { WeaTableNew } from 'comsMobx';
+const WeaTable = WeaTableNew.WeaTable;
+
+@inject('payrollStore')
+@observer
+export default class TemplateSettingList extends React.Component {
+ componentWillMount() {
+ const { payrollStore } = this.props;
+ const { getPayrollTemplateList } = payrollStore;
+ getPayrollTemplateList();
+ }
+ render() {
+ const { payrollStore } = this.props;
+ const { templateStore } = payrollStore;
+ return (
+
+
+
+ )
+ }
+}
\ No newline at end of file
diff --git a/pc4mobx/hrmSalary/stores/index.js b/pc4mobx/hrmSalary/stores/index.js
index e26a2be8..594052fd 100644
--- a/pc4mobx/hrmSalary/stores/index.js
+++ b/pc4mobx/hrmSalary/stores/index.js
@@ -13,6 +13,7 @@ import { SalaryItemStore } from './salaryItem'
import { LedgerStore } from './ledger'
import { ArchivesStore } from './archives'
import { salaryFileStore } from './salaryFile';
+import { payrollStore } from './payroll';
module.exports = {
baseFormStore: new BaseFormStore(),
@@ -28,6 +29,7 @@ module.exports = {
salaryItemStore: new SalaryItemStore(),
ledgerStore: new LedgerStore(),
archivesStore: new ArchivesStore(),
- salaryFileStore: new salaryFileStore()
+ salaryFileStore: new salaryFileStore(),
+ payrollStore: new payrollStore()
};
diff --git a/pc4mobx/hrmSalary/stores/payroll.js b/pc4mobx/hrmSalary/stores/payroll.js
new file mode 100644
index 00000000..0839cdff
--- /dev/null
+++ b/pc4mobx/hrmSalary/stores/payroll.js
@@ -0,0 +1,211 @@
+import { observable, action, toJS } from 'mobx';
+import { message } from 'antd';
+import { WeaForm, WeaTableNew } from 'comsMobx';
+
+import * as API from '../apis/payroll'; // 引入API接口文件
+import { notNull } from '../util/validate';
+
+const { TableStore } = WeaTableNew;
+
+export class payrollStore {
+ @observable tableStore = new TableStore(); // new table
+ @observable form = new WeaForm(); // nrew 一个form
+ @observable condition = []; // 存储后台得到的form数据
+ @observable hasRight = true; // 判断用户是有权限查看当前页面: 没有权限渲染无权限页面,有权限渲染数据
+ @observable showSearchAd = false; // 高级搜索面板显示
+ @observable loading = true; // 数据加载状态
+
+ // **** 模板页面 ****
+ @observable templateStore = new TableStore(); // 模板设置列表
+ // 基础设置表单
+ @observable templateBaseData = {} // 基础信息表单数据
+ @observable salarySobOptions = [] // 账套列表
+ // 显示设置表单
+ @observable salaryTemplateShowSet = {} // 显示设置基础表单
+ @observable salaryItemSet = [] // 显示设置薪资项
+
+ // 基础信息表单数据
+ @action
+ setTemplateBaseData = (templateBaseData) => this.templateBaseData = templateBaseData
+
+ // 显示设置基础表单
+ @action
+ setSalaryTemplateShowSet = (salaryTemplateShowSet) => this.salaryTemplateShowSet = salaryTemplateShowSet
+
+ // 初始化操作
+ @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;
+ 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;
+ } else {
+ message.error(res.msg || '接口调用失败!')
+ }
+ this.loading = false;
+ }));
+ }
+
+ @action
+ setShowSearchAd = bool => this.showSearchAd = bool;
+
+ // 高级搜索 - 搜索
+ @action doSearch = () => {
+ this.getTableDatas();
+ this.showSearchAd = false;
+ }
+
+ // 工资单模板-工资单模板列表
+ @action
+ getPayrollTemplateList = () => {
+ let params = {}
+ API.getPayrollTemplateList(params).then(res => {
+ if(res.status) {
+ this.templateStore.getDatas(res.data.datas);
+ } else {
+ message.error(res.errormsg || "获取失败");
+ }
+ })
+ }
+
+ // 工资单模板-获取工资单模板基础设置表单
+ @action
+ getPayrollBaseForm = (id = "") => {
+ let params = {
+ id
+ }
+ return new Promise((resolve, reject) => {
+ API.getPayrollBaseForm(params).then(res => {
+ if(res.status) {
+ let response = res.data.salaryTemplateBaseSet
+ let templateBaseData = response.data
+ templateBaseData.salarySob = templateBaseData.salarySob !== undefined ? templateBaseData.salarySob : null;
+ this.templateBaseData = templateBaseData // 基础信息表单数据
+
+ this.salarySobOptions = response.salarySobOptions ?
+ response.salarySobOptions.map(item => {
+ let result = {}
+ result.showname = item.name;
+ result.key = item.id + "";
+ result.selected = false;
+ return result;
+ }) : []
+ resolve({
+ templateBaseData: this.templateBaseData,
+ salarySobOptions: this.salarySobOptions
+ });
+ } else {
+ message.errro(res.errormsg || "获取失败");
+ reject()
+ }
+ })
+ })
+ }
+
+
+ // 工资单模板-获取工资单模板显示设置表单
+ @action
+ getPayrollShowForm = (id = "") => {
+ let params = {
+ id
+ }
+ API.getPayrollShowForm(params).then(res => {
+ if(res.status) {
+ this.salaryTemplateShowSet = res.data.salaryTemplateShowSet.data
+ } else {
+ message.error(res.errormsg || "获取失败")
+ }
+ })
+ }
+
+ // 工资单模板-获取薪资项目设置
+ @action
+ getPayrollItemList = (salarySobId = "") => {
+ let params = {
+ salarySobId
+ }
+ API.getPayrollItemList(params).then(res => {
+ if(res.status) {
+ this.salaryItemSet = res.data
+ } else {
+ message.error(res.errormsg || "获取失败")
+ }
+ })
+ }
+
+ // 初始化显示设置表单
+ @action
+ initShowSettingForm = (id = "") => {
+ this.getPayrollShowForm(id);
+ if(id == "") {
+ this.getPayrollItemList(this.templateBaseData.salarySob)
+ }
+ }
+
+ // 校验显示设置表单
+ validateSalaryTemplateShowSet = () => {
+ if(!notNull(this.salaryTemplateShowSet.theme)) {
+ message.warning("工资单主题不能为空");
+ return false;
+ }
+ return true;
+ }
+
+ // 拼装保存参数
+ convertParams = () => {
+ let params = {...this.templateBaseData, ...this.salaryTemplateShowSet}
+ params.salarySobId = params.salarySob
+ params.emailStatus = params.emailStatus ? params.emailStatus : false;
+ params.msgStatus = params.msgStatus ? params.msgStatus : false
+ params.salaryItemNullStatus = params.salaryItemNullStatus ? params.salaryItemNullStatus : false;
+ params.salaryItemZeroStatus = params.salaryItemZeroStatus ? params.salaryItemZeroStatus : false;
+ params.salaryItemSetting = this.salaryItemSet
+ return params
+ }
+
+
+ // 工资单模板-新建工资单模板
+ @action
+ fetchSavePayroll = () => {
+ if(!(this.validateSalaryTemplateShowSet())) {
+ return false
+ }
+ let params = this.convertParams()
+ return new Promise((resolve, reject) => {
+ API.savePayroll(params).then(res => {
+ if(res.status) {
+ message.success("保存成功");
+ this.getPayrollTemplateList();
+ resolve();
+ } else {
+ message.error(res.errormsg || "保存失败")
+ reject()
+ }
+ })
+ })
+ }
+
+}
\ No newline at end of file
diff --git a/pc4mobx/hrmSalary/util/validate.js b/pc4mobx/hrmSalary/util/validate.js
index 5c0391fc..0d1ac881 100644
--- a/pc4mobx/hrmSalary/util/validate.js
+++ b/pc4mobx/hrmSalary/util/validate.js
@@ -1,12 +1,18 @@
+/**
+ * 判断是否为空
+ * @param {*} name
+ * @returns false 为空 , true 不为空
+ */
export const notNull = (name) => {
if(typeof(name) == "string") {
name = name.trim()
}
- if(name !== undefined) {
- name = name.toString()
- }
- if(!name || name == "") {
- return false
+ if(typeof(name) == "string") {
+ if(name == "") {
+ return false;
+ }
+ } else if(name === null || name === undefined) {
+ return false;
}
return true
}
\ No newline at end of file