drugStockFlow.vue 16KB

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