You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

117 lines
2.9 KiB

2 months ago
2 months ago
2 months ago
2 months ago
  1. <script setup lang="ts">
  2. import { getContainerList } from 'apis/container'
  3. import { getSolsList } from 'apis/solution'
  4. import { FtMessage } from 'libs/message'
  5. import { useHomeStore } from 'stores/homeStore'
  6. import { useSolutionStore } from 'stores/useSolutionStore'
  7. import { onMounted, ref } from 'vue'
  8. const emits = defineEmits(['ok', 'cancel'])
  9. const homeStore = useHomeStore()
  10. let currentCommandId = ''
  11. onMounted(() => {
  12. queryContainerList()
  13. querySolutionList()
  14. })
  15. const containerList = ref<Container.ContainerItem[]>([])
  16. const queryContainerList = async () => {
  17. const res = await getContainerList()
  18. containerList.value = res.filter(item => item.type === 0)
  19. }
  20. const cancel = async () => {
  21. currentCommandId = Date.now().toString()
  22. const params = {
  23. commandId: currentCommandId,
  24. command: 'liquid_motor_origin',
  25. params: {},
  26. }
  27. await homeStore.sendControl(params)
  28. emits('cancel')
  29. }
  30. const solutionList = ref<Solution.SolutionItem[]>([])
  31. const solutionMap = ref<Record<string | number, string>>({})
  32. const solutionStore = useSolutionStore()
  33. const querySolutionList = async () => {
  34. const res = await getSolsList()
  35. if (res && res.list) {
  36. solutionList.value = res.list
  37. solutionList.value.forEach((item) => {
  38. if (item.id) {
  39. solutionMap.value[item.id] = item.name
  40. }
  41. })
  42. solutionStore.updateSolution(res.list)
  43. }
  44. }
  45. const filled_solution_start = async () => {
  46. if (!checked.value) {
  47. FtMessage.warning('请选择要预充的溶液')
  48. return
  49. }
  50. currentCommandId = Date.now().toString()
  51. const params = {
  52. commandId: currentCommandId,
  53. command: 'liquid_pre_fill_start',
  54. params: {
  55. solutionId: checked.value,
  56. },
  57. }
  58. await homeStore.sendControl(params)
  59. }
  60. const filled_solution_stop = async () => {
  61. currentCommandId = Date.now().toString()
  62. const params = {
  63. commandId: currentCommandId,
  64. command: 'liquid_pre_fill_stop',
  65. params: {},
  66. }
  67. await homeStore.sendControl(params)
  68. }
  69. const checked = ref<number>()
  70. </script>
  71. <template>
  72. <FtDialog visible title="预充管路" width="50%">
  73. <el-radio-group v-model="checked">
  74. <el-radio v-for="item in containerList" :key="item.id" border :label="solutionMap[item.solutionId]" :value="item.id" />
  75. </el-radio-group>
  76. <template #footer>
  77. <ft-button type="primary" :click-handle="filled_solution_start">
  78. 开始预充
  79. </ft-button>
  80. <ft-button type="primary" :click-handle="filled_solution_stop">
  81. 停止预充
  82. </ft-button>
  83. <ft-button :click-handle="cancel">
  84. 完成预充
  85. </ft-button>
  86. </template>
  87. </FtDialog>
  88. </template>
  89. <style scoped lang="scss">
  90. .item-box {
  91. display: flex;
  92. align-items: center;
  93. justify-content: space-between;
  94. padding: 5px;
  95. }
  96. .el-checkbox {
  97. margin: 10px 5px;
  98. min-width: 100px;
  99. }
  100. .button-box {
  101. margin-top: 10px;
  102. display: flex;
  103. justify-content: center;
  104. }
  105. </style>