DrugDispensing.vue 39KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495969798991001011021031041051061071081091101111121131141151161171181191201211221231241251261271281291301311321331341351361371381391401411421431441451461471481491501511521531541551561571581591601611621631641651661671681691701711721731741751761771781791801811821831841851861871881891901911921931941951961971981992002012022032042052062072082092102112122132142152162172182192202212222232242252262272282292302312322332342352362372382392402412422432442452462472482492502512522532542552562572582592602612622632642652662672682692702712722732742752762772782792802812822832842852862872882892902912922932942952962972982993003013023033043053063073083093103113123133143153163173183193203213223233243253263273283293303313323333343353363373383393403413423433443453463473483493503513523533543553563573583593603613623633643653663673683693703713723733743753763773783793803813823833843853863873883893903913923933943953963973983994004014024034044054064074084094104114124134144154164174184194204214224234244254264274284294304314324334344354364374384394404414424434444454464474484494504514524534544554564574584594604614624634644654664674684694704714724734744754764774784794804814824834844854864874884894904914924934944954964974984995005015025035045055065075085095105115125135145155165175185195205215225235245255265275285295305315325335345355365375385395405415425435445455465475485495505515525535545555565575585595605615625635645655665675685695705715725735745755765775785795805815825835845855865875885895905915925935945955965975985996006016026036046056066076086096106116126136146156166176186196206216226236246256266276286296306316326336346356366376386396406416426436446456466476486496506516526536546556566576586596606616626636646656666676686696706716726736746756766776786796806816826836846856866876886896906916926936946956966976986997007017027037047057067077087097107117127137147157167177187197207217227237247257267277287297307317327337347357367377387397407417427437447457467477487497507517527537547557567577587597607617627637647657667677687697707717727737747757767777787797807817827837847857867877887897907917927937947957967977987998008018028038048058068078088098108118128138148158168178188198208218228238248258268278288298308318328338348358368378388398408418428438448458468478488498508518528538548558568578588598608618628638648658668678688698708718728738748758768778788798808818828838848858868878888898908918928938948958968978988999009019029039049059069079089099109119129139149159169179189199209219229239249259269279289299309319329339349359369379389399409419429439449459469479489499509519529539549559569579589599609619629639649659669679689699709719729739749759769779789799809819829839849859869879889899909919929939949959969979989991000100110021003100410051006100710081009101010111012101310141015101610171018101910201021102210231024102510261027102810291030103110321033103410351036103710381039104010411042104310441045104610471048104910501051105210531054105510561057105810591060106110621063106410651066106710681069107010711072107310741075107610771078107910801081108210831084108510861087108810891090109110921093109410951096109710981099110011011102110311041105110611071108110911101111111211131114111511161117111811191120112111221123112411251126112711281129113011311132113311341135113611371138113911401141114211431144114511461147114811491150115111521153115411551156115711581159116011611162116311641165116611671168116911701171117211731174117511761177117811791180118111821183118411851186118711881189119011911192119311941195119611971198119912001201120212031204120512061207120812091210121112121213121412151216121712181219122012211222122312241225122612271228122912301231123212331234123512361237123812391240124112421243124412451246124712481249125012511252125312541255125612571258125912601261126212631264126512661267126812691270127112721273127412751276127712781279128012811282128312841285128612871288128912901291129212931294129512961297129812991300130113021303130413051306130713081309131013111312131313141315131613171318131913201321132213231324132513261327132813291330133113321333133413351336133713381339134013411342134313441345134613471348134913501351135213531354135513561357135813591360136113621363
  1. <template>
  2. <!--药品发药页面-->
  3. <div class="main-contain new-main-contain">
  4. <div class="position">
  5. <!-- <bread-crumb :crumbs='crumbs'></bread-crumb>-->
  6. <bread-crumb :crumbs="crumbs"></bread-crumb>
  7. </div>
  8. <div
  9. class="app-container"
  10. style="display: flex; flex: 1; padding: 10px 20px 0px 20px"
  11. >
  12. <div class="mainLeft">
  13. <div>
  14. <div class="list">
  15. <el-date-picker
  16. style="width: 300px"
  17. v-model="start_time"
  18. type="date"
  19. format="yyyy-MM-dd"
  20. value-format="yyyy-MM-dd"
  21. placeholder="选择日期"
  22. @change="changeTimes()"
  23. >
  24. </el-date-picker>
  25. </div>
  26. <div class="list">
  27. <el-radio-group v-model="state" @change="lala()">
  28. <el-radio :label="1">待发药</el-radio>
  29. <el-radio :label="2">已发药</el-radio>
  30. </el-radio-group>
  31. </div>
  32. <div class="list">
  33. <el-input
  34. size="small"
  35. style="width: 239px"
  36. v-model="keywords"
  37. class="filter-item"
  38. placeholder="请输入药品名称"
  39. />
  40. <el-button
  41. size="small"
  42. class="filter-item"
  43. type="primary"
  44. @click="searchAction"
  45. >搜索
  46. </el-button>
  47. </div>
  48. <el-table
  49. v-if="state == 1"
  50. height="60vh"
  51. :data="waiting_drug"
  52. border
  53. style="width: 100%"
  54. highlight-current-row
  55. ref="table01"
  56. @current-change="handleCurrentChange"
  57. :row-style="{ color: '#303133' }"
  58. :header-cell-style="{
  59. backgroundColor: 'rgb(245, 247, 250)',
  60. color: '#606266',
  61. }"
  62. >
  63. <el-table-column prop="name" label="名称" width="100">
  64. <template slot-scope="scope">
  65. {{ scope.row.name }}
  66. </template>
  67. </el-table-column>
  68. <el-table-column prop="specifications" label="规格" width="100">
  69. <template slot-scope="scope">
  70. {{ scope.row.specifications }}
  71. </template>
  72. </el-table-column>
  73. <el-table-column prop="stock" label="库存" width="100">
  74. <template slot-scope="scope">
  75. {{ scope.row.stock }}
  76. </template>
  77. </el-table-column>
  78. </el-table>
  79. <el-table
  80. v-if="state == 2"
  81. :height="tableHeight"
  82. :data="issued_drug"
  83. border
  84. style="width: 100%"
  85. highlight-current-row
  86. @current-change="handleCurrentChange"
  87. :row-style="{ color: '#303133' }"
  88. :header-cell-style="{
  89. backgroundColor: 'rgb(245, 247, 250)',
  90. color: '#606266',
  91. }"
  92. ref="table02"
  93. >
  94. <el-table-column prop="name" label="名称" width="100">
  95. <template slot-scope="scope">
  96. {{ scope.row.name }}
  97. </template>
  98. </el-table-column>
  99. <el-table-column prop="specifications" label="规格" width="100">
  100. <template slot-scope="scope">
  101. {{ scope.row.specifications }}
  102. </template>
  103. </el-table-column>
  104. <el-table-column prop="stock" label="库存" width="100">
  105. <template slot-scope="scope">
  106. {{ scope.row.stock }}
  107. </template>
  108. </el-table-column>
  109. </el-table>
  110. </div>
  111. </div>
  112. <div class="mainRight">
  113. <div class="titlelist">
  114. <div>
  115. 班次:
  116. <el-select
  117. v-model="shift"
  118. placeholder="请选择"
  119. @change="getdrugsdetails"
  120. >
  121. <el-option
  122. v-for="item in banshift"
  123. :key="item.value"
  124. :label="item.text"
  125. :value="item.value"
  126. >
  127. </el-option>
  128. </el-select>
  129. 分区:
  130. <el-select
  131. v-model="partition"
  132. placeholder="请选择"
  133. @change="getdrugsdetails"
  134. >
  135. <el-option
  136. v-for="item in fen"
  137. :key="item.id"
  138. :label="item.name"
  139. :value="item.id"
  140. >
  141. </el-option>
  142. </el-select>
  143. 给药途径:
  144. <el-select
  145. v-model="deliveryway"
  146. placeholder="请选择"
  147. @change="getdruglist02"
  148. >
  149. <el-option
  150. v-for="item in routeofadministration"
  151. :key="item.name"
  152. :label="item.name"
  153. :value="item.name"
  154. >
  155. </el-option>
  156. </el-select>
  157. </div>
  158. <div>
  159. <el-button type="primary" @click="toExport" v-if="state == 2"
  160. >导出</el-button
  161. >
  162. <!-- <el-button type="primary" @click="tt">调试</el-button>-->
  163. <el-button type="primary" @click="dispense" v-if="state == 1"
  164. >发药</el-button
  165. >
  166. <el-button type="primary" @click="toPrint">打印</el-button>
  167. <!-- <el-button @click="tt">调试</el-button>-->
  168. </div>
  169. </div>
  170. <el-divider></el-divider>
  171. <div class="right_table">
  172. <el-table
  173. ref="table_01"
  174. :height="tableHeight"
  175. :data="tableData"
  176. :summary-method="getSummaries_t1"
  177. show-summary
  178. border
  179. highlight-current-row
  180. style="width: 100%"
  181. :row-style="{ color: '#303133' }"
  182. :header-cell-style="{
  183. backgroundColor: 'rgb(245, 247, 250)',
  184. color: '#606266',
  185. }"
  186. @selection-change="handleSelectionChange"
  187. v-if="state == 1"
  188. >
  189. <el-table-column type="selection" width="55" align="center">
  190. </el-table-column>
  191. <el-table-column
  192. type="index"
  193. label="序号"
  194. width="50"
  195. align="center"
  196. >
  197. </el-table-column>
  198. <el-table-column
  199. prop="name"
  200. label="患者名称"
  201. width="100"
  202. align="center"
  203. >
  204. <template slot-scope="scope">
  205. {{ scope.row.name }}
  206. </template>
  207. </el-table-column>
  208. <el-table-column
  209. prop="name"
  210. label="单次用量"
  211. width="100"
  212. align="center"
  213. >
  214. <template slot-scope="scope">
  215. {{ scope.row.single_dosage }}
  216. </template>
  217. </el-table-column>
  218. <el-table-column
  219. prop="name"
  220. label="用法"
  221. width="100"
  222. align="center"
  223. >
  224. <template slot-scope="scope">
  225. {{ scope.row.usage }}
  226. </template>
  227. </el-table-column>
  228. <el-table-column
  229. prop="name"
  230. label="频率"
  231. width="100"
  232. align="center"
  233. >
  234. <template slot-scope="scope">
  235. {{ scope.row.frequency }}
  236. </template>
  237. </el-table-column>
  238. <el-table-column
  239. prop="name"
  240. label="天数"
  241. width="100"
  242. align="center"
  243. >
  244. <template slot-scope="scope">
  245. {{ scope.row.days }}
  246. </template>
  247. </el-table-column>
  248. <el-table-column
  249. prop="name"
  250. label="总量"
  251. width="100"
  252. align="center"
  253. >
  254. <template slot-scope="scope">
  255. {{ scope.row.total }}
  256. </template>
  257. </el-table-column>
  258. <el-table-column label="药品追溯码" width="162" align="center">
  259. <template slot-scope="scope">
  260. <div @click="getDrugCode(scope.row.ID,scope.row.data_sources,scope.row.DrugCode,scope.$index)"><el-input style="width: 100;" v-model="scope.row.DrugCode"></el-input></div>
  261. </template>
  262. </el-table-column>
  263. <el-table-column
  264. prop="name"
  265. label="数据来源"
  266. width="102"
  267. align="center"
  268. >
  269. <template slot-scope="scope">
  270. {{ scope.row.data_sources }}
  271. </template>
  272. </el-table-column>
  273. </el-table>
  274. </div>
  275. <div class="right_table">
  276. <el-table
  277. ref="table_01"
  278. :height="tableHeight"
  279. :data="tableData"
  280. :summary-method="getSummaries_t2"
  281. show-summary
  282. border
  283. highlight-current-row
  284. style="width: 100%"
  285. :row-style="{ color: '#303133' }"
  286. :header-cell-style="{
  287. backgroundColor: 'rgb(245, 247, 250)',
  288. color: '#606266',
  289. }"
  290. @selection-change="handleSelectionChange"
  291. v-if="state == 2"
  292. >
  293. <!-- <el-table-column type="selection" width="55"> </el-table-column>-->
  294. <el-table-column
  295. type="index"
  296. label="序号"
  297. width="120"
  298. align="center"
  299. >
  300. </el-table-column>
  301. <el-table-column
  302. prop="name"
  303. label="患者名称"
  304. width="180"
  305. align="center"
  306. >
  307. <template slot-scope="scope">
  308. {{ scope.row.name }}
  309. </template>
  310. </el-table-column>
  311. <el-table-column
  312. prop="name"
  313. label="单次用量"
  314. width="170"
  315. align="center"
  316. >
  317. <template slot-scope="scope">
  318. {{ scope.row.single_dosage }}
  319. </template>
  320. </el-table-column>
  321. <el-table-column
  322. prop="name"
  323. label="用法"
  324. width="160"
  325. align="center"
  326. >
  327. <template slot-scope="scope">
  328. {{ scope.row.usage }}
  329. </template>
  330. </el-table-column>
  331. <el-table-column
  332. prop="name"
  333. label="频率"
  334. width="160"
  335. align="center"
  336. >
  337. <template slot-scope="scope">
  338. {{ scope.row.frequency }}
  339. </template>
  340. </el-table-column>
  341. <el-table-column
  342. prop="name"
  343. label="天数"
  344. width="160"
  345. align="center"
  346. >
  347. <template slot-scope="scope">
  348. {{ scope.row.days }}
  349. </template>
  350. </el-table-column>
  351. <el-table-column
  352. prop="name"
  353. label="总量"
  354. width="160"
  355. align="center"
  356. >
  357. <template slot-scope="scope">
  358. {{ scope.row.total }}
  359. </template>
  360. </el-table-column>
  361. <el-table-column
  362. prop="name"
  363. label="数据来源"
  364. width="162"
  365. align="center"
  366. >
  367. <template slot-scope="scope">
  368. {{ scope.row.data_sources }}
  369. </template>
  370. </el-table-column>
  371. <el-table-column
  372. prop="name"
  373. label="领药人"
  374. width="160"
  375. align="center"
  376. >
  377. <template slot-scope="scope">
  378. {{ scope.row.people }}
  379. </template>
  380. </el-table-column>
  381. </el-table>
  382. </div>
  383. <!-- <div style="background-color: #f5f7fa;display:flex;padding: 10px;justify-content:space-around;position:absolute;width:75.6%;margin-top: 27.5%;
  384. "><div style="width: 40%;padding-left:3%">合计 </div> <div style="width: 40%;display: flex;justify-content:center;padding-left: 37%">{{total}}</div></div> -->
  385. <div style="margin-top: 25px; display: flex" v-if="state == 1">
  386. <span style="line-height: 36px">领药人:</span>
  387. <el-select v-model="admin_user_id" placeholder="请选择">
  388. <el-option
  389. v-for="item in doctorList"
  390. :key="item.admin_user_id"
  391. :label="item.user_name"
  392. :value="item.admin_user_id"
  393. >
  394. </el-option>
  395. </el-select>
  396. <span
  397. style="display: inline-block;padding-left: 30px;line-height: 36px;}"
  398. >选中: {{ select_total }}</span
  399. >
  400. </div>
  401. </div>
  402. <el-dialog title="设置" :visible.sync="dialogVisible" width="30%">
  403. <span style="font-size: 17px">请选择药品是否要通过药房管理出库</span>
  404. <span style="display: block; padding: 18px 25px">
  405. <el-radio v-model="is_open" label="1">是</el-radio>
  406. <el-radio v-model="is_open" label="2">否</el-radio>
  407. </span>
  408. <div
  409. style="
  410. height: 50px;
  411. background: #c7ebfc;
  412. border-radius: 5px;
  413. padding: 7px;
  414. "
  415. >
  416. <i class="el-icon-info" style="color: #3399ff; font-size: 17px"></i>
  417. 若选择为是,则通过药房发药的药品都会在发药之后进行出库,否则按原来的方式进行出库管理
  418. </div>
  419. <span slot="footer" class="dialog-footer">
  420. <el-button @click="dialogVisible = false">取 消</el-button>
  421. <el-button type="primary" @click="SaveSetting">保 存</el-button>
  422. </span>
  423. </el-dialog>
  424. <el-dialog
  425. title="药品追溯码"
  426. :visible.sync="dialogVisibleOne"
  427. width="40%">
  428. <span>
  429. <el-input
  430. @keyup.native="changeText"
  431. type="textarea"
  432. placeholder="请输入内容"
  433. v-model="textarea"
  434. :rows="10"
  435. >
  436. </el-input>
  437. </span>
  438. <span slot="footer" class="dialog-footer">
  439. <el-button @click="dialogVisibleOne = false">取 消</el-button>
  440. <el-button type="primary" @click="saveTextArea()">确 定</el-button>
  441. </span>
  442. </el-dialog>
  443. </div>
  444. <drug-print
  445. ref="drugprint"
  446. :visibility="isVisibility"
  447. :propsTable="propsTable"
  448. :state="state"
  449. >
  450. </drug-print>
  451. </div>
  452. </template>
  453. <script>
  454. import drugPrint from "./print/drugPrint.vue";
  455. import BreadCrumb from "@/xt_pages/components/bread-crumb";
  456. import {
  457. getTodayAdviceList,
  458. getPharmacyBaseDrug,
  459. updatePharmacyBaseDrug,
  460. SaveSetting,
  461. getPharmacyConfig,
  462. getUserdDrugList,
  463. } from "@/api/his/advice";
  464. import {
  465. dispensemedicine,
  466. waitingmedicine,
  467. getpatientswithdrugs,
  468. medicinedeparture,
  469. getcurrentname,
  470. getpartitionlist,
  471. routeofadministration,
  472. changeDrugCode
  473. } from "@/api/pharmacy";
  474. const moment = require("moment");
  475. export default {
  476. components: {
  477. BreadCrumb,
  478. drugPrint,
  479. },
  480. data() {
  481. return {
  482. crumbs: [
  483. { path: false, name: "药房管理" },
  484. { path: "/Pharmacy/DrugDispensing", name: "药品发药" },
  485. ],
  486. tableHeight: 490,
  487. datepick: "",
  488. state: 1,
  489. waitmount: 0,
  490. alreadmount: 0,
  491. tableData: [],
  492. tableData_list: [],
  493. tableList: [],
  494. multipleSelection: [],
  495. start_time: moment(new Date()).add("year", 0).format("YYYY-MM-DD"),
  496. patientList: [],
  497. keywords: "",
  498. dialogVisible: false,
  499. is_open: "2",
  500. isVisibility: "",
  501. propsTable: "",
  502. doctorList: [],
  503. admin_user_id:0,
  504. waiting_drug: [], //待发药列表
  505. issued_drug: [], //已发药列表
  506. currentRow: null,
  507. tmp: 0,
  508. banshift: [
  509. { value: 0, text: "全部班" },
  510. { value: 1, text: "上午" },
  511. { value: 2, text: "下午" },
  512. { value: 3, text: "晚上" },
  513. ],
  514. shift: 0, //班次
  515. fen: [],
  516. partition: 0, //分区
  517. routeofadministration: [],
  518. deliveryway: "全部", //给药途径
  519. total: "", //合计
  520. select_total: "",
  521. dialogVisibleOne:false,
  522. textarea:"",
  523. id:0,
  524. is_source:0,
  525. drug_code:0,
  526. currentRow:{},
  527. currentIndex:0,
  528. };
  529. },
  530. methods: {
  531. getDrugCode(id,DataSources,DrugCode,index){
  532. this.id = id
  533. var is_source =0
  534. if (DataSources == "his处方"){
  535. is_source = 1
  536. }
  537. if (DataSources == "临时医嘱"){
  538. is_source = 2
  539. }
  540. this.is_source = is_source
  541. this.textarea = DrugCode
  542. this.currentIndex = index
  543. this.dialogVisibleOne = true
  544. },
  545. saveTextArea(){
  546. var params = {
  547. id:this.id,
  548. data_source:this.is_source,
  549. drug_code:this.textarea,
  550. }
  551. console.log("paramss",params)
  552. changeDrugCode(params).then(response=>{
  553. if(response.data.state == 1){
  554. this.$message.success("保存成功!")
  555. for(let i=0;i<this.tableData.length;i++){
  556. if(this.currentIndex == i){
  557. this.tableData[i].DrugCode = this.textarea
  558. }
  559. }
  560. this.dialogVisibleOne = false
  561. }
  562. })
  563. },
  564. changeText(event){
  565. // 检查是否为特定的按键,例如回车键,来确认扫码枪输入完成
  566. if (event.key === 'Enter') {
  567. var textarea = ""
  568. textarea += this.textarea + ","
  569. this.textarea = textarea
  570. }
  571. },
  572. tt() {},
  573. async fun3() {
  574. this.fun1().then((val) => {
  575. this.fun2();
  576. });
  577. },
  578. async fun4(tps) {
  579. this.fun1().then((val) => {
  580. for (let i = 0; i < this.issued_drug.length; i++) {
  581. if (tps == this.issued_drug[i].id) {
  582. this.$refs.table02.setCurrentRow(this.issued_drug[i]);
  583. this.handleCurrentChange(this.issued_drug[i]);
  584. }
  585. }
  586. });
  587. },
  588. async fun5(tps) {
  589. console.log("fun3", tps);
  590. this.fun1().then((val) => {
  591. for (let i = 0; i < this.waiting_drug.length; i++) {
  592. if (tps == this.waiting_drug[i].id) {
  593. this.$refs.table01.setCurrentRow(this.waiting_drug[i]);
  594. this.handleCurrentChange(this.waiting_drug[i]);
  595. }
  596. }
  597. });
  598. },
  599. // 单位去重
  600. unique_unit(arr) {
  601. return arr.filter(function (item, index, arr) {
  602. //当前元素,在原始数组中的第一个索引==当前索引值,否则返回当前元素
  603. return arr.indexOf(item, 0) === index;
  604. });
  605. },
  606. // 获取单位
  607. getDose_unit(val) {
  608. // console.log(val);
  609. var newLength = 0;
  610. var singleChar = "";
  611. var newStr = "";
  612. var chineseRegex = /[^\x00-\xff]/g;
  613. let strLength = val.replace(chineseRegex, "**").length;
  614. // console.log(strLength, "strLength");
  615. for (var i = 0; i < strLength; i++) {
  616. singleChar = val.charAt(i).toString();
  617. // console.log(singleChar,'singleChar')
  618. // console.log(singleChar.match(chineseRegex),'')
  619. if (singleChar.match(chineseRegex) != null) {
  620. newLength += 2;
  621. newStr += singleChar;
  622. } else {
  623. newLength++;
  624. }
  625. if (newLength > strLength) {
  626. break;
  627. }
  628. // newStr += singleChar;
  629. }
  630. // if (hasDot && strLength > len) {
  631. // newStr += "...";
  632. // }
  633. // console.log(newStr,'newStr')
  634. return newStr;
  635. },
  636. getSummaries_t1(param) {
  637. const { columns, data } = param;
  638. const sums = [];
  639. let dose_unit = [];
  640. let unit_1 = [];
  641. let unit_2 = [];
  642. columns.forEach((column, index) => {
  643. if (index === 0) {
  644. sums[index] = "合计";
  645. return;
  646. }
  647. if (index === 7) {
  648. // 单位裁切
  649. data.forEach((el, index) => {
  650. dose_unit.push(this.getDose_unit(el.total));
  651. });
  652. dose_unit = this.unique_unit(dose_unit);
  653. console.log(dose_unit,'dose_unit')
  654. // // 数据合计
  655. data.forEach((el, index) => {
  656. if (this.getDose_unit(el.total) === dose_unit[0]) {
  657. unit_1.push(parseInt(el.total));
  658. }
  659. if (this.getDose_unit(el.total) === dose_unit[1]) {
  660. unit_2.push(parseInt(el.total));
  661. }
  662. });
  663. unit_1 = eval(unit_1.join("+"));
  664. unit_2 = eval(unit_2.join("+"));
  665. if (dose_unit[0] == undefined) {
  666. sums[index] = "";
  667. } else if (dose_unit[1] == undefined || unit_2 == undefined) {
  668. sums[index] = `${unit_1}${dose_unit[0]}`;
  669. } else {
  670. sums[index] = `${unit_1}${dose_unit[0]}+${unit_2}${dose_unit[1]}`;
  671. }
  672. return;
  673. }
  674. });
  675. return sums;
  676. },
  677. getSummaries_t2(param) {
  678. const { columns, data } = param;
  679. const sums = [];
  680. let dose_unit = [];
  681. let unit_1 = [];
  682. let unit_2 = [];
  683. columns.forEach((column, index) => {
  684. if (index === 0) {
  685. sums[index] = "合计";
  686. return;
  687. }
  688. if (index === 6) {
  689. // 单位裁切
  690. data.forEach((el, index) => {
  691. dose_unit.push(this.getDose_unit(el.total));
  692. });
  693. dose_unit = this.unique_unit(dose_unit);
  694. // 数据合计
  695. data.forEach((el, index) => {
  696. if (this.getDose_unit(el.total) === dose_unit[0]) {
  697. unit_1.push(parseInt(el.total));
  698. }
  699. if (this.getDose_unit(el.total) === dose_unit[1]) {
  700. unit_1.push(parseInt(el.total));
  701. }
  702. });
  703. unit_1 = eval(unit_1.join("+"));
  704. unit_2 = eval(unit_2.join("+"));
  705. // sums[index] = unit_1+dose_unit[0]+ "+" +unit_2+dose_unit[1];
  706. if (dose_unit[0] == undefined) {
  707. sums[index] = "";
  708. } else if (dose_unit[1] == undefined || unit_2 == undefined) {
  709. sums[index] = `${unit_1}${dose_unit[0]}`;
  710. } else {
  711. sums[index] = `${unit_1}${dose_unit[0]}+${unit_2}${dose_unit[1]}`;
  712. }
  713. return;
  714. }
  715. });
  716. return sums;
  717. },
  718. changeTimes() {
  719. // alert("aa")
  720. // this.getdruglist();
  721. this.fun3();
  722. },
  723. //初始化
  724. init() {
  725. this.state = 1;
  726. this.tableData = null;
  727. this.currentRow = null;
  728. },
  729. lala() {
  730. this.currentRow = null;
  731. this.tableData = null;
  732. this.selectedbydefault();
  733. },
  734. searchAction() {
  735. // this.getlist();
  736. this.tableData = null;
  737. this.currentRow = null;
  738. this.getdruglist();
  739. },
  740. // 跳转打印页面
  741. toPrint() {
  742. if (this.state == 1 && this.multipleSelection.length == 0) {
  743. this.$message.error("未选择任何数据");
  744. return;
  745. }
  746. if (this.state == 2 && this.tableData == null) {
  747. this.$message.error("未选择任何数据");
  748. return;
  749. }
  750. this.$refs.drugprint.show(
  751. this.tableData,
  752. this.currentRow,
  753. this.state,
  754. this.multipleSelection,
  755. this.start_time
  756. );
  757. },
  758. toExport() {
  759. if (this.state == 1 && this.multipleSelection.length == 0) {
  760. this.$message.error("未选择任何数据");
  761. return;
  762. }
  763. if (this.state == 2 && this.tableData == null) {
  764. this.$message.error("未选择任何数据");
  765. return;
  766. }
  767. // for (let i = 0; i < this.tableData.length; i++) {
  768. // this.tableData[i].index = i + 1;
  769. // this.tableData[i].name = this.tableData[i].dose + this.tableData[i].dose_unit + "*" + this.tableData[i].min_number + this.tableData[i].min_unit +
  770. // "/" +
  771. // this.tableData[i].max_unit;
  772. //
  773. // this.tableData[i].total_price = (
  774. // this.tableData[i].warehousing_count * this.exportList[i].price
  775. // ).toFixed(2);
  776. // for (let j = 0; j < this.manufacturerList.length; j++) {
  777. // if (this.exportList[i].manufacturer == this.manufacturerList[j].id) {
  778. // this.exportList[i].manufacturer =
  779. // this.manufacturerList[j].manufacturer_name;
  780. // }
  781. // if (this.exportList[i].manufacturer == 0) {
  782. // this.exportList[i].manufacturer = "";
  783. // }
  784. // }
  785. //
  786. // for (let z = 0; z < this.dealerList.length; z++) {
  787. // if (this.exportList[i].dealer == this.dealerList[z].id) {
  788. // this.exportList[i].dealer = this.dealerList[z].dealer_name;
  789. // }
  790. // if (this.exportList[i].dealer == 0) {
  791. // this.exportList[i].dealer = "";
  792. // }
  793. // }
  794. // }
  795. if (this.state == 1) {
  796. import("@/vendor/Export2Excel").then((excel) => {
  797. for (let i = 0; i < this.multipleSelection.length; i++) {
  798. this.multipleSelection[i].index = i + 1;
  799. this.multipleSelection[i].time = this.start_time;
  800. this.multipleSelection[i].yname = this.currentRow.name;
  801. }
  802. const tHeader = [
  803. "序号",
  804. "时间",
  805. "患者名称",
  806. "药品名称",
  807. "单次用量",
  808. "用法",
  809. "频率",
  810. "天数",
  811. "总量",
  812. "数据来源",
  813. ];
  814. const filterVal = [
  815. "index",
  816. "time",
  817. "name",
  818. "yname",
  819. "single_dosage",
  820. "usage",
  821. "frequency",
  822. "days",
  823. "total",
  824. "data_sources",
  825. ];
  826. const data = this.formatJson(filterVal, this.multipleSelection);
  827. excel.export_json_to_excel({
  828. header: tHeader,
  829. data,
  830. filename: "发药单详情",
  831. });
  832. this.downloadLoading = false;
  833. });
  834. } else if (this.state == 2) {
  835. import("@/vendor/Export2Excel").then((excel) => {
  836. for (let i = 0; i < this.tableData.length; i++) {
  837. this.tableData[i].index = i + 1;
  838. this.tableData[i].time = this.start_time;
  839. this.tableData[i].yname = this.currentRow.name;
  840. }
  841. const tHeader = [
  842. "序号",
  843. "日期",
  844. "患者名称",
  845. "药品名称",
  846. "单次用量",
  847. "用法",
  848. "频率",
  849. "天数",
  850. "总量",
  851. "数据来源",
  852. "领药人",
  853. ];
  854. const filterVal = [
  855. "index",
  856. "time",
  857. "name",
  858. "yname",
  859. "single_dosage",
  860. "usage",
  861. "frequency",
  862. "days",
  863. "total",
  864. "data_sources",
  865. "people",
  866. ];
  867. const data = this.formatJson(filterVal, this.tableData);
  868. excel.export_json_to_excel({
  869. header: tHeader,
  870. data,
  871. filename: "发药单详情",
  872. });
  873. this.downloadLoading = false;
  874. });
  875. } else {
  876. this.$message.error("药品状态异常");
  877. return;
  878. }
  879. // import("@/vendor/Export2Excel").then((excel) => {
  880. // // for (let i = 0; i < this.tableData.length; i++) {
  881. // // for (let j = 0; j < this.drugTypeList.length; j++) {
  882. // // if (this.exportList[i].drug_type == this.drugTypeList[j].id) {
  883. // // this.exportList[i].drug_type = this.drugTypeList[j].name;
  884. // // }
  885. // // }
  886. // // }
  887. //
  888. // const tHeader = [
  889. // "序号",
  890. // "患者名称",
  891. // "单次用量",
  892. // "用法",
  893. // "频率",
  894. // "天数",
  895. // "总量",
  896. // "数据来源",
  897. // ];
  898. // const filterVal = [
  899. // "index",
  900. // "drug_name",
  901. // "drug_type",
  902. // "unit",
  903. // "batch_number",
  904. // "warehousing_count",
  905. // "price",
  906. // "total_price",
  907. // ];
  908. //
  909. // const data = this.tableData;
  910. // excel.export_json_to_excel({
  911. // header: tHeader,
  912. // data,
  913. // filename: "药品入库单详情",
  914. // });
  915. // this.downloadLoading = false;
  916. // });
  917. },
  918. formatJson(filterVal, jsonData) {
  919. return jsonData.map((v) => filterVal.map((j) => v[j]));
  920. },
  921. //列表选择与合计
  922. handleSelectionChange(val) {
  923. this.multipleSelection = val;
  924. let coculate = val;
  925. let sums = "";
  926. let dose_unit = [];
  927. let unit_1 = [];
  928. let unit_2 = [];
  929. coculate.forEach((el, index) => {
  930. // dose_unit.push(el.total.substr(el.total.length - 1, 1));
  931. dose_unit.push(this.getDose_unit(el.total))
  932. });
  933. dose_unit = this.unique_unit(dose_unit);
  934. // 数据合计
  935. coculate.forEach((el, index) => {
  936. if (this.getDose_unit(el.total) === dose_unit[0]) {
  937. unit_1.push(parseInt(el.total));
  938. }
  939. });
  940. coculate.forEach((el, index) => {
  941. if (this.getDose_unit(el.total) === dose_unit[1]) {
  942. unit_2.push(parseInt(el.total));
  943. }
  944. });
  945. unit_1 = eval(unit_1.join("+"));
  946. unit_2 = eval(unit_2.join("+"));
  947. if (dose_unit[0] == undefined) {
  948. sums = "";
  949. } else if (dose_unit[1] == undefined) {
  950. sums = `${unit_1}${dose_unit[0]}`;
  951. } else {
  952. sums = `${unit_1}${dose_unit[0]}+${unit_2}${dose_unit[1]}`;
  953. }
  954. // sums = `${unit_1}${dose_unit[0]}+${unit_2}${dose_unit[1]}`;
  955. this.select_total = sums;
  956. },
  957. //默认选中
  958. selectedbydefault() {
  959. if (this.state == 1 && this.waiting_drug.length > 0) {
  960. this.$refs.table01.setCurrentRow(this.waiting_drug[0]);
  961. this.handleCurrentChange(this.waiting_drug[0]);
  962. }
  963. if (this.state == 2 && this.issued_drug.length > 0) {
  964. this.$refs.table02.setCurrentRow(this.issued_drug[0]);
  965. this.handleCurrentChange(this.issued_drug[0]);
  966. }
  967. },
  968. //包装selectedbydefault
  969. fun2() {
  970. // return new Promise((resolve, reject) => {
  971. if (this.state == 1 && this.waiting_drug.length > 0) {
  972. this.$refs.table01.setCurrentRow(this.waiting_drug[0]);
  973. this.handleCurrentChange(this.waiting_drug[0]);
  974. }
  975. if (this.state == 2 && this.issued_drug.length > 0) {
  976. this.$refs.table02.setCurrentRow(this.issued_drug[0]);
  977. this.handleCurrentChange(this.issued_drug[0]);
  978. }
  979. // });
  980. },
  981. // 药品发药
  982. dispense() {
  983. var tps = this.currentRow.id;
  984. if (this.multipleSelection.length < 1) {
  985. this.$message.error("未选择任何信息");
  986. return;
  987. }
  988. var tmp = "";
  989. for (var i = 0; i < this.multipleSelection.length; i++) {
  990. tmp = tmp + this.multipleSelection[i].id + ",";
  991. }
  992. var params = {
  993. creater: this.admin_user_id,
  994. ids: tmp,
  995. };
  996. this.$confirm("确定是否对该药品进行发药?", "患者发药", {
  997. confirmButtonText: "确 定",
  998. cancelButtonText: "取 消",
  999. type: "warning",
  1000. }).then(() => {
  1001. medicinedeparture(params).then((res) => {
  1002. if (res.data.state == 1) {
  1003. this.$message.success("操作成功");
  1004. this.getdruglist();
  1005. //刷新列表
  1006. this.handleCurrentChange(this.currentRow);
  1007. this.fun4(tps);
  1008. this.state = 2;
  1009. this.multipleSelection = [];
  1010. } else {
  1011. this.$message.error("操作失败:" + res.data.msg);
  1012. //刷新列表
  1013. this.handleCurrentChange(this.currentRow);
  1014. this.fun5(tps);
  1015. this.state = 1;
  1016. }
  1017. });
  1018. });
  1019. },
  1020. //获取药品列表
  1021. getdruglist02() {
  1022. // var tps = this.currentRow.id;
  1023. this.tableData = [];
  1024. var params = {
  1025. keyword: this.keywords,
  1026. time: this.start_time,
  1027. deliveryway: this.deliveryway,
  1028. };
  1029. waitingmedicine(params).then((res) => {
  1030. if (res.data.state == 1) {
  1031. this.waiting_drug = res.data.data.list;
  1032. }
  1033. });
  1034. dispensemedicine(params).then((res) => {
  1035. if (res.data.state == 1) {
  1036. this.issued_drug = res.data.data.list;
  1037. }
  1038. });
  1039. if (this.state == 2) {
  1040. this.handleCurrentChange(this.currentRow);
  1041. // this.fun5(tps);
  1042. } else {
  1043. this.handleCurrentChange(this.currentRow);
  1044. // this.fun4(tps);
  1045. }
  1046. },
  1047. //获取药品列表
  1048. getdruglist() {
  1049. var params = {
  1050. keyword: this.keywords,
  1051. time: this.start_time,
  1052. deliveryway: this.deliveryway,
  1053. };
  1054. waitingmedicine(params).then((res) => {
  1055. if (res.data.state == 1) {
  1056. this.waiting_drug = res.data.data.list;
  1057. }
  1058. });
  1059. dispensemedicine(params).then((res) => {
  1060. if (res.data.state == 1) {
  1061. this.issued_drug = res.data.data.list;
  1062. }
  1063. });
  1064. },
  1065. async fun1() {
  1066. var params = {
  1067. keyword: this.keywords,
  1068. time: this.start_time,
  1069. deliveryway: this.deliveryway,
  1070. };
  1071. await waitingmedicine(params).then((res) => {
  1072. if (res.data.state == 1) {
  1073. this.waiting_drug = res.data.data.list;
  1074. }
  1075. });
  1076. await dispensemedicine(params).then((res) => {
  1077. if (res.data.state == 1) {
  1078. this.issued_drug = res.data.data.list;
  1079. }
  1080. });
  1081. console.log("fun1");
  1082. },
  1083. morencreatename() {
  1084. var param = {};
  1085. getcurrentname(param).then((res) => {
  1086. if (res.data.state == 1) {
  1087. this.admin_user_id = res.data.data.list;
  1088. console.log("this.admin_user_id(药)", this.admin_user_id);
  1089. }
  1090. });
  1091. },
  1092. //获取领药人选项
  1093. getlist() {
  1094. var params = {
  1095. start_time: this.start_time,
  1096. keywords: this.keywords,
  1097. };
  1098. getTodayAdviceList(params).then((response) => {
  1099. if (response.data.state == 1) {
  1100. this.doctorList = response.data.data.doctorlist;
  1101. // this.admin_user_id = this.doctorList[0].admin_user_id
  1102. // this.admin_user_id = this.tmp
  1103. }
  1104. });
  1105. },
  1106. // //获取药品的患者信息
  1107. informationofdrugs(val) {
  1108. var params = {
  1109. // patient_id: this.currentRow.
  1110. };
  1111. },
  1112. handleCurrentChange(val) {
  1113. this.currentRow = val;
  1114. this.total = "";
  1115. if (this.state == 1) {
  1116. this.getdrugsdetails(0);
  1117. }
  1118. if (this.state == 2) {
  1119. this.getdrugsdetails(1);
  1120. }
  1121. },
  1122. getdrugsdetails(val) {
  1123. if (this.state == 1) {
  1124. val = 0;
  1125. } else {
  1126. val = 1;
  1127. }
  1128. var params = {
  1129. drug_id: this.currentRow.id,
  1130. is_medicine: val,
  1131. time: this.start_time,
  1132. shift: this.shift,
  1133. partition: this.partition,
  1134. deliveryway: this.deliveryway,
  1135. };
  1136. getpatientswithdrugs(params).then((res) => {
  1137. if (res.data.state == 1) {
  1138. var list = res.data.data.list; //列表数据
  1139. if(this.$store.getters.xt_user.org.id == 10188 || this.$store.getters.xt_user.org.id == 10217 ){
  1140. this.tableData = []
  1141. if(list!=null && list.length >0){
  1142. for(let i=0;i<list.length;i++){
  1143. if(list[i].data_sources != "临时医嘱"){
  1144. this.tableData.push(list[i])
  1145. }
  1146. }
  1147. }
  1148. }
  1149. if(this.$store.getters.xt_user.org.id != 10188 && this.$store.getters.xt_user.org.id != 10217){
  1150. this.tableData = []
  1151. this.tableData = list
  1152. }
  1153. this.total = res.data.data.total; //合计
  1154. } else {
  1155. this.$message.error(res.data.msg);
  1156. }
  1157. });
  1158. },
  1159. toSetting() {
  1160. getPharmacyConfig().then((response) => {
  1161. if (response.data.state == 1) {
  1162. this.dialogVisible = true;
  1163. var config = response.data.data.config;
  1164. this.is_open = config.is_open.toString();
  1165. }
  1166. });
  1167. },
  1168. SaveSetting() {
  1169. var params = {
  1170. is_open: parseInt(this.is_open),
  1171. };
  1172. SaveSetting(params).then((response) => {
  1173. if (response.data.state == 1) {
  1174. var config = response.data.data.config;
  1175. this.$message.success("保存成功!");
  1176. this.dialogVisible = false;
  1177. }
  1178. });
  1179. },
  1180. getrouteofadministration() {
  1181. var params = {};
  1182. routeofadministration(params).then((res) => {
  1183. if (res.data.state == 1) {
  1184. this.routeofadministration = res.data.data.list;
  1185. }
  1186. });
  1187. },
  1188. getgetpartitionlist() {
  1189. var params = {};
  1190. getpartitionlist(params).then((res) => {
  1191. this.fen = res.data.data.list;
  1192. });
  1193. },
  1194. getUserlist(drug_id) {
  1195. var params = {
  1196. start_time: this.start_time,
  1197. drug_id: drug_id,
  1198. };
  1199. getUserdDrugList(params).then((response) => {
  1200. if (response.data.state == 1) {
  1201. var advicelist = response.data.data.advicelist;
  1202. for (let i = 0; i < advicelist.length; i++) {
  1203. advicelist[i].type = 1;
  1204. advicelist[i].day = " ";
  1205. this.tableList.push(advicelist[i]);
  1206. }
  1207. var hisAdviceList = response.data.data.hisAdviceList;
  1208. for (let i = 0; i < hisAdviceList.length; i++) {
  1209. hisAdviceList[i].type = 2;
  1210. this.tableList.push(hisAdviceList[i]);
  1211. }
  1212. var patient = response.data.data.patient;
  1213. this.patientList = patient;
  1214. }
  1215. });
  1216. },
  1217. },
  1218. created() {
  1219. this.init();
  1220. this.morencreatename();
  1221. this.getlist();
  1222. // this.getdruglist();
  1223. this.fun3();
  1224. this.getrouteofadministration();
  1225. this.getgetpartitionlist();
  1226. },
  1227. updated() {
  1228. this.$nextTick(() => {
  1229. if (this.$refs["table_01"]) {
  1230. this.$refs["table_01"].doLayout();
  1231. } else if (this.$refs["table_02"]) {
  1232. this.$refs["table_02"].doLayout();
  1233. }
  1234. });
  1235. },
  1236. };
  1237. </script>
  1238. <style rel="stylesheet/css" lang="scss" scoped>
  1239. .new-main-contain {
  1240. height: 100%;
  1241. display: flex;
  1242. flex-direction: column;
  1243. }
  1244. .app-container {
  1245. height: 100%;
  1246. }
  1247. .mainLeft {
  1248. width: 300px;
  1249. height: 100%;
  1250. display: flex;
  1251. flex-direction: column;
  1252. .el-radio {
  1253. margin-right: 75px;
  1254. }
  1255. .list {
  1256. margin: 10px 0;
  1257. }
  1258. }
  1259. .mainRight {
  1260. margin-left: 10px;
  1261. flex: 1;
  1262. height: 100%;
  1263. display: flex;
  1264. flex-direction: column;
  1265. overflow-y: hidden;
  1266. .titlelist {
  1267. display: flex;
  1268. justify-content: space-between;
  1269. white-space: nowrap;
  1270. color: #909399;
  1271. font-size: 14px;
  1272. /deep/ .el-input__inner {
  1273. font-size: 13px !important;
  1274. }
  1275. }
  1276. .el-button {
  1277. height: 34px;
  1278. width: 65px;
  1279. }
  1280. .el-table {
  1281. margin-top: -13px;
  1282. }
  1283. /deep/ .el-divider {
  1284. height: 2px;
  1285. margin-top: 10px;
  1286. }
  1287. }
  1288. /deep/ .el-table--scrollable-x .el-table__body-wrapper {
  1289. overflow-y: auto;
  1290. overflow-x: hidden;
  1291. }
  1292. /deep/ .right_table {
  1293. .el-table__body-wrapper {
  1294. overflow-y: auto;
  1295. overflow-x: scroll !important;
  1296. }
  1297. // /deep/ .el-table__footer-wrapper {
  1298. // margin-top: -2px !important;
  1299. // }
  1300. }
  1301. /deep/ .gutter {
  1302. width: 15px !important;
  1303. display: inline-block !important;
  1304. }
  1305. /deep/ .el-table__fixed-right-patch {
  1306. width: 15px !important;
  1307. }
  1308. /deep/ .el-table__fixed-right {
  1309. bottom: 0 !important;
  1310. left: auto;
  1311. right: 0;
  1312. }
  1313. /deep/ .el-table__body-wrapper::-webkit-scrollbar {
  1314. width: 15px !important;
  1315. height: 15px !important;
  1316. }
  1317. </style>