| 123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253 |
- <template>
- <div class="app-container">
- <el-form :model="queryParams" ref="queryForm" :inline="true" v-show="showSearch" label-width="68px">
- <!-- 现有表单内容保持不变 -->
- <el-form-item label="企微主体" prop="corpId">
- <el-select v-model="queryParams.corpId" placeholder="企微主体" size="small" @change="updateCorpId()">
- <el-option
- v-for="dict in myQwCompanyList"
- :key="dict.dictValue"
- :label="dict.dictLabel"
- :value="dict.dictValue"
- />
- </el-select>
- </el-form-item>
- <el-form-item label="企微账号" prop="qwUserId">
- <el-input
- v-model="queryParams.qwUserId"
- placeholder="请输入企微账号"
- clearable
- size="small"
- @keyup.enter.native="handleQuery"
- />
- </el-form-item>
- <el-form-item label="企微昵称" prop="qwUserName">
- <el-input
- v-model="queryParams.qwUserName"
- placeholder="请输入企微昵称"
- clearable
- size="small"
- @keyup.enter.native="handleQuery"
- />
- </el-form-item>
- <el-form-item>
- <el-button type="cyan" icon="el-icon-search" size="mini" @click="handleQuery">搜索</el-button>
- <el-button icon="el-icon-refresh" size="mini" @click="resetQuery">重置</el-button>
- </el-form-item>
- </el-form>
- <el-table
- height="500"
- border
- v-loading="loading"
- :data="customerList"
- ref="customerList"
- @selection-change="handleSelectionChange"
- >
- <!-- 添加多选列 -->
- <el-table-column type="selection" width="55" align="center" />
- <el-table-column label="企微昵称" align="center" prop="qwUserName" />
- <el-table-column label="企微账号" align="center" prop="qwUserId" />
- <el-table-column label="企微所属部门" align="center" prop="departmentName" />
- <el-table-column label="状态" align="center" prop="status" >
- <template slot-scope="scope">
- <dict-tag :options="qwStatusOptions" :value="scope.row.status"/>
- </template>
- </el-table-column>
- <el-table-column label="企微主体" align="center" prop="corpName" />
- </el-table>
- <div style="margin-top: 10px; text-align: right;">
- <el-button type="primary" @click="handleBatchBind">确定</el-button>
- <el-button @click="cancelSelect">取消选择</el-button>
- </div>
- <pagination
- v-show="total>0"
- :total="total"
- :page.sync="queryParams.pageNum"
- :limit.sync="queryParams.pageSize"
- @pagination="getList"
- />
- </div>
- </template>
- <script>
- import { userList,listUser, getUser, delUser, addUser, updateUser, exportUser, updateUserWeclome,getMyQwCompanyList,getMyQwUserList,relieveFastGptRoleById,staffListUser } from '@/api/qw/user'
- export default {
- name: "miniCustomer",
- components: {},
- data() {
- return {
- // 遮罩层
- loading: true,
- myQwCompanyList:[],
- qwStatusOptions:[],
- // 显示搜索条件
- showSearch: true,
- // 总条数
- total: 0,
- // 员工表格数据
- customerList: [],
- // 弹出层标题
- title: "",
- // 是否显示弹出层
- open: false,
- // 查询参数
- queryParams: {
- pageNum: 1,
- pageSize: 10,
- qwUserId: null,
- corpId: null,
- qwUserName: null,
- },
- // 表单参数
- form: {},
- // 表单校验
- rules: {},
- // 多选数据
- selectedUsers: [],
- // 已选中的用户ID列表(用于初始化选中状态)
- preSelectedUserIds: []
- };
- },
- created() {
- this.getDicts("sys_qw_user_status").then(response => {
- this.qwStatusOptions = response.data;
- });
- getMyQwCompanyList().then(response => {
- this.myQwCompanyList = response.data;
- if(this.myQwCompanyList!=null){
- this.queryParams.corpId=this.myQwCompanyList[0].dictValue
- this.getList();
- }
- });
- },
- methods: {
- updateCorpId(){
- this.getList();
- },
- /** 查询客户列表 */
- getList() {
- this.loading = true;
- userList(this.queryParams).then(response => {
- this.customerList = response.rows;
- this.total = response.total;
- this.loading = false;
- // 在数据加载完成后设置已选中项
- this.$nextTick(() => {
- this.setPreSelectedItems();
- });
- });
- },
- // 设置预选中的项
- setPreSelectedItems() {
- if (this.preSelectedUserIds.length > 0 && this.customerList.length > 0) {
- // 找到需要预选中的行
- const selectedRows = this.customerList.filter(row =>
- this.preSelectedUserIds.includes(row.id)
- );
- // 设置选中状态
- this.$nextTick(() => {
- selectedRows.forEach(row => {
- this.$refs.customerList.toggleRowSelection(row, true);
- });
- });
- }
- },
- // 多选处理
- handleSelectionChange(selection) {
- this.selectedUsers = selection;
- },
- // 批量绑定选择
- handleBatchBind() {
- if (this.selectedUsers.length === 0) {
- this.$message.warning("请至少选择一个用户");
- return;
- }
- // 发送所有选中的用户数据
- this.selectedUsers.forEach(user => {
- this.$emit("bindQwUser", user);
- });
- // 清空选择
- this.clearSelection();
- this.$emit('close'); // 通知父组件关闭对话框
- },
- // 添加一个新的方法用于清除选择
- clearSelection() {
- this.selectedUsers = [];
- this.preSelectedUserIds = [];
- if (this.$refs.customerList) {
- this.$refs.customerList.clearSelection();
- }
- },
- // 设置已选中的用户(由父组件调用)
- setSelectedUsers(users) {
- this.preSelectedUserIds = users.map(user => user.id);
- this.selectedUsers = [...users];
- // 如果数据已经加载,直接设置选中状态
- if (this.customerList.length > 0) {
- this.setPreSelectedItems();
- }
- },
- // 取消选择
- cancelSelect() {
- this.$refs.customerList.clearSelection();
- this.selectedUsers = [];
- },
- // 取消按钮
- cancel() {
- this.open = false;
- this.reset();
- this.clearSelection(); // 清除选择
- },
- /** 搜索按钮操作 */
- handleQuery() {
- this.queryParams.pageNum = 1;
- this.getList();
- },
- /** 重置按钮操作 */
- resetQuery() {
- this.resetForm("queryForm");
- this.queryParams.corpId= this.myQwCompanyList[0].dictValue;
- this.handleQuery();
- },
- }
- };
- </script>
- <style>
- .el-tag + .el-tag {
- margin-left: 10px;
- }
- .button-new-tag {
- margin-left: 10px;
- height: 32px;
- line-height: 30px;
- padding-top: 0;
- padding-bottom: 0;
- }
- .input-new-tag {
- width: 90px;
- margin-left: 10px;
- vertical-align: bottom;
- }
- .el-dialog__wrapper{
- z-index: 100000;
- }
- </style>
|