YzEditor.vue 26 KB

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