Commit 7d6ff37f1b32828fd4090c09970e2cc0239c3ac8

Authored by 温伟
2 parents 182da788 c03ca117

Merge branch 'fix/zfl' into 'perf/main_dev'

修复组态下发命令一直是单向和数据动效显示隐藏隐藏组件取值

See merge request yunteng/thingskit-scada!163
1 1 import type { DeviceAttributeItemType, DeviceItemType, DeviceProfileItemType, OrganizationItemType, RpcCommandType, SendValue, ThingsModel, ThingsModelItemType } from './model'
2   -import type { CommandWayEnum } from '@/enums/commandEnum'
  2 +import { CommandWayEnum } from '@/enums/commandEnum'
3 3 import type { DeviceTypeEnum } from '@/enums/datasource'
4 4 import { isShareMode } from '@/utils/env'
5 5 import { defHttp } from '@/utils/http'
... ... @@ -15,6 +15,7 @@ enum Api {
15 15 RPC_COMMAND = '/rpc/',
16 16 GET_DEVICE_ACTIVE = 'plugins/telemetry/DEVICE/',
17 17 RPC_ONEWAY = '/rpc/oneway',
  18 + RPC_TWOWAY = '/rpc/twoway',
18 19
19 20 GEN_MODBUS_COMMAND = '/js/modbus',
20 21 GET_DEVICE_DETAIL = '/device/', // 获取设备详情
... ... @@ -88,9 +89,9 @@ export const getDeviceActive = (deviceId: string) => {
88 89 }
89 90
90 91 // 命令下发
91   -export const sendRpcOneway = (param: SendValue | any, deviceId?: string) => {
  92 +export const sendRpcOneway = (param: SendValue | any, deviceId?: string, way?: string) => {
92 93 return defHttp.post({
93   - url: `${Api.RPC_ONEWAY}/${deviceId}`,
  94 + url: `${way !== CommandWayEnum.TWO_WAY ? Api.RPC_ONEWAY : Api.RPC_TWOWAY}/${deviceId}`,
94 95 data: param,
95 96 },
96 97 {
... ...
... ... @@ -161,11 +161,13 @@ export interface RangeItemType {
161 161 }
162 162
163 163 export interface BasicActDataType {
164   - deviceId: string
165   - attr: string
  164 + deviceId?: string
  165 + attr?: string
166 166 enable?: boolean
167 167 deviceProfileId?: string | number
  168 + deviceProfileTemplateId?: string | number
168 169 attrInfo?: ThingsModelItemType
  170 + deviceInfo?: DeviceTypeEnum
169 171 }
170 172
171 173 export interface FlashActDataType extends BasicActDataType {
... ...
... ... @@ -79,7 +79,6 @@ const handleDeleteRow = (data: FlashActDataType) => {
79 79
80 80 const getFieldsValue = () => {
81 81 const values = getFieldsForm()
82   - const { deviceId, attr, deviceProfileId, attrInfo } = values
83 82 const rangeList = unref(dataSource).map((item) => {
84 83 return {
85 84 ...item,
... ... @@ -87,17 +86,14 @@ const getFieldsValue = () => {
87 86 }
88 87 })
89 88 return {
90   - deviceId,
91   - attr,
92   - deviceProfileId,
93   - attrInfo,
  89 + ...values,
94 90 rangeList,
95 91 } as BasicFlashActDataType
96 92 }
97 93
98 94 const setFieldsValue = (list: FlashActDataType) => {
99   - const { attr, deviceId, rangeList } = list || {}
100   - setFieldsForm({ attr, deviceId })
  95 + const { rangeList } = list || {}
  96 + setFieldsForm(list || {})
101 97 clearValidate()
102 98 dataSource.value = rangeList ? rangeList?.map(item => ({ ...item, uuid: buildUUID() })) : [getInitTableRecord()]
103 99 }
... ...
... ... @@ -128,3 +128,14 @@ defineExpose<ComponentExposeType>({
128 128 </template>
129 129 </BasicTable>
130 130 </template>
  131 +
  132 +<style lang="less" scoped>
  133 + .variable-image-form {
  134 + >:deep(.ant-row) {
  135 + >.ant-col {
  136 + @apply px-4;
  137 + }
  138 + }
  139 + }
  140 +</style>
  141 +
... ...
... ... @@ -11,6 +11,7 @@ import { genModbusCommand, getDeviceActiveTime, getDeviceInfo, getThingsModelSer
11 11 import { ThingsModelForm } from '@/core/Library/components/ThingsModelForm'
12 12 import { useMessage } from '@/hooks/web/useMessage'
13 13 import type { StructJSON } from '@/api/device/model'
  14 +import { CommandWayEnum } from '@/enums/commandEnum'
14 15
15 16 interface ServiceInfo {
16 17 title?: string
... ... @@ -19,6 +20,7 @@ interface ServiceInfo {
19 20 transportType?: string
20 21 callType?: string
21 22 code?: string
  23 + way?: string
22 24 }
23 25
24 26 const visible = ref<boolean>(false)
... ... @@ -49,6 +51,7 @@ const serviceInfo = reactive<ServiceInfo>({
49 51 transportType: '',
50 52 callType: '',
51 53 code: '',
  54 + way: '', // 单向还是双向
52 55 })
53 56
54 57 const [register, { getFieldsValue, validate, setFieldsValue, updateSchema, setProps }] = useForm({ // 自定义下发值
... ... @@ -88,11 +91,12 @@ const getDeviceDetail = async (deviceId: string) => {
88 91 }
89 92
90 93 const open = async (_data: SingleClickEventDataType) => {
  94 + console.warn(_data, 'data')
91 95 const { operationPassword } = _data || {}
92 96 dataSourceJson.value = _data.deviceInfo
93 97 isPasswordInfo.value = operationPassword || {}
94 98 // commandWay-->命令下发方式
95   - const { commandWay, customCommand, serviceCommand, service, callType } = _data || {}
  99 + const { commandWay, customCommand, serviceCommand, service, callType, way } = _data || {}
96 100 isCommandWay.value = commandWay
97 101 const { attrInfo, deviceId } = unref(dataSourceJson)
98 102 const { identifier, extensionDesc, detail, name } = attrInfo || {}// 属性信息
... ... @@ -110,6 +114,7 @@ const open = async (_data: SingleClickEventDataType) => {
110 114 formField.value = identifier
111 115 isShowActionType.value = !!actionType // 判断modBUS类型时 物模型是否填写扩展描述
112 116 serviceInfo.callType = callType // 服务命令调用方式 是同步还是异步
  117 + serviceInfo.way = way || 'oneway' // 命令下发是双向还是单向
113 118
114 119 serviceInfo.transportType = transportType
115 120 serviceInfo.code = code
... ... @@ -268,7 +273,7 @@ const handleSubmit = async () => {
268 273 persistent: true,
269 274 method: 'methodThingskit',
270 275 params: serviceInfo.transportType !== TransportTypeEnum.TCP && unref(isCommandWay) === CommandDeliveryWayEnum.SERVICE ? { service: unref(sendValue) } : unref(sendValue),
271   - }, dataSourceJson.value.deviceId)
  276 + }, dataSourceJson.value.deviceId, serviceInfo.way)
272 277 createMessage.success('命令下发成功')
273 278 visible.value = false
274 279 isInputData.value = false
... ...