Browse Source

组织管理添加结构物

master
dengyinhuan 2 years ago
parent
commit
64dc7c32e9
  1. 1
      api/app/lib/controllers/organization/user.js
  2. 9
      api/app/lib/models/user.js
  3. 1
      script/1.0.3/schema/7.update_user.sql
  4. 36
      web/client/src/sections/organization/components/userModal.js
  5. 24
      web/client/src/sections/organization/containers/user.js

1
api/app/lib/controllers/organization/user.js

@ -235,6 +235,7 @@ async function creatUser(ctx, next) {
delete: false,
phone: data.phone,
post: data.post,
structure:data.structure
})
ctx.status = 204;

9
api/app/lib/models/user.js

@ -95,6 +95,15 @@ module.exports = dc => {
primaryKey: false,
field: "post",
autoIncrement: false
},
structure: {
type: DataTypes.STRING,
allowNull: true,
defaultValue: null,
comment: "结构物",
primaryKey: false,
field: "structure",
autoIncrement: false
}
}, {
tableName: "user",

1
script/1.0.3/schema/7.update_user.sql

@ -0,0 +1 @@
ALTER TABLE "user" ADD structure VARCHAR(40);

36
web/client/src/sections/organization/components/userModal.js

@ -4,7 +4,7 @@ import { Spin, Card, Modal, TreeSelect, message } from 'antd';
import ProForm, { ProFormText, ModalForm, ProFormSwitch, ProFormTreeSelect } from '@ant-design/pro-form';
const UserModal = (props) => {
const { visible, modalType, depData, onVisibleChange, onConfirm, editData } = props
const { visible, modalType, depData, onVisibleChange, onConfirm, editData ,tableList} = props
const reg_tel = /^1([358][0-9]|4[579]|66|7[0135678]|9[89])[0-9]{8}$/;
const onFinish = (values) => {
if (onConfirm) {
@ -105,7 +105,35 @@ const UserModal = (props) => {
/>
</ProForm.Group>
<ProForm.Group>
<ProFormText
<ProFormTreeSelect
name={['contract', 'structure']}
placeholder="请选择结构物"
width="md"
label="关注结构物"
required
// fieldNames={{
// title: 'name',
// key: 'id',
// children: 'subordinate'
// }}
onSelect={(selectedKeys, { selected, selectedNodes }) => {
}}
fieldProps={{
fieldNames: {
label: 'title',
},
treeDefaultExpandAll: false,
}}
rules={[{ required: true, message: '请选择结构物' }]}
request={async () => {
console.log(tableList);
const opts = tableList?.map(i=>({title:i.name,value:i.id}))
return opts
}}
expandedKeys={["title"]}
/>
<ProFormText
name={['contract', 'email']}
width="md"
label="邮箱"
@ -116,6 +144,9 @@ const UserModal = (props) => {
{ type: 'email', message: '请输入正确格式的邮箱' },
]}
/>
</ProForm.Group>
<ProForm.Group>
{modalType == 'edit' ? null : <ProFormText.Password
name={['contract', 'password']}
width="md"
@ -131,6 +162,7 @@ const UserModal = (props) => {
]}
/>}
</ProForm.Group>
<ProForm.Group>
<ProFormSwitch
name={['contract', 'enable']}

24
web/client/src/sections/organization/containers/user.js

@ -12,13 +12,13 @@ const TreeNode = Tree.TreeNode;
const UserManage = (props) => {
const user = JSON.parse(sessionStorage.getItem('user'));
const { dispatch, loading, depMessage, depUser, clientHeight } = props;
const [tableList, settableList] = useState([])
const { dispatch, loading, depMessage, depUser, clientHeight,actions } = props;
// 部门
const [deptModalVisible, setDeptModalVisible] = useState(false);
const [deptModalType, setDeptModalType] = useState();
const [deptModalRecord, setDeptModalRecord] = useState();
const { projectRegime } = actions
// 成员
const [modalVisible, setModalVisible] = useState(false);
const [modalType, setModalType] = useState();
@ -29,8 +29,20 @@ const UserManage = (props) => {
useEffect(() => {
dispatch(getDepMessage())
projectList()
}, [])
const projectList = (obj) => {
dispatch(projectRegime.getProjectList()).then(res => {
// console.log(res)
if (res.success) {
settableList(res.payload.data?.rows)
// setLimits(res.payload.data?.count)
}
})
}
useEffect(() => {
if (depMessage.length) {
setDepSelectedKeys([depMessage[0].id])
@ -197,7 +209,7 @@ const UserManage = (props) => {
</div>
</div>
}
console.log(tableList,'tableList')
return (<div >
<Spin spinning={loading} /* style={{ height: "calc(100vh - 70px)" }} */>
<Row gutter={16} /* style={{ overflow: "scroll" }} */>
@ -304,6 +316,7 @@ const UserManage = (props) => {
modalType={modalType}
onConfirm={onConfirm}
editData={modalRecord}
tableList={tableList}
/>
: ''
}
@ -325,7 +338,8 @@ function mapStateToProps(state) {
clientHeight: global.clientHeight,
loading: depMessage.isRequesting,
depMessage: depMessage.data || [],
depUser: depUser.data || []
depUser: depUser.data || [],
actions: global.actions
};
}

Loading…
Cancel
Save