index.vue 4.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166
  1. <template>
  2. <z-paging class="page" ref="paging" v-model="dataList" @query="queryList">
  3. <!-- z-paging默认铺满全屏,此时页面所有view都应放在z-paging标签内,否则会被盖住 -->
  4. <!-- 需要固定在页面顶部的view请通过slot="top"插入,包括自定义的导航栏 -->
  5. <view>
  6. <view class="item" v-for="(item, index) in dataList" :key="index">
  7. <uni-row class="flex-wrap" style="padding: 10px">
  8. <uni-col :span="8">{{ $t('statusChange.deviceName') + ': ' }}</uni-col>
  9. <uni-col :span="16">{{ item.deviceName }}</uni-col>
  10. <uni-col :span="8" style="margin-top: 8px">{{ $t('statusChange.deviceCode') + ': ' }}</uni-col>
  11. <uni-col :span="16" style="margin-top: 8px">{{ item.deviceCode }}</uni-col>
  12. <uni-col :span="8" style="margin-top: 8px">{{ $t('statusChange.beforeStatus') + ': ' }}</uni-col>
  13. <uni-col :span="16" style="margin-top: 8px">{{ getStatusName(item.oldStatus) }}</uni-col>
  14. <uni-col :span="8" style="margin-top: 8px">{{ $t('statusChange.afterStatus') + ': ' }}</uni-col>
  15. <uni-col :span="16" style="margin-top: 8px">{{ getStatusName(item.newStatus) }}</uni-col>
  16. <uni-col :span="8" style="margin-top: 8px">{{ $t('statusChange.reason') + ': ' }}</uni-col>
  17. <uni-col :span="16" style="margin-top: 8px">{{ item.reason }}</uni-col>
  18. <uni-col :span="8" style="margin-top: 8px">{{ $t('statusChange.createUser') + ': ' }}</uni-col>
  19. <uni-col :span="16" style="margin-top: 8px">{{ item.creatorName }}</uni-col>
  20. </uni-row>
  21. </view>
  22. </view>
  23. </z-paging>
  24. </template>
  25. <script setup>
  26. import { onMounted, ref } from 'vue'
  27. import { onLoad } from "@dcloudio/uni-app"
  28. import { getDeviceStatusHistoryList } from "@/api/statusChange"
  29. import { useDataDictStore } from "@/store/modules/dataDict";
  30. const paging = ref(null)
  31. // v-model绑定的这个变量不要在分页请求结束中自己赋值,直接使用即可
  32. const dataList = ref([])
  33. const deviceId = ref('')
  34. onLoad((params) => {
  35. deviceId.value = params.id
  36. })
  37. const deviceStatusList = ref([])
  38. const getStatusName = (code) => {
  39. for (const item of deviceStatusList.value) {
  40. if (item.value === code) {
  41. return item.label
  42. }
  43. }
  44. }
  45. // @query所绑定的方法不要自己调用!!需要刷新列表数据时,只需要调用paging.value.reload()即可
  46. const queryList = (pageNo, pageSize) => {
  47. // 此处请求仅为演示,请替换为自己项目中的请求
  48. getDeviceStatusHistoryList({
  49. pageNo,
  50. pageSize,
  51. deviceId: deviceId.value,
  52. }).then(res => {
  53. // console.log('res', res)
  54. // 将请求结果通过complete传给z-paging处理,同时也代表请求结束,这一行必须调用
  55. paging.value.complete(res.data.list);
  56. }).catch(() => {
  57. // 如果请求失败写paging.value.complete(false);
  58. // 注意,每次都需要在catch中写这句话很麻烦,z-paging提供了方案可以全局统一处理
  59. // 在底层的网络请求抛出异常时,写uni.$emit('z-paging-error-emit');即可
  60. paging.value.complete(false);
  61. })
  62. }
  63. const { getDataDictList } = useDataDictStore()
  64. onMounted(async () => {
  65. deviceStatusList.value = getDataDictList('pms_device_status')
  66. })
  67. </script>
  68. <style lang="scss" scoped>
  69. .page {
  70. box-sizing: border-box;
  71. padding: 10px !important;
  72. }
  73. .search-row {
  74. height: 35px;
  75. position: fixed;
  76. left: 15px;
  77. width: calc(100% - 30px) !important;
  78. background: #F3F5F9;
  79. z-index: 10;
  80. .mini-btn {
  81. height: 35px;
  82. line-height: 35px;
  83. width: calc(100% - 10px);
  84. margin-left: 10px;
  85. }
  86. }
  87. .item {
  88. width: 100%;
  89. background: #FFFFFF;
  90. border-radius: 6px;
  91. margin-top: 10px;
  92. font-size: 14px;
  93. }
  94. .item-module {
  95. width: 100%;
  96. height: 42px;
  97. box-sizing: border-box;
  98. padding: 10px 15px 10px 10px;
  99. border-radius: 6px 6px 0 0;
  100. background: linear-gradient(270deg, #FFFFFF 0%, #8EBEFF 100%);
  101. &.tobeFilled {
  102. background: linear-gradient(270deg, #FFFFFF 0%, #FFF0F0 100%);
  103. }
  104. .module-status {
  105. // min-width: 60px;
  106. height: 23px;
  107. padding: 0 6px;
  108. background: #FFEBEB;
  109. border-radius: 3px;
  110. border: 1px solid #FFFFFF;
  111. text-align: center;
  112. font-weight: 500;
  113. font-size: 16px;
  114. line-height: 23px;
  115. color: #E7000D;
  116. }
  117. }
  118. .item-title-width {
  119. min-width: 70px;
  120. }
  121. .item-title-bg {
  122. background: linear-gradient( 270deg, #FFFFFF 0%, #8EBEFF 100%);
  123. border-radius: 6px 6px 0 0;
  124. padding: 10px;
  125. display: flex;
  126. justify-content: space-between;
  127. }
  128. .item-title {
  129. font-size: 16px;
  130. color: #333333;
  131. flex: 1;
  132. }
  133. .item-status {
  134. padding: 4px 14px;
  135. background: #EBF5FF;
  136. border-radius: 3px;
  137. border: 1px solid #FFFFFF;
  138. color: #004098;
  139. font-size: 14px;
  140. }
  141. .item-button {
  142. background: #FFFFFF;
  143. border-radius: 3px;
  144. border: 1px solid #004098;
  145. color: #004098;
  146. margin-right: 0;
  147. }
  148. </style>