index.vue 70 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394959697989910010110210310410510610710810911011111211311411511611711811912012112212312412512612712812913013113213313413513613713813914014114214314414514614714814915015115215315415515615715815916016116216316416516616716816917017117217317417517617717817918018118218318418518618718818919019119219319419519619719819920020120220320420520620720820921021121221321421521621721821922022122222322422522622722822923023123223323423523623723823924024124224324424524624724824925025125225325425525625725825926026126226326426526626726826927027127227327427527627727827928028128228328428528628728828929029129229329429529629729829930030130230330430530630730830931031131231331431531631731831932032132232332432532632732832933033133233333433533633733833934034134234334434534634734834935035135235335435535635735835936036136236336436536636736836937037137237337437537637737837938038138238338438538638738838939039139239339439539639739839940040140240340440540640740840941041141241341441541641741841942042142242342442542642742842943043143243343443543643743843944044144244344444544644744844945045145245345445545645745845946046146246346446546646746846947047147247347447547647747847948048148248348448548648748848949049149249349449549649749849950050150250350450550650750850951051151251351451551651751851952052152252352452552652752852953053153253353453553653753853954054154254354454554654754854955055155255355455555655755855956056156256356456556656756856957057157257357457557657757857958058158258358458558658758858959059159259359459559659759859960060160260360460560660760860961061161261361461561661761861962062162262362462562662762862963063163263363463563663763863964064164264364464564664764864965065165265365465565665765865966066166266366466566666766866967067167267367467567667767867968068168268368468568668768868969069169269369469569669769869970070170270370470570670770870971071171271371471571671771871972072172272372472572672772872973073173273373473573673773873974074174274374474574674774874975075175275375475575675775875976076176276376476576676776876977077177277377477577677777877978078178278378478578678778878979079179279379479579679779879980080180280380480580680780880981081181281381481581681781881982082182282382482582682782882983083183283383483583683783883984084184284384484584684784884985085185285385485585685785885986086186286386486586686786886987087187287387487587687787887988088188288388488588688788888989089189289389489589689789889990090190290390490590690790890991091191291391491591691791891992092192292392492592692792892993093193293393493593693793893994094194294394494594694794894995095195295395495595695795895996096196296396496596696796896997097197297397497597697797897998098198298398498598698798898999099199299399499599699799899910001001100210031004100510061007100810091010101110121013101410151016101710181019102010211022102310241025102610271028102910301031103210331034103510361037103810391040104110421043104410451046104710481049105010511052105310541055105610571058105910601061106210631064106510661067106810691070107110721073107410751076107710781079108010811082108310841085108610871088108910901091109210931094109510961097109810991100110111021103110411051106110711081109111011111112111311141115111611171118111911201121112211231124112511261127112811291130113111321133113411351136113711381139114011411142114311441145114611471148114911501151115211531154115511561157115811591160116111621163116411651166116711681169117011711172117311741175117611771178117911801181118211831184118511861187118811891190119111921193119411951196119711981199120012011202120312041205120612071208120912101211121212131214121512161217121812191220122112221223122412251226122712281229123012311232123312341235123612371238123912401241124212431244124512461247124812491250125112521253125412551256125712581259126012611262126312641265126612671268126912701271127212731274127512761277127812791280128112821283128412851286128712881289129012911292129312941295129612971298129913001301130213031304130513061307130813091310131113121313131413151316131713181319132013211322132313241325132613271328132913301331133213331334133513361337133813391340134113421343134413451346134713481349135013511352135313541355135613571358135913601361136213631364136513661367136813691370137113721373137413751376137713781379138013811382138313841385138613871388138913901391139213931394139513961397139813991400140114021403140414051406140714081409141014111412141314141415141614171418141914201421142214231424142514261427142814291430143114321433143414351436143714381439144014411442144314441445144614471448144914501451145214531454145514561457145814591460146114621463146414651466146714681469147014711472147314741475147614771478147914801481148214831484148514861487148814891490149114921493149414951496149714981499150015011502150315041505150615071508150915101511151215131514151515161517151815191520152115221523152415251526152715281529153015311532153315341535153615371538153915401541154215431544154515461547154815491550155115521553155415551556155715581559156015611562156315641565156615671568156915701571157215731574157515761577157815791580158115821583158415851586158715881589159015911592159315941595159615971598159916001601160216031604160516061607160816091610161116121613161416151616161716181619162016211622162316241625162616271628162916301631163216331634163516361637163816391640164116421643164416451646164716481649165016511652165316541655165616571658165916601661166216631664166516661667166816691670167116721673167416751676167716781679168016811682168316841685168616871688168916901691169216931694169516961697169816991700170117021703170417051706170717081709171017111712171317141715171617171718171917201721172217231724172517261727172817291730173117321733173417351736173717381739174017411742174317441745174617471748174917501751175217531754175517561757175817591760176117621763176417651766176717681769177017711772177317741775177617771778177917801781178217831784178517861787178817891790179117921793179417951796179717981799180018011802180318041805180618071808180918101811181218131814181518161817181818191820182118221823182418251826182718281829183018311832183318341835183618371838183918401841184218431844184518461847184818491850185118521853185418551856185718581859186018611862186318641865186618671868186918701871187218731874187518761877187818791880188118821883188418851886188718881889189018911892189318941895189618971898189919001901190219031904190519061907190819091910191119121913191419151916191719181919192019211922192319241925192619271928192919301931193219331934193519361937193819391940194119421943194419451946194719481949195019511952195319541955195619571958195919601961196219631964196519661967196819691970197119721973197419751976197719781979198019811982198319841985198619871988198919901991199219931994199519961997199819992000200120022003200420052006200720082009201020112012201320142015201620172018201920202021202220232024202520262027202820292030203120322033203420352036203720382039204020412042204320442045204620472048204920502051205220532054205520562057205820592060206120622063206420652066206720682069207020712072207320742075207620772078207920802081208220832084208520862087208820892090209120922093209420952096209720982099210021012102210321042105210621072108210921102111211221132114211521162117211821192120212121222123212421252126212721282129213021312132213321342135213621372138213921402141214221432144214521462147214821492150215121522153215421552156215721582159216021612162216321642165216621672168216921702171217221732174217521762177217821792180218121822183218421852186218721882189219021912192219321942195219621972198219922002201220222032204220522062207220822092210221122122213221422152216221722182219222022212222222322242225222622272228222922302231223222332234223522362237223822392240224122422243224422452246
  1. <template>
  2. <div class="app-container">
  3. <el-row :gutter="20">
  4. <el-col :span="18" :class="{ edit: menudata }">
  5. <el-card shadow="always" :body-style="{ padding: '20px' }">
  6. <template #header>
  7. <div>
  8. <span>字段编辑</span>
  9. </div>
  10. </template>
  11. <!-- <Queryfrom
  12. :form-vals="checkedWhere"
  13. @getList="getList"
  14. ref="mychild"
  15. /> -->
  16. <el-select
  17. v-model="tableName"
  18. placeholder="请选择数据表"
  19. filterable
  20. @change="getList"
  21. class="mb10"
  22. >
  23. <el-option
  24. v-for="item in tableList"
  25. :key="item.tableName"
  26. :label="item.tableComment"
  27. :value="item.tableName"
  28. >
  29. <span class="discribe" style="float: left">{{
  30. item.tableComment
  31. }}</span>
  32. <span style="float: right; color: #8492a6; font-size: 13px">{{
  33. item.tableName
  34. }}</span>
  35. </el-option>
  36. </el-select>
  37. <!-- <el-form
  38. :model="tableFieldList"
  39. ref="tableForm"
  40. :rules="rules"
  41. :inline="false"
  42. size="normal"
  43. > -->
  44. <el-table
  45. :data="tableFieldList"
  46. border
  47. ref="dragTable"
  48. row-key="id"
  49. max-height="500px"
  50. >
  51. <!--
  52. :tree-props="{ children: 'children', hasChildren: 'hasChildren' }"
  53. -->
  54. >
  55. <el-table-column
  56. type="index"
  57. label="序号"
  58. width="50"
  59. class-name="allowDrag"
  60. >
  61. </el-table-column>
  62. <el-table-column align="center" prop="fieldName" label="数据字段">
  63. </el-table-column>
  64. <el-table-column
  65. align="center"
  66. prop="fieldDescription"
  67. label="字段描述"
  68. >
  69. <template slot-scope="scope">
  70. <!-- <el-form-item size="normal" prop="fieldDescription"> -->
  71. <input
  72. :class="{
  73. isNullDesc:
  74. scope.row.fieldDescription == '' &&
  75. scope.row.isShow &&
  76. isInputInvalid
  77. ? true
  78. : false,
  79. ipt: true,
  80. }"
  81. v-model="scope.row.fieldDescription"
  82. />
  83. <!-- <el-input v-model="scope.row.fieldDescription" /> -->
  84. <!-- </el-form-item> -->
  85. </template>
  86. </el-table-column>
  87. <el-table-column align="center" prop="relationTable" label="关联表">
  88. <template slot-scope="scope">
  89. <el-select
  90. v-model="scope.row.relationTable"
  91. :disabled="
  92. !scope.row.relationTableList ||
  93. !scope.row.relationTableList.length
  94. "
  95. placeholder="请选择关联的表"
  96. clearable
  97. filterable
  98. @change="ralationTableChange(scope.row)"
  99. >
  100. <el-option
  101. v-for="item in scope.row.relationTableList"
  102. :key="item.tableName"
  103. :label="item.tableComment"
  104. :value="item.tableName"
  105. >
  106. <span style="float: left">{{ item.tableComment }}</span>
  107. <span
  108. style="float: right; color: #8492a6; font-size: 13px"
  109. >{{ item.tableName }}</span
  110. >
  111. </el-option>
  112. </el-select>
  113. </template>
  114. </el-table-column>
  115. <el-table-column
  116. align="center"
  117. prop="relationFieldName"
  118. label="关联条件字段"
  119. >
  120. <template slot-scope="scope">
  121. <el-select
  122. v-model="scope.row.relationFieldName"
  123. @change="relationFieldChange(scope.row)"
  124. :disabled="!scope.row.disableRelaFieldName"
  125. placeholder="关联字段"
  126. filterable
  127. >
  128. <el-option
  129. v-for="item in scope.row.relaFieldNameList"
  130. :key="item.fieldName"
  131. :label="item.fieldDescription"
  132. :value="item.fieldName"
  133. >
  134. </el-option>
  135. </el-select>
  136. </template>
  137. </el-table-column>
  138. <el-table-column
  139. align="center"
  140. prop="relationType"
  141. label="关联方式"
  142. >
  143. <template slot-scope="scope">
  144. <el-select
  145. v-model="scope.row.relationType"
  146. placeholder="请选择关联方式"
  147. :disabled="!scope.row.disableRelaType"
  148. @change="relationTypeChangeHandler(scope.row)"
  149. filterable
  150. >
  151. <el-option
  152. v-for="item in relaTypeList"
  153. :key="item.value"
  154. :label="item.label"
  155. :value="item.value"
  156. >
  157. </el-option>
  158. </el-select>
  159. </template>
  160. </el-table-column>
  161. <!-- <el-table-column prop="relationShowField" label="关联显示字段">
  162. <template slot-scope="scope">
  163. <el-select
  164. v-model="scope.row.relationShowField"
  165. :disabled="!scope.row.disableRelaFieldName"
  166. placeholder="请选择"
  167. clearable
  168. filterable
  169. multiple
  170. >
  171. <el-option
  172. v-for="item in scope.row.relaFieldNameList"
  173. :key="item.fieldName"
  174. :label="item.fieldDescription"
  175. :value="item.fieldName + ' ' + item.fieldDescription"
  176. >
  177. </el-option>
  178. </el-select>
  179. </template>
  180. </el-table-column> -->
  181. <el-table-column align="center" prop="isShow" label="是否显示">
  182. <template slot-scope="scope">
  183. <el-switch v-model="scope.row.isShow"></el-switch>
  184. </template>
  185. </el-table-column>
  186. <el-table-column
  187. align="center"
  188. prop="isSearch"
  189. label="是否包含查询"
  190. >
  191. <template slot-scope="scope">
  192. <el-switch v-model="scope.row.isSearch"></el-switch>
  193. </template>
  194. </el-table-column>
  195. <el-table-column align="center" prop="isExport" label="是否导出">
  196. <template slot-scope="scope">
  197. <el-switch v-model="scope.row.isExport"></el-switch>
  198. </template>
  199. </el-table-column>
  200. <!-- <el-table-column
  201. prop="defaultValue"
  202. label="筛选条件"
  203. align="center"
  204. >
  205. </el-table-column> -->
  206. <!-- <el-table-column prop="isCount" label="是否统计">
  207. <template slot-scope="scope">
  208. <el-switch v-model="scope.row.isCount"> </el-switch>
  209. </template>
  210. </el-table-column> -->
  211. <!-- <el-table-column
  212. label="操作"
  213. align="center"
  214. class-name="small-padding fixed-width"
  215. >
  216. <template slot-scope="scope">
  217. <el-button
  218. size="mini"
  219. type="text"
  220. icon="el-icon-edit"
  221. @click="handleUpdate(scope.row)"
  222. >修改
  223. </el-button>
  224. <el-button
  225. size="mini"
  226. type="text"
  227. icon="el-icon-delete"
  228. @click="handleDelete(scope.row)"
  229. >删除
  230. </el-button>
  231. </template>
  232. </el-table-column> -->
  233. </el-table>
  234. <!-- </el-form> -->
  235. </el-card>
  236. </el-col>
  237. <el-col :span="6" :class="{ menudata: menudata }">
  238. <el-tabs v-model="activeName" @tab-click="tabhandleClick">
  239. <el-tab-pane label="菜单编辑" name="menuedit">
  240. <el-card shadow="always" :body-style="{ padding: '10px' }">
  241. <!-- <template #header>
  242. <div>
  243. <span>菜单编辑</span>
  244. </div>
  245. </template> -->
  246. <el-form
  247. ref="formData"
  248. :model="formData"
  249. label-width="100px"
  250. :rules="rules"
  251. >
  252. <el-form-item label="菜单名称" prop="menuName">
  253. <el-input v-model="formData.menuName"></el-input>
  254. </el-form-item>
  255. <el-form-item label="菜单路由" prop="routePath">
  256. <!-- <el-select v-model="formData.routePath" placeholder="请选择路由">
  257. <el-option label="区域一" value="shanghai"></el-option>
  258. <el-option label="区域二" value="beijing"></el-option>
  259. </el-select> -->
  260. <treeselect
  261. :append-to-body="true"
  262. v-model="formData.routePath"
  263. :options="menus"
  264. :normalizer="normalizer"
  265. @change="treeSelectChange"
  266. @focus="treeSelectFocus"
  267. :show-count="true"
  268. placeholder="请选择父级路由"
  269. />
  270. </el-form-item>
  271. <el-form-item label="是否显示列表" v-if="false">
  272. <el-switch v-model="formData.isShowList"></el-switch>
  273. </el-form-item>
  274. <el-form-item label="时间格式" prop="timeFormate">
  275. <el-select
  276. v-model="formData.timeFormate"
  277. placeholder="请选择时间格式"
  278. >
  279. <el-option
  280. v-for="val in dict.type.sys_time_format"
  281. :key="val.value"
  282. :label="val.label"
  283. :value="val.value"
  284. ></el-option>
  285. </el-select>
  286. </el-form-item>
  287. <el-form-item label="表格主键" prop="primaryKey">
  288. <el-select
  289. v-model="formData.primaryKey"
  290. placeholder="请选择表格主键"
  291. >
  292. <el-option
  293. v-for="val in primaryKeyList"
  294. :key="val.fieldName"
  295. :label="val.fieldDescription"
  296. :value="val.fieldName"
  297. ></el-option>
  298. </el-select>
  299. </el-form-item>
  300. <el-form-item label="操作列按钮" prop="btnGroupList">
  301. <el-select
  302. v-model="formData.btnGroupList"
  303. placeholder="请选择按钮组"
  304. clearable
  305. multiple
  306. >
  307. <el-option
  308. v-for="val in btnGroupOptions"
  309. :key="val.btnKey"
  310. :label="val.btnGroupName"
  311. :value="val.btnKey"
  312. ></el-option>
  313. </el-select>
  314. </el-form-item>
  315. <el-form-item label="排序依赖字段">
  316. <el-select
  317. v-model="formData.orderByColumn"
  318. placeholder="请选择排序依赖"
  319. >
  320. <el-option
  321. v-for="val in orderByFieldList"
  322. :key="val.fieldName"
  323. :label="val.fieldDescription"
  324. :value="val.tableName + '.' + val.fieldName"
  325. ></el-option>
  326. </el-select>
  327. </el-form-item>
  328. <el-form-item label="排序方式" v-show="formData.orderByColumn">
  329. <el-radio v-model="formData.isAsc" :label="false"
  330. >升序
  331. </el-radio
  332. >
  333. <el-radio v-model="formData.isAsc" :label="true"
  334. >降序
  335. </el-radio
  336. >
  337. </el-form-item>
  338. <el-form-item>
  339. <el-button size="mini" @click="previewHandle">预览</el-button>
  340. <el-button size="mini" type="primary" @click="createHandle">{{
  341. tId ? "确认修改" : "确认创建"
  342. }}
  343. </el-button>
  344. </el-form-item>
  345. </el-form>
  346. </el-card>
  347. </el-tab-pane>
  348. <el-tab-pane label="数据统计" name="datacount">
  349. <el-button
  350. type="primary"
  351. class="inline-large-button"
  352. icon="el-icon-plus"
  353. size="mini"
  354. @click="addDataDialog"
  355. >
  356. 添加数据字段
  357. </el-button>
  358. <!-- <el-button size="mini" type="primary" @click=countHandle>确定统计</el-button> -->
  359. <el-table
  360. :data="dragTableStatisticList"
  361. border
  362. class="mb10"
  363. style="width: 100%"
  364. >
  365. <!-- <el-table-column prop="number" label="序号" width="50"> -->
  366. style="width: 100%">
  367. <el-table-column
  368. type="index"
  369. label="序号"
  370. width="50"
  371. class-name="allowDrag"
  372. >
  373. </el-table-column>
  374. <!-- <el-table-column prop="datafield" label="数据字段" width="80"> -->
  375. <el-table-column prop="statisticTitle" label="统计标题">
  376. </el-table-column>
  377. <el-table-column prop="statisticField" label="统计数据">
  378. </el-table-column>
  379. <!-- <el-table-column prop="type" label="类型" width="50"> -->
  380. <el-table-column prop="statisticType" label="统计类型">
  381. </el-table-column>
  382. <el-table-column
  383. label="操作"
  384. align="center"
  385. class-name="small-padding fixed-width"
  386. >
  387. <template slot-scope="scope">
  388. <el-dropdown>
  389. <el-button type="warning" plain size="small">
  390. 处理<i class="el-icon-arrow-down el-icon--right"></i>
  391. </el-button>
  392. <el-dropdown-menu slot="dropdown">
  393. <el-dropdown-item>
  394. <el-button
  395. size="mini"
  396. type="text"
  397. icon="el-icon-edit"
  398. @click="handleUpdateStat(scope.row)"
  399. >修改
  400. </el-button>
  401. </el-dropdown-item>
  402. <el-dropdown-item>
  403. <el-button
  404. size="mini"
  405. type="text"
  406. icon="el-icon-delete"
  407. @click="handleDeleteStat(scope.row)"
  408. >删除
  409. </el-button>
  410. </el-dropdown-item>
  411. </el-dropdown-menu>
  412. </el-dropdown>
  413. </template>
  414. </el-table-column>
  415. </el-table>
  416. </el-tab-pane>
  417. <el-tab-pane label="样式编辑" name="styleEdit">
  418. <StyleFormPanel
  419. ref="styleTableRef"
  420. :tableFieldList="tableFieldList"
  421. :dragTableStyleList="dragTableStyleList"
  422. />
  423. </el-tab-pane>
  424. <el-tab-pane label="数据筛选" name="dataFilter">
  425. <!-- <StyleFormPanel
  426. ref="styleTableRef"
  427. :tableFieldList="tableFieldList"
  428. :dragTableStyleList="dragTableStyleList"
  429. /> -->
  430. <DataFilterPanel
  431. ref="dataFilterRef"
  432. :tableFieldList="tableFieldList"
  433. :filterDataEcho="filterDataEcho"
  434. ></DataFilterPanel>
  435. </el-tab-pane>
  436. <el-tab-pane label="按钮配置" name="classificationQuery">
  437. <ClassificationQueryPanel
  438. ref="classificationQueryRef"
  439. :tableFieldList="tableFieldList"
  440. :classificationDataEcho="classificationDataEcho"
  441. ></ClassificationQueryPanel>
  442. </el-tab-pane>
  443. </el-tabs>
  444. </el-col>
  445. </el-row>
  446. <el-dialog title="效果预览" :visible.sync="isShowPreview" width="50%">
  447. <div class="cardBox">
  448. <el-card
  449. shadow="hover"
  450. :body-style="{ padding: '20px' }"
  451. class="card"
  452. v-for="(item, index) in deepragTableStatisticList"
  453. :key="index"
  454. >
  455. <el-tooltip
  456. class="item"
  457. effect="dark"
  458. :content="item.statisticTitle"
  459. placement="top-start"
  460. >
  461. <div class="title">
  462. {{
  463. item.statisticTitle
  464. ? item.statisticTitle
  465. : item.statisticDescription
  466. }}
  467. </div>
  468. </el-tooltip>
  469. <!-- <el-tooltip
  470. class="item"
  471. effect="dark"
  472. :content="item.statisticDescription"
  473. placement="top-start"
  474. >
  475. <div class="description">{{ item.statisticDescription }}</div>
  476. </el-tooltip> -->
  477. <div class="type">
  478. <!-- <div class="statisticType">{{ item.statisticType }}</div> -->
  479. <div class="count">统计结果</div>
  480. </div>
  481. </el-card>
  482. </div>
  483. <el-row :gutter="10" class="mb8">
  484. <el-col :span="18">
  485. <el-input placeholder="请输入" clearable/>
  486. </el-col>
  487. <el-col :span="6" class="previewbtn">
  488. <el-button
  489. type="primary"
  490. icon="el-icon-search"
  491. size="small"
  492. @click="() => {}"
  493. >搜索
  494. </el-button
  495. >
  496. <el-button icon="el-icon-refresh" size="small" @click="() => {}"
  497. >重置
  498. </el-button
  499. >
  500. </el-col>
  501. </el-row>
  502. <el-row :gutter="10" class="mb8">
  503. <el-col :span="1.5">
  504. <el-button
  505. type="primary"
  506. plain
  507. icon="el-icon-plus"
  508. size="mini"
  509. @click="() => {}"
  510. >新增
  511. </el-button>
  512. </el-col>
  513. <el-col :span="1.5">
  514. <el-button
  515. type="success"
  516. plain
  517. icon="el-icon-edit"
  518. size="mini"
  519. :disabled="false"
  520. @click="() => {}"
  521. >修改
  522. </el-button>
  523. </el-col>
  524. <el-col :span="1.5">
  525. <el-button
  526. type="danger"
  527. plain
  528. icon="el-icon-delete"
  529. size="mini"
  530. :disabled="false"
  531. @click="() => {}"
  532. >删除
  533. </el-button>
  534. </el-col>
  535. <el-col :span="1.5">
  536. <el-button plain icon="el-icon-upload2" size="mini" @click="() => {}"
  537. >导入
  538. </el-button>
  539. </el-col>
  540. <el-col :span="1.5">
  541. <el-button
  542. type="warning"
  543. plain
  544. icon="el-icon-download"
  545. size="mini"
  546. @click="() => {}"
  547. >导出
  548. </el-button>
  549. </el-col>
  550. <!-- <right-toolbar
  551. showSearch.sync="true"
  552. @queryTable="() => {}"
  553. ></right-toolbar> -->
  554. </el-row>
  555. <el-table :data="tableDataList" @selection-change="() => {}">
  556. <el-table-column
  557. type="selection"
  558. width="55"
  559. align="center"
  560. ></el-table-column>
  561. <!-- <span v-for="(key, val) in columns" :key="key">
  562. <el-table-column :label="key" align="center" :prop="val" />
  563. </span> -->
  564. <el-table-column
  565. v-for="item in columns"
  566. :key="item.key + item.value"
  567. :label="item.value"
  568. align="center"
  569. :prop="toUpperCase(item.key)"
  570. />
  571. <el-table-column
  572. label="操作"
  573. align="center"
  574. class-name="small-padding fixed-width"
  575. >
  576. <!-- <template slot-scope="scope"> -->
  577. <template>
  578. <!-- <el-button
  579. size="mini"
  580. type="text"
  581. icon="el-icon-edit"
  582. @click="() => {}"
  583. >修改
  584. </el-button>
  585. <el-button
  586. size="mini"
  587. type="text"
  588. icon="el-icon-delete"
  589. @click="() => {}"
  590. >删除
  591. </el-button> -->
  592. <el-dropdown>
  593. <el-button type="warning" plain size="small">
  594. 处理<i class="el-icon-arrow-down el-icon--right"></i>
  595. </el-button>
  596. <el-dropdown-menu slot="dropdown">
  597. <el-dropdown-item
  598. >
  599. <el-button
  600. size="mini"
  601. type="text"
  602. icon="el-icon-edit"
  603. @click="() => {}"
  604. >修改
  605. </el-button
  606. >
  607. </el-dropdown-item
  608. >
  609. <el-dropdown-item
  610. >
  611. <el-button
  612. size="mini"
  613. type="text"
  614. icon="el-icon-delete"
  615. @click="() => {}"
  616. >删除
  617. </el-button
  618. >
  619. </el-dropdown-item>
  620. </el-dropdown-menu>
  621. </el-dropdown>
  622. </template>
  623. </el-table-column>
  624. </el-table>
  625. <pagination
  626. v-show="total > 0"
  627. :total="total"
  628. :page.sync="queryParams.pageNum"
  629. :limit.sync="queryParams.pageSize"
  630. @pagination="pageList"
  631. />
  632. <template #footer>
  633. <span>
  634. <el-button @click="isShowPreview = false">关闭</el-button>
  635. <el-button type="primary" @click="createHandle">{{
  636. tId ? "确认修改" : "确认创建"
  637. }}</el-button>
  638. </span>
  639. </template>
  640. </el-dialog>
  641. <!-- 添加数据统计对话框 -->
  642. <el-dialog :title="staictitle" :visible.sync="isShowAddData" width="30%">
  643. <el-form label-width="100px" :model="dataCountFormData">
  644. <el-form-item label="统计标题" prop="statisticTitle">
  645. <el-input v-model="dataCountFormData.statisticTitle"></el-input>
  646. </el-form-item>
  647. <el-form-item label="统计数据">
  648. <el-select
  649. v-model="dataCountFormData.statisticField"
  650. placeholder="请选择统计字段"
  651. >
  652. <el-option
  653. v-for="item in dataArr"
  654. :key="item.id"
  655. :label="item.fieldName"
  656. :value="item.tableName + '.' + item.fieldName"
  657. >
  658. <span class="discribe" style="float: left; margin-right: 5px"
  659. >{{ isShowTableName }}
  660. </span>
  661. <span style="float: right; color: #8492a6; font-size: 13px">{{
  662. item.fieldName
  663. }}</span>
  664. </el-option>
  665. </el-select>
  666. </el-form-item>
  667. <!-- <el-form-item label="类型">
  668. <el-select v-model="dataCountFormData.type" placeholder="请选择类型">
  669. <el-option label="数量" value="num"></el-option>
  670. <el-option label="状态" value="status"></el-option> -->
  671. <el-form-item label="统计类型">
  672. <el-select
  673. v-model="dataCountFormData.statisticType"
  674. placeholder="请选择统计类型"
  675. >
  676. <el-option
  677. v-for="item in dataType"
  678. :key="item.dictCode"
  679. :label="item.dictLabel"
  680. :value="item.dictValue"
  681. ></el-option>
  682. <!-- <el-option label="状态" value="status"></el-option> -->
  683. </el-select>
  684. </el-form-item>
  685. </el-form>
  686. <span slot="footer" class="dialog-footer">
  687. <el-button @click="closeAddDialog">取 消</el-button>
  688. <el-button
  689. v-if="staictitle == '修改统计数据字段'"
  690. type="primary"
  691. @click="upadtaData"
  692. >确 定</el-button
  693. >
  694. <el-button v-else type="primary" @click="addData">确 定</el-button>
  695. </span>
  696. </el-dialog>
  697. </div>
  698. </template>
  699. <script>
  700. import {
  701. delTableData,
  702. dragTableInfo,
  703. listTable,
  704. unionListTableData,
  705. getInfoBySqlKey,
  706. addTableData,
  707. addStatistic,
  708. updateStatistic,
  709. insertByDefaultBtn,
  710. } from "@/api/tablelist/commonTable";
  711. import {getDicts} from "@/api/system/dict/data";
  712. import {
  713. getFormName,
  714. getListName,
  715. dragTablePreview,
  716. } from "@/api/dragform/form.js";
  717. import {getTableInfo, editTable} from "@/api/system/table.js";
  718. import {addDragTable} from "@/api/tablelist/commonTable.js";
  719. import {getParticMenu, updateMenu} from "@/api/system/menu.js";
  720. import {getMenuList, addMenu, tbnHasPerms} from "@/api/menu.js";
  721. import Queryfrom from "@/views/tablelist/commonTable/queryfrom.vue";
  722. import {mapState} from "vuex";
  723. import Sortable from "sortablejs";
  724. import Treeselect from "@riophae/vue-treeselect";
  725. import "@riophae/vue-treeselect/dist/vue-treeselect.css";
  726. import {v4 as uuidv4} from "uuid";
  727. import {listBtn} from "@/api/system/btn";
  728. import StyleFormPanel from "./components/StyleFormPanel.vue";
  729. import DataFilterPanel from "./components/DataFilterPanel.vue";
  730. import ClassificationQueryPanel from "./components/ClassificationQueryPanel.vue";
  731. export default {
  732. name: "tableMange",
  733. dicts: ["sys_time_format", "table_statistic_type"],
  734. props: [],
  735. components: {
  736. Queryfrom,
  737. Treeselect,
  738. StyleFormPanel,
  739. DataFilterPanel,
  740. ClassificationQueryPanel,
  741. },
  742. data() {
  743. return {
  744. menuList: [], //路由数组
  745. btnTemplate: [], //按钮模板
  746. isNeedNewMenu: false, //是否需要新菜单
  747. filterDataEcho: "", //数据过滤回显数据
  748. classificationDataEcho: "", //分类查询回显数据
  749. staictitle: "添加统计数据字段",
  750. isInputInvalid: false,
  751. // 修改表格时的menuId
  752. menuId: "",
  753. // 修改表格的id
  754. tId: "",
  755. // 当前模板信息
  756. templateInfo: {},
  757. // 排序方式 默认降序
  758. sortState: true,
  759. // 列信息
  760. columns: {},
  761. // 查询条件
  762. queryFromWhere: {},
  763. // 当前table唯一标识
  764. sqlKey: "",
  765. // 动态数据sqlkey
  766. staticSqlKey: "",
  767. // 表格的高度
  768. tableKey: "",
  769. // tableHeight: document.documentElement.scrollHeight - 245 + "px",
  770. tableList: [], //所有表格列表
  771. tableFieldList: [], // 当前表格字段数据
  772. tableName: "", // 当前表名称
  773. relationTableList: [], //关联表格列表
  774. relationFieldList: [], //关联字段列表
  775. relationTypeList: [], //关联方式列表
  776. total: 0, //表格数据总数
  777. relaTypeList: [
  778. {
  779. label: "等值连接",
  780. value: "INNER JOIN",
  781. },
  782. {
  783. label: "左连接",
  784. value: "LEFT JOIN",
  785. },
  786. {
  787. label: "右连接",
  788. value: "RIGHT JOIN",
  789. },
  790. ],
  791. headerList: [
  792. {
  793. prop: "fieldName",
  794. label: "数据字段",
  795. },
  796. {
  797. prop: "fieldDescription",
  798. label: "字段描述",
  799. },
  800. {
  801. prop: "relationTable",
  802. label: "关联表",
  803. },
  804. {
  805. prop: "relationFieldName",
  806. label: "关联字段",
  807. },
  808. {
  809. prop: "relationType",
  810. label: "关联方式",
  811. },
  812. {
  813. prop: "isShow",
  814. label: "是否显示",
  815. },
  816. {
  817. prop: "isSearch",
  818. label: "是否包含查询",
  819. },
  820. {
  821. prop: "isExport",
  822. label: "是否导出",
  823. },
  824. {
  825. prop: "isCount",
  826. label: "是否统计",
  827. },
  828. ], //表头列表
  829. // 右侧筛选条件勾选数据
  830. // checkedList: [], //勾选的查询框
  831. // checkedWhere:[],//需要渲染的查询表单
  832. // 右侧表单编辑
  833. formData: {
  834. menuName: "",
  835. routePath: undefined,
  836. isShowList: true,
  837. timeFormate: "",
  838. orderByColumn: "",
  839. isAsc: false,
  840. primaryKey: "",
  841. btnGroupList: [],
  842. },
  843. rules: {
  844. menuName: [
  845. {required: true, message: "请输入菜单名称", trigger: "blur"},
  846. ],
  847. routePath: [
  848. {required: true, message: "请选择路由", trigger: "change"},
  849. ],
  850. timeFormate: [
  851. {required: true, message: "请选择时间格式", trigger: "change"},
  852. ],
  853. primaryKey: [
  854. {required: true, message: "请选择表格主键", trigger: "blur"},
  855. ],
  856. fieldDescription: [
  857. {required: true, message: "请输入字段描述", trigger: "blur"},
  858. ],
  859. },
  860. menus: [], //路由列表数据
  861. // 预览弹窗相关
  862. isShowPreview: false, //弹窗显示与隐藏
  863. queryParams: {
  864. pageNum: 1,
  865. pageSize: 10,
  866. orderByColumn: "",
  867. isAsc: false,
  868. basicMap: {
  869. sql: "",
  870. },
  871. },
  872. loading: false, //表格加载
  873. tableDataList: [], //数据
  874. editData: {},
  875. menuOrderNum: 0,
  876. // tab动态切换
  877. activeName: "menuedit",
  878. // 数据统计对象
  879. dataCountFormData: {},
  880. // 添加数据统计表格
  881. dragTableStatisticList: [],
  882. deepragTableStatisticList: [],
  883. tableSqlList: [],
  884. searchFieldList: [],
  885. // 是否切换到数据统计
  886. menudata: false,
  887. // 显示添加字段对话框dataArr
  888. isShowAddData: false,
  889. dataType: [],
  890. uuid: "",
  891. // 样式编辑tab数据
  892. dragTableStyleList: [],
  893. //操作列按钮组数据
  894. btnGroupOptions: [],
  895. };
  896. },
  897. computed: {
  898. ...mapState({
  899. databaseName: (state) => state.user.dataSource.databaseName,
  900. databaseType: (state) => state.user.dataSource.databaseType,
  901. username: (state) => state.user.dataSource.username,
  902. tenantId: (state) => state.user.tenant.tenantId,
  903. tenantName: (state) => state.user.tenant.tenantName,
  904. }),
  905. // 数据字段
  906. dataArr() {
  907. return this.tableFieldList.filter((item) => item.isShow);
  908. },
  909. // 数据统计字段表名中文
  910. isShowTableName() {
  911. let tableComment;
  912. this.tableList.forEach((item) => {
  913. if (item.tableName === this.tableName) {
  914. tableComment = item.tableComment;
  915. }
  916. });
  917. return tableComment;
  918. },
  919. ...mapState({
  920. databaseName: (state) => state.user.dataSource.databaseName,
  921. databaseType: (state) => state.user.dataSource.databaseType,
  922. username: (state) => state.user.dataSource.username,
  923. tenantId: (state) => state.user.tenant.tenantId,
  924. tenantCode: (state) => state.user.tenant.tenantCode,
  925. }),
  926. searchArr() {
  927. if (!this.templateInfo?.where?.length) return [];
  928. return this.templateInfo.where.map((item) => item.conditionName);
  929. },
  930. checkedWhere() {
  931. if (!this.templateInfo?.where?.length) return [];
  932. return this.templateInfo?.where.filter((item) => {
  933. return this.checkedList.includes(item.conditionName);
  934. });
  935. },
  936. orderByFieldList() {
  937. // return this.tableFieldList.filter((item) => item.isShow);
  938. return this.tableFieldList;
  939. },
  940. primaryKeyList() {
  941. return this.tableFieldList.filter((item) => !item.isChildren);
  942. },
  943. // menuOrderNum() {
  944. // if (!this.formData.routePath) return 0;
  945. // let targetMenu = this.getTargetMenu(this.menus);
  946. // console.log(targetMenu);
  947. // if (targetMenu.children?.length) {
  948. // return targetMenu.children.length;
  949. // } else {
  950. // return 0;
  951. // }
  952. // },
  953. },
  954. watch: {
  955. tableName: function (val) {
  956. if (val) {
  957. this.relationTableList = this.tableList
  958. .filter((item) => item.tableName != val)
  959. .map((item) => {
  960. return {
  961. tableName: item.tableName,
  962. tableComment: item.tableComment,
  963. };
  964. });
  965. } else {
  966. this.relationTableList = [];
  967. }
  968. },
  969. "formData.routePath"(nval, oval) {
  970. let targetMenu = this.getTargetMenu(this.menus);
  971. this.menuOrderNum = targetMenu.children ? targetMenu.children.length : 0;
  972. },
  973. },
  974. methods: {
  975. // 获取按钮模板数据
  976. async getBtnTemplate() {
  977. try {
  978. let res = await getDicts("drag_table_btn_template");
  979. if (res.code == 200) {
  980. this.btnTemplate = res.data.map((item) => JSON.parse(item.remark));
  981. } else {
  982. console.log(res);
  983. this.$message.error("获取按钮模板数据失败");
  984. }
  985. } catch (error) {
  986. console.log(error);
  987. this.$message.error("获取按钮模板数据失败");
  988. }
  989. },
  990. // 格式化按钮模板数据
  991. formateBtnTemplate() {
  992. let res = {
  993. hasPermiName: "",
  994. dragTableBtnTop: {},
  995. dragTableBtnRight: {},
  996. };
  997. let moduleName = this.menuList.find(
  998. (item) => item.menuId == this.formData.routePath
  999. )?.menuName;
  1000. res.hasPermiName =
  1001. this.tenantCode + ":" + moduleName + ":" + this.formData.menuName;
  1002. let primaryKey = this.tableName + "." + this.formData.primaryKey;
  1003. this.btnTemplate.forEach((item) => {
  1004. item.children.forEach((i) => {
  1005. if (i.btnType == "UPDATE" || i.btnType == "DELETE") {
  1006. let btnParams = {commonFieldData: [], conditionData: []};
  1007. btnParams.conditionData.push({
  1008. fieldName: primaryKey,
  1009. fieldValue: "",
  1010. });
  1011. i.btnParams = JSON.stringify(btnParams);
  1012. }
  1013. });
  1014. });
  1015. res.dragTableBtnTop = this.btnTemplate[0];
  1016. res.dragTableBtnRight = this.btnTemplate[1];
  1017. return res;
  1018. },
  1019. // 字段描述验证规则
  1020. // blurval(value){
  1021. // this.isInputInvalid = value == '' ? true : false;
  1022. // },
  1023. // 树形控件change回调
  1024. treeSelectChange(val) {
  1025. // await this.getMenuList();
  1026. //没有change事件
  1027. console.log("val", val);
  1028. },
  1029. async treeSelectFocus() {
  1030. await this.getMenuList();
  1031. },
  1032. // 获取目标menu
  1033. getTargetMenu(menus) {
  1034. for (let i = 0; i < menus.length; i++) {
  1035. if (menus[i].menuId == this.formData.routePath) {
  1036. return menus[i];
  1037. } else if (menus.children?.length) {
  1038. return this.getTargetMenu(menus.children);
  1039. }
  1040. }
  1041. return false;
  1042. },
  1043. /** 查询列表 */
  1044. getList(queryParams) {
  1045. if (!this.tableName) return;
  1046. let data = {
  1047. databaseName: this.databaseName,
  1048. databaseType: this.databaseType,
  1049. tableName: this.tableName,
  1050. };
  1051. let tableComment = this.getTableCommont(this.tableName, this.tableList);
  1052. // 获取当前表单结构信息
  1053. getListName(data).then((res) => {
  1054. // console.log(res);
  1055. this.tableFieldList = res.map((item, index) => {
  1056. return {
  1057. id: this.tableName + "_" + item.fieldName,
  1058. fieldName: item.fieldName,
  1059. fieldDescription: item.fieldDescription,
  1060. relationTable: "",
  1061. relationFieldName: "",
  1062. relaFieldNameList: [],
  1063. disableRelaFieldName: false,
  1064. relationType: "",
  1065. relationShowField: [],
  1066. relationShowFiledList: [],
  1067. disableRelaType: false,
  1068. isShow: true,
  1069. isSearch: false,
  1070. isExport: false,
  1071. relationTableList: this.relationTableList,
  1072. tableName: this.tableName,
  1073. tableComment,
  1074. relationFieldList: [],
  1075. };
  1076. });
  1077. // console.log(this.tableFieldList);
  1078. });
  1079. },
  1080. // 关联表变化回调
  1081. async ralationTableChange(row) {
  1082. this.tableFieldList = this.tableFieldList.filter((item) => {
  1083. return !row.relationFieldList.some((val) => {
  1084. return val.id == item.id;
  1085. });
  1086. });
  1087. row.relationFieldName = "";
  1088. row.relationType = "";
  1089. row.disableRelaFieldName = false;
  1090. row.disableRelaType = false;
  1091. row.relationFieldList = [];
  1092. if (!row.relationTable) {
  1093. return;
  1094. }
  1095. // 获取关联表的字段
  1096. let data = {
  1097. databaseName: this.databaseName,
  1098. databaseType: this.databaseType,
  1099. tableName: row.relationTable,
  1100. };
  1101. let tableComment = this.getTableCommont(
  1102. row.relationTable,
  1103. this.tableList
  1104. );
  1105. let res = await getListName(data);
  1106. // 关联字段下拉列表数据
  1107. row.relaFieldNameList = res.map((item) => {
  1108. return {
  1109. fieldName: item.fieldName,
  1110. fieldDescription: item.fieldDescription,
  1111. };
  1112. });
  1113. let relationTableList = row.relationTableList.filter(
  1114. (item) => row.relationTable != item.tableName
  1115. );
  1116. row.relationFieldList = row.relaFieldNameList.map((item, index) => {
  1117. return {
  1118. id: row.relationTable + "_" + item.fieldName,
  1119. fieldName: item.fieldName,
  1120. fieldDescription: item.fieldDescription,
  1121. relationTable: "",
  1122. relationFieldName: "",
  1123. relaFieldNameList: [],
  1124. disableRelaFieldName: false,
  1125. relationType: "",
  1126. relationShowField: [],
  1127. relationShowFiledList: [],
  1128. disableRelaType: false,
  1129. isShow: true,
  1130. isSearch: false,
  1131. isExport: false,
  1132. relationTableList,
  1133. tableName: row.relationTable,
  1134. tableComment,
  1135. relationFieldList: [],
  1136. isChildren: true,
  1137. };
  1138. });
  1139. // this.tableFieldList = [...this.tableFieldList, ...row.relationFieldList];
  1140. row.disableRelaFieldName = true;
  1141. },
  1142. // 关联类型变化回调
  1143. relationTypeChangeHandler(row) {
  1144. let tempRelationFieldList = row.relationFieldList.filter((item) => {
  1145. return !this.tableFieldList.find((val) => val.id === item.id);
  1146. });
  1147. this.tableFieldList = [...this.tableFieldList, ...tempRelationFieldList];
  1148. },
  1149. // 关联字段回调
  1150. relationFieldChange(row) {
  1151. if (!row.relationFieldName) {
  1152. row.relationType = "";
  1153. row.disableRelaType = false;
  1154. row.relaFieldNameList = [];
  1155. return;
  1156. }
  1157. row.disableRelaType = true;
  1158. },
  1159. // 勾选框回调
  1160. handleSelectionChange(selection) {
  1161. this.ids = selection.map((item) => item.id);
  1162. // this.single = selection.length != 1;
  1163. this.multiple = !selection.length;
  1164. },
  1165. // 分页查询
  1166. pageList(row) {
  1167. this.$refs.mychild.pageList(
  1168. row == undefined
  1169. ? {
  1170. limit: this.queryParams.pageSize,
  1171. page: this.queryParams.pageNum,
  1172. }
  1173. : row
  1174. );
  1175. },
  1176. // 多选框改变回调
  1177. checkedChangeHandle(val) {
  1178. },
  1179. // 获取所有表格
  1180. async getAllTable() {
  1181. let data = {
  1182. databaseName: this.databaseName,
  1183. databaseType: this.databaseType,
  1184. };
  1185. let res = await getFormName(data);
  1186. const baseTable = await this.getDicts("base_table");
  1187. this.tableList = res.data.filter((item) => {
  1188. return !baseTable.data.some(
  1189. (value) =>
  1190. value.dictValue.toLowerCase() == item.tableName.toLowerCase()
  1191. );
  1192. });
  1193. },
  1194. //处理表格行拖拽
  1195. initDragTable() {
  1196. const el = this.$refs.dragTable.$el.querySelectorAll(
  1197. ".el-table__body-wrapper > table > tbody"
  1198. )[0];
  1199. const sortable = Sortable.create(el, {
  1200. handle: ".allowDrag",
  1201. onEnd: (evt) => {
  1202. const targetRow = this.tableFieldList.splice(evt.oldIndex, 1)[0];
  1203. this.tableFieldList.splice(evt.newIndex, 0, targetRow);
  1204. for (let index in this.tableFieldList) {
  1205. this.tableFieldList[index].sort = parseInt(index) + 1;
  1206. }
  1207. },
  1208. });
  1209. },
  1210. /** 转换菜单数据结构 */
  1211. normalizer(node) {
  1212. if (node.children && !node.children.length) {
  1213. delete node.children;
  1214. }
  1215. return {
  1216. id: node.menuId,
  1217. label: node.menuName,
  1218. children: node.children,
  1219. };
  1220. },
  1221. // 获取路由表单数据
  1222. async getMenuList() {
  1223. let res = await getMenuList();
  1224. if (res.code == 200) {
  1225. this.menuList = res.data;
  1226. this.menus = this.handleTree(res.data, "menuId");
  1227. }
  1228. },
  1229. // 校验字段合法性(递归版)
  1230. validateField(tableFieldList, validateParams) {
  1231. if (!tableFieldList.length) {
  1232. return;
  1233. }
  1234. for (let i = 0; i < tableFieldList.length; i++) {
  1235. let temp = tableFieldList[i];
  1236. if (!temp.fieldDescription?.trim() && temp.isShow) {
  1237. //描述字段不能为空
  1238. validateParams.isFieldDescrib = true;
  1239. }
  1240. if (
  1241. temp.relationTable &&
  1242. (!temp.relationFieldName || !temp.relationType)
  1243. ) {
  1244. // 关联条件不足
  1245. validateParams.isRelationFieldAll = true;
  1246. }
  1247. if (temp.relationFieldList.length) {
  1248. this.validateField(temp.relationFieldList, validateParams);
  1249. }
  1250. }
  1251. },
  1252. // 校验字段合法性(非递归版)
  1253. validateTableData(tableFieldList) {
  1254. if (!tableFieldList.length) {
  1255. return {
  1256. val: false,
  1257. meg: "字段个数不能为空",
  1258. };
  1259. }
  1260. for (let i = 0; i < tableFieldList.length; i++) {
  1261. let temp = tableFieldList[i];
  1262. if (!temp.fieldDescription?.trim() && temp.isShow) {
  1263. return {
  1264. val: false,
  1265. msg: "显示的字段,字段描述不能为空",
  1266. };
  1267. }
  1268. if (
  1269. temp.relationTable &&
  1270. (!temp.relationFieldName || !temp.relationType)
  1271. ) {
  1272. return {
  1273. val: false,
  1274. msg: "关联条件不足,请完善关联条件",
  1275. };
  1276. }
  1277. }
  1278. if (tableFieldList.filter((item) => item.isShow).length == 0) {
  1279. return {
  1280. val: false,
  1281. msg: "显示的字段数不能为空",
  1282. };
  1283. }
  1284. if (
  1285. tableFieldList.filter((item) => item.isExport && !item.isChildren)
  1286. .length == 0
  1287. ) {
  1288. return {
  1289. val: false,
  1290. msg: "导出字段中至少应有一个主表字段",
  1291. };
  1292. }
  1293. // 导出的字段的描述不能重复
  1294. let describeArr = tableFieldList
  1295. .filter((item) => item.isExport)
  1296. .map((item) => item.fieldDescription);
  1297. let isRepeat = false;
  1298. describeArr.map((item) => {
  1299. if (describeArr.indexOf(item) != describeArr.lastIndexOf(item)) {
  1300. isRepeat = true;
  1301. }
  1302. });
  1303. if (isRepeat) {
  1304. return {
  1305. val: false,
  1306. msg: "导出的字段描述不能重复",
  1307. };
  1308. }
  1309. return {
  1310. val: true,
  1311. msg: "",
  1312. };
  1313. },
  1314. // 递归拼接查询语句
  1315. getSQLString(tableFieldList, fieldArr, tableArr, sqlType = "mysql") {
  1316. let prefix = "{DBNAME}.";
  1317. let asOrSpace = sqlType == "oracle" ? " " : " AS ";
  1318. for (let i = 0; i < tableFieldList.length; i++) {
  1319. let temp = tableFieldList[i];
  1320. // if (temp.isShow) {
  1321. let tempArr = prefix + temp.tableName + "." + temp.fieldName;
  1322. // 给主表也加上表名前缀
  1323. // if (temp.isChildren) {
  1324. tempArr += asOrSpace + temp.tableName + "_" + temp.fieldName;
  1325. // }
  1326. fieldArr.push(tempArr);
  1327. // }
  1328. if (temp.relationTable && temp.relationFieldName && temp.relationType) {
  1329. // fieldArr.push(temp.relationTable + "." + temp.relationFieldName);
  1330. let isNeedUsername = sqlType == "oracle" ? this.username + "." : "";
  1331. tableArr.push(
  1332. temp.relationType +
  1333. " " +
  1334. isNeedUsername +
  1335. prefix +
  1336. temp.relationTable +
  1337. asOrSpace +
  1338. temp.relationTable +
  1339. " ON " +
  1340. prefix +
  1341. temp.relationTable +
  1342. "." +
  1343. temp.relationFieldName +
  1344. " = " +
  1345. prefix +
  1346. temp.tableName +
  1347. "." +
  1348. temp.fieldName
  1349. );
  1350. }
  1351. // if (temp.relationFieldList.length) {
  1352. // this.getSQLString(temp.relationFieldList, fieldArr, tableArr);
  1353. // }
  1354. }
  1355. // 如果主键不包含显示,则添加至sql语句中
  1356. let isNotInclude = this.primaryKeyList.find(
  1357. (val) => !val.isShow && val.fieldName == this.formData.primaryKey
  1358. );
  1359. if (isNotInclude) {
  1360. fieldArr.push(
  1361. prefix +
  1362. isNotInclude.tableName +
  1363. "." +
  1364. isNotInclude.fieldName +
  1365. asOrSpace +
  1366. isNotInclude.tableName +
  1367. "_" +
  1368. isNotInclude.fieldName
  1369. );
  1370. }
  1371. },
  1372. // 拼接查询sql语句
  1373. getSQLStr() {
  1374. let classificationData =
  1375. this.$refs.classificationQueryRef.getConditions(); //按钮中的查询条件
  1376. let prefix = "{DBNAME}.";
  1377. let sqlType = this.databaseType; //数据库类型
  1378. let asOrSpace = sqlType == "oracle" ? " " : " AS ";
  1379. // let sqlType = "oracle";
  1380. let sql = "";
  1381. // mysql
  1382. sql += "SELECT ";
  1383. let fieldNameArr = [],
  1384. relaTypeArr = [];
  1385. this.getSQLString(
  1386. this.tableFieldList,
  1387. fieldNameArr,
  1388. relaTypeArr,
  1389. sqlType
  1390. );
  1391. // if (discriISEmpty) {
  1392. // return false;
  1393. // }
  1394. let styleFieldList = this.$refs.styleTableRef.getStyleTableField();
  1395. styleFieldList = styleFieldList.map((item) => {
  1396. return `${prefix}${item}${asOrSpace}${item.replace(".", "_")}`;
  1397. });
  1398. let set = new Set([...fieldNameArr, ...styleFieldList]);
  1399. fieldNameArr = [...set];
  1400. let isNeedUsername = sqlType == "oracle" ? this.username + "." : "";
  1401. sql +=
  1402. fieldNameArr.join(",") +
  1403. " FROM " +
  1404. isNeedUsername +
  1405. prefix +
  1406. this.tableName +
  1407. asOrSpace +
  1408. this.tableName;
  1409. if (relaTypeArr.length) {
  1410. sql += " " + relaTypeArr.join(" ");
  1411. }
  1412. return sql;
  1413. },
  1414. getStaticSQL(key) {
  1415. let prefix = "{DBNAME}.";
  1416. let sqlType = this.databaseType; //数据库类型
  1417. // let sqlType = "oracle";
  1418. let sql = "";
  1419. // mysql
  1420. sql += "SELECT ";
  1421. let fieldNameArr = [],
  1422. relaTypeArr = [];
  1423. this.getSQLString(
  1424. this.tableFieldList,
  1425. fieldNameArr,
  1426. relaTypeArr,
  1427. sqlType
  1428. );
  1429. let isNeedUsername = sqlType == "oracle" ? this.username + "." : "";
  1430. let asOrSpace = sqlType == "oracle" ? " " : " AS ";
  1431. sql +=
  1432. key +
  1433. " FROM " +
  1434. isNeedUsername +
  1435. prefix +
  1436. this.tableName +
  1437. asOrSpace +
  1438. this.tableName;
  1439. if (relaTypeArr.length) {
  1440. sql += " " + relaTypeArr.join(" ");
  1441. }
  1442. return sql;
  1443. },
  1444. // 处理列表信息
  1445. columnsHandler(columns) {
  1446. let resArr = [];
  1447. columns.forEach((item) => {
  1448. for (const key in item) {
  1449. let tempObj = {};
  1450. tempObj.key = key;
  1451. tempObj.value = item[key];
  1452. resArr.push(tempObj);
  1453. }
  1454. });
  1455. return resArr;
  1456. },
  1457. // 下划线命名转驼峰命名
  1458. toUpperCase(str) {
  1459. let nstr = str.replace(/(?:_)+([^_])/g, function ($0, $1) {
  1460. return $1.toUpperCase();
  1461. });
  1462. nstr = nstr.replace(nstr[0], nstr[0].toLowerCase());
  1463. return nstr;
  1464. },
  1465. // 递归获取列表信息
  1466. getCol(
  1467. tableFieldList,
  1468. columns,
  1469. searchFieldList = [],
  1470. tableExportField = {},
  1471. allColumns = []
  1472. ) {
  1473. if (!tableFieldList.length) return;
  1474. for (let i = 0; i < tableFieldList.length; i++) {
  1475. let temp = tableFieldList[i];
  1476. let tempFieldName = "",
  1477. exportFieldName = "";
  1478. if (temp.isChildren) {
  1479. tempFieldName = temp.tableName + "_" + temp.fieldName;
  1480. exportFieldName = temp.tableName + "@" + temp.fieldName;
  1481. } else {
  1482. // tempFieldName = temp.fieldName;
  1483. tempFieldName = temp.tableName + "_" + temp.fieldName;
  1484. exportFieldName = temp.tableName + "_" + temp.fieldName;
  1485. }
  1486. // 保存所有字段
  1487. let obj = {
  1488. tableName: temp.tableName,
  1489. fieldName: temp.fieldName,
  1490. fieldDescription: temp.fieldDescription,
  1491. };
  1492. allColumns.push(obj);
  1493. if (temp.isShow) {
  1494. let tempObj = {};
  1495. // if (temp.isChildren) {
  1496. // tempObj[temp.tableName + "_" + temp.fieldName] =
  1497. // temp.fieldDescription;
  1498. // } else {
  1499. // tempObj[temp.fieldName] = temp.fieldDescription;
  1500. // }
  1501. tempObj[tempFieldName] = temp.fieldDescription;
  1502. columns.push(tempObj);
  1503. }
  1504. if (temp.isSearch) {
  1505. searchFieldList.push(temp.tableName + "." + temp.fieldName);
  1506. }
  1507. if (temp.isExport) {
  1508. tableExportField[exportFieldName] = temp.fieldDescription;
  1509. }
  1510. // 递归
  1511. // if (temp.relationFieldList) {
  1512. // this.getCol(
  1513. // temp.relationFieldList,
  1514. // columns,
  1515. // searchFieldList,
  1516. // tableExportField
  1517. // );
  1518. // }
  1519. }
  1520. },
  1521. // 更新路由
  1522. reloadRouter() {
  1523. this.$store.dispatch("GenerateRoutes").then((accessRoutes) => {
  1524. this.$router.addRoutes(accessRoutes); // 动态添加可访问路由表
  1525. });
  1526. },
  1527. // 预览结果回调
  1528. async previewHandle() {
  1529. this.$refs.formData.validate(async (valid) => {
  1530. // 至少包含一个查询项
  1531. if (valid) {
  1532. if (!this.tableName) {
  1533. this.$message.error("请选择数据表");
  1534. return;
  1535. }
  1536. // 检验表单合法性
  1537. let validRes = this.validateTableData(this.tableFieldList);
  1538. if (!validRes.val) {
  1539. this.$message.error(validRes.msg);
  1540. return;
  1541. }
  1542. // let validateParams = {
  1543. // isFieldDescrib: false,
  1544. // isRelationFieldAll: false,
  1545. // };
  1546. // this.validateField(this.tableFieldList, validateParams);
  1547. // console.log(validateParams);
  1548. // if (validateParams.isFieldDescrib) {
  1549. // this.$message.error("需要显示的字段描述不能为空");
  1550. // return;
  1551. // }
  1552. // if (validateParams.isRelationFieldAll) {
  1553. // this.$message.error("请补全关联条件");
  1554. // return;
  1555. // }
  1556. // 拼接预览的sql查询语句
  1557. this.queryParams.basicMap.sql = this.getSQLStr();
  1558. // 获取表头信息
  1559. let tempColumns = [],
  1560. searchFieldList = [];
  1561. this.getCol(this.tableFieldList, tempColumns, searchFieldList);
  1562. if (!searchFieldList.length) {
  1563. this.$message.warning("请至少选择一个包含查询字段");
  1564. return false;
  1565. }
  1566. const dataType = await this.getDicts("table_statistic_type");
  1567. this.deepragTableStatisticList = JSON.parse(
  1568. JSON.stringify(this.dragTableStatisticList)
  1569. );
  1570. this.deepragTableStatisticList.forEach((item) => {
  1571. dataType.data.forEach((val) => {
  1572. if (val.dictValue == item.statisticType) {
  1573. item.statisticType = val.dictLabel;
  1574. }
  1575. });
  1576. });
  1577. this.columns = this.columnsHandler(tempColumns);
  1578. this.queryParams.isAsc = this.formData.isAsc;
  1579. // 发送请求获取预览数据
  1580. let res = await dragTablePreview(this.queryParams);
  1581. this.tableDataList = [];
  1582. res.rows.forEach((item) => {
  1583. this.tableDataList.push(item.resultMap);
  1584. });
  1585. this.total = res.total;
  1586. this.isShowPreview = true;
  1587. } else {
  1588. this.$message.warning("请完善表单");
  1589. return false;
  1590. }
  1591. });
  1592. // this.$refs.tableForm.validate((val) => {
  1593. // if (val) {
  1594. // } else {
  1595. // this.$message.warning("请完善表单");
  1596. // return false;
  1597. // }
  1598. // });
  1599. },
  1600. // 处理配置的条件查询按钮数据
  1601. getBtnData(searchArr = []) {
  1602. // 按钮条件list
  1603. let classificationData =
  1604. this.$refs.classificationQueryRef.getConditions();
  1605. let res = searchArr
  1606. .map((item) => {
  1607. return {
  1608. conditionField: item,
  1609. conditionName: "超级查询",
  1610. conditionType: "SuperQuery",
  1611. };
  1612. })
  1613. // .filter((item) => {
  1614. // return !classificationData.some((v) => {
  1615. // return v.conditionField == item.conditionField;
  1616. // });
  1617. // });
  1618. return [...res, ...classificationData];
  1619. },
  1620. // 创建回调
  1621. async createHandle() {
  1622. // console.log(123);
  1623. // this.sqlKey = uuidv4();
  1624. this.isInputInvalid = true;
  1625. this.$refs.formData.validate(async (valid) => {
  1626. if (valid) {
  1627. // 检验表单合法性
  1628. let validRes = this.validateTableData(this.tableFieldList);
  1629. if (!validRes.val) {
  1630. this.$message.error(validRes.msg);
  1631. return;
  1632. }
  1633. let columns = [],
  1634. searchFieldList = [],
  1635. tableExportField = {},
  1636. allColumns = [];
  1637. this.getCol(
  1638. this.tableFieldList,
  1639. columns,
  1640. searchFieldList,
  1641. tableExportField,
  1642. allColumns
  1643. );
  1644. let echoData = {
  1645. tableName: this.tableName,
  1646. tableFieldData: this.tableFieldList,
  1647. formData: this.formData,
  1648. filterData: encodeURIComponent(
  1649. this.$refs.dataFilterRef?.getEchoData()
  1650. ),
  1651. };
  1652. if (!searchFieldList.length) {
  1653. this.$message.warning("请至少选择一个包含查询字段");
  1654. return false;
  1655. }
  1656. // let validateParams = {
  1657. // isFieldDescrib: false,
  1658. // isRelationFieldAll: false,
  1659. // };
  1660. // this.validateField(this.tableFieldList, validateParams);
  1661. // console.log(validateParams);
  1662. // if (validateParams.isFieldDescrib) {
  1663. // this.$message.error("需要显示的字段描述不能为空");
  1664. // return;
  1665. // }
  1666. // if (validateParams.isRelationFieldAll) {
  1667. // this.$message.error("请补全关联条件");
  1668. // return;
  1669. // }
  1670. // console.log("123", columns);
  1671. this.uuid = uuidv4();
  1672. this.tableKey = uuidv4();
  1673. // 表单
  1674. let result;
  1675. let btnTemplate = this.formateBtnTemplate();
  1676. console.log(btnTemplate);
  1677. // if (this.tId && this.menuId) {
  1678. if (this.menuId && !this.isNeedNewMenu) {
  1679. //原菜单存在,仅需要修改菜单数据
  1680. let payLoad = {
  1681. menuId: this.menuId,
  1682. menuName: this.formData.menuName,
  1683. parentId: this.formData.routePath,
  1684. component: "tablelist/commonTable/listInfo",
  1685. icon: "",
  1686. isCache: "0",
  1687. isFrame: "1",
  1688. menuType: "C",
  1689. orderNum: this.menuOrderNum,
  1690. status: "0",
  1691. visible: "0",
  1692. tenantId: this.tenantId,
  1693. };
  1694. result = await updateMenu(payLoad);
  1695. } else if (this.isNeedNewMenu) {
  1696. //给旧表格新增菜单
  1697. let tableKeyObj = {
  1698. tableKey: this.editData.tableKey,
  1699. };
  1700. let payLoad = {
  1701. component: "tablelist/commonTable/listInfo",
  1702. icon: "",
  1703. isCache: "0",
  1704. isFrame: "1",
  1705. menuName: this.formData.menuName,
  1706. // menuId: this.formData.routePath,
  1707. menuType: "C",
  1708. orderNum: this.menuOrderNum,
  1709. parentId: this.formData.routePath,
  1710. path: this.uuid,
  1711. query: JSON.stringify(tableKeyObj),
  1712. status: "0",
  1713. visible: "0",
  1714. tenantId: this.tenantId,
  1715. };
  1716. result = await addMenu(payLoad);
  1717. } else {
  1718. let tableKeyObj = {
  1719. tableKey: this.uuid,
  1720. };
  1721. let payLoad = {
  1722. component: "tablelist/commonTable/listInfo",
  1723. icon: "",
  1724. isCache: "0",
  1725. isFrame: "1",
  1726. menuName: this.formData.menuName,
  1727. // menuId: this.formData.routePath,
  1728. menuType: "C",
  1729. orderNum: this.menuOrderNum,
  1730. parentId: this.formData.routePath,
  1731. path: this.uuid,
  1732. query: JSON.stringify(tableKeyObj),
  1733. status: "0",
  1734. visible: "0",
  1735. tenantId: this.tenantId,
  1736. };
  1737. result = await addMenu(payLoad);
  1738. }
  1739. if (result.code == 200) {
  1740. // 更新路由
  1741. this.reloadRouter();
  1742. let conditions = this.$refs.dataFilterRef?.getConditions();
  1743. let conditionDefaultValueMap = {};
  1744. conditions.map((item) => {
  1745. conditionDefaultValueMap[item.fieldName] = encodeURIComponent(
  1746. " " + item.condition + " " + item.refValue
  1747. );
  1748. });
  1749. // let isAsc = this.formData.isAsc == "ASC" ? 0 : 1;
  1750. let btnData = this.getBtnData(searchFieldList);
  1751. let data = {
  1752. conditionDefaultValueMap, //数据筛选条件
  1753. tId: this.tId,
  1754. dtName: this.formData.menuName,
  1755. menuId: this.formData.routePath,
  1756. tableKey: this.uuid, // 暂定
  1757. dtTableName: this.tableName,
  1758. primaryKey: this.formData.primaryKey,
  1759. orderByColumn: this.formData.orderByColumn,
  1760. sortOrder: this.formData.isAsc,
  1761. sqlKey: this.tableKey,
  1762. dtColumnName: columns, //列字段标题名称(存储显示字段信息
  1763. timeFormat: this.formData.timeFormate,
  1764. // searchFieldList: searchFieldList, //搜索字段数组
  1765. searchFieldList: btnData, //搜索字段数组
  1766. tableSql: this.getSQLStr(), // 暂定
  1767. tableExportField: tableExportField, //导出字段名及列名
  1768. echoData: JSON.stringify(echoData),
  1769. spare: JSON.stringify(allColumns), //所有字段数据
  1770. // 样式相关数据
  1771. dragTableStyleList: this.$refs.styleTableRef.getSaveData(),
  1772. };
  1773. this.dragTableStatisticList.forEach((item) => {
  1774. if (this.tId == "") {
  1775. item.tableKey = this.tableKey;
  1776. this.staticSqlKey = uuidv4();
  1777. item.sqlKey = this.staticSqlKey;
  1778. }
  1779. if (item.sqlKey) {
  1780. this.staticSqlKey = item.sqlKey;
  1781. } else {
  1782. this.staticSqlKey = uuidv4();
  1783. item.sqlKey = this.staticSqlKey;
  1784. }
  1785. let key =
  1786. item.statisticType +
  1787. "(" +
  1788. item.statisticField +
  1789. ")" +
  1790. " as result";
  1791. this.tableSqlList.push({
  1792. tableSql: this.getStaticSQL(key),
  1793. sqlKey: this.staticSqlKey,
  1794. });
  1795. this.searchFieldList = searchFieldList;
  1796. });
  1797. let res;
  1798. let res1;
  1799. // if (this.tId && this.menuId) {
  1800. if (this.tId) {
  1801. data.menuId = this.menuId || result.data;
  1802. data.sqlKey = this.editData.sqlKey;
  1803. data.tableKey = this.editData.tableKey;
  1804. data.dragTableBtnRelevanceList = this.getBtnMapList(
  1805. data.tableKey
  1806. );
  1807. res = await editTable(data);
  1808. this.dragTableStatisticList.forEach((item) => {
  1809. item.tableKey = this.editData.tableKey;
  1810. });
  1811. // console.log(res);
  1812. res1 = await updateStatistic({
  1813. tableKey: this.editData.tableKey,
  1814. dragTableStatisticList: this.dragTableStatisticList,
  1815. tableSqlList: this.tableSqlList,
  1816. searchFieldList: this.searchFieldList,
  1817. dtTableName: this.tableName,
  1818. });
  1819. } else {
  1820. data.menuId = result.data;
  1821. data.dragTableBtnRelevanceList = this.getBtnMapList(
  1822. data.tableKey
  1823. );
  1824. res = await addDragTable(data);
  1825. // console.log('123456789', res)
  1826. this.dragTableStatisticList.forEach((item) => {
  1827. item.tableKey = this.uuid;
  1828. });
  1829. if (res.code == 200 && this.dragTableStatisticList.length !== 0) {
  1830. // 新增统计数据
  1831. res1 = addStatistic({
  1832. tableKey: this.uuid,
  1833. dragTableStatisticList: this.dragTableStatisticList,
  1834. tableSqlList: this.tableSqlList,
  1835. searchFieldList: this.searchFieldList,
  1836. dtTableName: this.tableName,
  1837. });
  1838. }
  1839. if (res.code == 200) {
  1840. // 新增默认按钮数据
  1841. btnTemplate.tableKey = data.tableKey;
  1842. btnTemplate.menuID = result.data;
  1843. let btnRes = await insertByDefaultBtn(btnTemplate);
  1844. if (btnRes.code == 200) {
  1845. console.log(btnRes);
  1846. // 发送权限请求
  1847. let payload = btnRes.data.map((item) => {
  1848. return {
  1849. ...item,
  1850. tenantId: this.tenantId,
  1851. };
  1852. });
  1853. let btnPowerRes = await tbnHasPerms(payload);
  1854. } else {
  1855. console.error(btnRes);
  1856. }
  1857. }
  1858. }
  1859. // 关闭当前页面
  1860. if (this.tId) {
  1861. if (res.code == 200) {
  1862. this.$message.success("修改成功");
  1863. this.$tab.closePage();
  1864. this.$router.push({
  1865. path: "/system/fromModel/index/tablelist",
  1866. });
  1867. } else {
  1868. this.$message.warning("修改失败");
  1869. }
  1870. } else {
  1871. if (res.code == 200) {
  1872. this.$message.success("创建成功");
  1873. this.$tab.closePage();
  1874. this.$router.push({
  1875. path: "/system/fromModel/index/tablelist",
  1876. });
  1877. } else {
  1878. this.$message.warning("创建失败");
  1879. }
  1880. this.isShowPreview = false;
  1881. }
  1882. } else {
  1883. this.$message.warning(result.msg);
  1884. return;
  1885. }
  1886. } else {
  1887. this.$message.warning("请完善表单");
  1888. return false;
  1889. }
  1890. });
  1891. },
  1892. getBtnMapList(tableKey) {
  1893. let res = this.formData.btnGroupList.map((item) => {
  1894. return {
  1895. tableKey,
  1896. btnKey: item,
  1897. };
  1898. });
  1899. return res;
  1900. },
  1901. // 修改表格回显数据
  1902. async initTableData(tId) {
  1903. let res = await getTableInfo(tId);
  1904. if (res.code == 200) {
  1905. this.dragTableStatisticList = res.data.dragTableStatisticList;
  1906. this.dragTableStyleList = res.data.dragTableStyleList;
  1907. let echoData = JSON.parse(res.data.echoData);
  1908. this.tableName = echoData.tableName;
  1909. this.tableFieldList = echoData.tableFieldData;
  1910. this.filterDataEcho = echoData.filterData;
  1911. let {
  1912. isShowList,
  1913. timeFormate,
  1914. orderByColumn,
  1915. isAsc,
  1916. primaryKey,
  1917. menuName,
  1918. btnGroupList,
  1919. } = echoData.formData;
  1920. Object.assign(this.formData, {
  1921. menuName,
  1922. isShowList,
  1923. timeFormate,
  1924. orderByColumn,
  1925. isAsc,
  1926. primaryKey,
  1927. btnGroupList,
  1928. });
  1929. this.formData.routePath = this.getParentMenuId(
  1930. res.data.menuId,
  1931. this.menus,
  1932. {}
  1933. );
  1934. //处理联合查询回显数据
  1935. this.classificationDataEcho = res.data.searchFieldList.filter(
  1936. (item) => item.conditionType != "SuperQuery" && item.conditionType != "DefaultQuery"
  1937. );
  1938. if (!this.formData.routePath) {
  1939. this.$message.warning("该表格菜单路由已经删除,请重新配置");
  1940. this.isNeedNewMenu = true;
  1941. }
  1942. // this.formData.routePath
  1943. this.editData = res.data;
  1944. let val = await getParticMenu(res.data.tableKey);
  1945. if (val.code == 200) {
  1946. this.menuId = val.data?.menuId;
  1947. }
  1948. } else {
  1949. this.$message.error("数据回显失败");
  1950. }
  1951. },
  1952. // 获取父级menuId
  1953. getParentMenuId(menuId, menus) {
  1954. let res;
  1955. for (let i = 0; i < menus.length; i++) {
  1956. let item = menus[i];
  1957. if (item.menuId == menuId) {
  1958. res = item.parentId;
  1959. break;
  1960. } else if (item.children?.length) {
  1961. if (
  1962. this.getParentMenuId(
  1963. menuId,
  1964. JSON.parse(JSON.stringify(item.children))
  1965. )
  1966. ) {
  1967. res = this.getParentMenuId(
  1968. menuId,
  1969. JSON.parse(JSON.stringify(item.children))
  1970. );
  1971. }
  1972. }
  1973. }
  1974. return res;
  1975. },
  1976. // tab切换
  1977. tabhandleClick() {
  1978. this.menudata = this.activeName != "menuedit" ? true : false;
  1979. },
  1980. // 添加数据字段对话框
  1981. async addDataDialog() {
  1982. this.staictitle = "添加统计数据字段";
  1983. this.isShowAddData = true;
  1984. this.dataType = await this.getDicts("table_statistic_type");
  1985. this.dataType = this.dataType.data;
  1986. // console.log(this.dataType)
  1987. },
  1988. async updataDialog() {
  1989. // console.log(this.dataType)
  1990. },
  1991. // 修改数据字段
  1992. upadtaData() {
  1993. this.dragTableStatisticList.forEach((item, index) => {
  1994. // console.log(this.dataCountFormData);
  1995. if (item.id !== undefined && item.id == this.dataCountFormData.id) {
  1996. this.dragTableStatisticList[index] = this.dataCountFormData;
  1997. } else if (item.xid == this.dataCountFormData.xid) {
  1998. this.dragTableStatisticList[index] = this.dataCountFormData;
  1999. }
  2000. });
  2001. this.isShowAddData = false;
  2002. // console.log(this.dragTableStatisticList)
  2003. this.dataCountFormData = {};
  2004. },
  2005. // 添加数据字段
  2006. addData() {
  2007. // console.log(this.dataCountFormData);
  2008. this.dataCountFormData.xid = Date.now();
  2009. this.dataCountFormData.tableKey = this.tableKey;
  2010. this.dragTableStatisticList.push(this.dataCountFormData);
  2011. this.isShowAddData = false;
  2012. this.dataCountFormData = {};
  2013. },
  2014. // 关闭添加数据字段
  2015. closeAddDialog() {
  2016. this.isShowAddData = false;
  2017. this.dataCountFormData = {};
  2018. },
  2019. // 确定统计
  2020. countHandle() {
  2021. addStatistic({
  2022. dragTableStatisticList: this.dragTableStatisticList,
  2023. tableSqlList: this.tableSqlList,
  2024. searchFieldList: this.searchFieldList,
  2025. dtTableName: this.tableName,
  2026. }).then((res) => {
  2027. // console.log(res)
  2028. });
  2029. },
  2030. // 修改统计信息
  2031. async handleUpdateStat(row) {
  2032. // console.log(row);
  2033. this.dataCountFormData = row;
  2034. this.dataCountFormData.xid = Date.now();
  2035. this.staictitle = "修改统计数据字段";
  2036. this.dataType = await this.getDicts("table_statistic_type");
  2037. this.dataType = this.dataType.data;
  2038. this.isShowAddData = true;
  2039. // console.log(this.dataCountFormData)
  2040. // console.log(this.dragTableStatisticList);
  2041. },
  2042. // 删除统计信息
  2043. handleDeleteStat(row) {
  2044. this.dragTableStatisticList.forEach((item, index) => {
  2045. if (item.id == row.id) {
  2046. this.dragTableStatisticList.splice(index, 1);
  2047. }
  2048. });
  2049. },
  2050. // 获取当前表描述
  2051. getTableCommont(tableName, tableList) {
  2052. return tableList.find((item) => item.tableName == tableName).tableComment;
  2053. },
  2054. // 获取按钮组数据
  2055. async getBtnList() {
  2056. let res = await listBtn({isEnablePaging: false, btnParentId: 0});
  2057. // this.btnGroupOption=res.rows
  2058. // this.btnGroupOptions = res.rows.filter((item) => !item.whetherBind);
  2059. this.btnGroupOptions = res.rows.filter((item) => {
  2060. let isMyBtn = this.formData.btnGroupList.some(
  2061. (val) => item.btnKey == val
  2062. );
  2063. return !item.whetherBind || isMyBtn;
  2064. });
  2065. },
  2066. },
  2067. created() {
  2068. },
  2069. async mounted() {
  2070. this.getBtnTemplate();
  2071. this.getAllTable();
  2072. this.initDragTable();
  2073. await this.getMenuList();
  2074. if (this.$route.query.tId) {
  2075. this.tId = this.$route.query.tId;
  2076. await this.initTableData(this.tId);
  2077. }
  2078. this.getBtnList();
  2079. },
  2080. };
  2081. </script>
  2082. <style scoped lang="scss">
  2083. .discribe {
  2084. display: block;
  2085. max-width: 200px;
  2086. white-space: nowrap;
  2087. overflow: hidden;
  2088. text-overflow: ellipsis;
  2089. }
  2090. .ipt {
  2091. height: 36px;
  2092. line-height: 36px;
  2093. font-size: 14px;
  2094. width: 100%;
  2095. outline: none;
  2096. text-align: center;
  2097. background-color: #fff;
  2098. border: 1px solid #dcdfe6;
  2099. color: #606266;
  2100. display: inline-block;
  2101. border-radius: 4px;
  2102. }
  2103. .isNullDesc {
  2104. border-color: #ff4949 !important;
  2105. }
  2106. .ipt:focus {
  2107. border-color: #1890ff;
  2108. }
  2109. ::v-deep .right_card {
  2110. min-height: 500px !important;
  2111. }
  2112. ::v-deep .vue-treeselect--has-value .vue-treeselect__input {
  2113. vertical-align: middle !important;
  2114. }
  2115. .menudata {
  2116. width: 70% !important;
  2117. }
  2118. .edit {
  2119. width: 30% !important;
  2120. }
  2121. .mb10 {
  2122. margin-top: 10px;
  2123. }
  2124. .cardBox {
  2125. display: flex;
  2126. align-content: space-between;
  2127. flex-wrap: wrap;
  2128. align-content: flex-start;
  2129. }
  2130. .card {
  2131. /* width:15%; */
  2132. height: 150px;
  2133. flex-basis: 15%;
  2134. margin-bottom: 10px;
  2135. margin-right: 15px;
  2136. min-width: 180px;
  2137. .title {
  2138. /* width:20%; */
  2139. font-size: 18px;
  2140. margin-bottom: 5px;
  2141. white-space: nowrap;
  2142. overflow: hidden;
  2143. text-overflow: ellipsis;
  2144. }
  2145. .description {
  2146. width: 70%;
  2147. font-size: 13px;
  2148. color: #9699a2;
  2149. overflow: hidden;
  2150. text-overflow: ellipsis;
  2151. display: -webkit-box;
  2152. -webkit-box-orient: vertical;
  2153. -webkit-line-clamp: 3;
  2154. word-break: break-all;
  2155. float: left;
  2156. }
  2157. .type {
  2158. float: right;
  2159. margin-top: 40px;
  2160. .statisticType {
  2161. font-size: 18px;
  2162. }
  2163. }
  2164. .count {
  2165. font-size: 25px;
  2166. }
  2167. }
  2168. .mb8 {
  2169. ::v-deep .el-col-18 {
  2170. width: 30% !important;
  2171. min-width: 220px !important;
  2172. }
  2173. ::v-deep .previewbtn {
  2174. min-width: 190px !important;
  2175. }
  2176. }
  2177. </style>