drugStockFlow.vue 16KB

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