<template> <span> <c-button type="primary" icon="el-icon-search" class="m-inputbtn-btn" @click="onDialogOpen"></c-button> <el-dialog title="机构选择" :visible.sync="dialogOpen" v-if="dialogOpen" append-to-body> <c-list-search ref="listSearch" @form-reset="handleReset" @form-search="handleSearch" :formCount="formCount"> <template v-slot="slotProps"> <el-form class="m-table-search-form" :model="model" ref="paramsForm" :inline="true" label-position="right" label-width="100px" size="small"> <el-form-item label="机构号" prop="instNo"> <c-input v-model="model.instNo" style="width:100%" maxlength="16" placeholder="请输入"></c-input> </el-form-item> <el-form-item label="机构名称" prop="instName"> <c-input v-model="model.instName" style="width:100%" maxlength="16" placeholder="请输入"></c-input> </el-form-item> </el-form> </template> </c-list-search> <c-list-page ref="cList" :columnsConfig="columnsConfig" :params="searchParams" :pageSize="pageSize" :multipleSelect="false" :loadDataFirstRender="false" :url="url" :watchCurrentChg="false" @current-change="handleCurrentChange" @row-dblclick="handleRowDBClick" maxHeight="300px" /> </el-dialog> </span> </template> <script> import Api from "~/service/Api"; import Utils from "~/utils" export default { data: function () { return { dialogOpen:false, loading:true, model:{ instNo:'', instName:'' }, formCount: 2, // 传入搜索项的数量,组件根据数量判断是否可收起 // 映射到 list 中的搜索参数模型,searchParams 改变后会自动重新拉取数据 searchParams: {}, // 列表的配置项 columnsConfig: [ { prop: "instNo", label: "机构码" }, { prop: "instName", label: "机构名称" }, { prop: "pbcInstNo", label: "人行机构编码" }, { prop: "instType", label: "机构类别" }, { prop: "instSubType", label: "机构类别细分" }, { prop: "instShtName", label: "机构简称" }, { prop: "instAddr", label: "机构地址" } ], // 每页展示的数据。默认为20 pageSize: 10, url:"v1/pm/instManage/queryInstFromSync" } }, mounted(){ this.handleSearch() }, methods: { onDialogOpen(){ this.dialogOpen = true }, handleRowDBClick: function (row) { this.$emit('instselect',row) this.dialogOpen = false }, // 重置搜索条件需要更新到 searchParams 上 handleReset: function () { this.model = { instNo: '', instName: '' } }, handleCurrentChange: async function(){ this.handleSearch() }, // 点击搜索需要更新 searchParams 的值,注意不能直接将 params 赋值给 searchParams handleSearch: async function () { this.$refs["paramsForm"].validate(async valid => { if(valid){ let requrl = this.url+"?pageIndex=" +this.$refs['cList'].listConfig.current +"&pageSize="+this.pageSize; this.$refs['cList'].loading = true; let rtnmsg = await Api.post(requrl,this.model); if(rtnmsg.code == 0){ this.$refs['cList'].listConfig.list = rtnmsg.data; this.$refs['cList'].listConfig.total = rtnmsg.pageInfo.total; this.$refs['cList'].listConfig.current = rtnmsg.pageInfo.pageIndex; }else { this.$notify.error({ title: "错误", message: "服务请求失败!" }); } this.$refs['cList'].loading = false; } }) } } } </script> <style> .m-table .m-table-operation { margin-top: 15px; } .m-table .m-table-search-operation-simple { position: absolute; right: 20px; top: 20px; } </style>