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

221 lines
5.6 KiB

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