YzEditor.vue 36 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886887888889890891892893894895896897898899900901902903904905906907908909910911912913914915916917918919920921922923924925926927928929930931932933934935936937938939940941942943944945946947948949950951952953954955956957958959960961962963964965966967968969970971972973974975976977978979980981982983984985986987988989990991992993994995996997998999100010011002100310041005100610071008100910101011101210131014101510161017101810191020102110221023102410251026102710281029103010311032103310341035103610371038
  1. <template>
  2. <div ref="editorMainRef" style="min-width: 200px">
  3. <div v-if="tiShiBiaoTi?.length > 0" class="editor__title">
  4. <span v-for="item in tiShiBiaoTi">
  5. {{ item }}
  6. </span>
  7. </div>
  8. <div class="ribbon">
  9. <button @click="qingKong" title="清空工作台">清空工作台</button>
  10. <el-divider direction="vertical"/>
  11. <button @click="toAddAnOrder" title="录入医嘱">录入医嘱</button>
  12. <el-divider direction="vertical"/>
  13. <button @click="copyClick" title="复制当前工作台的医嘱,并粘贴到工作台中">复制</button>
  14. <button @click="pasteClick" :disabled="copyOrderNo.actOrderNo === null"
  15. title="复制当前工作台的医嘱,并粘贴到工作台中">粘贴
  16. </button>
  17. <el-divider direction="vertical"/>
  18. <button @click="duplicateAndPaste" title="复制当前工作台的医嘱,并粘贴到工作台中">复制并粘贴</button>
  19. <el-divider direction="vertical"/>
  20. <button @click="openTheOrderPopUpWindow" title="打开医嘱弹窗,如转科,抗菌药物信息,处置医嘱等">打开医嘱弹窗
  21. </button>
  22. </div>
  23. <div class="editing_area"
  24. :style="{color: isEdit ? '#0014fc' : ''}">
  25. <div class="yz_editor__disable" v-if="isEdit"></div>
  26. <div class="yz_input__box">
  27. <div>
  28. 医嘱名称:
  29. <xc-combo-grid
  30. style="width: 240px"
  31. ref="searchRef"
  32. :disabled="isEdit"
  33. v-model="yiZhuData.orderName"
  34. :table-header="tableHeader"
  35. :query-data-func="searchOrders"
  36. :current-key="yiZhuData.orderCode + yiZhuData.orderName"
  37. @rowClick="xuanZhongFeiYong">
  38. <el-table-column label="说明书" fixed="left">
  39. <template #default="{row}">
  40. <el-button @click.stop="drugManual.open(row.orderCode,row.serial)"
  41. :disabled="row.groupNo === '00'">
  42. 说明书
  43. </el-button>
  44. </template>
  45. </el-table-column>
  46. </xc-combo-grid>
  47. </div>
  48. <div class="input__style">
  49. {{ yiZhuData.drugSpecification }}
  50. </div>
  51. <div>
  52. 频率:
  53. <select-v4
  54. :data="yaoPinPingLvData"
  55. ref="pingLvRef"
  56. key="frequCode"
  57. v-model="yiZhuData.frequCode"
  58. :disabled="queryParam.frequCode === frequCodeEnum.temporary "
  59. style="width: 120px"/>
  60. </div>
  61. <div>
  62. 一次剂量:
  63. <el-input-number v-model="yiZhuData.dose"
  64. :step="jiLiangValue"
  65. :controls="false"
  66. :min="0"
  67. ref="doseRef"
  68. id="yz_dose"
  69. :precision="dosePrecision"
  70. style="width: 110px"
  71. @change="jiSuanLingLiang"/>
  72. <XcSelect v-model="yiZhuData"
  73. :data="yaoPinJiLiangData"
  74. :name="['doseUnit', 'doseUnitName']"
  75. :width="80"
  76. @change="xuanZheJiLiang">
  77. <XcOption label="value"/>
  78. <XcOption label="name"/>
  79. </XcSelect>
  80. </div>
  81. <div>
  82. 领量:
  83. <!-- <el-input-number-->
  84. <!-- style="width: 60px"-->
  85. <!-- v-model="yiZhuData.drugQuan"-->
  86. <!-- :min="1"-->
  87. <!-- :controls="false"/>-->
  88. <!-- <span style="color: red">{{ yiZhuData.miniUnitName }}</span>-->
  89. <!-- 先暂时去掉这个限制 -->
  90. <template v-if="currentPage === 'takeMedicine'">
  91. <el-input-number
  92. style="width: 60px"
  93. v-model="yiZhuData.drugQuan"
  94. :min="1"
  95. :controls="false"/>
  96. <span style="color: red">{{ yiZhuData.miniUnitName }}</span>
  97. </template>
  98. <template v-else-if="yiZhuData.serial === '00'">
  99. <el-input-number
  100. style="width: 60px"
  101. v-model="yiZhuData.drugQuan"
  102. :min="0"
  103. :controls="false"/>
  104. </template>
  105. <template v-else>
  106. {{ yiZhuData.drugQuan }}
  107. {{ yiZhuData.miniUnitName }}
  108. </template>
  109. </div>
  110. </div>
  111. <div class="yz_input__box">
  112. <div>
  113. 给药方式:
  114. <select-v4
  115. key="supplyCode"
  116. :disabled="yiZhuData.serial === '00'"
  117. style="width: 120px"
  118. v-model="yiZhuData.supplyCode"
  119. :data="geiYaoFangShiData"
  120. clearable/>
  121. </div>
  122. <div>
  123. 开始时间:
  124. <el-date-picker
  125. style="width: 160px"
  126. v-model="yiZhuData.startTime"
  127. :disabled-date="disabledDate"
  128. id="yz_startTime"
  129. type="datetime"
  130. format="YYYY-MM-DD HH:mm:ss"
  131. value-format="YYYY-MM-DD HH:mm:ss"
  132. @change="cydyDrugQuan(false)"
  133. ></el-date-picker>
  134. </div>
  135. <div>
  136. 停止时间:
  137. <el-date-picker
  138. style="width: 160px"
  139. v-model="yiZhuData.endTime"
  140. @change="cydyDrugQuan(false)"
  141. id="yz_endTime"
  142. :disabled="yiZhuData.frequCode === 'ONCE'"
  143. :disabled-date="disabledDate"
  144. format="YYYY-MM-DD HH:mm:ss"
  145. type="datetime"
  146. value-format="YYYY-MM-DD HH:mm:ss"
  147. ></el-date-picker>
  148. </div>
  149. <div class="input__style" style="width: 120px">
  150. 医生: {{ yiZhuData.enterOperName ? yiZhuData.enterOperName : store.state.user.info.name }}
  151. </div>
  152. <div>
  153. 执行科室:
  154. <xc-select-v3
  155. style="width: 120px"
  156. v-model="yiZhuData"
  157. :data="zhiXingKeShiData"
  158. id="yz_execUnit"
  159. code="execUnit"
  160. name="execUnitName"
  161. :remote-method="metZhiXingKeShi"/>
  162. </div>
  163. </div>
  164. <div class="yz_input__box">
  165. <div class="div_center__box">
  166. 医嘱时间:
  167. <div class="input__style"> {{ yiZhuData.orderTime }}</div>
  168. </div>
  169. <div>
  170. 父医嘱:
  171. <xc-combo-grid v-model="yiZhuData.parentNoName"
  172. style="width: 120px;"
  173. placeholder="父医嘱"
  174. clearable
  175. @clear="clearDoctorSOrder"
  176. @focus="fuYiZhuClick"
  177. @rowClick="modifyDosingMethod"
  178. :table-header="parentOrder"
  179. :data="fuYiZhuData">
  180. </xc-combo-grid>
  181. </div>
  182. <div :title="yiZhuData.discription" class="div_center__box">
  183. 描述:
  184. <div class="input__style" style="overflow: auto;width: 240px">
  185. {{ yiZhuData.discription }}
  186. </div>
  187. </div>
  188. </div>
  189. <div class="yz_input__box">
  190. <div class="div_center__box" :title="yiZhuData.instruction">
  191. <div style="width: 87px">
  192. 医生嘱托:
  193. </div>
  194. <el-input v-model="yiZhuData.instruction"
  195. clearable
  196. style="width: 220px"
  197. maxlength="50"
  198. show-word-limit/>
  199. </div>
  200. <div class="div_center__box">
  201. <el-select
  202. v-model="yiZhuData.kfFlag"
  203. id="yz_kfFlag"
  204. clearable
  205. style="width: 80px"
  206. @clear="yiZhuData.kfFlag = null">
  207. <el-option key="1" label="饭前" value="1"></el-option>
  208. <el-option key="2" label="饭后" value="2"></el-option>
  209. </el-select>
  210. </div>
  211. <div>
  212. 费用标志:
  213. <el-select v-model="yiZhuData.selfBuy"
  214. :disabled="yiZhuData.serial === '00'"
  215. clearable style="width: 120px"
  216. @clear="yiZhuData.selfBuy = null">
  217. <el-option label="自备" value="1"/>
  218. <el-option label="嘱托" value="2"/>
  219. <el-option label="基数药" value="3"/>
  220. <el-option :disabled="currentPage !== 'takeMedicine'" label="出院带药" value="4"/>
  221. </el-select>
  222. </div>
  223. <div class="div_center__box">
  224. <xc-checkbox
  225. label="医保自费"
  226. v-model="yiZhuData.ybSelfFlag"
  227. inactive-value="0"
  228. active-value="1"/>
  229. &nbsp;&nbsp;&nbsp;
  230. <xc-checkbox
  231. label="紧急"
  232. v-model="yiZhuData.emergencyFlag"
  233. @keydown.tab="toAddAnOrder"
  234. active-value="1"
  235. inactive-value="0"/>
  236. </div>
  237. <div>
  238. 录入/确认/停止
  239. <div style="display: inline-block">
  240. <span style="background-color:#05ff00;padding: 2px;">
  241. {{ yiZhuData.enterOperName }}
  242. </span>
  243. /
  244. <span style="background-color:#0000fa;padding: 2px;color: white ">
  245. {{ yiZhuData.signerName }}
  246. </span>
  247. /
  248. <span style="background-color:red;padding: 2px;">
  249. {{ yiZhuData.modifierName }}
  250. </span>
  251. </div>
  252. </div>
  253. </div>
  254. </div>
  255. <!-- 报错信息 -->
  256. <bao-cun-xin-xi @clickError="clickError"
  257. :data="errorMessageData"
  258. :currentKey="yiZhuData.actOrderNo"
  259. ref="baoCunXinXiRef"/>
  260. <!-- 弹窗医嘱 -->
  261. <yz-dialog :yz-data="yiZhuData" ref="yzDialogRef"/>
  262. </div>
  263. </template>
  264. <script setup name='YzEditor'>
  265. import {
  266. confirmOrders, copyOrder,
  267. copyTheDoctorSOrder,
  268. enterOrders,
  269. getOrderNo,
  270. getParentOrders,
  271. huoQuFeiYongXinXi,
  272. huoQuXiangMu,
  273. huoQuZhiXinKeShi,
  274. toDeleteAnOrder
  275. } from '@/api/zhu-yuan-yi-sheng/yi-zhu-lu-ru'
  276. import {listNotBlank, stringIsBlank, stringNotBlank} from '@/utils/blank-utils'
  277. import {getServerDateApi} from '@/api/public-api'
  278. import Sleep from '@/utils/sleep'
  279. import XcComboGrid from "@/components/xiao-chan/combo-grid/XcComboGrid";
  280. import XcSelectV3 from "@/components/xiao-chan/select-v3/XcSelectV3";
  281. import XcOption from "@/components/xiao-chan/select/XcOption";
  282. import XcSelect from "@/components/xiao-chan/select/XcSelect";
  283. import store from "@/store"
  284. import XcCheckbox from "@/components/xiao-chan/checkbox/XcCheckbox";
  285. import {BizException, ExceptionEnum} from "@/utils/BizException";
  286. import BaoCunXinXi from "@/components/zhu-yuan-yi-sheng/yi-zhu-lu-ru/BaoCunXinXi";
  287. import {clone} from "@/utils/clone";
  288. import {
  289. queryParam,
  290. yiZhuData,
  291. yzData,
  292. currentPage,
  293. isCydy,
  294. drugManual,
  295. tableHeader,
  296. frequCodeEnum,
  297. yaoPinPingLvData,
  298. geiYaoFangShiData, yzMitt, tempYzData
  299. } from "@/views/hospitalization/zhu-yuan-yi-sheng/public-js/zhu-yuan-yi-sheng";
  300. import {ElMessageBox} from "element-plus";
  301. import YzDialog from "@/components/zhu-yuan-yi-sheng/yi-zhu-lu-ru/dialog/YzDialog";
  302. import Dig from "@/utils/math";
  303. import SelectV4 from "@/components/xiao-chan/select-v4/SelectV4.vue";
  304. import {shortcutTrigger, xcEvent} from "@/utils/xckeydown";
  305. import {xcMessage} from "@/utils/xiaochan-element-plus";
  306. const props = defineProps({
  307. patientInfo: {
  308. type: Object,
  309. default: null
  310. },
  311. openGroupOrderTemplate: Function,
  312. })
  313. const emits = defineEmits(['successfullyEntered'])
  314. let parentOrder = [
  315. {prop: 'actOrderNo', label: "医嘱号"},
  316. {prop: 'orderName', label: "医嘱名称", width: 250},
  317. {prop: 'orderTime', label: "时间"}
  318. ]
  319. const searchOrders = (val) => {
  320. return huoQuXiangMu(val, queryParam.value.groupNo)
  321. }
  322. /*提示信息*/
  323. const tiShiBiaoTi = ref([])
  324. // 填充数据
  325. const xuanZhongFeiYong = async (row, laiyuan = 1) => {
  326. console.log(row)
  327. if (row.serial === '0000' && row.groupNo === '0000') {
  328. props.openGroupOrderTemplate(row.orderCode);
  329. return;
  330. }
  331. if (row.serial === '00' && isCydy()) {
  332. qingKong()
  333. return BizException(ExceptionEnum.LOGICAL_ERROR, '出院带药不能开项目')
  334. }
  335. if (yiZhuData.value.actOrderNo === 'tempOrderNo') {
  336. yiZhuData.value.actOrderNo = await getOrderNo()
  337. }
  338. let tempOrderNo = null
  339. // 查询医嘱是不会有医嘱号的,医生会在原来的医嘱上面修改成项目或者药品
  340. // 保留一下医嘱号 不然 yiZhuData.value = row 这个会把医嘱号给干掉
  341. if (laiyuan === 1) {
  342. tempOrderNo = yiZhuData.value.actOrderNo
  343. }
  344. await fuYiZhuClick()
  345. qingKong()
  346. await Sleep(200)
  347. // 克隆一下数据防止有问题
  348. yiZhuData.value = clone(row) // clone(row)
  349. if (tempOrderNo !== null) {
  350. yiZhuData.value.actOrderNo = tempOrderNo;
  351. yiZhuData.value.statusFlag = '1'
  352. }
  353. let newData = yiZhuData.value.statusFlag === '1'
  354. if (row.serial === '01' || row.serial === '99') {
  355. try {
  356. let queryKey = row.orderCode + '_' + row.serial + '_' + props.patientInfo.zkWard + '_' + queryParam.value.groupNo
  357. let res = await huoQuFeiYongXinXi(queryKey)
  358. console.log(res)
  359. // 加载药品计量
  360. yaoPinJiLiangData.value = res.yaoPingJiLiang
  361. if (newData) {
  362. // 判断是否 是皮试的药 如果是就只能有这些 给药方式
  363. // geiYaoFangShiData.value = res.piShi
  364. // 是否是 抗菌药物
  365. yiZhuData.value.kjywFlag = res.data.kjywFlag
  366. // 提示信息
  367. tiShiBiaoTi.value = res.prompt
  368. // 最小单位名称
  369. if (row.serial === '01') {
  370. yiZhuData.value.miniUnit = res.data.miniUnit;
  371. yiZhuData.value.miniUnitName = res.data.miniUnitName;
  372. } else {
  373. yiZhuData.value.miniUnit = res.data.packUnit;
  374. yiZhuData.value.miniUnitName = res.data.packUnitName;
  375. }
  376. yiZhuData.value.packSize = res.data.packSize
  377. yiZhuData.value.packUnit = res.data.packUnit
  378. yiZhuData.value.drugVolume = res.data.volum
  379. yiZhuData.value.drugVolUnit = res.data.volUnit
  380. // 加载 剂量单位
  381. if (stringNotBlank(yiZhuData.value.doseUnit)) {
  382. yaoPinJiLiangData.value.forEach((item) => {
  383. if (item.code === yiZhuData.value.doseUnit) {
  384. jiLiangValue.value = item.value
  385. }
  386. })
  387. } else if (listNotBlank(yaoPinJiLiangData.value)) {
  388. // 没有剂量单位的时候默认加载第一个计量单位 并且计算
  389. yiZhuData.value.doseUnit = yaoPinJiLiangData.value[0].code
  390. yiZhuData.value.dose = yaoPinJiLiangData.value[0].value
  391. jiLiangValue.value = yaoPinJiLiangData.value[0].value
  392. }
  393. await jiSuanLingLiang(yiZhuData.value.dose)
  394. // 加载默认频率 如果已经填写了 就用有的
  395. if (stringIsBlank(row.frequCode)) {
  396. // 如果药品中自带了 频率就用药品表的频率
  397. if (stringNotBlank(res.data.frequCode)) {
  398. yiZhuData.value.frequCode = res.data.frequCode
  399. yiZhuData.value.frequCodeName = res.data.frequCodeName
  400. } else {
  401. yiZhuData.value.frequCode = 'ONCE'
  402. yiZhuData.value.frequCodeName = '一次'
  403. }
  404. }
  405. // 加载给药方式 如果已经有了就没事了
  406. if (stringIsBlank(yiZhuData.value.supplyCode)) {
  407. if (stringNotBlank(res.data.supplyCode)) {
  408. yiZhuData.value.supplyCode = res.data.supplyCode
  409. yiZhuData.value.supplyCodeName = res.data.supplyCodeName
  410. }
  411. }
  412. }
  413. openTheOrderPopUpWindow()
  414. } catch (e) {
  415. if (yiZhuData.value.statusFlag === '1') {
  416. await Sleep(200)
  417. qingKong()
  418. }
  419. }
  420. } else {
  421. yiZhuData.value.kjywFlag = 0
  422. try {
  423. let queryKey = row.orderCode + '_' + '00' + '_' + props.patientInfo.zkWard + '_' + queryParam.value.groupNo
  424. let res = await huoQuFeiYongXinXi(queryKey)
  425. if (newData) {
  426. openTheOrderPopUpWindow('请输入处置医嘱名')
  427. if (stringNotBlank(res.prompt)) {
  428. tiShiBiaoTi.value = res.prompt
  429. }
  430. if (!row.dose) {
  431. yiZhuData.value.dose = 1
  432. }
  433. // 如果是项目就不需要给药方式
  434. yiZhuData.value.supplyCode = null
  435. yiZhuData.value.supplyCodeName = ''
  436. }
  437. } catch (e) {
  438. if (yiZhuData.value.statusFlag === '1') {
  439. await Sleep(200)
  440. qingKong()
  441. }
  442. }
  443. }
  444. if (newData) {
  445. // 判断这个是不是 新添加的数据 如果是空的就是 新数据
  446. let serverDate = await getServerDateApi()
  447. if (!yiZhuData.value.orderTime) {
  448. yiZhuData.value.orderTime = serverDate
  449. }
  450. if (!yiZhuData.value.startTime) {
  451. yiZhuData.value.startTime = serverDate
  452. }
  453. // 用来加载默认的执行科室
  454. if (stringIsBlank(row.execUnit)) {
  455. if (stringNotBlank(props.patientInfo.zkWard)) {
  456. yiZhuData.value.execUnit = props.patientInfo.zkWard
  457. yiZhuData.value.execUnitName = props.patientInfo.zkWardName
  458. }
  459. } else if (props.patientInfo.zkWard && row.execUnit.startsWith("8")) {
  460. yiZhuData.value.execUnit = props.patientInfo.zkWard
  461. yiZhuData.value.execUnitName = props.patientInfo.zkWardName
  462. }
  463. if (!yiZhuData.value.frequCode) {
  464. yiZhuData.value.frequCode = 'ONCE'
  465. yiZhuData.value.frequCodeName = '一次'
  466. }
  467. try {
  468. pingLvRef.value.focus()
  469. } catch (e) {
  470. console.log(e)
  471. }
  472. if (queryParam.value.frequCode === frequCodeEnum.temporary) {
  473. yiZhuData.value.frequCode = 'ONCE'
  474. yiZhuData.value.frequCodeName = '一次'
  475. }
  476. }
  477. if (currentPage.value === 'takeMedicine') {
  478. yiZhuData.value.selfBuy = '4'
  479. yiZhuData.value.frequCode = 'ONCE'
  480. yiZhuData.value.supplyCode = '007'
  481. }
  482. // 显示父医嘱的名称
  483. if (yiZhuData.value.statusFlag !== '1' && yiZhuData.value.parentNo) {
  484. fuYiZhuData.value = []
  485. fuYiZhuData.value.push({
  486. actOrderNo: yiZhuData.value.parentNo,
  487. orderName: yiZhuData.value.parentNoName,
  488. })
  489. }
  490. // 如果搜索了医嘱那么 这里就需要 重新赋值,不认表格就没办法变化了,把原来的换掉
  491. for (let i = 0, len = yzData.value.length; i < len; i++) {
  492. let item = yzData.value[i];
  493. if (yiZhuData.value.actOrderNo === item.actOrderNo) {
  494. yzData.value[i] = yiZhuData.value
  495. return
  496. }
  497. }
  498. if (laiyuan === 1) {
  499. if (currentPage.value === frequCodeEnum.temporary && yiZhuData.value.frequCode !== 'ONCE') {
  500. yiZhuData.value.frequCode = 'ONCE'
  501. } else if (currentPage.value === frequCodeEnum.longTerm && yiZhuData.value.frequCode === 'ONCE') {
  502. yiZhuData.value.frequCode = 'ALWAYS'
  503. }
  504. }
  505. }
  506. /* 频率 */
  507. const pingLvRef = ref()
  508. /*计算领量*/
  509. const jiSuanLingLiang = async (val) => {
  510. await nextTick()
  511. // 出院带药
  512. if (yiZhuData.value.selfBuy === '4') {
  513. return;
  514. }
  515. if (jiLiangValue.value <= 0) {
  516. return;
  517. }
  518. let drugQuanA = Math.ceil(Dig.division(val, jiLiangValue.value))
  519. yiZhuData.value.drugQuan = drugQuanA;
  520. }
  521. /* 选择剂量 */
  522. const yaoPinJiLiangData = ref([])
  523. const jiLiangValue = ref(0)
  524. const xuanZheJiLiang = (val) => {
  525. jiLiangValue.value = val.value
  526. yiZhuData.value.dose = val.value
  527. jiSuanLingLiang(yiZhuData.value.dose)
  528. }
  529. /* 给药方式 */
  530. // const geiYaoFangShiData = ref([])
  531. // 医嘱限制时间不能在之前
  532. const disabledDate = (time) => {
  533. if (props.patientInfo?.admissDate) {
  534. return time.getTime() < new Date(props.patientInfo?.admissDate).getTime() - 8.64e7
  535. }
  536. return true
  537. }
  538. /* 获取执行科室 */
  539. const zhiXingKeShiData = ref([])
  540. const metZhiXingKeShi = (val) => {
  541. huoQuZhiXinKeShi(val).then((res) => {
  542. zhiXingKeShiData.value = res
  543. })
  544. }
  545. /* 父医嘱 */
  546. const fuYiZhuData = ref([])
  547. const fuYiZhuClick = async () => {
  548. fuYiZhuData.value = []
  549. fuYiZhuData.value = await getParentOrders(props.patientInfo.inpatientNo, props.patientInfo.admissTimes)
  550. let tempIndex = fuYiZhuData.value.findIndex(item => {
  551. return item.actOrderNo == yiZhuData.value.actOrderNo
  552. })
  553. if (tempIndex > -1) {
  554. fuYiZhuData.value.splice(tempIndex, 1)
  555. }
  556. }
  557. const modifyDosingMethod = (val) => {
  558. if (yiZhuData.value.actOrderNo == val.actOrderNo) {
  559. BizException(ExceptionEnum.MESSAGE_ERROR, '无法选择自己');
  560. }
  561. yiZhuData.value.parentNo = val.actOrderNo
  562. yiZhuData.value.parentNoName = val.orderName
  563. yiZhuData.value.orderTime = val.orderTime
  564. yiZhuData.value.startTime = val.startTime
  565. yiZhuData.value.endTime = val.endTime
  566. yiZhuData.value.supplyCode = '044'
  567. yiZhuData.value.supplyCodeName = '副药'
  568. yiZhuData.value.frequCode = val.frequCode
  569. yiZhuData.value.frequCodeName = val.frequCodeName
  570. yiZhuData.value.groupNo = val.groupNo
  571. yiZhuData.value.groupNoName = val.groupNoName
  572. }
  573. const clearDoctorSOrder = () => {
  574. yiZhuData.value.parentNo = null
  575. yiZhuData.value.parentNoName = ''
  576. }
  577. /**
  578. * 添加医嘱
  579. * @returns {Promise<void>}
  580. */
  581. const addOrderNo = async () => {
  582. if (stringIsBlank(props.patientInfo.inpatientNo)) {
  583. BizException(ExceptionEnum.MESSAGE_ERROR, '请先选择患者')
  584. }
  585. // 如果有录入数据的话就需要保存一下
  586. if (stringNotBlank(yiZhuData.value.actOrderNo) && yiZhuData.value.statusFlag === '1' && yiZhuData.value.actOrderNo !== 'tempOrderNo') {
  587. let param = {
  588. inpatientNo: props.patientInfo.inpatientNo,
  589. admissTimes: props.patientInfo.admissTimes,
  590. actOrderNo: yiZhuData.value.actOrderNo,
  591. groupNo: queryParam.value.groupNo,
  592. data: yiZhuData.value
  593. }
  594. try {
  595. let res = await enterOrders(param)
  596. // 如果有错误信息 就 提示
  597. if (res !== null && res.error) {
  598. baoCunXinXiRef.value.openOrClose()
  599. errorMessageData.value = res.data
  600. return
  601. }
  602. emits('successfullyEntered', yiZhuData.value)
  603. // 医嘱保存了 就删除错误提示
  604. if (errorMessageData.value) {
  605. for (let key in errorMessageData.value) {
  606. if (key === yiZhuData.value.actOrderNo.toString()) {
  607. delete errorMessageData.value[key]
  608. break
  609. }
  610. }
  611. }
  612. // 如果没有了错误信息 就关闭
  613. if (!!errorMessageData.value) {
  614. baoCunXinXiRef.value.openOrClose(false)
  615. }
  616. qingKong()
  617. yiZhuData.value.actOrderNo = 'tempOrderNo'
  618. openSearch()
  619. } catch (e) {
  620. console.log(e)
  621. }
  622. } else {
  623. qingKong()
  624. yiZhuData.value.actOrderNo = 'tempOrderNo'
  625. openSearch()
  626. }
  627. }
  628. const qingKong = () => {
  629. yaoPinJiLiangData.value = []
  630. jiLiangValue.value = 0
  631. tiShiBiaoTi.value = []
  632. tempData = null
  633. yiZhuData.value = {
  634. id: '',
  635. actOrderNo: null,
  636. orderName: '',
  637. orderCode: '',
  638. // 频率
  639. frequCode: '',
  640. frequCodeName: '',
  641. drugSpecification: '',
  642. dose: 0,
  643. // 领量
  644. doseUnit: '',
  645. doseUnitName: '',
  646. supplyCode: '',
  647. supplyCodeName: '',
  648. startTime: '',
  649. endTime: '',
  650. orderTime: '',
  651. doctorName: '',
  652. drugFlag: '',
  653. execUnit: '',
  654. execUnitName: '',
  655. parentNo: '',
  656. parentNoName: '',
  657. physicianName: '',
  658. discription: '',
  659. instruction: null,
  660. kfFlag: null,
  661. selfBuy: null,
  662. ybSelfFlag: '0',
  663. emergencyFlag: '0',
  664. drugQuan: 0,
  665. miniUnitName: '',
  666. serial: '',
  667. miniUnit: '',
  668. psFlag: false,
  669. kjywFlag: 0,
  670. yyfs: null,
  671. ssqk: null,
  672. yysj: null,
  673. zkObj: '',
  674. zkWardCode: '',
  675. zkDeptCode: '',
  676. statusFlag: '1'
  677. }
  678. }
  679. // 判断是否可以编辑
  680. const isEdit = computed(() => {
  681. return !!(stringIsBlank(yiZhuData.value.actOrderNo)
  682. || yiZhuData.value.statusFlag !== '1'
  683. || stringIsBlank(props.patientInfo.inpatientNo));
  684. })
  685. let baoCunXinXiRef = ref(null)
  686. const toAddAnOrder = async () => {
  687. if (stringIsBlank(props.patientInfo.inpatientNo)) {
  688. BizException(ExceptionEnum.MESSAGE_ERROR, '请先选择患者')
  689. }
  690. if (stringIsBlank(yiZhuData.value.actOrderNo) || yiZhuData.value.actOrderNo === 'tempOrderNo') {
  691. BizException(ExceptionEnum.MESSAGE_ERROR, '请先选择一个医嘱')
  692. }
  693. // 有 医嘱 不是 录入就说明在看医嘱 直接清空就可以了
  694. if (stringNotBlank(yiZhuData.value.orderCode) && yiZhuData.value.statusFlag !== '1') {
  695. qingKong()
  696. return
  697. }
  698. if (yiZhuData.value.frequCode === 'ONCE' && currentPage.value === 'longTerm') {
  699. BizException(ExceptionEnum.LOGICAL_ERROR, '长期医嘱页面无法选择临时医嘱频率。')
  700. }
  701. let param = {
  702. inpatientNo: props.patientInfo.inpatientNo,
  703. admissTimes: props.patientInfo.admissTimes,
  704. actOrderNo: yiZhuData.value.actOrderNo,
  705. groupNo: queryParam.value.groupNo,
  706. data: yiZhuData.value
  707. }
  708. try {
  709. let res = await enterOrders(param)
  710. if (res !== null && res.error) {
  711. baoCunXinXiRef.value.openOrClose()
  712. errorMessageData.value = res.data
  713. return
  714. }
  715. if (errorMessageData.value) {
  716. for (let key in errorMessageData.value) {
  717. if (key === yiZhuData.value.actOrderNo.toString()) {
  718. delete errorMessageData.value[key]
  719. break
  720. }
  721. }
  722. }
  723. // 如果错误信息是空的就关闭
  724. if (Object.keys(errorMessageData.value).length === 0) {
  725. baoCunXinXiRef.value.openOrClose(false)
  726. }
  727. emits('successfullyEntered', yiZhuData.value)
  728. qingKong()
  729. } catch (e) {
  730. console.log(e)
  731. }
  732. }
  733. /**
  734. * 点击了确认医嘱
  735. */
  736. const confirmOrdersClick = async () => {
  737. try {
  738. let res = await confirmOrders(props.patientInfo)
  739. if (res !== null && res.error) {
  740. baoCunXinXiRef.value.openOrClose()
  741. errorMessageData.value = res.data
  742. }
  743. } catch (e) {
  744. }
  745. }
  746. const yzDialogRef = ref(null)
  747. const openTheOrderPopUpWindow = () => {
  748. if (!isEdit.value) {
  749. yzDialogRef.value.openOrClose(true)
  750. }
  751. }
  752. // 错误信息
  753. const errorMessageData = ref({})
  754. /**
  755. * 点击了查看错误信息
  756. * @param val 数据
  757. */
  758. const clickError = (val) => {
  759. if (yiZhuData.value.actOrderNo === 'tempOrderNo') {
  760. qingKong()
  761. }
  762. if (stringNotBlank(yiZhuData.value.actOrderNo)) {
  763. let param = {
  764. inpatientNo: props.patientInfo.inpatientNo,
  765. admissTimes: props.patientInfo.admissTimes,
  766. actOrderNo: yiZhuData.value.actOrderNo,
  767. data: yiZhuData.value
  768. }
  769. enterOrders(param).then((res) => {
  770. if (res !== null && res.error) {
  771. errorMessageData.value[yiZhuData.value.actOrderNo] = res.data[yiZhuData.value.actOrderNo]
  772. return
  773. }
  774. delete errorMessageData.value[yiZhuData.value.actOrderNo]
  775. xuanZhongFeiYong(val.data, 2)
  776. }).catch(e => {
  777. })
  778. } else {
  779. xuanZhongFeiYong(val.data, 2)
  780. }
  781. }
  782. /**
  783. * 填充 数据
  784. * @param data
  785. */
  786. let tempData = null
  787. const fillData = async (data) => {
  788. await fuYiZhuClick()
  789. await xuanZhongFeiYong(data, 2)
  790. tempData = JSON.stringify(yiZhuData.value)
  791. }
  792. // 删除医嘱
  793. const toDeleteAnOrderClick = () => {
  794. if (stringIsBlank(yiZhuData.value.actOrderNo)) {
  795. BizException(ExceptionEnum.MESSAGE_ERROR, '请先选择要删除的医嘱')
  796. }
  797. ElMessageBox.confirm(`确认是否要删除<span style="color: red"> ${yiZhuData.value.orderName} </span>`, '提示', {
  798. type: 'warning',
  799. dangerouslyUseHTMLString: true
  800. }).then(() => {
  801. toDeleteAnOrder(yiZhuData.value.actOrderNo).then(() => {
  802. yzMitt.emit('queryYz', false)
  803. qingKong()
  804. })
  805. })
  806. }
  807. const editorMainRef = ref()
  808. const searchRef = ref(null)
  809. const openSearch = () => {
  810. if (isEdit.value) return
  811. searchRef.value.focus()
  812. }
  813. const dosePrecision = computed(() => {
  814. return yiZhuData.value.serial === '00' ? 2 : 3
  815. })
  816. let copyOrderNo = $ref({
  817. actOrderNo: null,
  818. frequCode: '',
  819. deptCode: '',
  820. inpatientNo: '',
  821. admissTimes: 0
  822. })
  823. const copyClick = () => {
  824. if (stringIsBlank(yiZhuData.value.actOrderNo) || yiZhuData.value.actOrderNo === 'tempOrderNo') {
  825. BizException(ExceptionEnum.MESSAGE_ERROR, '请先选择医嘱')
  826. }
  827. copy(yiZhuData.value.actOrderNo, yiZhuData.value.frequCode)
  828. }
  829. const copy = (actOrderNo, frequCode) => {
  830. copyOrderNo.actOrderNo = actOrderNo
  831. copyOrderNo.frequCode = frequCode
  832. xcMessage.success('复制成功。')
  833. }
  834. const pasteClick = () => {
  835. if (currentPage.value === frequCodeEnum.temporary && copyOrderNo.frequCode !== 'ONCE') {
  836. copyOrderNo.frequCode = 'ONCE'
  837. } else if (currentPage.value === frequCodeEnum.longTerm && copyOrderNo.frequCode === 'ONCE') {
  838. copyOrderNo.frequCode = 'ALWAYS'
  839. } else if (currentPage.value === frequCodeEnum.takeMedicine) {
  840. copyOrderNo.frequCode = 'ONCE'
  841. }
  842. copyOrderNo.deptCode = props.patientInfo.zkWard
  843. copyOrderNo.inpatientNo = props.patientInfo.inpatientNo
  844. copyOrderNo.admissTimes = props.patientInfo.admissTimes
  845. copyFuncApi()
  846. }
  847. const copyFuncApi = async () => {
  848. let list = await copyOrder(copyOrderNo)
  849. let temp = {}
  850. list.forEach(item => {
  851. temp[item] = true
  852. })
  853. // 查询医嘱
  854. await yzMitt.emit('queryYz');
  855. yzMitt.emit('scrollEndAndTwinkle', temp)
  856. copyOrderNo.actOrderNo = null
  857. }
  858. /**
  859. * 复制粘贴医嘱
  860. * @returns {Promise<void>}
  861. */
  862. const duplicateAndPaste = () => {
  863. if (stringIsBlank(yiZhuData.value.actOrderNo) || yiZhuData.value.actOrderNo === 'tempOrderNo') {
  864. BizException(ExceptionEnum.MESSAGE_ERROR, '请先选择医嘱')
  865. }
  866. copyOrderNo = {
  867. actOrderNo: yiZhuData.value.actOrderNo,
  868. frequCode: yiZhuData.value.frequCode,
  869. deptCode: props.patientInfo.zkWard,
  870. inpatientNo: props.patientInfo.inpatientNo,
  871. admissTimes: props.patientInfo.admissTimes
  872. }
  873. copyFuncApi()
  874. }
  875. let shortcutKeyRegistration = {
  876. ctrl: {s: toAddAnOrder},
  877. alt: {a: addOrderNo}
  878. }
  879. onMounted(() => {
  880. yzMitt.on('copy', copy)
  881. yzMitt.on('paste', pasteClick)
  882. yzMitt.on('allowReplication', () => {
  883. return copyOrderNo.actOrderNo !== null
  884. })
  885. yzMitt.on('deleteAnOrderByOrderNo', ({actOrderNo, orderName}, clearOrNot = true) => {
  886. if (stringIsBlank(actOrderNo)) {
  887. BizException(ExceptionEnum.MESSAGE_ERROR, '请先选择要删除的医嘱')
  888. }
  889. ElMessageBox.confirm(`确认是否要删除<span style="color: red"> ${orderName} </span>`, '提示', {
  890. type: 'warning',
  891. dangerouslyUseHTMLString: true
  892. }).then(() => {
  893. toDeleteAnOrder(actOrderNo).then(() => {
  894. yzMitt.emit('queryYz', false)
  895. if (clearOrNot) {
  896. qingKong()
  897. }
  898. })
  899. }).catch(() => {
  900. })
  901. })
  902. })
  903. let keyWatch = null
  904. onDeactivated(() => {
  905. if (keyWatch != null) {
  906. keyWatch()
  907. }
  908. })
  909. onActivated(() => {
  910. keyWatch = watch(() => xcEvent.value, () => {
  911. shortcutTrigger(xcEvent.value, shortcutKeyRegistration)
  912. })
  913. })
  914. defineExpose({
  915. addOrderNo,
  916. fillData,
  917. toDeleteAnOrderClick,
  918. confirmOrdersClick,
  919. isEdit
  920. })
  921. </script>
  922. <style scoped lang="scss">
  923. .editing_area {
  924. position: relative;
  925. width: max-content;
  926. }
  927. .editor__title {
  928. background-color: #ffdb04;
  929. padding: 5px;
  930. width: 100%;
  931. overflow-x: auto;
  932. }
  933. .yz_editor__disable {
  934. position: absolute;
  935. height: 100%;
  936. width: 100%;
  937. z-index: 89;
  938. border: 1px solid red;
  939. &::before {
  940. position: absolute;
  941. content: '只读';
  942. bottom: 0;
  943. right: 0;
  944. color: red;
  945. }
  946. }
  947. .yz_input__box {
  948. display: flex;
  949. margin-top: 6px;
  950. flex-wrap: wrap;
  951. div {
  952. margin-left: 3px;
  953. }
  954. .div_center__box {
  955. display: flex;
  956. justify-content: center;
  957. align-items: center;
  958. }
  959. .input__style {
  960. width: 125px;
  961. line-height: 22px;
  962. height: 22px;
  963. border: 1px solid
  964. }
  965. }
  966. </style>