index.vue 5.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143
  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. <template #top>
  6. <uni-row class="search-row flex-row align-center justify-between" style="padding-top: 2px">
  7. <!-- <uni-col :span="8">-->
  8. <!-- <uni-data-select-->
  9. <!-- v-model="type"-->
  10. <!-- :localdata="typeList"-->
  11. <!-- @change="searchList"-->
  12. <!-- />-->
  13. <!-- </uni-col>-->
  14. <uni-col :span="19">
  15. <uni-easyinput
  16. v-model="keywords"
  17. :styles="inputStyles"
  18. :placeholderStyle="placeholderStyle"
  19. :placeholder="$t('common.searchHint')" />
  20. </uni-col>
  21. <uni-col :span="5" class="flex-row justify-end">
  22. <button class="mini-btn" type="primary" size="mini" @click="searchList">
  23. {{ $t('operation.search')}}</button>
  24. </uni-col>
  25. </uni-row>
  26. </template>
  27. <view class="list">
  28. <view class="item" v-for="(item,index) in dataList" :key="index">
  29. <view class="item-module flex-row align-center justify-between tobeFilled">
  30. <view class="module-name">
  31. {{ item.createTime }}
  32. </view>
  33. <view class="module-status pending">
  34. {{ item.status }}
  35. </view>
  36. </view>
  37. <view class="item-content">
  38. <view class="item-title flex-row">
  39. <span class="item-title-width">{{$t('overtime.item.type')}}:</span>
  40. <span>{{ item.type }}</span>
  41. </view>
  42. <view class="item-title flex-row">
  43. <span class="item-title-width">{{ $t('overtime.item.title')}}:</span>
  44. <span>{{item.title }}</span>
  45. </view>
  46. </view>
  47. <view class="item-btn flex-row align-center justify-end">
  48. <button type="primary" @click="navigatorDetail(item)">{{$t('operation.fill')}}</button>
  49. </view>
  50. </view>
  51. </view>
  52. </z-paging>
  53. </template>
  54. <script setup>
  55. import { ref, reactive, nextTick, getCurrentInstance } from 'vue'
  56. import { onShow } from '@dcloudio/uni-app'
  57. import { getOvertimeTaskList } from "@/api/task"
  58. const type = ref('')
  59. const keywords = ref('')
  60. const placeholderStyle = ref('color:#797979;font-weight:500;font-size:16px')
  61. const inputStyles = reactive({
  62. backgroundColor: '#FFFFFF',
  63. color: '#797979',
  64. })
  65. const paging = ref(null)
  66. // v-model绑定的这个变量不要在分页请求结束中自己赋值,直接使用即可
  67. const dataList = ref([])
  68. const { appContext } = getCurrentInstance();
  69. const t = appContext.config.globalProperties.$t;
  70. const typeList = [
  71. { value: t('overtime.type1'), text: t('overtime.type1') },
  72. { value: t('overtime.type2'), text: t('overtime.type2') },
  73. { value: t('overtime.type3'), text: t('overtime.type3') },
  74. { value: t('overtime.type4'), text: t('overtime.type4') },
  75. ]
  76. // @query所绑定的方法不要自己调用!!需要刷新列表数据时,只需要调用paging.value.reload()即可
  77. const queryList = (pageNo, pageSize) => {
  78. // 此处请求仅为演示,请替换为自己项目中的请求
  79. getOvertimeTaskList({
  80. pageNo,
  81. pageSize,
  82. commonParam: keywords.value,
  83. // type: type.value,
  84. }).then(res => {
  85. // 将请求结果通过complete传给z-paging处理,同时也代表请求结束,这一行必须调用
  86. paging.value.complete(res.data.list);
  87. }).catch((e) => {
  88. console.log(e)
  89. // 如果请求失败写paging.value.complete(false);
  90. // 注意,每次都需要在catch中写这句话很麻烦,z-paging提供了方案可以全局统一处理
  91. // 在底层的网络请求抛出异常时,写uni.$emit('z-paging-error-emit');即可
  92. paging.value.complete(false);
  93. })
  94. }
  95. const searchList = () => {
  96. paging.value.reload()
  97. }
  98. const navigatorDetail = (item) => {
  99. if (item.type === '维修工单') {
  100. uni.navigateTo({ url: '/pages/repair/edit?id=' + item.id })
  101. } else if (item.type === '运行记录') {
  102. const json = JSON.stringify({
  103. orderId: item.id
  104. })
  105. uni.navigateTo({ url: `/pages/recordFilling/detail?view=1&param=${json}` })
  106. } else if (item.type === '保养工单') {
  107. uni.navigateTo({ url: "/pages/maintenance/edit?id=" + item.id })
  108. } else if (item.type === '巡检工单') {
  109. uni.navigateTo({ url: "/pages/inspection/edit?id=" + item.id })
  110. }
  111. }
  112. onShow(() => nextTick(() => searchList()))
  113. </script>
  114. <style lang="scss" scoped>
  115. @import "@/style/work-order.scss";
  116. .search-row {
  117. height: 35px;
  118. background: #F3F5F9;
  119. .mini-btn {
  120. height: 35px;
  121. line-height: 35px;
  122. width: 100%;
  123. margin-left: 8px;
  124. }
  125. }
  126. .item {
  127. width: 100%;
  128. height: 204px;
  129. min-height: 204px;
  130. background: #FFFFFF;
  131. border-radius: 6px;
  132. margin-top: 10px;
  133. }
  134. </style>