purchaseStockQuery.vue 31KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886887888889890891892893894895896897898899900901902903904905906907908909910911912913914915916917918919920921922923924925926927928929930931932933934935936937938939940941942943944945946947948949950951952953954955956957958959960961962963964965966967968969970971972973974975976977978979980981982983984985986987988989990991992993994995996997998999100010011002100310041005100610071008100910101011101210131014101510161017
  1. <template>
  2. <div class="main-contain">
  3. <div class="app-container "
  4. style="padding-left:0px;margin:0px;"
  5. v-loading="loading"
  6. element-loading-text="拼命加载中">
  7. <div style="justify-content: space-between;margin: 0px 0 12px 0;display: flex;align-items: center;">
  8. <div>
  9. <span style="font-size:14px;color:#606266">操作时间:</span>
  10. <el-date-picker
  11. size="small"
  12. v-model="start_time"
  13. prefix-icon="el-icon-date"
  14. :editable="false"
  15. style="width: 150px;"
  16. type="date"
  17. placeholder="选择日期时间"
  18. align="right"
  19. format="yyyy-MM-dd"
  20. value-format="yyyy-MM-dd"
  21. @change="startTimeChange"
  22. :picker-options="pickerOptions"
  23. :clearable="false"
  24. ></el-date-picker>
  25. <span>-</span>
  26. <el-date-picker
  27. size="small"
  28. v-model="end_time"
  29. prefix-icon="el-icon-date"
  30. :editable="false"
  31. style="width: 150px;"
  32. type="date"
  33. placeholder="选择日期时间"
  34. align="right"
  35. format="yyyy-MM-dd"
  36. value-format="yyyy-MM-dd"
  37. @change="endTimeChange"
  38. :picker-options="pickerOptions"
  39. :clearable="false"
  40. ></el-date-picker>
  41. <span style="font-size:14px;color:#606266">耗材类型:</span>
  42. <el-select v-model="good_type" style="width:200px;margin-right:10px;" placeholder="请选择"
  43. filterable
  44. @change="changeGoodTypeName">
  45. <el-option
  46. v-for="item in goodTypeList"
  47. :key="item.id"
  48. :label="item.type_name"
  49. :value="item.id">
  50. </el-option>
  51. </el-select>
  52. <el-input v-model="keyword" style="width:200px" placeholder="请输入耗材名称或生产厂商" ></el-input>
  53. <el-button type="primary" icon="el-icon-search" @click="seach">搜索</el-button>
  54. </div>
  55. <div>
  56. <el-button type="primary" size="small" @click="toPrint">打印</el-button>
  57. <el-button type="primary" size="small" @click="exportList">导出</el-button>
  58. </div>
  59. </div>
  60. <el-table
  61. :row-style="{ color: '#303133' }"
  62. :header-cell-style="{
  63. backgroundColor: 'rgb(245, 247, 250)',
  64. color: '#606266'
  65. }"
  66. :data="tableList"
  67. :class="signAndWeighBoxPatients"
  68. border
  69. >
  70. <el-table-column label="耗材类型" align="center">
  71. <template slot-scope="scope">
  72. {{getGoodTypeName(scope.row.good_type_id)}}
  73. </template>
  74. </el-table-column>
  75. <el-table-column label="耗材名称" align="center">
  76. <template slot-scope="scope">
  77. {{scope.row.good_name}}
  78. </template>
  79. </el-table-column>
  80. <el-table-column label="规格&单位" align="center">
  81. <template slot-scope="scope">
  82. {{scope.row.specification_name}}/{{scope.row.packing_unit}}
  83. </template>
  84. </el-table-column>
  85. <el-table-column label="生产厂商" align="center">
  86. <template slot-scope="scope">
  87. {{getManufacturName(scope.row.manufacturer)}}
  88. </template>
  89. </el-table-column>
  90. <el-table-column label="期初结余" align="center">
  91. <el-table-column prop="stockIn" label="数量" width="100">
  92. </el-table-column>
  93. <el-table-column prop="stock_in_price" label="进货金额" width="100">
  94. </el-table-column>
  95. <el-table-column prop="stockMoney" label="销售金额" width="100">
  96. </el-table-column>
  97. </el-table-column>
  98. <el-table-column label="本期增加" align="center">
  99. <el-table-column prop="stockAdd" label="数量" width="100">
  100. </el-table-column>
  101. <el-table-column prop="addStockMoney" label="进货金额" width="100">
  102. </el-table-column>
  103. <el-table-column prop="saleStockMoney" label="销售金额" width="100">
  104. </el-table-column>
  105. </el-table-column>
  106. <el-table-column label="本期减少" align="center">
  107. <el-table-column prop="outStock" label="数量" width="100">
  108. </el-table-column>
  109. <el-table-column prop="stockOutprice" label="进货金额" width="100">
  110. </el-table-column>
  111. <el-table-column prop="saleOutMoney" label="销售金额" width="100">
  112. </el-table-column>
  113. </el-table-column>
  114. <el-table-column label="期末结余" align="center">
  115. <el-table-column prop="overStock" label="数量" width="100">
  116. </el-table-column>
  117. <el-table-column prop="overPrice" label="进货金额" width="100">
  118. </el-table-column>
  119. <el-table-column prop="overMoney" label="销售金额" width="100">
  120. </el-table-column>
  121. </el-table-column>
  122. </el-table>
  123. <el-pagination
  124. @size-change="handleSizeChange"
  125. @current-change="handleCurrentChange"
  126. :page-sizes="[10, 50, 100,200,500,1000]"
  127. :page-size="10"
  128. background
  129. align="right"
  130. style="margin-top:20px;"
  131. layout="total, sizes, prev, pager, next, jumper"
  132. :total="total"
  133. >
  134. </el-pagination>
  135. </div>
  136. </div>
  137. </template>
  138. <script>
  139. import { getStorehouseList,getPurchaseStockQuery } from "@/api/drug/drug"
  140. import {
  141. getStockDrugCount
  142. } from "@/api/stock";
  143. import { uParseTime } from '@/utils/tools'
  144. const moment = require('moment')
  145. export default {
  146. data(){
  147. return{
  148. tableList:[],
  149. goodList:[
  150. {id:1,name:"全部耗材"},
  151. {id:2,name:"库存预警"},
  152. ],
  153. houseList:[],
  154. storehouse_id:0,
  155. good_type:0,
  156. multipleSelection: [],
  157. signAndWeighBoxPatients: "sign-and-weigh-box-patients",
  158. manufacturerList:[],
  159. limit:10,
  160. page:1,
  161. total:0,
  162. keyword:"",
  163. goodTypeList:[],
  164. start_time:"",
  165. end_time:"",
  166. countList:[],
  167. outCountList:[],
  168. autoCountList:[],
  169. cancelCountList:[],
  170. org_id:this.$store.getters.xt_user.org_id,
  171. dialogVisible:false,
  172. start_first_time:"",
  173. end_first_time:"",
  174. tableData:[],
  175. good_id:0,
  176. patientList:[],
  177. good_name:"",
  178. specification_name:"",
  179. loading:false,
  180. pickerOptions:{ //禁用当前日期之前的日期
  181. disabledDate(v) {
  182. return v.getTime() < 1667232000000
  183. },
  184. },
  185. }
  186. },
  187. methods:{
  188. changeStorehouseName(){
  189. },
  190. changeGoodTypeName(){
  191. this.getlist()
  192. },
  193. getStorehouseList(){
  194. getStorehouseList().then(response=>{
  195. if(response.data.state == 1){
  196. var houseList = response.data.data.list
  197. var obj = {id:0,storehouse_name:"全部"}
  198. this.houseList.push(obj)
  199. for(let i=0;i<houseList.length;i++){
  200. this.houseList.push(houseList[i])
  201. }
  202. this.manufacturerList = response.data.data.manufacturerList
  203. var obj = {id:0,type_name:"全部"}
  204. this.goodTypeList.push(obj)
  205. var goodTypeList = response.data.data.goodTypeList
  206. for(let i=0;i<goodTypeList.length;i++){
  207. this.goodTypeList.push(goodTypeList[i])
  208. }
  209. this.patientList = response.data.data.patientList
  210. }
  211. })
  212. },
  213. getlist(){
  214. this.loading = true
  215. var params = {
  216. good_type:this.good_type,
  217. keyword:this.keyword,
  218. page:this.page,
  219. limit:this.limit,
  220. start_time:this.start_time,
  221. end_time:this.end_time,
  222. }
  223. getPurchaseStockQuery(params).then(response=>{
  224. if(response.data.state == 1){
  225. var list = response.data.data.list
  226. this.loading = false
  227. for(let i=0;i<list.length;i++){
  228. list[i].stockIn = this.getWarehouseInfoStart(list[i].StartFlowInfo,list[i].StartOutFlowInfo,list[i].WareStartStockInventoryProfit,list[i].WareStartStockInventoryLosses,list[i].StartCancelFlowInfo) //期初结余
  229. list[i].stock_in_price = this.getWarehouseInfoStartPrice(list[i].StartFlowInfo,list[i].StartOutFlowInfo,list[i].WareStartStockInventoryProfit,list[i].WareStartStockInventoryLosses,list[i].StartCancelFlowInfo)
  230. list[i].stockMoney = this.getWarehouseInfoStartMoney(list[i].StartFlowInfo,list[i].StartOutFlowInfo,list[i].WareStartStockInventoryProfit,list[i].WareStartStockInventoryLosses,list[i].StartCancelFlowInfo)
  231. list[i].stockAdd = this.getWarehouseInfoOne(list[i].StartFlowWarehouseInfo,list[i].WareStartEndStockInventoryProfit)//期间增加
  232. list[i].addStockMoney = this.getAddStockMony(list[i].StartFlowWarehouseInfo,list[i].WareStartEndStockInventoryProfit)
  233. list[i].saleStockMoney = this.getSaleStockMony(list[i].StartFlowWarehouseInfo,list[i].WareStartEndStockInventoryProfit)
  234. list[i].outStock = this.getWarehosueOutInfo(list[i].WarehouseOutInfoStart,list[i].WareStartEndStockInventoryLosses,list[i].StartEndCancelFLowInfo)//本期减少
  235. list[i].stockOutprice = this.stockOutprice(list[i].WarehouseOutInfoStart,list[i].WareStartEndStockInventoryLosses,list[i].StartEndCancelFLowInfo)
  236. list[i].saleOutMoney = this.getSaleStockMony(list[i].WarehouseOutInfoStart,list[i].WareStartEndStockInventoryLosses,list[i].StartEndCancelFLowInfo)
  237. list[i].overStock= this.getEndWarehouseInfo(list[i].EndFlowInfo,list[i].EndFlowOutInfo,list[i].WareEndStockInventoryProfit,list[i].WareEndStockInventoryLosses,list[i].EndCancelFLowInfo)
  238. list[i].overPrice= this.getEndOverPrice(list[i].EndFlowInfo,list[i].EndFlowOutInfo,list[i].WareEndStockInventoryProfit,list[i].WareEndStockInventoryLosses,list[i].EndCancelFLowInfo)
  239. list[i].overMoney = this.getEndSalePrice(list[i].EndFlowInfo,list[i].EndFlowOutInfo,list[i].WareEndStockInventoryProfit,list[i].WareEndStockInventoryLosses,list[i].EndCancelFLowInfo)
  240. }
  241. this.tableList = list
  242. this.total = response.data.data.total
  243. this.manufacturerList = response.data.data.manufacturerList
  244. }
  245. })
  246. },
  247. getManufacturName(id){
  248. var manufacturer_name = ""
  249. for(let i=0;i<this.manufacturerList.length;i++){
  250. if(id == this.manufacturerList[i].id){
  251. manufacturer_name = this.manufacturerList[i].manufacturer_name
  252. }
  253. }
  254. return manufacturer_name
  255. },
  256. handleSizeChange(val) {
  257. this.limit = val;
  258. this.getlist()
  259. },
  260. handleCurrentChange(val) {
  261. this.page = val;
  262. this.getlist()
  263. },
  264. handleSizeChangeOne(val) {
  265. this.limitone = val;
  266. this.toDialogClick(this.good_id,this.good_name,this.specification_name)
  267. },
  268. handleCurrentChangeOne(val) {
  269. this.pageone = val;
  270. this.toDialogClick(this.good_id,this.good_name,this.specification_name)
  271. },
  272. seach(){
  273. this.goodTypeList = []
  274. this.getStorehouseList()
  275. this.getlist()
  276. },
  277. getGoodTypeName(id){
  278. var type_name = ""
  279. for(let i=0;i<this.goodTypeList.length;i++){
  280. if(id == this.goodTypeList[i].id){
  281. type_name = this.goodTypeList[i].type_name
  282. }
  283. }
  284. return type_name
  285. },
  286. getHouseName(id){
  287. var storehouse_name = ""
  288. for(let i=0;i<this.houseList.length;i++){
  289. if(id == this.houseList[i].id){
  290. storehouse_name = this.houseList[i].storehouse_name
  291. }
  292. }
  293. return storehouse_name
  294. },
  295. getWareInfoCount(val,storehouse_id){
  296. var count = 0
  297. if(val.length > 0){
  298. for(let i=0;i<val.length;i++){
  299. if(val[i].storehouse_id == storehouse_id){
  300. count +=val[i].warehousing_count
  301. }
  302. }
  303. }
  304. if(count > 0){
  305. return count
  306. }else{
  307. return ""
  308. }
  309. },
  310. getStockDrugCount(){
  311. var params ={
  312. keywords: this.keywords,
  313. start_time:this.start_time,
  314. end_time:this.end_time,
  315. }
  316. getStockDrugCount(params).then(response=>{
  317. if(response.data.state == 1){
  318. var outlist = response.data.data.outList
  319. this.outCountList = outlist
  320. var autoCount = response.data.data.autoCount
  321. this.autoCountList = autoCount
  322. var totalCount = response.data.data.totalCount
  323. this.cancelCountList = totalCount
  324. }
  325. })
  326. },
  327. getWareInfoCountOne(val,storehouse_id){
  328. var count = 0
  329. if(val.length > 0){
  330. for(let i=0;i<val.length;i++){
  331. if(val[i].storehouse_id == storehouse_id){
  332. count +=val[i].stock_count
  333. }
  334. }
  335. }
  336. if(count > 0){
  337. return count
  338. }else{
  339. return ""
  340. }
  341. },
  342. getOutCount(id){
  343. var count = 0
  344. for(let i=0;i<this.outCountList.length;i++){
  345. if(id == this.outCountList[i].good_id){
  346. count = this.outCountList[i].count
  347. }
  348. }
  349. return count
  350. },
  351. getAutoCount(id){
  352. var count= 0
  353. for(let i=0;i<this.autoCountList.length;i++){
  354. if(id == this.autoCountList[i].good_id){
  355. count = this.autoCountList[i].count
  356. }
  357. }
  358. return count
  359. },
  360. getCancelCount(id){
  361. var count = 0
  362. for(let i=0;i<this.cancelCountList.length;i++){
  363. if(id == this.cancelCountList[i].good_id){
  364. count = this.cancelCountList[i].count
  365. }
  366. }
  367. return count
  368. },
  369. getCancelCountInfo(cancel_stock_info,storehouse_id){
  370. var count = 0
  371. if(cancel_stock_info.length >0){
  372. for(let i=0;i<cancel_stock_info.length;i++){
  373. if(storehouse_id == cancel_stock_info[i].storehouse_id){
  374. count += cancel_stock_info[i].count
  375. }
  376. }
  377. }
  378. return count
  379. },
  380. getWareOutInfoCount(warehouse_out_info,storehouse_id){
  381. var count = 0
  382. if(warehouse_out_info.length > 0){
  383. for(let i=0;i<warehouse_out_info.length;i++){
  384. if(storehouse_id == warehouse_out_info[i].storehouse_id){
  385. count +=warehouse_out_info[i].count
  386. }
  387. }
  388. }
  389. return count
  390. },
  391. getInCount(id){
  392. var count= 0
  393. for(let i=0;i<this.countList.length;i++){
  394. if(id == this.countList[i].good_id){
  395. count = this.countList[i].count
  396. }
  397. }
  398. return count
  399. },
  400. getOutCount(id){
  401. var count = 0
  402. for(let i=0;i<this.outCountList.length;i++){
  403. if(id == this.outCountList[i].good_id){
  404. count = this.outCountList[i].count
  405. }
  406. }
  407. return count
  408. },
  409. getAutoCount(id){
  410. var count= 0
  411. for(let i=0;i<this.autoCountList.length;i++){
  412. if(id == this.autoCountList[i].good_id){
  413. count = this.autoCountList[i].count
  414. }
  415. }
  416. return count
  417. },
  418. getCancelCount(id){
  419. var count = 0
  420. for(let i=0;i<this.cancelCountList.length;i++){
  421. if(id == this.cancelCountList[i].good_id){
  422. count = this.cancelCountList[i].count
  423. }
  424. }
  425. return count
  426. },
  427. getStockCount(id){
  428. var stock_count = 0
  429. for(let i=0;i<this.countList.length;i++){
  430. if(id == this.countList[i].good_id){
  431. stock_count = this.countList[i].stock_count
  432. }
  433. }
  434. return stock_count
  435. },
  436. getWareInfo(arr){
  437. var total = 0
  438. if(arr.length > 0){
  439. for(let i=0;i<arr.length;i++){
  440. total += parseInt(arr[i].warehousing_count)
  441. }
  442. }else{
  443. total = ""
  444. }
  445. return total
  446. },
  447. getOverplus(arr){
  448. var total = 0
  449. if(arr.length > 0){
  450. for(let i=0;i<arr.length;i++){
  451. total += arr[i].stock_count
  452. }
  453. }else{
  454. total = ""
  455. }
  456. return total
  457. },
  458. getCancelInfo(arr){
  459. var total = 0
  460. if(arr.length > 0){
  461. for(let i=0;i<arr.length;i++){
  462. total += arr[i].count
  463. }
  464. }else{
  465. total = ""
  466. }
  467. return total
  468. },
  469. getOverFlushInfo(arr){
  470. var total = 0
  471. if(arr.length >0){
  472. for(let i=0;i<arr.length;i++){
  473. total += arr[i].stock_count
  474. }
  475. }
  476. return total
  477. },
  478. startFirstTimeChange(){
  479. this.getlist()
  480. },
  481. endEndTimeChange(){
  482. this.getlist()
  483. },
  484. getTime(val) {
  485. if(val < 0){
  486. return ""
  487. }
  488. if(val == ""){
  489. return ""
  490. }else {
  491. return uParseTime(val, '{y}-{m}-{d}')
  492. }
  493. },
  494. getName(id){
  495. var name = ""
  496. for(let i=0;i<this.patientList.length;i++){
  497. if(id == this.patientList[i].id){
  498. name = this.patientList[i].name
  499. }
  500. }
  501. return name
  502. },
  503. endTimeChange(){
  504. this.getlist()
  505. },
  506. startTimeChange(){
  507. this.getlist()
  508. },
  509. getWarehouseInfoStart(arr1,arr2,arr3,arr4,arr5){
  510. var count =0
  511. var countOne =0
  512. var countTwo= 0
  513. var countthree = 0 //期初
  514. var countfour = 0
  515. var countfive = 0
  516. if(arr1!=null && arr1.length > 0){
  517. for(let i=0;i<arr1.length;i++){
  518. countOne +=arr1[i].count
  519. }
  520. }
  521. if(arr2!=null && arr2.length > 0){
  522. for(let i=0;i<arr2.length;i++){
  523. countTwo +=arr2[i].count
  524. }
  525. }
  526. if(arr3!=null && arr3.length > 0){
  527. for(let i=0;i<arr3.length;i++){
  528. countthree +=arr3[i].count
  529. }
  530. }
  531. if(arr4!=null && arr4.length > 0){
  532. for(let i=0;i<arr4.length;i++){
  533. countfour +=arr4[i].count
  534. }
  535. }
  536. if(arr5!=null && arr5.length > 0){
  537. for(let i=0;i<arr5.length;i++){
  538. countfive +=arr5[i].count
  539. }
  540. }
  541. console.log("countOne",countOne)
  542. console.log("countTwo",countTwo)
  543. console.log("countthree",countthree)
  544. console.log("countfour",countfour)
  545. console.log("*********************")
  546. count = countOne - countTwo + countthree - countfour + countfive
  547. if(count > 0 ){
  548. return count
  549. }else{
  550. return 0
  551. }
  552. },
  553. getWarehouseInfo(val){
  554. var count =0
  555. for(let i=0;i<val.length;i++){
  556. count +=val[i].stock_count
  557. }
  558. if(count > 0 ){
  559. return count
  560. }else{
  561. return 0
  562. }
  563. },
  564. getWarehouseInfoOne(val,val2){
  565. var count =0
  566. var countOne = 0
  567. var all_count = 0
  568. if(val!=null && val.length >0){
  569. for(let i=0;i<val.length;i++){
  570. count +=val[i].count
  571. }
  572. }
  573. if(val2!=null && val2.length > 0){
  574. for(let i=0;i<val2.length;i++){
  575. countOne +=val2[i].count
  576. }
  577. }
  578. all_count = count + countOne
  579. console.log("count2332323223232o2222222222wide",count)
  580. console.log("countONE23232322323323223",countOne)
  581. console.log("all_count9999999999999wode",all_count)
  582. console.log("-------------------------------------------")
  583. if(all_count > 0 ){
  584. return all_count
  585. }else{
  586. return 0
  587. }
  588. },
  589. getAddStockMony(val,val2){
  590. var total_price =0
  591. var total_price_one = 0
  592. var all_price = 0
  593. if(val!=null && val.length >0){
  594. for(let i=0;i<val.length;i++){
  595. total_price +=val[i].count * val[i].buy_price
  596. }
  597. }
  598. if(val2!=null && val2.length > 0){
  599. for(let i=0;i<val2.length;i++){
  600. total_price_one +=val2[i].count * val2[i].price
  601. }
  602. }
  603. all_price = total_price + total_price_one
  604. if(all_price >0 ){
  605. return total_price.toFixed(2)
  606. }else{
  607. return "0.00"
  608. }
  609. },
  610. getSaleStockMony(val,val2){
  611. var total_price =0
  612. var total_price_one = 0
  613. var all_price = 0
  614. if(val!=null && val.length >0){
  615. for(let i=0;i<val.length;i++){
  616. total_price +=val[i].count * val[i].price
  617. }
  618. }
  619. if(val2!=null && val2.length > 0){
  620. for(let i=0;i<val2.length;i++){
  621. total_price_one +=val2[i].count * val2[i].price
  622. }
  623. }
  624. all_price = total_price + total_price_one
  625. if(all_price >0 ){
  626. return all_price.toFixed(2)
  627. }else{
  628. return "0.00"
  629. }
  630. },
  631. getWarehouseOut(val){
  632. var count = 0
  633. for(let i=0;i<val.length;i++){
  634. count +=val[i].count
  635. }
  636. if(count >0){
  637. return count
  638. }else{
  639. return 0
  640. }
  641. },
  642. open(){
  643. this.start_time = moment().year(2022).month(10).date(1).format('YYYY-MM-DD')
  644. this.end_time = moment(new Date()).add('year',0).format("YYYY-MM-DD")
  645. this.houseList = []
  646. this.goodTypeList= []
  647. this.getStorehouseList()
  648. this.getlist()
  649. //this.getStockDrugCount()
  650. },
  651. getWarehouseInfoStartPrice(arr,arr1,arr2,arr3,arr4){
  652. var total_price = 0
  653. var total_price_one = 0
  654. var total_price_two = 0
  655. var total_price_three = 0
  656. var total_price_four = 0
  657. var total_price_all = 0
  658. if(arr!=null&&arr.length > 0){
  659. for(let i=0;i<arr.length;i++){
  660. total_price += arr[i].count * arr[i].buy_price
  661. }
  662. }
  663. if(arr1!=null && arr1.length > 0){
  664. for(let i=0;i<arr1.length;i++){
  665. total_price_one +=arr1[i].count * arr1[i].buy_price
  666. }
  667. }
  668. if(arr2!=null && arr2.length > 0){
  669. for(let i=0;i<arr2.length;i++){
  670. total_price_two +=arr2[i].count * arr2[i].buy_price
  671. }
  672. }
  673. if(arr3!=null && arr3.length > 0){
  674. for(let i=0;i<arr3.length;i++){
  675. total_price_three +=arr3[i].count * arr3[i].buy_price
  676. }
  677. }
  678. if(arr4!=null && arr4.length > 0){
  679. for(let i=0;i<arr4.length;i++){
  680. total_price_three +=arr4[i].count * arr4[i].buy_price
  681. }
  682. }
  683. total_price_all = total_price - total_price_one + total_price_two - total_price_three + total_price_four
  684. if (total_price_all > 0) {
  685. return total_price_all.toFixed(2)
  686. }else{
  687. return "0.00"
  688. }
  689. },
  690. getWarehouseInfoStartMoney(arr,arr1,arr2,arr3,arr4){
  691. var total_price = 0
  692. var total_price_one = 0
  693. var total_price_two = 0
  694. var total_price_three = 0
  695. var total_price_four = 0
  696. var total_price_all = 0
  697. if(arr!=null && arr.length >0){
  698. for(let i=0;i<arr.length;i++){
  699. total_price +=arr[i].count * arr[i].price
  700. }
  701. }
  702. if(arr1!=null && arr1.length > 0){
  703. for(let i=0;i<arr1.length;i++){
  704. total_price_one +=arr1[i].count * arr1[i].price
  705. }
  706. }
  707. if(arr2!=null && arr2.length > 0){
  708. for(let i=0;i<arr2.length;i++){
  709. total_price_two +=arr2[i].count * arr2[i].price
  710. }
  711. }
  712. if(arr3!=null && arr3.length > 0){
  713. for(let i=0;i<arr3.length;i++){
  714. total_price_three +=arr3[i].count * arr3[i].price
  715. }
  716. }
  717. if(arr4!=null && arr4.length > 0){
  718. for(let i=0;i<arr4.length;i++){
  719. total_price_four +=arr4[i].count * arr4[i].price
  720. }
  721. }
  722. total_price_all = total_price - total_price_one + total_price_two - total_price_three + total_price_four
  723. if (total_price_all > 0) {
  724. return total_price_all.toFixed(2)
  725. }else{
  726. return "0.00"
  727. }
  728. },
  729. getWarehosueOutInfo(val,val2,val3){
  730. var count = 0
  731. var count_one = 0
  732. var all_count = 0
  733. var count_two = 0
  734. if(val!=null && val.length >0){
  735. for(let i=0;i<val.length;i++){
  736. count +=val[i].count
  737. }
  738. }
  739. if(val2!=null && val2.length > 0){
  740. for(let i=0;i<val2.length;i++){
  741. count_one +=val2[i].count
  742. }
  743. }
  744. if(val3!=null && val3.length > 0){
  745. for(let i=0;i<val3.length;i++){
  746. count_two +=val3[i].count
  747. }
  748. }
  749. all_count = count +count_one - count_two
  750. if(all_count >0){
  751. return all_count
  752. }else{
  753. return 0
  754. }
  755. },
  756. stockOutprice(val,val2,val3){
  757. var total_price = 0
  758. var total_price_one = 0
  759. var total_price_two = 0
  760. var all_price = 0
  761. if(val!=null && val.length >0){
  762. for(let i=0;i<val.length;i++){
  763. total_price +=val[i].count * val[i].buy_price
  764. }
  765. }
  766. if(val2!=null && val2.length > 0){
  767. for(let i=0;i<val2.length;i++){
  768. total_price_one +=val2[i].count * val2[i].buy_price
  769. }
  770. }
  771. if(val3!=null && val3.length > 0){
  772. for(let i=0;i<val3.length;i++){
  773. total_price_two +=val3[i].count * val3[i].buy_price
  774. }
  775. }
  776. all_price = total_price + total_price_one - total_price_two
  777. if(all_price >0){
  778. return all_price.toFixed(2)
  779. }else{
  780. return "0.00"
  781. }
  782. },
  783. saleOutprice(val,val2,val3){
  784. var total_price = 0
  785. var total_price_one = 0
  786. var all_price = 0
  787. var total_price_two = 0
  788. if(val!=null && val.length >0){
  789. for(let i=0;i<val.length;i++){
  790. total_price +=val[i].count * val[i].xt_warehouse_info.packing_price
  791. }
  792. }
  793. if(val2!=null && val2.length > 0){
  794. for(let i=0;i<val2.length;i++){
  795. total_price_one +=val2[i].count * val2[i].price
  796. }
  797. }
  798. if(val3!=null && val3.length > 0){
  799. for(let i=0;i<val3.length;i++){
  800. total_price_two +=val3[i].count * val3[i].price
  801. }
  802. }
  803. all_price = total_price + total_price_one - total_price_two
  804. if(all_price >0){
  805. return all_price.toFixed(2)
  806. }else{
  807. return "0.00"
  808. }
  809. },
  810. getEndWarehouseInfo(val,val3,val1,val2,val4){
  811. var count = 0
  812. var count_one = 0
  813. var count_two = 0
  814. var count_three =0
  815. var count_four = 0
  816. var all_count = 0
  817. if(val!=null && val.length >0){
  818. for(let i=0;i<val.length;i++){
  819. count +=val[i].count
  820. }
  821. }
  822. if(val1!=null&&val1.length >0){
  823. for(let i=0;i<val1.length;i++){
  824. count_one +=val1[i].count
  825. }
  826. }
  827. if(val3!=null&& val3.length > 0){
  828. for(let i=0;i<val3.length;i++){
  829. count_three +=val3[i].count
  830. }
  831. }
  832. if(val2!=null&&val2.length >0){
  833. for(let i=0;i<val2.length;i++){
  834. count_two +=val2[i].count
  835. }
  836. }
  837. if(val4!=null&&val4.length >0){
  838. for(let i=0;i<val4.length;i++){
  839. count_four +=val4[i].count
  840. }
  841. }
  842. all_count = count- count_three + count_one - count_two + count_four
  843. if(all_count >0){
  844. return all_count
  845. }else{
  846. return 0
  847. }
  848. },
  849. getEndOverPrice(val,val3,val1,val2,val4){
  850. var total_price = 0
  851. var total_price_one = 0
  852. var total_price_two = 0
  853. var total_price_three = 0
  854. var total_price_four =0
  855. var all_price = 0
  856. if(val!=null && val.length >0){
  857. for(let i=0;i<val.length;i++){
  858. total_price +=val[i].count * val[i].buy_price
  859. }
  860. }
  861. if(val1!=null && val1.length > 0){
  862. for(let i=0;i<val1.length;i++){
  863. total_price_one +=val1[i].count * val1[i].buy_price
  864. }
  865. }
  866. if(val3!=null && val3.length > 0){
  867. for(let i=0;i<val3.length;i++){
  868. total_price_three +=val3[i].count * val3[i].buy_price
  869. }
  870. }
  871. if(val2!=null && val2.length > 0){
  872. for(let i=0;i<val2.length;i++){
  873. total_price_two +=val2[i].count * val2[i].buy_price
  874. }
  875. }
  876. if(val4!=null && val4.length > 0){
  877. for(let i=0;i<val4.length;i++){
  878. total_price_four +=val4[i].count * val4[i].buy_price
  879. }
  880. }
  881. console.log("total_price",total_price)
  882. console.log("total_price_three",total_price_three)
  883. console.log("total_price_two",total_price_two)
  884. console.log("total_price_one",total_price_one)
  885. console.log("total_price_four",total_price_four)
  886. all_price = total_price- total_price_three +total_price_one - total_price_two + total_price_four
  887. console.log("arrll_price",all_price)
  888. if(all_price >0){
  889. return all_price.toFixed(2)
  890. }else{
  891. return "0.00"
  892. }
  893. },
  894. getEndSalePrice(val,val3,val1,val2,val4){
  895. var total_price = 0
  896. var total_price_one = 0
  897. var total_price_two = 0
  898. var total_price_three = 0
  899. var total_price_four = 0
  900. var all_price= 0
  901. if(val!=null && val.length >0){
  902. for(let i=0;i<val.length;i++){
  903. total_price +=val[i].count * val[i].price
  904. }
  905. }
  906. if(val1!=null && val1.length >0){
  907. for(let i=0;i<val1.length;i++){
  908. total_price_one +=val1[i].count * val1[i].price
  909. }
  910. }
  911. if(val3!=null && val3.length >0){
  912. for(let i=0;i<val3.length;i++){
  913. total_price_three +=val3[i].count * val3[i].price
  914. }
  915. }
  916. if(val2!=null && val2.length >0){
  917. for(let i=0;i<val2.length;i++){
  918. total_price_two +=val2[i].count * val2[i].price
  919. }
  920. }
  921. if(val4!=null && val4.length >0){
  922. for(let i=0;i<val4.length;i++){
  923. total_price_four +=val4[i].count * val4[i].price
  924. }
  925. }
  926. var all_price = total_price-total_price_three + total_price_one - total_price_two + total_price_four
  927. if(all_price >0){
  928. return all_price.toFixed(2)
  929. }else{
  930. return "0.00"
  931. }
  932. },
  933. toPrint(){
  934. this.$router.push({path:"/purchase/stock/query/print?start_time="+this.start_time+"&end_time="+this.end_time+"&page="+this.page+"&limit="+this.limit+"&keyword="+this.keyword+"&good_type="+this.good_type})
  935. },
  936. exportList: function() {
  937. for(let i=0;i<this.tableList.length;i++){
  938. this.tableList[i].index = i+1
  939. this.tableList[i].query_date = this.start_time+"~"+this.end_time
  940. this.tableList[i].good_type = this.getGoodTypeName(this.tableList[i].good_type_id)
  941. this.tableList[i].manufacturer_name = this.getManufacturName(this.tableList[i].manufacturer)
  942. this.tableList[i].specification_name_one = this.tableList[i].specification_name + "/"+this.tableList[i].packing_unit
  943. }
  944. import('@/vendor/Export2Excel').then(excel => {
  945. const multiHeader = [['序号', '查询日期',' 耗材类型','耗材名称','规格&单位','生产产商', '期初结余' , '', '', '本期增加', '', '', '本期减少' , '', '', '期末结余' , '', '']]
  946. const header = ['', '','','','','', '数量', '进货金额', '销售金额', '数量', '进货金额', '销售金额', '数量', '进货金额', '销售金额', '数量', '进货金额', '销售金额']
  947. const merges = ['A1:A2', 'B1:B2','C1:C2','D1:D2','E1:E2','F1:F2','G1:I1', 'J1:L1', 'M1:O1', 'P1:R1']
  948. const filterVal = ['index', 'query_date', 'good_type','good_name','specification_name_one','manufacturer_name','stockIn','stock_in_price','stockMoney','stockAdd','addStockMoney','saleStockMoney','outStock','stockOutprice','saleOutMoney','overStock','overPrice','overMoney']
  949. const data = this.formatJson(filterVal, this.tableList)
  950. const filename = '进销存查询'
  951. excel.export_json_to_excel({
  952. multiHeader,
  953. header,
  954. merges,
  955. data,
  956. filename
  957. })
  958. })
  959. },
  960. formatJson(filterVal, jsonData) {
  961. return jsonData.map(v => filterVal.map(j => v[j]));
  962. },
  963. },
  964. // created(){
  965. // this.getStorehouseList()
  966. // this.getlist()
  967. // this.getStockDrugCount()
  968. // }
  969. }
  970. </script>