bindTeamBoxNew.vue 12 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395
  1. <!--
  2. * @Description: 新增/编辑弹框
  3. * @Author: Sugar.
  4. * @Date: 2023-11-24 13:55:00
  5. * @LastEditors: gcz
  6. * @LastEditTime: 2025-03-24 11:07:37
  7. * @FilePath: \great_webui\src\views\priceConfigurationUilt\dialog\bindTeamBoxNew.vue
  8. * @Copyright: Copyright (c) 2016~2023 by Sugar., All Rights Reserved.
  9. -->
  10. <template>
  11. <el-dialog
  12. :title="title"
  13. :visible.sync="open"
  14. width="900px"
  15. append-to-body
  16. :close-on-click-modal="false"
  17. @close="cancel"
  18. >
  19. <div class="dialog" style="padding: 0">
  20. <el-row :gutter="10" class="mb8">
  21. <el-col :span="1.5">
  22. <el-button
  23. type="primary"
  24. plain
  25. icon="el-icon-plus"
  26. size="mini"
  27. @click="handleAdd"
  28. >添加</el-button>
  29. </el-col>
  30. <el-col :span="1.5">
  31. <el-form :model="queryParams" ref="queryForm" size="small" :inline="true" label-width="120px">
  32. <el-form-item label="团队名称" label-width="70px">
  33. <el-input
  34. v-model="queryParams.teamName"
  35. placeholder="请输入团队名称"
  36. clearable
  37. style="width: 240px;"
  38. @keyup.enter.native="getList"
  39. />
  40. </el-form-item>
  41. <el-form-item>
  42. <el-button type="primary" icon="el-icon-search" size="mini" @click="getList">搜索</el-button>
  43. <el-button icon="el-icon-refresh" size="mini" @click="resetQuery1">重置</el-button>
  44. </el-form-item>
  45. </el-form>
  46. </el-col>
  47. </el-row>
  48. <el-table ref="tables" v-loading="tabLoading" :data="dataList" border>
  49. <el-table-column label="序号" align="center" type="index" width="50"></el-table-column>
  50. <el-table-column label="团队名称" align="center" prop="teamName" />
  51. <!-- <el-table-column label="团队类型" align="center" prop="type">
  52. <template slot-scope="scope">
  53. <dict-tag :options="dict.type.team_type" :value="scope.row.type"/>
  54. </template>
  55. </el-table-column> -->
  56. <!-- <el-table-column label="负责人" align="center" prop="contact" /> -->
  57. <el-table-column label="操作" align="center" width="80px" class-name="small-padding fixed-width">
  58. <template slot-scope="scope">
  59. <el-button
  60. size="mini"
  61. type="text"
  62. @click="handleDelete(scope.row)"
  63. >移除</el-button>
  64. </template>
  65. </el-table-column>
  66. </el-table>
  67. <pagination
  68. v-show="total>0"
  69. :total="total"
  70. :page.sync="queryParams.pageNum"
  71. :limit.sync="queryParams.pageSize"
  72. @pagination="getList"
  73. />
  74. </div>
  75. <el-dialog
  76. title="团队选择"
  77. :visible.sync="selectionOpen"
  78. width="600px"
  79. append-to-body
  80. :close-on-click-modal="false"
  81. @close="selectionCancel"
  82. >
  83. <div class="dialog" style="padding: 0">
  84. <div>
  85. <el-form :model="queryParamsS" ref="queryForm" size="small" :inline="true" label-width="120px">
  86. <el-form-item label="团队名称" label-width="70px">
  87. <el-input
  88. v-model="queryParamsS.name"
  89. placeholder="请输入团队名称"
  90. clearable
  91. style="width: 240px;"
  92. @keyup.enter.native="handleQuery"
  93. />
  94. </el-form-item>
  95. <el-form-item>
  96. <el-button type="primary" icon="el-icon-search" size="mini" @click="handleQuery">搜索</el-button>
  97. <el-button icon="el-icon-refresh" size="mini" @click="resetQuery">重置</el-button>
  98. </el-form-item>
  99. </el-form>
  100. </div>
  101. <el-table ref="tablesS" row-key="id" v-loading="selectionTabLoading" :data="selectionDataList" border @selection-change="handleSelectionChange">
  102. <el-table-column type="selection" reserve-selection width="50" align="center" />
  103. <el-table-column label="序号" align="center" type="index" width="50"></el-table-column>
  104. <el-table-column label="团队名称" align="center" prop="name" />
  105. <el-table-column label="团队类型" align="center" prop="type">
  106. <template slot-scope="scope">
  107. <dict-tag :options="dict.type.team_type" :value="scope.row.type"/>
  108. </template>
  109. </el-table-column>
  110. <el-table-column label="负责人" align="center" prop="contact" />
  111. </el-table>
  112. <pagination
  113. v-show="selectionTabTotal>0"
  114. :total="selectionTabTotal"
  115. :page.sync="selectQueryParams.pageNum"
  116. :limit.sync="selectQueryParams.pageSize"
  117. @pagination="getSelectList"
  118. />
  119. </div>
  120. <span slot="footer" class="dialog-footer">
  121. <el-button @click="selectionCancel">取消</el-button>
  122. <el-button
  123. type="primary"
  124. @click="submitForm"
  125. :disabled="selectList.length==0"
  126. v-loading.fullscreen.lock="loading"
  127. element-loading-text="提交中..."
  128. element-loading-spinner="el-icon-loading"
  129. element-loading-background="rgba(0, 0, 0, 0.8)"
  130. >
  131. <span v-if="loading">提交中...</span>
  132. <span v-else>确认(已选{{ selectList.length }})</span>
  133. </el-button>
  134. </span>
  135. </el-dialog>
  136. <span slot="footer" class="dialog-footer">
  137. <el-button type="primary" @click="cancel">确认</el-button>
  138. </span>
  139. </el-dialog>
  140. </template>
  141. <script>
  142. import { bindTeamApi,getTeamList,removeTeamApi,getSelectById,allTeamList } from "@/api/priceConfiguration/index";
  143. import Editor from "@/components/Editor";
  144. import { getToken } from "@/utils/auth";
  145. import { updateStatus } from '@/api/team/teamMr'
  146. export default {
  147. name: "bindTeamBoxNew",
  148. components: {
  149. Editor,
  150. },
  151. props: {
  152. dict: {
  153. type: Object,
  154. default: () => [],
  155. },
  156. },
  157. data() {
  158. return {
  159. title: "团队绑定",
  160. model: "EDIT",
  161. open: false,
  162. loading: false,
  163. tabLoading: false,
  164. selectionTabLoading: false,
  165. dataList: [],
  166. selectionDataList: [],
  167. total: 0,
  168. selectionTabTotal: 0,
  169. // 查询参数
  170. queryParams: {
  171. pageNum: 1,
  172. pageSize: 10,
  173. // type: 1,
  174. },
  175. selectQueryParams: {
  176. pageNum: 1,
  177. pageSize: 10,
  178. // type: 2,
  179. },
  180. selectList: [],
  181. selectionOpen: false,
  182. onwObj: {},
  183. queryParamsS: {},
  184. form: {
  185. id: undefined,
  186. teamIdList: []
  187. }
  188. };
  189. },
  190. methods: {
  191. /**
  192. * 打开弹框
  193. * @date 2023-11-22
  194. * @param {any} obj
  195. * @returns {any}
  196. */
  197. async openDialog(title, obj) {
  198. this.open = true;
  199. this.title = "团队绑定";
  200. this.queryParams = {
  201. pageNum: 1,
  202. pageSize: 10,
  203. type: 1,
  204. }
  205. this.onwObj = obj;
  206. this.getList();
  207. },
  208. handleAdd() {
  209. this.selectList = []
  210. this.queryParamsS = {}
  211. this.getSelectList();
  212. this.selectionOpen = true
  213. this.$nextTick(()=>{
  214. this.$refs.tablesS.clearSelection()
  215. })
  216. },
  217. /** 获取详情 */
  218. async getSelectByIdFun(obj) {
  219. try {
  220. let res = await getSelectById({
  221. id: obj.id
  222. })
  223. if(res.code == 200){
  224. // 已绑定的团队列表
  225. }
  226. } catch (error) {
  227. }
  228. },
  229. /** 查询列表 */
  230. getList(obj) {
  231. this.tabLoading = true;
  232. this.queryParams.id = this.onwObj.id
  233. getTeamList({...this.queryParams})
  234. .then(response => {
  235. this.dataList = response.rows;
  236. this.total = response.total;
  237. this.tabLoading = false;
  238. }
  239. ).catch(() => {
  240. this.tabLoading = false;
  241. });
  242. },
  243. /** 查询列表 */
  244. getSelectList(obj) {
  245. this.selectionTabLoading = true;
  246. allTeamList({...this.selectQueryParams,...this.queryParamsS})
  247. .then(response => {
  248. this.selectionDataList = response.data.rows;
  249. this.selectionTabTotal = response.data.total;
  250. this.selectionTabLoading = false;
  251. }
  252. ).catch(() => {
  253. this.selectionTabLoading = false;
  254. });
  255. },
  256. // 多选框选中数据
  257. handleSelectionChange(selection) {
  258. this.selectList = selection;
  259. },
  260. /**
  261. * 保存
  262. * @date 2023-11-22
  263. * @returns {any}
  264. */
  265. async submitForm() {
  266. try {
  267. if(this.selectList.length <= 0) {
  268. this.$message.error("请勾选团队!");
  269. return false
  270. }
  271. this.loading = true;
  272. // 先获取已绑定的团队
  273. const selectRes = await getSelectById({
  274. id: this.onwObj.id
  275. });
  276. let existingTeamIds = [];
  277. if (selectRes.code === 200 && selectRes.data.teamList) {
  278. existingTeamIds = selectRes.data.teamList.map(item => item.teamId);
  279. }
  280. // 新选择的团队ID
  281. let newTeamIds = this.selectList.map(item => item.id);
  282. // 合并并去重
  283. let teamIdList = [...new Set([...existingTeamIds, ...newTeamIds])];
  284. const { code } = await bindTeamApi({
  285. id: this.onwObj.id,
  286. teamIdList: teamIdList
  287. });
  288. if (code === 200) {
  289. this.$message.success("操作成功!");
  290. this.getList();
  291. this.selectionOpen = false;
  292. }
  293. } catch (error) {
  294. console.error('绑定团队失败:', error);
  295. this.$message.error("操作失败!");
  296. } finally {
  297. this.loading = false;
  298. }
  299. },
  300. /** 删除按钮操作 */
  301. handleDelete(row) {
  302. this.$confirm('是否确认移除数据团队名称为"' + row.teamName + '"的数据项?', '提示', {
  303. confirmButtonText: '确定',
  304. cancelButtonText: '取消',
  305. type: 'warning'
  306. }).then(() => {
  307. removeTeamApi({
  308. id: this.onwObj.id,
  309. teamIdList: [row.teamId]
  310. }).then((res) => {
  311. if (res.code == 200) {
  312. this.$message({
  313. type: 'success',
  314. message: '操作成功!'
  315. });
  316. this.getList();
  317. }
  318. });
  319. }).catch(() => {});
  320. },
  321. /**
  322. * 重置
  323. * @date 2023-11-22
  324. * @returns {any}
  325. */
  326. reset() {
  327. },
  328. /**
  329. * 关闭弹框
  330. * @date 2023-11-22
  331. * @returns {any}
  332. */
  333. cancel() {
  334. this.open = false;
  335. },
  336. selectionCancel() {
  337. this.selectionOpen = false;
  338. },
  339. handleQuery() {
  340. this.getSelectList()
  341. },
  342. resetQuery() {
  343. this.queryParamsS = {}
  344. this.getSelectList()
  345. },
  346. resetQuery1() {
  347. this.queryParams.teamName = null
  348. this.getList()
  349. }
  350. },
  351. };
  352. </script>
  353. <style lang="scss" scoped>
  354. .dialog {
  355. padding: 0 30px;
  356. max-height: 65vh;
  357. min-height: 65vh;
  358. overflow: hidden;
  359. overflow-y: auto;
  360. }
  361. .dialog {
  362. padding: 0 30px;
  363. .upload-btn {
  364. width: 100px;
  365. height: 100px;
  366. background-color: #fbfdff;
  367. border: dashed 1px #c0ccda;
  368. border-radius: 5px;
  369. i {
  370. font-size: 30px;
  371. margin-top: 20px;
  372. }
  373. &-text {
  374. margin-top: -10px;
  375. }
  376. }
  377. .avatar {
  378. cursor: pointer;
  379. }
  380. }
  381. </style>