patientDrugQuery.vue 21KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680
  1. <template>
  2. <div class="main-contain">
  3. <div class="app-container" style="padding-left:0px;margin:0px;" v-loading="loading"
  4. element-loading-text="拼命加载中">
  5. <el-container>
  6. <div style="width:27%">
  7. <!-- <el-row style="white-space:nowrap;display:flex;line-height: 31px;">
  8. <span style="font-size:14px;color:#606266"> 时间:</span>
  9. <el-date-picker
  10. size="small"
  11. v-model="start_time"
  12. prefix-icon="el-icon-date"
  13. :editable="false"
  14. type="date"
  15. placeholder="选择日期时间"
  16. align="right"
  17. format="yyyy-MM-dd"
  18. value-format="yyyy-MM-dd"
  19. @change="startTimeChange"
  20. :clearable="false"
  21. ></el-date-picker>
  22. <span>-</span>
  23. <el-date-picker
  24. size="small"
  25. v-model="end_time"
  26. prefix-icon="el-icon-date"
  27. :editable="false"
  28. type="date"
  29. placeholder="选择日期时间"
  30. align="right"
  31. format="yyyy-MM-dd"
  32. value-format="yyyy-MM-dd"
  33. @change="endTimeChange"
  34. ></el-date-picker>
  35. </el-row> -->
  36. <el-row></el-row>
  37. <el-row>
  38. <el-col :span="24" style="display:flex">
  39. <el-input style="margin-top:10px;margin-bottom:10px" placeholder="请输入患者姓名" v-model="keyword"></el-input>&nbsp;
  40. <el-button style="height: 35px;margin-top: 10px;margin-bottom: 10px;" type="primary" @click="onSearch" icon="el-icon-search">搜索</el-button>
  41. </el-col>
  42. </el-row>
  43. <el-row>
  44. <el-table
  45. ref="singleTable"
  46. :data="patientList"
  47. highlight-current-row
  48. border
  49. @current-change="handleCurrentChange"
  50. height="440"
  51. :row-style="{ color: '#303133' }"
  52. :header-cell-style="{
  53. backgroundColor: 'rgb(245, 247, 250)',
  54. color: '#606266'
  55. }"
  56. >
  57. <el-table-column
  58. prop="date"
  59. label="序号"
  60. align="center"
  61. >
  62. <template slot-scope="scope">
  63. {{scope.$index + 1}}
  64. </template>
  65. </el-table-column>
  66. <el-table-column
  67. prop="name"
  68. label="姓名"
  69. align="center">
  70. <template slot-scope="scope">
  71. {{scope.row.name}}
  72. </template>
  73. </el-table-column>
  74. </el-table>
  75. </el-row>
  76. </div>
  77. <el-main>
  78. <div class="main newMain">
  79. <el-tabs>
  80. <el-tab-pane label="患者使用列表">
  81. <div style="float:right;margin-bottom:10px">
  82. <!-- <el-button type="primary" @click="toPrint">打印</el-button>
  83. <el-button type="primary" @click="exportList">导出</el-button> -->
  84. </div>
  85. <el-table
  86. :data="tableList"
  87. highlight-current-row
  88. border
  89. height="440"
  90. :row-style="{ color: '#303133' }"
  91. :header-cell-style="{
  92. backgroundColor: 'rgb(245, 247, 250)',
  93. color: '#606266'
  94. }"
  95. >
  96. <el-table-column
  97. prop="date"
  98. label="药品名称"
  99. align="center"
  100. >
  101. <template slot-scope="scope">
  102. {{scope.row.drug.drug_name}}
  103. </template>
  104. </el-table-column>
  105. <el-table-column
  106. prop="date"
  107. label="药品规格"
  108. align="center"
  109. >
  110. <template slot-scope="scope">
  111. {{ scope.row.drug.dose}}{{ scope.row.drug.dose_unit }} * {{ scope.row.drug.min_number }}{{ scope.row.drug.min_unit }} /{{ scope.row.drug.max_unit }}
  112. </template>
  113. </el-table-column>
  114. <el-table-column
  115. prop="name"
  116. label="生产厂家"
  117. align="center">
  118. <template slot-scope="scope">
  119. {{ getManufacturName(scope.row.drug.manufacturer) }}
  120. </template>
  121. </el-table-column>
  122. <el-table-column
  123. prop="name"
  124. label="规格&单位"
  125. align="center">
  126. <template slot-scope="scope">
  127. {{scope.row.dose}}{{scope.row.dose_unit}} * {{scope.row.min_number}}{{scope.row.min_unit}}/{{scope.row.max_unit}}
  128. </template>
  129. </el-table-column>
  130. <el-table-column
  131. prop="name"
  132. label="入库数量"
  133. align="center">
  134. <template slot-scope="scope">
  135. {{ scope.row.sum_in_count }}
  136. </template>
  137. </el-table-column>
  138. <el-table-column
  139. prop="name"
  140. label="出库数量"
  141. align="center">
  142. <template slot-scope="scope">
  143. {{ scope.row.sum_out_count }}
  144. </template>
  145. </el-table-column>
  146. <el-table-column
  147. prop="name"
  148. label="退库数量"
  149. align="center">
  150. <template slot-scope="scope">
  151. {{ scope.row.sum_cancel_count }}
  152. </template>
  153. </el-table-column>
  154. <el-table-column
  155. prop="name"
  156. label="实际出库"
  157. align="center">
  158. <template slot-scope="scope">
  159. {{ scope.row.sum_act_out_count }}
  160. </template>
  161. </el-table-column>
  162. <el-table-column
  163. prop="name"
  164. label="剩余库存"
  165. align="center">
  166. <template slot-scope="scope">
  167. {{ scope.row.flush_count }}
  168. </template>
  169. </el-table-column>
  170. <el-table-column label="操作" align="center" width="200px">
  171. <template slot-scope="scope">
  172. <el-button
  173. size="small"
  174. type="primary"
  175. @click="toClick(scope.row)"
  176. >库存流水
  177. </el-button>
  178. <el-button
  179. size="small"
  180. type="primary"
  181. @click="toClickOne(scope.row)"
  182. >批次
  183. </el-button>
  184. </template>
  185. </el-table-column>
  186. </el-table>
  187. <el-pagination
  188. @size-change="handleSizeChange"
  189. @current-change="handleCurrentChangeOne"
  190. :page-sizes="[10, 50, 100,200,500,1000]"
  191. :page-size="10"
  192. background
  193. align="right"
  194. style="margin-top:20px;"
  195. layout="total, sizes, prev, pager, next, jumper"
  196. :total="total"
  197. >
  198. </el-pagination>
  199. </el-tab-pane>
  200. </el-tabs>
  201. </div>
  202. </el-main>
  203. </el-container>
  204. </el-container>
  205. </el-container>
  206. </div>
  207. </div>
  208. </template>
  209. <script>
  210. import { getGoodPatientList,getSelfDrugWarehouseOutDetailByPatientId } from "@/api/drug/drug"
  211. export default {
  212. data(){
  213. return{
  214. zoneList:[],
  215. zone_id:0,
  216. tableData:[],
  217. DeviceTypeType:[],
  218. device_type:"",
  219. forms:{},
  220. start_time:"",
  221. end_time:"",
  222. patientList:[],
  223. tableList:[],
  224. keyword:"",
  225. manufacturerList:[],
  226. patient_id:0,
  227. patient:{},
  228. limit:10,
  229. page:1,
  230. total:0,
  231. loading:false,
  232. }
  233. },
  234. methods:{
  235. handleSizeChange(val) {
  236. this.limit = val;
  237. this.getDrugWarehouseOutDetailByPatientId()
  238. },
  239. handleCurrentChangeOne(val) {
  240. this.page = val;
  241. this.getDrugWarehouseOutDetailByPatientId()
  242. },
  243. startTimeChange(){
  244. this.handleCurrentChange(this.patient)
  245. },
  246. endTimeChange(){
  247. this.handleCurrentChange(this.patient)
  248. },
  249. getManufacturName(id){
  250. var manufacturer_name = ""
  251. for(let i=0;i<this.manufacturerList.length;i++){
  252. if(id == this.manufacturerList[i].id){
  253. manufacturer_name = this.manufacturerList[i].manufacturer_name
  254. }
  255. }
  256. return manufacturer_name
  257. },
  258. getDearName(id){
  259. var dear_name = ""
  260. for(let i=0;i<this.dealerList.length;i++){
  261. if(id == this.dealerList[i].id){
  262. dear_name = this.dealerList[i].dealer_name
  263. }
  264. }
  265. return dear_name
  266. },
  267. getlist(){
  268. this.loading = true
  269. var params = {
  270. keyword:this.keyword,
  271. }
  272. getGoodPatientList(params).then(response=>{
  273. if(response.data.state == 1){
  274. this.loading = false
  275. var list = response.data.data.list
  276. this.patientList=[]
  277. this.patientList = list
  278. this.$refs.singleTable.setCurrentRow(this.patientList[0]);
  279. this.handleCurrentChange(this.patientList[0])
  280. }
  281. })
  282. },
  283. onSearch(){
  284. this.getlist()
  285. },
  286. handleCurrentChange(val){
  287. this.patient = val
  288. var params = {
  289. patient_id:val.id,
  290. start_time:this.start_time,
  291. end_time:this.end_time,
  292. limit:this.limit,
  293. page:this.page,
  294. }
  295. getSelfDrugWarehouseOutDetailByPatientId(params).then(response=>{
  296. if(response.data.state == 1){
  297. var list = response.data.data.list
  298. this.tableList = list
  299. this.total = response.data.data.total
  300. this.manufacturerList = response.data.data.manufacturerList
  301. }
  302. })
  303. },
  304. getDrugWarehouseOutDetailByPatientId(){
  305. var params = {
  306. patient_id:this.patient.id,
  307. start_time:this.start_time,
  308. end_time:this.end_time,
  309. limit:this.limit,
  310. page:this.page,
  311. }
  312. console.log("hh23232323232323",params)
  313. getDrugWarehouseOutDetailByPatientId(params).then(response=>{
  314. if(response.data.state == 1){
  315. var list = response.data.data.list
  316. console.log("list233223232323",list)
  317. var outlist = response.data.data.outlist
  318. this.manufacturerList = response.data.data.manufacturerList
  319. if(list!=null && list.length > 0){
  320. for(let i=0;i<list.length;i++){
  321. if(list[i].count_unit == list[i].drug.max_unit){
  322. list[i].count = list[i].count * list[i].drug.min_number
  323. }
  324. }
  325. }
  326. let dataInfo = {}
  327. list.forEach((item, index) => {
  328. let { drug_id } = item
  329. if (!dataInfo[drug_id]) {
  330. dataInfo[drug_id] = {
  331. drug_id,
  332. child: [],
  333. dose:item.drug.dose,
  334. dose_unit:item.drug.dose_unit,
  335. min_number:item.drug.min_number,
  336. min_unit:item.drug.min_unit,
  337. max_unit:item.drug.max_unit,
  338. drug_name:item.drug.drug_name,
  339. manufacturer:this.getManufacturName(item.manufacturer),
  340. }
  341. }
  342. })
  343. let arr = Object.values(dataInfo)
  344. arr.forEach((item,index)=>{
  345. for(let i=0;i<outlist.length;i++){
  346. if(item.drug_id == outlist[i].drug_id){
  347. item.child.push(outlist[i])
  348. }
  349. }
  350. })
  351. this.tableList = arr
  352. }
  353. })
  354. },
  355. getManufacturName(id){
  356. var manufacturer_name = ""
  357. for(let i=0;i<this.manufacturerList.length;i++){
  358. if(id == this.manufacturerList[i].id){
  359. manufacturer_name = this.manufacturerList[i].manufacturer_name
  360. }
  361. }
  362. return manufacturer_name
  363. },
  364. open(){
  365. console.log("haaaaaaaaaaaaaaaaaaaaaaa")
  366. this.getlist()
  367. },
  368. getCount(val,min_number,max_unit,min_unit){
  369. var total = 0
  370. var min_str = ""
  371. var max_str = ""
  372. if(val!=null && val.length>0){
  373. for(let i=0;i<val.length;i++){
  374. total +=val[i].count
  375. }
  376. }
  377. if (total < min_number) {
  378. min_str = total + min_unit;
  379. }
  380. if (total == 0) {
  381. min_str = "";
  382. max_str = "";
  383. }
  384. if (total >= min_number) {
  385. if (parseInt(total / min_number) != 0) {
  386. max_str = parseInt(total / min_number) + max_unit;
  387. }
  388. if (total % min_number != 0) {
  389. min_str = (total % min_number) + min_unit;
  390. }
  391. }
  392. return max_str + min_str;
  393. },
  394. toPrint(){
  395. var patient_name = ""
  396. for(let i=0;i<this.patientList.length;i++){
  397. if(this.patient.id == this.patientList[i].id){
  398. patient_name = this.patientList[i].name
  399. }
  400. }
  401. this.$router.push({path:"/drugs/patient/print?start_time="+this.start_time+"&end_time="+this.end_time+"&page="+this.page+"&limit="+this.limit+"&keyword="+this.keyword+"&patient_id="+this.patient.id+"&patient_name="+patient_name})
  402. },
  403. exportList(){
  404. for(let i=0;i<this.tableList.length;i++){
  405. this.tableList[i].index = i+1
  406. this.tableList[i].count_name = this.getCount(this.tableList[i].child,this.tableList[i].min_number,this.tableList[i].max_unit,this.tableList[i].min_unit)
  407. this.tableList[i].query_date = this.start_time + "~" + this.end_time
  408. this.tableList[i].specification_name = this.tableList[i].dose +this.tableList[i].dose_unit + "*"+this.tableList[i].min_number+this.tableList[i].min_unit+"/"+this.tableList[i].max_unit
  409. this.tableList[i].patient_name = ""
  410. if(this.tableList[i].index == 1){
  411. this.tableList[i].patient_name = this.getPatientName(this.patient.id)
  412. }
  413. }
  414. import('@/vendor/Export2Excel').then(excel => {
  415. const tHeader = ['序号','患者姓名','查询日期','药品名称','生产厂家','规格&单位','数量']
  416. const filterVal = ['index','patient_name','query_date','drug_name', 'manufacturer','specification_name','count_name']
  417. const data = this.formatJson(filterVal,this.tableList)
  418. excel.export_json_to_excel({
  419. header: tHeader,
  420. data,
  421. filename: '患者药品使用查询表'
  422. })
  423. })
  424. },
  425. formatJson(filterVal, jsonData) {
  426. return jsonData.map(v => filterVal.map(j => v[j]))
  427. },
  428. getPatientName(id){
  429. var patient_name = ""
  430. for(let i=0;i<this.patientList.length;i++){
  431. if(id == this.patientList[i].id){
  432. patient_name = this.patientList[i].name
  433. }
  434. }
  435. return patient_name
  436. },
  437. toClick(val){
  438. var manufacturer_name = ""
  439. var specification_name = ""
  440. for(let i=0;i<this.manufacturerList.length;i++){
  441. if(val.drug.manufacturer == this.manufacturerList[i].id){
  442. manufacturer_name = this.manufacturerList[i].manufacturer_name
  443. }
  444. }
  445. specification_name = val.drug.specification_name + "/" + val.drug.packing_unit
  446. this.$router.push({path:"/stock/selfwarehouse/selfdrugflow?drug_id="+val.drug_id+"&manufacturer="+manufacturer_name+"&packing_unit="+val.drug.packing_unit+"&overCount="+val.flush_count+"&patient_id="+val.patient_id})
  447. },
  448. toClickOne(val){
  449. var manufacturer_name = ""
  450. var specification_name = ""
  451. for(let i=0;i<this.manufacturerList.length;i++){
  452. if(val.drug.manufacturer == this.manufacturerList[i].id){
  453. manufacturer_name = this.manufacturerList[i].manufacturer_name
  454. }
  455. }
  456. specification_name = val.drug.specification_name + "/" + val.drug.packing_unit
  457. this.$router.push({path:"/stock/selfwarehouse/selfdrugbatchnumber?drug_id="+val.drug_id+"&manufacturer="+manufacturer_name+"&packing_unit="+val.drug.packing_unit+"&overCount="+val.flush_count+"&patient_id="+val.patient_id})
  458. },
  459. },
  460. created(){
  461. var nowDate = new Date();
  462. var nowYear = nowDate.getFullYear();
  463. var nowMonth = nowDate.getMonth() + 1;
  464. var nowDay = nowDate.getDate();
  465. this.end_time =
  466. nowYear +
  467. "-" +
  468. (nowMonth < 10 ? "0" + nowMonth : nowMonth) +
  469. "-" +
  470. (nowDay < 10 ? "0" + nowDay : nowDay);
  471. nowDate.setMonth(nowDate.getMonth() - 1);
  472. nowYear = nowDate.getFullYear();
  473. nowMonth = nowDate.getMonth() + 1;
  474. nowDay = nowDate.getDate();
  475. this.start_time =
  476. nowYear +
  477. "-" +
  478. (nowMonth < 10 ? "0" + nowMonth : nowMonth) +
  479. "-" +
  480. (nowDay < 10 ? "0" + nowDay : nowDay);
  481. },
  482. }
  483. </script>
  484. <style lang="scss" scoped>
  485. .zone{
  486. // margin-left: 30px;
  487. // text-align: left;
  488. width: 70px;
  489. display: inline-block;
  490. color:#606266;
  491. }
  492. .disinfect{
  493. position: relative;
  494. .newButton{
  495. // position: absolute;
  496. // right: 2%;
  497. // top:4px;
  498. // z-index: 9;
  499. margin-bottom: 10px;
  500. margin-left: 90%;
  501. }
  502. }
  503. .disinfectOne{
  504. position: relative;
  505. .newButtonOne{
  506. position: absolute;
  507. right: 0;
  508. top: -10;
  509. z-index: 18;
  510. }
  511. }
  512. .but{
  513. width: 200px;
  514. height: 50px;
  515. // border: solid 1px red;
  516. margin-left: 77%;
  517. }
  518. .clearn{
  519. width: 460px;
  520. height: 50px;
  521. // border:solid 1px red;
  522. margin-left:650px;
  523. }
  524. .zClass{
  525. width: 200px;
  526. height: 200px;
  527. // border:solid 1px red;
  528. margin-left: 450px;
  529. margin-top: 200px;
  530. }
  531. .warn{
  532. color: red;
  533. font-size: 14px;
  534. width: 100%;
  535. display: inline-block;
  536. margin-left: 96px;
  537. }
  538. .userbutton{
  539. margin-bottom: 10px;
  540. margin-left: 82%
  541. }
  542. /deep/ .el-tabs__content{
  543. margin-top: 10px;
  544. }
  545. </style>
  546. <style lang="scss">
  547. .a{
  548. margin-bottom: 10px;
  549. margin-top: 6px;
  550. }
  551. .b{
  552. .el-button{
  553. margin-left: 90%;
  554. margin-bottom: 10px;
  555. }
  556. }
  557. .stoppage{
  558. .el-form-item__label{
  559. width:190px;
  560. }
  561. }
  562. .st{
  563. .el-form-item__label{
  564. width:-10px;
  565. }
  566. }
  567. .main{
  568. position: relative;
  569. .newButtonOne{
  570. position:absolute;
  571. right: 0;
  572. z-index: 2;
  573. }
  574. }
  575. .elbutton{
  576. // border: solid 1px red;
  577. height: 50px;
  578. width: 400px;
  579. margin-left: 650px;
  580. }
  581. // .el-form-item__label {
  582. // width: 130px;
  583. // font-size: 14px;
  584. // }
  585. .el-form-item__error {
  586. margin-left: 130px;
  587. }
  588. .el-upload-list__item-name {
  589. color: #606266;
  590. display: block;
  591. margin-right: 40px;
  592. overflow: hidden;
  593. padding-left: 4px;
  594. text-overflow: ellipsis;
  595. transition: color .3s;
  596. white-space: nowrap;
  597. }
  598. .el-main{
  599. padding-top: 0px;
  600. }
  601. .newMain{
  602. .el-form-item__label{
  603. width: 104px;
  604. }
  605. }
  606. .newDisinfectOne{
  607. .el-input--prefix .el-input__inner{
  608. padding-left: 15px
  609. }
  610. }
  611. .stoppage{
  612. .el-form-item__label{
  613. width: 18%;
  614. }
  615. }
  616. .newItem{
  617. .el-form-item__label{
  618. width: 130px;
  619. }
  620. }
  621. .formItem{
  622. .el-form-item__label{
  623. width: 104px;
  624. line-height: 30px;
  625. }
  626. }
  627. .newname{
  628. .el-form-item__label{
  629. width: 60px;
  630. }
  631. }
  632. ::-webkit-scrollbar{
  633. height: 20px;
  634. }
  635. </style>