<template>
    <div>
        <table class="spfm-table" v-if="infoApply">
            <tr>
                <th>工单标题</th>
                <td colspan="3">{{infoApply.tit}}</td>
            </tr>

            <tr>
                <th>需求类型</th>
                <td>{{infoApply.mbhxqlx}}</td>
                <th>投放位置</th>
                <td>{{parserWz(infoApply.mbhtfwz)}}</td>
            </tr>

            <tr>
                <th>开始时间</th>
                <td>{{infoApply.mbhkssj}}</td>
                <th>结束时间</th>
                <td>{{infoApply.mbhjssj}}</td>
            </tr>

            <tr>
                <th>投放区域</th>
                <td>{{(infoApply.mbhtfqy)}}</td>
                <th>投放定向</th>
                <td>{{parserTFDX(infoApply.mbhtfdx)}}</td>
            </tr>           

            <tr>
                <th>素材名称</th>
                <td>{{infoApply.mbhscmc}}</td>
                <th>素材时长</th>
                <td>{{infoApply.mbhscsc}}</td>
            </tr>      


            <tr>
                <th>素材类型</th>
                <td>{{infoApply.mbhsclx}}</td>
                <th>拨测要求</th>
                <td>{{parserBc(infoApply.mbhbcyq)}}</td>
            </tr> 
            
            <tr>
                <th>状态</th>
                <td>{{parserStatus(infoApply.status)}}</td>
                <th>是否上线</th>
                <td>{{parserPublish(infoApply.publish)}}</td>
            </tr> 

            <tr>
                <th>创建人</th>
                <td>{{infoApply.createLoginName}}</td>
                <th>创建时间</th>
                <td>{{infoApply.createTime}}</td>
            </tr> 

            <tr>
                <th>附件</th>
                <td colspan="3">
                    <uploadDown :datalist="datalist" :dialogStatus="uploadstatus"></uploadDown>
                </td>
            </tr>
        </table>
    </div>
</template>

<script>
import uploadDown from '@/components/uploadDown.vue'
export default {
    components:{uploadDown},
    props: {
        woNo:   { required: false,type: String},
        itemId: { required: false,type: String},
        taskName:{ required: false, type: String}
    },
    data(){
        return{
            loading:false,
            tableData:[],
            infoApply:'',
            labelPosition: 'right',
            uploadstatus:false,
            datalist: {
                url: '/bpm/api/download',
                type: 1
            },

        }
    },
    methods:{
        handlePublishUpload(){

        },
        parserPublish(v){
            if(v==="0"){
                return "未上线";
            }else if(v==="1"){
                return "上线";
            }
        },
        parserStatus(v){
            if(v==="0"){
                return "审批中";
            }else if(v==="1"){
                return "归档";
            }else if(v==="2"){
                return "结束";
            }
        },
        parserBc(v){
            return this.pp(v)        
        },
        parserWz(v){
            return this.pp(v)        
        },
        parserTFDX(v){
            return this.pp(v)
        },
        pp(v){
            if(v!==undefined){
                v = v.replace("[","").replace("]","").replace("\"","").replace("\"","").replace("\"","").replace("\"","").replace("\"","").replace("\"","").replace("\"","")
                v = v.replace("\"","").replace("\"","").replace("\"","").replace("\"","").replace("\"","").replace("\"","").replace("\"","")
            }
            return v;
        },
        loadData(){
            this.$http({
                url: "/market/mbh/list",
                method: "post",
                headers: {"Content-Type": "application/json"},
                data: {"itemId":this.itemId,"woNo":this.woNo}
            }).then((res) => {
                if(res.data.result==0){
                    this.tableData = res.data.body
                    this.infoApply = this.tableData[0]
                    //
                    //console.log(this.infoApply)
                    let xFile = JSON.parse(this.infoApply.attrList);
                    for(var i = 0 ;i<xFile.length ;i++){
                        xFile[i].fileName = xFile[i].name;
                    }
                    this.datalist.attList = xFile;
                    this.uploadstatus =true
                }else{
                this.$message({ showClose: true, message: '系统异常',type: 'error'});
                }
            });
        }
    },
    created(){
        this.loadData()
    }
}
</script>

<style scoped lang="scss">
    .spfm-table{ width: 100%;border-collapse: collapse; }
    .spfm-table th {border-width: 1px;padding: 8px;border-style: solid;border-color: #EBEEF5; width:100px;font-weight: 500;}
    .spfm-table td {border-width: 1px;padding: 8px;border-style: solid;border-color: #EBEEF5;}
</style>
