<template>
    <div class="edit-view">
        <page-title>
            <el-button @click="$router.go(-1)" :disabled="saving">取消</el-button>
            <!-- <el-button @click="onDelete" :disabled="saving" type="danger" v-if="formData.id"> 删除 </el-button>
            <el-button @click="onSave" :loading="saving" type="primary">保存</el-button> -->
        </page-title>
        <div class="edit-view__content-wrapper">
            <div class="edit-view__content-section">
                <el-form
                    :model="formData"
                    :rules="rules"
                    ref="form"
                    label-width="140px"
                    label-position="right"
                    size="small"
                    style="max-width: 500px"
                    v-if="formData != null"
                >
                    <el-form-item prop="userId" label="用户ID">
                        {{formData.userId}}
                    </el-form-item>
                    <el-form-item prop="collectionId" label="藏品ID">
                        {{formData.collectionId}}
                    </el-form-item>
                    <el-form-item prop="collectionId" label="编号">
                        {{formData.number}}
                    </el-form-item>
                    <el-form-item prop="name" label="名称">
                        {{formData.name}}
                    </el-form-item>


                    <el-form-item prop="pic" label="图片">
                        <el-image :src="formData.pic && formData.pic[0].url"  style="height:150px;" :preview-src-list="[formData.pic && formData.pic[0].url]">
                        </el-image>
                    </el-form-item>
                    <el-form-item prop="detail" label="详情" style="width: calc(100vw - 450px)">
                        <rich-text v-model="formData.detail" :disabled="true"></rich-text>
                    </el-form-item>
                    <el-form-item prop="publicShow" label="是否公开展示">
                        <el-tag  type="success"  v-if="formData.publicShow">是</el-tag>
                        <el-tag  type="info"  v-else >否</el-tag>
                    </el-form-item>
                    <el-form-item prop="consignment" label="是否寄售">
                        <el-tag  type="success"  v-if="formData.consignment">是</el-tag>
                        <el-tag  type="info"  v-else >否</el-tag>
                    </el-form-item>
                    <el-form-item prop="categories" label="分类ID">
                        {{formData.categories}}
                    </el-form-item>

                    <fieldset class="div-wrapper">
                        <legend>买入信息</legend>
                        <el-form-item prop="orderId" label="购买订单ID">
                            {{formData.orderId}}
                        </el-form-item>
                        <el-form-item prop="price" label="购买价格">
                            {{formData.price}}
                        </el-form-item>
                        <el-form-item prop="royalties" label="版税比例">
                            {{formData.royalties}}%
                        </el-form-item>
                        <el-form-item prop="serviceCharge" label="手续费比例">
                            {{formData.serviceCharge}}%
                        </el-form-item>
                        
                        <el-form-item prop="tokenId" label="TOKENID">
                            {{formData.tokenId}}
                        </el-form-item>
                        <el-form-item prop="ipfsUrl" label="IPFS地址">
                            {{formData.ipfsUrl}}
                        </el-form-item>
                        <el-form-item prop="txHash" label="链上hash">
                            {{formData.txHash}}
                        </el-form-item>
                         <el-form-item prop="fromAssetId" label="二手来源资产ID">
                            {{formData.fromAssetId}}
                        </el-form-item>
                        <el-form-item prop="variableType" label="是否打开">
                            {{formData.variableType}}
                        </el-form-item>
                        <el-form-item prop="blindBoxId" label="打开的盲盒ID">
                            {{formData.blindBoxId}}
                        </el-form-item>
                        
                    </fieldset>

                    <fieldset  class="div-wrapper">
                        <legend>卖出信息</legend>
                        <el-form-item prop="sellPrice" label="转让价格">
                            {{formData.sellPrice}}
                        </el-form-item>
                        <el-form-item prop="outTxHash" label="转让hash">
                            {{formData.outTxHash}}
                        </el-form-item>
                        <el-form-item prop="outOrderId" label="转让订单ID">
                            {{formData.outOrderId}}
                        </el-form-item>
                        <el-form-item prop="outTime" label="售出时间">
                            {{formData.outTime}}
                        </el-form-item>

                    </fieldset>
                    
                    <fieldset class="div-wrapper">
                        <legend>持有信息</legend>
                        <el-form-item prop="owner" label="当前持有者姓名">
                            {{formData.owner}}
                        </el-form-item>
                        <el-form-item prop="ownerId" label="当前持有者ID">
                            {{formData.ownerId}}
                        </el-form-item>
                    </fieldset>

                    <el-form-item prop="status" label="状态">
                         <el-tag :type="assetStatusMap[formData.status].type" v-if="assetStatusMap[formData.status]">{{
                            assetStatusMap[formData.status]
                        }}</el-tag>
                    </el-form-item>
                    <el-form-item prop="createdAt" label="创建时间">
                       {{formData.createdAt}}
                    </el-form-item>
                    
                    <el-form-item class="form-submit">
                        <el-button @click="$router.go(-1)" :disabled="saving">取消</el-button>
                    </el-form-item>
                </el-form>
            </div>
        </div>
    </div>
</template>
<script>

import { assetStatusMap } from '@/utils/constant.js';

export default {
    name: 'AssetEdit',
    created() {
        if (this.$route.query.id) {
            this.$http
                .get('asset/get/' + this.$route.query.id)
                .then(res => {
                    this.formData = res;
                })
                .catch(e => {
                    console.log(e);
                    this.$message.error(e.error);
                });
        }
    },
    data() {
        return {
            saving: false,
            formData: null,
            rules: {},
            assetStatusMap
        };
    },
    methods: {
       
    }
};
</script>
<style lang="less" scoped>
    .div-wrapper{
        margin-top:20px;
        padding:0px;
    }
</style>
