DrugDispensing.vue 40KB

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