tsbOpwConfig.js 1.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960
  1. /** 液位仪 cmdType 与 Web 子页映射 */
  2. export const OPW_CMD = {
  3. MAIN: 'common:opw',
  4. QUERY: 'common:opw:query',
  5. PASSTHROUGH: 'common:opw:passthrough'
  6. }
  7. export const OPW_SUB_PAGE = {
  8. main: OPW_CMD.MAIN,
  9. query: OPW_CMD.QUERY,
  10. passthrough: OPW_CMD.PASSTHROUGH
  11. }
  12. export const OPW_CMD_SUB_PAGE = {
  13. [OPW_CMD.MAIN]: 'main',
  14. [OPW_CMD.QUERY]: 'query',
  15. [OPW_CMD.PASSTHROUGH]: 'passthrough'
  16. }
  17. export const OPW_SUB_PAGE_TITLE = {
  18. main: '液位仪',
  19. query: '液位仪查询',
  20. passthrough: '液位仪透传'
  21. }
  22. export const OPW_BUTTON = {
  23. QUERY_A: 'common:opw:query:a',
  24. QUERY_B: 'common:opw:query:b',
  25. QUERY_485: 'common:opw:query:485',
  26. VIEW_RAW_LOG: 'common:opw:query:rawLog'
  27. }
  28. export const OPW_BAUDRATES = ['2400', '4800', '9600', '19200', '38400', '57600', '115200']
  29. export const OPW_TANK_COLUMNS = [
  30. { prop: 'tankNo', label: '罐号', width: 70 },
  31. { prop: 'oilWaterVolume1', label: '油水体积1', width: 100 },
  32. { prop: 'oilWaterVolume2', label: '油水体积2', width: 100 },
  33. { prop: 'remainingVolume', label: '剩余体积', width: 100 },
  34. { prop: 'oilHeight', label: '油高', width: 70 },
  35. { prop: 'waterHeight', label: '水高', width: 70 },
  36. { prop: 'temperature', label: '温度', width: 70 },
  37. { prop: 'waterVolume', label: '水体积', width: 80 },
  38. { prop: 'serialPort', label: '串口', width: 70 },
  39. { prop: 'readTime', label: '读取时间', width: 150 }
  40. ]
  41. /** 按 key 存在性合并 WS 数据:不存在不更新,null/'' 渲染为空 */
  42. export function applyPartialFields(target, data, fields, defaults = {}) {
  43. if (!data || !target) {
  44. return
  45. }
  46. fields.forEach((key) => {
  47. if (!Object.prototype.hasOwnProperty.call(data, key)) {
  48. return
  49. }
  50. const val = data[key]
  51. target[key] = val == null || val === '' ? (defaults[key] != null ? defaults[key] : '') : val
  52. })
  53. }