newDrugInventory.vue 31KB

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