index.vue 15 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309
  1. <template>
  2. <z-paging ref="paging" v-model="list" bgColor="#f7f7f7" @query="query" @scroll="onPageScroll">
  3. <template #top>
  4. <up-navbar :fixed="true" :bgColor="navBarBgColor">
  5. <template #left>
  6. <view class="d-flex a-c pb-5" id="topup-navbar" :style="{ width: `${bubble.left - 30}px` }">
  7. <image class="home_icon mr-20" src="https://ta.zycpzs.cn/oss-file/smart-trace/szyy/images/common/home.png" mode="widthFix" />
  8. <text class="f-s-40 c-333 f-w-5 w-s-no">中药材种植全链条追溯</text>
  9. <view class="flex1"></view>
  10. </view>
  11. </template>
  12. </up-navbar>
  13. </template>
  14. <view class="h-500 w-100%" style="background: linear-gradient(to left, #d2f7d5, #eafad8); position: absolute; top: 0; left: 0; z-index: -1"> </view>
  15. <template>
  16. <up-navbar :fixed="false" bgColor="transparent">
  17. <template #left>
  18. <view class="pd-10"></view>
  19. </template>
  20. </up-navbar>
  21. <view class="user-page-header pd-10 d-flex a-c mg-14 p-rtv">
  22. <view class="user-page-header-avatar mr-20 p-rtv">
  23. <up-avatar size="116rpx" :src="avatar || 'https://ta.zycpzs.cn/oss-file/smart-trace/szyy/images/common/avatar.png'"></up-avatar>
  24. </view>
  25. <view class="flex1 ov-hd mr-40">
  26. <view class="p-rtv d-flex a-c mb-6">
  27. <view class="flex1 ov-hd f-s-32 c-333 d-flex a-ed">
  28. <text class="mr-12 up-line-1 f-w-5">{{ name }}</text>
  29. <text class="c-999 f-s-24">{{ setCipByNum(phone ?? null, 3, 4) || '-' }}</text>
  30. </view>
  31. </view>
  32. <view class="f-s-22 mr-10 radius-30 pt-4 pb-4 pl-10 pr-10 c-primary bg-#b7e8bc" style="width: max-content">
  33. {{ currentCpyName }}
  34. </view>
  35. </view>
  36. </view>
  37. </template>
  38. <template>
  39. <view class="p-rtv">
  40. <view class="pd-10 mg-14">
  41. <view class="b-radius pd-6" style="border: 1rpx solid #fff; background: linear-gradient(90deg, #c1f3c5 0%, rgba(193, 243, 197, 0.5) 20%, rgba(255, 255, 255, 0.5) 35%, rgba(255, 255, 255, 0.5) 50%, rgba(232, 255, 234, 0.5) 100%, #e8ffea 100%), linear-gradient(90deg, transparent 0%, rgba(255, 255, 255, 0.3) 30%, rgba(255, 255, 255, 0.3) 80%, transparent 100%)">
  42. <view class="b-radius pd-10 p-rtv" style="border: 1rpx solid #baedbf">
  43. <image class="w-200" src="/static/images/plant/typeofBusiness.png" mode="widthFix" style="position: absolute; top: 10rpx; left: 10rpx" />
  44. <view v-if="!speciesArray.length" class="pd-20"></view>
  45. <view v-if="speciesArray.length" class="d-flex pr-15">
  46. <view class="flex1"></view>
  47. <view class="f-s-22 c-primary" @click="$u.route({ url: '/plant/species/config/index' })">去修改{{ '>' }}</view>
  48. </view>
  49. <view v-if="speciesArray.length" class="c-#333 f-s-24 d-flex pl-40 pr-15 pb-15 pt-15">
  50. <view class="ov-hd tx-ov w-s-no">{{ speciesArray.join('、') }}</view>
  51. <view v-if="speciesArray.length > 4" class="flex1 w-s-no">等{{ speciesArray.length }}个品种 </view>
  52. </view>
  53. <view v-if="!speciesArray.length" @click="$u.route({ url: '/plant/species/config/index' })" class="c-primary bg-#E3F6E7 f-s-22 mg-at radius-10 w-250 h-50 d-flex a-c j-c"> 暂未配置品种,去配置{{ '>' }}</view>
  54. <view v-if="!speciesArray.length" class="pd-7"></view>
  55. </view>
  56. </view>
  57. </view>
  58. <view class="b-radius pt-0 bg-#f7f7f7" style="border: 1rpx solid #fff; border-bottom-color: transparent; margin-top: -40rpx">
  59. <up-sticky :offset-top="stickyTop">
  60. <view class="d-flex a-c pd-16 p-rtv">
  61. <view class="c-333 f-s-32 f-w-5 z-index-1">基地与地块管理</view>
  62. <image class="w-230" src="/static/images/plant/BasePlotManagement.png" mode="widthFix" style="position: absolute; top: 44rpx; left: 16rpx; z-index: 0" />
  63. <view class="flex1"></view>
  64. <view @click="$u.route({ url: '/plant/base/gap-base-info/index' })" class="c-primary f-s-22 z-index-1">GAP基地获评信息管理{{ '>' }}</view>
  65. <image src="/static/images/plant/basePlotBG.png" class="w-100%" mode="widthFix" style="position: absolute; top: 0; left: 0; z-index: -1"></image>
  66. </view>
  67. <view class="d-flex a-c pt-20 pb-20 pl-16 pr-16 bg-#f7f7f7">
  68. <view class="min-w-170 flex1">
  69. <ut-action-sheet v-model="form.queryType" :tabs="[{ label: '全部', value: '' }]" @change="onRefresh" title="选择原料类型">
  70. <view class="d-flex search-select-item a-c">
  71. <view class="flex1 ov-hd f-s-28 c-333 text-center f-w-5 w-s-no">{{ '全部' }} </view>
  72. <up-icon size="24rpx" color="#333" name="arrow-down-fill" class="mr-5"></up-icon>
  73. </view>
  74. </ut-action-sheet>
  75. </view>
  76. <view class="h-86 pl-20 w-100%">
  77. <ut-search ref="searchRef" v-model="form.keyword" @search="changeSeach" margin="0" :border="false" placeholder="搜基地名称、编号、地址、负责人" bgColor="#fff" height="86rpx" borderRadius="10rpx"></ut-search>
  78. </view>
  79. </view>
  80. </up-sticky>
  81. <view class="pd-16">
  82. <template>
  83. <view v-for="(item, index) in list" :key="index" class="b-radius bg-#fff pd-20 mb-20">
  84. <view class="c-333 f-s-34 pd-5 f-w-5">{{ item?.baseName }}</view>
  85. <view class="c-ccc f-s-24 pd-5 pt-0">{{ item?.baseCode }}</view>
  86. <view class="d-flex a-c">
  87. <view class="c-333 f-s-28 pd-5">
  88. <text class="c-#666">基地面积:</text>
  89. <text class="f-w-5">{{ item?.gapInfo?.area || '-' }}</text>
  90. </view>
  91. <view class="flex1"></view>
  92. <view class="c-333 f-s-28 pd-5">
  93. <text class="c-#666">建设时间:</text>
  94. <text class="f-w-5">{{ item?.buildDate || '-' }}</text>
  95. </view>
  96. </view>
  97. <view class="c-333 f-s-28 pd-5">
  98. <text class="c-#666">基地地址:</text>
  99. <text class="f-w-5">{{ item?.gapInfo?.address || '-' }}</text>
  100. </view>
  101. <view class="c-333 f-s-28 pd-5 d-flex">
  102. <text class="c-#666 w-s-no">当前在地品种:</text>
  103. <text class="ov-hd tx-ov w-s-no f-w-5">{{ item.plantingVarieties?.map((items) => items.variety).join('、') || '-' }}</text>
  104. <text v-if="item.plantingVarieties?.length" class="flex1 w-s-no f-w-5">等{{ item.plantingVarieties?.length }}个品种</text>
  105. </view>
  106. <view class="pd-10"></view>
  107. <view class="p-rtv">
  108. <up-image width="100%" :src="item.gapInfo?.basePic" mode="widthFix"> </up-image>
  109. <view class="pl-20 pr-20 pt-10 pb-10 bg-#00000080 c-#ccc f-s-20" style="position: absolute; bottom: 140rpx; right: 0; border-radius: 10rpx 0 0 10rpx"> {{ item?.contactName }}负责</view>
  110. <view class="pl-20 pr-20 pt-10 pb-10 bg-#00000080 c-#ccc f-s-20" style="position: absolute; bottom: 80rpx; right: 0; border-radius: 10rpx 0 0 10rpx"> 公司+合作社</view>
  111. <view class="pl-20 pr-20 pt-10 pb-10 bg-#00000080 c-#ccc f-s-20" style="position: absolute; bottom: 20rpx; right: 0; border-radius: 10rpx 0 0 10rpx"> 经度:E{{ item?.gapInfo?.lng }} 纬度:N{{ item?.gapInfo?.lat }}</view>
  112. </view>
  113. </view>
  114. </template>
  115. </view>
  116. </view>
  117. </view>
  118. </template>
  119. <template #empty>
  120. <ut-empty class="mg-at" color="#ccc" size="28rpx" image="/static/images/plant/noEmptyBase.png">尚未添加绘制种养殖基地信息~</ut-empty>
  121. <view class="b-radius c-#fff f-s-36 bg-#37A954 h-78 w-382 d-flex a-c j-c mg-at" @click="showDeleteDialog = true">
  122. <img class="w-38 h-36 mr-10" src="/static/images/plant/chooseGAP.png" alt="" mode="widthFix" />
  123. <text>去添加基地</text>
  124. </view>
  125. </template>
  126. </z-paging>
  127. <ut-confirm-dialog v-model:show="showDeleteDialog" width="80vw" title="请选择要添加到基地类型" :confirmText="'确认选择'" :cancelText="'取消'" @confirm="handlechoseConfirm" @cancel="handleDeleteCancel">
  128. <view class="" v-for="item in pt_base_type" :key="item?.value">
  129. <view style="border: 1rpx solid" :style="{ backgroundColor: item?.value == basetype ? '#EBF6EE' : '#f7f7f7', borderColor: item?.value == basetype ? '#37A954' : 'transparent' }" class="pr-30 d-flex a-c mb-20 radius-100" @click="handlechose(item.value)">
  130. <view class="radius-50% mg-8">
  131. <up-avatar size="90rpx" :src="item?.avatar || 'https://ta.zycpzs.cn/oss-file/smart-trace/szyy/images/common/avatar.png'" class="mr-20"></up-avatar>
  132. </view>
  133. <view class="c-#333 f-s-34">
  134. {{ item?.label }}
  135. </view>
  136. <view class="flex1"></view>
  137. <view class="d-flex">
  138. <img v-if="basetype === item.value" class="w-30 h-30" src="/static/images/plant/chooseSuccessfully.png" mode="widthFix" alt="" />
  139. </view>
  140. </view>
  141. </view>
  142. </ut-confirm-dialog>
  143. </template>
  144. <script setup lang="ts">
  145. import { useClientRequest } from '@/utils/request';
  146. import { setCipByNum } from '@/utils/public';
  147. import { useInfoStore } from '@/store';
  148. import { computed, ref } from 'vue';
  149. const { proxy } = getCurrentInstance() as ComponentInternalInstance;
  150. const { pt_base_type } = toRefs<any>(proxy?.useDict('pt_base_type'));
  151. const infoStore = useInfoStore();
  152. // 获取用户信息
  153. const avatar = computed(() => infoStore.userInfo?.avatar || '');
  154. const name = computed(() => infoStore.userInfo?.name || '');
  155. const phone = computed(() => infoStore.userInfo?.phone || '');
  156. const currentCpyName = computed(() => infoStore.userInfo?.currentCpyName || '');
  157. // 证书文件类型
  158. interface CertFile {
  159. fileName: string;
  160. url: string;
  161. fileSize: number;
  162. }
  163. // 差异信息类型
  164. interface GapInfo {
  165. id: number;
  166. sourceType: string;
  167. gapBaseName: string;
  168. sn: string;
  169. medicineName: string;
  170. medicineId: number;
  171. area: number;
  172. basePic: string;
  173. lng: number;
  174. lat: number;
  175. adcode: string;
  176. address: string;
  177. ratedDate: string; // 格式: "YYYY-MM-DD"
  178. certFile: CertFile[];
  179. res: string;
  180. auditor: number;
  181. msg: string;
  182. }
  183. // 种植品种类型
  184. interface PlantingVariety {
  185. baseId: number;
  186. varietyId: string;
  187. variety: string;
  188. }
  189. // 坐标点类型
  190. interface Coordinate {
  191. lng: number;
  192. lat: number;
  193. }
  194. // 主数据类型
  195. interface BaseData {
  196. id: number;
  197. baseName: string;
  198. baseCode?: string;
  199. baseType?: string;
  200. adcode?: string;
  201. buildDate?: string; // 格式: "YYYY-MM-DD"
  202. orgType: string;
  203. contactId: number;
  204. contactTel: string;
  205. contactName?: string;
  206. lng: number;
  207. lat: number;
  208. basePic: string;
  209. address: string;
  210. area: number;
  211. gapFlag: string;
  212. gapInfo: GapInfo;
  213. cpyid: number;
  214. appid: number;
  215. partnerId: number;
  216. createBy: number;
  217. updateBy: number;
  218. createTime: string; // ISO 8601 格式
  219. updateTime: string; // ISO 8601 格式
  220. hide: string;
  221. plantingVarieties: PlantingVariety[];
  222. coordinates: Coordinate[][]; // 二维坐标数组
  223. }
  224. const instance = getCurrentInstance();
  225. const list = ref<BaseData[]>();
  226. const paging = ref();
  227. const bubble = ref(uni.getMenuButtonBoundingClientRect());
  228. const form = ref({ queryType: '', keyword: '' });
  229. const speciesArray = ref([]);
  230. const navBarBgColor = ref('transparent');
  231. const stickyTop = ref(0);
  232. const changeSeach = () => {
  233. paging.value.reload();
  234. };
  235. const onRefresh = () => {
  236. paging.value.reload();
  237. };
  238. const onPageScroll = (e: any) => {
  239. const { scrollTop } = e.detail;
  240. if (scrollTop > 20) {
  241. navBarBgColor.value = '#d9f8d6';
  242. } else {
  243. navBarBgColor.value = 'transparent';
  244. }
  245. };
  246. const query = async (pageNum: number, pageSize: number) => {
  247. const params = {
  248. pageNum,
  249. pageSize,
  250. ...form.value,
  251. };
  252. const res = await useClientRequest.get('/plt-api/app/base/pageList', params);
  253. const { rows } = res;
  254. paging.value.complete(rows);
  255. };
  256. // 查询企业的种植品种
  257. const getSpecies = async () => {
  258. const res = await useClientRequest.get('/plt-api/app/cpyVariety/list');
  259. if (res.code === 200) {
  260. speciesArray.value = res.data.map((item: any) => item.medicineName);
  261. }
  262. };
  263. const showDeleteDialog = ref(false);
  264. const basetype = ref();
  265. const handlechose = (item: string) => {
  266. basetype.value = item;
  267. };
  268. // 处理删除取消
  269. const handleDeleteCancel = () => {
  270. showDeleteDialog.value = false;
  271. basetype.value = null;
  272. };
  273. const handlechoseConfirm = () => {
  274. uni.$u.route({ type: 'navigateTo', url: '/plant/base/base-edit/index', params: { basetype: basetype.value } });
  275. };
  276. onMounted(() => {
  277. const querys = uni.createSelectorQuery().in(instance?.proxy);
  278. querys
  279. .select('#topup-navbar')
  280. .boundingClientRect((data: any) => {
  281. stickyTop.value = data.top + data.height;
  282. })
  283. .exec();
  284. getSpecies();
  285. });
  286. // setTimeout(() => {
  287. // useClientRequest.get('/time');
  288. // }, 2000);
  289. </script>
  290. <style lang="scss" scoped>
  291. // @import '@/assets/styles/theme.scss';
  292. .search-select-item {
  293. height: 86rpx;
  294. background-color: #fff;
  295. border-radius: 10rpx;
  296. box-sizing: border-box;
  297. padding-left: 16rpx;
  298. padding-right: 16rpx;
  299. padding-top: 14rpx;
  300. padding-bottom: 14rpx;
  301. }
  302. </style>