Commit e533ec09 authored by Maofei94's avatar Maofei94

perf: 修改web配置

parent 3aedbcd1
Pipeline #23541 passed with stages
in 20 minutes 50 seconds
...@@ -8,6 +8,10 @@ import { ...@@ -8,6 +8,10 @@ import {
postAddWebSite, postAddWebSite,
deleteWebsite, deleteWebsite,
getAllConfigName, getAllConfigName,
getWebSite,
addWebsite,
editWebsite,
omsDeleteWebsite,
} from '@/services/webConfig/api'; } from '@/services/webConfig/api';
import { EditTwoTone, ExclamationCircleOutlined } from '@ant-design/icons'; import { EditTwoTone, ExclamationCircleOutlined } from '@ant-design/icons';
import Modal from 'antd/lib/modal/Modal'; import Modal from 'antd/lib/modal/Modal';
...@@ -97,11 +101,12 @@ const WebConfigPage = props => { ...@@ -97,11 +101,12 @@ const WebConfigPage = props => {
const updateWebconfig = (webTitle, canceled = { cancel: false }) => { const updateWebconfig = (webTitle, canceled = { cancel: false }) => {
setLoading(true); setLoading(true);
return getWebconfig(webTitle) return getWebSite(webTitle)
.then(res => { .then(res => {
setLoading(false); setLoading(false);
if (!canceled.cancel) { if (!canceled.cancel) {
setConfigObj(res); // setConfigObj(res);
setConfigObj(res.data);
if (webTitle === curWeb.text) { if (webTitle === curWeb.text) {
setToEdit(res); setToEdit(res);
} }
...@@ -124,7 +129,7 @@ const WebConfigPage = props => { ...@@ -124,7 +129,7 @@ const WebConfigPage = props => {
if (client) { if (client) {
deleteWebsite(client) deleteWebsite(client)
.then(res => { .then(res => {
if (res.success) { if (res.code === 0 || res.success) {
notification.success({ notification.success({
message: `删除网站${webToOperate.text}成功!`, message: `删除网站${webToOperate.text}成功!`,
duration: 3, duration: 3,
...@@ -222,17 +227,21 @@ const WebConfigPage = props => { ...@@ -222,17 +227,21 @@ const WebConfigPage = props => {
baseLogoUrl, baseLogoUrl,
}; };
setSubmitting(true); setSubmitting(true);
// const requestMap = {
// postEditWebConfig,
// postAddWebSite,
// };
const requestMap = { const requestMap = {
postEditWebConfig, addWebsite,
postAddWebSite, editWebsite,
}; };
const successMsg = isEdit ? '保存成功!' : '新增网站成功!'; const successMsg = isEdit ? '保存成功!' : '新增网站成功!';
const failMsg = isEdit ? '编辑失败!' : '新增网站失败!'; const failMsg = isEdit ? '编辑失败!' : '新增网站失败!';
requestMap[isEdit ? 'postEditWebConfig' : 'postAddWebSite'](values) requestMap[isEdit ? 'editWebsite' : 'addWebsite'](values)
.then(res => { .then(res => {
setSubmitting(false); setSubmitting(false);
if (res.success) { if (res.code === 0) {
setCurWeb({ ...curWeb, text: values.title }); setCurWeb({ ...curWeb, text: values.title });
notification.success({ notification.success({
message: successMsg, message: successMsg,
......
...@@ -205,35 +205,35 @@ export const getDefaultGetWebconfig = ({ ...@@ -205,35 +205,35 @@ export const getDefaultGetWebconfig = ({
// }, // },
// ], // ],
// }, // },
theme: { // theme: {
label: '系统皮肤', // label: '系统皮肤',
formType: ITEM_TYPE.SELECT, // formType: ITEM_TYPE.SELECT,
initialValue: '', // initialValue: '',
showSearch: true, // showSearch: true,
filterOption: (input, option) => // filterOption: (input, option) =>
option.children.toLowerCase().indexOf(input.toLowerCase()) >= 0, // option.children.toLowerCase().indexOf(input.toLowerCase()) >= 0,
options: // options:
webThemes.map(t => ({ // webThemes.map(t => ({
value: t.value, // value: t.value,
children: t.text, // children: t.text,
key: t.value, // key: t.value,
})) || [], // })) || [],
onDropdownVisibleChange: onGetThemes, // onDropdownVisibleChange: onGetThemes,
}, // },
style: { // style: {
label: '系统风格', // label: '系统风格',
formType: ITEM_TYPE.SELECT, // formType: ITEM_TYPE.SELECT,
initialValue: '', // initialValue: '',
options: Object.keys( // options: Object.keys(
isIntegerate(initialValues.mode, hasIntegerate) // isIntegerate(initialValues.mode, hasIntegerate)
? integrateStyleData // ? integrateStyleData
: singleStyleData, // : singleStyleData,
).map(k => ({ // ).map(k => ({
value: k, // value: k,
key: k, // key: k,
children: integrateStyleData[k] || singleStyleData[k], // children: integrateStyleData[k] || singleStyleData[k],
})), // })),
}, // },
menu: { menu: {
label: '菜单类型', label: '菜单类型',
formType: ITEM_TYPE.SINGLE_RADIO, formType: ITEM_TYPE.SINGLE_RADIO,
...@@ -243,15 +243,15 @@ export const getDefaultGetWebconfig = ({ ...@@ -243,15 +243,15 @@ export const getDefaultGetWebconfig = ({
children: menuStyle[k], children: menuStyle[k],
})), })),
}, },
mdi: { // mdi: {
label: '功能标签', // label: '功能标签',
formType: ITEM_TYPE.SINGLE_RADIO, // formType: ITEM_TYPE.SINGLE_RADIO,
options: Object.keys(MDILabel).map(k => ({ // options: Object.keys(MDILabel).map(k => ({
value: k, // value: k,
key: k, // key: k,
children: MDILabel[k], // children: MDILabel[k],
})), // })),
}, // },
qrcode: { qrcode: {
label: '二维码地址', label: '二维码地址',
formType: ITEM_TYPE.INPUT, formType: ITEM_TYPE.INPUT,
...@@ -266,57 +266,57 @@ export const getDefaultGetWebconfig = ({ ...@@ -266,57 +266,57 @@ export const getDefaultGetWebconfig = ({
children: notificationTypes[k], children: notificationTypes[k],
})), })),
}, },
mapPlan: { // mapPlan: {
label: '地图方案', // label: '地图方案',
formType: ITEM_TYPE.SELECT, // formType: ITEM_TYPE.SELECT,
options: mapConfigs.map(m => ({ // options: mapConfigs.map(m => ({
value: m.value, // value: m.value,
children: m.text, // children: m.text,
key: m.value, // key: m.value,
})), // })),
onDropdownVisibleChange: onGetMapConfig, // onDropdownVisibleChange: onGetMapConfig,
}, // },
hideMap: { // hideMap: {
label: '按需加载地图', // label: '按需加载地图',
formType: ITEM_TYPE.SINGLE_RADIO, // formType: ITEM_TYPE.SINGLE_RADIO,
optionType: 'button', // optionType: 'button',
options: [ // options: [
{ // {
value: true, // value: true,
key: '1', // key: '1',
children: '是', // children: '是',
}, // },
{ // {
value: false, // value: false,
key: '2', // key: '2',
children: '否', // children: '否',
}, // },
], // ],
}, // },
waterMark: { // waterMark: {
label: '地图水印', // label: '地图水印',
formType: ITEM_TYPE.SINGLE_RADIO, // formType: ITEM_TYPE.SINGLE_RADIO,
options: [ // options: [
{ // {
value: true, // value: true,
key: '1', // key: '1',
children: '显示', // children: '显示',
}, // },
{ // {
value: false, // value: false,
key: '2', // key: '2',
children: '不显示', // children: '不显示',
}, // },
], // ],
}, // },
}; };
if (initialValues) { if (initialValues) {
Object.keys(config).forEach(k => { Object.keys(config).forEach(k => {
config[k].initialValue = config[k].initialValue =
typeof initialValues[k] !== 'undefined' ? initialValues[k] : ''; typeof initialValues[k] !== 'undefined' ? initialValues[k] : '';
if (k === 'alarmWays') { // if (k === 'alarmWays') {
config[k].initialValue = config[k].initialValue.split(','); // config[k].initialValue = config[k].initialValue.split(',');
} // }
// if (k === 'mode' && initialValues.mode) { // if (k === 'mode' && initialValues.mode) {
// config[k].options = [ // config[k].options = [
// { // {
......
...@@ -131,12 +131,29 @@ export const delProductList = params => ...@@ -131,12 +131,29 @@ export const delProductList = params =>
* @新接口 * @新接口
*/ */
// 根据title获取网站配置 // 根据title获取网站配置
export const getWebSite = params => export const getWebSite = title =>
get(`${PUBLISH_SERVICE}/WebSite/GetWebsite`, params); get(`${PUBLISH_SERVICE}/WebSite/GetWebsite`, { title });
// 添加网站配置 // 添加网站配置
export const addWebsite = params => export const addWebsite = params => {
post(`${PUBLISH_SERVICE}/WebSite/AddWebsite`, params); const obj = { ...params };
export const editWebsite = params => Object.keys(obj).forEach(k => {
post(`${PUBLISH_SERVICE}/WebSite/EditWebsite`, params); if (typeof obj[k] === 'string') {
obj[k] = obj[k].trim();
}
});
return post(`${PUBLISH_SERVICE}/WebSite/AddWebsite`, obj);
};
export const editWebsite = params => {
const obj = { ...params };
Object.keys(obj).forEach(k => {
if (typeof obj[k] === 'string') {
obj[k] = obj[k].trim();
}
});
return post(`${PUBLISH_SERVICE}/WebSite/EditWebsite`, obj);
};
// 删除网站
export const omsDeleteWebsite = params => export const omsDeleteWebsite = params =>
post(`${PUBLISH_SERVICE}/WebSite/DeleteWebsite`, params); get(`${PUBLISH_SERVICE}/WebSite/DeleteWebsite`, params);
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