Commit 48b6727e92c0436bc23b9d04be6fc89be4d22841

Authored by ww
1 parent 35db9ca4

perf: 优化参数设置下发弹窗新增设备名称/属性/服务名称显示

... ... @@ -5075,7 +5075,7 @@ DataFormatPanel.prototype.addDataFont = function (container) {
5075 5075
5076 5076 /**
5077 5077 * @description 用于在其他位置获取数据源绑定的数据,在生成数据源面板中进行了改写
5078   - * @return {{orgId: string, attr: string, deviceId: string, deviceType: string, deviceProfileId: string, deviceCode: string, registerAddress: string, method: string, thingsModelDataType: string}}
  5078 + * @return {{orgId: string, attr: string, deviceId: string, deviceType: string, deviceProfileId: string, deviceCode: string, registerAddress: string, method: string, thingsModelDataType: string, deviceName: string, attrName: string}}
5079 5079 */
5080 5080 function getDataSourceBindValue() {
5081 5081
... ... @@ -5235,7 +5235,9 @@ DataFormatPanel.prototype.addDataFont = function (container) {
5235 5235
5236 5236
5237 5237 async function mount() {
5238   - const { component, echoDataSource, getValue } = generateDataSourceComponent({ validate: true })
  5238 + const cell = vertices[0]
  5239 + const isSwitch = cell.getAttribute('componentType') == 'switch'
  5240 + const { component, echoDataSource, getValue } = generateDataSourceComponent({ validate: true, extractAttribute: isSwitch ? 'BOOL' : null })
5239 5241 $(fragment).append(title).append(component)
5240 5242 $(container).append(fragment)
5241 5243
... ... @@ -6586,7 +6588,7 @@ DataFormatPanel.prototype.addDataFont = function (container) {
6586 6588 function getSwitchSubmitValue(field) {
6587 6589 const dataSources = getDataSourceBindValue()
6588 6590 const enableStatus = getEnableStatus(field)
6589   - return { configurationId, contentId: currentPageId.id, nodeId: graphId, dataSources: { ...dataSources, additional: { deviceCode: dataSources?.deviceCode, method: dataSources?.method, registerAddress: dataSources?.registerAddress, thingsModelDataType: dataSources?.thingsModelDataType } }, ...enableStatus }
  6591 + return { configurationId, contentId: currentPageId.id, nodeId: graphId, dataSources: { ...dataSources, additional: { deviceCode: dataSources?.deviceCode, method: dataSources?.method, registerAddress: dataSources?.registerAddress, thingsModelDataType: dataSources?.thingsModelDataType, deviceName: dataSources?.deviceName, attrName: dataSources?.attrName } }, ...enableStatus }
6590 6592 }
6591 6593
6592 6594
... ... @@ -8703,9 +8705,10 @@ DataFormatPanel.prototype.addDataFont = function (container) {
8703 8705 * @param {object} options
8704 8706 * @param {string} [options.overrideClass = ''] options.overrideClass
8705 8707 * @param {boolean} [options.validate = true ] options.validate
  8708 + * @param {boolean} [options.extractAttribute ] options.extractAttribute
8706 8709 */
8707 8710 function generateDataSourceComponent(options = {}) {
8708   - const { overrideClass = '', validate = true } = options
  8711 + const { overrideClass = '', validate = true, extractAttribute } = options
8709 8712 const componentFilter = `data-source__component-filter-${Date.now()}`
8710 8713 const componentId = `data-source__component-${Date.now()}`
8711 8714
... ... @@ -8885,7 +8888,10 @@ DataFormatPanel.prototype.addDataFont = function (container) {
8885 8888 if (deviceProfileId) {
8886 8889 const [err, res] = await to(ConfigurationNodeApi.getDeviceAttribute(deviceProfileId))
8887 8890 thingsModel = res
8888   - $(`#${componentId} `).find(`select[name="${enumDataSourceConst.ATTR}"]`).html(UseLayUi.generateOptionTemplate({ dataSource: Array.isArray(res) ? res : [], labelField: 'name', valueField: 'identifier' }))
  8891 + if (extractAttribute) {
  8892 + thingsModel = thingsModel.filter(item => item.detail?.dataType?.type == extractAttribute)
  8893 + }
  8894 + $(`#${componentId} `).find(`select[name="${enumDataSourceConst.ATTR}"]`).html(UseLayUi.generateOptionTemplate({ dataSource: Array.isArray(thingsModel) ? thingsModel : [], labelField: 'name', valueField: 'identifier' }))
8889 8895 form.render('select', componentFilter)
8890 8896 }
8891 8897 }
... ... @@ -9016,6 +9022,12 @@ DataFormatPanel.prototype.addDataFont = function (container) {
9016 9022
9017 9023 $(`#${componentId} input[name="${enumDataSourceConst.ORG_ID}"]`).val(orgNode?.id).parent().find('span').html(orgNode?.name)
9018 9024
  9025 + const currentDevice = deviceList.find(item => item.tbDeviceId == deviceId)
  9026 + const deviceName = currentDevice?.alias || currentDevice?.name
  9027 +
  9028 + const currentAttr = thingsModel.find(item => item.identifier == attr)
  9029 + const attrName = currentAttr?.name
  9030 +
9019 9031 form.val(componentFilter, {
9020 9032 orgId,
9021 9033 deviceId,
... ... @@ -9026,7 +9038,9 @@ DataFormatPanel.prototype.addDataFont = function (container) {
9026 9038 deviceCode,
9027 9039 registerAddress,
9028 9040 thingsModelDataType,
9029   - actionType
  9041 + actionType,
  9042 + deviceName,
  9043 + attrName,
9030 9044 })
9031 9045
9032 9046 })
... ... @@ -16379,8 +16393,17 @@ class HandleDataInteraction {
16379 16393 }
16380 16394
16381 16395 function createLayer() {
  16396 + const currentData = contentData.dataSources.find(item => item.nodeId == nodeId)
  16397 + const { deviceName, attrName } = currentData?.additional || {}
  16398 +
  16399 + let name
  16400 + if (content.commandType == '0' || content.commandType == '2') {
  16401 + name = `${deviceName || ''} - ${attrName || ''}`
  16402 + } else {
  16403 + name = `${deviceName || ''} - ${content?.service}`
  16404 + }
16382 16405 layer.open({
16383   - title: '参数设置',
  16406 + title: `参数设置 - ${name}`,
16384 16407 content: createContent(),
16385 16408 area: '400px',
16386 16409 btn: ["应用", "取消"],
... ...