XinZhengCaoYao.vue 14 KB

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