panku_record.vue 9.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456
  1. <template>
  2. <view class="recordContainer">
  3. <view class="search">
  4. <view class="time">
  5. <picker mode="date" @change="toChangeStartTime">
  6. <view class="value">{{ searchParams.start_time | dateFormatter('yyyy-MM-dd') }}</view>
  7. </picker>
  8. <view class="fixed">至</view>
  9. <picker mode="date" @change="toChangeEndTime">
  10. <view class="value">{{ searchParams.end_time | dateFormatter('yyyy-MM-dd') }}</view>
  11. </picker>
  12. </view>
  13. <view class="btn" @click="toSearch">查询</view>
  14. </view>
  15. <view class="Header">
  16. <view>盘库记录</view>
  17. <view>
  18. <text>入库:<text class="spec">{{ infoList.reduce((a, b) => a + Number(b.man), 0) }}套</text></text>
  19. <text>出库:<text class="spec">{{ infoList.reduce((a, b) => a + Number(b.woman), 0) }}套</text></text>
  20. </view>
  21. </view>
  22. <view v-for="item in infoList" :key="item.type" class="typeCard">
  23. <view class="header" :class="item.toggle ? 'open' : ''" @click="toGetDetail(item)">
  24. <view class="icon"></view>
  25. <view class="name">{{ item.type_name }}</view>
  26. </view>
  27. <template v-if="item.toggle">
  28. <scroll-view scroll-y="true" class="scrollList">
  29. <template v-if="item.children.length > 0">
  30. <view v-for="btem in item.children" :key="btem.id" class="scrollItem">
  31. <view class="sex">{{ btem.sex ? '男款' : '女款' }}</view>
  32. <view class="size">{{ btem.size }}</view>
  33. <view class="time">{{ btem.created_at | dateFormatter('yyyy/MM/dd hh:mm:ss') }}</view>
  34. <view class="num spec">
  35. {{ +btem.storage_type === 1 ? '-' : '+' }}{{ btem.num }}
  36. </view>
  37. </view>
  38. <view v-if="!item.isMore" class="scrollItem noMore">没有更多记录了</view>
  39. </template>
  40. <template v-else>
  41. <view class="noTip">暂无记录</view>
  42. </template>
  43. </scroll-view>
  44. </template>
  45. <view class="all panku">
  46. <view class="ku">
  47. 入库:<text class="spec">{{ item.man }}套</text>
  48. </view>
  49. <view class="ku">
  50. 出库:<text class="spec">{{ item.woman }}套</text>
  51. </view>
  52. </view>
  53. </view>
  54. </view>
  55. </template>
  56. <script>
  57. import {
  58. panKuRecord,
  59. panKuRecordDetail
  60. } from "@/apis/stock.js"
  61. import {
  62. dateFormatter
  63. } from "@/filters/index.js"
  64. export default {
  65. data() {
  66. return {
  67. recoedParams: {
  68. start_time: '',
  69. end_time: ''
  70. },
  71. infoList: [],
  72. searchParams: {
  73. start_time: dateFormatter(Date.now(), 'yyyy-MM-dd'),
  74. end_time: dateFormatter(Date.now(), 'yyyy-MM-dd')
  75. }
  76. }
  77. },
  78. onLoad() {
  79. this.recoedParams.start_time = dateFormatter(Date.now(), 'yyyy-MM-dd')
  80. this.recoedParams.end_time = dateFormatter(Date.now(), 'yyyy-MM-dd')
  81. this.getStockRecord()
  82. },
  83. methods: {
  84. // 查询
  85. toSearch() {
  86. let {
  87. start_time,
  88. end_time
  89. } = this.searchParams
  90. if (new Date(end_time).getTime() < new Date(start_time).getTime()) {
  91. uni.showModal({
  92. content: "结束时间不能大于开始时间",
  93. showCancel: false
  94. })
  95. return false
  96. }
  97. this.recoedParams.start_time = start_time
  98. this.recoedParams.end_time = end_time
  99. this.getStockRecord()
  100. },
  101. // 结束时间
  102. toChangeEndTime(e) {
  103. this.searchParams.end_time = e.detail.value
  104. },
  105. // 开始时间
  106. toChangeStartTime(e) {
  107. this.searchParams.start_time = e.detail.value
  108. },
  109. // 记录详情
  110. toGetDetail(data) {
  111. if (data.total && data.isMore) {
  112. this.getRecordDetail(data.page_index, data.type, list => {
  113. data.children = [...data.children, ...list]
  114. data.toggle = !data.toggle
  115. if (list.length < 20) {
  116. data.isMore = false
  117. }
  118. })
  119. } else {
  120. data.toggle = !data.toggle
  121. }
  122. console.log(data, 'data')
  123. },
  124. getRecordDetail(page, type, cb) {
  125. uni.showLoading()
  126. panKuRecordDetail({
  127. page_index: page,
  128. type,
  129. start_time: this.recoedParams.start_time + ' 00:00:00',
  130. end_time: this.recoedParams.end_time + ' 00:00:00'
  131. }).then(res => {
  132. uni.hideLoading()
  133. if (res.code === 200) {
  134. cb && cb(res.data.list)
  135. console.log(res.data.list, 'list')
  136. } else {
  137. uni.showModal({
  138. content: res.message || '查看记录详情失败',
  139. showCancel: false
  140. })
  141. }
  142. }).catch(() => {
  143. uni.hideLoading()
  144. uni.showModal({
  145. content: '查看记录详情失败',
  146. showCancel: false
  147. })
  148. })
  149. },
  150. // 记录
  151. getStockRecord() {
  152. uni.showLoading()
  153. const _this = this
  154. let {
  155. start_time,
  156. end_time
  157. } = this.recoedParams
  158. panKuRecord({
  159. start_time: start_time + ' 00:00:00',
  160. end_time: end_time + ' 00:00:00'
  161. }).then(res => {
  162. if (res.code === 200) {
  163. _this.infoList = Object.keys(res.data).map(k => {
  164. let item = Object.assign({}, res.data[k])
  165. item.type = this.changeKey(k).type
  166. item.type_name = this.changeKey(k).name
  167. item.children = []
  168. item.total = Number(item.man) + Number(item.woman)
  169. item.toggle = false
  170. item.page_index = 1
  171. item.isMore = true
  172. return item
  173. })
  174. console.log(this.infoList, 'infoList')
  175. } else {
  176. uni.showModal({
  177. content: res.message || "获取库存记录失败",
  178. showCancel: false
  179. })
  180. }
  181. }).catch(() => {
  182. uni.hideLoading()
  183. uni.showModal({
  184. content: "获取库存记录失败",
  185. showCancel: false
  186. })
  187. })
  188. },
  189. changeKey(k) {
  190. let m = new Map([
  191. ['simple', {
  192. name: '简约版',
  193. type: '1'
  194. }],
  195. ['new_old', {
  196. name: '纯棉版',
  197. type: '3'
  198. }],
  199. ['old', {
  200. name: '高腰版',
  201. type: '2'
  202. }],
  203. ['hard', {
  204. name: '精装版',
  205. type: '0'
  206. }],
  207. ['youth', {
  208. name: '青春版',
  209. type: '4'
  210. }]
  211. ])
  212. return m.get(k)
  213. }
  214. }
  215. }
  216. </script>
  217. <style lang="scss" scoped>
  218. page {
  219. display: flex;
  220. flex-direction: column;
  221. }
  222. .recordContainer {
  223. width: 100%;
  224. flex: 1;
  225. background-color: #F9F9FB;
  226. padding: 30rpx;
  227. box-sizing: border-box;
  228. .search {
  229. width: 100%;
  230. display: flex;
  231. align-items: center;
  232. justify-content: space-between;
  233. .time {
  234. width: 468rpx;
  235. height: 68rpx;
  236. border-radius: 68rpx;
  237. background-color: #ffffff;
  238. padding: 0 34rpx;
  239. box-sizing: border-box;
  240. line-height: 68rpx;
  241. font-size: 28rpx;
  242. display: flex;
  243. align-items: center;
  244. justify-content: space-between;
  245. .value {
  246. color: #999999;
  247. letter-spacing: 1px;
  248. }
  249. .fixed {
  250. color: #333333;
  251. }
  252. }
  253. .btn {
  254. width: 192rpx;
  255. height: 68rpx;
  256. border-radius: 68rpx;
  257. text-align: center;
  258. line-height: 68rpx;
  259. color: #FFFFFF;
  260. font-size: 28rpx;
  261. background: linear-gradient(to right, #F97C55 0%, #F44545 100%);
  262. }
  263. }
  264. .Header {
  265. width: 100%;
  266. height: 110rpx;
  267. display: flex;
  268. align-items: center;
  269. justify-content: space-between;
  270. color: #333333;
  271. font-size: 32rpx;
  272. line-height: 44rpx;
  273. .spec {
  274. color: #EA4A41 !important;
  275. font-weight: bold;
  276. }
  277. }
  278. .typeCard {
  279. width: 100%;
  280. border-radius: 24rpx;
  281. background-color: #ffffff;
  282. margin-bottom: 30rpx;
  283. overflow: hidden;
  284. .header {
  285. width: 100%;
  286. height: 104rpx;
  287. padding: 0 30rpx;
  288. box-sizing: border-box;
  289. display: flex;
  290. align-items: center;
  291. justify-content: flex-start;
  292. border-bottom: 1px solid #EEEEEE;
  293. .icon {
  294. width: 30rpx;
  295. height: 30rpx;
  296. border-radius: 50%;
  297. background-color: rgba(234, 74, 65, 0.36);
  298. margin-right: 10rpx;
  299. display: flex;
  300. align-items: center;
  301. justify-content: center;
  302. &::before {
  303. content: "";
  304. display: block;
  305. width: 18rpx;
  306. height: 18rpx;
  307. border-radius: 50%;
  308. background-color: #EA4A41;
  309. }
  310. }
  311. .name {
  312. color: #333333;
  313. font-size: 32rpx;
  314. line-height: 44rpx;
  315. }
  316. &::after {
  317. display: block;
  318. content: "";
  319. margin-left: auto;
  320. width: 30rpx;
  321. height: 30rpx;
  322. background-image: url(../../static/new_my/arrow.png);
  323. background-position: center;
  324. background-size: cover;
  325. background-repeat: no-repeat;
  326. }
  327. &.open {
  328. &::after {
  329. transform: rotate(90deg) !important;
  330. }
  331. }
  332. }
  333. .scrollList {
  334. width: 100%;
  335. height: 416rpx;
  336. .scrollItem {
  337. width: 100%;
  338. height: 104rpx;
  339. border-bottom: 1px solid #EEEEEE;
  340. box-sizing: border-box;
  341. padding: 0 30rpx;
  342. color: #333333;
  343. font-size: 28rpx;
  344. line-height: 40rpx;
  345. display: flex;
  346. align-items: center;
  347. justify-content: space-between;
  348. .spec {
  349. font-size: 32rpx !important;
  350. color: #EA4A41 !important;
  351. }
  352. &.noMore {
  353. justify-content: center !important;
  354. border-bottom: none !important;
  355. }
  356. .sex,
  357. .size,
  358. .time,
  359. .num {
  360. width: 100rpx;
  361. overflow: hidden;
  362. text-overflow: ellipsis;
  363. }
  364. .time {
  365. width: 300rpx !important;
  366. }
  367. .num {
  368. flex: 1 !important;
  369. text-align: right;
  370. }
  371. }
  372. .noTip {
  373. width: 100%;
  374. height: 100%;
  375. display: flex;
  376. align-items: center;
  377. justify-content: center;
  378. color: #333333;
  379. font-size: 28rpx;
  380. }
  381. }
  382. .all {
  383. width: 100%;
  384. height: 116rpx;
  385. padding: 0 30rpx;
  386. display: flex;
  387. align-items: center;
  388. justify-content: space-between;
  389. .sex {
  390. color: #333333;
  391. font-size: 28rpx;
  392. line-height: 40rpx;
  393. }
  394. .num {
  395. color: #999999;
  396. font-size: 28rpx;
  397. .spec {
  398. color: #EA4A41;
  399. font-size: 40rpx;
  400. line-height: 56rpx;
  401. font-weight: bold;
  402. }
  403. }
  404. }
  405. .panku {
  406. justify-content: center !important;
  407. .ku {
  408. color: #333333;
  409. font-size: 28rpx;
  410. .spec {
  411. color: #EA4A41 !important;
  412. font-size: 36rpx !important;
  413. line-height: 50rpx !important;
  414. }
  415. &:nth-last-of-type(1) {
  416. margin-left: 20rpx;
  417. }
  418. }
  419. }
  420. }
  421. }
  422. </style>