123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397 |
- <!--
- * @Description: 新增/编辑弹框
- * @Author: Sugar.
- * @Date: 2023-11-24 13:55:00
- * @LastEditors: gcz
- * @LastEditTime: 2025-03-24 11:07:37
- * @FilePath: \great_webui\src\views\priceConfigurationUilt\dialog\bindTeamBoxNew.vue
- * @Copyright: Copyright (c) 2016~2023 by Sugar., All Rights Reserved.
- -->
- <template>
- <el-dialog
- :title="title"
- :visible.sync="open"
- width="900px"
- append-to-body
- :close-on-click-modal="false"
- @close="cancel"
- >
- <div class="dialog" style="padding: 0">
- <el-row :gutter="10" class="mb8">
- <el-col :span="1.5">
- <el-button
- type="primary"
- plain
- icon="el-icon-plus"
- size="mini"
- @click="handleAdd"
- >添加</el-button>
- </el-col>
- <el-col :span="1.5">
- <el-form :model="queryParams" ref="queryForm" size="small" :inline="true" label-width="120px">
- <el-form-item label="团队名称" label-width="70px">
- <el-input
- v-model="queryParams.teamName"
- placeholder="请输入团队名称"
- clearable
- style="width: 240px;"
- @keyup.enter.native="getList"
- />
- </el-form-item>
- <el-form-item>
- <el-button type="primary" icon="el-icon-search" size="mini" @click="getList">搜索</el-button>
- <el-button icon="el-icon-refresh" size="mini" @click="resetQuery1">重置</el-button>
- </el-form-item>
- </el-form>
- </el-col>
- </el-row>
- <el-table ref="tables" v-loading="tabLoading" :data="dataList" border>
- <el-table-column label="序号" align="center" type="index" width="50"></el-table-column>
- <el-table-column label="团队名称" align="center" prop="teamName" />
- <!-- <el-table-column label="团队类型" align="center" prop="type">
- <template slot-scope="scope">
- <dict-tag :options="dict.type.team_type" :value="scope.row.type"/>
- </template>
- </el-table-column> -->
- <!-- <el-table-column label="负责人" align="center" prop="contact" /> -->
- <el-table-column label="操作" align="center" width="80px" class-name="small-padding fixed-width">
- <template slot-scope="scope">
- <el-button
- size="mini"
- type="text"
- @click="handleDelete(scope.row)"
- >移除</el-button>
- </template>
- </el-table-column>
- </el-table>
- <pagination
- v-show="total>0"
- :total="total"
- :page.sync="queryParams.pageNum"
- :limit.sync="queryParams.pageSize"
- @pagination="getList"
- />
- </div>
-
- <el-dialog
- title="团队选择"
- :visible.sync="selectionOpen"
- width="600px"
- append-to-body
- :close-on-click-modal="false"
- @close="selectionCancel"
- >
- <div class="dialog" style="padding: 0">
- <div>
- <el-form :model="queryParamsS" ref="queryForm" size="small" :inline="true" label-width="120px">
- <el-form-item label="团队名称" label-width="70px">
- <el-input
- v-model="queryParamsS.name"
- placeholder="请输入团队名称"
- clearable
- style="width: 240px;"
- @keyup.enter.native="handleQuery"
- />
- </el-form-item>
- <el-form-item>
- <el-button type="primary" 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>
- </div>
- <el-table ref="tablesS" row-key="id" v-loading="selectionTabLoading" :data="selectionDataList" border @selection-change="handleSelectionChange">
- <el-table-column type="selection" reserve-selection width="50" align="center" />
- <el-table-column label="序号" align="center" type="index" width="50"></el-table-column>
- <el-table-column label="团队名称" align="center" prop="name" />
- <el-table-column label="团队类型" align="center" prop="type">
- <template slot-scope="scope">
- <dict-tag :options="dict.type.team_type" :value="scope.row.type"/>
- </template>
- </el-table-column>
- <el-table-column label="负责人" align="center" prop="contact" />
- </el-table>
- <pagination
- v-show="selectionTabTotal>0"
- :total="selectionTabTotal"
- :page.sync="selectQueryParams.pageNum"
- :limit.sync="selectQueryParams.pageSize"
- @pagination="getSelectList"
- />
- </div>
- <span slot="footer" class="dialog-footer">
- <el-button @click="selectionCancel">取消</el-button>
- <el-button
- type="primary"
- @click="submitForm"
- :disabled="selectList.length==0"
- v-loading.fullscreen.lock="loading"
- element-loading-text="提交中..."
- element-loading-spinner="el-icon-loading"
- element-loading-background="rgba(0, 0, 0, 0.8)"
- >
- <span v-if="loading">提交中...</span>
- <span v-else>确认(已选{{ selectList.length }})</span>
- </el-button>
- </span>
- </el-dialog>
-
- <span slot="footer" class="dialog-footer">
- <el-button type="primary" @click="cancel">确认</el-button>
- </span>
- </el-dialog>
- </template>
-
- <script>
- import { bindTeamApi,getTeamList,removeTeamApi,getSelectById,allTeamList } from "@/api/priceConfiguration/index";
- import Editor from "@/components/Editor";
- import { getToken } from "@/utils/auth";
- import { updateStatus } from '@/api/team/teamMr'
- export default {
- name: "bindTeamBoxNew",
- components: {
- Editor,
- },
- props: {
- dict: {
- type: Object,
- default: () => [],
- },
- },
- data() {
- return {
- title: "团队绑定",
- model: "EDIT",
- open: false,
- loading: false,
- tabLoading: false,
- selectionTabLoading: false,
- dataList: [],
- selectionDataList: [],
- total: 0,
- selectionTabTotal: 0,
- // 查询参数
- queryParams: {
- pageNum: 1,
- pageSize: 10,
- // type: 1,
- },
- selectQueryParams: {
- pageNum: 1,
- pageSize: 10,
- checkStatus: 1,
- status: 1,
- // type: 2,
- },
- selectList: [],
- selectionOpen: false,
- onwObj: {},
- queryParamsS: {},
- form: {
- id: undefined,
- teamIdList: []
- }
- };
- },
- methods: {
- /**
- * 打开弹框
- * @date 2023-11-22
- * @param {any} obj
- * @returns {any}
- */
- async openDialog(title, obj) {
- this.open = true;
- this.title = "团队绑定";
- this.queryParams = {
- pageNum: 1,
- pageSize: 10,
- type: 1,
- }
- this.onwObj = obj;
- this.getList();
- },
- handleAdd() {
- this.selectList = []
- this.queryParamsS = {}
- this.getSelectList();
- this.selectionOpen = true
- this.$nextTick(()=>{
- this.$refs.tablesS.clearSelection()
- })
- },
- /** 获取详情 */
- async getSelectByIdFun(obj) {
- try {
- let res = await getSelectById({
- id: obj.id
- })
- if(res.code == 200){
- // 已绑定的团队列表
-
- }
- } catch (error) {
- }
- },
- /** 查询列表 */
- getList(obj) {
- this.tabLoading = true;
- this.queryParams.id = this.onwObj.id
- getTeamList({...this.queryParams})
- .then(response => {
- this.dataList = response.rows;
- this.total = response.total;
- this.tabLoading = false;
- }
- ).catch(() => {
- this.tabLoading = false;
- });
- },
- /** 查询列表 */
- getSelectList(obj) {
- this.selectionTabLoading = true;
- allTeamList({...this.selectQueryParams,...this.queryParamsS})
- .then(response => {
- this.selectionDataList = response.data.rows;
- this.selectionTabTotal = response.data.total;
- this.selectionTabLoading = false;
- }
- ).catch(() => {
- this.selectionTabLoading = false;
- });
- },
- // 多选框选中数据
- handleSelectionChange(selection) {
- this.selectList = selection;
- },
- /**
- * 保存
- * @date 2023-11-22
- * @returns {any}
- */
- async submitForm() {
- try {
- if(this.selectList.length <= 0) {
- this.$message.error("请勾选团队!");
- return false
- }
- this.loading = true;
-
- // 先获取已绑定的团队
- const selectRes = await getSelectById({
- id: this.onwObj.id
- });
-
- let existingTeamIds = [];
- if (selectRes.code === 200 && selectRes.data.teamList) {
- existingTeamIds = selectRes.data.teamList.map(item => item.teamId);
- }
-
- // 新选择的团队ID
- let newTeamIds = this.selectList.map(item => item.id);
-
- // 合并并去重
- let teamIdList = [...new Set([...existingTeamIds, ...newTeamIds])];
- const { code } = await bindTeamApi({
- id: this.onwObj.id,
- teamIdList: teamIdList
- });
- if (code === 200) {
- this.$message.success("操作成功!");
- this.getList();
- this.selectionOpen = false;
- }
- } catch (error) {
- console.error('绑定团队失败:', error);
- this.$message.error("操作失败!");
- } finally {
- this.loading = false;
- }
- },
- /** 删除按钮操作 */
- handleDelete(row) {
- this.$confirm('是否确认移除数据团队名称为"' + row.teamName + '"的数据项?', '提示', {
- confirmButtonText: '确定',
- cancelButtonText: '取消',
- type: 'warning'
- }).then(() => {
- removeTeamApi({
- id: this.onwObj.id,
- teamIdList: [row.teamId]
- }).then((res) => {
- if (res.code == 200) {
- this.$message({
- type: 'success',
- message: '操作成功!'
- });
- this.getList();
- }
- });
- }).catch(() => {});
- },
- /**
- * 重置
- * @date 2023-11-22
- * @returns {any}
- */
- reset() {
-
- },
- /**
- * 关闭弹框
- * @date 2023-11-22
- * @returns {any}
- */
- cancel() {
- this.open = false;
- },
- selectionCancel() {
- this.selectionOpen = false;
- },
-
- handleQuery() {
- this.getSelectList()
- },
- resetQuery() {
- this.queryParamsS = {}
- this.getSelectList()
- },
- resetQuery1() {
- this.queryParams.teamName = null
- this.getList()
- }
- },
- };
- </script>
-
- <style lang="scss" scoped>
- .dialog {
- padding: 0 30px;
- max-height: 65vh;
- min-height: 65vh;
- overflow: hidden;
- overflow-y: auto;
- }
- .dialog {
- padding: 0 30px;
- .upload-btn {
- width: 100px;
- height: 100px;
- background-color: #fbfdff;
- border: dashed 1px #c0ccda;
- border-radius: 5px;
- i {
- font-size: 30px;
- margin-top: 20px;
- }
- &-text {
- margin-top: -10px;
- }
- }
- .avatar {
- cursor: pointer;
- }
- }
- </style>
-
|