巴林闲侠 2 years ago
parent
commit
641cf6d3b1
  1. 2
      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

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

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

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

@ -95,6 +95,15 @@ module.exports = dc => {
primaryKey: false, primaryKey: false,
field: "post", field: "post",
autoIncrement: false autoIncrement: false
},
structure: {
type: DataTypes.STRING,
allowNull: true,
defaultValue: null,
comment: "结构物",
primaryKey: false,
field: "structure",
autoIncrement: false
} }
}, { }, {
tableName: "user", 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'; import ProForm, { ProFormText, ModalForm, ProFormSwitch, ProFormTreeSelect } from '@ant-design/pro-form';
const UserModal = (props) => { 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 reg_tel = /^1([358][0-9]|4[579]|66|7[0135678]|9[89])[0-9]{8}$/;
const onFinish = (values) => { const onFinish = (values) => {
if (onConfirm) { if (onConfirm) {
@ -105,7 +105,35 @@ const UserModal = (props) => {
/> />
</ProForm.Group> </ProForm.Group>
<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']} name={['contract', 'email']}
width="md" width="md"
label="邮箱" label="邮箱"
@ -116,6 +144,9 @@ const UserModal = (props) => {
{ type: 'email', message: '请输入正确格式的邮箱' }, { type: 'email', message: '请输入正确格式的邮箱' },
]} ]}
/> />
</ProForm.Group>
<ProForm.Group>
{modalType == 'edit' ? null : <ProFormText.Password {modalType == 'edit' ? null : <ProFormText.Password
name={['contract', 'password']} name={['contract', 'password']}
width="md" width="md"
@ -131,6 +162,7 @@ const UserModal = (props) => {
]} ]}
/>} />}
</ProForm.Group> </ProForm.Group>
<ProForm.Group> <ProForm.Group>
<ProFormSwitch <ProFormSwitch
name={['contract', 'enable']} name={['contract', 'enable']}

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

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

Loading…
Cancel
Save