血透系统pad前端

AddNewOrders.vue 18KB

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