warehousing.vue 9.1KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317
  1. <template>
  2. <div class="page_warehousing">
  3. <div class="quarterBox">
  4. <p :class="Num == 1 ? 'active' : ''" @click="onClick(1)">近一月</p>
  5. <p :class="Num == 2 ? 'active' : ''" @click="onClick(2)">近三月</p>
  6. <p :class="Num == 3 ? 'active' : ''" @click="onClick(3)">近半年</p>
  7. <!-- <div class="toolBox"> -->
  8. <div class="toolOne" @click="startShow = true">
  9. <div style="display: flex;align-items: center;">
  10. {{ query.start_time }}
  11. <van-icon name="arrow-down"/>
  12. </div>
  13. </div>
  14. <div class="toolOne" @click="endShow = true">
  15. <div style="display: flex;align-items: center;">
  16. {{ query.end_time }}
  17. <van-icon name="arrow-down"/>
  18. </div>
  19. </div>
  20. <!-- </div> -->
  21. </div>
  22. <div>
  23. <el-table ref="tab" :data="tableData" style="width: 100%" :height="tableHeight" border :header-cell-style="{backgroundColor: 'rgb(245, 247, 250)',color: '#606266'}">
  24. <el-table-column label="商品类型" align="center">
  25. <template slot-scope="scope">
  26. <span v-if="scope.row.is_total == 1">{{ scope.row.type.type_name }}</span>
  27. <span v-if="scope.row.is_total == 2">合计</span>
  28. </template>
  29. </el-table-column>
  30. <el-table-column label="规格名称" align="center" width="80">
  31. <template slot-scope="scope">
  32. <span v-if="scope.row.is_total == 1">{{ scope.row.specification_name }}</span>
  33. <span v-if="scope.row.is_total == 2"></span>
  34. </template>
  35. </el-table-column>
  36. <el-table-column label="数量" align="center" width="80">
  37. <!--style="color: #579ef8"-->
  38. <template slot-scope="scope">
  39. <span v-if="scope.row.is_total == 1">{{calCount(scope.row) }}</span>
  40. <span v-if="scope.row.is_total == 2"></span>
  41. </template>
  42. </el-table-column>
  43. <el-table-column label="总价" align="center" width="80">
  44. <template slot-scope="scope">
  45. <span v-if="scope.row.is_total == 1">{{getTotal(scope.row)}}</span>
  46. <span v-if="scope.row.is_total == 2">{{scope.row.total}}</span>
  47. </template>
  48. </el-table-column>
  49. </el-table>
  50. </div>
  51. <div>
  52. <van-popup v-model="startShow" position="bottom" :style="{ height: '40%' }">
  53. <van-datetime-picker
  54. v-model="currentDate1"
  55. type="date"
  56. :min-date="minDate"
  57. :max-date="maxDate"
  58. @confirm="getstartTime"
  59. @cancel="startShow = false"
  60. />
  61. </van-popup>
  62. <van-popup v-model="endShow" position="bottom" :style="{ height: '40%' }">
  63. <van-datetime-picker
  64. v-model="currentDate2"
  65. type="date"
  66. :min-date="minDate"
  67. :max-date="maxDate"
  68. @confirm="getstartTime2"
  69. @cancel="endShow = false"
  70. />
  71. </van-popup>
  72. </div>
  73. </div>
  74. </template>
  75. <script>
  76. const moment = require('moment')
  77. import {GetStockInfo} from "@/api/statistics";
  78. export default {
  79. data() {
  80. return {
  81. tableHeight:'',
  82. currentDate1: new Date(new Date().setDate(new Date().getDate() - 7)),
  83. currentDate2: new Date(),
  84. minDate: new Date(new Date().setFullYear(new Date().getFullYear() - 1)),
  85. maxDate: new Date(),
  86. query: {
  87. start_time: "",
  88. end_time: "",
  89. type: 1,
  90. },
  91. Num: 1,
  92. startShow: false,
  93. endShow: false,
  94. currentDate: new Date(),
  95. startTime: "请选择",
  96. endTime: "请选择",
  97. tableData: []
  98. }
  99. },
  100. methods: {
  101. getTotal(stock) {
  102. let total = 0
  103. var array = []
  104. array = stock.query_warehousing_info
  105. for (let i = 0; i < array.length; i++) {
  106. total = total + (array[i].warehousing_count * array[i].price)
  107. }
  108. return total
  109. },
  110. calCount(stock) {
  111. let total = 0
  112. var array = []
  113. array = stock.query_warehousing_info
  114. for (let i = 0; i < array.length; i++) {
  115. total = total + array[i].warehousing_count
  116. }
  117. return total
  118. },
  119. GetStockInfo() {
  120. },
  121. stockInCount: function (row) {
  122. let total = 0;
  123. for (let i = 0; i < row.query_warehousing_info.length; i++) {
  124. total = total + row.query_warehousing_info[i].warehousing_count;
  125. }
  126. return total;
  127. },
  128. onClick(id) {
  129. if (id == 1) {
  130. this.Num = 1;
  131. } else if (id == 2) {
  132. this.Num = 2;
  133. } else if (id == 3) {
  134. this.Num = 3;
  135. }
  136. switch (this.Num) {
  137. case 1: //近1个月
  138. this.currentDate1 = new Date(new Date().setMonth(new Date().getMonth() + 1)),
  139. this.currentDate2 = new Date()
  140. this.isStop = false
  141. const startDate = moment().subtract('month', 1).format('YYYY-MM-DD')
  142. this.query.start_time = startDate
  143. const endDate = moment(new Date()).format('YYYY-MM-DD')
  144. this.query.end_time = endDate
  145. this.GetStockInfo(this.query)
  146. break
  147. case 2: //近三月
  148. this.currentDate1 = new Date(new Date().setMonth(new Date().getMonth() - 3)),
  149. this.currentDate2 = new Date()
  150. this.isStop = false
  151. this.query.page = 1
  152. this.query.start_time = moment().subtract('month', 3).format('YYYY-MM-DD')
  153. this.query.end_time = moment(new Date()).format('YYYY-MM-DD')
  154. this.GetStockInfo(this.query)
  155. break
  156. case 3: //近6月
  157. this.isStop = false
  158. this.query.page = 1
  159. this.query.start_time = moment().subtract('month', 6).format('YYYY-MM-DD')
  160. this.query.end_time = moment(new Date()).format('YYYY-MM-DD')
  161. this.GetStockInfo(this.query)
  162. break
  163. }
  164. },
  165. getstartTime(value) {
  166. this.Num = 0
  167. let year = value.getFullYear();
  168. let month = value.getMonth() + 1;
  169. let day = value.getDate();
  170. if (month >= 1 && month <= 9) {
  171. month = `0${month}`;
  172. }
  173. if (day >= 1 && day <= 9) {
  174. day = `0${day}`;
  175. }
  176. this.query.start_time = `${year}-${month}-${day}`;
  177. this.GetStockInfo(this.query)
  178. this.startShow = false;
  179. },
  180. getstartTime2(value) {
  181. this.Num = 0
  182. let year = value.getFullYear();
  183. let month = value.getMonth() + 1;
  184. let day = value.getDate();
  185. if (month >= 1 && month <= 9) {
  186. month = `0${month}`;
  187. }
  188. if (day >= 1 && day <= 9) {
  189. day = `0${day}`;
  190. }
  191. this.query.end_time = `${year}-${month}-${day}`;
  192. this.GetStockInfo(this.query)
  193. this.endShow = false;
  194. },
  195. GetStockInfo(params) {
  196. this.tableData = []
  197. GetStockInfo(params)
  198. .then(rs => {
  199. var resp = rs.data
  200. if (resp.state == 1) {
  201. let all_total = 0
  202. for (let i = 0; i < resp.data.list.length; i++) {
  203. if (resp.data.list[i].query_warehousing_info.length > 0) {
  204. resp.data.list[i]['is_total'] = 1
  205. this.tableData.push(resp.data.list[i])
  206. for (let b = 0; b < resp.data.list[i].query_warehousing_info.length; b++) {
  207. all_total = all_total + (resp.data.list[i].query_warehousing_info[b].warehousing_count * resp.data.list[i].query_warehousing_info[b].price)
  208. }
  209. }
  210. }
  211. let obj = {
  212. is_total:2,
  213. total:all_total,
  214. }
  215. this.tableData.push(obj)
  216. } else {
  217. this.$toast({
  218. message: resp.msg
  219. })
  220. }
  221. })
  222. .catch(error => {
  223. })
  224. },
  225. }, created() {
  226. this.tableHeight = (document.documentElement.clientHeight - (Number(document.documentElement.style.fontSize.slice(0, -2)) * 2.75)) + 'px'
  227. // this.query.start_time = moment().subtract('day', 7).format('YYYY-MM-DD')
  228. this.query.start_time = moment().subtract('month', 1).format('YYYY-MM-DD')
  229. // 本月的结束时间
  230. this.query.end_time = moment(new Date()).format('YYYY-MM-DD')
  231. this.GetStockInfo(this.query)
  232. }
  233. }
  234. </script>
  235. <style lang="scss" scoped>
  236. .page_warehousing {
  237. .quarterBox {
  238. display: flex;
  239. height: 2.5rem;
  240. align-items: center;
  241. justify-content: space-around;
  242. p {
  243. width: 3rem;
  244. height: 1.875rem;
  245. line-height: 1.875rem;
  246. background: rgba(246, 246, 246, 1);
  247. opacity: 0.8;
  248. border-radius: 0.3125rem;
  249. color: #8d8d8d;
  250. cursor: pointer;
  251. text-align: center;
  252. font-size: 0.8125rem;
  253. }
  254. .active {
  255. background: rgba(51, 138, 251, 1);
  256. color: #fff;
  257. border: 1px solid #338afb;
  258. }
  259. }
  260. .toolOne {
  261. width: 6.25rem;
  262. height: 1.875rem;
  263. background: rgba(246, 246, 246, 1);
  264. border-radius: 5px;
  265. text-align: center;
  266. font-size: 0.8125rem;
  267. color: #8d8d8d;
  268. display: flex;
  269. align-items: center;
  270. justify-content: space-around;
  271. }
  272. }
  273. </style>
  274. <style lang="scss">
  275. ::-webkit-scrollbar {
  276. height: 0;
  277. width: 0;
  278. }
  279. </style>