血透系统pad前端

AddNewOrders.vue 21KB

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