stockFlow.vue 14KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458
  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. 耗材名称:{{this.$route.query.good_name}} &nbsp;
  9. 库存: {{getInCount(this.$route.query.id)- getOutCount(this.$route.query.id) - getAutoCount(this.$route.query.id) + getCancelCount(this.$route.query.id)}}{{this.$route.query.packing_unit }} &nbsp;
  10. 规格:{{this.$route.query.specification_name}} &nbsp;
  11. 厂家:{{this.$route.query.manufacturer}}
  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.stock_way == 4">采购入库</span>
  63. <span v-if="scope.row.stock_way == 3">手动出库</span>
  64. <span v-if="scope.row.stock_way == 2">自动出库</span>
  65. </template>
  66. </el-table-column>
  67. <el-table-column prop="drug_name" label="出/入库单据编码" align="center">
  68. <template slot-scope="scope">
  69. <span v-if="scope.row.stock_way == 2 || scope.row.stock_way == 3"> {{scope.row.warehouse_out_order_number}}</span>
  70. <span v-if="scope.row.stock_way == 4">{{scope.row.warehousing_order}}</span>
  71. </template>
  72. </el-table-column>
  73. <el-table-column prop="drug_name" label="操作日期" align="center">
  74. <template slot-scope="scope">
  75. {{getTime(scope.row.ctime)}}
  76. </template>
  77. </el-table-column>
  78. <el-table-column prop="drug_name" label="出入库数量" align="center">
  79. <template slot-scope="scope">
  80. <span v-if="scope.row.stock_way == 4 && scope.row.warehousing_count!=0"> {{scope.row.warehousing_count}}{{packing_unit}}</span>
  81. <span v-if="(scope.row.stock_way == 2 || scope.row.stock_way == 3) && scope.row.count!=0">{{scope.row.count}}{{packing_unit}}</span>
  82. </template>
  83. </el-table-column>
  84. <el-table-column prop="drug_name" label="剩余库存量" align="center">
  85. <template slot-scope="scope">
  86. <!-- <span v-if="scope.row.stock_way == 4 && scope.row.stock_count!=0">{{scope.row.stock_count}} </span> -->
  87. {{getInCount(scope.row.good_id)- getOutCount(scope.row.good_id) - getAutoCount(scope.row.good_id)}}{{packing_unit}}
  88. </template>
  89. </el-table-column>
  90. <el-table-column prop="drug_name" label="进/出货单价" align="center">
  91. <template slot-scope="scope">
  92. <span v-if="scope.row.stock_way == 4"> {{scope.row.price}}</span>
  93. <span v-if="scope.row.stock_way == 2 || scope.row.stock_way == 3">{{scope.row.price}}</span>
  94. </template>
  95. </el-table-column>
  96. <el-table-column prop="drug_name" label="有效期" align="center">
  97. <template slot-scope="scope" >
  98. <span v-if="scope.row.stock_way == 4"> {{getTime(scope.row.expiry_date)}}</span>
  99. <span v-if="scope.row.stock_way == 2 || scope.row.stock_way == 3">{{getTime(scope.row.expiry_date)}}</span>
  100. </template>
  101. </el-table-column>
  102. <el-table-column prop="drug_name" label="批号" align="center">
  103. <template slot-scope="scope" >
  104. <span v-if="scope.row.stock_way == 2"> {{scope.row.number}}</span>
  105. <span v-if="scope.row.stock_way == 4 || scope.row.stock_way == 3">{{scope.row.number}}</span>
  106. </template>
  107. </el-table-column>
  108. <el-table-column prop="drug_name" label="生产商" align="center">
  109. <template slot-scope="scope">
  110. <span v-if="scope.row.stock_way == 4"> {{getManufacturer(scope.row.manufacturer)}}</span>
  111. <span v-if="scope.row.stock_way == 2 || scope.row.stock_way == 3">{{getManufacturer(scope.row.manufacturer)}}</span>
  112. </template>
  113. </el-table-column>
  114. </el-table>
  115. <el-pagination
  116. @size-change="handleSizeChange"
  117. @current-change="handleCurrentChange"
  118. :page-sizes="[10, 50, 100,500,1000]"
  119. :page-size="10"
  120. background
  121. align="right"
  122. style="margin-top:20px;"
  123. layout="total, sizes, prev, pager, next, jumper"
  124. :total="total"
  125. >
  126. </el-pagination>
  127. </div>
  128. </div>
  129. </template>
  130. <script>
  131. import { uParseTime } from '@/utils/tools'
  132. import BreadCrumb from '@/xt_pages/components/bread-crumb'
  133. import {getStockInList,getStockOutList} from "@/api/drug/drug_stock";
  134. import {getStockDrugCount} from "@/api/stock"
  135. export default {
  136. name: 'stockIn',
  137. created() {
  138. var nowDate = new Date();
  139. var nowYear = nowDate.getFullYear();
  140. var nowMonth = nowDate.getMonth() + 1;
  141. var nowDay = nowDate.getDate();
  142. this.end_time =
  143. nowYear +
  144. "-" +
  145. (nowMonth < 10 ? "0" + nowMonth : nowMonth) +
  146. "-" +
  147. (nowDay < 10 ? "0" + nowDay : nowDay);
  148. nowDate.setMonth(nowDate.getMonth() - 1);
  149. nowYear = nowDate.getFullYear();
  150. nowMonth = nowDate.getMonth() + 1;
  151. nowDay = nowDate.getDate();
  152. this.start_time =
  153. nowYear +
  154. "-" +
  155. (nowMonth < 10 ? "0" + nowMonth : nowMonth) +
  156. "-" +
  157. (nowDay < 10 ? "0" + nowDay : nowDay);
  158. this.getlist()
  159. this.getStockDrugCount()
  160. this.getStockOutList()
  161. this.packing_unit = this.$route.query.packing_unit
  162. },
  163. components: {
  164. BreadCrumb
  165. },
  166. data() {
  167. return {
  168. crumbs: [
  169. { path: false, name: '库存管理' },
  170. { path: '/stock/drugs/stock/query', name: '药品库存查询' },
  171. { path:'/drugstock/in/drugstockflow',name:'库存流水'}
  172. ],
  173. keywords: '',
  174. total: 0,
  175. multipleSelection: [],
  176. signAndWeighBoxPatients: 'sign-and-weigh-box-patients',
  177. start_time: '',
  178. end_time: '',
  179. page: 1,
  180. limit: 10,
  181. goodType: [],
  182. goodInfo: [],
  183. tempArr: [],
  184. sameRowArr: [],
  185. WarehouseInfo: {
  186. loading: false,
  187. warehouseInfoDate: []
  188. },
  189. tableData:[],
  190. drug_category:0,
  191. stock_type:0,
  192. drugCategory:[
  193. {id:0,name:"全部"}
  194. ],
  195. drugTypeList:[],
  196. tableList:[],
  197. manufacturerList:[],
  198. stockType:[
  199. {id:0,name:"全部"},
  200. {id:3,name:"手动出库"},
  201. {id:2,name:"自动出库"},
  202. {id:4,name:"采购入库"},
  203. ],
  204. countList:[],
  205. outCountList:[],
  206. autoCountList:[],
  207. keywords:"",
  208. obj:{},
  209. packing_unit:"",
  210. cancelCountList:[]
  211. }
  212. },
  213. methods:{
  214. handleSizeChange(val) {
  215. this.limit = val
  216. this.getlist()
  217. this.getStockOutList()
  218. },
  219. handleCurrentChange(val) {
  220. this.page = val
  221. this.getlist()
  222. this.getStockOutList()
  223. },
  224. startTimeChange: function(val) {
  225. this.tableList = []
  226. var time = this.getTimestamp(val) - this.getTimestamp(this.end_time);
  227. if (time > 0) {
  228. this.$message.error("开始时间不能大于结束时间");
  229. this.start_time = "";
  230. } else {
  231. this.getlist()
  232. this.getStockOutList()
  233. }
  234. },
  235. endTimeChange: function(val) {
  236. this.tableList = []
  237. var time = this.getTimestamp(val) - this.getTimestamp(this.start_time);
  238. if (time < 0) {
  239. this.$message.error("结束时间不能小于开始时间");
  240. this.end_time = "";
  241. } else {
  242. this.getlist()
  243. this.getStockOutList()
  244. }
  245. },
  246. getManufacturer(id){
  247. var name = ""
  248. for(let i=0;i<this.manufacturerList.length;i++){
  249. if(id == this.manufacturerList[i].id){
  250. name = this.manufacturerList[i].manufacturer_name
  251. }
  252. }
  253. return name
  254. },
  255. getTime(val) {
  256. if(val < 0){
  257. return ""
  258. }
  259. if(val == ""){
  260. return ""
  261. }else {
  262. return uParseTime(val, '{y}-{m}-{d}')
  263. }
  264. },
  265. //入库详情
  266. getlist(){
  267. var params= {
  268. limit:this.limit,
  269. page:this.page,
  270. id:this.$route.query.id,
  271. start_time:this.start_time,
  272. end_time:this.end_time,
  273. is_sys:this.stockType
  274. }
  275. getStockInList(params).then(response=>{
  276. if(response.data.state == 1){
  277. var list = response.data.data.list
  278. for(let i=0;i<list.length;i++){
  279. list[i].stock_way = 4
  280. this.tableList.push(list[i])
  281. }
  282. var total = response.data.data.total
  283. this.total = total
  284. console.log("入库数据",this.tableList)
  285. var manufacturerList = response.data.data.manufacturerList
  286. this.manufacturerList = manufacturerList
  287. }
  288. })
  289. },
  290. getStockOutList(){
  291. var params= {
  292. limit:this.limit,
  293. page:this.page,
  294. id:this.$route.query.id,
  295. start_time:this.start_time,
  296. end_time:this.end_time,
  297. is_sys:this.stock_type
  298. }
  299. getStockOutList(params).then(response=>{
  300. if(response.data.state == 1){
  301. var outList = response.data.data.outList
  302. console.log("outList990-0000990",outList)
  303. for(let i=0;i<outList.length;i++){
  304. if(outList[i].is_sys == 0){
  305. outList[i].stock_way = 3
  306. }
  307. if(outList[i].is_sys == 1){
  308. outList[i].stock_way = 2
  309. }
  310. this.tableList.push(outList[i])
  311. }
  312. var total = response.data.data.total
  313. this.total = total
  314. }
  315. })
  316. },
  317. getStockDrugCount(){
  318. var params ={
  319. keywords: this.keywords,
  320. start_time:this.start_time,
  321. end_time:this.end_time,
  322. }
  323. getStockDrugCount(params).then(response=>{
  324. if(response.data.state == 1){
  325. var count = response.data.data.count
  326. console.log("详情入库统计",count)
  327. this.countList = count
  328. var outlist = response.data.data.outList
  329. console.log("详情出库数量",outlist)
  330. this.outCountList = outlist
  331. var autoCount = response.data.data.autoCount
  332. console.log("详情自动出库",autoCount)
  333. this.autoCountList = autoCount
  334. var totalCount = response.data.data.totalCount
  335. console.log("totalcount",totalCount)
  336. this.cancelCountList = totalCount
  337. }
  338. })
  339. },
  340. getInCount(id){
  341. var count= ""
  342. for(let i=0;i<this.countList.length;i++){
  343. if(id == this.countList[i].good_id){
  344. count = this.countList[i].count
  345. }
  346. }
  347. return count
  348. },
  349. getOutCount(id){
  350. console.log("id222",id)
  351. var count = ""
  352. for(let i=0;i<this.outCountList.length;i++){
  353. if(id == this.outCountList[i].good_id){
  354. count = this.outCountList[i].count
  355. }
  356. }
  357. return count
  358. },
  359. getAutoCount(id){
  360. var count= ""
  361. for(let i=0;i<this.autoCountList.length;i++){
  362. if(id == this.autoCountList[i].good_id){
  363. count = this.autoCountList[i].count
  364. }
  365. }
  366. return count
  367. },
  368. getCancelCount(id){
  369. var count = 0
  370. for(let i=0;i<this.cancelCountList.length;i++){
  371. if(id == this.cancelCountList[i].good_id){
  372. count = this.cancelCountList[i].count
  373. }
  374. }
  375. return count
  376. },
  377. getTimestamp(time) {
  378. // 把时间日期转成时间戳
  379. return new Date(time).getTime() / 1000;
  380. },
  381. changeDrug(val){
  382. this.tableList= []
  383. if(val == 4 || val == 0){
  384. this.getlist()
  385. }
  386. if(val == 2 || val == 3 || val == 0){
  387. this.getStockOutList()
  388. }
  389. }
  390. }
  391. }
  392. </script>
  393. <style rel="stylesheet/css" lang="scss" scoped>
  394. .information {
  395. border: 1px #dcdfe6 solid;
  396. padding: 30px 20px 30px 20px;
  397. .border {
  398. border-bottom: 1px #dcdfe6 solid;
  399. margin: 0px 0 20px 0;
  400. }
  401. }
  402. .title {
  403. background: #409eff;
  404. height: 44px;
  405. line-height: 44px;
  406. padding: 0 0 0 10px;
  407. color: #fff;
  408. margin: 0 0 10px 0;
  409. }
  410. .edit_separater {
  411. border-top: 1px solid rgb(233, 233, 233);
  412. margin-top: 15px;
  413. margin-bottom: 15px;
  414. }
  415. </style>
  416. <style>
  417. .sign-and-weigh-box .sign-and-weigh-box-patients .cell {
  418. font-size: 12px;
  419. }
  420. .sign-and-weigh-box .sign-and-weigh-box-patients .current-row > td {
  421. background: #6fb5fa;
  422. }
  423. .count {
  424. color: #bd2c00;
  425. }
  426. .el-table td,
  427. .el-table th.is-leaf,
  428. .el-table--border,
  429. .el-table--group {
  430. border-color: #d0d3da;
  431. }
  432. .el-table--border::after,
  433. .el-table--group::after,
  434. .el-table::before {
  435. background-color: #d0d3da;
  436. }
  437. </style>