dataJiDe.vue 31 KB

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