index.vue 19 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491
  1. <template>
  2. <div class="base-container">
  3. <fnHeader :hideSwitch="true" :hideShadow="true" showDate></fnHeader>
  4. <div class="content">
  5. <div class="left">
  6. <div class="btn" @click="goBack">
  7. <img src="@/assets/images/common/back-icon.png" alt="" />
  8. 返回
  9. </div>
  10. <chart-box class="left-cont" name="编辑农事" color="yellow">
  11. <template #title-right>
  12. <steps :active="active"></steps>
  13. </template>
  14. <div class="box">
  15. <div class="box-item" v-if="active === 0">
  16. <div class="box-title">
  17. <div>
  18. 选择农事类型
  19. <span>(可多选)</span>
  20. </div>
  21. </div>
  22. <div class="list">
  23. <div
  24. class="list-item"
  25. @click="handleItem(item, index)"
  26. :class="{ active: item.active }"
  27. v-for="(item, index) in checkData"
  28. :key="index"
  29. >
  30. {{ item.label }}
  31. <el-icon size="25" color="#FFD489" v-show="item.active"
  32. ><CircleCheckFilled
  33. /></el-icon>
  34. <div v-show="!item.active" class="round"></div>
  35. </div>
  36. </div>
  37. </div>
  38. <template v-else>
  39. <div class="box-item">
  40. <div class="box-title">基本信息</div>
  41. <el-form class="box-form" :model="form">
  42. <el-form-item label="农事名称">
  43. <el-input v-model="form.name" />
  44. </el-form-item>
  45. <el-form-item label="农事目的">
  46. <el-input v-model="form.mudi" />
  47. </el-form-item>
  48. <el-form-item label="触发条件">
  49. <el-input v-model="form.tiaojian" />
  50. </el-form-item>
  51. </el-form>
  52. </div>
  53. <div class="box-item" v-for="(item, index) in boxList" :key="index">
  54. <div class="box-title border-none">
  55. {{ item.label }}处方
  56. <div class="add-text" @click="handleAdd(index)">
  57. <el-icon class="icon"><Plus /></el-icon>
  58. 添加药物
  59. </div>
  60. </div>
  61. <div class="box-item-children" v-for="(ele,idx) in item.children" :key="idx + 'id'">
  62. <div class="index">{{ idx < 10 ? "0" + (idx + 1) : idx + 1 }}</div>
  63. <custom-table></custom-table>
  64. <div class="box-textarea">
  65. <el-input
  66. class="textarea"
  67. v-model="textarea"
  68. :rows="1"
  69. type="textarea"
  70. placeholder="用药注意事项备注"
  71. />
  72. </div>
  73. <div class="btn-group">
  74. <div class="delete" @click="handleDelete(index,idx)">删除</div>
  75. <div>重置</div>
  76. </div>
  77. </div>
  78. </div>
  79. <div class="box-item">
  80. <el-input
  81. class="textarea"
  82. v-model="textarea"
  83. type="textarea"
  84. placeholder="用药注意事项备注"
  85. />
  86. </div>
  87. </template>
  88. </div>
  89. <div class="footer">
  90. <div class="button" @click="handleOk">{{ active === 0 ? "确定" : "下发农事" }}</div>
  91. </div>
  92. </chart-box>
  93. </div>
  94. <div class="right">
  95. <div class="map-header">
  96. <div class="title">
  97. <img src="@/assets/images/common/area-icon.png" alt="" />
  98. 执行农事区域
  99. </div>
  100. <el-checkbox-group v-model="checkValue" @change="handleCheck">
  101. <el-checkbox
  102. v-for="item in checkList"
  103. :key="item.value"
  104. :label="item.label"
  105. :value="item.value"
  106. />
  107. </el-checkbox-group>
  108. </div>
  109. <div ref="mapRef" class="map">
  110. <div class="map-bg map-btn">查看巡园照片</div>
  111. <div class="map-bg map-legend">
  112. <div class="item">
  113. <img src="@/assets/images/map/status/bhyc.png" alt="" />
  114. 病害异常
  115. </div>
  116. <div class="item">
  117. <img src="@/assets/images/map/status/chyc.png" alt="" />
  118. 虫害异常
  119. </div>
  120. <div class="item">
  121. <img src="@/assets/images/map/status/szyc.png" alt="" />
  122. 生长异常
  123. </div>
  124. </div>
  125. </div>
  126. </div>
  127. </div>
  128. </div>
  129. </template>
  130. <script setup>
  131. import { onMounted, ref } from "vue";
  132. import { ElMessage } from "element-plus";
  133. import fnHeader from "@/components/fnHeader.vue";
  134. import steps from "./components/steps.vue";
  135. import customTable from "./components/table.vue";
  136. import FarmMap from "./farmMap";
  137. import { deepClone } from "@/common/commonFun";
  138. import chartBox from "@/components/chartBox.vue";
  139. import { useRouter, useRoute } from "vue-router";
  140. import { useStore } from "vuex";
  141. let store = useStore();
  142. let farmMap = new FarmMap();
  143. const active = ref(0);
  144. const checkList = ref([
  145. { value: "0", label: "生长异常" },
  146. { value: "1", label: "病害异常" },
  147. { value: "2", label: "虫害异常" },
  148. ]);
  149. const checkValue = ref(["0"]);
  150. const handleCheck = (e) => {
  151. console.log("e", e);
  152. };
  153. const checkData = ref([
  154. { value: "0", label: "生长异常", active: true, children: [{index: 1}] },
  155. { value: "1", label: "病害异常", active: false, children: [{index: 1}] },
  156. { value: "2", label: "虫害异常", active: false, children: [{index: 1}] },
  157. ]);
  158. const handleItem = (item, index) => {
  159. checkData.value[index].active = !checkData.value[index].active;
  160. // const curIndex = checkValue.value.indexOf(item.value)
  161. // if(curIndex===-1){
  162. // checkValue.value.push(item.value)
  163. // }else{
  164. // checkValue.value.splice(curIndex,1)
  165. // checkList.value[index].active = false
  166. // }
  167. };
  168. const router = useRouter();
  169. const route = useRoute();
  170. const mapRef = ref();
  171. onMounted(() => {
  172. getList();
  173. farmMap.initMap("POINT(113.61448114737868 23.585550924763083)", mapRef.value);
  174. });
  175. const getList = () => {
  176. console.log("000");
  177. };
  178. const goBack = () => {
  179. router.go(-1);
  180. };
  181. //确定/下发农事
  182. const handleOk = () => {
  183. if (active.value) {
  184. console.log("123");
  185. } else {
  186. active.value = 1;
  187. const arr = checkData.value.filter((item) => item.active);
  188. boxList.value = deepClone(arr);
  189. }
  190. };
  191. const form = ref({
  192. name: "梢期防虫",
  193. mudi: "防治荔枝病虫害",
  194. tiaojian: "单树花带叶率 40%",
  195. });
  196. const textarea = ref("");
  197. const boxList = ref([]);
  198. //添加
  199. const handleAdd = (index) => {
  200. boxList.value[index].children.push({ index: 1 });
  201. };
  202. //删除
  203. const handleDelete = (index,childIndex) => {
  204. if (boxList.value[index].children.length === 1) return ElMessage.warning("最少保留一个处方");
  205. boxList.value[index].children.splice(childIndex, 1);
  206. };
  207. </script>
  208. <style lang="scss" scoped>
  209. .base-container {
  210. width: 100%;
  211. height: 100vh;
  212. color: #fff;
  213. position: relative;
  214. box-sizing: border-box;
  215. z-index: 1;
  216. background: #000;
  217. .content {
  218. width: 100%;
  219. height: calc(100% - 74px);
  220. display: flex;
  221. justify-content: space-between;
  222. box-sizing: border-box;
  223. padding: 20px;
  224. .left {
  225. width: 473px;
  226. height: 100%;
  227. box-sizing: border-box;
  228. .btn {
  229. display: flex;
  230. align-items: center;
  231. justify-content: center;
  232. border: 1px solid rgba(255, 255, 255, 0.78);
  233. border-radius: 4px;
  234. padding: 9px;
  235. margin-bottom: 13px;
  236. width: 104px;
  237. cursor: pointer;
  238. img {
  239. width: 14px;
  240. margin-right: 5px;
  241. }
  242. }
  243. .left-cont {
  244. width: 100%;
  245. height: calc(100% - 48px - 4px);
  246. .box {
  247. width: 100%;
  248. height: calc(100% - 58px);
  249. padding: 16px 12px;
  250. box-sizing: border-box;
  251. overflow-y: auto;
  252. .box-item {
  253. background: rgba(255, 255, 255, 0.04);
  254. border: 1px solid #444444;
  255. border-radius: 8px;
  256. padding: 16px 12px;
  257. box-sizing: border-box;
  258. width: 100%;
  259. .box-title {
  260. font-size: 20px;
  261. border-bottom: 1px solid #333333;
  262. padding: 0 0 12px 13px;
  263. margin-bottom: 21px;
  264. position: relative;
  265. display: flex;
  266. justify-content: space-between;
  267. &.border-none {
  268. border: none;
  269. padding-bottom: 0;
  270. }
  271. &::before {
  272. content: "";
  273. position: absolute;
  274. left: 0;
  275. top: 6px;
  276. width: 3px;
  277. height: 16px;
  278. background: #fff;
  279. border-radius: 11px;
  280. }
  281. span {
  282. font-size: 14px;
  283. color: #9f9f9f;
  284. }
  285. .add-text {
  286. font-size: 16px;
  287. color: #ffd489;
  288. display: flex;
  289. align-items: center;
  290. cursor: pointer;
  291. .icon {
  292. margin-right: 3px;
  293. }
  294. }
  295. }
  296. .list {
  297. .list-item {
  298. background: rgba(255, 255, 255, 0.05);
  299. border-radius: 8px;
  300. font-size: 18px;
  301. padding: 16px;
  302. display: flex;
  303. align-items: center;
  304. justify-content: space-between;
  305. border: 1px solid transparent;
  306. cursor: pointer;
  307. &.active {
  308. border-color: #ffd489;
  309. background: rgba(255, 212, 137, 0.05);
  310. }
  311. .round {
  312. border: 1px solid #cecece;
  313. border-radius: 50%;
  314. width: 20px;
  315. height: 20px;
  316. }
  317. }
  318. .list-item + .list-item {
  319. margin-top: 16px;
  320. }
  321. }
  322. // 编辑处方
  323. .box-form {
  324. ::v-deep {
  325. .el-form-item__label {
  326. color: #9f9f9f;
  327. }
  328. .el-input__wrapper {
  329. background: transparent;
  330. box-shadow: 0 0 0 1px #9f9f9f;
  331. .el-input__inner {
  332. color: #fff;
  333. }
  334. }
  335. }
  336. }
  337. .box-item-children {
  338. border: 1px solid #444444;
  339. border-radius: 8px;
  340. padding: 9px;
  341. box-sizing: border-box;
  342. position: relative;
  343. .index {
  344. position: absolute;
  345. top: 0;
  346. left: 0;
  347. background: #ffd489;
  348. border-radius: 4px 0 4px 0;
  349. font-size: 12px;
  350. color: #1d1d1d;
  351. padding: 0 7px;
  352. }
  353. .box-textarea {
  354. border-radius: 4px;
  355. padding: 10px;
  356. background: rgba(255, 255, 255, 0.05);
  357. margin: 16px 0 20px 0;
  358. }
  359. .btn-group {
  360. display: flex;
  361. div {
  362. background: rgba(255, 212, 137, 0.05);
  363. border-radius: 4px;
  364. border: 1px solid #ffd489;
  365. padding: 6px;
  366. flex: 1;
  367. color: #ffd489;
  368. text-align: center;
  369. cursor: pointer;
  370. }
  371. .delete {
  372. background: rgba(249, 152, 81, 0.05);
  373. border: 1px solid #f99851;
  374. color: #f99851;
  375. margin-right: 12px;
  376. }
  377. }
  378. }
  379. .box-item-children + .box-item-children{
  380. margin-top: 12px;
  381. }
  382. .textarea {
  383. ::v-deep {
  384. .el-textarea__inner {
  385. background: transparent;
  386. box-shadow: none;
  387. color: #fff;
  388. padding: 0;
  389. }
  390. }
  391. }
  392. }
  393. .box-item + .box-item {
  394. margin-top: 16px;
  395. }
  396. }
  397. .footer {
  398. width: 100%;
  399. height: 58px;
  400. border-top: 0.5px solid #555555;
  401. background: rgba(255, 255, 255, 0.04);
  402. display: flex;
  403. justify-content: flex-end;
  404. align-items: center;
  405. .button {
  406. font-size: 16px;
  407. padding: 8px 58px;
  408. background: #ffd489;
  409. border-radius: 4px;
  410. color: #000;
  411. margin-right: 12px;
  412. cursor: pointer;
  413. }
  414. }
  415. }
  416. }
  417. .right {
  418. width: calc(100% - 473px - 18px);
  419. margin-left: 18px;
  420. height: 100%;
  421. background: #191919;
  422. border: 0.6px solid #444444;
  423. padding: 20px;
  424. box-sizing: border-box;
  425. border-radius: 8px;
  426. .map-header {
  427. display: flex;
  428. justify-content: space-between;
  429. .title {
  430. font-size: 22px;
  431. display: flex;
  432. align-items: flex-end;
  433. font-family: "PangMenZhengDao";
  434. margin-bottom: 16px;
  435. img {
  436. margin-right: 8px;
  437. }
  438. }
  439. }
  440. .map {
  441. width: 100%;
  442. clip-path: inset(0px round 4px);
  443. height: calc(100% - 31px - 16px);
  444. position: relative;
  445. .map-bg {
  446. position: absolute;
  447. z-index: 2;
  448. background: rgba(0, 0, 0, 0.6);
  449. border-radius: 18px;
  450. padding: 7px 16px;
  451. right: 20px;
  452. }
  453. .map-btn {
  454. top: 19px;
  455. cursor: pointer;
  456. }
  457. .map-legend {
  458. bottom: 21px;
  459. display: flex;
  460. align-items: center;
  461. .item {
  462. display: flex;
  463. align-items: center;
  464. img {
  465. margin-right: 5px;
  466. }
  467. }
  468. .item + .item {
  469. margin-left: 20px;
  470. }
  471. }
  472. }
  473. }
  474. }
  475. }
  476. </style>