query.vue 41KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495969798991001011021031041051061071081091101111121131141151161171181191201211221231241251261271281291301311321331341351361371381391401411421431441451461471481491501511521531541551561571581591601611621631641651661671681691701711721731741751761771781791801811821831841851861871881891901911921931941951961971981992002012022032042052062072082092102112122132142152162172182192202212222232242252262272282292302312322332342352362372382392402412422432442452462472482492502512522532542552562572582592602612622632642652662672682692702712722732742752762772782792802812822832842852862872882892902912922932942952962972982993003013023033043053063073083093103113123133143153163173183193203213223233243253263273283293303313323333343353363373383393403413423433443453463473483493503513523533543553563573583593603613623633643653663673683693703713723733743753763773783793803813823833843853863873883893903913923933943953963973983994004014024034044054064074084094104114124134144154164174184194204214224234244254264274284294304314324334344354364374384394404414424434444454464474484494504514524534544554564574584594604614624634644654664674684694704714724734744754764774784794804814824834844854864874884894904914924934944954964974984995005015025035045055065075085095105115125135145155165175185195205215225235245255265275285295305315325335345355365375385395405415425435445455465475485495505515525535545555565575585595605615625635645655665675685695705715725735745755765775785795805815825835845855865875885895905915925935945955965975985996006016026036046056066076086096106116126136146156166176186196206216226236246256266276286296306316326336346356366376386396406416426436446456466476486496506516526536546556566576586596606616626636646656666676686696706716726736746756766776786796806816826836846856866876886896906916926936946956966976986997007017027037047057067077087097107117127137147157167177187197207217227237247257267277287297307317327337347357367377387397407417427437447457467477487497507517527537547557567577587597607617627637647657667677687697707717727737747757767777787797807817827837847857867877887897907917927937947957967977987998008018028038048058068078088098108118128138148158168178188198208218228238248258268278288298308318328338348358368378388398408418428438448458468478488498508518528538548558568578588598608618628638648658668678688698708718728738748758768778788798808818828838848858868878888898908918928938948958968978988999009019029039049059069079089099109119129139149159169179189199209219229239249259269279289299309319329339349359369379389399409419429439449459469479489499509519529539549559569579589599609619629639649659669679689699709719729739749759769779789799809819829839849859869879889899909919929939949959969979989991000100110021003100410051006100710081009101010111012101310141015101610171018101910201021102210231024102510261027102810291030103110321033103410351036103710381039104010411042104310441045104610471048104910501051105210531054105510561057105810591060106110621063106410651066106710681069107010711072107310741075107610771078107910801081108210831084108510861087108810891090109110921093109410951096109710981099110011011102110311041105110611071108110911101111111211131114111511161117111811191120112111221123112411251126112711281129113011311132113311341135113611371138113911401141114211431144114511461147114811491150115111521153115411551156115711581159116011611162116311641165116611671168116911701171117211731174117511761177117811791180118111821183118411851186118711881189119011911192119311941195119611971198119912001201120212031204120512061207120812091210121112121213121412151216121712181219122012211222122312241225122612271228122912301231123212331234123512361237123812391240124112421243124412451246124712481249125012511252125312541255125612571258125912601261126212631264126512661267126812691270127112721273127412751276127712781279128012811282128312841285128612871288128912901291129212931294129512961297129812991300130113021303130413051306130713081309131013111312131313141315131613171318131913201321132213231324132513261327132813291330133113321333133413351336133713381339134013411342134313441345134613471348134913501351135213531354135513561357135813591360136113621363136413651366136713681369137013711372137313741375137613771378137913801381138213831384138513861387138813891390139113921393139413951396139713981399140014011402140314041405140614071408140914101411141214131414141514161417141814191420142114221423
  1. <template>
  2. <div class="main-contain">
  3. <div class="position">
  4. <bread-crumb :crumbs="crumbs"></bread-crumb>
  5. <div>
  6. <el-button
  7. size="small"
  8. class="filter-item"
  9. type="primary"
  10. @click="setting"
  11. >设置
  12. </el-button>
  13. <el-button
  14. size="small"
  15. class="filter-item"
  16. type="primary"
  17. icon="el-icon-printer"
  18. @click="printOrder"
  19. >打印
  20. </el-button>
  21. <el-button
  22. size="small"
  23. class="filter-item"
  24. type="primary"
  25. @click="exportStock"
  26. >导出
  27. </el-button>
  28. </div>
  29. </div>
  30. <div class="app-container">
  31. <div class="cell clearfix">
  32. <div>
  33. <span>仓库名称:</span>
  34. <el-select
  35. v-model="storehouse_id"
  36. style="width: 200px; margin-right: 10px"
  37. placeholder="请选择"
  38. filterable
  39. @change="changeStorehouseName"
  40. >
  41. <el-option
  42. v-for="item in storeList"
  43. :key="item.id"
  44. :label="item.storehouse_name"
  45. :value="item.id"
  46. >
  47. </el-option>
  48. </el-select>
  49. <span>药品名称:</span>
  50. <el-select
  51. v-model="drug_id"
  52. style="width: 200px; margin-right: 10px"
  53. placeholder="请选择"
  54. filterable
  55. @change="changeDrugName"
  56. >
  57. <el-option
  58. v-for="item in medicalList"
  59. :key="item.id"
  60. :label="item.drug_name"
  61. :value="item.id"
  62. >
  63. </el-option>
  64. </el-select>
  65. </div>
  66. <!-- <el-select v-model="drug_type" style="width:160px;margin-right:10px;" placeholder="请选择" @change="changeDrug">
  67. <el-option
  68. v-for="(item,index) in drugTypeList"
  69. :key="index"
  70. :label="item.name"
  71. :value="item.id">
  72. </el-option>
  73. </el-select> -->
  74. <!-- <el-date-picker
  75. v-model="start_time"
  76. prefix-icon="el-icon-date"
  77. :editable="false"
  78. style="width: 196px;"
  79. type="date"
  80. placeholder="选择日期时间"
  81. align="right"
  82. format="yyyy-MM-dd"
  83. value-format="yyyy-MM-dd"
  84. @change="startTimeChange"
  85. ></el-date-picker>-
  86. <el-date-picker
  87. v-model="end_time"
  88. prefix-icon="el-icon-date"
  89. :editable="false"
  90. style="width: 196px;margin-right:10px;"
  91. type="date"
  92. placeholder="选择日期时间"
  93. align="right"
  94. format="yyyy-MM-dd"
  95. value-format="yyyy-MM-dd"
  96. @change="endTimeChange"
  97. ></el-date-picker> -->
  98. <!-- <el-input
  99. style="width: 200px;"
  100. class="filter-item"
  101. v-model.trim="keywords"
  102. placeholder="药品名称"
  103. />
  104. <el-button
  105. size="small"
  106. class="filter-item"
  107. type="primary"
  108. icon="el-icon-search"
  109. @click="search"
  110. >搜索
  111. </el-button> -->
  112. </div>
  113. <!-- <el-button @click="lili()">调试</el-button>-->
  114. <el-table
  115. :data="tableList"
  116. border
  117. style="width: 100%"
  118. :cell-class-name="cellStyle"
  119. >
  120. <el-table-column
  121. prop="drug_type"
  122. label="药品类型"
  123. width="100"
  124. align="center"
  125. >
  126. <template slot-scope="scope">
  127. {{ getDrugType(scope.row.drug_type) }}
  128. </template>
  129. </el-table-column>
  130. <el-table-column prop="drug_name" label="药品名称" align="center">
  131. <template slot-scope="scope">
  132. {{ scope.row.drug_name }}
  133. </template>
  134. </el-table-column>
  135. <el-table-column prop="drug_name" label="规格&&单位" align="center">
  136. <template slot-scope="scope">
  137. {{
  138. scope.row.dose +
  139. scope.row.dose_unit +
  140. "*" +
  141. scope.row.min_number +
  142. scope.row.min_unit +
  143. "/" +
  144. scope.row.max_unit
  145. }}
  146. </template>
  147. </el-table-column>
  148. <el-table-column prop="drug_name" label="国家编码" align="center">
  149. <template slot-scope="scope">
  150. {{ scope.row.medical_insurance_number }}
  151. </template>
  152. </el-table-column>
  153. <el-table-column prop="drug_name" label="进货单价" align="center">
  154. <template slot-scope="scope">
  155. {{ scope.row.last_price }}
  156. </template>
  157. </el-table-column>
  158. <el-table-column prop="drug_name" label="厂家" align="center">
  159. <template slot-scope="scope">
  160. {{ getManufacturerList(scope.row.manufacturer) }}
  161. </template>
  162. </el-table-column>
  163. <el-table-column prop="drug_name" label="仓库名称" align="center">
  164. <template slot-scope="scope">
  165. <tr
  166. style="background: none"
  167. v-for="(item, index) in scope.row.drug_warehouse"
  168. :key="index"
  169. >
  170. <td
  171. style="
  172. border-right: none;
  173. border-inline-end: none;
  174. text-align: center;
  175. "
  176. >
  177. {{ getHouseName(item.storehouse_id) }}
  178. </td>
  179. </tr>
  180. </template>
  181. </el-table-column>
  182. <el-table-column prop="drug_name" label="入库数量" align="center">
  183. <template slot-scope="scope">
  184. <tr
  185. style="background: none"
  186. v-for="(item, index) in scope.row.drug_warehouse"
  187. :key="index"
  188. >
  189. <td
  190. style="
  191. border-right: none;
  192. border-inline-end: none;
  193. text-align: center;
  194. "
  195. >
  196. {{
  197. getWarehoseInfoSeven(
  198. scope.row.drug_warehouse_info,
  199. scope.row.max_unit,
  200. scope.row.min_unit,
  201. scope.row.min_number,
  202. item.storehouse_id
  203. )
  204. }}&nbsp;
  205. </td>
  206. </tr>
  207. </template>
  208. </el-table-column>
  209. <el-table-column prop="drug_name" label="出库数量" align="center">
  210. <template slot-scope="scope">
  211. <tr
  212. style="background: none"
  213. v-for="(item, index) in scope.row.drug_warehouse"
  214. :key="index"
  215. >
  216. <td
  217. style="
  218. border-right: none;
  219. border-inline-end: none;
  220. text-align: center;
  221. "
  222. >
  223. <span>
  224. {{
  225. getOutFlushNight(
  226. scope.row.drug_warehouse_info,
  227. scope.row.max_unit,
  228. scope.row.min_unit,
  229. scope.row.min_number,
  230. scope.row.drug_cancel_stock_info,
  231. item.storehouse_id
  232. )
  233. }}&nbsp;
  234. </span>
  235. </td>
  236. </tr>
  237. </template>
  238. </el-table-column>
  239. <el-table-column prop="drug_name" label="剩余库存量" align="center">
  240. <template slot-scope="scope">
  241. <tr
  242. style="background: none"
  243. v-for="(item, index) in scope.row.drug_warehouse"
  244. :key="index"
  245. >
  246. <td
  247. style="
  248. border-right: none;
  249. border-inline-end: none;
  250. text-align: center;
  251. "
  252. >
  253. {{
  254. getOverFlushInfoEight(
  255. scope.row.drug_warehouse_info,
  256. scope.row.max_unit,
  257. scope.row.min_unit,
  258. scope.row.min_number,
  259. item.storehouse_id,
  260. scope.row.storehouse_id
  261. )
  262. }}&nbsp;
  263. </td>
  264. </tr>
  265. </template>
  266. </el-table-column>
  267. <el-table-column
  268. prop="drug_name"
  269. label="总库存量"
  270. align="center"
  271. v-if="showThree"
  272. >
  273. <template slot-scope="scope">
  274. <div v-if="getWarehoseInfo(scope.row.drug_warehouse_info) > 0">
  275. {{
  276. getOverFlushInfo(
  277. scope.row.drug_warehouse_info,
  278. scope.row.max_unit,
  279. scope.row.min_unit,
  280. scope.row.min_number
  281. )
  282. ? getOverFlushInfo(
  283. scope.row.drug_warehouse_info,
  284. scope.row.max_unit,
  285. scope.row.min_unit,
  286. scope.row.min_number
  287. )
  288. : 0
  289. }}
  290. </div>
  291. </template>
  292. </el-table-column>
  293. <el-table-column
  294. prop="drug_name"
  295. label="操作"
  296. align="center"
  297. width="200px"
  298. >
  299. <template slot-scope="scope">
  300. <el-button
  301. size="small"
  302. type="primary"
  303. @click="handleDetail(scope.row)"
  304. >库存流水
  305. </el-button>
  306. <el-button
  307. size="small"
  308. type="primary"
  309. @click="handleBatch(scope.row)"
  310. >批次
  311. </el-button>
  312. </template>
  313. </el-table-column>
  314. </el-table>
  315. <el-pagination
  316. @size-change="handleSizeChange"
  317. @current-change="handleCurrentChange"
  318. :page-sizes="[10, 50, 100, 200, 500, 1000]"
  319. :page-size="10"
  320. background
  321. align="right"
  322. style="margin-top: 20px"
  323. layout="total, sizes, prev, pager, next, jumper"
  324. :total="total"
  325. >
  326. </el-pagination>
  327. </div>
  328. <setting-dialog ref="dialog"></setting-dialog>
  329. </div>
  330. </template>
  331. <script>
  332. import { uParseTime } from "@/utils/tools";
  333. import BreadCrumb from "@/xt_pages/components/bread-crumb";
  334. import { getDrugStockList, getDrugCountList } from "@/api/drug/drug_stock";
  335. import SettingDialog from "./settingDialog/index";
  336. import { getDictionaryDataConfig } from "@/utils/data";
  337. import { min } from "moment";
  338. export default {
  339. name: "stockIn",
  340. created() {
  341. if (this.$route.path == "/Pharmacy/MedicianManagement") {
  342. this.crumbs = [
  343. { path: false, name: "药品管理" },
  344. { path: "/stock/drugs/stock/query", name: "药品库存查询" },
  345. ];
  346. }
  347. var start_time = window.sessionStorage.getItem("start_time");
  348. var end_time = window.sessionStorage.getItem("end_time");
  349. if (start_time != null) {
  350. this.start_time = start_time;
  351. }
  352. if (end_time != null) {
  353. this.end_time = end_time;
  354. }
  355. window.sessionStorage.removeItem("start_time");
  356. window.sessionStorage.removeItem("end_time");
  357. this.getlist();
  358. var drugCategory = getDictionaryDataConfig("system", "drug_category");
  359. this.drugCategory.push(...drugCategory);
  360. var drugTypeList = getDictionaryDataConfig("system", "drug_type");
  361. this.drugTypeList.push(...drugTypeList);
  362. this.org_id = this.$store.getters.xt_user.org.id;
  363. },
  364. components: {
  365. SettingDialog,
  366. BreadCrumb,
  367. },
  368. data() {
  369. return {
  370. crumbs: [
  371. { path: false, name: "库存管理" },
  372. { path: "/stock/drugs/stock/query", name: "药品库存查询" },
  373. ],
  374. keywords: "",
  375. multipleSelection: [],
  376. signAndWeighBoxPatients: "sign-and-weigh-box-patients",
  377. start_time: "",
  378. end_time: "",
  379. page: 1,
  380. limit: 10,
  381. total: 0,
  382. goodType: [],
  383. goodInfo: [],
  384. tempArr: [],
  385. sameRowArr: [],
  386. WarehouseInfo: {
  387. loading: false,
  388. warehouseInfoDate: [],
  389. },
  390. tableData: [],
  391. drug_category: 0,
  392. drugCategory: [{ id: 0, name: "全部" }],
  393. drugTypeList: [{ id: 0, name: "全部" }],
  394. tableList: [],
  395. manufacturerList: [],
  396. countList: [],
  397. outCountList: [],
  398. autoCountList: [],
  399. keyword: "",
  400. drug_type: 0,
  401. minCount: [],
  402. drugOutList: [],
  403. cancelCountList: [],
  404. allCountList: [],
  405. org_id: "",
  406. showOne: true,
  407. showTwo: false,
  408. showThree: true,
  409. showFour: false,
  410. houseList: [],
  411. medicalList: [],
  412. storehouse_id: 0,
  413. drug_id: 0,
  414. storeList: [],
  415. };
  416. },
  417. methods: {
  418. lili(){
  419. console.log("调试:this.tanlelist",this.tableList)
  420. },
  421. //获取库存
  422. getlist() {
  423. const params = {
  424. page: this.page,
  425. limit: this.limit,
  426. keyword: this.keywords,
  427. drug_type: this.drug_type,
  428. start_time: this.start_time,
  429. end_time: this.end_time,
  430. drug_id: this.drug_id,
  431. storehouse_id: this.storehouse_id,
  432. };
  433. getDrugStockList(params).then((response) => {
  434. if (response.data.state == 1) {
  435. var list = response.data.data.list;
  436. for (let i = 0; i < list.length; i++) {
  437. for (let j = 0; j < list[i].drug_warehouse_info.length; j++) {
  438. if (list[i].max_unit == list[i].drug_warehouse_info[j].max_unit) {
  439. list[i].drug_warehouse_info[j].stock_max_number =
  440. list[i].min_number *
  441. list[i].drug_warehouse_info[j].stock_max_number;
  442. list[i].drug_warehouse_info[j].warehousing_count =
  443. list[i].min_number *
  444. list[i].drug_warehouse_info[j].warehousing_count;
  445. }
  446. }
  447. for (let y = 0; y < list[i].drug_warehouse_out.length; y++) {
  448. if (
  449. list[i].drug_warehouse_out[y].count_unit == list[i].max_unit
  450. ) {
  451. list[i].drug_warehouse_out[y].count =
  452. list[i].drug_warehouse_out[y].count * list[i].min_number;
  453. }
  454. }
  455. for (let z = 0; z < list[i].drug_cancel_stock_info.length; z++) {
  456. if (
  457. list[i].drug_cancel_stock_info[z].max_unit == list[i].max_unit
  458. ) {
  459. list[i].drug_cancel_stock_info[z].count =
  460. list[i].drug_cancel_stock_info[z].count * list[i].min_number;
  461. }
  462. }
  463. }
  464. var arr = [];
  465. for (let i = 0; i < list.length; i++) {
  466. if (list[i].drug_warehouse_info.length > 0) {
  467. arr.push(list[i]);
  468. }
  469. }
  470. this.tableList = arr;
  471. var total = response.data.data.total;
  472. this.total = total;
  473. this.manufacturerList = response.data.data.manufacturerList;
  474. this.houseList = [];
  475. this.storeList = [];
  476. var obj = {
  477. id: 0,
  478. storehouse_name: "全部",
  479. };
  480. var objOne = {
  481. id: 0,
  482. drug_name: "全部",
  483. };
  484. this.storeList.push(obj);
  485. for (let i = 0; i < response.data.data.houseList.length; i++) {
  486. this.houseList.push(response.data.data.houseList[i]);
  487. this.storeList.push(response.data.data.houseList[i]);
  488. }
  489. this.medicalList = [];
  490. this.medicalList.push(objOne);
  491. for (let i = 0; i < response.data.data.medicalList.length; i++) {
  492. for (
  493. let j = 0;
  494. j < response.data.data.manufacturerList.length;
  495. j++
  496. ) {
  497. if (
  498. response.data.data.medicalList[i].manufacturer ==
  499. response.data.data.manufacturerList[j].id
  500. ) {
  501. response.data.data.medicalList[i].manufacturer =
  502. response.data.data.manufacturerList[j].manufacturer_name;
  503. }
  504. }
  505. response.data.data.medicalList[i].drug_name =
  506. response.data.data.medicalList[i].drug_name +
  507. response.data.data.medicalList[i].dose +
  508. response.data.data.medicalList[i].dose_unit +
  509. "*" +
  510. response.data.data.medicalList[i].min_number +
  511. response.data.data.medicalList[i].min_unit +
  512. "/" +
  513. response.data.data.medicalList[i].max_unit +
  514. " " +
  515. response.data.data.medicalList[i].manufacturer;
  516. this.medicalList.push(response.data.data.medicalList[i]);
  517. }
  518. }
  519. });
  520. },
  521. handleSpanTempArr() {
  522. this.tempArr = [];
  523. for (let i = 0; i < this.WarehouseInfo.warehouseInfoDate.length; i++) {
  524. if (i === 0) {
  525. this.tempArr.push(1);
  526. this.pos = 0;
  527. } else {
  528. // 判断当前元素与上一个元素是否相同
  529. if (
  530. this.WarehouseInfo.warehouseInfoDate[i].drug_name ===
  531. this.WarehouseInfo.warehouseInfoDate[i - 1].drug_name
  532. ) {
  533. this.tempArr[this.pos] += 1;
  534. this.tempArr.push(0);
  535. } else {
  536. this.tempArr.push(1);
  537. this.pos = i;
  538. }
  539. }
  540. }
  541. let sameRowArr = [],
  542. sIdx = 0;
  543. this.WarehouseInfo.warehouseInfoDate.forEach((item, index) => {
  544. item.index = index;
  545. if (index === 0) {
  546. sameRowArr.push([index]);
  547. } else {
  548. if (
  549. item.drug_name ===
  550. this.WarehouseInfo.warehouseInfoDate[index - 1].drug_name
  551. ) {
  552. sameRowArr[sIdx].push(index);
  553. } else {
  554. sIdx = sIdx + 1;
  555. sameRowArr.push([index]);
  556. }
  557. }
  558. });
  559. this.sameRowArr = sameRowArr;
  560. },
  561. merge({ row, column, rowIndex, columnIndex }) {
  562. if (columnIndex === 0) {
  563. const _row = this.tempArr[rowIndex];
  564. const _col = _row > 0 ? 1 : 0;
  565. return {
  566. rowspan: _row,
  567. colspan: _col,
  568. };
  569. }
  570. },
  571. getSpecificationName: function (id) {
  572. let name = "";
  573. for (let i = 0; i < this.goodInfo.length; i++) {
  574. if (this.goodInfo[i].id == id) {
  575. name = this.goodInfo[i].specification_name;
  576. }
  577. }
  578. return name;
  579. },
  580. getTypeName: function (id) {
  581. let name = "";
  582. for (let i = 0; i < this.goodType.length; i++) {
  583. if (this.goodType[i].id == id) {
  584. name = this.goodType[i].type_name;
  585. }
  586. }
  587. return name;
  588. },
  589. handleBack: function () {
  590. this.$router.go(-1);
  591. },
  592. handleSizeChange(val) {
  593. this.limit = val;
  594. this.getlist();
  595. },
  596. handleCurrentChange(val) {
  597. this.page = val;
  598. this.getlist();
  599. },
  600. calculate: function (val) {
  601. return Math.round(parseFloat(val) * 100) / 100;
  602. },
  603. startTimeChange: function (val) {
  604. window.sessionStorage.removeItem("start_time");
  605. var time = this.getTimestamp(val) - this.getTimestamp(this.end_time);
  606. if (time > 0) {
  607. this.$message.error("开始时间不能大于结束时间");
  608. this.start_time = "";
  609. } else {
  610. this.getlist();
  611. }
  612. },
  613. endTimeChange: function (val) {
  614. window.sessionStorage.removeItem("end_time");
  615. var time = this.getTimestamp(val) - this.getTimestamp(this.start_time);
  616. if (time < 0) {
  617. this.$message.error("结束时间不能小于开始时间");
  618. this.end_time = "";
  619. } else {
  620. if (this.end_time == "") {
  621. this.showOne = true;
  622. this.showTwo = false;
  623. this.showThree = true;
  624. this.showFour = false;
  625. this.getlist();
  626. }
  627. if (this.end_time != "") {
  628. this.showOne = false;
  629. this.showTwo = true;
  630. this.showThree = false;
  631. this.showFour = true;
  632. this.getlist();
  633. this.getDrugCountList();
  634. }
  635. }
  636. },
  637. stockInCount: function (row) {
  638. let total = 0;
  639. for (let i = 0; i < row.query_drug_warehousing_info.length; i++) {
  640. total = total + row.query_drug_warehousing_info[i].warehousing_count;
  641. }
  642. return total;
  643. },
  644. salesReturnCount: function (row) {
  645. let total = 0;
  646. for (let i = 0; i < row.query_drug_sales_return_info.length; i++) {
  647. total = total + row.query_drug_sales_return_info[i].count;
  648. }
  649. return total;
  650. },
  651. stockOutCount: function (row) {
  652. let total = 0;
  653. for (let i = 0; i < row.query_drug_warehouseout_info.length; i++) {
  654. total = total + row.query_drug_warehouseout_info[i].count;
  655. }
  656. return total;
  657. },
  658. cancelStockCount: function (row) {
  659. let total = 0;
  660. for (let i = 0; i < row.query_drug_cancel_stock_info.length; i++) {
  661. total = total + row.query_drug_cancel_stock_info[i].count;
  662. }
  663. return total;
  664. },
  665. search: function () {
  666. this.getlist();
  667. },
  668. setting: function () {
  669. this.$refs.dialog.show();
  670. },
  671. exportStock() {
  672. for (let i = 0; i < this.tableList.length; i++) {
  673. this.tableList[i].index = i + 1;
  674. this.tableList[i].drug_type_name = this.getDrugType(
  675. this.tableList[i].drug_type
  676. );
  677. this.tableList[i].unit =
  678. this.tableList[i].dose +
  679. this.tableList[i].dose_unit +
  680. "*" +
  681. this.tableList[i].min_number +
  682. this.tableList[i].min_unit +
  683. "/" +
  684. this.tableList[i].max_unit;
  685. this.tableList[i].manufacturer_name = this.getManufacturerList(
  686. this.tableList[i].manufacturer
  687. );
  688. this.tableList[i].inCount = this.getWarehoseInfoOne(
  689. this.tableList[i].drug_warehouse_info,
  690. this.tableList[i].max_unit,
  691. this.tableList[i].min_unit,
  692. this.tableList[i].min_number
  693. );
  694. if (this.end_time == 0) {
  695. this.tableList[i].outCount = this.getWarehouseOutInfo(
  696. this.tableList[i].drug_warehouse_out,
  697. this.tableList[i].max_unit,
  698. this.tableList[i].min_unit,
  699. this.tableList[i].min_number
  700. );
  701. this.tableList[i].overplusCount = this.getOverFlushInfo(
  702. this.tableList[i].drug_warehouse_info,
  703. this.tableList[i].max_unit,
  704. this.tableList[i].min_unit,
  705. this.tableList[i].min_number
  706. );
  707. }
  708. if (this.end_time != 0) {
  709. this.tableList[i].outCount =
  710. this.getOutCount(this.tableList[i].id) +
  711. this.getAutoCount(this.tableList[i].id);
  712. this.tableList[i].overplusCount =
  713. this.getWarehoseInfo(this.tableList[i].drug_warehouse_info) -
  714. this.getOutCount(this.tableList[i].id) -
  715. this.getAutoCount(this.tableList[i].id);
  716. }
  717. }
  718. import("@/vendor/Export2Excel").then((excel) => {
  719. const tHeader = [
  720. "序号",
  721. "药品类型",
  722. "药品名称",
  723. "规格型号&单位",
  724. "国家编码",
  725. "进货单价",
  726. "厂家",
  727. "入库数量",
  728. "出库数量",
  729. "剩余库存量",
  730. ];
  731. const filterVal = [
  732. "index",
  733. "drug_type_name",
  734. "drug_name",
  735. "unit",
  736. "medical_insurance_number",
  737. "last_price",
  738. "manufacturer_name",
  739. "inCount",
  740. "outCount",
  741. "overplusCount",
  742. ];
  743. const data = this.formatJson(filterVal, this.tableList);
  744. excel.export_json_to_excel({
  745. header: tHeader,
  746. data,
  747. filename: "药品查询",
  748. });
  749. this.downloadLoading = false;
  750. });
  751. },
  752. formatJson(filterVal, jsonData) {
  753. return jsonData.map((v) => filterVal.map((j) => v[j]));
  754. },
  755. getDictionaryDataConfig(module, filed_name) {
  756. return getDictionaryDataConfig(module, filed_name);
  757. },
  758. getTimestamp(time) {
  759. // 把时间日期转成时间戳
  760. return new Date(time).getTime() / 1000;
  761. },
  762. changeDrug() {
  763. this.getlist();
  764. },
  765. printOrder() {
  766. window.sessionStorage.setItem("start_time", this.start_time);
  767. window.sessionStorage.setItem("end_time", this.end_time);
  768. this.$router.push({
  769. name: "drugQueryPrint",
  770. query: {
  771. drug_type: this.drug_type,
  772. keyword: this.keywords,
  773. start_time: this.start_time,
  774. end_time: this.end_time,
  775. page: this.page,
  776. limit: this.limit,
  777. },
  778. });
  779. },
  780. getDrugType(id) {
  781. var name = "";
  782. for (let i = 0; i < this.drugTypeList.length; i++) {
  783. if (this.drugTypeList[i].id == id) {
  784. name = this.drugTypeList[i].name;
  785. }
  786. }
  787. return name;
  788. },
  789. getManufacturerList(id) {
  790. var name = "";
  791. for (let i = 0; i < this.manufacturerList.length; i++) {
  792. if (id == this.manufacturerList[i].id) {
  793. name = this.manufacturerList[i].manufacturer_name;
  794. }
  795. }
  796. return name;
  797. },
  798. handleDetail(val) {
  799. console.log("val232332323223323", val);
  800. var manufacturer_name = "";
  801. for (let i = 0; i < this.manufacturerList.length; i++) {
  802. if (val.manufacturer == this.manufacturerList[i].id) {
  803. manufacturer_name = this.manufacturerList[i].manufacturer_name;
  804. }
  805. }
  806. var unit =
  807. val.dose +
  808. val.dose_unit +
  809. "*" +
  810. val.min_number +
  811. val.min_unit +
  812. "/" +
  813. val.max_unit;
  814. var over_plus = this.getOverFlushInfo(
  815. val.drug_warehouse_info,
  816. val.max_unit,
  817. val.min_unit,
  818. val.min_number
  819. );
  820. this.$router.push({
  821. path:
  822. "/drugstock/in/drugstockflow?drug_id=" +
  823. val.id +
  824. "&manufacturer=" +
  825. manufacturer_name +
  826. "&unit=" +
  827. unit +
  828. "&min_number=" +
  829. val.min_number +
  830. "&max_unit=" +
  831. val.max_unit +
  832. "&min_unit=" +
  833. val.min_unit +
  834. "&over_plus=" +
  835. over_plus,
  836. });
  837. window.sessionStorage.setItem("start_time", this.start_time);
  838. window.sessionStorage.setItem("end_time", this.end_time);
  839. },
  840. handleBatch(val) {
  841. console.log("val322332323232", val);
  842. var manufacturer_name = "";
  843. for (let i = 0; i < this.manufacturerList.length; i++) {
  844. if (val.manufacturer == this.manufacturerList[i].id) {
  845. manufacturer_name = this.manufacturerList[i].manufacturer_name;
  846. }
  847. }
  848. var unit =
  849. val.dose +
  850. val.dose_unit +
  851. "*" +
  852. val.min_number +
  853. val.min_unit +
  854. "/" +
  855. val.max_unit;
  856. var over_plus = this.getOverFlushInfo(
  857. val.drug_warehouse_info,
  858. val.max_unit,
  859. val.min_unit,
  860. val.min_number
  861. );
  862. window.sessionStorage.setItem("start_time", this.start_time);
  863. window.sessionStorage.setItem("end_time", this.end_time);
  864. this.$router.push({
  865. path:
  866. "/drugstock/in/drugbatchnumber?drug_id=" +
  867. val.id +
  868. "&manufacturer=" +
  869. manufacturer_name +
  870. "&unit=" +
  871. unit +
  872. "&min_number=" +
  873. val.min_number +
  874. "&max_unit=" +
  875. val.max_unit +
  876. "&min_unit=" +
  877. val.min_unit +
  878. "&over_plus=" +
  879. over_plus,
  880. });
  881. },
  882. getDrugCountList() {
  883. var params = {
  884. keyword: this.keywords,
  885. start_time: this.start_time,
  886. end_time: this.end_time,
  887. };
  888. console.log("paramsw2ww", params);
  889. getDrugCountList(params).then((response) => {
  890. if (response.data.state == 1) {
  891. var minCount = response.data.data.minCount;
  892. console.log("minCount", minCount);
  893. this.minCount = minCount;
  894. var cancelCountList = response.data.data.cancelCountList;
  895. this.cancelCountList = cancelCountList;
  896. var info = response.data.data.info;
  897. for (let i = 0; i < info.length; i++) {
  898. if (info[i].count_unit == info[i].max_unit) {
  899. info[i].count = info[i].count * info[i].min_number;
  900. }
  901. }
  902. this.outCountList = response.data.data.outCountList;
  903. console.log("手动出库", this.outCountList);
  904. this.auCountList = response.data.data.auCountList;
  905. console.log("自动出库", this.auCountList);
  906. this.drugOutList = info;
  907. }
  908. });
  909. },
  910. getInCount(id) {
  911. var count = 0;
  912. for (let i = 0; i < this.countList.length; i++) {
  913. if (id == this.countList[i].drug_id) {
  914. count = this.countList[i].count;
  915. }
  916. }
  917. return count;
  918. },
  919. getOutCount(id) {
  920. var count = 0;
  921. for (let i = 0; i < this.outCountList.length; i++) {
  922. if (id == this.outCountList[i].drug_id) {
  923. count = this.outCountList[i].count;
  924. }
  925. }
  926. return count;
  927. },
  928. getAutoCount(id) {
  929. var count = 0;
  930. for (let i = 0; i < this.autoCountList.length; i++) {
  931. if (id == this.autoCountList[i].drug_id) {
  932. count = this.autoCountList[i].count;
  933. }
  934. }
  935. return count;
  936. },
  937. getMinCount(id) {
  938. var count = 0;
  939. for (let i = 0; i < this.minCount.length; i++) {
  940. if (id == this.minCount[i].drug_id) {
  941. count = this.minCount[i].count;
  942. }
  943. }
  944. return count;
  945. },
  946. getCount(drug_id, min_number, max_unit, min_unit) {
  947. var total = 0;
  948. var str = "";
  949. var min_str = "";
  950. var arr = [];
  951. for (let i = 0; i < this.allCountList.length; i++) {
  952. if (drug_id == this.allCountList[i].drug_id) {
  953. arr.push(this.allCountList[i]);
  954. }
  955. }
  956. var arrTwo = [];
  957. for (let i = 0; i < arr.length; i++) {
  958. if (arr[i].drug_id == 1236) {
  959. arrTwo.push(arr[i]);
  960. }
  961. if (arr[i].count_unit == max_unit) {
  962. arr[i].count = arr[i].count * min_number;
  963. }
  964. if (arr[i].count_unit == min_unit) {
  965. arr[i].count = arr[i].count;
  966. }
  967. total += arr[i].count;
  968. }
  969. if (total < min_number) {
  970. str = "";
  971. min_str = total + min_unit;
  972. }
  973. if (total >= min_number) {
  974. if (parseInt(total / min_number) != 0) {
  975. str = parseInt(total / min_number) + max_unit;
  976. }
  977. if (total % min_number != 0) {
  978. min_str = (total % min_number) + min_unit;
  979. }
  980. }
  981. return str + min_str;
  982. },
  983. getCountOne(drug_id) {
  984. var count = 0;
  985. for (let i = 0; i < this.drugOutList.length; i++) {
  986. if (drug_id == this.drugOutList[i].drug_id) {
  987. count += parseInt(this.drugOutList[i].count);
  988. }
  989. }
  990. return count;
  991. },
  992. getCountTwo(drug_id, min_number, max_unit, min_unit) {
  993. var total_count = 0;
  994. var out_count = 0;
  995. var count = 0;
  996. var str = "";
  997. var str_min = "";
  998. total_count = this.getInCount(drug_id) * min_number;
  999. out_count = this.getCountOne(drug_id);
  1000. count = total_count - out_count;
  1001. if (parseInt(count / min_number) != 0) {
  1002. str = parseInt(count / min_number) + max_unit;
  1003. }
  1004. if (count % min_number != 0) {
  1005. str_min = (count % min_number) + min_unit;
  1006. }
  1007. return str + str_min;
  1008. },
  1009. getCancelCount(id) {
  1010. var count = 0;
  1011. for (let i = 0; i < this.cancelCountList.length; i++) {
  1012. if (id == this.cancelCountList[i].drug_id) {
  1013. count = this.cancelCountList[i].count;
  1014. }
  1015. }
  1016. return count;
  1017. },
  1018. getWarehoseInfo(arr) {
  1019. var total = 0;
  1020. if (arr.length > 0) {
  1021. for (let i = 0; i < arr.length; i++) {
  1022. total += parseInt(arr[i].warehousing_count);
  1023. }
  1024. }
  1025. if (total == 0) {
  1026. total = "";
  1027. }
  1028. return total;
  1029. },
  1030. getWarehoseInfoOne(arr, max_unit, min_unit, min_number) {
  1031. var total = 0;
  1032. var max_str = "";
  1033. var min_str = "";
  1034. if (arr.length > 0) {
  1035. for (let i = 0; i < arr.length; i++) {
  1036. total += parseInt(arr[i].warehousing_count);
  1037. }
  1038. }
  1039. if (total < min_number) {
  1040. min_str = total + min_unit;
  1041. }
  1042. if (total == 0) {
  1043. min_str = "";
  1044. max_str = "";
  1045. }
  1046. if (total >= min_number) {
  1047. if (parseInt(total / min_number) != 0) {
  1048. max_str = parseInt(total / min_number) + max_unit;
  1049. }
  1050. if (total % min_number != 0) {
  1051. min_str = (total % min_number) + min_unit;
  1052. }
  1053. }
  1054. return max_str + min_str;
  1055. },
  1056. getOverFlushInfo(arr, max_unit, min_unit, min_number) {
  1057. var max_str = "";
  1058. var min_str = "";
  1059. var total = 0;
  1060. var newarr = arr;
  1061. if (newarr.length > 0) {
  1062. for (let i = 0; i < newarr.length; i++) {
  1063. total += newarr[i].stock_max_number + newarr[i].stock_min_number;
  1064. }
  1065. }
  1066. if (total < min_number) {
  1067. min_str = total + min_unit;
  1068. }
  1069. if (total == 0) {
  1070. min_str = "";
  1071. max_str = "";
  1072. }
  1073. if (total >= min_number) {
  1074. if (parseInt(total / min_number) != 0) {
  1075. max_str = parseInt(total / min_number) + max_unit;
  1076. }
  1077. if (total % min_number != 0) {
  1078. min_str = (total % min_number) + min_unit;
  1079. }
  1080. }
  1081. return max_str + min_str;
  1082. },
  1083. getWarehouseOutInfo(arr, max_unit, min_unit, min_number) {
  1084. var min_str = "";
  1085. var max_str = "";
  1086. var total = 0;
  1087. if (arr.length > 0) {
  1088. for (let i = 0; i < arr.length; i++) {
  1089. total += parseInt(arr[i].count);
  1090. }
  1091. }
  1092. if (total < min_number) {
  1093. min_str = total + min_unit;
  1094. }
  1095. if (total == 0) {
  1096. min_str = "";
  1097. max_str = "";
  1098. }
  1099. if (total >= min_number) {
  1100. if (parseInt(total / min_number) != 0) {
  1101. max_str = parseInt(total / min_number) + max_unit;
  1102. }
  1103. if (total % min_number != 0) {
  1104. min_str = (total % min_number) + min_unit;
  1105. }
  1106. }
  1107. return max_str + min_str;
  1108. },
  1109. getDrugOutList(arr, max_unit, min_unit, min_number) {
  1110. var str = "";
  1111. var str_min = "";
  1112. if (arr.length > 0) {
  1113. for (let i = 0; i < arr.length; i++) {
  1114. if (parseInt(arr[i].count / min_number) != 0) {
  1115. str = parseInt(arr[i].count / min_number) + max_unit;
  1116. }
  1117. if (arr[i].count % min_number != 0) {
  1118. str_min = (arr[i].count % min_number) + min_unit;
  1119. }
  1120. }
  1121. }
  1122. return str + str_min;
  1123. },
  1124. getDrugChaCount(
  1125. info,
  1126. out_info,
  1127. max_unit,
  1128. min_unit,
  1129. min_number,
  1130. cancel_info
  1131. ) {
  1132. var total_info = 0;
  1133. var total_out = 0;
  1134. var cha_count = 0;
  1135. var cancel_count = 0;
  1136. if (info.length > 0) {
  1137. for (let i = 0; i < info.length; i++) {
  1138. total_info += info[i].warehousing_count * min_number;
  1139. }
  1140. }
  1141. if (out_info.length > 0) {
  1142. for (let j = 0; j < out_info.length; j++) {
  1143. total_out += out_info[j].count;
  1144. }
  1145. }
  1146. if (cancel_info.length > 0) {
  1147. for (let z = 0; z < cancel_info.length; z++) {
  1148. cancel_count += cancel_info[z].count;
  1149. }
  1150. }
  1151. cha_count = total_info - total_out + cancel_count;
  1152. var str = "";
  1153. var str_min = "";
  1154. if (parseInt(cha_count / min_number) != 0) {
  1155. str = parseInt(cha_count / min_number) + max_unit;
  1156. }
  1157. if (cha_count % min_number != 0) {
  1158. str_min = (cha_count % min_number) + min_unit;
  1159. }
  1160. return str + str_min;
  1161. },
  1162. getOutFlush(info, max_unit, min_unit, min_number, cancel_info) {
  1163. var str = "";
  1164. var str_min = "";
  1165. //总库存
  1166. var total = 0;
  1167. var out_count = 0;
  1168. var over_count = 0;
  1169. var cancel_count = 0;
  1170. for (let i = 0; i < info.length; i++) {
  1171. total += info[i].warehousing_count;
  1172. }
  1173. for (let j = 0; j < info.length; j++) {
  1174. out_count += info[j].stock_max_number + info[j].stock_min_number;
  1175. }
  1176. // for(let z=0;z<cancel_info.length;z++){
  1177. // cancel_count += cancel_info[z].count
  1178. // }
  1179. // over_count = total - out_count + cancel_count
  1180. over_count = total - out_count;
  1181. if (parseInt(over_count / min_number) != 0) {
  1182. str = parseInt(over_count / min_number) + max_unit;
  1183. }
  1184. if (over_count % min_number != 0) {
  1185. str_min = (over_count % min_number) + min_unit;
  1186. }
  1187. return str + str_min;
  1188. },
  1189. getHouseName(id) {
  1190. var storehouse_name = "";
  1191. for (let i = 0; i < this.houseList.length; i++) {
  1192. if (id == this.houseList[i].id) {
  1193. storehouse_name = this.houseList[i].storehouse_name;
  1194. }
  1195. }
  1196. return storehouse_name;
  1197. },
  1198. getWarehoseInfoSeven(arr, max_unit, min_unit, min_number, storehouse_id) {
  1199. var total = 0;
  1200. var max_str = "";
  1201. var min_str = "";
  1202. if (arr.length > 0) {
  1203. for (let i = 0; i < arr.length; i++) {
  1204. if (arr[i].storehouse_id == storehouse_id) {
  1205. total += parseInt(arr[i].warehousing_count);
  1206. }
  1207. }
  1208. }
  1209. if (total < min_number) {
  1210. min_str = total + min_unit;
  1211. }
  1212. if (total == 0) {
  1213. min_str = "";
  1214. max_str = "";
  1215. }
  1216. if (total >= min_number) {
  1217. if (parseInt(total / min_number) != 0) {
  1218. max_str = parseInt(total / min_number) + max_unit;
  1219. }
  1220. if (total % min_number != 0) {
  1221. min_str = (total % min_number) + min_unit;
  1222. }
  1223. }
  1224. return max_str + min_str;
  1225. },
  1226. getOverFlushInfoEight(arr, max_unit, min_unit, min_number, storehouse_id) {
  1227. var max_str = "";
  1228. var min_str = "";
  1229. var total = 0;
  1230. var newarr = arr;
  1231. if (newarr.length > 0) {
  1232. for (let i = 0; i < newarr.length; i++) {
  1233. if (newarr[i].storehouse_id == storehouse_id) {
  1234. total += newarr[i].stock_max_number + newarr[i].stock_min_number;
  1235. }
  1236. }
  1237. }
  1238. if (total < min_number) {
  1239. min_str = total + min_unit;
  1240. }
  1241. if (total == 0) {
  1242. min_str = "";
  1243. max_str = "";
  1244. }
  1245. if (total >= min_number) {
  1246. if (parseInt(total / min_number) != 0) {
  1247. max_str = parseInt(total / min_number) + max_unit;
  1248. }
  1249. if (total % min_number != 0) {
  1250. min_str = (total % min_number) + min_unit;
  1251. }
  1252. }
  1253. return max_str + min_str;
  1254. },
  1255. getOutFlushNight(
  1256. info,
  1257. max_unit,
  1258. min_unit,
  1259. min_number,
  1260. cancel_info,
  1261. storehouse_id
  1262. ) {
  1263. var str = "";
  1264. var str_min = "";
  1265. //总库存
  1266. var total = 0;
  1267. var out_count = 0;
  1268. var over_count = 0;
  1269. var cancel_count = 0;
  1270. for (let i = 0; i < info.length; i++) {
  1271. if (info[i].storehouse_id == storehouse_id) {
  1272. total += info[i].warehousing_count;
  1273. }
  1274. }
  1275. for (let j = 0; j < info.length; j++) {
  1276. if (info[j].storehouse_id == storehouse_id) {
  1277. out_count += info[j].stock_max_number + info[j].stock_min_number;
  1278. }
  1279. }
  1280. // for(let z=0;z<cancel_info.length;z++){
  1281. // cancel_count += cancel_info[z].count
  1282. // }
  1283. // over_count = total - out_count + cancel_count
  1284. over_count = total - out_count;
  1285. if (parseInt(over_count / min_number) != 0) {
  1286. str = parseInt(over_count / min_number) + max_unit;
  1287. }
  1288. if (over_count % min_number != 0) {
  1289. str_min = (over_count % min_number) + min_unit;
  1290. }
  1291. return str + str_min;
  1292. },
  1293. changeStorehouseName() {
  1294. this.getlist();
  1295. },
  1296. changeDrugName() {
  1297. this.getlist();
  1298. },
  1299. // 合并单元格样式
  1300. cellStyle({ row, column, rowIndex, columnIndex }) {
  1301. let arr = [6, 7, 8, 9];
  1302. if (arr.indexOf(columnIndex) > -1) {
  1303. return "spanClass";
  1304. }
  1305. },
  1306. },
  1307. };
  1308. </script>
  1309. <style rel="stylesheet/css" lang="scss" scoped>
  1310. .information {
  1311. border: 1px #dcdfe6 solid;
  1312. padding: 30px 20px 30px 20px;
  1313. .border {
  1314. border-bottom: 1px #dcdfe6 solid;
  1315. margin: 0px 0 20px 0;
  1316. }
  1317. }
  1318. .title {
  1319. background: #409eff;
  1320. height: 44px;
  1321. line-height: 44px;
  1322. padding: 0 0 0 10px;
  1323. color: #fff;
  1324. margin: 0 0 10px 0;
  1325. }
  1326. .edit_separater {
  1327. border-top: 1px solid rgb(233, 233, 233);
  1328. margin-top: 15px;
  1329. margin-bottom: 15px;
  1330. }
  1331. </style>
  1332. <style>
  1333. .sign-and-weigh-box .sign-and-weigh-box-patients .cell {
  1334. font-size: 12px;
  1335. }
  1336. .sign-and-weigh-box .sign-and-weigh-box-patients .current-row > td {
  1337. background: #6fb5fa;
  1338. }
  1339. .count {
  1340. color: #bd2c00;
  1341. }
  1342. .el-table td,
  1343. .el-table th.is-leaf,
  1344. .el-table--border,
  1345. .el-table--group {
  1346. border-color: #d0d3da;
  1347. }
  1348. .el-table--border::after,
  1349. .el-table--group::after,
  1350. .el-table::before {
  1351. background-color: #d0d3da;
  1352. }
  1353. /* 合并表格线样式 */
  1354. .spanClass .cell {
  1355. padding: 0 !important;
  1356. }
  1357. .spanClass .cell tr {
  1358. display: inline-block;
  1359. width: 100%;
  1360. }
  1361. .spanClass .cell tr td {
  1362. padding: 10px 0;
  1363. border-bottom: 1px solid #ebeef5;
  1364. display: block;
  1365. width: 100%;
  1366. }
  1367. .spanClass .cell tr:last-of-type td {
  1368. border-bottom: none;
  1369. }
  1370. </style>