index.vue 9.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209
  1. <template>
  2. <z-paging ref="paging" v-model="list" bgColor="#f7f7f7" @query="query" hide-no-more-inside>
  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($event, item)" 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 }">{{ item?.level || '' }}{{ 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. <template v-if="item?.instoreType == '2'">
  44. <view class="pd2-4-0 f-s-28">
  45. <span class="c-#666">入库批号:</span>
  46. <span class="c-#333 f-w-500">{{ item?.batchCode || '-' }}</span>
  47. </view>
  48. <view v-if="item?.supplierId" class="pd2-4-0 f-s-28">
  49. <span class="c-#666">供应商:</span>
  50. <span class="c-#333 f-w-500">{{ item?.supplierInfo?.cusName || '-' }}</span>
  51. </view>
  52. </template>
  53. <template v-if="item?.instoreType == '3'">
  54. <view class="pd2-4-0 f-s-28">
  55. <span class="c-#666">采收批号:</span>
  56. <span class="c-#333 f-w-500">{{ item?.harvestInfo?.harvestCode || '-' }}</span>
  57. </view>
  58. <view class="pd2-4-0 f-s-28">
  59. <span class="c-#666">采收基地:</span>
  60. <span class="c-#333 f-w-500">
  61. {{ item?.harvestInfo?.baseInfo?.baseName || '-' }}
  62. </span>
  63. </view>
  64. </template>
  65. <view v-if="item?.warehouses?.length" class="pd2-4-0 f-s-28">
  66. <span class="c-#666">存放库房:</span>
  67. <span class="c-#333 f-w-500">{{ getStorageRoomNames(item?.warehouses) || '-' }}</span>
  68. </view>
  69. <view class="pd2-4-0 f-s-28">
  70. <span class="c-#666">入库量:</span>
  71. <span class="c-#333 f-w-500">{{ item?.capacity }}{{ item?.unit }}</span>
  72. </view>
  73. <view class="d-flex">
  74. <view v-if="item?.inputAmount" class="pd2-4-0 f-s-28 flex1">
  75. <span class="c-#666">出库量:</span>
  76. <span class="c-#333 f-w-500">{{ item?.inputAmount || '0' }}{{ item?.unit }}</span>
  77. </view>
  78. <view v-if="item?.restAmount" class="pd2-4-0 f-s-28 flex1">
  79. <span class="c-danger">剩余量:</span>
  80. <span class="c-danger f-w-500">{{ item?.restAmount || '0' }}{{ item?.unit }}</span>
  81. </view>
  82. </view>
  83. </view>
  84. </up-swipe-action-item>
  85. </up-swipe-action>
  86. </view>
  87. <template #empty>
  88. <view class="d-flex flex-cln a-c" style="margin-top: -200rpx">
  89. <ut-empty class="mg-at" color="#ccc" size="28rpx">暂无鲜货信息,点击下方+号新增吧</ut-empty>
  90. </view>
  91. </template>
  92. <template #bottom>
  93. <fresh-goods-bottom></fresh-goods-bottom>
  94. </template>
  95. </z-paging>
  96. </template>
  97. <script setup lang="ts">
  98. import { useClientRequest } from '@/utils/request';
  99. import { selectDictListClass } from '@/utils/ruoyi';
  100. import { getStorageRoomNames } from '@/utils/common';
  101. import FreshGoodsBottom from './model/fresh-goods-bottom.vue';
  102. const { proxy } = getCurrentInstance() as ComponentInternalInstance;
  103. const { pt_fresh_instore_type } = toRefs<any>(proxy?.useDict('pt_fresh_instore_type'));
  104. const list = ref<any[]>();
  105. const form = ref({ keyword: '', restFlag: '1', instoreType: '', storageType: '4' });
  106. const paging = ref();
  107. const tabs = ref([
  108. { label: '有库存', value: '1' },
  109. { label: '无库存', value: '0' },
  110. ]);
  111. const changeSeach = () => {
  112. paging.value.reload();
  113. };
  114. const query = async (pageNum: number, pageSize: number) => {
  115. const params = {
  116. pageNum,
  117. pageSize,
  118. ...form.value,
  119. };
  120. const res = await useClientRequest.get('/plt-api/app/storage/list', params);
  121. if (res) {
  122. const { rows } = res;
  123. paging.value.complete(rows);
  124. }
  125. };
  126. // 暂存项左滑删除配置
  127. const optionsActionTemp = reactive([
  128. {
  129. text: '删除',
  130. style: {
  131. backgroundColor: '#F74C30',
  132. },
  133. },
  134. ]);
  135. // 暂存项删除点击(本地移除)
  136. const clickTempSwipe = async (event: object, item: any) => {
  137. const { name, index } = event as any;
  138. if (index === 0) {
  139. if (item.instoreType == '3') {
  140. return uni.showModal({
  141. title: '提示',
  142. content: '该批次为采收入库的种源,请前往种养殖-采收管理里删除采收记录,入库记录将同步删除。',
  143. showCancel: false,
  144. confirmText: '知道了',
  145. confirmColor: '#41c06d',
  146. });
  147. }
  148. try {
  149. const res = await uni.showModal({
  150. title: '删除提示',
  151. content: '确定删除鲜货信息吗?',
  152. confirmColor: '#F74C30',
  153. });
  154. if (!res.confirm) return;
  155. await uni.showLoading({
  156. title: '删除中...',
  157. mask: true,
  158. });
  159. await useClientRequest.get(`/plt-api/app/storage/removeById/${name}`);
  160. uni.hideLoading();
  161. uni.showToast({
  162. title: '删除成功',
  163. icon: 'success',
  164. });
  165. paging.value?.reload();
  166. } catch (error) {
  167. console.error('删除暂存鲜货信息失败:', error);
  168. }
  169. }
  170. };
  171. const onRefresh = () => {
  172. paging.value.reload();
  173. };
  174. onMounted(() => {
  175. uni.$on('refreshStorageRoomList', () => {
  176. onRefresh();
  177. });
  178. });
  179. </script>
  180. <style lang="scss" scoped>
  181. .search-select-item {
  182. height: 86rpx;
  183. background-color: #fff;
  184. border-radius: 10rpx;
  185. box-sizing: border-box;
  186. padding: 12rpx;
  187. }
  188. .tag-span {
  189. padding: 4rpx 12rpx;
  190. font-size: 20rpx;
  191. border-radius: 18rpx;
  192. }
  193. .li-item-head {
  194. margin-left: -24rpx;
  195. margin-top: -24rpx;
  196. }
  197. .li-left-tag {
  198. padding: 6rpx 16rpx;
  199. color: #fff;
  200. border-radius: 16rpx 0 16rpx 0;
  201. font-size: 20rpx;
  202. font-weight: 500;
  203. }
  204. </style>