Commit db9cad40 authored by 邓超's avatar 邓超

fix: 优化流程,移动应用配置,表模块

parent 690ce428
Pipeline #35661 skipped with stages
......@@ -7,15 +7,30 @@ import Authozed from '@/utils/authority';
import UserLogin from '@/pages/user/login';
import UserLayout from '@/layouts/UserLayout';
import { AUTHORITY, BASENAME } from '@/utils/constants';
import { Modal } from 'antd';
import { PictureWallProvider } from '@/components/Upload/context';
export default appConnector(function App(props) {
const { routesConfig } = props;
const getConfirmation = (msg, callBack) => {
Modal.confirm({
title: '确认',
content: msg,
okText: '确认',
cancelText: '取消',
onOk() {
callBack(true);
},
onCancel() {
callBack(false);
},
});
};
return (
<>
<Helmet titleTemplate="%s - 运维平台" defaultTitle="运维平台">
<meta name="description" content="运维平台" />
</Helmet>
<Router basename={BASENAME}>
<Router basename={BASENAME} getUserConfirmation={getConfirmation}>
<Authozed
noMatch={
<UserLayout>
......
......@@ -9,7 +9,7 @@ import PicturesWall from '@/components/Upload/index';
const { Item } = Form;
const { Option } = Select;
const AddConfig = props => {
const { miniTitle, submitCallback, subType, addCallback } = props;
const { miniTitle, submitCallback, subType, addCallback, singleList } = props;
console.log(subType, 'ubType');
const [config, setConfig] = useState(''); // 网站配置信息
const [loginList, setLoginList] = useState([
......@@ -40,6 +40,19 @@ const AddConfig = props => {
const submit = value => {
form.validateFields().then(valid => {
if (valid) {
if (
singleList.some(
item =>
item.text === valid.title || item.id.slice(6) === valid.client,
)
) {
notification.error({
message: '提示',
duration: 3,
description: '应用名称跟类别不能重复',
});
return;
}
setLoading(true);
const obj = { ...form.getFieldsValue() };
let params = { ...obj, mode: 'single' };
......
......@@ -262,7 +262,11 @@ const MobileConfigPage = props => {
}}
visible={addVisible}
>
<AddConfig addCallback={addCallback} submitCallback={submitCallback} />
<AddConfig
addCallback={addCallback}
submitCallback={submitCallback}
singleList={singleList}
/>
</Drawer>
</PageContainer>
);
......
......@@ -293,7 +293,7 @@ const MiniMenu = props => {
// obj.relatedRoleList = String(roleList) || '';
// }
console.log(obj);
const parentID = item.menuID ? item.menuID : -1;
const parentID = item.menuID ? item.menuID : '-1';
addMenu({
_dc: Date.now(),
parentID,
......@@ -437,7 +437,7 @@ const MiniMenu = props => {
_dc: Date.now(),
}).then(res => {
console.log(res);
if (res.success) {
if (res.code === 0) {
setFlag(flag + 1);
} else {
notification.error({
......
......@@ -216,7 +216,7 @@ const TableManager = (props) => {
align: 'center'
},
{
title: '字段数量',
title: '附加字段',
dataIndex: 'fieldCount',
key: 'fieldCount',
align: 'center',
......@@ -334,7 +334,7 @@ const TableManager = (props) => {
align: 'center',
},
{
title: '字段数量',
title: '附加字段',
dataIndex: 'fieldCount',
key: 'fieldCount',
align: 'center',
......
......@@ -37,6 +37,7 @@ const Workflow = () => {
const [editIndex, setEditIndex] = useState(); // 编辑流程组得索引
const [treeVisible, setTreeVisible] = useState(true);
const [chartLoading, setChartLoading] = useState(false); // 流程图的loading
const [canSelect, setCanSelect] = useState(true); // 是否可以切换树
const [visible, setVisible] = useState({
FlowModal: false,
FlowGroupModal: false,
......@@ -129,8 +130,8 @@ const Workflow = () => {
showModal('FlowGroupModal', true);
setModalType('add');
};
// 点击节点树触发
const onSelect = (prop, treeNode) => {
// 选择节点
const chooseNode = (prop, treeNode) => {
if (!treeNode || treeNode.node.children) {
setCurrentSelectId(treeId);
return;
......@@ -157,6 +158,27 @@ const Workflow = () => {
setCurrentSelectId(treeId);
}
};
// 点击节点树触发
const onSelect = (prop, treeNode) => {
// 如果没有保存弹是否保存弹窗
if (!canSelect) {
confirm({
title: '流程未保存确定要切换吗?',
icon: <ExclamationCircleOutlined />,
content: '',
okText: '是',
okType: 'danger',
cancelText: '否',
onOk() {
setCanSelect(true);
chooseNode(prop, treeNode);
},
onCancel() {},
});
} else {
chooseNode(prop, treeNode);
}
};
// 处理树数据
const mapTree = (val, index) => {
const obj = { ...val };
......@@ -222,6 +244,10 @@ const Workflow = () => {
// 选中当前选中的节点
onSelect();
};
// 数据改变后的回调函数
const leaveCallBack = val => {
setCanSelect(!val);
};
return (
<PageContainer>
<div className={styles.flowContainer}>
......@@ -273,6 +299,7 @@ const Workflow = () => {
flowData={flowData}
flowID={currentSelectId}
chartLoading={chartLoading}
leaveCallBack={leaveCallBack}
/>
) : (
<Empty
......
......@@ -3,6 +3,7 @@ import { Button, Modal, notification, Spin } from 'antd';
import { SaveNodeChange, GetFlowNode } from '@/services/platform/workflow';
import { ExclamationCircleOutlined } from '@ant-design/icons';
import { Prompt } from 'react-router-dom';
import * as go from 'gojs';
import styles from '../workflow.less';
import NodeModal from './flowChartComponents/NodeModal';
......@@ -10,7 +11,7 @@ import imgUrl from '@/assets/images/icons/closeBlue.png';
const { confirm } = Modal;
let diagram = null;
const FlowChart = props => {
const { flowData, flowID, chartLoading } = props;
const { flowData, flowID, chartLoading, leaveCallBack } = props;
const [visible, setVisible] = useState(false);
const [editMsg, setEditMsg] = useState({}); // 编辑节点的信息
const [modalType, setModalType] = useState(''); // 存入弹窗是编辑还是新增
......@@ -20,10 +21,12 @@ const FlowChart = props => {
const [deleteLine, setDeleteLine] = useState(); // 删除的线id
const [deleteNode, setDeleteNode] = useState(); // 删除的节点id
const [AddNodes, setAddNodes] = useState([]); // 新增数组
const [initFlowData, setInitFlowData] = useState({}); // 初始数据,用来比对是否有修改流程图
const [currentFlowData, setCurrentFlowData] = useState({
Nodes: [],
Lines: [],
}); // 组件内得流程图数据
const [showLeaveTip, setShowLeaveTip] = useState(false); // 离开路由是否又提醒
const objGo = go.GraphObject.make;
// 监听删除,给删除数组里添加删除id
useEffect(() => {
......@@ -36,6 +39,7 @@ const FlowChart = props => {
setDeleteNodes([...DeleteNodes, deleteNode]);
}
}, [deleteNode]);
// 初始化
useEffect(() => {
// 初始化流程图
init();
......@@ -73,6 +77,7 @@ const FlowChart = props => {
setDeleteNode('');
setDeleteLine('');
setCurrentFlowData(JSON.parse(JSON.stringify(flowData)));
setShowLeaveTip(false);
}
}, [flowData]);
// 存入在树形流程中选择得流程数据
......@@ -81,13 +86,30 @@ const FlowChart = props => {
if (currentFlowData.Nodes.length === 0) {
nodeDataArray = [];
} else {
nodeDataArray = currentFlowData.Nodes.map(item => {
// 处理老数据,让老数据可以正常展示
nodeDataArray = currentFlowData.Nodes.map((item, index) => {
let obj;
obj = item;
obj.key = item.NodeId;
if (obj.points === '') {
if (obj.NodeType === '1') {
obj.points = `${(index * 200).toString()}" 100"`;
} else {
obj.points = `${(index * 200).toString()}" -22"`;
}
}
return obj;
});
}
// 保存初始数据
setInitFlowData(
JSON.parse(
JSON.stringify({
Nodes: nodeDataArray,
Lines: currentFlowData.Lines,
}),
),
);
diagram.model = go.Model.fromJson({
linkFromPortIdProperty: 'fromPort', // 所需信息:
linkToPortIdProperty: 'toPort', // 标识数据属性名称
......@@ -112,6 +134,8 @@ const FlowChart = props => {
};
// 删除节点
const delNode = () => {
setShowLeaveTip(true);
leaveCallBack(true);
diagram.commandHandler.deleteSelection();
};
// 流程图初始化
......@@ -303,12 +327,30 @@ const FlowChart = props => {
nodeData.roleList = roleList;
diagram.model.updateTargetBindings(nodeData);
}
// 关闭时进行数据比对看数据是否改变
let diagramObj = JSON.parse(diagram.model.toJson());
let stageJson = {
Nodes: diagramObj.nodeDataArray,
Lines: diagramObj.linkDataArray,
};
if (
JSON.stringify(stageJson.Nodes) === JSON.stringify(initFlowData.Nodes)
) {
setShowLeaveTip(false);
leaveCallBack(false);
} else {
leaveCallBack(true);
setShowLeaveTip(true);
}
setVisible(false);
};
// 获取保存后的流程数据
const getFlowData = () => {
GetFlowNode({ flowID }).then(res => {
if (res.code === 0) {
// 保存后离开不用提醒要修改数据了
setShowLeaveTip(false);
leaveCallBack(false);
setCurrentFlowData(res.data);
} else {
notification.error({
......@@ -355,9 +397,15 @@ const FlowChart = props => {
};
return (
<>
<Prompt
message="编辑的内容还未保存,确定要离开该页面吗?"
when={showLeaveTip}
/>
<div className={styles.buttonList}>
<Button onClick={() => addNode()}>添加节点</Button>
<Button onClick={() => saveFlow()}>保存</Button>
<Button type="primary" onClick={() => saveFlow()}>
保存
</Button>
</div>
<Spin spinning={chartLoading}>
<div
......
......@@ -13,7 +13,7 @@ import {
Popconfirm,
message,
} from 'antd';
import { DeleteOutlined } from '@ant-design/icons';
import { DeleteOutlined, EditTwoTone } from '@ant-design/icons';
import RoalChoose from './nodeModalComponents/RoalChoose';
const { Option } = Select;
......@@ -21,6 +21,8 @@ const NodeModal = props => {
const { onSubumit, handleCancel, visible, modalType, editMsg } = props;
const [form] = Form.useForm();
const [showRoal, setShowRoal] = useState(false); // 是否显示选择角色用户弹窗
const [isEdit, setIsEdit] = useState(); // 是编辑角色还是添加角色
const [chooseUser, setChooseUser] = useState(); // 当前编辑角色或者机构的默认承办人
const [nodeMsg, setNodeMsg] = useState({
NodeName: '',
NodeType: '',
......@@ -58,8 +60,8 @@ const NodeModal = props => {
setNodeMsg({ ...nodeMsg, roleList });
};
// 添加用户
const addUser = obj => {
if (obj.roleId === '') {
const addUser = (obj, treeLength) => {
if (obj.roleId === '' || obj.roleName === '' || treeLength === 0) {
notification.error({
message: '提示',
duration: 3,
......@@ -68,7 +70,10 @@ const NodeModal = props => {
return;
}
// 如果已经有角色就提示
if (nodeMsg.roleList.some(item => item.roleId === obj.roleId)) {
if (
nodeMsg.roleList.some(item => item.roleId === obj.roleId) &&
isEdit === 'add'
) {
notification.error({
message: '提示',
duration: 3,
......@@ -76,9 +81,28 @@ const NodeModal = props => {
});
return;
}
// 编辑角色覆盖原有
let chooseIndex = nodeMsg.roleList.findIndex(
item => item.roleId === obj.roleId,
);
let newList;
if (chooseIndex === -1) {
// 添加表格
setNodeMsg({ ...nodeMsg, roleList: [...nodeMsg.roleList, obj] });
} else {
newList = [...nodeMsg.roleList];
newList[chooseIndex] = obj;
// 修改表格
setNodeMsg({ ...nodeMsg, roleList: [...newList] });
}
console.log(chooseIndex, obj, '选中人');
setShowRoal(false);
// 添加表格
setNodeMsg({ ...nodeMsg, roleList: [...nodeMsg.roleList, obj] });
};
// 编辑默认承办人
const toEdit = record => {
setIsEdit('edit');
setChooseUser(record);
setShowRoal(true);
};
// 定义表格
const columns = [
......@@ -120,6 +144,12 @@ const NodeModal = props => {
/>
</Popconfirm>
</Tooltip>
<Tooltip title="修改默认承办人">
<EditTwoTone
onClick={() => toEdit(record)}
style={{ fontSize: '16px', color: '#1890FF' }}
/>
</Tooltip>
</Space>
</>
),
......@@ -196,6 +226,7 @@ const NodeModal = props => {
style={{ marginBottom: '10px' }}
onClick={() => {
setShowRoal(true);
setIsEdit('add');
}}
>
添加
......@@ -207,11 +238,18 @@ const NodeModal = props => {
bordered
size="small"
scroll={{ y: 'calc(100vh - 550px)' }}
onRow={record => ({
onDoubleClick: () => {
toEdit(record);
},
})}
pagination={false}
/>
</Drawer>
<RoalChoose
visible={showRoal}
modalType={isEdit}
chooseUser={chooseUser}
handleCancel={() => setShowRoal(false)}
onSubumit={addUser}
/>
......
......@@ -9,6 +9,8 @@ import {
Pagination,
Spin,
Divider,
notification,
Empty,
} from 'antd';
import Tree from '@/components/ExpendableTree';
import { UserOutlined } from '@ant-design/icons';
......@@ -17,7 +19,7 @@ import styles from '../../../workflow.less';
const CheckboxGroup = Checkbox.Group;
const RoalChoose = props => {
const { onSubumit, handleCancel, visible } = props;
const { onSubumit, handleCancel, visible, modalType, chooseUser } = props;
const [form] = Form.useForm();
const [currentSelectId, setCurrentSelectId] = useState(''); // 当前选择节点Id
const [currentRoalName, setCurrentRoalName] = useState(''); // 当前选择节点名称
......@@ -28,35 +30,70 @@ const RoalChoose = props => {
const [checkAll, setCheckAll] = useState(false); // 全选框全选样式
const [total, setTotal] = useState(); // 角色人员条数
const [loading, setLoading] = useState(false); // 加载时的loading
const [userList, setUserList] = useState([]); // 编辑选中的用户信息
const [currentPage, setCurrentPage] = useState(1);
// 初始化
useEffect(() => {
form.resetFields();
if (visible) {
setCurrentSelectId('');
setCurrentPage(1);
if (modalType === 'edit') {
form.setFieldsValue({ roleName: chooseUser.roleName });
setUserList(chooseUser.defaultUserId);
getData('', 1, 10, chooseUser.roleId);
} else {
getData('', 1, 10);
}
} else {
setUserList([]);
setTreeData([]);
setPlainOptions([]);
setCheckedList([]);
setIndeterminate(false);
setCheckAll(false);
setCurrentPage(1);
getData('', 0);
} else {
setTreeData([]);
}
}, [visible]);
// 获取表单回显
const getData = (roleName, pageIndex, pageSize) => {
// 默认选中第一个
useEffect(() => {
if (treeData.length > 0) {
setCurrentSelectId(treeData[0].id);
setCurrentRoalName(treeData[0].name);
let options = treeData[0].userList.map(item => ({
label: item.name,
value: item.id,
}));
setPlainOptions(options);
}
}, [treeData]);
// 对默认选中的进行处理
useEffect(() => {
if (userList.length > 0 && modalType === 'edit') {
onChange(userList);
} else {
setCheckedList([]);
setIndeterminate(false);
setCheckAll(false);
}
}, [plainOptions]);
// 获取左侧树回显
const getData = (roleName, pageIndex, pageSize, roleId) => {
roleName = roleName || '';
setLoading(true);
GetRoleUser({ roleName, pageIndex, pageSize }).then(res => {
GetRoleUser({ roleName, pageIndex, pageSize, roleId }).then(res => {
setLoading(false);
if (res.code === 0) {
setTreeData(res.data.data);
setTotal(res.data.count);
} else {
notification.error({
message: '提示',
duration: 3,
description: res.msg,
});
}
});
};
// 提交表单
// 保存角色
const onFinish = () => {
form.validateFields().then(validate => {
if (validate) {
......@@ -66,7 +103,7 @@ const RoalChoose = props => {
setIndeterminate(false);
setCheckAll(false);
setCurrentPage(1);
getData(validate.roleName, 1);
getData(validate.roleName, 1, 10);
}
});
};
......@@ -76,6 +113,7 @@ const RoalChoose = props => {
return {
title: obj.name,
key: obj.id,
disabled: modalType === 'edit' && obj.name !== chooseUser.roleName,
userList: obj.userList,
};
};
......@@ -84,16 +122,13 @@ const RoalChoose = props => {
setCurrentRoalName(e.node.title);
if (selectedKeys[0]) {
// 选择后对复选框的用户进行重新赋值
let userList = [...e.node.userList];
let options = userList.map(item => ({
let userLists = [...e.node.userList];
let options = userLists.map(item => ({
label: item.name,
value: item.id,
}));
setCurrentSelectId(selectedKeys[0]);
setPlainOptions(options);
setCheckedList([]);
setIndeterminate(false);
setCheckAll(false);
}
};
// 监听分页
......@@ -143,7 +178,7 @@ const RoalChoose = props => {
defaultUserId: checkedList,
defauletUserName: DeafaultUserName,
};
onSubumit(obj);
onSubumit(obj, treeData.length);
};
return (
<Modal
......@@ -164,12 +199,17 @@ const RoalChoose = props => {
<Form.Item name="roleName">
<Input
prefix={<UserOutlined className="site-form-item-icon" />}
placeholder="RoleName"
placeholder="请输入机构或角色名称"
disabled={modalType === 'edit'}
allowClear
/>
</Form.Item>
<Form.Item>
<Button type="primary" htmlType="submit">
<Button
type="primary"
htmlType="submit"
disabled={modalType === 'edit'}
>
搜索
</Button>
</Form.Item>
......@@ -182,13 +222,20 @@ const RoalChoose = props => {
角色列表
</span>
<Divider style={{ margin: '10px 0' }} />
<Tree
blockNode
autoExpandParent
onSelect={onSelect}
selectedKeys={[currentSelectId]}
treeData={treeData.map(item => mapTree(item))}
/>
{treeData.length > 0 ? (
<Tree
blockNode
autoExpandParent
onSelect={onSelect}
selectedKeys={[currentSelectId]}
treeData={treeData.map(item => mapTree(item))}
/>
) : (
<Empty
image={Empty.PRESENTED_IMAGE_SIMPLE}
description="未有查找到角色"
/>
)}
</div>
</Spin>
{/* 分页 */}
......@@ -215,11 +262,18 @@ const RoalChoose = props => {
</Checkbox>
<Divider style={{ margin: '10px 0' }} />
<div className={styles.checkContent}>
<CheckboxGroup
options={plainOptions}
value={checkedList}
onChange={onChange}
/>
{plainOptions.length > 0 ? (
<CheckboxGroup
options={plainOptions}
value={checkedList}
onChange={onChange}
/>
) : (
<Empty
image={Empty.PRESENTED_IMAGE_SIMPLE}
description="未有查找到用户"
/>
)}
</div>
</div>
</div>
......
......@@ -104,7 +104,7 @@ export const addWebsite = (params, options) => {
// 菜单拖拽
export const dragMenu = params =>
get(`${CITY_SERVICE}/OMS.svc/P_DragMenu`, params);
post(`${PUBLISH_SERVICE}/WebSite/DragMenu `, params);
export const deleteMiniMenu = params =>
get(`${PUBLISH_SERVICE}/PlatformCenter/DeleteMiniMenu`, params);
......
......@@ -13,7 +13,7 @@ export const UpdateFlowGroup = param =>
post(`${PUBLISH_SERVICE}/WorkFlow/UpdateFlowGroup`, param);
// 查询全部角色对应的人员
export const GetRoleUser = param =>
get(`${PUBLISH_SERVICE}/WorkFlow/GetRoleUser`, param);
post(`${PUBLISH_SERVICE}/WorkFlow/GetRoleUser`, param);
// 获取节点信息
export const GetNodeInfo = param =>
get(`${PUBLISH_SERVICE}/WorkFlow/GetNodeInfo`, param);
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment