chuku_record.vue 11 KB

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