purchaseNewStockQuery.vue 46KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886887888889890891892893894895896897898899900901902903904905906907908909910911912913914915916917918919920921922923924925926927928929930931932933934935936937938939940941942943944945946947948949950951952953954955956957958959960961962963964965966967968969970971972973974975976977978979980981982983984985986987988989990991992993994995996997998999100010011002100310041005100610071008100910101011101210131014101510161017101810191020102110221023102410251026102710281029103010311032103310341035103610371038103910401041104210431044104510461047104810491050105110521053105410551056105710581059106010611062106310641065106610671068106910701071107210731074107510761077107810791080108110821083108410851086108710881089109010911092109310941095109610971098109911001101110211031104110511061107110811091110111111121113111411151116111711181119112011211122112311241125112611271128112911301131113211331134113511361137113811391140114111421143114411451146114711481149115011511152115311541155115611571158115911601161116211631164116511661167116811691170117111721173117411751176117711781179118011811182118311841185118611871188118911901191119211931194119511961197119811991200120112021203120412051206120712081209121012111212121312141215121612171218121912201221122212231224122512261227122812291230123112321233123412351236123712381239124012411242124312441245124612471248124912501251125212531254125512561257125812591260126112621263126412651266126712681269127012711272127312741275127612771278127912801281128212831284128512861287128812891290129112921293129412951296129712981299130013011302130313041305130613071308130913101311131213131314131513161317131813191320132113221323132413251326132713281329133013311332133313341335133613371338133913401341134213431344134513461347134813491350135113521353135413551356135713581359136013611362136313641365136613671368136913701371137213731374137513761377137813791380138113821383138413851386138713881389139013911392139313941395139613971398139914001401140214031404140514061407140814091410141114121413141414151416141714181419142014211422
  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. :picker-options="pickerOptions"
  22. :clearable="false"
  23. ></el-date-picker>
  24. <span>-</span>
  25. <el-date-picker
  26. size="small"
  27. v-model="end_time"
  28. prefix-icon="el-icon-date"
  29. :editable="false"
  30. style="width: 150px;"
  31. type="date"
  32. placeholder="选择日期时间"
  33. align="right"
  34. format="yyyy-MM-dd"
  35. value-format="yyyy-MM-dd"
  36. :picker-options="pickerOptions"
  37. :clearable="false"
  38. ></el-date-picker>
  39. <el-button type="primary" icon="el-icon-search" @click="getAllQuery">查询</el-button>
  40. <span style="font-size:14px;color:#606266">库存预警:</span>
  41. <el-select v-model="query_type" style="width:250px;margin-right:10px;" placeholder="请选择"
  42. filterable
  43. @change="changeGoodName">
  44. <el-option
  45. v-for="item in goodList"
  46. :key="item.id"
  47. :label="item.name"
  48. :value="item.id">
  49. </el-option>
  50. </el-select>
  51. <span style="font-size:14px;color:#606266">耗材类型:</span>
  52. <el-select v-model="good_type" style="width:200px;margin-right:10px;" placeholder="请选择"
  53. filterable
  54. @change="changeGoodTypeName">
  55. <el-option
  56. v-for="item in goodTypeList"
  57. :key="item.id"
  58. :label="item.type_name"
  59. :value="item.id">
  60. </el-option>
  61. </el-select>
  62. <el-input v-model="keyword" style="width:200px" placeholder="请输入耗材名称或生产厂商" ></el-input>
  63. <el-button type="primary" icon="el-icon-search" @click="seach">搜索</el-button>
  64. </div>
  65. <div>
  66. <!-- <el-button type="primary" size="small" @click="toOverCount">调试</el-button> -->
  67. <el-button type="primary" size="small" @click="toPrint">打印</el-button>
  68. <el-button type="primary" size="small" @click="exportList">导出</el-button>
  69. </div>
  70. </div>
  71. <el-table
  72. :row-style="{ color: '#303133' }"
  73. :header-cell-style="{
  74. backgroundColor: 'rgb(245, 247, 250)',
  75. color: '#606266'
  76. }"
  77. :data="tableList"
  78. :class="signAndWeighBoxPatients"
  79. border
  80. >
  81. <el-table-column label="耗材编码" align="center" v-if="org_id ==9956 || org_id == 0">
  82. <template slot-scope="scope">
  83. <span>{{ scope.row.good_number?scope.row.good_number:"" }}</span>
  84. </template>
  85. </el-table-column>
  86. <el-table-column label="国家编码" align="center">
  87. <template slot-scope="scope">
  88. <span>{{ scope.row.social_security_directory_code?scope.row.social_security_directory_code:"" }}</span>
  89. </template>
  90. </el-table-column>
  91. <el-table-column label="耗材类型" align="center">
  92. <template slot-scope="scope">
  93. {{getGoodTypeName(scope.row.good_type_id)}}
  94. </template>
  95. </el-table-column>
  96. <el-table-column label="耗材名称" align="center">
  97. <template slot-scope="scope">
  98. {{scope.row.good_name}}
  99. </template>
  100. </el-table-column>
  101. <el-table-column label="规格&单位" align="center">
  102. <template slot-scope="scope">
  103. {{scope.row.specification_name}}/{{scope.row.packing_unit}}
  104. </template>
  105. </el-table-column>
  106. <el-table-column label="生产厂商" align="center" v-if="org_id!=10679">
  107. <template slot-scope="scope">
  108. {{getManufacturName(scope.row.manufacturer)}}
  109. </template>
  110. </el-table-column>
  111. <el-table-column label="经销商" align="center">
  112. <template slot-scope="scope">
  113. {{getDearName(scope.row.dealer)}}
  114. </template>
  115. </el-table-column>
  116. <el-table-column label="期初结余" align="center">
  117. <el-table-column prop="stockIn" label="数量" width="100">
  118. </el-table-column>
  119. <el-table-column prop="stock_in_price" label="进货金额" width="100">
  120. </el-table-column>
  121. <el-table-column prop="stockMoney" label="销售金额" width="100">
  122. </el-table-column>
  123. </el-table-column>
  124. <el-table-column label="本期增加" align="center">
  125. <el-table-column prop="stockAdd" label="数量" width="100">
  126. </el-table-column>
  127. <el-table-column prop="addStockMoney" label="进货金额" width="100">
  128. </el-table-column>
  129. <el-table-column prop="saleStockMoney" label="销售金额" width="100">
  130. </el-table-column>
  131. </el-table-column>
  132. <el-table-column label="本期减少" align="center">
  133. <el-table-column prop="outStock" label="数量" width="100">
  134. </el-table-column>
  135. <el-table-column prop="stockOutprice" label="进货金额" width="100">
  136. </el-table-column>
  137. <el-table-column prop="saleOutMoney" label="销售金额" width="100">
  138. </el-table-column>
  139. </el-table-column>
  140. <el-table-column label="期末结余" align="center">
  141. <el-table-column prop="overStock" label="数量" width="100">
  142. </el-table-column>
  143. <el-table-column prop="overPrice" label="进货金额" width="100">
  144. </el-table-column>
  145. <el-table-column prop="overMoney" label="销售金额" width="100">
  146. </el-table-column>
  147. </el-table-column>
  148. </el-table>
  149. <el-pagination
  150. @size-change="handleSizeChange"
  151. @current-change="handleCurrentChange"
  152. :page-sizes="[10, 50, 100,200,300,400,500,1000]"
  153. :page-size="10"
  154. background
  155. align="right"
  156. style="margin-top:20px;"
  157. layout="total, sizes, prev, pager, next, jumper"
  158. :total="total"
  159. >
  160. </el-pagination>
  161. </div>
  162. </div>
  163. </template>
  164. <script>
  165. import { getStorehouseList,getNewPurchaseStockQuery,getGoodOverCount } from "@/api/drug/drug"
  166. import {
  167. getStockDrugCount
  168. } from "@/api/stock";
  169. import { uParseTime } from '@/utils/tools'
  170. const moment = require('moment')
  171. export default {
  172. data(){
  173. return{
  174. tableList:[],
  175. goodList:[
  176. {id:1,name:"全部耗材"},
  177. {id:2,name:"库存预警"},
  178. {id:3,name:"库存为零"},
  179. {id:4,name:"库存不为零"},
  180. ],
  181. houseList:[],
  182. storehouse_id:0,
  183. good_type:0,
  184. multipleSelection: [],
  185. signAndWeighBoxPatients: "sign-and-weigh-box-patients",
  186. manufacturerList:[],
  187. limit:10,
  188. page:1,
  189. total:0,
  190. keyword:"",
  191. goodTypeList:[],
  192. start_time:"",
  193. end_time:"",
  194. countList:[],
  195. outCountList:[],
  196. autoCountList:[],
  197. cancelCountList:[],
  198. org_id:this.$store.getters.xt_user.org_id,
  199. dialogVisible:false,
  200. start_first_time:"",
  201. end_first_time:"",
  202. tableData:[],
  203. good_id:0,
  204. patientList:[],
  205. good_name:"",
  206. specification_name:"",
  207. loading:false,
  208. pickerOptions:{ //禁用当前日期之前的日期
  209. disabledDate(v) {
  210. return v.getTime() < 1667491200000
  211. },
  212. },
  213. dealerList:[],
  214. medicalInsuranceLevelList:[],
  215. query_type:1
  216. }
  217. },
  218. methods:{
  219. changeGoodName(){
  220. this.getlist()
  221. },
  222. changeStorehouseName(){
  223. },
  224. changeGoodTypeName(){
  225. this.getlist()
  226. },
  227. getStorehouseList(){
  228. getStorehouseList().then(response=>{
  229. if(response.data.state == 1){
  230. var houseList = response.data.data.list
  231. var obj = {id:0,storehouse_name:"全部"}
  232. this.houseList.push(obj)
  233. for(let i=0;i<houseList.length;i++){
  234. this.houseList.push(houseList[i])
  235. }
  236. this.manufacturerList = response.data.data.manufacturerList
  237. var obj = {id:0,type_name:"全部"}
  238. this.goodTypeList.push(obj)
  239. var goodTypeList = response.data.data.goodTypeList
  240. for(let i=0;i<goodTypeList.length;i++){
  241. this.goodTypeList.push(goodTypeList[i])
  242. }
  243. this.patientList = response.data.data.patientList
  244. this.dealerList = response.data.data.dealerList
  245. }
  246. })
  247. },
  248. getlist(){
  249. this.loading = true
  250. var params = {
  251. good_type:this.good_type,
  252. keyword:this.keyword,
  253. page:this.page,
  254. limit:this.limit,
  255. start_time:this.start_time,
  256. end_time:this.end_time,
  257. query_type:this.query_type,
  258. }
  259. getNewPurchaseStockQuery(params).then(response=>{
  260. if(response.data.state == 1){
  261. var list = response.data.data.list
  262. this.loading = false
  263. for(let i=0;i<list.length;i++){
  264. if(this.org_id ==10210 || this.org_id ==10215 || this.org_id == 10265){
  265. list[i].stockIn = list[i].GoodStartFlowInfo.over_count
  266. }else{
  267. console.log("HHAHHAHA",list[i].id)
  268. console.log("耗材id",list[i].specification_name)
  269. console.log("入库",this.getAllStockIn(list[i].StWarehousingInfoTwo))
  270. console.log("盘盈",this.getAllStockInFlow(list[i].WareStartInStockFlow))
  271. console.log("出库",this.getAllOutStockIn(list[i].WarehouseOutInfoTenty) )
  272. console.log("盘亏",this.getAllStockOutFlow(list[i].WareStartOutStockFlow))
  273. //针对武穴软水盐的问题
  274. if(list[i].id== 5052){
  275. list[i].stockIn = list[i].GoodStartFlowInfo.over_count
  276. }else{
  277. list[i].stockIn = this.getAllStockIn(list[i].StWarehousingInfoTwo) + this.getAllStockInFlow(list[i].WareStartInStockFlow) - this.getAllOutStockIn(list[i].WarehouseOutInfoTenty) - this.getAllStockOutFlow(list[i].WareStartOutStockFlow)
  278. if(list[i].stockIn <0){
  279. list[i].stockIn =0
  280. }
  281. }
  282. }
  283. if(this.org_id ==10697 || this.org_id == 0 || this.org_id == 9478){
  284. list[i].stock_in_price = list[i].buy_price
  285. list[i].stockMoney = (list[i].buy_price * list[i].stockIn).toFixed(2)
  286. }else if(this.org_id ==9671){
  287. list[i].stock_in_price = list[i].buy_price
  288. list[i].stockMoney = (list[i].buy_price * list[i].stockIn).toFixed(2)
  289. }else if(this.org_id == 10644){
  290. list[i].stock_in_price = "/"
  291. console.log("val1",this.getAllStockInPrice(list[i].StWarehousingInfoTwo))
  292. console.log("val2",this.getAllStockInFlowPrice(list[i].WareStartInStockFlow))
  293. console.log("val3",this.getAllOutStockInPrice(list[i].WarehouseOutInfoTenty) )
  294. console.log("val4",this.getAllStockOutFlowPrice(list[i].WareStartOutStockFlow))
  295. list[i].stockMoney = parseFloat(this.getAllStockInPrice(list[i].StWarehousingInfoTwo)) +parseFloat(this.getAllStockInFlowPrice(list[i].WareStartInStockFlow)) - parseFloat(this.getAllOutStockInPrice(list[i].WarehouseOutInfoTenty)) - parseFloat(this.getAllStockOutFlowPrice(list[i].WareStartOutStockFlow))
  296. console.log("剩余33333333 ",list[i].stockMoney)
  297. if(list[i].stockMoney>0){
  298. list[i].stockMoney = list[i].stockMoney.toFixed(2)
  299. }
  300. }else{
  301. list[i].stock_in_price = "/"
  302. list[i].stockMoney = "/"
  303. }
  304. list[i].stockAdd = this.getWarehouseInfoOne(list[i].StartFlowWarehouseInfo,list[i].WareStartEndStockInventoryProfit)//期间增加
  305. if(this.org_id ==10697 || this.org_id ==9478 ){
  306. list[i].addStockMoney = list[i].buy_price
  307. list[i].saleStockMoney = (list[i].buy_price *list[i].stockAdd).toFixed(2)
  308. }else if(this.org_id == 0){
  309. list[i].addStockMoney = list[i].buy_price
  310. list[i].saleStockMoney = (list[i].buy_price *list[i].stockAdd).toFixed(2)
  311. } else if(this.org_id == 10644 || this.org_id == 10752){
  312. list[i].addStockMoney = "/"
  313. list[i].saleStockMoney = this.getWarehouseInfoOnePrice(list[i].StartFlowWarehouseInfo,list[i].WareStartEndStockInventoryProfit)
  314. } else{
  315. list[i].addStockMoney = "/"
  316. list[i].saleStockMoney = "/"
  317. }
  318. list[i].outStock = this.getWarehosueOutInfo(list[i].WarehouseOutInfoStart,list[i].WareStartEndStockInventoryLosses,list[i].StartEndCancelFLowInfo)//本期减少
  319. if(this.org_id == 10697 || this.org_id == 9478){
  320. list[i].stockOutprice = list[i].buy_price
  321. list[i].saleOutMoney = (list[i].buy_price * list[i].outStock).toFixed(2)
  322. }else if(this.org_id == 0){
  323. list[i].stockOutprice = list[i].buy_price
  324. list[i].saleOutMoney = (list[i].buy_price * list[i].outStock).toFixed(2)
  325. }else if(this.org_id == 10644 || this.org_id == 10752 ){
  326. list[i].stockOutprice = "/"
  327. list[i].saleOutMoney = this.getWarehosueOutInfoPrice(list[i].WarehouseOutInfoStart,list[i].WareStartEndStockInventoryLosses,list[i].StartEndCancelFLowInfo)
  328. if(list[i].saleOutMoney == "NaN"){
  329. list[i].saleOutMoney = ""
  330. }
  331. console.log("list[i].saleOutMoney",list[i].saleOutMoney)
  332. }else{
  333. list[i].stockOutprice = "/"
  334. list[i].saleOutMoney = "/"
  335. }
  336. if(this.org_id == 10265 || this.org_id == 0){
  337. list[i].overStock = list[i].GoodEndFlowInfo.over_count
  338. }else{
  339. if((list[i].stockIn + list[i].stockAdd - list[i].outStock)>0 ){
  340. list[i].overStock = list[i].stockIn + list[i].stockAdd - list[i].outStock
  341. }else{
  342. list[i].overStock = 0
  343. }
  344. }
  345. if(this.org_id ==10697 || this.org_id == 9478){
  346. list[i].overPrice = list[i].buy_price
  347. list[i].overMoney = (list[i].buy_price*list[i].overStock).toFixed(2)
  348. }else if(this.org_id == 0){
  349. list[i].overPrice = list[i].GoodEndFlowInfo.buy_price
  350. list[i].overMoney = (list[i].GoodEndFlowInfo.buy_price*list[i].overStock).toFixed(2)
  351. } else if(this.org_id ==10644 || this.org_id == 10752){
  352. list[i].overPrice = "/"
  353. list[i].overMoney = (parseFloat(list[i].stockMoney) + parseFloat(list[i].saleStockMoney) - parseFloat(list[i].saleOutMoney)).toFixed(2)
  354. }else{
  355. list[i].overPrice = "/"
  356. list[i].overMoney = "/"
  357. }
  358. }
  359. console.log("listwowowoowowowow",list)
  360. var obj = {good_number:"",medical_insurance_level:"",social_security_directory_code:"合计",good_type_id:"",good_name:"",specification_name:"",packing_unit:"",manufacturer:"",dealer:"",stockIn:"",stock_in_price:"",stockMoney:0,outStock:"",stockOutprice:"",saleStockMoney:0,saleOutMoney:0,overStock:"",overPrice:"",overMoney:0}
  361. if(this.org_id == 0 || this.org_id == 10697 || this.org_id == 9478){
  362. if(list.length!=null){
  363. for(let i=0;i<list.length;i++){
  364. obj.stockMoney += parseFloat(list[i].stockMoney)
  365. obj.saleStockMoney += parseFloat(list[i].saleStockMoney)
  366. obj.saleOutMoney += parseFloat(list[i].saleOutMoney)
  367. obj.overMoney += parseFloat(list[i].overMoney)
  368. }
  369. obj.stockMoney = obj.stockMoney.toFixed(2)
  370. obj.saleStockMoney = obj.saleStockMoney.toFixed(2)
  371. obj.overMoney = obj.overMoney.toFixed(2)
  372. obj.saleOutMoney = obj.saleOutMoney.toFixed(2)
  373. list.push(obj)
  374. }
  375. }
  376. console.log("list233333333333333333333333333333333",list)
  377. this.tableList = list
  378. this.total = response.data.data.total
  379. this.manufacturerList = response.data.data.manufacturerList
  380. }
  381. })
  382. },
  383. getManufacturName(id){
  384. var manufacturer_name = ""
  385. for(let i=0;i<this.manufacturerList.length;i++){
  386. if(id == this.manufacturerList[i].id){
  387. manufacturer_name = this.manufacturerList[i].manufacturer_name
  388. }
  389. }
  390. return manufacturer_name
  391. },
  392. handleSizeChange(val) {
  393. this.limit = val;
  394. this.getlist()
  395. },
  396. handleCurrentChange(val) {
  397. this.page = val;
  398. this.getlist()
  399. },
  400. handleSizeChangeOne(val) {
  401. this.limitone = val;
  402. this.toDialogClick(this.good_id,this.good_name,this.specification_name)
  403. },
  404. handleCurrentChangeOne(val) {
  405. this.pageone = val;
  406. this.toDialogClick(this.good_id,this.good_name,this.specification_name)
  407. },
  408. seach(){
  409. this.goodTypeList = []
  410. this.getStorehouseList()
  411. this.getlist()
  412. },
  413. getGoodTypeName(id){
  414. var type_name = ""
  415. for(let i=0;i<this.goodTypeList.length;i++){
  416. if(id == this.goodTypeList[i].id){
  417. type_name = this.goodTypeList[i].type_name
  418. }
  419. }
  420. if(type_name !='全部'){
  421. return type_name
  422. }
  423. },
  424. getHouseName(id){
  425. var storehouse_name = ""
  426. for(let i=0;i<this.houseList.length;i++){
  427. if(id == this.houseList[i].id){
  428. storehouse_name = this.houseList[i].storehouse_name
  429. }
  430. }
  431. return storehouse_name
  432. },
  433. getWareInfoCount(val,storehouse_id){
  434. var count = 0
  435. if(val.length > 0){
  436. for(let i=0;i<val.length;i++){
  437. if(val[i].storehouse_id == storehouse_id){
  438. count +=val[i].warehousing_count
  439. }
  440. }
  441. }
  442. if(count > 0){
  443. return count
  444. }else{
  445. return ""
  446. }
  447. },
  448. getStockDrugCount(){
  449. var params ={
  450. keywords: this.keywords,
  451. start_time:this.start_time,
  452. end_time:this.end_time,
  453. }
  454. getStockDrugCount(params).then(response=>{
  455. if(response.data.state == 1){
  456. var outlist = response.data.data.outList
  457. this.outCountList = outlist
  458. var autoCount = response.data.data.autoCount
  459. this.autoCountList = autoCount
  460. var totalCount = response.data.data.totalCount
  461. this.cancelCountList = totalCount
  462. }
  463. })
  464. },
  465. getWareInfoCountOne(val,storehouse_id){
  466. var count = 0
  467. if(val.length > 0){
  468. for(let i=0;i<val.length;i++){
  469. if(val[i].storehouse_id == storehouse_id){
  470. count +=val[i].stock_count
  471. }
  472. }
  473. }
  474. if(count > 0){
  475. return count
  476. }else{
  477. return ""
  478. }
  479. },
  480. getOutCount(id){
  481. var count = 0
  482. for(let i=0;i<this.outCountList.length;i++){
  483. if(id == this.outCountList[i].good_id){
  484. count = this.outCountList[i].count
  485. }
  486. }
  487. return count
  488. },
  489. getAutoCount(id){
  490. var count= 0
  491. for(let i=0;i<this.autoCountList.length;i++){
  492. if(id == this.autoCountList[i].good_id){
  493. count = this.autoCountList[i].count
  494. }
  495. }
  496. return count
  497. },
  498. getCancelCount(id){
  499. var count = 0
  500. for(let i=0;i<this.cancelCountList.length;i++){
  501. if(id == this.cancelCountList[i].good_id){
  502. count = this.cancelCountList[i].count
  503. }
  504. }
  505. return count
  506. },
  507. getCancelCountInfo(cancel_stock_info,storehouse_id){
  508. var count = 0
  509. if(cancel_stock_info.length >0){
  510. for(let i=0;i<cancel_stock_info.length;i++){
  511. if(storehouse_id == cancel_stock_info[i].storehouse_id){
  512. count += cancel_stock_info[i].count
  513. }
  514. }
  515. }
  516. return count
  517. },
  518. getWareOutInfoCount(warehouse_out_info,storehouse_id){
  519. var count = 0
  520. if(warehouse_out_info.length > 0){
  521. for(let i=0;i<warehouse_out_info.length;i++){
  522. if(storehouse_id == warehouse_out_info[i].storehouse_id){
  523. count +=warehouse_out_info[i].count
  524. }
  525. }
  526. }
  527. return count
  528. },
  529. getInCount(id){
  530. var count= 0
  531. for(let i=0;i<this.countList.length;i++){
  532. if(id == this.countList[i].good_id){
  533. count = this.countList[i].count
  534. }
  535. }
  536. return count
  537. },
  538. getOutCount(id){
  539. var count = 0
  540. for(let i=0;i<this.outCountList.length;i++){
  541. if(id == this.outCountList[i].good_id){
  542. count = this.outCountList[i].count
  543. }
  544. }
  545. return count
  546. },
  547. getAutoCount(id){
  548. var count= 0
  549. for(let i=0;i<this.autoCountList.length;i++){
  550. if(id == this.autoCountList[i].good_id){
  551. count = this.autoCountList[i].count
  552. }
  553. }
  554. return count
  555. },
  556. getCancelCount(id){
  557. var count = 0
  558. for(let i=0;i<this.cancelCountList.length;i++){
  559. if(id == this.cancelCountList[i].good_id){
  560. count = this.cancelCountList[i].count
  561. }
  562. }
  563. return count
  564. },
  565. getStockCount(id){
  566. var stock_count = 0
  567. for(let i=0;i<this.countList.length;i++){
  568. if(id == this.countList[i].good_id){
  569. stock_count = this.countList[i].stock_count
  570. }
  571. }
  572. return stock_count
  573. },
  574. getWareInfo(arr){
  575. var total = 0
  576. if(arr.length > 0){
  577. for(let i=0;i<arr.length;i++){
  578. total += parseInt(arr[i].warehousing_count)
  579. }
  580. }else{
  581. total = ""
  582. }
  583. return total
  584. },
  585. getOverplus(arr){
  586. var total = 0
  587. if(arr.length > 0){
  588. for(let i=0;i<arr.length;i++){
  589. total += arr[i].stock_count
  590. }
  591. }else{
  592. total = ""
  593. }
  594. return total
  595. },
  596. getCancelInfo(arr){
  597. var total = 0
  598. if(arr.length > 0){
  599. for(let i=0;i<arr.length;i++){
  600. total += arr[i].count
  601. }
  602. }else{
  603. total = ""
  604. }
  605. return total
  606. },
  607. getOverFlushInfo(arr){
  608. var total = 0
  609. if(arr.length >0){
  610. for(let i=0;i<arr.length;i++){
  611. total += arr[i].stock_count
  612. }
  613. }
  614. return total
  615. },
  616. startFirstTimeChange(){
  617. this.getlist()
  618. },
  619. endEndTimeChange(){
  620. this.getlist()
  621. },
  622. getTime(val) {
  623. if(val < 0){
  624. return ""
  625. }
  626. if(val == ""){
  627. return ""
  628. }else {
  629. return uParseTime(val, '{y}-{m}-{d}')
  630. }
  631. },
  632. getName(id){
  633. var name = ""
  634. for(let i=0;i<this.patientList.length;i++){
  635. if(id == this.patientList[i].id){
  636. name = this.patientList[i].name
  637. }
  638. }
  639. return name
  640. },
  641. endTimeChange(){
  642. this.getlist()
  643. },
  644. startTimeChange(){
  645. this.getlist()
  646. },
  647. getWarehouseInfoStart(arr1,arr2,arr3,arr4,arr5){
  648. var count =0
  649. var countOne =0
  650. var countTwo= 0
  651. var countthree = 0 //期初
  652. var countfour = 0
  653. var countfive = 0
  654. if(arr1!=null && arr1.length > 0){
  655. for(let i=0;i<arr1.length;i++){
  656. countOne +=arr1[i].count
  657. }
  658. }
  659. if(arr2!=null && arr2.length > 0){
  660. for(let i=0;i<arr2.length;i++){
  661. countTwo +=arr2[i].count
  662. }
  663. }
  664. if(arr3!=null && arr3.length > 0){
  665. for(let i=0;i<arr3.length;i++){
  666. countthree +=arr3[i].count
  667. }
  668. }
  669. if(arr4!=null && arr4.length > 0){
  670. for(let i=0;i<arr4.length;i++){
  671. countfour +=arr4[i].count
  672. }
  673. }
  674. if(arr5!=null && arr5.length > 0){
  675. for(let i=0;i<arr5.length;i++){
  676. countfive +=arr5[i].count
  677. }
  678. }
  679. count = countOne - countTwo + countthree - countfour + countfive
  680. if(count > 0 ){
  681. return count
  682. }else{
  683. return 0
  684. }
  685. },
  686. getWarehouseInfo(val){
  687. var count =0
  688. for(let i=0;i<val.length;i++){
  689. count +=val[i].stock_count
  690. }
  691. if(count > 0 ){
  692. return count
  693. }else{
  694. return 0
  695. }
  696. },
  697. getWarehouseInfoOne(val,val2){
  698. var count =0
  699. var countOne = 0
  700. var all_count = 0
  701. if(val!=null && val.length >0){
  702. for(let i=0;i<val.length;i++){
  703. count +=val[i].count
  704. }
  705. }
  706. if(val2!=null && val2.length > 0){
  707. for(let i=0;i<val2.length;i++){
  708. countOne +=val2[i].count
  709. }
  710. }
  711. all_count = count + countOne
  712. if(all_count > 0 ){
  713. return all_count
  714. }else{
  715. return 0
  716. }
  717. },
  718. getWarehouseInfoOnePrice(val,val2){
  719. var count_price =0
  720. var count_one_price = 0
  721. var all_count_price = 0
  722. if(val!=null && val.length >0){
  723. for(let i=0;i<val.length;i++){
  724. count_price +=val[i].count * val[i].price
  725. }
  726. }
  727. if(val2!=null && val2.length > 0){
  728. for(let i=0;i<val2.length;i++){
  729. count_one_price +=val2[i].count * val2[i].price
  730. }
  731. }
  732. all_count_price = count_price + count_one_price
  733. if(all_count_price > 0 ){
  734. return all_count_price.toFixed(2)
  735. }else{
  736. return 0
  737. }
  738. },
  739. getAddStockMony(val,val2){
  740. var total_price =0
  741. var total_price_one = 0
  742. var all_price = 0
  743. if(val!=null && val.length >0){
  744. for(let i=0;i<val.length;i++){
  745. total_price +=val[i].count * val[i].buy_price
  746. }
  747. }
  748. if(val2!=null && val2.length > 0){
  749. for(let i=0;i<val2.length;i++){
  750. total_price_one +=val2[i].count * val2[i].price
  751. }
  752. }
  753. all_price = total_price + total_price_one
  754. if(all_price >0 ){
  755. return total_price.toFixed(2)
  756. }else{
  757. return "0.00"
  758. }
  759. },
  760. getSaleStockMony(val,val2){
  761. var total_price =0
  762. var total_price_one = 0
  763. var all_price = 0
  764. if(val!=null && val.length >0){
  765. for(let i=0;i<val.length;i++){
  766. total_price +=val[i].count * val[i].price
  767. }
  768. }
  769. if(val2!=null && val2.length > 0){
  770. for(let i=0;i<val2.length;i++){
  771. total_price_one +=val2[i].count * val2[i].price
  772. }
  773. }
  774. all_price = total_price + total_price_one
  775. if(all_price >0 ){
  776. return all_price.toFixed(2)
  777. }else{
  778. return ""
  779. }
  780. },
  781. getWarehouseOut(val){
  782. var count = 0
  783. for(let i=0;i<val.length;i++){
  784. count +=val[i].count
  785. }
  786. if(count >0){
  787. return count
  788. }else{
  789. return 0
  790. }
  791. },
  792. open(){
  793. // this.start_time = moment().year(2022).month(10).date(4).format('YYYY-MM-DD')
  794. this.start_time = moment().startOf('month').format('YYYY-MM-DD')
  795. this.end_time = moment(new Date()).add('year',0).format("YYYY-MM-DD")
  796. this.houseList = []
  797. this.goodTypeList= []
  798. this.getStorehouseList()
  799. this.getlist()
  800. //this.getStockDrugCount()
  801. },
  802. getWarehouseInfoStartPrice(arr,arr1,arr2,arr3,arr4){
  803. var total_price = 0
  804. var total_price_one = 0
  805. var total_price_two = 0
  806. var total_price_three = 0
  807. var total_price_four = 0
  808. var total_price_all = 0
  809. if(arr!=null&&arr.length > 0){
  810. for(let i=0;i<arr.length;i++){
  811. total_price += arr[i].count * arr[i].buy_price
  812. }
  813. }
  814. if(arr1!=null && arr1.length > 0){
  815. for(let i=0;i<arr1.length;i++){
  816. total_price_one +=arr1[i].count * arr1[i].buy_price
  817. }
  818. }
  819. if(arr2!=null && arr2.length > 0){
  820. for(let i=0;i<arr2.length;i++){
  821. total_price_two +=arr2[i].count * arr2[i].buy_price
  822. }
  823. }
  824. if(arr3!=null && arr3.length > 0){
  825. for(let i=0;i<arr3.length;i++){
  826. total_price_three +=arr3[i].count * arr3[i].buy_price
  827. }
  828. }
  829. if(arr4!=null && arr4.length > 0){
  830. for(let i=0;i<arr4.length;i++){
  831. total_price_three +=arr4[i].count * arr4[i].buy_price
  832. }
  833. }
  834. total_price_all = total_price - total_price_one + total_price_two - total_price_three + total_price_four
  835. if (total_price_all > 0) {
  836. return total_price_all.toFixed(2)
  837. }else{
  838. return "0.00"
  839. }
  840. },
  841. getWarehouseInfoStartMoney(arr,arr1,arr2,arr3,arr4){
  842. var total_price = 0
  843. var total_price_one = 0
  844. var total_price_two = 0
  845. var total_price_three = 0
  846. var total_price_four = 0
  847. var total_price_all = 0
  848. if(arr!=null && arr.length >0){
  849. for(let i=0;i<arr.length;i++){
  850. total_price +=arr[i].count * arr[i].price
  851. }
  852. }
  853. if(arr1!=null && arr1.length > 0){
  854. for(let i=0;i<arr1.length;i++){
  855. total_price_one +=arr1[i].count * arr1[i].price
  856. }
  857. }
  858. if(arr2!=null && arr2.length > 0){
  859. for(let i=0;i<arr2.length;i++){
  860. total_price_two +=arr2[i].count * arr2[i].price
  861. }
  862. }
  863. if(arr3!=null && arr3.length > 0){
  864. for(let i=0;i<arr3.length;i++){
  865. total_price_three +=arr3[i].count * arr3[i].price
  866. }
  867. }
  868. if(arr4!=null && arr4.length > 0){
  869. for(let i=0;i<arr4.length;i++){
  870. total_price_four +=arr4[i].count * arr4[i].price
  871. }
  872. }
  873. total_price_all = total_price - total_price_one + total_price_two - total_price_three + total_price_four
  874. if (total_price_all > 0) {
  875. return total_price_all.toFixed(2)
  876. }else{
  877. return ""
  878. }
  879. },
  880. getWarehosueOutInfo(val,val2,val3){
  881. var count = 0
  882. var count_one = 0
  883. var all_count = 0
  884. var count_two = 0
  885. if(val!=null && val.length >0){
  886. for(let i=0;i<val.length;i++){
  887. count +=val[i].count
  888. }
  889. }
  890. if(val2!=null && val2.length > 0){
  891. for(let i=0;i<val2.length;i++){
  892. count_one +=val2[i].count
  893. }
  894. }
  895. if(val3!=null && val3.length > 0){
  896. for(let i=0;i<val3.length;i++){
  897. count_two +=val3[i].count
  898. }
  899. }
  900. console.log("本期减少",count)
  901. console.log("盘亏",count_one)
  902. console.log("退库",count_two)
  903. all_count = count +count_one - count_two
  904. console.log("数据我哦我我",all_count)
  905. if(all_count >0){
  906. return all_count
  907. }else{
  908. return 0
  909. }
  910. },
  911. getWarehosueOutInfoPrice(val,val2,val3){
  912. var count_price = 0
  913. var count_one_price = 0
  914. var all_count_price = 0
  915. var count_two_price = 0
  916. if(val!=null && val.length >0){
  917. for(let i=0;i<val.length;i++){
  918. count_price += val[i].count * val[i].price
  919. }
  920. }
  921. if(val2!=null && val2.length > 0){
  922. for(let i=0;i<val2.length;i++){
  923. count_one_price +=val2[i].count * val2[i].price
  924. }
  925. }
  926. if(val3!=null && val3.length > 0){
  927. for(let i=0;i<val3.length;i++){
  928. count_two_price +=val3[i].count * val3[i].price
  929. }
  930. }
  931. console.log("本期减少",count_price)
  932. console.log("盘亏",count_one_price)
  933. console.log("退库",all_count_price)
  934. all_count_price = count_price +count_one_price - count_two_price
  935. console.log("数据我哦我我",all_count_price)
  936. if(all_count_price >0){
  937. return all_count_price.toFixed(2)
  938. }else{
  939. return "0.00"
  940. }
  941. },
  942. stockOutprice(val,val2,val3){
  943. var total_price = 0
  944. var total_price_one = 0
  945. var total_price_two = 0
  946. var all_price = 0
  947. if(val!=null && val.length >0){
  948. for(let i=0;i<val.length;i++){
  949. total_price +=val[i].count * val[i].buy_price
  950. }
  951. }
  952. if(val2!=null && val2.length > 0){
  953. for(let i=0;i<val2.length;i++){
  954. total_price_one +=val2[i].count * val2[i].buy_price
  955. }
  956. }
  957. if(val3!=null && val3.length > 0){
  958. for(let i=0;i<val3.length;i++){
  959. total_price_two +=val3[i].count * val3[i].buy_price
  960. }
  961. }
  962. all_price = total_price + total_price_one - total_price_two
  963. if(all_price >0){
  964. return all_price.toFixed(2)
  965. }else{
  966. return "0.00"
  967. }
  968. },
  969. saleOutprice(val,val2,val3){
  970. var total_price = 0
  971. var total_price_one = 0
  972. var all_price = 0
  973. var total_price_two = 0
  974. if(val!=null && val.length >0){
  975. for(let i=0;i<val.length;i++){
  976. total_price +=val[i].count * val[i].xt_warehouse_info.packing_price
  977. }
  978. }
  979. if(val2!=null && val2.length > 0){
  980. for(let i=0;i<val2.length;i++){
  981. total_price_one +=val2[i].count * val2[i].price
  982. }
  983. }
  984. if(val3!=null && val3.length > 0){
  985. for(let i=0;i<val3.length;i++){
  986. total_price_two +=val3[i].count * val3[i].price
  987. }
  988. }
  989. all_price = total_price + total_price_one - total_price_two
  990. if(all_price >0){
  991. return all_price.toFixed(2)
  992. }else{
  993. return "0.00"
  994. }
  995. },
  996. getEndWarehouseInfo(val,val3,val1,val2,val4){
  997. var count = 0
  998. var count_one = 0
  999. var count_two = 0
  1000. var count_three =0
  1001. var count_four = 0
  1002. var all_count = 0
  1003. if(val!=null && val.length >0){
  1004. for(let i=0;i<val.length;i++){
  1005. count +=val[i].count
  1006. }
  1007. }
  1008. if(val1!=null&&val1.length >0){
  1009. for(let i=0;i<val1.length;i++){
  1010. count_one +=val1[i].count
  1011. }
  1012. }
  1013. if(val3!=null&& val3.length > 0){
  1014. for(let i=0;i<val3.length;i++){
  1015. count_three +=val3[i].count
  1016. }
  1017. }
  1018. if(val2!=null&&val2.length >0){
  1019. for(let i=0;i<val2.length;i++){
  1020. count_two +=val2[i].count
  1021. }
  1022. }
  1023. if(val4!=null&&val4.length >0){
  1024. for(let i=0;i<val4.length;i++){
  1025. count_four +=val4[i].count
  1026. }
  1027. }
  1028. all_count = count- count_three + count_one - count_two + count_four
  1029. if(all_count >0){
  1030. return all_count
  1031. }else{
  1032. return 0
  1033. }
  1034. },
  1035. getEndOverPrice(val,val3,val1,val2,val4){
  1036. var total_price = 0
  1037. var total_price_one = 0
  1038. var total_price_two = 0
  1039. var total_price_three = 0
  1040. var total_price_four =0
  1041. var all_price = 0
  1042. if(val!=null && val.length >0){
  1043. for(let i=0;i<val.length;i++){
  1044. total_price +=val[i].count * val[i].buy_price
  1045. }
  1046. }
  1047. if(val1!=null && val1.length > 0){
  1048. for(let i=0;i<val1.length;i++){
  1049. total_price_one +=val1[i].count * val1[i].buy_price
  1050. }
  1051. }
  1052. if(val3!=null && val3.length > 0){
  1053. for(let i=0;i<val3.length;i++){
  1054. total_price_three +=val3[i].count * val3[i].buy_price
  1055. }
  1056. }
  1057. if(val2!=null && val2.length > 0){
  1058. for(let i=0;i<val2.length;i++){
  1059. total_price_two +=val2[i].count * val2[i].buy_price
  1060. }
  1061. }
  1062. if(val4!=null && val4.length > 0){
  1063. for(let i=0;i<val4.length;i++){
  1064. total_price_four +=val4[i].count * val4[i].buy_price
  1065. }
  1066. }
  1067. console.log("total_price",total_price)
  1068. console.log("total_price_three",total_price_three)
  1069. console.log("total_price_two",total_price_two)
  1070. console.log("total_price_one",total_price_one)
  1071. console.log("total_price_four",total_price_four)
  1072. all_price = total_price- total_price_three +total_price_one - total_price_two + total_price_four
  1073. console.log("arrll_price",all_price)
  1074. if(all_price >0){
  1075. return all_price.toFixed(2)
  1076. }else{
  1077. return "0.00"
  1078. }
  1079. },
  1080. getEndSalePrice(val,val3,val1,val2,val4){
  1081. var total_price = 0
  1082. var total_price_one = 0
  1083. var total_price_two = 0
  1084. var total_price_three = 0
  1085. var total_price_four = 0
  1086. var all_price= 0
  1087. if(val!=null && val.length >0){
  1088. for(let i=0;i<val.length;i++){
  1089. total_price +=val[i].count * val[i].price
  1090. }
  1091. }
  1092. if(val1!=null && val1.length >0){
  1093. for(let i=0;i<val1.length;i++){
  1094. total_price_one +=val1[i].count * val1[i].price
  1095. }
  1096. }
  1097. if(val3!=null && val3.length >0){
  1098. for(let i=0;i<val3.length;i++){
  1099. total_price_three +=val3[i].count * val3[i].price
  1100. }
  1101. }
  1102. if(val2!=null && val2.length >0){
  1103. for(let i=0;i<val2.length;i++){
  1104. total_price_two +=val2[i].count * val2[i].price
  1105. }
  1106. }
  1107. if(val4!=null && val4.length >0){
  1108. for(let i=0;i<val4.length;i++){
  1109. total_price_four +=val4[i].count * val4[i].price
  1110. }
  1111. }
  1112. var all_price = total_price-total_price_three + total_price_one - total_price_two + total_price_four
  1113. if(all_price >0){
  1114. return all_price.toFixed(2)
  1115. }else{
  1116. return "0.00"
  1117. }
  1118. },
  1119. toPrint(){
  1120. 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+"&query_type="+this.query_type})
  1121. },
  1122. exportList: function() {
  1123. if(this.org_id!=0&& this.org_id!=9956 && this.org_id!=10697 && this.org_id!=10375 && this.org_id!=9478){
  1124. for(let i=0;i<this.tableList.length;i++){
  1125. this.tableList[i].index = i+1
  1126. this.tableList[i].query_date = this.start_time+"~"+this.end_time
  1127. this.tableList[i].good_type = this.getGoodTypeName(this.tableList[i].good_type_id)
  1128. this.tableList[i].manufacturer_name = this.getManufacturName(this.tableList[i].manufacturer)
  1129. this.tableList[i].dealer_name = this.getDearName(this.tableList[i].dealer)
  1130. this.tableList[i].specification_name_one = this.tableList[i].specification_name + "/"+this.tableList[i].packing_unit
  1131. }
  1132. import('@/vendor/Export2Excel').then(excel => {
  1133. const multiHeader = [['序号', '查询日期',' 耗材类型','耗材名称','规格&单位','生产产商','经销商', '期初结余' , '', '', '本期增加', '', '', '本期减少' , '', '', '期末结余' , '', '']]
  1134. const header = ['', '','','','','','', '数量', '进货金额', '销售金额', '数量', '进货金额', '销售金额', '数量', '进货金额', '销售金额', '数量', '进货金额', '销售金额']
  1135. const merges = ['A1:A2', 'B1:B2','C1:C2','D1:D2','E1:E2','F1:F2','G1:G2','H1:J1', 'K1:M1', 'N1:P1', 'Q1:S1']
  1136. 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']
  1137. const data = this.formatJson(filterVal, this.tableList)
  1138. const filename = '进销存查询'
  1139. excel.export_json_to_excel({
  1140. multiHeader,
  1141. header,
  1142. merges,
  1143. data,
  1144. filename
  1145. })
  1146. })
  1147. }
  1148. if(this.org_id == 9956){
  1149. for(let i=0;i<this.tableList.length;i++){
  1150. this.tableList[i].index = i+1
  1151. this.tableList[i].query_date = this.start_time+"~"+this.end_time
  1152. this.tableList[i].good_type = this.getGoodTypeName(this.tableList[i].good_type_id)
  1153. this.tableList[i].manufacturer_name = this.getManufacturName(this.tableList[i].manufacturer)
  1154. this.tableList[i].dealer_name = this.getDearName(this.tableList[i].dealer)
  1155. this.tableList[i].specification_name_one = this.tableList[i].specification_name + "/"+this.tableList[i].packing_unit
  1156. }
  1157. import('@/vendor/Export2Excel').then(excel => {
  1158. const multiHeader = [['序号','耗材编码', '查询日期',' 耗材类型','耗材名称','规格&单位','生产产商','经销商', '期初结余' , '', '', '本期增加', '', '', '本期减少' , '', '', '期末结余' , '', '']]
  1159. const header = ['','', '','','','','','', '数量', '进货金额', '销售金额', '数量', '进货金额', '销售金额', '数量', '进货金额', '销售金额', '数量', '进货金额', '销售金额']
  1160. 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']
  1161. 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']
  1162. const data = this.formatJson(filterVal, this.tableList)
  1163. const filename = '进销存查询'
  1164. excel.export_json_to_excel({
  1165. multiHeader,
  1166. header,
  1167. merges,
  1168. data,
  1169. filename
  1170. })
  1171. })
  1172. }
  1173. if(this.org_id == 10697 || this.org_id == 0 || this.org_id == 10375 || this.org_id == 9478){
  1174. for(let i=0;i<this.tableList.length;i++){
  1175. this.tableList[i].index = i+1
  1176. this.tableList[i].query_date = this.start_time+"~"+this.end_time
  1177. this.tableList[i].good_type = this.getGoodTypeName(this.tableList[i].good_type_id)
  1178. this.tableList[i].manufacturer_name = this.getManufacturName(this.tableList[i].manufacturer)
  1179. this.tableList[i].dealer_name = this.getDearName(this.tableList[i].dealer)
  1180. this.tableList[i].specification_name_one = this.tableList[i].specification_name + "/"+this.tableList[i].packing_unit
  1181. }
  1182. import('@/vendor/Export2Excel').then(excel => {
  1183. const multiHeader = [['序号','国家编码', '查询日期',' 耗材类型','耗材名称','规格&单位','生产产商','经销商', '期初结余' , '', '', '本期增加', '', '', '本期减少' , '', '', '期末结余' , '', '']]
  1184. const header = ['','', '','','','','','', '数量', '进货金额', '销售金额', '数量', '进货金额', '销售金额', '数量', '进货金额', '销售金额', '数量', '进货金额', '销售金额']
  1185. 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']
  1186. const filterVal = ['index','social_security_directory_code', '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']
  1187. const data = this.formatJson(filterVal, this.tableList)
  1188. const filename = '进销存查询'
  1189. excel.export_json_to_excel({
  1190. multiHeader,
  1191. header,
  1192. merges,
  1193. data,
  1194. filename
  1195. })
  1196. })
  1197. }
  1198. },
  1199. formatJson(filterVal, jsonData) {
  1200. return jsonData.map(v => filterVal.map(j => v[j]));
  1201. },
  1202. toOverCount(){
  1203. getGoodOverCount().then(response=>{
  1204. if(response.data.state == 1){
  1205. var msg = response.data.data.msg
  1206. this.$message.success("调试成功")
  1207. }
  1208. })
  1209. },
  1210. getDearName(id){
  1211. var dear_name = ""
  1212. for(let i=0;i<this.dealerList.length;i++){
  1213. if(id == this.dealerList[i].id){
  1214. dear_name = this.dealerList[i].dealer_name
  1215. }
  1216. }
  1217. return dear_name
  1218. },
  1219. getAllStockIn(val){
  1220. var count = 0
  1221. if(val!=null && val.length>0){
  1222. for(let i=0;i<val.length;i++){
  1223. count+= val[i].warehousing_count
  1224. }
  1225. }
  1226. return count
  1227. },
  1228. getAllStockInPrice(val){
  1229. var total_price =0
  1230. if(val!=null && val.length>0){
  1231. for(let i=0;i<val.length;i++){
  1232. if(this.org_id == 10644){
  1233. total_price += val[i].warehousing_count * val[i].price
  1234. }
  1235. if(this.org_id != 10644){
  1236. total_price += val[i].warehousing_count * val[i].packing_price
  1237. }
  1238. }
  1239. }
  1240. if(total_price>0){
  1241. return total_price.toFixed(2)
  1242. }else{
  1243. return total_price
  1244. }
  1245. },
  1246. getAllOutStockIn(val){
  1247. var count = 0
  1248. if(val!=null && val.length>0){
  1249. for(let i=0;i<val.length;i++){
  1250. count +=val[i].count
  1251. }
  1252. }
  1253. return count
  1254. },
  1255. getAllOutStockInPrice(val){
  1256. var total_price = 0
  1257. if(val!=null && val.length>0){
  1258. for(let i=0;i<val.length;i++){
  1259. total_price += val[i].count * val[i].price
  1260. }
  1261. }
  1262. if(total_price>0){
  1263. return total_price.toFixed(2)
  1264. }else{
  1265. return total_price
  1266. }
  1267. },
  1268. getAllStockInFlow(val){
  1269. var count = 0
  1270. if(val!=null && val.length>0){
  1271. for(let i=0;i<val.length;i++){
  1272. count+= val[i].count
  1273. }
  1274. }
  1275. return count
  1276. },
  1277. getAllStockInFlowPrice(val){
  1278. var total_price = 0
  1279. if(val!=null && val.length>0){
  1280. for(let i=0;i<val.length;i++){
  1281. total_price+= val[i].count * val[i].price
  1282. }
  1283. }
  1284. if(total_price>0){
  1285. return total_price.toFixed(2)
  1286. }else{
  1287. return total_price
  1288. }
  1289. },
  1290. getAllStockOutFlow(val){
  1291. var count = 0
  1292. if(val!=null && val.length>0){
  1293. for(let i=0;i<val.length;i++){
  1294. count+= val[i].count
  1295. }
  1296. }
  1297. return count
  1298. },
  1299. getAllStockOutFlowPrice(val){
  1300. var total_price = 0
  1301. if(val!=null && val.length>0){
  1302. for(let i=0;i<val.length;i++){
  1303. total_price+= val[i].count * val[i].price
  1304. }
  1305. }
  1306. if(total_price>0){
  1307. return total_price.toFixed(2)
  1308. }else{
  1309. return total_price
  1310. }
  1311. },
  1312. getAllQuery(){
  1313. this.getlist()
  1314. }
  1315. },
  1316. created(){
  1317. }
  1318. }
  1319. </script>