|
|
@@ -0,0 +1,124 @@
|
|
|
+<template>
|
|
|
+ <view class="tree-page">
|
|
|
+ <view class="tree-empty" v-if="loading">加载中...</view>
|
|
|
+ <view class="tree-empty" v-else-if="!rows.length">{{ emptyText }}</view>
|
|
|
+ <view class="tree-row" v-else v-for="(row, rowIndex) in rows" :key="rowIndex">
|
|
|
+ <text class="row-index">第{{ rowIndex + 1 }}筛</text>
|
|
|
+ <view class="num-list">
|
|
|
+ <text class="num-item" v-for="(num, numIndex) in row" :key="numIndex">{{ num }}</text>
|
|
|
+ </view>
|
|
|
+ </view>
|
|
|
+ </view>
|
|
|
+</template>
|
|
|
+<script>
|
|
|
+import { getTree } from "@/api/order"
|
|
|
+export default {
|
|
|
+ name: "tree",
|
|
|
+ components: {},
|
|
|
+ mixins: [],
|
|
|
+ data() {
|
|
|
+ return {
|
|
|
+ option: {},
|
|
|
+ rows: [],
|
|
|
+ loading: false,
|
|
|
+ emptyText: "暂无数据"
|
|
|
+ }
|
|
|
+ },
|
|
|
+ onLoad(option){
|
|
|
+ this.option = option || {}
|
|
|
+ this.init()
|
|
|
+ },
|
|
|
+ methods: {
|
|
|
+ init(){
|
|
|
+ let orderSn = this.option.orderSn||''
|
|
|
+ let productId = this.option.productId||0
|
|
|
+ this.loading = true
|
|
|
+ this.emptyText = "暂无数据"
|
|
|
+ getTree({ orderSn, productId }).then(res=>{
|
|
|
+ if(res.code == 1){
|
|
|
+ let list = (res.data && res.data.list) || []
|
|
|
+ this.rows = this.formatRows(list)
|
|
|
+ if (!this.rows.length) {
|
|
|
+ this.emptyText = "暂无数量数据"
|
|
|
+ }
|
|
|
+ } else {
|
|
|
+ this.rows = []
|
|
|
+ this.emptyText = res.msg || "获取数据失败"
|
|
|
+ }
|
|
|
+ }).catch(() => {
|
|
|
+ this.rows = []
|
|
|
+ this.emptyText = "获取数据失败"
|
|
|
+ }).finally(() => {
|
|
|
+ this.loading = false
|
|
|
+ })
|
|
|
+ },
|
|
|
+ formatRows(list) {
|
|
|
+ let nums = []
|
|
|
+ list.forEach(item => {
|
|
|
+ if (Array.isArray(item)) {
|
|
|
+ item.forEach(child => {
|
|
|
+ if (child && child.num !== undefined) {
|
|
|
+ nums.push(child.num)
|
|
|
+ } else if (typeof child === "number" || typeof child === "string") {
|
|
|
+ nums.push(child)
|
|
|
+ }
|
|
|
+ })
|
|
|
+ } else if (item && item.num !== undefined) {
|
|
|
+ nums.push(item.num)
|
|
|
+ }
|
|
|
+ })
|
|
|
+
|
|
|
+ let rows = []
|
|
|
+ for (let i = 0; i < nums.length; i += 5) {
|
|
|
+ rows.push(nums.slice(i, i + 5))
|
|
|
+ }
|
|
|
+ return rows
|
|
|
+ }
|
|
|
+ }
|
|
|
+}
|
|
|
+</script>
|
|
|
+<style lang="scss" scoped>
|
|
|
+.tree-page {
|
|
|
+ padding: 24upx;
|
|
|
+}
|
|
|
+
|
|
|
+.tree-row {
|
|
|
+ display: flex;
|
|
|
+ align-items: center;
|
|
|
+ margin-top: 20upx;
|
|
|
+
|
|
|
+ &:first-child {
|
|
|
+ margin-top: 0;
|
|
|
+ }
|
|
|
+}
|
|
|
+
|
|
|
+.tree-empty {
|
|
|
+ padding-top: 120upx;
|
|
|
+ text-align: center;
|
|
|
+ color: #999;
|
|
|
+ font-size: 32upx;
|
|
|
+}
|
|
|
+
|
|
|
+.row-index {
|
|
|
+ width: 120upx;
|
|
|
+ color: #3385FF;
|
|
|
+ font-size: 32upx;
|
|
|
+}
|
|
|
+
|
|
|
+.num-list {
|
|
|
+ flex: 1;
|
|
|
+ display: flex;
|
|
|
+ align-items: center;
|
|
|
+}
|
|
|
+
|
|
|
+.num-item {
|
|
|
+ min-width: 80upx;
|
|
|
+ margin-left: 16upx;
|
|
|
+ font-size: 34upx;
|
|
|
+ color: #333;
|
|
|
+
|
|
|
+ &:first-child {
|
|
|
+ margin-left: 0;
|
|
|
+ }
|
|
|
+}
|
|
|
+</style>
|