Commit e11438b3 authored by 彭俊龙's avatar 彭俊龙

站点选择器增加可配置站点可选范围属性

parent 71a6fd4a
......@@ -100,6 +100,18 @@ export function getStationListByUserID(id, isAll) {
});
}
// 站点选择器查询
export function getSiteTree() {
return request({
// headers: {
// 'Civ-Site': window?.globalConfig?.userInfo?.site
// },
url: `PandaOMS/OMS/UserCenter/GetSiteTree?node=-1`,
method: 'get',
});
}
//自动计算字符串转化
export function getFormFieldAnalysisDtos(data) {
return request({
......
......@@ -978,6 +978,15 @@ const baseWidgets = [
widget: 'SourceType',
default: '手动输入',
},
siteSelect: {
title: '站点选择范围',
name: '站点选择范围',
type: 'array',
widget: 'SiteSelect',
default: [],
hidden: "{{formData.sourceType != '站点'}}",
dependencies: ['sourceType'],
},
options: {
title: '',
name: '选项',
......
......@@ -24,7 +24,8 @@ const ComboBox = (props) => {
isMySite,
isSearch,
isStoreID,
color
color,
siteSelect
} = schema
const [dictionaryList, setDictionaryList] = useState([])
const [tableData, setTableData] = useState([])
......@@ -58,7 +59,16 @@ const ComboBox = (props) => {
case '表数据':
return Array.isArray(tableData) ? tableData : []
case '站点':
return Array.isArray(site) ? site : []
if(Array.isArray(site)){
if(siteSelect && siteSelect.length > 0){
let stationIds = siteSelect.map(s=> s+'')
return site.filter(s=> stationIds.includes(s.stationID))
}else{
return site;
}
}else{
return []
}
default:
return []
}
......
import React, { useState, useMemo, useEffect } from 'react'
import { Select, message, Tag, options, TreeSelect } from 'antd'
import { getSiteTree, getStationIDListByUserID } from '../../../../../apis/process'
const SiteSelect = props => {
const userID = window?.globalConfig?.userInfo?.OID || 1
const { value, onChange, schema, addons } = props
const {
placeholder,
disabled,
formDisabled,
sourceType,
options,
dictionary,
tableName,
fieldName,
presetValue,
isMultiple,
isEdit,
isMySite,
isSearch,
isStoreID,
color
} = schema
const { SHOW_PARENT } = TreeSelect;
const [siteTree, setSiteTree] = useState([]);
useEffect(()=>{
getStation();
}, [])
const getStation = async () => {
const { code, data, msg } = await getSiteTree()
if (code === 0) {
if (Array.isArray(data.list)) {
const sites = mapTree(data.list);
console.log(sites, '树形结构数据');
setSiteTree(sites);
} else {
setSiteTree([])
}
} else {
message.error(msg)
}
}
const mapTree = (sites = [])=>{
let list = [];
sites.forEach(site=> {
list.push({
title: site.text,
key: site.id,
value: site.id,
children: site.children && site.children.length > 0 ? mapTree(site.children) : []
})
})
return list;
}
const tProps = {
allowClear: true,
treeData: siteTree,
onChange,
value,
treeCheckable: true,
showCheckedStrategy: TreeSelect.SHOW_ALL,
placeholder: '配置站点选择范围',
style: {
width: '100%',
},
};
return <TreeSelect {...tProps} />;
}
export default SiteSelect
\ No newline at end of file
......@@ -12,6 +12,7 @@ import HiddenCondition from './HiddenCondition'
import SwitchDefault from './SwitchDefault'
import RichTextDefault from './RichTextDefault'
import IsHidden from './IsHidden'
import SiteSelect from './SiteSelect'
import IsText from './IsText'
const groupBase = {
......@@ -29,7 +30,8 @@ const groupBase = {
RichTextDefault,
IsHidden,
IsText,
FollowFieldHide
FollowFieldHide,
SiteSelect
}
export default groupBase
\ No newline at end of file
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