血透系统pad前端

AddNewOrders.vue 20KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640
  1. <template>
  2. <div v-loading="loading">
  3. <div class="Dialog" style="width: 11.8rem;" v-show="show_dialog_key == 0">
  4. <div class="DialogTit">
  5. <div class="back" @click="backAction">
  6. <span class="iconfont">&#xe720;</span>返回
  7. </div>
  8. <h1 class="name">新增医嘱</h1>
  9. <span class="success" @click="comfirmAction">保存</span>
  10. </div>
  11. <div class="yzNav" style="width:100%;">
  12. <span class="newSpan" @click="addOrderByTemplateAction">选择模板</span>
  13. <span class="newSpan" @click="addNewOrderAction">新增内容</span>
  14. <span class="newSpan" @click="modifyOrderAction">修改内容</span>
  15. <span class="newSpan" @click="deleteOrderAction">删除内容</span>
  16. </div>
  17. <div class="content clearfix backgroundColor">
  18. <div style="overflow: hidden;">
  19. <div class="cell" style="margin-top: 0;">
  20. <label>医嘱类型</label>
  21. <el-input
  22. class="typeInput"
  23. ref="advice_type"
  24. value="临时"
  25. disabled
  26. ></el-input>
  27. </div>
  28. <div class="cell" style="margin-top: 0;">
  29. <label>开始时间</label>
  30. <el-input
  31. class="typeInput"
  32. :value="start_time_str"
  33. readonly
  34. @focus="selectStartTimeAction"
  35. ></el-input>
  36. </div>
  37. </div>
  38. <div style="overflow: hidden;margin-top: 15px">
  39. <div class="cell" style="margin-top: 0;">
  40. <label>开嘱医生: {{ $store.getters.user.user.user_name }}</label>
  41. </div>
  42. <div class="cell" style="margin-top: 0;">
  43. <label>开嘱时间 {{ record_date_str }}</label>
  44. </div>
  45. </div>
  46. <div
  47. id="newDialogContent"
  48. class="DialogContent choose"
  49. style="height: 6.2rem;"
  50. >
  51. <div class="newAddTable">
  52. <table class="table">
  53. <tr>
  54. <th width="30%">医嘱内容</th>
  55. <th width="20%">药品规格</th>
  56. <th width="10%">开药数量</th>
  57. <th width="10%">单次用量</th>
  58. <th width="15%">给药途径</th>
  59. <th width="15%">执行频率</th>
  60. </tr>
  61. <template v-for="(advice, advice_index) in advices">
  62. <tr
  63. :key="advice_index"
  64. @click="clickAdviceAction(advice_index)"
  65. :class="{
  66. 'row-class-active':
  67. advice_index == selecting_advice_index &&
  68. selecting_subdrug_index < 0
  69. }"
  70. >
  71. <td
  72. style="text-align: left; padding-left: 5px; padding-right: 5px;"
  73. >
  74. {{ advice.title }}
  75. </td>
  76. <td v-if="advice.advice_desc">
  77. {{ advice.advice_desc }}{{ advice.drug_spec_unit }}
  78. </td>
  79. <td v-if="advice.prescribing_number">
  80. {{ advice.prescribing_number
  81. }}{{ advice.prescribing_number_unit }}
  82. </td>
  83. <td v-else></td>
  84. <td v-if="advice.single_dose">
  85. {{ advice.single_dose }} {{ advice.single_dose_unit }}
  86. </td>
  87. <td v-else></td>
  88. <td>{{ advice.delivery_way }}</td>
  89. <td>{{ advice.execution_frequency }}</td>
  90. </tr>
  91. <tr
  92. v-for="(subdrug, subdrug_index) in advice.subdrugs"
  93. :key="advice_index + '_' + subdrug_index"
  94. @click="clickSubdrugAction(advice_index, subdrug_index)"
  95. :class="{
  96. 'row-class-active':
  97. advice_index == selecting_advice_index &&
  98. subdrug_index == selecting_subdrug_index
  99. }"
  100. >
  101. <td
  102. style="text-align: left; padding-right: 5px; padding-left: 25px;"
  103. >
  104. {{ subdrug.title }}
  105. </td>
  106. <td>
  107. {{ subdrug.advice_desc }} {{ subdrug.drug_spec_unit }}
  108. </td>
  109. <td>
  110. <span v-if="subdrug.prescribing_number">
  111. {{ subdrug.prescribing_number
  112. }}{{ subdrug.prescribing_number_unit }}
  113. </span>
  114. </td>
  115. <td>
  116. <span v-if="subdrug.single_dose">
  117. {{ subdrug.single_dose }}
  118. {{ subdrug.single_dose_unit }}
  119. </span>
  120. </td>
  121. <!--<td v-if="subdrug.single_dose">{{ subdrug.single_dose }} {{ subdrug.single_dose_unit }}</td>-->
  122. <td></td>
  123. <td></td>
  124. </tr>
  125. </template>
  126. </table>
  127. </div>
  128. </div>
  129. </div>
  130. </div>
  131. <!-- <single-option-dialog
  132. :visibility="show_dialog_key == 1"
  133. title="医嘱模板"
  134. @did-selected="didSelectOrderTemplate"
  135. @back="show_dialog_key = 0"
  136. :options="advice_templates"
  137. option_key="id"
  138. option_label_key="name"
  139. ></single-option-dialog>-->
  140. <advice-template
  141. :visibility="show_dialog_key == 1"
  142. @back="show_dialog_key = 0"
  143. @finish="didSelectTemplateAdvice"
  144. :templates="advice_templates"
  145. ></advice-template>
  146. <order-form-dialog
  147. ref="order_form"
  148. @back="show_dialog_key = 0"
  149. @did-create-new="didAddNewOrder"
  150. @did-modify="didModifyOrder"
  151. :drug_spec_unit_options="drug_spec_unit_options"
  152. :delivery_way_options="delivery_way_options"
  153. :execution_frequency_options="execution_frequency_options"
  154. :single_dose_unit_options="single_dose_unit_options"
  155. :prescribing_number_unit_options="prescribing_number_unit_options"
  156. ></order-form-dialog>
  157. <mt-datetime-picker
  158. ref="start_time_picker"
  159. type="datetime"
  160. @confirm="didSelectStartTime"
  161. v-model="start_time"
  162. ></mt-datetime-picker>
  163. </div>
  164. </template>
  165. <script>
  166. import SingleOptionDialog from "./single_option_dialog";
  167. import OrderFormDialog from "./order_form";
  168. import AdviceTemplate from "./select_advice_template_dialog";
  169. import { Toast, Dialog } from "vant";
  170. import { parseTime } from "@/utils";
  171. import { batchCreateAdvices } from "@/api/advice";
  172. import { setTimeout } from "timers";
  173. export default {
  174. name: "AddNewOrdersDialogContent",
  175. components: {
  176. SingleOptionDialog,
  177. OrderFormDialog,
  178. AdviceTemplate
  179. },
  180. props: {
  181. group_no: {
  182. // 新增的医嘱所属分组,不传则默认创建新分组
  183. type: Number,
  184. default: 0
  185. },
  186. patient_id: {
  187. type: Number,
  188. default: 0
  189. },
  190. advice_templates: {
  191. type: Array,
  192. default: function() {
  193. return [];
  194. }
  195. },
  196. drug_spec_unit_options: {
  197. type: Array,
  198. default: function() {
  199. return [];
  200. }
  201. },
  202. delivery_way_options: {
  203. type: Array,
  204. default: function() {
  205. return [];
  206. }
  207. },
  208. execution_frequency_options: {
  209. type: Array,
  210. default: function() {
  211. return [];
  212. }
  213. },
  214. single_dose_unit_options: {
  215. type: Array,
  216. default: function() {
  217. return [];
  218. }
  219. },
  220. prescribing_number_unit_options: {
  221. type: Array,
  222. default: function() {
  223. return [];
  224. }
  225. }
  226. },
  227. data() {
  228. return {
  229. show_dialog_key: 0,
  230. loading: false,
  231. record_date_str: "",
  232. start_time: new Date(),
  233. start_time_str: "",
  234. selecting_advice_index: -1,
  235. selecting_subdrug_index: -1,
  236. advices: []
  237. };
  238. },
  239. mounted() {
  240. this.record_date_str = parseTime(new Date(), "{y}-{m}-{d}");
  241. this.start_time_str =
  242. parseTime(this.start_time, "{y}-{m}-{d} {h}:{i}") + ":00";
  243. },
  244. methods: {
  245. backAction: function() {
  246. this.$emit("back-action");
  247. },
  248. addOrderByTemplateAction: function() {
  249. this.show_dialog_key = 1;
  250. this.selecting_advice_index = -1;
  251. },
  252. addNewOrderAction: function() {
  253. this.show_dialog_key = 2;
  254. this.$refs.order_form.showWithNew();
  255. this.selecting_advice_index = -1;
  256. },
  257. clickAdviceAction: function(advice_index) {
  258. this.selecting_advice_index = advice_index;
  259. this.selecting_subdrug_index = -1;
  260. },
  261. clickSubdrugAction: function(advice_index, subdrug_index) {
  262. this.selecting_advice_index = advice_index;
  263. this.selecting_subdrug_index = subdrug_index;
  264. },
  265. modifyOrderAction: function() {
  266. if (this.selecting_advice_index >= 0) {
  267. if (this.selecting_subdrug_index < 0) {
  268. this.show_dialog_key = 2;
  269. this.$refs.order_form.showWithEdit(
  270. this.advices[this.selecting_advice_index]
  271. );
  272. } else {
  273. this.show_dialog_key = 2;
  274. this.$refs.order_form.showWithEdit(
  275. this.advices[this.selecting_advice_index].subdrugs[
  276. this.selecting_subdrug_index
  277. ]
  278. );
  279. }
  280. } else {
  281. Toast.fail("请先选择医嘱内容");
  282. }
  283. },
  284. deleteOrderAction: function() {
  285. Dialog.confirm({
  286. title: "删除医嘱",
  287. message: "确认删除医嘱吗?"
  288. }).then(() => {
  289. if (this.selecting_advice_index >= 0) {
  290. if (this.selecting_subdrug_index < 0) {
  291. this.advices.splice(this.selecting_advice_index, 1);
  292. this.selecting_advice_index = -1;
  293. } else {
  294. var advice = this.advices[this.selecting_advice_index];
  295. advice.subdrugs.splice(this.selecting_subdrug_index, 1);
  296. this.selecting_advice_index = -1;
  297. this.selecting_subdrug_index = -1;
  298. }
  299. } else {
  300. Toast.fail("请先选择医嘱内容");
  301. }
  302. });
  303. },
  304. selectStartTimeAction: function() {
  305. this.$refs.start_time_picker.open();
  306. },
  307. comfirmAction: function() {
  308. if (this.advices.length == 0) {
  309. Toast.fail("请创建医嘱");
  310. return;
  311. }
  312. var data = {};
  313. data.advice_type = 2;
  314. data.advice_date = this.record_date_str;
  315. data.start_time = this.start_time_str;
  316. var adviceJSONs = [];
  317. for (let index = 0; index < this.advices.length; index++) {
  318. const advice = this.advices[index];
  319. var json = {
  320. advice_name: advice.title,
  321. advice_desc: advice.advice_desc,
  322. drug_spec: String(advice.drug_spec),
  323. drug_spec_unit: advice.drug_spec_unit,
  324. single_dose: String(advice.single_dose),
  325. single_dose_unit: advice.single_dose_unit,
  326. prescribing_number: String(advice.prescribing_number),
  327. prescribing_number_unit: advice.prescribing_number_unit,
  328. delivery_way: advice.delivery_way,
  329. execution_frequency: advice.execution_frequency,
  330. remark: advice.remark,
  331. subdrugs: []
  332. };
  333. for (let s_i = 0; s_i < advice.subdrugs.length; s_i++) {
  334. const subdrug = advice.subdrugs[s_i];
  335. json.subdrugs.push({
  336. advice_name: subdrug.title,
  337. advice_desc: subdrug.advice_desc,
  338. drug_spec: String(subdrug.drug_spec),
  339. drug_spec_unit: subdrug.drug_spec_unit,
  340. single_dose: String(subdrug.single_dose),
  341. single_dose_unit: subdrug.single_dose_unit,
  342. prescribing_number: String(subdrug.prescribing_number),
  343. prescribing_number_unit: subdrug.prescribing_number_unit
  344. });
  345. }
  346. adviceJSONs.push(json);
  347. }
  348. data.adviceNames = adviceJSONs;
  349. // console.log(adviceJSONs)
  350. this.loading = true;
  351. batchCreateAdvices(this.patient_id, this.group_no, data)
  352. .then(rs => {
  353. this.loading = false;
  354. var resp = rs.data;
  355. if (resp.state == 1) {
  356. // 返回数组,清空数据,隐藏弹框
  357. this.$emit("did-create-advices", resp.data.advices);
  358. var t = this;
  359. setTimeout(function() {
  360. t.advices.splice(0, t.advices.length);
  361. t.show_dialog_key = 0;
  362. t.selecting_advice_index = -1;
  363. }, 500);
  364. } else {
  365. Toast.fail(resp.msg);
  366. }
  367. })
  368. .catch(err => {
  369. this.loading = false;
  370. Toast.fail(err);
  371. });
  372. // batchCreateAdvices()
  373. },
  374. didSelectStartTime: function(time) {
  375. this.start_time_str = parseTime(time, "{y}-{m}-{d} {h}:{i}") + ":00";
  376. console.log(".");
  377. },
  378. didSelectTemplateAdvice: function(resp_advices) {
  379. this.show_dialog_key = 0;
  380. var advices = [];
  381. for (let index = 0; index < resp_advices.length; index++) {
  382. const adv = resp_advices[index];
  383. if (adv.parent_id == 0) {
  384. advices.push({
  385. id: adv.id,
  386. title: adv.advice_name,
  387. advice_desc: adv.advice_desc,
  388. drug_spec: adv.drug_spec,
  389. drug_spec_unit: adv.drug_spec_unit,
  390. delivery_way: adv.delivery_way,
  391. execution_frequency: adv.execution_frequency,
  392. single_dose: adv.single_dose,
  393. single_dose_unit: adv.single_dose_unit,
  394. prescribing_number: adv.prescribing_number,
  395. prescribing_number_unit: adv.prescribing_number_unit,
  396. subdrugs: []
  397. });
  398. }
  399. }
  400. for (let r_a_i = 0; r_a_i < resp_advices.length; r_a_i++) {
  401. const resp_adv = resp_advices[r_a_i];
  402. if (resp_adv.parent_id > 0) {
  403. for (let p_i = 0; p_i < advices.length; p_i++) {
  404. const p_adv = advices[p_i];
  405. if (p_adv.id == resp_adv.parent_id) {
  406. var subdrug = {
  407. id: resp_adv.id,
  408. title: resp_adv.advice_name,
  409. advice_desc: resp_adv.advice_desc,
  410. drug_spec: resp_adv.drug_spec,
  411. drug_spec_unit: resp_adv.drug_spec_unit,
  412. delivery_way: resp_adv.delivery_way,
  413. execution_frequency: resp_adv.execution_frequency,
  414. single_dose: resp_adv.single_dose,
  415. single_dose_unit: resp_adv.single_dose_unit,
  416. prescribing_number: resp_adv.prescribing_number,
  417. prescribing_number_unit: resp_adv.prescribing_number_unit
  418. };
  419. p_adv.subdrugs.push(subdrug);
  420. break;
  421. }
  422. }
  423. }
  424. }
  425. this.advices.push(...advices);
  426. },
  427. // didSelectOrderTemplate: function(index) {
  428. // this.show_dialog_key = 0;
  429. // var template = this.advice_templates[index];
  430. // var advices = [];
  431. // for (
  432. // let index = 0;
  433. // index < template.DoctorAdviceTemplate.length;
  434. // index++
  435. // ) {
  436. // const temp = template.DoctorAdviceTemplate[index];
  437. // if (temp.parent_id == 0) {
  438. // var advice = {
  439. // id: temp.id,
  440. // title: temp.advice_name,
  441. // advice_desc: temp.advice_desc,
  442. // // drug_spec: temp.drug_spec,
  443. // // drug_spec_unit: temp.drug_spec_unit,
  444. // delivery_way: temp.delivery_way,
  445. // execution_frequency: temp.execution_frequency,
  446. // single_dose: temp.single_dose,
  447. // single_dose_unit: temp.single_dose_unit,
  448. // prescribing_number: temp.prescribing_number,
  449. // prescribing_number_unit: temp.prescribing_number_unit,
  450. // subdrugs: []
  451. // };
  452. // advices.push(advice);
  453. // }
  454. // }
  455. // for (
  456. // let temp_i = 0;
  457. // temp_i < template.DoctorAdviceTemplate.length;
  458. // temp_i++
  459. // ) {
  460. // const temp = template.DoctorAdviceTemplate[temp_i];
  461. // if (temp.parent_id > 0) {
  462. // for (let p_i = 0; p_i < advices.length; p_i++) {
  463. // const advice = advices[p_i];
  464. // if (advice.id == temp.parent_id) {
  465. // var subdrug = {
  466. // id: temp.id,
  467. // title: temp.advice_name,
  468. // advice_desc: temp.advice_desc,
  469. // // drug_spec: temp.drug_spec,
  470. // // drug_spec_unit: temp.drug_spec_unit,
  471. // delivery_way: temp.delivery_way,
  472. // execution_frequency: temp.execution_frequency,
  473. // single_dose: temp.single_dose,
  474. // single_dose_unit: temp.single_dose_unit,
  475. // prescribing_number: temp.prescribing_number,
  476. // prescribing_number_unit: temp.prescribing_number_unit
  477. // };
  478. // advice.subdrugs.push(subdrug);
  479. // break;
  480. // }
  481. // }
  482. // }
  483. // }
  484. // this.advices.push(...advices);
  485. // },
  486. didAddNewOrder: function(order) {
  487. this.$refs.order_form.dismiss();
  488. this.show_dialog_key = 0;
  489. order.id = 0;
  490. order.subdrugs = [];
  491. this.advices.push(order);
  492. },
  493. didModifyOrder: function(order) {
  494. this.$refs.order_form.dismiss();
  495. this.show_dialog_key = 0;
  496. if (this.selecting_advice_index >= 0) {
  497. var advice = this.advices[this.selecting_advice_index];
  498. if (this.selecting_subdrug_index < 0) {
  499. advice.title = order.title;
  500. advice.advice_desc = order.advice_desc;
  501. // advice.drug_spec = order.drug_spec;
  502. advice.drug_spec_unit = order.drug_spec_unit;
  503. advice.delivery_way = order.delivery_way;
  504. advice.execution_frequency = order.execution_frequency;
  505. advice.single_dose = order.single_dose;
  506. advice.single_dose_unit = order.single_dose_unit;
  507. advice.prescribing_number = order.prescribing_number;
  508. advice.prescribing_number_unit = order.prescribing_number_unit;
  509. advice.remark = order.remark;
  510. } else {
  511. var subdrug = advice.subdrugs[this.selecting_subdrug_index];
  512. subdrug.title = order.title;
  513. subdrug.advice_desc = order.advice_desc;
  514. // subdrug.drug_spec = order.drug_spec;
  515. subdrug.drug_spec_unit = order.drug_spec_unit;
  516. subdrug.single_dose = order.single_dose;
  517. subdrug.single_dose_unit = order.single_dose_unit;
  518. subdrug.prescribing_number = order.prescribing_number;
  519. subdrug.prescribing_number_unit = order.prescribing_number_unit;
  520. }
  521. }
  522. }
  523. }
  524. };
  525. </script>
  526. <style style="stylesheet/scss" lang="scss" scoped>
  527. #newDialogContent {
  528. @media only screen and (max-width: 415px) {
  529. height: 8.8rem !important;
  530. }
  531. @media only screen and (min-width: 768px) {
  532. height: 7.8rem !important;
  533. }
  534. }
  535. .backgroundColor {
  536. background: #fff;
  537. }
  538. .newAddTable {
  539. width: 100%;
  540. // overflow: auto;
  541. }
  542. .table {
  543. width: 1200px;
  544. overflow-x: scroll;
  545. // margin-top: 0rem;
  546. @media only screen and (max-width: 767px) {
  547. width: 1000px;
  548. }
  549. tr {
  550. th {
  551. background: $main-color;
  552. color: #fff;
  553. height: 1.2rem;
  554. line-height: 1.2rem;
  555. }
  556. td {
  557. line-height: 1.2rem;
  558. }
  559. }
  560. }
  561. .content {
  562. .cell {
  563. float: left;
  564. width: 4.5rem;
  565. margin: 0.35rem 0.3rem 0 0.4rem;
  566. label {
  567. display: block;
  568. height: 0.6rem;
  569. line-height: 0.6rem;
  570. color: $pgh-color;
  571. font-size: 0.45rem;
  572. margin-bottom: 0.2rem;
  573. }
  574. select {
  575. width: 100%;
  576. padding: 0.2rem 0;
  577. border: 1px $border-color solid;
  578. border-radius: 2px;
  579. padding-left: 5px;
  580. }
  581. .inputBox {
  582. border: 1px $border-color solid;
  583. border-radius: 2px;
  584. padding: 0.18rem 0;
  585. padding-left: 5px;
  586. }
  587. .textarea {
  588. width: 100%;
  589. height: 1.22rem;
  590. border: 1px $border-color solid;
  591. border-radius: 2px;
  592. padding-left: 5px;
  593. }
  594. }
  595. .doctor-name {
  596. line-height: 0.7rem;
  597. font-size: 0.35rem;
  598. margin-left: 0.4rem;
  599. }
  600. .row-class-active > td {
  601. background: #badcff !important;
  602. }
  603. }
  604. .newSpan {
  605. padding: 0 0.3rem;
  606. }
  607. </style>
  608. <style lang="scss">
  609. .newAddTable {
  610. .table tr td {
  611. padding: 0;
  612. }
  613. }
  614. .typeInput {
  615. .el-input__inner {
  616. @media only screen and (min-width: 768px) {
  617. height: 60px;
  618. line-height: 60px;
  619. }
  620. }
  621. }
  622. </style>