purchaseNewStockQuery.vue 35KB

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