|
|
@ -7,26 +7,22 @@ import { IconSearch, IconHelpCircle, IconAlertCircle, IconMinusCircle, IconPlusC |
|
|
|
import { SkeletonScreen } from "$components"; |
|
|
|
|
|
|
|
const AddModel = props => { |
|
|
|
const { dispatch, user, error, actions, close, editionData, searchValue } = props |
|
|
|
const { dispatch, user, error, actions, close, editionData, searchValue, dataToModal } = props |
|
|
|
const { edition } = actions |
|
|
|
const [query, setQuery] = useState({ limit: 10, page: 0 }); //页码信息 |
|
|
|
const [limits, setLimits] = useState()//每页实际条数 |
|
|
|
const [detailV, setDetailV] = useState(false) |
|
|
|
const [property, setProperty] = useState([{ key: 'hb', value: 'ture' }]) |
|
|
|
const [attributeValue, setattributeValue] = useState({}) |
|
|
|
const [type, setType] = useState('groups') //类型的判断 |
|
|
|
const [type, setType] = useState('group') //类型的判断 |
|
|
|
const [isEditor, setIsEditor] = useState(false) |
|
|
|
const [appearType, setAppearType] = useState('mqtt') |
|
|
|
const api = useRef() |
|
|
|
|
|
|
|
useEffect(() => { |
|
|
|
if(editionData){ |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
}, []) |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
return ( |
|
|
|
<> |
|
|
@ -39,17 +35,18 @@ const AddModel = props => { |
|
|
|
console.log(r); |
|
|
|
r.ctx_res = JSON.parse(r.ctx_res) |
|
|
|
// delete r.type |
|
|
|
if (dataToModal?.id) { |
|
|
|
dispatch(edition.putedge(dataToModal?.id, r)).then(res => { |
|
|
|
if (editionData) { |
|
|
|
dispatch(edition.postAlterPlugIn(searchValue, editionData, r)).then(res => { |
|
|
|
console.log(res) |
|
|
|
if (res.success) { |
|
|
|
close() |
|
|
|
// close() |
|
|
|
} |
|
|
|
}) |
|
|
|
} else { |
|
|
|
dispatch(edition.postAddPlugIn(searchValue, r)).then(res => {//查询网关列表 |
|
|
|
dispatch(edition.postAddPlugIn(searchValue, r)).then(res => { |
|
|
|
if (res.success) { |
|
|
|
console.log(res); |
|
|
|
close() |
|
|
|
} |
|
|
|
}) |
|
|
|
} |
|
|
@ -83,7 +80,7 @@ const AddModel = props => { |
|
|
|
labelPosition="left" |
|
|
|
placeholder='请输入名称' |
|
|
|
style={{ width: 240, marginBottom: 12 }} |
|
|
|
initValue={dataToModal?.name || ''} |
|
|
|
initValue={dataToModal?.Plugin?.name || ''} |
|
|
|
rules={[{ required: true, message: "请输入设备名称" }]} |
|
|
|
/> |
|
|
|
<Form.Select |
|
|
@ -92,10 +89,10 @@ const AddModel = props => { |
|
|
|
labelPosition="left" |
|
|
|
placeholder='请选择类型' |
|
|
|
style={{ width: 240, marginBottom: 12 }} |
|
|
|
initValue={dataToModal?.softwareVer || type} |
|
|
|
initValue={dataToModal?.Plugin?.type || type} |
|
|
|
rules={[{ required: true, message: "请选择类型" }]} |
|
|
|
> |
|
|
|
{[{ name: '上报', value: 'groups' }, { name: '计算', value: 'antenna' }].map(v => <Form.Select.Option key={v.value} value={v.value}>{v.name}</Form.Select.Option>)} |
|
|
|
{[{ name: '上报', value: 'group' }, { name: '计算', value: 'antenna' }].map(v => <Form.Select.Option key={v.value} value={v.value}>{v.name}</Form.Select.Option>)} |
|
|
|
</Form.Select> |
|
|
|
<Form.TextArea |
|
|
|
field='description' |
|
|
@ -103,7 +100,7 @@ const AddModel = props => { |
|
|
|
labelPosition="left" |
|
|
|
placeholder='' |
|
|
|
style={{ width: 300, marginBottom: 12 }} |
|
|
|
initValue={dataToModal?.name || ''} |
|
|
|
initValue={dataToModal?.Plugin?.description || ''} |
|
|
|
autosize |
|
|
|
rows={1} |
|
|
|
/> |
|
|
@ -112,9 +109,9 @@ const AddModel = props => { |
|
|
|
label='是否启动:' |
|
|
|
labelPosition="left" |
|
|
|
style={{ marginBottom: 12 }} |
|
|
|
initValue={dataToModal?.name || true} |
|
|
|
initValue={dataToModal?.Plugin?.enable || true} |
|
|
|
/> |
|
|
|
{type == 'groups' ? |
|
|
|
{type == 'group' ? |
|
|
|
<> |
|
|
|
<Form.Select |
|
|
|
field="ctx_type" |
|
|
@ -122,7 +119,7 @@ const AddModel = props => { |
|
|
|
labelPosition="left" |
|
|
|
placeholder='请选择上报类型' |
|
|
|
style={{ width: 240, marginBottom: 12 }} |
|
|
|
initValue={'' || 'mqtt'} |
|
|
|
initValue={dataToModal?.AntennaCtx?.type || 'mqtt'} |
|
|
|
rules={[{ required: true, message: "请选择上报类型" }]} |
|
|
|
> |
|
|
|
{[{ name: 'mqtt', value: 'mqtt' }, { name: 'http', value: 'http' }, { name: 'db', value: 'db' }].map(v => <Form.Select.Option key={v.value} value={v.value}>{v.name}</Form.Select.Option>)} |
|
|
@ -133,7 +130,7 @@ const AddModel = props => { |
|
|
|
labelPosition="left" |
|
|
|
placeholder='请选择脚本语言' |
|
|
|
style={{ width: 240, marginBottom: 12 }} |
|
|
|
initValue={'' || 'Lua'} |
|
|
|
initValue={dataToModal?.AntennaCtx?.res_lang || 'Lua'} |
|
|
|
rules={[{ required: true, message: "请选择脚本语言" }]} |
|
|
|
> |
|
|
|
{[{ name: 'Lua', value: 'Lua' },].map(v => <Form.Select.Option key={v.value} value={v.value}>{v.name}</Form.Select.Option>)} |
|
|
@ -144,7 +141,7 @@ const AddModel = props => { |
|
|
|
labelPosition="left" |
|
|
|
placeholder='请选择脚本类型' |
|
|
|
style={{ width: 240, marginBottom: 12 }} |
|
|
|
initValue={'' || 'INLINE'} |
|
|
|
initValue={dataToModal?.AntennaCtx?.res_type || 'INLINE'} |
|
|
|
rules={[{ required: true, message: "请选择脚本类型" }]} |
|
|
|
> |
|
|
|
{[{ name: 'INLINE', value: 'INLINE' }].map(v => <Form.Select.Option key={v.value} value={v.value}>{v.name}</Form.Select.Option>)} |
|
|
@ -203,7 +200,7 @@ const AddModel = props => { |
|
|
|
label={<>脚本<Button theme='borderless' type='secondary' style={{ width: 46, height: 32 }} onClick={() => setIsEditor(!isEditor)}>{isEditor ? '完成' : '编辑'}</Button></>} |
|
|
|
labelPosition="left" |
|
|
|
style={{ width: 300, marginBottom: 12 }} |
|
|
|
initValue={dataToModal?.name || JSON.stringify([])} |
|
|
|
initValue={dataToModal?.AntennaCtx?.res || JSON.stringify([])} |
|
|
|
autosize |
|
|
|
disabled={!isEditor} |
|
|
|
/> |
|
|
@ -212,7 +209,7 @@ const AddModel = props => { |
|
|
|
label='定时任务:' |
|
|
|
labelPosition="left" |
|
|
|
style={{ width: 180, marginBottom: 12 }} |
|
|
|
initValue={dataToModal?.name || ''} |
|
|
|
initValue={dataToModal?.AntennaCtx?.cron || ''} |
|
|
|
/> |
|
|
|
</> |
|
|
|
: <> |
|
|
@ -223,7 +220,7 @@ const AddModel = props => { |
|
|
|
labelPosition="left" |
|
|
|
placeholder='' |
|
|
|
style={{ width: 300, marginBottom: 12 }} |
|
|
|
initValue={dataToModal?.name || JSON.stringify([])} |
|
|
|
initValue={JSON.stringify(dataToModal?.GroupCtx?.groups) || JSON.stringify([])} |
|
|
|
autosize |
|
|
|
rules={[{ required: true, message: "请输入计算配置" }]} |
|
|
|
/> |
|
|
|