<template>
	<view class="mainBox">
		<view v-for="(item, index) in tableList" :key="index" style="position: relative;">
			<myCard :item="item" :btnList="btnList" :index="index+1" :columns="columns" @del="del(index)">
				<u--input placeholder="请输入" slot="name" v-model="item.name">
				</u--input>
				<u--textarea v-model="item.analysis" slot="analysis" placeholder="请输入内容" autoHeight></u--textarea>

			</myCard>
		</view>


		<view class="add" @click="add">
			<u-icon name="plus" color="#fff"></u-icon>
		</view>
		<view style="height: 84rpx;" v-if="isDrawer"></view>
		<view class="footerButton" v-if="isDrawer">
			<u-button type="primary" @click="save" text="保存"></u-button>
		</view>
	</view>
</template>

<script>
	import myCard from '../../components/myCard.vue'
	export default {
		components: {
			myCard
		},
		props: {
			isDrawer: {
				default: false
			}
		},
		data() {
			return {
				tableList: [],
				btnList: [{
					name: '删除',
					apiName: 'del',
					btnType: 'error ',
					type: '2',
					pageUrl: '',
				}],
				columns: [
					[{
						label: '竞争对手名称：',
						prop: 'name',
						slot: 'name',
						className: 'perce100',
						style:{
							marginBottom:'14rpx'
						}
					}],
					[{
						label: '竞品分析：',
						prop: 'analysis',
						slot: 'analysis',
						className: 'perce100',
						style:{
							marginBottom:'14rpx'
						}
					}],
					[{
						label: '操作：',
						prop: 'action',
						type: 'action',
						className: 'perce100',
					}],
				]

			}
		},
		created() {

		},
		methods: {
			add(status) {
				this.tableList.push({
					name: '',
					analysis: ''
				})
			},
			init(list) {
				if (list) {
					this.tableList = JSON.parse(JSON.stringify(list))
				}

			},
			save() {
				uni.$emit('setBusinessOpportunity')
			},
			del(index) {
				this.tableList.splice(index, 1);
			},
			getValue() {
				return this.tableList
			},
		}
	}
</script>

<style lang="scss" scoped>
	.add {
		width: 96rpx;
		height: 96rpx;
		border-radius: 48rpx;
		background: #3c9cff;
		position: fixed;
		bottom: 100rpx;
		right: 24rpx;
		display: flex;
		align-items: center;
		justify-content: center;
		z-index: 99;
	}

	.footerButton {
		width: 100%;
		height: 84rpx;
		display: flex;
		position: fixed;
		bottom: 0;
		z-index: 10;

		/deep/.u-button {
			height: 100%;
		}
		>view {
			flex: 1;

		}
	}

	.item {
		display: flex;
		flex-direction: column;
		padding: 16rpx;

		>view {
			padding-top: 14rpx;
		}

		.item_title {
			font-size: 32rpx;
			font-weight: 800;
		}

		.item_list {
			display: flex;
			align-items: center;

			text {
				font-size: 28rpx;
			}

			.lable {
				color: #626060;
			}

			.value {
				color: #333;
				margin-left: 12rpx;
				flex: 1
			}
		}
	}

	/deep/.u-swipe-action-item__right__button__wrapper {
		background-color: #f56c6c !important;
	}

	/deep/.u-input {
		padding: 0 !important;
	}

	/deep/uni-textarea {
		padding: 0 !important;
	}
</style>