drugStockFlow.vue 18KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589
  1. <template>
  2. <div class="main-contain">
  3. <div class="position">
  4. <bread-crumb :crumbs="crumbs"></bread-crumb>
  5. </div>
  6. <div class="app-container ">
  7. <div class="cell clearfix">
  8. 药品名称:<span>{{getName(this.$route.query.drug_id)}}</span>&nbsp;
  9. 库存: {{this.$route.query.over_plus}}
  10. 规格:<span>{{this.$route.query.unit}}</span>&nbsp;
  11. 厂家:<span>{{this.$route.query.manufacturer}}</span>&nbsp;
  12. </div>
  13. <div class="cell clearfix">
  14. <span>日期查询:</span>
  15. <el-date-picker
  16. size="small"
  17. v-model="start_time"
  18. prefix-icon="el-icon-date"
  19. :editable="false"
  20. style="width: 196px;"
  21. type="date"
  22. placeholder="选择日期时间"
  23. align="right"
  24. format="yyyy-MM-dd"
  25. value-format="yyyy-MM-dd"
  26. @change="startTimeChange"
  27. ></el-date-picker>-
  28. <el-date-picker
  29. size="small"
  30. v-model="end_time"
  31. prefix-icon="el-icon-date"
  32. :editable="false"
  33. style="width: 196px;margin-right:10px;"
  34. type="date"
  35. placeholder="选择日期时间"
  36. align="right"
  37. format="yyyy-MM-dd"
  38. value-format="yyyy-MM-dd"
  39. @change="endTimeChange"
  40. ></el-date-picker>
  41. <span>出入库方式:</span>
  42. <el-select v-model="stock_type" style="width:160px;margin-right:10px;" placeholder="请选择" @change="changeDrug">
  43. <el-option
  44. v-for="(item,index) in stockType"
  45. :key="index"
  46. :label="item.name"
  47. :value="item.id">
  48. </el-option>
  49. </el-select>
  50. </div>
  51. <el-table
  52. :data="tableList"
  53. border
  54. style="width: 100%">
  55. <el-table-column prop="date" label="序号" width="180" align="center">
  56. <template slot-scope="scope">
  57. {{scope.$index + 1}}
  58. </template>
  59. </el-table-column>
  60. <el-table-column prop="drug_type" label="出入库方式" width="180" align="center">
  61. <template slot-scope="scope">
  62. <span v-if="scope.row.consumable_type == 1">手动入库</span>
  63. <span v-if="scope.row.consumable_type == 2">手动出库</span>
  64. <span v-if="scope.row.consumable_type == 3">自动出库</span>
  65. <span v-if="scope.row.consumable_type == 4">手动退库</span>
  66. <span v-if="scope.row.consumable_type == 7">自动退库</span>
  67. <span v-if="scope.row.consumable_type == 5">报损数量</span>
  68. <span v-if="scope.row.consumable_type == 10">盘盈</span>
  69. <span v-if="scope.row.consumable_type == 11">盘亏</span>
  70. </template>
  71. </el-table-column>
  72. <el-table-column prop="drug_name" label="出/入库单据编码" align="center">
  73. <template slot-scope="scope">
  74. <span v-if="scope.row.consumable_type == 1">{{scope.row.warehousing_order}}</span>
  75. <span v-if="scope.row.consumable_type == 2 || scope.row.consumable_type == 3">{{scope.row.warehouse_out_order_number}}</span>
  76. <span v-if="scope.row.consumable_type == 4 || scope.row.consumable_type == 7">{{scope.row.cancel_order_number}}</span>
  77. <span v-if="scope.row.consumable_type == 5">{{scope.row.warehouse_out_order_number}}</span>
  78. <span v-if="scope.row.consumable_type == 10 || scope.row.consumable_type == 11">{{scope.row.warehousing_order}}</span>
  79. </template>
  80. </el-table-column>
  81. <el-table-column prop="drug_name" label="操作日期" align="center">
  82. <template slot-scope="scope">
  83. {{getTime(scope.row.ctime,"{y}-{h}-{d}")}}
  84. </template>
  85. </el-table-column>
  86. <el-table-column prop="drug_name" label="数量" align="center">
  87. <template slot-scope="scope">
  88. {{scope.row.count}}
  89. </template>
  90. </el-table-column>
  91. <el-table-column prop="drug_name" label="单位" align="center">
  92. <template slot-scope="scope">
  93. {{scope.row.max_unit}}
  94. </template>
  95. </el-table-column>
  96. <!-- <el-table-column prop="drug_name" label="剩余量" align="center">
  97. <template slot-scope="scope">
  98. {{getCountList(scope.row.BaseDrugLib.min_number,scope.row.DrugWarehouseInfo,scope.row.BaseDrugLib.max_unit,scope.row.BaseDrugLib.min_unit)}}
  99. </template>
  100. </el-table-column> -->
  101. <el-table-column prop="drug_name" label="单价" align="center">
  102. <template slot-scope="scope">
  103. <span v-if="scope.row.price >0">{{scope.row.price}}</span>
  104. <span v-if="scope.row.price == 0">{{getPrice(scope.row.drug_id)}}</span>
  105. </template>
  106. </el-table-column>
  107. <el-table-column prop="drug_name" label="有效期" align="center">
  108. <template slot-scope="scope">
  109. {{getTime(scope.row.expire_date,"{y}-{h}-{d}")}}
  110. </template>
  111. </el-table-column>
  112. <!-- <el-table-column prop="drug_name" label="批号" align="center">
  113. <template slot-scope="scope">
  114. <span>{{scope.row.batch_number}}</span>
  115. </template>
  116. </el-table-column> -->
  117. <!-- <el-table-column prop="drug_name" label="生产商" align="center">
  118. <template slot-scope="scope">
  119. {{getManufacturer(scope.row.manufacturer)}}
  120. </template>
  121. </el-table-column> -->
  122. </el-table>
  123. <el-pagination
  124. @size-change="handleSizeChange"
  125. @current-change="handleCurrentChange"
  126. :page-sizes="[10, 50, 100,500,1000]"
  127. :page-size="10"
  128. background
  129. align="right"
  130. style="margin-top:20px;"
  131. layout="total, sizes, prev, pager, next, jumper"
  132. :total="total"
  133. >
  134. </el-pagination>
  135. </div>
  136. <setting-dialog
  137. ref="dialog"
  138. ></setting-dialog>
  139. </div>
  140. </template>
  141. <script>
  142. import { uParseTime } from '@/utils/tools'
  143. import BreadCrumb from '@/xt_pages/components/bread-crumb'
  144. import { getDrugStockFlow,getOutDrugStockFlow,getDrugCountList,getDrugFlow } from '@/api/drug/drug_stock'
  145. import SettingDialog from './settingDialog/index'
  146. import { getDictionaryDataConfig } from "@/utils/data";
  147. export default {
  148. name: 'stockIn',
  149. created() {
  150. var nowDate = new Date();
  151. var nowYear = nowDate.getFullYear();
  152. var nowMonth = nowDate.getMonth() + 1;
  153. var nowDay = nowDate.getDate();
  154. this.end_time =
  155. nowYear +
  156. "-" +
  157. (nowMonth < 10 ? "0" + nowMonth : nowMonth) +
  158. "-" +
  159. (nowDay < 10 ? "0" + nowDay : nowDay);
  160. nowDate.setMonth(nowDate.getMonth() - 1);
  161. nowYear = nowDate.getFullYear();
  162. nowMonth = nowDate.getMonth() + 1;
  163. nowDay = nowDate.getDate();
  164. this.start_time =
  165. nowYear +
  166. "-" +
  167. (nowMonth < 10 ? "0" + nowMonth : nowMonth) +
  168. "-" +
  169. (nowDay < 10 ? "0" + nowDay : nowDay);
  170. var drugCategory = getDictionaryDataConfig('system','drug_category')
  171. this.drugCategory.push(...drugCategory)
  172. this.drugTypeList = getDictionaryDataConfig('system','drug_type')
  173. // this.getlist()
  174. // this.getOutList()
  175. // this.getDrugCountList()
  176. this.getDrugFlow()
  177. },
  178. components: {
  179. SettingDialog,
  180. BreadCrumb
  181. },
  182. data() {
  183. return {
  184. crumbs: [
  185. { path: false, name: '库存管理' },
  186. { path: '/stock/drugs/stock/query', name: '药品库存查询' },
  187. { path:'/drugstock/in/drugstockflow',name:'库存流水'}
  188. ],
  189. keywords: '',
  190. total: 0,
  191. multipleSelection: [],
  192. signAndWeighBoxPatients: 'sign-and-weigh-box-patients',
  193. start_time: '',
  194. end_time: '',
  195. page: 1,
  196. limit: 10,
  197. goodType: [],
  198. goodInfo: [],
  199. tempArr: [],
  200. sameRowArr: [],
  201. WarehouseInfo: {
  202. loading: false,
  203. warehouseInfoDate: []
  204. },
  205. tableData:[],
  206. drug_category:0,
  207. stock_type:0,
  208. drugCategory:[
  209. {id:0,name:"全部"}
  210. ],
  211. drugTypeList:[],
  212. tableList:[],
  213. manufacturerList:[],
  214. list:[],
  215. stockType:[
  216. {id:0,name:"全部"},
  217. {id:1,name:"手动入库"},
  218. {id:2,name:"手动出库"},
  219. {id:3,name:"自动出库"},
  220. {id:4,name:"手动退库"},
  221. {id:10,name:"盘盈"},
  222. {id:11,name:"盘亏"}
  223. ],
  224. outList:[],
  225. countList:[],
  226. outCountList:[],
  227. autoCountList:[],
  228. drugOutList:[],
  229. total:0,
  230. drug:{},
  231. }
  232. },
  233. methods:{
  234. getlist(){
  235. console.log("2332233232",this.$route.query.drug_id)
  236. var params = {
  237. drug_id:this.$route.query.drug_id,
  238. start_time:this.start_time,
  239. end_time:this.end_time,
  240. page:this.page,
  241. limit:this.limit,
  242. stock_type:this.stock_type,
  243. }
  244. console.log("params23322323232332",params)
  245. getDrugStockFlow(params).then(response=>{
  246. if(response.data.state == 1){
  247. var list = response.data.data.list
  248. console.log("库存数量",list)
  249. for(let i=0;i<list.length;i++){
  250. list[i].drug_way = 4
  251. this.tableList.push(list[i])
  252. }
  253. var total = response.data.data.total
  254. this.total = total
  255. var manufacturerList = response.data.data.manufacturerList
  256. this.manufacturerList = manufacturerList
  257. this.drug = response.data.data.drug
  258. }
  259. })
  260. },
  261. getOutList(){
  262. var params = {
  263. drug_id:this.$route.query.drug_id,
  264. start_time:this.start_time,
  265. end_time:this.end_time,
  266. page:this.page,
  267. limit:this.limit,
  268. stock_type:this.stock_type,
  269. }
  270. getOutDrugStockFlow(params).then(response=>{
  271. if(response.data.state == 1){
  272. var outList = response.data.data.outList
  273. console.log("outlist",outList)
  274. for(let i=0;i<outList.length;i++){
  275. if(outList[i].is_sys == 1){
  276. outList[i].drug_way = 2
  277. }
  278. if(outList[i].is_sys == 0){
  279. console.log("进来22222")
  280. outList[i].drug_way = 1
  281. }
  282. this.tableList.push(outList[i])
  283. }
  284. this.total = response.data.data.total
  285. console.log("出库列表数据",this.tableList)
  286. }
  287. })
  288. },
  289. handleSizeChange(val) {
  290. this.limit = val
  291. this.getDrugFlow()
  292. },
  293. handleCurrentChange(val) {
  294. this.page = val
  295. this.getDrugFlow()
  296. },
  297. startTimeChange: function(val) {
  298. var time = this.getTimestamp(val) - this.getTimestamp(this.end_time);
  299. if (time > 0) {
  300. this.$message.error("开始时间不能大于结束时间");
  301. this.start_time = "";
  302. } else {
  303. this.getDrugFlow()
  304. }
  305. },
  306. endTimeChange: function(val) {
  307. var time = this.getTimestamp(val) - this.getTimestamp(this.start_time);
  308. if (time < 0) {
  309. this.$message.error("结束时间不能小于开始时间");
  310. this.end_time = "";
  311. } else {
  312. this.getDrugFlow()
  313. }
  314. },
  315. getManufacturer(id){
  316. var name = ""
  317. for(let i=0;i<this.manufacturerList.length;i++){
  318. if(id == this.manufacturerList[i].id){
  319. name = this.manufacturerList[i].manufacturer_name
  320. }
  321. }
  322. return name
  323. },
  324. getTime(val) {
  325. if(val < 0){
  326. return ""
  327. }
  328. if(val == ""){
  329. return ""
  330. }else {
  331. return uParseTime(val, '{y}-{m}-{d}')
  332. }
  333. },
  334. getDrugCountList(){
  335. var params = {
  336. keyword: this.keywords,
  337. start_time:this.start_time,
  338. end_time:this.end_time,
  339. }
  340. getDrugCountList(params).then(response=>{
  341. if(response.data.state == 1){
  342. var countlist = response.data.data.countList
  343. // console.log("入库数据",countlist)
  344. this.countList = countlist
  345. var outcountlist = response.data.data.outCountList
  346. // console.log("出库数据",outcountlist)
  347. this.outCountList = outcountlist
  348. var aucountlist = response.data.data.auCountList
  349. // console.log("自动数据",aucountlist)
  350. this.autoCountList = aucountlist
  351. var minCount = response.data.data.minCount
  352. // console.log("minCount",minCount)
  353. this.minCount = minCount
  354. var info = response.data.data.info
  355. for(let i=0;i<info.length;i++){
  356. if(info[i].count_unit == info[i].max_unit){
  357. info[i].count = info[i].count * info[i].min_number
  358. }
  359. }
  360. // console.log("info2222222",info)
  361. this.drugOutList = info
  362. }
  363. })
  364. },
  365. getInCount(id){
  366. var count = ""
  367. for(let i=0;i<this.countList.length;i++){
  368. if(id == this.countList[i].drug_id){
  369. count = this.countList[i].count
  370. }
  371. }
  372. return count
  373. },
  374. getOutCount(id){
  375. var count = ""
  376. for(let i=0;i<this.outCountList.length;i++){
  377. if(id == this.outCountList[i].drug_id){
  378. count = this.outCountList[i].count
  379. }
  380. }
  381. return count
  382. },
  383. getAutoCount(id){
  384. var count= ""
  385. for(let i=0;i<this.autoCountList.length;i++){
  386. if(id == this.autoCountList[i].drug_id){
  387. count = this.autoCountList[i].count
  388. }
  389. }
  390. return count
  391. },
  392. getTimestamp(time) { // 把时间日期转成时间戳
  393. return (new Date(time)).getTime() / 1000
  394. },
  395. changeDrug(val){
  396. this.tableList = []
  397. this.getDrugFlow()
  398. },
  399. getMinCount(id){
  400. var count=""
  401. for(let i=0;i<this.minCount.length;i++){
  402. if(id == this.minCount[i].drug_id){
  403. count = this.minCount[i].count
  404. }
  405. }
  406. return count
  407. },
  408. getCount(drug_id,min_number,max_unit,min_unit){
  409. var count= 0
  410. var str = ""
  411. var min_str = ""
  412. for(let i=0;i<this.drugOutList.length;i++){
  413. if(drug_id == this.drugOutList[i].drug_id){
  414. count += parseInt(this.drugOutList[i].count)
  415. }
  416. }
  417. if(parseInt(count/min_number)!=0){
  418. str = parseInt(count/min_number)+ max_unit
  419. }
  420. if((count%min_number)!=0){
  421. min_str = count%min_number + min_unit
  422. }
  423. return str + min_str
  424. },
  425. getCountOne(drug_id){
  426. var count= 0
  427. for(let i=0;i<this.drugOutList.length;i++){
  428. if(drug_id == this.drugOutList[i].drug_id){
  429. count += parseInt(this.drugOutList[i].count)
  430. }
  431. }
  432. return count
  433. },
  434. getCountTwo(drug_id,min_number,max_unit,min_unit){
  435. var total_count = 0
  436. var out_count = 0
  437. var count = 0
  438. var str = ""
  439. var str_min = ""
  440. total_count = this.getInCount(drug_id) * min_number
  441. out_count = this.getCountOne(drug_id)
  442. count = total_count-out_count
  443. if(parseInt(count/min_number)!=0){
  444. str = parseInt(count/min_number) + max_unit
  445. }
  446. if((count%min_number)!=0){
  447. str_min = count%min_number + min_unit
  448. }
  449. console.log("str2323222",str)
  450. console.log("str22333333",str_min)
  451. return str+str_min
  452. },
  453. getDrugFlow(){
  454. var params = {
  455. drug_id:this.$route.query.drug_id,
  456. start_time:this.start_time,
  457. end_time:this.end_time,
  458. page:this.page,
  459. limit:this.limit,
  460. stock_type:this.stock_type,
  461. }
  462. getDrugFlow(params).then(response=>{
  463. if(response.data.state ==1){
  464. var list = response.data.data.list
  465. console.log("list232323232",list)
  466. this.tableList = list
  467. var total = response.data.data.total
  468. console.log("total23232",total)
  469. this.total =total
  470. this.manufacturerList = response.data.data.manufacturerList
  471. this.dealerList = response.data.data.dealerList
  472. var drug = response.data.data.drug
  473. console.log("drug233223232323223",drug)
  474. this.drug = drug
  475. }
  476. })
  477. },
  478. getCountList(min_number,val,max_unit,min_unit){
  479. var total = 0
  480. var str = ""
  481. var str_min = ""
  482. for(let i=0;i<val.length;i++){
  483. total += (val[i].stock_max_number * min_number + val[i].stock_min_number)
  484. }
  485. if(parseInt(total/min_number)!=0){
  486. str = parseInt(total/min_number) + max_unit
  487. }
  488. if((total%min_number)!=0){
  489. str_min = total%min_number + min_unit
  490. }
  491. return str+str_min
  492. },
  493. getName(drug_id){
  494. var name = ""
  495. if(drug_id == this.drug.id){
  496. name = this.drug.drug_name
  497. }
  498. return name
  499. },
  500. getPrice(id){
  501. var min_price = 0
  502. if(id == this.drug.id){
  503. min_price = this.drug.min_price
  504. }
  505. return min_price
  506. }
  507. }
  508. }
  509. </script>
  510. <style rel="stylesheet/css" lang="scss" scoped>
  511. .information {
  512. border: 1px #dcdfe6 solid;
  513. padding: 30px 20px 30px 20px;
  514. .border {
  515. border-bottom: 1px #dcdfe6 solid;
  516. margin: 0px 0 20px 0;
  517. }
  518. }
  519. .title {
  520. background: #409eff;
  521. height: 44px;
  522. line-height: 44px;
  523. padding: 0 0 0 10px;
  524. color: #fff;
  525. margin: 0 0 10px 0;
  526. }
  527. .edit_separater {
  528. border-top: 1px solid rgb(233, 233, 233);
  529. margin-top: 15px;
  530. margin-bottom: 15px;
  531. }
  532. </style>
  533. <style>
  534. .sign-and-weigh-box .sign-and-weigh-box-patients .cell {
  535. font-size: 12px;
  536. }
  537. .sign-and-weigh-box .sign-and-weigh-box-patients .current-row > td {
  538. background: #6fb5fa;
  539. }
  540. .count {
  541. color: #bd2c00;
  542. }
  543. .el-table td,
  544. .el-table th.is-leaf,
  545. .el-table--border,
  546. .el-table--group {
  547. border-color: #d0d3da;
  548. }
  549. .el-table--border::after,
  550. .el-table--group::after,
  551. .el-table::before {
  552. background-color: #d0d3da;
  553. }
  554. </style>