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