bindTeamBoxNew.vue 12 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397
  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. checkStatus: 1,
  179. status: 1,
  180. // type: 2,
  181. },
  182. selectList: [],
  183. selectionOpen: false,
  184. onwObj: {},
  185. queryParamsS: {},
  186. form: {
  187. id: undefined,
  188. teamIdList: []
  189. }
  190. };
  191. },
  192. methods: {
  193. /**
  194. * 打开弹框
  195. * @date 2023-11-22
  196. * @param {any} obj
  197. * @returns {any}
  198. */
  199. async openDialog(title, obj) {
  200. this.open = true;
  201. this.title = "团队绑定";
  202. this.queryParams = {
  203. pageNum: 1,
  204. pageSize: 10,
  205. type: 1,
  206. }
  207. this.onwObj = obj;
  208. this.getList();
  209. },
  210. handleAdd() {
  211. this.selectList = []
  212. this.queryParamsS = {}
  213. this.getSelectList();
  214. this.selectionOpen = true
  215. this.$nextTick(()=>{
  216. this.$refs.tablesS.clearSelection()
  217. })
  218. },
  219. /** 获取详情 */
  220. async getSelectByIdFun(obj) {
  221. try {
  222. let res = await getSelectById({
  223. id: obj.id
  224. })
  225. if(res.code == 200){
  226. // 已绑定的团队列表
  227. }
  228. } catch (error) {
  229. }
  230. },
  231. /** 查询列表 */
  232. getList(obj) {
  233. this.tabLoading = true;
  234. this.queryParams.id = this.onwObj.id
  235. getTeamList({...this.queryParams})
  236. .then(response => {
  237. this.dataList = response.rows;
  238. this.total = response.total;
  239. this.tabLoading = false;
  240. }
  241. ).catch(() => {
  242. this.tabLoading = false;
  243. });
  244. },
  245. /** 查询列表 */
  246. getSelectList(obj) {
  247. this.selectionTabLoading = true;
  248. allTeamList({...this.selectQueryParams,...this.queryParamsS})
  249. .then(response => {
  250. this.selectionDataList = response.data.rows;
  251. this.selectionTabTotal = response.data.total;
  252. this.selectionTabLoading = false;
  253. }
  254. ).catch(() => {
  255. this.selectionTabLoading = false;
  256. });
  257. },
  258. // 多选框选中数据
  259. handleSelectionChange(selection) {
  260. this.selectList = selection;
  261. },
  262. /**
  263. * 保存
  264. * @date 2023-11-22
  265. * @returns {any}
  266. */
  267. async submitForm() {
  268. try {
  269. if(this.selectList.length <= 0) {
  270. this.$message.error("请勾选团队!");
  271. return false
  272. }
  273. this.loading = true;
  274. // 先获取已绑定的团队
  275. const selectRes = await getSelectById({
  276. id: this.onwObj.id
  277. });
  278. let existingTeamIds = [];
  279. if (selectRes.code === 200 && selectRes.data.teamList) {
  280. existingTeamIds = selectRes.data.teamList.map(item => item.teamId);
  281. }
  282. // 新选择的团队ID
  283. let newTeamIds = this.selectList.map(item => item.id);
  284. // 合并并去重
  285. let teamIdList = [...new Set([...existingTeamIds, ...newTeamIds])];
  286. const { code } = await bindTeamApi({
  287. id: this.onwObj.id,
  288. teamIdList: teamIdList
  289. });
  290. if (code === 200) {
  291. this.$message.success("操作成功!");
  292. this.getList();
  293. this.selectionOpen = false;
  294. }
  295. } catch (error) {
  296. console.error('绑定团队失败:', error);
  297. this.$message.error("操作失败!");
  298. } finally {
  299. this.loading = false;
  300. }
  301. },
  302. /** 删除按钮操作 */
  303. handleDelete(row) {
  304. this.$confirm('是否确认移除数据团队名称为"' + row.teamName + '"的数据项?', '提示', {
  305. confirmButtonText: '确定',
  306. cancelButtonText: '取消',
  307. type: 'warning'
  308. }).then(() => {
  309. removeTeamApi({
  310. id: this.onwObj.id,
  311. teamIdList: [row.teamId]
  312. }).then((res) => {
  313. if (res.code == 200) {
  314. this.$message({
  315. type: 'success',
  316. message: '操作成功!'
  317. });
  318. this.getList();
  319. }
  320. });
  321. }).catch(() => {});
  322. },
  323. /**
  324. * 重置
  325. * @date 2023-11-22
  326. * @returns {any}
  327. */
  328. reset() {
  329. },
  330. /**
  331. * 关闭弹框
  332. * @date 2023-11-22
  333. * @returns {any}
  334. */
  335. cancel() {
  336. this.open = false;
  337. },
  338. selectionCancel() {
  339. this.selectionOpen = false;
  340. },
  341. handleQuery() {
  342. this.getSelectList()
  343. },
  344. resetQuery() {
  345. this.queryParamsS = {}
  346. this.getSelectList()
  347. },
  348. resetQuery1() {
  349. this.queryParams.teamName = null
  350. this.getList()
  351. }
  352. },
  353. };
  354. </script>
  355. <style lang="scss" scoped>
  356. .dialog {
  357. padding: 0 30px;
  358. max-height: 65vh;
  359. min-height: 65vh;
  360. overflow: hidden;
  361. overflow-y: auto;
  362. }
  363. .dialog {
  364. padding: 0 30px;
  365. .upload-btn {
  366. width: 100px;
  367. height: 100px;
  368. background-color: #fbfdff;
  369. border: dashed 1px #c0ccda;
  370. border-radius: 5px;
  371. i {
  372. font-size: 30px;
  373. margin-top: 20px;
  374. }
  375. &-text {
  376. margin-top: -10px;
  377. }
  378. }
  379. .avatar {
  380. cursor: pointer;
  381. }
  382. }
  383. </style>