completedWork.vue 45 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886887888889890891892893894895896897898899900901902903904905906907908909910911912913914915916917918919920921922923924925926927928929930931932933934935936937938939940941942943944945946947948949950951952953954955956957958959960961962963964965966967968969970971972973974975976977978979980981982983984985986987988989990991992993994995996997998999100010011002100310041005100610071008100910101011101210131014101510161017101810191020102110221023102410251026102710281029103010311032103310341035103610371038103910401041104210431044104510461047104810491050105110521053105410551056105710581059106010611062106310641065106610671068106910701071107210731074107510761077107810791080108110821083108410851086108710881089109010911092109310941095109610971098109911001101110211031104110511061107110811091110111111121113111411151116111711181119112011211122112311241125112611271128112911301131113211331134113511361137113811391140114111421143114411451146114711481149115011511152115311541155115611571158115911601161116211631164116511661167116811691170117111721173117411751176117711781179118011811182118311841185
  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. router.back();
  430. } else {
  431. getDetail(queryRecordId.value);
  432. }
  433. };
  434. const quotationData = ref({});
  435. const toList = (val) => {
  436. if (!val) return [];
  437. return JSON.parse(val);
  438. };
  439. const handleClose = () => {
  440. if(showBack.value){
  441. router.replace({
  442. path: "/task_condition",
  443. });
  444. }else{
  445. router.back();
  446. }
  447. };
  448. const speciesList = computed(() => toList(quotationData.value.serviceSpecies));
  449. const equipmentList = computed(() => toList(quotationData.value.serviceEquipment));
  450. const agriculturalRole = ref(null);
  451. const userId = ref(null);
  452. const showBack = ref(false);
  453. const queryRecordId = ref(null);
  454. onActivated(async () => {
  455. //
  456. const userInfo = JSON.parse(localStorage.getItem("localUserInfo"));
  457. agriculturalRole.value = userInfo.agriculturalRole;
  458. userId.value = userInfo.id;
  459. //
  460. query.value = useRoute().query?.miniJson ? JSON.parse(useRoute().query?.miniJson) : {};
  461. let id = null;
  462. if(query.value?.id){
  463. id = query.value?.id;
  464. showBack.value = false;
  465. }else{
  466. const data = JSON.parse(query.value?.paramsPage);
  467. id = data?.id;
  468. showBack.value = true;
  469. }
  470. queryRecordId.value = id;
  471. if (id) {
  472. await getDetail(id);
  473. //查询农场状态信息
  474. getFarmWorkArrangeDetail(detailData.value.farmWorkArrangeId);
  475. }
  476. });
  477. const farmStatusText = ref("");
  478. const getFarmWorkArrangeDetail = (id) => {
  479. VE_API.farm.getFarmWorkArrangeDetail({ id }).then(({ data }) => {
  480. farmStatusText.value = data.farmStatus;
  481. });
  482. };
  483. // 药肥费用总计:∑(单价 * 单亩用量 * 亩数)
  484. const pesticideCostTotal = computed(() => {
  485. const list = settingData();
  486. const area = Number(detailData.value?.area || 0);
  487. if (!list.length || !area) return 0;
  488. const sum = list.reduce((acc, item) => {
  489. const price = Number(item?.muPrice || 0);
  490. const dosage = Number(quotationData.value.executionMethod === 1 ? item?.muUsage2 : item?.muUsage || 0);
  491. if (!price || !dosage) return acc;
  492. return acc + price * dosage * area;
  493. }, 0);
  494. return Number(sum.toFixed(2));
  495. });
  496. // 报价合计 = 药肥费用 + 服务费用
  497. const totalCost = computed(() => {
  498. const pesticide = Number(pesticideCostTotal.value || 0);
  499. const service = Number(serviceCostTotal.value || 0);
  500. if (!pesticide && !service) return '--';
  501. return Number((pesticide + service).toFixed(2));
  502. });
  503. // 服务费用总计(数值):亩单价 * 亩数
  504. const serviceCostTotal = computed(() => {
  505. const price = Number(detailData.value?.serviceMuPrice || 0);
  506. const area = Number(detailData.value?.area || 0);
  507. if (!price || !area) return 0;
  508. return Number((price * area).toFixed(2));
  509. });
  510. const settingData = () => {
  511. return flattenDomains(quotationData.value.prescriptionList);
  512. };
  513. function flattenDomains(data) {
  514. if (!data || !Array.isArray(data)) return [];
  515. // 将所有 prescriptionList 中的 pesticideFertilizerList 合并成一个数组
  516. return data.reduce((acc, item) => {
  517. const list = item?.pesticideFertilizerList || [];
  518. return acc.concat(list);
  519. }, []);
  520. }
  521. const detailData = ref({});
  522. // 计算距离执行时间的天数差
  523. const daysDiff = computed(() => {
  524. if (!detailData.value?.expectedExecuteDate) {
  525. return 0;
  526. }
  527. const executeDate = new Date(detailData.value.expectedExecuteDate);
  528. const today = new Date();
  529. // 将时间设置为 00:00:00,只比较日期
  530. executeDate.setHours(0, 0, 0, 0);
  531. today.setHours(0, 0, 0, 0);
  532. // 计算天数差(毫秒转天数)
  533. const diffTime = executeDate.getTime() - today.getTime();
  534. const diffDays = Math.floor(diffTime / (1000 * 60 * 60 * 24));
  535. return diffDays;
  536. });
  537. const getDetail = async (id) => {
  538. const { data } = await VE_API.z_farm_work_record.getDetail({ id });
  539. if (data && data.length > 0) {
  540. detailData.value = data[0];
  541. // 报价信息
  542. handlePriceInfo();
  543. }
  544. };
  545. const handlePriceInfo = async () => {
  546. let priceDataObj = {};
  547. const { data } = await VE_API.z_farm_work_record_cost.getByRecordId({ farmWorkRecordId: detailData.value.id });
  548. priceDataObj = data;
  549. // 执行方式为1:无人机,则使用无人机价格,否则使用人工价格
  550. detailData.value.serviceMuPrice = data?.farmWorkServiceCost;
  551. if (priceDataObj && Object.keys(priceDataObj).length > 0) {
  552. // 合并外层字段
  553. quotationData.value = {
  554. ...detailData.value,
  555. ...priceDataObj,
  556. };
  557. // 根据 itemsList 的 pesticideFertilizerId 匹配并赋值品牌和价格
  558. if (priceDataObj.itemsList && Array.isArray(priceDataObj.itemsList) && detailData.value.prescriptionList) {
  559. // 创建价格映射表
  560. const priceMap = new Map();
  561. priceDataObj.itemsList.forEach((item) => {
  562. priceMap.set(String(item.pesticideFertilizerId), {
  563. brand: item.brand || "",
  564. price: item.price || 0,
  565. });
  566. });
  567. // 遍历处方列表,赋值品牌和价格,并计算格式化字段供 price-table 使用
  568. quotationData.value.prescriptionList = detailData.value.prescriptionList.map((prescription) => {
  569. return {
  570. ...prescription,
  571. pesticideFertilizerList: prescription.pesticideFertilizerList.map((pesticide) => {
  572. const pesticideId = String(pesticide.pesticideFertilizerId || "");
  573. const priceInfo = priceMap.get(pesticideId);
  574. if (priceInfo) {
  575. const price = priceInfo.price || 0;
  576. const muUsage = pesticide.muUsage || 0;
  577. const unit = pesticide.unit || "";
  578. const area = detailData.value.area || 0;
  579. // 计算总价:优先使用 totalPrice,否则计算 price * muUsage * area
  580. const total = price * muUsage * area;
  581. return {
  582. ...pesticide,
  583. brand: priceInfo.brand || "--",
  584. // 格式化字段供 price-table 组件使用
  585. price: price > 0 ? `${price}元/${unit}` : "--", // 格式化单价显示
  586. dosage: muUsage > 0 ? `${muUsage}${unit}` : "--", // 格式化用量显示
  587. total: total > 0 ? total.toFixed(2) : "--", // 格式化总价显示
  588. };
  589. }
  590. return pesticide;
  591. }),
  592. };
  593. });
  594. }
  595. }
  596. };
  597. </script>
  598. <style lang="scss" scoped>
  599. .completed-work {
  600. height: 100vh;
  601. position: relative;
  602. overflow: auto;
  603. font-size: 14px;
  604. background: #f2f3f5;
  605. .work-content {
  606. height: calc(100% - 40px);
  607. overflow: auto;
  608. box-sizing: border-box;
  609. &.hasBottom {
  610. padding-bottom: 60px;
  611. }
  612. .info-wrap {
  613. margin-bottom: 80px;
  614. }
  615. .work-wrap {
  616. position: relative;
  617. z-index: 3;
  618. padding: 0 12px;
  619. top: -16px;
  620. }
  621. .pt-10 {
  622. padding-top: 10px;
  623. }
  624. .fixed-btn-wrap {
  625. position: fixed;
  626. z-index: 10;
  627. bottom: 0;
  628. left: 0;
  629. width: 100%;
  630. padding: 10px 12px 25px;
  631. box-sizing: border-box;
  632. display: flex;
  633. align-items: center;
  634. justify-content: space-between;
  635. background: #fff;
  636. box-shadow: 2px 2px 5px rgba(0, 0, 0, 0.4);
  637. &.center {
  638. justify-content: center;
  639. }
  640. .fixed-btn {
  641. width: 120px;
  642. text-align: center;
  643. height: 40px;
  644. line-height: 40px;
  645. background: linear-gradient(180deg, #70bffe, #2199f8);
  646. border-radius: 25px;
  647. color: #fff;
  648. font-size: 14px;
  649. box-sizing: border-box;
  650. &.orange {
  651. color: #ff953d;
  652. border: 1px solid #ff953d;
  653. background: rgba(255, 149, 61, 0.1);
  654. }
  655. &.excute {
  656. background: linear-gradient(180deg, #ffd887, #ed9e1e);
  657. }
  658. &.second {
  659. background: #ffffff;
  660. border: 1px solid rgba(153, 153, 153, 0.5);
  661. color: #666666;
  662. }
  663. &.primary-text {
  664. width: 160px;
  665. background: rgba(33, 153, 248, 0.1);
  666. color: #2199f8;
  667. border: 1px solid #2199f8;
  668. }
  669. &.width-120 {
  670. width: 120px;
  671. }
  672. }
  673. }
  674. .card-title {
  675. font-size: 16px;
  676. font-weight: bold;
  677. color: #000;
  678. display: flex;
  679. align-items: center;
  680. justify-content: space-between;
  681. .tag-text {
  682. color: #2199f8;
  683. font-size: 12px;
  684. font-weight: normal;
  685. }
  686. .point-wrap {
  687. display: flex;
  688. align-items: center;
  689. color: #393939;
  690. font-size: 12px;
  691. font-weight: normal;
  692. .point {
  693. width: 6px;
  694. height: 6px;
  695. border-radius: 50%;
  696. background: #393939;
  697. margin-right: 4px;
  698. }
  699. }
  700. .type-tag {
  701. margin-left: 5px;
  702. font-size: 12px;
  703. color: #000000;
  704. padding: 4px 10px;
  705. background: rgba(119, 119, 119, 0.1);
  706. border-radius: 20px;
  707. font-weight: normal;
  708. height: 26px;
  709. line-height: 26px;
  710. }
  711. }
  712. .box-wrap {
  713. background: #fff;
  714. padding: 10px;
  715. border-radius: 8px;
  716. }
  717. .step-wrap {
  718. padding: 18px 0;
  719. }
  720. .content-status {
  721. position: relative;
  722. padding: 26px 12px 20px 12px;
  723. color: #fff;
  724. z-index: 2;
  725. display: flex;
  726. justify-content: space-between;
  727. align-items: center;
  728. &::after {
  729. content: "";
  730. z-index: -1;
  731. position: absolute;
  732. left: 0;
  733. top: 0;
  734. height: 136px;
  735. background: #2199f8;
  736. width: 100%;
  737. }
  738. .status-l {
  739. .stauts-text {
  740. font-size: 22px;
  741. display: flex;
  742. align-items: center;
  743. .status-icon {
  744. width: 24px;
  745. height: 24px;
  746. background: #ffffff;
  747. border-radius: 50%;
  748. margin-right: 8px;
  749. }
  750. }
  751. .stauts-sub-text {
  752. // color: rgba(255, 255, 255, 0.51);
  753. font-size: 14px;
  754. }
  755. .time-text {
  756. color: #ffff;
  757. }
  758. }
  759. &.warning {
  760. &::after {
  761. background: #ff953d;
  762. }
  763. .stauts-sub-text {
  764. color: #fff;
  765. }
  766. }
  767. .status-r {
  768. height: 32px;
  769. line-height: 32px;
  770. padding: 0 16px;
  771. color: #2199f8;
  772. font-size: 16px;
  773. background: #fff;
  774. border-radius: 20px;
  775. }
  776. }
  777. .info-content {
  778. padding: 10px 0;
  779. position: relative;
  780. }
  781. .info-title-wrap {
  782. display: flex;
  783. align-items: center;
  784. justify-content: space-between;
  785. color: #000;
  786. .info-more {
  787. font-size: 18px;
  788. }
  789. .unit-text {
  790. font-size: 12px;
  791. }
  792. }
  793. .info-content-wrap {
  794. .price-bottom {
  795. padding-top: 8px;
  796. .price-info {
  797. padding: 8px 0;
  798. display: flex;
  799. align-items: center;
  800. justify-content: space-between;
  801. color: rgba(0, 0, 0, 0.2);
  802. .main-text {
  803. padding-left: 20px;
  804. color: rgba(0, 0, 0, 0.8);
  805. }
  806. .info-c {
  807. flex: 1;
  808. text-align: center;
  809. }
  810. }
  811. .price-total {
  812. height: 38px;
  813. display: flex;
  814. align-items: center;
  815. justify-content: center;
  816. border: 1px solid rgba(33, 153, 248, 0.5);
  817. background: rgba(33, 153, 248, 0.1);
  818. color: #000000;
  819. border-radius: 4px;
  820. .main-val {
  821. font-size: 20px;
  822. font-weight: bold;
  823. color: #2199f8;
  824. padding-right: 2px;
  825. }
  826. }
  827. }
  828. }
  829. .executor-info {
  830. margin-top: 14px;
  831. &.mt-0 {
  832. margin-top: 0;
  833. }
  834. .executor-title {
  835. font-size: 18px;
  836. font-weight: bold;
  837. color: #000;
  838. margin-bottom: 12px;
  839. }
  840. .executor-content {
  841. .executor-info {
  842. display: flex;
  843. align-items: flex-start;
  844. gap: 12px;
  845. }
  846. .executor-avatar {
  847. flex-shrink: 0;
  848. img {
  849. width: 60px;
  850. height: 60px;
  851. border-radius: 8px;
  852. object-fit: cover;
  853. }
  854. }
  855. .executor-details {
  856. flex: 1;
  857. .org-name {
  858. display: flex;
  859. align-items: center;
  860. gap: 8px;
  861. margin-bottom: 3px;
  862. .name {
  863. font-size: 16px;
  864. font-weight: bold;
  865. color: #000;
  866. }
  867. .rating {
  868. font-size: 16px;
  869. color: #ff953d;
  870. font-weight: bold;
  871. }
  872. }
  873. .service-info {
  874. .service-item {
  875. font-size: 12px;
  876. color: #b6b6b6;
  877. line-height: 1.3;
  878. margin-bottom: 2px;
  879. span {
  880. color: #666666;
  881. }
  882. }
  883. }
  884. }
  885. }
  886. .contact-buttons {
  887. display: flex;
  888. justify-content: flex-end;
  889. gap: 8px;
  890. margin-top: 16px;
  891. .contact-btn {
  892. width: 88px;
  893. height: 32px;
  894. border-radius: 20px;
  895. color: rgba(0, 0, 0, 0.5);
  896. background: #fff;
  897. border: 1px solid rgba(0, 0, 0, 0.1);
  898. }
  899. }
  900. }
  901. .farm-info {
  902. color: rgba(0, 0, 0, 0.6);
  903. font-size: 14px;
  904. margin-top: 14px;
  905. .info-title {
  906. display: flex;
  907. align-items: center;
  908. justify-content: space-between;
  909. color: rgba(41, 41, 41, 0.3);
  910. .info-more {
  911. display: flex;
  912. align-items: center;
  913. }
  914. }
  915. }
  916. .farm-photo {
  917. margin-top: 10px;
  918. .photo-list {
  919. display: flex;
  920. align-items: center;
  921. width: 100%;
  922. overflow: auto;
  923. padding-bottom: 10px;
  924. .photo-item {
  925. width: 92px;
  926. height: 92px;
  927. border-radius: 8px;
  928. object-fit: cover;
  929. }
  930. .img-item {
  931. img {
  932. width: 92px;
  933. height: 92px;
  934. border-radius: 8px;
  935. object-fit: cover;
  936. margin-right: 12px;
  937. }
  938. }
  939. .view-box {
  940. width: 92px;
  941. height: 92px;
  942. border-radius: 8px;
  943. object-fit: cover;
  944. }
  945. }
  946. .list-text {
  947. text-align: center;
  948. color: rgba(0, 0, 0, 0.5);
  949. padding-top: 2px;
  950. }
  951. }
  952. .farm-data {
  953. margin-top: 10px;
  954. .data-content {
  955. margin-top: 8px;
  956. border-top: 1px solid #f5f5f5;
  957. padding: 8px 0;
  958. }
  959. }
  960. .form-item {
  961. display: flex;
  962. align-items: center;
  963. font-size: 14px;
  964. color: #767676;
  965. height: 24px;
  966. .item-name {
  967. width: 80px;
  968. color: rgba(0, 0, 0, 0.2);
  969. }
  970. }
  971. .form-item + .form-item {
  972. padding-top: 2px;
  973. }
  974. .farm-table {
  975. margin-top: 10px;
  976. .table-item {
  977. padding: 10px 0 12px 0;
  978. }
  979. }
  980. .new-wrap {
  981. border-radius: 5px;
  982. text-align: center;
  983. border: 1px solid rgba(225, 225, 225, 0.5);
  984. .new-title {
  985. background: rgba(241, 241, 241, 0.4);
  986. border-radius: 5px 5px 0 0;
  987. border-bottom: 1px solid rgba(225, 225, 225, 0.5);
  988. display: flex;
  989. color: #767676;
  990. // justify-content: space-around;
  991. padding: 5px 6px;
  992. font-size: 12px;
  993. .table-name {
  994. width: 24px;
  995. font-size: 12px;
  996. margin: 0 auto;
  997. }
  998. }
  999. .title-1 {
  1000. width: 46px;
  1001. }
  1002. .title-2 {
  1003. flex: 1;
  1004. }
  1005. .title-3 {
  1006. width: 52px;
  1007. }
  1008. .title-4 {
  1009. width: 56px;
  1010. }
  1011. .title-5 {
  1012. width: 52px;
  1013. }
  1014. .new-table-wrap {
  1015. .new-prescription {
  1016. .new-table {
  1017. height: 45px;
  1018. display: flex;
  1019. align-items: center;
  1020. background: #fff;
  1021. border-radius: 5px;
  1022. color: rgba(0, 0, 0, 0.6);
  1023. font-size: 11px;
  1024. .line-l {
  1025. display: flex;
  1026. flex: 1;
  1027. .line-2 {
  1028. flex: 1;
  1029. padding: 0 2px;
  1030. }
  1031. }
  1032. .line-r {
  1033. &.has-border {
  1034. border-left: 1px solid rgba(225, 225, 225, 0.8);
  1035. }
  1036. .line-3 {
  1037. display: flex;
  1038. align-items: center;
  1039. }
  1040. .sub-line {
  1041. padding: 10px 0;
  1042. }
  1043. .line-4 {
  1044. display: flex;
  1045. align-items: center;
  1046. border-top: 1px solid rgba(225, 225, 225, 0.8);
  1047. }
  1048. .execute-line {
  1049. border-right: 1px solid rgba(225, 225, 225, 0.8);
  1050. }
  1051. }
  1052. }
  1053. .note-text {
  1054. margin: 8px 0 4px 0;
  1055. color: rgba(0, 0, 0, 0.4);
  1056. background: #fff;
  1057. padding: 6px 8px;
  1058. border-radius: 5px;
  1059. text-align: left;
  1060. font-size: 11px;
  1061. }
  1062. }
  1063. .new-prescription + .new-prescription {
  1064. .new-table {
  1065. border-top: 1px solid rgba(0, 0, 0, 0.08);
  1066. }
  1067. }
  1068. }
  1069. }
  1070. .work-map {
  1071. padding: 10px 0;
  1072. .map-content {
  1073. padding-top: 8px;
  1074. .map-dom {
  1075. height: 166px;
  1076. width: 100%;
  1077. clip-path: inset(0px round 8px);
  1078. }
  1079. }
  1080. }
  1081. }
  1082. }
  1083. .task-tips-popup {
  1084. width: 75%;
  1085. padding: 28px 28px 20px;
  1086. display: flex;
  1087. flex-direction: column;
  1088. align-items: center;
  1089. justify-content: center;
  1090. .create-farm-icon {
  1091. width: 40px;
  1092. height: 40px;
  1093. margin-bottom: 12px;
  1094. }
  1095. .farm-check-icon {
  1096. width: 68px;
  1097. height: 68px;
  1098. margin-bottom: 12px;
  1099. }
  1100. .create-farm-text {
  1101. font-size: 20px;
  1102. font-weight: 500;
  1103. line-height: 40px;
  1104. margin-bottom: 32px;
  1105. text-align: center;
  1106. &.success-text {
  1107. font-size: 23px;
  1108. font-weight: 400;
  1109. }
  1110. }
  1111. .main-text {
  1112. color: #2199f8;
  1113. }
  1114. .create-farm-btn {
  1115. width: 100%;
  1116. box-sizing: border-box;
  1117. padding: 8px;
  1118. border-radius: 25px;
  1119. font-size: 16px;
  1120. background: #2199f8;
  1121. color: #fff;
  1122. text-align: center;
  1123. }
  1124. }
  1125. </style>