purchaseNewStockQuery.vue 32KB

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