index.vue 11 KB

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