diff --git a/pc4mobx/hrmSalary/apis/payroll.js b/pc4mobx/hrmSalary/apis/payroll.js index c322c94f..fdef4e0e 100644 --- a/pc4mobx/hrmSalary/apis/payroll.js +++ b/pc4mobx/hrmSalary/apis/payroll.js @@ -202,8 +202,12 @@ export const salaryBillSendSum = (params) => { return postFetch("/api/bs/hrmsalary/salaryBill/send/sum", params); }; //工资单发放-发送短信验证码 -export const sendMobileCode = (params) => { - return postFetch("/api/bs/hrmsalary/salaryBill/sendMobileCode", params); +export const sendMobileCode = (params, header = {}) => { + return postFetch("/api/bs/hrmsalary/salaryBill/sendMobileCode", params, header); +}; +//工资单发放-发送短信验证码 +export const checkMobileCode = (params, header = {}) => { + return postFetch("/api/bs/hrmsalary/salaryBill/checkMobileCode", params, header); }; //工资单-验证方式 export const payrollCheckType = params => { diff --git a/pc4mobx/hrmSalary/components/captchaModal/index.js b/pc4mobx/hrmSalary/components/captchaModal/index.js index a7f00b9b..1ae52279 100644 --- a/pc4mobx/hrmSalary/components/captchaModal/index.js +++ b/pc4mobx/hrmSalary/components/captchaModal/index.js @@ -6,22 +6,29 @@ */ import React, { Component } from "react"; import { WeaDialog, WeaError, WeaFormItem, WeaInput, WeaLocaleProvider, WeaSearchGroup } from "ecCom"; -import { sendMobileCode } from "../../apis/payroll"; -import { Button } from "antd"; +import { WeaForm, WeaSwitch } from "comsMobx"; +import { checkMobileCode, sendMobileCode } from "../../apis/payroll"; +import { getQueryString } from "../../util/url"; +import FormInfo from "../FormInfo"; +import { captchaCondition } from "../../pages/mobilePayroll/pwdCondtion"; +import MobileModal from "../../pages/mobilePayroll/mobileModal"; +import { Button, message } from "antd"; import "./index.less"; +const form = new WeaForm(); const { getLabel } = WeaLocaleProvider; class Index extends Component { constructor(props) { super(props); - this.state = { - captcha: "", - time: 60 - }; + this.state = { captcha: "", time: 60 }; this.timeRef = null; } + componentDidMount() { + form.initFormFields(captchaCondition); + } + componentWillUnmount() { clearInterval(this.timeRef); } @@ -48,44 +55,73 @@ class Index extends Component { } }); }; - handleConfirm = () => { - if (!this.state.captcha) { + handleConfirm = async () => { + const type = getQueryString("type"), f = await form.validateForm(); + if (!this.state.captcha && type !== "phone") { this.refs.weaError.showError(); - // return + return; + } else if (!f.isValid && type === "phone") { + f.showErrors(); + return; } - this.props.onCancel(); - this.props.onConfirm(); + checkMobileCode({ id: this.props.id, mobileCode: this.state.captcha }).then(({ status, errormsg }) => { + if (status) { + this.props.onCancel(); + this.props.onConfirm(); + } else { + message.error(errormsg); + } + }); }; render() { - const { captcha, time } = this.state; - return ( - {getLabel(826, "确定")} - ]} - > - - - -
- this.setState({ captcha })}/> - -
-
-
-
-
+ const { captcha, time } = this.state, type = getQueryString("type"); + const itemRender = { + mobileCode: (field, textAreaProps, form, formParams) => { + return (
+ this.setState({ captcha: form.getFormParams().mobileCode })}/> + +
); + } + }; + return ( + { + type === "phone" ? + + : + {getLabel(826, "确定")} + ]} + > + + + +
+ this.setState({ captcha })}/> + +
+
+
+
+
+ } +
); } } diff --git a/pc4mobx/hrmSalary/components/captchaModal/index.less b/pc4mobx/hrmSalary/components/captchaModal/index.less index 4f8d23b7..2728112b 100644 --- a/pc4mobx/hrmSalary/components/captchaModal/index.less +++ b/pc4mobx/hrmSalary/components/captchaModal/index.less @@ -5,25 +5,25 @@ .wea-form-item-wrapper { .wea-error { width: 100%; - - .captchaInputBox { - display: flex; - align-items: center; - - .wea-input-normal { - flex: 1; - } - - button { - padding: 8px 10px; - border-radius: 0; - min-width: 80px; - text-align: center; - height: 30px; - line-height: 15px; - } - } } } } } + +.captchaInputBox { + display: flex; + align-items: center; + + .wea-input-normal { + flex: 1; + } + + button { + padding: 8px 10px; + border-radius: 0; + min-width: 80px; + text-align: center; + height: 30px; + line-height: 15px; + } +} diff --git a/pc4mobx/hrmSalary/pages/mobilePayroll/index.js b/pc4mobx/hrmSalary/pages/mobilePayroll/index.js index a1756ede..2c429758 100644 --- a/pc4mobx/hrmSalary/pages/mobilePayroll/index.js +++ b/pc4mobx/hrmSalary/pages/mobilePayroll/index.js @@ -37,15 +37,12 @@ export default class MobilePayroll extends React.Component { this.id = getQueryString("id"); const { mySalaryStore: { init, setMySalaryBill } } = this.props; setMySalaryBill({}); - if (type !== "phone") { - const { data, status } = await payrollCheckType(); - if (status && data === "PWD") { - init(false, () => this.getMySalaryBill(this.id)); - } else { - this.setState({ captchaVisible: true }); - } + const { data, status } = await payrollCheckType(); + if (status && data === "PWD") { + type !== "phone" ? init(false, () => this.getMySalaryBill(this.id)) : await this.initMobile(); + } else { + this.setState({ captchaVisible: true }); } - type === "phone" && await this.initMobile(); } initMobile = async () => { @@ -159,7 +156,10 @@ export default class MobilePayroll extends React.Component { this.setState({ captchaVisible: false })} - onConfirm={() => this.props.mySalaryStore.setInitEmVerify()} + onConfirm={() => { + setInitEmVerify(); + this.getMySalaryBill(getQueryString("id")); + }} /> ; const { diff --git a/pc4mobx/hrmSalary/pages/mobilePayroll/pwdCondtion.js b/pc4mobx/hrmSalary/pages/mobilePayroll/pwdCondtion.js index 5cb571e6..159807e0 100644 --- a/pc4mobx/hrmSalary/pages/mobilePayroll/pwdCondtion.js +++ b/pc4mobx/hrmSalary/pages/mobilePayroll/pwdCondtion.js @@ -1,6 +1,25 @@ import { WeaLocaleProvider } from "ecCom"; const { getLabel } = WeaLocaleProvider; +export const captchaCondition = [ + { + items: [ + { + colSpan: 1, + conditionType: "INPUT", + domkey: ["mobileCode"], + fieldcol: 18, + label: getLabel(111, "验证码"), + labelcol: 6, + detailtype: 1, + rules: "required|string", + viewAttr: 3 + } + ], + title: "", + defaultshow: true + } +]; export const loginCondition = [ { items: [ diff --git a/pc4mobx/hrmSalary/util/request.js b/pc4mobx/hrmSalary/util/request.js index 4fd7e4e4..ef487037 100644 --- a/pc4mobx/hrmSalary/util/request.js +++ b/pc4mobx/hrmSalary/util/request.js @@ -16,12 +16,12 @@ export const formHeaderPost = (url, method, params, header) => { body: formdata }).then(res => res.json()); }; -export const postFetch = (url, params) => { +export const postFetch = (url, params, header = {}) => { if (typeof localStorage.access_token === "string" && localStorage.access_token !== "") { params.access_token = localStorage.access_token; } url = server + url + "?__random__=" + (new Date()).valueOf(); - return fetch(url, getFetchParams("POST", params)).then(res => res.json()); + return fetch(url, getFetchParams("POST", params, header)).then(res => res.json()); }; export const headerRequestFetch = (url, method, params, header) => { if (typeof localStorage.access_token === "string" && localStorage.access_token !== "") {