DrugDispensing.vue 19KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639
  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. @change="changeTimes()"
  22. >
  23. </el-date-picker>
  24. </div>
  25. <div class="list">
  26. <el-radio-group v-model="state" @change="lala()">
  27. <el-radio :label="1">待发药</el-radio>
  28. <el-radio :label="2">已发药</el-radio>
  29. </el-radio-group>
  30. </div>
  31. <div class="list">
  32. <el-input
  33. size="small"
  34. style="width: 239px"
  35. v-model="keywords"
  36. class="filter-item"
  37. placeholder="请输入药品名称"
  38. />
  39. <el-button
  40. size="small"
  41. class="filter-item"
  42. type="primary"
  43. @click="searchAction"
  44. >搜索
  45. </el-button>
  46. </div>
  47. <el-table v-if="state == 1"
  48. :height="tableHeight"
  49. :data="waiting_drug"
  50. border
  51. style="width: 100%"
  52. highlight-current-row
  53. ref="table01"
  54. @current-change="handleCurrentChange"
  55. >
  56. <el-table-column prop="name" label="名称" width="100">
  57. <template slot-scope="scope">
  58. {{scope.row.name}}
  59. </template>
  60. </el-table-column>
  61. <el-table-column prop="specifications" label="规格" width="100">
  62. <template slot-scope="scope">
  63. {{scope.row.specifications}}
  64. </template>
  65. </el-table-column>
  66. <el-table-column prop="stock" label="库存" width="100">
  67. <template slot-scope="scope">
  68. {{scope.row.stock}}
  69. </template>
  70. </el-table-column>
  71. </el-table>
  72. <el-table
  73. v-if="state == 2"
  74. :height="tableHeight"
  75. :data="issued_drug"
  76. border
  77. style="width: 100%"
  78. highlight-current-row
  79. @current-change="handleCurrentChange"
  80. ref="table02"
  81. >
  82. <el-table-column prop="name" label="名称" width="100">
  83. <template slot-scope="scope">
  84. {{scope.row.name}}
  85. </template>
  86. </el-table-column>
  87. <el-table-column prop="specifications" label="规格" width="100">
  88. <template slot-scope="scope">
  89. {{scope.row.specifications}}
  90. </template>
  91. </el-table-column>
  92. <el-table-column prop="stock" label="库存" width="100">
  93. <template slot-scope="scope">
  94. {{scope.row.stock}}
  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="tt">调试</el-button>-->
  103. <el-button type="primary" @click="dispense" v-if="state == 1">发药</el-button>
  104. <el-button type="primary" @click="toPrint">打印</el-button>
  105. <!-- <el-button @click="tt">调试</el-button>-->
  106. <!-- <el-button type="primary" @click="toSetting">设置</el-button>-->
  107. </div>
  108. <el-divider></el-divider>
  109. <div>
  110. <el-table
  111. :height="tableHeight"
  112. :data="tableData"
  113. border
  114. style="width: 1328px"
  115. @selection-change="handleSelectionChange"
  116. v-if="state == 1"
  117. >
  118. <el-table-column type="selection" width="55" align="center"> </el-table-column>
  119. <el-table-column type="index" label="序号" width="120" align="center">
  120. </el-table-column>
  121. <el-table-column prop="name" label="患者名称" width="180" align="center">
  122. <template slot-scope="scope">
  123. {{scope.row.name}}
  124. </template>
  125. </el-table-column>
  126. <el-table-column prop="name" label="单次用量" width="170" align="center">
  127. <template slot-scope="scope">
  128. {{scope.row.single_dosage}}
  129. </template>
  130. </el-table-column>
  131. <el-table-column prop="name" label="用法" width="160" align="center">
  132. <template slot-scope="scope">
  133. {{scope.row.usage}}
  134. </template>
  135. </el-table-column>
  136. <el-table-column prop="name" label="频率" width="160" align="center">
  137. <template slot-scope="scope">
  138. {{scope.row.frequency}}
  139. </template>
  140. </el-table-column>
  141. <el-table-column prop="name" label="天数" width="160" align="center">
  142. <template slot-scope="scope">
  143. {{scope.row.days}}
  144. </template>
  145. </el-table-column>
  146. <el-table-column prop="name" label="总量" width="160" align="center">
  147. <template slot-scope="scope">
  148. {{scope.row.total}}
  149. </template>
  150. </el-table-column>
  151. <el-table-column prop="name" label="数据来源" width="162" align="center">
  152. <template slot-scope="scope">
  153. {{scope.row.data_sources}}
  154. </template>
  155. </el-table-column>
  156. </el-table>
  157. </div>
  158. <div>
  159. <el-table
  160. :height="tableHeight"
  161. :data="tableData"
  162. border
  163. style="width: 1328px"
  164. v-if="state == 2"
  165. >
  166. <!-- <el-table-column type="selection" width="55"> </el-table-column>-->
  167. <el-table-column type="index" label="序号" width="120" align="center">
  168. </el-table-column>
  169. <el-table-column prop="name" label="患者名称" width="180" align="center">
  170. <template slot-scope="scope">
  171. {{scope.row.name}}
  172. </template>
  173. </el-table-column>
  174. <el-table-column prop="name" label="单次用量" width="170" align="center">
  175. <template slot-scope="scope">
  176. {{scope.row.single_dosage}}
  177. </template>
  178. </el-table-column>
  179. <el-table-column prop="name" label="用法" width="160" align="center">
  180. <template slot-scope="scope">
  181. {{scope.row.usage}}
  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.frequency}}
  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.days}}
  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.total}}
  197. </template>
  198. </el-table-column>
  199. <el-table-column prop="name" label="数据来源" width="162" align="center">
  200. <template slot-scope="scope">
  201. {{scope.row.data_sources}}
  202. </template>
  203. </el-table-column>
  204. <el-table-column prop="name" label="领药人" width="160" align="center">
  205. <template slot-scope="scope">
  206. {{scope.row.people}}
  207. </template>
  208. </el-table-column>
  209. </el-table>
  210. </div>
  211. <div style="margin-top:12px;" v-if="state == 1">领药人:
  212. <el-select v-model="admin_user_id" placeholder="请选择">
  213. <el-option
  214. v-for="item in doctorList"
  215. :key="item.admin_user_id"
  216. :label="item.user_name"
  217. :value="item.admin_user_id">
  218. </el-option>
  219. </el-select>
  220. </div>
  221. </div>
  222. <el-dialog title="设置" :visible.sync="dialogVisible" width="30%">
  223. <span style="font-size: 17px">请选择药品是否要通过药房管理出库</span>
  224. <span style="display: block; padding: 18px 25px">
  225. <el-radio v-model="is_open" label="1">是</el-radio>
  226. <el-radio v-model="is_open" label="2">否</el-radio>
  227. </span>
  228. <div style="height: 50px; background: #c7ebfc; border-radius: 5px;padding: 7px;">
  229. <i class="el-icon-info" style="color: #3399ff;font-size: 17px;"></i>
  230. 若选择为是,则通过药房发药的药品都会在发药之后进行出库,否则按原来的方式进行出库管理
  231. </div>
  232. <span slot="footer" class="dialog-footer">
  233. <el-button @click="dialogVisible = false">取 消</el-button>
  234. <el-button type="primary" @click="SaveSetting">保 存</el-button>
  235. </span>
  236. </el-dialog>
  237. </div>
  238. <drug-print
  239. ref="drugprint"
  240. :visibility="isVisibility"
  241. :propsTable="propsTable"
  242. :state="state"
  243. >
  244. </drug-print>
  245. </div>
  246. </template>
  247. <script>
  248. import drugPrint from "./print/drugPrint.vue";
  249. import BreadCrumb from "@/xt_pages/components/bread-crumb";
  250. import { getTodayAdviceList,getPharmacyBaseDrug,updatePharmacyBaseDrug,SaveSetting,getPharmacyConfig,getUserdDrugList } from "@/api/his/advice";
  251. import {
  252. dispensemedicine,
  253. waitingmedicine,
  254. getpatientswithdrugs,
  255. medicinedeparture,
  256. getcurrentname
  257. } from "@/api/pharmacy"
  258. const moment = require('moment')
  259. export default {
  260. components: {
  261. BreadCrumb,
  262. drugPrint,
  263. },
  264. data() {
  265. return {
  266. crumbs: [
  267. { path: false, name: "药房管理" },
  268. { path: "/Pharmacy/DrugDispensing", name: "药品发药" },
  269. ],
  270. tableHeight: 400,
  271. datepick: "",
  272. state: 1,
  273. waitmount: 0,
  274. alreadmount: 0,
  275. tableData: [],
  276. tableData_list: [],
  277. tableList:[],
  278. multipleSelection: [],
  279. start_time:moment(new Date()).add('year',0).format("YYYY-MM-DD"),
  280. patientList:[],
  281. keywords:"",
  282. dialogVisible:false,
  283. is_open:"2",
  284. isVisibility:"",
  285. propsTable:"",
  286. doctorList:[],
  287. admin_user_id:0,
  288. waiting_drug:[],//待发药列表
  289. issued_drug:[],//已发药列表
  290. currentRow:null,
  291. tmp:0,
  292. };
  293. },
  294. methods: {
  295. tt(){
  296. console.log("this.currentRow",this.currentRow)
  297. this.$router.go(0)
  298. },
  299. async fun3(){
  300. console.log("fun3")
  301. this.fun1().then(val => {
  302. this.fun2();
  303. })
  304. },
  305. async fun4(tps){
  306. console.log("fun3",tps)
  307. this.fun1().then(val => {
  308. console.log("this.issued_drug",this.issued_drug)
  309. for(let i = 0;i < this.issued_drug.length;i++){
  310. if(tps == this.issued_drug[i].id){
  311. this.$refs.table02.setCurrentRow(this.issued_drug[i]);
  312. this.handleCurrentChange(this.issued_drug[i])
  313. }
  314. }
  315. })
  316. },
  317. async fun5(tps){
  318. console.log("fun3",tps)
  319. this.fun1().then(val => {
  320. console.log("this.issued_drug",this.waiting_drug)
  321. for(let i = 0;i < this.waiting_drug.length;i++){
  322. if(tps == this.waiting_drug[i].id){
  323. this.$refs.table01.setCurrentRow(this.waiting_drug[i]);
  324. this.handleCurrentChange(this.waiting_drug[i])
  325. }
  326. }
  327. })
  328. },
  329. changeTimes(){
  330. // alert("aa")
  331. // this.getdruglist();
  332. this.fun3();
  333. },
  334. //初始化
  335. init(){
  336. this.state = 1
  337. this.tableData = null
  338. this.currentRow = null
  339. },
  340. lala(){
  341. this.currentRow = null
  342. this.tableData = null
  343. this.selectedbydefault()
  344. },
  345. searchAction() {
  346. // this.getlist();
  347. this.tableData = null
  348. this.currentRow = null
  349. this.getdruglist();
  350. },
  351. // 跳转打印页面
  352. toPrint() {
  353. if (this.state == 1 && this.multipleSelection.length == 0){
  354. this.$message.error("未选择任何数据");
  355. return
  356. }
  357. if (this.state == 2 && this.tableData == null){
  358. this.$message.error("未选择任何数据");
  359. return
  360. }
  361. this.$refs.drugprint.show(this.tableData,this.currentRow,this.state,this.multipleSelection,this.start_time);
  362. },
  363. //列表选择
  364. handleSelectionChange(val) {
  365. this.multipleSelection = val;
  366. },
  367. //默认选中
  368. selectedbydefault(){
  369. if(this.state == 1 && this.waiting_drug.length > 0){
  370. this.$refs.table01.setCurrentRow(this.waiting_drug[0]);
  371. this.handleCurrentChange(this.waiting_drug[0])
  372. }
  373. if(this.state == 2 && this.issued_drug.length >0){
  374. this.$refs.table02.setCurrentRow(this.issued_drug[0]);
  375. this.handleCurrentChange(this.issued_drug[0])
  376. }
  377. },
  378. //包装selectedbydefault
  379. fun2(){
  380. console.log("3333333this.waitmount_data",this.waiting_drug)
  381. // return new Promise((resolve, reject) => {
  382. if(this.state == 1 && this.waiting_drug.length > 0){
  383. this.$refs.table01.setCurrentRow(this.waiting_drug[0]);
  384. this.handleCurrentChange(this.waiting_drug[0])
  385. }
  386. if(this.state == 2 && this.issued_drug.length >0){
  387. this.$refs.table02.setCurrentRow(this.issued_drug[0]);
  388. this.handleCurrentChange(this.issued_drug[0])
  389. }
  390. // });
  391. },
  392. // 药品发药
  393. dispense() {
  394. var tps = this.currentRow.id;
  395. if(this.multipleSelection.length < 1){
  396. this.$message.error("未选择任何信息")
  397. return
  398. }
  399. var tmp = "";
  400. console.log("初始值",tmp)
  401. for (var i=0;i < this.multipleSelection.length;i++){
  402. tmp = tmp + this.multipleSelection[i].id + ","
  403. }
  404. var params = {
  405. creater: this.admin_user_id,
  406. ids: tmp,
  407. }
  408. medicinedeparture(params).then((res) => {
  409. if (res.data.state == 1){
  410. this.$message.success("操作成功")
  411. this.getdruglist();
  412. //刷新列表
  413. this.handleCurrentChange(this.currentRow);
  414. this.fun4(tps);
  415. this.state = 2;
  416. this.multipleSelection = []
  417. }else{
  418. this.$message.error("操作失败:" + res.data.msg)
  419. //刷新列表
  420. this.handleCurrentChange(this.currentRow);
  421. this.fun5(tps);
  422. this.state = 1;
  423. }
  424. })
  425. },
  426. //获取药品列表
  427. getdruglist(){
  428. var params = {
  429. keyword: this.keywords,
  430. time: this.start_time,
  431. }
  432. waitingmedicine(params).then((res) => {
  433. if (res.data.state == 1){
  434. this.waiting_drug = res.data.data.list
  435. }
  436. })
  437. dispensemedicine(params).then((res) => {
  438. if (res.data.state == 1){
  439. this.issued_drug = res.data.data.list
  440. }
  441. })
  442. },
  443. async fun1(){
  444. var params = {
  445. keyword: this.keywords,
  446. time: this.start_time,
  447. }
  448. await waitingmedicine(params).then((res) => {
  449. if (res.data.state == 1){
  450. this.waiting_drug = res.data.data.list
  451. }
  452. console.log("fun1lil1111i")
  453. })
  454. await dispensemedicine(params).then((res) => {
  455. if (res.data.state == 1){
  456. this.issued_drug = res.data.data.list
  457. }
  458. console.log("fun122222222")
  459. })
  460. console.log("fun1")
  461. },
  462. morencreatename(){
  463. var param ={}
  464. getcurrentname(param).then((res) => {
  465. console.log("res(药)",res)
  466. if (res.data.state == 1){
  467. this.admin_user_id = res.data.data.list;
  468. console.log("this.admin_user_id(药)",this.admin_user_id)
  469. }
  470. });
  471. },
  472. //获取领药人选项
  473. getlist(){
  474. var params = {
  475. start_time:this.start_time,
  476. keywords:this.keywords,
  477. }
  478. getTodayAdviceList(params).then(response=>{
  479. if(response.data.state == 1){
  480. this.doctorList = response.data.data.doctorlist
  481. console.log("this.admin_user_id(药2)",this.admin_user_id)
  482. // this.admin_user_id = this.doctorList[0].admin_user_id
  483. // this.admin_user_id = this.tmp
  484. }
  485. })
  486. },
  487. // //获取药品的患者信息
  488. informationofdrugs(val){
  489. var params = {
  490. // patient_id: this.currentRow.
  491. }
  492. },
  493. handleCurrentChange(val) {
  494. this.currentRow = val;
  495. if(this.state == 1){
  496. this.getdrugsdetails(0)
  497. }
  498. if (this.state == 2){
  499. this.getdrugsdetails(1)
  500. }
  501. },
  502. getdrugsdetails(val){
  503. var params = {
  504. drug_id:this.currentRow.id,
  505. is_medicine:val,
  506. time:this.start_time,
  507. }
  508. getpatientswithdrugs(params).then((res) => {
  509. if (res.data.state == 1){
  510. this.tableData = res.data.data.list;//列表数据
  511. }else {
  512. this.$message.error(res.data.msg);
  513. }
  514. })
  515. },
  516. toSetting(){
  517. getPharmacyConfig().then(response=>{
  518. if(response.data.state == 1){
  519. this.dialogVisible = true
  520. var config = response.data.data.config
  521. this.is_open = config.is_open.toString()
  522. }
  523. })
  524. },
  525. SaveSetting(){
  526. var params = {
  527. is_open:parseInt(this.is_open),
  528. }
  529. SaveSetting(params).then(response=>{
  530. if(response.data.state == 1){
  531. var config = response.data.data.config
  532. this.$message.success("保存成功!")
  533. this.dialogVisible = false
  534. }
  535. })
  536. },
  537. getUserlist(drug_id){
  538. var params = {
  539. start_time:this.start_time,
  540. drug_id:drug_id,
  541. }
  542. getUserdDrugList(params).then(response=>{
  543. if(response.data.state == 1){
  544. var advicelist = response.data.data.advicelist
  545. for(let i=0;i<advicelist.length;i++){
  546. advicelist[i].type = 1
  547. advicelist[i].day = " "
  548. this.tableList.push(advicelist[i])
  549. }
  550. var hisAdviceList = response.data.data.hisAdviceList
  551. for(let i=0;i<hisAdviceList.length;i++){
  552. hisAdviceList[i].type = 2
  553. this.tableList.push(hisAdviceList[i])
  554. }
  555. var patient = response.data.data.patient
  556. this.patientList = patient
  557. }
  558. })
  559. }
  560. },
  561. created() {
  562. this.init();
  563. this.morencreatename();
  564. this.getlist();
  565. // this.getdruglist();
  566. this.fun3();
  567. },
  568. };
  569. </script>
  570. <style rel="stylesheet/css" lang="scss" scoped>
  571. .new-main-contain {
  572. height: 100%;
  573. display: flex;
  574. flex-direction: column;
  575. }
  576. .app-container {
  577. height: 100%;
  578. }
  579. .mainLeft {
  580. width: 300px;
  581. height: 100%;
  582. display: flex;
  583. flex-direction: column;
  584. .el-radio {
  585. margin-right: 75px;
  586. }
  587. .list {
  588. margin: 10px 0;
  589. }
  590. }
  591. .mainRight {
  592. margin-left: 10px;
  593. flex: 1;
  594. height: 100%;
  595. display: flex;
  596. flex-direction: column;
  597. overflow-y: auto;
  598. .titlelist {
  599. display: flex;
  600. justify-content: flex-end;
  601. }
  602. }
  603. /deep/ .el-table--scrollable-x .el-table__body-wrapper {
  604. overflow: auto;
  605. }
  606. /deep/ .gutter {
  607. width: 15px !important;
  608. display: inline-block !important;
  609. }
  610. /deep/ .el-table__fixed-right-patch {
  611. width: 15px !important;
  612. }
  613. /deep/ .el-table__fixed-right {
  614. bottom: 0 !important;
  615. left: auto;
  616. right: 0;
  617. }
  618. /deep/ .el-table__body-wrapper::-webkit-scrollbar {
  619. width: 15px !important;
  620. height: 15px !important;
  621. }
  622. </style>