prescriptionBox.vue 19 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567
  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. });
  234. // 表单
  235. const formRef = ref();
  236. const dynamicValidateForm = reactive({
  237. name: "",
  238. conditionRate: "",
  239. executeDate: "",
  240. usageMode: "",
  241. prescriptionList: [
  242. {
  243. name: "",
  244. pesticideFertilizerList: [
  245. {
  246. key: 1,
  247. typeName: "",
  248. muUsage: "",
  249. muUsage2: "",
  250. ratio: "",
  251. ratio2: "",
  252. remark: "",
  253. },
  254. ],
  255. },
  256. ],
  257. });
  258. const addDomain = (parentIndex) => {
  259. dynamicValidateForm.prescriptionList[parentIndex].pesticideFertilizerList.unshift({
  260. key: Date.now(),
  261. muUsage: "",
  262. muUsage2: "",
  263. ratio: "",
  264. ratio2: "",
  265. remark: "",
  266. });
  267. };
  268. const removeDomain = (parentIndex, item) => {
  269. const index = dynamicValidateForm.prescriptionList[parentIndex].pesticideFertilizerList.indexOf(item);
  270. if (index !== -1) {
  271. dynamicValidateForm.prescriptionList[parentIndex].pesticideFertilizerList.splice(index, 1);
  272. }
  273. };
  274. const resetItemForm = (parentIndex, index) => {
  275. dynamicValidateForm.prescriptionList[parentIndex].pesticideFertilizerList[index] = {
  276. typeName: "",
  277. muUsage: "",
  278. muUsage2: "",
  279. ratio: "",
  280. ratio2: "",
  281. remark: "",
  282. };
  283. };
  284. /**
  285. * 选择药肥的时候修改订单中药肥pesticideFertilizerId 以外其他数据
  286. * @param index
  287. */
  288. const handlePesticideFertilizerChange = (index) => {
  289. let obj = pesticideFertilizersOptions.value.filter(
  290. (item) => dynamicValidateForm.domains[index].pesticideFertilizerId === item.id
  291. )[0];
  292. dynamicValidateForm.domains[index] = {
  293. ...dynamicValidateForm.domains[index],
  294. typeName: obj.typeName,
  295. unit: obj.unit,
  296. defaultRatio: obj.defaultRatio,
  297. usageModeList: obj.usageModeList,
  298. ratio: obj.defaultRatio,
  299. defaultName: obj.defaultName,
  300. pesticideFertilizerName: obj.name,
  301. };
  302. console.log(dynamicValidateForm.domains);
  303. };
  304. const submitForm = (formEl) => {
  305. if (!formEl) return;
  306. formEl.validate((valid) => {
  307. if (valid) {
  308. submit();
  309. } else {
  310. console.log("error submit!");
  311. }
  312. });
  313. };
  314. const submit = () => {
  315. const data = {
  316. orderId: props.prescriptioData.orderId,
  317. orderStatus: 1,
  318. pesticideFertilizers: dynamicValidateForm.domains,
  319. };
  320. VE_API.order.confirm(data).then(({ code }) => {
  321. if (code == 0) {
  322. console.log("专家下发处方成功");
  323. eventBus.emit("discover:submitForm");
  324. window.location.reload();
  325. }
  326. });
  327. };
  328. const formatIndex = (index) => {
  329. return String(index + 1).padStart(2, "0");
  330. };
  331. const handleTableData = (item) => {
  332. return [
  333. {
  334. typeName: item.typeName,
  335. defaultName: item.defaultName,
  336. executeStyle: 1,
  337. ratio: item.ratio || item.defaultRatio,
  338. usageMode: item.usageMode,
  339. muUsage: item.muUsage,
  340. unit: item.unit,
  341. },
  342. {
  343. typeName: item.typeName,
  344. defaultName: item.defaultName,
  345. executeStyle: 2,
  346. ratio: item.ratio2,
  347. usageMode: "---",
  348. muUsage: item.muUsage2,
  349. unit: item.unit,
  350. },
  351. ];
  352. };
  353. const remove = () => {
  354. ElMessageBox.confirm("是否要删除这个农事?", "警告", {
  355. confirmButtonText: "删除",
  356. cancelButtonText: "取消",
  357. type: "warning",
  358. }).then(() => {
  359. VE_API.farm.deleteFarmWork({ libId: infoItem.value.farmWorkLibId }).then(({ code }) => {
  360. if (code === 0) {
  361. ElMessage({
  362. type: "success",
  363. message: "删除成功!",
  364. });
  365. setTimeout(() => {
  366. // router.go(-1);
  367. router.replace("/expert_album?reload=true");
  368. }, 500);
  369. }
  370. });
  371. });
  372. };
  373. </script>
  374. <style lang="scss" scoped>
  375. @import "./boxClass.scss";
  376. .recipe-box {
  377. .recipe-title {
  378. display: flex;
  379. align-items: center;
  380. justify-content: space-between;
  381. margin-bottom: 10px;
  382. padding-left: 10px;
  383. position: relative;
  384. &::before {
  385. content: "";
  386. position: absolute;
  387. left: 0;
  388. top: 3px;
  389. width: 3px;
  390. height: 15px;
  391. background: #fff;
  392. border-radius: 11px;
  393. }
  394. .recipe-name {
  395. color: #fff;
  396. font-size: 15px;
  397. }
  398. .recipe-btn {
  399. color: #FFD489;
  400. display: flex;
  401. align-items: center;
  402. cursor: pointer;
  403. .icon{
  404. margin-right: 3px;
  405. }
  406. }
  407. }
  408. .usage-mode {
  409. display: flex;
  410. align-items: center;
  411. font-size: 16px;
  412. color: #727272;
  413. padding: 2px 0 12px 0;
  414. span {
  415. color: #fff;
  416. }
  417. }
  418. }
  419. .prescription-result {
  420. position: relative;
  421. &.has-wrap {
  422. border: 0.5px solid #444444;
  423. border-radius: 4px;
  424. padding: 8px 10px 10px 10px;
  425. }
  426. .result-index {
  427. position: absolute;
  428. left: -1px;
  429. top: -1px;
  430. padding: 0 8px;
  431. background: #2199f8;
  432. color: #fff;
  433. font-size: 12px;
  434. border-radius: 4px 0 4px 0;
  435. }
  436. .result-title {
  437. display: flex;
  438. justify-content: center;
  439. align-items: center;
  440. padding-bottom: 8px;
  441. .title-item {
  442. display: flex;
  443. align-items: center;
  444. .name {
  445. color: rgba(33, 153, 248, 0.85);
  446. }
  447. .value {
  448. color: rgba(0, 0, 0, 0.4);
  449. }
  450. }
  451. .title-item + .title-item {
  452. padding-left: 16px;
  453. }
  454. }
  455. }
  456. .new-wrap {
  457. border-radius: 5px;
  458. text-align: center;
  459. border: 1px solid #444444;
  460. .new-title {
  461. background: rgba(255, 255, 255, 0.04);
  462. border-radius: 5px 5px 0 0;
  463. display: flex;
  464. color: #727272;
  465. // justify-content: space-around;
  466. padding: 5px 6px;
  467. font-size: 14px;
  468. .table-name {
  469. width: 40px;
  470. font-size: 14px;
  471. margin: 0 auto;
  472. }
  473. }
  474. .title-1 {
  475. width: 62px;
  476. }
  477. .title-2 {
  478. flex: 1;
  479. }
  480. .title-3 {
  481. width: 64px;
  482. }
  483. .title-4 {
  484. width: 76px;
  485. }
  486. .title-5 {
  487. width: 68px;
  488. }
  489. .new-table-wrap {
  490. .new-prescription {
  491. padding: 0 8px;
  492. .new-table {
  493. display: flex;
  494. align-items: center;
  495. // border: 1px solid #444444;
  496. border-radius: 5px;
  497. color: #CECECE;
  498. font-size: 16px;
  499. .line-l {
  500. display: flex;
  501. flex: 1;
  502. padding: 8px 0;
  503. .line-2 {
  504. flex: 1;
  505. padding: 0 2px;
  506. }
  507. }
  508. .line-r {
  509. // padding: 8px 0;
  510. &.has-border {
  511. border-left: 1px solid #444444;
  512. }
  513. .line-3 {
  514. display: flex;
  515. align-items: center;
  516. }
  517. .sub-line {
  518. padding: 10px 0;
  519. }
  520. .line-4 {
  521. display: flex;
  522. align-items: center;
  523. border-top: 1px solid #444444;
  524. }
  525. .execute-line {
  526. border-right: 1px solid #444444;
  527. }
  528. }
  529. }
  530. .note-text {
  531. // margin: 8px 0 4px 0;
  532. color: #9F9F9F;
  533. background: rgba(255, 255, 255, 0.05);
  534. padding: 6px 8px;
  535. border-radius: 5px;
  536. text-align: left;
  537. font-size: 16px;
  538. }
  539. }
  540. .new-prescription + .new-prescription {
  541. // margin-top: 8px;
  542. border-top: 1px solid #444444;
  543. }
  544. }
  545. }
  546. </style>