index.vue 5.0 KB

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