index.vue 5.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128
  1. <template>
  2. <z-paging ref="paging" v-model="list" bgColor="#fff" @query="query" :auto="false" safe-area-inset-bottom>
  3. <template #top>
  4. <view class="">
  5. <up-navbar :title="title" @leftClick="navigateBackOrHome()" :fixed="false"></up-navbar>
  6. <view class="pd-24">
  7. <ut-search ref="searchRef" v-model="form.keyword" @search="changeSeach" @change="changeSeach" margin="0" :border="false" placeholder="可输入药材名称或动植物基原名称搜索" bgColor="#f7f7f7" height="86rpx" borderRadius="16rpx"></ut-search>
  8. </view>
  9. </view>
  10. </template>
  11. <view class="pd-24" v-if="!showSearch">
  12. <template v-if="speArray.length">
  13. <view class="f-s-32 c-#333 f-w-5 mb-20">快捷选择主营品种</view>
  14. <view class="d-flex a-c f-w-w">
  15. <spe-lable class="mr-20 mb-20" v-for="(item, index) in speArray" :key="index" :text="item?.medicineName" size="30rpx" :id="item?.id" @click="changeSpe(item?.medicineName)" />
  16. </view>
  17. </template>
  18. <template>
  19. <ut-empty text=""></ut-empty>
  20. <view class="d-flex flex-cln j-c a-c">
  21. <view class="c-#ccc f-s-28">您可以<text class="c-primary">直接搜索,</text>或前往<text class="c-primary">基地-主营品种配置</text>页面进行</view>
  22. <view class="c-#ccc f-s-28">主营品种配置,配置后下次即可快捷选择。</view>
  23. </view>
  24. </template>
  25. </view>
  26. <view class="pd-24" v-if="showSearch">
  27. <view class="f-s-32 c-#333 f-w-5 mb-20">搜索结果</view>
  28. <view class="pd-30 d-flex bg-#FBFDFB border-#37A954 b-radius mb-20" v-for="(item, index) in list" :key="index">
  29. <up-radio-group v-model="radiovalue1">
  30. <view @click="radiovalue1 = item?.id" class="d-flex w-100%">
  31. <view class="">
  32. <view class="mb-20 ov-hd tx-ov">
  33. <text class="c-#333 f-s-34 f-w-5 mr-5">{{ item?.varietyName }}</text>
  34. <text class="c-#666 f-s-24 tx-ov ov-hd">{{ item?.latinName }}</text>
  35. </view>
  36. <view class="mb-20">
  37. <text class="c-#333 f-s-28 f-w-5 mr-5">{{ item?.genusName }}</text>
  38. <text class="c-#666 f-s-24 tx-ov ov-hd">{{ item?.genusLatinName }}</text>
  39. </view>
  40. <view class="">
  41. <text class="c-#666 f-s-24">产出:</text>
  42. <text class="c-#666 f-s-24 tx-ov ov-hd">{{ item?.medicineName }}</text>
  43. </view>
  44. </view>
  45. <view class="flex1"></view>
  46. <view class="d-flex j-c a-c">
  47. <view @click.stop class="">
  48. <up-radio activeColor="#37A954" label="" :name="item?.id"> </up-radio>
  49. </view>
  50. </view>
  51. </view>
  52. </up-radio-group>
  53. </view>
  54. </view>
  55. <template #bottom v-if="showSearch">
  56. <view class="pd-24 d-flex j-c gap-20 base-bottom-wrap">
  57. <up-button type="primary" @click="save()">确认选择</up-button>
  58. </view>
  59. </template>
  60. </z-paging>
  61. </template>
  62. <script setup lang="ts">
  63. import { useClientRequest } from '@/utils/request';
  64. import SpeLable from './models/speLable.vue';
  65. import { recursiveDecodeURIComponentSimple } from '@/utils/ruoyi';
  66. const paging = ref();
  67. const list = ref<any[]>([]);
  68. const form = ref({
  69. keyword: '',
  70. });
  71. const speArray = ref<any[]>([]);
  72. const showSearch = ref(false);
  73. const query = async (pageNo: number, pageSize: number) => {
  74. const params = {
  75. pageNo,
  76. pageSize,
  77. ...form.value,
  78. };
  79. const res = await useClientRequest.get('/plt-api/app/cpyVariety/pageList', params);
  80. const { rows } = res;
  81. paging.value.complete(rows);
  82. };
  83. const changeSeach = () => {
  84. if (!form.value?.keyword) {
  85. showSearch.value = false;
  86. } else {
  87. showSearch.value = true;
  88. }
  89. paging.value.reload();
  90. };
  91. const changeSpe = (data: string) => {
  92. form.value.keyword = data;
  93. changeSeach();
  94. };
  95. const getSpecies = async () => {
  96. console.log('getSpecies');
  97. if (form.value?.keyword) {
  98. return;
  99. }
  100. const res = await useClientRequest.get('/plt-api/app/cpyVariety/list');
  101. if (res.code === 200) {
  102. speArray.value = res.data;
  103. }
  104. };
  105. const radiovalue1 = ref('苹果');
  106. const save = () => {
  107. const res = list.value.find((item) => item.id === radiovalue1.value);
  108. if (!res) return;
  109. uni.$emit('updateBiologicalname', { msg: res });
  110. uni.navigateBack({ delta: 1 });
  111. };
  112. const title = ref('选择动植物名称');
  113. onLoad((options) => {
  114. console.log(options);
  115. const decodedOptions = recursiveDecodeURIComponentSimple(options);
  116. if (decodedOptions?.title) {
  117. title.value = decodedOptions?.title || '选择动植物名称';
  118. }
  119. });
  120. onMounted(() => {
  121. getSpecies();
  122. });
  123. onUnload(() => {
  124. console.log('????');
  125. uni.$off('updateBiologicalname');
  126. });
  127. </script>