Commit de216299ff1b6692989e6d1e5a465602aeb4ebaa

Authored by xp.Huang
2 parents 35db9ca4 48b6727e

Merge branch 'perf/preview-mode-params-setting' into 'main_dev'

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

See merge request yunteng/thingskit-scada!106
@@ -5075,7 +5075,7 @@ DataFormatPanel.prototype.addDataFont = function (container) { @@ -5075,7 +5075,7 @@ DataFormatPanel.prototype.addDataFont = function (container) {
5075 5075
5076 /** 5076 /**
5077 * @description 用于在其他位置获取数据源绑定的数据,在生成数据源面板中进行了改写 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 function getDataSourceBindValue() { 5080 function getDataSourceBindValue() {
5081 5081
@@ -5235,7 +5235,9 @@ DataFormatPanel.prototype.addDataFont = function (container) { @@ -5235,7 +5235,9 @@ DataFormatPanel.prototype.addDataFont = function (container) {
5235 5235
5236 5236
5237 async function mount() { 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 $(fragment).append(title).append(component) 5241 $(fragment).append(title).append(component)
5240 $(container).append(fragment) 5242 $(container).append(fragment)
5241 5243
@@ -6586,7 +6588,7 @@ DataFormatPanel.prototype.addDataFont = function (container) { @@ -6586,7 +6588,7 @@ DataFormatPanel.prototype.addDataFont = function (container) {
6586 function getSwitchSubmitValue(field) { 6588 function getSwitchSubmitValue(field) {
6587 const dataSources = getDataSourceBindValue() 6589 const dataSources = getDataSourceBindValue()
6588 const enableStatus = getEnableStatus(field) 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,9 +8705,10 @@ DataFormatPanel.prototype.addDataFont = function (container) {
8703 * @param {object} options 8705 * @param {object} options
8704 * @param {string} [options.overrideClass = ''] options.overrideClass 8706 * @param {string} [options.overrideClass = ''] options.overrideClass
8705 * @param {boolean} [options.validate = true ] options.validate 8707 * @param {boolean} [options.validate = true ] options.validate
  8708 + * @param {boolean} [options.extractAttribute ] options.extractAttribute
8706 */ 8709 */
8707 function generateDataSourceComponent(options = {}) { 8710 function generateDataSourceComponent(options = {}) {
8708 - const { overrideClass = '', validate = true } = options 8711 + const { overrideClass = '', validate = true, extractAttribute } = options
8709 const componentFilter = `data-source__component-filter-${Date.now()}` 8712 const componentFilter = `data-source__component-filter-${Date.now()}`
8710 const componentId = `data-source__component-${Date.now()}` 8713 const componentId = `data-source__component-${Date.now()}`
8711 8714
@@ -8885,7 +8888,10 @@ DataFormatPanel.prototype.addDataFont = function (container) { @@ -8885,7 +8888,10 @@ DataFormatPanel.prototype.addDataFont = function (container) {
8885 if (deviceProfileId) { 8888 if (deviceProfileId) {
8886 const [err, res] = await to(ConfigurationNodeApi.getDeviceAttribute(deviceProfileId)) 8889 const [err, res] = await to(ConfigurationNodeApi.getDeviceAttribute(deviceProfileId))
8887 thingsModel = res 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 form.render('select', componentFilter) 8895 form.render('select', componentFilter)
8890 } 8896 }
8891 } 8897 }
@@ -9016,6 +9022,12 @@ DataFormatPanel.prototype.addDataFont = function (container) { @@ -9016,6 +9022,12 @@ DataFormatPanel.prototype.addDataFont = function (container) {
9016 9022
9017 $(`#${componentId} input[name="${enumDataSourceConst.ORG_ID}"]`).val(orgNode?.id).parent().find('span').html(orgNode?.name) 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 form.val(componentFilter, { 9031 form.val(componentFilter, {
9020 orgId, 9032 orgId,
9021 deviceId, 9033 deviceId,
@@ -9026,7 +9038,9 @@ DataFormatPanel.prototype.addDataFont = function (container) { @@ -9026,7 +9038,9 @@ DataFormatPanel.prototype.addDataFont = function (container) {
9026 deviceCode, 9038 deviceCode,
9027 registerAddress, 9039 registerAddress,
9028 thingsModelDataType, 9040 thingsModelDataType,
9029 - actionType 9041 + actionType,
  9042 + deviceName,
  9043 + attrName,
9030 }) 9044 })
9031 9045
9032 }) 9046 })
@@ -16379,8 +16393,17 @@ class HandleDataInteraction { @@ -16379,8 +16393,17 @@ class HandleDataInteraction {
16379 } 16393 }
16380 16394
16381 function createLayer() { 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 layer.open({ 16405 layer.open({
16383 - title: '参数设置', 16406 + title: `参数设置 - ${name}`,
16384 content: createContent(), 16407 content: createContent(),
16385 area: '400px', 16408 area: '400px',
16386 btn: ["应用", "取消"], 16409 btn: ["应用", "取消"],