<template> <div> <div v-show="showSearch"> <label class="title"><span class="name">仓库</span> :</label> <el-select size="small" v-model="storehouse_id" filterable placeholder="请选择仓库" style="width:200px" @change="changeStorehouse"> <el-option v-for="(option, index) in houseList" :key="index" :label="option.storehouse_name" :value="option.id"> </el-option> </el-select> </div> <div> <div style="margin-top:20px">日期:{{nowTime}} 盘点人:{{user_name}}</div> <div style="float:right;margin-bottom:10px"><el-button type="primary" @click="saveInentoryList">保存</el-button></div> <el-table :data="tableData" border :header-cell-style="{ backgroundColor: 'rgb(245, 247, 250)' }" style="width:100%"> <el-table-column prop="date" label="药品名称" width="150" align="center"> <template slot-scope="scope"> {{scope.row.drug_name}} </template> </el-table-column> <el-table-column prop="name" label="规格" width="100" align="center"> <template slot-scope="scope"> {{scope.row.specification_name}} </template> </el-table-column> <el-table-column prop="name" label="入库单号" width="100" align="center"> <template slot-scope="scope"> {{scope.row.warehousing_order}} </template> </el-table-column> <el-table-column prop="name" label="有效期" width="100" align="center"> <template slot-scope="scope"> {{getTime(scope.row.expiry_date)}} </template> </el-table-column> <el-table-column prop="name" label="批号" width="100" align="center"> <template slot-scope="scope"> {{scope.row.batch_number}} </template> </el-table-column> <el-table-column prop="name" label="进货价" width="100" align="center"> <template slot-scope="scope"> {{scope.row.price}} </template> </el-table-column> <el-table-column prop="name" label="生产厂商" width="100" align="center"> <template slot-scope="scope"> {{scope.row.manufacturer_name}} </template> </el-table-column> <el-table-column prop="name" label="仓库名称" width="100" align="center"> <template slot-scope="scope"> {{getHouseName(scope.row.storehouse_id)}} </template> </el-table-column> <el-table-column prop="name" label="盘点前数量" width="180" align="center"> <template slot-scope="scope"> <span><el-input style="width:100px" v-model="scope.row.stock_max_number" :disabled="true"></el-input>{{scope.row.max_unit}}</span> <span v-if="scope.row.XtBaseDrug.max_unit!=scope.row.XtBaseDrug.min_unit"><el-input style="width:100px" v-model="scope.row.stock_min_number" :disabled="true"></el-input>{{scope.row.min_unit}}</span> </template> </el-table-column> <el-table-column prop="name" label="盘点后数量" width="180" align="center"> <template slot-scope="scope"> <el-input style="width:100px" v-model="scope.row.last_stock_max_number"></el-input>{{scope.row.max_unit}} <span v-if="scope.row.XtBaseDrug.max_unit!=scope.row.XtBaseDrug.min_unit"><el-input style="width:100px" v-model="scope.row.last_stock_min_number"></el-input>{{scope.row.min_unit}}</span> </template> </el-table-column> <el-table-column prop="name" label="盘点原因" width="180" align="center"> <template slot-scope="scope"> <el-select v-model="scope.row.type" placeholder="请选择"> <el-option v-for="item in reasonList" :key="item.id" :label="item.name" :value="item.id"> </el-option> </el-select> </template> </el-table-column> <el-table-column prop="name" width="200" align="center"> <template slot-scope="scope"> <span><el-button type="danger" @click="toDelete(scope.$index,scope.row.drug_id)">不盘点此批次</el-button></span> </template> </el-table-column> </el-table> </div> </div> </template> <script> import { uParseTime } from '@/utils/tools' import { postSearchDrugWarehouseList,saveDrugInventory,getDrugInventoryList,SaveDrugCheckedInventory,getDrugInventoryDetail,modifyInventory,SaveDrugProofInventory,getDrugWarehouseInfoTotal,deleteDrugInventory,saveInentoryList,getDrugInventoryWarehouseInfoList} from "@/api/drug/drug" import { getDrugBatchNumber } from "@/api/drug/drug_stock" import { getDataConfig } from '@/utils/data' const moment = require("moment"); export default { name: "drugInventory", data() { return{ nowTime: moment(new Date()).format("YYYY-MM-DD HH:MM:SS"), user_name:this.$store.getters.xt_user.user.user_name, searchKey:'', value1:'', value2:'', tableData: [], dialogVisible:false, form: { id:"", drug_name: '', retail_price :'', new_price:"", count:"", remark:"", warehousing_order:"", manufacturer:"", dealer:"", number:"", warehousing_unit:"", specification_name:"", buy_price:"", drug_id:"", packing_unit:"", drug_origin_place:"", report_count:"", total:"", dose:"", dose_unit:"", min_number:"", min_unit:"", max_unit:"", last_price:"", batch_number:"", product_date:"", expiry_date:"", warehouse_info_id:"", proof_count:"", min_count:"", min_unit:"", storehouse_id:"", }, total: 0, editdialogVisible:false, limit:10, page:1, start_time:"", end_time:"", tableList:[], doctorList:[], checkDialogVisible:false, ids:"", checker:this.$store.getters.xt_user.user.id, check_time:new Date(), id:"", modifydialogVisible:false, numberList:[], profdialogVisible:false, index:"", unitList:[], reasonList:[ {id:6,name:"默认"}, {id:1,name:"到期退货"}, {id:2,name:"异常退货"}, {id:3,name:"退货"}, {id:4,name:"损坏"}, {id:5,name:"不计入报损分析"}, {id:7,name:"有效期到期"}, ], activeNames: [0,1,2,3,4,5,6,7,8,9,10], showTable:false, showSearch:true, inventory_total:0, WarehouseList:[], showTableOne:false, panShow:true, panOneShow:true, houseList:[], storehouse_id:"", } }, methods:{ changeNumber(val){ this.form.warehouse_info_id = val this.getDrugWarehouseInfoTotal(val) }, search(){ this.getlist() }, print(){ if(this.ids == ""){ this.$message.error("请勾选打印数据") return false } this.$router.push({path:'/stock/drugs/inventoryPrint?ids='+this.ids}) }, handleSizeChange(val){ this.limit = val this.getlist() }, handleCurrentChange(val){ this.page = val this.getlist() }, querySearchAsync(keyword, cb) { let key = ''; if (keyword != undefined) { key = keyword } var params = { keyword:key, storehouse_id:this.storehouse_id, } postSearchDrugWarehouseList(params).then(response => { if (response.data.state == 1) { var list = response.data.data.list // console.log("列表数据",list) this.drugList = list var manufacturerList = response.data.data.manufacturerList this.manufacturerList = manufacturerList var dealer = response.data.data.dealerList this.dealerList = dealer for(let i=0;i<this.drugList.length;i++){ for(let j=0;j<this.manufacturerList.length;j++){ if(this.drugList[i].manufacturer == this.manufacturerList[j].id){ this.drugList[i].manufacturer = this.manufacturerList[j].manufacturer_name } } } for(let i=0;i<this.drugList.length;i++){ for(let j=0;j<this.dealerList.length;j++){ if(this.drugList[i].dealer == this.dealerList[j].id){ this.drugList[i].dealer = this.dealerList[j].dealer_name } } } cb(this.drugList) } else { cb([]) } }) }, getTime(val) { if(val < 0){ return "" } if(val == ""){ return "" }else { return uParseTime(val, '{y}-{m}-{d}') } }, getTotal(total,max_unit,min_unit,min_number){ var str = "" var min_str = "" if(total<min_number){ str = "" min_str = total + min_unit } if(total >= min_number){ if(parseInt(total/min_number)!=0){ str = parseInt(total/min_number)+ max_unit } if((total%min_number)!=0){ min_str = total%min_number + min_unit } } return str + min_str }, addInventory(){ if(this.form.drug_name == ""){ this.$message.error("请输入药品名称") return } if(this.form.batch_number == undefined){ this.$message.error("请选择批次") return } if(this.form.count == ""){ this.$message.error("请输入盘点数量") return } if(this.form.min_count == ""){ this.form.min_count = 0 } var obj = { drug_id:this.form.drug_id, drug_name:this.form.drug_name, warehousing_unit:this.form.warehousing_unit, count:this.form.count, min_count:this.form.min_count, min_unit:this.form.min_unit, retail_price:this.form.retail_price.toString(), manufacturer:this.form.manufacturer, drug_origin_place:this.form.drug_origin_place, remark:this.form.remark, new_price:this.form.new_price.toString(), warehousing_order:this.form.warehousing_order, dealer:this.form.dealer, last_price:this.form.last_price, start_time:this.getTime(new Date()), number:this.form.number, total:this.form.total, specification_name:this.form.specification_name, batch_number:this.form.batch_number, expiry_date:this.form.expiry_date, product_date:this.form.product_date, warehouse_info_id:this.form.warehouse_info_id, } this.tableData.push(obj) this.form.drug_name = "" this.form.warehousing_unit = "" this.form.count = "" this.form.retail_price = "" this.form.manufacturer = "" this.form.drug_origin_place = "" this.form.number = "" this.form.remark = "" this.form.new_price = "" this.form.warehousing_order = "" this.form.dealer = "" this.form.last_price = "" this.form.number = "" this.form.total = "" this.form.specification_name = "" this.form.batch_number = "" this.form.expiry_date = "" this.form.product_date = "" }, toEdit(val,index){ this.form.id= val.id this.form.drug_id = val.drug_id, this.form.drug_name = val.drug_name this.form.retail_price = val.retail_price this.form.warehousing_order = val.warehousing_order this.form.number = val.number this.form.dealer = val.dealer this.form.manufacturer = val.manufacturer this.form.remark = val.remark this.form.warehousing_unit = val.warehousing_unit this.form.total = val.total this.form.batch_number = val.batch_number this.form.last_price = val.last_price this.form.specification_name = val.specification_name this.form.expiry_date = val.expiry_date this.form.product_date =val.product_date this.form.count = val.count this.form.min_count = val.min_count this.form.min_unit = val.min_unit this.index = index this.editdialogVisible = true }, saveInventory(){ for(let i=0;i<this.tableData.length;i++){ if(this.form.id == this.tableData[i].id){ this.tableData[i].drug_id = this.form.drug_id this.tableData[i].drug_name = this.form.drug_name this.tableData[i].retail_price = this.form.retail_price this.tableData[i].warehousing_order = this.form.warehousing_order this.tableData[i].number = this.form.number this.tableData[i].dealer = this.form.dealer this.tableData[i].manufacturer = this.form.manufacturer this.tableData[i].remark = this.form.remark this.tableData[i].warehouseing_unit = this.form.warehousing_unit this.tableData[i].total = this.form.total this.tableData[i].batch_number = this.form.batch_number this.tableData[i].last_price = this.form.last_price this.tableData[i].specification_name = this.form.specification_name this.tableData[i].expiry_date = this.form.expiry_date this.tableData[i].product_date = this.form.product_date this.tableData[i].count =this.form.count this.tableData[i].min_unit = this.form.min_unit this.tableData[i].min_count = this.form.min_count } if(this.index == i){ this.tableData[i].drug_id = this.form.drug_id this.tableData[i].drug_name = this.form.drug_name this.tableData[i].retail_price = this.form.retail_price this.tableData[i].warehousing_order = this.form.warehousing_order this.tableData[i].number = this.form.number this.tableData[i].dealer = this.form.dealer this.tableData[i].manufacturer = this.form.manufacturer this.tableData[i].remark = this.form.remark this.tableData[i].warehouseing_unit = this.form.warehousing_unit this.tableData[i].total = this.form.total this.tableData[i].batch_number = this.form.batch_number this.tableData[i].last_price = this.form.last_price this.tableData[i].specification_name = this.form.specification_name this.tableData[i].expiry_date = this.form.expiry_date this.tableData[i].product_date = this.form.product_date this.tableData[i].count =this.form.count this.tableData[i].min_unit = this.form.min_unit this.tableData[i].min_count = this.form.min_count } } this.editdialogVisible = false }, saveDrugInventory(){ for(let i=0;i<this.tableData.length;i++){ this.tableData[i].retail_price = this.tableData[i].retail_price.toString() this.tableData[i].last_price = this.tableData[i].last_price.toString() this.tableData[i].count = parseInt(this.tableData[i].count) this.tableData[i].min_count = parseInt(this.tableData[i].min_count) if(this.tableData[i].expiry_date == undefined){ this.tableData[i].expiry_date = 0 }else{ this.tableData[i].expiry_date = this.tableData[i].expiry_date } if( this.tableData[i].product_date == undefined){ this.tableData[i].product_date = 0 }else{ this.tableData[i].product_date = this.tableData[i].product_date } if(this.tableData[i].dealer == 0){ this.tableData[i].dealer = "" } if(this.tableData[i].manufacturer == 0){ this.tableData[i].manufacturer = "" } if(this.tableData[i].batch_number == undefined){ this.tableData[i].batch_number = "" } } var params = { tableData:this.tableData } saveDrugInventory(params).then(response=>{ if(response.data.state == 1){ var msg = response.data.data.msg this.$message.success("保存成功") this.getlist() this.editdialogVisible = false this.dialogVisible = false } }) }, getlist(){ var params = { limit:this.limit, page:this.page, keyword:this.searchKey, start_time:this.start_time, end_time:this.end_time, } getDrugInventoryList(params).then(response=>{ if(response.data.state == 1){ this.total = response.data.data.total this.tableList = [] this.tableList = response.data.data.list this.doctorList =[] this.doctorList = response.data.data.doctorList this.houseList = [] this.houseList = response.data.data.houseList this.storehouse_id = response.data.data.houseConfig.drug_storehouse_out this.getDrugInventoryWarehouseInfoList() } }) }, getDoctorName(id){ var name = "" for(let i=0;i<this.doctorList.length;i++){ if(id == this.doctorList[i].admin_user_id){ name = this.doctorList[i].user_name } } return name }, changePrice(val){ var arr = [] for(let i=0;i<val.length;i++){ arr.push(val[i].id) } var str = arr.join(",") this.ids = str }, toCheck(){ if(this.ids.length <=0){ this.$message.error("请勾选核对数据") return }else{ this.checkDialogVisible = true } }, SaveDrugCheckedInventory(){ var params = { ids:this.ids, check_time:this.getTime(this.check_time), checker:this.checker, } SaveDrugCheckedInventory(params).then(response=>{ if(response.data.state == 1){ this.$message.success("保存成功") var msg = response.data.data.msg this.checkDialogVisible = false this.tableData = [] this.getlist() } }) }, editInventory(id,check_status){ if(check_status == 1){ this.$message.error("已核对不能编辑") return false } getDrugInventoryDetail(id).then(response=>{ if(response.data.state == 1){ var detail = response.data.data.detail this.id = detail.id this.form.drug_id = detail.drug_id this.form.drug_name = detail.drug_name this.form.specification_name = detail.specification_name this.form.retail_price = detail.retail_price this.form.warehousing_order =detail.warehousing_order this.form.number = detail.number this.form.manufacturer = detail.manufacturer this.form.remark = detail.remark this.form.warehousing_unit = detail.warehousing_unit this.form.total = detail.total this.form.last_price = detail.last_price this.form.count = parseInt(detail.count) this.form.drug_origin_place = detail.drug_origin_place this.form.stock_max_number = detail.stock_max_number this.form.stock_min_number = detail.stock_min_number this.form.warehouse_info_id = detail.warehouse_info_id this.form.min_unit = detail.min_unit this.form.min_count = detail.min_count this.modifydialogVisible = true } }) }, modifyInventory(){ var params = { id:this.id, drug_id:this.form.drug_id, drug_name:this.form.drug_name, specification_name:this.form.specification_name, warehousing_unit:this.form.warehousing_unit, last_price:this.form.last_price, retail_price:this.form.retail_price, count:parseInt(this.form.count), total:this.form.total, drug_origin_place:this.form.drug_origin_place, batch_number:this.form.batch_number, manufacturer:this.form.manufacturer, remark:this.form.remark, stock_max_number:this.form.stock_max_number, stock_min_number:this.form.stock_min_number, warehouse_info_id:this.form.warehouse_info_id, min_count:parseInt(this.form.min_count), min_unit:this.form.min_unit, } modifyInventory(params).then(response=>{ if(response.data.state == 1){ var inventory = response.data.data.inventory this.modifydialogVisible = false this.getlist() } }) }, deleteDrugInventory(id,check_status,index){ if(check_status == 1){ this.$message.error("已核对的不能编辑") return } this.$confirm('是否删除所选内容?', '提示', { confirmButtonText: '确定', cancelButtonText: '取消', type: 'warning' }).then(() => { deleteDrugInventory(id).then(response => { if (response.data.state == 1) { var msg = response.data.data.msg this.$message.success("保存成功") this.tableList.splice(index,1) } }) }).catch(() => { this.loading = false }); }, toMove(item,index){ this.$confirm('此操作将移除药品整个批次, 是否继续?', '提示', { confirmButtonText: '确定', cancelButtonText: '取消', type: 'warning' }).then(() => { this.tableData.splice(index,1) this.WarehouseList = [] this.activeNames = [0,1,2,3,4,5,6,7,8,9,10] }).catch(() => { this.loading = false }); }, toDelete(index,drug_id){ for(let i=0;i<this.tableData.length;i++){ if(drug_id == this.tableData[i].drug_id){ this.tableData.splice(index,1) } } }, getDrugBatchNumber(id){ var params = { id:id } getDrugBatchNumber(params).then(response=>{ if(response.data.state == 1){ var list = response.data.data.list this.numberList = list } }) }, toProof(id){ getDrugInventoryDetail(id).then(response=>{ if(response.data.state == 1){ var detail = response.data.data.detail this.id = detail.id this.form.drug_id = detail.drug_id this.form.drug_name = detail.drug_name this.form.specification_name = detail.specification_name this.form.retail_price = detail.retail_price this.form.warehousing_order =detail.warehousing_order this.form.number = detail.number this.form.manufacturer = detail.manufacturer this.form.remark = detail.remark this.form.warehousing_unit = detail.warehousing_unit this.form.total = detail.total this.form.last_price = detail.last_price this.form.count = parseInt(detail.count) this.form.drug_origin_place = detail.drug_origin_place this.form.warehouse_info_id = detail.warehouse_info_id this.profdialogVisible = true } }) }, proofInventory(){ var params = { id:this.id, warehouseing_unit:this.form.warehousing_unit, warehouse_info_id:this.form.warehouse_info_id, total:this.total.toString(), remark:this.remark, proof_count:parseInt(this.form.proof_count), } SaveDrugProofInventory(params).then(response=>{ if(response.data.state == 1){ var inventory = response.data.data.inventory this.profdialogVisible = false this.getlist() } }) }, changeStartTime(val){ this.start_time = this.getTime(val) this.getlist() }, changeEndTime(val){ this.end_time = this.getTime(val) this.getlist() }, getDrugWarehouseInfoTotal(val){ var params = { id:val, } getDrugWarehouseInfoTotal(params).then(response=>{ if(response.data.state == 1){ var list = response.data.data.list var max_total = 0 var min_total = 0 for(let i=0;i<list.length;i++){ max_total += list[i].stock_max_number min_total +=list[i].stock_min_number } if(max_total >0 ){ this.form.total = max_total + list[0].XtBaseDrug.max_unit } if(min_total > 0){ this.form.total = this.form.total + min_total + list[0].XtBaseDrug.min_unit } } }) }, getDataConfig(module, filed_name) { return getDataConfig(module, filed_name) }, changeMaxUnit(val){ this.form.warehousing_unit = val }, saveInentoryList(){ for(let i=0;i<this.tableData.length;i++){ if(this.tableData[i].last_stock_max_number == ""){ this.tableData[i].last_stock_max_number = 0 } if(this.tableData[i].last_stock_min_number == ""){ this.tableData[i].last_stock_min_number = 0 } this.tableData[i].last_stock_max_number = parseInt(this.tableData[i].last_stock_max_number) this.tableData[i].last_stock_min_number = parseInt(this.tableData[i].last_stock_min_number) this.tableData[i].storehouse_id = this.storehouse_id } var arr = [] for(let i=0;i<this.tableData.length;i++){ if((this.tableData[i].stock_max_number!=this.tableData[i].last_stock_max_number) || (this.tableData[i].stock_min_number!=this.tableData[i].last_stock_min_number)){ arr.push(this.tableData[i]) } } if(arr.length == 0){ this.$message.error("请修改数据后保存!") loading.close() return false } var params = { tableData:arr } console.log("arr23233232w",arr) const loading = this.$loading({ lock: true, text: 'Loading', spinner: 'el-icon-loading', background: 'rgba(0, 0, 0, 0.7)' }) saveInentoryList(params).then(response=>{ if(response.data.state == 1){ var inventory = response.data.data.inventory loading.close() this.$message.success("保存成功") this.WarehouseList = [] this.tableData = [] this.getDrugInventoryWarehouseInfoList() } }) }, getHouseName(id){ var storehouse_name = "" for(let i=0;i<this.houseList.length;i++){ if(id == this.houseList[i].id){ storehouse_name = this.houseList[i].storehouse_name } } return storehouse_name }, changeStorehouse(){ this.getDrugInventoryWarehouseInfoList() }, getDrugInventoryWarehouseInfoList(){ var params = { storehouse_id:this.storehouse_id, } console.log("params222222wo",params) const loading = this.$loading({ lock: true, text: 'Loading', spinner: 'el-icon-loading', background: 'rgba(0, 0, 0, 0.7)' }) getDrugInventoryWarehouseInfoList(params).then(response=>{ if(response.data.state == 1){ loading.close() var list = response.data.data.list this.manufacturerList = [] this.manufacturerList = response.data.data.manufacturerList for(let i=0;i<list.length;i++){ if(list[i].XtBaseDrug.max_unit == list[i].XtBaseDrug.min_unit){ list[i].stock_max_number += list[i].stock_min_number list[i].stock_min_number = 0 } list[i].drug_name = list[i].XtBaseDrug.drug_name list[i].specification_name = list[i].XtBaseDrug.dose +list[i].XtBaseDrug.dose_unit + "*"+list[i].XtBaseDrug.min_number +list[i].XtBaseDrug.min_unit+"/"+list[i].XtBaseDrug.max_unit list[i].warehouseing_unit = list[i].max_unit list[i].max_unit = list[i].XtBaseDrug.max_unit list[i].min_unit = list[i].XtBaseDrug.min_unit list[i].last_stock_max_number = "" list[i].last_stock_min_number = "" list[i].min_number = list[i].XtBaseDrug.min_number list[i].manufacturer_name = "" // list[i].type = 4 list[i].last_stock_max_number = list[i].stock_max_number list[i].last_stock_min_number = list[i].stock_min_number for(let j=0;j<this.manufacturerList.length;j++){ if(list[i].manufacturer == this.manufacturerList[j].id){ list[i].manufacturer_name = this.manufacturerList[j].manufacturer_name } } } this.tableData = [] this.tableData = list } }) } }, created(){ this.unitList = this.getDataConfig('hemodialysis','units') this.getlist() }, mounted() { }, }; </script> <style lang="scss"> .addDrugsDialog { .el-dialog__body { padding-top: 0px; } .noMargin{ .el-form-item__content{ margin-left: 0 !important; } } } </style>