DrugDispensing.vue 17KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533
  1. <template>
  2. <div class="main-contain new-main-contain">
  3. <div class="position">
  4. <!-- <bread-crumb :crumbs='crumbs'></bread-crumb>-->
  5. <bread-crumb :crumbs="crumbs"></bread-crumb>
  6. </div>
  7. <div
  8. class="app-container"
  9. style="display: flex; flex: 1; padding: 10px 20px 0px 20px"
  10. >
  11. <div class="mainLeft">
  12. <div>
  13. <div class="list">
  14. <el-date-picker
  15. style="width: 300px"
  16. v-model="start_time"
  17. type="date"
  18. format="yyyy-MM-dd"
  19. value-format="yyyy-MM-dd"
  20. placeholder="选择日期"
  21. >
  22. </el-date-picker>
  23. </div>
  24. <div class="list">
  25. <el-radio-group v-model="state">
  26. <el-radio :label="1">待发药</el-radio>
  27. <el-radio :label="2">已发药</el-radio>
  28. </el-radio-group>
  29. </div>
  30. <div class="list">
  31. <el-input
  32. size="small"
  33. style="width: 239px"
  34. v-model="keywords"
  35. class="filter-item"
  36. placeholder="请输入药品名称"
  37. />
  38. <el-button
  39. size="small"
  40. class="filter-item"
  41. type="primary"
  42. @click="searchAction"
  43. >搜索
  44. </el-button>
  45. </div>
  46. <el-table
  47. v-if="state == 1"
  48. :height="tableHeight"
  49. :data="tableData"
  50. border
  51. style="width: 100%"
  52. highlight-current-row
  53. ref="singleTable"
  54. @current-change="handleCurrentChange"
  55. >
  56. <el-table-column prop="name" label="名称" width="100">
  57. <template slot-scope="scope">
  58. {{scope.row.drug_name}}
  59. </template>
  60. </el-table-column>
  61. <el-table-column prop="specifications" label="规格" width="100">
  62. <template slot-scope="scope">
  63. {{scope.row.dose}}{{scope.row.dose_unit}}*{{scope.row.min_number}}{{scope.row.min_unit}}/{{scope.row.max_unit}}
  64. </template>
  65. </el-table-column>
  66. <el-table-column prop="stock" label="库存" width="100">
  67. <template slot-scope="scope">
  68. {{getWarehoseInfo(scope.row.drug_warehouse_info,scope.row.max_unit,scope.row.min_unit,scope.row.min_number)}}
  69. </template>
  70. </el-table-column>
  71. </el-table>
  72. <el-table
  73. v-if="state == 2"
  74. :height="tableHeight"
  75. :data="tableData"
  76. border
  77. style="width: 100%"
  78. highlight-current-row
  79. @current-change="handleSelectionChangeOne"
  80. ref="singleTable"
  81. >
  82. <el-table-column prop="name" label="名称" width="100">
  83. <template slot-scope="scope">
  84. {{scope.row.drug_name}}
  85. </template>
  86. </el-table-column>
  87. <el-table-column prop="specifications" label="规格" width="100">
  88. <template slot-scope="scope">
  89. {{scope.row.dose}}{{scope.row.dose_unit}}*{{scope.row.min_number}}{{scope.row.min_unit}}/{{scope.row.max_unit}}
  90. </template>
  91. </el-table-column>
  92. <el-table-column prop="stock" label="库存" width="100">
  93. <template slot-scope="scope">
  94. {{getWarehoseInfo(scope.row.drug_warehouse_info,scope.row.max_unit,scope.row.min_unit,scope.row.min_number)}}
  95. </template>
  96. </el-table-column>
  97. </el-table>
  98. </div>
  99. </div>
  100. <div class="mainRight">
  101. <div class="titlelist">
  102. <el-button type="primary" @click="dispense" v-if="state == 1">发药</el-button>
  103. <el-button type="primary" @click="toPrint">打印</el-button>
  104. <el-button type="primary" @click="toSetting">设置</el-button>
  105. </div>
  106. <el-divider></el-divider>
  107. <div>
  108. <el-table
  109. :height="tableHeight"
  110. :data="tableData_list"
  111. border
  112. style="width: 1328px"
  113. @selection-change="handleSelectionChange"
  114. v-if="state == 1"
  115. >
  116. >
  117. <el-table-column type="selection" width="55"> </el-table-column>
  118. <el-table-column type="index" label="序号" width="120" align="center">
  119. <template slot-scope="scope">
  120. {{scope.$index + 1}}
  121. </template>
  122. </el-table-column>
  123. <el-table-column prop="name" label="患者名称" width="180" align="center">
  124. <template slot-scope="scope">
  125. {{getPatientName(scope.row.patient_id)}}
  126. </template>
  127. </el-table-column>
  128. <el-table-column prop="name" label="单次用量" width="170" align="center">
  129. <template slot-scope="scope">
  130. {{scope.row.single_dose}}
  131. </template>
  132. </el-table-column>
  133. <el-table-column prop="name" label="用法" width="160" align="center">
  134. <template slot-scope="scope">
  135. {{scope.row.delivery_way}}
  136. </template>
  137. </el-table-column>
  138. <el-table-column prop="name" label="频率" width="160" align="center">
  139. <template slot-scope="scope">
  140. {{scope.row.execution_frequency}}
  141. </template>
  142. </el-table-column>
  143. <el-table-column prop="name" label="天数" width="160" align="center">
  144. <template slot-scope="scope">
  145. {{scope.row.day}}
  146. </template>
  147. </el-table-column>
  148. <el-table-column prop="name" label="总量" width="160" align="center">
  149. <template slot-scope="scope">
  150. {{scope.row.prescribing_number}}
  151. </template>
  152. </el-table-column>
  153. <el-table-column prop="name" label="数据来源" width="162" align="center">
  154. <template slot-scope="scope">
  155. <span v-if="scope.row.type == 1">血透</span>
  156. <span v-if="scope.row.type == 2">HIS</span>
  157. </template>
  158. </el-table-column>
  159. </el-table>
  160. <el-table
  161. :height="tableHeight"
  162. :data="tableList"
  163. border
  164. style="width: 1328px"
  165. v-if="state == 2"
  166. >
  167. >
  168. <el-table-column type="selection" width="55"> </el-table-column>
  169. <el-table-column type="index" label="序号" width="120" align="center">
  170. <template slot-scope="scope">
  171. {{scope.$index + 1}}
  172. </template>
  173. </el-table-column>
  174. <el-table-column prop="name" label="患者名称" width="180" align="center">
  175. <template slot-scope="scope">
  176. {{getPatientName(scope.row.patient_id)}}
  177. </template>
  178. </el-table-column>
  179. <el-table-column prop="name" label="单次用量" width="170" align="center">
  180. <template slot-scope="scope">
  181. {{scope.row.single_dose}}
  182. </template>
  183. </el-table-column>
  184. <el-table-column prop="name" label="用法" width="160" align="center">
  185. <template slot-scope="scope">
  186. {{scope.row.delivery_way}}
  187. </template>
  188. </el-table-column>
  189. <el-table-column prop="name" label="频率" width="160" align="center">
  190. <template slot-scope="scope">
  191. {{scope.row.execution_frequency}}
  192. </template>
  193. </el-table-column>
  194. <el-table-column prop="name" label="天数" width="160" align="center">
  195. <template slot-scope="scope">
  196. {{scope.row.day}}
  197. </template>
  198. </el-table-column>
  199. <el-table-column prop="name" label="总量" width="160" align="center">
  200. <template slot-scope="scope">
  201. {{scope.row.prescribing_number}}
  202. </template>
  203. </el-table-column>
  204. <el-table-column prop="name" label="数据来源" width="162" align="center">
  205. <template slot-scope="scope">
  206. <span v-if="scope.row.type == 1">血透</span>
  207. <span v-if="scope.row.type == 2">HIS</span>
  208. </template>
  209. </el-table-column>
  210. </el-table>
  211. </div>
  212. <div style="margin-top">领料人:
  213. <el-select v-model="admin_user_id" placeholder="请选择">
  214. <el-option
  215. v-for="item in doctorList"
  216. :key="item.admin_user_id"
  217. :label="item.user_name"
  218. :value="item.admin_user_id">
  219. </el-option>
  220. </el-select>
  221. </div>
  222. </div>
  223. <el-dialog
  224. title="设置"
  225. :visible.sync="dialogVisible"
  226. width="30%">
  227. <span>请选择药品是否要通过药房管理出库</span>
  228. <span>
  229. <el-radio v-model="is_open" label="1">是</el-radio>
  230. <el-radio v-model="is_open" label="2">否</el-radio>
  231. </span>
  232. <span>
  233. 若选择为是,则通过药房发药的药品都会在发药之后进行出库,否则按原来的方式进行出库管理
  234. </span>
  235. <span slot="footer" class="dialog-footer">
  236. <el-button @click="dialogVisible = false">取 消</el-button>
  237. <el-button type="primary" @click="SaveSetting">确 定</el-button>
  238. </span>
  239. </el-dialog>
  240. </div>
  241. <drug-print
  242. ref="drugprint"
  243. :visibility="isVisibility"
  244. :propsTable="propsTable"
  245. :state="state"
  246. >
  247. </drug-print>
  248. </div>
  249. </template>
  250. <script>
  251. import drugPrint from "./print/drugPrint.vue";
  252. import BreadCrumb from "@/xt_pages/components/bread-crumb";
  253. import { getTodayAdviceList,getPharmacyBaseDrug,updatePharmacyBaseDrug,SaveSetting,getPharmacyConfig,getUserdDrugList } from "@/api/his/advice";
  254. const moment = require('moment')
  255. export default {
  256. components: {
  257. BreadCrumb,
  258. drugPrint,
  259. },
  260. data() {
  261. return {
  262. crumbs: [
  263. { path: false, name: "药品发药" },
  264. { path: "/Pharmacy/DrugDispensing", name: "药品发药" },
  265. ],
  266. tableHeight: 400,
  267. datepick: "",
  268. state: 1,
  269. waitmount: 0,
  270. alreadmount: 0,
  271. tableData: [],
  272. tableData_list: [],
  273. tableList:[],
  274. multipleSelection: [],
  275. start_time:moment(new Date()).add('year',0).format("YYYY-MM-DD"),
  276. patientList:[],
  277. keywords:"",
  278. dialogVisible:false,
  279. is_open:"2",
  280. isVisibility:"",
  281. propsTable:"",
  282. doctorList:[],
  283. admin_user_id:this.$store.getters.xt_user.user.id,
  284. };
  285. },
  286. methods: {
  287. searchAction() {
  288. this.getlist();
  289. },
  290. // 跳转打印页面
  291. toPrint() {
  292. // this.$router.push({ path: "/Pharmacy/print/patientPrint" });
  293. this.$refs.drugprint.show();
  294. },
  295. handleSelectionChange(val) {
  296. this.multipleSelection = val;
  297. },
  298. handleSelectionChangeOne(val){
  299. this.tableList = []
  300. this.getUserlist(val.id)
  301. },
  302. // 药品发药
  303. dispense() {
  304. var blood_ids = []
  305. var his_ids = []
  306. var bloodStr = ""
  307. var hisStr = ""
  308. for(let i=0;i<this.tableData.length;i++){
  309. if(this.tableData[i].type == 1){
  310. blood_ids.push(this.tableData[i].id)
  311. }
  312. if(this.tableData[i].type == 2){
  313. his_ids.push(this.tableData[i].id)
  314. }
  315. }
  316. bloodStr = blood_ids.join(",")
  317. hisStr = his_ids.join(",")
  318. var params = {
  319. bloodStr:bloodStr,
  320. hisStr:hisStr,
  321. admin_user_id:this.admin_user_id,
  322. }
  323. this.$confirm("确定是否对该药品进行发药?", "患者发药", {
  324. confirmButtonText: "确 定",
  325. cancelButtonText: "取 消",
  326. type: "warning",
  327. }).then(() => {
  328. updatePharmacyBaseDrug(params).then(response=>{
  329. if(response.data.state == 1){
  330. var msg = response.data.data.msg
  331. var medical = response.data.data.medical
  332. if(msg === 1){
  333. this.$message.success("发药成功!")
  334. }
  335. if(msg == 2 || msg ===3){
  336. this.$message.error("库存不足")
  337. }
  338. }
  339. })
  340. }).catch(() => {});
  341. },
  342. // 药品退药
  343. endispense() {
  344. var params = {};
  345. this.$confirm("确定是否对该药品进行退药?", "患者退药", {
  346. confirmButtonText: "确 定",
  347. cancelButtonText: "取 消",
  348. type: "warning",
  349. })
  350. .then(() => {})
  351. .catch(() => {});
  352. },
  353. handleSelectionChange(val) {
  354. this.multipleSelection = val;
  355. },
  356. getlist(){
  357. var params = {
  358. start_time:this.start_time,
  359. keywords:this.keywords,
  360. }
  361. getTodayAdviceList(params).then(response=>{
  362. if(response.data.state == 1){
  363. var list = response.data.data.list
  364. this.$refs.singleTable.setCurrentRow(list[0])
  365. this.tableData = list
  366. var doctorlist = response.data.data.doctorlist
  367. this.doctorList = doctorlist
  368. }
  369. })
  370. },
  371. getWarehoseInfo(arr, max_unit, min_unit, min_number) {
  372. var total = 0;
  373. var max_str = "";
  374. var min_str = "";
  375. if (arr.length > 0) {
  376. for (let i = 0; i < arr.length; i++) {
  377. total += parseInt(arr[i].stock_max_number+ arr[i].stock_min_number);
  378. }
  379. }
  380. if (total < min_number) {
  381. min_str = total + min_unit;
  382. }
  383. if (total == 0) {
  384. min_str = "";
  385. max_str = "";
  386. }
  387. if (total >= min_number) {
  388. if (parseInt(total / min_number) != 0) {
  389. max_str = parseInt(total / min_number) + max_unit;
  390. }
  391. if (total % min_number != 0) {
  392. min_str = (total % min_number) + min_unit;
  393. }
  394. }
  395. return max_str + min_str;
  396. },
  397. handleCurrentChange(row) {
  398. this.getPharmacyBaseDrug(row.id)
  399. },
  400. getPharmacyBaseDrug(drug_id){
  401. var params = {
  402. start_time:this.start_time,
  403. drug_id:drug_id,
  404. }
  405. getPharmacyBaseDrug(params).then(response=>{
  406. if(response.data.state == 1){
  407. var advicelist = response.data.data.advicelist
  408. for(let i=0;i<advicelist.length;i++){
  409. advicelist[i].type = 1
  410. advicelist[i].day = " "
  411. this.tableData_list.push(advicelist[i])
  412. }
  413. var hisAdviceList = response.data.data.hisAdviceList
  414. for(let i=0;i<hisAdviceList.length;i++){
  415. hisAdviceList[i].type = 2
  416. this.tableData_list.push(hisAdviceList[i])
  417. }
  418. var patient = response.data.data.patient
  419. this.patientList = patient
  420. }
  421. })
  422. },
  423. getPatientName(id){
  424. var name = ""
  425. for(let i=0;i<this.patientList.length;i++){
  426. if(id == this.patientList[i].id){
  427. name = this.patientList[i].name
  428. }
  429. }
  430. return name
  431. },
  432. toSetting(){
  433. getPharmacyConfig().then(response=>{
  434. if(response.data.state == 1){
  435. this.dialogVisible = true
  436. var config = response.data.data.config
  437. this.is_open = config.is_open.toString()
  438. }
  439. })
  440. },
  441. SaveSetting(){
  442. var params = {
  443. is_open:parseInt(this.is_open),
  444. }
  445. SaveSetting(params).then(response=>{
  446. if(response.data.state == 1){
  447. var config = response.data.data.config
  448. this.$message.success("保存成功!")
  449. this.dialogVisible = false
  450. }
  451. })
  452. },
  453. getUserlist(drug_id){
  454. var params = {
  455. start_time:this.start_time,
  456. drug_id:drug_id,
  457. }
  458. getUserdDrugList(params).then(response=>{
  459. if(response.data.state == 1){
  460. var advicelist = response.data.data.advicelist
  461. for(let i=0;i<advicelist.length;i++){
  462. advicelist[i].type = 1
  463. advicelist[i].day = " "
  464. this.tableList.push(advicelist[i])
  465. }
  466. var hisAdviceList = response.data.data.hisAdviceList
  467. for(let i=0;i<hisAdviceList.length;i++){
  468. hisAdviceList[i].type = 2
  469. this.tableList.push(hisAdviceList[i])
  470. }
  471. var patient = response.data.data.patient
  472. this.patientList = patient
  473. }
  474. })
  475. }
  476. },
  477. created() {
  478. this.getlist()
  479. },
  480. };
  481. </script>
  482. <style rel="stylesheet/css" lang="scss" scoped>
  483. .new-main-contain {
  484. height: 100%;
  485. display: flex;
  486. flex-direction: column;
  487. }
  488. .app-container {
  489. height: 100%;
  490. }
  491. .mainLeft {
  492. width: 300px;
  493. height: 100%;
  494. display: flex;
  495. flex-direction: column;
  496. .el-radio {
  497. margin-right: 75px;
  498. }
  499. .list {
  500. margin: 10px 0;
  501. }
  502. }
  503. .mainRight {
  504. margin-left: 10px;
  505. flex: 1;
  506. height: 100%;
  507. display: flex;
  508. flex-direction: column;
  509. overflow-y: auto;
  510. .titlelist {
  511. display: flex;
  512. justify-content: flex-end;
  513. }
  514. }
  515. </style>