@@ -134,10 +134,6 @@ const TableList = () => { | |||
type="primary" | |||
key="primary" | |||
onClick={() => { | |||
if (DeviceId == undefined) { | |||
message.error('请选择门店或者设备'); | |||
return; | |||
} | |||
setStockModalVisible(true); | |||
}} | |||
> | |||
@@ -26,13 +26,13 @@ const CreateForm = (props) => { | |||
<Input /> | |||
</Form.Item> | |||
<Form.Item label={'设备名称'} name="deviceName" rules={[{ required: true,max:50 }]}> | |||
<Form.Item label={'设备名称'} name="deviceName" rules={[{ required: true, max: 50 }]}> | |||
<Input /> | |||
</Form.Item> | |||
<Form.Item label={'设备类型'} name="deviceTypeKey" rules={[{ required: true }]}> | |||
<Select> | |||
{ props.dicData.map((item, index) => { | |||
<Select> | |||
{props.dicData.map((item, index) => { | |||
return ( | |||
<Select.Option index={index} value={item.code} key={item.code}> | |||
{item.value} | |||
@@ -62,7 +62,26 @@ const CreateForm = (props) => { | |||
})} | |||
</Select> | |||
</Form.Item> | |||
<Form.Item | |||
noStyle | |||
shouldUpdate={(prevValues, currentValues) => prevValues.deviceTypeKey !== currentValues.deviceTypeKey} | |||
> | |||
{({ getFieldValue }) => | |||
getFieldValue('deviceTypeKey') === 'TMC' ? ( | |||
<Form.Item name="deviceVersion" label="设备版本" initialValue="WorryFreeEdition"> | |||
<Select> | |||
{props.deviceVersions?.map((item, index) => { | |||
return ( | |||
<Select.Option index={index} value={item.code} key={item.code}> | |||
{item.name} | |||
</Select.Option> | |||
); | |||
})} | |||
</Select> | |||
</Form.Item> | |||
) : null | |||
} | |||
</Form.Item> | |||
<Form.Item label={'状态'} name="status" rules={[{ required: true }]}> | |||
<Select placeholder="请选择状态"> | |||
<OptGroup> | |||
@@ -72,10 +91,10 @@ const CreateForm = (props) => { | |||
</Select> | |||
</Form.Item> | |||
<Form.Item label={'设备坐标'} name="deviceLoc"> | |||
<Input placeholder="104.070734,30.575041" /> | |||
<Input placeholder="104.070734,30.575041" /> | |||
</Form.Item> | |||
<Form.Item label={'设备详细地址'} name="deviceAddr"> | |||
<Input placeholder="成都市武侯区桂溪街道环球中心N5-9111C" /> | |||
<Input placeholder="成都市武侯区桂溪街道环球中心N5-9111C" /> | |||
</Form.Item> | |||
<Form.Item> | |||
<Button type="primary" htmlType="submit"> | |||
@@ -11,6 +11,7 @@ import { | |||
UpdateDeviceInfo, | |||
DelDeviceInfo, | |||
GetDeviceType, | |||
GetDeviceVersions, | |||
} from './services'; | |||
import { gettree } from '../../sys/org/service'; | |||
const key = 'message'; | |||
@@ -85,6 +86,8 @@ const GoodsTypeManage = () => { | |||
const [OrgListArray, setOrgListArray] = useState([]); | |||
const [dicDataAny, setDicDataAny] = useState([]); | |||
const [dicData, setDicData] = useState([]); | |||
const [deviceVersion, setDeviceVersion] = useState([]); | |||
//初始化数据 | |||
useEffect(() => { | |||
const initStoreType = () => { | |||
@@ -104,11 +107,26 @@ const GoodsTypeManage = () => { | |||
}; | |||
function initOrgList() { | |||
gettree().then((r) => { | |||
inittree(r.data); | |||
function inittree(datas) { | |||
for (var i in datas) { | |||
if( datas[i]['type']==2|| datas[i]['type']==3){ | |||
datas[i]['disabled']=false; | |||
}else{ | |||
datas[i]['disabled']=true; | |||
} | |||
if (datas[i].children) { | |||
inittree(datas[i].children); | |||
} | |||
} | |||
} | |||
setOrgList(r.data); | |||
let list = {}; | |||
formateData(r.data); | |||
function formateData(datas) { | |||
for (var i in datas) { | |||
list[datas[i]['disabled']]=true; | |||
list[datas[i]['value']] = { text: datas[i]['title'] }; | |||
if (datas[i].children) { | |||
formateData(datas[i].children); | |||
@@ -139,8 +157,18 @@ const GoodsTypeManage = () => { | |||
}); | |||
} | |||
intDicData(); | |||
initDeviceVersion(); | |||
}, []); | |||
const initDeviceVersion = async () => { | |||
const response = await GetDeviceVersions(); | |||
if (response.statusCode == 200) { | |||
setDeviceVersion(response.data); | |||
} else { | |||
message.error('获取设备版本失败'); | |||
} | |||
} | |||
/** 新建/更新窗口的弹窗 */ | |||
const [createModalVisible, handleModalVisible] = useState(false); | |||
/** 分布更新窗口的弹窗 */ | |||
@@ -228,7 +256,7 @@ const GoodsTypeManage = () => { | |||
更新 | |||
</a>, | |||
<a | |||
key="primary" | |||
key="primary2" | |||
onClick={() => { | |||
record.status = record.status == 0 ? 1 : 0; | |||
UpdateDeviceInfo(record).then((r) => { | |||
@@ -341,6 +369,7 @@ const GoodsTypeManage = () => { | |||
setCurrentRow(undefined); | |||
}} | |||
createModalVisible={createModalVisible} | |||
deviceVersions={deviceVersion} | |||
values={currentRow || {}} | |||
/> | |||
</PageContainer> | |||
@@ -41,3 +41,11 @@ export async function DelDeviceInfo(data) { | |||
method: 'GET', | |||
}); | |||
} | |||
/** 获取所有设备版本 */ | |||
export async function GetDeviceVersions() { | |||
return request(`/kitchen/api/Device/GetDeviceVersions`, { | |||
method: 'post', | |||
}); | |||
} | |||