inventory.vue 35KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886887888889890891892893894895896897898899900901902903904905906907908909910911912913914915916917918919920921922923924925926927928929930931932933934935936
  1. <template>
  2. <div>
  3. <div v-show="showSearch">
  4. <label class="title"><span class="name">仓库</span> :</label>
  5. <el-select size="small" v-model="storehouse_id" filterable placeholder="请选择仓库" style="width:200px">
  6. <el-option
  7. v-for="(option, index) in houseList"
  8. :key="index"
  9. :label="option.storehouse_name"
  10. :value="option.id">
  11. </el-option>
  12. </el-select>
  13. <el-autocomplete
  14. class="checkSearch"
  15. popper-class="my-autocomplete"
  16. v-model="form.drug_name"
  17. :fetch-suggestions="querySearchAsync"
  18. :trigger-on-focus="true"
  19. placeholder="请输入药品名称"
  20. @select="handleSelect"
  21. style="width:300px;"
  22. >
  23. <i class="el-icon-search el-input__icon" slot="suffix"></i>
  24. <template slot-scope="{ item }">
  25. <div class="name">{{ item.drug_name + item.dose + item.dose_unit + "*" +item.min_number + item.min_unit +"/" + item.max_unit + " "+item.manufacturer}}</div>
  26. </template>
  27. </el-autocomplete>
  28. </div>
  29. <div v-show="showTable">
  30. <div>日期:{{nowTime}} 盘点人:{{user_name}}</div>
  31. <div style="float:right;margin-bottom:10px"><el-button type="primary" @click="saveInentoryList">保存</el-button></div>
  32. <el-collapse v-model="activeNames">
  33. <el-collapse-item :name="index" v-for="(item,index) in tableData" :key="index">
  34. <template slot="title">
  35. <div style="font-size:16px">{{item.drug_name}}</div> &nbsp;&nbsp;{{item.specification_name}} <el-button type="warning" icon="el-icon-remove" style="margin-left:20px;" @click="toMove(item,index)">移除</el-button>
  36. </template>
  37. <el-table :data="item.child" border :header-cell-style="{ backgroundColor: 'rgb(245, 247, 250)' }" style="width:100%">
  38. <el-table-column prop="date" label="药品名称" width="150" align="center">
  39. <template slot-scope="scope">
  40. {{scope.row.drug_name}}
  41. </template>
  42. </el-table-column>
  43. <el-table-column prop="name" label="规格" width="100" align="center">
  44. <template slot-scope="scope">
  45. {{scope.row.specification_name}}
  46. </template>
  47. </el-table-column>
  48. <el-table-column prop="name" label="入库单号" width="100" align="center">
  49. <template slot-scope="scope">
  50. {{scope.row.warehousing_order}}
  51. </template>
  52. </el-table-column>
  53. <el-table-column prop="name" label="有效期" width="100" align="center">
  54. <template slot-scope="scope">
  55. {{getTime(scope.row.expiry_date)}}
  56. </template>
  57. </el-table-column>
  58. <el-table-column prop="name" label="批号" width="100" align="center">
  59. <template slot-scope="scope">
  60. {{scope.row.batch_number}}
  61. </template>
  62. </el-table-column>
  63. <el-table-column prop="name" label="进货价" width="100" align="center">
  64. <template slot-scope="scope">
  65. {{scope.row.price}}
  66. </template>
  67. </el-table-column>
  68. <el-table-column prop="name" label="生产厂商" width="100" align="center">
  69. <template slot-scope="scope">
  70. {{scope.row.manufacturer_name}}
  71. </template>
  72. </el-table-column>
  73. <el-table-column prop="name" label="仓库名称" width="100" align="center">
  74. <template slot-scope="scope">
  75. {{getHouseName(scope.row.storehouse_id)}}
  76. </template>
  77. </el-table-column>
  78. <el-table-column prop="name" label="盘点前数量" width="180" align="center">
  79. <template slot-scope="scope">
  80. <span><el-input style="width:100px" v-model="scope.row.stock_max_number" :disabled="true"></el-input>{{scope.row.max_unit}}</span>
  81. <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>
  82. </template>
  83. </el-table-column>
  84. <el-table-column prop="name" label="盘点后数量" width="180" align="center">
  85. <template slot-scope="scope">
  86. <el-input style="width:100px" v-model="scope.row.last_stock_max_number"></el-input>{{scope.row.max_unit}}
  87. <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>
  88. </template>
  89. </el-table-column>
  90. <el-table-column prop="name" label="盘点原因" width="180" align="center">
  91. <template slot-scope="scope">
  92. <el-select v-model="scope.row.type" placeholder="请选择">
  93. <el-option
  94. v-for="item in reasonList"
  95. :key="item.id"
  96. :label="item.name"
  97. :value="item.id">
  98. </el-option>
  99. </el-select>
  100. </template>
  101. </el-table-column>
  102. <el-table-column prop="name" width="200" align="center">
  103. <template slot-scope="scope">
  104. <span><el-button type="danger" @click="toDelete(scope.$index,scope.row.drug_id)">不盘点此批次</el-button></span>
  105. </template>
  106. </el-table-column>
  107. </el-table>
  108. </el-collapse-item>
  109. <label class="title"><span class="name">仓库</span> :</label>
  110. <el-select size="small" v-model="storehouse_id" filterable placeholder="请选择仓库" style="width:200px">
  111. <el-option
  112. v-for="(option, index) in houseList"
  113. :key="index"
  114. :label="option.storehouse_name"
  115. :value="option.id">
  116. </el-option>
  117. </el-select>
  118. <el-autocomplete
  119. class="checkSearch"
  120. popper-class="my-autocomplete"
  121. v-model="form.drug_name"
  122. :fetch-suggestions="querySearchAsync"
  123. :trigger-on-focus="true"
  124. placeholder="请输入药品名称"
  125. @select="handleSelect"
  126. style="width:300px;"
  127. v-show="showTableOne"
  128. >
  129. <i class="el-icon-search el-input__icon" slot="suffix"></i>
  130. <template slot-scope="{ item }">
  131. <div class="name">{{ item.drug_name + item.dose + item.dose_unit + "*" +item.min_number + item.min_unit +"/" + item.max_unit + " "+item.manufacturer}}</div>
  132. </template>
  133. </el-autocomplete>
  134. </el-collapse>
  135. </div>
  136. </div>
  137. </template>
  138. <script>
  139. import { uParseTime } from '@/utils/tools'
  140. import { postSearchDrugWarehouseList,getDrugWarehouseInfoList,saveDrugInventory,getDrugInventoryList,SaveDrugCheckedInventory,getDrugInventoryDetail,modifyInventory,SaveDrugProofInventory,getDrugWarehouseInfoTotal,deleteDrugInventory,saveInentoryList} from "@/api/drug/drug"
  141. import { getDrugBatchNumber } from "@/api/drug/drug_stock"
  142. import { getDataConfig } from '@/utils/data'
  143. const moment = require("moment");
  144. export default {
  145. name: "drugInventory",
  146. data() {
  147. return{
  148. nowTime: moment(new Date()).format("YYYY-MM-DD HH:MM:SS"),
  149. user_name:this.$store.getters.xt_user.user.user_name,
  150. searchKey:'',
  151. value1:'',
  152. value2:'',
  153. tableData: [],
  154. dialogVisible:false,
  155. form: {
  156. id:"",
  157. drug_name: '',
  158. retail_price :'',
  159. new_price:"",
  160. count:"",
  161. remark:"",
  162. warehousing_order:"",
  163. manufacturer:"",
  164. dealer:"",
  165. number:"",
  166. warehousing_unit:"",
  167. specification_name:"",
  168. buy_price:"",
  169. drug_id:"",
  170. packing_unit:"",
  171. drug_origin_place:"",
  172. report_count:"",
  173. total:"",
  174. dose:"",
  175. dose_unit:"",
  176. min_number:"",
  177. min_unit:"",
  178. max_unit:"",
  179. last_price:"",
  180. batch_number:"",
  181. product_date:"",
  182. expiry_date:"",
  183. warehouse_info_id:"",
  184. proof_count:"",
  185. min_count:"",
  186. min_unit:"",
  187. storehouse_id:"",
  188. },
  189. total: 0,
  190. editdialogVisible:false,
  191. limit:10,
  192. page:1,
  193. start_time:"",
  194. end_time:"",
  195. tableList:[],
  196. doctorList:[],
  197. checkDialogVisible:false,
  198. ids:"",
  199. checker:this.$store.getters.xt_user.user.id,
  200. check_time:new Date(),
  201. id:"",
  202. modifydialogVisible:false,
  203. numberList:[],
  204. profdialogVisible:false,
  205. index:"",
  206. unitList:[],
  207. reasonList:[
  208. {id:6,name:"默认"},
  209. {id:1,name:"到期退货"},
  210. {id:2,name:"异常退货"},
  211. {id:3,name:"退货"},
  212. {id:4,name:"损坏"},
  213. {id:5,name:"不计入报损分析"},
  214. {id:7,name:"有效期到期"},
  215. ],
  216. activeNames: [0,1,2,3,4,5,6,7,8,9,10],
  217. showTable:false,
  218. showSearch:true,
  219. inventory_total:0,
  220. WarehouseList:[],
  221. showTableOne:false,
  222. panShow:true,
  223. panOneShow:true,
  224. houseList:[],
  225. storehouse_id:"",
  226. }
  227. },
  228. methods:{
  229. changeNumber(val){
  230. this.form.warehouse_info_id = val
  231. this.getDrugWarehouseInfoTotal(val)
  232. },
  233. search(){
  234. this.getlist()
  235. },
  236. print(){
  237. if(this.ids == ""){
  238. this.$message.error("请勾选打印数据")
  239. return false
  240. }
  241. this.$router.push({path:'/stock/drugs/inventoryPrint?ids='+this.ids})
  242. },
  243. handleSizeChange(val){
  244. this.limit = val
  245. this.getlist()
  246. },
  247. handleCurrentChange(val){
  248. this.page = val
  249. this.getlist()
  250. },
  251. querySearchAsync(keyword, cb) {
  252. let key = '';
  253. if (keyword != undefined) {
  254. key = keyword
  255. }
  256. var params = {
  257. keyword:key,
  258. storehouse_id:this.storehouse_id,
  259. }
  260. postSearchDrugWarehouseList(params).then(response => {
  261. if (response.data.state == 1) {
  262. var list = response.data.data.list
  263. // console.log("列表数据",list)
  264. this.drugList = list
  265. var manufacturerList = response.data.data.manufacturerList
  266. this.manufacturerList = manufacturerList
  267. var dealer = response.data.data.dealerList
  268. this.dealerList = dealer
  269. for(let i=0;i<this.drugList.length;i++){
  270. for(let j=0;j<this.manufacturerList.length;j++){
  271. if(this.drugList[i].manufacturer == this.manufacturerList[j].id){
  272. this.drugList[i].manufacturer = this.manufacturerList[j].manufacturer_name
  273. }
  274. }
  275. }
  276. for(let i=0;i<this.drugList.length;i++){
  277. for(let j=0;j<this.dealerList.length;j++){
  278. if(this.drugList[i].dealer == this.dealerList[j].id){
  279. this.drugList[i].dealer = this.dealerList[j].dealer_name
  280. }
  281. }
  282. }
  283. cb(this.drugList)
  284. } else {
  285. cb([])
  286. }
  287. })
  288. },
  289. handleSelect(val){
  290. var drugIds = []
  291. for(let i=0;i<this.tableData.length;i++){
  292. drugIds.push(this.tableData[i].drug_id)
  293. }
  294. var strId = drugIds.join(",")
  295. if (strId.indexOf(val.drug_id)!=-1){
  296. this.$message.error("不能添加重复药品!")
  297. return
  298. }
  299. var params = {
  300. id:val.drug_id,
  301. storehouse_id:this.storehouse_id,
  302. }
  303. getDrugWarehouseInfoList(params).then(response=>{
  304. if(response.data.state == 1){
  305. var list = response.data.data.list
  306. for(let i=0;i<list.length;i++){
  307. if(list[i].XtBaseDrug.max_unit == list[i].XtBaseDrug.min_unit){
  308. list[i].stock_max_number += list[i].stock_min_number
  309. list[i].stock_min_number = 0
  310. this.panShow = false
  311. this.panOneShow = false
  312. }
  313. list[i].drug_name = list[i].XtBaseDrug.drug_name
  314. 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
  315. list[i].warehouseing_unit = list[i].max_unit
  316. list[i].max_unit = list[i].XtBaseDrug.max_unit
  317. list[i].min_unit = list[i].XtBaseDrug.min_unit
  318. list[i].last_stock_max_number = ""
  319. list[i].last_stock_min_number = ""
  320. list[i].min_number = list[i].XtBaseDrug.min_number
  321. list[i].manufacturer_name = ""
  322. list[i].type = 6
  323. for(let j=0;j<this.manufacturerList.length;j++){
  324. if(list[i].manufacturer == this.manufacturerList[j].id){
  325. list[i].manufacturer_name = this.manufacturerList[j].manufacturer_name
  326. }
  327. }
  328. this.WarehouseList.push(list[i])
  329. }
  330. console.log("lisrt2332323223322323232323",list)
  331. let objInfo = {}
  332. this.WarehouseList.forEach((item,index)=>{
  333. let { drug_id } = item
  334. if(!objInfo[drug_id]){
  335. objInfo[drug_id] = {
  336. drug_id,
  337. child:[],
  338. drug_name:item.drug_name,
  339. specification_name:item.specification_name,
  340. warehouseing_unit:item.max_unit,
  341. price:item.price,
  342. max_unit:item.max_unit,
  343. min_unit:item.min_unit,
  344. batch_number:item.batch_number,
  345. expiry_date:item.expiry_date,
  346. type:0,
  347. }
  348. }
  349. })
  350. let newList = Object.values(objInfo);
  351. for(let i=0;i<this.WarehouseList.length;i++){
  352. for(let j=0;j<newList.length;j++){
  353. if(this.WarehouseList[i].drug_id == newList[j].drug_id){
  354. newList[j].child.push(this.WarehouseList[i])
  355. }
  356. }
  357. }
  358. this.tableData = newList
  359. this.showSearch = false
  360. this.showTable = true
  361. if(this.tableData.length >=1){
  362. this.showTableOne = true
  363. }
  364. this.inventory_total = this.tableData.length
  365. }
  366. })
  367. },
  368. getTime(val) {
  369. if(val < 0){
  370. return ""
  371. }
  372. if(val == ""){
  373. return ""
  374. }else {
  375. return uParseTime(val, '{y}-{m}-{d}')
  376. }
  377. },
  378. getTotal(total,max_unit,min_unit,min_number){
  379. var str = ""
  380. var min_str = ""
  381. if(total<min_number){
  382. str = ""
  383. min_str = total + min_unit
  384. }
  385. if(total >= min_number){
  386. if(parseInt(total/min_number)!=0){
  387. str = parseInt(total/min_number)+ max_unit
  388. }
  389. if((total%min_number)!=0){
  390. min_str = total%min_number + min_unit
  391. }
  392. }
  393. return str + min_str
  394. },
  395. addInventory(){
  396. if(this.form.drug_name == ""){
  397. this.$message.error("请输入药品名称")
  398. return
  399. }
  400. if(this.form.batch_number == undefined){
  401. this.$message.error("请选择批次")
  402. return
  403. }
  404. if(this.form.count == ""){
  405. this.$message.error("请输入盘点数量")
  406. return
  407. }
  408. if(this.form.min_count == ""){
  409. this.form.min_count = 0
  410. }
  411. var obj = {
  412. drug_id:this.form.drug_id,
  413. drug_name:this.form.drug_name,
  414. warehousing_unit:this.form.warehousing_unit,
  415. count:this.form.count,
  416. min_count:this.form.min_count,
  417. min_unit:this.form.min_unit,
  418. retail_price:this.form.retail_price.toString(),
  419. manufacturer:this.form.manufacturer,
  420. drug_origin_place:this.form.drug_origin_place,
  421. remark:this.form.remark,
  422. new_price:this.form.new_price.toString(),
  423. warehousing_order:this.form.warehousing_order,
  424. dealer:this.form.dealer,
  425. last_price:this.form.last_price,
  426. start_time:this.getTime(new Date()),
  427. number:this.form.number,
  428. total:this.form.total,
  429. specification_name:this.form.specification_name,
  430. batch_number:this.form.batch_number,
  431. expiry_date:this.form.expiry_date,
  432. product_date:this.form.product_date,
  433. warehouse_info_id:this.form.warehouse_info_id,
  434. }
  435. this.tableData.push(obj)
  436. this.form.drug_name = ""
  437. this.form.warehousing_unit = ""
  438. this.form.count = ""
  439. this.form.retail_price = ""
  440. this.form.manufacturer = ""
  441. this.form.drug_origin_place = ""
  442. this.form.number = ""
  443. this.form.remark = ""
  444. this.form.new_price = ""
  445. this.form.warehousing_order = ""
  446. this.form.dealer = ""
  447. this.form.last_price = ""
  448. this.form.number = ""
  449. this.form.total = ""
  450. this.form.specification_name = ""
  451. this.form.batch_number = ""
  452. this.form.expiry_date = ""
  453. this.form.product_date = ""
  454. },
  455. toEdit(val,index){
  456. this.form.id= val.id
  457. this.form.drug_id = val.drug_id,
  458. this.form.drug_name = val.drug_name
  459. this.form.retail_price = val.retail_price
  460. this.form.warehousing_order = val.warehousing_order
  461. this.form.number = val.number
  462. this.form.dealer = val.dealer
  463. this.form.manufacturer = val.manufacturer
  464. this.form.remark = val.remark
  465. this.form.warehousing_unit = val.warehousing_unit
  466. this.form.total = val.total
  467. this.form.batch_number = val.batch_number
  468. this.form.last_price = val.last_price
  469. this.form.specification_name = val.specification_name
  470. this.form.expiry_date = val.expiry_date
  471. this.form.product_date =val.product_date
  472. this.form.count = val.count
  473. this.form.min_count = val.min_count
  474. this.form.min_unit = val.min_unit
  475. this.index = index
  476. this.editdialogVisible = true
  477. },
  478. saveInventory(){
  479. for(let i=0;i<this.tableData.length;i++){
  480. if(this.form.id == this.tableData[i].id){
  481. this.tableData[i].drug_id = this.form.drug_id
  482. this.tableData[i].drug_name = this.form.drug_name
  483. this.tableData[i].retail_price = this.form.retail_price
  484. this.tableData[i].warehousing_order = this.form.warehousing_order
  485. this.tableData[i].number = this.form.number
  486. this.tableData[i].dealer = this.form.dealer
  487. this.tableData[i].manufacturer = this.form.manufacturer
  488. this.tableData[i].remark = this.form.remark
  489. this.tableData[i].warehouseing_unit = this.form.warehousing_unit
  490. this.tableData[i].total = this.form.total
  491. this.tableData[i].batch_number = this.form.batch_number
  492. this.tableData[i].last_price = this.form.last_price
  493. this.tableData[i].specification_name = this.form.specification_name
  494. this.tableData[i].expiry_date = this.form.expiry_date
  495. this.tableData[i].product_date = this.form.product_date
  496. this.tableData[i].count =this.form.count
  497. this.tableData[i].min_unit = this.form.min_unit
  498. this.tableData[i].min_count = this.form.min_count
  499. }
  500. if(this.index == i){
  501. this.tableData[i].drug_id = this.form.drug_id
  502. this.tableData[i].drug_name = this.form.drug_name
  503. this.tableData[i].retail_price = this.form.retail_price
  504. this.tableData[i].warehousing_order = this.form.warehousing_order
  505. this.tableData[i].number = this.form.number
  506. this.tableData[i].dealer = this.form.dealer
  507. this.tableData[i].manufacturer = this.form.manufacturer
  508. this.tableData[i].remark = this.form.remark
  509. this.tableData[i].warehouseing_unit = this.form.warehousing_unit
  510. this.tableData[i].total = this.form.total
  511. this.tableData[i].batch_number = this.form.batch_number
  512. this.tableData[i].last_price = this.form.last_price
  513. this.tableData[i].specification_name = this.form.specification_name
  514. this.tableData[i].expiry_date = this.form.expiry_date
  515. this.tableData[i].product_date = this.form.product_date
  516. this.tableData[i].count =this.form.count
  517. this.tableData[i].min_unit = this.form.min_unit
  518. this.tableData[i].min_count = this.form.min_count
  519. }
  520. }
  521. this.editdialogVisible = false
  522. },
  523. saveDrugInventory(){
  524. for(let i=0;i<this.tableData.length;i++){
  525. this.tableData[i].retail_price = this.tableData[i].retail_price.toString()
  526. this.tableData[i].last_price = this.tableData[i].last_price.toString()
  527. this.tableData[i].count = parseInt(this.tableData[i].count)
  528. this.tableData[i].min_count = parseInt(this.tableData[i].min_count)
  529. if(this.tableData[i].expiry_date == undefined){
  530. this.tableData[i].expiry_date = 0
  531. }else{
  532. this.tableData[i].expiry_date = this.tableData[i].expiry_date
  533. }
  534. if( this.tableData[i].product_date == undefined){
  535. this.tableData[i].product_date = 0
  536. }else{
  537. this.tableData[i].product_date = this.tableData[i].product_date
  538. }
  539. if(this.tableData[i].dealer == 0){
  540. this.tableData[i].dealer = ""
  541. }
  542. if(this.tableData[i].manufacturer == 0){
  543. this.tableData[i].manufacturer = ""
  544. }
  545. if(this.tableData[i].batch_number == undefined){
  546. this.tableData[i].batch_number = ""
  547. }
  548. }
  549. var params = {
  550. tableData:this.tableData
  551. }
  552. saveDrugInventory(params).then(response=>{
  553. if(response.data.state == 1){
  554. var msg = response.data.data.msg
  555. this.$message.success("保存成功")
  556. this.getlist()
  557. this.editdialogVisible = false
  558. this.dialogVisible = false
  559. }
  560. })
  561. },
  562. getlist(){
  563. var params = {
  564. limit:this.limit,
  565. page:this.page,
  566. keyword:this.searchKey,
  567. start_time:this.start_time,
  568. end_time:this.end_time,
  569. }
  570. getDrugInventoryList(params).then(response=>{
  571. if(response.data.state == 1){
  572. this.total = response.data.data.total
  573. this.tableList = response.data.data.list
  574. this.doctorList = response.data.data.doctorList
  575. this.houseList = response.data.data.houseList
  576. this.storehouse_id = response.data.data.houseConfig.drug_storehouse_out
  577. }
  578. })
  579. },
  580. getDoctorName(id){
  581. var name = ""
  582. for(let i=0;i<this.doctorList.length;i++){
  583. if(id == this.doctorList[i].admin_user_id){
  584. name = this.doctorList[i].user_name
  585. }
  586. }
  587. return name
  588. },
  589. changePrice(val){
  590. var arr = []
  591. for(let i=0;i<val.length;i++){
  592. arr.push(val[i].id)
  593. }
  594. var str = arr.join(",")
  595. this.ids = str
  596. },
  597. toCheck(){
  598. if(this.ids.length <=0){
  599. this.$message.error("请勾选核对数据")
  600. return
  601. }else{
  602. this.checkDialogVisible = true
  603. }
  604. },
  605. SaveDrugCheckedInventory(){
  606. var params = {
  607. ids:this.ids,
  608. check_time:this.getTime(this.check_time),
  609. checker:this.checker,
  610. }
  611. SaveDrugCheckedInventory(params).then(response=>{
  612. if(response.data.state == 1){
  613. this.$message.success("保存成功")
  614. var msg = response.data.data.msg
  615. this.checkDialogVisible = false
  616. this.tableData = []
  617. this.getlist()
  618. }
  619. })
  620. },
  621. editInventory(id,check_status){
  622. if(check_status == 1){
  623. this.$message.error("已核对不能编辑")
  624. return false
  625. }
  626. getDrugInventoryDetail(id).then(response=>{
  627. if(response.data.state == 1){
  628. var detail = response.data.data.detail
  629. this.id = detail.id
  630. this.form.drug_id = detail.drug_id
  631. this.form.drug_name = detail.drug_name
  632. this.form.specification_name = detail.specification_name
  633. this.form.retail_price = detail.retail_price
  634. this.form.warehousing_order =detail.warehousing_order
  635. this.form.number = detail.number
  636. this.form.manufacturer = detail.manufacturer
  637. this.form.remark = detail.remark
  638. this.form.warehousing_unit = detail.warehousing_unit
  639. this.form.total = detail.total
  640. this.form.last_price = detail.last_price
  641. this.form.count = parseInt(detail.count)
  642. this.form.drug_origin_place = detail.drug_origin_place
  643. this.form.stock_max_number = detail.stock_max_number
  644. this.form.stock_min_number = detail.stock_min_number
  645. this.form.warehouse_info_id = detail.warehouse_info_id
  646. this.form.min_unit = detail.min_unit
  647. this.form.min_count = detail.min_count
  648. this.modifydialogVisible = true
  649. }
  650. })
  651. },
  652. modifyInventory(){
  653. var params = {
  654. id:this.id,
  655. drug_id:this.form.drug_id,
  656. drug_name:this.form.drug_name,
  657. specification_name:this.form.specification_name,
  658. warehousing_unit:this.form.warehousing_unit,
  659. last_price:this.form.last_price,
  660. retail_price:this.form.retail_price,
  661. count:parseInt(this.form.count),
  662. total:this.form.total,
  663. drug_origin_place:this.form.drug_origin_place,
  664. batch_number:this.form.batch_number,
  665. manufacturer:this.form.manufacturer,
  666. remark:this.form.remark,
  667. stock_max_number:this.form.stock_max_number,
  668. stock_min_number:this.form.stock_min_number,
  669. warehouse_info_id:this.form.warehouse_info_id,
  670. min_count:parseInt(this.form.min_count),
  671. min_unit:this.form.min_unit,
  672. }
  673. modifyInventory(params).then(response=>{
  674. if(response.data.state == 1){
  675. var inventory = response.data.data.inventory
  676. this.modifydialogVisible = false
  677. this.getlist()
  678. }
  679. })
  680. },
  681. deleteDrugInventory(id,check_status,index){
  682. if(check_status == 1){
  683. this.$message.error("已核对的不能编辑")
  684. return
  685. }
  686. this.$confirm('是否删除所选内容?', '提示', {
  687. confirmButtonText: '确定',
  688. cancelButtonText: '取消',
  689. type: 'warning'
  690. }).then(() => {
  691. deleteDrugInventory(id).then(response => {
  692. if (response.data.state == 1) {
  693. var msg = response.data.data.msg
  694. this.$message.success("保存成功")
  695. this.tableList.splice(index,1)
  696. }
  697. })
  698. }).catch(() => {
  699. this.loading = false
  700. });
  701. },
  702. toMove(item,index){
  703. this.$confirm('此操作将移除药品整个批次, 是否继续?', '提示', {
  704. confirmButtonText: '确定',
  705. cancelButtonText: '取消',
  706. type: 'warning'
  707. }).then(() => {
  708. this.tableData.splice(index,1)
  709. this.WarehouseList = []
  710. this.activeNames = [0,1,2,3,4,5,6,7,8,9,10]
  711. }).catch(() => {
  712. this.loading = false
  713. });
  714. },
  715. toDelete(index,drug_id){
  716. for(let i=0;i<this.tableData.length;i++){
  717. if(drug_id == this.tableData[i].drug_id){
  718. this.tableData[i].child.splice(index,1)
  719. if(this.tableData[i].child.length == 0){
  720. this.tableData.splice(index,1)
  721. }
  722. }
  723. }
  724. this.WarehouseList = []
  725. this.activeNames = [0,1,2,3,4,5,6,7,8,9,10]
  726. },
  727. exportList(){
  728. import('@/vendor/Export2Excel').then(excel => {
  729. const tHeader = ['药品名称', '规格', '单位','零售价','当前库存','盘点数','亏损金额']
  730. const filterVal = ['drug_name', 'spe', 'count','retail_price','total','count','']
  731. const data = this.formatJson(filterVal, this.tableList)
  732. excel.export_json_to_excel({
  733. header: tHeader,
  734. data,
  735. filename: '耗材盘点'
  736. })
  737. this.downloadLoading = false
  738. })
  739. },
  740. formatJson(filterVal, jsonData) {
  741. return jsonData.map(v => filterVal.map(j => v[j]));
  742. },
  743. getDrugBatchNumber(id){
  744. var params = {
  745. id:id
  746. }
  747. getDrugBatchNumber(params).then(response=>{
  748. if(response.data.state == 1){
  749. var list = response.data.data.list
  750. this.numberList = list
  751. }
  752. })
  753. },
  754. toProof(id){
  755. getDrugInventoryDetail(id).then(response=>{
  756. if(response.data.state == 1){
  757. var detail = response.data.data.detail
  758. this.id = detail.id
  759. this.form.drug_id = detail.drug_id
  760. this.form.drug_name = detail.drug_name
  761. this.form.specification_name = detail.specification_name
  762. this.form.retail_price = detail.retail_price
  763. this.form.warehousing_order =detail.warehousing_order
  764. this.form.number = detail.number
  765. this.form.manufacturer = detail.manufacturer
  766. this.form.remark = detail.remark
  767. this.form.warehousing_unit = detail.warehousing_unit
  768. this.form.total = detail.total
  769. this.form.last_price = detail.last_price
  770. this.form.count = parseInt(detail.count)
  771. this.form.drug_origin_place = detail.drug_origin_place
  772. this.form.warehouse_info_id = detail.warehouse_info_id
  773. this.profdialogVisible = true
  774. }
  775. })
  776. },
  777. proofInventory(){
  778. var params = {
  779. id:this.id,
  780. warehouseing_unit:this.form.warehousing_unit,
  781. warehouse_info_id:this.form.warehouse_info_id,
  782. total:this.total.toString(),
  783. remark:this.remark,
  784. proof_count:parseInt(this.form.proof_count),
  785. }
  786. SaveDrugProofInventory(params).then(response=>{
  787. if(response.data.state == 1){
  788. var inventory = response.data.data.inventory
  789. this.profdialogVisible = false
  790. this.getlist()
  791. }
  792. })
  793. },
  794. changeStartTime(val){
  795. this.start_time = this.getTime(val)
  796. this.getlist()
  797. },
  798. changeEndTime(val){
  799. this.end_time = this.getTime(val)
  800. this.getlist()
  801. },
  802. getDrugWarehouseInfoTotal(val){
  803. var params = {
  804. id:val,
  805. }
  806. getDrugWarehouseInfoTotal(params).then(response=>{
  807. if(response.data.state == 1){
  808. var list = response.data.data.list
  809. var max_total = 0
  810. var min_total = 0
  811. for(let i=0;i<list.length;i++){
  812. max_total += list[i].stock_max_number
  813. min_total +=list[i].stock_min_number
  814. }
  815. if(max_total >0 ){
  816. this.form.total = max_total + list[0].XtBaseDrug.max_unit
  817. }
  818. if(min_total > 0){
  819. this.form.total = this.form.total + min_total + list[0].XtBaseDrug.min_unit
  820. }
  821. }
  822. })
  823. },
  824. getDataConfig(module, filed_name) {
  825. return getDataConfig(module, filed_name)
  826. },
  827. changeMaxUnit(val){
  828. this.form.warehousing_unit = val
  829. },
  830. saveInentoryList(){
  831. var arr = []
  832. for(let i=0;i<this.tableData.length;i++){
  833. for(let j=0;j<this.tableData[i].child.length;j++){
  834. arr.push(this.tableData[i].child[j])
  835. }
  836. }
  837. for(let i=0;i<arr.length;i++){
  838. if(arr[i].last_stock_max_number == ""){
  839. arr[i].last_stock_max_number = 0
  840. }
  841. if(arr[i].last_stock_min_number == ""){
  842. arr[i].last_stock_min_number = 0
  843. }
  844. arr[i].last_stock_max_number = parseInt(arr[i].last_stock_max_number)
  845. arr[i].last_stock_min_number = parseInt(arr[i].last_stock_min_number)
  846. arr[i].storehouse_id = this.storehouse_id
  847. }
  848. var params = {
  849. tableData:arr
  850. }
  851. saveInentoryList(params).then(response=>{
  852. if(response.data.state == 1){
  853. var inventory = response.data.data.inventory
  854. this.$message.success("保存成功")
  855. this.WarehouseList = []
  856. this.tableData = []
  857. }
  858. })
  859. },
  860. getHouseName(id){
  861. var storehouse_name = ""
  862. for(let i=0;i<this.houseList.length;i++){
  863. if(id == this.houseList[i].id){
  864. storehouse_name = this.houseList[i].storehouse_name
  865. }
  866. }
  867. return storehouse_name
  868. }
  869. },
  870. created(){
  871. this.unitList = this.getDataConfig('hemodialysis','units')
  872. this.getlist()
  873. },
  874. mounted() {
  875. },
  876. };
  877. </script>
  878. <style lang="scss">
  879. .addDrugsDialog {
  880. .el-dialog__body {
  881. padding-top: 0px;
  882. }
  883. .noMargin{
  884. .el-form-item__content{
  885. margin-left: 0 !important;
  886. }
  887. }
  888. }
  889. </style>