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

179 lines
4.4 KiB

2 months ago
2 months ago
2 months ago
2 months ago
2 months ago
2 months ago
2 months ago
2 months ago
2 months ago
4 weeks ago
4 weeks ago
2 months ago
2 months ago
2 months ago
2 months ago
2 months ago
2 months ago
2 months ago
  1. <script lang="ts" setup>
  2. // import { useSettingStore } from '@/stores/settingStore'
  3. import { syncSendCmd } from 'apis/system'
  4. import { ElMessageBox } from 'element-plus'
  5. import { computed, onMounted, ref } from 'vue'
  6. import { FtMessage } from '@/libs/message'
  7. import HistoryDetail from './HistoryDetail.vue'
  8. // const settingStore = useSettingStore()
  9. const tableData = ref<string[]>([])
  10. const selectedRecords = ref<Setting.History[]>([])
  11. const visible = ref(false)
  12. onMounted(() => {
  13. getRecord()
  14. })
  15. const getRecord = () => {
  16. const params = {
  17. className: 'DisinfectionLogsService',
  18. fnName: 'getRecordList',
  19. params: {},
  20. }
  21. syncSendCmd(params).then((res) => {
  22. if (res.ackcode === 0 && res.rely && res.rely.length) {
  23. const list: string[] = res.rely.map((item: Setting.History) => {
  24. return {
  25. name: item,
  26. }
  27. })
  28. tableData.value = list
  29. }
  30. })
  31. }
  32. const showDetail = (historyItem: Setting.History) => {
  33. const detailParams = {
  34. className: 'DisinfectionLogsService',
  35. fnName: 'getRecord',
  36. params: {
  37. logName: historyItem.name,
  38. },
  39. }
  40. syncSendCmd(detailParams).then(() => {
  41. visible.value = true
  42. })
  43. }
  44. const onDelHistory = () => {
  45. if (!selectedRecords.value.length) {
  46. FtMessage.warning('请选择要删除的数据')
  47. return
  48. }
  49. ElMessageBox.confirm('请确认是否删除?', '删除', {
  50. confirmButtonText: '确认',
  51. cancelButtonText: '取消',
  52. type: 'warning',
  53. }).then(() => {
  54. const delParams = {
  55. className: 'DisinfectionLogsService',
  56. fnName: 'deleteReports',
  57. params: {
  58. logNames: selectedRecords.value.map(item => item.name),
  59. },
  60. }
  61. syncSendCmd(delParams).then((res) => {
  62. if (res.ackcode === 0) {
  63. FtMessage.success('删除成功')
  64. getRecord()
  65. }
  66. })
  67. })
  68. }
  69. const onExportHistory = () => {
  70. // if (!selectedRecords.value.length) {
  71. // FtMessage.warning('请选择要导出的数据')
  72. // return
  73. // }
  74. const exportParams = {
  75. className: 'DisinfectionLogsService',
  76. fnName: 'exportAllRecord',
  77. params: {},
  78. }
  79. syncSendCmd(exportParams)
  80. .then((res) => {
  81. if (res.ackcode === 0) {
  82. FtMessage.success('导出成功')
  83. }
  84. })
  85. .catch((error) => {
  86. console.error('导出记录失败:', error)
  87. })
  88. }
  89. const handleSelectionChange = (rows: Setting.History[]) => {
  90. selectedRecords.value = rows
  91. }
  92. const onClose = () => {
  93. visible.value = false
  94. }
  95. const deleteBtnVisible = computed(() => {
  96. return JSON.parse(localStorage.user).roleType.includes('admin')
  97. })
  98. </script>
  99. <template>
  100. <div>
  101. <div class="history-export">
  102. <bt-button type="primary" button-text="全部导出" @click="onExportHistory" />
  103. <bt-button v-if="deleteBtnVisible" type="primary" button-text="删除" @click="onDelHistory" />
  104. </div>
  105. <div class="history-table">
  106. <el-table :data="tableData" style="width: 100%" height="100%" @selection-change="handleSelectionChange">
  107. <el-table-column type="selection" width="55" />
  108. <el-table-column type="index" label="序号" width="80" />
  109. <el-table-column prop="name" label="消毒日期" />
  110. <el-table-column prop="detail" label="操作" width="100">
  111. <template #default="scoped">
  112. <div class="user-opera">
  113. <el-button class="view-button" @click.stop="showDetail(scoped.row)">
  114. 查看
  115. </el-button>
  116. </div>
  117. </template>
  118. </el-table-column>
  119. </el-table>
  120. </div>
  121. <ft-dialog v-model="visible" title="消毒详情" width="80vw" @cancel="onClose">
  122. <div>
  123. <HistoryDetail />
  124. </div>
  125. </ft-dialog>
  126. </div>
  127. </template>
  128. <style lang="scss" scoped>
  129. .main-content {
  130. height: $main-container-height;
  131. padding: 10px;
  132. background: $gradient-color;
  133. .history-export {
  134. margin: 10px;
  135. }
  136. .history-table {
  137. height: 73vh;
  138. overflow: auto;
  139. }
  140. .view-button,
  141. .delete-button {
  142. border: none;
  143. padding: 4px 8px;
  144. border-radius: 3px;
  145. cursor: pointer;
  146. margin-right: 5px;
  147. transition: all 0.3s;
  148. font-family: serif;
  149. }
  150. .view-button {
  151. background-color: #e6f0ff;
  152. color: #1890ff;
  153. }
  154. .view-button:hover {
  155. background-color: #1890ff;
  156. color: white;
  157. }
  158. .delete-button {
  159. background-color: #ffe6e6;
  160. color: #ff4d4f;
  161. }
  162. .delete-button:hover {
  163. background-color: #ff4d4f;
  164. color: white;
  165. }
  166. }
  167. </style>