<template> <div> <!-- 选择项目 --> <el-dialog title="选择渠道" :visible.sync="showChannelItem" width="1000px" append-to-body > <el-table class="tableWrapper" ref="channelTable" @row-click="clickRow" :data="channelList" @selection-change="handleSelectionChange" > <el-table-column type="selection" width="55" align="center" /> <!-- <el-table-column label="主键ID" align="center" prop="id" /> --> <el-table-column label="渠道编号" align="center" prop="channelCode" /> <el-table-column label="渠道名称" width="150" align="center" prop="channelName" > <template slot-scope="scope"> <div :title="scope.row.channelName"> {{ scope.row.channelName }} </div> </template> </el-table-column> <el-table-column label="渠道类别" width="450" align="center" prop="channelType" > <template slot-scope="scope"> <dict-tag :options="dict.type.channel_type" :value="scope.row.channelType" /> </template> </el-table-column> <el-table-column label="联系人" align="center" prop="contacts" /> <el-table-column label="联系电话" width="150" align="center" prop="telephone" /> <el-table-column label="渠道负责人" align="center" prop="channelHead" /> <el-table-column label="状态" align="center" prop="status"> <template slot-scope="scope"> <dict-tag :options="dict.type.channel_status" :value="scope.row.status" /> </template> </el-table-column> </el-table> <pagination v-show="channelItemTotal > 0" :total="channelItemTotal" :page.sync="channelQueryParams.pageNum" :limit.sync="channelQueryParams.pageSize" @pagination="getList" /> <div slot="footer" class="dialog-footer"> <el-button type="primary" @click="submit" v-preventReClick >确 定</el-button > <el-button @click="cancel">取 消</el-button> </div> </el-dialog> </div> </template> <script> import { listChannel } from "@/api/invest/channel"; export default { props: {}, dicts: ["channel_type", "channel_status"], data() { return { showChannelItem: false, // 总条数 channelItemTotal: 0, channelList: [], channelQueryParams: { pageNum: 1, pageSize: 10, orderByColumn: "createTime", isAsc: "desc", }, // 选中数组 ids: [], idsName: [], // 非单个禁用 single: true, // 非多个禁用 multiple: true, }; }, mounted() { this.getList(); }, methods: { clickRow(row) { this.$refs.channelTable.toggleRowSelection(row); }, // 多选框选中数据 handleSelectionChange(selection) { if (selection.length > 1) { this.$modal.msg("只能选择一个渠道"); this.$refs.channelTable.clearSelection(); return; } if (this.ids.length == 0) { this.ids = selection; } else { this.$modal.msg("只能选择一个渠道"); this.ids = []; // channelTable与table的ref绑定的一样 this.$refs.channelTable.clearSelection(); } }, /** 查询会议列表 */ getList() { listChannel(this.channelQueryParams).then((response) => { this.channelList = response.rows; this.channelItemTotal = response.total; }); }, submit() { // console.log("确定", this.ids); this.$emit("getChannelInfo", this.ids); this.showChannelItem = false; }, cancel() { this.showChannelItem = false; }, }, }; </script>