prescriptionBox.vue 19 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573
  1. <template>
  2. <!-- 专家处方 -->
  3. <!-- <div class="work-item" :class="{ dark: prescriptioData?.orderStatus === 0 && ROLETYPE != '3' }"> -->
  4. <div class="work-item">
  5. <div class="work-info">
  6. <!-- <img
  7. v-if="prescriptioData?.orderStatus === 0 && ROLETYPE == '3'"
  8. class="todo-img"
  9. src="@/assets/img/gallery/todo.png"
  10. /> -->
  11. <div class="prescription-box">
  12. <div class="step-box">
  13. <step-box
  14. :orderStatus="infoItem.orderStatus"
  15. v-if="infoItem.orderStatus || infoItem.orderStatus === 0"
  16. ></step-box>
  17. </div>
  18. <div class="work-info-conetnt">
  19. <div class="info-item">
  20. <div class="info-name">农事编号:</div>
  21. <div class="info-value">{{ infoItem.orderId }}</div>
  22. </div>
  23. <div class="info-item">
  24. <div class="info-name">服务亩数:</div>
  25. <div class="info-value">{{ infoItem.area }}亩</div>
  26. </div>
  27. <div class="info-item">
  28. <div class="info-name">服务区域:</div>
  29. <div class="info-value">{{ infoItem.serviceRegion }}</div>
  30. </div>
  31. <div v-if="prescriptioData?.orderStatus === 0 && ROLETYPE == '3'">
  32. <div class="info-item">
  33. <div class="info-name">触发条件:</div>
  34. <div class="info-value">
  35. {{ infoItem.condition }}
  36. <div class="select-value">
  37. <el-select v-model="infoItem.condition" placeholder="请选择" style="width: 80px">
  38. <el-option v-for="num in 9" :key="num" :value="20 + (num - 1) * 5 + '%'">
  39. {{ 20 + (num - 1) * 5 }}%
  40. </el-option>
  41. </el-select>
  42. </div>
  43. </div>
  44. </div>
  45. <div class="info-item time-picker">
  46. <div class="info-name">执行时间:</div>
  47. <div class="info-value">
  48. <el-date-picker
  49. style="width: 150px"
  50. value-format="YYYY-MM-DD"
  51. v-model="infoItem.executeDate"
  52. type="date"
  53. :clearable="false"
  54. class="date-info"
  55. placeholder="选择日期"
  56. />
  57. </div>
  58. </div>
  59. </div>
  60. <div v-else>
  61. <div class="info-item">
  62. <div class="info-name">触发条件:</div>
  63. <div class="info-value">{{ infoItem.condition }}</div>
  64. </div>
  65. <div class="info-item">
  66. <div class="info-name">执行时间:</div>
  67. <div class="info-value">{{ infoItem.executeDate }}</div>
  68. </div>
  69. </div>
  70. </div>
  71. <!-- <div class="desc">
  72. {{ prescriptioData.expertPrescription || prescriptioData.weatherWarningMsg }}
  73. </div> -->
  74. <!-- 显示简略信息 -->
  75. <!-- v-if="prescriptioData?.orderStatus === 0 && ROLETYPE == '3'" -->
  76. <div class="prescription-item">
  77. <div class="recipe-box">
  78. <div class="recipe-title">
  79. <div class="recipe-name">药物处方</div>
  80. </div>
  81. <div class="usage-mode">
  82. 施用方式:<span>{{ prescriptioData.usageMode }}</span>
  83. </div>
  84. <div class="new-wrap">
  85. <div class="new-title">
  86. <div class="title-1"><div class="table-name">使用功效</div></div>
  87. <div class="title-2"><div class="table-name">肥药名称</div></div>
  88. <div class="title-3"><div class="table-name">执行方式</div></div>
  89. <div class="title-4"><div class="table-name">药肥配比</div></div>
  90. <div class="title-5"><div class="table-name">单亩用量</div></div>
  91. </div>
  92. <div
  93. class="new-table-wrap"
  94. v-for="(prescriptionItem, prescriptionI) in prescriptioData.prescriptionList"
  95. :key="prescriptionI"
  96. >
  97. <div
  98. class="new-prescription"
  99. v-for="(subP, subI) in prescriptionItem.pesticideFertilizerList"
  100. :key="subI"
  101. >
  102. <div class="new-table">
  103. <div class="line-l">
  104. <div class="line-1 title-1">{{ subP.typeName }}</div>
  105. <div class="line-2">{{ subP.defaultName }}</div>
  106. </div>
  107. <div class="line-r" :class="{'has-border': prescriptioData.usageMode === '叶面施'}">
  108. <div class="line-3">
  109. <div class="sub-line title-3" :class="{'execute-line': prescriptioData.usageMode === '叶面施'}">人工</div>
  110. <div class="sub-line title-4">1:{{ subP.ratio }}{{ subP.unit }}</div>
  111. <div class="sub-line title-5">{{ subP.muUsage }}{{ subP.unit }}</div>
  112. </div>
  113. <div class="line-4" v-if="prescriptioData.usageMode === '叶面施'">
  114. <div class="sub-line title-3 execute-line">无人机</div>
  115. <div class="sub-line title-4">{{ subP.ratio2 ? subP.ratio2 : "---" }}</div>
  116. <div class="sub-line title-5">{{ subP.muUsage2 ? subP.muUsage2 : "---" }}</div>
  117. </div>
  118. </div>
  119. </div>
  120. <div class="note-text" v-if="subP.remark">{{ subP.remark }}</div>
  121. </div>
  122. </div>
  123. </div>
  124. </div>
  125. </div>
  126. <div class="prescription-item" v-if="prescriptioData?.orderStatus === 0">
  127. <div class="sub-title">
  128. <div class="sub-line"></div>
  129. <div class="sub-name">指标动态</div>
  130. <div class="sub-line"></div>
  131. </div>
  132. <div class="prescription-chart">
  133. <!-- <chart :key="1" type="feature" :indexName="infoItem.indexName" :chartJson="prescriptioData.indexJson"></chart> -->
  134. </div>
  135. </div>
  136. <div class="prescription-item" v-if="prescriptioData?.orderStatus === 0 && ROLETYPE == '3'">
  137. <el-button class="btn" type="danger" plain @click="remove()">删除</el-button>
  138. <el-button class="btn" type="primary" @click="submitForm(formRef)">确认下发</el-button>
  139. </div>
  140. </div>
  141. </div>
  142. </div>
  143. </template>
  144. <script setup>
  145. import { ElMessage, ElMessageBox } from "element-plus";
  146. import eventBus from "@/api/eventBus";
  147. import chart from "./chart.vue";
  148. import { onActivated, onMounted, reactive, ref } from "vue";
  149. import { useStore } from "vuex";
  150. import stepBox from "@/components/common/stepBox.vue";
  151. import customTable from "./table.vue";
  152. import { useRouter, useRoute } from "vue-router";
  153. const router = useRouter();
  154. const props = defineProps({
  155. prescriptioData: {
  156. type: Object,
  157. },
  158. });
  159. const tableHeader = [
  160. {
  161. name: "使用功效",
  162. props: "typeName",
  163. },
  164. {
  165. name: "肥药名称",
  166. props: "defaultName",
  167. },
  168. {
  169. name: "执行方式",
  170. props: "usageMode1",
  171. },
  172. {
  173. name: "药肥配比",
  174. props: "usageMode",
  175. },
  176. {
  177. name: "单亩用量",
  178. props: "muUsage",
  179. },
  180. ];
  181. const tableData = ref([
  182. {
  183. brand: "",
  184. defaultDroneRatio: null,
  185. defaultName: "灌水",
  186. defaultRatio: null,
  187. executeStyle: null,
  188. id: "686142764512972800",
  189. muPrice: null,
  190. muUsage: 222,
  191. muUsage2: null,
  192. orderId: "686142764492001280",
  193. pesticideFertilizerCode: "",
  194. pesticideFertilizerId: "15",
  195. pesticideFertilizerName: "灌水",
  196. price: null,
  197. ratio: 11,
  198. ratio2: null,
  199. remark: "",
  200. typeName: "调节",
  201. unit: "kg",
  202. usageMode: "",
  203. list: [],
  204. },
  205. ]);
  206. const infoItem = ref({});
  207. const store = useStore();
  208. const ROLETYPE = '3';
  209. // const ROLETYPE = store.state.app.curRole;
  210. // 农事类型--区分表格显示字段等
  211. const workType = ref(false);
  212. let pesticideFertilizersOptions = ref([
  213. {
  214. id: "null",
  215. name: "芸苔素内酯 15000倍",
  216. typeName: "30",
  217. defaultRatio: null,
  218. defaultDroneRatio: null,
  219. unit: 0,
  220. defaultName: "调节",
  221. },
  222. ]);
  223. VE_API.order.pesticideFertilizers().then(({ data }) => {
  224. pesticideFertilizersOptions.value = data;
  225. tableData.value[0].list = data;
  226. });
  227. onMounted(() => {
  228. dynamicValidateForm.usageMode = props.prescriptioData.usageMode;
  229. dynamicValidateForm.prescriptionList = props.prescriptioData.prescriptionList.map((item) => ({ ...item }));
  230. // submit() // submit()
  231. console.log("dynamicValidateForm.domains",props.prescriptioData);
  232. infoItem.value = props.prescriptioData;
  233. if(infoItem.value.area)
  234. infoItem.value.area = infoItem.value.area.toFixed(2);
  235. for(let item of infoItem.value.conditionList){
  236. infoItem.value.condition=item
  237. }
  238. });
  239. // 表单
  240. const formRef = ref();
  241. const dynamicValidateForm = reactive({
  242. name: "",
  243. conditionRate: "",
  244. executeDate: "",
  245. usageMode: "",
  246. prescriptionList: [
  247. {
  248. name: "",
  249. pesticideFertilizerList: [
  250. {
  251. key: 1,
  252. typeName: "",
  253. muUsage: "",
  254. muUsage2: "",
  255. ratio: "",
  256. ratio2: "",
  257. remark: "",
  258. },
  259. ],
  260. },
  261. ],
  262. });
  263. const addDomain = (parentIndex) => {
  264. dynamicValidateForm.prescriptionList[parentIndex].pesticideFertilizerList.unshift({
  265. key: Date.now(),
  266. muUsage: "",
  267. muUsage2: "",
  268. ratio: "",
  269. ratio2: "",
  270. remark: "",
  271. });
  272. };
  273. const removeDomain = (parentIndex, item) => {
  274. const index = dynamicValidateForm.prescriptionList[parentIndex].pesticideFertilizerList.indexOf(item);
  275. if (index !== -1) {
  276. dynamicValidateForm.prescriptionList[parentIndex].pesticideFertilizerList.splice(index, 1);
  277. }
  278. };
  279. const resetItemForm = (parentIndex, index) => {
  280. dynamicValidateForm.prescriptionList[parentIndex].pesticideFertilizerList[index] = {
  281. typeName: "",
  282. muUsage: "",
  283. muUsage2: "",
  284. ratio: "",
  285. ratio2: "",
  286. remark: "",
  287. };
  288. };
  289. /**
  290. * 选择药肥的时候修改订单中药肥pesticideFertilizerId 以外其他数据
  291. * @param index
  292. */
  293. const handlePesticideFertilizerChange = (index) => {
  294. let obj = pesticideFertilizersOptions.value.filter(
  295. (item) => dynamicValidateForm.domains[index].pesticideFertilizerId === item.id
  296. )[0];
  297. dynamicValidateForm.domains[index] = {
  298. ...dynamicValidateForm.domains[index],
  299. typeName: obj.typeName,
  300. unit: obj.unit,
  301. defaultRatio: obj.defaultRatio,
  302. usageModeList: obj.usageModeList,
  303. ratio: obj.defaultRatio,
  304. defaultName: obj.defaultName,
  305. pesticideFertilizerName: obj.name,
  306. };
  307. console.log(dynamicValidateForm.domains);
  308. };
  309. const submitForm = (formEl) => {
  310. if (!formEl) return;
  311. formEl.validate((valid) => {
  312. if (valid) {
  313. submit();
  314. } else {
  315. console.log("error submit!");
  316. }
  317. });
  318. };
  319. const submit = () => {
  320. const data = {
  321. orderId: props.prescriptioData.orderId,
  322. orderStatus: 1,
  323. pesticideFertilizers: dynamicValidateForm.domains,
  324. };
  325. VE_API.order.confirm(data).then(({ code }) => {
  326. if (code == 0) {
  327. console.log("专家下发处方成功");
  328. eventBus.emit("discover:submitForm");
  329. window.location.reload();
  330. }
  331. });
  332. };
  333. const formatIndex = (index) => {
  334. return String(index + 1).padStart(2, "0");
  335. };
  336. const handleTableData = (item) => {
  337. return [
  338. {
  339. typeName: item.typeName,
  340. defaultName: item.defaultName,
  341. executeStyle: 1,
  342. ratio: item.ratio || item.defaultRatio,
  343. usageMode: item.usageMode,
  344. muUsage: item.muUsage,
  345. unit: item.unit,
  346. },
  347. {
  348. typeName: item.typeName,
  349. defaultName: item.defaultName,
  350. executeStyle: 2,
  351. ratio: item.ratio2,
  352. usageMode: "---",
  353. muUsage: item.muUsage2,
  354. unit: item.unit,
  355. },
  356. ];
  357. };
  358. const remove = () => {
  359. ElMessageBox.confirm("是否要删除这个农事?", "警告", {
  360. confirmButtonText: "删除",
  361. cancelButtonText: "取消",
  362. type: "warning",
  363. }).then(() => {
  364. VE_API.farm.deleteFarmWork({ libId: infoItem.value.farmWorkLibId }).then(({ code }) => {
  365. if (code === 0) {
  366. ElMessage({
  367. type: "success",
  368. message: "删除成功!",
  369. });
  370. setTimeout(() => {
  371. // router.go(-1);
  372. router.replace("/expert_album?reload=true");
  373. }, 500);
  374. }
  375. });
  376. });
  377. };
  378. </script>
  379. <style lang="scss" scoped>
  380. @import "./boxClass.scss";
  381. .recipe-box {
  382. .recipe-title {
  383. display: flex;
  384. align-items: center;
  385. justify-content: space-between;
  386. margin-bottom: 10px;
  387. padding-left: 10px;
  388. position: relative;
  389. &::before {
  390. content: "";
  391. position: absolute;
  392. left: 0;
  393. top: 3px;
  394. width: 3px;
  395. height: 15px;
  396. background: #fff;
  397. border-radius: 11px;
  398. }
  399. .recipe-name {
  400. color: #fff;
  401. font-size: 15px;
  402. }
  403. .recipe-btn {
  404. color: #FFD489;
  405. display: flex;
  406. align-items: center;
  407. cursor: pointer;
  408. .icon{
  409. margin-right: 3px;
  410. }
  411. }
  412. }
  413. .usage-mode {
  414. display: flex;
  415. align-items: center;
  416. font-size: 16px;
  417. color: #727272;
  418. padding: 2px 0 12px 0;
  419. span {
  420. color: #fff;
  421. }
  422. }
  423. }
  424. .prescription-result {
  425. position: relative;
  426. &.has-wrap {
  427. border: 0.5px solid #444444;
  428. border-radius: 4px;
  429. padding: 8px 10px 10px 10px;
  430. }
  431. .result-index {
  432. position: absolute;
  433. left: -1px;
  434. top: -1px;
  435. padding: 0 8px;
  436. background: #2199f8;
  437. color: #fff;
  438. font-size: 12px;
  439. border-radius: 4px 0 4px 0;
  440. }
  441. .result-title {
  442. display: flex;
  443. justify-content: center;
  444. align-items: center;
  445. padding-bottom: 8px;
  446. .title-item {
  447. display: flex;
  448. align-items: center;
  449. .name {
  450. color: rgba(33, 153, 248, 0.85);
  451. }
  452. .value {
  453. color: rgba(0, 0, 0, 0.4);
  454. }
  455. }
  456. .title-item + .title-item {
  457. padding-left: 16px;
  458. }
  459. }
  460. }
  461. .new-wrap {
  462. border-radius: 5px;
  463. text-align: center;
  464. border: 1px solid #444444;
  465. .new-title {
  466. background: rgba(255, 255, 255, 0.04);
  467. border-radius: 5px 5px 0 0;
  468. display: flex;
  469. color: #727272;
  470. // justify-content: space-around;
  471. padding: 5px 6px;
  472. font-size: 14px;
  473. .table-name {
  474. width: 40px;
  475. font-size: 14px;
  476. margin: 0 auto;
  477. }
  478. }
  479. .title-1 {
  480. width: 62px;
  481. }
  482. .title-2 {
  483. flex: 1;
  484. }
  485. .title-3 {
  486. width: 64px;
  487. }
  488. .title-4 {
  489. width: 76px;
  490. }
  491. .title-5 {
  492. width: 68px;
  493. }
  494. .new-table-wrap {
  495. .new-prescription {
  496. padding: 0 8px;
  497. .new-table {
  498. display: flex;
  499. align-items: center;
  500. // border: 1px solid #444444;
  501. border-radius: 5px;
  502. color: #CECECE;
  503. font-size: 16px;
  504. .line-l {
  505. display: flex;
  506. flex: 1;
  507. padding: 8px 0;
  508. .line-2 {
  509. flex: 1;
  510. padding: 0 2px;
  511. }
  512. }
  513. .line-r {
  514. // padding: 8px 0;
  515. &.has-border {
  516. border-left: 1px solid #444444;
  517. }
  518. .line-3 {
  519. display: flex;
  520. align-items: center;
  521. }
  522. .sub-line {
  523. padding: 10px 0;
  524. }
  525. .line-4 {
  526. display: flex;
  527. align-items: center;
  528. border-top: 1px solid #444444;
  529. }
  530. .execute-line {
  531. border-right: 1px solid #444444;
  532. }
  533. }
  534. }
  535. .note-text {
  536. // margin: 8px 0 4px 0;
  537. color: #9F9F9F;
  538. background: rgba(255, 255, 255, 0.05);
  539. padding: 6px 8px;
  540. border-radius: 5px;
  541. text-align: left;
  542. font-size: 16px;
  543. }
  544. }
  545. .new-prescription + .new-prescription {
  546. // margin-top: 8px;
  547. border-top: 1px solid #444444;
  548. }
  549. }
  550. }
  551. </style>