index.vue 4.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179
  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">
  7. <uni-col :span="18">
  8. <view class="search-bar" @click="searchList">
  9. <text>{{ $t('inventory.searchHint') }}</text>
  10. </view>
  11. </uni-col>
  12. <uni-col :span="6" class="flex-row justify-end">
  13. <button class="mini-btn" type="primary" size="mini" @click="searchList">
  14. {{ $t('operation.search') }}
  15. </button>
  16. </uni-col>
  17. </uni-row>
  18. </template>
  19. <view>
  20. <view class="item" v-for="(item,index) in dataList" :key="index">
  21. <uni-row>
  22. <uni-col :span="6">{{ $t('inventory.materialName') }}</uni-col>
  23. <uni-col :span="18">{{ item.materialName }}</uni-col>
  24. <uni-col :span="6" style="margin-top: 8px">{{ $t('inventory.costCenter') }}</uni-col>
  25. <uni-col :span="18" style="margin-top: 8px">{{ item.costCenter }}</uni-col>
  26. <uni-col :span="6" style="margin-top: 8px">{{ $t('inventory.quantity') }}</uni-col>
  27. <uni-col :span="18" style="margin-top: 8px">{{ item.quantity }}</uni-col>
  28. </uni-row>
  29. </view>
  30. </view>
  31. </z-paging>
  32. </template>
  33. <script setup>
  34. import {
  35. ref,
  36. onMounted
  37. } from 'vue'
  38. import {
  39. getInventoryList
  40. } from "@/api/inventory";
  41. // const materialName = ref('')
  42. // const placeholderStyle = ref('color:#797979; font-weight:500; font-size:16px')
  43. // const inputStyles = reactive({
  44. // backgroundColor: '#FFFFFF',
  45. // color: '#797979',
  46. // })
  47. const paging = ref(null)
  48. // v-model绑定的这个变量不要在分页请求结束中自己赋值,直接使用即可
  49. const dataList = ref([])
  50. // @query所绑定的方法不要自己调用!!需要刷新列表数据时,只需要调用paging.value.reload()即可
  51. const queryList = (pageNo, pageSize) => {
  52. // 此处请求仅为演示,请替换为自己项目中的请求
  53. getInventoryList({
  54. pageNo,
  55. pageSize,
  56. ...searchParams.value,
  57. }).then(res => {
  58. console.log('res', res)
  59. // 将请求结果通过complete传给z-paging处理,同时也代表请求结束,这一行必须调用
  60. paging.value.complete(res.data.list);
  61. }).catch(() => {
  62. // 如果请求失败写paging.value.complete(false);
  63. // 注意,每次都需要在catch中写这句话很麻烦,z-paging提供了方案可以全局统一处理
  64. // 在底层的网络请求抛出异常时,写uni.$emit('z-paging-error-emit');即可
  65. paging.value.complete(false);
  66. })
  67. }
  68. // 跳转到高级搜索页
  69. const searchList = () => {
  70. // paging.value.reload()
  71. uni.navigateTo({
  72. url: '/pages/inventory/search/index?params=' + JSON.stringify(searchParams.value ?? '{}')
  73. })
  74. }
  75. const searchParams = ref()
  76. onMounted(() => {
  77. // 接收从高级搜索页返回的数据
  78. uni.$on('search', (params) => {
  79. searchParams.value = params
  80. paging.value.reload()
  81. })
  82. })
  83. </script>
  84. <style lang="scss" scoped>
  85. .page {
  86. box-sizing: border-box;
  87. padding: 10px !important;
  88. }
  89. .search-row {
  90. height: 35px;
  91. width: 100%;
  92. background: #F3F5F9;
  93. z-index: 10;
  94. .mini-btn {
  95. height: 35px;
  96. line-height: 35px;
  97. width: calc(100% - 10px);
  98. margin-left: 10px;
  99. }
  100. }
  101. .search-bar {
  102. width: auto;
  103. height: 32px;
  104. display: flex;
  105. align-items: center;
  106. padding: 0 10px;
  107. background-color: white;
  108. border-radius: 4px;
  109. color: #939393;
  110. font-size: 12px;
  111. }
  112. .item {
  113. width: 100%;
  114. background: #FFFFFF;
  115. border-radius: 6px;
  116. margin-top: 10px;
  117. padding: 14px 20px;
  118. font-size: 14px;
  119. box-sizing: border-box;
  120. }
  121. .item-module {
  122. width: 100%;
  123. height: 42px;
  124. box-sizing: border-box;
  125. padding: 10px 15px 10px 10px;
  126. border-radius: 6px 6px 0 0;
  127. background: linear-gradient(270deg, #FFFFFF 0%, #8EBEFF 100%);
  128. &.tobeFilled {
  129. background: linear-gradient(270deg, #FFFFFF 0%, #FFF0F0 100%);
  130. }
  131. .module-status {
  132. // min-width: 60px;
  133. height: 23px;
  134. padding: 0 6px;
  135. background: #FFEBEB;
  136. border-radius: 3px;
  137. border: 1px solid #FFFFFF;
  138. text-align: center;
  139. font-weight: 500;
  140. font-size: 16px;
  141. line-height: 23px;
  142. color: #E7000D;
  143. }
  144. }
  145. .item-content {
  146. width: 100%;
  147. height: calc(100% - 42px - 32px - 15px);
  148. box-sizing: border-box;
  149. padding: 15px 20px 15px 10px;
  150. font-weight: 500;
  151. font-size: 14px;
  152. color: #333333;
  153. line-height: 20px;
  154. }
  155. .item-title {
  156. width: 100%;
  157. margin-bottom: 15px;
  158. }
  159. .item-title-width {
  160. min-width: 70px;
  161. }
  162. </style>