消毒机设备
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.

219 lines
4.9 KiB

2 months ago
2 months ago
2 months ago
2 months ago
2 months ago
2 months ago
2 months ago
3 weeks ago
2 months ago
2 months ago
2 months ago
2 months ago
2 months ago
2 months ago
4 weeks ago
2 months ago
4 weeks ago
4 weeks ago
2 months ago
4 weeks ago
2 months ago
4 weeks ago
2 months ago
4 weeks ago
2 months ago
4 weeks ago
2 months ago
4 weeks ago
2 months ago
  1. <script lang="ts" setup>
  2. import { FtMessage } from '@/libs/message'
  3. import { FtMessageBox } from '@/libs/messageBox'
  4. import { convertValuesToInt } from '@/libs/utils'
  5. import { useFormulaStore } from '@/stores/formulaStore'
  6. import { syncSendCmd } from 'apis/system'
  7. import { ElMessageBox } from 'element-plus'
  8. import { onMounted, ref, watchEffect } from 'vue'
  9. const formulaStore = useFormulaStore()
  10. const selectedIndex = ref<number | null>(null)
  11. const recipes = ref<Formula.FormulaItem[]>([])
  12. const currectFormula = ref<Formula.FormulaItem>()
  13. onMounted(() => {
  14. initFormulaList()
  15. })
  16. watchEffect(() => {
  17. recipes.value = formulaStore.formulaList as Formula.FormulaItem[]
  18. })
  19. const initFormulaList = () => {
  20. if (formulaStore.formulaList && formulaStore.formulaList.length) {
  21. recipes.value = formulaStore.formulaList as Formula.FormulaItem[]
  22. }
  23. else {
  24. formulaStore.initFormulaList()
  25. }
  26. }
  27. const selectRecipe = (item: Formula.FormulaItem, index: number) => {
  28. selectedIndex.value = selectedIndex.value === index ? null : index
  29. item = convertValuesToInt(item) as Formula.FormulaItem
  30. formulaStore.updateSelectedFormulaData(item)
  31. }
  32. const onStartFormula = (item: Formula.FormulaItem) => {
  33. formulaStore.updateSelectedFormulaData(item)
  34. // 执行配方时做设备的状态检查
  35. FtMessageBox.warning('请确认是否使用此配方进行消毒?').then(() => {
  36. currectFormula.value = item
  37. if (item.formula_id) {
  38. const params = {
  39. className: 'DisinfectionCtrlServiceExt',
  40. fnName: 'startWithFormula',
  41. params: {
  42. formulaid: item.formula_id,
  43. },
  44. }
  45. syncSendCmd(params).then((res) => {
  46. if (res.ackcode === 0) {
  47. // 把选择执行的配方同步至运行参数
  48. formulaStore.updateSelectedFormulaDataByList(item)
  49. FtMessage.success('已开始消毒')
  50. }
  51. })
  52. }
  53. })
  54. }
  55. const deleteRecipe = (item: Formula.FormulaItem) => {
  56. ElMessageBox.confirm(
  57. '请确认是否删除?',
  58. '删除',
  59. {
  60. confirmButtonText: '确认',
  61. cancelButtonText: '取消',
  62. type: 'warning',
  63. },
  64. ).then(() => {
  65. if (item.formula_id) {
  66. const delParams = {
  67. className: 'SettingMgrService',
  68. fnName: 'delFormula',
  69. params: {
  70. formula_id: item.formula_id,
  71. },
  72. }
  73. syncSendCmd(delParams).then(() => {
  74. FtMessage.success('操作成功')
  75. formulaStore.initFormulaList()
  76. })
  77. }
  78. })
  79. }
  80. </script>
  81. <template>
  82. <div v-if="recipes.length" class="recipe-management">
  83. <ul class="recipe-list">
  84. <li
  85. v-for="(item, index) in recipes"
  86. :key="index"
  87. :class="{ selected: selectedIndex === index }"
  88. @click="selectRecipe(item, index)"
  89. >
  90. <span class="formula-name">{{ item.name }}</span>
  91. <div class="actions">
  92. <el-button class="view-button" @click.stop="onStartFormula(item)">
  93. 执行配方
  94. </el-button>
  95. <el-button class="delete-button" @click.stop="deleteRecipe(item)">
  96. 删除
  97. </el-button>
  98. <span v-if="selectedIndex === index" class="selected-icon">
  99. <i class="fa fa-check-circle" />
  100. </span>
  101. </div>
  102. </li>
  103. </ul>
  104. </div>
  105. <div v-else>
  106. <el-empty description="description">
  107. <template #description>
  108. <span style="color: #ababab">未配置配方</span>
  109. </template>
  110. </el-empty>
  111. </div>
  112. </template>
  113. <style scoped>
  114. .recipe-management {
  115. font-family: serif;
  116. border: 1px solid #ccc;
  117. padding: 10px;
  118. border-radius: 5px;
  119. overflow: auto;
  120. width: 30vw;
  121. }
  122. .add-recipe-button {
  123. background-color: #e6f7ff;
  124. color: #1890ff;
  125. border: none;
  126. padding: 6px 12px;
  127. border-radius: 3px;
  128. cursor: pointer;
  129. margin-bottom: 10px;
  130. transition: all 0.3s;
  131. }
  132. .add-recipe-button:hover {
  133. background-color: #1890ff;
  134. color: white;
  135. }
  136. .recipe-list {
  137. list-style: none;
  138. padding: 0;
  139. margin: 0;
  140. .formula-name{
  141. font-size: 1.5rem;
  142. color: var(--el-text-color-regular);
  143. width: 8rem;
  144. }
  145. }
  146. .recipe-list li {
  147. display: flex;
  148. align-items: center;
  149. justify-content: space-between;
  150. padding: 10px;
  151. border-radius: 4px;
  152. margin-bottom: 8px;
  153. transition: all 0.2s;
  154. cursor: pointer;
  155. }
  156. .recipe-list li:hover {
  157. background-color: #f5f7fa;
  158. }
  159. .recipe-list li.selected {
  160. background-color: #e6f7ff;
  161. /* border: 1px solid #1890ff; */
  162. /* padding: 9px; */
  163. }
  164. .actions {
  165. display: flex;
  166. align-items: center;
  167. }
  168. .view-button, .delete-button {
  169. border: none;
  170. padding: 4px 8px;
  171. border-radius: 3px;
  172. cursor: pointer;
  173. margin-right: 5px;
  174. transition: all 0.3s;
  175. font-family: serif;
  176. }
  177. .view-button {
  178. background-color: #e6f0ff;
  179. color: #1890ff;
  180. }
  181. .view-button:hover {
  182. background-color: #1890ff;
  183. color: white;
  184. }
  185. .delete-button {
  186. background-color: #ffe6e6;
  187. color: #ff4d4f;
  188. }
  189. .delete-button:hover {
  190. background-color: #ff4d4f;
  191. color: white;
  192. }
  193. .selected-icon {
  194. color: #1890ff;
  195. /* margin-left: 8px; */
  196. }
  197. </style>