purchaseNewStockQuery.vue 35KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394959697989910010110210310410510610710810911011111211311411511611711811912012112212312412512612712812913013113213313413513613713813914014114214314414514614714814915015115215315415515615715815916016116216316416516616716816917017117217317417517617717817918018118218318418518618718818919019119219319419519619719819920020120220320420520620720820921021121221321421521621721821922022122222322422522622722822923023123223323423523623723823924024124224324424524624724824925025125225325425525625725825926026126226326426526626726826927027127227327427527627727827928028128228328428528628728828929029129229329429529629729829930030130230330430530630730830931031131231331431531631731831932032132232332432532632732832933033133233333433533633733833934034134234334434534634734834935035135235335435535635735835936036136236336436536636736836937037137237337437537637737837938038138238338438538638738838939039139239339439539639739839940040140240340440540640740840941041141241341441541641741841942042142242342442542642742842943043143243343443543643743843944044144244344444544644744844945045145245345445545645745845946046146246346446546646746846947047147247347447547647747847948048148248348448548648748848949049149249349449549649749849950050150250350450550650750850951051151251351451551651751851952052152252352452552652752852953053153253353453553653753853954054154254354454554654754854955055155255355455555655755855956056156256356456556656756856957057157257357457557657757857958058158258358458558658758858959059159259359459559659759859960060160260360460560660760860961061161261361461561661761861962062162262362462562662762862963063163263363463563663763863964064164264364464564664764864965065165265365465565665765865966066166266366466566666766866967067167267367467567667767867968068168268368468568668768868969069169269369469569669769869970070170270370470570670770870971071171271371471571671771871972072172272372472572672772872973073173273373473573673773873974074174274374474574674774874975075175275375475575675775875976076176276376476576676776876977077177277377477577677777877978078178278378478578678778878979079179279379479579679779879980080180280380480580680780880981081181281381481581681781881982082182282382482582682782882983083183283383483583683783883984084184284384484584684784884985085185285385485585685785885986086186286386486586686786886987087187287387487587687787887988088188288388488588688788888989089189289389489589689789889990090190290390490590690790890991091191291391491591691791891992092192292392492592692792892993093193293393493593693793893994094194294394494594694794894995095195295395495595695795895996096196296396496596696796896997097197297397497597697797897998098198298398498598698798898999099199299399499599699799899910001001100210031004100510061007100810091010101110121013101410151016101710181019102010211022102310241025102610271028102910301031103210331034103510361037103810391040104110421043104410451046104710481049105010511052105310541055105610571058105910601061106210631064106510661067106810691070107110721073107410751076107710781079108010811082108310841085108610871088108910901091109210931094109510961097109810991100110111021103110411051106110711081109111011111112111311141115111611171118111911201121112211231124112511261127112811291130113111321133113411351136113711381139114011411142114311441145114611471148114911501151115211531154115511561157
  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. console.log("期初",list[i].stockIn)
  271. console.log("增加",list[i].stockAdd)
  272. console.log("出库",list[i].outStock)
  273. if((list[i].stockIn + list[i].stockAdd - list[i].outStock)>0 ){
  274. list[i].overStock = list[i].stockIn + list[i].stockAdd - list[i].outStock
  275. }else{
  276. list[i].overStock = 0
  277. }
  278. }
  279. list[i].overPrice = "/"
  280. list[i].overMoney = "/"
  281. }
  282. console.log("listwowowoowowowow",list)
  283. this.tableList = list
  284. this.total = response.data.data.total
  285. this.manufacturerList = response.data.data.manufacturerList
  286. }
  287. })
  288. },
  289. getManufacturName(id){
  290. var manufacturer_name = ""
  291. for(let i=0;i<this.manufacturerList.length;i++){
  292. if(id == this.manufacturerList[i].id){
  293. manufacturer_name = this.manufacturerList[i].manufacturer_name
  294. }
  295. }
  296. return manufacturer_name
  297. },
  298. handleSizeChange(val) {
  299. this.limit = val;
  300. this.getlist()
  301. },
  302. handleCurrentChange(val) {
  303. this.page = val;
  304. this.getlist()
  305. },
  306. handleSizeChangeOne(val) {
  307. this.limitone = val;
  308. this.toDialogClick(this.good_id,this.good_name,this.specification_name)
  309. },
  310. handleCurrentChangeOne(val) {
  311. this.pageone = val;
  312. this.toDialogClick(this.good_id,this.good_name,this.specification_name)
  313. },
  314. seach(){
  315. this.goodTypeList = []
  316. this.getStorehouseList()
  317. this.getlist()
  318. },
  319. getGoodTypeName(id){
  320. var type_name = ""
  321. for(let i=0;i<this.goodTypeList.length;i++){
  322. if(id == this.goodTypeList[i].id){
  323. type_name = this.goodTypeList[i].type_name
  324. }
  325. }
  326. return type_name
  327. },
  328. getHouseName(id){
  329. var storehouse_name = ""
  330. for(let i=0;i<this.houseList.length;i++){
  331. if(id == this.houseList[i].id){
  332. storehouse_name = this.houseList[i].storehouse_name
  333. }
  334. }
  335. return storehouse_name
  336. },
  337. getWareInfoCount(val,storehouse_id){
  338. var count = 0
  339. if(val.length > 0){
  340. for(let i=0;i<val.length;i++){
  341. if(val[i].storehouse_id == storehouse_id){
  342. count +=val[i].warehousing_count
  343. }
  344. }
  345. }
  346. if(count > 0){
  347. return count
  348. }else{
  349. return ""
  350. }
  351. },
  352. getStockDrugCount(){
  353. var params ={
  354. keywords: this.keywords,
  355. start_time:this.start_time,
  356. end_time:this.end_time,
  357. }
  358. getStockDrugCount(params).then(response=>{
  359. if(response.data.state == 1){
  360. var outlist = response.data.data.outList
  361. this.outCountList = outlist
  362. var autoCount = response.data.data.autoCount
  363. this.autoCountList = autoCount
  364. var totalCount = response.data.data.totalCount
  365. this.cancelCountList = totalCount
  366. }
  367. })
  368. },
  369. getWareInfoCountOne(val,storehouse_id){
  370. var count = 0
  371. if(val.length > 0){
  372. for(let i=0;i<val.length;i++){
  373. if(val[i].storehouse_id == storehouse_id){
  374. count +=val[i].stock_count
  375. }
  376. }
  377. }
  378. if(count > 0){
  379. return count
  380. }else{
  381. return ""
  382. }
  383. },
  384. getOutCount(id){
  385. var count = 0
  386. for(let i=0;i<this.outCountList.length;i++){
  387. if(id == this.outCountList[i].good_id){
  388. count = this.outCountList[i].count
  389. }
  390. }
  391. return count
  392. },
  393. getAutoCount(id){
  394. var count= 0
  395. for(let i=0;i<this.autoCountList.length;i++){
  396. if(id == this.autoCountList[i].good_id){
  397. count = this.autoCountList[i].count
  398. }
  399. }
  400. return count
  401. },
  402. getCancelCount(id){
  403. var count = 0
  404. for(let i=0;i<this.cancelCountList.length;i++){
  405. if(id == this.cancelCountList[i].good_id){
  406. count = this.cancelCountList[i].count
  407. }
  408. }
  409. return count
  410. },
  411. getCancelCountInfo(cancel_stock_info,storehouse_id){
  412. var count = 0
  413. if(cancel_stock_info.length >0){
  414. for(let i=0;i<cancel_stock_info.length;i++){
  415. if(storehouse_id == cancel_stock_info[i].storehouse_id){
  416. count += cancel_stock_info[i].count
  417. }
  418. }
  419. }
  420. return count
  421. },
  422. getWareOutInfoCount(warehouse_out_info,storehouse_id){
  423. var count = 0
  424. if(warehouse_out_info.length > 0){
  425. for(let i=0;i<warehouse_out_info.length;i++){
  426. if(storehouse_id == warehouse_out_info[i].storehouse_id){
  427. count +=warehouse_out_info[i].count
  428. }
  429. }
  430. }
  431. return count
  432. },
  433. getInCount(id){
  434. var count= 0
  435. for(let i=0;i<this.countList.length;i++){
  436. if(id == this.countList[i].good_id){
  437. count = this.countList[i].count
  438. }
  439. }
  440. return count
  441. },
  442. getOutCount(id){
  443. var count = 0
  444. for(let i=0;i<this.outCountList.length;i++){
  445. if(id == this.outCountList[i].good_id){
  446. count = this.outCountList[i].count
  447. }
  448. }
  449. return count
  450. },
  451. getAutoCount(id){
  452. var count= 0
  453. for(let i=0;i<this.autoCountList.length;i++){
  454. if(id == this.autoCountList[i].good_id){
  455. count = this.autoCountList[i].count
  456. }
  457. }
  458. return count
  459. },
  460. getCancelCount(id){
  461. var count = 0
  462. for(let i=0;i<this.cancelCountList.length;i++){
  463. if(id == this.cancelCountList[i].good_id){
  464. count = this.cancelCountList[i].count
  465. }
  466. }
  467. return count
  468. },
  469. getStockCount(id){
  470. var stock_count = 0
  471. for(let i=0;i<this.countList.length;i++){
  472. if(id == this.countList[i].good_id){
  473. stock_count = this.countList[i].stock_count
  474. }
  475. }
  476. return stock_count
  477. },
  478. getWareInfo(arr){
  479. var total = 0
  480. if(arr.length > 0){
  481. for(let i=0;i<arr.length;i++){
  482. total += parseInt(arr[i].warehousing_count)
  483. }
  484. }else{
  485. total = ""
  486. }
  487. return total
  488. },
  489. getOverplus(arr){
  490. var total = 0
  491. if(arr.length > 0){
  492. for(let i=0;i<arr.length;i++){
  493. total += arr[i].stock_count
  494. }
  495. }else{
  496. total = ""
  497. }
  498. return total
  499. },
  500. getCancelInfo(arr){
  501. var total = 0
  502. if(arr.length > 0){
  503. for(let i=0;i<arr.length;i++){
  504. total += arr[i].count
  505. }
  506. }else{
  507. total = ""
  508. }
  509. return total
  510. },
  511. getOverFlushInfo(arr){
  512. var total = 0
  513. if(arr.length >0){
  514. for(let i=0;i<arr.length;i++){
  515. total += arr[i].stock_count
  516. }
  517. }
  518. return total
  519. },
  520. startFirstTimeChange(){
  521. this.getlist()
  522. },
  523. endEndTimeChange(){
  524. this.getlist()
  525. },
  526. getTime(val) {
  527. if(val < 0){
  528. return ""
  529. }
  530. if(val == ""){
  531. return ""
  532. }else {
  533. return uParseTime(val, '{y}-{m}-{d}')
  534. }
  535. },
  536. getName(id){
  537. var name = ""
  538. for(let i=0;i<this.patientList.length;i++){
  539. if(id == this.patientList[i].id){
  540. name = this.patientList[i].name
  541. }
  542. }
  543. return name
  544. },
  545. endTimeChange(){
  546. this.getlist()
  547. },
  548. startTimeChange(){
  549. this.getlist()
  550. },
  551. getWarehouseInfoStart(arr1,arr2,arr3,arr4,arr5){
  552. var count =0
  553. var countOne =0
  554. var countTwo= 0
  555. var countthree = 0 //期初
  556. var countfour = 0
  557. var countfive = 0
  558. if(arr1!=null && arr1.length > 0){
  559. for(let i=0;i<arr1.length;i++){
  560. countOne +=arr1[i].count
  561. }
  562. }
  563. if(arr2!=null && arr2.length > 0){
  564. for(let i=0;i<arr2.length;i++){
  565. countTwo +=arr2[i].count
  566. }
  567. }
  568. if(arr3!=null && arr3.length > 0){
  569. for(let i=0;i<arr3.length;i++){
  570. countthree +=arr3[i].count
  571. }
  572. }
  573. if(arr4!=null && arr4.length > 0){
  574. for(let i=0;i<arr4.length;i++){
  575. countfour +=arr4[i].count
  576. }
  577. }
  578. if(arr5!=null && arr5.length > 0){
  579. for(let i=0;i<arr5.length;i++){
  580. countfive +=arr5[i].count
  581. }
  582. }
  583. console.log("countOne",countOne)
  584. console.log("countTwo",countTwo)
  585. console.log("countthree",countthree)
  586. console.log("countfour",countfour)
  587. console.log("*********************")
  588. count = countOne - countTwo + countthree - countfour + countfive
  589. if(count > 0 ){
  590. return count
  591. }else{
  592. return 0
  593. }
  594. },
  595. getWarehouseInfo(val){
  596. var count =0
  597. for(let i=0;i<val.length;i++){
  598. count +=val[i].stock_count
  599. }
  600. if(count > 0 ){
  601. return count
  602. }else{
  603. return 0
  604. }
  605. },
  606. getWarehouseInfoOne(val,val2){
  607. var count =0
  608. var countOne = 0
  609. var all_count = 0
  610. if(val!=null && val.length >0){
  611. for(let i=0;i<val.length;i++){
  612. count +=val[i].count
  613. }
  614. }
  615. if(val2!=null && val2.length > 0){
  616. for(let i=0;i<val2.length;i++){
  617. countOne +=val2[i].count
  618. }
  619. }
  620. all_count = count + countOne
  621. console.log("count2332323223232o2222222222wide",count)
  622. console.log("countONE23232322323323223",countOne)
  623. console.log("all_count9999999999999wode",all_count)
  624. console.log("-------------------------------------------")
  625. if(all_count > 0 ){
  626. return all_count
  627. }else{
  628. return 0
  629. }
  630. },
  631. getAddStockMony(val,val2){
  632. var total_price =0
  633. var total_price_one = 0
  634. var all_price = 0
  635. if(val!=null && val.length >0){
  636. for(let i=0;i<val.length;i++){
  637. total_price +=val[i].count * val[i].buy_price
  638. }
  639. }
  640. if(val2!=null && val2.length > 0){
  641. for(let i=0;i<val2.length;i++){
  642. total_price_one +=val2[i].count * val2[i].price
  643. }
  644. }
  645. all_price = total_price + total_price_one
  646. if(all_price >0 ){
  647. return total_price.toFixed(2)
  648. }else{
  649. return "0.00"
  650. }
  651. },
  652. getSaleStockMony(val,val2){
  653. var total_price =0
  654. var total_price_one = 0
  655. var all_price = 0
  656. if(val!=null && val.length >0){
  657. for(let i=0;i<val.length;i++){
  658. total_price +=val[i].count * val[i].price
  659. }
  660. }
  661. if(val2!=null && val2.length > 0){
  662. for(let i=0;i<val2.length;i++){
  663. total_price_one +=val2[i].count * val2[i].price
  664. }
  665. }
  666. all_price = total_price + total_price_one
  667. if(all_price >0 ){
  668. return all_price.toFixed(2)
  669. }else{
  670. return "0.00"
  671. }
  672. },
  673. getWarehouseOut(val){
  674. var count = 0
  675. for(let i=0;i<val.length;i++){
  676. count +=val[i].count
  677. }
  678. if(count >0){
  679. return count
  680. }else{
  681. return 0
  682. }
  683. },
  684. open(){
  685. // this.start_time = moment().year(2022).month(10).date(4).format('YYYY-MM-DD')
  686. this.start_time = moment().startOf('month').format('YYYY-MM-DD')
  687. this.end_time = moment(new Date()).add('year',0).format("YYYY-MM-DD")
  688. this.houseList = []
  689. this.goodTypeList= []
  690. this.getStorehouseList()
  691. this.getlist()
  692. //this.getStockDrugCount()
  693. },
  694. getWarehouseInfoStartPrice(arr,arr1,arr2,arr3,arr4){
  695. var total_price = 0
  696. var total_price_one = 0
  697. var total_price_two = 0
  698. var total_price_three = 0
  699. var total_price_four = 0
  700. var total_price_all = 0
  701. if(arr!=null&&arr.length > 0){
  702. for(let i=0;i<arr.length;i++){
  703. total_price += arr[i].count * arr[i].buy_price
  704. }
  705. }
  706. if(arr1!=null && arr1.length > 0){
  707. for(let i=0;i<arr1.length;i++){
  708. total_price_one +=arr1[i].count * arr1[i].buy_price
  709. }
  710. }
  711. if(arr2!=null && arr2.length > 0){
  712. for(let i=0;i<arr2.length;i++){
  713. total_price_two +=arr2[i].count * arr2[i].buy_price
  714. }
  715. }
  716. if(arr3!=null && arr3.length > 0){
  717. for(let i=0;i<arr3.length;i++){
  718. total_price_three +=arr3[i].count * arr3[i].buy_price
  719. }
  720. }
  721. if(arr4!=null && arr4.length > 0){
  722. for(let i=0;i<arr4.length;i++){
  723. total_price_three +=arr4[i].count * arr4[i].buy_price
  724. }
  725. }
  726. total_price_all = total_price - total_price_one + total_price_two - total_price_three + total_price_four
  727. if (total_price_all > 0) {
  728. return total_price_all.toFixed(2)
  729. }else{
  730. return "0.00"
  731. }
  732. },
  733. getWarehouseInfoStartMoney(arr,arr1,arr2,arr3,arr4){
  734. var total_price = 0
  735. var total_price_one = 0
  736. var total_price_two = 0
  737. var total_price_three = 0
  738. var total_price_four = 0
  739. var total_price_all = 0
  740. if(arr!=null && arr.length >0){
  741. for(let i=0;i<arr.length;i++){
  742. total_price +=arr[i].count * arr[i].price
  743. }
  744. }
  745. if(arr1!=null && arr1.length > 0){
  746. for(let i=0;i<arr1.length;i++){
  747. total_price_one +=arr1[i].count * arr1[i].price
  748. }
  749. }
  750. if(arr2!=null && arr2.length > 0){
  751. for(let i=0;i<arr2.length;i++){
  752. total_price_two +=arr2[i].count * arr2[i].price
  753. }
  754. }
  755. if(arr3!=null && arr3.length > 0){
  756. for(let i=0;i<arr3.length;i++){
  757. total_price_three +=arr3[i].count * arr3[i].price
  758. }
  759. }
  760. if(arr4!=null && arr4.length > 0){
  761. for(let i=0;i<arr4.length;i++){
  762. total_price_four +=arr4[i].count * arr4[i].price
  763. }
  764. }
  765. total_price_all = total_price - total_price_one + total_price_two - total_price_three + total_price_four
  766. if (total_price_all > 0) {
  767. return total_price_all.toFixed(2)
  768. }else{
  769. return "0.00"
  770. }
  771. },
  772. getWarehosueOutInfo(val,val2,val3){
  773. var count = 0
  774. var count_one = 0
  775. var all_count = 0
  776. var count_two = 0
  777. if(val!=null && val.length >0){
  778. for(let i=0;i<val.length;i++){
  779. count +=val[i].count
  780. }
  781. }
  782. if(val2!=null && val2.length > 0){
  783. for(let i=0;i<val2.length;i++){
  784. count_one +=val2[i].count
  785. }
  786. }
  787. if(val3!=null && val3.length > 0){
  788. for(let i=0;i<val3.length;i++){
  789. count_two +=val3[i].count
  790. }
  791. }
  792. console.log("countwowowoowow3333",count)
  793. console.log("count_one222222",count_one)
  794. console.log("count_two222222",count_two)
  795. all_count = count +count_one - count_two
  796. console.log("数据我哦我我",all_count)
  797. if(all_count >0){
  798. return all_count
  799. }else{
  800. return 0
  801. }
  802. },
  803. stockOutprice(val,val2,val3){
  804. var total_price = 0
  805. var total_price_one = 0
  806. var total_price_two = 0
  807. var all_price = 0
  808. if(val!=null && val.length >0){
  809. for(let i=0;i<val.length;i++){
  810. total_price +=val[i].count * val[i].buy_price
  811. }
  812. }
  813. if(val2!=null && val2.length > 0){
  814. for(let i=0;i<val2.length;i++){
  815. total_price_one +=val2[i].count * val2[i].buy_price
  816. }
  817. }
  818. if(val3!=null && val3.length > 0){
  819. for(let i=0;i<val3.length;i++){
  820. total_price_two +=val3[i].count * val3[i].buy_price
  821. }
  822. }
  823. all_price = total_price + total_price_one - total_price_two
  824. if(all_price >0){
  825. return all_price.toFixed(2)
  826. }else{
  827. return "0.00"
  828. }
  829. },
  830. saleOutprice(val,val2,val3){
  831. var total_price = 0
  832. var total_price_one = 0
  833. var all_price = 0
  834. var total_price_two = 0
  835. if(val!=null && val.length >0){
  836. for(let i=0;i<val.length;i++){
  837. total_price +=val[i].count * val[i].xt_warehouse_info.packing_price
  838. }
  839. }
  840. if(val2!=null && val2.length > 0){
  841. for(let i=0;i<val2.length;i++){
  842. total_price_one +=val2[i].count * val2[i].price
  843. }
  844. }
  845. if(val3!=null && val3.length > 0){
  846. for(let i=0;i<val3.length;i++){
  847. total_price_two +=val3[i].count * val3[i].price
  848. }
  849. }
  850. all_price = total_price + total_price_one - total_price_two
  851. if(all_price >0){
  852. return all_price.toFixed(2)
  853. }else{
  854. return "0.00"
  855. }
  856. },
  857. getEndWarehouseInfo(val,val3,val1,val2,val4){
  858. var count = 0
  859. var count_one = 0
  860. var count_two = 0
  861. var count_three =0
  862. var count_four = 0
  863. var all_count = 0
  864. if(val!=null && val.length >0){
  865. for(let i=0;i<val.length;i++){
  866. count +=val[i].count
  867. }
  868. }
  869. if(val1!=null&&val1.length >0){
  870. for(let i=0;i<val1.length;i++){
  871. count_one +=val1[i].count
  872. }
  873. }
  874. if(val3!=null&& val3.length > 0){
  875. for(let i=0;i<val3.length;i++){
  876. count_three +=val3[i].count
  877. }
  878. }
  879. if(val2!=null&&val2.length >0){
  880. for(let i=0;i<val2.length;i++){
  881. count_two +=val2[i].count
  882. }
  883. }
  884. if(val4!=null&&val4.length >0){
  885. for(let i=0;i<val4.length;i++){
  886. count_four +=val4[i].count
  887. }
  888. }
  889. all_count = count- count_three + count_one - count_two + count_four
  890. if(all_count >0){
  891. return all_count
  892. }else{
  893. return 0
  894. }
  895. },
  896. getEndOverPrice(val,val3,val1,val2,val4){
  897. var total_price = 0
  898. var total_price_one = 0
  899. var total_price_two = 0
  900. var total_price_three = 0
  901. var total_price_four =0
  902. var all_price = 0
  903. if(val!=null && val.length >0){
  904. for(let i=0;i<val.length;i++){
  905. total_price +=val[i].count * val[i].buy_price
  906. }
  907. }
  908. if(val1!=null && val1.length > 0){
  909. for(let i=0;i<val1.length;i++){
  910. total_price_one +=val1[i].count * val1[i].buy_price
  911. }
  912. }
  913. if(val3!=null && val3.length > 0){
  914. for(let i=0;i<val3.length;i++){
  915. total_price_three +=val3[i].count * val3[i].buy_price
  916. }
  917. }
  918. if(val2!=null && val2.length > 0){
  919. for(let i=0;i<val2.length;i++){
  920. total_price_two +=val2[i].count * val2[i].buy_price
  921. }
  922. }
  923. if(val4!=null && val4.length > 0){
  924. for(let i=0;i<val4.length;i++){
  925. total_price_four +=val4[i].count * val4[i].buy_price
  926. }
  927. }
  928. console.log("total_price",total_price)
  929. console.log("total_price_three",total_price_three)
  930. console.log("total_price_two",total_price_two)
  931. console.log("total_price_one",total_price_one)
  932. console.log("total_price_four",total_price_four)
  933. all_price = total_price- total_price_three +total_price_one - total_price_two + total_price_four
  934. console.log("arrll_price",all_price)
  935. if(all_price >0){
  936. return all_price.toFixed(2)
  937. }else{
  938. return "0.00"
  939. }
  940. },
  941. getEndSalePrice(val,val3,val1,val2,val4){
  942. var total_price = 0
  943. var total_price_one = 0
  944. var total_price_two = 0
  945. var total_price_three = 0
  946. var total_price_four = 0
  947. var all_price= 0
  948. if(val!=null && val.length >0){
  949. for(let i=0;i<val.length;i++){
  950. total_price +=val[i].count * val[i].price
  951. }
  952. }
  953. if(val1!=null && val1.length >0){
  954. for(let i=0;i<val1.length;i++){
  955. total_price_one +=val1[i].count * val1[i].price
  956. }
  957. }
  958. if(val3!=null && val3.length >0){
  959. for(let i=0;i<val3.length;i++){
  960. total_price_three +=val3[i].count * val3[i].price
  961. }
  962. }
  963. if(val2!=null && val2.length >0){
  964. for(let i=0;i<val2.length;i++){
  965. total_price_two +=val2[i].count * val2[i].price
  966. }
  967. }
  968. if(val4!=null && val4.length >0){
  969. for(let i=0;i<val4.length;i++){
  970. total_price_four +=val4[i].count * val4[i].price
  971. }
  972. }
  973. var all_price = total_price-total_price_three + total_price_one - total_price_two + total_price_four
  974. if(all_price >0){
  975. return all_price.toFixed(2)
  976. }else{
  977. return "0.00"
  978. }
  979. },
  980. toPrint(){
  981. 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})
  982. },
  983. exportList: function() {
  984. if(this.org_id!=0&& this.org_id!=9956){
  985. for(let i=0;i<this.tableList.length;i++){
  986. this.tableList[i].index = i+1
  987. this.tableList[i].query_date = this.start_time+"~"+this.end_time
  988. this.tableList[i].good_type = this.getGoodTypeName(this.tableList[i].good_type_id)
  989. this.tableList[i].manufacturer_name = this.getManufacturName(this.tableList[i].manufacturer)
  990. this.tableList[i].dealer_name = this.getDearName(this.tableList[i].dealer)
  991. this.tableList[i].specification_name_one = this.tableList[i].specification_name + "/"+this.tableList[i].packing_unit
  992. }
  993. import('@/vendor/Export2Excel').then(excel => {
  994. const multiHeader = [['序号', '查询日期',' 耗材类型','耗材名称','规格&单位','生产产商','经销商', '期初结余' , '', '', '本期增加', '', '', '本期减少' , '', '', '期末结余' , '', '']]
  995. const header = ['', '','','','','','', '数量', '进货金额', '销售金额', '数量', '进货金额', '销售金额', '数量', '进货金额', '销售金额', '数量', '进货金额', '销售金额']
  996. const merges = ['A1:A2', 'B1:B2','C1:C2','D1:D2','E1:E2','F1:F2','G1:G2','H1:J1', 'K1:M1', 'N1:P1', 'Q1:S1']
  997. 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']
  998. const data = this.formatJson(filterVal, this.tableList)
  999. const filename = '进销存查询'
  1000. excel.export_json_to_excel({
  1001. multiHeader,
  1002. header,
  1003. merges,
  1004. data,
  1005. filename
  1006. })
  1007. })
  1008. }
  1009. if(this.org_id == 0 || this.org_id == 9956){
  1010. for(let i=0;i<this.tableList.length;i++){
  1011. this.tableList[i].index = i+1
  1012. this.tableList[i].query_date = this.start_time+"~"+this.end_time
  1013. this.tableList[i].good_type = this.getGoodTypeName(this.tableList[i].good_type_id)
  1014. this.tableList[i].manufacturer_name = this.getManufacturName(this.tableList[i].manufacturer)
  1015. this.tableList[i].dealer_name = this.getDearName(this.tableList[i].dealer)
  1016. this.tableList[i].specification_name_one = this.tableList[i].specification_name + "/"+this.tableList[i].packing_unit
  1017. }
  1018. import('@/vendor/Export2Excel').then(excel => {
  1019. const multiHeader = [['序号','耗材编码', '查询日期',' 耗材类型','耗材名称','规格&单位','生产产商','经销商', '期初结余' , '', '', '本期增加', '', '', '本期减少' , '', '', '期末结余' , '', '']]
  1020. const header = ['','', '','','','','','', '数量', '进货金额', '销售金额', '数量', '进货金额', '销售金额', '数量', '进货金额', '销售金额', '数量', '进货金额', '销售金额']
  1021. 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']
  1022. 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']
  1023. const data = this.formatJson(filterVal, this.tableList)
  1024. const filename = '进销存查询'
  1025. excel.export_json_to_excel({
  1026. multiHeader,
  1027. header,
  1028. merges,
  1029. data,
  1030. filename
  1031. })
  1032. })
  1033. }
  1034. },
  1035. formatJson(filterVal, jsonData) {
  1036. return jsonData.map(v => filterVal.map(j => v[j]));
  1037. },
  1038. toOverCount(){
  1039. getGoodOverCount().then(response=>{
  1040. if(response.data.state == 1){
  1041. var msg = response.data.data.msg
  1042. this.$message.success("调试成功")
  1043. }
  1044. })
  1045. },
  1046. getDearName(id){
  1047. var dear_name = ""
  1048. for(let i=0;i<this.dealerList.length;i++){
  1049. if(id == this.dealerList[i].id){
  1050. dear_name = this.dealerList[i].dealer_name
  1051. }
  1052. }
  1053. return dear_name
  1054. },
  1055. getAllStockIn(val){
  1056. var count = 0
  1057. if(val!=null && val.length>0){
  1058. for(let i=0;i<val.length;i++){
  1059. count+= val[i].warehousing_count
  1060. }
  1061. }
  1062. return count
  1063. },
  1064. getAllOutStockIn(val){
  1065. var count = 0
  1066. if(val!=null && val.length>0){
  1067. for(let i=0;i<val.length;i++){
  1068. count +=val[i].count
  1069. }
  1070. }
  1071. return count
  1072. },
  1073. getAllStockInFlow(val){
  1074. var count = 0
  1075. if(val!=null && val.length>0){
  1076. for(let i=0;i<val.length;i++){
  1077. count+= val[i].count
  1078. }
  1079. }
  1080. return count
  1081. },
  1082. getAllStockOutFlow(val){
  1083. var count = 0
  1084. if(val!=null && val.length>0){
  1085. for(let i=0;i<val.length;i++){
  1086. count+= val[i].count
  1087. }
  1088. }
  1089. return count
  1090. }
  1091. },
  1092. }
  1093. </script>