<template>
	<div>
		<div>
			<el-button type="primary" @click="handlePackage">包</el-button>
			<el-button type="primary" @click="handleProc">增删改过程</el-button>


		</div>
		<div>
			<el-input type="textarea" :autosize="{ minRows: 2, maxRows: 4}" placeholder="请输入内容" v-model="textarea">
			</el-input>
		</div>


		<el-row>
			<el-col :span="12">
				<el-button type="primary" @click="handlePage">分页查询过程</el-button>
				<el-table :data="tableData" stripe border class="el-table-user" style="width: 99%;">
					<el-table-column prop="USER_DESC" label="姓名" width="100">
					</el-table-column>
					<el-table-column prop="DEPT_NAME" label="部门" width="100">
					</el-table-column>
					<el-table-column prop="POST_NAME" label="岗位" width="100">
					</el-table-column>
				</el-table>
				<el-pagination @size-change="handleSizeChange" @current-change="handleCurrentChange" :current-page="currentPage"
				 :page-sizes="pageSizes" :page-size="pageSize" layout="total, sizes, prev, pager, next, jumper" :total="totalRows">
				</el-pagination>
			</el-col>
			<el-col :span="12">
				<el-button type="primary" @click="handleNoPage">不分页查询过程</el-button>
				<el-table :data="tableDataNoPage" stripe border class="el-table-user" style="width: 99%;">
					<el-table-column prop="USER_DESC" label="姓名" width="100">
					</el-table-column>
					<el-table-column prop="DEPT_NAME" label="部门" width="100">
					</el-table-column>
					<el-table-column prop="POST_NAME" label="岗位" width="100">
					</el-table-column>
				</el-table>
			</el-col>
		</el-row>




	</div>
</template>

<script>
	import axios from '@/axios';
	export default {
		data() {
			return {
				textarea: '',
				tableData: [],
				tableDataNoPage: [],
				currentPage: 1,
				totalRows: 0,
				pageSizes: [10, 50, 100, 200],
				pageSize: 10,
			}
		},
		methods: {
			getTableData() {
				var url = 'Common/doProcQueryPage.do'
				var my = ["李"]
				var param = {
					procName: 'pack_test.select',
					page: this.currentPage,
					rows: this.pageSize,
					param: JSON.stringify(my)
				}
				axios.post(url, param).then(response => {

					if (response.data.code == '0') {
						this.totalRows = response.data.data.rows
						this.tableData = response.data.data.list
					} else {
						this.$message({
							type: 'error',
							message: '查询失败' + response.data.msg
						});
					}

				});
			},
			handlePackage() {
				var url = 'Common/doProc.do'
				var my = ["参数1", "参数2", "参数3", "参数4", "参数5", "参数6"]
				var param = {
					procName: 'pack_test.test1',
					param: JSON.stringify(my)
				}
				axios.post(url, param).then(response => {

					if (response.data.code == '0') {
						this.textarea = response.data.data
					} else {
						this.$message({
							type: 'error',
							message: '查询失败' + response.data.msg
						});
					}

				});
			},
			handleProc() {
				var url = 'Common/doProc.do'
				var my = ["参数1", "参数2", "参数3", "参数4", "参数5"]
				var param = {
					procName: 'proc_test',
					param: JSON.stringify(my)
				}
				axios.post(url, param).then(response => {

					if (response.data.code == '0') {
						this.textarea = response.data.data
					} else {
						this.$message({
							type: 'error',
							message: '查询失败' + response.data.msg
						});
					}

				});
			},
			handlePage() {
				this.getTableData()
			},

			// 修改每页行数
			handleSizeChange(val) {
				this.pageSize = val
				this.getTableData()
			},
			// 修改当前页事件
			handleCurrentChange(val) {
				this.currentPage = val
				this.getTableData()
			},

			handleNoPage() {
				var url = 'Common/doProcQuery.do'
				var my = [""]
				var param = {
					procName: 'pack_test.selectTest',
					param: JSON.stringify(my)
				}
				axios.post(url, param).then(response => {

					if (response.data.code == '0') {
						this.tableDataNoPage = response.data.data
					} else {
						this.$message({
							type: 'error',
							message: '查询失败' + response.data.msg
						});
					}

				});
			},
		}
	}
</script>

<style>

</style>
