JsEditForm.vue 27 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886887888889890891892893894895896897898899900901902903904905906907908909910911912913914915916917918919920921922923924925926927928929930931932933934935936
  1. <template>
  2. <div
  3. class="inner-container"
  4. :element-loading-text="saveText"
  5. >
  6. <el-scrollbar class="data-set-scrollbar">
  7. <div class="header">
  8. <el-page-header class="bs-el-page-header">
  9. <template slot="content">
  10. <div class="page-header">
  11. <div class="page-header-left">
  12. {{ !isEdit ? 'JS数据集详情' : dataForm.id ? 'JS数据集编辑' : 'JS数据集新增' }}
  13. </div>
  14. <div class="page-header-right">
  15. <el-button
  16. class="bs-el-button-default"
  17. @click="openNewWindow('https://www.yuque.com/chuinixiongkou/bigscreen/groovy_dataset')"
  18. >
  19. 帮助
  20. </el-button>
  21. <el-button
  22. v-if="isEdit"
  23. type="primary"
  24. @click="save('form')"
  25. >
  26. 保存
  27. </el-button>
  28. <el-button
  29. class="bs-el-button-default"
  30. @click="goBack"
  31. >
  32. 返回
  33. </el-button>
  34. </div>
  35. </div>
  36. </template>
  37. </el-page-header>
  38. </div>
  39. <el-row style="margin: 16px 16px 0;">
  40. <el-col :span="isEdit ? 16 : 24">
  41. <el-form
  42. ref="form"
  43. :model="dataForm"
  44. :rules="rules"
  45. label-width="120px"
  46. style="padding: 16px 16px 0;"
  47. class="bs-el-form"
  48. >
  49. <el-row :gutter="20">
  50. <el-col :span="12">
  51. <el-form-item
  52. label="数据集名称"
  53. prop="name"
  54. >
  55. <el-input
  56. v-model="dataForm.name"
  57. class="bs-el-input"
  58. clearable
  59. :disabled="!isEdit"
  60. />
  61. </el-form-item>
  62. </el-col>
  63. <el-col :span="12">
  64. <el-form-item
  65. label="分组"
  66. prop="typeId"
  67. >
  68. <el-select
  69. ref="selectParentName"
  70. v-model="dataForm.typeId"
  71. class="bs-el-select"
  72. popper-class="bs-el-select"
  73. placeholder="请选择分组"
  74. clearable
  75. :disabled="!isEdit"
  76. filterable
  77. :filter-method="selectorFilter"
  78. @clear="clearType"
  79. @visible-change="setCurrentNode"
  80. >
  81. <el-option
  82. style="height: auto;padding: 0;"
  83. :label="typeName"
  84. :value="dataForm.typeId"
  85. >
  86. <div class="tree-box">
  87. <el-tree
  88. ref="categorySelectTree"
  89. :data="categoryData"
  90. node-key="id"
  91. :indent="0"
  92. :props="{ label: 'name', children: 'children' }"
  93. :default-expand-all="true"
  94. :highlight-current="true"
  95. :expand-on-click-node="false"
  96. class="bs-el-tree"
  97. :filter-node-method="treeFilter"
  98. @node-click="selectParentCategory"
  99. >
  100. <span
  101. slot-scope="{ data }"
  102. class="custom-tree-node"
  103. >
  104. <span>
  105. <i
  106. :class="data.children && data.children.length ? 'el-icon el-icon-folder' : 'el-icon el-icon-document'"
  107. />
  108. {{ data.name }}
  109. </span>
  110. </span>
  111. </el-tree>
  112. </div>
  113. </el-option>
  114. </el-select>
  115. </el-form-item>
  116. </el-col>
  117. </el-row>
  118. <el-row :gutter="20">
  119. <el-col :span="12">
  120. <el-form-item
  121. label="描述"
  122. prop="remark"
  123. >
  124. <el-input
  125. v-model="dataForm.remark"
  126. class="bs-el-input"
  127. :disabled="!isEdit"
  128. />
  129. </el-form-item>
  130. </el-col>
  131. <el-col :span="12">
  132. <el-form-item
  133. label="标签"
  134. prop="labelIds"
  135. >
  136. <LabelSelect
  137. :dataset-id="datasetId"
  138. :id-list="dataForm.labelIds"
  139. @commit="(ids) =>{dataForm.labelIds = ids}"
  140. />
  141. </el-form-item>
  142. </el-col>
  143. </el-row>
  144. </el-form>
  145. <div
  146. v-if="isEdit"
  147. class="sql-config"
  148. >
  149. <div>
  150. <codemirror
  151. ref="targetInSql"
  152. v-model="dataForm.config.script"
  153. :options="codemirrorOption"
  154. style="margin-top: 2px"
  155. />
  156. </div>
  157. <div class="bs-codemirror-bottom-text">
  158. <strong>请使用 return 将运行结果返回出来,结果数据需要为数组格式</strong>
  159. <br>
  160. <strong>动态参数使用: 使用${}将参数包裹,例如:let name = <span style="color: red;">${name}。</span>
  161. </strong>
  162. </div>
  163. <div style="text-align: center; padding: 16px 0;">
  164. <el-button
  165. type="primary"
  166. @click="scriptExecute()"
  167. >
  168. 解析并运行
  169. </el-button>
  170. </div>
  171. </div>
  172. </el-col>
  173. <el-col
  174. v-if="isEdit"
  175. :span="8"
  176. >
  177. <div class="right-setting">
  178. <div class="paramConfig">
  179. <div class="title-style bs-title-style">
  180. 动态参数
  181. <el-button
  182. type="text"
  183. style="float: right;border: none;margin-top: -4px;"
  184. @click="$refs.paramsSettingDialog.open()"
  185. >
  186. 配置
  187. </el-button>
  188. </div>
  189. <div class="field-wrap bs-field-wrap bs-scrollbar">
  190. <div
  191. v-for="param in dataForm.config.paramsList"
  192. :key="param.name"
  193. class="field-item"
  194. @click="$refs.paramsSettingDialog.open()"
  195. >
  196. <span>{{ param.name }}</span>&nbsp;<span
  197. v-show="param.remark"
  198. style="color: #909399;"
  199. >
  200. ({{ param.remark }})
  201. </span>
  202. <el-button
  203. class="edit_field"
  204. type="text"
  205. style="float: right;border: none;margin-top: 2px;"
  206. @click="$refs.paramsSettingDialog.open()"
  207. >
  208. 配置
  209. </el-button>
  210. </div>
  211. </div>
  212. </div>
  213. <div class="structure">
  214. <div class="title-style bs-title-style">
  215. 输出字段
  216. <el-button
  217. type="text"
  218. style="float: right;border: none;margin-top: -4px;"
  219. @click="$refs.outputFieldDialog.open()"
  220. >
  221. 配置
  222. </el-button>
  223. </div>
  224. <div class="field-wrap bs-field-wrap bs-scrollbar">
  225. <div
  226. v-for="(field, key) in outputFieldList"
  227. :key="key"
  228. class="field-item"
  229. @click="$refs.outputFieldDialog.open()"
  230. >
  231. <span>{{ field.fieldName }}</span>&nbsp;
  232. <span
  233. v-show="field.fieldDesc"
  234. style="color: #909399;"
  235. >
  236. ({{ field.fieldDesc }})</span>
  237. <el-button
  238. class="edit_field"
  239. type="text"
  240. style="float: right;border: none;margin-top: 2px;"
  241. @click="$refs.outputFieldDialog.open()"
  242. >
  243. 配置
  244. </el-button>
  245. </div>
  246. </div>
  247. </div>
  248. </div>
  249. </el-col>
  250. </el-row>
  251. <div
  252. v-if="isEdit"
  253. class="dataPreView"
  254. style="margin-top: 12px;"
  255. >
  256. <div class="result-view">
  257. 数据预览
  258. </div>
  259. <div
  260. v-loading="tableLoading"
  261. class="bs-table-box is-Edit bs-scrollbar"
  262. >
  263. <el-table
  264. align="center"
  265. :data="dataPreviewList"
  266. max-height="400"
  267. :border="true"
  268. class="bs-el-table bs-scrollbar"
  269. >
  270. <el-table-column
  271. v-for="(value, key) in dataPreviewList[0]"
  272. :key="key"
  273. :label="key"
  274. align="center"
  275. show-overflow-tooltip
  276. :render-header="renderHeader"
  277. >
  278. <template slot-scope="scope">
  279. <span>{{ scope.row[key] }}</span>
  280. </template>
  281. </el-table-column>
  282. </el-table>
  283. </div>
  284. </div>
  285. <div
  286. v-if="!isEdit"
  287. class="dataPreView"
  288. >
  289. <el-tabs v-model="activeName">
  290. <el-tab-pane
  291. v-loading="tableLoading"
  292. label="数据预览"
  293. name="data"
  294. >
  295. <div class="bs-table-box">
  296. <el-table
  297. align="center"
  298. :data="dataPreviewList"
  299. max-height="400"
  300. class="bs-el-table"
  301. >
  302. <el-table-column
  303. v-for="(value, key) in dataPreviewList[0]"
  304. :key="key"
  305. :label="key"
  306. align="center"
  307. show-overflow-tooltip
  308. :render-header="renderHeader"
  309. >
  310. <template slot-scope="scope">
  311. <span>{{ scope.row[key] }}</span>
  312. </template>
  313. </el-table-column>
  314. </el-table>
  315. </div>
  316. </el-tab-pane>
  317. <el-tab-pane
  318. v-loading="tableLoading"
  319. label="数据集结构"
  320. name="structure"
  321. >
  322. <div class="bs-table-box">
  323. <el-table
  324. max-height="400"
  325. :data="outputFieldList"
  326. :border="true"
  327. align="center"
  328. >
  329. <el-table-column
  330. align="center"
  331. show-overflow-tooltip
  332. prop="fieldName"
  333. label="字段值"
  334. />
  335. <el-table-column
  336. align="center"
  337. prop="fieldDesc"
  338. label="字段描述"
  339. >
  340. <template slot-scope="scope">
  341. <el-input
  342. v-if="isEdit"
  343. v-model="scope.row.fieldDesc"
  344. size="small"
  345. class="labeldsc bs-el-input"
  346. />
  347. <span v-else>{{ scope.row.fieldDesc }}</span>
  348. </template>
  349. </el-table-column>
  350. </el-table>
  351. </div>
  352. </el-tab-pane>
  353. </el-tabs>
  354. </div>
  355. <ParamsSettingDialog
  356. ref="paramsSettingDialog"
  357. :params-list="dataForm.config.paramsList"
  358. @saveParams="saveParams"
  359. />
  360. <OutputFieldDialog
  361. ref="outputFieldDialog"
  362. :output-field-list="outputFieldList"
  363. @setFieldList="(list) => { outputFieldList = list }"
  364. >
  365. <template #output-field-table-column>
  366. <slot name="output-field-table-column" />
  367. </template>
  368. </OutputFieldDialog>
  369. </el-scrollbar>
  370. <FieldFillDialog
  371. ref="fieldFillDialog"
  372. @fieldDescFill="fieldDescFill"
  373. @fieldDescEdit="fieldDescEdit"
  374. @toSave="toSave"
  375. />
  376. </div>
  377. </template>
  378. <script>
  379. import LabelSelect from 'data-room-ui/DataSetLabelManagement/src/LabelSelect.vue'
  380. import ParamsSettingDialog from './JsComponents/ParamsSettingDialog.vue'
  381. import OutputFieldDialog from './JsComponents/OutputFieldDialog.vue'
  382. import FieldFillDialog from './JsComponents/FieldFillDialog.vue'
  383. import { nameCheckRepeat, datasetAdd, datasetUpdate, getDataset, getCategoryTree } from 'data-room-ui/js/utils/datasetConfigService'
  384. import { codemirror } from 'vue-codemirror'
  385. import 'codemirror/mode/javascript/javascript'
  386. import 'codemirror/lib/codemirror.css'
  387. import 'codemirror/theme/nord.css'
  388. export default {
  389. name: 'JsEditForm',
  390. components: {
  391. codemirror,
  392. FieldFillDialog,
  393. ParamsSettingDialog,
  394. OutputFieldDialog,
  395. LabelSelect
  396. },
  397. props: {
  398. config: {
  399. type: Object,
  400. default: () => { }
  401. },
  402. isEdit: {
  403. type: Boolean,
  404. default: false
  405. },
  406. datasetId: {
  407. type: String,
  408. default: null
  409. },
  410. typeId: {
  411. type: String,
  412. default: ''
  413. },
  414. appCode: {
  415. type: String,
  416. default: ''
  417. }
  418. },
  419. data () {
  420. const validateName = (rule, value, callback) => {
  421. nameCheckRepeat({
  422. id: this.datasetId,
  423. name: value,
  424. moduleCode: this.appCode
  425. }).then((r) => {
  426. if (r) {
  427. callback(new Error('数据集名称已存在'))
  428. } else {
  429. callback()
  430. }
  431. })
  432. }
  433. return {
  434. dataForm: {
  435. id: '',
  436. name: '',
  437. typeId: '',
  438. remark: '',
  439. labelIds: [],
  440. config: {
  441. script: '',
  442. paramsList: []
  443. }
  444. },
  445. rules: {
  446. name: [
  447. { required: true, message: '请输入数据集名称', trigger: 'blur' },
  448. { validator: validateName, trigger: 'blur' }
  449. ],
  450. typeId: [
  451. { required: true, message: '请选择分组', trigger: 'blur' }
  452. ]
  453. },
  454. codemirrorOption: {
  455. mode: 'text/javascript',
  456. lineNumbers: true,
  457. lineWrapping: true,
  458. theme: 'nord',
  459. extraKey: { Ctrl: 'autocomplete' },
  460. hintOptions: {
  461. completeSingle: true
  462. }
  463. },
  464. activeName: 'data',
  465. dataPreviewList: [],
  466. outputFieldList: [],
  467. structurePreviewListCopy: [],
  468. typeName: '',
  469. categoryData: [],
  470. // fieldDescVisible: false,
  471. fieldsetVisible: false,
  472. paramsVisible: false,
  473. tableLoading: false,
  474. saveloading: false,
  475. saveText: '',
  476. // paramsListCopy: [],
  477. isSet: false, // 参数是否配置状态
  478. passTest: false,
  479. fieldDesc: null // 字段描述
  480. }
  481. },
  482. watch: {
  483. 'dataForm.config.script' (val) {
  484. if (!val) {
  485. this.passTest = false
  486. }
  487. }
  488. },
  489. mounted () {
  490. this.init()
  491. },
  492. methods: {
  493. async init () {
  494. this.categoryData = await getCategoryTree({ tableName: 'dataset', moduleCode: this.appCode })
  495. if (this.typeId) {
  496. this.dataForm.typeId = this.typeId
  497. this.$nextTick(() => {
  498. try {
  499. this.typeName = this.$refs.categorySelectTree.getNode(this.dataForm.typeId).data.name
  500. } catch (error) {
  501. console.error(error)
  502. }
  503. })
  504. }
  505. if (this.datasetId) {
  506. getDataset(this.datasetId).then(res => {
  507. const { id, name, typeId, remark, datasetType, moduleCode, editable, sourceId, config } = res
  508. const { script, paramsList, fieldDesc, fieldList } = config
  509. this.dataForm = { id, name, typeId, remark, datasetType, moduleCode, editable, sourceId, config: { script, paramsList }, labelIds: this.dataForm.labelIds }
  510. this.fieldDesc = fieldDesc
  511. this.outputFieldList = fieldList
  512. this.scriptExecute(true)
  513. })
  514. }
  515. },
  516. // 保存数据集
  517. save (formName, nochecktosave = false) {
  518. if (this.passTest === false) {
  519. this.$message.error('请确保脚本不为空且执行通过')
  520. return
  521. }
  522. if (!this.outputFieldList.length) {
  523. this.$message.warning('该执行脚本未生成输出字段,请重新检查')
  524. return
  525. }
  526. if (!nochecktosave) {
  527. const temp = this.outputFieldList.some(item => {
  528. return item.fieldDesc === '' || !item.hasOwnProperty('fieldDesc')
  529. }) // true-存在为空
  530. if (temp) {
  531. this.$refs.fieldFillDialog.open()
  532. // this.fieldDescVisible = true
  533. return
  534. }
  535. }
  536. this.$refs[formName].validate((valid) => {
  537. if (valid) {
  538. this.saveloading = true
  539. this.saveText = '正在保存...'
  540. const { datasetId, dataForm, appCode, fieldDesc, outputFieldList } = this
  541. const form = {
  542. id: datasetId,
  543. name: dataForm.name,
  544. typeId: dataForm.typeId,
  545. remark: dataForm.remark,
  546. datasetType: 'js',
  547. moduleCode: appCode,
  548. editable: appCode ? 1 : 0,
  549. labelIds: dataForm.labelIds,
  550. config: {
  551. className: 'com.gccloud.dataset.entity.config.JsDataSetConfig',
  552. script: dataForm.config.script,
  553. fieldDesc,
  554. paramsList: dataForm.config.paramsList,
  555. fieldList: outputFieldList
  556. }
  557. }
  558. const datasetSave = this.dataForm.id === '' ? datasetAdd : datasetUpdate
  559. datasetSave(form).then(() => {
  560. this.$message.success('操作成功')
  561. this.$parent.init(false)
  562. this.$parent.setType = null
  563. this.saveloading = false
  564. this.saveText = ''
  565. this.goBack()
  566. }).catch(() => {
  567. this.saveloading = false
  568. this.saveText = ''
  569. })
  570. }
  571. })
  572. },
  573. saveParams (val) {
  574. this.dataForm.config.paramsList = val
  575. },
  576. // 取消操作
  577. // cancelField () {
  578. // this.structurePreviewListCopy = cloneDeep(this.outputFieldList)
  579. // this.fieldsetVisible = false
  580. // },
  581. // 设置输出字段
  582. setField () {
  583. // this.outputFieldList = cloneDeep(this.structurePreviewListCopy)
  584. // if (this.outputFieldList.length) {
  585. // this.fieldDesc = {}
  586. // this.outputFieldList.forEach(key => {
  587. // this.fieldDesc[key.fieldName] = key.fieldDesc
  588. // })
  589. // } else {
  590. // this.fieldDesc = null
  591. // }
  592. // this.fieldsetVisible = false
  593. },
  594. // 字段值填充
  595. fieldDescFill () {
  596. this.fieldDesc = {}
  597. this.outputFieldList.forEach(field => {
  598. if (field.fieldDesc === '' || !field.hasOwnProperty('fieldDesc')) {
  599. field.fieldDesc = field.fieldName
  600. this.fieldDesc[field.fieldName] = field.fieldName
  601. } else {
  602. this.fieldDesc[field.fieldName] = field.fieldDesc
  603. }
  604. })
  605. this.save('form')
  606. this.$refs.fieldFillDialog.close()
  607. // this.fieldDescVisible = false
  608. },
  609. // 进入编辑
  610. fieldDescEdit () {
  611. this.$refs.fieldFillDialog.close()
  612. // this.fieldDescVisible = false
  613. this.fieldsetVisible = true
  614. },
  615. // 继续保存
  616. toSave () {
  617. this.fieldDesc = {}
  618. this.outputFieldList.forEach(field => {
  619. this.fieldDesc[field.fieldName] = field.fieldDesc
  620. })
  621. this.save('form', true)
  622. this.$refs.fieldFillDialog.close()
  623. // this.fieldDescVisible = false
  624. },
  625. // 字段描述构建及同步
  626. buildFieldDesc () {
  627. const fieldDesc = {}
  628. this.outputFieldList.forEach(field => {
  629. if (this.fieldDesc.hasOwnProperty(field.fieldName)) {
  630. field.fieldDesc = this.fieldDesc[field.fieldName]
  631. }
  632. fieldDesc[field.fieldName] = field.fieldDesc
  633. })
  634. this.fieldDesc = fieldDesc
  635. },
  636. // 脚本执行
  637. scriptExecute (isInit = false) {
  638. if (this.dataForm.config.script) {
  639. const javascript = this.dataForm.config.script
  640. let scriptMethod = null
  641. try {
  642. const scriptAfterReplacement = javascript.replace(/\${(.*?)}/g, (match, p) => {
  643. const value = this.dataForm.config.paramsList.find(param => param.name === p).value
  644. if (!isNaN(value)) {
  645. return value
  646. } else {
  647. return `'${value}'`
  648. }
  649. })
  650. // eslint-disable-next-line no-new-func
  651. scriptMethod = new Function(scriptAfterReplacement)
  652. } catch (error) {
  653. this.passTest = false
  654. this.$message.error(`脚本执行错误,请检查脚本,具体错误:${error}`)
  655. return
  656. }
  657. // 调用方法生成随机数据
  658. const returnResult = scriptMethod()
  659. // 检查数据是否为数组
  660. if (!Array.isArray(returnResult)) {
  661. this.passTest = false
  662. this.$message.error('脚本执行结果不是数组,请检查脚本')
  663. return
  664. }
  665. const keys = []
  666. returnResult.forEach(item => {
  667. Object.keys(item).forEach(key => {
  668. if (!keys.includes(key)) {
  669. keys.push(key)
  670. }
  671. })
  672. })
  673. if (this.outputFieldList.length === 0) {
  674. this.outputFieldList = keys.map(item => {
  675. return {
  676. fieldName: item,
  677. fieldDesc: ''
  678. }
  679. })
  680. }
  681. // 如果脚本有变化,生成的keys和outputFieldList的长度不一致,就重新生成outputFieldList,仅删除或添加变化的那个字段,其余的不变化
  682. if (this.outputFieldList.length !== keys.length) {
  683. const newOutputFieldList = []
  684. keys.forEach(key => {
  685. const field = this.outputFieldList.find(item => item.fieldName === key)
  686. if (field) {
  687. newOutputFieldList.push(field)
  688. } else {
  689. newOutputFieldList.push({
  690. fieldName: key,
  691. fieldDesc: ''
  692. })
  693. }
  694. })
  695. this.outputFieldList = newOutputFieldList
  696. }
  697. // 如果脚本有变化,生成的keys和outputFieldList的长度一致,仅字段名变化了,就重新生成outputFieldList
  698. if (this.outputFieldList.length === keys.length) {
  699. const newOutputFieldList = []
  700. keys.forEach(key => {
  701. const field = this.outputFieldList.find(item => item.fieldName === key)
  702. if (field) {
  703. newOutputFieldList.push(field)
  704. } else {
  705. newOutputFieldList.push({
  706. fieldName: key,
  707. fieldDesc: ''
  708. })
  709. }
  710. })
  711. this.outputFieldList = newOutputFieldList
  712. }
  713. // 如果有字段描述,就同步
  714. if (this.outputFieldList.length && this.fieldDesc && !isInit) {
  715. this.buildFieldDesc()
  716. }
  717. // 如果有数据,就通过测试
  718. if (this.outputFieldList.length > 0) {
  719. // this.structurePreviewListCopy = cloneDeep(this.outputFieldList)
  720. this.dataPreviewList = returnResult
  721. this.passTest = true
  722. if (!isInit) {
  723. this.$message.success('脚本执行通过')
  724. }
  725. } else {
  726. this.passTest = false
  727. }
  728. } else {
  729. this.passTest = false
  730. this.$message.error('请填写脚本')
  731. }
  732. },
  733. // 执行事件
  734. // toExecute () {
  735. // if (this.dataForm.config.paramsList.length) {
  736. // this.isSet = false
  737. // this.paramsVisible = true
  738. // } else {
  739. // 无参数,直接执行脚本
  740. // this.scriptExecute()
  741. // }
  742. // },
  743. // 清空分类
  744. clearType () {
  745. this.typeName = ''
  746. this.dataForm.typeId = ''
  747. },
  748. // 分类展开高亮
  749. setCurrentNode ($event) {
  750. if ($event) {
  751. const key = this.dataForm.typeId || null
  752. this.$refs.categorySelectTree.setCurrentKey(key)
  753. }
  754. },
  755. // openParamsSetting () {
  756. // this.$refs.paramsSettingDialog.open()
  757. // },
  758. // 分类选择
  759. selectParentCategory (value) {
  760. this.dataForm.typeId = value.id
  761. this.typeName = value.name
  762. this.$refs.selectParentName.blur()
  763. },
  764. goBack () {
  765. this.$emit('back')
  766. },
  767. renderHeader (h, { column, index }) {
  768. const labelLong = column.label.length // 表头label长度
  769. const size = 14 // 根据需要定义标尺,直接使用字体大小确定就行,也可以根据需要定义
  770. column.minWidth = labelLong * size < 120 ? 120 : labelLong * size // 根据label长度计算该表头最终宽度
  771. return h('span', { class: 'cell-content', style: { width: '100%' } }, [column.label])
  772. },
  773. openNewWindow (url) {
  774. window.open(url, '_blank')
  775. },
  776. selectorFilter (value) {
  777. this.$refs.categorySelectTree.filter(value)
  778. },
  779. treeFilter (value, data) {
  780. if (!value) return true
  781. return data.name.indexOf(value) !== -1
  782. }
  783. }
  784. }
  785. </script>
  786. <style lang="scss" scoped>
  787. @import '../../assets/style/bsTheme.scss';
  788. .data-set-scrollbar {
  789. height: 100%;
  790. overflow-y: auto;
  791. overflow-x: none;
  792. .el-scrollbar__view {
  793. height: 100%;
  794. }
  795. }
  796. ::v-deep .el-input__inner {
  797. width: 100% !important;
  798. }
  799. .page-header {
  800. display: flex;
  801. position: relative;
  802. .page-header-right {
  803. position: absolute;
  804. right: 16px;
  805. }
  806. }
  807. .sql-config {
  808. padding: 0 16px;
  809. }
  810. .operation {
  811. ::v-deep .el-select {
  812. width: 200px !important;
  813. margin-right: 16px;
  814. }
  815. display: flex;
  816. }
  817. ::v-deep .CodeMirror {
  818. height: 180px !important;
  819. font-family: Helvetica, Tahoma;
  820. }
  821. .no-border {
  822. border: 0;
  823. }
  824. ::v-deep .fieldDescCheck {
  825. .el-dialog__body {
  826. height: fit-content !important;
  827. min-height: unset !important;
  828. }
  829. }
  830. .title-style {
  831. padding: 8px 12px;
  832. background-color: #f6f7fb;
  833. border-left: 5px solid var(--bs-el-color-primary);
  834. margin: 16px 16px 0 0;
  835. }
  836. .field-wrap {
  837. // max-height: 110px;
  838. overflow: auto;
  839. margin-right: 16px;
  840. cursor: pointer;
  841. .field-item {
  842. line-height: 32px;
  843. padding: 0 12px 0 16px;
  844. .edit_field {
  845. display: none;
  846. }
  847. &:hover {
  848. background-color: #f2f7fe;
  849. .edit_field {
  850. display: block;
  851. }
  852. }
  853. }
  854. }
  855. .right-setting {
  856. height: 358px;
  857. overflow: hidden;
  858. display: flex;
  859. flex-direction: column;
  860. .paramConfig {
  861. max-height: 179px;
  862. .field-wrap {
  863. max-height: 127px;
  864. }
  865. }
  866. .structure {
  867. flex: 1;
  868. overflow: hidden;
  869. .field-wrap {
  870. height: calc(100% - 40px);
  871. }
  872. }
  873. }
  874. .result-view {
  875. font-size: 14px;
  876. font-weight: 600;
  877. color: var(--bs-el-text);
  878. position: relative;
  879. padding: 16px 0;
  880. padding-left: 12px;
  881. border-bottom: 1px solid var(--bs-background-1);
  882. &::before {
  883. content: "";
  884. height: 14px;
  885. position: absolute;
  886. left: 0;
  887. top: 50%;
  888. transform: translateY(-50%);
  889. border-left: 4px solid var(--bs-el-color-primary);
  890. }
  891. }
  892. ::v-deep .bs-table-box.is-Edit .el-table {
  893. max-height: unset !important;
  894. .el-table__body-wrapper {
  895. max-height: unset !important;
  896. }
  897. }
  898. .bs-table-box {
  899. padding: 0;
  900. height: 100% !important;
  901. margin-bottom: 0 !important;
  902. }
  903. .tree-box {
  904. padding: 0;
  905. }
  906. </style>