index.vue 22 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459
  1. <template>
  2. <z-paging ref="paging" v-model="list" bgColor="#f7f7f7" @query="query" @scroll="onPageScroll" safe-area-inset-bottom>
  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" zIndex="10">
  60. <view class="pd-24 p-rtv bg-#f7f7f7">
  61. <image src="/static/images/plant/basePlotBG.png" class="w-100%" mode="widthFix" style="position: absolute; top: 0; left: 0"></image>
  62. <view class="d-flex a-c mb-26 p-rtv">
  63. <view class="p-rtv d-flex flex-cln">
  64. <view class="c-333 f-s-32 f-w-5 z-index-1">基地与地块管理</view>
  65. <image class="w-230 h-11" style="margin-top: -10rpx" src="/static/images/plant/BasePlotManagement.png" mode="widthFix" />
  66. </view>
  67. <view class="flex1"></view>
  68. <view @click="$u.route({ url: '/plant/base/gap-base-info/index' })" class="c-primary f-s-22 z-index-1">GAP基地获评信息管理{{ '>' }}</view>
  69. </view>
  70. <view class="d-flex a-c p-rtv">
  71. <view class="w-220">
  72. <ut-action-sheet v-model="form.queryType" :tabs="typeNums" @change="onRefresh" title="选择原料类型">
  73. <view class="d-flex search-select-item a-c">
  74. <view class="flex1 ov-hd f-s-26 c-333 text-center f-w-5 w-s-no up-line-1">{{ selectDictLabel(typeNums, form?.queryType) || '全部' }} </view>
  75. <up-icon size="24rpx" color="#333" name="arrow-down-fill" class="ml-5"></up-icon>
  76. </view>
  77. </ut-action-sheet>
  78. </view>
  79. <view class="pl-16 flex1 ov-hd">
  80. <ut-search ref="searchRef" v-model="form.keyword" @search="changeSeach" margin="0" :border="false" placeholder="搜基地名称、编号、地址、负责人" bgColor="#fff" height="86rpx" borderRadius="10rpx"></ut-search>
  81. </view>
  82. </view>
  83. </view>
  84. </up-sticky>
  85. <view class="pd4-10-24-24-24">
  86. <template>
  87. <up-swipe-action>
  88. <up-swipe-action-item v-for="(item, index) in list" :key="index" :name="item?.id" :options="optionsActionTemp" @click="clickTempSwipe" class="mb-20 b-radius">
  89. <view class="b-radius bg-#fff pd-20 p-rtv" @click.stop="$u.route({ url: '/plant/base/base-detail/index', params: { id: item.id } })">
  90. <view class="c-333 f-s-34 pd-5 f-w-5">{{ item?.baseName }}</view>
  91. <view class="c-ccc f-s-24 pd-5 pt-0">{{ item?.baseCode }}</view>
  92. <view class="d-flex a-c">
  93. <view class="c-333 f-s-28 pd-5">
  94. <text class="c-#666">基地面积:</text>
  95. <text class="f-w-5">{{ item?.gapInfo?.area || '-' }}</text>
  96. </view>
  97. <view class="flex1"></view>
  98. <view class="c-333 f-s-28 pd-5">
  99. <text class="c-#666">建设时间:</text>
  100. <text class="f-w-5">{{ item?.buildDate || '-' }}</text>
  101. </view>
  102. </view>
  103. <view class="c-333 f-s-28 pd-5">
  104. <text class="c-#666">基地地址:</text>
  105. <text class="f-w-5">{{ item?.gapInfo?.address || '-' }}</text>
  106. </view>
  107. <view v-if="item?.plantingVarieties?.length" class="c-333 f-s-28 pd-5 d-flex">
  108. <text class="c-#666 w-s-no">当前在地品种:</text>
  109. <text class="ov-hd tx-ov w-s-no f-w-5">{{ item.plantingVarieties?.map((items) => items.variety).join('、') || '-' }}</text>
  110. <text v-if="item?.plantingVarieties?.length" class="flex1 w-s-no f-w-5">等{{ item.plantingVarieties?.length }}个品种</text>
  111. </view>
  112. <template v-if="item.gapInfo?.basePic">
  113. <view class="pd-10"></view>
  114. <view class="p-rtv">
  115. <image class="w-full h-310" :src="item.gapInfo?.basePic" mode="aspectFill"></image>
  116. <view class="d-flex flex-cln a-ed" style="position: absolute; bottom: 20rpx; right: 0">
  117. <view class="pd2-10-20 bg-black-op-0.5 c-#ccc f-s-20 mb-10" style="border-radius: 10rpx 0 0 10rpx; width: max-content">{{ item?.contactName }}负责</view>
  118. <view class="pd2-10-20 bg-black-op-0.5 c-#ccc f-s-20 mb-10" style="border-radius: 10rpx 0 0 10rpx; width: max-content">{{ selectDictLabel(pt_org_type, item?.orgType) }}</view>
  119. <view class="pd2-10-20 bg-black-op-0.5 c-#ccc f-s-20" style="border-radius: 10rpx 0 0 10rpx; width: max-content">经度:E{{ item?.gapInfo?.lng }} 纬度:N{{ item?.gapInfo?.lat }}</view>
  120. </view>
  121. <view style="position: absolute; top: 20rpx; left: 0">
  122. <view class="base-status-gap-1" v-if="+item?.gapFlag">获评{{ item?.gapInfo?.medicineName }}GAP基地</view>
  123. <template v-if="item?.swyqRes">
  124. <view class="base-status-gap-1" v-if="item?.swyqRes == '1'">获评{{ item?.swyqVarietyName }}三无一全基地</view>
  125. <view class="base-status-gap-2" v-if="item?.swyqRes == '2'">标记{{ item?.swyqVarietyName }}三无一全基地未通过审核</view>
  126. <view class="base-status-gap-0" v-if="item?.swyqRes == '0'">标记{{ item?.swyqVarietyName }}三无一全基地待审核</view>
  127. </template>
  128. </view>
  129. </view>
  130. </template>
  131. <template v-else>
  132. <view v-if="item?.contactName" class="c-333 f-s-28 pd-5">
  133. <text class="c-#666">负责人:</text>
  134. <text class="f-w-5">{{ item?.contactName || '-' }}</text>
  135. </view>
  136. <view v-if="item?.orgType" class="c-333 f-s-28 pd-5">
  137. <text class="c-#666">组织方式:</text>
  138. <text class="f-w-5">{{ selectDictLabel(pt_org_type, item?.orgType) }}</text>
  139. </view>
  140. <view v-if="item?.orgType" class="c-333 f-s-28 pd-5">
  141. <text class="c-#666">经纬度:</text>
  142. <text class="f-w-5">E{{ item?.gapInfo?.lng }},N{{ item?.gapInfo?.lat }}</text>
  143. </view>
  144. </template>
  145. <view v-if="+(item?.tempFlag ?? 0)" class="temp_flag">暂存</view>
  146. </view>
  147. </up-swipe-action-item>
  148. </up-swipe-action>
  149. </template>
  150. </view>
  151. </view>
  152. </view>
  153. </template>
  154. <template #empty>
  155. <view class="" style="margin-top: -200rpx">
  156. <ut-empty class="mg-at" color="#ccc" size="28rpx" image="/static/images/plant/noEmptyBase.png">尚未添加绘制种养殖基地信息~</ut-empty>
  157. <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">
  158. <img class="w-38 h-36 mr-10" src="/static/images/plant/chooseGAP.png" alt="" mode="widthFix" />
  159. <text>去添加基地</text>
  160. </view>
  161. </view>
  162. </template>
  163. <view class="h-210" v-if="list?.length"></view>
  164. <view v-if="list?.length" :style="{ height: `${safeAreaBottom}px` }"></view>
  165. </z-paging>
  166. <ut-tabar activeTab="base"></ut-tabar>
  167. <ut-confirm-dialog v-model:show="showDeleteDialog" width="80vw" title="请选择要添加到基地类型" :confirmText="'确认选择'" :cancelText="'取消'" @confirm="handlechoseConfirm" @cancel="handleDeleteCancel">
  168. <view class="" v-for="item in pt_base_type" :key="item?.value">
  169. <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)">
  170. <view class="radius-50% mg-8">
  171. <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>
  172. </view>
  173. <view class="c-#333 f-s-34">
  174. {{ item?.label }}
  175. </view>
  176. <view class="flex1"></view>
  177. <view class="d-flex">
  178. <img v-if="basetype === item.value" class="w-30 h-30" src="/static/images/plant/chooseSuccessfully.png" mode="widthFix" alt="" />
  179. </view>
  180. </view>
  181. </view>
  182. </ut-confirm-dialog>
  183. <ut-suspension @click="showDeleteDialog = true">
  184. <image src="/static/images/plant/addBase.png" mode="widthFix" class="w-120 h-120"></image>
  185. </ut-suspension>
  186. </template>
  187. <script setup lang="ts">
  188. import { useClientRequest } from '@/utils/request';
  189. import { setCipByNum } from '@/utils/public';
  190. import { useInfoStore } from '@/store';
  191. const { proxy } = getCurrentInstance() as ComponentInternalInstance;
  192. const { pt_base_type, pt_org_type } = toRefs<any>(proxy?.useDict('pt_base_type', 'pt_org_type'));
  193. const infoStore = useInfoStore();
  194. // 获取用户信息
  195. const avatar = computed(() => infoStore.userInfo?.avatar || '');
  196. const name = computed(() => infoStore.userInfo?.name || '');
  197. const phone = computed(() => infoStore.userInfo?.phone || '');
  198. const currentCpyName = computed(() => infoStore.userInfo?.currentCpyName || '');
  199. const windowInfo = uni.getWindowInfo();
  200. const safeAreaBottom = windowInfo.safeAreaInsets.bottom;
  201. // 证书文件类型
  202. interface CertFile {
  203. fileName: string;
  204. url: string;
  205. fileSize: number;
  206. }
  207. // 差异信息类型
  208. interface GapInfo {
  209. id: number;
  210. sourceType: string;
  211. gapBaseName: string;
  212. sn: string;
  213. medicineName: string;
  214. medicineId: number;
  215. area: number;
  216. basePic: string;
  217. lng: number;
  218. lat: number;
  219. adcode: string;
  220. address: string;
  221. ratedDate: string; // 格式: "YYYY-MM-DD"
  222. certFile: CertFile[];
  223. res: string;
  224. auditor: number;
  225. msg: string;
  226. }
  227. // 种植品种类型
  228. interface PlantingVariety {
  229. baseId: number;
  230. varietyId: string;
  231. variety: string;
  232. }
  233. // 坐标点类型
  234. interface Coordinate {
  235. lng: number;
  236. lat: number;
  237. }
  238. // 主数据类型
  239. interface BaseData {
  240. id: number;
  241. baseName: string;
  242. baseCode?: string;
  243. baseType?: string;
  244. adcode?: string;
  245. buildDate?: string; // 格式: "YYYY-MM-DD"
  246. orgType: string;
  247. contactId: number;
  248. contactTel: string;
  249. contactName?: string;
  250. lng: number;
  251. lat: number;
  252. basePic: string;
  253. address: string;
  254. area: number;
  255. gapFlag: string;
  256. gapInfo: GapInfo;
  257. cpyid: number;
  258. appid: number;
  259. partnerId: number;
  260. createBy: number;
  261. updateBy: number;
  262. createTime: string; // ISO 8601 格式
  263. updateTime: string; // ISO 8601 格式
  264. hide: string;
  265. plantingVarieties: PlantingVariety[];
  266. coordinates: Coordinate[][]; // 二维坐标数组
  267. tempFlag?: number | string;
  268. swyqRes?: string;
  269. swyqVarietyName?: string;
  270. }
  271. const instance = getCurrentInstance();
  272. const list = ref<BaseData[]>();
  273. const paging = ref();
  274. const bubble = ref(uni.getMenuButtonBoundingClientRect());
  275. const form = ref({ queryType: '', keyword: '' });
  276. const speciesArray = ref([]);
  277. const navBarBgColor = ref('transparent');
  278. const stickyTop = ref(0);
  279. const systemInfo = uni.getSystemInfoSync();
  280. const sus = ref({
  281. left: 0,
  282. bottom: 0,
  283. });
  284. sus.value.left = systemInfo.windowWidth - 10;
  285. sus.value.bottom = systemInfo.windowHeight - 200;
  286. const changeSeach = () => {
  287. paging.value.reload();
  288. };
  289. const onRefresh = () => {
  290. paging.value.reload();
  291. };
  292. const onPageScroll = (e: any) => {
  293. const { scrollTop } = e.detail;
  294. if (scrollTop > 20) {
  295. navBarBgColor.value = '#d9f8d6';
  296. } else {
  297. navBarBgColor.value = 'transparent';
  298. }
  299. };
  300. const query = async (pageNum: number, pageSize: number) => {
  301. const params = {
  302. pageNum,
  303. pageSize,
  304. ...form.value,
  305. };
  306. if (pageNum == 1) {
  307. getBaseCount();
  308. }
  309. const res = await useClientRequest.get('/plt-api/app/base/pageList', params);
  310. console.log(res, 'res');
  311. if (res) {
  312. const { rows } = res;
  313. paging.value.complete(rows);
  314. }
  315. };
  316. // 查询企业的种植品种
  317. const getSpecies = async () => {
  318. const res = await useClientRequest.get('/plt-api/app/cpyVariety/list');
  319. if (res?.code === 200) {
  320. speciesArray.value = res.data?.map((item: any) => item.medicineName);
  321. }
  322. };
  323. const showDeleteDialog = ref(false);
  324. const basetype = ref();
  325. const handlechose = (item: string) => {
  326. basetype.value = item;
  327. };
  328. // 处理取消
  329. const handleDeleteCancel = () => {
  330. showDeleteDialog.value = false;
  331. basetype.value = null;
  332. };
  333. const handlechoseConfirm = () => {
  334. uni.$u.route({ type: 'navigateTo', url: '/plant/base/base-edit/index', params: { baseType: basetype.value } });
  335. };
  336. // 暂存项左滑删除配置
  337. const optionsActionTemp = reactive([
  338. {
  339. text: '删除',
  340. style: {
  341. backgroundColor: '#f56c6c',
  342. },
  343. },
  344. ]);
  345. // 暂存项删除点击(本地移除)
  346. const clickTempSwipe = async (event: object) => {
  347. const { name, index } = event as any;
  348. if (index === 0) {
  349. try {
  350. const res = await uni.showModal({
  351. title: '删除提示',
  352. content: '确定删除该基地吗?',
  353. confirmColor: '#f56c6c',
  354. });
  355. if (!res.confirm) return;
  356. await uni.showLoading({
  357. title: '删除中...',
  358. mask: true,
  359. });
  360. await useClientRequest.get(`/plt-api/app/base/delById/${name}`);
  361. uni.hideLoading();
  362. uni.showToast({
  363. title: '删除成功',
  364. icon: 'success',
  365. });
  366. paging.value?.reload();
  367. } catch (error) {
  368. console.error('删除暂存基地失败:', error);
  369. }
  370. }
  371. };
  372. const typeNums = ref<any[]>([]);
  373. // 获取统计信息
  374. const getBaseCount = async () => {
  375. try {
  376. const res = await useClientRequest.get('/plt-api/app/base/getBaseCount');
  377. if (res?.code === 200) {
  378. console.log(res);
  379. typeNums.value = res.data?.map((item: any) => {
  380. return {
  381. label: `${item.name}(${item.num})`,
  382. value: item.type,
  383. };
  384. });
  385. }
  386. } catch (error) {
  387. console.error('获取地块统计信息失败:', error);
  388. }
  389. };
  390. onMounted(() => {
  391. const querys = uni.createSelectorQuery().in(instance?.proxy);
  392. querys
  393. .select('#topup-navbar')
  394. .boundingClientRect((data: any) => {
  395. console.log(data);
  396. stickyTop.value = data.top + data.height;
  397. })
  398. .exec();
  399. getSpecies();
  400. uni.$on('refreshBaseList', () => {
  401. onRefresh();
  402. });
  403. });
  404. onShow(() => {
  405. getSpecies();
  406. });
  407. </script>
  408. <style lang="scss" scoped>
  409. // @import '@/assets/styles/theme.scss';
  410. .search-select-item {
  411. height: 86rpx;
  412. background-color: #fff;
  413. border-radius: 10rpx;
  414. box-sizing: border-box;
  415. padding: 12rpx;
  416. }
  417. .temp_flag {
  418. position: absolute;
  419. right: 0;
  420. top: 0;
  421. background-color: #c5c6c6;
  422. color: #fff;
  423. font-size: 20rpx;
  424. padding: 4rpx 16rpx;
  425. border-radius: 0 16rpx 0 16rpx;
  426. }
  427. .base-status-gap-1 {
  428. font-size: 24rpx;
  429. color: #fff;
  430. font-weight: 500;
  431. background-image: linear-gradient(to right, #37a954, #a4d14e);
  432. padding: 6rpx 24rpx 6rpx 16rpx;
  433. border-radius: 0 20rpx 20rpx 0;
  434. }
  435. .base-status-gap-2 {
  436. font-size: 24rpx;
  437. color: #fff;
  438. font-weight: 500;
  439. background: rgba(#fc333f, 0.8);
  440. padding: 6rpx 24rpx 6rpx 16rpx;
  441. border-radius: 0 20rpx 20rpx 0;
  442. }
  443. .base-status-gap-0 {
  444. font-size: 24rpx;
  445. color: #fff;
  446. font-weight: 500;
  447. background: rgba(#ffad11, 0.8);
  448. padding: 6rpx 24rpx 6rpx 16rpx;
  449. border-radius: 0 20rpx 20rpx 0;
  450. }
  451. </style>