<template>
  <div>
		<div class="title">面函列表</div>
		<div class="e-table-wrapper">
			<el-table
				:data="model.trnmod.trndoc.docmod.doclst"
				style="width: 100%"
				>
				<el-table-column
					prop="role"
					label="角色">
				</el-table-column>
				<el-table-column
					prop="cortyp"
					label="面函类型">
				</el-table-column>
				<el-table-column
					prop="id"
					label="凭证代码">
				</el-table-column>
				<el-table-column
					prop="docnam"
					label="凭证名称">
				</el-table-column>
				<el-table-column
					prop="op"
					label="操作">
					<template slot-scope="scope">
						<el-button size="small" type="primary"
                                @click="detail(scope.row)">明细</el-button>
					</template>
					
				</el-table-column>
			</el-table>
		</div>
		 <el-dialog :title="title" :visible.sync="dialogOpen" :destroy-on-close="true" width="95%">
            <c-docshow :path="viewurl"/>
        </el-dialog>
  </div>
</template>

<script>
import Api from "~/service/Api"
import Utils from "~/utils"

export default {
	props:['model'],
	data(){
		return {
			viewurl:"",
			title:'',
			dialogOpen:false
			}
	},
	methods:{
		async detail(row){
			let cortyp = row.cortyp
			let rtnmsg
			if (cortyp == 'SWT'|| cortyp == 'FMT' || cortyp == 'CMT') {
				this.model.setmod.msgmod.doccod = row.id
				rtnmsg = await Api.post('cptopn/msgmod_butshw', {  data: Utils.flatObject(this.model) })
			} else {
				this.model.trnmod.trndoc.doccod = row.id
				this.model.trnmod.trndoc.cortyp = cortyp
				rtnmsg = await Api.post('cptopn/trndoc_butshw', {  data: Utils.flatObject(this.model) })
			}
			console.log(rtnmsg)
			if (rtnmsg.code == SUCCESS) {
				if (cortyp == 'SWT' || cortyp == 'FMT' || cortyp == 'CMT') {
					let viewurl = rtnmsg.data.setmod_msgmod_docpth; 
					this.viewurl = viewurl
					this.title="报文"
					//window.open(viewurl, 'newwindow', 'height=1200,width=800,top=100,left=100,toolbar=no,resizable=no,menubar=no,location=no, status=no');
				} 
				else if(cortyp == 'ELC')
				{
					Modal.info({title:'电证报文',content:<div style={{height:400,overflow:'auto'}}><ELCMessage mty={row.id} message={rtnmsg.data["\\trnmod\\trndoc\\docinf"]}/></div>,
							width:1000,
							
						})
				}
				else {
					let url = rtnmsg.data.trnmod_trndoc_docpth;
					this.viewurl = url
					this.title = "面函"
					//console.log(url)
					//window.open(url)
					// window.location.href = url
					// let url = rtnmsg.data.trndoc_docpth;
					// let viewurl = "/psbcfront/pdfjs/web/viewer.html";
					// viewurl += "?file=" + url;
					// 	window.open(viewurl, 'newwindow', 'height=1200,width=800,top=100,left=100,toolbar=no,resizable=no,menubar=no,location=no, status=no');
				}
				this.dialogOpen=true
			}
			else {
				this.$notify.error({title: '错误',message: '服务请求失败!'})
			}
		}
	}
}
</script>

<style scoped>
.title {
	color: rgba(0, 0, 0, 0.65);
	font-size: 14px;
}
</style>