logList.uvue 7.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313
  1. <template>
  2. <view class="container">
  3. <!-- 列表内容 -->
  4. <!-- #ifdef APP -->
  5. <list-view class="list" :bounces="false" :scroll-y="true" :custom-nested-scroll="true"
  6. @scrolltolower="loadData(null)" associative-container="nested-scroll-view">
  7. <list-item class="list-item" type="10">
  8. <!-- #endif -->
  9. <view class="download-card" v-for="(item, index) in logs" :key="index" >
  10. <view @click="enterItem(item.id)">
  11. <view class="info-row">
  12. <text class="label">模块:</text>
  13. <text class="value">{{ item.module }}</text>
  14. </view>
  15. <view class="info-row">
  16. <text class="label">日志内容:</text>
  17. <text class="value">{{ item.title }}</text>
  18. </view>
  19. <view class="info-row">
  20. <text class="label">操作人员</text>
  21. <text class="value">{{ item.createuser }}</text>
  22. </view>
  23. <view class="info-row">
  24. <text class="label">操作时间:</text>
  25. <text class="value">{{ item.createtime }}</text>
  26. </view>
  27. </view>
  28. </view>
  29. <!-- #ifdef APP -->
  30. </list-item type="20">
  31. <list-item class="loading">
  32. <uni-loading :loading="loading" color="#999" :text="loadingText"></uni-loading>
  33. </list-item>
  34. </list-view>
  35. <!-- #endif -->
  36. </view>
  37. </template>
  38. <script setup>
  39. import { ref, reactive } from 'vue'
  40. import { getList, selectPageSql } from '@/api/work';
  41. import { downloadDataFromAPI, uploadDataToAPI } from '@/utils/dataProcessor';
  42. const backPressOptions = reactive({
  43. from: 'backbutton'
  44. } as OnBackPressOptions)
  45. onBackPress((options : OnBackPressOptions) : boolean | null => {
  46. console.log('onBackPress', options)
  47. // 使用reLaunch代替switchTab,避免多层跳转时的闪回问题
  48. // reLaunch会关闭所有页面并打开到目标页面,适合需要完全重置导航栈的场景
  49. uni.reLaunch({
  50. url: `/pages/work/index`,
  51. })
  52. // 返回true表示拦截默认返回行为
  53. return true
  54. })
  55. type Log = {
  56. id : number,
  57. module : string,
  58. title : string,
  59. content : string,
  60. msg : string,
  61. createuser: string,
  62. createtime: string
  63. }
  64. var initLog = [] as Log[]
  65. var logs = ref<Log[]>([]);
  66. const loading = ref(false)
  67. const isEnded = ref(false)
  68. const loadingError = ref('')
  69. const currentPage = ref(1)
  70. const map = ref(new Map<number, string>([[1, '未执行'], [2, '执行中'], [3, '执行完'], [4, '有错误']]))
  71. const loadingText = computed((): string => {
  72. if (loading.value) {
  73. return "加载中..."
  74. } else if (isEnded.value) {
  75. return "没有更多了"
  76. } else if (loadingError.value.length > 0) {
  77. return loadingError.value
  78. } else {
  79. return ""
  80. }
  81. })
  82. // #ifdef APP-ANDROID
  83. const loadData = (loadComplete : (() => void) | null) {
  84. if (loading.value || isEnded.value) {
  85. return
  86. }
  87. loading.value = true
  88. let offset = currentPage.value === 1 ? 0 : (currentPage.value-1) * 10
  89. selectPageSql('app_operate_log', 'id', offset).then((res : UTSJSONObject) => {
  90. console.log(res)
  91. let dataList = res?.['data'] as UTSJSONObject[] ?? Array<UTSJSONObject>()
  92. if (dataList != null && dataList.length > 0) {
  93. dataList.forEach(item => {
  94. if (item != null) {
  95. let log = JSON.parse<Log>(item.toJSONString());
  96. if (log != null) {
  97. initLog.push(log)
  98. }
  99. }
  100. });
  101. currentPage.value++
  102. }else{
  103. isEnded.value = true
  104. }
  105. logs.value = initLog
  106. loading.value = false
  107. if (loadComplete != null) {
  108. loadComplete()
  109. }
  110. })
  111. }
  112. onMounted(() => {
  113. loadData(null)
  114. })
  115. // #endif
  116. // #ifdef H5
  117. logs = [{
  118. id: 1,
  119. module: "app_media_info",
  120. dataid: 0,
  121. content : "新增数据成功",
  122. params: "1CFA1040-00#S",
  123. createtime: "2025-06-23",
  124. updatetime: "2025-06-23",
  125. status: 1
  126. }, {
  127. id: 2,
  128. module: "app_media_info",
  129. dataid: 0,
  130. content : "新增数据成功",
  131. params: "1CFA1040-00#S",
  132. createtime: "2025-06-23",
  133. updatetime: "2025-06-23",
  134. status: 1
  135. }] as Log[];
  136. // #endif
  137. const enterItem = (id : number) => {
  138. uni.navigateTo({
  139. url: `/pages/work/log/logDetail?id=${id}`
  140. });
  141. }
  142. defineExpose({
  143. loadData,
  144. backPressOptions
  145. })
  146. </script>
  147. <style scope>
  148. .container {
  149. padding: 24rpx;
  150. background-color: #f0f4f8;
  151. flex: 1;
  152. display: flex;
  153. flex-direction: column;
  154. font-family: "PingFang SC", "Helvetica Neue", Helvetica, Arial, sans-serif;
  155. /* #ifndef APP-ANDROID */
  156. min-height: 100vh;
  157. /* #endif */
  158. height: 120rpx;
  159. }
  160. .search-bar {
  161. background-color: #ffffff;
  162. border-radius: 10rpx;
  163. box-shadow: 0 2rpx 10rpx rgba(0, 0, 0, 0.1);
  164. }
  165. /* 搜索输入框:占满容器剩余空间,放在按钮左侧 */
  166. .search-input {
  167. /* 清除默认输入框样式 */
  168. border: none;
  169. background: transparent;
  170. width: 70%;
  171. margin-left: 10rpx;
  172. }
  173. /* 扫描按钮:放在输入框右侧,距离最右10rpx */
  174. .scan-btn {
  175. justify-content: center;
  176. align-items: center; /* 新增:按钮内部图标垂直居中 */
  177. /* 关键:右侧10rpx边距,实现"距离最右10rpx" */
  178. margin-left: auto; /* 自动推到flex容器最右侧 */
  179. margin-right: 10rpx; /* 与容器右边缘保持10rpx间距 */
  180. }
  181. .download-card {
  182. background: #ffffff;
  183. border-radius: 20rpx;
  184. padding: 24rpx 32rpx;
  185. box-shadow: 0 8rpx 15rpx rgba(0, 43, 92, 0.1);
  186. display: flex;
  187. flex-direction: column;
  188. margin-bottom: 20rpx;
  189. margin-top: 40rpx;
  190. margin-left: 20rpx;
  191. margin-right: 20rpx;
  192. }
  193. .download-card .view {
  194. margin-bottom: 16rpx;
  195. }
  196. /* 信息行 */
  197. .info-row {
  198. display: flex;
  199. flex-direction: row;
  200. /* #ifdef H5 */
  201. font-size: 28rpx;
  202. color: #33475b;
  203. /* #endif */
  204. align-items: center;
  205. }
  206. .info-row>.label {
  207. margin-left: 10rpx;
  208. }
  209. .info-row>.value {
  210. margin-left: 10rpx;
  211. }
  212. .btn-panel {
  213. display: flex;
  214. justify-content: space-between;
  215. align-items: center;
  216. margin-left: 5rpx;
  217. margin-right: 5rpx;
  218. }
  219. .label {
  220. font-weight: bold;
  221. color: #102a43;
  222. min-width: 100rpx;
  223. }
  224. .value {
  225. flex: 1;
  226. word-break: break-all;
  227. word-wrap: break-word;
  228. }
  229. .btn {
  230. align-self: flex-end;
  231. background-color: #00aaff;
  232. color: #fff;
  233. border: none;
  234. border-radius: 32rpx;
  235. padding: 2rpx 30rpx;
  236. font-size: 24rpx;
  237. font-weight: bold;
  238. /* #ifndef APP-ANDROID */
  239. transition: background-color 0.3s ease;
  240. /* #endif */
  241. margin-top: 30rpx;
  242. }
  243. .process-value {
  244. width: 120rpx;
  245. min-width: 100rpx;
  246. text-align: center;
  247. border-radius: 10rpx;
  248. }
  249. .bg-green {
  250. background-color: seagreen;
  251. }
  252. .bg-yellow {
  253. background-color: yellow;
  254. }
  255. .bg-black {
  256. background-color: #102a43;
  257. }
  258. .btn-first {
  259. margin-left: 5rpx;
  260. }
  261. .btn-second {
  262. margin-right: 5rpx;
  263. margin-left: auto;
  264. }
  265. .loading {
  266. padding: 30px;
  267. align-items: center;
  268. }
  269. .list {
  270. flex: 1;
  271. background-color: #ffffff;
  272. }
  273. .list-item {
  274. flex-direction: column;
  275. margin-top: 10px;
  276. padding: 10px;
  277. }
  278. </style>