fabu.vue 28 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886887888889890891892893894895896897898899900901902903904905906907908909910911912913914915916917918919920921922923924925926927928929930931932933934
  1. <template>
  2. <!-- 审核devkind = 'SYS' -->
  3. <div style="width: 100%;;display: flex;">
  4. <div style="width: 15%;;background-color: #F2F6FC;max-height: 85vh;overflow: auto;">
  5. <div style="display: flex;padding-top: 1%;padding-top: 5%;">
  6. <el-input
  7. v-model="inputNode"
  8. style="width:90%;margin-left: 5%;background-color: #ebeef5;"
  9. class="w-50 m-2"
  10. :prefix-icon="Search"
  11. />
  12. <!-- <el-button style="margin-left: 2%;width: 10%;background-color: #F7F7F7" :icon="Filter"/> -->
  13. <!-- <el-button type="primary" @click="showAdd" style="margin-left: 5%;width: 10%;" :icon="Plus"/> -->
  14. </div>
  15. <!-- <Plus style="width: 1em; height: 1em; margin-left:90%;cursor: pointer;color: #337ecc;" @click="showAddTree"/> -->
  16. <el-tree :expand-on-click-node="false" ref="treeRef" :filter-node-method="filterNode" :current-node-key="currentNodeKey" class="treeLeft" :data="data" @node-click="handleNodeClick" node-key="id" style="margin-left: 5%;margin-top: 5%;width: 90%;background-color: transparent;" default-expand-all :key="valueKet">
  17. <template #default="{ node, data }">
  18. <span style="justify-content: space-between;display: flex;width: 100%;align-items: center;">
  19. <div class="custom-tree-node">
  20. <svg-icon icon-class="model2" style="color: #eebe77;" v-if="data.nodeType=='MODEL'"/>
  21. <svg-icon icon-class="model" dstyle="color: #13E03B;" v-if="data.nodeType=='SERVICE'"/>
  22. <svg-icon svg-icon icon-class="cate" style="color: red;" v-if="data.nodeType=='TREE'"/>
  23. <span>{{ node.label }}</span>
  24. </div>
  25. </span>
  26. </template>
  27. </el-tree>
  28. </div>
  29. <div style="width: 84%;margin-left: 1%;padding-top: 0.5%;" class="tab-container">
  30. <div>
  31. <el-table
  32. :data="tableData"
  33. style="width: 98%;margin-left: 1%;margin-top: 0.5%;"
  34. :cell-style="{ padding:'5px' }"
  35. :header-cell-style="{fontSize: '14px',height: heightAll*0.01+'px',}"
  36. :row-style="{ fontSize: '17px',textAlign:'center'}"
  37. border >
  38. <el-table-column type="index" label="序号" width="80">
  39. <template #default="{ $index }">
  40. <div style="text-align: center;">
  41. {{ $index + 1 }}
  42. </div>
  43. </template>
  44. </el-table-column>
  45. <el-table-column prop="name" label="服务名称" width="200">
  46. </el-table-column>
  47. <el-table-column prop="type" label="接口类型" width="200">
  48. </el-table-column>
  49. <el-table-column prop="url" label="接口地址" show-overflow-tooltip/>
  50. <el-table-column prop="rqtype" label="请求方式" width="200"/>
  51. <el-table-column prop="rptype" label="响应类型" width="150">
  52. <template #default="scope">
  53. <div style="text-align: center;display: flex;" v-if="scope.row.rptype=='1'">
  54. JSON
  55. </div>
  56. <div style="text-align: center;display: flex;" v-if="scope.row.rptype=='2'">
  57. XML
  58. </div>
  59. <div style="text-align: center;display: flex;" v-if="scope.row.rptype=='3'">
  60. HTML
  61. </div>
  62. </template>
  63. </el-table-column>
  64. <el-table-column prop="audit" label="发布状态" width="100">
  65. <template #default="scope">
  66. <div style="text-align: center;display: flex;color:#67C23A" v-if="scope.row.publish=='1'">
  67. 已发布
  68. </div>
  69. <div style="text-align: center;display: flex;color:#F56C6C" v-if="scope.row.publish=='0'||scope.row.publish==null">
  70. 未发布
  71. </div>
  72. </template>
  73. </el-table-column>
  74. <el-table-column prop="address" label="操作" width="150">
  75. <template #default="scope">
  76. <!-- <div style="display: flex;justify-content: space-between;width: 100%;">
  77. <el-button type="danger" text size="mini" style="margin-left: -5%;" @click="handleDelete(scope.row)">注销</el-button>
  78. <el-button @click="showDe(scope.row)" type="primary" text size="mini" style="margin-left: 0%;">查看</el-button>
  79. <el-button @click="testSer(scope.row)" type="primary" text size="mini" style="margin-left: 0%;">测试</el-button>
  80. <el-button @click="testSer(scope.row)" type="primary" text size="mini" style="margin-left: 0%;">审核</el-button>
  81. </div> -->
  82. <div style="display: flex;">
  83. <el-button @click="shenhe(scope.row)" type="primary" text size="mini" style="margin-left: 0%;">发布</el-button>
  84. <el-button @click="showLog(scope.row)" type="primary" text size="mini" style="margin-left: 0%;">日志</el-button>
  85. </div>
  86. </template>
  87. </el-table-column>
  88. </el-table>
  89. </div>
  90. <el-dialog @close="clearAdd" v-model="dialogVisible" title="" width="60%" destroy-on-close :key="tableKey">
  91. <div style="display: flex;align-items: center;">
  92. <div v-if="detailJson.rqtype==='GET'">
  93. <el-tag class="ml-2" type="warning">GET</el-tag>
  94. </div>
  95. <div v-if="detailJson.rqtype==='POST'">
  96. <el-tag class="ml-2" type="warning">POST</el-tag>
  97. </div>
  98. <div style="margin-left: 1%;">
  99. {{ detailJson.name }}:
  100. </div>
  101. <div style="margin-left: 1%;">
  102. {{ detailJson.url }}
  103. </div>
  104. </div>
  105. <el-descriptions style="margin-top: 1%;" :column="3" border>
  106. <el-descriptions-item label="接口类型">{{ detailJson.type }}</el-descriptions-item>
  107. <el-descriptions-item label="请求方式">{{ detailJson.rqtype }}</el-descriptions-item>
  108. <el-descriptions-item label="响应类型">{{ detailJson.rptype }}</el-descriptions-item>
  109. <el-descriptions-item label="服务分类">{{ detailJson.cateCode }}</el-descriptions-item>
  110. </el-descriptions>
  111. <div style="margin-top:4%;font-size: 18px;">
  112. 请求参数
  113. </div>
  114. <el-table
  115. style="margin-top: 1%;width: 98%;"
  116. :data="tableDataCan"
  117. :cell-style="{ textAlign: 'center',padding:'2px 0' }"
  118. :header-cell-style="{fontSize: '14px', textAlign: 'center'}"
  119. :row-style="{ height: heightAll*0.01+'px',fontSize: '17px',textAlign:'center' }"
  120. border >
  121. <el-table-column prop="paramCode" label="参数字段">
  122. </el-table-column>
  123. <el-table-column prop="paramName" label="参数名称">
  124. </el-table-column>
  125. <el-table-column prop="paramType" label="参数类型" width="200">
  126. </el-table-column>
  127. <el-table-column prop="paramValue" label="参数示例">
  128. </el-table-column>
  129. <el-table-column prop="paramNote" label="参数说明" show-overflow-tooltip>
  130. </el-table-column>
  131. </el-table>
  132. <div style="margin-top:4%;font-size: 18px;">
  133. 返回参数
  134. </div>
  135. <el-input readonly placeholder="" :rows="8" type="textarea" v-model="dataJsonXiang" size="mini" text style="margin-top: 1%;width: 98%;" ></el-input>
  136. <template #footer>
  137. <span class="dialog-footer">
  138. <el-button type="primary" @click="dialogVisible = false" size="mini">
  139. 确定
  140. </el-button>
  141. </span>
  142. </template>
  143. </el-dialog>
  144. <el-dialog @close="clearAdd" v-model="dialogVisibleTest" title="" width="40%" destroy-on-close :key="tableKey">
  145. <el-form size="mini" :key="tableKey" style="margin-top: 1%;width: 90%;" label-position="right" label-width="120px" :rules="rulesLev">
  146. <el-form-item label="是否发布:" prop="" style="">
  147. <el-radio-group v-model="publish" style="margin-top: -0.5%;">
  148. <el-radio value="1" size="large">发布</el-radio>
  149. <el-radio value="0" size="large">不发布</el-radio>
  150. </el-radio-group>
  151. </el-form-item>
  152. <el-form-item label="说明:" prop="" style="">
  153. <el-input v-model="auditRemark" style="width: 100%;" type="textarea"/>
  154. </el-form-item>
  155. </el-form>
  156. <div style="display: flex;font-size: 13px;align-items: center;line-height: 1.5;margin-left: 1%;margin-top: 5%;">
  157. <div style="">
  158. 当前审核人:
  159. </div>
  160. <div>
  161. {{userName}}
  162. </div>
  163. <div style="margin-left: 5%;">
  164. 当前日期:
  165. </div>
  166. <div>
  167. {{date}}
  168. </div>
  169. </div>
  170. <template #footer>
  171. <span class="dialog-footer">
  172. <el-button size="mini" @click="dialogVisibleTest = false">取消</el-button>
  173. <el-button type="primary" @click="saveShenhe" size="mini">
  174. 提交
  175. </el-button>
  176. </span>
  177. </template>
  178. </el-dialog>
  179. <el-dialog @close="clearFromLev" title="" v-model="dialogVisibleLevel" width="50%" destroy-on-close :key="tableKey">
  180. <el-table
  181. style="margin-top: 1%;width: 98%;min-height: 400px;"
  182. :data="tableDataLog"
  183. :cell-style="{ textAlign: 'center',padding:'2px 0' }"
  184. :header-cell-style="{fontSize: '14px', textAlign: 'center'}"
  185. :row-style="{ height: heightAll*0.01+'px',fontSize: '17px',textAlign:'center' }"
  186. border >
  187. <el-table-column prop="createBy" label="发布人员名称">
  188. </el-table-column>
  189. <el-table-column prop="createTime" label="发布时间">
  190. </el-table-column>
  191. <el-table-column prop="remark" label="发布备注" show-overflow-tooltip>
  192. </el-table-column>
  193. <el-table-column prop="audit" label="发布状态" width="100">
  194. <template #default="scope">
  195. <div style="text-align: center;display: flex;color:#67C23A" v-if="scope.row.state=='1'">
  196. 已发布
  197. </div>
  198. <div style="text-align: center;display: flex;color:#67C23A" v-if="scope.row.state=='2'">
  199. 下线
  200. </div>
  201. <div style="text-align: center;display: flex;color:#F56C6C" v-if="scope.row.state=='0'||scope.row.state==null">
  202. 未发布
  203. </div>
  204. </template>
  205. </el-table-column>
  206. </el-table>
  207. <template #footer>
  208. <span class="dialog-footer">
  209. <el-button type="primary" size="mini" @click="dialogVisibleLevel = false">确定</el-button>
  210. </span>
  211. </template>
  212. </el-dialog>
  213. </div>
  214. </div>
  215. </template>
  216. <script setup>
  217. import {getCatalog} from "@/api/service/catalog";
  218. import { Plus,Search,Filter,Promotion,Check } from '@element-plus/icons-vue'
  219. import { reactive } from 'vue'
  220. import { changeSerShenhe } from "@/api/register/regCom";
  221. import { modelTreeSelect,getSerDe,addService,shenheLog,addServiceParam,delService,addTree,deTree,getServiceInfo,testService,publishModel } from "@/api/service/info";
  222. import { ref, onMounted, onUnmounted, nextTick,onBeforeMount } from 'vue';
  223. import { getUserProfile } from "@/api/system/user";
  224. import JsonViewer from 'vue-json-viewer'
  225. import 'vue-json-viewer/style.css'
  226. import JsonEditorVue from 'json-editor-vue3'
  227. import { cloneDeep } from 'lodash'
  228. import { useClipboard } from "@vueuse/core";
  229. const { proxy } = getCurrentInstance();
  230. const tableDataLog = ref([])
  231. const JsonAdd= ref(JSON.stringify({ data: "初始值1" }))
  232. const exampleAdd = ref('')
  233. const dialogVisibleLevel = ref(false)
  234. const detail = ref({
  235. name:'',
  236. rqtype:'',
  237. rptype:''
  238. })
  239. const userName = ref('')
  240. const date = ref('')
  241. const publish = ref('1')
  242. const auditRemark = ref()
  243. const show1Lev = ref(true)
  244. const inputNode =ref('')
  245. const isEdit = ref(true)
  246. const dataReturn = ref('')
  247. const optionsCan = ref([
  248. {
  249. label:"string",
  250. value:'string'
  251. },
  252. {
  253. label:"int",
  254. value:'int'
  255. },
  256. {
  257. label:"boolean",
  258. value:'boolean'
  259. },
  260. {
  261. label:"array",
  262. value:'array'
  263. },
  264. {
  265. label:"object",
  266. value:'object'
  267. },
  268. {
  269. label:"number",
  270. value:'number'
  271. },
  272. {
  273. label:"null",
  274. value:'null'
  275. },
  276. {
  277. label:"any",
  278. value:'any'
  279. },
  280. ])
  281. const currentNodeKey = ref('')
  282. const options = ref([
  283. {label:'开发中',
  284. value:'1'
  285. },
  286. {label:'运行中',
  287. value:'2'
  288. },
  289. ])
  290. const dataJsonXiang = ref([])
  291. const parTree = ref({})
  292. const valueKet = ref(0)
  293. const tableDataCan = ref([
  294. {
  295. itemName:'',
  296. itemCode:'',
  297. paramType:'',
  298. paramNote:''
  299. }
  300. ])
  301. const dialogVisibleTest = ref(false)
  302. const optionsMdid = ref([])
  303. const optionsRqtype = ref([
  304. {label:'GET',
  305. value:'GET'
  306. },
  307. {label:'POST',
  308. value:'POST'
  309. },
  310. ])
  311. const optionsType= ref([
  312. {label:'RESTful',
  313. value:'RESTful'
  314. },
  315. {label:'WebService',
  316. value:'WebService'
  317. },
  318. {label:'HTTP',
  319. value:'HTTP'
  320. },
  321. {label:'WebSocket',
  322. value:'WebSocket'
  323. },
  324. ])
  325. const data = ref([])
  326. const select = ref('1')
  327. const activeName = ref('first')
  328. const title = ref('')
  329. const titleTree = ref('')
  330. const currentPage = ref(1)
  331. const total = ref(1)
  332. const tableData = ref([])
  333. const tableheight = window.innerHeight*0.7
  334. const heightAll = window.innerHeight
  335. const dialogVisible = ref(false)
  336. const dialogVisibleTree = ref(false)
  337. const isAdd = ref(false)
  338. const isAddTa = ref(false)
  339. const treeId = ref('');
  340. const valueSta = ref('1');
  341. const example = ref('');
  342. const tableDataCanAdd = ref([
  343. {
  344. itemName:'',
  345. itemCode:'',
  346. paramType:'',
  347. paramNote:''
  348. }
  349. ])
  350. const formZu = ref({
  351. itemName:'',
  352. itemTp:'',
  353. itemEn:'',
  354. itemTp:'',
  355. itemDataTp:'',
  356. itemDefaultVal:'',
  357. itemUnit:'',
  358. itemNotes:'',
  359. });
  360. const parId= ref('')
  361. const formJi = ref({
  362. name:'',
  363. cateCode:'',
  364. type:'',
  365. url:'',
  366. rqtype:'',
  367. rptype:'',
  368. intro:'',
  369. });
  370. const rulesJi = reactive({
  371. name: [{ required: true, message: '必填', trigger: 'blur' }],
  372. url: [{ required: true, message: '必填', trigger: 'blur' }],
  373. cateCode: [{ required: true, message: '必填', trigger: 'blur' }],
  374. });
  375. const formRefJi = ref();
  376. const parMdid = ref('')
  377. const formAdd = ref({
  378. name:'',
  379. cateCode:'',
  380. type:'',
  381. url:'',
  382. rqtype:'',
  383. rptype:'',
  384. intro:'',
  385. mdid:''
  386. });
  387. const rulesAdd = reactive({
  388. mdid: [{ required: true, message: '必填', trigger: 'blur' }],
  389. name: [{ required: true, message: '必填', trigger: 'blur' }],
  390. url: [{ required: true, message: '必填', trigger: 'blur' }],
  391. cateCode: [{ required: true, message: '必填', trigger: 'blur' }],
  392. });
  393. const formRefAdd = ref();
  394. const treeRef = ref(null);
  395. const formTree = ref({
  396. itemName:'',
  397. catePid:'',
  398. itemNo:'',
  399. itemNotes:''
  400. });
  401. const rulesTree = reactive({
  402. itemNo: [{ required: true, message: '必填', trigger: 'blur' }],
  403. catePid: [{ required: true, message: '必填', trigger: 'blur' }],
  404. itemName: [{ required: true, message: '必填', trigger: 'blur' }],
  405. });
  406. const formRefTree = ref();
  407. const formLev = ref({
  408. itemName:'',
  409. itemNo:'',
  410. itemNotes:'',
  411. });
  412. const rulesLev = reactive({
  413. itemNotes: [{ required: true, message: '必填', trigger: 'blur' }],
  414. itemNo: [{ required: true, message: '必填', trigger: 'blur' }],
  415. itemName: [{ required: true, message: '必填', trigger: 'blur' }],
  416. });
  417. const formRefLev = ref();
  418. const cascaderOptions = ref([])
  419. const props1 = ref({
  420. checkStrictly: true,
  421. })
  422. const detailJson = ref('')
  423. const parOptions = ref([])
  424. watch(inputNode, (val) => {
  425. treeRef.value?.filter(val); // 调用树的过滤方法
  426. });
  427. const filterNode = (value, data) => {
  428. if (!value) return true; // 空搜索时显示所有节点
  429. return data.label.includes(value); // 检查节点标签是否包含关键字
  430. };
  431. const copied = ref(false);
  432. const parShenhe = ref({})
  433. function showLog(row){
  434. dialogVisibleLevel.value = true
  435. var par = {
  436. proId:row.srvId,
  437. proType:'PUBLISH'
  438. }
  439. shenheLog(par).then(res=>{
  440. tableDataLog.value = res.data
  441. })
  442. }
  443. function saveShenhe(){
  444. parShenhe.value.publish = publish.value
  445. parShenhe.value.auditRemark = auditRemark.value
  446. publishModel(parShenhe).then(res=>{
  447. if(res.code===200){
  448. proxy.$modal.msgSuccess("已发布!");
  449. var par1 = {
  450. data:{id:parMdid.value}
  451. }
  452. handleNodeClick(null,par1,null)
  453. }
  454. dialogVisibleTest.value = false
  455. })
  456. }
  457. function shenhe(row){
  458. dialogVisibleTest.value = true
  459. parShenhe.value = {
  460. srvId:row.srvId,
  461. }
  462. // proxy.$modal.confirm('是否确认审核?').then(function () {
  463. // return changeSerShenhe(par).then(res=>{
  464. // if(res.code===200){
  465. // proxy.$modal.msgSuccess("已审核!");
  466. // handleNodeClick(parMdid.value)
  467. // }
  468. // })
  469. // }).then(() => {
  470. // }).catch(() => {});
  471. }
  472. function test(){
  473. var par = detailJson.value
  474. par.params = tableDataCan.value
  475. testService(par).then(res=>{
  476. console.log(res)
  477. dataReturn.value = res.msg
  478. })
  479. }
  480. function testSer(row){
  481. getSerDe(row.srvId).then(res=>{
  482. if(res.code===200){
  483. detailJson.value = res.data.ptService
  484. console.log(detailJson.value)
  485. dialogVisibleTest.value = true
  486. tableDataCan.value = res.data.list
  487. }
  488. })
  489. }
  490. function showDe(row){
  491. getSerDe(row.srvId).then(res=>{
  492. if(res.code===200){
  493. detailJson.value = res.data.ptService
  494. dialogVisible.value = true
  495. detailJson.value.cateCode = row.cateCode
  496. detailJson.value.rptype = row.rptype
  497. tableDataCan.value = res.data.list
  498. dataJsonXiang.value = res.data.ptService.rpcontent
  499. }
  500. })
  501. }
  502. function filterModelNodes(nodes) {
  503. if (!Array.isArray(nodes)) return [];
  504. const result = [];
  505. for (const node of nodes) {
  506. // 递归处理子节点(如果有)
  507. const filteredChildren = node.children ? filterModelNodes(node.children) : [];
  508. if (node.nodeType === 'MODEL') {
  509. // 保留当前节点,并更新其子节点
  510. node.value = node.id
  511. result.push({
  512. ...node,
  513. children: filteredChildren
  514. });
  515. } else {
  516. // 删除当前节点,将其子节点提升到当前层级
  517. result.push(...filteredChildren);
  518. }
  519. }
  520. return result;
  521. }
  522. function clearAdd(){
  523. tableDataCan.value = [
  524. ]
  525. dataReturn.value = ''
  526. auditRemark.value = ''
  527. publish.value = '1'
  528. }
  529. function extractModelNodesDFSIterative(root) {
  530. const result = [];
  531. const stack = root;
  532. while (stack.length > 0) {
  533. const node = stack.pop();
  534. if (node.nodeType === 'MODEL') {
  535. result.push(node);
  536. }
  537. // 子节点逆序入栈(保证从左到右遍历)
  538. if (node.children) {
  539. for (let i = node.children.length - 1; i >= 0; i--) {
  540. stack.push(node.children[i]);
  541. }
  542. }
  543. }
  544. return result;
  545. }
  546. function delAll(){
  547. proxy.$modal.confirm('是否确认删除?').then(function () {
  548. return deTree(parTree.value.id);
  549. }).then(() => {
  550. getTreeLeft();
  551. proxy.$modal.msgSuccess("删除成功");
  552. dialogVisibleLevel.value = false
  553. }).catch(() => {});
  554. }
  555. function clearFromLev(){
  556. formLev.value = {
  557. itemName:'',
  558. itemNo:'',
  559. itemNotes:'',
  560. }
  561. }
  562. function addNextLevel(){
  563. dialogVisibleLevel.value = true
  564. show1Lev.value = false
  565. }
  566. function saveAddNextLevel(){
  567. formRefLev.value.validate((valid) => {
  568. if(valid){
  569. var par = formLev.value
  570. par.treeType = 'MODEL'
  571. par.treePid = parTree.value.id
  572. addTree(par).then(res=>{
  573. if(res.code===200){
  574. proxy.$modal.msgSuccess("新增成功");
  575. getTreeLeft()
  576. dialogVisibleLevel.value = false
  577. }
  578. })
  579. }
  580. });
  581. }
  582. function add1Level(){
  583. dialogVisibleLevel.value = true
  584. show1Lev.value = true
  585. }
  586. function saveAdd1Level(){
  587. formRefLev.value.validate((valid) => {
  588. if(valid){
  589. var par = formLev.value
  590. par.treeType = 'MODEL'
  591. par.treePid = parTree.value.pid
  592. addTree(par).then(res=>{
  593. if(res.code===200){
  594. proxy.$modal.msgSuccess("新增成功");
  595. getTreeLeft()
  596. dialogVisibleLevel.value = false
  597. }
  598. })
  599. }
  600. });
  601. }
  602. async function delSer(){
  603. proxy.$modal.confirm('是否确认删除?').then(function () {
  604. return delService(parId.value.id);
  605. }).then(() => {
  606. getTreeLeft();
  607. proxy.$modal.msgSuccess("删除成功");
  608. }).catch(() => {});
  609. }
  610. async function addSer(){
  611. console.log(JsonAdd.value)
  612. var valid
  613. await formRefAdd.value.validate((valid1) => {
  614. valid = valid1
  615. });
  616. console.log(valid)
  617. if(valid){
  618. var par = formAdd.value
  619. par.example = exampleAdd.value
  620. par.rpcontent = JsonAdd.value
  621. par.cateCode = par.cateCode[0]
  622. console.log(par)
  623. await addService(par).then(res=>{
  624. if(res.code===200){
  625. var parCan = tableDataCanAdd.value
  626. parCan.srvId = res.data.srvId
  627. addServiceParam(parCan).then(res1=>{
  628. if(res1.code===200){
  629. proxy.$modal.msgSuccess("新增成功");
  630. getTreeLeft()
  631. }
  632. })
  633. }
  634. })
  635. }
  636. }
  637. function showAdd(){
  638. dialogVisible.value = true
  639. }
  640. async function handleNodeClick(node,data,event){
  641. // parTree.value = data.data
  642. // currentNodeKey.value = data.data.id
  643. // isEdit.value = false
  644. // parId.value = data.data
  645. // await getSerDe(data.data.id).then(res=>{
  646. // if(res.data.ptService){
  647. // detail.value = res.data.ptService
  648. // tableDataCan.value = res.data.list
  649. // dataReturn.value = res.data.returnList
  650. // console.log(tableDataCan.value)
  651. // dataJsonXiang.value = res.data.ptService.rpcontent
  652. // formJi.value = res.data.ptService
  653. // example.value = res.data.ptService.example
  654. // }
  655. // })
  656. parMdid.value = data.data.id
  657. var par = {
  658. mdid:data.data.id
  659. }
  660. console.log(data.data.id)
  661. await getServiceInfo(par).then(res=>{
  662. if(res.data){
  663. tableData.value = res.data.serviceList
  664. }
  665. })
  666. parOptions.value.forEach(option => {
  667. option.label = option.cateName;
  668. option.value = option.cateCode;
  669. });
  670. console.log(parOptions.value)
  671. for(var i = 0; i < parOptions.value.length; i++){
  672. for(var i1 = 0; i1 < tableData.value.length; i1++){
  673. console.log(i1);
  674. if(parOptions.value[i].value === tableData.value[i1].cateCode){
  675. tableData.value[i1].cateCode = parOptions.value[i].label
  676. }
  677. }
  678. }
  679. var par = [
  680. {
  681. value:'1',
  682. label:'JSON'
  683. },
  684. {
  685. value:'2',
  686. label:'XML'
  687. },
  688. {
  689. value:'3',
  690. label:'HTML'
  691. }
  692. ]
  693. for(var i = 0; i < par.length; i++){
  694. for(var i1 = 0; i1 < tableData.value.length; i1++){
  695. if(par[i].value === tableData.value[i1].rptype){
  696. tableData.value[i1].rptype = par[i].label
  697. }
  698. }
  699. }
  700. }
  701. async function getTreeLeft(){
  702. var par = {
  703. params:{
  704. level:'2',
  705. devkind:'SYS'
  706. }
  707. }
  708. await modelTreeSelect(par).then(res=>{
  709. par = res.data
  710. data.value = res.data
  711. })
  712. optionsMdid.value = filterModelNodes(par)
  713. console.log(optionsMdid.value)
  714. }
  715. function renameTreeProperties(tree) {
  716. // 深拷贝避免修改原始数据(可选,根据需求)
  717. const newTree = cloneDeep(tree); // 使用 lodash
  718. // 或:const newTree = JSON.parse(JSON.stringify(tree)); // 原生方法(不兼容函数等)
  719. // 递归处理函数
  720. const processNode = (node) => {
  721. // 重命名属性
  722. if ('cateName' in node) {
  723. node.label = node.cateName;
  724. delete node.cateName;
  725. }
  726. if ('cateCode' in node) {
  727. node.value = node.cateCode;
  728. delete node.cateCode;
  729. }
  730. // 递归处理子节点
  731. if (node.children && node.children.length > 0) {
  732. node.children.forEach(child => processNode(child));
  733. }
  734. };
  735. // 遍历根节点
  736. newTree.forEach(rootNode => processNode(rootNode));
  737. return newTree;
  738. }
  739. function fetchData() {
  740. getUserProfile().then(response => {
  741. userName.value = response.data.userName
  742. });
  743. getCatalog().then((r) => {
  744. parOptions.value = r.data
  745. cascaderOptions.value = renameTreeProperties(buildTree(r.data))
  746. console.log(cascaderOptions.value)
  747. });
  748. }
  749. function buildTree(flatData, rootValue = '0') {
  750. const nodeMap = new Map();
  751. const tree = [];
  752. flatData.forEach(item => {
  753. nodeMap.set(item.cateCode, { ...item, children: [] });
  754. });
  755. for (const [code, node] of nodeMap) {
  756. const parentCode = node.catePcode;
  757. if (parentCode === rootValue || !parentCode) {
  758. tree.push(node);
  759. continue;
  760. }
  761. const parent = nodeMap.get(parentCode);
  762. if (parent) {
  763. parent.children.push(node);
  764. } else {
  765. console.warn(`Orphan node detected: ${code}. Parent ${parentCode} not found`);
  766. }
  767. }
  768. return tree;
  769. }
  770. function addPa(){
  771. var par = {
  772. itemName:''
  773. }
  774. tableDataCan.value.push(par)
  775. }
  776. function delCan(index){
  777. tableDataCan.value.splice(index, 1)
  778. }
  779. function addCanAdd(){
  780. var par = {
  781. parName:''
  782. }
  783. tableDataCanAdd.value.push(par)
  784. }
  785. function delCanAdd(index){
  786. tableDataCanAdd.value.splice(index, 1)
  787. }
  788. function getDate(){
  789. const today = new Date();
  790. const year = today.getFullYear();
  791. // 月份加1并补零
  792. const month = String(today.getMonth() + 1).padStart(2, '0');
  793. // 日期补零
  794. const day = String(today.getDate()).padStart(2, '0');
  795. date.value = `${year}-${month}-${day}`;
  796. }
  797. onMounted(() => {
  798. fetchData()
  799. getTreeLeft()
  800. getDate()
  801. });
  802. </script>
  803. <style scoped>
  804. .noBorSel :deep(.el-select__wrapper){
  805. box-shadow: none !important; /* 去除阴影边框 */
  806. border: 1px solid transparent !important; /* 设置透明边框 */
  807. background-color: transparent !important; /* 可选:透明背景 */
  808. }
  809. .noBor :deep(.el-input__wrapper) {
  810. box-shadow: none !important; /* 去除阴影边框 */
  811. border: 1px solid transparent !important; /* 设置透明边框 */
  812. background-color: transparent !important; /* 可选:透明背景 */
  813. }
  814. /* 节点垂直间距 */
  815. :deep(.el-tree-node) {
  816. margin-bottom:5px !important; /* 增大节点间距 */
  817. }
  818. .el-popover.custom-popover {
  819. min-width: 50px;
  820. padding: 8px; /* 可选:调整内边距 */
  821. }
  822. </style>
  823. <style>
  824. .dot {
  825. width: 20px; /* 控制圆点直径 */
  826. height: 20px;
  827. background-color: #333; /* 实心颜色 */
  828. border-radius: 50%; /* 关键属性 */
  829. display: inline-block; /* 确保与其他元素并排 */
  830. }
  831. /* 全局透明样式(不使用 scoped) */
  832. .transparent-select .el-select__wrapper {
  833. background-color: transparent !important;
  834. border-color: transparent !important;
  835. box-shadow: none !important;
  836. }
  837. .transparent-select .el-select__selection {
  838. background-color: transparent;
  839. }
  840. /* 处理悬停和聚焦状态 */
  841. .transparent-select .el-select__wrapper:hover,
  842. .transparent-select .el-select__wrapper.is-focused {
  843. border-color: transparent !important;
  844. box-shadow: none !important;
  845. }
  846. /* 下拉箭头图标 */
  847. .transparent-select .el-select__caret {
  848. color: rgba(0, 0, 0, 0.5); /* 半透明图标 */
  849. }
  850. </style>
  851. <style scoped>
  852. :deep(.treeLeft) .el-tree-node__content {
  853. display: flex !important;
  854. height: 28px; /* 按设计稿调整高度 */
  855. align-items: center;
  856. padding-top: 0 !important;
  857. }
  858. :deep(.treeLeft) .el-tree-node__content:hover {
  859. background-color: #e9e9eb;
  860. }
  861. :deep(.treeLeft) .el-tree-node__content:active {
  862. background-color: rgka(69,157,255,0.1) !important;
  863. }
  864. /* 选中态(Active) */
  865. :deep(.treeLeft) .el-tree-node.is-current > .el-tree-node__content {
  866. background-color: #c6e2ff !important;
  867. }
  868. .tab-container {
  869. height: 100vh; /* 关键:父容器明确高度 */
  870. display: flex;
  871. flex-direction: column;
  872. }
  873. .drag-handle {
  874. cursor: move;
  875. }
  876. .ghost {
  877. opacity: 0.5;
  878. background: #c8ebfb;
  879. }
  880. /* 防止文字选中 */
  881. :deep(.el-table__row) {
  882. user-select: none;
  883. -webkit-user-select: none;
  884. }
  885. </style>
  886. <style scoped lang="scss">
  887. .custom-tree-node {
  888. display: flex; /* 启用 Flex 布局 */
  889. align-items: center; /* 垂直居中 */
  890. gap: 8px; /* 图标与文字间距 */
  891. justify-content: space-between;
  892. }
  893. .el-table .el-table__row td {
  894. height: 60px !important; /* 行高 */
  895. }
  896. .custom-tree-node {
  897. display: flex; /* 启用 Flex 布局 */
  898. align-items: center; /* 垂直居中 */
  899. gap: 8px; /* 图标与文字间距 */
  900. }
  901. </style>