XinZhengCaoYao.vue 16 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530
  1. <template>
  2. <CyFlex content-size>
  3. <template #header>
  4. <div>
  5. <el-button type="primary" @click="openCaoYaoTemplate">取模板</el-button>
  6. <el-button :disabled="mingXi.list.length === 0" type="success" @click="cunMuBan.dialog = true">存模板
  7. </el-button>
  8. <el-divider direction="vertical"></el-divider>
  9. <el-button :disabled="mingXi.list.length === 0" type="success" @click="dianJiBaoCunCaoYao">保存数据
  10. </el-button>
  11. <cao-yao-cuo-wu-xin-xin :data="errorMsg"/>
  12. </div>
  13. <div style="margin-top: 5px">
  14. <el-form label-width="120px">
  15. <el-row>
  16. <el-col :span="6">
  17. <el-form-item class="bi_tian" label="处方名:">
  18. <el-input v-model="chuFang.orderName" style="width: 120px"></el-input>
  19. </el-form-item>
  20. </el-col>
  21. <el-col :span="6">
  22. <el-form-item class="bi_tian" label="剂数:">
  23. <el-input-number v-model="chuFang.quantity" :min="0"></el-input-number>
  24. </el-form-item>
  25. </el-col>
  26. <el-col :span="6" v-if="show">
  27. <el-form-item class="bi_tian" label="代煎:">
  28. <el-input-number v-model="chuFang.quantityDj"
  29. :max="chuFang.quantity"
  30. :min="0"/>
  31. </el-form-item>
  32. </el-col>
  33. <el-col :span="6">
  34. <el-form-item class="bi_tian" label="执行科室:">
  35. <dept-select v-model="chuFang.execDept"/>
  36. </el-form-item>
  37. </el-col>
  38. <el-col :span="6">
  39. <el-form-item label="每日剂数:">
  40. <el-input-number v-model="chuFang.cyMtjs"></el-input-number>
  41. </el-form-item>
  42. </el-col>
  43. <el-col :span="6">
  44. <el-form-item label="类型:">
  45. <el-select v-model="chuFang.cyJssm" clearable filterable size="small" style="width: 120px">
  46. <el-option v-for="item in jiaShuiLeiXing"
  47. :key="item.code"
  48. :label="item.name"
  49. :value="item.code"/>
  50. </el-select>
  51. </el-form-item>
  52. </el-col>
  53. <el-col :span="6">
  54. <el-form-item label="加水量(ml):">
  55. <el-input-number v-model="chuFang.cyJsl"/>
  56. </el-form-item>
  57. </el-col>
  58. <el-col :span="6" v-if="show">
  59. <el-form-item label="煮取(ml):">
  60. <el-input-number v-model="chuFang.cyZql"/>
  61. </el-form-item>
  62. </el-col>
  63. <el-col :span="6" v-if="show">
  64. <el-form-item label="复煎:">
  65. <el-input-number v-model="chuFang.cyFj"/>
  66. </el-form-item>
  67. </el-col>
  68. <el-col :span="6">
  69. <el-form-item label="分几次:">
  70. <el-input-number v-model="chuFang.cyFfcs"/>
  71. </el-form-item>
  72. </el-col>
  73. <el-col :span="6">
  74. <el-form-item label="服用说明:">
  75. <el-select v-model="chuFang.cyFysm" clearable filterable size="small" style="width: 120px">
  76. <el-option v-for="item in fuYongFangFaShuJu" :key="item.code" :label="item.name"
  77. :value="item.code">
  78. <span style="color: #8492a6; font-size: 12px">{{ item.code }}</span>
  79. <el-divider direction="vertical"></el-divider>
  80. <span>{{ item.name }}</span></el-option>
  81. </el-select>
  82. </el-form-item>
  83. </el-col>
  84. <el-col :span="6">
  85. <el-form-item class="bi_tian" label="药房:">
  86. <el-switch
  87. v-model="chuFang.groupNo"
  88. active-color="#13ce66"
  89. active-text="中药颗粒"
  90. active-value="83"
  91. inactive-color="#fbbd08"
  92. inactive-text="草药"
  93. inactive-value="81"
  94. @change="clearHerbalInformation">
  95. </el-switch>
  96. </el-form-item>
  97. </el-col>
  98. </el-row>
  99. </el-form>
  100. <el-divider></el-divider>
  101. <el-form label-width="120px">
  102. <el-row>
  103. <el-col :span="6">
  104. <el-form-item class="bi_tian" label="药品编码:">
  105. <CyComboGrid v-model="caoYao"
  106. value="chargeCode"
  107. label="chargeCodeName"
  108. @rowClick="({row}) => dianJiXuanZhongCaoYao(row)"
  109. :table-header="headerTable"
  110. :remote-method="queryHerbalMedicineOrder"
  111. ref="xcComboRef"
  112. >
  113. </CyComboGrid>
  114. </el-form-item>
  115. </el-col>
  116. <el-col :span="6">
  117. <el-form-item label="数量:">
  118. <el-input-number v-model="caoYao.quantity" :min="1"/>
  119. </el-form-item>
  120. </el-col>
  121. <el-col :span="6">
  122. <el-form-item label="说明:">
  123. <el-input v-model="caoYao.instruction"
  124. :maxlength="30"
  125. clearable
  126. show-word-limit
  127. type="textarea"
  128. @keydown.tab="addTo"/>
  129. <el-button @click="addTo">添加</el-button>
  130. </el-form-item>
  131. </el-col>
  132. </el-row>
  133. </el-form>
  134. </div>
  135. </template>
  136. <template #default="{height}">
  137. <el-table :data="mingXi.list"
  138. style="width: 100%"
  139. :height="height"
  140. highlight-current-row stripe
  141. @row-click="dianJiBianJi">
  142. <el-table-column type="index"></el-table-column>
  143. <el-table-column label="编码" prop="chargeCode"></el-table-column>
  144. <el-table-column label="名称" prop="chargeCodeName"></el-table-column>
  145. <el-table-column label="数量" prop="quantity"></el-table-column>
  146. <el-table-column label="金额" prop="je"></el-table-column>
  147. <el-table-column label="规格" prop="specification"></el-table-column>
  148. <el-table-column label="单价" prop="retprice"></el-table-column>
  149. <el-table-column label="药房" prop="groupName"></el-table-column>
  150. <el-table-column label="说明" prop="instruction"></el-table-column>
  151. <el-table-column label="包装大小" prop="serial">
  152. <template #default="scope">
  153. <span v-if="scope.row.serial === '01'">小包装</span>
  154. <span v-else-if="scope.row.serial === '99'">大包装</span>
  155. </template>
  156. </el-table-column>
  157. <el-table-column label="操作">
  158. <template #default="scope">
  159. <el-button
  160. circle
  161. icon="Delete"
  162. type="danger"
  163. @click="removeHerbs(scope.$index)"
  164. >
  165. </el-button>
  166. </template>
  167. </el-table-column>
  168. </el-table>
  169. </template>
  170. </CyFlex>
  171. <!-- 获取草药模板 -->
  172. <cao-yao-mu-ban v-if="muBanZuJian"
  173. @close="muBanZuJian = false"
  174. @xuanZhongShuJu="dianJiXuanZhongMuBanShuJu"></cao-yao-mu-ban>
  175. <!-- 下面是新增模板 -->
  176. <el-dialog v-model="cunMuBan.dialog" center title="存模板">
  177. 模板名称:
  178. <el-input v-model="cunMuBan.patternName" clearable maxlength="30" show-word-limit
  179. @keyup.enter="dianJiCunMuBan"></el-input>
  180. </el-dialog>
  181. </template>
  182. <script setup>
  183. import {computed, onMounted, ref, watch} from 'vue'
  184. import {
  185. cuoWuXinXi,
  186. huanZheXinXi,
  187. youWuXuanZheHuanZhe,
  188. mingXi,
  189. onChangePatient
  190. } from '@/views/hospitalization/zhu-yuan-yi-sheng/public-js/zhu-yuan-yi-sheng'
  191. import {
  192. baoCunCaoYao,
  193. chongFuMuBanMing,
  194. cunMuBanApi,
  195. fuYongFangFa,
  196. huoQuCaoYao
  197. } from '@/api/zhu-yuan-yi-sheng/cao-yao-yi-zhu'
  198. import {ElMessage, ElMessageBox} from 'element-plus'
  199. import {stringIsBlank, stringNotBlank} from '@/utils/blank-utils'
  200. import CaoYaoMuBan from '@/components/zhu-yuan-yi-sheng/cao-yao-yi-zhu/CaoYaoMuBan.vue'
  201. import {yaoPinXiangMuPiPeiYiBao} from '@/api/public-api'
  202. import sleep from "@/utils/sleep";
  203. import CaoYaoCuoWuXinXin from "@/components/zhu-yuan-yi-sheng/cao-yao-yi-zhu/CaoYaoCuoWuXinXin.vue";
  204. import DeptSelect from "@/components/xiao-chan/dept-code/DeptSelect.vue";
  205. import Dig from "@/utils/math";
  206. import CyFlex from "@/components/cy/flex/src/CyFlex.vue";
  207. import CyComboGrid from "@/components/cy/combo-grid/src/CyComboGrid.vue";
  208. import {useUserStore} from "@/pinia/user-store";
  209. import useDialogToJs from "@/components/js-dialog-comp/useDialogToJs";
  210. const props = defineProps({
  211. saveSuccess: Function
  212. })
  213. /**
  214. * 处方信息
  215. */
  216. const chuFang = ref({
  217. orderName: '草药',
  218. quantity: 0,
  219. quantityDj: 0,
  220. cyMtjs: 0,
  221. cyJsl: 400,
  222. cyZql: 200,
  223. cyFj: 0,
  224. cyFfcs: 0,
  225. cyJssm: '',
  226. groupNo: '81',
  227. execDept: ''
  228. })
  229. const show = computed(() => {
  230. return chuFang.value.groupNo !== '83'
  231. })
  232. /**
  233. * 编辑草药
  234. * @type {Ref<UnwrapRef<{chargeCodeName: string, quantity: number, retprice: number, instruction: string, je: string, chargeCode: string}>>}
  235. */
  236. const caoYao = ref({
  237. chargeCode: '',
  238. chargeCodeName: '',
  239. quantity: 0,
  240. retprice: 0,
  241. instruction: '',
  242. je: '',
  243. })
  244. // 清空数据
  245. const wipeData = () => {
  246. mingXi.value.list = []
  247. mingXi.value.weiYi = []
  248. caoYao.value = {
  249. chargeCode: '',
  250. chargeCodeName: '',
  251. quantity: 0,
  252. retprice: 0,
  253. instruction: '',
  254. je: '',
  255. }
  256. chuFang.value = {
  257. orderName: '草药',
  258. quantity: 0,
  259. quantityDj: 0,
  260. cyMtjs: 0,
  261. cyJsl: 400,
  262. cyZql: 200,
  263. cyFj: 0,
  264. cyFfcs: 0,
  265. cyJssm: '',
  266. groupNo: '81',
  267. execDept: huanZheXinXi.value.smallDept
  268. }
  269. }
  270. /**
  271. * 删除草药下标
  272. * @param index
  273. */
  274. const removeHerbs = (index) => {
  275. mingXi.value.weiYi.splice(index, 1);
  276. mingXi.value.list.splice(index, 1)
  277. }
  278. const headerTable = [
  279. {name: '编码', code: 'chargeCode', width: 60},
  280. {name: '名称', code: 'chargeCodeName', width: 150},
  281. {name: '药房', code: 'groupName', width: 100},
  282. {name: '单价', code: 'retprice', width: 90},
  283. {name: '规格', code: 'specification', width: 50},
  284. {name: '包装', code: 'serial', width: 50},
  285. ]
  286. const queryHerbalMedicineOrder = (val) => {
  287. return huoQuCaoYao(val, chuFang.value.groupNo)
  288. }
  289. /**
  290. * 草药服用方法数据
  291. * @type {Ref<UnwrapRef<*[]>>}
  292. */
  293. const fuYongFangFaShuJu = ref([])
  294. const dianJiXuanZhongCaoYao = (row) => {
  295. let key = row.chargeCode + row.serial
  296. if (mingXi.value.weiYi.indexOf(key) > -1) {
  297. return ElMessage.error('请勿重复添加。')
  298. } else {
  299. row.quantity = 1
  300. row.je = row.retprice
  301. caoYao.value = row
  302. }
  303. }
  304. const xcComboRef = ref()
  305. const addTo = async () => {
  306. if (stringNotBlank(caoYao.value.chargeCode)) {
  307. let key = caoYao.value.chargeCode + caoYao.value.serial
  308. let index = mingXi.value.weiYi.indexOf(key)
  309. if (index > -1) {
  310. mingXi.value.list.splice(index, 1)
  311. mingXi.value.weiYi.splice(index, 1)
  312. }
  313. mingXi.value.list.push(caoYao.value)
  314. mingXi.value.weiYi.push(key)
  315. caoYao.value = {
  316. chargeCode: '',
  317. chargeCodeName: '',
  318. quantity: 0,
  319. retprice: 0,
  320. instruction: '',
  321. je: '',
  322. }
  323. }
  324. await sleep(100)
  325. xcComboRef.value.focus()
  326. }
  327. const dianJiBianJi = (row) => {
  328. caoYao.value = row
  329. }
  330. watch(
  331. () => caoYao.value.quantity,
  332. () => {
  333. caoYao.value.je = Dig.multiply(caoYao.value.quantity, caoYao.value.retprice).toFixed(2)
  334. }
  335. )
  336. /**
  337. * 下面是取模板的
  338. */
  339. const muBanZuJian = ref(false)
  340. const dianJiXuanZhongMuBanShuJu = (data, next) => {
  341. let flag = false
  342. for (let item of data) {
  343. if (item.groupNo !== chuFang.value.groupNo) {
  344. ElMessage.error('模板药房和当前药房不相同')
  345. return
  346. }
  347. }
  348. data.forEach((item) => {
  349. let key = item.chargeCode + item.serial
  350. if (mingXi.value.weiYi.indexOf(key) > -1) {
  351. flag = true
  352. } else {
  353. item.je = Dig.multiply(item.quantity, item.retprice).toFixed(2)
  354. item.groupName = item.groupNo === '81' ? '门诊中药房' : '颗粒剂药房'
  355. mingXi.value.list.push(item)
  356. mingXi.value.weiYi.push(key)
  357. }
  358. })
  359. next()
  360. if (flag) {
  361. ElMessage({
  362. showClose: true,
  363. message: '请勿重复添加。',
  364. type: 'error',
  365. })
  366. }
  367. }
  368. /**
  369. * 下面是存模板
  370. */
  371. const cunMuBan = ref({
  372. patternName: '',
  373. dialog: false,
  374. chongFuBiaoZhi: false,
  375. })
  376. const userStore = useUserStore()
  377. const dianJiCunMuBan = () => {
  378. let val = cunMuBan.value.patternName
  379. if (stringIsBlank(val)) return
  380. chongFuMuBanMing(val).then((res) => {
  381. if (res) {
  382. return ElMessage.error('模板名重复。')
  383. } else {
  384. let data = {
  385. patternName: val,
  386. list: mingXi.value.list,
  387. deptCode: userStore.userInfo.deptCode,
  388. }
  389. cunMuBanApi(data).then(() => {
  390. cunMuBan.value.dialog = false
  391. cunMuBan.value.patternName = ''
  392. wipeData()
  393. })
  394. }
  395. })
  396. }
  397. /**
  398. * 保存草药
  399. */
  400. const dianJiBaoCunCaoYao = () => {
  401. if (youWuXuanZheHuanZhe()) return
  402. if (stringIsBlank(chuFang.value.orderName)) {
  403. return ElMessage.error('请输入处方名。')
  404. }
  405. if (stringIsBlank(chuFang.value.execDept)) {
  406. chuFang.value.execDept = huanZheXinXi.value.smallDept
  407. ElMessage.error('执行科室默认使用患者小科室。')
  408. }
  409. let listCode = [];
  410. mingXi.value.list.forEach((item) => {
  411. listCode.push(item.chargeCode + '-' + item.serial)
  412. })
  413. yaoPinXiangMuPiPeiYiBao(listCode).then((res) => {
  414. if (stringNotBlank(res)) {
  415. cuoWuXinXi.value = res
  416. ElMessageBox.confirm(res, '提示', {
  417. type: 'warning',
  418. dangerouslyUseHTMLString: true,
  419. confirmButtonText: '继续录入'
  420. })
  421. .then(() => {
  422. baoCunShuJu()
  423. })
  424. .catch(() => {
  425. })
  426. } else {
  427. baoCunShuJu()
  428. }
  429. })
  430. }
  431. const errorMsg = ref({
  432. data: {},
  433. count: 0
  434. })
  435. function baoCunShuJu() {
  436. ElMessageBox.confirm(chuFang.value.quantity > 20 ? '剂数大于20是否继续录入?' : '请确定好数据?', '提示', {
  437. type: 'warning',
  438. }).then(() => {
  439. let data = chuFang.value
  440. data.inpatientNo = huanZheXinXi.value.inpatientNo
  441. data.admissTimes = huanZheXinXi.value.admissTimes
  442. data.list = mingXi.value.list
  443. data.deptCode = userStore.userInfo.deptCode
  444. baoCunCaoYao(data).then((res) => {
  445. if (res?.error) {
  446. errorMsg.value.data = res.data
  447. errorMsg.value.count = msgLength()
  448. } else {
  449. errorMsg.value.data = {}
  450. errorMsg.value.count = 0
  451. wipeData();
  452. props.saveSuccess()
  453. }
  454. })
  455. })
  456. .catch(() => {
  457. })
  458. }
  459. const msgLength = () => {
  460. let a = 0;
  461. for (let dataKey in errorMsg.value.data) {
  462. a += 1
  463. }
  464. return a
  465. }
  466. const clearHerbalInformation = () => {
  467. mingXi.value.weiYi = []
  468. mingXi.value.list = []
  469. caoYao.value.chargeCodeName = ''
  470. caoYao.value.quantity = 1
  471. caoYao.value.instruction = ''
  472. chuFang.value.cyZql = 0
  473. chuFang.value.quantityDj = 0
  474. chuFang.value.cyFj = 0
  475. chuFang.value.orderName = chuFang.value.groupNo === '81' ? '草药' : '中药颗粒'
  476. }
  477. function openCaoYaoTemplate() {
  478. useDialogToJs(CaoYaoMuBan, {
  479. onXuanZhongShuJu: dianJiXuanZhongMuBanShuJu
  480. })
  481. }
  482. onChangePatient(() => {
  483. chuFang.value.execDept = huanZheXinXi.value.smallDept || ""
  484. })
  485. onMounted(() => {
  486. fuYongFangFa().then((res) => {
  487. fuYongFangFaShuJu.value = res
  488. })
  489. })
  490. const jiaShuiLeiXing = [
  491. {code: '加凉水', name: '加凉水'},
  492. {code: '加温水', name: '加温水'},
  493. {code: '加开水', name: '加开水'},
  494. {code: '加冰水', name: '加冰水'},
  495. {code: '加外糖水', name: '加外糖水'},
  496. {code: '外敷', name: '外敷'},
  497. ]
  498. </script>
  499. <style scoped></style>