YzEditor.vue 26 KB

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