completedWork.vue 45 KB

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