index.vue 2.6 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394959697
  1. <template>
  2. <el-dialog
  3. v-model="dialogVisible"
  4. :close-on-click-modal="false"
  5. :title="parameter.title"
  6. :destroy-on-close="true"
  7. :fullscreen="parameter.fullscreen"
  8. draggable
  9. >
  10. <div class="params-box">
  11. <el-descriptions title="">
  12. <div v-for="item in airResult" :key="item.code">
  13. <el-descriptions-item :label="getTitle(item.code)">
  14. <el-switch v-model="item.value" disabled active-value="1" inactive-value="0" />
  15. </el-descriptions-item>
  16. </div>
  17. </el-descriptions>
  18. </div>
  19. <template #footer>
  20. <span class="dialog-footer">
  21. <el-button @click="handleCancel">取消</el-button>
  22. </span>
  23. </template>
  24. </el-dialog>
  25. </template>
  26. <script setup lang="ts" name="airResult">
  27. import { ref, computed, onMounted } from 'vue'
  28. import { useAirStore } from '@/stores/modules/air'
  29. import { getDictsApi } from '@/api/modules/system/dictData'
  30. import { useUserStore } from '@/stores/modules/user'
  31. import { initWebSocket } from '@/utils/websocket'
  32. onMounted(() => {
  33. const userStore = useUserStore()
  34. let protocol = window.location.protocol === 'https:' ? 'wss://' : 'ws://'
  35. // initWebSocket(protocol + 'localhost:8089' + '/resource/websocket')
  36. initWebSocket(protocol + window.location.host + import.meta.env.VITE_API_URL + '/websocket/message/' + userStore.name)
  37. })
  38. let paramsDicts = ref()
  39. getDictsApi('air_order_result').then(res => {
  40. paramsDicts.value = res.data
  41. })
  42. export interface ParameterProps {
  43. title: string // 标题
  44. fullscreen?: boolean // 是否全屏
  45. sortieNo?: any
  46. parameters?: any[]
  47. }
  48. const airResult = computed(() => {
  49. return useAirStore().airResult.params
  50. })
  51. const getTitle = val => {
  52. // console.log(val)
  53. // console.log('paramsDict', paramsDicts.value)
  54. const item = paramsDicts.value.filter(item => {
  55. // console.log('item.dictValue', item.dictValue)
  56. // console.log('item.dictValue == val', item.dictValue == val)
  57. return item.dictValue == val
  58. })
  59. // paramsDict
  60. return item[0].dictLabel
  61. }
  62. // dialog状态
  63. const dialogVisible = ref(false)
  64. const butLoading = ref(false)
  65. // 父组件传过来的参数
  66. const parameter = ref<ParameterProps>({
  67. title: '',
  68. fullscreen: true
  69. })
  70. // 取消按钮,重置表单,关闭弹框
  71. const handleCancel = () => {
  72. dialogVisible.value = false
  73. }
  74. // 接收父组件参数
  75. const openDialog = async (params: ParameterProps) => {
  76. parameter.value = { ...parameter.value, ...params }
  77. butLoading.value = false
  78. dialogVisible.value = true
  79. }
  80. defineExpose({
  81. openDialog
  82. })
  83. </script>
  84. <style scoped lang="scss">
  85. .params-box {
  86. min-height: 500px;
  87. }
  88. .dialog-footer {
  89. margin-bottom: 20px;
  90. }
  91. </style>