index.vue 5.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141
  1. <template>
  2. <z-paging ref="paging" v-model="list" bgColor="#f7f7f7" @query="query">
  3. <template #top>
  4. <ut-navbar title="种源库" :fixed="false" :breadcrumb="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 p-rtv" @click.stop="$u.route({ url: '/plant/storage/seed-source/detail/index', params: { id: item.id } })">
  29. <SeedSourceCard :item="item" :dict="{ pt_seed_instore_type, pt_seed_type, pt_fungus_code_type }"></SeedSourceCard>
  30. </view>
  31. </up-swipe-action-item>
  32. </up-swipe-action>
  33. </view>
  34. <template #empty>
  35. <view class="d-flex flex-cln a-c" style="margin-top: -200rpx">
  36. <ut-empty class="mg-at" color="#ccc" size="28rpx">暂无种源信息,点击下方+号新增吧</ut-empty>
  37. </view>
  38. </template>
  39. <template #bottom>
  40. <source-bottom></source-bottom>
  41. </template>
  42. </z-paging>
  43. </template>
  44. <script setup lang="ts">
  45. import { useClientRequest } from '@/utils/request';
  46. import SourceBottom from './model/source-bottom.vue';
  47. import SeedSourceCard from '@/plant/models/warehouseCard/seed-source-card.vue';
  48. const { proxy } = getCurrentInstance() as ComponentInternalInstance;
  49. 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'));
  50. const list = ref<any[]>();
  51. const form = ref({ keyword: '', restFlag: '1', instoreType: '' });
  52. const paging = ref();
  53. const tabs = ref([
  54. { label: '有库存', value: '1' },
  55. { label: '无库存', value: '0' },
  56. ]);
  57. const changeSeach = () => {
  58. paging.value.reload();
  59. };
  60. const query = async (pageNum: number, pageSize: number) => {
  61. const params = {
  62. pageNum,
  63. pageSize,
  64. ...form.value,
  65. };
  66. const res = await useClientRequest.get('/plt-api/app/storageSeed/page', params);
  67. if (res) {
  68. const { rows } = res;
  69. paging.value.complete(rows);
  70. }
  71. };
  72. // 暂存项左滑删除配置
  73. const optionsActionTemp = reactive([
  74. {
  75. text: '删除',
  76. style: {
  77. backgroundColor: '#F74C30',
  78. },
  79. },
  80. ]);
  81. // 暂存项删除点击(本地移除)
  82. const clickTempSwipe = async (event: object, item: any) => {
  83. const { name, index } = event as any;
  84. if (index === 0) {
  85. if (item.instoreType == '3') {
  86. return uni.showModal({
  87. title: '提示',
  88. content: '该批次为采收入库的鲜货,请前往种养殖-采收管理里删除采收记录,入库记录将同步删除。',
  89. showCancel: false,
  90. confirmText: '知道了',
  91. confirmColor: '#41c06d',
  92. });
  93. }
  94. try {
  95. const res = await uni.showModal({
  96. title: '删除提示',
  97. content: '确定删除种源信息吗?',
  98. confirmColor: '#F74C30',
  99. });
  100. if (!res.confirm) return;
  101. await uni.showLoading({
  102. title: '删除中...',
  103. mask: true,
  104. });
  105. await useClientRequest.get(`/plt-api/app/storageSeed/removeById/${name}`);
  106. uni.hideLoading();
  107. uni.showToast({
  108. title: '删除成功',
  109. icon: 'success',
  110. });
  111. paging.value?.reload();
  112. } catch (error) {
  113. console.error('删除暂存种源信息失败:', error);
  114. }
  115. }
  116. };
  117. const onRefresh = () => {
  118. paging.value.reload();
  119. };
  120. onMounted(() => {
  121. uni.$on('refreshStorageRoomList', () => {
  122. onRefresh();
  123. });
  124. });
  125. </script>
  126. <style lang="scss" scoped>
  127. .search-select-item {
  128. height: 86rpx;
  129. background-color: #fff;
  130. border-radius: 10rpx;
  131. box-sizing: border-box;
  132. padding: 12rpx;
  133. }
  134. </style>