<!--
 * @Author: XuanJi
 * @Date: 2024-05-18 20:51:40
 * @LastEditors: XuanJi
 * @LastEditTime: 2024-05-25 23:50:09
 * @Message: Nothing
-->

<template>
    <view class="list-datail" v-cloak>
        <uv-cell-group :border="false">
            <uv-cell
                title="合作内容"
                :label="detail.content"
                :border="false"
                :cellStyle="{ padding: '15px' }"
            ></uv-cell>
            <uv-cell title="时间" :label="detail.time" :border="false" :cellStyle="{ padding: '15px' }"></uv-cell>
            <uv-cell
                title="关联产品"
                :label="getShowNames(detail.product)"
                :border="false"
                :cellStyle="{ padding: '15px' }"
            ></uv-cell>
        </uv-cell-group>
    </view>
</template>
<script>
import { getSrmCooperate, getProductsTreeNoAuth} from "@/config/http.js";
export default {
    data() {
        return {
            detail: {},
        };
    },
    async onLoad(e) {
        const id = e.id;
        const resData = await getSrmCooperate(id);
        console.log(resData);
        this.detail = resData;
		this.getProductsList();
		
    },
    computed: {
        getShowNames() {
            return (rv = []) => {
                if (!rv || !rv.length) return "";
                let names = [];
                this.vuex_products.map(item => {
                    let itemNs = [];
                    if (item.children && item.children.length) {
                        item.children.map(v => {
                            if (rv.includes(v.id)) {
                                itemNs.push(v.name);
                            }
                        });
                    }
                    names = names.concat(itemNs);
                });
                return names.join("，");
            };
        },
    },
	methods:{
		async getProductsList() {
		    if (!this.vuex_products.length) {
		        const data = await getProductsTreeNoAuth();
		        this.$uv.vuex("vuex_products", data ? data : []);
		    }
		},
	}
};
</script>
<style scoped lang="scss">
page {
    background-color: $uv-bg-color;
}
.list-datail {
    background: #fff;
}
.uv-cell {
    /deep/ .uv-cell__title {
        display: flex;
        flex-direction: column;
        justify-content: flex-start;
    }
}
</style>