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

246 lines
6.2 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
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 { ElLoading } from 'element-plus'
  5. import { FtMessage } from 'libs/message'
  6. import { computed, onMounted, ref } from 'vue'
  7. import HistoryDetail from '../setting/HistoryDetail.vue'
  8. // const settingStore = useSettingStore()
  9. // const systemStore = useSystemStore()
  10. const tableData = ref<string[]>([])
  11. const selectedRecords = ref<Setting.History[]>([])
  12. const visible = ref(false)
  13. const detailData = ref()
  14. onMounted(() => {
  15. getRecord()
  16. })
  17. const getRecord = () => {
  18. const params = {
  19. className: 'DisinfectionLogsService',
  20. fnName: 'getRecordList',
  21. params: {},
  22. }
  23. syncSendCmd(params).then((res) => {
  24. if (res.ackcode === 0 && res.rely && res.rely.length) {
  25. const list: string[] = res.rely.map((item: Setting.History) => {
  26. return {
  27. name: item,
  28. }
  29. })
  30. tableData.value = list
  31. }
  32. })
  33. }
  34. const showDetail = (historyItem: Setting.History) => {
  35. const detailParams = {
  36. className: 'DisinfectionLogsService',
  37. fnName: 'getRecord',
  38. params: {
  39. logName: historyItem.name,
  40. },
  41. }
  42. syncSendCmd(detailParams).then((res) => {
  43. // 把值附给详情的列表
  44. detailData.value = res.rely
  45. visible.value = true
  46. })
  47. }
  48. const printDetail = (historyItem: Setting.History) => {
  49. FtMessage.info('开始打印!')
  50. const detailParams = {
  51. className: 'DisinfectionLogsService',
  52. fnName: 'printRecord',
  53. params: {
  54. logName: historyItem.name,
  55. },
  56. }
  57. syncSendCmd(detailParams).then(() => {
  58. FtMessage.success('正在打印中!')
  59. })
  60. }
  61. // const onDelHistory = () => {
  62. // if (!selectedRecords.value.length) {
  63. // FtMessage.warning('请选择要删除的数据')
  64. // return
  65. // }
  66. // ElMessageBox.confirm('请确认是否删除?', '删除', {
  67. // confirmButtonText: '确认',
  68. // cancelButtonText: '取消',
  69. // type: 'warning',
  70. // }).then(() => {
  71. // const delParams = {
  72. // className: 'DisinfectionLogsService',
  73. // fnName: 'deleteReports',
  74. // params: {
  75. // logNames: selectedRecords.value.map(item => item.name),
  76. // },
  77. // }
  78. // syncSendCmd(delParams).then((res) => {
  79. // if (res.ackcode === 0) {
  80. // FtMessage.success('删除成功')
  81. // getRecord()
  82. // }
  83. // })
  84. // })
  85. // }
  86. const onExportHistory = () => {
  87. if (!selectedRecords.value.length) {
  88. FtMessage.warning('请选择要导出的数据')
  89. return
  90. }
  91. const loading = ElLoading.service({
  92. lock: true,
  93. text: '正在导出',
  94. background: 'rgba(255, 255, 255, 0.8)',
  95. })
  96. const exportParams = {
  97. className: 'DisinfectionLogsService',
  98. fnName: 'exportRecord',
  99. params: {
  100. logNames: selectedRecords.value.map(item => item.name),
  101. },
  102. }
  103. syncSendCmd(exportParams)
  104. .then((res) => {
  105. if (res.ackcode === 0) {
  106. FtMessage.success('导出成功')
  107. }
  108. })
  109. .catch((error) => {
  110. console.error('导出记录失败:', error)
  111. })
  112. .finally(() => {
  113. loading.close()
  114. })
  115. }
  116. const handleSelectionChange = (rows: Setting.History[]) => {
  117. selectedRecords.value = rows
  118. }
  119. const onClose = () => {
  120. visible.value = false
  121. }
  122. // const deleteBtnVisible = computed(() => {
  123. // return systemStore.systemUser?.name === 'admin'
  124. // })
  125. const currentPage = ref(1)
  126. const pageSize = ref(9)
  127. const handleCurrentChange = (page: number) => {
  128. currentPage.value = page
  129. }
  130. // 计算当前页数据
  131. const currentPageData = computed(() => {
  132. const start = (currentPage.value - 1) * pageSize.value
  133. const end = start + pageSize.value
  134. return tableData.value?.slice(start, end)
  135. })
  136. </script>
  137. <template>
  138. <div>
  139. <div class="history-export">
  140. <bt-button type="primary" button-text="导出" @click="onExportHistory" />
  141. <!-- <bt-button v-if="deleteBtnVisible" type="primary" button-text="删除" @click="onDelHistory" /> -->
  142. </div>
  143. <div class="history-table">
  144. <el-table :data="currentPageData" style="width: 100%" height="100%" @selection-change="handleSelectionChange">
  145. <el-table-column type="selection" width="55" />
  146. <!-- <el-table-column type="index" label="序号" width="80" /> -->
  147. <el-table-column prop="name" label="消毒日期" />
  148. <el-table-column prop="detail" label="操作" width="200">
  149. <template #default="scoped">
  150. <div class="user-opera">
  151. <el-button type="primary" @click.stop="showDetail(scoped.row)">
  152. 查看
  153. </el-button>
  154. <el-button type="primary" @click.stop="printDetail(scoped.row)">
  155. 打印
  156. </el-button>
  157. </div>
  158. </template>
  159. </el-table-column>
  160. </el-table>
  161. </div>
  162. <div class="audit-pagination">
  163. <el-pagination
  164. layout="prev, pager, next"
  165. :total="tableData.length"
  166. :page-size="pageSize"
  167. :current-page="currentPage"
  168. @current-change="handleCurrentChange"
  169. />
  170. </div>
  171. <ft-dialog v-model="visible" title="消毒详情" width="80vw" @cancel="onClose">
  172. <div>
  173. <HistoryDetail :data="detailData" />
  174. </div>
  175. </ft-dialog>
  176. </div>
  177. </template>
  178. <style lang="scss" scoped>
  179. .user-opera {
  180. display: flex;
  181. align-items: center;
  182. }
  183. .main-content {
  184. height: $main-container-height;
  185. padding: 10px;
  186. background: $gradient-color;
  187. .history-export {
  188. height: 50px;
  189. display: flex;
  190. align-items: center;
  191. }
  192. .history-table {
  193. height: 68vh;
  194. overflow: auto;
  195. }
  196. .view-button,
  197. .delete-button,
  198. .print-button {
  199. border: none;
  200. padding: 4px 8px;
  201. border-radius: 3px;
  202. cursor: pointer;
  203. margin-right: 5px;
  204. transition: all 0.3s;
  205. font-family: serif;
  206. }
  207. .print-button {
  208. background-color: #e6f0ff;
  209. color: #1890ff;
  210. }
  211. .view-button {
  212. background-color: #e6f0ff;
  213. color: #1890ff;
  214. }
  215. .view-button:hover {
  216. background-color: #1890ff;
  217. color: white;
  218. }
  219. .print-button:hover {
  220. background-color: #1890ff;
  221. color: white;
  222. }
  223. .delete-button {
  224. background-color: #ffe6e6;
  225. color: #ff4d4f;
  226. }
  227. .delete-button:hover {
  228. background-color: #ff4d4f;
  229. color: white;
  230. }
  231. }
  232. .audit-pagination {
  233. height: 50px;
  234. display: flex;
  235. align-items: center;
  236. float: right;
  237. }
  238. </style>