123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513 |
- <template>
- <view class="recordContainer">
- <view class="record-body">
- <view class="search">
- <view class="time">
- <picker mode="date" @change="toChangeStartTime">
- <view class="value">{{ searchParams.start_time | dateFormatter('yyyy-MM-dd') }}</view>
- </picker>
- <view class="fixed">至</view>
- <picker mode="date" @change="toChangeEndTime">
- <view class="value">{{ searchParams.end_time | dateFormatter('yyyy-MM-dd') }}</view>
- </picker>
- </view>
- <view class="btn" @click="toSearch">查询</view>
- </view>
- <view class="Header">
- <view>入库记录</view>
- <view>
- 总共入库:<text class="spec">{{ infoList.reduce((a, b) => a + Number(b.total), 0) }}套</text>
- </view>
- </view>
- <view v-for="item in infoList" :key="item.type" class="typeCard">
- <view class="header" :class="item.toggle ? 'open' : ''" @click="toGetDetail(item)">
- <view class="icon"></view>
- <view class="name">{{ item.type_name }}</view>
- </view>
- <template v-if="item.toggle">
- <scroll-view scroll-y="true" class="scrollList">
- <template v-if="item.children.length > 0">
- <view v-for="btem in item.children" :key="btem.id" class="scrollItem">
- <view class="sex">{{ btem.sex ? '男款' : '女款' }}</view>
- <view class="size">{{ btem.size }}</view>
- <view class="time">{{ btem.created_at | dateFormatter('yyyy/MM/dd hh:mm:ss') }}</view>
- <view class="num spec">
- +{{ btem.num }}
- </view>
- </view>
- <view v-if="!item.isMore" class="scrollItem noMore">没有更多记录了</view>
- </template>
- <template v-else>
- <view class="noTip">暂无记录</view>
- </template>
- </scroll-view>
- </template>
- <view class="all">
- <view class="sex">
- 男款:{{ item.man }}套/女款:{{ item.woman }}套
- </view>
- <view class="num">入库:<text class="spec">{{ item.total }}套</text></view>
- </view>
- </view>
- </view>
- </view>
- </template>
- <script>
- import {
- stockRecordNew,
- stockRecordDetailNew
- } from "@/apis/stock.js"
- import {
- dateFormatter
- } from "@/filters/index.js"
- export default {
- data() {
- return {
- recoedParams: {
- start_time: '',
- end_time: '',
- record_type: 0
- },
- infoList: [],
- searchParams: {
- start_time: dateFormatter(Date.now(), 'yyyy-MM-dd'),
- end_time: dateFormatter(Date.now(), 'yyyy-MM-dd')
- }
- }
- },
- onLoad(e) {
- this.recoedParams.start_time = dateFormatter(Date.now(), 'yyyy-MM-dd')
- this.recoedParams.end_time = dateFormatter(Date.now(), 'yyyy-MM-dd')
- this.getStockRecord()
- },
- methods: {
- // 查询
- toSearch() {
- let {
- start_time,
- end_time
- } = this.searchParams
- if (new Date(end_time).getTime() < new Date(start_time).getTime()) {
- uni.showModal({
- content: "结束时间不能大于开始时间",
- showCancel: false
- })
- return false
- }
- this.recoedParams.start_time = start_time
- this.recoedParams.end_time = end_time
- this.getStockRecord()
- },
- // 结束时间
- toChangeEndTime(e) {
- this.searchParams.end_time = e.detail.value
- },
- // 开始时间
- toChangeStartTime(e) {
- this.searchParams.start_time = e.detail.value
- },
- // 记录详情
- toGetDetail(data) {
- if (data.total && data.isMore) {
- this.getRecordDetail(data.page_index, data.type, list => {
- data.children = [...data.children, ...list]
- data.toggle = !data.toggle
- if (list.length < 20) {
- data.isMore = false
- }
- })
- } else {
- data.toggle = !data.toggle
- }
- },
- getRecordDetail(page, type, cb) {
- uni.showLoading()
- stockRecordDetailNew({
- page_index: page,
- type,
- record_type: this.recoedParams.record_type,
- start_time: this.recoedParams.start_time + ' 00:00:00',
- end_time: this.recoedParams.end_time + ' 23:59:59'
- }).then(res => {
- uni.hideLoading()
- if (res.code === 200) {
- cb && cb(res.data.list)
- } else {
- uni.showModal({
- content: res.message || '查看记录详情失败',
- showCancel: false
- })
- }
- }).catch(() => {
- uni.hideLoading()
- uni.showModal({
- content: '查看记录详情失败',
- showCancel: false
- })
- })
- },
- // 记录
- getStockRecord() {
- uni.showLoading()
- const _this = this
- let {
- start_time,
- end_time,
- record_type
- } = this.recoedParams
- stockRecordNew({
- start_time: start_time + ' 00:00:00',
- end_time: end_time + ' 23:59:59',
- record_type,
- status: -1
- }).then(res => {
- if (res.code === 200) {
- _this.infoList = Object.keys(res.data).map(k => {
- let item = Object.assign({}, res.data[k])
- item.type = this.changeKey(k).type
- item.type_name = this.changeKey(k).name
- item.children = []
- item.total = Number(item.man) + Number(item.woman)
- item.toggle = false
- item.page_index = 1
- item.isMore = true
- return item
- })
- } else {
- uni.showModal({
- content: res.message || "获取库存记录失败",
- showCancel: false
- })
- }
- }).catch(() => {
- uni.hideLoading()
- uni.showModal({
- content: "获取库存记录失败",
- showCancel: false
- })
- })
- },
- changeKey(k) {
- let m = new Map([
- ['simple', {
- name: '简约版',
- type: '1'
- }],
- ['new_old', {
- name: '纯棉版',
- type: '3'
- }],
- ['old', {
- name: '高腰版',
- type: '2'
- }],
- ['hard', {
- name: '精装版',
- type: '0'
- }],
- ['youth', {
- name: '青春版',
- type: '4'
- }]
- ])
- return m.get(k)
- }
- }
- }
- </script>
- <style lang="scss" scoped>
- page {
- width: 100%;
- }
- .recordContainer {
- background-color: #F9F9FB;
- box-sizing: border-box;
- display: flex;
- flex-direction: column;
- justify-content: space-between;
- .nav {
- width: 100%;
- height: 104rpx;
- padding: 0 60rpx;
- box-sizing: border-box;
- background-color: #ffffff;
- display: flex;
- align-items: center;
- justify-content: space-between;
- &-item {
- position: relative;
- color: #333333;
- font-size: 32rpx;
- line-height: 44rpx;
- &.active {
- color: #EA4A41 !important;
- &::after {
- content: "";
- display: block;
- position: absolute;
- bottom: 0;
- left: 50%;
- transform: translateX(-50%);
- width: 30rpx;
- height: 4rpx;
- border-radius: 4rpx;
- background: linear-gradient(97deg, #F97C55 0%, #F44545 100%);
- }
- }
- }
- }
- .record-body {
- width: 100%;
- padding: 30rpx;
- box-sizing: border-box;
- }
- .search {
- width: 100%;
- display: flex;
- align-items: center;
- justify-content: space-between;
- .time {
- width: 468rpx;
- height: 68rpx;
- border-radius: 68rpx;
- background-color: #ffffff;
- padding: 0 34rpx;
- box-sizing: border-box;
- line-height: 68rpx;
- font-size: 28rpx;
- display: flex;
- align-items: center;
- justify-content: space-between;
- .value {
- color: #999999;
- letter-spacing: 1px;
- }
- .fixed {
- color: #333333;
- }
- }
- .btn {
- width: 192rpx;
- height: 68rpx;
- border-radius: 68rpx;
- text-align: center;
- line-height: 68rpx;
- color: #FFFFFF;
- font-size: 28rpx;
- background: linear-gradient(to right, #F97C55 0%, #F44545 100%);
- }
- }
- .Header {
- width: 100%;
- height: 110rpx;
- display: flex;
- align-items: center;
- justify-content: space-between;
- color: #333333;
- font-size: 32rpx;
- line-height: 44rpx;
- .spec {
- color: #EA4A41 !important;
- font-weight: bold;
- }
- }
- .typeCard {
- width: 100%;
- border-radius: 24rpx;
- background-color: #ffffff;
- margin-bottom: 30rpx;
- overflow: hidden;
- .header {
- width: 100%;
- height: 104rpx;
- padding: 0 30rpx;
- box-sizing: border-box;
- display: flex;
- align-items: center;
- justify-content: flex-start;
- border-bottom: 1px solid #EEEEEE;
- .icon {
- width: 30rpx;
- height: 30rpx;
- border-radius: 50%;
- background-color: rgba(234, 74, 65, 0.36);
- margin-right: 10rpx;
- display: flex;
- align-items: center;
- justify-content: center;
- &::before {
- content: "";
- display: block;
- width: 18rpx;
- height: 18rpx;
- border-radius: 50%;
- background-color: #EA4A41;
- }
- }
- .name {
- color: #333333;
- font-size: 32rpx;
- line-height: 44rpx;
- }
- &::after {
- display: block;
- content: "";
- margin-left: auto;
- width: 30rpx;
- height: 30rpx;
- background-image: url(../../static/new_my/arrow.png);
- background-position: center;
- background-size: cover;
- background-repeat: no-repeat;
- }
- &.open {
- &::after {
- transform: rotate(90deg) !important;
- }
- }
- }
- .scrollList {
- width: 100%;
- height: 416rpx;
- .scrollItem {
- width: 100%;
- height: 104rpx;
- border-bottom: 1px solid #EEEEEE;
- box-sizing: border-box;
- padding: 0 30rpx;
- color: #333333;
- font-size: 28rpx;
- line-height: 40rpx;
- display: flex;
- align-items: center;
- justify-content: space-between;
- .spec {
- font-size: 32rpx !important;
- color: #EA4A41 !important;
- }
- &.noMore {
- justify-content: center !important;
- border-bottom: none !important;
- }
- .sex,
- .size,
- .time,
- .num,
- .type {
- width: 80rpx;
- overflow: hidden;
- text-overflow: ellipsis;
- }
- .time {
- width: 280rpx !important;
- }
- .num {
- flex: 1 !important;
- text-align: right;
- }
- .type {
- text-align: right;
- }
- .spec2 {
- color: #0E8EFF !important;
- }
- }
- .noTip {
- width: 100%;
- height: 100%;
- display: flex;
- align-items: center;
- justify-content: center;
- color: #333333;
- font-size: 28rpx;
- }
- }
- .all {
- width: 100%;
- height: 116rpx;
- padding: 0 30rpx;
- display: flex;
- align-items: center;
- justify-content: space-between;
- .sex {
- color: #333333;
- font-size: 28rpx;
- line-height: 40rpx;
- }
- .num {
- color: #999999;
- font-size: 28rpx;
- .spec {
- color: #EA4A41;
- font-size: 40rpx;
- line-height: 56rpx;
- font-weight: bold;
- }
- }
- }
- .panku {
- justify-content: center !important;
- .ku {
- color: #333333;
- font-size: 28rpx;
- .spec {
- color: #EA4A41 !important;
- font-size: 36rpx !important;
- line-height: 50rpx !important;
- }
- &:nth-last-of-type(1) {
- margin-left: 20rpx;
- }
- }
- }
- }
- }
- </style>
|