index.vue 52 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495969798991001011021031041051061071081091101111121131141151161171181191201211221231241251261271281291301311321331341351361371381391401411421431441451461471481491501511521531541551561571581591601611621631641651661671681691701711721731741751761771781791801811821831841851861871881891901911921931941951961971981992002012022032042052062072082092102112122132142152162172182192202212222232242252262272282292302312322332342352362372382392402412422432442452462472482492502512522532542552562572582592602612622632642652662672682692702712722732742752762772782792802812822832842852862872882892902912922932942952962972982993003013023033043053063073083093103113123133143153163173183193203213223233243253263273283293303313323333343353363373383393403413423433443453463473483493503513523533543553563573583593603613623633643653663673683693703713723733743753763773783793803813823833843853863873883893903913923933943953963973983994004014024034044054064074084094104114124134144154164174184194204214224234244254264274284294304314324334344354364374384394404414424434444454464474484494504514524534544554564574584594604614624634644654664674684694704714724734744754764774784794804814824834844854864874884894904914924934944954964974984995005015025035045055065075085095105115125135145155165175185195205215225235245255265275285295305315325335345355365375385395405415425435445455465475485495505515525535545555565575585595605615625635645655665675685695705715725735745755765775785795805815825835845855865875885895905915925935945955965975985996006016026036046056066076086096106116126136146156166176186196206216226236246256266276286296306316326336346356366376386396406416426436446456466476486496506516526536546556566576586596606616626636646656666676686696706716726736746756766776786796806816826836846856866876886896906916926936946956966976986997007017027037047057067077087097107117127137147157167177187197207217227237247257267277287297307317327337347357367377387397407417427437447457467477487497507517527537547557567577587597607617627637647657667677687697707717727737747757767777787797807817827837847857867877887897907917927937947957967977987998008018028038048058068078088098108118128138148158168178188198208218228238248258268278288298308318328338348358368378388398408418428438448458468478488498508518528538548558568578588598608618628638648658668678688698708718728738748758768778788798808818828838848858868878888898908918928938948958968978988999009019029039049059069079089099109119129139149159169179189199209219229239249259269279289299309319329339349359369379389399409419429439449459469479489499509519529539549559569579589599609619629639649659669679689699709719729739749759769779789799809819829839849859869879889899909919929939949959969979989991000100110021003100410051006100710081009101010111012101310141015101610171018101910201021102210231024102510261027102810291030103110321033103410351036103710381039104010411042104310441045104610471048104910501051105210531054105510561057105810591060106110621063106410651066106710681069107010711072107310741075107610771078107910801081108210831084108510861087108810891090109110921093109410951096109710981099110011011102110311041105110611071108110911101111111211131114111511161117111811191120112111221123112411251126112711281129113011311132113311341135113611371138113911401141114211431144114511461147114811491150115111521153115411551156115711581159116011611162116311641165116611671168116911701171117211731174117511761177117811791180118111821183118411851186118711881189119011911192119311941195119611971198119912001201120212031204120512061207120812091210121112121213121412151216121712181219122012211222122312241225122612271228122912301231123212331234123512361237123812391240124112421243124412451246124712481249125012511252125312541255125612571258125912601261126212631264126512661267126812691270127112721273127412751276127712781279128012811282128312841285128612871288128912901291129212931294129512961297129812991300130113021303130413051306130713081309131013111312131313141315131613171318131913201321132213231324132513261327132813291330133113321333133413351336133713381339134013411342134313441345134613471348134913501351135213531354135513561357135813591360136113621363136413651366136713681369137013711372137313741375137613771378137913801381138213831384138513861387138813891390139113921393139413951396139713981399140014011402140314041405140614071408140914101411141214131414141514161417141814191420142114221423
  1. <template>
  2. <div class="new-farming-page">
  3. <custom-header :name="isAdd ? '新增农事' : '农事详情'"></custom-header>
  4. <div class="new-farming-content">
  5. <div v-if="!isAdd">
  6. <div class="step-wrap">
  7. <farm-steps :currentStep="0" />
  8. </div>
  9. <div class="box-wrap farm-info">
  10. <div class="info-title">
  11. <div class="card-title">农场现状</div>
  12. <div class="info-more">
  13. 点击查看更多
  14. <el-icon><ArrowRight /></el-icon>
  15. </div>
  16. </div>
  17. <div class="info-content">
  18. 当前农场指标:当前农场指标:当前农场指标:当前农场指标:当前农场指标:当前农场指标:当前农场指标:当前农场指标:当前农场指标:当前农场指标:当前农场指标:当前农场指标:当前农场指标
  19. </div>
  20. </div>
  21. <div class="box-wrap farm-photo">
  22. <div class="photo-list">
  23. <div class="img-item" v-for="(item, index) in 6" :key="index">
  24. <img class="photo-item" src="https://birdseye-img-ali-cdn.sysuimars.com/16926861-1e20-4cbd-8bf2-90208db5a2d0/806080da-1a30-4b5b-b64b-b22e722c6cb6/DJI_202509010800_001_806080da-1a30-4b5b-b64b-b22e722c6cb6/DJI_20250901080536_0045_V_code-ws0fsmge97gh.jpeg" alt="">
  25. </div>
  26. </div>
  27. <div class="list-text">点击查看更多</div>
  28. </div>
  29. </div>
  30. <el-form
  31. ref="formRef"
  32. style="max-width: 600px"
  33. label-position="left"
  34. :rules="rules"
  35. :model="dynamicValidateForm"
  36. class="demo-dynamic"
  37. >
  38. <div class="farm-card" v-if="!isAdd">
  39. <div class="card-title">{{ detailData?.farmWorkName }}<span class="type-tag">标准农事</span></div>
  40. <div class="info-content">
  41. <el-form-item label-width="70px" class="form-item text-item" label="农事编号">
  42. <div class="info-text">
  43. {{ detailData?.code }}
  44. </div>
  45. </el-form-item>
  46. <el-form-item label-width="70px" class="form-item text-item" label="服务亩数">
  47. <div class="info-text">
  48. {{ detailData?.area ? detailData?.area + '亩' : '--' }}
  49. </div>
  50. </el-form-item>
  51. <el-form-item label-width="70px" class="form-item text-item" label="服务区域">
  52. <div class="info-text">
  53. {{ detailData?.serviceRegion }}
  54. </div>
  55. </el-form-item>
  56. <el-form-item label-width="70px" class="form-item" prop="conditionRate" label="触发条件">
  57. <div class="condition-wrap">
  58. {{ detailData?.condition }}
  59. <!-- <el-select v-model="dynamicValidateForm.condition" placeholder="请选择触发条件" style="width: 58%">
  60. <el-option v-for="(item, index) in farmWorkIndexNameList" :key="index" :value="item" :label="item" />
  61. </el-select>
  62. <span class="symbol"></span>
  63. <el-select v-model="dynamicValidateForm.conditionRate" placeholder="" style="width: 38%">
  64. <el-option :value="0" label="0%" />
  65. <el-option :value="5" label="5%" />
  66. <el-option :value="10" label="10%" />
  67. <el-option :value="20" label="20%" />
  68. <el-option :value="40" label="40%" />
  69. <el-option :value="60" label="60%" />
  70. <el-option :value="80" label="80%" />
  71. </el-select> -->
  72. </div>
  73. </el-form-item>
  74. <el-form-item label-width="70px" class="form-item" prop="executeDate" label="执行时间">
  75. <el-date-picker
  76. class="item-input"
  77. style="width: 100%"
  78. value-format="YYYY-MM-DD"
  79. v-model="dynamicValidateForm.executeDate"
  80. type="date"
  81. :clearable="false"
  82. placeholder="选择日期"
  83. />
  84. </el-form-item>
  85. </div>
  86. </div>
  87. <template v-else>
  88. <div class="farm-card progress">
  89. <span class="progress-title">农事进度</span>
  90. <el-radio-group v-model="farmProgress">
  91. <el-radio :value="0">已做</el-radio>
  92. <el-radio :value="1">未做</el-radio>
  93. </el-radio-group>
  94. </div>
  95. <div class="farm-card" v-if="farmProgress === 0">
  96. <div class="card-title">基本信息</div>
  97. <div class="info-content">
  98. <el-form-item label-width="82px" class="form-item" prop="farmWorkName" label="农事名称">
  99. <el-select v-model="dynamicValidateForm.farmWorkName" placeholder="请选择农事名称" style="width: 100%">
  100. <el-option v-for="(item, index) in farmWorkNameList" :key="index" :value="item" :label="item" />
  101. </el-select>
  102. </el-form-item>
  103. <el-form-item label-width="82px" class="form-item" prop="name" label="农事目的">
  104. <el-input
  105. v-model="dynamicValidateForm.purpose"
  106. style="width: 100%"
  107. :rows="2"
  108. type="textarea"
  109. placeholder="请输入农事目的"
  110. />
  111. </el-form-item>
  112. <el-form-item label-width="82px" class="form-item" prop="conditionRate" label="执行时间">
  113. <el-date-picker
  114. v-model="dynamicValidateForm.checkDay"
  115. value-format="YYYY-MM-DD"
  116. type="date"
  117. placeholder="请选择执行时间"
  118. style="width: 100%"
  119. />
  120. </el-form-item>
  121. <!-- <el-form-item label-width="82px" class="form-item" prop="conditionRate" label="触发条件">
  122. <div class="condition-wrap">
  123. <el-select v-model="dynamicValidateForm.condition" placeholder="请选择触发条件" style="width: 58%">
  124. <el-option v-for="(item, index) in farmWorkIndexNameList" :key="index" :value="item" :label="item" />
  125. </el-select>
  126. <span class="symbol"></span>
  127. <el-select v-model="dynamicValidateForm.conditionRate" placeholder="请选择" style="width: 38%">
  128. <el-option :value="0" label="0%" />
  129. <el-option :value="5" label="5%" />
  130. <el-option :value="10" label="10%" />
  131. <el-option :value="20" label="20%" />
  132. <el-option :value="40" label="40%" />
  133. <el-option :value="60" label="60%" />
  134. <el-option :value="80" label="80%" />
  135. </el-select>
  136. </div>
  137. </el-form-item> -->
  138. </div>
  139. </div>
  140. </template>
  141. <div class="farm-card prescription-content" v-if="farmProgress === 0">
  142. <div class="card-title pb-12">药物处方</div>
  143. <el-form-item label-width="82px" class="form-item" prop="usageMode" label="施用方式">
  144. <el-select v-model="dynamicValidateForm.usageMode" placeholder="请选择施用方式" style="width: 100%">
  145. <el-option
  146. v-for="(usage, uId) in allUsageModeList"
  147. :key="uId"
  148. :label="usage"
  149. :value="usage"
  150. />
  151. </el-select>
  152. </el-form-item>
  153. <div v-if="dynamicValidateForm.usageMode !== '人工农事'">
  154. <el-form-item
  155. v-for="(prescriptionItem, prescriptionI) in dynamicValidateForm.prescriptionList"
  156. :key="prescriptionI"
  157. :prop="'prescriptions.' + prescriptionI + '.value'"
  158. class="prescription-item"
  159. >
  160. <div class="recipe-item">
  161. <div class="sub-title">
  162. <div>{{ prescriptionItem.name }}处方</div>
  163. <div class="add-tag" @click="addDomain(prescriptionI)">
  164. <el-icon color="#2199F8"><Plus /></el-icon>新增药物
  165. </div>
  166. </div>
  167. <div class="recipe-form">
  168. <el-form-item
  169. v-for="(domain, index) in prescriptionItem.pesticideFertilizerList"
  170. :key="domain.key"
  171. :prop="'pesticideFertilizerList.' + index + '.value'"
  172. >
  173. <div class="form-box">
  174. <div class="form-index">{{ formatIndex(index) }}</div>
  175. <div class="box-item" v-if="domain.typeName">
  176. <div class="form-l">使用功效</div>
  177. <div class="form-r r-text">
  178. {{ domain.typeName }}
  179. <!-- <el-select
  180. v-model="domain.typeName"
  181. placeholder="请选择"
  182. style="width: 100%"
  183. >
  184. <el-option :label="domain.typeName" :value="domain.typeName" />
  185. </el-select> -->
  186. </div>
  187. </div>
  188. <div class="box-item">
  189. <div class="form-l">肥药名称</div>
  190. <div class="form-r">
  191. <el-select
  192. filterable
  193. @change="handlePesticideFertilizerChange(prescriptionI, index)"
  194. v-model="domain.pesticideFertilizerId"
  195. placeholder="请选择"
  196. style="width: 100%"
  197. >
  198. <el-option
  199. v-for="item in pesticideFertilizersOptions"
  200. :key="item.id"
  201. :label="item.defaultName"
  202. :value="item.id"
  203. />
  204. </el-select>
  205. </div>
  206. </div>
  207. <div class="form-title">人工方式</div>
  208. <div class="box-item sub-item">
  209. <div class="form-l has-sub">
  210. <div class="main-name">肥药配比</div>
  211. <div class="sub-name">(药剂:兑水量)</div>
  212. </div>
  213. <div class="form-r input-box text-center">
  214. <el-input
  215. v-model="domain.ratio"
  216. style="width: 100%"
  217. placeholder="请输入"
  218. />
  219. </div>
  220. </div>
  221. <!-- <div class="box-item sub-item">
  222. <div class="form-l">施用方式</div>
  223. <div class="form-r">
  224. <el-select
  225. v-model="domain.usageMode"
  226. placeholder="请选择"
  227. style="width: 100%"
  228. >
  229. <el-option
  230. v-for="(usage, uId) in domain.usageModeList"
  231. :key="uId"
  232. :label="usage"
  233. :value="usage"
  234. />
  235. </el-select>
  236. </div>
  237. </div> -->
  238. <div class="box-item sub-item">
  239. <div class="form-l has-sub">
  240. <div class="main-name">单亩用量</div>
  241. <div class="sub-name">(亩数:药剂)</div>
  242. </div>
  243. <div class="form-r input-box text-center">
  244. <el-input
  245. v-model="domain.muUsage"
  246. style="width: 100%"
  247. placeholder="请输入"
  248. />
  249. </div>
  250. </div>
  251. <div v-if="dynamicValidateForm.usageMode === '叶面施'">
  252. <div class="form-title">无人机</div>
  253. <div class="box-item sub-item">
  254. <div class="form-l has-sub">
  255. <div class="main-name">肥药配比</div>
  256. <div class="sub-name">(药剂:兑水量)</div>
  257. </div>
  258. <div class="form-r input-box text-center">
  259. <el-input
  260. v-model="domain.ratio2"
  261. style="width: 100%"
  262. placeholder="请输入"
  263. />
  264. </div>
  265. </div>
  266. <div class="box-item sub-item">
  267. <div class="form-l has-sub">
  268. <div class="main-name">单亩用量</div>
  269. <div class="sub-name">(亩数:药剂)</div>
  270. </div>
  271. <div class="form-r input-box text-center">
  272. <el-input
  273. v-model="domain.muUsage2"
  274. style="width: 100%"
  275. placeholder="请输入"
  276. />
  277. </div>
  278. </div>
  279. </div>
  280. <div class="input-box mark-box">
  281. <el-input
  282. v-model="domain.remark"
  283. style="width: 100%"
  284. placeholder="备注:用药注意事项"
  285. />
  286. </div>
  287. <div class="action-btn">
  288. <el-button
  289. class="btn delete-btn"
  290. @click.prevent="removeDomain(prescriptionI, domain)"
  291. >
  292. 删除
  293. </el-button>
  294. <el-button
  295. type="default"
  296. class="btn"
  297. @click.prevent="resetItemForm(prescriptionI, index)"
  298. >
  299. 重置
  300. </el-button>
  301. </div>
  302. </div>
  303. </el-form-item>
  304. </div>
  305. </div>
  306. </el-form-item>
  307. </div>
  308. </div>
  309. <div class="farm-card progress" v-else>
  310. <div class="situation-description">
  311. <div class="description-title">状况描述</div>
  312. <div class="description-content">
  313. <el-input
  314. v-model="situationDescription"
  315. type="textarea"
  316. :rows="3"
  317. placeholder="请输入目前农场状况"
  318. class="description-textarea"
  319. />
  320. <div class="upload-section">
  321. <el-button class="upload-btn" @click="handleUploadImage">
  322. <el-icon><Upload /></el-icon>
  323. 上传图片
  324. </el-button>
  325. <div class="upload-tip">上传图片,专家诊断更清晰</div>
  326. </div>
  327. </div>
  328. </div>
  329. </div>
  330. <div class="farm-card map-content" v-if="false">
  331. <!-- <div class="farm-card map-content" v-if="!(curRole==1 && isAdd)"> -->
  332. <div class="card-title">执行农事区域</div>
  333. <div class="info-content">
  334. <div class="area-select">
  335. 执行分区:
  336. <span class="block"></span>
  337. <el-select
  338. popper-class="v-select-popper-ns"
  339. v-model="regionId"
  340. placeholder="请选择分区"
  341. style="width: 160px"
  342. @change="changeRegion"
  343. >
  344. <el-option
  345. v-for="(area, index) in areaList"
  346. :key="index"
  347. :label="area.name"
  348. :value="area.id"
  349. >
  350. </el-option>
  351. </el-select>
  352. </div>
  353. <div class="area-select">
  354. 服务亩数:
  355. <span class="block"></span>{{ serveArea }}
  356. </div>
  357. <div class="bottom-map" ref="areaRef"></div>
  358. <div>
  359. <div class="check-btn">
  360. <el-checkbox v-model="checkedArea" @change="handleArea" label="全选" size="large" />
  361. </div>
  362. </div>
  363. </div>
  364. </div>
  365. <div class="submit-btn" v-if="!isAdd">
  366. <div class="btn second" @click="handleIgnore">忽略</div>
  367. <div class="btn" @click.prevent="submitForm(formRef)">下发农事</div>
  368. </div>
  369. <div class="submit-btn" v-if="isAdd && farmProgress === 0">
  370. <div class="btn second">取消</div>
  371. <div class="btn" @click.prevent="submitForm(formRef)">确定新增</div>
  372. </div>
  373. <div v-if="isAdd && farmProgress === 1">
  374. <div class="expert-diagnosis-btn" @click="handleExpertDiagnosis">邀请专家诊断</div>
  375. </div>
  376. </el-form>
  377. </div>
  378. </div>
  379. <popup v-model:show="showTaskPopup" round class="task-tips-popup">
  380. <template v-if="taskPopupType === 'warning'">
  381. <img class="create-farm-icon" src="@/assets/img/home/create-farm-icon.png" alt="" />
  382. <div class="create-farm-text">
  383. <div>您确认忽略 <span class="main-text">{{ detailData?.farmName }}</span> 的 <span class="main-text">{{ detailData?.farmWorkName }}</span> 农事吗</div>
  384. </div>
  385. </template>
  386. <template v-else>
  387. <img class="farm-check-icon" src="@/assets/img/home/right.png" alt="">
  388. <div class="create-farm-text success-text">农事已下发成功</div>
  389. </template>
  390. <div class="create-farm-btn" @click="handlePopupBtn">{{ taskPopupType === 'warning' ? '确认忽略' : '我知道了' }}</div>
  391. </popup>
  392. </template>
  393. <script setup>
  394. import { onActivated, ref, reactive, onDeactivated, computed, onMounted } from "vue";
  395. import { useRouter, useRoute } from "vue-router";
  396. import { ElMessage } from "element-plus";
  397. import customHeader from "@/components/customHeader.vue";
  398. import NewFarmMap from "./newFarmMap";
  399. import { useStore } from "vuex";
  400. import { Popup } from "vant";
  401. import farmSteps from "@/components/farmSteps.vue";
  402. import dayjs from "dayjs";
  403. const store = useStore();
  404. const router = useRouter();
  405. const route = useRoute();
  406. // 角色
  407. // const curRole = store.state.app.curRole
  408. const curRole = 0
  409. const gardenId = ref(null);
  410. const actionType = ref([]);
  411. const isAdd = ref(false)
  412. const showTaskPopup = ref(false);
  413. const taskPopupType = ref('warning');
  414. isAdd.value = route.query.isAdd ? true : false
  415. onMounted(() => {
  416. const id = route.query.id;
  417. if (id) {
  418. getDetail(id);
  419. }
  420. window.scrollTo(0, 0);
  421. getFarmWorkNameList();
  422. getFarmWorkIndexNameList();
  423. if (route.query.data) {
  424. actionType.value = JSON.parse(route.query.data);
  425. } else {
  426. actionType.value = ["生长异常"];
  427. }
  428. dynamicValidateForm.prescriptionList = actionType.value.map((name) => ({
  429. name,
  430. pesticideFertilizerList: [
  431. {
  432. key: 1,
  433. typeName: "",
  434. muUsage: "",
  435. muUsage2: "",
  436. ratio: "",
  437. ratio2: "",
  438. remark: "",
  439. },
  440. ],
  441. }));
  442. if (!(curRole==1 && isAdd.value)) {
  443. const point = store.state.home.miniUserLocationPoint;
  444. // newFarmMap.initMap(point, areaRef.value);
  445. // eventBus.on("editNsMap:areaVal", getArea);
  446. gardenId.value = route.query.gardenId;
  447. // getAreaList(() => {
  448. // newFarmMap.initArea(areaList.value);
  449. // });
  450. }
  451. getWarningMsg();
  452. });
  453. onDeactivated(() => {
  454. // areaRef.value && newFarmMap.destroyMap();
  455. resetForm(formRef.value);
  456. });
  457. const detailData = ref({});
  458. const getDetail = (id) => {
  459. VE_API.z_farm_work_record.getDetail({ id }).then(({ data }) => {
  460. const res = data[0];
  461. detailData.value = res;
  462. dynamicValidateForm.executeDate = res.executeDate;
  463. dynamicValidateForm.usageMode = res.usageMode;
  464. res.prescriptionList.forEach(item => {
  465. item.pesticideFertilizerList.forEach(pesticide => {
  466. pesticide.typeName = item.name;
  467. });
  468. });
  469. dynamicValidateForm.prescriptionList = res.prescriptionList;
  470. });
  471. };
  472. function handleIgnore() {
  473. taskPopupType.value = 'warning';
  474. showTaskPopup.value = true;
  475. }
  476. function handlePopupBtn() {
  477. showTaskPopup.value = false;
  478. if (taskPopupType.value === 'warning') {
  479. // 确认忽略
  480. }
  481. }
  482. const resetForm = (formEl) => {
  483. if (!formEl) return;
  484. formEl.resetFields();
  485. serveArea.value = null;
  486. regionId.value = null;
  487. };
  488. // 表单
  489. const formRef = ref();
  490. const dynamicValidateForm = reactive({
  491. farmWorkName: "",
  492. conditionRate: "",
  493. purpose: "",
  494. executeDate: dayjs().format("YYYY-MM-DD"),
  495. checkDay: "",
  496. usageMode: "",
  497. prescriptionList: [
  498. {
  499. name: "",
  500. pesticideFertilizerList: [
  501. {
  502. key: 1,
  503. typeName: "",
  504. muUsage: "",
  505. muUsage2: "",
  506. ratio: "",
  507. ratio2: "",
  508. remark: "",
  509. },
  510. ],
  511. },
  512. ],
  513. });
  514. const rules = {
  515. farmWorkName: [
  516. {
  517. required: true,
  518. message: "请输入农事名称",
  519. trigger: "blur",
  520. },
  521. ],
  522. conditionRate: [
  523. {
  524. required: false,
  525. message: "请输入触发条件",
  526. trigger: "blur",
  527. },
  528. ],
  529. executeDate: [
  530. {
  531. required: false,
  532. message: "请选择执行时间",
  533. trigger: "blur",
  534. },
  535. ],
  536. checkDay: [
  537. {
  538. required: true,
  539. message: "请选择复核时间",
  540. trigger: "blur",
  541. },
  542. ],
  543. };
  544. const formatIndex = (index) => {
  545. return String(index + 1).padStart(2, "0");
  546. };
  547. const addDomain = (parentIndex) => {
  548. dynamicValidateForm.prescriptionList[parentIndex].pesticideFertilizerList.unshift({
  549. key: Date.now(),
  550. muUsage: "",
  551. muUsage2: "",
  552. ratio: "",
  553. ratio2: "",
  554. remark: "",
  555. });
  556. };
  557. let pesticideFertilizersOptions = ref([
  558. // {
  559. // id: 'null',
  560. // name: "芸苔素内酯 15000倍",
  561. // typeName: "30",
  562. // defaultRatio: null,
  563. // defaultDroneRatio: null,
  564. // unit: 0,
  565. // defaultName: "调节",
  566. // },
  567. {
  568. brand: "天润美满",
  569. capacity: 1000,
  570. count: null,
  571. defaultDroneRatio: null,
  572. defaultName: "生物活性酶",
  573. defaultRatio: null,
  574. ftl: "",
  575. id: "185",
  576. name: "生物活性酶",
  577. pesticideFertilizerCode: "1185",
  578. price: 220.0,
  579. processUnit: "",
  580. typeId: 1,
  581. typeName: "调节",
  582. unit: "ml",
  583. unitUsage: null,
  584. unitWaterAmount: null,
  585. usageModeList: ["叶面施"],
  586. },
  587. {
  588. brand: "",
  589. capacity: null,
  590. count: null,
  591. defaultDroneRatio: null,
  592. defaultName: "矮壮素",
  593. defaultRatio: null,
  594. ftl: "",
  595. id: "145",
  596. name: "矮壮素",
  597. pesticideFertilizerCode: "1145",
  598. price: null,
  599. processUnit: "",
  600. typeId: 1,
  601. typeName: "调节",
  602. unit: "ml",
  603. unitUsage: null,
  604. unitWaterAmount: null,
  605. usageModeList: ["叶面施"],
  606. },
  607. ]);
  608. VE_API.z_farm_work_order.pesticideFertilizersList().then(({ data }) => {
  609. pesticideFertilizersOptions.value = data;
  610. });
  611. const allUsageMode = ref(null);
  612. const allUsageModeList = ["叶面施", "根部施", "人工农事"];
  613. // 农事名称列表
  614. const farmWorkIndexNameList = ref([
  615. "片区拔节率",
  616. "园区花蕾率",
  617. "单树花蕾率",
  618. "片区雄穗抽出率",
  619. "园区花量大率",
  620. "单树花量大率",
  621. "片区分蘖率",
  622. ]);
  623. function getFarmWorkIndexNameList() {
  624. farmWorkIndexNameList.value = [
  625. "片区拔节率",
  626. "园区花蕾率",
  627. "单树花蕾率",
  628. "片区雄穗抽出率",
  629. "园区花量大率",
  630. "单树花量大率",
  631. "片区分蘖率",
  632. ];
  633. // VE_API.farm.fetchFarmWorkIndexNameList().then(({data}) => {
  634. // farmWorkIndexNameList.value = data
  635. // })
  636. }
  637. // 触发指标列表
  638. const farmWorkNameList = ref([]);
  639. function getFarmWorkNameList() {
  640. // VE_API.farm.fetchFarmWorkNameList().then(({data}) => {
  641. // farmWorkNameList.value = data
  642. // })
  643. }
  644. // 预警文字信息
  645. const warningMsg = ref("");
  646. const getWarningMsg = () => {
  647. // VE_API.farm.getFarmWorkWarningMsg({farmId: gardenId.value}).then(({data}) => {
  648. // warningMsg.value = data
  649. // })
  650. };
  651. /**
  652. * 选择药肥的时候修改订单中药肥pesticideFertilizerId 以外其他数据
  653. * @param index
  654. */
  655. const handlePesticideFertilizerChange = (parentIndex, index) => {
  656. let obj = pesticideFertilizersOptions.value.filter(
  657. (item) =>
  658. dynamicValidateForm.prescriptionList[parentIndex].pesticideFertilizerList[index].pesticideFertilizerId ===
  659. item.id
  660. )[0];
  661. dynamicValidateForm.prescriptionList[parentIndex].pesticideFertilizerList[index] = {
  662. ...dynamicValidateForm.prescriptionList[parentIndex].pesticideFertilizerList[index],
  663. typeName: obj.typeName,
  664. unit: obj.unit,
  665. defaultRatio: obj.defaultRatio,
  666. usageModeList: obj.usageModeList,
  667. ratio: obj.defaultRatio,
  668. defaultName: obj.defaultName,
  669. pesticideFertilizerName: obj.name,
  670. pesticideFertilizerCode: obj.pesticideFertilizerCode,
  671. };
  672. };
  673. const removeDomain = (parentIndex, item) => {
  674. const index = dynamicValidateForm.prescriptionList[parentIndex].pesticideFertilizerList.indexOf(item);
  675. if (index !== -1) {
  676. dynamicValidateForm.prescriptionList[parentIndex].pesticideFertilizerList.splice(index, 1);
  677. }
  678. };
  679. const resetItemForm = (parentIndex, index) => {
  680. dynamicValidateForm.prescriptionList[parentIndex].pesticideFertilizerList[index] = {
  681. typeName: "",
  682. muUsage: "",
  683. muUsage2: "",
  684. ratio: "",
  685. ratio2: "",
  686. remark: "",
  687. };
  688. };
  689. const submitForm = (formEl) => {
  690. if (!formEl) return;
  691. formEl.validate((valid) => {
  692. if (valid) {
  693. taskPopupType.value = 'success';
  694. showTaskPopup.value = true;
  695. // router.push({
  696. // path: "/completed_work",
  697. // query: {
  698. // id: 1,
  699. // status: 1,
  700. // },
  701. // });
  702. // submit();
  703. } else {
  704. console.log("error submit!");
  705. }
  706. });
  707. };
  708. const submit = () => {
  709. let executeBlueZones = null
  710. if (!(curRole==1 && isAdd.value)) {
  711. executeBlueZones = newFarmMap.getSelectedBlueRegion();
  712. }
  713. // if (!executeBlueZones || !executeBlueZones.length) {
  714. // ElMessage({
  715. // message: "请选择执行区域",
  716. // type: "warning",
  717. // });
  718. // return false
  719. // }
  720. console.log("dynamicValidateForm.prescriptionList", dynamicValidateForm.prescriptionList);
  721. // 检查药物所有项是否都包含特定的字段
  722. // const hasRequiredFields = dynamicValidateForm.prescriptionList.every(item => {
  723. // return item.pesticideFertilizerList.every(domain => {
  724. // const hasPesticideFertilizerCode = 'pesticideFertilizerCode' in domain
  725. // const hasMuUsage = 'muUsage' in domain;
  726. // const hasRatio = 'ratio' in domain;
  727. // const isMuUsageValid = domain.muUsage !== '';
  728. // const isRatioValid = domain.ratio ? true : false;
  729. // return hasPesticideFertilizerCode && hasMuUsage && hasRatio && isMuUsageValid && isRatioValid
  730. // });
  731. // })
  732. // if (!hasRequiredFields) {
  733. // ElMessage({
  734. // message: "请完善药物信息",
  735. // type: "warning",
  736. // });
  737. // return false
  738. // }
  739. // const flattenedDomains = flattenDomains(dynamicValidateForm.prescription)
  740. const data = {
  741. ...dynamicValidateForm,
  742. // prescription: flattenedDomains,
  743. farmWorkType: farmWorkTypeVal.value,
  744. farmId: gardenId.value,
  745. regionId: regionId.value,
  746. executeBlueZones,
  747. // weatherWarningMsg: warningMsg.value,
  748. // allUsageMode: allUsageMode.value,
  749. };
  750. console.log("ddddaaaaa", data);
  751. // 新增农事
  752. VE_API.farm.saveFarmWork(data).then(({ code }) => {
  753. if (code === 0) {
  754. ElMessage({
  755. message: "保存成功",
  756. type: "success",
  757. });
  758. setTimeout(() => {
  759. // router.go(-1);
  760. router.replace("/expert_album?reload=true");
  761. }, 500);
  762. }
  763. });
  764. // const data = {
  765. // orderId: props.prescriptioData.orderId,
  766. // orderStatus: 1,
  767. // pesticideFertilizers: dynamicValidateForm.domains,
  768. // };
  769. // VE_API.order.confirm(data).then(({ code }) => {
  770. // if (code == 0) {
  771. // console.log('专家下发处方成功');
  772. // eventBus.emit('discover:submitForm')
  773. // window.location.reload()
  774. // }
  775. // });
  776. };
  777. const farmWorkTypeVal = computed(() => {
  778. const valueMap = {
  779. 生长异常: 1,
  780. 病虫异常: 3,
  781. 营养农事: 2,
  782. };
  783. if (actionType.value.length === 1) {
  784. return valueMap[actionType.value[0]] || null; // 如果只有一个元素,返回对应的值,否则返回 null
  785. } else {
  786. return 1;
  787. }
  788. });
  789. function flattenDomains(data) {
  790. return data.reduce((acc, item) => {
  791. return acc.concat(item.pesticideFertilizerList);
  792. }, []);
  793. }
  794. // 地图
  795. const areaRef = ref(null);
  796. let newFarmMap = new NewFarmMap();
  797. const serveArea = ref(null);
  798. // 农场分区列表
  799. const areaList = ref([]);
  800. const regionId = ref(null);
  801. const farmProgress = ref(0)
  802. // 状况描述相关数据
  803. const situationDescription = ref('')
  804. // 切换分区
  805. const changeRegion = (e) => {
  806. checkedArea.value = false;
  807. newFarmMap.getBlueRegion({ gardenId: gardenId.value, regionId: e }, () => {
  808. // newFarmMap.setBlueRegion([{id: "ws0y1me7h94u"}, {id: "ws0y1me545tg"}])
  809. // serveArea.value = "3.72亩"
  810. });
  811. };
  812. // 所选蓝色分区的面积
  813. const getArea = (val) => {
  814. serveArea.value = val.toFixed(2) + "亩";
  815. };
  816. const checkedArea = ref(false);
  817. const handleArea = (e) => {
  818. newFarmMap.toggleAllArea(e);
  819. };
  820. // 处理上传图片
  821. const handleUploadImage = () => {
  822. // 这里可以添加上传图片的逻辑
  823. console.log('上传图片');
  824. };
  825. // 处理邀请专家诊断
  826. const handleExpertDiagnosis = () => {
  827. // 这里可以添加邀请专家诊断的逻辑
  828. console.log('邀请专家诊断');
  829. };
  830. </script>
  831. <style lang="scss" scoped>
  832. .new-farming-page {
  833. height: 100vh;
  834. position: relative;
  835. overflow: auto;
  836. font-size: 14px;
  837. background: #f2f3f5;
  838. ::v-deep {
  839. .custom-header {
  840. position: fixed;
  841. top: 0;
  842. padding-bottom: 1px;
  843. }
  844. }
  845. .step-wrap {
  846. padding: 12px 0;
  847. }
  848. .box-wrap {
  849. background: #fff;
  850. padding: 10px;
  851. border-radius: 8px;
  852. }
  853. .new-farming-content {
  854. margin: 41px 0 62px 0;
  855. padding: 4px 12px 8px 12px;
  856. width: 100%;
  857. box-sizing: border-box;
  858. // ::v-deep {
  859. // .el-select__input {
  860. // color: #2199F8;
  861. // }
  862. // .el-select__wrapper {
  863. // color: #2199F8;
  864. // min-height: 30px;
  865. // line-height: 28px;
  866. // box-shadow: 0 0 0 1px rgba(33, 153, 248, 0.3) inset;
  867. // }
  868. // .el-select__caret {
  869. // color: #2199F8;
  870. // }
  871. // .el-select__placeholder {
  872. // color: #2199F8;
  873. // }
  874. // .el-radio {
  875. // margin-right: 16px;
  876. // }
  877. // .el-input__wrapper {
  878. // box-shadow: 0 0 0 1px rgba(33, 153, 248, 0.3) inset;
  879. // }
  880. // .el-input__prefix {
  881. // color: #2199F8;
  882. // }
  883. // .el-input__inner {
  884. // color: #2199F8;
  885. // --el-input-placeholder-color: rgba(33, 153, 248, 0.43);
  886. // }
  887. // .el-tag.el-tag--info {
  888. // --el-tag-text-color: #2199F8;
  889. // --el-tag-bg-color: rgba(33, 153, 248, 0.1);
  890. // }
  891. // }
  892. .farm-info {
  893. color: rgba(0, 0, 0, 0.6);
  894. font-size: 14px;
  895. margin-top: 14px;
  896. .info-title {
  897. display: flex;
  898. align-items: center;
  899. justify-content: space-between;
  900. color: rgba(41, 41, 41, 0.3);
  901. .info-more {
  902. display: flex;
  903. align-items: center;
  904. }
  905. }
  906. }
  907. .farm-photo {
  908. margin-top: 10px;
  909. .photo-list {
  910. display: flex;
  911. align-items: center;
  912. width: 100%;
  913. overflow: auto;
  914. padding-bottom: 10px;
  915. .photo-item {
  916. width: 92px;
  917. height: 92px;
  918. border-radius: 8px;
  919. object-fit: cover;
  920. }
  921. .img-item + .img-item {
  922. margin-left: 12px;
  923. }
  924. }
  925. .list-text {
  926. text-align: center;
  927. color: rgba(0, 0, 0, 0.5);
  928. padding-top: 2px;
  929. }
  930. }
  931. .submit-btn {
  932. z-index: 10;
  933. position: fixed;
  934. bottom: 0px;
  935. left: 0;
  936. width: 100%;
  937. display: flex;
  938. align-items: center;
  939. justify-content: space-between;
  940. padding: 12px;
  941. background: #fff;
  942. box-sizing: border-box;
  943. box-shadow: 0 4px 4px rgba(0, 0, 0, 0.4);
  944. border-top: 1px solid rgba(0, 0, 0, 0.1);
  945. .btn {
  946. height: 40px;
  947. border-radius: 25px;
  948. line-height: 40px;
  949. width: 110px;
  950. text-align: center;
  951. background: linear-gradient(180deg, #70BFFE, #2199F8);
  952. color: #FFFFFF;
  953. font-size: 14px;
  954. &.second {
  955. background: #FFFFFF;
  956. border: 1px solid rgba(153, 153, 153, 0.5);
  957. color: #666666;
  958. }
  959. }
  960. .btn + .btn {
  961. margin-left: 12px;
  962. }
  963. }
  964. }
  965. .card-title {
  966. font-size: 16px;
  967. font-weight: bold;
  968. color: #000;
  969. display: flex;
  970. align-items: center;
  971. // justify-content: space-between;
  972. .add-tag {
  973. font-size: 12px;
  974. color: #2199f8;
  975. padding: 4px 8px;
  976. background: rgba(33, 153, 248, 0.16);
  977. border-radius: 20px;
  978. font-weight: normal;
  979. height: 25px;
  980. line-height: 25px;
  981. }
  982. .type-tag {
  983. margin-left: 5px;
  984. font-size: 12px;
  985. color: #000000;
  986. padding: 0 10px;
  987. background: rgba(119, 119, 119, 0.1);
  988. border-radius: 20px;
  989. font-weight: normal;
  990. height: 26px;
  991. line-height: 26px;
  992. }
  993. }
  994. .pb-12 {
  995. padding-bottom: 12px;
  996. }
  997. .farm-card {
  998. background: #ffffff;
  999. border-radius: 8px;
  1000. padding: 12px 12px 0 12px;
  1001. width: 100%;
  1002. box-sizing: border-box;
  1003. margin-top: 10px;
  1004. color: rgba(0, 0, 0, 0.4);
  1005. &.progress{
  1006. display: flex;
  1007. align-items: center;
  1008. padding: 12px;
  1009. .progress-title{
  1010. margin-right: 12px;
  1011. }
  1012. ::v-deep{
  1013. .el-radio{
  1014. margin-right: 10px;
  1015. }
  1016. }
  1017. }
  1018. &.map-content {
  1019. margin-top: 12px;
  1020. }
  1021. &.prescription-content {
  1022. padding: 12px;
  1023. }
  1024. }
  1025. .usage-mode-wrap {
  1026. padding: 0 12px;
  1027. margin-top: 12px;
  1028. .info-content {
  1029. padding-top: 14px;
  1030. padding-bottom: 1px;
  1031. }
  1032. .el-form-item--default {
  1033. margin-bottom: 0;
  1034. }
  1035. }
  1036. ::v-deep {
  1037. .el-form-item__label {
  1038. height: 30px;
  1039. line-height: 30px;
  1040. color: rgba(0, 0, 0, 0.4);
  1041. }
  1042. .el-form-item.is-required:not(.is-no-asterisk).asterisk-left>.el-form-item__label:before {
  1043. display: none;
  1044. }
  1045. }
  1046. .info-content {
  1047. padding: 10px 0;
  1048. position: relative;
  1049. .condition-wrap {
  1050. display: flex;
  1051. align-items: center;
  1052. width: 100%;
  1053. .symbol {
  1054. width: 10px;
  1055. // text-align: center;
  1056. // padding: 0 4px;
  1057. }
  1058. }
  1059. .item-input {
  1060. // width: 60%;
  1061. min-width: 140px;
  1062. max-width: 240px;
  1063. }
  1064. .recheck-text {
  1065. padding-left: 6px;
  1066. }
  1067. .info-item {
  1068. display: flex;
  1069. justify-content: space-between;
  1070. align-items: center;
  1071. width: 100%;
  1072. }
  1073. .info-item + .info-item {
  1074. margin-top: 12px;
  1075. }
  1076. .bottom-map {
  1077. width: 100%;
  1078. height: 250px;
  1079. clip-path: inset(0px round 8px);
  1080. }
  1081. .check-btn {
  1082. position: absolute;
  1083. bottom: 16px;
  1084. right: 6px;
  1085. background: rgba(0, 0, 0, 0.6);
  1086. padding: 0 8px;
  1087. border-radius: 8px;
  1088. ::v-deep {
  1089. .el-checkbox {
  1090. color: #fff;
  1091. }
  1092. }
  1093. }
  1094. .area-select {
  1095. padding-bottom: 12px;
  1096. .block {
  1097. width: 12px;
  1098. display: inline-block;
  1099. }
  1100. }
  1101. }
  1102. ::v-deep {
  1103. .el-form-item--default {
  1104. margin-bottom: 8px;
  1105. &.text-item {
  1106. margin-bottom: 2px;
  1107. .el-form-item__content {
  1108. line-height: 24px;
  1109. }
  1110. .el-form-item__label {
  1111. height: 24px;
  1112. line-height: 24px;
  1113. }
  1114. }
  1115. }
  1116. }
  1117. .sub-title {
  1118. display: flex;
  1119. align-items: center;
  1120. justify-content: space-between;
  1121. color: rgba(0, 0, 0, 0.6);
  1122. font-size: 14px;
  1123. .add-tag {
  1124. font-size: 12px;
  1125. color: #2199f8;
  1126. padding: 0 8px;
  1127. border: 1px solid #2199F8;
  1128. border-radius: 5px;
  1129. font-weight: normal;
  1130. height: 28px;
  1131. line-height: 28px;
  1132. }
  1133. }
  1134. .recipe-item {
  1135. width: 100%;
  1136. .recipe-form {
  1137. padding-top: 8px;
  1138. ::v-deep {
  1139. .el-form-item {
  1140. &:last-child {
  1141. margin-bottom: 0;
  1142. }
  1143. }
  1144. }
  1145. }
  1146. .box-item {
  1147. display: flex;
  1148. align-items: center;
  1149. justify-content: space-between;
  1150. color: rgba(0, 0, 0, 0.4);
  1151. .r-text {
  1152. width: 140px;
  1153. text-align: center;
  1154. }
  1155. .form-r {
  1156. width: 60%;
  1157. min-width: 140px;
  1158. max-width: 240px;
  1159. }
  1160. }
  1161. .form-box {
  1162. border: 1px solid rgba(33, 153, 248, 0.8);
  1163. border-radius: 8px;
  1164. padding: 20px 10px;
  1165. width: 100%;
  1166. position: relative;
  1167. // background: rgb(209, 235, 255, 0.3);
  1168. // margin-bottom: 12px;
  1169. .form-index {
  1170. position: absolute;
  1171. left: 0;
  1172. top: 0;
  1173. padding: 0 6px;
  1174. background: #2199F8;
  1175. border-radius: 4px 0 4px 0;
  1176. height: 18px;
  1177. line-height: 18px;
  1178. font-size: 12px;
  1179. color: #fff;
  1180. }
  1181. .input-box {
  1182. &.mark-box {
  1183. padding: 8px 0 12px 0;
  1184. }
  1185. }
  1186. .text-center {
  1187. ::v-deep {
  1188. .el-input__inner {
  1189. text-align: center;
  1190. }
  1191. }
  1192. }
  1193. .action-btn {
  1194. display: flex;
  1195. justify-content: flex-end;
  1196. .btn {
  1197. color: #8F8F8F;
  1198. border-radius: 25px;
  1199. padding: 5px 30px;
  1200. }
  1201. .delete-btn {
  1202. color: rgba(255, 89, 89, 0.9);
  1203. background: #fff;
  1204. border: 1px solid rgba(255, 89, 89, 0.9);
  1205. }
  1206. }
  1207. .btn-group {
  1208. padding-top: 12px;
  1209. }
  1210. .sub-item {
  1211. padding-left: 10px;
  1212. .has-sub {
  1213. display: flex;
  1214. flex-direction: column;
  1215. align-items: center;
  1216. .main-name {
  1217. line-height: 20px;
  1218. }
  1219. .sub-name {
  1220. font-size: 10px;
  1221. color: rgba(129, 129, 129, 0.5);
  1222. line-height: 14px;
  1223. }
  1224. }
  1225. .colunm-sub {
  1226. display: flex;
  1227. align-items: center;
  1228. .sub-name {
  1229. font-size: 10px;
  1230. color: rgba(129, 129, 129, 0.5);
  1231. }
  1232. }
  1233. .r-text {
  1234. width: 132px;
  1235. text-align: center;
  1236. font-size: 14px;
  1237. color: #474747;
  1238. }
  1239. .price {
  1240. ::v-deep {
  1241. .el-input__wrapper {
  1242. box-shadow: 0 0 0 1px rgba(33, 153, 248, 0.3) inset;
  1243. }
  1244. .el-input__inner {
  1245. color: #2199f8;
  1246. }
  1247. }
  1248. }
  1249. }
  1250. .form-title {
  1251. font-size: 14px;
  1252. padding-top: 6px;
  1253. color: #000;
  1254. font-weight: 600;
  1255. }
  1256. .box-item + .box-item {
  1257. margin-top: 8px;
  1258. }
  1259. }
  1260. .form-box + .form-box {
  1261. margin-top: 8px;
  1262. }
  1263. .usageMode-wrap {
  1264. padding-top: 8px;
  1265. }
  1266. }
  1267. // 状况描述样式
  1268. .situation-description {
  1269. width: 100%;
  1270. .description-title {
  1271. font-size: 16px;
  1272. font-weight: bold;
  1273. color: #000;
  1274. margin-bottom: 12px;
  1275. }
  1276. .description-content {
  1277. .description-textarea {
  1278. margin-bottom: 10px;
  1279. width: 100%;
  1280. }
  1281. .upload-section {
  1282. .upload-btn {
  1283. width: 112px;
  1284. height: 32px;
  1285. border-radius: 3px;
  1286. border: 1px solid #e0e0e0;
  1287. background: #fff;
  1288. color: #000;
  1289. font-size: 14px;
  1290. display: flex;
  1291. align-items: center;
  1292. justify-content: center;
  1293. margin-bottom: 8px;
  1294. .el-icon {
  1295. margin-right: 6px;
  1296. }
  1297. }
  1298. .upload-tip {
  1299. font-size: 12px;
  1300. color: #999;
  1301. line-height: 1.4;
  1302. }
  1303. }
  1304. }
  1305. }
  1306. // 专家诊断按钮样式
  1307. .expert-diagnosis-btn {
  1308. width: 180px;
  1309. height: 40px;
  1310. border-radius: 24px;
  1311. background: linear-gradient(180deg, #70BFFE 0%, #2199F8 100%);
  1312. color: #FFFFFF;
  1313. display: flex;
  1314. align-items: center;
  1315. justify-content: center;
  1316. margin: 30px auto 0;
  1317. }
  1318. }
  1319. .task-tips-popup {
  1320. width: 75%;
  1321. padding: 28px 28px 20px;
  1322. display: flex;
  1323. flex-direction: column;
  1324. align-items: center;
  1325. justify-content: center;
  1326. .create-farm-icon{
  1327. width: 40px;
  1328. height: 40px;
  1329. margin-bottom: 12px;
  1330. }
  1331. .farm-check-icon{
  1332. width: 68px;
  1333. height: 68px;
  1334. margin-bottom: 12px;
  1335. }
  1336. .create-farm-text{
  1337. font-size: 20px;
  1338. font-weight: 500;
  1339. line-height: 40px;
  1340. margin-bottom: 32px;
  1341. text-align: center;
  1342. &.success-text{
  1343. font-size: 23px;
  1344. font-weight: 400;
  1345. }
  1346. }
  1347. .main-text {
  1348. color: #2199F8;
  1349. }
  1350. .create-farm-btn{
  1351. width: 100%;
  1352. box-sizing: border-box;
  1353. padding: 8px;
  1354. border-radius: 25px;
  1355. font-size: 16px;
  1356. background: #2199F8;
  1357. color: #fff;
  1358. text-align: center;
  1359. }
  1360. }
  1361. </style>