index.vue 41 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394959697989910010110210310410510610710810911011111211311411511611711811912012112212312412512612712812913013113213313413513613713813914014114214314414514614714814915015115215315415515615715815916016116216316416516616716816917017117217317417517617717817918018118218318418518618718818919019119219319419519619719819920020120220320420520620720820921021121221321421521621721821922022122222322422522622722822923023123223323423523623723823924024124224324424524624724824925025125225325425525625725825926026126226326426526626726826927027127227327427527627727827928028128228328428528628728828929029129229329429529629729829930030130230330430530630730830931031131231331431531631731831932032132232332432532632732832933033133233333433533633733833934034134234334434534634734834935035135235335435535635735835936036136236336436536636736836937037137237337437537637737837938038138238338438538638738838939039139239339439539639739839940040140240340440540640740840941041141241341441541641741841942042142242342442542642742842943043143243343443543643743843944044144244344444544644744844945045145245345445545645745845946046146246346446546646746846947047147247347447547647747847948048148248348448548648748848949049149249349449549649749849950050150250350450550650750850951051151251351451551651751851952052152252352452552652752852953053153253353453553653753853954054154254354454554654754854955055155255355455555655755855956056156256356456556656756856957057157257357457557657757857958058158258358458558658758858959059159259359459559659759859960060160260360460560660760860961061161261361461561661761861962062162262362462562662762862963063163263363463563663763863964064164264364464564664764864965065165265365465565665765865966066166266366466566666766866967067167267367467567667767867968068168268368468568668768868969069169269369469569669769869970070170270370470570670770870971071171271371471571671771871972072172272372472572672772872973073173273373473573673773873974074174274374474574674774874975075175275375475575675775875976076176276376476576676776876977077177277377477577677777877978078178278378478578678778878979079179279379479579679779879980080180280380480580680780880981081181281381481581681781881982082182282382482582682782882983083183283383483583683783883984084184284384484584684784884985085185285385485585685785885986086186286386486586686786886987087187287387487587687787887988088188288388488588688788888989089189289389489589689789889990090190290390490590690790890991091191291391491591691791891992092192292392492592692792892993093193293393493593693793893994094194294394494594694794894995095195295395495595695795895996096196296396496596696796896997097197297397497597697797897998098198298398498598698798898999099199299399499599699799899910001001100210031004100510061007100810091010101110121013101410151016101710181019102010211022102310241025102610271028102910301031103210331034103510361037103810391040104110421043104410451046104710481049105010511052105310541055105610571058105910601061106210631064106510661067106810691070107110721073107410751076107710781079108010811082108310841085108610871088108910901091109210931094109510961097109810991100110111021103110411051106110711081109111011111112111311141115111611171118111911201121112211231124112511261127112811291130113111321133113411351136113711381139114011411142114311441145114611471148114911501151115211531154115511561157115811591160116111621163116411651166116711681169117011711172117311741175117611771178117911801181118211831184118511861187118811891190119111921193119411951196119711981199120012011202120312041205120612071208120912101211121212131214121512161217121812191220122112221223122412251226122712281229123012311232123312341235123612371238123912401241124212431244124512461247124812491250125112521253125412551256125712581259126012611262126312641265126612671268126912701271127212731274127512761277127812791280128112821283128412851286128712881289129012911292129312941295129612971298129913001301130213031304130513061307130813091310131113121313
  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. <!-- 按钮隐藏条件 -->
  537. <div class="filter-table-wrap" style="width: 100%">
  538. <span class="title mb10">按钮隐藏条件</span>
  539. <el-table :data="btnHidenCondtionData" style="width: 100%">
  540. <el-table-column label="序号" type="index" width="50">
  541. </el-table-column>
  542. <el-table-column
  543. prop="fieldName"
  544. label="字段名"
  545. width="150"
  546. align="center"
  547. >
  548. <template slot-scope="scope">
  549. <el-select v-model="scope.row.fieldName" placeholder="请选择">
  550. <el-option
  551. v-for="item in rootFieldInfo.fieldList"
  552. :key="item.value"
  553. :label="item.value"
  554. :value="item.key"
  555. >
  556. <span style="float: left">{{ item.value }}</span>
  557. <span
  558. style="float: right; color: #8492a6; font-size: 13px"
  559. >{{ item.key }}</span
  560. >
  561. </el-option>
  562. </el-select>
  563. </template>
  564. </el-table-column>
  565. <el-table-column
  566. prop="mark"
  567. label="符号"
  568. width="150"
  569. align="center"
  570. >
  571. <template slot-scope="scope">
  572. <el-select v-model="scope.row.mark" placeholder="请选择">
  573. <el-option
  574. v-for="item in markList"
  575. :key="item"
  576. :label="item"
  577. :value="item"
  578. ></el-option>
  579. </el-select>
  580. </template>
  581. </el-table-column>
  582. <el-table-column
  583. prop="refValue"
  584. label="参考值"
  585. width="150"
  586. align="center"
  587. >
  588. <template slot-scope="scope">
  589. <!-- <el-button
  590. type="info"
  591. size="small"
  592. icon="el-icon-edit"
  593. @click="editFlagHandler(scope.row, scope.$index)"
  594. >
  595. </el-button> -->
  596. <el-input
  597. v-model="scope.row.refValue"
  598. placeholder="请输入默认值"
  599. size="normal"
  600. clearable
  601. >
  602. </el-input>
  603. </template>
  604. </el-table-column>
  605. <el-table-column label="操作" align="center">
  606. <template slot-scope="scope">
  607. <el-button
  608. size="mini"
  609. type="danger"
  610. icon="el-icon-delete"
  611. @click="deleteBtnHidenCondition(scope.$index)"
  612. >删除
  613. </el-button>
  614. </template>
  615. </el-table-column>
  616. </el-table>
  617. <el-button
  618. type="primary"
  619. class="inline-large-button mb10"
  620. icon="el-icon-plus"
  621. size="mini"
  622. style="width: 100%"
  623. @click="addBtnHidenCondition"
  624. >
  625. 添加参数
  626. </el-button>
  627. </div>
  628. </el-row>
  629. </el-form>
  630. <div slot="footer" class="dialog-footer">
  631. <el-button type="primary" @click="submitForm">确 定</el-button>
  632. <el-button @click="cancel">取 消</el-button>
  633. </div>
  634. </el-dialog>
  635. </div>
  636. </template>
  637. <script>
  638. import {
  639. listBtn,
  640. addBtn,
  641. getBtn,
  642. updateBtn,
  643. delBtn,
  644. checkBtn,
  645. } from "@/api/system/btn";
  646. import { listForm } from "@/api/dragform/form";
  647. import { listProcess } from "@/api/bpmprocess/process";
  648. import { listTable } from "@/api/dragform/tableList";
  649. import { listScript } from "@/api/bpmprocess/process";
  650. import Treeselect from "@riophae/vue-treeselect";
  651. import "@riophae/vue-treeselect/dist/vue-treeselect.css";
  652. import IconSelect from "@/components/IconSelect";
  653. import { v4 as uuidv4 } from "uuid";
  654. import { dragTableInfo } from "@/api/tablelist/commonTable";
  655. import { camelCase } from "@/utils";
  656. import { mark } from "@/components/updateModule/k-form-design/lib/k-form-design.common";
  657. export default {
  658. name: "ExcuteBtnMange",
  659. dicts: ["sys_show_hide", "sys_normal_disable"],
  660. components: { Treeselect, IconSelect },
  661. data() {
  662. return {
  663. // 记录编辑状态
  664. editType: true, //true:新增 false:修改
  665. // 遮罩层
  666. loading: true,
  667. // 显示搜索条件
  668. showSearch: true,
  669. // 菜单表格树数据
  670. btnList: [],
  671. // 菜单树选项
  672. menuOptions: [],
  673. // 弹出层标题
  674. title: "",
  675. // 是否显示弹出层
  676. open: false,
  677. // 是否展开,默认全部折叠
  678. isExpandAll: false,
  679. // 重新渲染表格状态
  680. refreshTable: true,
  681. // 查询参数
  682. queryParams: {
  683. btnParentId: 0,
  684. btnGroupName: "",
  685. pageNum: 1,
  686. pageSize: 10,
  687. btnName: "",
  688. },
  689. // btnGroupName: "",
  690. // 分页数据
  691. total: 0,
  692. // 表单参数
  693. form: {},
  694. // 表单校验
  695. rules: {
  696. btnParentId: [
  697. { required: true, message: "上级按钮不能为空", trigger: "change" },
  698. ],
  699. btnGroupName: [
  700. { required: true, message: "按钮组名不能为空", trigger: "blur" },
  701. ],
  702. btnSort: [{ required: true, message: "排序不能为空", trigger: "blur" }],
  703. btnType: [
  704. {
  705. required: true,
  706. message: "按钮类型不能为空",
  707. trigger: "change",
  708. },
  709. ],
  710. btnFormKey: [
  711. {
  712. validator: this.checkBtnFormKey,
  713. trigger: "change",
  714. },
  715. ],
  716. btnProcessKey: [
  717. {
  718. validator: this.checkBtnProcessKey,
  719. trigger: "change",
  720. },
  721. ],
  722. btnScriptKey: [
  723. {
  724. validator: this.checkBtnScriptKey,
  725. trigger: "change",
  726. },
  727. ],
  728. },
  729. // 按钮组表单数据
  730. btnGroupFormData: {
  731. btnGroupName: "", //按钮组名
  732. btnParentId: "", //父节点id
  733. btnName: "", //按钮显示的文字
  734. btnIcon: "", //按钮图标
  735. btnType: "DIRECTORY", //0:操作按钮,1,其他,2表单,3内链,4流程,5脚本, 6,目录, 7:外链
  736. btnFormKey: null, //表单唯一标识
  737. btnProcessKey: "", //流程唯一标识
  738. btnTableKey: "", //表格唯一标识
  739. btnScriptKey: "", //脚本唯一标识
  740. btnShowCondition: "", //按钮显示条件
  741. btnParams: "", //操作参数
  742. btnHasPermi: "", //权限字符
  743. btnSort: 0, //按钮顺序
  744. btnKey: "",
  745. },
  746. conditionBtnData: [],
  747. btnTypeOptions: [
  748. // {
  749. // value: 0,
  750. // label: "操作按钮",
  751. // },
  752. // {
  753. // value: 1,
  754. // label: "其它",
  755. // },
  756. // {
  757. // value: 2,
  758. // label: "表单",
  759. // },
  760. // {
  761. // value: 3,
  762. // label: "内链",
  763. // },
  764. // {
  765. // value: 4,
  766. // label: "流程",
  767. // },
  768. // {
  769. // value: 5,
  770. // label: "脚本",
  771. // },
  772. {
  773. // value: "6",
  774. value: "DIRECTORY",
  775. label: "目录",
  776. },
  777. {
  778. // value: "7",
  779. value: "OUTLINK",
  780. label: "外链",
  781. },
  782. {
  783. // value: "3",
  784. value: "INNERLINK",
  785. label: "内链",
  786. },
  787. {
  788. value: "INSERT",
  789. label: "新增",
  790. },
  791. {
  792. // value: "8",
  793. value: "UPDATE",
  794. label: "修改",
  795. },
  796. {
  797. value: "DELETE",
  798. label: "删除",
  799. },
  800. {
  801. value: "EXECUTE",
  802. label: "执行脚本",
  803. },
  804. {
  805. value: "INITIATED",
  806. label: "发起流程",
  807. },
  808. ],
  809. formOptions: [],
  810. tableOptions: [],
  811. processOptions: [],
  812. scriptOptions: [],
  813. // 普遍字段参数
  814. commonFieldData: [
  815. // {
  816. // fieldName: "",
  817. // fieldValue: "",
  818. // },
  819. ],
  820. // 按钮隐藏条件
  821. btnHidenCondtionData: [
  822. // {
  823. // fieldName: "", //参考字段
  824. // mark: "", //参考符号
  825. // refValue: "", //参考值
  826. // },
  827. ],
  828. rootFieldInfo: {
  829. tableName: "",
  830. fieldList: [],
  831. },
  832. queryTableData: [
  833. {
  834. key: "",
  835. value: "",
  836. },
  837. ],
  838. columns: [
  839. {
  840. label: "参数名",
  841. prop: "key",
  842. },
  843. {
  844. label: "值",
  845. prop: "value",
  846. },
  847. ],
  848. markList: [">", "<", "=", ">=", "<=", "!="],
  849. };
  850. },
  851. // created() {
  852. // this.getList();
  853. // this.initFormSubData();
  854. // },
  855. mounted() {
  856. this.getList();
  857. this.initFormSubData();
  858. },
  859. methods: {
  860. // 自定义字段校验
  861. checkBtnFormKey(rule, value, callback) {
  862. let { btnType } = this.btnGroupFormData;
  863. console.log(btnType);
  864. if (btnType == "INSERT" || btnType == "UPDATE") {
  865. if (!value) {
  866. callback(new Error("请绑定表单"));
  867. }
  868. }
  869. callback();
  870. },
  871. checkBtnProcessKey(rule, value, callback) {
  872. let { btnType } = this.btnGroupFormData;
  873. console.log(btnType);
  874. if (btnType == "EXECUTE" || btnType == "INITIATED") {
  875. if (!value) {
  876. callback(new Error("请绑定流程"));
  877. }
  878. }
  879. callback();
  880. },
  881. checkBtnScriptKey(rule, value, callback) {
  882. let { btnType } = this.btnGroupFormData;
  883. console.log(btnType);
  884. if (btnType == "EXECUTE") {
  885. if (!value) {
  886. callback(new Error("请绑定脚本"));
  887. }
  888. }
  889. callback();
  890. },
  891. // 删除公共传参
  892. deleteFilterItem(index) {
  893. this.commonFieldData.splice(index, 1);
  894. },
  895. // 删除query参数
  896. deleteQueryItem(index) {
  897. this.queryTableData.splice(index, 1);
  898. },
  899. // 添加公共传参
  900. addFilterHandler() {
  901. if (this.rootFieldInfo.fieldList.length == 0) {
  902. this.$message.error("请先将按钮组绑定给表格");
  903. return;
  904. }
  905. this.commonFieldData.push({
  906. fieldName: "",
  907. fieldValue: "",
  908. });
  909. },
  910. // 添加按钮隐藏条件
  911. addBtnHidenCondition() {
  912. if (this.rootFieldInfo.fieldList.length == 0) {
  913. this.$message.error("请先将按钮组绑定给表格");
  914. return;
  915. }
  916. this.btnHidenCondtionData.push({
  917. fieldName: "", //参考字段
  918. mark: "", //参考符号
  919. refValue: "", //参考值
  920. });
  921. },
  922. // 删除按钮隐藏条件
  923. deleteBtnHidenCondition(index) {
  924. this.btnHidenCondtionData.splice(index, 1);
  925. },
  926. // 获取根节点绑定表格的字段数据
  927. async getRootFieldInfo(btnKey) {
  928. let res = await checkBtn({ btnKey });
  929. if (res.code == 200) {
  930. if (res.rows[0]?.tableKey) {
  931. let tableInfo = await dragTableInfo({
  932. queryMap: { tableKey: res.rows[0].tableKey },
  933. });
  934. this.rootFieldInfo.fieldList = this.columnsHandler(
  935. JSON.parse(tableInfo.data.resultMap.template.dtColumnName)
  936. );
  937. }
  938. }
  939. },
  940. // 处理列表信息
  941. columnsHandler(columns) {
  942. let resArr = [];
  943. columns.forEach((item) => {
  944. for (const key in item) {
  945. let tempObj = {};
  946. tempObj.key = camelCase(key);
  947. tempObj.value = item[key];
  948. resArr.push(tempObj);
  949. }
  950. });
  951. return resArr;
  952. },
  953. // 给所有节点设置根节点key
  954. setRootBtnKey(rows, rootKey = "") {
  955. if (rows.length == 0) {
  956. return rows;
  957. }
  958. for (let i = 0; i < rows.length; i++) {
  959. let row = rows[i];
  960. if (row.btnParentId == 0) {
  961. row.rootKey = row.btnKey;
  962. } else {
  963. row.rootKey = rootKey;
  964. }
  965. if (row.children.length != 0) {
  966. row.children = this.setRootBtnKey(row.children, row.rootKey);
  967. }
  968. }
  969. return rows;
  970. },
  971. // 选择图标
  972. selected(name) {
  973. this.btnGroupFormData.btnIcon = name;
  974. },
  975. /** 查询菜单列表 */
  976. getList() {
  977. this.loading = true;
  978. if (this.queryParams.btnGroupName || this.queryParams.btnName) {
  979. this.queryParams.btnParentId = null;
  980. } else {
  981. this.queryParams.btnParentId = 0;
  982. }
  983. listBtn(this.queryParams).then((response) => {
  984. let res = this.setRootBtnKey(response.rows);
  985. this.btnList = res;
  986. this.loading = false;
  987. });
  988. },
  989. /** 转换菜单数据结构 */
  990. normalizer(node) {
  991. // if (node.children && !node.children.length) {
  992. // delete node.children;
  993. // }
  994. return {
  995. id: node.id,
  996. label: node.btnName,
  997. children: node.children,
  998. };
  999. },
  1000. /** 查询菜单下拉树结构 */
  1001. getTreeselect() {
  1002. listBtn({ ...this.queryParams, isEnablePaging: false }).then(
  1003. (response) => {
  1004. this.menuOptions = [];
  1005. const btnTemp = {
  1006. id: 0,
  1007. btnGroupName: "新建按钮组",
  1008. btnName: "新建按钮组",
  1009. children: [],
  1010. btnType: "DIRECTORY",
  1011. };
  1012. let _this = this;
  1013. console.log(response.rows);
  1014. let res = response.rows.filter((node) => _this.getAllMenuList(node));
  1015. btnTemp.children.push(...res);
  1016. this.menuOptions.push(btnTemp);
  1017. }
  1018. );
  1019. },
  1020. // 只保留目录
  1021. getAllMenuList(node) {
  1022. // 如果当前节点的btnType等于6,则保留该节点,否则删除该节点
  1023. if (node.btnType == "DIRECTORY") {
  1024. if (Array.isArray(node.children) && node.children.length != 0) {
  1025. // 递归遍历子节点,并删除所有btnType不等于DIRECTORY的子节点
  1026. let _this = this;
  1027. node.children = node.children.filter((child) =>
  1028. _this.getAllMenuList(child)
  1029. );
  1030. }
  1031. return node;
  1032. } else {
  1033. return false;
  1034. }
  1035. },
  1036. // 取消按钮
  1037. cancel() {
  1038. this.open = false;
  1039. this.reset();
  1040. },
  1041. // 表单重置
  1042. reset() {
  1043. this.btnGroupFormData = {
  1044. btnGroupName: "", //按钮组名
  1045. btnParentId: "", //父节点id
  1046. btnName: "", //按钮显示的文字
  1047. btnIcon: "", //按钮图标
  1048. btnType: "DIRECTORY", //0:操作按钮,1,其他,2表单,3跳转,4流程,5脚本
  1049. btnFormKey: null, //表单唯一标识
  1050. btnProcessKey: "", //流程唯一标识
  1051. btnTableKey: "", //表格唯一标识
  1052. btnScriptKey: "", //脚本唯一标识
  1053. btnShowCondition: "", //按钮显示条件
  1054. btnParams: "", //操作参数
  1055. btnHasPermi: "", //权限字符
  1056. btnSort: 0, //按钮顺序
  1057. btnKey: "",
  1058. };
  1059. this.commonFieldData = [];
  1060. this.resetForm("btnGroupFormRef");
  1061. },
  1062. /** 搜索按钮操作 */
  1063. handleQuery() {
  1064. this.getList();
  1065. },
  1066. /** 重置按钮操作 */
  1067. resetQuery() {
  1068. this.resetForm("queryForm");
  1069. console.log(this.queryParams);
  1070. this.handleQuery();
  1071. },
  1072. /** 新增按钮操作 */
  1073. async handleAdd(row) {
  1074. this.reset();
  1075. this.getTreeselect();
  1076. this.editType = row ? true : false;
  1077. if (row != null && row.id) {
  1078. //在已知节点下新增
  1079. await this.getRootFieldInfo(row.rootKey);
  1080. this.btnGroupFormData.btnParentId = row.id;
  1081. this.title = "新增按钮";
  1082. } else {
  1083. this.btnGroupFormData.btnParentId = 0;
  1084. this.title = "添加按钮组";
  1085. }
  1086. this.open = true;
  1087. },
  1088. /** 展开/折叠操作 */
  1089. toggleExpandAll() {
  1090. this.refreshTable = false;
  1091. this.isExpandAll = !this.isExpandAll;
  1092. this.$nextTick(() => {
  1093. this.refreshTable = true;
  1094. });
  1095. },
  1096. /** 修改按钮操作 */
  1097. async handleUpdate(row) {
  1098. this.reset();
  1099. this.getTreeselect();
  1100. this.editType = false;
  1101. //在已知节点下新增
  1102. await this.getRootFieldInfo(row.rootKey);
  1103. getBtn(row.id).then((response) => {
  1104. let { btnType, btnParams, btnShowCondition } = response.data;
  1105. if ((btnType == 3 || btnType == 7) && btnParams) {
  1106. //内链或外链
  1107. let tempObj = JSON.parse(btnParams);
  1108. response.data.btnParams = tempObj.url;
  1109. this.commonFieldData = JSON.parse(tempObj.commonFieldData) || [];
  1110. } else {
  1111. btnParams && (this.commonFieldData = JSON.parse(btnParams) || []);
  1112. }
  1113. this.btnHidenCondtionData = [];
  1114. if (btnShowCondition) {
  1115. this.btnHidenCondtionData = JSON.parse(btnShowCondition);
  1116. }
  1117. this.btnGroupFormData = response.data;
  1118. this.open = true;
  1119. this.title = "修改按钮";
  1120. });
  1121. },
  1122. // 校验复杂逻辑表单数据
  1123. myValidate(formData) {
  1124. // 校验按钮名和按钮必须填一个
  1125. let res = {};
  1126. res.flag = true;
  1127. let nameOrIcon = !!formData.btnName || !!formData.btnIcon;
  1128. if (!nameOrIcon) {
  1129. res.flag = false;
  1130. res.msg = "按钮名称和图标,至少需要有一个!";
  1131. return res;
  1132. }
  1133. return res;
  1134. },
  1135. // 获取公共数据
  1136. // getCommonData(list) {
  1137. // if (list.length == 0) return '';
  1138. // },
  1139. /** 提交按钮 */
  1140. submitForm() {
  1141. this.$refs["btnGroupFormRef"].validate(async (valid) => {
  1142. console.log(this.btnGroupFormData);
  1143. console.log(valid);
  1144. if (valid) {
  1145. let validateRes = this.myValidate(this.btnGroupFormData);
  1146. if (!validateRes.flag) {
  1147. this.$message.error(validateRes.msg);
  1148. return;
  1149. }
  1150. // 获取公共参数
  1151. // let commonData=this.getCommonData(this.commonFieldData)
  1152. if (
  1153. this.btnGroupFormData.btnType != 3 &&
  1154. this.btnGroupFormData.btnType != 7
  1155. ) {
  1156. this.btnGroupFormData.btnParams = JSON.stringify(
  1157. this.commonFieldData
  1158. );
  1159. } else {
  1160. let tempObj = {};
  1161. tempObj.url = this.btnGroupFormData.btnParams;
  1162. tempObj.commonFieldData = JSON.stringify(this.commonFieldData);
  1163. this.btnGroupFormData.btnParams = JSON.stringify(tempObj);
  1164. }
  1165. this.btnGroupFormData.btnShowCondition = this.getHidenConditions();
  1166. console.log(this.btnGroupFormData.btnShowCondition);
  1167. if (this.editType) {
  1168. // 新增按钮组
  1169. this.btnGroupFormData.btnKey = uuidv4();
  1170. let res = await addBtn(this.btnGroupFormData);
  1171. if (res.code == 200) {
  1172. this.$message.success("添加成功");
  1173. } else {
  1174. this.$message.error("网络异常,请稍后添加");
  1175. }
  1176. } else {
  1177. // 修改按钮组
  1178. let res = await updateBtn(this.btnGroupFormData);
  1179. if (res.code == 200) {
  1180. this.$message.success("修改成功");
  1181. } else {
  1182. this.$message.error("网络异常,请稍后修改");
  1183. }
  1184. }
  1185. this.getList();
  1186. this.open = false;
  1187. }
  1188. });
  1189. },
  1190. // 格式化按钮隐藏条件
  1191. getHidenConditions() {
  1192. console.log(this.btnHidenCondtionData);
  1193. if (this.btnHidenCondtionData.length == 0) return "";
  1194. let temp = this.btnHidenCondtionData.filter((item) => {
  1195. return item.fieldName && item.mark && item.refValue;
  1196. });
  1197. if (temp.length > 0) {
  1198. return JSON.stringify(temp);
  1199. } else {
  1200. return "";
  1201. }
  1202. },
  1203. // 更新路由
  1204. reloadRouter() {
  1205. this.$store.dispatch("GenerateRoutes").then((accessRoutes) => {
  1206. this.$router.addRoutes(accessRoutes); // 动态添加可访问路由表
  1207. });
  1208. },
  1209. /** 删除按钮操作 */
  1210. handleDelete(row) {
  1211. this.$modal
  1212. .confirm('是否确认删除名称为"' + row.btnGroupName + '"的数据项?')
  1213. .then(function () {
  1214. return delBtn(row.id);
  1215. })
  1216. .then(() => {
  1217. this.getList();
  1218. this.$modal.msgSuccess("删除成功");
  1219. })
  1220. .catch(() => {});
  1221. },
  1222. // 初始化表单辅助数据
  1223. async initFormSubData() {
  1224. try {
  1225. //获取表单选项数据
  1226. let formRes = await listForm({ isEnablePaging: false });
  1227. if (formRes.code == 200) {
  1228. formRes.rows.forEach((item) => {
  1229. item.fId = item.fId.toString();
  1230. });
  1231. this.formOptions = formRes.rows;
  1232. } else {
  1233. this.$message.error("网络异常请稍后再试");
  1234. }
  1235. // 获取流程选项数据
  1236. let processRes = await listProcess({ isEnablePaging: false });
  1237. if (processRes.code == 200) {
  1238. this.processOptions = [
  1239. ...processRes.rows,
  1240. {
  1241. processKey: "unknown",
  1242. processName: "未知流程",
  1243. },
  1244. ];
  1245. } else {
  1246. this.$message.error("网络异常请稍后再试");
  1247. }
  1248. // 获取表格选项数据
  1249. let TableRes = await listTable({ isEnablePaging: false });
  1250. if (TableRes.code == 200) {
  1251. this.tableOptions = TableRes.rows;
  1252. } else {
  1253. this.$message.error("网络异常请稍后再试");
  1254. }
  1255. // 获取脚本选项数据
  1256. let scriptRes = await listScript({ isEnablePaging: false });
  1257. if (scriptRes.code == 200) {
  1258. this.scriptOptions = scriptRes.rows;
  1259. } else {
  1260. this.$message.error("网络异常请稍后再试");
  1261. }
  1262. } catch (error) {
  1263. console.log(error);
  1264. }
  1265. },
  1266. // 添加按钮条件
  1267. addConditionHandler() {
  1268. this.conditionBtnData.push({
  1269. tableName: "",
  1270. fieldName: "",
  1271. condition: 1, //1:> 2:< 3:= 4:>= 5:<=
  1272. flagValue: 0,
  1273. fieldList: [],
  1274. });
  1275. },
  1276. },
  1277. };
  1278. </script>
  1279. <style scoped lang="scss" scoped>
  1280. /* #app .sidebar-container .submenu-title-noDropdown:hover, #app .sidebar-container .el-submenu__title:hover {
  1281. background-color: rgba(0, 0, 0, 0.06) !important;
  1282. } */
  1283. .submenu-title-noDropdown:hover {
  1284. background-color: linear-gradient(to right, blue, rgb(69, 118, 225));
  1285. }
  1286. .filter-table-wrap {
  1287. display: flex;
  1288. flex-direction: column;
  1289. align-items: center;
  1290. }
  1291. .table-wrap {
  1292. width: 100%;
  1293. display: flex;
  1294. flex-direction: column;
  1295. align-items: center;
  1296. }
  1297. .title {
  1298. font-weight: 600;
  1299. }
  1300. </style>