signer.vue 50 KB

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