index.vue 4.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122
  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" :tabs="tabs"></ut-tabs>
  9. </view>
  10. <view class="d-flex a-c">
  11. <view class="min-w-170 flex1">
  12. <ut-action-sheet :tabs="[{ label: '全部', value: '' }]" @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">{{ '全部' }} </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/seed-source/detail/index', params: { id: item.id } })">
  29. <view>{{ item?.variety }}</view>
  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. const { proxy } = getCurrentInstance() as ComponentInternalInstance;
  48. const { pt_task_type } = toRefs<any>(proxy?.useDict('pt_task_type'));
  49. const list = ref<any[]>();
  50. const form = ref({ keyword: '' });
  51. const paging = ref();
  52. const tabs = ref([
  53. { label: '有库存', value: 'seed' },
  54. { label: '无库存', value: 'seedling' },
  55. ]);
  56. const changeSeach = () => {
  57. paging.value.reload();
  58. };
  59. const query = async (pageNum: number, pageSize: number) => {
  60. const params = {
  61. pageNum,
  62. pageSize,
  63. ...form.value,
  64. };
  65. const res = await useClientRequest.get('/plt-api/app/storageSeed/page', params);
  66. if (res) {
  67. const { rows } = res;
  68. paging.value.complete(rows);
  69. }
  70. };
  71. // 暂存项左滑删除配置
  72. const optionsActionTemp = reactive([
  73. {
  74. text: '删除',
  75. style: {
  76. backgroundColor: '#f56c6c',
  77. },
  78. },
  79. ]);
  80. // 暂存项删除点击(本地移除)
  81. const clickTempSwipe = async (event: object) => {
  82. const { name, index } = event as any;
  83. if (index === 0) {
  84. try {
  85. const res = await uni.showModal({
  86. title: '删除提示',
  87. content: '确定删除该基地吗?',
  88. confirmColor: '#f56c6c',
  89. });
  90. if (!res.confirm) return;
  91. await uni.showLoading({
  92. title: '删除中...',
  93. mask: true,
  94. });
  95. await useClientRequest.get(`/plt-api/app/base/delById/${name}`);
  96. uni.hideLoading();
  97. uni.showToast({
  98. title: '删除成功',
  99. icon: 'success',
  100. });
  101. paging.value?.reload();
  102. } catch (error) {
  103. console.error('删除暂存基地失败:', error);
  104. }
  105. }
  106. };
  107. const onRefresh = () => {
  108. paging.value.reload();
  109. };
  110. </script>
  111. <style lang="scss" scoped>
  112. .search-select-item {
  113. height: 86rpx;
  114. background-color: #fff;
  115. border-radius: 10rpx;
  116. box-sizing: border-box;
  117. padding: 12rpx;
  118. }
  119. </style>