调用接口,传入对应的参数,在表单内显示
查询(数据加载查询功能,带对应所需参数的高级查询)
html
<Form :model="params" class="myForm" label-position="right" inline>
<FormItem>
<Input v-model="params.RGNM" placeholder="水库注册登记号" clearable></Input>
</FormItem>
<FormItem>
<Input v-model="params.RSNM" placeholder="水库名称" clearable></Input>
</FormItem>
<FormItem>
<RadioGroup v-model="params.ZXZT">
<!--状态传文字 ZXZT 默认为true-->
<Radio label="">全部</Radio>
<Radio label="未执行" true-value="未执行"></Radio>
<Radio label="按原调令执行" true-value="按原调令执行"></Radio>
<Radio label="在原调令基础上推迟执行" true-value="在原调令基础上推迟执行"></Radio>
</RadioGroup>
</FormItem>
<FormItem>
<Button type="primary" @click="newAdd" v-if="lvl < 4">新增</Button>
</FormItem>
<FormItem>
<Button type="primary" @click="loadData(1)">查询</Button>
</FormItem>
<FormItem>
<Button type="primary" @click="high">高级查询</Button>
</FormItem>
<FormItem>
<Button type="primary" @click="downloadExcel">导出Excel</Button>
</FormItem>
<!-- 高级搜索 -->
</Form>
js
export default {
data() {
return {
params: {
index: 1,
num: 15,
ZXZT: '', //执行状态
DDTYPE: '', //调度类别
DDTIME1: '', //调度时间
DDTIME2: '', //调度时间
ZXTIME1: '',
ZXTIME2: '',
RSNM: '', //水库名称
RGNM: '', //水库注册登记号
PRV: '', //省
CITY: '', //市
CNTY: '', //县
TOWN: '', //镇
PRSC: '', //规模
RSINCD: '', //
},
}
},
methods:{
loadData() {
let _this = this;
this.axios({
url: "/API/YJDD/List",
method: "get",
params: _this.params
}).then(res => {
if (res.status == 200 && res.data.DATA) {
this.alltotal = res.data.COUNT; //返回总条数
//console.log("res.data", res.data);
_this.setData(res.data.DATA);
//this.$Message.success("请求数据成功!");
_this.loading = false; //关闭加载
_this.ifHigh = false; //关闭加载
_this.params = this.params;//这里有毛病
} else {
console.log(res.data); //控制台输出错误
_this.loading = false; //关闭加载
}
}).catch(err => {
//失败
console.log(err);
_this.loading = false;
})
},
setData(List) {
this.tableData = List.map(item => {
if (item.DDTIME != null) {
item.DDTIME = item.DDTIME.slice(0, 10); //map后的对象
}
if (item.ZXTIME != null) {
item.ZXTIME = item.ZXTIME.slice(0, 10); //map后的对象
}
return item;
})
},
//高级查询
GJCX_son(searchParams) { //searchParams是子组件传过来的数据
this.params.CITY = searchParams.vCty1; //将子组件数据赋值给父组件,这边是单个拼接赋值 多个拼接赋值用object.assign
this.params.CNTY = searchParams.vCnt1;
this.params.TOWN = searchParams.vTwn1;
this.params.PRSC = searchParams.scale;
this.params.DDTYPE = searchParams.DDTYPE;
this.params.DDTIME1 = searchParams.DDTIME1;
this.params.ZXTIME1 = searchParams.ZXTIME1;
this.params.DDTIME2 = searchParams.DDTIME2;
this.params.ZXTIME2 = searchParams.ZXTIME2;
this.params.index = 1;
this.loadData(1);
},
},
mounted() {
this.loadData();
}
}