Commit b9e31db7 authored by 皮倩雯's avatar 皮倩雯

fix: '内置字段'

parent be3a5c2f
Pipeline #60885 waiting for manual action with stages
...@@ -4,7 +4,6 @@ import { Form, Modal, Input, Select, Checkbox, notification, Card } from 'antd'; ...@@ -4,7 +4,6 @@ import { Form, Modal, Input, Select, Checkbox, notification, Card } from 'antd';
import { loadTableFields, addTables, addFields } from '@/services/tablemanager/tablemanager'; import { loadTableFields, addTables, addFields } from '@/services/tablemanager/tablemanager';
import styles from './index.less'; import styles from './index.less';
const CheckboxGroup = Checkbox.Group; const CheckboxGroup = Checkbox.Group;
import qs from 'qs';
const { Option } = Select; const { Option } = Select;
const AddModal = props => { const AddModal = props => {
const { callBackSubmit = () => {}, type, visible, tableList, formObj } = props; const { callBackSubmit = () => {}, type, visible, tableList, formObj } = props;
...@@ -12,20 +11,61 @@ const AddModal = props => { ...@@ -12,20 +11,61 @@ const AddModal = props => {
const [form] = Form.useForm(); const [form] = Form.useForm();
const { Item } = Form; const { Item } = Form;
const [plainOptions, setPlainOptions] = useState([]); // 复选框所有内容 const [plainOptions, setPlainOptions] = useState([]); // 复选框所有内容
const [plainOptionsInside, setPlainOptionsInside] = useState([]); // 复选框所有内容
const [checkedList, setCheckedList] = useState([]); // 选中的复选框内容 const [checkedList, setCheckedList] = useState([]); // 选中的复选框内容
const [indeterminate, setIndeterminate] = useState(true); const [indeterminate, setIndeterminate] = useState(true);
const [checkAll, setCheckAll] = useState(false); const [checkAll, setCheckAll] = useState(false);
const [indeterminate1, setIndeterminate1] = useState(false); // 内置分组
const [checkAll1, setCheckAll1] = useState(false); // 内置分组
const onChange = list => { const onChange = list => {
setCheckedList(list); setCheckedList(list);
setIndeterminate(!!list.length && list.length < plainOptions.length); let data = [];
setCheckAll(list.length === plainOptions.length); if (plainOptionsInside.length > 0) {
plainOptionsInside.map(i => {
if (i.isCheck) {
data.push(i);
}
});
}
let aa = data.length + list.length;
let bb = plainOptionsInside.length + plainOptions.length;
setIndeterminate(!!aa && aa < bb);
setCheckAll(aa == bb);
}; };
const onCheckAllChange = e => { const onCheckAllChange = e => {
setCheckedList(e.target.checked ? plainOptions : []); setCheckedList(e.target.checked ? plainOptions : []);
setIndeterminate(false); setIndeterminate(false);
setCheckAll(e.target.checked); setCheckAll(e.target.checked);
let data = [...plainOptionsInside];
data.map(i => {
i.isCheck = e.target.checked;
});
setPlainOptionsInside(data);
setIndeterminate1(false);
setCheckAll1(e.target.checked);
};
const onCheckAllChange1 = e => {
let data = [...plainOptionsInside];
data.map(i => {
i.isCheck = e.target.checked;
});
let list = [];
data.map(j => {
if (j.isCheck) {
list.push(j);
}
});
setPlainOptionsInside(data);
setIndeterminate1(false);
setCheckAll1(e.target.checked);
let aa = list.length + checkedList.length;
let bb = plainOptionsInside.length + plainOptions.length;
setCheckAll(aa == bb);
setIndeterminate(!!aa && aa < bb);
}; };
// 提交 // 提交
const onSubmit = () => { const onSubmit = () => {
...@@ -33,20 +73,29 @@ const AddModal = props => { ...@@ -33,20 +73,29 @@ const AddModal = props => {
(checkedList || []).map(item => { (checkedList || []).map(item => {
fieldNames.push({ fieldNames: item }); fieldNames.push({ fieldNames: item });
}); });
let list = [];
if (plainOptionsInside.length > 0) {
plainOptionsInside.map(i => {
if (i.isCheck) {
list.push(i.fieldName);
}
});
}
let datalist = checkedList.concat(list);
form.validateFields().then(validate => { form.validateFields().then(validate => {
if (validate) { if (validate) {
let obj = form.getFieldsValue(); let obj = form.getFieldsValue();
setLoading(true); setLoading(true);
let data = {}, let data = {};
url = JSON.stringify(formObj) == '{}' ? addTables : addFields; let url = JSON.stringify(formObj) == '{}' ? addTables : addFields;
if (JSON.stringify(formObj) == '{}') { if (JSON.stringify(formObj) == '{}') {
data = { data = {
tableName: obj.tableName, tableName: obj.tableName,
alias: obj.tableAlias || '', alias: obj.tableAlias || '',
fieldNames: checkedList.join(','), fieldNames: datalist.join(','),
}; };
} else { } else {
data = { tableName: formObj.tableName, fieldNames: checkedList.join(',') }; data = { tableName: formObj.tableName, fieldNames: datalist.join(',') };
} }
url(data) url(data)
.then(res => { .then(res => {
...@@ -94,17 +143,36 @@ const AddModal = props => { ...@@ -94,17 +143,36 @@ const AddModal = props => {
loadTableFields({ tableName: name }).then(response => { loadTableFields({ tableName: name }).then(response => {
if (response.data.root.length) { if (response.data.root.length) {
// eslint-disable-next-line one-var // eslint-disable-next-line one-var
let arr = [], let arr = [];
newArr = []; let newArr = [];
let insideArr = [];
response.data.root.map(item => { response.data.root.map(item => {
newArr.push(item.fieldName); if (item.isDefaultField == true) {
if (item.isCheck) { insideArr.push({ fieldName: item.fieldName, isCheck: item.isCheck });
arr.push(item.fieldName); } else {
newArr.push(item.fieldName);
if (item.isCheck) {
arr.push(item.fieldName);
}
} }
}); });
setCheckAll(arr.length === newArr.length); let list = [];
setIndeterminate(!!arr.length && arr.length < newArr.length); if (insideArr.length > 0) {
insideArr.map(i => {
if (i.isCheck) {
list.push(i);
}
});
setCheckAll1(list.length === insideArr.length);
setIndeterminate1(!!list.length && list.length < insideArr.length);
}
let aa = arr.length + list.length;
let bb = newArr.length + insideArr.length;
setCheckAll(aa == bb);
setIndeterminate(!!aa && aa < bb);
setPlainOptions(newArr); setPlainOptions(newArr);
setPlainOptionsInside(insideArr);
setCheckedList(arr); setCheckedList(arr);
} else { } else {
setCheckAll(false); setCheckAll(false);
...@@ -126,6 +194,28 @@ const AddModal = props => { ...@@ -126,6 +194,28 @@ const AddModal = props => {
renderField(value); renderField(value);
}; };
const onchenge = (e, item) => {
let data = [...plainOptionsInside];
data.map(i => {
if (i.fieldName == item) {
i.isCheck = e.target.checked;
}
});
setPlainOptionsInside(data);
let list = [];
data.map(j => {
if (j.isCheck) {
list.push(j);
}
});
setIndeterminate1(!!list.length && list.length < plainOptionsInside.length);
setCheckAll1(list.length === plainOptionsInside.length);
let aa = list.length + checkedList.length;
let bb = plainOptionsInside.length + plainOptions.length;
setIndeterminate(!!aa && aa < bb);
setCheckAll(aa == bb);
};
return ( return (
<Modal <Modal
title={JSON.stringify(formObj) == '{}' ? '附加表' : '附加字段'} title={JSON.stringify(formObj) == '{}' ? '附加表' : '附加字段'}
...@@ -139,7 +229,7 @@ const AddModal = props => { ...@@ -139,7 +229,7 @@ const AddModal = props => {
{...props} {...props}
onOk={() => onSubmit()} onOk={() => onSubmit()}
confirmLoading={loading} confirmLoading={loading}
forceRender={true} forceRender
getContainer={false} getContainer={false}
> >
{visible && ( {visible && (
...@@ -153,13 +243,11 @@ const AddModal = props => { ...@@ -153,13 +243,11 @@ const AddModal = props => {
> >
<Select onChange={handleChange} showSearch> <Select onChange={handleChange} showSearch>
{tableList.length {tableList.length
? tableList.map((item, index) => { ? tableList.map((item, index) => (
return ( <Select.Option key={index} value={item.text}>
<Select.Option key={index} value={item.text}> {item.text}plainOptions
{item.text} </Select.Option>
</Select.Option> ))
);
})
: ''} : ''}
</Select> </Select>
</Item> </Item>
...@@ -183,10 +271,65 @@ const AddModal = props => { ...@@ -183,10 +271,65 @@ const AddModal = props => {
</Checkbox> </Checkbox>
} }
> >
{plainOptions.length ? ( {plainOptions.length > 0 && (
<CheckboxGroup options={plainOptions} value={checkedList} onChange={onChange} /> <CheckboxGroup options={plainOptions} value={checkedList} onChange={onChange} />
)}
{plainOptionsInside.length > 0 ? (
<>
<div
style={{
position: 'relative',
top: '12px',
marginLeft: '16px',
backgroundColor: 'white',
width: '100px',
paddingLeft: '5px',
}}
>
<Checkbox
style={{ color: 'red' }}
indeterminate={indeterminate1}
onChange={onCheckAllChange1}
checked={checkAll1}
>
<strong>内置字段</strong>
</Checkbox>
</div>
<div
style={{
display: 'flex',
flexWrap: 'wrap',
border: '1px solid #d7d3d3',
borderRadius: '2px',
paddingTop: '20px',
}}
>
{plainOptionsInside.map(i => (
<div
style={{
width: '110px',
overflow: 'hidden',
paddingBottom: '10px',
marginLeft: '20px',
textOverflow: 'ellipsis',
whiteSpace: 'nowrap',
}}
>
<Checkbox
style={{ color: 'red' }}
checked={i.isCheck}
onChange={e => {
onchenge(e, i.fieldName);
}}
>
{i.fieldName}
</Checkbox>
</div>
))}
</div>
</>
) : ( ) : (
'' <></>
)} )}
</Card> </Card>
</div> </div>
......
...@@ -20,8 +20,13 @@ ...@@ -20,8 +20,13 @@
height: 15rem; height: 15rem;
overflow-y: scroll; overflow-y: scroll;
} }
.ant-checkbox-group-item {
width: 135px !important;
margin-bottom: 10px;
}
} }
.paneTitle { .paneTitle {
font-weight: bold; font-weight: bold;
font-size: 18px; font-size: 18px;
......
...@@ -3,6 +3,7 @@ import { ...@@ -3,6 +3,7 @@ import {
CreateTablePost, CreateTablePost,
getTableInfo, getTableInfo,
updateTablePost, updateTablePost,
GetDefaultTableFields,
} from '@/services/tablemanager/tablemanager'; } from '@/services/tablemanager/tablemanager';
import { import {
Form, Form,
...@@ -18,9 +19,15 @@ import { ...@@ -18,9 +19,15 @@ import {
Switch, Switch,
Spin, Spin,
} from 'antd'; } from 'antd';
import { DeleteOutlined, PlusOutlined, MinusOutlined, DeleteFilled } from '@ant-design/icons'; import {
DeleteOutlined,
PlusOutlined,
MinusOutlined,
DeleteFilled,
KeyOutlined,
} from '@ant-design/icons';
import styles from './TableView.less'; import styles from './TableView.less';
import { defaultFields } from './defaultFields'; // import { defaultFields } from './defaultFields';
const EditableContext = React.createContext(null); const EditableContext = React.createContext(null);
const tableMap = { 事件表: '事件', 工单表: '工单', 台账表: '台账', 设备表: '设备', 反馈表: '反馈' }; const tableMap = { 事件表: '事件', 工单表: '工单', 台账表: '台账', 设备表: '设备', 反馈表: '反馈' };
...@@ -316,14 +323,18 @@ const TableView = props => { ...@@ -316,14 +323,18 @@ const TableView = props => {
}); });
} else { } else {
let list = []; let list = [];
defaultFields.forEach(item => { GetDefaultTableFields().then(res => {
if (item.value === tableType) { console.log(res.data);
list = item.list.map((val, index) => ({ ...val, keyIndex: index })); res.data.forEach(item => {
} if (item.value === tableType) {
list = item.list.map((val, index) => ({ ...val, keyIndex: index }));
}
});
console.log(list);
setDefaultData(list);
setCount(list.length);
setDataSource(list);
}); });
setDefaultData(list);
setCount(list.length);
setDataSource(list);
} }
} else { } else {
setShowDefault(true); setShowDefault(true);
...@@ -514,6 +525,15 @@ const TableView = props => { ...@@ -514,6 +525,15 @@ const TableView = props => {
ellipsis: true, ellipsis: true,
editable: true, editable: true,
align: 'center', align: 'center',
render: (text, record) => (
<>
{console.log(record)}
<span>{text}</span>
{record.IsIndex && (
<KeyOutlined style={{ color: '#d0d328', fontSize: '20px', marginLeft: '15px' }} />
)}
</>
),
}, },
{ {
title: '字段类型', title: '字段类型',
......
...@@ -15,6 +15,7 @@ ...@@ -15,6 +15,7 @@
import React, { useState, useEffect, useCallback, useRef } from 'react'; import React, { useState, useEffect, useCallback, useRef } from 'react';
import { Form, Modal, Divider, Checkbox, Tabs, Empty } from 'antd'; import { Form, Modal, Divider, Checkbox, Tabs, Empty } from 'antd';
import DragTable from '@/components/DragTable/DragTable'; import DragTable from '@/components/DragTable/DragTable';
import classnames from 'classnames';
import styles from './incident.less'; import styles from './incident.less';
const CheckboxGroup = Checkbox.Group; const CheckboxGroup = Checkbox.Group;
const EditModal = props => { const EditModal = props => {
...@@ -312,7 +313,13 @@ const EditModal = props => { ...@@ -312,7 +313,13 @@ const EditModal = props => {
<> <>
<div className={styles.cardContent}> <div className={styles.cardContent}>
{title.map((item, index) => ( {title.map((item, index) => (
<div className={styles.cardItemData} key={index}> <div
className={classnames({
[styles.cardItemData]: true,
[styles.cardItemData1]: item == '内置字段',
})}
key={index}
>
<Divider <Divider
orientation="left" orientation="left"
style={{ style={{
...@@ -329,7 +336,11 @@ const EditModal = props => { ...@@ -329,7 +336,11 @@ const EditModal = props => {
checked={checkAll[index]} checked={checkAll[index]}
style={{ marginRight: '7px' }} style={{ marginRight: '7px' }}
/> />
{item} {item == '内置字段' ? (
<span style={{ color: 'red' }}>{item}</span>
) : (
<span>{item}</span>
)}
</Divider> </Divider>
<CheckboxGroup <CheckboxGroup
options={filed[item]} options={filed[item]}
......
...@@ -209,6 +209,16 @@ ...@@ -209,6 +209,16 @@
border: 1px solid #b5b8c8; border: 1px solid #b5b8c8;
margin-bottom: 1rem; margin-bottom: 1rem;
overflow-x: scroll; overflow-x: scroll;
}
.cardItemData1 {
padding: 1rem;
border: 1px solid #b5b8c8;
margin-bottom: 1rem;
overflow-x: scroll;
.ant-checkbox-group-item {
color: red !important;
}
} }
} }
.listCard1 { .listCard1 {
...@@ -273,7 +283,7 @@ ...@@ -273,7 +283,7 @@
} }
.imgg { .imgg {
position: relative; position: relative;
top: -33px; top: -80px;
left: -9px; left: -9px;
height: 104px; height: 104px;
width: 104px; width: 104px;
......
...@@ -73,8 +73,8 @@ const FlowModal = props => { ...@@ -73,8 +73,8 @@ const FlowModal = props => {
label="流程名称" label="流程名称"
name="FlowName" name="FlowName"
rules={[ rules={[
{ {
required: true, required: true,
message: '请输入流程名称', message: '请输入流程名称',
}, },
{ {
...@@ -82,11 +82,8 @@ const FlowModal = props => { ...@@ -82,11 +82,8 @@ const FlowModal = props => {
let aa = form.getFieldValue().FlowName; let aa = form.getFieldValue().FlowName;
if (modalType === 'add' && keep.indexOf(aa) != -1) { if (modalType === 'add' && keep.indexOf(aa) != -1) {
return Promise.reject('流程名称已存在'); return Promise.reject('流程名称已存在');
} else if ( }
modalType === 'edit' && if (modalType === 'edit' && keep.indexOf(aa) != -1 && aa != msg.FlowName) {
keep.indexOf(aa) != -1 &&
aa != msg.FlowName
) {
return Promise.reject('流程名称已存在'); return Promise.reject('流程名称已存在');
} }
return Promise.resolve(); return Promise.resolve();
...@@ -105,7 +102,16 @@ const FlowModal = props => { ...@@ -105,7 +102,16 @@ const FlowModal = props => {
))} ))}
</Select> </Select>
</Form.Item> </Form.Item>
<Form.Item label="编码前缀" name="Prefix"> <Form.Item
label="编码前缀"
name="Prefix"
rules={[
{
required: true,
message: '请输入编码前缀',
},
]}
>
<Input placeholder="请输入编码前缀" /> <Input placeholder="请输入编码前缀" />
</Form.Item> </Form.Item>
<Form.Item label="流程描述" name="Text"> <Form.Item label="流程描述" name="Text">
......
...@@ -9,9 +9,11 @@ import { ...@@ -9,9 +9,11 @@ import {
notification, notification,
Spin, Spin,
Pagination, Pagination,
Checkbox,
} from 'antd'; } from 'antd';
import copy from 'copy-to-clipboard'; import copy from 'copy-to-clipboard';
import PageContainer from '@/components/BasePageContainer'; import PageContainer from '@/components/BasePageContainer';
import { CheckSquareFilled, ConsoleSqlOutlined } from '@ant-design/icons';
import styles from './ManagementDataBase.less'; import styles from './ManagementDataBase.less';
import { import {
tableCheck, tableCheck,
...@@ -20,7 +22,6 @@ import { ...@@ -20,7 +22,6 @@ import {
databaseStandardGetLog, databaseStandardGetLog,
databaseStandardGetLogNew, databaseStandardGetLogNew,
} from '@/services/database/api'; } from '@/services/database/api';
import { CheckSquareFilled, ConsoleSqlOutlined } from '@ant-design/icons';
const ManagementDataBase = () => { const ManagementDataBase = () => {
const [autoCheckList, setAutoCheckList] = useState([]); // 自动列表 const [autoCheckList, setAutoCheckList] = useState([]); // 自动列表
...@@ -37,6 +38,9 @@ const ManagementDataBase = () => { ...@@ -37,6 +38,9 @@ const ManagementDataBase = () => {
const [pageSize, setPageSize] = useState(10); const [pageSize, setPageSize] = useState(10);
const [checkSql, setCheckSql] = useState(''); const [checkSql, setCheckSql] = useState('');
const [sqlVisible, setSqlVisible] = useState(false); const [sqlVisible, setSqlVisible] = useState(false);
const [repairTypeList, setRepairTypeList] = useState([]);
const [keepValue, setKeepValue] = useState([]);
const [list, setlist] = useState(['表', '字段', '主外键', '主键', '索引', '复合索引']);
// 检查数据库表 // 检查数据库表
useEffect(() => { useEffect(() => {
setCheckLoading(true); setCheckLoading(true);
...@@ -84,6 +88,18 @@ const ManagementDataBase = () => { ...@@ -84,6 +88,18 @@ const ManagementDataBase = () => {
item.key = index; item.key = index;
return item; return item;
}); });
console.log(list);
console.log(res.RepairTypeList);
let data = [];
list.map(i => {
console.log(i);
if (res.RepairTypeList.indexOf(i) != -1) {
data.push(i);
}
});
console.log(data);
setKeepValue(res.RepairTypeList);
setRepairTypeList(data);
setAutoCheckList(arr); setAutoCheckList(arr);
setCheckList(arr2); setCheckList(arr2);
} }
...@@ -139,30 +155,65 @@ const ManagementDataBase = () => { ...@@ -139,30 +155,65 @@ const ManagementDataBase = () => {
}; };
// 升级功能 // 升级功能
const handleUpdate = () => { const handleUpdate = () => {
setCheckLoading(true); if (repairTypeList.length > 0) {
updateDateBase() if (keepValue.length > 0) {
.then(res => { setCheckLoading(true);
setCheckLoading(false); updateDateBase({ checkeRepairTypes: keepValue.toString() })
setCheckFlag(checkFlag + 1); .then(res => {
setUpFlag(upFlag + 1); setCheckLoading(false);
if (res.code === 0) { setCheckFlag(checkFlag + 1);
notification.success({ setUpFlag(upFlag + 1);
message: '通知', if (res.code === 0) {
duration: 3, notification.success({
description: '修复成功', message: '通知',
duration: 3,
description: '修复成功',
});
} else {
notification.error({
message: '通知',
duration: 15,
description: res.msg,
});
}
})
.catch(err => {
setCheckLoading(false);
console.error(err);
}); });
} else { } else {
notification.error({ notification.error({
message: '通知', message: '提示',
duration: 15, duration: 3,
description: res.msg, description: '请勾选升级列表',
}); });
} }
}) } else {
.catch(err => { setCheckLoading(true);
setCheckLoading(false); updateDateBase()
console.error(err); .then(res => {
}); setCheckLoading(false);
setCheckFlag(checkFlag + 1);
setUpFlag(upFlag + 1);
if (res.code === 0) {
notification.success({
message: '通知',
duration: 3,
description: '修复成功',
});
} else {
notification.error({
message: '通知',
duration: 15,
description: res.msg,
});
}
})
.catch(err => {
setCheckLoading(false);
console.error(err);
});
}
}; };
const handleErrLog = (text, val) => { const handleErrLog = (text, val) => {
setModalTitle(val); setModalTitle(val);
...@@ -359,11 +410,27 @@ const ManagementDataBase = () => { ...@@ -359,11 +410,27 @@ const ManagementDataBase = () => {
console.log(e); console.log(e);
setCheckSql(e); setCheckSql(e);
}; };
const onChange = e => {
console.log(e);
setKeepValue(e);
};
return ( return (
<> <>
<PageContainer> <PageContainer>
<Card> <Card>
<div className={styles.tableTitle}>表结构自动化修复</div> <div className={styles.tableTitle}>
<span style={{ marginRight: '100px' }}>升级详情</span>
{repairTypeList.length > 0 && (
<>
<span>升级类型:</span>
<div style={{ display: 'inline-block' }}>
<Checkbox.Group options={repairTypeList} value={keepValue} onChange={onChange} />
</div>
</>
)}
</div>
<Spin tip="loading..." spinning={checkLoading}> <Spin tip="loading..." spinning={checkLoading}>
<Table <Table
className={styles.mgTop20} className={styles.mgTop20}
...@@ -379,7 +446,7 @@ const ManagementDataBase = () => { ...@@ -379,7 +446,7 @@ const ManagementDataBase = () => {
</Button> </Button>
<Popconfirm <Popconfirm
title=" title="
是否升级当前连接数据库?" 是否根据已选类型,升级当前连接数据库?"
okText="确认" okText="确认"
cancelText="取消" cancelText="取消"
onConfirm={() => { onConfirm={() => {
...@@ -396,7 +463,7 @@ const ManagementDataBase = () => { ...@@ -396,7 +463,7 @@ const ManagementDataBase = () => {
</Card> </Card>
<Card className={styles.mgTop20}> <Card className={styles.mgTop20}>
<div className={styles.tableTitle}> <div className={styles.tableTitle}>
手动修复 (字段长度不统一,请手动修改差异,数据可能会截断,请谨慎操作) 手动升级 (字段长度不统一,请手动修改差异,数据可能会截断,请谨慎操作)
</div> </div>
<Table <Table
className={styles.mgTop20} className={styles.mgTop20}
......
...@@ -38,6 +38,7 @@ const modules = { ...@@ -38,6 +38,7 @@ const modules = {
[{ align: [] }], [{ align: [] }],
['bold', 'italic', 'underline', 'strike', 'blockquote'], ['bold', 'italic', 'underline', 'strike', 'blockquote'],
[{ list: 'ordered' }, { list: 'bullet' }, { indent: '-1' }, { indent: '+1' }], [{ list: 'ordered' }, { list: 'bullet' }, { indent: '-1' }, { indent: '+1' }],
['clean'], // 清空
], ],
}; };
...@@ -232,125 +233,128 @@ const AddModal = props => { ...@@ -232,125 +233,128 @@ const AddModal = props => {
}; };
// 提交 // 提交
const onSubmit = () => { const onSubmit = () => {
form.validateFields().then(validate => { console.log(form.getFieldsValue().siteDescription);
if (validate) { console.log(form.getFieldsValue().siteDescription.textContent);
setLoading(true); // form.validateFields().then(validate => {
let obj = form.getFieldsValue(); // if (validate) {
if (obj.internetAddress || obj.intranetAddress) { // setLoading(true);
if (obj.accountParamValue == '熊猫ticket') { // let obj = form.getFieldsValue();
obj.accountParamValue = 1; // console.log(obj.siteDescription);
} else if (obj.accountParamValue == '熊猫token') { // if (obj.internetAddress || obj.intranetAddress) {
obj.accountParamValue = 2; // if (obj.accountParamValue == '熊猫ticket') {
} // obj.accountParamValue = 1;
let aa = { key: obj.accountParamKey, value: obj.accountParamValue }; // } else if (obj.accountParamValue == '熊猫token') {
let bb = []; // obj.accountParamValue = 2;
bb.push(aa); // }
if (obj.iconUrl.file) { // let aa = { key: obj.accountParamKey, value: obj.accountParamValue };
obj.iconUrl = obj.iconUrl.file.response.data; // let bb = [];
} // bb.push(aa);
let data = []; // if (obj.iconUrl.file) {
if (obj.coordinate) { // obj.iconUrl = obj.iconUrl.file.response.data;
data = obj.coordinate.split(','); // }
} // let data = [];
let dataList = []; // if (obj.coordinate) {
if (fileList.length > 0) { // data = obj.coordinate.split(',');
fileList.map(i => { // }
if (i.submitUrl) { // let dataList = [];
dataList.push(i.submitUrl); // if (fileList.length > 0) {
} else { // fileList.map(i => {
dataList.push(i.response.data); // if (i.submitUrl) {
} // dataList.push(i.submitUrl);
}); // } else {
} // dataList.push(i.response.data);
if (type === 'add') { // }
AddIntegratedLogin({ // });
systemName: obj.systemName, // }
subtitle: obj.subtitle, // if (type === 'add') {
internetAddress: obj.internetAddress, // AddIntegratedLogin({
intranetAddress: obj.intranetAddress, // systemName: obj.systemName,
accountParam: bb, // subtitle: obj.subtitle,
iconUrl: obj.iconUrl, // internetAddress: obj.internetAddress,
accountType: 'Panda', // intranetAddress: obj.intranetAddress,
isHide: false, // accountParam: bb,
target: obj.target, // iconUrl: obj.iconUrl,
isMaster: obj.isMaster, // accountType: 'Panda',
images: dataList, // isHide: false,
mapSetting: obj.mapSetting, // target: obj.target,
coordinate: data, // isMaster: obj.isMaster,
siteDescription: obj.siteDescription, // images: dataList,
}) // mapSetting: obj.mapSetting,
.then(res => { // coordinate: data,
if (res.code === 0) { // siteDescription: obj.siteDescription,
onCancel(); // })
setLoading(false); // .then(res => {
callBackSubmit(); // if (res.code === 0) {
notification.success({ // onCancel();
message: '提示', // setLoading(false);
duration: 3, // callBackSubmit();
description: res.msg || '新增成功', // notification.success({
}); // message: '提示',
} else { // duration: 3,
setLoading(false); // description: res.msg || '新增成功',
notification.error({ // });
message: '提示', // } else {
duration: 3, // setLoading(false);
description: res.msg || '新增失败', // notification.error({
}); // message: '提示',
} // duration: 3,
}) // description: res.msg || '新增失败',
.catch(err => { // });
setLoading(false); // }
}); // })
} else { // .catch(err => {
EditIntegratedLogin({ // setLoading(false);
systemName: obj.systemName, // });
subtitle: obj.subtitle, // } else {
internetAddress: obj.internetAddress, // EditIntegratedLogin({
intranetAddress: obj.intranetAddress, // systemName: obj.systemName,
accountParam: bb, // subtitle: obj.subtitle,
iconUrl: obj.iconUrl, // internetAddress: obj.internetAddress,
accountType: 'Panda', // intranetAddress: obj.intranetAddress,
target: obj.target, // accountParam: bb,
isMaster: obj.isMaster, // iconUrl: obj.iconUrl,
images: dataList, // accountType: 'Panda',
clients: pickItem.clients, // target: obj.target,
isHide: pickItem.isHide, // isMaster: obj.isMaster,
mapSetting: obj.mapSetting, // images: dataList,
coordinate: data, // clients: pickItem.clients,
siteDescription: obj.siteDescription, // isHide: pickItem.isHide,
}) // mapSetting: obj.mapSetting,
.then(res => { // coordinate: data,
if (res.code === 0) { // siteDescription: obj.siteDescription,
onCancel(); // })
setLoading(false); // .then(res => {
callBackSubmit(); // if (res.code === 0) {
notification.success({ // onCancel();
message: '提示', // setLoading(false);
duration: 3, // callBackSubmit();
description: res.msg || '编辑成功', // notification.success({
}); // message: '提示',
} else { // duration: 3,
setLoading(false); // description: res.msg || '编辑成功',
notification.error({ // });
message: '提示', // } else {
duration: 3, // setLoading(false);
description: res.msg || '编辑失败', // notification.error({
}); // message: '提示',
} // duration: 3,
}) // description: res.msg || '编辑失败',
.catch(err => { // });
setLoading(false); // }
}); // })
} // .catch(err => {
} else { // setLoading(false);
notification.warning({ // });
message: '提示', // }
duration: 3, // } else {
description: '内网地址或外网地址必须填写一项', // notification.warning({
}); // message: '提示',
} // duration: 3,
} // description: '内网地址或外网地址必须填写一项',
}); // });
// }
// }
// });
}; };
const layout = { const layout = {
......
...@@ -194,7 +194,7 @@ const Integrate = () => { ...@@ -194,7 +194,7 @@ const Integrate = () => {
<EditTwoTone onClick={() => edit(record)} style={{ fontSize: '16px' }} /> <EditTwoTone onClick={() => edit(record)} style={{ fontSize: '16px' }} />
</Tooltip> </Tooltip>
{record.isHide ? ( {record.isHide ? (
<Tooltip title="用"> <Tooltip title="用">
<Popconfirm <Popconfirm
placement="left" placement="left"
title={ title={
...@@ -207,11 +207,11 @@ const Integrate = () => { ...@@ -207,11 +207,11 @@ const Integrate = () => {
cancelText="取消" cancelText="取消"
onConfirm={() => startUser(record)} onConfirm={() => startUser(record)}
> >
<UnlockOutlined style={{ fontSize: '16px', color: '#1890ff' }} /> <LockOutlined style={{ fontSize: '16px', color: '#e86060' }} />
</Popconfirm> </Popconfirm>
</Tooltip> </Tooltip>
) : ( ) : (
<Tooltip title="用"> <Tooltip title="用">
<Popconfirm <Popconfirm
placement="left" placement="left"
title={ title={
...@@ -224,7 +224,7 @@ const Integrate = () => { ...@@ -224,7 +224,7 @@ const Integrate = () => {
cancelText="取消" cancelText="取消"
onConfirm={() => freezeUser(record)} onConfirm={() => freezeUser(record)}
> >
<LockOutlined style={{ fontSize: '16px', color: '#e86060' }} /> <UnlockOutlined style={{ fontSize: '16px', color: '#1890ff' }} />
</Popconfirm> </Popconfirm>
</Tooltip> </Tooltip>
)} )}
......
...@@ -2,10 +2,11 @@ import React, { useState, useEffect } from 'react'; ...@@ -2,10 +2,11 @@ import React, { useState, useEffect } from 'react';
import { Form, Select, Input, Button, Radio, notification, Spin } from 'antd'; import { Form, Select, Input, Button, Radio, notification, Spin } from 'antd';
import { editWebsite, getWebsite, addWebsite } from '@/services/mobileConfig/api'; import { editWebsite, getWebsite, addWebsite } from '@/services/mobileConfig/api';
import PicturesWall from '@/components/Upload/index'; import PicturesWall from '@/components/Upload/index';
import { stripBasename } from 'history/pathutils';
const { Item } = Form; const { Item } = Form;
const { Option } = Select; const { Option } = Select;
const SiteConfig = props => { const SiteConfig = props => {
const { miniTitle, submitCallback, addCallback, parentKey, clientName } = props; const { miniTitle, submitCallback, addCallback, parentKey, clientName, singleList } = props;
const [config, setConfig] = useState(''); // 网站配置信息 const [config, setConfig] = useState(''); // 网站配置信息
const [loginList, setLoginList] = useState([{ text: '默认界面', value: 'default' }]); // 系统登陆页 const [loginList, setLoginList] = useState([{ text: '默认界面', value: 'default' }]); // 系统登陆页
const [styleList, setStyleList] = useState([ const [styleList, setStyleList] = useState([
...@@ -14,6 +15,8 @@ const SiteConfig = props => { ...@@ -14,6 +15,8 @@ const SiteConfig = props => {
]); // 系统风格 ]); // 系统风格
const [themeList, setThemeList] = useState([{ text: '默认皮肤', value: 'default' }]); // 系统皮肤 const [themeList, setThemeList] = useState([{ text: '默认皮肤', value: 'default' }]); // 系统皮肤
const [loading, setLoading] = useState(false); const [loading, setLoading] = useState(false);
const [keepText, setKeepText] = useState([]);
const [name, setName] = useState('');
const [form] = Form.useForm(); const [form] = Form.useForm();
const layout = { const layout = {
layout: 'horizontal', layout: 'horizontal',
...@@ -21,6 +24,12 @@ const SiteConfig = props => { ...@@ -21,6 +24,12 @@ const SiteConfig = props => {
wrapperCol: { span: 8 }, wrapperCol: { span: 8 },
}; };
useEffect(() => { useEffect(() => {
console.log(singleList);
let aa = [];
singleList.map(i => {
aa.push(i.text);
});
setKeepText(aa);
console.log(miniTitle, 'miniTitle'); console.log(miniTitle, 'miniTitle');
if (!miniTitle) { if (!miniTitle) {
return; return;
...@@ -38,6 +47,8 @@ const SiteConfig = props => { ...@@ -38,6 +47,8 @@ const SiteConfig = props => {
arr.map(k => { arr.map(k => {
obj[k] = res.data[k]; obj[k] = res.data[k];
}); });
console.log(obj);
setName(obj.title);
form.setFieldsValue(obj); form.setFieldsValue(obj);
}) })
.catch(err => { .catch(err => {
...@@ -89,6 +100,15 @@ const SiteConfig = props => { ...@@ -89,6 +100,15 @@ const SiteConfig = props => {
required: true, required: true,
message: '请输入应用名称', message: '请输入应用名称',
}, },
{
validator: (rule, value) => {
let data = form.getFieldValue().title;
if (keepText.indexOf(data) != -1 && data != name) {
return Promise.reject('标题已存在');
}
return Promise.resolve();
},
},
]} ]}
> >
<Input placeholder="请输入应用名称" allowClear /> <Input placeholder="请输入应用名称" allowClear />
......
...@@ -5,7 +5,7 @@ import PicturesWall from '@/components/Upload/index'; ...@@ -5,7 +5,7 @@ import PicturesWall from '@/components/Upload/index';
const { Item } = Form; const { Item } = Form;
const { Option } = Select; const { Option } = Select;
const AddConfig = props => { const AddConfig = props => {
const { miniTitle, submitCallback, subType, addCallback, singleList } = props; const { miniTitle, submitCallback, subType, addCallback, singleList, visible } = props;
console.log(subType, 'ubType'); console.log(subType, 'ubType');
const [config, setConfig] = useState(''); // 网站配置信息 const [config, setConfig] = useState(''); // 网站配置信息
const [loginList, setLoginList] = useState([{ text: '默认界面', value: 'default' }]); // 系统登陆页 const [loginList, setLoginList] = useState([{ text: '默认界面', value: 'default' }]); // 系统登陆页
...@@ -20,12 +20,35 @@ const AddConfig = props => { ...@@ -20,12 +20,35 @@ const AddConfig = props => {
{ text: 'mypanda', value: 'mypanda' }, { text: 'mypanda', value: 'mypanda' },
]); ]);
const [loading, setLoading] = useState(false); const [loading, setLoading] = useState(false);
const [keepTitle, setKeepTitle] = useState([]);
const [keepValue, setKeepValue] = useState([]);
const [form] = Form.useForm(); const [form] = Form.useForm();
const layout = { const layout = {
layout: 'horizontal', layout: 'horizontal',
labelCol: { span: 7 }, labelCol: { span: 7 },
wrapperCol: { span: 15 }, wrapperCol: { span: 15 },
}; };
useEffect(() => {
console.log(singleList);
let text = [];
let value = [];
singleList.map(i => {
text.push(i.text);
value.push(i.subSystemValue);
});
setKeepTitle(text);
setKeepValue(value);
if (visible) {
form.setFieldsValue({
title: '新应用',
shortcutIcon: 'assets\\images\\icon\\熊猫-白色.png',
loginTemplate: loginList[0].value,
theme: themeList[0].value,
style: styleList[0].value,
});
}
}, [visible]);
// 单选值改变 // 单选值改变
const radioChange = e => {}; const radioChange = e => {};
// 提交选择 // 提交选择
...@@ -82,6 +105,15 @@ const AddConfig = props => { ...@@ -82,6 +105,15 @@ const AddConfig = props => {
required: true, required: true,
message: '请输入应用名称', message: '请输入应用名称',
}, },
{
validator: (rule, value) => {
let data = form.getFieldValue().title;
if (keepTitle.indexOf(data) != -1) {
return Promise.reject('标题已存在');
}
return Promise.resolve();
},
},
]} ]}
> >
<Input placeholder="请输入应用名称" allowClear /> <Input placeholder="请输入应用名称" allowClear />
...@@ -94,6 +126,18 @@ const AddConfig = props => { ...@@ -94,6 +126,18 @@ const AddConfig = props => {
required: true, required: true,
message: '请输入虚拟目录', message: '请输入虚拟目录',
}, },
{
validator: (rule, value) => {
let data = form.getFieldValue().client;
if (data == 'CS') {
return Promise.reject('不允许输入CS');
}
if (keepValue.indexOf(data) != -1) {
return Promise.reject('虚拟目录已存在');
}
return Promise.resolve();
},
},
]} ]}
> >
<Input placeholder="请输入虚拟目录" allowClear /> <Input placeholder="请输入虚拟目录" allowClear />
......
...@@ -211,6 +211,7 @@ const MobileConfigPage = props => { ...@@ -211,6 +211,7 @@ const MobileConfigPage = props => {
addCallback={addCallback} addCallback={addCallback}
clientName={clientName} clientName={clientName}
parentKey={parentKey} parentKey={parentKey}
singleList={singleList}
/> />
), ),
}, },
...@@ -247,6 +248,7 @@ const MobileConfigPage = props => { ...@@ -247,6 +248,7 @@ const MobileConfigPage = props => {
visible={addVisible} visible={addVisible}
> >
<AddConfig <AddConfig
visible={addVisible}
addCallback={addCallback} addCallback={addCallback}
submitCallback={submitCallback} submitCallback={submitCallback}
singleList={singleList} singleList={singleList}
......
...@@ -15,6 +15,7 @@ const CheckList = props => { ...@@ -15,6 +15,7 @@ const CheckList = props => {
} }
}); });
valueCallback(arr); valueCallback(arr);
console.log(arr);
setList(arr); setList(arr);
} }
}, [info]); }, [info]);
......
...@@ -46,7 +46,17 @@ const colorList = [ ...@@ -46,7 +46,17 @@ const colorList = [
]; ];
export default props => { export default props => {
const { visible, onClose, config, hasIntegerate, isEdit, onOk, submitting, productList } = props; const {
visible,
onClose,
config,
hasIntegerate,
isEdit,
onOk,
submitting,
productList,
webs,
} = props;
const [form] = Form.useForm(); const [form] = Form.useForm();
const [loginPages, setLoginPages] = useState([]); const [loginPages, setLoginPages] = useState([]);
const [checkedList, setCheckedList] = useState([]); const [checkedList, setCheckedList] = useState([]);
...@@ -57,10 +67,22 @@ export default props => { ...@@ -57,10 +67,22 @@ export default props => {
const CheckboxGroup = Checkbox.Group; const CheckboxGroup = Checkbox.Group;
const [showAdvanced, setShowAdvanced] = useState(false); // 是否显示高级设置 const [showAdvanced, setShowAdvanced] = useState(false); // 是否显示高级设置
const [showParmarModal, setShowParmarModal] = useState(false); const [showParmarModal, setShowParmarModal] = useState(false);
const [keepText, setKeepText] = useState([]);
const [keepValue, setKeepValue] = useState([]);
useEffect(() => { useEffect(() => {
console.log(webs);
onGetLoginPages(); onGetLoginPages();
console.log(productList);
console.log(isEdit); console.log(isEdit);
let text = [];
let value = [];
webs.map(i => {
text.push(i.text);
value.push(i.subSystemValue);
});
setKeepText(text);
setKeepValue(value);
if (isEdit) { if (isEdit) {
console.log(config); console.log(config);
if (config != null && config.topMenu) { if (config != null && config.topMenu) {
...@@ -109,6 +131,10 @@ export default props => { ...@@ -109,6 +131,10 @@ export default props => {
} else { } else {
setColor('linear-gradient(0deg, #0066D6 0%, #39A9FF 100%)'); setColor('linear-gradient(0deg, #0066D6 0%, #39A9FF 100%)');
form.setFieldsValue({ form.setFieldsValue({
shortcutIcon: 'assets\\images\\icon\\熊猫-白色.png',
logo: 'assets\\images\\logo\\panda熊猫-汉字-白色.svg',
bannerLogo: 'assets\\images\\logo\\panda熊猫-汉字-蓝绿色.svg',
title: '新网站',
messageMarking: 'All', messageMarking: 'All',
messageVoice: true, messageVoice: true,
menuState: 'open', menuState: 'open',
...@@ -218,6 +244,18 @@ export default props => { ...@@ -218,6 +244,18 @@ export default props => {
required: true, required: true,
message: '标题为必填项', message: '标题为必填项',
}, },
{
validator: (rule, value) => {
let data = form.getFieldValue().title;
if (keepText.indexOf(data) != -1 && !isEdit) {
return Promise.reject('标题已存在');
}
if (keepText.indexOf(data) != -1 && data != config.title) {
return Promise.reject('标题已存在');
}
return Promise.resolve();
},
},
]} ]}
> >
<Input placeholder="请输入标题" autoComplete="off" /> <Input placeholder="请输入标题" autoComplete="off" />
...@@ -272,6 +310,18 @@ export default props => { ...@@ -272,6 +310,18 @@ export default props => {
required: true, required: true,
message: '虚拟目录不能为空', message: '虚拟目录不能为空',
}, },
{
validator: (rule, value) => {
let data = form.getFieldValue().client;
if (data == 'CS') {
return Promise.reject('不允许输入CS');
}
if (keepValue.indexOf(data) != -1 && !isEdit) {
return Promise.reject('虚拟目录已存在');
}
return Promise.resolve();
},
},
]} ]}
> >
<Input autoComplete="off" disabled={isEdit} /> <Input autoComplete="off" disabled={isEdit} />
...@@ -421,7 +471,7 @@ export default props => { ...@@ -421,7 +471,7 @@ export default props => {
<Form.Item label="Web4地图" name="hideMap"> <Form.Item label="Web4地图" name="hideMap">
<Radio.Group> <Radio.Group>
<Radio value={false}>开启</Radio> <Radio value={false}>开启</Radio>
<Radio value={true}>关闭</Radio> <Radio value>关闭</Radio>
</Radio.Group> </Radio.Group>
</Form.Item> </Form.Item>
<Form.Item <Form.Item
...@@ -451,7 +501,7 @@ export default props => { ...@@ -451,7 +501,7 @@ export default props => {
</Form.Item> </Form.Item>
<Form.Item label="语音播报" name="messageVoice"> <Form.Item label="语音播报" name="messageVoice">
<Radio.Group> <Radio.Group>
<Radio value={true}>开启</Radio> <Radio value>开启</Radio>
<Radio value={false}>关闭</Radio> <Radio value={false}>关闭</Radio>
</Radio.Group> </Radio.Group>
</Form.Item> </Form.Item>
......
...@@ -379,6 +379,7 @@ const WebConfigPage = props => { ...@@ -379,6 +379,7 @@ const WebConfigPage = props => {
{webs.map(item => renderTabPane(item))} {webs.map(item => renderTabPane(item))}
</Tabs> </Tabs>
<SiteConfig <SiteConfig
webs={webs}
productList={productList} productList={productList}
isEdit={isEdit} isEdit={isEdit}
visible={configVisible} visible={configVisible}
......
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