index.vue 1.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475
  1. <template>
  2. <div class="farm-card-page">
  3. <custom-header name="农事方案"></custom-header>
  4. <div class="farm-card-content">
  5. <tab-list
  6. v-if="curRole == 2"
  7. type="light"
  8. v-model="active"
  9. :tabs="tabs"
  10. @change="handleTabChange"
  11. class="tabs-list"
  12. />
  13. <plan-list :farm-id="route.query.farmId" :schemeId="active" isEdit> </plan-list>
  14. </div>
  15. </div>
  16. </template>
  17. <script setup>
  18. import customHeader from "@/components/customHeader.vue";
  19. import { onMounted, ref } from "vue";
  20. import { useRoute } from "vue-router";
  21. import tabList from "@/components/pageComponents/TabList.vue";
  22. import PlanList from "@/components/pageComponents/PlanList.vue";
  23. const route = useRoute();
  24. const curRole = localStorage.getItem("SET_USER_CUR_ROLE");
  25. const tabs = ref([]);
  26. const active = ref(null);
  27. const handleTabChange = (index) => {
  28. console.log(index);
  29. };
  30. onMounted(() => {
  31. if (curRole == 2) {
  32. getListMySchemes();
  33. }
  34. });
  35. const getListMySchemes = () => {
  36. VE_API.home.listMySchemes().then(({ data }) => {
  37. if (data.length) {
  38. tabs.value = data || [];
  39. active.value = data[0].id;
  40. } else {
  41. getSchemes();
  42. }
  43. });
  44. };
  45. const getSchemes = () => {
  46. VE_API.home.batchInitSchemes({ containerIds: [3], schemeName: "农资荔枝方案" }).then(({ code }) => {
  47. if (code == 0) {
  48. getListMySchemes();
  49. }
  50. });
  51. };
  52. </script>
  53. <style scoped lang="scss">
  54. .farm-card-page {
  55. width: 100%;
  56. height: 100vh;
  57. background: #f5f7fb;
  58. .farm-card-content {
  59. width: 100%;
  60. height: calc(100vh - 40px);
  61. padding-top: 10px;
  62. .tabs-list {
  63. margin: 0 0 10px 10px;
  64. }
  65. }
  66. }
  67. </style>