<template>
	<div>
		<el-dialog title="类型选择" :close-on-click-modal="false" draggable width="1100px" height="500px" @close="close"
			append-to-body v-model="visible">
			<div style="height: calc(100% - 80px);">
				<vxe-table border="inner" auto-resize resizable height="500px" :loading="loading" ref="typeTable"
					show-header-overflow show-overflow highlight-hover-row :menu-config="{}"
					:sort-config="{ remote: true }" :data="dataList"
					:tree-config="{ transform: true, rowField: 'collectTypeId', parentField: 'parentId', expandAll: true }"
					:checkbox-config="{}">
					<vxe-column type="seq" width="60" title="序号"></vxe-column>
					<!--          <vxe-column type="checkbox" width="40" ></vxe-column>-->
					<vxe-column type="radio" width="180"></vxe-column>
					<vxe-column title="类型" field="collectType" align="left" tree-node></vxe-column>
				</vxe-table>
			</div>
			<template #footer>
				<span class="dialog-footer">
					<el-button @click="close()" icon="el-icon-circle-close">关闭</el-button>
					<el-button type="primary" v-if="method != 'view'" @click="getProgramForType"
						icon="el-icon-circle-check" v-noMoreClick>确定</el-button>
				</span>
			</template>
		</el-dialog>
	</div>
</template>

<script>
import MaterialTypeService from '@/api/psi/MaterialTypeService'
export default {
	data() {
		return {
			searchForm: {
				name: ''
			},
			dataList: [],
			tablePage: {
				total: 0,
				currentPage: 1,
				pageSize: 10,
				orders: []
			},
			title: '',
			method: '',
			visible: false,
			loading: false
		}
	},
	materialTypeService: null,
	created() {
		this.materialTypeService = new MaterialTypeService()
	},
	components: {
	},
	methods: {
		init(dataList) {
			this.visible = true
			this.dataList = dataList
			// this.list()
		},
		// 表单提交
		getProgramForType() {
			let rows
			if (this.commonJS.isEmpty(this.$refs.typeTable.getRadioRecord())) {
				this.$message.error('请选择一条数据')
				return
			}
			rows = this.$refs.typeTable.getRadioRecord()
			if (rows.children.length > 0) {
				this.$message.error('请选择子集数据')
				return
			}
			this.$emit('getProgramForType', rows)
			this.close()
		},

		close() {
			this.detail = ''
			this.visible = false
		}
	}
}
</script>
<style>
.messageZindex {
	z-index: 9999 !important;
}
</style>
