purchaseNewStockQuery.vue 35KB

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