DrugDispensing.vue 19KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620
  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"> </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" 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
  223. title="设置"
  224. :visible.sync="dialogVisible"
  225. width="30%">
  226. <span>请选择药品是否要通过药房管理出库</span>
  227. <span>
  228. <el-radio v-model="is_open" label="1">是</el-radio>
  229. <el-radio v-model="is_open" label="2">否</el-radio>
  230. </span>
  231. <span>
  232. 若选择为是,则通过药房发药的药品都会在发药之后进行出库,否则按原来的方式进行出库管理
  233. </span>
  234. <span slot="footer" class="dialog-footer">
  235. <el-button @click="dialogVisible = false">取 消</el-button>
  236. <el-button type="primary" @click="SaveSetting">确 定</el-button>
  237. </span>
  238. </el-dialog>
  239. </div>
  240. <drug-print
  241. ref="drugprint"
  242. :visibility="isVisibility"
  243. :propsTable="propsTable"
  244. :state="state"
  245. >
  246. </drug-print>
  247. </div>
  248. </template>
  249. <script>
  250. import drugPrint from "./print/drugPrint.vue";
  251. import BreadCrumb from "@/xt_pages/components/bread-crumb";
  252. import { getTodayAdviceList,getPharmacyBaseDrug,updatePharmacyBaseDrug,SaveSetting,getPharmacyConfig,getUserdDrugList } from "@/api/his/advice";
  253. import {
  254. dispensemedicine,
  255. waitingmedicine,
  256. getpatientswithdrugs,
  257. medicinedeparture,
  258. getcurrentname
  259. } from "@/api/pharmacy"
  260. const moment = require('moment')
  261. export default {
  262. components: {
  263. BreadCrumb,
  264. drugPrint,
  265. },
  266. data() {
  267. return {
  268. crumbs: [
  269. { path: false, name: "药房管理" },
  270. { path: "/Pharmacy/DrugDispensing", name: "药品发药" },
  271. ],
  272. tableHeight: 400,
  273. datepick: "",
  274. state: 1,
  275. waitmount: 0,
  276. alreadmount: 0,
  277. tableData: [],
  278. tableData_list: [],
  279. tableList:[],
  280. multipleSelection: [],
  281. start_time:moment(new Date()).add('year',0).format("YYYY-MM-DD"),
  282. patientList:[],
  283. keywords:"",
  284. dialogVisible:false,
  285. is_open:"2",
  286. isVisibility:"",
  287. propsTable:"",
  288. doctorList:[],
  289. admin_user_id:0,
  290. waiting_drug:[],//待发药列表
  291. issued_drug:[],//已发药列表
  292. currentRow:null,
  293. tmp:0,
  294. };
  295. },
  296. methods: {
  297. tt(){
  298. console.log("this.currentRow",this.currentRow)
  299. this.$router.go(0)
  300. },
  301. async fun3(){
  302. console.log("fun3")
  303. this.fun1().then(val => {
  304. this.fun2();
  305. })
  306. },
  307. async fun4(tps){
  308. console.log("fun3",tps)
  309. this.fun1().then(val => {
  310. console.log("this.issued_drug",this.issued_drug)
  311. for(let i = 0;i < this.issued_drug.length;i++){
  312. if(tps == this.issued_drug[i].id){
  313. this.$refs.table02.setCurrentRow(this.issued_drug[i]);
  314. this.handleCurrentChange(this.issued_drug[i])
  315. }
  316. }
  317. })
  318. },
  319. async fun5(tps){
  320. console.log("fun3",tps)
  321. this.fun1().then(val => {
  322. console.log("this.issued_drug",this.waiting_drug)
  323. for(let i = 0;i < this.waiting_drug.length;i++){
  324. if(tps == this.waiting_drug[i].id){
  325. this.$refs.table01.setCurrentRow(this.waiting_drug[i]);
  326. this.handleCurrentChange(this.waiting_drug[i])
  327. }
  328. }
  329. })
  330. },
  331. changeTimes(){
  332. // alert("aa")
  333. // this.getdruglist();
  334. this.fun3();
  335. },
  336. //初始化
  337. init(){
  338. this.state = 1
  339. this.tableData = null
  340. this.currentRow = null
  341. },
  342. lala(){
  343. this.currentRow = null
  344. this.tableData = null
  345. this.selectedbydefault()
  346. },
  347. searchAction() {
  348. // this.getlist();
  349. this.tableData = null
  350. this.currentRow = null
  351. this.getdruglist();
  352. },
  353. // 跳转打印页面
  354. toPrint() {
  355. if (this.state == 1 && this.multipleSelection.length == 0){
  356. this.$message.error("未选择任何数据");
  357. return
  358. }
  359. if (this.state == 2 && this.tableData == null){
  360. this.$message.error("未选择任何数据");
  361. return
  362. }
  363. this.$refs.drugprint.show(this.tableData,this.currentRow,this.state,this.multipleSelection);
  364. },
  365. //列表选择
  366. handleSelectionChange(val) {
  367. this.multipleSelection = val;
  368. },
  369. //默认选中
  370. selectedbydefault(){
  371. if(this.state == 1 && this.waiting_drug.length > 0){
  372. this.$refs.table01.setCurrentRow(this.waiting_drug[0]);
  373. this.handleCurrentChange(this.waiting_drug[0])
  374. }
  375. if(this.state == 2 && this.issued_drug.length >0){
  376. this.$refs.table02.setCurrentRow(this.issued_drug[0]);
  377. this.handleCurrentChange(this.issued_drug[0])
  378. }
  379. },
  380. //包装selectedbydefault
  381. fun2(){
  382. console.log("3333333this.waitmount_data",this.waiting_drug)
  383. // return new Promise((resolve, reject) => {
  384. if(this.state == 1 && this.waiting_drug.length > 0){
  385. this.$refs.table01.setCurrentRow(this.waiting_drug[0]);
  386. this.handleCurrentChange(this.waiting_drug[0])
  387. }
  388. if(this.state == 2 && this.issued_drug.length >0){
  389. this.$refs.table02.setCurrentRow(this.issued_drug[0]);
  390. this.handleCurrentChange(this.issued_drug[0])
  391. }
  392. // });
  393. },
  394. // 药品发药
  395. dispense() {
  396. var tps = this.currentRow.id;
  397. if(this.multipleSelection.length < 1){
  398. this.$message.error("未选择任何信息")
  399. return
  400. }
  401. var tmp = "";
  402. console.log("初始值",tmp)
  403. for (var i=0;i < this.multipleSelection.length;i++){
  404. tmp = tmp + this.multipleSelection[i].id + ","
  405. }
  406. var params = {
  407. creater: this.admin_user_id,
  408. ids: tmp,
  409. }
  410. medicinedeparture(params).then((res) => {
  411. if (res.data.state == 1){
  412. this.$message.success("操作成功")
  413. this.getdruglist();
  414. //刷新列表
  415. this.handleCurrentChange(this.currentRow);
  416. this.fun4(tps);
  417. this.state = 2;
  418. this.multipleSelection = []
  419. }else{
  420. this.$message.error("操作失败:" + res.data.msg)
  421. //刷新列表
  422. this.handleCurrentChange(this.currentRow);
  423. this.fun5(tps);
  424. this.state = 1;
  425. }
  426. })
  427. },
  428. //获取药品列表
  429. getdruglist(){
  430. var params = {
  431. keyword: this.keywords,
  432. time: this.start_time,
  433. }
  434. waitingmedicine(params).then((res) => {
  435. if (res.data.state == 1){
  436. this.waiting_drug = res.data.data.list
  437. }
  438. })
  439. dispensemedicine(params).then((res) => {
  440. if (res.data.state == 1){
  441. this.issued_drug = res.data.data.list
  442. }
  443. })
  444. },
  445. async fun1(){
  446. var params = {
  447. keyword: this.keywords,
  448. time: this.start_time,
  449. }
  450. await waitingmedicine(params).then((res) => {
  451. if (res.data.state == 1){
  452. this.waiting_drug = res.data.data.list
  453. }
  454. console.log("fun1lil1111i")
  455. })
  456. await dispensemedicine(params).then((res) => {
  457. if (res.data.state == 1){
  458. this.issued_drug = res.data.data.list
  459. }
  460. console.log("fun122222222")
  461. })
  462. console.log("fun1")
  463. },
  464. morencreatename(){
  465. var param ={}
  466. getcurrentname(param).then((res) => {
  467. console.log("res(药)",res)
  468. if (res.data.state == 1){
  469. this.admin_user_id = res.data.data.list;
  470. console.log("this.admin_user_id(药)",this.admin_user_id)
  471. }
  472. });
  473. },
  474. //获取领药人选项
  475. getlist(){
  476. var params = {
  477. start_time:this.start_time,
  478. keywords:this.keywords,
  479. }
  480. getTodayAdviceList(params).then(response=>{
  481. if(response.data.state == 1){
  482. this.doctorList = response.data.data.doctorlist
  483. console.log("this.admin_user_id(药2)",this.admin_user_id)
  484. // this.admin_user_id = this.doctorList[0].admin_user_id
  485. // this.admin_user_id = this.tmp
  486. }
  487. })
  488. },
  489. // //获取药品的患者信息
  490. informationofdrugs(val){
  491. var params = {
  492. // patient_id: this.currentRow.
  493. }
  494. },
  495. handleCurrentChange(val) {
  496. this.currentRow = val;
  497. if(this.state == 1){
  498. this.getdrugsdetails(0)
  499. }
  500. if (this.state == 2){
  501. this.getdrugsdetails(1)
  502. }
  503. },
  504. getdrugsdetails(val){
  505. var params = {
  506. drug_id:this.currentRow.id,
  507. is_medicine:val,
  508. time:this.start_time,
  509. }
  510. getpatientswithdrugs(params).then((res) => {
  511. if (res.data.state == 1){
  512. this.tableData = res.data.data.list;//列表数据
  513. }else {
  514. this.$message.error(res.data.msg);
  515. }
  516. })
  517. },
  518. toSetting(){
  519. getPharmacyConfig().then(response=>{
  520. if(response.data.state == 1){
  521. this.dialogVisible = true
  522. var config = response.data.data.config
  523. this.is_open = config.is_open.toString()
  524. }
  525. })
  526. },
  527. SaveSetting(){
  528. var params = {
  529. is_open:parseInt(this.is_open),
  530. }
  531. SaveSetting(params).then(response=>{
  532. if(response.data.state == 1){
  533. var config = response.data.data.config
  534. this.$message.success("保存成功!")
  535. this.dialogVisible = false
  536. }
  537. })
  538. },
  539. getUserlist(drug_id){
  540. var params = {
  541. start_time:this.start_time,
  542. drug_id:drug_id,
  543. }
  544. getUserdDrugList(params).then(response=>{
  545. if(response.data.state == 1){
  546. var advicelist = response.data.data.advicelist
  547. for(let i=0;i<advicelist.length;i++){
  548. advicelist[i].type = 1
  549. advicelist[i].day = " "
  550. this.tableList.push(advicelist[i])
  551. }
  552. var hisAdviceList = response.data.data.hisAdviceList
  553. for(let i=0;i<hisAdviceList.length;i++){
  554. hisAdviceList[i].type = 2
  555. this.tableList.push(hisAdviceList[i])
  556. }
  557. var patient = response.data.data.patient
  558. this.patientList = patient
  559. }
  560. })
  561. }
  562. },
  563. created() {
  564. this.init();
  565. this.morencreatename();
  566. this.getlist();
  567. // this.getdruglist();
  568. this.fun3();
  569. },
  570. };
  571. </script>
  572. <style rel="stylesheet/css" lang="scss" scoped>
  573. .new-main-contain {
  574. height: 100%;
  575. display: flex;
  576. flex-direction: column;
  577. }
  578. .app-container {
  579. height: 100%;
  580. }
  581. .mainLeft {
  582. width: 300px;
  583. height: 100%;
  584. display: flex;
  585. flex-direction: column;
  586. .el-radio {
  587. margin-right: 75px;
  588. }
  589. .list {
  590. margin: 10px 0;
  591. }
  592. }
  593. .mainRight {
  594. margin-left: 10px;
  595. flex: 1;
  596. height: 100%;
  597. display: flex;
  598. flex-direction: column;
  599. overflow-y: auto;
  600. .titlelist {
  601. display: flex;
  602. justify-content: flex-end;
  603. }
  604. }
  605. </style>