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

220 lines
5.5 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
  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 { 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. </script>
  126. <template>
  127. <div>
  128. <div class="history-export">
  129. <bt-button type="primary" button-text="导出" @click="onExportHistory" />
  130. <!-- <bt-button v-if="deleteBtnVisible" type="primary" button-text="删除" @click="onDelHistory" /> -->
  131. </div>
  132. <div class="history-table">
  133. <el-table :data="tableData" style="width: 100%" height="100%" @selection-change="handleSelectionChange">
  134. <el-table-column type="selection" width="55" />
  135. <el-table-column type="index" label="序号" width="80" />
  136. <el-table-column prop="name" label="消毒日期" />
  137. <el-table-column prop="detail" label="操作" width="200">
  138. <template #default="scoped">
  139. <div class="user-opera">
  140. <el-button type="primary" @click.stop="showDetail(scoped.row)">
  141. 查看
  142. </el-button>
  143. <el-button type="primary" @click.stop="printDetail(scoped.row)">
  144. 打印
  145. </el-button>
  146. </div>
  147. </template>
  148. </el-table-column>
  149. </el-table>
  150. </div>
  151. <ft-dialog v-model="visible" title="消毒详情" width="80vw" @cancel="onClose">
  152. <div>
  153. <HistoryDetail :data="detailData" />
  154. </div>
  155. </ft-dialog>
  156. </div>
  157. </template>
  158. <style lang="scss" scoped>
  159. .user-opera {
  160. display: flex;
  161. align-items: center;
  162. }
  163. .main-content {
  164. height: $main-container-height;
  165. padding: 10px;
  166. background: $gradient-color;
  167. .history-export {
  168. height: 50px;
  169. display: flex;
  170. align-items: center;
  171. }
  172. .history-table {
  173. height: 73vh;
  174. overflow: auto;
  175. }
  176. .view-button,
  177. .delete-button,
  178. .print-button {
  179. border: none;
  180. padding: 4px 8px;
  181. border-radius: 3px;
  182. cursor: pointer;
  183. margin-right: 5px;
  184. transition: all 0.3s;
  185. font-family: serif;
  186. }
  187. .print-button {
  188. background-color: #e6f0ff;
  189. color: #1890ff;
  190. }
  191. .view-button {
  192. background-color: #e6f0ff;
  193. color: #1890ff;
  194. }
  195. .view-button:hover {
  196. background-color: #1890ff;
  197. color: white;
  198. }
  199. .print-button:hover {
  200. background-color: #1890ff;
  201. color: white;
  202. }
  203. .delete-button {
  204. background-color: #ffe6e6;
  205. color: #ff4d4f;
  206. }
  207. .delete-button:hover {
  208. background-color: #ff4d4f;
  209. color: white;
  210. }
  211. }
  212. </style>