Commit b863cfb9b8543790da3a5b484e5054fd460e2e25

Authored by ww
1 parent a1f68930

fix: get device attribute by device profile id

... ... @@ -3,7 +3,7 @@ class ConfigurationNodeApi {
3 3 /**
4 4 * @description 获取用户权限
5 5 */
6   - static getUserPermissions(){
  6 + static getUserPermissions() {
7 7 return defHttp.get('/yt/role/me/permissions')
8 8 }
9 9
... ... @@ -171,4 +171,14 @@ class ConfigurationNodeApi {
171 171 static getStreamingVideoPlayUrl(id) {
172 172 return defHttp.get(`/yt/video/url/${id}`)
173 173 }
  174 +
  175 + /**
  176 + * @description 获取设备物模型属性
  177 + * @param {*} deviceProfileId
  178 + * @param {*} dataType
  179 + * @returns
  180 + */
  181 + static getDeviceAttribute(deviceProfileId, dataType) {
  182 + return defHttp.get(`/yt/device/attributes/${deviceProfileId}`, { params: { dataType } })
  183 + }
174 184 }
... ...
... ... @@ -7777,13 +7777,13 @@ DataFormatPanel.prototype.addDataFont = function (container) {
7777 7777
7778 7778 /**
7779 7779 * @description
7780   - * @type {{id: string, deviceType: string, name: string}[]}
  7780 + * @type {{id: string, deviceType: string, name: string, deviceProfileId: string}[]}
7781 7781 */
7782 7782 let deviceList = []
7783 7783
7784 7784 /**
7785 7785 * @description
7786   - * @type {{id: string, deviceType: string, name: string}[]}
  7786 + * @type {{id: string, deviceType: string, name: string, deviceProfileId: string}[]}
7787 7787 */
7788 7788 let slaveDeviceList = []
7789 7789
... ... @@ -7850,10 +7850,10 @@ DataFormatPanel.prototype.addDataFont = function (container) {
7850 7850 /**
7851 7851 * @description 根据设备ID获取属性
7852 7852 */
7853   - async function getAttrByDeviceId(tbDeviceId) {
7854   - if (tbDeviceId) {
7855   - const [err, res] = await to(ConfigurationNodeApi.getDeviceAttr(tbDeviceId))
7856   - $(`#${componentId} `).find(`select[name="${enumDataSourceConst.ATTR}"]`).html(UseLayUi.generateOptionTemplate({ dataSource: res }))
  7853 + async function getAttrByDeviceId(deviceProfileId) {
  7854 + if (deviceProfileId) {
  7855 + const [err, res] = await to(ConfigurationNodeApi.getDeviceAttribute(deviceProfileId))
  7856 + $(`#${componentId} `).find(`select[name="${enumDataSourceConst.ATTR}"]`).html(UseLayUi.generateOptionTemplate({ dataSource: Array.isArray(res) ? res : [], labelField: 'name', valueField: 'identifier' }))
7857 7857 form.render('select', componentFilter)
7858 7858 }
7859 7859 }
... ... @@ -7882,9 +7882,9 @@ DataFormatPanel.prototype.addDataFont = function (container) {
7882 7882 data: treeList,
7883 7883 onlyIconControl: true,
7884 7884 click(node) {
7885   - currentCheckedOrgNode = node.data.id
  7885 + currentCheckedOrgNode = node?.data?.id
7886 7886 form.val(componentFilter, {
7887   - [enumDataSourceConst.ORG_NAME]: node.data.title,
  7887 + [enumDataSourceConst.ORG_NAME]: node?.data?.title,
7888 7888 [enumDataSourceConst.DEVICE_ID]: null,
7889 7889 [enumDataSourceConst.SLAVE_DEVICE_ID]: null,
7890 7890 [enumDataSourceConst.ATTR]: null,
... ... @@ -7913,7 +7913,7 @@ DataFormatPanel.prototype.addDataFont = function (container) {
7913 7913 const selected = deviceList.find(item => item.id === value)
7914 7914 if (!selected) return
7915 7915 form.val(componentFilter, {
7916   - [enumDataSourceConst.DEVICE_NAME]: selected.name,
  7916 + [enumDataSourceConst.DEVICE_NAME]: selected?.name,
7917 7917 [enumDataSourceConst.SLAVE_DEVICE_ID]: null,
7918 7918 [enumDataSourceConst.ATTR]: null,
7919 7919 [enumDataSourceConst.SLAVE_DEVICE_NAME]: null,
... ... @@ -7928,7 +7928,8 @@ DataFormatPanel.prototype.addDataFont = function (container) {
7928 7928 $(`#${componentId}`).find(`select[name="${enumDataSourceConst.SLAVE_DEVICE_ID}"]`)
7929 7929 .attr('lay-verify', '').attr('lay-verType', 'tips')
7930 7930 .parentsUntil(`#${componentId}`).hide()
7931   - getAttrByDeviceId(selected.id)
  7931 + console.log(selected)
  7932 + getAttrByDeviceId(selected.deviceProfileId)
7932 7933 }
7933 7934 },
7934 7935 })
... ... @@ -7948,11 +7949,11 @@ DataFormatPanel.prototype.addDataFont = function (container) {
7948 7949 const { value } = data
7949 7950 const selected = slaveDeviceList.find(item => item.id === value)
7950 7951 form.val(componentFilter, {
7951   - [enumDataSourceConst.SLAVE_DEVICE_NAME]: selected.name,
  7952 + [enumDataSourceConst.SLAVE_DEVICE_NAME]: selected?.name,
7952 7953 [enumDataSourceConst.ATTR]: null,
7953 7954 [enumDataSourceConst.ATTR_NAME]: null,
7954 7955 })
7955   - getAttrByDeviceId(value)
  7956 + getAttrByDeviceId(selected.deviceProfileId)
7956 7957 },
7957 7958 })
7958 7959 $(component).append(slaveDeviceSelect)
... ... @@ -13448,7 +13449,7 @@ class DispatchCenter {
13448 13449
13449 13450 message && messageList.tsSubCmds.push(message)
13450 13451 })
13451   -
  13452 +
13452 13453 return messageList
13453 13454 }
13454 13455
... ...