DrugDispensing.vue 36KB

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