Commit de316bb7237392b5e30392c97154c68744d5ff44

Authored by xp.Huang
2 parents e5bbc807 553f3388

Merge branch 'fix/DEFECT-1492' into 'main_dev'

fix: 修复组态数据绑定参数设置名称回显问题

See merge request yunteng/thingskit-scada!119
@@ -7140,7 +7140,7 @@ DataFormatPanel.prototype.addDataFont = function (container) { @@ -7140,7 +7140,7 @@ DataFormatPanel.prototype.addDataFont = function (container) {
7140 */ 7140 */
7141 async function getAllGatewayDeviceAndConnectionDevice() { 7141 async function getAllGatewayDeviceAndConnectionDevice() {
7142 if (!recordData.orgId) return 7142 if (!recordData.orgId) return
7143 - const [err, res] = await to(ConfigurationNodeApi.getAllGatewayDeviceAndConnectionDevice(recordData.orgId)) 7143 + const [err, res] = await to(ConfigurationNodeApi.getMeetConditionsDevice({ organizationId: recordData.orgId }))
7144 allDeviceOptions = res 7144 allDeviceOptions = res
7145 mountAllDeviceToSelect() 7145 mountAllDeviceToSelect()
7146 } 7146 }
@@ -7149,7 +7149,8 @@ DataFormatPanel.prototype.addDataFont = function (container) { @@ -7149,7 +7149,8 @@ DataFormatPanel.prototype.addDataFont = function (container) {
7149 * @description 将设备选项挂载到节点中 7149 * @description 将设备选项挂载到节点中
7150 */ 7150 */
7151 function mountAllDeviceToSelect() { 7151 function mountAllDeviceToSelect() {
7152 - const generateOption = UseLayUi.generateOptionTemplate({ dataSource: allDeviceOptions, alias: 'alias' }) 7152 + const generateOption = UseLayUi.generateOptionTemplate({ dataSource: allDeviceOptions, labelField: 'name', valueField: 'tbDeviceId', alias: 'alias' })
  7153 +
7153 $(`#${enumActionEl.DEVICE_DATA_BODY_EL}`).find(`select[name="${enumConst.DEVICE}"]`).html(generateOption) 7154 $(`#${enumActionEl.DEVICE_DATA_BODY_EL}`).find(`select[name="${enumConst.DEVICE}"]`).html(generateOption)
7154 UseLayUi.nextTick(() => form.render('select')) 7155 UseLayUi.nextTick(() => form.render('select'))
7155 } 7156 }
@@ -7257,7 +7258,7 @@ DataFormatPanel.prototype.addDataFont = function (container) { @@ -7257,7 +7258,7 @@ DataFormatPanel.prototype.addDataFont = function (container) {
7257 function createAddRowListenEvent() { 7258 function createAddRowListenEvent() {
7258 $(`#${enumActionEl.ADD_ROW_EL}`).on('click', () => { 7259 $(`#${enumActionEl.ADD_ROW_EL}`).on('click', () => {
7259 addRecord() 7260 addRecord()
7260 - const generateOption = UseLayUi.generateOptionTemplate({ dataSource: allDeviceOptions, alias: 'alias' }) 7261 + const generateOption = UseLayUi.generateOptionTemplate({ dataSource: allDeviceOptions, labelField: 'name', valueField: 'tbDeviceId', alias: 'alias' })
7261 $(`#${enumActionEl.DEVICE_DATA_BODY_EL} tr`).last().find(`select[name="${enumConst.DEVICE}"]`).html(generateOption) 7262 $(`#${enumActionEl.DEVICE_DATA_BODY_EL} tr`).last().find(`select[name="${enumConst.DEVICE}"]`).html(generateOption)
7262 form.render('select') 7263 form.render('select')
7263 }) 7264 })
@@ -7267,7 +7268,7 @@ DataFormatPanel.prototype.addDataFont = function (container) { @@ -7267,7 +7268,7 @@ DataFormatPanel.prototype.addDataFont = function (container) {
7267 * @description 设置设备选项 7268 * @description 设置设备选项
7268 */ 7269 */
7269 function setDeviceOptions(row) { 7270 function setDeviceOptions(row) {
7270 - const generateOption = UseLayUi.generateOptionTemplate({ dataSource: allDeviceOptions, alias: 'alias' }) 7271 + const generateOption = UseLayUi.generateOptionTemplate({ dataSource: allDeviceOptions, labelField: 'name', valueField: 'tbDeviceId', alias: 'alias' })
7271 $(`#${enumActionEl.DEVICE_DATA_BODY_EL} tr[lay-filter="${getRowFilter(row)}"]`).find(`select[name="${enumConst.DEVICE}"]`).html(generateOption) 7272 $(`#${enumActionEl.DEVICE_DATA_BODY_EL} tr[lay-filter="${getRowFilter(row)}"]`).find(`select[name="${enumConst.DEVICE}"]`).html(generateOption)
7272 } 7273 }
7273 7274
@@ -7348,7 +7349,6 @@ DataFormatPanel.prototype.addDataFont = function (container) { @@ -7348,7 +7349,6 @@ DataFormatPanel.prototype.addDataFont = function (container) {
7348 7349
7349 const formModel = form.val(enumActionEl.FORM_FILTER) 7350 const formModel = form.val(enumActionEl.FORM_FILTER)
7350 if (!formModel[enumConst.ORG_ID]) return false 7351 if (!formModel[enumConst.ORG_ID]) return false
7351 -  
7352 for (let i = 0; i < tableData.length; i++) { 7352 for (let i = 0; i < tableData.length; i++) {
7353 const { value } = tableData[i] 7353 const { value } = tableData[i]
7354 if (!isJson(value)) { 7354 if (!isJson(value)) {
@@ -7561,7 +7561,9 @@ DataFormatPanel.prototype.addDataFont = function (container) { @@ -7561,7 +7561,9 @@ DataFormatPanel.prototype.addDataFont = function (container) {
7561 /** 7561 /**
7562 * @description 服务调用方式 7562 * @description 服务调用方式
7563 */ 7563 */
7564 - CALL_TYPE: 'callType' 7564 + CALL_TYPE: 'callType',
  7565 +
  7566 + SERVICE_NAME: 'serviceName'
7565 } 7567 }
7566 7568
7567 /** 7569 /**
@@ -7689,6 +7691,7 @@ DataFormatPanel.prototype.addDataFont = function (container) { @@ -7689,6 +7691,7 @@ DataFormatPanel.prototype.addDataFont = function (container) {
7689 [enumConst.TCP_COMMAND]: content[enumConst.TCP_COMMAND], 7691 [enumConst.TCP_COMMAND]: content[enumConst.TCP_COMMAND],
7690 [enumConst.TRANSPORTTYPE]: content[enumConst.TRANSPORTTYPE], 7692 [enumConst.TRANSPORTTYPE]: content[enumConst.TRANSPORTTYPE],
7691 [enumConst.SERVICE]: content[enumConst.SERVICE], 7693 [enumConst.SERVICE]: content[enumConst.SERVICE],
  7694 + [enumConst.SERVICE_NAME]: content[enumConst.SERVICE_NAME],
7692 [enumConst.SERVICE_COMMAND]: content[enumConst.SERVICE_COMMAND], 7695 [enumConst.SERVICE_COMMAND]: content[enumConst.SERVICE_COMMAND],
7693 [enumConst.SERVICE_ORIGINAL_CONFIGURATION]: content[enumConst.SERVICE_ORIGINAL_CONFIGURATION], 7696 [enumConst.SERVICE_ORIGINAL_CONFIGURATION]: content[enumConst.SERVICE_ORIGINAL_CONFIGURATION],
7694 } 7697 }
@@ -7816,7 +7819,7 @@ DataFormatPanel.prototype.addDataFont = function (container) { @@ -7816,7 +7819,7 @@ DataFormatPanel.prototype.addDataFont = function (container) {
7816 if (commandType === COMMAND_TYPE_ENUM.CUSTOM) { 7819 if (commandType === COMMAND_TYPE_ENUM.CUSTOM) {
7817 fields = [...fields, enumConst.JSON_COMMAND, enumConst.TCP_COMMAND] 7820 fields = [...fields, enumConst.JSON_COMMAND, enumConst.TCP_COMMAND]
7818 } else if (commandType === COMMAND_TYPE_ENUM.SERVICE) { 7821 } else if (commandType === COMMAND_TYPE_ENUM.SERVICE) {
7819 - fields = [...fields, enumConst.CALL_TYPE, enumConst.IDENTIFIER, enumConst.SERVICE, enumConst.SERVICE_COMMAND, enumConst.SERVICE_ORIGINAL_CONFIGURATION] 7822 + fields = [...fields, enumConst.CALL_TYPE, enumConst.IDENTIFIER, enumConst.SERVICE, enumConst.SERVICE_COMMAND, enumConst.SERVICE_ORIGINAL_CONFIGURATION, enumConst.SERVICE_NAME]
7820 } 7823 }
7821 7824
7822 return fields.reduce((prev, next) => ({ ...prev, [next]: formVal[next] }), {}) 7825 return fields.reduce((prev, next) => ({ ...prev, [next]: formVal[next] }), {})
@@ -7954,7 +7957,8 @@ DataFormatPanel.prototype.addDataFont = function (container) { @@ -7954,7 +7957,8 @@ DataFormatPanel.prototype.addDataFont = function (container) {
7954 } else { 7957 } else {
7955 form.val(enumActionEl.FORM_FILTER, { [enumConst.SERVICE_COMMAND]: needRender.functionJson?.inputData?.[0]?.serviceCommand || '' }) 7958 form.val(enumActionEl.FORM_FILTER, { [enumConst.SERVICE_COMMAND]: needRender.functionJson?.inputData?.[0]?.serviceCommand || '' })
7956 } 7959 }
7957 - form.val(enumActionEl.FORM_FILTER, { [enumConst.SERVICE_ORIGINAL_CONFIGURATION]: JSON.stringify(needRender.functionJson?.inputData || []), [enumConst.IDENTIFIER]: needRender?.identifier, [enumConst.CALL_TYPE]: needRender?.callType }) 7960 +
  7961 + form.val(enumActionEl.FORM_FILTER, { [enumConst.SERVICE_ORIGINAL_CONFIGURATION]: JSON.stringify(needRender.functionJson?.inputData || []), [enumConst.IDENTIFIER]: needRender?.identifier, [enumConst.CALL_TYPE]: needRender?.callType, [enumConst.SERVICE_NAME]: needRender?.functionName })
7958 }) 7962 })
7959 7963
7960 try { 7964 try {
@@ -8095,6 +8099,9 @@ DataFormatPanel.prototype.addDataFont = function (container) { @@ -8095,6 +8099,9 @@ DataFormatPanel.prototype.addDataFont = function (container) {
8095 </div> 8099 </div>
8096 </div> 8100 </div>
8097 <div style="display: none;"> 8101 <div style="display: none;">
  8102 + <input type="text" name="${enumConst.SERVICE_NAME}" placeholder="服务名称" />
  8103 + </div>
  8104 + <div style="display: none;">
8098 <input type="text" name="${enumConst.IDENTIFIER}" placeholder="标识符" /> 8105 <input type="text" name="${enumConst.IDENTIFIER}" placeholder="标识符" />
8099 </div> 8106 </div>
8100 <div style="display: none;"> 8107 <div style="display: none;">
@@ -15954,8 +15961,9 @@ class HandleDataInteraction { @@ -15954,8 +15961,9 @@ class HandleDataInteraction {
15954 const [err, res = []] = way === 'twoway' ? await to(ConfigurationNodeApi.deviceIsOnLine(deviceId)) : [null, [{ value: true }]] 15961 const [err, res = []] = way === 'twoway' ? await to(ConfigurationNodeApi.deviceIsOnLine(deviceId)) : [null, [{ value: true }]]
15955 const { value } = res[0] || {} 15962 const { value } = res[0] || {}
15956 if (value) { 15963 if (value) {
15957 - await to(ConfigurationNodeApi.sendInstruction(way, deviceId, data))  
15958 - UseLayUi.topSuccessMsg('下发成功~') 15964 + const [err, response] = await to(ConfigurationNodeApi.sendInstruction(way, deviceId, data))
  15965 + if (response?.rpcId) UseLayUi.topSuccessMsg('下发成功~')
  15966 + else UseLayUi.topErrorMsg('下发失败~')
15959 } else { 15967 } else {
15960 UseLayUi.errorMsg('设备不在线!') 15968 UseLayUi.errorMsg('设备不在线!')
15961 } 15969 }
@@ -16298,7 +16306,7 @@ class HandleDataInteraction { @@ -16298,7 +16306,7 @@ class HandleDataInteraction {
16298 { value: method, required: true, message: '未找到Modbus命令操作类型' }, 16306 { value: method, required: true, message: '未找到Modbus命令操作类型' },
16299 { value, message: '下发值不是一个数字', validator(value) { return value.toString().trim() && !isNaN(value) } }, 16307 { value, message: '下发值不是一个数字', validator(value) { return value.toString().trim() && !isNaN(value) } },
16300 ...(method == '05' ? [{ value, message: '下发类型必须为0或1', validator(value) { return value == 0 || value == 1 } }] : []), 16308 ...(method == '05' ? [{ value, message: '下发类型必须为0或1', validator(value) { return value == 0 || value == 1 } }] : []),
16301 - ...(method == '06' ? [{ value, message: `下发类型必须为整型,缩放因子为${zoomFactor}`, validator(value) { return !isNaN(value) && getNumberFloatPart(Number(value)) * zoomFactor % 1 === 0 } }, { value: Number(value) * zoomFactor, message: `最大值不能超过65535,缩放因子为${zoomFactor}`, validator(value) { return Number(value) <= parseInt('ffff', 16) } }] : []), 16309 + ...(method == '06' ? [{ value, message: `下发类型必须为正整型,缩放因子为${zoomFactor}`, validator(value) { return !isNaN(value) && value >= 0 && getNumberFloatPart(Number(value)) * zoomFactor % 1 === 0 } }, { value: Number(value) * zoomFactor, message: `最大值不能超过65535,缩放因子为${zoomFactor}`, validator(value) { return Number(value) <= parseInt('ffff', 16) } }] : []),
16302 ...(method == '16' ? [{ value, message: '下发类型精确到两位小数', validator(value) { return /^-?\d+(\.\d{0,2})?$/.test(Math.floor(Number(value)) * zoomFactor + getNumberFloatPart(Number(value)) * zoomFactor) } }] : []) 16310 ...(method == '16' ? [{ value, message: '下发类型精确到两位小数', validator(value) { return /^-?\d+(\.\d{0,2})?$/.test(Math.floor(Number(value)) * zoomFactor + getNumberFloatPart(Number(value)) * zoomFactor) } }] : [])
16303 ]) 16311 ])
16304 16312
@@ -16445,7 +16453,7 @@ class HandleDataInteraction { @@ -16445,7 +16453,7 @@ class HandleDataInteraction {
16445 if (content.commandType == '0' || content.commandType == '2') { 16453 if (content.commandType == '0' || content.commandType == '2') {
16446 name = `${deviceName || ''} - ${attrName || ''}` 16454 name = `${deviceName || ''} - ${attrName || ''}`
16447 } else { 16455 } else {
16448 - name = `${deviceName || ''} - ${content?.service}` 16456 + name = `${deviceName || ''} - ${content?.serviceName}`
16449 } 16457 }
16450 layer.open({ 16458 layer.open({
16451 title: `参数设置 - ${name}`, 16459 title: `参数设置 - ${name}`,