signer.vue 48 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495969798991001011021031041051061071081091101111121131141151161171181191201211221231241251261271281291301311321331341351361371381391401411421431441451461471481491501511521531541551561571581591601611621631641651661671681691701711721731741751761771781791801811821831841851861871881891901911921931941951961971981992002012022032042052062072082092102112122132142152162172182192202212222232242252262272282292302312322332342352362372382392402412422432442452462472482492502512522532542552562572582592602612622632642652662672682692702712722732742752762772782792802812822832842852862872882892902912922932942952962972982993003013023033043053063073083093103113123133143153163173183193203213223233243253263273283293303313323333343353363373383393403413423433443453463473483493503513523533543553563573583593603613623633643653663673683693703713723733743753763773783793803813823833843853863873883893903913923933943953963973983994004014024034044054064074084094104114124134144154164174184194204214224234244254264274284294304314324334344354364374384394404414424434444454464474484494504514524534544554564574584594604614624634644654664674684694704714724734744754764774784794804814824834844854864874884894904914924934944954964974984995005015025035045055065075085095105115125135145155165175185195205215225235245255265275285295305315325335345355365375385395405415425435445455465475485495505515525535545555565575585595605615625635645655665675685695705715725735745755765775785795805815825835845855865875885895905915925935945955965975985996006016026036046056066076086096106116126136146156166176186196206216226236246256266276286296306316326336346356366376386396406416426436446456466476486496506516526536546556566576586596606616626636646656666676686696706716726736746756766776786796806816826836846856866876886896906916926936946956966976986997007017027037047057067077087097107117127137147157167177187197207217227237247257267277287297307317327337347357367377387397407417427437447457467477487497507517527537547557567577587597607617627637647657667677687697707717727737747757767777787797807817827837847857867877887897907917927937947957967977987998008018028038048058068078088098108118128138148158168178188198208218228238248258268278288298308318328338348358368378388398408418428438448458468478488498508518528538548558568578588598608618628638648658668678688698708718728738748758768778788798808818828838848858868878888898908918928938948958968978988999009019029039049059069079089099109119129139149159169179189199209219229239249259269279289299309319329339349359369379389399409419429439449459469479489499509519529539549559569579589599609619629639649659669679689699709719729739749759769779789799809819829839849859869879889899909919929939949959969979989991000100110021003100410051006100710081009101010111012101310141015101610171018101910201021102210231024102510261027102810291030103110321033103410351036103710381039104010411042104310441045104610471048104910501051105210531054105510561057105810591060106110621063106410651066106710681069107010711072107310741075107610771078107910801081108210831084108510861087108810891090109110921093109410951096109710981099110011011102110311041105110611071108110911101111111211131114111511161117111811191120112111221123112411251126112711281129113011311132113311341135113611371138113911401141114211431144114511461147114811491150115111521153115411551156115711581159116011611162116311641165116611671168116911701171117211731174117511761177117811791180118111821183118411851186118711881189119011911192119311941195119611971198119912001201120212031204120512061207120812091210121112121213121412151216121712181219122012211222122312241225122612271228122912301231123212331234123512361237123812391240124112421243124412451246124712481249125012511252125312541255125612571258125912601261126212631264126512661267126812691270127112721273
  1. <template>
  2. <basic-container>
  3. <el-row :gutter="20" class="h100p">
  4. <el-col :span="6" class="h100p">
  5. <div class="grid-content1">
  6. <el-radio-group v-model="tabPosition" @input="getRoleData">
  7. <el-radio-button label="1">施工</el-radio-button>
  8. <el-radio-button label="2">监理</el-radio-button>
  9. <el-radio-button label="3">业主</el-radio-button>
  10. </el-radio-group>
  11. <div class="flex" style="margin-top: 10px">
  12. <el-input
  13. placeholder="请输入岗位名称"
  14. clearable
  15. @clear="clearInput"
  16. v-model="postText"
  17. >
  18. </el-input>
  19. <el-button class="mg-l-10" @click="searchPost"
  20. >搜索</el-button
  21. >
  22. </div>
  23. <div class="post-list">
  24. <el-scrollbar style="margin-top: 20px; height: 100%" v-loading="roleListLoading">
  25. <ul
  26. class="contextmenu"
  27. >
  28. <li v-for="item in roleData" :key="item"
  29. :class="{'selected': selectedItem === item}"
  30. @click="positionClick($event,item)">
  31. <span>{{item.roleName}}</span>
  32. </li>
  33. </ul>
  34. </el-scrollbar>
  35. </div>
  36. </div>
  37. </el-col>
  38. <el-col :span="18" class="h100p">
  39. <div class="grid-content2 ">
  40. <div class="header-btn">
  41. <el-button type="primary" size="small" @click="addEleClick">新增</el-button>
  42. <el-button type="info" size="small" @click="editEleClick" :disabled="checkedList.length<1">编辑</el-button>
  43. <el-button type="success" size="small" @click="openClick(row,1)" :loading="openLoading">启用</el-button>
  44. <el-button type="warning" size="small" @click="openClick(row,0)" :loading="closeLoading">停用</el-button>
  45. <el-button type="danger" size="small" @click="rowDel(row)" :loading="removeLoad">删除</el-button>
  46. </div>
  47. <div class="table-box">
  48. <el-table
  49. v-loading="tableLoading"
  50. ref="multipleTable"
  51. :data="tableData"
  52. tooltip-effect="dark"
  53. style="width: 100%"
  54. @selection-change="handleSelectionChange">
  55. <el-table-column
  56. type="selection"
  57. width="55">
  58. </el-table-column>
  59. <el-table-column
  60. label="电签元素名称"
  61. prop="eName"
  62. >
  63. </el-table-column>
  64. <el-table-column
  65. prop="elementTypeName"
  66. label="字符类型"
  67. >
  68. </el-table-column>
  69. <el-table-column
  70. label="元素来源"
  71. >
  72. <template slot-scope="scope">
  73. <el-link type="primary" @click="eleCheck(scope.row,scope.$index,1)">查看</el-link>
  74. </template>
  75. </el-table-column>
  76. <el-table-column
  77. label="绑定岗位"
  78. >
  79. <template slot-scope="scope">
  80. <el-link type="primary" @click="selectPost(scope.row,scope.$index,1)">查看</el-link>
  81. </template>
  82. </el-table-column>
  83. <el-table-column
  84. prop="status"
  85. label="状态"
  86. width="100"
  87. >
  88. <template slot-scope="scope">
  89. <i class="el-icon-success" style="font-size: 20px;color:#67C23A" v-if="scope.row.status==1"></i>
  90. <i class="el-icon-error" style="font-size: 20px;color:red" v-else></i>
  91. </template>
  92. </el-table-column>
  93. </el-table>
  94. </div>
  95. <div class="pagination-page">
  96. <el-pagination
  97. @size-change="handleSizeChange"
  98. @current-change="handleCurrentChange"
  99. :current-page="currentPage"
  100. :page-sizes="[10, 20, 30, 40,50]"
  101. :page-size="pageSize"
  102. layout="total, sizes, prev, pager, next, jumper"
  103. :total="total">
  104. </el-pagination>
  105. </div>
  106. </div>
  107. </el-col>
  108. </el-row>
  109. <el-dialog
  110. class="dialog-footer-center"
  111. append-to-body
  112. title="新增电签配置信息"
  113. :visible.sync="addDialogVisible"
  114. width="80%"
  115. :before-close="handleAddClose">
  116. <div>
  117. <el-table
  118. :data="tableData1"
  119. style="width: 100%"
  120. max-height="500"
  121. >
  122. <el-table-column
  123. label="电签元素名称"
  124. >
  125. <template slot-scope="scope">
  126. <el-select v-model="scope.row.eName" placeholder="请选择元素或搜索" filterable size="small" @change="changeEleType($event,scope.row)">
  127. <el-option
  128. v-for="item in eleOptions"
  129. :key="item.value"
  130. :label="item.label"
  131. :value="item.value">
  132. </el-option>
  133. </el-select>
  134. </template>
  135. </el-table-column>
  136. <el-table-column
  137. prop="name"
  138. label="字符类型"
  139. >
  140. <template slot-scope="scope">
  141. <el-select
  142. v-model="scope.row.elementType"
  143. disabled
  144. size="small"
  145. placeholder="请选择"
  146. >
  147. <el-option
  148. v-for="item in dataTypeList"
  149. :key="item.id"
  150. :label="item.dictValue"
  151. :value="item.dictKey"
  152. ></el-option>
  153. </el-select>
  154. </template>
  155. </el-table-column>
  156. <el-table-column
  157. prop="address"
  158. label="元素来源"
  159. >
  160. <template slot-scope="scope">
  161. <el-link type="warning" @click="eleCheck(scope.row,scope.$index)">请选择</el-link>
  162. </template>
  163. </el-table-column>
  164. <el-table-column
  165. prop="address"
  166. label="绑定岗位"
  167. > <template slot-scope="scope">
  168. <el-link type="warning" :underline="true" @click="selectPost(scope.row,scope.$index)">请选择</el-link>
  169. </template>
  170. </el-table-column>
  171. <el-table-column
  172. prop="tag"
  173. label="操作"
  174. width="100"
  175. >
  176. <template slot-scope="scope">
  177. <el-button type="text" @click="handleAdd(scope.row,scope.$index)">
  178. <i class="el-icon-circle-plus-outline" style="font-size: 20px;color:#67C23A"></i>
  179. </el-button>
  180. <el-button type="text" @click="handleDelete(scope.row,row,scope.$index)">
  181. <i class="el-icon-remove-outline" style="font-size: 20px;color:red"></i>
  182. </el-button>
  183. </template>
  184. </el-table-column>
  185. </el-table>
  186. </div>
  187. <span slot="footer" class="dialog-footer">
  188. <el-button type="primary" @click="saveBatch" :loading="saveBatchLoading">保存并生效</el-button>
  189. </span>
  190. </el-dialog>
  191. <!-- 选择元素来源 -->
  192. <el-dialog
  193. class="dialog-footer-center"
  194. append-to-body
  195. title="元素来源"
  196. :visible.sync="sourceDialogVisible"
  197. width="50%"
  198. :close="handleSourceClose">
  199. <div>
  200. <p class="tip-text" v-if="!isEleView" >
  201. 提示:配置之后会把所有元素表该元素字段都自动配置电签岗位对应关系。
  202. </p>
  203. <div class="source-radio-group">
  204. <el-radio-group v-model="selectedSourceOption" :disabled="isEleView">
  205. <el-radio :label="0">适配所有元素表</el-radio>
  206. <el-radio :label="1">部分元素表</el-radio>
  207. </el-radio-group>
  208. </div>
  209. <!-- 并行显示的下拉框 -->
  210. <div v-if="selectedSourceOption === 1&&!isEleView" class="dropdown-container">
  211. <el-select
  212. v-model="elementCategorySelect"
  213. placeholder="请选择表分类"
  214. style="flex: 1; margin-right: 10px;"
  215. clearable @change="changeSelect"
  216. >
  217. <el-option
  218. v-for="item in elementCategoryOptions"
  219. :key="item.value"
  220. :label="item.label"
  221. :value="item.value">
  222. </el-option>
  223. </el-select>
  224. <el-select
  225. v-loading="loadingList"
  226. v-model="elementTableNameSelect"
  227. placeholder="请输入元素表名称进行模糊检索"
  228. style="flex: 1;"
  229. filterable clearable multiple
  230. class="custom-multi-select"
  231. >
  232. <el-option
  233. v-for="item in elementTableOptions"
  234. :key="item.value"
  235. :label="item.label"
  236. :value="item.value">
  237. </el-option>
  238. </el-select>
  239. </div>
  240. <div v-if="selectedSourceOption === 1&&!isEleView" class="element-list-container">
  241. <el-scrollbar>
  242. <ul class="element-checkbox-list">
  243. <li v-for="(item, index) in elementList" :key="item.value" class="element-item">
  244. <el-checkbox v-model="item.checked" @change="changeEleClick($event,item)">{{ item.label }}</el-checkbox>
  245. </li>
  246. </ul>
  247. </el-scrollbar>
  248. </div>
  249. <el-table
  250. v-loading="elementLoading"
  251. v-if="selectedSourceOption === 1&&isEleView"
  252. :data="elementList1"
  253. border
  254. style="width: 100%;margin-top: 20px;"
  255. :header-cell-style="{ background: '#A0B7E2', color: 'black' }"
  256. >
  257. <el-table-column
  258. prop="name"
  259. label="元素表名称"
  260. align="center"
  261. >
  262. </el-table-column>
  263. </el-table>
  264. </div>
  265. <span slot="footer" class="dialog-footer" v-if="!isEleView">
  266. <el-button type="primary" @click="confirmSourceSelection">确 定</el-button>
  267. </span>
  268. </el-dialog>
  269. <!-- 绑定岗位弹窗 -->
  270. <el-dialog
  271. class="dialog-footer-center"
  272. append-to-body
  273. title="绑定岗位"
  274. :visible.sync="bindPostDialogVisible"
  275. width="50%"
  276. :before-close="handleBindPostClose">
  277. <div class="bind-post-content">
  278. <!-- 参建方分类 + 岗位名称下拉框 -->
  279. <div class="dropdown-pair" v-if="!isPosView">
  280. <el-select v-model="partyCategorySelect" placeholder="请选择参建方分类" style="flex: 1; margin-right: 10px;" @change="changePositionName">
  281. <el-option
  282. v-for="item in partyCategoryOptions"
  283. :key="item.value"
  284. :label="item.label"
  285. :value="item.value">
  286. </el-option>
  287. </el-select>
  288. <el-select v-model="positionNameSelect" filterable multiple placeholder="请输入岗位名称进行模糊检索" class="custom-multi-select" style="flex: 1;" v-loading="positionNameLoading">
  289. <el-option
  290. v-for="item in positionNameOptions"
  291. :key="item.value"
  292. :label="item.label"
  293. :value="item.value">
  294. </el-option>
  295. </el-select>
  296. </div>
  297. <!-- 岗位列表 -->
  298. <div class="position-list-container" v-if="!isPosView">
  299. <el-scrollbar > <!-- 18行 * 30px = 540px -->
  300. <ul class="position-checkbox-list">
  301. <li v-for="(item, index) in positionList" :key="index" class="position-item">
  302. <el-checkbox v-model="item.checked" @change="changePosClick($event,item)">{{ item.label }}</el-checkbox>
  303. </li>
  304. </ul>
  305. </el-scrollbar>
  306. </div>
  307. <el-table
  308. v-loading="bindPosLoading"
  309. v-if="isPosView"
  310. :data="positionList1"
  311. border
  312. :header-cell-style="{ background: '#A0B7E2', color: 'black' }"
  313. style="width: 100%;margin-top: 20px;">
  314. <el-table-column
  315. prop="type"
  316. label="所属方"
  317. align="center"
  318. >
  319. </el-table-column>
  320. <el-table-column
  321. prop="name"
  322. label="岗位名称"
  323. align="center"
  324. >
  325. </el-table-column>
  326. </el-table>
  327. </div>
  328. <span slot="footer" class="dialog-footer" v-if="!isPosView">
  329. <el-button @click="positionClose">取 消</el-button>
  330. <el-button type="primary" @click="confirmBindPostSelection">确 定</el-button>
  331. </span>
  332. </el-dialog>
  333. </basic-container>
  334. </template>
  335. <script>
  336. import {getRoleList,getListPage,getElementList,getTableTypeList,getTableList,queryAllRoleList,submitEle,elementDetail,roleDetail,removeEle,updateStatusEle} from "@/api/sigital/signer.js";
  337. import { getDictionary } from "@/api/system/dict";
  338. export default {
  339. data() {
  340. return {
  341. tabPosition: '1',
  342. postText: '',
  343. roleData:[],
  344. roleListLoading:false,
  345. multipleTable:null,
  346. tableData: [],
  347. tableLoading: false,
  348. selectedItem: {
  349. id: '',
  350. },
  351. removeLoad:false,
  352. openLoading:false,
  353. closeLoading:false,
  354. currentPage: 1,
  355. pageSize: 10,
  356. total: 0,
  357. addDialogVisible: false,
  358. saveBatchLoading: false,
  359. checkedList: [],
  360. tableData1: [{}],
  361. eleOptions: [
  362. ],
  363. dataTypeList: [],
  364. sourceDialogVisible: false, // 控制弹窗显示
  365. isEleView: true, // 是否查看
  366. eleCheckRow: {},
  367. eleIndex: 0,
  368. selectedSourceOption: 1, // 默认选中 "适配所有元素表"
  369. elementCategorySelect: '', // 元素分类表分类选中值
  370. loadingList: false,
  371. elementTableNameSelect: [], // 元素表名称筛选选中值
  372. elementCategoryOptions: [
  373. ],
  374. elementTableOptions: [
  375. ],
  376. allElementTableOptions: [],
  377. elementList:[],
  378. elementList1:[],
  379. elementLoading: false,
  380. bindPostDialogVisible: false,
  381. bindPosLoading: false,
  382. partyCategorySelect: '', // 参建方分类选中值
  383. positionNameSelect: [], // 岗位名称选中值
  384. partyCategoryOptions: [
  385. { value: '1', label: '施工方' },
  386. { value: '2', label: '监理方' },
  387. { value: '3', label: '业主方' }
  388. ],
  389. positionNameOptions: [],
  390. allPositionNameOptions : [],
  391. positionNameLoading: false,
  392. positionList: [],
  393. positionList1:[],
  394. isPosView: true, //
  395. // 是否查看
  396. selectedPostRow: {},
  397. selectedPostIndex: 0,
  398. }
  399. },
  400. watch: {
  401. elementTableNameSelect(newVal) {
  402. if (newVal) {
  403. let arr=[];
  404. this.allElementTableOptions.forEach(item => {
  405. newVal.forEach(tableName => {
  406. if (item.value === tableName) {
  407. arr.push(item)
  408. }
  409. });
  410. });
  411. // 更新 elementList 并自动选中对应的项
  412. this.elementList = arr.map(element => ({
  413. ...element,
  414. checked: true // 自动选中
  415. }))
  416. }
  417. },
  418. positionNameSelect(newVal) {
  419. if (newVal) {
  420. let arr=[];
  421. this.allPositionNameOptions.forEach(item => {
  422. newVal.forEach(roleName => {
  423. if (item.value === roleName) {
  424. arr.push(item)
  425. }
  426. });
  427. });
  428. // 更新 elementList 并自动选中对应的项
  429. this.positionList = arr.map(element => ({
  430. ...element,
  431. checked: true // 自动选中
  432. }))
  433. }
  434. },
  435. },
  436. methods: {
  437. clearInput() {
  438. this.postText = ''
  439. this.getRoleData();
  440. },
  441. searchPost() {
  442. this.getRoleData();
  443. },
  444. handleSelectionChange(val) {
  445. this.checkedList=val
  446. },
  447. //获取岗位列表
  448. getRoleData() {
  449. this.roleListLoading = true;
  450. getRoleList({
  451. type: this.tabPosition,
  452. roleName: this.postText
  453. }).then(res => {
  454. console.log(res,'res');
  455. this.roleListLoading = false;
  456. if (res.data.code == 200) {
  457. this.roleListLoading = false;
  458. this.roleData = res.data.data;
  459. }else{
  460. this.roleData = [];
  461. }
  462. })
  463. },
  464. positionClick(event, item){
  465. this.selectedItem = item;
  466. this.getTableData();
  467. },
  468. getTableData() {
  469. this.$refs.multipleTable.clearSelection();
  470. this.tableLoading = true;
  471. getListPage({
  472. size: this.pageSize,
  473. current: this.currentPage,
  474. keyword: this.postText,
  475. roleId: this.selectedItem.roleId||''
  476. }).then(res => {
  477. this.tableLoading = false;
  478. if (res.data.code == 200) {
  479. this.tableData = res.data.data['records'];
  480. this.total = res.data.data['total'];
  481. }else{
  482. this.tableData = [];
  483. }
  484. })
  485. },
  486. handleSizeChange(val) {
  487. this.pageSize = val;
  488. this.getTableData();
  489. },
  490. handleCurrentChange(val) {
  491. this.currentPage = val;
  492. this.getTableData();
  493. },
  494. addEleClick() {
  495. this.addDialogVisible = true;
  496. this.tableData1=[{}]
  497. },
  498. editEleClick(row) {
  499. this.addDialogVisible = true;
  500. this.tableData1 = [...this.checkedList]
  501. console.log( this.tableData1,' this.tableData1');
  502. this.isPosView=false
  503. this.isEleView=false
  504. },
  505. //启用
  506. openClick(row,type){
  507. if(type==1){
  508. this.openLoading=true;
  509. }else{
  510. this.closeLoading=true;
  511. }
  512. let ids = '';
  513. if (this.checkedList.length > 0) {
  514. ids = this.checkedList.map(item => item.id).join(',');
  515. }
  516. updateStatusEle({
  517. ids: ids,
  518. status: type
  519. })
  520. .then(res => {
  521. if(res.data.code==200){
  522. this.$message({
  523. type: 'success',
  524. message: '操作成功!'
  525. });
  526. this.getTableData();
  527. }else{
  528. this.$message({
  529. type: 'error',
  530. message: res.data.msg
  531. });
  532. }
  533. }).finally(() => {
  534. if(type==1){
  535. this.openLoading=false;
  536. }else{
  537. this.closeLoading=false;
  538. }
  539. });
  540. },
  541. handleAddClose(){
  542. this.addDialogVisible = false;
  543. },
  544. getEleOptions(){
  545. getElementList().then(res => {
  546. if (res.data.code == 200) {
  547. this.eleOptions = res.data.data.map(item => ({
  548. value: item.id,
  549. label: item.ename,
  550. etype: item.etype,
  551. }));
  552. }else{
  553. this.eleOptions = [];
  554. }
  555. });
  556. },
  557. getDataTypelist() {
  558. if (this.dataTypeList.length > 1) {
  559. return;
  560. }
  561. getDictionary({
  562. code: "data_type",
  563. }).then((res) => {
  564. res.data.data.forEach((element) => {
  565. element.dictKey = Number(element.dictKey);
  566. });
  567. this.dataTypeList = res.data.data;
  568. });
  569. },
  570. handleAdd(row,index) {
  571. console.log('新增', row);
  572. this.tableData1.splice(index + 1, 0, {});
  573. // this.elementList = [];
  574. // this.selectedSourceOption = 1;
  575. // this.elementTableNameSelect = [];
  576. // this.elementCategorySelect = '';
  577. // this.positionList = [];
  578. // this.positionNameSelect = [];
  579. // this.partyCategorySelect = '';
  580. // 新增操作的逻辑
  581. },
  582. handleDelete(row,index) {
  583. console.log('删除', row);
  584. this.tableData1.splice(index, 1);
  585. // 删除操作的逻辑
  586. },
  587. rowDel() {
  588. let ids=''
  589. if (this.checkedList.length > 0) {
  590. ids = this.checkedList.map(item => item.id).join(',');
  591. }
  592. let _that = this;
  593. this.$confirm("此操作将永久删除该文件, 是否继续?", "提示", {
  594. confirmButtonText: "确定",
  595. cancelButtonText: "取消",
  596. type: "warning",
  597. })
  598. .then(() => {
  599. _that.remove({ ids });
  600. })
  601. .catch(() => {
  602. this.$message({
  603. type: "info",
  604. message: "已取消删除",
  605. });
  606. })
  607. },
  608. async remove(ids) {
  609. this.removeLoad = true;
  610. removeEle(ids).then(res => {
  611. console.log(res,'res');
  612. this.removeLoad = false;
  613. if (res.data.code == 200) {
  614. this.$message({
  615. type: "success",
  616. message: "删除成功!",
  617. });
  618. this.getTableData();
  619. this.getRoleData();
  620. }
  621. }).finally(() => {
  622. this.removeLoad = false;
  623. });
  624. },
  625. changeEleType(value,row) {
  626. const selectedItem = this.eleOptions.find(item => item.value === value);
  627. if (selectedItem && selectedItem.etype != null) {
  628. row.elementType = selectedItem.etype; // 假设接口返回的 eleOptions 中有 etype 字段
  629. row.eName=selectedItem.label;
  630. row.elementId=selectedItem.value;
  631. }
  632. },
  633. //选择元素来源
  634. eleCheck(row,index,type) {
  635. this.getAllElements()
  636. this.eleCheckRow=row;
  637. this.eleIndex=index;
  638. if(type===1){
  639. this.isEleView = true;
  640. this.getEleDetail(row.id)
  641. this.selectedSourceOption=row.tableType
  642. }else{
  643. this.isEleView = false;
  644. this.selectedSourceOption=row.tableType
  645. if(row.id){
  646. this.getEleDetail(row.id,1)
  647. getTableList({
  648. tableType:''
  649. }).then(res => {
  650. if (res.data.code == 200) {
  651. this.elementTableOptions = res.data.data.map(item => ({
  652. value: item.id,
  653. label: item.tabChName
  654. }));
  655. // this.elementTableNameSelect=row.tableIds
  656. let arr=[];
  657. this.elementList.forEach(item => {
  658. arr.push(item.value)
  659. // item.checked = false;
  660. });
  661. this.elementTableNameSelect=arr
  662. }else{
  663. this.elementTableOptions = [];
  664. this.elementTableNameSelect=[]
  665. }
  666. });
  667. }else{
  668. this.elementCategorySelect=row.eleType
  669. this.changeSelect(row.eleType)
  670. this.elementTableNameSelect=row.tableIds
  671. }
  672. this.getElementCategoryOptions();
  673. }
  674. this.sourceDialogVisible = true;
  675. },
  676. //查看详情
  677. getEleDetail(id,type){
  678. this.elementLoading = true;
  679. elementDetail({
  680. id
  681. }).then(res => {
  682. this.elementLoading = false;
  683. if (res.data.code == 200) {
  684. if(type==1){
  685. // this.elementList = res.data.data;
  686. this.elementList = res.data.data.map(item => ({
  687. value: item.id,
  688. label: item.name,
  689. checked: true
  690. }));
  691. console.log( this.elementList,' this.elementList');
  692. }else{
  693. this.elementList1 = res.data.data;
  694. }
  695. }else{
  696. this.elementList1 = [];
  697. this.elementList = [];
  698. }
  699. })
  700. },
  701. getPosDetail(id){
  702. this.bindPosLoading = true;
  703. roleDetail({
  704. id
  705. }).then(res => {
  706. this.bindPosLoading = false;
  707. if (res.data.code == 200) {
  708. this.positionList1 = res.data.data;
  709. this.positionList = res.data.data;
  710. this.positionNameSelect=res.data.data.map(item => item.id)
  711. this.positionList.map(item => {
  712. item.label = item.name;
  713. item.value = item.id;
  714. item.checked = true
  715. });
  716. }else{
  717. this.positionList1 = [];
  718. this.positionList = [];
  719. }
  720. })
  721. },
  722. //获取元素表分类
  723. getElementCategoryOptions(){
  724. getTableTypeList().then(res => {
  725. if (res.data.code == 200) {
  726. this.elementCategoryOptions = res.data.data.map(item => ({
  727. value: item.dictKey,
  728. label: item.dictValue,
  729. id:item.id
  730. }));
  731. }else{ this.elementCategoryOptions = [];}
  732. });
  733. },
  734. changeSelect(){
  735. this.getElementTableOptions();
  736. },
  737. getAllElements(){
  738. getTableList({
  739. tableType:''
  740. }).then(res => {
  741. if (res.data.code == 200) {
  742. this.allElementTableOptions = res.data.data.map(item => ({
  743. value: item.id,
  744. label: item.tabChName
  745. }));
  746. }else{ this.allElementTableOptions = [];}
  747. });
  748. },
  749. //获取元素表List
  750. getElementTableOptions(){
  751. this.loadingList = true;
  752. getTableList({
  753. tableType:this.elementCategorySelect
  754. }).then(res => {
  755. this.loadingList = false;
  756. if (res.data.code == 200) {
  757. this.elementTableOptions = res.data.data.map(item => ({
  758. value: item.id,
  759. label: item.tabChName
  760. }));
  761. this.slec
  762. }else{ this.elementTableOptions = [];}
  763. });
  764. },
  765. // 弹窗关闭时的回调
  766. handleSourceClose(done) {
  767. this.sourceDialogVisible = false;
  768. done();
  769. },
  770. changeEleClick(value,item) {
  771. if(!value){
  772. this.elementTableNameSelect.forEach((ele,index)=>{
  773. if(ele == item.value){
  774. this.elementTableNameSelect.splice(index,1);
  775. }
  776. })
  777. }
  778. },
  779. changePosClick(value,item) {
  780. if(!value){
  781. this.positionNameSelect.forEach((ele,index)=>{
  782. if(ele == item.value){
  783. this.positionNameSelect.splice(index,1);
  784. }
  785. })
  786. }
  787. },
  788. quitClose() {
  789. this.sourceDialogVisible = false;
  790. this.selectedSourceOption = 1;
  791. this.elementTableNameSelect = [];
  792. this.elementList = [];
  793. this.elementCategorySelect = '';
  794. },
  795. positionClose() {
  796. this.bindPostDialogVisible = false;
  797. this.partyCategorySelect=''
  798. this.positionNameSelect = [];
  799. this.positionList = [];
  800. this.partyCategorySelect = '';
  801. },
  802. // 确认按钮点击事件
  803. confirmSourceSelection() {
  804. console.log(this.eleIndex,'eleIndex');
  805. if(!this.selectedSourceOption){
  806. this.$message({
  807. type: 'warning',
  808. message: '请选择元素来源!'
  809. });
  810. return
  811. }
  812. if (this.selectedSourceOption === 0) {
  813. // 处理适配所有元素表的逻辑
  814. console.log("适配所有元素表");
  815. // this.eleCheckRow.tableType = 1;
  816. this.tableData1.forEach((item, index) => {
  817. if (item.id === this.eleCheckRow.id) {
  818. this.tableData1[index].tableType = 0;
  819. }
  820. })
  821. } else {
  822. // 处理适配部分元素表的逻辑
  823. this.tableData1.forEach((item, index) => {
  824. if (index==this.eleIndex) {
  825. this.tableData1[index].tableType = 1;
  826. }
  827. })
  828. if (this.elementTableNameSelect.length > 0) {
  829. this.tableData1.forEach((item, index) => {
  830. if (index==this.eleIndex) {
  831. this.tableData1[index].tableIds = this.elementTableNameSelect
  832. this.tableData1[index].eleType = this.elementCategorySelect;
  833. }
  834. });
  835. }else{
  836. this.tableData1.forEach((item, index) => {
  837. if (index==this.eleIndex) {
  838. this.tableData1[index].tableIds ='';
  839. this.tableData1[index].eleType=''
  840. this.elementList1 = [];
  841. this.elementList = [];
  842. }
  843. });
  844. }
  845. }
  846. // 关闭弹窗
  847. this.sourceDialogVisible = false;
  848. },
  849. // 打开绑定岗位弹窗
  850. selectPost(row,index,type) {
  851. this.selectedPostIndex=index;
  852. this.getAllPositionNameOptions();
  853. this.positionNameOptions=this.allPositionNameOptions;
  854. if(type===1){
  855. this.isPosView=true
  856. if(row.id){
  857. this.getPosDetail(row.id)
  858. }
  859. }else{
  860. if(row.id){
  861. this.getPosDetail(row.id)
  862. }
  863. this.isPosView=false
  864. this.partyCategorySelect='1'
  865. this.getPositionList();
  866. this.selectedPostRow = row;
  867. // this.positionNameSelect=arr
  868. if(!row.id&&row.roleIds&&row.roleIds.length>0){
  869. this.positionNameSelect = row.roleIds;
  870. this.partyCategorySelect=row.partyCategory
  871. }else{
  872. this.positionNameSelect = [];
  873. this.partyCategorySelect = '';
  874. this.positionList = [];
  875. }
  876. }
  877. this.bindPostDialogVisible = true;
  878. },
  879. changePositionName() {
  880. this.getPositionList();
  881. },
  882. getAllPositionNameOptions() {
  883. queryAllRoleList({
  884. type:''
  885. }).then(res => {
  886. if (res.data.code == 200) {
  887. this.allPositionNameOptions = res.data.data.map(item => ({
  888. value: item.id,
  889. label: item.roleName
  890. }));
  891. }else{ this.allPositionNameOptions = [];}
  892. });
  893. },
  894. // 获取岗位列表
  895. getPositionList() {
  896. this.positionNameLoading = true;
  897. queryAllRoleList({
  898. type:this.partyCategorySelect
  899. }).then(res => {
  900. this.positionNameLoading = false;
  901. if (res.data.code == 200) {
  902. this.positionNameOptions = res.data.data.map(item => ({
  903. value: item.id,
  904. label: item.roleName
  905. }));
  906. }else{ this.positionNameOptions = [];}
  907. });
  908. },
  909. // 弹窗关闭回调
  910. handleBindPostClose(done) {
  911. this.bindPostDialogVisible = false;
  912. done();
  913. },
  914. // 确认选择岗位
  915. confirmBindPostSelection() {
  916. if(this.positionNameSelect.length==0){
  917. this.$message.error('请选择岗位')
  918. return
  919. }
  920. if (this.positionNameSelect.length > 0) {
  921. // this.selectedPostRow.roleIds = this.positionNameSelect.join(',');
  922. this.tableData1.forEach((item, index) => {
  923. if (this.selectedPostIndex == index) {
  924. this.tableData1[index].roleIds =this.positionNameSelect
  925. this.tableData1[index].partyCategory =this.partyCategorySelect
  926. }
  927. });
  928. }else{
  929. // this.selectedPostRow.roleIds = '';
  930. this.tableData1.forEach((item, index) => {
  931. if (this.selectedPostIndex == index) {
  932. this.tableData1[index].roleIds =[]
  933. this.tableData1[index].partyCategory = ''
  934. }
  935. });
  936. }
  937. console.log(this.tableData1,'this.tableData1');
  938. this.bindPostDialogVisible = false;
  939. },
  940. saveBatch(){
  941. console.log(this.tableData1,'this.tableData1');
  942. if(this.tableData1.length==0){
  943. this.$message.error('请选择数据')
  944. return
  945. }
  946. this.saveBatchLoading = true;
  947. submitEle(
  948. this.tableData1
  949. ).then((res) => {
  950. if(res.data.code==200){
  951. this.$message.success(res.data.msg)
  952. this.getTableData();
  953. this.getRoleData();
  954. this.addDialogVisible=false
  955. }else{
  956. this.$message.error(res.data.msg)
  957. }
  958. }).finally(() => {
  959. this.saveBatchLoading = false;
  960. });
  961. }
  962. },
  963. mounted() {
  964. this.getRoleData();
  965. this.getTableData();
  966. this.getEleOptions();
  967. this.getDataTypelist();
  968. },
  969. components: {}
  970. }
  971. </script>
  972. <style lang="scss" scoped>
  973. .h100p{
  974. height: 100%;
  975. }
  976. .grid-content1{
  977. height: 100%;
  978. border-right: 1px solid #D6D6D6;
  979. padding-right: 10px;
  980. .post-list{
  981. margin-top: -18px;
  982. height: calc(100% - 110px);
  983. // border: 1px solid red;
  984. }
  985. .contextmenu {
  986. padding: 4px 0; /* 添加适当的内边距 */
  987. // min-width: 120px;
  988. }
  989. .contextmenu ul {
  990. list-style: none; /* 移除小圆点 */
  991. padding: 0;
  992. margin: 0;
  993. // min-width: 80px;
  994. background: #fff;
  995. border: 1px solid #e4e7ed;
  996. border-radius: 4px;
  997. box-shadow: 0 2px 12px 0 rgba(0,0,0,.1);
  998. }
  999. .contextmenu li {
  1000. padding: 8px 16px;
  1001. line-height: 22px;
  1002. display: flex;
  1003. align-items: center;
  1004. cursor: pointer;
  1005. transition: all 0.3s;
  1006. &.selected {
  1007. background-color: #409eff;
  1008. color: white;
  1009. span {
  1010. color: white;
  1011. }
  1012. }
  1013. }
  1014. .contextmenu li i {
  1015. margin-right: 8px;
  1016. font-size: 16px;
  1017. }
  1018. .contextmenu li span {
  1019. font-size: 14px;
  1020. color: #606266;
  1021. }
  1022. .contextmenu li:hover,
  1023. .contextmenu li.active {
  1024. background-color: #f5f7fa;
  1025. color: #409eff;
  1026. }
  1027. .contextmenu li.divider {
  1028. height: 1px;
  1029. background-color: #e4e7ed;
  1030. margin: 4px 0;
  1031. padding: 0;
  1032. }
  1033. }
  1034. .grid-content2{
  1035. height: 100%;
  1036. display: flex;
  1037. flex-direction: column;
  1038. .header-btn{
  1039. margin-top: 10px;
  1040. text-align: right;
  1041. }
  1042. .table-box {
  1043. flex: 1;
  1044. overflow: hidden;
  1045. .el-table {
  1046. height: 100% !important;
  1047. }
  1048. }
  1049. }
  1050. .tip-text {
  1051. margin-top: -30px;
  1052. color: red;
  1053. }
  1054. .source-radio-group{
  1055. margin-top: 20px;
  1056. text-align: center;
  1057. }
  1058. .dropdown-container {
  1059. display: flex;
  1060. margin-top: 20px;
  1061. }
  1062. .element-list-container {
  1063. margin-top: 20px;
  1064. height: 300px;
  1065. overflow-y: auto
  1066. }
  1067. .element-checkbox-list {
  1068. list-style: none;
  1069. padding: 0;
  1070. margin: 0;
  1071. }
  1072. .element-item {
  1073. line-height: 30px;
  1074. padding-left: 10px;
  1075. }
  1076. .bind-post-content {
  1077. padding-bottom: 20px;
  1078. }
  1079. .dropdown-pair {
  1080. display: flex;
  1081. margin-bottom: 20px;
  1082. }
  1083. .position-list-container {
  1084. // border: 1px solid #e4e7ed;
  1085. border-radius: 4px;
  1086. padding: 10px;
  1087. height: 300px;
  1088. overflow-y: auto;
  1089. }
  1090. .position-checkbox-list {
  1091. list-style: none;
  1092. padding: 0;
  1093. margin: 0;
  1094. }
  1095. .position-item {
  1096. line-height: 30px;
  1097. padding-left: 10px;
  1098. }
  1099. .limit-height-select .el-select-dropdown__wrap {
  1100. max-height: 30px !important;
  1101. overflow-y: auto !important;
  1102. }
  1103. </style>
  1104. <style lang="scss" >
  1105. /* 限制已选标签容器高度并启用滚动 */
  1106. .custom-multi-select .el-select__tags {
  1107. max-height: 60px; /* 控制高度 */
  1108. overflow-y: auto; /* 启用滚动 */
  1109. white-space: normal; /* 允许换行(可选) */
  1110. }
  1111. /* 调整折叠标签的显示样式 */
  1112. .custom-multi-select .el-tag {
  1113. margin: 2px 4px 2px 0;
  1114. }
  1115. /* 可选:隐藏原生滚动条(更美观) */
  1116. .custom-multi-select .el-select__tags::-webkit-scrollbar {
  1117. width: 0;
  1118. }
  1119. .dialog-footer-center {
  1120. .el-dialog__footer {
  1121. text-align: center;
  1122. }
  1123. }
  1124. .pagination-page{
  1125. text-align: center;
  1126. margin-top: 10px;
  1127. }
  1128. </style>