ruku_record.vue 11 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513
  1. <template>
  2. <view class="recordContainer">
  3. <view class="record-body">
  4. <view class="search">
  5. <view class="time">
  6. <picker mode="date" @change="toChangeStartTime">
  7. <view class="value">{{ searchParams.start_time | dateFormatter('yyyy-MM-dd') }}</view>
  8. </picker>
  9. <view class="fixed">至</view>
  10. <picker mode="date" @change="toChangeEndTime">
  11. <view class="value">{{ searchParams.end_time | dateFormatter('yyyy-MM-dd') }}</view>
  12. </picker>
  13. </view>
  14. <view class="btn" @click="toSearch">查询</view>
  15. </view>
  16. <view class="Header">
  17. <view>入库记录</view>
  18. <view>
  19. 总共入库:<text class="spec">{{ infoList.reduce((a, b) => a + Number(b.total), 0) }}套</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.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">
  46. <view class="sex">
  47. 男款:{{ item.man }}套/女款:{{ item.woman }}套
  48. </view>
  49. <view class="num">入库:<text class="spec">{{ item.total }}套</text></view>
  50. </view>
  51. </view>
  52. </view>
  53. </view>
  54. </template>
  55. <script>
  56. import {
  57. stockRecordNew,
  58. stockRecordDetailNew
  59. } from "@/apis/stock.js"
  60. import {
  61. dateFormatter
  62. } from "@/filters/index.js"
  63. export default {
  64. data() {
  65. return {
  66. recoedParams: {
  67. start_time: '',
  68. end_time: '',
  69. record_type: 0
  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(e) {
  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. },
  123. getRecordDetail(page, type, cb) {
  124. uni.showLoading()
  125. stockRecordDetailNew({
  126. page_index: page,
  127. type,
  128. record_type: this.recoedParams.record_type,
  129. start_time: this.recoedParams.start_time + ' 00:00:00',
  130. end_time: this.recoedParams.end_time + ' 23:59:59'
  131. }).then(res => {
  132. uni.hideLoading()
  133. if (res.code === 200) {
  134. cb && cb(res.data.list)
  135. } else {
  136. uni.showModal({
  137. content: res.message || '查看记录详情失败',
  138. showCancel: false
  139. })
  140. }
  141. }).catch(() => {
  142. uni.hideLoading()
  143. uni.showModal({
  144. content: '查看记录详情失败',
  145. showCancel: false
  146. })
  147. })
  148. },
  149. // 记录
  150. getStockRecord() {
  151. uni.showLoading()
  152. const _this = this
  153. let {
  154. start_time,
  155. end_time,
  156. record_type
  157. } = this.recoedParams
  158. stockRecordNew({
  159. start_time: start_time + ' 00:00:00',
  160. end_time: end_time + ' 23:59:59',
  161. record_type,
  162. status: -1
  163. }).then(res => {
  164. if (res.code === 200) {
  165. _this.infoList = Object.keys(res.data).map(k => {
  166. let item = Object.assign({}, res.data[k])
  167. item.type = this.changeKey(k).type
  168. item.type_name = this.changeKey(k).name
  169. item.children = []
  170. item.total = Number(item.man) + Number(item.woman)
  171. item.toggle = false
  172. item.page_index = 1
  173. item.isMore = true
  174. return item
  175. })
  176. } else {
  177. uni.showModal({
  178. content: res.message || "获取库存记录失败",
  179. showCancel: false
  180. })
  181. }
  182. }).catch(() => {
  183. uni.hideLoading()
  184. uni.showModal({
  185. content: "获取库存记录失败",
  186. showCancel: false
  187. })
  188. })
  189. },
  190. changeKey(k) {
  191. let m = new Map([
  192. ['simple', {
  193. name: '简约版',
  194. type: '1'
  195. }],
  196. ['new_old', {
  197. name: '纯棉版',
  198. type: '3'
  199. }],
  200. ['old', {
  201. name: '高腰版',
  202. type: '2'
  203. }],
  204. ['hard', {
  205. name: '精装版',
  206. type: '0'
  207. }],
  208. ['youth', {
  209. name: '青春版',
  210. type: '4'
  211. }]
  212. ])
  213. return m.get(k)
  214. }
  215. }
  216. }
  217. </script>
  218. <style lang="scss" scoped>
  219. page {
  220. width: 100%;
  221. }
  222. .recordContainer {
  223. background-color: #F9F9FB;
  224. box-sizing: border-box;
  225. display: flex;
  226. flex-direction: column;
  227. justify-content: space-between;
  228. .nav {
  229. width: 100%;
  230. height: 104rpx;
  231. padding: 0 60rpx;
  232. box-sizing: border-box;
  233. background-color: #ffffff;
  234. display: flex;
  235. align-items: center;
  236. justify-content: space-between;
  237. &-item {
  238. position: relative;
  239. color: #333333;
  240. font-size: 32rpx;
  241. line-height: 44rpx;
  242. &.active {
  243. color: #EA4A41 !important;
  244. &::after {
  245. content: "";
  246. display: block;
  247. position: absolute;
  248. bottom: 0;
  249. left: 50%;
  250. transform: translateX(-50%);
  251. width: 30rpx;
  252. height: 4rpx;
  253. border-radius: 4rpx;
  254. background: linear-gradient(97deg, #F97C55 0%, #F44545 100%);
  255. }
  256. }
  257. }
  258. }
  259. .record-body {
  260. width: 100%;
  261. padding: 30rpx;
  262. box-sizing: border-box;
  263. }
  264. .search {
  265. width: 100%;
  266. display: flex;
  267. align-items: center;
  268. justify-content: space-between;
  269. .time {
  270. width: 468rpx;
  271. height: 68rpx;
  272. border-radius: 68rpx;
  273. background-color: #ffffff;
  274. padding: 0 34rpx;
  275. box-sizing: border-box;
  276. line-height: 68rpx;
  277. font-size: 28rpx;
  278. display: flex;
  279. align-items: center;
  280. justify-content: space-between;
  281. .value {
  282. color: #999999;
  283. letter-spacing: 1px;
  284. }
  285. .fixed {
  286. color: #333333;
  287. }
  288. }
  289. .btn {
  290. width: 192rpx;
  291. height: 68rpx;
  292. border-radius: 68rpx;
  293. text-align: center;
  294. line-height: 68rpx;
  295. color: #FFFFFF;
  296. font-size: 28rpx;
  297. background: linear-gradient(to right, #F97C55 0%, #F44545 100%);
  298. }
  299. }
  300. .Header {
  301. width: 100%;
  302. height: 110rpx;
  303. display: flex;
  304. align-items: center;
  305. justify-content: space-between;
  306. color: #333333;
  307. font-size: 32rpx;
  308. line-height: 44rpx;
  309. .spec {
  310. color: #EA4A41 !important;
  311. font-weight: bold;
  312. }
  313. }
  314. .typeCard {
  315. width: 100%;
  316. border-radius: 24rpx;
  317. background-color: #ffffff;
  318. margin-bottom: 30rpx;
  319. overflow: hidden;
  320. .header {
  321. width: 100%;
  322. height: 104rpx;
  323. padding: 0 30rpx;
  324. box-sizing: border-box;
  325. display: flex;
  326. align-items: center;
  327. justify-content: flex-start;
  328. border-bottom: 1px solid #EEEEEE;
  329. .icon {
  330. width: 30rpx;
  331. height: 30rpx;
  332. border-radius: 50%;
  333. background-color: rgba(234, 74, 65, 0.36);
  334. margin-right: 10rpx;
  335. display: flex;
  336. align-items: center;
  337. justify-content: center;
  338. &::before {
  339. content: "";
  340. display: block;
  341. width: 18rpx;
  342. height: 18rpx;
  343. border-radius: 50%;
  344. background-color: #EA4A41;
  345. }
  346. }
  347. .name {
  348. color: #333333;
  349. font-size: 32rpx;
  350. line-height: 44rpx;
  351. }
  352. &::after {
  353. display: block;
  354. content: "";
  355. margin-left: auto;
  356. width: 30rpx;
  357. height: 30rpx;
  358. background-image: url(../../static/new_my/arrow.png);
  359. background-position: center;
  360. background-size: cover;
  361. background-repeat: no-repeat;
  362. }
  363. &.open {
  364. &::after {
  365. transform: rotate(90deg) !important;
  366. }
  367. }
  368. }
  369. .scrollList {
  370. width: 100%;
  371. height: 416rpx;
  372. .scrollItem {
  373. width: 100%;
  374. height: 104rpx;
  375. border-bottom: 1px solid #EEEEEE;
  376. box-sizing: border-box;
  377. padding: 0 30rpx;
  378. color: #333333;
  379. font-size: 28rpx;
  380. line-height: 40rpx;
  381. display: flex;
  382. align-items: center;
  383. justify-content: space-between;
  384. .spec {
  385. font-size: 32rpx !important;
  386. color: #EA4A41 !important;
  387. }
  388. &.noMore {
  389. justify-content: center !important;
  390. border-bottom: none !important;
  391. }
  392. .sex,
  393. .size,
  394. .time,
  395. .num,
  396. .type {
  397. width: 80rpx;
  398. overflow: hidden;
  399. text-overflow: ellipsis;
  400. }
  401. .time {
  402. width: 280rpx !important;
  403. }
  404. .num {
  405. flex: 1 !important;
  406. text-align: right;
  407. }
  408. .type {
  409. text-align: right;
  410. }
  411. .spec2 {
  412. color: #0E8EFF !important;
  413. }
  414. }
  415. .noTip {
  416. width: 100%;
  417. height: 100%;
  418. display: flex;
  419. align-items: center;
  420. justify-content: center;
  421. color: #333333;
  422. font-size: 28rpx;
  423. }
  424. }
  425. .all {
  426. width: 100%;
  427. height: 116rpx;
  428. padding: 0 30rpx;
  429. display: flex;
  430. align-items: center;
  431. justify-content: space-between;
  432. .sex {
  433. color: #333333;
  434. font-size: 28rpx;
  435. line-height: 40rpx;
  436. }
  437. .num {
  438. color: #999999;
  439. font-size: 28rpx;
  440. .spec {
  441. color: #EA4A41;
  442. font-size: 40rpx;
  443. line-height: 56rpx;
  444. font-weight: bold;
  445. }
  446. }
  447. }
  448. .panku {
  449. justify-content: center !important;
  450. .ku {
  451. color: #333333;
  452. font-size: 28rpx;
  453. .spec {
  454. color: #EA4A41 !important;
  455. font-size: 36rpx !important;
  456. line-height: 50rpx !important;
  457. }
  458. &:nth-last-of-type(1) {
  459. margin-left: 20rpx;
  460. }
  461. }
  462. }
  463. }
  464. }
  465. </style>