completedWork.vue 45 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394959697989910010110210310410510610710810911011111211311411511611711811912012112212312412512612712812913013113213313413513613713813914014114214314414514614714814915015115215315415515615715815916016116216316416516616716816917017117217317417517617717817918018118218318418518618718818919019119219319419519619719819920020120220320420520620720820921021121221321421521621721821922022122222322422522622722822923023123223323423523623723823924024124224324424524624724824925025125225325425525625725825926026126226326426526626726826927027127227327427527627727827928028128228328428528628728828929029129229329429529629729829930030130230330430530630730830931031131231331431531631731831932032132232332432532632732832933033133233333433533633733833934034134234334434534634734834935035135235335435535635735835936036136236336436536636736836937037137237337437537637737837938038138238338438538638738838939039139239339439539639739839940040140240340440540640740840941041141241341441541641741841942042142242342442542642742842943043143243343443543643743843944044144244344444544644744844945045145245345445545645745845946046146246346446546646746846947047147247347447547647747847948048148248348448548648748848949049149249349449549649749849950050150250350450550650750850951051151251351451551651751851952052152252352452552652752852953053153253353453553653753853954054154254354454554654754854955055155255355455555655755855956056156256356456556656756856957057157257357457557657757857958058158258358458558658758858959059159259359459559659759859960060160260360460560660760860961061161261361461561661761861962062162262362462562662762862963063163263363463563663763863964064164264364464564664764864965065165265365465565665765865966066166266366466566666766866967067167267367467567667767867968068168268368468568668768868969069169269369469569669769869970070170270370470570670770870971071171271371471571671771871972072172272372472572672772872973073173273373473573673773873974074174274374474574674774874975075175275375475575675775875976076176276376476576676776876977077177277377477577677777877978078178278378478578678778878979079179279379479579679779879980080180280380480580680780880981081181281381481581681781881982082182282382482582682782882983083183283383483583683783883984084184284384484584684784884985085185285385485585685785885986086186286386486586686786886987087187287387487587687787887988088188288388488588688788888989089189289389489589689789889990090190290390490590690790890991091191291391491591691791891992092192292392492592692792892993093193293393493593693793893994094194294394494594694794894995095195295395495595695795895996096196296396496596696796896997097197297397497597697797897998098198298398498598698798898999099199299399499599699799899910001001100210031004100510061007100810091010101110121013101410151016101710181019102010211022102310241025102610271028102910301031103210331034103510361037103810391040104110421043104410451046104710481049105010511052105310541055105610571058105910601061106210631064106510661067106810691070107110721073107410751076107710781079108010811082108310841085108610871088108910901091109210931094109510961097109810991100110111021103110411051106110711081109111011111112111311141115111611171118111911201121112211231124112511261127112811291130113111321133113411351136113711381139114011411142114311441145114611471148114911501151115211531154115511561157115811591160116111621163116411651166116711681169117011711172117311741175117611771178117911801181118211831184118511861187118811891190119111921193
  1. <template>
  2. <div class="completed-work">
  3. <custom-header name="农事详情" isGoBack @goback="handleClose"></custom-header>
  4. <div class="work-content">
  5. <!-- <div class="step-wrap" v-show="query.status !== 'warning'">
  6. <farm-steps :currentStep="currentStep" />
  7. </div> -->
  8. <div class="content-status">
  9. <div class="status-l">
  10. <div class="stauts-text">待完成</div>
  11. <div class="stauts-sub-text" v-if="detailData?.executeDeadlineDate && !detailData?.expectedExecuteDate">
  12. 截止到 <span class="time-text">{{ detailData?.executeDeadlineDate }}</span>
  13. </div>
  14. <div class="stauts-sub-text" v-if="detailData?.expectedExecuteDate">
  15. <template v-if="daysDiff > 0">
  16. 距离执行时间还剩 <span class="time-text">{{ daysDiff }} 天</span>
  17. </template>
  18. <template v-else-if="daysDiff === 0">
  19. 执行时间为今天
  20. </template>
  21. <template v-else>
  22. 执行时间已过
  23. </template>
  24. </div>
  25. </div>
  26. <!-- <template v-if="query.status !== 'warning'">
  27. <div class="status-r" v-if="curRole == 0">{{ status === 0 ? "设置提醒" : "去评价" }}</div>
  28. <div class="status-r" v-if="curRole == 1">{{ status === 0 ? "提醒执行" : "提醒复核" }}</div>
  29. <div class="status-r" v-if="curRole == 2">{{ status === 0 ? "提醒执行" : "提醒复核" }}</div>
  30. </template> -->
  31. </div>
  32. <div class="work-wrap" v-if="query?.farmWorkOrderId || detailData?.flowStatus === 4">
  33. <div class="box-wrap executor-info" v-if="query.status === 'warning' || curRole == 0 || curRole == 2">
  34. <!-- <div class="executor-title">执行人</div> -->
  35. <div class="executor-content">
  36. <div class="executor-info mt-0">
  37. <div class="executor-avatar">
  38. <img
  39. 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?x-oss-process=image/resize,w_500"
  40. alt="执行人"
  41. />
  42. </div>
  43. <div class="executor-details">
  44. <div class="org-name">
  45. <span class="name">{{ quotationData.agriculturalStoreName || "--" }}</span>
  46. <span class="rating">{{
  47. quotationData.score ? quotationData.score + "分" : ""
  48. }}</span>
  49. </div>
  50. <div class="service-info">
  51. <div class="service-item">
  52. 服务品种:
  53. <span v-if="speciesList.length">
  54. <span v-for="(sp, sIdx) in speciesList" :key="sIdx">
  55. {{ sp }}<template v-if="sIdx < speciesList.length - 1">、</template>
  56. </span>
  57. </span>
  58. <span v-else>--</span>
  59. </div>
  60. <div class="service-item">
  61. 服务设备:
  62. <span v-if="equipmentList.length">
  63. <span v-for="(eq, eIdx) in equipmentList" :key="eIdx">
  64. {{ eq }}<template v-if="eIdx < equipmentList.length - 1">、</template>
  65. </span>
  66. </span>
  67. <span v-else>--</span>
  68. </div>
  69. </div>
  70. </div>
  71. </div>
  72. <div class="farm-info">
  73. <div class="info-title-wrap">
  74. <div class="sub-title">药肥费用</div>
  75. <div class="info-more">
  76. {{ pesticideCostTotal ? formatArea(pesticideCostTotal) : "--"
  77. }}<span class="unit-text">元</span>
  78. </div>
  79. </div>
  80. <div class="info-content-wrap">
  81. <price-table
  82. :prescriptionData="quotationData.prescriptionList"
  83. :area="detailData?.area"
  84. :isArrList="true"
  85. >
  86. <template #bottomContent>
  87. <div class="price-bottom">
  88. <div class="info-title-wrap">
  89. <div class="sub-title">服务费用</div>
  90. <div class="info-more">
  91. {{ detailData?.serviceMuPrice ? serviceCostTotal : "--" }}
  92. <span class="unit-text">元</span>
  93. </div>
  94. </div>
  95. <div class="price-info">
  96. <div class="info-l">
  97. 单亩价格<span class="main-text">{{
  98. detailData?.serviceMuPrice
  99. ? detailData?.serviceMuPrice + "元/亩"
  100. : "--"
  101. }}</span>
  102. </div>
  103. </div>
  104. <div class="price-total">
  105. 报价合计:<span class="main-val">
  106. {{ totalCost ? formatArea(totalCost) : "--" }} </span
  107. >元
  108. </div>
  109. </div>
  110. </template>
  111. </price-table>
  112. </div>
  113. </div>
  114. <!-- <div class="contact-buttons">
  115. <button class="contact-btn">电话联系</button>
  116. <button class="contact-btn">在线联系</button>
  117. </div> -->
  118. </div>
  119. </div>
  120. </div>
  121. <div class="work-wrap info-wrap">
  122. <div class="box-wrap farm-data">
  123. <div class="card-title">
  124. <div>{{ detailData?.farmWorkName }}<span class="type-tag">标准农事</span></div>
  125. <!-- <div class="point-wrap">
  126. <div class="point"></div>
  127. <span>2区</span>
  128. </div> -->
  129. <div class="tag-text">托管农事</div>
  130. </div>
  131. <div class="data-content">
  132. <div class="form-item">
  133. <div class="item-name">农事编号</div>
  134. <div class="item-text">{{ detailData?.code }}</div>
  135. </div>
  136. <div class="form-item">
  137. <div class="item-name">服务亩数</div>
  138. <div class="item-text">
  139. {{ detailData?.area ? formatArea(detailData?.area) + "亩" : "--" }}
  140. </div>
  141. </div>
  142. <div class="form-item">
  143. <div class="item-name">服务区域</div>
  144. <div class="item-text">{{ detailData?.serviceRegion }}</div>
  145. </div>
  146. <!-- <div class="form-item">
  147. <div class="item-name">触发条件</div>
  148. <div class="item-text">{{ detailData?.condition }}</div>
  149. </div> -->
  150. <div class="form-item" v-if="detailData?.expectedExecuteDate">
  151. <div class="item-name">执行时间</div>
  152. <div class="item-text">
  153. {{detailData?.expectedExecuteDate}}
  154. </div>
  155. </div>
  156. <div class="form-item" v-else-if="detailData?.executeDeadlineDate">
  157. <div class="item-name">截止日期</div>
  158. <div class="item-text">
  159. {{detailData?.executeDeadlineDate}}
  160. </div>
  161. </div>
  162. </div>
  163. </div>
  164. <div class="box-wrap farm-table">
  165. <div class="card-title">药物处方</div>
  166. <div class="table-item">
  167. <div class="form-item">
  168. <div class="item-name">施用方式</div>
  169. <div class="item-text">{{ detailData?.usageMode }}</div>
  170. </div>
  171. <div class="form-item">
  172. <div class="item-name">执行方式</div>
  173. <div class="item-text">
  174. {{ quotationData?.executionMethodName }}
  175. </div>
  176. </div>
  177. </div>
  178. <div class="new-wrap">
  179. <div class="new-title">
  180. <div class="title-1"><div class="table-name">药肥类型</div></div>
  181. <div class="title-2"><div class="table-name">药肥名称</div></div>
  182. <div class="title-4"><div class="table-name">药肥配比</div></div>
  183. <div class="title-5"><div class="table-name">单亩用量</div></div>
  184. </div>
  185. <div
  186. class="new-table-wrap"
  187. v-for="(prescriptionItem, prescriptionI) in detailData?.prescriptionList"
  188. :key="prescriptionI"
  189. >
  190. <div
  191. class="new-prescription"
  192. v-for="(subP, subI) in prescriptionItem.pesticideFertilizerList"
  193. :key="subI"
  194. >
  195. <div class="new-table">
  196. <div class="line-l">
  197. <div class="line-1 title-1">{{ subP.typeName }}</div>
  198. <div class="line-2">{{ subP.defaultName || subP.pesticideFertilizerName }}</div>
  199. </div>
  200. <div class="line-r">
  201. <div class="line-3">
  202. <div class="sub-line title-4">{{ quotationData.executionMethod === 1 ? subP.ratio2 : subP.ratio }}倍</div>
  203. <div class="sub-line title-5">{{ quotationData.executionMethod === 1 ? subP.muUsage2 : subP.muUsage }}{{ subP.unit }}</div>
  204. </div>
  205. </div>
  206. </div>
  207. <div class="note-text" v-if="subP.remark">{{ subP.remark }}</div>
  208. </div>
  209. </div>
  210. </div>
  211. </div>
  212. <!-- <div class="work-map">
  213. <div class="card-title">执行农事区域</div>
  214. <div class="map-content">
  215. <div class="map-dom" ref="areaRef"></div>
  216. </div>
  217. </div> -->
  218. </div>
  219. <!-- 农资,步骤:农资已执行,请求确认 -->
  220. <div class="fixed-btn-wrap" :class="{'center': !getButtonText()}" v-if="curRole == 2 && !detailData?.expectedExecuteDate">
  221. <div class="fixed-btn orange primary-text" @click="handleRemindExecuteTime" v-if="getButtonText()">提醒确认执行时间</div>
  222. <div class="fixed-btn orange" @click="selectExecuteTime">确认执行时间</div>
  223. </div>
  224. <div class="fixed-btn-wrap" :class="{'center': !getButtonText()}" v-if="curRole == 2 && detailData?.expectedExecuteDate">
  225. <div class="fixed-btn primary primary-text width-120" @click="handleExecute" v-if="getButtonText()">提醒执行</div>
  226. <div class="fixed-btn primary" @click="showOfferPopup(detailData)">上传照片</div>
  227. </div>
  228. <!-- 农资,步骤:农事已确认 -->
  229. <!-- <div class="fixed-btn-wrap" v-if="curRole == 2 && detailData?.expectedExecuteDate">
  230. <div class="fixed-btn second" @click="showPriceSheetPopup">生成报价单</div>
  231. <div class="fixed-btn" @click="handleTimelineAction(detailData)">转入农事任务</div>
  232. </div> -->
  233. </div>
  234. </div>
  235. <!-- 报价弹窗 -->
  236. <!-- <offer-popup :showPopup="showPopup" :executionData="executionData"></offer-popup> -->
  237. <!-- 服务报价单 -->
  238. <price-sheet-popup ref="priceSheetPopupRef"></price-sheet-popup>
  239. <!-- 需求发送成功 -->
  240. <popup v-model:show="showTaskPopup" round class="task-tips-popup">
  241. <template v-if="taskPopupType === 'warning'">
  242. <img class="create-farm-icon" src="@/assets/img/home/create-farm-icon.png" alt="" />
  243. <div class="create-farm-text">
  244. <div>您确认取消已发起的农事需求吗</div>
  245. </div>
  246. </template>
  247. <template v-else-if="taskPopupType === 'warningIgnore'">
  248. <img class="create-farm-icon" src="@/assets/img/home/create-farm-icon.png" alt="" />
  249. <div class="create-farm-text">
  250. <div>
  251. 您确认忽略 <span class="main-text">{{ detailData?.farmName }}</span> 的
  252. <span class="main-text">{{ detailData?.farmWorkName }}</span> 农事吗
  253. </div>
  254. </div>
  255. </template>
  256. <template v-else>
  257. <img class="farm-check-icon" src="@/assets/img/home/right.png" alt="" />
  258. <div class="create-farm-text success-text">{{ successText }}</div>
  259. </template>
  260. <div class="create-farm-btn" @click="handlePopupBtn">
  261. {{ taskPopupType === "warning" ? "确认" : taskPopupType === "warningIgnore" ? "确认忽略" : "我知道了" }}
  262. </div>
  263. </popup>
  264. <!-- 确认执行时间 -->
  265. <calendar v-model:show="showCalendar" @confirm="onConfirmExecuteTime" :min-date="minDate" :max-date="maxDate" />
  266. <!-- 上传照片弹窗 -->
  267. <review-upload-popup :key="10" v-model="showUpload" :record-id="sectionId" @success="handleSelfDone" />
  268. <!-- 新增:激活上传弹窗 -->
  269. <active-upload-popup ref="activeUploadPopupRef" @handleUploadSuccess="handleUploadSuccess"></active-upload-popup>
  270. <offer-popup ref="offerPopupRef" @uploadSuccess="handleUploadSuccess"></offer-popup>
  271. </template>
  272. <script setup>
  273. import customHeader from "@/components/customHeader.vue";
  274. import { ref, computed, onActivated, onDeactivated } from "vue";
  275. // import NewFarmMap from "./newFarmMap";
  276. import { useStore } from "vuex";
  277. import { Popup, Calendar } from "vant";
  278. import offerPopup from "@/components/popup/offerPopup.vue";
  279. import { useRouter, useRoute } from "vue-router";
  280. import farmSteps from "@/components/farmSteps.vue";
  281. import priceTable from "../agri_work/components/priceTable.vue";
  282. import priceSheetPopup from "@/components/popup/priceSheetPopup.vue";
  283. import uploadExecute from "@/views/old_mini/task_condition/components/uploadExecute.vue";
  284. import { base_img_url2 } from "@/api/config";
  285. import { ElMessage } from "element-plus";
  286. import { formatArea, formatDate } from "@/common/commonFun";
  287. import wx from "weixin-js-sdk";
  288. import reviewUploadPopup from "@/components/popup/reviewUploadPopup.vue";
  289. import FnShareSheet from "@/components/pageComponents/FnShareSheet.vue";
  290. import activeUploadPopup from "@/components/popup/activeUploadPopup.vue";
  291. import eventBus from "@/api/eventBus";
  292. const router = useRouter();
  293. const store = useStore();
  294. const query = ref({});
  295. // 角色
  296. // const curRole = store.state.app.curRole
  297. const curRole = ref(localStorage.getItem("SET_USER_CUR_ROLE"));
  298. // const curRole = 2;
  299. // 农资待生成报价单--currentStep:1;curRole:2
  300. // 农资已执行,有执行照片,请求确认--currentStep:2;curRole:2
  301. const showUpload = ref(false);
  302. const sectionId = ref(null);
  303. // 上传照片处理函数
  304. const handleUploadPhoto = ({ id }) => {
  305. showUpload.value = true;
  306. sectionId.value = id;
  307. };
  308. onDeactivated(() => {
  309. showUpload.value = false;
  310. sectionId.value = null;
  311. });
  312. const handleSelfDone = () => {
  313. VE_API.z_farm_work_record.updateFlowStatus({ id: queryRecordId.value, targetFlowStatus: 5 }).then((res) => {
  314. if (res.code === 0) {
  315. showUpload.value = false;
  316. sectionId.value = null;
  317. setTimeout(() => {
  318. router.replace({
  319. path: "/review_work",
  320. query: {
  321. miniJson: JSON.stringify({ id: queryRecordId.value, goBack: true }),
  322. },
  323. });
  324. }, 500);
  325. }
  326. });
  327. };
  328. const successText = ref("");
  329. const taskPopupActionType = ref(0);
  330. const showTaskPopup = ref(false);
  331. const taskPopupType = ref("");
  332. const handlePopupBtn = () => {
  333. showTaskPopup.value = false;
  334. if (taskPopupType.value === "warning") {
  335. // 取消发起
  336. VE_API.z_farm_work_record.updatePublicStatus({ recordId: queryRecordId.value, isPublic: 0 }).then((res) => {
  337. if (res.code === 0) {
  338. getDetail(queryRecordId.value);
  339. }
  340. });
  341. } else if (taskPopupType.value === "warningIgnore") {
  342. // 确认忽略
  343. VE_API.z_farm_work_record.ignoreFarmWorkRecord({ farmWorkRecordId: queryRecordId.value }).then((res) => {
  344. if (res.code === 0) {
  345. ElMessage.success("操作成功");
  346. router.back();
  347. }
  348. });
  349. } else {
  350. if (taskPopupActionType.value === 0) {
  351. getDetail(queryRecordId.value);
  352. } else {
  353. showUpload.value = false;
  354. sectionId.value = null;
  355. setTimeout(() => {
  356. router.replace({
  357. path: "/review_work",
  358. query: {
  359. miniJson: JSON.stringify({ id: queryRecordId.value, goBack: true }),
  360. },
  361. });
  362. }, 500);
  363. }
  364. }
  365. };
  366. const cancelDemand = () => {
  367. taskPopupType.value = "warning";
  368. showTaskPopup.value = true;
  369. };
  370. const priceSheetPopupRef = ref(null);
  371. const showPriceSheetPopup = () => {
  372. priceSheetPopupRef.value.handleShowPopup(detailData.value);
  373. };
  374. const getButtonText = () => {
  375. return agriculturalRole.value === 1 || (agriculturalRole.value === 2 && detailData.value.executorUserId != userId.value);
  376. };
  377. const offerPopupRef = ref(null);
  378. const isGoBack = ref(false);
  379. const showOfferPopup = (item) => {
  380. isGoBack.value = true;
  381. offerPopupRef.value.openPopup(item);
  382. };
  383. const handleExecute = () => {
  384. const query = {
  385. askInfo: { title: "农事提醒", content: "是否分享该农事提醒给好友" },
  386. shareText: '向您分享了一条农事执行提醒,请您尽快执行',
  387. targetUrl: `completed_work`,
  388. paramsPage: JSON.stringify({id: detailData.value.id}),
  389. imageUrl: 'https://birdseye-img.sysuimars.com/birdseye-look-mini/invite_bg.png',
  390. };
  391. wx.miniProgram.navigateTo({
  392. url: `/pages/subPages/share_page/index?pageParams=${JSON.stringify(query)}&type=sharePage`,
  393. });
  394. };
  395. const showCalendar = ref(false);
  396. const maxDate = ref(new Date());
  397. // 最小日期设置为今天,今天可以选择
  398. const minDate = new Date();
  399. const selectExecuteTime = () => {
  400. maxDate.value = new Date(detailData.value.executeDeadlineDate);
  401. showCalendar.value = true;
  402. };
  403. const handleRemindExecuteTime = () => {
  404. const query = {
  405. askInfo: { title: "农事提醒", content: "是否分享该农事提醒给好友" },
  406. shareText: '向您分享了一条农事提醒,请您尽快确认执行时间',
  407. targetUrl: `completed_work`,
  408. paramsPage: JSON.stringify({id: detailData.value.id}),
  409. imageUrl: 'https://birdseye-img.sysuimars.com/birdseye-look-mini/invite_bg.png',
  410. };
  411. wx.miniProgram.navigateTo({
  412. url: `/pages/subPages/share_page/index?pageParams=${JSON.stringify(query)}&type=sharePage`,
  413. });
  414. };
  415. const onConfirmExecuteTime = (date) => {
  416. showCalendar.value = false;
  417. VE_API.z_farm_work_record
  418. .updateExpectedExecuteDate({ recordId: queryRecordId.value, expectedExecuteDate: formatDate(date) })
  419. .then((res) => {
  420. if (res.code === 0) {
  421. ElMessage.success("操作成功");
  422. getDetail(queryRecordId.value);
  423. }
  424. });
  425. };
  426. const handleUploadSuccess = () => {
  427. if (isGoBack.value) {
  428. isGoBack.value = false;
  429. if(showBack.value){
  430. router.replace({
  431. path: "/task_condition",
  432. query: { active: '1' }
  433. });
  434. }else{
  435. router.back();
  436. }
  437. } else {
  438. getDetail(queryRecordId.value);
  439. }
  440. };
  441. const quotationData = ref({});
  442. const toList = (val) => {
  443. if (!val) return [];
  444. return JSON.parse(val);
  445. };
  446. const handleClose = () => {
  447. if(showBack.value){
  448. router.replace({
  449. path: "/task_condition",
  450. query: { active: '1' }
  451. });
  452. }else{
  453. router.back();
  454. }
  455. };
  456. const speciesList = computed(() => toList(quotationData.value.serviceSpecies));
  457. const equipmentList = computed(() => toList(quotationData.value.serviceEquipment));
  458. const agriculturalRole = ref(null);
  459. const userId = ref(null);
  460. const showBack = ref(false);
  461. const queryRecordId = ref(null);
  462. onActivated(async () => {
  463. //
  464. const userInfo = JSON.parse(localStorage.getItem("localUserInfo"));
  465. agriculturalRole.value = userInfo.agriculturalRole;
  466. userId.value = userInfo.id;
  467. //
  468. query.value = useRoute().query?.miniJson ? JSON.parse(useRoute().query?.miniJson) : {};
  469. let id = null;
  470. if(query.value?.id){
  471. id = query.value?.id;
  472. showBack.value = false;
  473. }else{
  474. const data = JSON.parse(query.value?.paramsPage);
  475. id = data?.id;
  476. showBack.value = true;
  477. }
  478. queryRecordId.value = id;
  479. if (id) {
  480. await getDetail(id);
  481. //查询农场状态信息
  482. getFarmWorkArrangeDetail(detailData.value.farmWorkArrangeId);
  483. }
  484. });
  485. const farmStatusText = ref("");
  486. const getFarmWorkArrangeDetail = (id) => {
  487. VE_API.farm.getFarmWorkArrangeDetail({ id }).then(({ data }) => {
  488. farmStatusText.value = data.farmStatus;
  489. });
  490. };
  491. // 药肥费用总计:∑(单价 * 单亩用量 * 亩数)
  492. const pesticideCostTotal = computed(() => {
  493. const list = settingData();
  494. const area = Number(detailData.value?.area || 0);
  495. if (!list.length || !area) return 0;
  496. const sum = list.reduce((acc, item) => {
  497. const price = Number(item?.muPrice || 0);
  498. const dosage = Number(quotationData.value.executionMethod === 1 ? item?.muUsage2 : item?.muUsage || 0);
  499. if (!price || !dosage) return acc;
  500. return acc + price * dosage * area;
  501. }, 0);
  502. return Number(sum.toFixed(2));
  503. });
  504. // 报价合计 = 药肥费用 + 服务费用
  505. const totalCost = computed(() => {
  506. const pesticide = Number(pesticideCostTotal.value || 0);
  507. const service = Number(serviceCostTotal.value || 0);
  508. if (!pesticide && !service) return '--';
  509. return Number((pesticide + service).toFixed(2));
  510. });
  511. // 服务费用总计(数值):亩单价 * 亩数
  512. const serviceCostTotal = computed(() => {
  513. const price = Number(detailData.value?.serviceMuPrice || 0);
  514. const area = Number(detailData.value?.area || 0);
  515. if (!price || !area) return 0;
  516. return Number((price * area).toFixed(2));
  517. });
  518. const settingData = () => {
  519. return flattenDomains(quotationData.value.prescriptionList);
  520. };
  521. function flattenDomains(data) {
  522. if (!data || !Array.isArray(data)) return [];
  523. // 将所有 prescriptionList 中的 pesticideFertilizerList 合并成一个数组
  524. return data.reduce((acc, item) => {
  525. const list = item?.pesticideFertilizerList || [];
  526. return acc.concat(list);
  527. }, []);
  528. }
  529. const detailData = ref({});
  530. // 计算距离执行时间的天数差
  531. const daysDiff = computed(() => {
  532. if (!detailData.value?.expectedExecuteDate) {
  533. return 0;
  534. }
  535. const executeDate = new Date(detailData.value.expectedExecuteDate);
  536. const today = new Date();
  537. // 将时间设置为 00:00:00,只比较日期
  538. executeDate.setHours(0, 0, 0, 0);
  539. today.setHours(0, 0, 0, 0);
  540. // 计算天数差(毫秒转天数)
  541. const diffTime = executeDate.getTime() - today.getTime();
  542. const diffDays = Math.floor(diffTime / (1000 * 60 * 60 * 24));
  543. return diffDays;
  544. });
  545. const getDetail = async (id) => {
  546. const { data } = await VE_API.z_farm_work_record.getDetail({ id });
  547. if (data && data.length > 0) {
  548. detailData.value = data[0];
  549. // 报价信息
  550. handlePriceInfo();
  551. }
  552. };
  553. const handlePriceInfo = async () => {
  554. let priceDataObj = {};
  555. const { data } = await VE_API.z_farm_work_record_cost.getByRecordId({ farmWorkRecordId: detailData.value.id });
  556. priceDataObj = data;
  557. // 执行方式为1:无人机,则使用无人机价格,否则使用人工价格
  558. detailData.value.serviceMuPrice = data?.farmWorkServiceCost;
  559. if (priceDataObj && Object.keys(priceDataObj).length > 0) {
  560. // 合并外层字段
  561. quotationData.value = {
  562. ...detailData.value,
  563. ...priceDataObj,
  564. };
  565. // 根据 itemsList 的 pesticideFertilizerId 匹配并赋值品牌和价格
  566. if (priceDataObj.itemsList && Array.isArray(priceDataObj.itemsList) && detailData.value.prescriptionList) {
  567. // 创建价格映射表
  568. const priceMap = new Map();
  569. priceDataObj.itemsList.forEach((item) => {
  570. priceMap.set(String(item.pesticideFertilizerId), {
  571. brand: item.brand || "",
  572. price: item.price || 0,
  573. });
  574. });
  575. // 遍历处方列表,赋值品牌和价格,并计算格式化字段供 price-table 使用
  576. quotationData.value.prescriptionList = detailData.value.prescriptionList.map((prescription) => {
  577. return {
  578. ...prescription,
  579. pesticideFertilizerList: prescription.pesticideFertilizerList.map((pesticide) => {
  580. const pesticideId = String(pesticide.pesticideFertilizerId || "");
  581. const priceInfo = priceMap.get(pesticideId);
  582. if (priceInfo) {
  583. const price = priceInfo.price || 0;
  584. const muUsage = pesticide.muUsage || 0;
  585. const unit = pesticide.unit || "";
  586. const area = detailData.value.area || 0;
  587. // 计算总价:优先使用 totalPrice,否则计算 price * muUsage * area
  588. const total = price * muUsage * area;
  589. return {
  590. ...pesticide,
  591. brand: priceInfo.brand || "--",
  592. // 格式化字段供 price-table 组件使用
  593. price: price > 0 ? `${price}元/${unit}` : "--", // 格式化单价显示
  594. dosage: muUsage > 0 ? `${muUsage}${unit}` : "--", // 格式化用量显示
  595. total: total > 0 ? total.toFixed(2) : "--", // 格式化总价显示
  596. };
  597. }
  598. return pesticide;
  599. }),
  600. };
  601. });
  602. }
  603. }
  604. };
  605. </script>
  606. <style lang="scss" scoped>
  607. .completed-work {
  608. height: 100vh;
  609. position: relative;
  610. overflow: auto;
  611. font-size: 14px;
  612. background: #f2f3f5;
  613. .work-content {
  614. height: calc(100% - 40px);
  615. overflow: auto;
  616. box-sizing: border-box;
  617. &.hasBottom {
  618. padding-bottom: 60px;
  619. }
  620. .info-wrap {
  621. margin-bottom: 80px;
  622. }
  623. .work-wrap {
  624. position: relative;
  625. z-index: 3;
  626. padding: 0 12px;
  627. top: -16px;
  628. }
  629. .pt-10 {
  630. padding-top: 10px;
  631. }
  632. .fixed-btn-wrap {
  633. position: fixed;
  634. z-index: 10;
  635. bottom: 0;
  636. left: 0;
  637. width: 100%;
  638. padding: 10px 12px 25px;
  639. box-sizing: border-box;
  640. display: flex;
  641. align-items: center;
  642. justify-content: space-between;
  643. background: #fff;
  644. box-shadow: 2px 2px 5px rgba(0, 0, 0, 0.4);
  645. &.center {
  646. justify-content: center;
  647. }
  648. .fixed-btn {
  649. width: 120px;
  650. text-align: center;
  651. height: 40px;
  652. line-height: 40px;
  653. background: linear-gradient(180deg, #70bffe, #2199f8);
  654. border-radius: 25px;
  655. color: #fff;
  656. font-size: 14px;
  657. box-sizing: border-box;
  658. &.orange {
  659. color: #ff953d;
  660. border: 1px solid #ff953d;
  661. background: rgba(255, 149, 61, 0.1);
  662. }
  663. &.excute {
  664. background: linear-gradient(180deg, #ffd887, #ed9e1e);
  665. }
  666. &.second {
  667. background: #ffffff;
  668. border: 1px solid rgba(153, 153, 153, 0.5);
  669. color: #666666;
  670. }
  671. &.primary-text {
  672. width: 160px;
  673. background: rgba(33, 153, 248, 0.1);
  674. color: #2199f8;
  675. border: 1px solid #2199f8;
  676. }
  677. &.width-120 {
  678. width: 120px;
  679. }
  680. }
  681. }
  682. .card-title {
  683. font-size: 16px;
  684. font-weight: bold;
  685. color: #000;
  686. display: flex;
  687. align-items: center;
  688. justify-content: space-between;
  689. .tag-text {
  690. color: #2199f8;
  691. font-size: 12px;
  692. font-weight: normal;
  693. }
  694. .point-wrap {
  695. display: flex;
  696. align-items: center;
  697. color: #393939;
  698. font-size: 12px;
  699. font-weight: normal;
  700. .point {
  701. width: 6px;
  702. height: 6px;
  703. border-radius: 50%;
  704. background: #393939;
  705. margin-right: 4px;
  706. }
  707. }
  708. .type-tag {
  709. margin-left: 5px;
  710. font-size: 12px;
  711. color: #000000;
  712. padding: 4px 10px;
  713. background: rgba(119, 119, 119, 0.1);
  714. border-radius: 20px;
  715. font-weight: normal;
  716. height: 26px;
  717. line-height: 26px;
  718. }
  719. }
  720. .box-wrap {
  721. background: #fff;
  722. padding: 10px;
  723. border-radius: 8px;
  724. }
  725. .step-wrap {
  726. padding: 18px 0;
  727. }
  728. .content-status {
  729. position: relative;
  730. padding: 26px 12px 20px 12px;
  731. color: #fff;
  732. z-index: 2;
  733. display: flex;
  734. justify-content: space-between;
  735. align-items: center;
  736. &::after {
  737. content: "";
  738. z-index: -1;
  739. position: absolute;
  740. left: 0;
  741. top: 0;
  742. height: 136px;
  743. background: #2199f8;
  744. width: 100%;
  745. }
  746. .status-l {
  747. .stauts-text {
  748. font-size: 22px;
  749. display: flex;
  750. align-items: center;
  751. .status-icon {
  752. width: 24px;
  753. height: 24px;
  754. background: #ffffff;
  755. border-radius: 50%;
  756. margin-right: 8px;
  757. }
  758. }
  759. .stauts-sub-text {
  760. // color: rgba(255, 255, 255, 0.51);
  761. font-size: 14px;
  762. }
  763. .time-text {
  764. color: #ffff;
  765. }
  766. }
  767. &.warning {
  768. &::after {
  769. background: #ff953d;
  770. }
  771. .stauts-sub-text {
  772. color: #fff;
  773. }
  774. }
  775. .status-r {
  776. height: 32px;
  777. line-height: 32px;
  778. padding: 0 16px;
  779. color: #2199f8;
  780. font-size: 16px;
  781. background: #fff;
  782. border-radius: 20px;
  783. }
  784. }
  785. .info-content {
  786. padding: 10px 0;
  787. position: relative;
  788. }
  789. .info-title-wrap {
  790. display: flex;
  791. align-items: center;
  792. justify-content: space-between;
  793. color: #000;
  794. .info-more {
  795. font-size: 18px;
  796. }
  797. .unit-text {
  798. font-size: 12px;
  799. }
  800. }
  801. .info-content-wrap {
  802. .price-bottom {
  803. padding-top: 8px;
  804. .price-info {
  805. padding: 8px 0;
  806. display: flex;
  807. align-items: center;
  808. justify-content: space-between;
  809. color: rgba(0, 0, 0, 0.2);
  810. .main-text {
  811. padding-left: 20px;
  812. color: rgba(0, 0, 0, 0.8);
  813. }
  814. .info-c {
  815. flex: 1;
  816. text-align: center;
  817. }
  818. }
  819. .price-total {
  820. height: 38px;
  821. display: flex;
  822. align-items: center;
  823. justify-content: center;
  824. border: 1px solid rgba(33, 153, 248, 0.5);
  825. background: rgba(33, 153, 248, 0.1);
  826. color: #000000;
  827. border-radius: 4px;
  828. .main-val {
  829. font-size: 20px;
  830. font-weight: bold;
  831. color: #2199f8;
  832. padding-right: 2px;
  833. }
  834. }
  835. }
  836. }
  837. .executor-info {
  838. margin-top: 14px;
  839. &.mt-0 {
  840. margin-top: 0;
  841. }
  842. .executor-title {
  843. font-size: 18px;
  844. font-weight: bold;
  845. color: #000;
  846. margin-bottom: 12px;
  847. }
  848. .executor-content {
  849. .executor-info {
  850. display: flex;
  851. align-items: flex-start;
  852. gap: 12px;
  853. }
  854. .executor-avatar {
  855. flex-shrink: 0;
  856. img {
  857. width: 60px;
  858. height: 60px;
  859. border-radius: 8px;
  860. object-fit: cover;
  861. }
  862. }
  863. .executor-details {
  864. flex: 1;
  865. .org-name {
  866. display: flex;
  867. align-items: center;
  868. gap: 8px;
  869. margin-bottom: 3px;
  870. .name {
  871. font-size: 16px;
  872. font-weight: bold;
  873. color: #000;
  874. }
  875. .rating {
  876. font-size: 16px;
  877. color: #ff953d;
  878. font-weight: bold;
  879. }
  880. }
  881. .service-info {
  882. .service-item {
  883. font-size: 12px;
  884. color: #b6b6b6;
  885. line-height: 1.3;
  886. margin-bottom: 2px;
  887. span {
  888. color: #666666;
  889. }
  890. }
  891. }
  892. }
  893. }
  894. .contact-buttons {
  895. display: flex;
  896. justify-content: flex-end;
  897. gap: 8px;
  898. margin-top: 16px;
  899. .contact-btn {
  900. width: 88px;
  901. height: 32px;
  902. border-radius: 20px;
  903. color: rgba(0, 0, 0, 0.5);
  904. background: #fff;
  905. border: 1px solid rgba(0, 0, 0, 0.1);
  906. }
  907. }
  908. }
  909. .farm-info {
  910. color: rgba(0, 0, 0, 0.6);
  911. font-size: 14px;
  912. margin-top: 14px;
  913. .info-title {
  914. display: flex;
  915. align-items: center;
  916. justify-content: space-between;
  917. color: rgba(41, 41, 41, 0.3);
  918. .info-more {
  919. display: flex;
  920. align-items: center;
  921. }
  922. }
  923. }
  924. .farm-photo {
  925. margin-top: 10px;
  926. .photo-list {
  927. display: flex;
  928. align-items: center;
  929. width: 100%;
  930. overflow: auto;
  931. padding-bottom: 10px;
  932. .photo-item {
  933. width: 92px;
  934. height: 92px;
  935. border-radius: 8px;
  936. object-fit: cover;
  937. }
  938. .img-item {
  939. img {
  940. width: 92px;
  941. height: 92px;
  942. border-radius: 8px;
  943. object-fit: cover;
  944. margin-right: 12px;
  945. }
  946. }
  947. .view-box {
  948. width: 92px;
  949. height: 92px;
  950. border-radius: 8px;
  951. object-fit: cover;
  952. }
  953. }
  954. .list-text {
  955. text-align: center;
  956. color: rgba(0, 0, 0, 0.5);
  957. padding-top: 2px;
  958. }
  959. }
  960. .farm-data {
  961. margin-top: 10px;
  962. .data-content {
  963. margin-top: 8px;
  964. border-top: 1px solid #f5f5f5;
  965. padding: 8px 0;
  966. }
  967. }
  968. .form-item {
  969. display: flex;
  970. align-items: center;
  971. font-size: 14px;
  972. color: #767676;
  973. height: 24px;
  974. .item-name {
  975. width: 80px;
  976. color: rgba(0, 0, 0, 0.2);
  977. }
  978. }
  979. .form-item + .form-item {
  980. padding-top: 2px;
  981. }
  982. .farm-table {
  983. margin-top: 10px;
  984. .table-item {
  985. padding: 10px 0 12px 0;
  986. }
  987. }
  988. .new-wrap {
  989. border-radius: 5px;
  990. text-align: center;
  991. border: 1px solid rgba(225, 225, 225, 0.5);
  992. .new-title {
  993. background: rgba(241, 241, 241, 0.4);
  994. border-radius: 5px 5px 0 0;
  995. border-bottom: 1px solid rgba(225, 225, 225, 0.5);
  996. display: flex;
  997. color: #767676;
  998. // justify-content: space-around;
  999. padding: 5px 6px;
  1000. font-size: 12px;
  1001. .table-name {
  1002. width: 24px;
  1003. font-size: 12px;
  1004. margin: 0 auto;
  1005. }
  1006. }
  1007. .title-1 {
  1008. width: 46px;
  1009. }
  1010. .title-2 {
  1011. flex: 1;
  1012. }
  1013. .title-3 {
  1014. width: 52px;
  1015. }
  1016. .title-4 {
  1017. width: 56px;
  1018. }
  1019. .title-5 {
  1020. width: 52px;
  1021. }
  1022. .new-table-wrap {
  1023. .new-prescription {
  1024. .new-table {
  1025. height: 45px;
  1026. display: flex;
  1027. align-items: center;
  1028. background: #fff;
  1029. border-radius: 5px;
  1030. color: rgba(0, 0, 0, 0.6);
  1031. font-size: 11px;
  1032. .line-l {
  1033. display: flex;
  1034. flex: 1;
  1035. .line-2 {
  1036. flex: 1;
  1037. padding: 0 2px;
  1038. }
  1039. }
  1040. .line-r {
  1041. &.has-border {
  1042. border-left: 1px solid rgba(225, 225, 225, 0.8);
  1043. }
  1044. .line-3 {
  1045. display: flex;
  1046. align-items: center;
  1047. }
  1048. .sub-line {
  1049. padding: 10px 0;
  1050. }
  1051. .line-4 {
  1052. display: flex;
  1053. align-items: center;
  1054. border-top: 1px solid rgba(225, 225, 225, 0.8);
  1055. }
  1056. .execute-line {
  1057. border-right: 1px solid rgba(225, 225, 225, 0.8);
  1058. }
  1059. }
  1060. }
  1061. .note-text {
  1062. margin: 8px 0 4px 0;
  1063. color: rgba(0, 0, 0, 0.4);
  1064. background: #fff;
  1065. padding: 6px 8px;
  1066. border-radius: 5px;
  1067. text-align: left;
  1068. font-size: 11px;
  1069. }
  1070. }
  1071. .new-prescription + .new-prescription {
  1072. .new-table {
  1073. border-top: 1px solid rgba(0, 0, 0, 0.08);
  1074. }
  1075. }
  1076. }
  1077. }
  1078. .work-map {
  1079. padding: 10px 0;
  1080. .map-content {
  1081. padding-top: 8px;
  1082. .map-dom {
  1083. height: 166px;
  1084. width: 100%;
  1085. clip-path: inset(0px round 8px);
  1086. }
  1087. }
  1088. }
  1089. }
  1090. }
  1091. .task-tips-popup {
  1092. width: 75%;
  1093. padding: 28px 28px 20px;
  1094. display: flex;
  1095. flex-direction: column;
  1096. align-items: center;
  1097. justify-content: center;
  1098. .create-farm-icon {
  1099. width: 40px;
  1100. height: 40px;
  1101. margin-bottom: 12px;
  1102. }
  1103. .farm-check-icon {
  1104. width: 68px;
  1105. height: 68px;
  1106. margin-bottom: 12px;
  1107. }
  1108. .create-farm-text {
  1109. font-size: 20px;
  1110. font-weight: 500;
  1111. line-height: 40px;
  1112. margin-bottom: 32px;
  1113. text-align: center;
  1114. &.success-text {
  1115. font-size: 23px;
  1116. font-weight: 400;
  1117. }
  1118. }
  1119. .main-text {
  1120. color: #2199f8;
  1121. }
  1122. .create-farm-btn {
  1123. width: 100%;
  1124. box-sizing: border-box;
  1125. padding: 8px;
  1126. border-radius: 25px;
  1127. font-size: 16px;
  1128. background: #2199f8;
  1129. color: #fff;
  1130. text-align: center;
  1131. }
  1132. }
  1133. </style>