myPrescription.vue 15 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437
  1. <template>
  2. <div class="prescription-page">
  3. <div class="filter-list">
  4. <div
  5. class="filter-item"
  6. v-for="(label, i) in filterTabs"
  7. :key="i"
  8. :class="{ active: i === activeFilterIndex }"
  9. @click="activeFilterIndex = i"
  10. >
  11. {{ label }}
  12. </div>
  13. </div>
  14. <div class="expert-prescription" :class="{ isSubPage: isSubPage }">
  15. <div class="plan-menu">
  16. <el-anchor :container="containerRef" direction="vertical" type="default" @click="handleClick">
  17. <el-menu :default-active="defaultActive" class="el-menu-vertical-demo">
  18. <el-sub-menu v-for="(menu, index) in menuData" :key="index" :index="String(menu.id)">
  19. <template #title>
  20. <img class="menu-icon" :src="require(`@/assets/img/gallery/icon-${index}.png`)" />
  21. <span class="menu-text">{{ menu.name }}</span>
  22. </template>
  23. <el-menu-item
  24. v-for="item in menu.farmWorkArrangeList"
  25. :key="item.id"
  26. :index="`${menu.id}-${item.id}`"
  27. >
  28. <el-anchor-link
  29. :href="'#' + menu.name + item.farmWorkDetail?.name"
  30. :title="item.farmWorkDetail?.name"
  31. />
  32. </el-menu-item>
  33. </el-sub-menu>
  34. </el-menu>
  35. </el-anchor>
  36. </div>
  37. <div class="expert-content" ref="containerRef">
  38. <div v-for="(section, index) in menuData" :key="index" class="content-section">
  39. <div
  40. class="section-item"
  41. v-for="(sub, subI) in section.farmWorkArrangeList"
  42. :key="index + '-' + subI"
  43. >
  44. <div class="section-id" :id="section.name + sub.farmWorkDetail?.name"></div>
  45. <record-item :record-item-data="sub">
  46. <template #title>
  47. <div class="box-title">
  48. <div class="title-l">
  49. {{ sub.farmWorkDetail?.name }}
  50. <span class="parent-text">{{ section.name }}</span>
  51. </div>
  52. <!-- <div class="title-r">
  53. <div class="btn-item del-btn" @click="deletePlan">
  54. <el-icon color="#fff" size="14"><Delete /></el-icon>
  55. </div>
  56. <div class="btn-item edit-btn">
  57. <el-icon color="#fff" size="14"><Edit /></el-icon>
  58. </div>
  59. </div> -->
  60. </div>
  61. </template>
  62. </record-item>
  63. </div>
  64. </div>
  65. </div>
  66. </div>
  67. <!-- 底部 -->
  68. <div class="fixed-bottom" :style="{ color: activeFilterIndex === defaultFilterIndex ? 'rgba(0, 0, 0, 0.5)' : '#2199F8' }" @click="handleSetDefault">{{activeFilterIndex === defaultFilterIndex ? '当前已是 默认方案' : '设置为 默认方案'}}</div>
  69. </div>
  70. <!-- <add-group ref="addGroupRef" @updateGroupList="getPlan" /> -->
  71. <action-sheet :style="{ bottom: tabBarHeight + 'px' }" v-model:show="showAction" title="选择农事类型(可多选)">
  72. <div class="content">
  73. <checkbox-group v-model="checkedType">
  74. <div class="action-content">
  75. <div
  76. class="action-item"
  77. :class="{ active: checkedType.includes(item) }"
  78. v-for="(item, index) in actionTypeList"
  79. :key="index"
  80. @click="toggleActionType(index)"
  81. >
  82. <div class="type-name">{{ item }}</div>
  83. <div>
  84. <checkbox :name="item" :ref="(el) => (checkboxRefs[index] = el)" @click.stop />
  85. </div>
  86. </div>
  87. </div>
  88. <div class="action-btn">
  89. <el-button @click="toNewFarming" :disabled="checkedType.length === 0" class="btn-one" type="primary"
  90. >确定</el-button
  91. >
  92. </div>
  93. </checkbox-group>
  94. </div>
  95. </action-sheet>
  96. </template>
  97. <script setup>
  98. import { computed, onMounted, ref } from "vue";
  99. import addGroup from "./addGroup.vue";
  100. import recordItem from "@/components/recordItem.vue";
  101. import { useStore } from "vuex";
  102. import { useRouter } from "vue-router";
  103. import { ActionSheet, Checkbox, CheckboxGroup } from "vant";
  104. import { ElMessage, ElMessageBox } from "element-plus";
  105. const props = defineProps({
  106. isSubPage: {
  107. type: Boolean,
  108. default: false,
  109. },
  110. });
  111. const store = useStore();
  112. const router = useRouter();
  113. // 顶部筛选标签
  114. const filterTabs = ref(["韦帮稳", "某某某", "某某某", "某某某"]);
  115. const activeFilterIndex = ref(0);
  116. const defaultFilterIndex = ref(0);
  117. const handleSetDefault = () => {
  118. if (activeFilterIndex.value === defaultFilterIndex.value) {
  119. ElMessage.warning('当前已是 默认方案');
  120. } else {
  121. ElMessageBox.confirm('确定要将当前方案设置为默认方案吗?', '提示', {
  122. confirmButtonText: '确定',
  123. cancelButtonText: '取消',
  124. type: 'warning'
  125. }).then(() => {
  126. defaultFilterIndex.value = activeFilterIndex.value;
  127. ElMessage.success('设置成功');
  128. }).catch(() => {});
  129. }
  130. };
  131. const tabBarHeight = computed(() => store.state.home.tabBarHeight);
  132. // 菜单
  133. const defaultActive = ref("1-1");
  134. const menuData = ref([]);
  135. function deletePlan() {
  136. ElMessageBox.confirm("是否确认删除该农事?", "提示", {
  137. confirmButtonText: "确定",
  138. cancelButtonText: "取消",
  139. type: "warning",
  140. })
  141. .then(() => {
  142. // ElMessage({
  143. // type: "success",
  144. // message: "删除成功!",
  145. // });
  146. })
  147. .catch(() => {});
  148. }
  149. const handleClick = (e) => {
  150. e.preventDefault();
  151. };
  152. const addGroupRef = ref(null);
  153. // 新增方案
  154. function newPlan() {
  155. addGroupRef.value.openClientPopup({ params: { farmIds: [farmId.value], containerId: containerId.value } });
  156. }
  157. // -------新增农事-----
  158. const showAction = ref(false);
  159. const addWork = () => {
  160. showAction.value = true;
  161. };
  162. const checkedType = ref([]);
  163. const checkboxRefs = ref([]);
  164. const actionTypeList = ref(["生长异常", "病虫异常", "营养农事"]);
  165. const toggleActionType = (index) => {
  166. checkboxRefs.value[index].toggle();
  167. };
  168. // 新增农事确定
  169. const toNewFarming = () => {
  170. router.push({
  171. path: "/modify_work",
  172. query: { data: JSON.stringify(checkedType.value), gardenId: 766, isAdd: true },
  173. });
  174. showAction.value = false;
  175. };
  176. const containerRef = ref(null);
  177. onMounted(() => {
  178. getFarmList(() => {
  179. getWorkList();
  180. });
  181. });
  182. const miniUserId = store.state.home.miniUserId;
  183. const farmItem = ref(null);
  184. const farmId = ref(null);
  185. const containerId = ref(null);
  186. const farmList = ref([]);
  187. function getFarmList(callback) {
  188. VE_API.farm.fetchFarmList({ userId: miniUserId, show3dFarm: false }).then(({ data }) => {
  189. farmList.value = data || [];
  190. if (data && data.length) {
  191. farmItem.value = { ...data[0], value: data[0].organId };
  192. farmId.value = data[0].organId;
  193. containerId.value = data[0].containerId;
  194. callback && callback();
  195. }
  196. });
  197. }
  198. function getWorkList() {
  199. VE_API.home
  200. .getPhenologyFarmWorkList({ farmId: farmId.value, containerId: containerId.value })
  201. .then(({ data }) => {
  202. menuData.value = data;
  203. });
  204. }
  205. </script>
  206. <style lang="scss" scoped>
  207. .prescription-page {
  208. height: 100%;
  209. background: #f5f7fb;
  210. position: relative;
  211. .filter-list {
  212. padding: 10px 12px;
  213. display: flex;
  214. align-items: center;
  215. gap: 12px;
  216. .filter-item {
  217. color: #8a8f94;
  218. padding: 6px 12px;
  219. &.active {
  220. color: #2199f8;
  221. background: rgba(33, 153, 248, 0.12);
  222. border-radius: 28px;
  223. }
  224. }
  225. }
  226. .expert-prescription {
  227. display: flex;
  228. width: 100%;
  229. height: calc(100vh - 52px - 48px);
  230. &.isSubPage {
  231. height: calc(100vh - 52px - 48px);
  232. }
  233. .plan-menu {
  234. width: 100px;
  235. height: 100%;
  236. overflow: auto;
  237. padding: 10px 0;
  238. box-sizing: border-box;
  239. background: #fff;
  240. border-radius: 0 10px 10px 0;
  241. .menu-icon {
  242. width: 13px;
  243. }
  244. .menu-text {
  245. padding: 0 4px;
  246. }
  247. ::v-deep {
  248. .el-anchor {
  249. height: 100%;
  250. background: none;
  251. }
  252. .el-anchor__marker {
  253. display: none;
  254. }
  255. .el-menu {
  256. background: none;
  257. border: none;
  258. .el-sub-menu__title {
  259. background: none;
  260. padding: 0 2px;
  261. justify-content: center;
  262. }
  263. .el-sub-menu__title {
  264. height: 32px;
  265. }
  266. .el-sub-menu .el-sub-menu__icon-arrow {
  267. position: static;
  268. padding-top: 6px;
  269. }
  270. .el-sub-menu {
  271. margin-bottom: 16px;
  272. &.is-opened {
  273. .el-sub-menu__icon-arrow {
  274. padding-bottom: 6px;
  275. padding-top: 0;
  276. }
  277. }
  278. .el-menu-item {
  279. height: 32px;
  280. line-height: 32px;
  281. margin: 4px 8px;
  282. padding: 0 2px;
  283. justify-content: center;
  284. background: none;
  285. }
  286. .el-menu-item.is-active {
  287. background: none;
  288. color: #fff;
  289. }
  290. .el-anchor__item {
  291. width: 100%;
  292. text-align: center;
  293. }
  294. .el-anchor__link {
  295. color: #666666;
  296. }
  297. .el-anchor__link.is-active {
  298. background: linear-gradient(180deg, #70bffe, #2199f8);
  299. border-radius: 20px;
  300. color: #fff;
  301. }
  302. }
  303. }
  304. .el-anchor__list {
  305. padding-left: 0;
  306. }
  307. }
  308. }
  309. .expert-content {
  310. width: calc(100% - 100px);
  311. height: 100%;
  312. overflow: auto;
  313. padding-bottom: 80px;
  314. box-sizing: border-box;
  315. .content-section {
  316. .section-item {
  317. position: relative;
  318. }
  319. .section-id {
  320. position: absolute;
  321. // top: -6px;
  322. top: 0;
  323. width: 100%;
  324. height: 1px;
  325. }
  326. }
  327. .box-title {
  328. display: flex;
  329. align-items: center;
  330. justify-content: space-between;
  331. padding-bottom: 8px;
  332. border-bottom: 1px solid #f5f5f5;
  333. margin-bottom: 8px;
  334. .title-l {
  335. font-size: 16px;
  336. font-weight: 600;
  337. color: #000;
  338. .parent-text {
  339. margin-left: 5px;
  340. font-size: 12px;
  341. font-weight: normal;
  342. padding: 4px 6px;
  343. border-radius: 14px;
  344. background: rgba(119, 119, 119, 0.1);
  345. }
  346. }
  347. .title-btn {
  348. width: 24px;
  349. height: 24px;
  350. border-radius: 50%;
  351. background: #2199f8;
  352. display: flex;
  353. align-items: center;
  354. justify-content: center;
  355. }
  356. .title-r {
  357. display: flex;
  358. align-items: center;
  359. .btn-item {
  360. width: 24px;
  361. height: 24px;
  362. border-radius: 50%;
  363. display: flex;
  364. align-items: center;
  365. justify-content: center;
  366. background: #2199f8;
  367. &.del-btn {
  368. margin-right: 5px;
  369. background: #ff953d;
  370. }
  371. }
  372. }
  373. }
  374. }
  375. }
  376. .fixed-bottom {
  377. position: fixed;
  378. bottom: 0;
  379. left: 0;
  380. width: 100%;
  381. text-align: center;
  382. padding: 20px;
  383. background: #fff;
  384. box-sizing: border-box;
  385. border-top: 1px solid rgba(153, 153, 153, 0.2);
  386. color: rgba(0, 0, 0, 0.5);
  387. }
  388. }
  389. .action-content {
  390. padding: 4px 12px 40px 12px;
  391. .action-item {
  392. display: flex;
  393. align-items: center;
  394. padding: 16px;
  395. border: 1px solid #dddddd;
  396. border-radius: 8px;
  397. color: #000000;
  398. .type-name {
  399. flex: 1;
  400. }
  401. &.active {
  402. background: rgba(33, 153, 248, 0.1);
  403. border-color: #2199f8;
  404. color: #2199f8;
  405. }
  406. }
  407. .action-item + .action-item {
  408. margin-top: 16px;
  409. }
  410. }
  411. .action-btn {
  412. padding: 0 12px 10px 12px;
  413. width: 100%;
  414. box-sizing: border-box;
  415. .btn-one {
  416. width: 100%;
  417. }
  418. }
  419. </style>