Commit 365074f7 authored by 涂伟's avatar 涂伟

fix: '1.运维维保卡片配置功能2.编码填写校验逻辑优化3.台账表设置表单样式优化'

parent a6c4d4d5
Pipeline #70618 waiting for manual action with stages
......@@ -122,7 +122,7 @@
"js-calendar-converter": "0.0.4",
"lodash": "4.17.11",
"minimist": "1.2.0",
"panda-xform": "^3.0.7",
"panda-xform": "^3.10.4",
"prop-types": "15.7.2",
"quill": "^1.3.7",
"rc-tween-one": "^3.0.6",
......
......@@ -467,7 +467,7 @@ const TableManager = props => {
title: '名称',
dataIndex: 'tableName',
key: 'tableName',
width: 400,
width: 200,
render: (text, record) => (
<div
onClick={e => fieldsConfig(record, e)}
......@@ -496,6 +496,7 @@ const TableManager = props => {
dataIndex: 'tableAlias',
key: 'tableAlias',
align: 'center',
width: 200,
render: text => <div>{text || <span style={{ color: 'grey' }}>(无)</span>}</div>,
},
{
......@@ -503,7 +504,7 @@ const TableManager = props => {
dataIndex: 'tableStyle',
key: 'tableStyle',
align: 'center',
width: 80,
width: 100,
render: text => <div>{!text ? <span style={{ color: 'grey' }}>(无)</span> : text}</div>,
},
// {
......
......@@ -15,6 +15,29 @@
.ant-pagination {
padding: 10px;
}
.tabs {
display: flex;
align-items: center;
justify-content: center;
float: left;
margin-left: 10px;
height: 100%;
>div {
margin-right: 10px;
border: 1px solid gainsboro;
padding: 5px 10px;
border-radius: 3px;
&:hover {
cursor: pointer;
}
&.active {
border-color: rgb(24,144,255);
color: rgb(24,144,255);
}
}
}
}
.ant-card-body {
......@@ -64,6 +87,10 @@
width: 100%;
}
.optionModal {
}
.doctorTable {
margin-bottom: 16px;
}
......
import React, { useEffect, useState, useRef, useMemo } from 'react';
import { Modal, Divider, Checkbox } from 'antd';
import styles from './optionEdit.less';
import DragTable from '@/components/DragTable/DragTable';
const CheckboxGroup = Checkbox.Group;
const Fieldselection = props => {
// 自定义获取改变后的值hooks
const usePrevious = value => {
const ref = useRef();
useEffect(() => {
ref.current = value;
});
return ref.current;
};
const { onSubumit, handleCancel, visible, fieldList, fieldData, fieldName } = props;
const [checkList, setCheckList] = useState([]);
const [selectList, setSelectList] = useState([]); // 选中字段列表
const [isFirst, setIsFirst] = useState(true);
const prevAmount = usePrevious({ checkList });
const columns = [
{
title: '字段名',
dataIndex: 'name',
width: 150,
key: 'name',
},
];
useEffect(() => {
if (visible) {
setCheckList(fieldList);
let newArr = fieldData.map(item => ({ name: item }));
setSelectList(newArr);
} else {
setSelectList([]);
setCheckList([]);
setIsFirst(true);
}
}, [visible]);
useEffect(() => {
if (prevAmount) {
selectAll();
}
}, [checkList]);
const selectAll = () => {
if (!visible) {
return;
}
// 是否第一次保存数据
if (isFirst) {
setIsFirst(false);
return;
}
// 新的选择后的数据(已选字段列表数据)
let newSelect = JSON.parse(JSON.stringify(selectList));
// 当前选中的
let currentArr = [];
// 上一次选中的
let preArr = [];
// 获取扁平化后的数组
checkList.forEach(item => {
currentArr = [...currentArr, ...item.defaultCheckedList];
});
prevAmount.checkList.forEach(item => {
preArr = [...preArr, ...item.defaultCheckedList];
});
currentArr = new Set(currentArr);
preArr = new Set(preArr);
// 找出相同的部分
let someArr = [...new Set([...currentArr].filter(x => preArr.has(x)))];
// 复选框事选中还是取消选中 add or del
let checkType;
if ([...currentArr].length > [...preArr].length) {
checkType = 'add';
} else if ([...currentArr].length < [...preArr].length) {
checkType = 'del';
}
if (checkType === 'add') {
// 添加新选中的元素
currentArr.forEach(item => {
if (someArr.indexOf(item) === -1) {
newSelect.push({ name: item });
}
});
} else if (checkType === 'del') {
// 删除取消勾选的元素
preArr.forEach(item => {
if (someArr.indexOf(item) === -1) {
newSelect.splice(newSelect.findIndex(ele => ele.name === item), 1);
}
});
}
setSelectList(newSelect);
};
// 提交表单
const onFinish = () => {
let callArr = selectList.map(item => item.name);
onSubumit(callArr);
};
// 复选框
const onChange = (list, index) => {
setCheckList(value => {
const chooseList = JSON.parse(JSON.stringify(value));
chooseList[index].defaultCheckedList = list;
chooseList[index].indeterminate =
!!list.length && list.length < chooseList[index].plainOptions.length;
chooseList[index].checkAll = list.length === chooseList[index].plainOptions.length;
return chooseList;
});
};
// 全选
const onCheckAllChange = (e, index) => {
setCheckList(value => {
const chooseList = JSON.parse(JSON.stringify(value));
chooseList[index].defaultCheckedList = e.target.checked ? chooseList[index].plainOptions : [];
chooseList[index].indeterminate = false;
chooseList[index].checkAll = e.target.checked;
return chooseList;
});
};
// 拖拽回调
const dragCallBack = arr => {
if (arr) {
setSelectList(arr);
}
};
return (
<Modal
title={fieldName === 'CarField' ? '卡片字段配置' : '详情字段配置'}
visible={visible}
onOk={onFinish}
width="750px"
onCancel={handleCancel}
maskClosable={false}
destroyOnClose
centered
>
<div className={styles.fieldContent}>
{/* 待选字段列表 */}
<div className={styles.willSelectBox}>
<div className={styles.header}>
<Divider orientation="left" className={styles.headDivider}>
待选字段列表
</Divider>
</div>
<div className={styles.cardContent}>
{checkList.map((item, index) => (
<div className={styles.cardBox} key={index}>
<div className={styles.title}>
<Divider orientation="left" className={styles.cardDivider}>
<span className={styles.groupName}>{item.groupName}</span>
<Checkbox
indeterminate={item.indeterminate}
onChange={e => onCheckAllChange(e, index)}
checked={item.checkAll}
/>
</Divider>
</div>
<div className={styles.filedList}>
<CheckboxGroup
key={index}
options={item.plainOptions}
value={item.defaultCheckedList}
onChange={list => onChange(list, index)}
/>
</div>
</div>
))}
</div>
</div>
{/* 已选字段列表 */}
<div className={styles.hasSelectBox}>
<div className={styles.header}>
<Divider orientation="left" className={styles.headDivider}>
已选字段列表
</Divider>
</div>
<div className={styles.doctorTable}>
<DragTable
bordered
rowKey={record => record.name}
columns={columns}
dataSource={selectList}
pagination={false}
size="small"
dragCallBack={dragCallBack}
ItemTypes="stadingOrder"
/>
</div>
</div>
</div>
</Modal>
);
};
export default Fieldselection;
// 字段集选择
.fieldContent {
display: flex;
.willSelectBox {
width: 50%;
height: 600px;
overflow-y: scroll;
padding: 8px;
border-right: 1px solid rgb(153, 187, 232);
box-sizing: border-box;
.cardContent {
height: 530px;
overflow-y: scroll;
.cardBox {
padding: 10px;
margin-bottom: 10px;
border: 1px solid #b5b8c8;
box-sizing: border-box;
}
.filedList {
.ant-checkbox-wrapper {
width: 100%;
}
}
}
}
.hasSelectBox {
width: 50%;
height: 600px;
padding: 8px 8px 8px 12px;
box-sizing: border-box;
.doctorTable {
margin-bottom: 16px;
height: 530px;
overflow-y: scroll;
}
}
.header {
margin: 0px 0px 10px;
background-color: rgb(223, 232, 246);
.headDivider {
margin-bottom: 10px;
background-color: #dfe8f6;
}
}
.cardDivider {
margin-bottom: 10px;
font-weight: 700;
color: #15428b;
line-height: 100%;
border-top-color: #99bbe8;
.groupName {
display: inline-block;
margin-right: 10px;
max-width: 200px;
overflow: hidden;
text-overflow: ellipsis;
white-space: nowrap;
vertical-align: middle;
}
.ant-checkbox-wrapper {
vertical-align: middle;
}
}
}
\ No newline at end of file
.feedBack {
display: flex;
flex-wrap: wrap;
>div {
width: 51%;
}
}
\ No newline at end of file
......@@ -1506,12 +1506,22 @@ const AddModal = props => {
required: true,
message: '请输入编码前缀',
},
{
validator: (rule, value) => {
let regex = new RegExp(/^[A-Z]{2,6}$/g);
if (!regex.test(value)) {
return Promise.reject('编码只能输入2-6位纯大写英文!');
}
return Promise.resolve();
},
},
]}
>
<Input
value={prefixName}
placeholder="请输入编码前缀"
style={{ marginLeft: '-3px' }}
maxLength={6}
/>
</Item>
</Col>
......
......@@ -429,7 +429,7 @@ const incident = () => {
});
},
okText: '确认导入',
cancelText: '我想想',
cancelText: '我想想',
});
} else {
message.error(res.msg);
......
......@@ -203,6 +203,7 @@ const NodeEdit = props => {
setFieldName(val);
loadEventFields({ eventTableName: value.TableName }).then(res => {
if (res.code === 0) {
console.log(value[val], value, val, 'valuevaluevaluevaluevalue');
let defaultCheckedList = value[val] ? value[val].split(',') : [];
// 保存所有的字段用于右侧显示
......
......@@ -540,14 +540,14 @@ const FlowModal = props => {
if (modalType === 'edit' && keep.indexOf(aa) != -1 && aa != msg.FlowName) {
return Promise.reject('流程名称已存在');
}
prefix(value);
// prefix(value);
// form.setFieldsValue({ Type: msg.name, Prefix: value });
return Promise.resolve();
},
},
]}
>
<Input placeholder="请输入流程名称" readOnly={modalType === 'edit'} />
<Input placeholder="请输入流程名称" onChange={prefix} readOnly={modalType === 'edit'} />
</Form.Item>
<Form.Item
label="分组信息"
......@@ -584,9 +584,18 @@ const FlowModal = props => {
required: true,
message: '请输入编码前缀',
},
{
validator: (rule, value) => {
let regex = new RegExp(/^[A-Z]{2,6}$/g);
if (!regex.test(value)) {
return Promise.reject('编码只能输入2-6位纯大写英文!');
}
return Promise.resolve();
},
},
]}
>
<Input placeholder="请输入编码前缀" maxLength={12} />
<Input placeholder="请输入编码前缀" maxLength={6} />
</Form.Item>
<Form.Item label="流程描述" name="Text">
<Input placeholder="请输入流程描述" />
......
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