<template>
	<!-- 纸媒上刊确认单样例 -->
	<div style="margin: 5px 0 20px 0;padding: 0 20px;">
		<el-table class="com-table" ref="multipleTable" :data="infodata" tooltip-effect="dark"
			size="small" border style="width: 100%">
			<el-table-column prop="media_name" label="投放媒体" width="200">
				<template slot-scope="scope">
					<el-input v-model="scope.row.mediaName"
						:disabled="titname != '添加'&&vision != '流程发起'"></el-input>
				</template>
			</el-table-column>
			<el-table-column prop="adv_theme" label="广告主题" width="200">
				<template slot-scope="scope">
					<el-input v-model="scope.row.advTheme"
						:disabled="titname != '添加'&&vision != '流程发起'"></el-input>
				</template>
			</el-table-column>
			<el-table-column prop="put_time" label="投放日期" width="200">
				<template slot-scope="scope">
					<el-input v-model="scope.row.putTime"
						:disabled="titname != '添加'&&vision != '流程发起'"></el-input>
				</template>
			</el-table-column>
			<el-table-column prop="put_spec" label="投放规格" width="200">
				<template slot-scope="scope">
					<el-input v-model="scope.row.putSpec"
						:disabled="titname != '添加'&&vision != '流程发起'"></el-input>
				</template>
			</el-table-column>
			<el-table-column prop="adv_size" label="广告尺寸" width="200">
				<template slot-scope="scope">
					<el-input v-model="scope.row.advSize" :disabled="titname != '添加'&&vision != '流程发起'">
					</el-input>
				</template>
			</el-table-column>
			<el-table-column prop="adv_site" label="广告位置" width="200">
				<template slot-scope="scope">
					<el-input v-model="scope.row.advSite"
						:disabled="titname != '添加'&&vision != '流程发起'"></el-input>
				</template>
			</el-table-column>
			<el-table-column prop="adv_color" label="广告颜色" width="200">
				<template slot-scope="scope">
					<el-input v-model="scope.row.advColor"
						:disabled="titname != '添加'&&vision != '流程发起'"></el-input>
				</template>
			</el-table-column>
			<el-table-column prop="cost_all" label="费用(不含税,元)" width="200">
				<template slot-scope="scope">
					<el-input v-model="scope.row.costAll"
						:disabled="titname != '添加'&&vision != '流程发起'" @change="sumfyno"></el-input>
				</template>
			</el-table-column>
			<el-table-column prop="cost_tax" label="费用(含税,元)" width="200">
				<template slot-scope="scope">
					<el-input v-model="scope.row.costTax"
						:disabled="titname != '添加'&&vision != '流程发起'"></el-input>
				</template>
			</el-table-column>
			<el-table-column prop="remark" label="备注" width="300">
				<template slot-scope="scope">
					<el-input v-model="scope.row.remark"
						:disabled="titname != '添加'&&vision != '流程发起'"></el-input>
				</template>
			</el-table-column>
	
			<el-table-column label="操作" width="120px" align="center" v-if="titname == '添加'"
				fixed="right">
				<template slot-scope="scope">
					<el-button size="mini" type="primary" @click="choline(1,scope)">添加</el-button>
					<el-button size="mini" type="danger" @click="choline(2,scope)">删除</el-button>
				</template>
			</el-table-column>
		</el-table>
		<div class="sumbox">总价：{{allSum}}</div>
	</div>
</template>

<script>
	export default {
		props: ["vision", "titname","infodatas","status","allSumnum"],
		data() {
			return {
				infodata: [],
				allSum: 0
			};
		},
		methods: {
			choline(v, n) {
				if (v == 1) {
					this.infodata.push({costAll:0})
				} else {
					this.infodata.splice(n.$index, 1)
				}
				this.allSum = 0;
				for (let i = 0; i < this.infodata.length; i++) {
					this.allSum += this.infodata[i].costAll*1;
				}
			},
			sumfyno(){
				this.allSum = 0;
				for (let i = 0; i < this.infodata.length; i++) {
					this.allSum += this.infodata[i].costAll*1;
				}
			}
		},
		mounted() {},
		created() {
			this.infodata = [{costAll:0}, {costAll:0}];
			if(this.status){
				this.infodata = this.infodatas;
				this.allSum = this.allSumnum;
			}
		},
		watch:{
			allSum(v){
				this.$emit('backsum',this.allSum,this.infodata)
			},
			status(v){
				this.infodata = this.infodatas;
				this.allSum = this.allSumnum;
			}
		}
	};
</script>

<style scoped lang="scss">
	.sumbox {
		width: 200px;
		background: aliceblue;
		float: right;
		padding: 5px;
		margin: 20px 0;
		font-size: 18px;
	}
</style>
