index.vue 7.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186
  1. <template>
  2. <z-paging ref="paging" v-model="list" bgColor="#f7f7f7" @query="query">
  3. <template #top>
  4. <ut-navbar title="鲜货库" :fixed="false"></ut-navbar>
  5. </template>
  6. <view class="pd3-24-24-0">
  7. <view class="mb-20">
  8. <ut-tabs mode="subsection" v-model="form.restFlag" :tabs="tabs" @change="onRefresh"></ut-tabs>
  9. </view>
  10. <view class="d-flex a-c">
  11. <view class="min-w-230 flex1">
  12. <ut-action-sheet v-model="form.instoreType" :tabs="[{ label: '全部', value: '' }, ...pt_fresh_instore_type]" mode="custom" @change="onRefresh" title="选择入库类型">
  13. <view class="d-flex search-select-item a-c">
  14. <view class="flex1 ov-hd f-s-28 c-333 text-center f-w-5 w-s-no">{{ selectDictLabel(pt_fresh_instore_type, form.instoreType) || '全部' }} </view>
  15. <up-icon size="24rpx" color="#333" name="arrow-down-fill" class="mr-5"></up-icon>
  16. </view>
  17. </ut-action-sheet>
  18. </view>
  19. <view class="h-86 pl-20 w-100%">
  20. <ut-search ref="searchRef" v-model="form.keyword" @search="changeSeach" margin="0" :border="false" placeholder="搜名称、批号、库房、供应商" bgColor="#fff" height="86rpx" borderRadius="10rpx"></ut-search>
  21. </view>
  22. </view>
  23. <view></view>
  24. </view>
  25. <view class="pd-24 bg-#f7f7f7">
  26. <up-swipe-action>
  27. <up-swipe-action-item v-for="(item, index) in list" :key="index" :name="item?.id" :options="optionsActionTemp" @click="clickTempSwipe" class="mb-20 b-radius">
  28. <view class="b-radius bg-#fff pd-20 p-rtv" @click.stop="$u.route({ url: '/plant/storage/fresh-goods/detail/index', params: { id: item.id } })">
  29. <view class="d-flex j-sb a-c li-item-head mb-16">
  30. <view class="li-left-tag" :class="{ [`bg-instore-${item?.instoreType}`]: true }">{{ selectDictLabel(pt_fresh_instore_type, item?.instoreType) }}</view>
  31. <view class="f-s-22 c-#666">{{ item?.instoreBizInfo?.instoreDate }}</view>
  32. </view>
  33. <view class="d-flex flex1 mb-10">
  34. <view class="flex1">
  35. <span class="f-s-34 c-#333 f-w-500 mr-10">{{ item?.variety }}</span>
  36. <span v-if="item?.partName" class="f-s-24 c-#666">{{ item?.partName }}</span>
  37. </view>
  38. <view>
  39. <view v-if="item?.examinReport?.length" class="tag-span c-primary bg-#EBF6EE">已检验</view>
  40. <view v-else class="tag-span c-danger bg-#F9ECEA">未检验</view>
  41. </view>
  42. </view>
  43. <view class="pd2-4-0 f-s-28">
  44. <span class="c-#666">入库批号:</span>
  45. <span class="c-#333 f-w-500">{{ item?.batchCode || '-' }}</span>
  46. </view>
  47. <view v-if="item?.supplierId" class="pd2-4-0 f-s-28">
  48. <span class="c-#666">供应商:</span>
  49. <span class="c-#333 f-w-500">{{ item?.supplierInfo?.cusName || '-' }}</span>
  50. </view>
  51. <view v-if="item?.warehouses?.length" class="pd2-4-0 f-s-28">
  52. <span class="c-#666">存放库房:</span>
  53. <span class="c-#333 f-w-500">{{ getStorageRoomNames(item?.warehouses) || '-' }}</span>
  54. </view>
  55. <view class="pd2-4-0 f-s-28">
  56. <span class="c-#666">入库量:</span>
  57. <span class="c-#333 f-w-500">{{ item?.capacity }}{{ item?.unit }}</span>
  58. </view>
  59. <view class="d-flex">
  60. <view v-if="item?.inputAmount" class="pd2-4-0 f-s-28 flex1">
  61. <span class="c-#666">出库量:</span>
  62. <span class="c-#333 f-w-500">{{ item?.inputAmount || '0' }}{{ item?.unit }}</span>
  63. </view>
  64. <view v-if="item?.restAmount" class="pd2-4-0 f-s-28 flex1">
  65. <span class="c-danger">剩余量:</span>
  66. <span class="c-danger f-w-500">{{ item?.restAmount || '0' }}{{ item?.unit }}</span>
  67. </view>
  68. </view>
  69. </view>
  70. </up-swipe-action-item>
  71. </up-swipe-action>
  72. </view>
  73. <template #empty>
  74. <view class="d-flex flex-cln a-c" style="margin-top: -200rpx">
  75. <ut-empty class="mg-at" color="#ccc" size="28rpx">暂无鲜货信息,点击下方+号新增吧</ut-empty>
  76. </view>
  77. </template>
  78. <template #bottom>
  79. <fresh-goods-bottom></fresh-goods-bottom>
  80. </template>
  81. </z-paging>
  82. </template>
  83. <script setup lang="ts">
  84. import { useClientRequest } from '@/utils/request';
  85. import { selectDictListClass } from '@/utils/ruoyi';
  86. import { getStorageRoomNames } from '@/utils/common';
  87. import FreshGoodsBottom from './model/fresh-goods-bottom.vue';
  88. const { proxy } = getCurrentInstance() as ComponentInternalInstance;
  89. const { pt_fresh_instore_type } = toRefs<any>(proxy?.useDict('pt_fresh_instore_type'));
  90. const list = ref<any[]>();
  91. const form = ref({ keyword: '', restFlag: '1', instoreType: '', storageType: '4' });
  92. const paging = ref();
  93. const tabs = ref([
  94. { label: '有库存', value: '1' },
  95. { label: '无库存', value: '0' },
  96. ]);
  97. const changeSeach = () => {
  98. paging.value.reload();
  99. };
  100. const query = async (pageNum: number, pageSize: number) => {
  101. const params = {
  102. pageNum,
  103. pageSize,
  104. ...form.value,
  105. };
  106. const res = await useClientRequest.get('/plt-api/app/storage/list', params);
  107. if (res) {
  108. const { rows } = res;
  109. paging.value.complete(rows);
  110. }
  111. };
  112. // 暂存项左滑删除配置
  113. const optionsActionTemp = reactive([
  114. {
  115. text: '删除',
  116. style: {
  117. backgroundColor: '#F74C30',
  118. },
  119. },
  120. ]);
  121. // 暂存项删除点击(本地移除)
  122. const clickTempSwipe = async (event: object) => {
  123. const { name, index } = event as any;
  124. if (index === 0) {
  125. try {
  126. const res = await uni.showModal({
  127. title: '删除提示',
  128. content: '确定删除鲜货信息吗?',
  129. confirmColor: '#F74C30',
  130. });
  131. if (!res.confirm) return;
  132. await uni.showLoading({
  133. title: '删除中...',
  134. mask: true,
  135. });
  136. await useClientRequest.get(`/plt-api/app/storage/removeById/${name}`);
  137. uni.hideLoading();
  138. uni.showToast({
  139. title: '删除成功',
  140. icon: 'success',
  141. });
  142. paging.value?.reload();
  143. } catch (error) {
  144. console.error('删除暂存鲜货信息失败:', error);
  145. }
  146. }
  147. };
  148. const onRefresh = () => {
  149. paging.value.reload();
  150. };
  151. onMounted(() => {
  152. uni.$on('refreshStorageRoomList', () => {
  153. onRefresh();
  154. });
  155. });
  156. </script>
  157. <style lang="scss" scoped>
  158. .search-select-item {
  159. height: 86rpx;
  160. background-color: #fff;
  161. border-radius: 10rpx;
  162. box-sizing: border-box;
  163. padding: 12rpx;
  164. }
  165. .tag-span {
  166. padding: 4rpx 12rpx;
  167. font-size: 20rpx;
  168. border-radius: 18rpx;
  169. }
  170. .li-item-head {
  171. margin-left: -24rpx;
  172. margin-top: -24rpx;
  173. }
  174. .li-left-tag {
  175. padding: 6rpx 16rpx;
  176. color: #fff;
  177. border-radius: 16rpx 0 16rpx 0;
  178. font-size: 20rpx;
  179. font-weight: 500;
  180. }
  181. </style>