index.vue 26 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886887888889890891892893894895
  1. <template>
  2. <div
  3. id="box"
  4. class="bs-container"
  5. @mousemove="mousemoveOnBox"
  6. @mouseup="mouseupOnBox"
  7. >
  8. <el-row
  9. v-show="datasetType === null"
  10. type="flex"
  11. class="layout"
  12. >
  13. <div
  14. id="left-box"
  15. class="left-box"
  16. :style="{ 'transition': transition + 's' }"
  17. >
  18. <div class="inner-container">
  19. <TypeTree
  20. ref="datasetsTypeTree"
  21. :dataset-type-list="datasetTypeList"
  22. :app-code="appCode"
  23. @nodeClick="nodeClick"
  24. @refreshData="refreshData"
  25. @expandedNodes="expandedNodes"
  26. @reCategory="getTreeList"
  27. />
  28. </div>
  29. </div>
  30. <div
  31. class="right-box inner-container"
  32. :style="{ 'transition': transition + 's' }"
  33. >
  34. <div
  35. id="resize"
  36. class="resize pack-up-box"
  37. @mousedown="mousedown"
  38. @mouseup="mouseup"
  39. @mousemove="mousemove"
  40. >
  41. <a
  42. v-if="isPackUpTree"
  43. @click="packUpTree"
  44. @mousedown="resize = null"
  45. @mouseup="resize = null"
  46. @mousemove="resize = null"
  47. >
  48. <i :class="isPackUpTree === false ? 'el-icon-caret-left' : 'el-icon-caret-right'" />
  49. </a>
  50. <a
  51. v-else
  52. class="visible-pack-up"
  53. >
  54. <span>||</span>
  55. </a>
  56. </div>
  57. <el-form
  58. ref="queryForm"
  59. :model="queryForm"
  60. class="filter-container bs-el-form"
  61. @submit.native.prevent
  62. >
  63. <el-form-item
  64. class="filter-item"
  65. prop="name"
  66. >
  67. <el-input
  68. v-model="queryForm.name"
  69. class="bs-el-input"
  70. placeholder="请输入数据集名称"
  71. clearable
  72. @keyup.enter.native="handleSearch()"
  73. @clear="handleSearch()"
  74. />
  75. </el-form-item>
  76. <el-form-item
  77. class="filter-item"
  78. prop="labelIds"
  79. >
  80. <el-select
  81. v-model="queryForm.labelIds"
  82. class="bs-el-select"
  83. popper-class="bs-el-select"
  84. clearable
  85. filterable
  86. multiple
  87. collapse-tags
  88. placeholder="请选择数据集关联标签"
  89. @clear="handleSearch()"
  90. >
  91. <el-option
  92. v-for="labelItem in labelList"
  93. :key="labelItem.id"
  94. :label="labelItem.labelName"
  95. :value="labelItem.id"
  96. />
  97. </el-select>
  98. </el-form-item>
  99. <el-form-item class="filter-item">
  100. <el-button
  101. :loading="dataListLoading"
  102. type="primary"
  103. icon="el-icon-search"
  104. @click="handleSearch()"
  105. >
  106. 查询
  107. </el-button>
  108. </el-form-item>
  109. <el-form-item class="filter-item">
  110. <el-button
  111. v-if="toAdd"
  112. class="bs-el-button-default"
  113. @click="addDataset"
  114. >
  115. 新增
  116. </el-button>
  117. </el-form-item>
  118. </el-form>
  119. <div class="bs-table-box">
  120. <el-table
  121. v-if="isDialog"
  122. ref="userTable"
  123. v-loading="dataListLoading"
  124. class="bs-el-table bs-scrollbar"
  125. :element-loading-text="loadingText"
  126. :data="tableData"
  127. :header-cell-style="sortStyle"
  128. @sort-change="reSort"
  129. @current-change="handleCurrentChange"
  130. @select="selectDs"
  131. @select-all="selectAll"
  132. >
  133. <el-empty slot="empty" />
  134. <el-table-column
  135. v-if="isDialog && multiple"
  136. type="selection"
  137. width="55"
  138. />
  139. <el-table-column
  140. prop="name"
  141. label="数据集名称"
  142. align="left"
  143. show-overflow-tooltip
  144. >
  145. <template slot-scope="scope">
  146. <el-radio
  147. v-if="isDialog && !multiple"
  148. v-model="curRow"
  149. :label="scope.row"
  150. >
  151. {{ scope.row.name }}
  152. </el-radio>
  153. <span v-else>{{ scope.row.name }}</span>
  154. </template>
  155. </el-table-column>
  156. <el-table-column
  157. prop="datasetType"
  158. label="数据集类型"
  159. align="center"
  160. show-overflow-tooltip
  161. >
  162. <template slot-scope="scope">
  163. <span>{{ datasetTypeList.find(type=>type.datasetType===scope.row.datasetType) ? datasetTypeList.find(type=>type.datasetType===scope.row.datasetType).name : '其他' }}</span>
  164. </template>
  165. </el-table-column>
  166. <el-table-column
  167. prop="labelIds"
  168. label="标签"
  169. align="center"
  170. show-overflow-tooltip
  171. >
  172. <template slot-scope="scope">
  173. <span>{{ getLabels(scope.row.labelIds).join(',') }}</span>
  174. </template>
  175. </el-table-column>
  176. <el-table-column
  177. prop="remark"
  178. label="备注"
  179. align="left"
  180. show-overflow-tooltip
  181. />
  182. <!--操作栏-->
  183. <el-table-column
  184. v-if="doEdit||isDelete"
  185. label="操作"
  186. width="200"
  187. align="center"
  188. >
  189. <template
  190. v-if="showOperate(scope.row.datasetType)"
  191. slot-scope="scope"
  192. >
  193. <el-button
  194. v-if="doEdit"
  195. class="bs-el-button-default"
  196. :disabled="scope.row.editable === 1 && !appCode"
  197. @click="toEdit(scope.row.id, scope.row.datasetType, scope.row.name, scope.row.typeId)"
  198. >
  199. 编辑
  200. </el-button>
  201. <el-button
  202. v-if="isDelete"
  203. class="bs-el-button-default"
  204. :loading="scope.row.loading"
  205. :disabled="scope.row.editable === 1 && !appCode"
  206. @click="delDataset(scope.row)"
  207. >
  208. 删除
  209. </el-button>
  210. </template>
  211. </el-table-column>
  212. </el-table>
  213. <el-table
  214. v-else
  215. ref="userTable"
  216. v-table
  217. v-loading="dataListLoading"
  218. height="0"
  219. class="bs-el-table bs-scrollbar"
  220. :element-loading-text="loadingText"
  221. :data="tableData"
  222. :header-cell-style="sortStyle"
  223. @sort-change="reSort"
  224. @current-change="handleCurrentChange"
  225. @select="selectDs"
  226. @select-all="selectAll"
  227. >
  228. <el-empty slot="empty" />
  229. <el-table-column
  230. v-if="isDialog && multiple"
  231. type="selection"
  232. width="55"
  233. />
  234. <el-table-column
  235. prop="name"
  236. label="数据集名称"
  237. align="left"
  238. show-overflow-tooltip
  239. >
  240. <template slot-scope="scope">
  241. <el-radio
  242. v-if="isDialog && !multiple"
  243. v-model="curRow"
  244. :label="scope.row"
  245. >
  246. {{ scope.row.name }}
  247. </el-radio>
  248. <span v-else>{{ scope.row.name }}</span>
  249. </template>
  250. </el-table-column>
  251. <el-table-column
  252. prop="datasetType"
  253. label="数据集类型"
  254. align="center"
  255. show-overflow-tooltip
  256. >
  257. <template slot-scope="scope">
  258. <span>{{ datasetTypeList.find(type=>type.datasetType===scope.row.datasetType) ? datasetTypeList.find(type=>type.datasetType===scope.row.datasetType).name : '其他' }}</span>
  259. </template>
  260. </el-table-column>
  261. <el-table-column
  262. prop="labelIds"
  263. label="标签"
  264. align="center"
  265. show-overflow-tooltip
  266. >
  267. <template slot-scope="scope">
  268. <span>{{ getLabels(scope.row.labelIds).join(',') }}</span>
  269. </template>
  270. </el-table-column>
  271. <el-table-column
  272. prop="remark"
  273. label="备注"
  274. align="left"
  275. show-overflow-tooltip
  276. />
  277. <!--操作栏-->
  278. <el-table-column
  279. v-if="doEdit||isDelete"
  280. label="操作"
  281. width="200"
  282. align="center"
  283. >
  284. <template
  285. v-if="showOperate(scope.row.datasetType)"
  286. slot-scope="scope"
  287. >
  288. <el-button
  289. v-if="doEdit"
  290. class="bs-el-button-default"
  291. :disabled="scope.row.editable === 1 && !appCode"
  292. @click="toEdit(scope.row.id, scope.row.datasetType, scope.row.name, scope.row.typeId)"
  293. >
  294. 编辑
  295. </el-button>
  296. <el-button
  297. v-if="isDelete"
  298. class="bs-el-button-default"
  299. :loading="scope.row.loading"
  300. :disabled="scope.row.editable === 1 && !appCode"
  301. @click="delDataset(scope.row)"
  302. >
  303. 删除
  304. </el-button>
  305. </template>
  306. </el-table-column>
  307. </el-table>
  308. </div>
  309. <div class="bs-pagination">
  310. <el-pagination
  311. class="bs-el-pagination"
  312. popper-class="bs-el-pagination"
  313. :current-page="current"
  314. :page-sizes="[10, 20, 50, 100]"
  315. :page-size="size"
  316. :total="totalCount"
  317. background
  318. prev-text="上一页"
  319. next-text="下一页"
  320. layout="total, prev, pager, next, sizes"
  321. @size-change="sizeChangeHandle"
  322. @current-change="currentChangeHandle"
  323. />
  324. </div>
  325. </div>
  326. </el-row>
  327. <!-- 新增-类型窗口 -->
  328. <DatasetTypeDialog
  329. ref="DatasetTypeDialog"
  330. :dataset-type-list="datasetTypeList"
  331. @openAddForm="openAddForm"
  332. />
  333. <checkDatasource
  334. ref="checkDatasource"
  335. :reason-list="reasonList"
  336. />
  337. <component
  338. :is="componentData.component"
  339. v-if="datasetType"
  340. ref="EditForm"
  341. :key="componentData.key"
  342. :config="componentData.config"
  343. :dataset-id="datasetId"
  344. :dataset-name="datasetName"
  345. :type-id="typeId"
  346. :is-edit="isEdit"
  347. :app-code="appCode"
  348. @back="back"
  349. >
  350. <template #output-field-table-column>
  351. <slot name="output-field-table-column" />
  352. </template>
  353. </component>
  354. </div>
  355. </template>
  356. <script>
  357. import TypeTree from './TypeTree.vue'
  358. import JsEditForm from './JsEditForm.vue'
  359. import JsonEditForm from './JsonEditForm.vue'
  360. import table from 'data-room-ui/js/utils/table.js'
  361. import ScriptEditForm from './ScriptEditForm.vue'
  362. import checkDatasource from 'data-room-ui/DataSourceManagement/src/checkDatasource.vue'
  363. import CustomEditForm from './CustomEditForm.vue'
  364. import { pageMixins } from 'data-room-ui/js/mixins/page'
  365. import OriginalEditForm from './OriginalEditForm.vue'
  366. import HttpEditForm from './HttpEditForm.vue'
  367. import DatasetTypeDialog from './DatasetTypeDialog.vue'
  368. import StoredProcedureEditForm from './StoredProcedureEditForm.vue'
  369. import { datasetPage, datasetRemove, datasetCheck } from 'data-room-ui/js/utils/datasetConfigService'
  370. import { getLabelList } from 'data-room-ui/js/utils/LabelConfigService'
  371. export default {
  372. name: 'DataSetManagement',
  373. directives: {
  374. table // 注册自定义指令
  375. },
  376. components: {
  377. TypeTree,
  378. DatasetTypeDialog,
  379. OriginalEditForm,
  380. CustomEditForm,
  381. JsonEditForm,
  382. StoredProcedureEditForm,
  383. ScriptEditForm,
  384. JsEditForm,
  385. checkDatasource,
  386. HttpEditForm
  387. },
  388. mixins: [pageMixins],
  389. props: {
  390. multiple: {
  391. type: Boolean,
  392. default: false
  393. },
  394. isDialog: {
  395. type: Boolean,
  396. default: false
  397. },
  398. dsValue: {
  399. type: [Array, Object],
  400. default: null
  401. },
  402. appCode: {
  403. type: String,
  404. default: ''
  405. },
  406. isBorder: {
  407. type: Boolean,
  408. default: false
  409. },
  410. toAdd: {
  411. type: Boolean,
  412. default: true
  413. },
  414. doEdit: {
  415. type: Boolean,
  416. default: true
  417. },
  418. isDelete: {
  419. type: Boolean,
  420. default: true
  421. }
  422. },
  423. data () {
  424. return {
  425. reasonList: [],
  426. datasetType: null,
  427. isEdit: false,
  428. categoryData: [],
  429. tableData: [], // 表格数据
  430. queryForm: {
  431. name: '',
  432. datasetType: '',
  433. typeId: '', // 分类id
  434. labelIds: []
  435. }, // 查询条件
  436. // 数据集类型
  437. datasetTypeList: [],
  438. labelList: [],
  439. isPackUpTree: false,
  440. transition: 0.1,
  441. loadingText: '正在加载数据',
  442. dataListLoading: false,
  443. leftBox: null,
  444. rightBox: null,
  445. startX: null,
  446. event: null,
  447. endX: null,
  448. resize: null,
  449. datasetId: '', // 数据集Id,用于详情与编辑
  450. datasetName: '', // 数据集名称
  451. typeId: '', // 详情typeId
  452. curRow: null,
  453. multipleSelection: [],
  454. // 远程组件
  455. componentData: {
  456. component: null,
  457. config: null,
  458. key: new Date().getTime()
  459. }
  460. }
  461. },
  462. computed: {
  463. allType () {
  464. return this.datasetTypeList.map(item => item.datasetType).filter(item => item !== '')
  465. }
  466. },
  467. watch: {
  468. datasetType (value) {
  469. if (value === null) {
  470. this.datasetId = ''
  471. this.datasetName = ''
  472. this.isEdit = false
  473. }
  474. }
  475. },
  476. mounted () {
  477. this.init()
  478. if (/Safari/.test(navigator.userAgent) && !/Chrome/.test(navigator.userAgent)) {
  479. // 当前浏览器为Safari浏览器
  480. // 执行相关操作
  481. document.addEventListener('mousemove', function (event) {
  482. if (event.buttons === 1) {
  483. event.preventDefault()
  484. }
  485. })
  486. }
  487. },
  488. methods: {
  489. getLabels (list) {
  490. const arr = []
  491. list?.forEach((item) => {
  492. arr.push(this.labelList.filter(x => x.id === item)[0]?.labelName)
  493. })
  494. return arr
  495. },
  496. toggleRowSelection () {
  497. this.$nextTick(() => {
  498. const dsIds = this.multipleSelection.map(ds => ds.id)
  499. this.$refs.userTable.clearSelection()
  500. this.tableData.forEach(item => {
  501. if (dsIds.includes(item.id)) {
  502. this.$refs.userTable.toggleRowSelection(item, true)
  503. }
  504. })
  505. })
  506. },
  507. // 全选
  508. selectAll (selection) {
  509. if (this.isDialog && this.multiple) {
  510. if (selection.length) {
  511. const dsIds = this.multipleSelection.map(ds => ds.id)
  512. selection.forEach(ds => {
  513. if (!dsIds.includes(ds.id)) {
  514. this.multipleSelection.push(ds)
  515. }
  516. })
  517. } else {
  518. this.tableData.forEach(row => {
  519. const dsIds = this.multipleSelection.map(ds => ds.id)
  520. const i = dsIds.indexOf(row.id)
  521. if (i > -1) this.multipleSelection.splice(i, 1)
  522. })
  523. }
  524. }
  525. },
  526. // 手动勾选
  527. selectDs (selection, row) {
  528. if (this.isDialog && this.multiple) {
  529. let dsIndex = null
  530. const ds = this.multipleSelection.find((ds, index) => {
  531. if (ds.id === row.id) {
  532. dsIndex = index
  533. return ds
  534. }
  535. })
  536. if (!ds) {
  537. this.multipleSelection.push(row)
  538. } else {
  539. this.multipleSelection.splice(dsIndex, 1)
  540. }
  541. }
  542. },
  543. // 获取选中数据集信息
  544. getSelectDs () {
  545. if (!this.isDialog) return
  546. if (this.multiple) {
  547. // 多选返回
  548. return this.multipleSelection
  549. } else {
  550. // 单选返回
  551. return this.curRow ? this.curRow : null
  552. }
  553. },
  554. // 单选数据集
  555. handleCurrentChange (currentRow) {
  556. this.curRow = currentRow
  557. },
  558. // 删除数据集
  559. delDataset (row) {
  560. row.loading = true
  561. datasetCheck(row.id).then((res) => {
  562. row.loading = false
  563. if (res.canDelete) {
  564. this.$confirm('确定删除当前数据集吗?', '提示', {
  565. confirmButtonText: '确定',
  566. cancelButtonText: '取消',
  567. type: 'warning',
  568. customClass: 'bs-el-message-box'
  569. }).then(() => {
  570. datasetRemove(row.id).then(res => {
  571. this.init(false)
  572. this.$message.success('删除成功')
  573. })
  574. }).catch(() => {
  575. })
  576. } else {
  577. this.reasonList = res.reasons
  578. this.$refs.checkDatasource.checkDatasourceVisible = true
  579. }
  580. })
  581. },
  582. // 详情
  583. toPreview (id, type, name, typeId) {
  584. this.datasetId = id
  585. this.datasetType = type
  586. this.datasetName = name
  587. this.typeId = typeId
  588. this.isEdit = false
  589. },
  590. toEdit (id, type, name, typeId) {
  591. this.datasetId = id
  592. this.datasetType = type
  593. this.componentData = this.getComponents(this.datasetTypeList.find(item => item?.datasetType === type)?.componentName) ?? ''
  594. this.datasetName = name
  595. this.typeId = typeId
  596. this.isEdit = true
  597. },
  598. // 回到管理端
  599. back () {
  600. this.datasetType = null
  601. this.isEdit = false
  602. },
  603. // 新增数据集-类型
  604. openAddForm (type, componentName) {
  605. this.datasetType = type
  606. this.componentData = this.getComponents(componentName)
  607. this.typeId = this.queryForm.typeId
  608. this.isEdit = true
  609. },
  610. showOperate (datasetType) {
  611. return this.getComponents(this.datasetTypeList.find(type => type.datasetType === datasetType)?.componentName)?.config?.showOperate ?? true
  612. },
  613. getComponents (componentName) {
  614. const components = Object.values(this.$options.components)
  615. let remoteComponentData = null
  616. if (window.BS_CONFIG?.customDatasetComponents && window.BS_CONFIG?.customDatasetComponents.length > 0) {
  617. // 获取远程组件
  618. remoteComponentData = window.BS_CONFIG?.customDatasetComponents.find(item => item.config.componentName === componentName)
  619. }
  620. return {
  621. component: components.find(component => component.name === componentName) || remoteComponentData?.vueFile,
  622. config: remoteComponentData?.config || null,
  623. key: new Date().getTime()
  624. }
  625. },
  626. // 初始化
  627. init (temp = true) {
  628. if (temp) {
  629. this.getTreeList()
  630. }
  631. if (this.isDialog) {
  632. if (this.multiple) {
  633. this.multipleSelection = this.dsValue ? this.dsValue : []
  634. } else {
  635. this.curRow = this.dsValue
  636. }
  637. }
  638. this.current = 1
  639. const list = [
  640. { name: '全部', datasetType: '' },
  641. { name: '原始数据集', datasetType: 'original', componentName: 'OriginalEditForm', description: '直接查询某个数据库表' },
  642. { name: '自助数据集', datasetType: 'custom', componentName: 'CustomEditForm', description: '自定义SQL语句查询' },
  643. { name: '存储过程数据集', datasetType: 'storedProcedure', componentName: 'StoredProcedureEditForm', description: '调用数据库存储过程查询' },
  644. { name: 'JSON数据集', datasetType: 'json', componentName: 'JsonEditForm', description: '直接定义静态数据' },
  645. { name: 'JS数据集', datasetType: 'js', componentName: 'JsEditForm', description: '编写JS代码进行动态模拟数据创建' },
  646. { name: 'HTTP数据集', datasetType: 'http', componentName: 'HttpEditForm', description: '接入第三方HTTP服务查询' },
  647. { name: '脚本数据集', datasetType: 'script', componentName: 'ScriptEditForm', description: '支持ES、Mongodb、国产化数据库、自定义Java代码查询' }
  648. ]
  649. if (window.BS_CONFIG?.datasetTypeList && window.BS_CONFIG?.datasetTypeList?.length !== 0) {
  650. this.datasetTypeList = [{ name: '全部', datasetType: '' }, ...list.filter(item => window.BS_CONFIG?.datasetTypeList.findIndex(x => x === item.datasetType) !== -1)]
  651. } else {
  652. this.datasetTypeList = [
  653. ...list
  654. ]
  655. }
  656. if (window.BS_CONFIG?.customDatasetComponents && window.BS_CONFIG?.customDatasetComponents.length > 0) {
  657. // 将获得到的远程数据集进行组装
  658. window.BS_CONFIG?.customDatasetComponents.forEach((item) => {
  659. this.datasetTypeList.push({ name: item.config.name, datasetType: item.config.datasetType, componentName: item.config.componentName })
  660. })
  661. }
  662. this.getDataList()
  663. // getLabelList().then(res => {
  664. // this.labelList = res
  665. // })
  666. },
  667. // 新增数据集
  668. addDataset () {
  669. this.$refs.DatasetTypeDialog.dialogVisible = true
  670. },
  671. selectChange () {
  672. this.getDataList()
  673. },
  674. getTreeList () {
  675. },
  676. // 获取表格数据
  677. getDataList () {
  678. getLabelList().then(res => {
  679. this.labelList = res
  680. })
  681. this.dataListLoading = true
  682. datasetPage({
  683. current: this.current,
  684. size: this.size,
  685. moduleCode: this.appCode,
  686. ...this.queryForm,
  687. datasetType: this.queryForm.datasetType === '' ? [...this.allType] : [this.queryForm.datasetType]
  688. }).then((data) => {
  689. this.tableData = data.list
  690. this.tableData.forEach(r => {
  691. this.$set(r, 'loading', false)
  692. })
  693. if (this.isDialog) {
  694. if (this.multiple && this.multipleSelection.length) {
  695. this.toggleRowSelection()
  696. } else if (this.curRow.id) {
  697. const ds = this.tableData.find(item => item.id === this.curRow.id)
  698. if (ds) this.curRow = ds
  699. }
  700. }
  701. this.totalCount = data.totalCount
  702. this.dataListLoading = false
  703. }).catch(() => {
  704. this.dataListLoading = false
  705. })
  706. },
  707. expandedNodes (data) {
  708. if (data && data > 50) {
  709. this.transition = 0
  710. } else {
  711. this.transition = 0.1
  712. }
  713. },
  714. nodeClick (row, type) {
  715. this.current = 1
  716. if (type === 'group') {
  717. this.queryForm.typeId = row.id
  718. this.queryForm.datasetType = ''
  719. } else if (type === 'type') {
  720. this.queryForm.typeId = ''
  721. this.queryForm.datasetType = row
  722. }
  723. this.getDataList()
  724. },
  725. refreshData (node) {
  726. if (node && node.id === this.queryForm.typeId) {
  727. this.queryForm.typeId = ''
  728. }
  729. this.getDataList()
  730. },
  731. handleSearch () {
  732. this.current = 1
  733. this.queryForm.typeId = ''
  734. // 清除左侧机构树的选中状态
  735. this.$refs.datasetsTypeTree.ztreeObj.cancelSelectedNode()
  736. this.getDataList()
  737. },
  738. // 拖拽修改div宽度
  739. mousedown (e) {
  740. this.resize = document.getElementsByClassName('resize')[0]
  741. this.resize.left = document.getElementById('left-box').getBoundingClientRect().width
  742. this.leftBox = document.getElementsByClassName('left-box')[0]
  743. this.rightBox = document.getElementsByClassName('right-box')[0]
  744. this.startX = e.clientX
  745. },
  746. mousemove (e) {
  747. this.event = e
  748. if (this.resize) {
  749. const boxWidth = document.getElementById('box').getBoundingClientRect().width
  750. this.endX = e.clientX
  751. const offset = document.getElementById('box').getBoundingClientRect().left > 300 ? 0 : 25
  752. const moveLen = this.resize.left + (this.endX - this.startX) + offset
  753. this.leftBox.style.width = moveLen / boxWidth * 100 + '%'
  754. this.rightBox.style.width = ((1 - moveLen / boxWidth) * 100) + '%'
  755. this.isPackUpTree = false
  756. if (moveLen < 100 && this.endX - this.startX < 0) {
  757. this.isPackUpTree = true
  758. this.leftBox.style.width = '0%'
  759. this.rightBox.style.width = '100%'
  760. } else if (moveLen / boxWidth > 0.5) {
  761. this.leftBox.style.width = '50%'
  762. this.rightBox.style.width = '50%'
  763. }
  764. }
  765. },
  766. packUpTree () {
  767. this.$refs.datasetsTypeTree.expandedNodes()
  768. this.isPackUpTree = !this.isPackUpTree
  769. if (!this.isPackUpTree) {
  770. this.leftBox.style.width = '25%'
  771. this.rightBox.style.width = '75%'
  772. } else {
  773. this.leftBox.style.width = '0%'
  774. this.rightBox.style.width = '100%'
  775. }
  776. },
  777. mouseup () {
  778. if (this.resize) {
  779. this.resize = null
  780. if (this.endX < 350 && this.endX - this.startX > 0) {
  781. this.isPackUpTree = false
  782. this.leftBox.style.width = '25%'
  783. this.rightBox.style.width = '75%'
  784. }
  785. }
  786. },
  787. mousemoveOnBox (e) {
  788. this.mousemove(e)
  789. },
  790. mouseupOnBox () {
  791. this.resize = null
  792. if (this.endX < 350 && this.endX - this.startX > 0) {
  793. this.isPackUpTree = false
  794. this.leftBox.style.width = '25%'
  795. this.rightBox.style.width = '75%'
  796. }
  797. this.resize = null
  798. }
  799. }
  800. }
  801. </script>
  802. <style lang="scss" scoped>
  803. @import '../../assets/style/bsTheme.scss';
  804. @import '../../assets/style/zTree/treePackUp.scss';
  805. ::v-deep .big-screen-router-view-wrap{
  806. padding-left: 16px !important;
  807. }
  808. .bs-pagination {
  809. padding: 0 !important;
  810. right: 16px !important;
  811. bottom: 16px !important;
  812. position: absolute !important;
  813. ::v-deep .el-input__inner {
  814. width: 110px !important;
  815. border:none;
  816. background: var(--bs-el-background-1);
  817. }
  818. }
  819. .bs-container .inner-container .el-form .filter-item {
  820. ::v-deep .el-input__inner {
  821. width: 200px;
  822. }
  823. }
  824. ::v-deep .left-tab-box {
  825. span {
  826. color: var(--bs-el-text);
  827. }
  828. }
  829. ::v-deep .left-tab-box ul li.tab-active {
  830. background-color: var(--bs-el-background-3);
  831. }
  832. ::v-deep .left-tab-box ul li:hover {
  833. background-color: var(--bs-el-background-3);
  834. }
  835. .el-dialog {
  836. .bs-container {
  837. // max-height: calc(90vh - 236px) !important;
  838. .el-table {
  839. height: calc(100vh - 390px);
  840. }
  841. ::v-deep .ztree {
  842. max-height: calc(90vh - 325px) !important;
  843. }
  844. ::v-deep .el-tabs__item.is-active {
  845. border-bottom: none !important;
  846. }
  847. }
  848. }
  849. ::v-deep .ztreeNodeMenu {
  850. ul {
  851. background-color: var(--bs-background-1);
  852. }
  853. li:hover {
  854. background-color: var(--bs-el-background-3);
  855. span {
  856. color: var(--bs-el-color-primary);
  857. }
  858. }
  859. span {
  860. color: var(--bs-el-text);
  861. }
  862. .triangle {
  863. background-color: var(--bs-background-1) !important;
  864. }
  865. }
  866. .layout {
  867. width: 100%;
  868. height: 100%;
  869. }
  870. ::v-deep .el-table__body-wrapper{
  871. max-height: unset !important;
  872. }
  873. </style>