index.vue 36 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394959697989910010110210310410510610710810911011111211311411511611711811912012112212312412512612712812913013113213313413513613713813914014114214314414514614714814915015115215315415515615715815916016116216316416516616716816917017117217317417517617717817918018118218318418518618718818919019119219319419519619719819920020120220320420520620720820921021121221321421521621721821922022122222322422522622722822923023123223323423523623723823924024124224324424524624724824925025125225325425525625725825926026126226326426526626726826927027127227327427527627727827928028128228328428528628728828929029129229329429529629729829930030130230330430530630730830931031131231331431531631731831932032132232332432532632732832933033133233333433533633733833934034134234334434534634734834935035135235335435535635735835936036136236336436536636736836937037137237337437537637737837938038138238338438538638738838939039139239339439539639739839940040140240340440540640740840941041141241341441541641741841942042142242342442542642742842943043143243343443543643743843944044144244344444544644744844945045145245345445545645745845946046146246346446546646746846947047147247347447547647747847948048148248348448548648748848949049149249349449549649749849950050150250350450550650750850951051151251351451551651751851952052152252352452552652752852953053153253353453553653753853954054154254354454554654754854955055155255355455555655755855956056156256356456556656756856957057157257357457557657757857958058158258358458558658758858959059159259359459559659759859960060160260360460560660760860961061161261361461561661761861962062162262362462562662762862963063163263363463563663763863964064164264364464564664764864965065165265365465565665765865966066166266366466566666766866967067167267367467567667767867968068168268368468568668768868969069169269369469569669769869970070170270370470570670770870971071171271371471571671771871972072172272372472572672772872973073173273373473573673773873974074174274374474574674774874975075175275375475575675775875976076176276376476576676776876977077177277377477577677777877978078178278378478578678778878979079179279379479579679779879980080180280380480580680780880981081181281381481581681781881982082182282382482582682782882983083183283383483583683783883984084184284384484584684784884985085185285385485585685785885986086186286386486586686786886987087187287387487587687787887988088188288388488588688788888989089189289389489589689789889990090190290390490590690790890991091191291391491591691791891992092192292392492592692792892993093193293393493593693793893994094194294394494594694794894995095195295395495595695795895996096196296396496596696796896997097197297397497597697797897998098198298398498598698798898999099199299399499599699799899910001001100210031004100510061007100810091010101110121013101410151016101710181019102010211022102310241025102610271028102910301031103210331034103510361037103810391040104110421043104410451046104710481049105010511052105310541055105610571058105910601061106210631064106510661067106810691070107110721073107410751076107710781079108010811082108310841085108610871088108910901091109210931094109510961097109810991100110111021103110411051106110711081109111011111112111311141115111611171118111911201121112211231124112511261127112811291130113111321133113411351136113711381139114011411142114311441145114611471148114911501151115211531154115511561157115811591160116111621163116411651166116711681169117011711172117311741175
  1. <template>
  2. <div class="app-container">
  3. <el-form
  4. :model="queryParams"
  5. ref="queryForm"
  6. size="small"
  7. :inline="true"
  8. v-show="showSearch"
  9. @submit.native.prevent
  10. >
  11. <el-form-item label="按钮组名" prop="btnGroupName">
  12. <el-input
  13. v-model="queryParams.btnGroupName"
  14. placeholder="请输入按钮组名"
  15. clearable
  16. @keyup.enter.native="handleQuery"
  17. />
  18. </el-form-item>
  19. <el-form-item label="按钮名称" prop="btnName">
  20. <el-input
  21. v-model="queryParams.btnName"
  22. placeholder="请输入按钮名称"
  23. clearable
  24. @keyup.enter.native="handleQuery"
  25. />
  26. </el-form-item>
  27. <el-form-item>
  28. <el-button
  29. type="primary"
  30. icon="el-icon-search"
  31. size="mini"
  32. @click="handleQuery"
  33. >搜索</el-button
  34. >
  35. <el-button icon="el-icon-refresh" size="mini" @click="resetQuery"
  36. >重置</el-button
  37. >
  38. </el-form-item>
  39. </el-form>
  40. <el-row :gutter="10" class="mb8">
  41. <el-col :span="1.5">
  42. <el-button
  43. type="primary"
  44. plain
  45. icon="el-icon-plus"
  46. size="mini"
  47. @click="handleAdd"
  48. v-hasPermi="['system:menu:add']"
  49. >新增</el-button
  50. >
  51. </el-col>
  52. <el-col :span="1.5">
  53. <el-button
  54. type="info"
  55. plain
  56. icon="el-icon-sort"
  57. size="mini"
  58. @click="toggleExpandAll"
  59. >展开/折叠</el-button
  60. >
  61. </el-col>
  62. <right-toolbar
  63. :showSearch.sync="showSearch"
  64. @queryTable="getList"
  65. ></right-toolbar>
  66. </el-row>
  67. <el-table
  68. v-if="refreshTable"
  69. v-loading="loading"
  70. :data="btnList"
  71. row-key="id"
  72. :default-expand-all="isExpandAll"
  73. :tree-props="{ children: 'children', hasChildren: 'hasChildren' }"
  74. >
  75. <el-table-column
  76. prop="btnGroupName"
  77. label="按钮组名称"
  78. :show-overflow-tooltip="true"
  79. width="160"
  80. align="center"
  81. ></el-table-column>
  82. <el-table-column prop="btnIcon" label="图标" align="center" width="100">
  83. <template v-if="scope.row.btnIcon" slot-scope="scope">
  84. <svg-icon :icon-class="scope.row.btnIcon" />
  85. </template>
  86. </el-table-column>
  87. <el-table-column
  88. prop="btnName"
  89. label="按钮名称"
  90. align="center"
  91. ></el-table-column>
  92. <el-table-column
  93. prop="btnSort"
  94. label="排序"
  95. align="center"
  96. width="60"
  97. ></el-table-column>
  98. <el-table-column
  99. prop="btnHasPermi"
  100. label="权限标识"
  101. :show-overflow-tooltip="true"
  102. align="center"
  103. ></el-table-column>
  104. <el-table-column
  105. label="操作"
  106. align="center"
  107. class-name="small-padding fixed-width"
  108. >
  109. <template slot-scope="scope">
  110. <el-dropdown>
  111. <el-button type="warning" plain size="small">
  112. 处理<i class="el-icon-arrow-down el-icon--right"></i>
  113. </el-button>
  114. <el-dropdown-menu slot="dropdown">
  115. <el-dropdown-item
  116. ><el-button
  117. size="mini"
  118. type="text"
  119. icon="el-icon-edit"
  120. @click="handleUpdate(scope.row)"
  121. v-hasPermi="['system:menu:edit']"
  122. >修改</el-button
  123. ></el-dropdown-item
  124. >
  125. <el-dropdown-item v-if="scope.row.btnType == 'DIRECTORY'"
  126. ><el-button
  127. size="mini"
  128. type="text"
  129. icon="el-icon-plus"
  130. @click="handleAdd(scope.row)"
  131. v-hasPermi="['system:menu:add']"
  132. >新增</el-button
  133. ></el-dropdown-item
  134. >
  135. <el-dropdown-item
  136. ><el-button
  137. size="mini"
  138. type="text"
  139. icon="el-icon-delete"
  140. @click="handleDelete(scope.row)"
  141. v-hasPermi="['system:menu:remove']"
  142. >删除</el-button
  143. ></el-dropdown-item
  144. >
  145. </el-dropdown-menu>
  146. </el-dropdown>
  147. <!-- <el-button
  148. size="mini"
  149. type="text"
  150. icon="el-icon-edit"
  151. @click="handleUpdate(scope.row)"
  152. v-hasPermi="['system:menu:edit']"
  153. >修改</el-button>
  154. <el-button
  155. size="mini"
  156. type="text"
  157. icon="el-icon-plus"
  158. @click="handleAdd(scope.row)"
  159. v-hasPermi="['system:menu:add']"
  160. >新增</el-button>
  161. <el-button
  162. size="mini"
  163. type="text"
  164. icon="el-icon-delete"
  165. @click="handleDelete(scope.row)"
  166. v-hasPermi="['system:menu:remove']"
  167. >删除</el-button> -->
  168. </template>
  169. </el-table-column>
  170. </el-table>
  171. <!-- 添加或修改对话框 -->
  172. <el-dialog :title="title" :visible.sync="open" width="680px" append-to-body>
  173. <el-form
  174. ref="btnGroupFormRef"
  175. :model="btnGroupFormData"
  176. :rules="rules"
  177. label-width="100px"
  178. >
  179. <el-row type="flex" style="flex-wrap: wrap">
  180. <el-col :span="12">
  181. <el-form-item label="上级按钮" prop="btnParentId">
  182. <treeselect
  183. v-model="btnGroupFormData.btnParentId"
  184. :options="menuOptions"
  185. :normalizer="normalizer"
  186. :show-count="true"
  187. placeholder="选择上级按钮"
  188. />
  189. </el-form-item>
  190. </el-col>
  191. <el-col :span="24" v-if="btnGroupFormData.btnParentId == 0">
  192. <el-form-item label="按钮组名" prop="btnGroupName">
  193. <el-input
  194. v-model="btnGroupFormData.btnGroupName"
  195. placeholder=""
  196. size="normal"
  197. ></el-input>
  198. </el-form-item>
  199. </el-col>
  200. <el-col :span="12">
  201. <el-form-item label="按钮名" prop="btnName">
  202. <el-input
  203. v-model="btnGroupFormData.btnName"
  204. placeholder=""
  205. size="normal"
  206. ></el-input>
  207. </el-form-item>
  208. </el-col>
  209. <el-col :span="12">
  210. <el-form-item label="按钮图标" prop="btnIcon">
  211. <el-popover
  212. placement="bottom-start"
  213. width="460"
  214. trigger="click"
  215. @show="$refs['iconSelect'].reset()"
  216. >
  217. <IconSelect
  218. ref="iconSelect"
  219. @selected="selected"
  220. :active-icon="btnGroupFormData.icon"
  221. />
  222. <el-input
  223. slot="reference"
  224. v-model="btnGroupFormData.icon"
  225. placeholder="点击选择图标"
  226. readonly
  227. >
  228. <svg-icon
  229. v-if="btnGroupFormData.btnIcon"
  230. slot="prefix"
  231. :icon-class="btnGroupFormData.btnIcon"
  232. style="width: 25px"
  233. />
  234. <i
  235. v-else
  236. slot="prefix"
  237. class="el-icon-search el-input__icon"
  238. />
  239. </el-input>
  240. </el-popover>
  241. </el-form-item>
  242. </el-col>
  243. <el-col :span="12">
  244. <el-form-item label="排序" prop="btnSort">
  245. <el-input-number
  246. v-model="btnGroupFormData.btnSort"
  247. controls-position="right"
  248. :min="0"
  249. />
  250. </el-form-item>
  251. </el-col>
  252. <el-col :span="12">
  253. <el-form-item label="权限标识" prop="btnIcon">
  254. <el-input
  255. v-model="btnGroupFormData.btnHasPermi"
  256. placeholder="请输入权限标识"
  257. maxlength="100"
  258. />
  259. <span slot="label">
  260. <el-tooltip
  261. content="控制器中定义的权限字符,如:@PreAuthorize(`@ss.hasPermi('system:user:list')`)"
  262. placement="top"
  263. >
  264. <i class="el-icon-question"></i>
  265. </el-tooltip>
  266. 权限字符
  267. </span>
  268. </el-form-item>
  269. </el-col>
  270. <el-col :span="12">
  271. <el-form-item label="按钮类型" prop="btnType">
  272. <el-select
  273. v-model="btnGroupFormData.btnType"
  274. placeholder="请选择按钮类型"
  275. filterable
  276. >
  277. <el-option
  278. v-for="item in btnTypeOptions"
  279. :key="item.value"
  280. :label="item.label"
  281. :value="item.value"
  282. >
  283. </el-option>
  284. </el-select>
  285. </el-form-item>
  286. </el-col>
  287. <!-- 非目录 -->
  288. <template v-if="btnGroupFormData.btnType != 'DIRECTORY'">
  289. <el-col
  290. :span="12"
  291. v-show="
  292. btnGroupFormData.btnType != 'DIRECTORY' &&
  293. btnGroupFormData.btnType != 'OUTLINK' &&
  294. btnGroupFormData.btnType != 'INNERLINK'
  295. "
  296. >
  297. <el-form-item label="绑定表单" prop="btnFormKey">
  298. <el-select
  299. v-model="btnGroupFormData.btnFormKey"
  300. placeholder="请选择表单"
  301. clearable
  302. filterable
  303. >
  304. <el-option
  305. v-for="item in formOptions"
  306. :key="item.fId"
  307. :label="item.dfName"
  308. :value="item.fId"
  309. >
  310. </el-option>
  311. </el-select>
  312. </el-form-item>
  313. </el-col>
  314. <el-col :span="12" v-show="btnGroupFormData.btnType == 'INITIATED'">
  315. <el-form-item label="执行流程" prop="btnProcessKey">
  316. <el-select
  317. v-model="btnGroupFormData.btnProcessKey"
  318. placeholder="请选择执行流程"
  319. clearable
  320. filterable
  321. >
  322. <el-option
  323. v-for="item in processOptions"
  324. :key="item.processKey"
  325. :label="item.processName"
  326. :value="item.processKey"
  327. >
  328. </el-option>
  329. </el-select>
  330. </el-form-item>
  331. </el-col>
  332. <el-col
  333. :span="12"
  334. v-show="
  335. btnGroupFormData.btnType == 'INSERT' ||
  336. btnGroupFormData.btnType == 'UPDATE' ||
  337. btnGroupFormData.btnType == 'DELETE'
  338. "
  339. >
  340. <el-form-item label="绑定表格" prop="btnTableKey">
  341. <el-select
  342. v-model="btnGroupFormData.btnTableKey"
  343. placeholder="请选择表格"
  344. clearable
  345. filterable
  346. >
  347. <el-option
  348. v-for="item in tableOptions"
  349. :key="item.tableKey"
  350. :label="item.dtName"
  351. :value="item.tableKey"
  352. >
  353. </el-option>
  354. </el-select>
  355. </el-form-item>
  356. </el-col>
  357. <el-col :span="12" v-show="btnGroupFormData.btnType == 'EXECUTE'">
  358. <el-form-item label="绑定脚本" prop="btnScriptKey">
  359. <el-select
  360. v-model="btnGroupFormData.btnScriptKey"
  361. placeholder="请选择绑定节点"
  362. clearable
  363. filterable
  364. >
  365. <el-option
  366. v-for="item in scriptOptions"
  367. :key="item.scriptKey"
  368. :label="item.scriptName"
  369. :value="item.scriptKey"
  370. >
  371. </el-option>
  372. </el-select>
  373. </el-form-item>
  374. </el-col>
  375. <el-col
  376. :span="24"
  377. v-show="
  378. btnGroupFormData.btnType == 3 || btnGroupFormData.btnType == 7
  379. "
  380. >
  381. <el-form-item label="跳转路由" prop="btnParams">
  382. <el-input
  383. v-model="btnGroupFormData.btnParams"
  384. placeholder="请输入跳转的路由地址"
  385. size="normal"
  386. ></el-input>
  387. </el-form-item>
  388. </el-col>
  389. <!-- <div class="table-wrap">
  390. <span class="title mb10">添加query参数</span>
  391. <el-table
  392. :data="queryTableData"
  393. border
  394. stripe
  395. style="width: 100%"
  396. >
  397. <el-table-column align="center" type="index" width="50" />
  398. <el-table-column
  399. v-for="col in columns"
  400. :prop="col.prop"
  401. :key="col.prop"
  402. :label="col.label"
  403. width="150"
  404. align="center"
  405. >
  406. <template slot-scope="scope">
  407. <el-input
  408. v-model="scope.row[col.prop]"
  409. placeholder=""
  410. size="normal"
  411. clearable
  412. ></el-input>
  413. </template>
  414. </el-table-column>
  415. <el-table-column label="操作" align="center">
  416. <template slot-scope="scope">
  417. <el-button
  418. size="mini"
  419. type="danger"
  420. icon="el-icon-delete"
  421. @click="deleteQueryItem(scope.$index)"
  422. >删除
  423. </el-button>
  424. </template>
  425. </el-table-column>
  426. </el-table>
  427. </div> -->
  428. <el-col :span="24">
  429. <!--
  430. v-show="
  431. btnGroupFormData.btnType != 3 && btnGroupFormData.btnType != 7
  432. " -->
  433. <!-- <el-form-item label="" prop="btnParams"> -->
  434. <div class="filter-table-wrap" style="width: 100%">
  435. <span class="title mb10"
  436. >{{
  437. btnGroupFormData.btnType != 3 &&
  438. btnGroupFormData.btnType != 7
  439. ? "公共"
  440. : "query"
  441. }}参数</span
  442. >
  443. <el-table :data="commonFieldData" style="width: 100%">
  444. <el-table-column label="序号" type="index" width="50">
  445. </el-table-column>
  446. <el-table-column
  447. prop="fieldName"
  448. label="字段名"
  449. width="150"
  450. align="center"
  451. >
  452. <template slot-scope="scope">
  453. <el-select
  454. v-model="scope.row.fieldName"
  455. placeholder="请选择"
  456. >
  457. <el-option
  458. v-for="item in rootFieldInfo.fieldList"
  459. :key="item.value"
  460. :label="item.value"
  461. :value="item.key"
  462. >
  463. <span style="float: left">{{ item.value }}</span>
  464. <span
  465. style="
  466. float: right;
  467. color: #8492a6;
  468. font-size: 13px;
  469. "
  470. >{{ item.key }}</span
  471. >
  472. </el-option>
  473. </el-select>
  474. </template>
  475. </el-table-column>
  476. <el-table-column
  477. prop="flagValue"
  478. label="默认值"
  479. width="150"
  480. align="center"
  481. >
  482. <template slot="header" slot-scope="">
  483. 默认值
  484. <el-tooltip
  485. class="item"
  486. effect="dark"
  487. content="不设置默认值时,默认为当前行的该字段"
  488. placement="top-start"
  489. >
  490. <i class="el-icon-info"></i>
  491. </el-tooltip>
  492. </template>
  493. <template slot-scope="scope">
  494. <!-- <el-button
  495. type="info"
  496. size="small"
  497. icon="el-icon-edit"
  498. @click="editFlagHandler(scope.row, scope.$index)"
  499. >
  500. </el-button> -->
  501. <el-input
  502. v-model="scope.row.fieldValue"
  503. placeholder="请输入默认值"
  504. size="normal"
  505. clearable
  506. >
  507. </el-input>
  508. </template>
  509. </el-table-column>
  510. <el-table-column label="操作" align="center">
  511. <template slot-scope="scope">
  512. <el-button
  513. size="mini"
  514. type="danger"
  515. icon="el-icon-delete"
  516. @click="deleteFilterItem(scope.$index)"
  517. >删除
  518. </el-button>
  519. </template>
  520. </el-table-column>
  521. </el-table>
  522. <el-button
  523. type="primary"
  524. class="inline-large-button mb10"
  525. icon="el-icon-plus"
  526. size="mini"
  527. style="width: 100%"
  528. @click="addFilterHandler"
  529. >
  530. 添加参数
  531. </el-button>
  532. </div>
  533. <!-- </el-form-item> -->
  534. </el-col>
  535. </template>
  536. </el-row>
  537. </el-form>
  538. <div slot="footer" class="dialog-footer">
  539. <el-button type="primary" @click="submitForm">确 定</el-button>
  540. <el-button @click="cancel">取 消</el-button>
  541. </div>
  542. </el-dialog>
  543. </div>
  544. </template>
  545. <script>
  546. import {
  547. listBtn,
  548. addBtn,
  549. getBtn,
  550. updateBtn,
  551. delBtn,
  552. checkBtn,
  553. } from "@/api/system/btn";
  554. import { listForm } from "@/api/dragform/form";
  555. import { listProcess } from "@/api/bpmprocess/process";
  556. import { listTable } from "@/api/dragform/tableList";
  557. import { listScript } from "@/api/bpmprocess/process";
  558. import Treeselect from "@riophae/vue-treeselect";
  559. import "@riophae/vue-treeselect/dist/vue-treeselect.css";
  560. import IconSelect from "@/components/IconSelect";
  561. import { v4 as uuidv4 } from "uuid";
  562. import { dragTableInfo } from "@/api/tablelist/commonTable";
  563. import { camelCase } from "@/utils";
  564. export default {
  565. name: "ExcuteBtnMange",
  566. dicts: ["sys_show_hide", "sys_normal_disable"],
  567. components: { Treeselect, IconSelect },
  568. data() {
  569. return {
  570. // 记录编辑状态
  571. editType: true, //true:新增 false:修改
  572. // 遮罩层
  573. loading: true,
  574. // 显示搜索条件
  575. showSearch: true,
  576. // 菜单表格树数据
  577. btnList: [],
  578. // 菜单树选项
  579. menuOptions: [],
  580. // 弹出层标题
  581. title: "",
  582. // 是否显示弹出层
  583. open: false,
  584. // 是否展开,默认全部折叠
  585. isExpandAll: false,
  586. // 重新渲染表格状态
  587. refreshTable: true,
  588. // 查询参数
  589. queryParams: {
  590. btnParentId: 0,
  591. btnGroupName: "",
  592. pageNum: 1,
  593. pageSize: 10,
  594. btnName: "",
  595. },
  596. // btnGroupName: "",
  597. // 分页数据
  598. total: 0,
  599. // 表单参数
  600. form: {},
  601. // 表单校验
  602. rules: {
  603. btnParentId: [
  604. { required: true, message: "上级按钮不能为空", trigger: "change" },
  605. ],
  606. btnGroupName: [
  607. { required: true, message: "按钮组名不能为空", trigger: "blur" },
  608. ],
  609. btnSort: [{ required: true, message: "排序不能为空", trigger: "blur" }],
  610. btnType: [
  611. {
  612. required: true,
  613. message: "按钮类型不能为空",
  614. trigger: "change",
  615. },
  616. ],
  617. btnFormKey: [
  618. {
  619. validator: this.checkBtnFormKey,
  620. trigger: "change",
  621. },
  622. ],
  623. btnProcessKey: [
  624. {
  625. validator: this.checkBtnProcessKey,
  626. trigger: "change",
  627. },
  628. ],
  629. btnScriptKey: [
  630. {
  631. validator: this.checkBtnScriptKey,
  632. trigger: "change",
  633. },
  634. ],
  635. },
  636. // 按钮组表单数据
  637. btnGroupFormData: {
  638. btnGroupName: "", //按钮组名
  639. btnParentId: "", //父节点id
  640. btnName: "", //按钮显示的文字
  641. btnIcon: "", //按钮图标
  642. btnType: "DIRECTORY", //0:操作按钮,1,其他,2表单,3内链,4流程,5脚本, 6,目录, 7:外链
  643. btnFormKey: null, //表单唯一标识
  644. btnProcessKey: "", //流程唯一标识
  645. btnTableKey: "", //表格唯一标识
  646. btnScriptKey: "", //脚本唯一标识
  647. btnShowCondition: "", //按钮显示条件
  648. btnParams: "", //操作参数
  649. btnHasPermi: "", //权限字符
  650. btnSort: 0, //按钮顺序
  651. btnKey: "",
  652. },
  653. conditionBtnData: [],
  654. btnTypeOptions: [
  655. // {
  656. // value: 0,
  657. // label: "操作按钮",
  658. // },
  659. // {
  660. // value: 1,
  661. // label: "其它",
  662. // },
  663. // {
  664. // value: 2,
  665. // label: "表单",
  666. // },
  667. // {
  668. // value: 3,
  669. // label: "内链",
  670. // },
  671. // {
  672. // value: 4,
  673. // label: "流程",
  674. // },
  675. // {
  676. // value: 5,
  677. // label: "脚本",
  678. // },
  679. {
  680. // value: "6",
  681. value: "DIRECTORY",
  682. label: "目录",
  683. },
  684. {
  685. // value: "7",
  686. value: "OUTLINK",
  687. label: "外链",
  688. },
  689. {
  690. // value: "3",
  691. value: "INNERLINK",
  692. label: "内链",
  693. },
  694. {
  695. value: "INSERT",
  696. label: "新增",
  697. },
  698. {
  699. // value: "8",
  700. value: "UPDATE",
  701. label: "修改",
  702. },
  703. {
  704. value: "DELETE",
  705. label: "删除",
  706. },
  707. {
  708. value: "EXECUTE",
  709. label: "执行脚本",
  710. },
  711. {
  712. value: "INITIATED",
  713. label: "发起流程",
  714. },
  715. ],
  716. formOptions: [],
  717. tableOptions: [],
  718. processOptions: [],
  719. scriptOptions: [],
  720. // 普遍字段参数
  721. commonFieldData: [
  722. // {
  723. // fieldName: "",
  724. // fieldValue: "",
  725. // },
  726. ],
  727. rootFieldInfo: {
  728. tableName: "",
  729. fieldList: [],
  730. },
  731. queryTableData: [
  732. {
  733. key: "",
  734. value: "",
  735. },
  736. ],
  737. columns: [
  738. {
  739. label: "参数名",
  740. prop: "key",
  741. },
  742. {
  743. label: "值",
  744. prop: "value",
  745. },
  746. ],
  747. };
  748. },
  749. // created() {
  750. // this.getList();
  751. // this.initFormSubData();
  752. // },
  753. mounted() {
  754. this.getList();
  755. this.initFormSubData();
  756. },
  757. methods: {
  758. // 自定义字段校验
  759. checkBtnFormKey(rule, value, callback) {
  760. let { btnType } = this.btnGroupFormData;
  761. console.log(btnType);
  762. if (btnType == "INSERT" || btnType == "UPDATE") {
  763. if (!value) {
  764. callback(new Error("请绑定表单"));
  765. }
  766. }
  767. callback();
  768. },
  769. checkBtnProcessKey(rule, value, callback) {
  770. let { btnType } = this.btnGroupFormData;
  771. console.log(btnType);
  772. if (btnType == "EXECUTE" || btnType == "INITIATED") {
  773. if (!value) {
  774. callback(new Error("请绑定流程"));
  775. }
  776. }
  777. callback();
  778. },
  779. checkBtnScriptKey(rule, value, callback) {
  780. let { btnType } = this.btnGroupFormData;
  781. console.log(btnType);
  782. if (btnType == "EXECUTE") {
  783. if (!value) {
  784. callback(new Error("请绑定脚本"));
  785. }
  786. }
  787. callback();
  788. },
  789. // 删除公共传参
  790. deleteFilterItem(index) {
  791. this.commonFieldData.splice(index, 1);
  792. },
  793. // 删除query参数
  794. deleteQueryItem(index) {
  795. this.queryTableData.splice(index, index);
  796. },
  797. // 添加公共传参
  798. addFilterHandler() {
  799. if (this.rootFieldInfo.fieldList.length == 0) {
  800. this.$message.error("请先将按钮组绑定给表格");
  801. return;
  802. }
  803. this.commonFieldData.push({
  804. fieldName: "",
  805. fieldValue: "",
  806. });
  807. },
  808. // 获取根节点绑定表格的字段数据
  809. async getRootFieldInfo(btnKey) {
  810. let res = await checkBtn({ btnKey });
  811. if (res.code == 200) {
  812. if (res.rows[0]?.tableKey) {
  813. let tableInfo = await dragTableInfo({
  814. queryMap: { tableKey: res.rows[0].tableKey },
  815. });
  816. this.rootFieldInfo.fieldList = this.columnsHandler(
  817. JSON.parse(tableInfo.data.resultMap.template.dtColumnName)
  818. );
  819. }
  820. }
  821. },
  822. // 处理列表信息
  823. columnsHandler(columns) {
  824. let resArr = [];
  825. columns.forEach((item) => {
  826. for (const key in item) {
  827. let tempObj = {};
  828. tempObj.key = camelCase(key);
  829. tempObj.value = item[key];
  830. resArr.push(tempObj);
  831. }
  832. });
  833. return resArr;
  834. },
  835. // 给所有节点设置根节点key
  836. setRootBtnKey(rows, rootKey = "") {
  837. if (rows.length == 0) {
  838. return rows;
  839. }
  840. for (let i = 0; i < rows.length; i++) {
  841. let row = rows[i];
  842. if (row.btnParentId == 0) {
  843. row.rootKey = row.btnKey;
  844. } else {
  845. row.rootKey = rootKey;
  846. }
  847. if (row.children.length != 0) {
  848. row.children = this.setRootBtnKey(row.children, row.rootKey);
  849. }
  850. }
  851. return rows;
  852. },
  853. // 选择图标
  854. selected(name) {
  855. this.btnGroupFormData.btnIcon = name;
  856. },
  857. /** 查询菜单列表 */
  858. getList() {
  859. this.loading = true;
  860. if (this.queryParams.btnGroupName || this.queryParams.btnName) {
  861. this.queryParams.btnParentId = null;
  862. } else {
  863. this.queryParams.btnParentId = 0;
  864. }
  865. listBtn(this.queryParams).then((response) => {
  866. let res = this.setRootBtnKey(response.rows);
  867. this.btnList = res;
  868. this.loading = false;
  869. });
  870. },
  871. /** 转换菜单数据结构 */
  872. normalizer(node) {
  873. // if (node.children && !node.children.length) {
  874. // delete node.children;
  875. // }
  876. return {
  877. id: node.id,
  878. label: node.btnName,
  879. children: node.children,
  880. };
  881. },
  882. /** 查询菜单下拉树结构 */
  883. getTreeselect() {
  884. listBtn({ ...this.queryParams, isEnablePaging: false }).then(
  885. (response) => {
  886. this.menuOptions = [];
  887. const btnTemp = {
  888. id: 0,
  889. btnGroupName: "新建按钮组",
  890. btnName: "新建按钮组",
  891. children: [],
  892. btnType: "DIRECTORY",
  893. };
  894. let _this = this;
  895. console.log(response.rows);
  896. let res = response.rows.filter((node) => _this.getAllMenuList(node));
  897. btnTemp.children.push(...res);
  898. this.menuOptions.push(btnTemp);
  899. }
  900. );
  901. },
  902. // 只保留目录
  903. getAllMenuList(node) {
  904. // 如果当前节点的btnType等于6,则保留该节点,否则删除该节点
  905. if (node.btnType == "DIRECTORY") {
  906. if (Array.isArray(node.children) && node.children.length != 0) {
  907. // 递归遍历子节点,并删除所有btnType不等于DIRECTORY的子节点
  908. let _this = this;
  909. node.children = node.children.filter((child) =>
  910. _this.getAllMenuList(child)
  911. );
  912. }
  913. return node;
  914. } else {
  915. return false;
  916. }
  917. },
  918. // 取消按钮
  919. cancel() {
  920. this.open = false;
  921. this.reset();
  922. },
  923. // 表单重置
  924. reset() {
  925. this.btnGroupFormData = {
  926. btnGroupName: "", //按钮组名
  927. btnParentId: "", //父节点id
  928. btnName: "", //按钮显示的文字
  929. btnIcon: "", //按钮图标
  930. btnType: "DIRECTORY", //0:操作按钮,1,其他,2表单,3跳转,4流程,5脚本
  931. btnFormKey: null, //表单唯一标识
  932. btnProcessKey: "", //流程唯一标识
  933. btnTableKey: "", //表格唯一标识
  934. btnScriptKey: "", //脚本唯一标识
  935. btnShowCondition: "", //按钮显示条件
  936. btnParams: "", //操作参数
  937. btnHasPermi: "", //权限字符
  938. btnSort: 0, //按钮顺序
  939. btnKey: "",
  940. };
  941. this.commonFieldData = [];
  942. this.resetForm("btnGroupFormRef");
  943. },
  944. /** 搜索按钮操作 */
  945. handleQuery() {
  946. this.getList();
  947. },
  948. /** 重置按钮操作 */
  949. resetQuery() {
  950. this.resetForm("queryForm");
  951. console.log(this.queryParams);
  952. this.handleQuery();
  953. },
  954. /** 新增按钮操作 */
  955. async handleAdd(row) {
  956. this.reset();
  957. this.getTreeselect();
  958. this.editType = row ? true : false;
  959. if (row != null && row.id) {
  960. //在已知节点下新增
  961. await this.getRootFieldInfo(row.rootKey);
  962. this.btnGroupFormData.btnParentId = row.id;
  963. this.title = "新增按钮";
  964. } else {
  965. this.btnGroupFormData.btnParentId = 0;
  966. this.title = "添加按钮组";
  967. }
  968. this.open = true;
  969. },
  970. /** 展开/折叠操作 */
  971. toggleExpandAll() {
  972. this.refreshTable = false;
  973. this.isExpandAll = !this.isExpandAll;
  974. this.$nextTick(() => {
  975. this.refreshTable = true;
  976. });
  977. },
  978. /** 修改按钮操作 */
  979. async handleUpdate(row) {
  980. this.reset();
  981. this.getTreeselect();
  982. this.editType = false;
  983. //在已知节点下新增
  984. await this.getRootFieldInfo(row.rootKey);
  985. getBtn(row.id).then((response) => {
  986. let { btnType, btnParams } = response.data;
  987. if ((btnType == 3 || btnType == 7) && btnParams) {
  988. //内链或外链
  989. let tempObj = JSON.parse(btnParams);
  990. response.data.btnParams = tempObj.url;
  991. this.commonFieldData = JSON.parse(tempObj.commonFieldData) || [];
  992. } else {
  993. btnParams && (this.commonFieldData = JSON.parse(btnParams) || []);
  994. }
  995. this.btnGroupFormData = response.data;
  996. this.open = true;
  997. this.title = "修改按钮";
  998. });
  999. },
  1000. // 校验复杂逻辑表单数据
  1001. myValidate(formData) {
  1002. // 校验按钮名和按钮必须填一个
  1003. let res = {};
  1004. res.flag = true;
  1005. let nameOrIcon = !!formData.btnName || !!formData.btnIcon;
  1006. if (!nameOrIcon) {
  1007. res.flag = false;
  1008. res.msg = "按钮名称和图标,至少需要有一个!";
  1009. return res;
  1010. }
  1011. return res;
  1012. },
  1013. // 获取公共数据
  1014. // getCommonData(list) {
  1015. // if (list.length == 0) return '';
  1016. // },
  1017. /** 提交按钮 */
  1018. submitForm() {
  1019. this.$refs["btnGroupFormRef"].validate(async (valid) => {
  1020. console.log(this.btnGroupFormData);
  1021. console.log(valid);
  1022. if (valid) {
  1023. let validateRes = this.myValidate(this.btnGroupFormData);
  1024. if (!validateRes.flag) {
  1025. this.$message.error(validateRes.msg);
  1026. return;
  1027. }
  1028. // 获取公共参数
  1029. // let commonData=this.getCommonData(this.commonFieldData)
  1030. if (
  1031. this.btnGroupFormData.btnType != 3 &&
  1032. this.btnGroupFormData.btnType != 7
  1033. ) {
  1034. this.btnGroupFormData.btnParams = JSON.stringify(
  1035. this.commonFieldData
  1036. );
  1037. } else {
  1038. let tempObj = {};
  1039. tempObj.url = this.btnGroupFormData.btnParams;
  1040. tempObj.commonFieldData = JSON.stringify(this.commonFieldData);
  1041. this.btnGroupFormData.btnParams = JSON.stringify(tempObj);
  1042. }
  1043. if (this.editType) {
  1044. // 新增按钮组
  1045. this.btnGroupFormData.btnKey = uuidv4();
  1046. let res = await addBtn(this.btnGroupFormData);
  1047. if (res.code == 200) {
  1048. this.$message.success("添加成功");
  1049. } else {
  1050. this.$message.error("网络异常,请稍后添加");
  1051. }
  1052. } else {
  1053. // 修改按钮组
  1054. let res = await updateBtn(this.btnGroupFormData);
  1055. if (res.code == 200) {
  1056. this.$message.success("修改成功");
  1057. } else {
  1058. this.$message.error("网络异常,请稍后修改");
  1059. }
  1060. }
  1061. this.getList();
  1062. this.open = false;
  1063. }
  1064. });
  1065. },
  1066. // 更新路由
  1067. reloadRouter() {
  1068. this.$store.dispatch("GenerateRoutes").then((accessRoutes) => {
  1069. this.$router.addRoutes(accessRoutes); // 动态添加可访问路由表
  1070. });
  1071. },
  1072. /** 删除按钮操作 */
  1073. handleDelete(row) {
  1074. this.$modal
  1075. .confirm('是否确认删除名称为"' + row.btnGroupName + '"的数据项?')
  1076. .then(function () {
  1077. return delBtn(row.id);
  1078. })
  1079. .then(() => {
  1080. this.getList();
  1081. this.$modal.msgSuccess("删除成功");
  1082. })
  1083. .catch(() => {});
  1084. },
  1085. // 初始化表单辅助数据
  1086. async initFormSubData() {
  1087. try {
  1088. //获取表单选项数据
  1089. let formRes = await listForm({ isEnablePaging: false });
  1090. if (formRes.code == 200) {
  1091. formRes.rows.forEach((item) => {
  1092. item.fId = item.fId.toString();
  1093. });
  1094. this.formOptions = formRes.rows;
  1095. } else {
  1096. this.$message.error("网络异常请稍后再试");
  1097. }
  1098. // 获取流程选项数据
  1099. let processRes = await listProcess({ isEnablePaging: false });
  1100. if (processRes.code == 200) {
  1101. this.processOptions = [
  1102. ...processRes.rows,
  1103. {
  1104. processKey: "unknown",
  1105. processName: "未知流程",
  1106. },
  1107. ];
  1108. } else {
  1109. this.$message.error("网络异常请稍后再试");
  1110. }
  1111. // 获取表格选项数据
  1112. let TableRes = await listTable({ isEnablePaging: false });
  1113. if (TableRes.code == 200) {
  1114. this.tableOptions = TableRes.rows;
  1115. } else {
  1116. this.$message.error("网络异常请稍后再试");
  1117. }
  1118. // 获取脚本选项数据
  1119. let scriptRes = await listScript({ isEnablePaging: false });
  1120. if (scriptRes.code == 200) {
  1121. this.scriptOptions = scriptRes.rows;
  1122. } else {
  1123. this.$message.error("网络异常请稍后再试");
  1124. }
  1125. } catch (error) {
  1126. console.log(error);
  1127. }
  1128. },
  1129. // 添加按钮条件
  1130. addConditionHandler() {
  1131. this.conditionBtnData.push({
  1132. tableName: "",
  1133. fieldName: "",
  1134. condition: 1, //1:> 2:< 3:= 4:>= 5:<=
  1135. flagValue: 0,
  1136. fieldList: [],
  1137. });
  1138. },
  1139. },
  1140. };
  1141. </script>
  1142. <style scoped lang="scss" scoped>
  1143. /* #app .sidebar-container .submenu-title-noDropdown:hover, #app .sidebar-container .el-submenu__title:hover {
  1144. background-color: rgba(0, 0, 0, 0.06) !important;
  1145. } */
  1146. .submenu-title-noDropdown:hover {
  1147. background-color: linear-gradient(to right, blue, rgb(69, 118, 225));
  1148. }
  1149. .filter-table-wrap {
  1150. display: flex;
  1151. flex-direction: column;
  1152. align-items: center;
  1153. }
  1154. .table-wrap {
  1155. width: 100%;
  1156. display: flex;
  1157. flex-direction: column;
  1158. align-items: center;
  1159. }
  1160. .title {
  1161. font-weight: 600;
  1162. }
  1163. </style>