diff --git a/package.json b/package.json index 1f979fd..d7a879d 100644 --- a/package.json +++ b/package.json @@ -1,11 +1,11 @@ { "private": true, "scripts": { - "start": "set PORT=2000 && cross-env ESLINT=none roadhog server", - "startbt": "set PORT=2001 && cross-env ESLINT=none roadhog server", - "startly": "set PORT=2002 && cross-env ESLINT=none roadhog server", - "startkljl": "set PORT=2003 && cross-env ESLINT=none roadhog server", - "startxt": "set PORT=2004 && cross-env ESLINT=none roadhog server", + "start": "set PORT=5000 && cross-env ESLINT=none roadhog server", + "startbt": "set PORT=5001 && cross-env ESLINT=none roadhog server", + "startly": "set PORT=5002 && cross-env ESLINT=none roadhog server", + "startkljl": "set PORT=5003 && cross-env ESLINT=none roadhog server", + "startxt": "set PORT=5004 && cross-env ESLINT=none roadhog server", "build": "cross-env ESLINT=none roadhog build", "build:report": "cross-env ESLINT=none NODE_ENV=production ANALYZE=true roadhog build" }, diff --git a/src/components/CustomPages/FM/UserEditPageAuth.js b/src/components/CustomPages/FM/UserEditPageAuth.js new file mode 100644 index 0000000..e227069 --- /dev/null +++ b/src/components/CustomPages/FM/UserEditPageAuth.js @@ -0,0 +1,797 @@ +import React from 'react' +import { connect } from 'dva' +import { Button, Row, Col, Form, Input, Select, Transfer, message, Upload, Icon, Modal, DatePicker, Checkbox } from 'antd' +import { + extend, + extendRule, + initFilter, + getOnlyPropertyData, + extendInclude, + setDataFieldValue, + getPropertyData, + guid +} from '../../../utils/common' +import moment from 'moment' +import DropDownPagination from '../../common/DropDownPaginationEx' +import config from '../../../config' +import classNames from 'classnames' +import styles from '../../../baseComponents/Component.css' +import storage from '../../../utils/storage' +import FormPage from '../../FormPage'; +import MultiSelectPagination from "../../common/MultiSelectPagination"; +const Option = Select.Option +const { TextArea } = Input +const CheckboxGroup = Checkbox.Group +class UserEditPageAuth extends React.Component { + // UserEditPage 复制过来处理授权问题 + constructor(props) { + super(props) + this.state = { + data: { + PASSWORD: 'E10ADC3949BA59ABBE56E057F20F883E', // 默认密码为123456 + }, + btns: [], + userGroupTargetKeys: [], + roleTargetKeys: [], + roleGroupTargetKeys: [], + disabled: true, + SignaturePhoto: "" + } + + }; + + componentDidMount() { + this.props.form.resetFields() + this.loadData() + }; + + componentWillReceiveProps(NextProps) { + const { data } = this.props + let { id } = data ? data : {} + if (!id) + id = '' + if (NextProps.custom['userEditClick' + id]) { + this.props.form.resetFields() + this.props.dispatch({ + type: 'custom/save', + payload: { + ['userEditClick' + id]: false + }, + }) + this.loadData() + } + } + + loadDataSource = (orgId) => { + const { dispatch } = this.props + const userGroupJson = initFilter(orgId, '', 'CODE', 1) + extendRule(userGroupJson, 'ENABLE_STATUS', 1, 0) + userGroupJson.OrgType = 1 + dispatch({ + type: 'FMBase/getUserGroupDatasource', + payload: userGroupJson, + }) + const roleJson = initFilter(orgId, '', 'CODE', 1) + extendRule(roleJson, 'ENABLE_STATUS', 1, 0) + roleJson.OrgType = 1 + dispatch({ + type: 'FMBase/getRoleDatasource', + payload: roleJson, + + }) + const roleGroupJson = initFilter(orgId, '', 'CODE', 1) + extendRule(roleGroupJson, 'ENABLE_STATUS', 1, 0) + roleGroupJson.OrgType = 1 + dispatch({ + type: 'FMBase/getRoleGroupDatasource', + payload: roleGroupJson, + }) + }; + loadData = () => { + const { data, formId, login } = this.props + const { id } = data || {} + + if (id) { + const userJson = initFilter(this.props.login.OrgId) + extendRule(userJson, 'ID', 1, id) + extendInclude(userJson, 'Nav_Department') + extendInclude(userJson, 'Nav_ApproveRole') + extendInclude(userJson, 'Nav_Person.Nav_TeamPersons.Nav_Team') + extendInclude(userJson, 'Nav_Person.Nav_Post') + extendInclude(userJson, 'Nav_BelongRoles') + // extendInclude(userJson, 'Nav_BelongRoleGroups') + // extendInclude(userJson, 'Nav_BelongUserGroups') + // extendInclude(userJson, 'Nav_UserPhotoFiles') + extendInclude(userJson, 'Nav_UserPhotoFiles.Nav_ImgFile') + extendInclude(userJson, 'Nav_UserSignFiles.Nav_ImgFile') + extendInclude(userJson, 'Nav_ProdutionUnit.Nav_Enums') + this.props.dispatch({ + type: 'FMUserEdit/getUser', + payload: userJson, + onComplete: (ret) => { + if (ret) { + ret.ID_CARD_SHOW = ret.ID_CARD + if (ret.ID_CARD_SHOW != null && ret.ID_CARD_SHOW.length > 1) { + ret.ID_CARD_SHOW = ret.ID_CARD_SHOW.replace(/^(.{5})(?:\d+)(.{2})$/, "$1***********$2") + } + let userGroup = [] + let role = [] + let roleGroup = [] + if (ret.Nav_BelongRoles) { + ret.Nav_BelongRoles.forEach(item => { + role.push(item.BELONG_ROLE_ID.toString().toUpperCase()) + }) + } + if (ret.Nav_BelongRoleGroups) { + ret.Nav_BelongRoleGroups.forEach(item => { + roleGroup.push(item.BELONG_ROLE_GROUP_ID.toString().toUpperCase()) + }) + } + + if (ret.Nav_BelongUserGroups) { + ret.Nav_BelongUserGroups.forEach(item => { + userGroup.push(item.BELONG_USER_GROUP_ID.toString().toUpperCase()) + }) + } + + this.loadDataSource(ret.ORG_ID) + this.fillData(ret) + this.fillSignData(ret) + this.setState({ + data: ret, + userGroupTargetKeys: userGroup, + roleTargetKeys: role, + roleGroupTargetKeys: roleGroup, + disabled: true, + SignaturePhoto: (ret?.FILE_PATH) ? (config.picServerHost + ret.FILE_PATH) : '', + }) + } + } + }) + } + else { + this.props.form.resetFields() + this.loadDataSource(login.OrgId) + + this.setState({ + data: { + ...this.state.data, + ORG_ID: this.props.login.OrgId, + ENABLE_STATUS: 0, + ID: guid(), + Nav_Person: { + Nav_TeamPersons: [], + Nav_Post: {} + }, + }, + disabled: false, + }) + const { form, } = this.props + const { setFieldsValue } = form + if (this.props.login.OrgCode) { + setFieldsValue({ + CODE: (this.props.login.OrgCode), + }) + } + } + if (formId) { + const btnJson = initFilter(this.props.login.OrgId, '', 'NUM', 0) + extendRule(btnJson, 'PAGE_CUSTOM_FORM_ID', 1, formId) + this.props.dispatch({ + type: 'FMUserEdit/getBtnList', + payload: btnJson, + onComplete: (ret) => { + if (ret) { + this.setState({ + btns: ret, + }) + } + } + }) + } + + + }; + + fillData = (ret) => { + const updateLoadFileList = [] + if (ret.Nav_UserPhotoFiles) { + ret.Nav_UserPhotoFiles.forEach(t => { + updateLoadFileList.push({ + uid: t.ID, + name: t.Nav_ImgFile ? t.Nav_ImgFile.FILE_NAME : '未知文件', + status: 'done', + response: { Data: { imgFileID: t.IMG_FILE_ID }, file: t }, + }) + }) + } + this.setState({ + updateLoadFileList: updateLoadFileList, + }) + } + + fillSignData = (ret) => { + const updateLoadSignFileList = [] + if (ret.Nav_UserSignFiles) { + ret.Nav_UserSignFiles.forEach(t => { + updateLoadSignFileList.push({ + uid: t.ID, + name: t.Nav_ImgFile ? t.Nav_ImgFile.FILE_NAME : '未知文件', + status: 'done', + response: { Data: { imgFileID: t.IMG_FILE_ID }, file: t }, + }) + }) + } + this.setState({ + updateLoadSignFileList: updateLoadSignFileList, + }) + } + saveAuth = () => { + debugger + const { form, dispatch, data } = this.props + const { validateFieldsAndScroll } = form + const { updateLoadFileList, updateLoadSignFileList } = this.state + this.state.data.FILE_PATH = this.state.SignaturePhoto.replace(config.picServerHost, '') + + validateFieldsAndScroll((errors, values) => { + if (errors) return + extend(this.state.data, values) + let updateData = getOnlyPropertyData(this.state.data) + const ret = this.state.data + if (values.ID_CARD_SHOW != null && values.ID_CARD_SHOW != '' && values.ID_CARD_SHOW.indexOf('*') < 0 && (ret.ID_CARD == null || ret.ID_CARD != values.ID_CARD_SHOW)) { + ret.ID_CARD = values.ID_CARD_SHOW + updateData.ID_CARD = values.ID_CARD_SHOW + } + let personTeam = getPropertyData(this.state.data.Nav_Person); + let userGroup = [] + let role = [] + let roleGroup = [] + let userPhoto = [] + let userSign = [] + if (updateLoadFileList) { + updateLoadFileList.forEach(item => { + if (item.response && item.response.Data) { + userPhoto.push({ IMG_FILE_ID: item.response.Data.imgFileID, ORG_ID: updateData.ORG_ID, USER_ID: updateData.ID }) + } + }) + } + if (updateLoadSignFileList) { + updateLoadSignFileList.forEach(item => { + if (item.response && item.response.Data) { + userSign.push({ IMG_FILE_ID: item.response.Data.imgFileID, ORG_ID: updateData.ORG_ID, USER_ID: updateData.ID }) + } + }) + } + if (this.state.roleTargetKeys) { + this.state.roleTargetKeys.forEach(item => { + let isGet = false + if (ret.Nav_BelongRoles) { + ret.Nav_BelongRoles.forEach(t => { + if (t.BELONG_ROLE_ID.toString().toUpperCase() == item) { + role.push(t) + isGet = true + } + }) + } + if (!isGet) { + role.push({ BELONG_ROLE_ID: item, ORG_ID: updateData.ORG_ID }) + } + }) + } + + if (this.state.userGroupTargetKeys) { + this.state.userGroupTargetKeys.forEach(item => { + let isGet = false + if (ret.Nav_BelongUserGroups) { + ret.Nav_BelongUserGroups.forEach(t => { + if (t.BELONG_USER_GROUP_ID.toString().toUpperCase() == item) { + userGroup.push(t) + isGet = true + } + }) + } + if (!isGet) { + userGroup.push({ BELONG_USER_GROUP_ID: item, ORG_ID: updateData.ORG_ID }) + } + }) + } + + + if (this.state.roleGroupTargetKeys) { + this.state.roleGroupTargetKeys.forEach(item => { + let isGet = false + if (ret.Nav_BelongRoleGroups) { + ret.Nav_BelongRoleGroups.forEach(t => { + if (t.BELONG_ROLE_GROUP_ID.toString().toUpperCase() == item) { + roleGroup.push(t) + isGet = true + } + }) + } + if (!isGet) { + roleGroup.push({ BELONG_ROLE_GROUP_ID: item, ORG_ID: updateData.ORG_ID }) + } + }) + } + + updateData['Nav_BelongRoles'] = role + updateData['Nav_BelongUserGroups'] = userGroup + updateData['Nav_BelongRoleGroups'] = roleGroup + // updateData['Nav_UserPhotoFiles'] = userPhoto + // updateData['Nav_UserSignFiles'] = userSign + // updateData['Nav_Person'] = personTeam; + dispatch({ + // type: 'FMUserEdit/updateUserAuth', + // //type: 'FMUserEdit/updateUser', + // payload: updateData, + + type: 'app/getDataByPost', + payload: updateData, + url: 'FM/User/UpdateAuth', + onComplete: (ret) => { + if (ret) { + if (data.close) { + data.close() + } + message.success('执行成功') + } + } + }) + + // if (data && data.length > 0) { + // let json = initFilter(this.props.login.OrgId, record.ID); + // this.props.dispatch({ + // type: 'app/getDataByPost', + // payload: json, + // url: 'FM/User/GetProductionUnit', + // onComplete: (ret) => { + // if (ret) { + // this.setState({ + // data: { + // ...this.state.data, + // MineType: ret.MineType + // } + // }) + // } + // } + // }); + // this.setState({ + // data: { + // ...this.state.data, + // DEPARTMENT_ID: data[0], + // Nav_Department: { NAME: record.NAME }, + // } + // }) + // } + // else { + // this.setState({ + // data: { + // ...this.state.data, + // Nav_Department: { NAME: null }, + // DEPARTMENT_ID: null, + // } + // }) + // }; + + }) + }; + + handleSopClick = async function (recordId, ids) { + await this.props.dispatch({ + type: 'custom/save', + payload: { + ['sopViewClick' + recordId]: true, + }, + }); + }; + + handleSopShowModal = (file) => { + this.setState({ + sopData: { ids: file.response.Data.imgFileID, id: file.response.Data.imgFileID }, + sopVisible: true + }, () => { + this.handleSopClick(file.response.Data.imgFileID, file.response.Data.imgFileID); + }); + }; + handleSopCloseModal = () => { + this.setState({ + sopVisible: false + }); + }; + + render() { + const { form } = this.props + const { getFieldDecorator } = form + + const handleRoleChange = (nextTargetKeys, direction, moveKeys) => { + this.setState({ roleTargetKeys: nextTargetKeys }) + } + const formItemLayout = { + labelCol: { span: 6 }, + wrapperCol: { span: 18 }, + } + const onSelectDepartment = ({ data, record }) => { + + if (data && data.length > 0) { + let json = initFilter(this.props.login.OrgId, record.ID); + this.props.dispatch({ + type: 'app/getDataByPost', + payload: json, + url: 'FM/User/GetProductionUnit', + onComplete: (ret) => { + if (ret) { + this.setState({ + data: { + ...this.state.data, + MineType: ret.MineType + } + }) + } + } + }); + this.setState({ + data: { + ...this.state.data, + DEPARTMENT_ID: data[0], + Nav_Department: { NAME: record.NAME }, + } + }) + } + else { + this.setState({ + data: { + ...this.state.data, + Nav_Department: { NAME: null }, + DEPARTMENT_ID: null, + } + }) + }; + } + const onSelectApproveRole = ({ data, record }) => { + + if (data && data.length > 0) { + this.setState({ + data: { + ...this.state.data, + APPROVE_ROLE_ID: data[0], + Nav_ApproveRole: { NAME: record.NAME } + } + }) + } + else { + this.setState({ + data: { + ...this.state.data, + Nav_ApproveRole: { NAME: null }, + APPROVE_ROLE_ID: null, + } + }) + }; + } + const onSelectPost = ({ data, record }) => { + var tmpData = { ...this.state.data }; + if (data && data.length > 0) { + tmpData.Nav_Person.Post_ID = data[0]; + tmpData.Nav_Person.Nav_Post = { NAME: record.NAME }; + + } + else { + tmpData.Nav_Person.Post_ID = ''; + tmpData.Nav_Person.Nav_Post = { NAME: '' }; + }; + this.setState({ + data: tmpData + }) + } + const onSelectPerson = ({ data, record }) => { + if (data && data.length > 0) { + this.setState({ + data: { + ...this.state.data, + PERSON_ID: data[0], + Nav_Person: { NAME: record.NAME } + } + }) + } + else { + this.setState({ + data: { + ...this.state.data, + Nav_Person: { NAME: null }, + PERSON_ID: null, + } + }) + }; + } + + const onSelectTeam = (value) => { + var tmpData = { ...this.state.data } + setDataFieldValue(tmpData, 'Nav_Person.Nav_TeamPersons', value) + this.setState({ + data: tmpData, + }); + } + const onSelectProduction = (value) => { + var tmpData = { ...this.state.data } + setDataFieldValue(tmpData, 'Nav_ProdutionUnit', value) + this.setState({ + data: tmpData, + }); + } + const onUnitChange = (value) => { + var tmpData = { ...this.state.data } + if (value.length == 0) { + setDataFieldValue(tmpData, 'MineType', value.toString()) + } + else { + setDataFieldValue(tmpData, 'MineType', tmpData.MineType + "," + value.toString()) + } + this.setState({ + data: tmpData, + }); + } + const onChange = (field, value,) => { + const data = { ...this.state.data }; + data[field] = value; + this.setState({ + data: data, + }); + } + + const that = this + const Tenant = storage('lacal').getItem('Tenant').val + const uploadSopProps = { + name: 'file', + action: config.serviceHost('api/PF/File/UploadFileToImage'), + data: { OrgId: this.props.login.OrgId, IsSaveSelf: true }, + fileList: this.state.updateLoadFileList, + headers: { + Tenant: Tenant, + }, + onPreview: function (file) { + that.handleSopShowModal(file); + }, + onChange(info) { + that.setState({ + updateLoadFileList: info.fileList, + }) + if (info.file.status === 'done') { + message.success(`${info.file.name} file uploaded successfully`) + } else if (info.file.status === 'error') { + message.error(`${info.file.name} file upload failed.`) + } + }, + } + + const uploadSingProps = { + name: 'file', + action: config.serviceHost('api/PF/File/UploadFileToImage'), + data: { OrgId: this.props.login.OrgId, IsSaveSelf: true, USER_ID: this.props.data.id }, + fileList: this.state.updateLoadSignFileList, + headers: { + Tenant: Tenant, + }, + onPreview: function (file) { + that.handleSopShowModal(file); + }, + onChange(info) { + that.setState({ + updateLoadSignFileList: info.fileList, + SignaturePhoto: config.picServerHost + info?.file?.response?.Data.imgFilePath + }) + if (info.file.status === 'done') { + // console.log(that.state) + message.success(`${info.file.name} file uploaded successfully`) + } else if (info.file.status === 'error') { + message.error(`${info.file.name} file upload failed.`) + } + }, + } + return ( +
+
+
+ +
+
+ + + + + + {getFieldDecorator('NAME', { + validateTrigger: 'onBlur', + initialValue: this.state.data.NAME, + rules: [{ required: true, message: '请输入姓名' }], + })()} + + + + + {getFieldDecorator('CODE', { + validateTrigger: 'onBlur', + initialValue: this.state.data.CODE, + rules: [{ required: true, message: '请输入登入名' }], + })()} + + + + + {getFieldDecorator('Nav_Department.NAME', { + validateTrigger: 'onBlur', + initialValue: this.state.data?.Nav_Department?.NAME, + })()} + + + + + {getFieldDecorator('Nav_Person.Nav_Post.NAME', { + validateTrigger: 'onBlur', + initialValue: this.state.data?.Nav_Person?.Nav_Post?.NAME, + })()} + + + + + {getFieldDecorator('PHONE', { + validateTrigger: 'onBlur', + initialValue: this.state.data.PHONE, + rules: [], + })()} + + + + + {getFieldDecorator('ID_CARD_SHOW', { + initialValue: this.state.data.ID_CARD_SHOW, + rules: [], + })()} + + + + + {getFieldDecorator('SEX', { + initialValue: this.state.data.SEX ? this.state.data.SEX.toString() : "0", + rules: [], + })()} + + + + + { onChange('ENTRYTIME', dateString, 0) }} + /> + + + + + { onChange('DEPARTURETIME', dateString, 0) }} + /> + + + + + {getFieldDecorator('WORKINGYEAR', { + initialValue: this.state.data.WORKINGYEAR, + rules: [], + })()} + + + + + {getFieldDecorator('Nav_ApproveRole.NAME', { + validateTrigger: 'onBlur', + initialValue: this.state.data?.Nav_ApproveRole?.NAME, + })()} + + + + + { + // extendRule(params, 'CODE', 1, 'BSMineTypeEnum'); + params.OrderType = 1 + params.OrgId = this.state.data ? this.state.data.ORG_ID : this.props.login.OrgId + // params.Parameter1='BSMineTypeEnum' + }} /> + + + + + + {getFieldDecorator('REMARK', { + initialValue: this.state.data.REMARK, + })(