You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
113 lines
2.9 KiB
113 lines
2.9 KiB
<script>
|
|
import {chooseList} from "../../../api/chooselist/chooselist";
|
|
export default {
|
|
name: "chooseListDemo",
|
|
props:{
|
|
searchList:{
|
|
type: Array,
|
|
required:true
|
|
},
|
|
columnList:{
|
|
type: Array,
|
|
required: true,
|
|
},
|
|
tagNo:{
|
|
type: String,
|
|
required: true
|
|
},
|
|
useSite:{
|
|
type:Boolean,
|
|
default: true,
|
|
}
|
|
},
|
|
data(){
|
|
return{
|
|
searchModel:{},
|
|
chooseListData:[],
|
|
visible:false
|
|
}
|
|
},
|
|
methods:{
|
|
openChooseList(){
|
|
this.searchList.forEach((item)=>{
|
|
this.searchModel = {}
|
|
this.$nextTick(() => {
|
|
this.$set(this.searchModel, item.value, undefined);
|
|
});
|
|
})
|
|
this.searchBtn()
|
|
},
|
|
closeChooseList(){
|
|
this.chooseListData = [];
|
|
},
|
|
searchBtn(){
|
|
let params = JSON.parse(JSON.stringify(this.searchModel))
|
|
params.tagNo = this.tagNo
|
|
params.columnList = this.columnList.map((item)=>item.columnProp)
|
|
params.site = this.useSite?this.$store.state.user.site:''
|
|
chooseList(params).then(({data})=>{
|
|
if (data && data.code === 0){
|
|
this.chooseListData = data.baseListData;
|
|
}else {
|
|
this.$message.error(data.msg)
|
|
}
|
|
})
|
|
},
|
|
getRowData(row) {
|
|
this.visible = false
|
|
this.$emit('getBaseData',row)
|
|
},
|
|
init(){
|
|
this.visible = true
|
|
}
|
|
},
|
|
}
|
|
</script>
|
|
|
|
<template>
|
|
<div class="chooseListDemo">
|
|
<el-dialog v-bind="$attrs" :visible.sync="visible" v-on="$listeners" @open="openChooseList" @close="closeChooseList">
|
|
<el-form :model="searchModel" label-position="top">
|
|
<el-row :gutter="20">
|
|
<el-col :span="6" v-for="(item,index) in searchList" :key="index">
|
|
<el-form-item :label="item.label">
|
|
<el-input v-model="searchModel[item.value]" clearable></el-input>
|
|
</el-form-item>
|
|
</el-col>
|
|
<el-col :span="6">
|
|
<el-form-item label=" ">
|
|
<el-button type="primary" @click="searchBtn">查询</el-button>
|
|
</el-form-item>
|
|
</el-col>
|
|
</el-row>
|
|
</el-form>
|
|
<el-table
|
|
height="30vh"
|
|
:data="chooseListData"
|
|
border @row-dblclick="getRowData"
|
|
style="width: 100%;">
|
|
<el-table-column
|
|
v-for="(item,index) in columnList" :key="index"
|
|
:sortable="item.columnSortable"
|
|
:prop="item.columnProp"
|
|
:header-align="item.headerAlign"
|
|
:show-overflow-tooltip="item.showOverflowTooltip"
|
|
:align="item.align"
|
|
:fixed="item.fixed===''?false:item.fixed"
|
|
:min-width="item.columnWidth"
|
|
:label="item.columnLabel">
|
|
<template slot-scope="scope">
|
|
{{ scope.row[item.columnProp] }}
|
|
</template>
|
|
</el-table-column>
|
|
</el-table>
|
|
<span slot="footer" class="dialog-footer">
|
|
|
|
</span>
|
|
</el-dialog>
|
|
</div>
|
|
</template>
|
|
|
|
<style scoped>
|
|
|
|
</style>
|