Commit 80345082 authored by shaoan123's avatar shaoan123

修改消息平台模块

parent 4b453311
Pipeline #32512 skipped with stages
......@@ -304,7 +304,6 @@ const ProjectManage = () => {
/>
</div>
<Button type="primary" onClick={handleReset}>重置</Button>
<Button type="primary" style={{ marginLeft: "10px" }} icon={<PlusCircleOutlined />} onClick={onAddClick}><span style={{ marginTop: "-3px" }}>新增</span></Button>
</div>
......
......@@ -40,12 +40,11 @@ const VisibleIISAgentConfig = props => {
const dateFormat = 'YYYY-MM-DD HH:mm:ss';
const { agentConfig, value, onIISAgentSubmit } = props
useEffect(() => {
console.log('agentConfig', agentConfig);
if (agentConfig) {
let startTime = agentConfig.LoopMode === 'ByOnce' ? moment(new Date(new Date().toLocaleDateString()), 'YYYY-MM-DD 00:00:00').add(1, 'days') : moment(new Date(new Date().toLocaleDateString()), 'YYYY-MM-DD 00:00:00')
form.setFieldsValue({
is_enable: agentConfig.Enabled,
url_type: agentConfig.Absolute ? false : true,
url_type: agentConfig.Absolute ? true : false,
url_path: agentConfig.Url,
request_header: agentConfig.CustomHeader,
plan_type: agentConfig.LoopMode,
......@@ -108,23 +107,20 @@ const VisibleIISAgentConfig = props => {
setInterval(1)
setLoop_unit('Hour')
}
}, [agentConfig])
useEffect(() => {
if (value) {
form.setFieldsValue({
name: value
})
setSelectRole(props.value)
}
}, [props])
const handleCancel = () => {
setPreviewVisible(false)
}
const handleOk = () => {
const handleOk = async () => {
let fv = form.getFieldValue()
if ((fv.loop_mode === 'ByDay' && !selectValues.length) || (fv.loop_mode === 'ByWeek' && !weekData.length)) {
message.warning('请选择计划执行日')
......@@ -135,7 +131,7 @@ const VisibleIISAgentConfig = props => {
CustomHeader: fv.request_header || '',
StartFrom: fv.start_time && fv.start_time.format(dateFormat),
EndAt: fv.end_time && fv.end_time.format(dateFormat),
LoopMode: fv.loop_mode,
LoopMode: fv.loop_mode === 'ByOnce' ? 'BYLOOP' : fv.loop_mode,
LoopUnit: loop_unit,
MonthOfYear: null,
WeekOfMonth: null,
......@@ -148,17 +144,18 @@ const VisibleIISAgentConfig = props => {
AllowLog: fv.enable_log,
Enabled: isUse,
Timeout: fv.time_out ? parseInt(fv.time_out) : 30,
Absolute: true,
Absolute: fv.url_type,
SiteInfo: null,
Name: fv.name,
Tolerate: null,
UseTimeout: waitCheck
}
fv.time_out ? data.MillisecondsTimeout = parseInt(fv.time_out) : ''
onIISAgentSubmit && onIISAgentSubmit(
setPreviewVisible(false)
await onIISAgentSubmit && onIISAgentSubmit(
data
)
setPreviewVisible(false)
}
const handleClick = () => {
if (value) {
......@@ -233,18 +230,22 @@ const VisibleIISAgentConfig = props => {
setIsUse(value)
}
const handleExe = (e) => {
let obj = form.getFieldValue()
let value = e.target.value
setIsType(value)
if (value === '执行一次') {
changeLoopMode('ByOnce')
setLoop_unit('Second')
form.setFieldsValue({
loop_mode: 'ByOnce',
hour_of_day: '',
day_of_week: ''
day_of_week: '',
end_time: obj.start_time
})
if (!agentConfig) {
form.setFieldsValue({
start_time: moment(new Date(new Date().toLocaleDateString()), 'YYYY-MM-DD 00:00:00').add(1, 'days')
start_time: moment(new Date(new Date().toLocaleDateString()), 'YYYY-MM-DD 00:00:00').add(1, 'days'),
end_time: moment(new Date(new Date().toLocaleDateString()), 'YYYY-MM-DD 00:00:00').add(1, 'days')
})
setExeTime(moment().add(1, 'days').format('YYYY-MM-DD 00:00:00'))
}
......@@ -253,7 +254,8 @@ const VisibleIISAgentConfig = props => {
changeLoopMode('BYLOOP')
setExeType(true)
form.setFieldsValue({
loop_mode: 'BYLOOP'
loop_mode: 'BYLOOP',
end_time: ''
})
if (!agentConfig) {
form.setFieldsValue({
......@@ -279,6 +281,12 @@ const VisibleIISAgentConfig = props => {
}
const changeStartTime = (e) => {
setExeTime(moment(e).format('YYYY-MM-DD HH:mm:ss'))
let obj = form.getFieldValue()
if (obj.loop_mode === 'ByOnce')
setLoop_unit('Second')
form.setFieldsValue({
end_time: moment(e).format('YYYY-MM-DD HH:mm:ss')
})
}
const changeDay = (data) => {
console.log('data', data);
......@@ -305,7 +313,6 @@ const VisibleIISAgentConfig = props => {
visible={previewVisible}
onOk={() => handleOk()}
confirmLoading={loading}
visible={previewVisible}
onCancel={handleCancel}
>
......
......@@ -9,9 +9,10 @@ import {
Popconfirm,
message,
Tooltip,
notification
notification,
Spin
} from 'antd';
import { PlusCircleOutlined, EditTwoTone, DeleteOutlined} from '@ant-design/icons';
import { PlusCircleOutlined, EditTwoTone, DeleteOutlined } from '@ant-design/icons';
const { Search } = Input;
const { Option } = Select;
......@@ -35,9 +36,9 @@ const TemplateManage = () => {
});
const [currentTemplate, setCurrentTempalte] = useState({});
const [data, setData] = useState([])
const [flag,setFlag] = useState(0)
const [flag, setFlag] = useState(0)
const [option, setOption] = useState([]); // 下拉列表数据
const [treeLoading, setTreeLoading] = useState(false);
useEffect(() => {
getTemplateList()
......@@ -45,18 +46,20 @@ const TemplateManage = () => {
}, [flag])
const getTemplateList = (obj) => {
setTreeLoading(true)
GetMessageTemplate(obj).then(
res => {
setTreeLoading(false)
let list = []
if (res.code === 0) {
res.data.map((item, index) => {
list.push({
key: item.Id,
Id:item.Id,
Id: item.Id,
name: item.LikeName,
type: item.Type,
third_name: item.Name,
third_id:item.No,
third_id: item.No,
template_params: item.TDescription,
analysis_params: item.ParsingRules,
desc: item.ParsingDescription
......@@ -65,12 +68,14 @@ const TemplateManage = () => {
setData(list)
}
}
)
).catch(e=>{
setTreeLoading(false)
})
}
const selectFocus = (obj) => {
GetThirdpartyTemplates(obj).then(res => {
if (res.msg==="Ok") {
if (res.msg === "Ok") {
setOption(res.data);
} else {
notification.error({
......@@ -90,57 +95,57 @@ const TemplateManage = () => {
title: '编号',
dataIndex: 'Id',
key: 'Id',
align:'center',
width:80,
align: 'center',
width: 80,
render: text => <a>{text}</a>,
},
{
title: '模板名称',
dataIndex: 'name',
key: 'name',
align:'center',
align: 'center',
},
{
title: '模板类型',
dataIndex: 'type',
key: 'type',
align:'center',
align: 'center',
},
{
title: '第三方模板名称',
dataIndex: 'third_name',
key: 'third_name',
align:'center',
align: 'center',
},
{
title: '第三方模版编号',
dataIndex: 'third_id',
key: 'third_id',
align:'center',
align: 'center',
},
{
title: '模板参数',
dataIndex: 'template_params',
key: 'template_params',
align:'center',
align: 'center',
},
{
title: '模板参数说明',
dataIndex: 'desc',
key: 'desc',
align:'center',
align: 'center',
},
{
title: '解析参数',
dataIndex: 'analysis_params',
key: 'analysis_params',
align:'center',
align: 'center',
},
{
title: '操作',
dataIndex: 'action',
key: 'action',
align:'center',
align: 'center',
width: 150,
ellipsis: true,
render: (text, record) => (
......@@ -166,7 +171,7 @@ const TemplateManage = () => {
delTemplate(record);
}}
>
<DeleteOutlined style={{ fontSize: '16px', color: '#e86060' }}/>
<DeleteOutlined style={{ fontSize: '16px', color: '#e86060' }} />
</Popconfirm>
</div>
</Tooltip>
......@@ -191,22 +196,21 @@ const TemplateManage = () => {
}
}
const changeDesc = (record) => {
setCurrentTempalte(record)
handleShowModal("editVisible", true)
}
const AddTemplate= ()=>{
const AddTemplate = () => {
handleShowModal("addVisible", true)
}
const delTemplate = (record)=>{
const delTemplate = (record) => {
DeleteMessageTemplate({
id:record.Id
id: record.Id
}).then(
res =>{
if(res.code === 0){
res => {
if (res.code === 0) {
message.success("模板删除成功!")
setFlag(flag + 1)
}else{
} else {
message.warn("模板删除失败!")
}
}
......@@ -221,23 +225,22 @@ const TemplateManage = () => {
handleShowModal("editVisible", false)
}
const onSubmit = (result) => {
console.log(result)
UpdateMessageTemplate({
Id:result.Id,
Type:result.type,
LikeName:result.name,
Name:result.third_name,
No:result.third_id,
ParsingRules:result.analysis_params,
ParsingDescription:result.desc,
TDescription:result.params
Id: result.Id,
Type: result.type,
LikeName: result.name,
Name: result.third_name,
No: result.third_id,
ParsingRules: result.analysis_params,
ParsingDescription: result.desc,
TDescription: result.params
}).then(
res =>{
if(res.code === 0){
res => {
if (res.code === 0) {
message.success("模板保存成功!")
handleShowModal("editVisible", false)
setFlag(flag + 1)
}else{
} else {
message.warn("模板保存失败!")
}
}
......@@ -249,20 +252,20 @@ const TemplateManage = () => {
}
const onAddSubmit = (result) => {
InsertMessageTemplate({
Type:result.type,
LikeName:result.name,
Name:result.third_name,
No:result.third_id,
ParsingRules:result.analysis_params,
ParsingDescription:result.desc,
TDescription:result.params
Type: result.type,
LikeName: result.name,
Name: result.third_name,
No: result.third_id,
ParsingRules: result.analysis_params,
ParsingDescription: result.desc,
TDescription: result.params
}).then(
res =>{
if(res.code === 0){
res => {
if (res.code === 0) {
message.success("模板添加成功!")
handleShowModal("addVisible", false)
setFlag(flag + 1)
}else{
} else {
message.warn("模板添加失败!")
}
}
......@@ -271,6 +274,7 @@ const TemplateManage = () => {
return (
<div className={styles.template_container}>
<Spin tip="loading..." spinning={treeLoading}>
<div className={styles.operate_bar}>
<div className={styles.template_type}>
<div className={styles.title}>模板类型</div>
......@@ -295,7 +299,7 @@ const TemplateManage = () => {
</div>
<Button type="primary" onClick={handleReset}>重置</Button>
<Button type="primary" style={{ marginLeft: "10px"}} icon={<PlusCircleOutlined style={{ verticalAlign:"middle"}}/>} onClick={AddTemplate}><span style={{ marginTop:"-3px"}}>新增</span></Button>
<Button type="primary" style={{ marginLeft: "10px" }} icon={<PlusCircleOutlined style={{ verticalAlign: "middle" }} />} onClick={AddTemplate}><span style={{ marginTop: "-3px" }}>新增</span></Button>
</div>
<div className={styles.list_view}>
......@@ -313,7 +317,7 @@ const TemplateManage = () => {
onCancel={() => handleShowModal('editVisible', false)}
option={option}
confirmModal={editModal}
onSubmit={ onSubmit}
onSubmit={onSubmit}
/>
<AddModal
visible={visibleParams.addVisible}
......@@ -321,9 +325,9 @@ const TemplateManage = () => {
onCancel={() => handleShowModal('addVisible', false)}
option={option}
confirmModal={addModal}
onSubmit={ onAddSubmit}
onSubmit={onAddSubmit}
/>
</Spin>
</div>
)
}
......
......@@ -21,7 +21,6 @@ const AddModal = props => {
}
useEffect(() => {
if (option) {
console.log('option',option);
setTemplateName(option.filter(item => item.Type === '公众号'))
form.setFieldsValue({
type: '公众号'
......@@ -151,7 +150,7 @@ const AddModal = props => {
<Item
label="模板参数"
labelCol={{ span: 6 }}
name="params"
rules={[
{
......@@ -160,11 +159,12 @@ const AddModal = props => {
},
]}
>
<TextArea rows={4} placeholder="first|Second|Third|Four" />
<TextArea rows={4} style={{width:'96%'}} placeholder="first|Second|Third|Four" />
</Item>
<Item
label="参数说明"
name="desc"
labelCol={{ span: 6 }}
rules={[
{
required: true,
......@@ -172,11 +172,12 @@ const AddModal = props => {
},
]}
>
<TextArea rows={4} placeholder="first: 标题信息|Second: 展示内容|Third: 时间|Four: 备注信息" />
<TextArea style={{width:'96%'}} rows={4} placeholder="first: 标题信息|Second: 展示内容|Third: 时间|Four: 备注信息" />
</Item>
<Item
label="参数解析"
name="analysis_params"
labelCol={{ span: 6 }}
rules={[
{
required: true,
......@@ -184,7 +185,7 @@ const AddModal = props => {
},
]}
>
<TextArea rows={4} placeholder="param1|param2|param3|param4" />
<TextArea rows={4} style={{width:'96%'}} placeholder="param1|param2|param3|param4" />
</Item>
</Form>
</div>
......
......@@ -9,6 +9,7 @@ const EditModal = props => {
const { option } = props;
const [form] = Form.useForm();
const [templateName, setTemplateName] = useState([]);
const [loading, setLoading] = useState(false);
const onSubmit = () => {
form.submit()
......@@ -30,6 +31,9 @@ const EditModal = props => {
desc: props.template.desc,
analysis_params: props.template.analysis_params,
})
if (option) {
setTemplateName(option.filter(item => item.Type === props.template.type))
}
}, [props.template])
const layout = {
......@@ -42,13 +46,17 @@ const EditModal = props => {
},
};
const onChange = value => {
const { length } = value;
const onChangeType = (value) => {
console.log(option.filter(item => item.Type === value),'123');
setTemplateName(option.filter(item => item.Type === value))
}
const onChange = (value, option) => {
form.setFieldsValue({
dbName: value[length - 1],
});
};
third_id: option.code
})
// setTemplateName(option.filter(item => item.Type === value))
};
return (
<SiteModal
{...props}
......@@ -90,7 +98,7 @@ const EditModal = props => {
},
]}
>
<Select>
<Select onChange={(value) => onChangeType(value)}>
<Select.Option value="公众号">公众号</Select.Option>
<Select.Option value="短信">短信</Select.Option>
</Select>
......@@ -112,17 +120,13 @@ const EditModal = props => {
{/* <Input placeholder="请输入模板名称" /> */}
<Select
placeholder="请选择模板名称"
// onFocus={() => {
// selectFocus();
// }}
onChange={e => {
onChange(e);
}}
onChange={(value, option) => onChange(value, option)}
>
{option &&
option.length > 0 &&
option.map((item, index) => (
<Option value={item.Name} key={item.Name + index}>
{templateName &&
templateName.length > 0 &&
templateName.map((item, index) => (
<Option value={item.Name} key={item.Name + index} code={item.Code}>
{item.Name}
</Option>
))}
......@@ -154,7 +158,7 @@ const EditModal = props => {
<Item
label="模板参数"
name="params"
labelCol="{span:10}"
labelCol={{ span: 3 }}
style={{ marginLeft: '1.4rem' }}
rules={[
{
......@@ -176,7 +180,7 @@ const EditModal = props => {
<Col span={23}>
<Item
label="参数说明"
labelCol="{span:10}"
labelCol={{ span: 3 }}
style={{ marginLeft: '1.4rem' }}
name="desc"
rules={[
......@@ -199,7 +203,7 @@ const EditModal = props => {
<Col span={23}>
<Item
label="参数解析"
labelCol="{span:10}"
labelCol={{ span: 3 }}
style={{ marginLeft: '1.4rem' }}
name="analysis_params"
rules={[
......
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