|
@@ -0,0 +1,711 @@
|
|
|
|
+<template>
|
|
|
|
+ <el-row>
|
|
|
|
+ <p v-if="activeData.__vModel__ && activeData.__config__.viewDataType !== 'STRING'" style="color: #ff0000; font-size: 12px; margin-bottom: 18px">
|
|
|
|
+ {{
|
|
|
|
+ '提示:当前绑定控件字段 「 ' +
|
|
|
|
+ activeData.__config__.label +
|
|
|
|
+ ' 」 为 ' +
|
|
|
|
+ activeData.__config__.viewDataType +
|
|
|
|
+ ' 类型,使用单行文本可能会造成录入信息错误,如需使用单行文本请添加数据类型校验!!!'
|
|
|
|
+ }}
|
|
|
|
+ </p>
|
|
|
|
+ <el-form-item label="控件标题">
|
|
|
|
+ <el-input v-model="activeData.__config__.label" placeholder="请输入控件标题" />
|
|
|
|
+ </el-form-item>
|
|
|
|
+ <el-form-item label="占位提示">
|
|
|
|
+ <el-input v-model="activeData.placeholder" placeholder="请输入占位提示" />
|
|
|
|
+ </el-form-item>
|
|
|
|
+ <template v-if="!activeData.__config__.isSubTable">
|
|
|
|
+ <el-form-item label="控件栅格">
|
|
|
|
+ <el-slider v-model="activeData.__config__.span" :max="24" :min="6" show-stops :step="2" show-tooltip />
|
|
|
|
+ </el-form-item>
|
|
|
|
+ <el-form-item label="标题宽度">
|
|
|
|
+ <el-input-number v-model="activeData.__config__.labelWidth" placeholder="标题宽度" :min="0" :precision="0" controls-position="right" />
|
|
|
|
+ </el-form-item>
|
|
|
|
+ </template>
|
|
|
|
+ <el-form-item label="控件宽度" v-if="activeData.__config__.isSubTable">
|
|
|
|
+ <el-input-number v-model="activeData.__config__.columnWidth" placeholder="控件宽度" :min="0" :precision="0" controls-position="right" />
|
|
|
|
+ </el-form-item>
|
|
|
|
+ <el-form-item>
|
|
|
|
+ <template slot="label">
|
|
|
|
+ <span>自动填写</span>
|
|
|
|
+ <el-tooltip style="cursor: pointer" effect="dark" :content="'设置指定规则,将结果自动填写到字段输入框中'" placement="top">
|
|
|
|
+ <i class="el-icon-question" />
|
|
|
|
+ </el-tooltip>
|
|
|
|
+ </template>
|
|
|
|
+ <el-select v-model="activeData.__config__.inputType" @change="activeData.defaultVarType = []" placeholder="请选择">
|
|
|
|
+ <el-option label="指定数值" :value="1">
|
|
|
|
+ <span>指定数值</span>
|
|
|
|
+ <el-tooltip style="cursor: pointer" effect="dark" :content="'创建数据时将指定数值自动输入'" placement="top">
|
|
|
|
+ <i class="el-icon-question" />
|
|
|
|
+ </el-tooltip>
|
|
|
|
+ </el-option>
|
|
|
|
+ <el-option label="自定义表达式" :value="2">
|
|
|
|
+ <span>自定义表达式</span>
|
|
|
|
+ <el-tooltip style="cursor: pointer" effect="dark" :content="'通过函数和本表其他字段的运算结果自动填入,被引用的字段值改变时不会改变当前字段值'" placement="top">
|
|
|
|
+ <i class="el-icon-question" />
|
|
|
|
+ </el-tooltip>
|
|
|
|
+ </el-option>
|
|
|
|
+ <el-option label="页面变量" :value="4">
|
|
|
|
+ <span>页面变量</span>
|
|
|
|
+ <el-tooltip style="cursor: pointer" effect="dark" :content="'通过页面内定义变量值结果自动填入'" placement="top">
|
|
|
|
+ <i class="el-icon-question" />
|
|
|
|
+ </el-tooltip>
|
|
|
|
+ </el-option>
|
|
|
|
+ </el-select>
|
|
|
|
+ </el-form-item>
|
|
|
|
+ <el-form-item label="指定数值" v-if="activeData.__config__.inputType === 1">
|
|
|
|
+ <el-input :value="setDefaultValue(activeData.__config__.defaultValue)" placeholder="请输入默认值" @input="onDefaultValueInput" />
|
|
|
|
+ </el-form-item>
|
|
|
|
+ <el-form-item label="自定义表达" v-if="activeData.__config__.inputType === 2">
|
|
|
|
+ <customExpression :defaultValueExp="activeData.defaultValueExp" @onChangeExp="setDefaultValExp" :dbLinkId="dbLinkId" :drawList="drawList" :activeData="activeData" />
|
|
|
|
+ </el-form-item>
|
|
|
|
+ <el-form-item label="选择变量" v-if="activeData.__config__.inputType === 4">
|
|
|
|
+ <el-cascader ref="varCascader" @change="varchange" v-model="activeData.defaultVarType" :options="varTypeList" @visible-change="allVarListChange"></el-cascader>
|
|
|
|
+ </el-form-item>
|
|
|
|
+ <el-form-item v-if="(activeData.__config__.inputType === 4 && cascaderTypeshow) || activeData.cascaderType">
|
|
|
|
+ <template slot="label">
|
|
|
|
+ <span>选择层级</span>
|
|
|
|
+ <el-tooltip style="cursor: pointer" effect="dark" :content="'适用于级联组件全局变量,可配置选择层级'" placement="top">
|
|
|
|
+ <i class="el-icon-question" />
|
|
|
|
+ </el-tooltip>
|
|
|
|
+ </template>
|
|
|
|
+ <el-select v-model="activeData.cascaderType" placeholder="请选择">
|
|
|
|
+ <el-option label="子节点值" value="son"></el-option>
|
|
|
|
+ <el-option label="父节点值" value="topLeve"></el-option>
|
|
|
|
+ </el-select>
|
|
|
|
+ </el-form-item>
|
|
|
|
+ <el-form-item label="前缀">
|
|
|
|
+ <el-input v-model="activeData.__slot__.prepend" placeholder="请输入前缀" />
|
|
|
|
+ </el-form-item>
|
|
|
|
+ <el-form-item label="后缀">
|
|
|
|
+ <el-input v-model="activeData.__slot__.append" placeholder="请输入后缀" />
|
|
|
|
+ </el-form-item>
|
|
|
|
+ <el-form-item label="前图标">
|
|
|
|
+ <el-input v-model="activeData['prefix-icon']" placeholder="请输入前图标名称">
|
|
|
|
+ <el-button slot="append" @click="openIconsDialog('prefix-icon')"> 选择 </el-button>
|
|
|
|
+ </el-input>
|
|
|
|
+ </el-form-item>
|
|
|
|
+ <el-form-item label="后图标">
|
|
|
|
+ <el-input v-model="activeData['suffix-icon']" placeholder="请输入后图标名称">
|
|
|
|
+ <el-button slot="append" @click="openIconsDialog('suffix-icon')"> 选择 </el-button>
|
|
|
|
+ </el-input>
|
|
|
|
+ </el-form-item>
|
|
|
|
+ <el-form-item label="最多输入">
|
|
|
|
+ <el-input v-model="activeData.maxlength" placeholder="请输入字符长度" type="number">
|
|
|
|
+ <template slot="append">个字符</template>
|
|
|
|
+ </el-input>
|
|
|
|
+ </el-form-item>
|
|
|
|
+ <!-- <el-form-item label="显示标签">
|
|
|
|
+ <el-switch v-model="activeData.__config__.showLabel" />
|
|
|
|
+ </el-form-item> -->
|
|
|
|
+ <!-- <el-form-item label="输入统计">
|
|
|
|
+ <el-switch v-model="activeData['show-word-limit']" />
|
|
|
|
+ </el-form-item> -->
|
|
|
|
+ <!-- <el-form-item label="能否清空">
|
|
|
|
+ <el-switch v-model="activeData.clearable" />
|
|
|
|
+ </el-form-item> -->
|
|
|
|
+ <el-form-item>
|
|
|
|
+ <template slot="label">
|
|
|
|
+ <span>应用变量</span>
|
|
|
|
+ <el-tooltip style="cursor: pointer" effect="dark" :content="'将当前组件应用为表单内全局变量'" placement="top">
|
|
|
|
+ <i class="el-icon-question" />
|
|
|
|
+ </el-tooltip>
|
|
|
|
+ </template>
|
|
|
|
+ <el-switch v-model="activeData.allVar" />
|
|
|
|
+ </el-form-item>
|
|
|
|
+ <el-form-item label="是否密码">
|
|
|
|
+ <el-switch v-model="activeData['show-password']" />
|
|
|
|
+ </el-form-item>
|
|
|
|
+ <el-form-item label="是否只读">
|
|
|
|
+ <el-switch v-model="activeData.readonly" />
|
|
|
|
+ </el-form-item>
|
|
|
|
+ <el-form-item label="是否禁用">
|
|
|
|
+ <el-switch v-model="activeData.disabled" />
|
|
|
|
+ </el-form-item>
|
|
|
|
+ <el-form-item label="是否隐藏">
|
|
|
|
+ <el-switch v-model="activeData.displayNone" />
|
|
|
|
+ </el-form-item>
|
|
|
|
+ <el-form-item label="是否URL">
|
|
|
|
+ <el-switch v-model="activeData.isUrl" />
|
|
|
|
+ </el-form-item>
|
|
|
|
+ <el-form-item label="只做展示">
|
|
|
|
+ <el-switch
|
|
|
|
+ v-model="activeData.isText"
|
|
|
|
+ @change="
|
|
|
|
+ activeData.__vModel__ = 'isOnlyRead_' + +new Date()
|
|
|
|
+ activeData.__vModelName__ = 'isOnlyRead_' + +new Date()
|
|
|
|
+ "
|
|
|
|
+ />
|
|
|
|
+ </el-form-item>
|
|
|
|
+ <el-form-item label="别名展示">
|
|
|
|
+ <el-switch v-model="activeData.anotherName" />
|
|
|
|
+ <el-button
|
|
|
|
+ v-if="activeData.anotherName"
|
|
|
|
+ style="margin-left: 100px"
|
|
|
|
+ size="mini"
|
|
|
|
+ icon="el-icon-plus"
|
|
|
|
+ @click="activeData.anotherNameList.push({ realValue: '', anotherName: '', columnBackgroundColor: null })"
|
|
|
|
+ >添加</el-button
|
|
|
|
+ >
|
|
|
|
+ </el-form-item>
|
|
|
|
+ <columnAnotherName v-if="activeData.anotherName" :anotherNameList="activeData.anotherNameList" />
|
|
|
|
+ <el-form-item label="开启扫码">
|
|
|
|
+ <el-switch v-model="activeData.isScan" />
|
|
|
|
+ </el-form-item>
|
|
|
|
+ <template>
|
|
|
|
+ <el-form-item label="" label-width="40px">
|
|
|
|
+ <el-radio-group v-model="activeData.__config__.dataType" size="small" style="text-align: center" @change="dataTypeChange">
|
|
|
|
+ <!-- <el-radio-button label="static">静态数据</el-radio-button>-->
|
|
|
|
+ <!-- <el-radio-button label="dictionary">数据字典</el-radio-button>-->
|
|
|
|
+ <el-radio-button label="dynamic">API数据</el-radio-button>
|
|
|
|
+ </el-radio-group>
|
|
|
|
+ </el-form-item>
|
|
|
|
+ <template v-if="activeData.__config__.dataType === 'dynamic'">
|
|
|
|
+ <el-form-item label="API数据">
|
|
|
|
+ <el-cascader
|
|
|
|
+ :options="dataInterfaceSelector"
|
|
|
|
+ v-model="activeData.__config__.propsUrl"
|
|
|
|
+ placeholder="请选择API数据"
|
|
|
|
+ :filter-method="apiFilterMethod"
|
|
|
|
+ :props="{ expandTrigger: 'hover', emitPath: false }"
|
|
|
|
+ :show-all-levels="false"
|
|
|
|
+ @change="propsUrlChange"
|
|
|
|
+ clearable
|
|
|
|
+ filterable
|
|
|
|
+ >
|
|
|
|
+ </el-cascader>
|
|
|
|
+ </el-form-item>
|
|
|
|
+ <el-divider v-if="activeData.__config__.ApiParams && activeData.__config__.ApiParams.length">API输入参数设置</el-divider>
|
|
|
|
+ <el-form-item class="varFormItem" v-for="(param, i) of activeData.__config__.ApiParams" :key="i" :label="param.name + ' ' + param.key">
|
|
|
|
+ <el-cascader v-model="param.varType" :options="varTypeList"></el-cascader>
|
|
|
|
+ <el-input v-if="param.varType == 1 && param.datatype === 'string'" v-model="param.def"></el-input>
|
|
|
|
+ <el-input v-if="param.varType == 1 && param.datatype === 'number'" v-model="param.def" type="number"></el-input>
|
|
|
|
+ <el-date-picker v-if="param.varType == 1 && param.datatype === 'date'" v-model="param.def" placeholder="选择日期" type="date" value-format="yyyyMMdd"></el-date-picker>
|
|
|
|
+ <el-date-picker v-if="param.varType == 1 && param.datatype === 'month'" v-model="param.def" placeholder="选择月" type="month" value-format="yyyyMM"></el-date-picker>
|
|
|
|
+ <el-time-picker v-if="param.varType == 1 && param.datatype === 'time'" v-model="param.def" placeholder="选择时间" value-format="HH:mm:ss"></el-time-picker>
|
|
|
|
+ <el-date-picker v-if="param.varType == 1 && param.datatype === 'timestamp'" v-model="param.def" placeholder="选择日期" type="date" value-format="timestamp"></el-date-picker>
|
|
|
|
+ <el-time-picker v-if="param.varType == 1 && param.datatype === 'timestamp'" v-model="param.def" placeholder="选择时间" value-format="timestamp"></el-time-picker>
|
|
|
|
+ </el-form-item>
|
|
|
|
+ <el-divider>API返回值设置</el-divider>
|
|
|
|
+ <el-form-item>
|
|
|
|
+ <template slot="label">
|
|
|
|
+ <span>组件设置:</span>
|
|
|
|
+ <el-tooltip style="cursor: pointer" effect="dark" :content="'当前组件设置,指定API返回值某一项作为key或value'" placement="top">
|
|
|
|
+ <i class="el-icon-question" />
|
|
|
|
+ </el-tooltip>
|
|
|
|
+ </template>
|
|
|
|
+ <el-button size="mini" type="primary" plain @click="previewClick" icon="View">API返回值结构预览</el-button>
|
|
|
|
+ </el-form-item>
|
|
|
|
+ <template v-if="activeData.__config__.ApiReturn && activeData.__config__.ApiReturn.length">
|
|
|
|
+ <el-form-item>
|
|
|
|
+ <template slot="label">
|
|
|
|
+ <span>变量设置:</span>
|
|
|
|
+ <el-tooltip style="cursor: pointer" effect="dark" :content="'当前页面变量设置,从API返回值结构预览中选择一或多个类作为变量'" placement="top">
|
|
|
|
+ <i class="el-icon-question" />
|
|
|
|
+ </el-tooltip>
|
|
|
|
+ </template>
|
|
|
|
+ </el-form-item>
|
|
|
|
+ <el-table :data="activeData.__config__.ApiReturn" style="width: 100%">
|
|
|
|
+ <el-table-column prop="keyName" label="API返回值"></el-table-column>
|
|
|
|
+ <el-table-column label="页面变量名">
|
|
|
|
+ <template slot-scope="scope">
|
|
|
|
+ <el-input @input="varNamefitlte(scope.row, $event)" v-model="scope.row.varName" placeholder="请输入页面变量名" />
|
|
|
|
+ <div v-if="varNamefitlteclass(scope.row, scope.row.varName)" style="color: red">变量名重复 重新输入</div>
|
|
|
|
+ </template>
|
|
|
|
+ </el-table-column>
|
|
|
|
+ <el-table-column label="操作" width="50">
|
|
|
|
+ <template slot-scope="scope">
|
|
|
|
+ <div class="close-btn select-line-icon" style="cursor: pointer" @click="activeData.__config__.ApiReturn.splice(scope.$index, 1)">
|
|
|
|
+ <i class="el-icon-delete" />
|
|
|
|
+ </div>
|
|
|
|
+ </template>
|
|
|
|
+ </el-table-column>
|
|
|
|
+ </el-table>
|
|
|
|
+ </template>
|
|
|
|
+ </template>
|
|
|
|
+ <!-- <el-divider />-->
|
|
|
|
+ </template>
|
|
|
|
+ <el-divider>校验</el-divider>
|
|
|
|
+ <el-form-item label="是否必填">
|
|
|
|
+ <el-switch v-model="activeData.__config__.required" />
|
|
|
|
+ </el-form-item>
|
|
|
|
+ <div v-for="(item, index) in activeData.__config__.regList" :key="index" class="reg-item">
|
|
|
|
+ <span class="close-btn" @click="activeData.__config__.regList.splice(index, 1)">
|
|
|
|
+ <i class="el-icon-close" />
|
|
|
|
+ </span>
|
|
|
|
+ <el-form-item label="表达式">
|
|
|
|
+ <el-input v-model="item.pattern" placeholder="请输入正则" />
|
|
|
|
+ </el-form-item>
|
|
|
|
+ <el-form-item label="错误提示" style="margin-bottom: 0">
|
|
|
|
+ <el-input v-model="item.message" placeholder="请输入错误提示" />
|
|
|
|
+ </el-form-item>
|
|
|
|
+ </div>
|
|
|
|
+ <div class="mt-10">
|
|
|
|
+ <el-dropdown>
|
|
|
|
+ <el-button type="primary">添加常用校验<i class="el-icon-arrow-down el-icon--right"></i> </el-button>
|
|
|
|
+ <el-dropdown-menu slot="dropdown">
|
|
|
|
+ <el-dropdown-item @click.native="addHandle(item)" v-for="(item, i) in ruleList" :key="i"> {{ item.label }}</el-dropdown-item>
|
|
|
|
+ </el-dropdown-menu>
|
|
|
|
+ </el-dropdown>
|
|
|
|
+ <el-button type="primary" @click="addReg" style="margin-left: 10px"> 自定义规则 </el-button>
|
|
|
|
+ </div>
|
|
|
|
+ <iconBox :visible.sync="iconsVisible" :current="activeData[currentIconModel]" @choiceIcon="setIcon" />
|
|
|
|
+ <el-dialog :visible.sync="previewShow" title="API数据结构预览" width="800px" append-to-body class="source-http-preview">
|
|
|
|
+ <el-table :data="previewArr" border row-key="path" default-expand-all>
|
|
|
|
+ <el-table-column label="结构">
|
|
|
|
+ <template #default="scope">
|
|
|
|
+ {{ scope.row.key }}
|
|
|
|
+ </template>
|
|
|
|
+ </el-table-column>
|
|
|
|
+ <el-table-column label="类型" width="100px" align="center">
|
|
|
|
+ <template #default="scope">
|
|
|
|
+ {{ scope.row.type }}
|
|
|
|
+ </template>
|
|
|
|
+ </el-table-column>
|
|
|
|
+ <el-table-column label="jsonpath">
|
|
|
|
+ <template #default="scope">
|
|
|
|
+ {{ scope.row.path }}
|
|
|
|
+ </template>
|
|
|
|
+ </el-table-column>
|
|
|
|
+ <el-table-column label="操作" width="140px" align="center">
|
|
|
|
+ <template #default="scope">
|
|
|
|
+ <el-button v-if="scope.row.type === 'array'" size="small" type="primary" plain @click="getAllPath(scope.row)"> 使用全部子项 </el-button>
|
|
|
|
+ <el-button v-if="scope.row.type !== 'array' && scope.row.type !== 'object'" size="small" type="primary" plain @click="getPath(scope.row)"> 使用 </el-button>
|
|
|
|
+ </template>
|
|
|
|
+ </el-table-column>
|
|
|
|
+ </el-table>
|
|
|
|
+ </el-dialog>
|
|
|
|
+ </el-row>
|
|
|
|
+</template>
|
|
|
|
+<script>
|
|
|
|
+import iconBox from '@/components/JNPF-iconBox'
|
|
|
|
+import customExpression from '@/components/Generator/index/RightComponents/customExpression'
|
|
|
|
+import columnAnotherName from '@/components/Generator/index/RightComponents/componets/columnAnotherName'
|
|
|
|
+import comMixin from './mixin'
|
|
|
|
+import { loopActiveTabelList, loopRelationList, loopRelationTabelList } from '@/utils'
|
|
|
|
+import { dataapicategoryList, dataapiDetail, dataapiList } from '@/api/systemData/dataInterface'
|
|
|
|
+import { getparamsys, paramList } from '@/api/newbi/globalParams'
|
|
|
|
+import { getAPIData } from '@/components/Dataset-filter/util'
|
|
|
|
+import { openurl } from '@/components/Dataset-filter/report'
|
|
|
|
+import { param } from '@/components/Dataset-filter/config'
|
|
|
|
+export default {
|
|
|
|
+ props: ['activeData', 'dbLinkId', 'drawList'],
|
|
|
|
+ mixins: [comMixin],
|
|
|
|
+ components: { iconBox, customExpression, columnAnotherName },
|
|
|
|
+ data() {
|
|
|
|
+ return {
|
|
|
|
+ iconsVisible: false,
|
|
|
|
+ currentIconModel: null,
|
|
|
|
+ ruleList: [
|
|
|
|
+ {
|
|
|
|
+ pattern: '/^\\d+$/',
|
|
|
|
+ message: '请输入正确的数字',
|
|
|
|
+ label: '数字'
|
|
|
|
+ },
|
|
|
|
+ {
|
|
|
|
+ pattern: '/^[1-9]\\d*\\.\\d*|0\\.\\d*[1-9]\\d*|0?\\.0+|0$/',
|
|
|
|
+ message: '请输入正确的金额',
|
|
|
|
+ label: '金额'
|
|
|
|
+ },
|
|
|
|
+ {
|
|
|
|
+ pattern: '/^0\\d{2,3}-?\\d{7,8}$/',
|
|
|
|
+ message: '请输入正确的电话号码',
|
|
|
|
+ label: '电话'
|
|
|
|
+ },
|
|
|
|
+ {
|
|
|
|
+ pattern: '/^1[3456789]\\d{9}$/',
|
|
|
|
+ message: '请输入正确的手机号码',
|
|
|
|
+ label: '手机'
|
|
|
|
+ },
|
|
|
|
+ {
|
|
|
|
+ pattern: '/^1[3456789]\\d{9}$|^0\\d{2,3}-?\\d{7,8}$/',
|
|
|
|
+ message: '请输入正确的联系方式',
|
|
|
|
+ label: '电话/手机'
|
|
|
|
+ },
|
|
|
|
+ {
|
|
|
|
+ pattern: '/^[a-z0-9]+([._\\-]*[a-z0-9])*@([a-z0-9]+[-a-z0-9]*[a-z0-9]+.){1,63}[a-z0-9]+$/',
|
|
|
|
+ message: '请输入正确的邮箱',
|
|
|
|
+ label: '邮箱'
|
|
|
|
+ },
|
|
|
|
+ {
|
|
|
|
+ pattern: '/^[1-9]\\d{5}(18|19|([23]\\d))\\d{2}((0[1-9])|(10|11|12))(([0-2][1-9])|10|20|30|31)\\d{3}[0-9Xx]$/',
|
|
|
|
+ message: '请输入正确的身份证号码',
|
|
|
|
+ label: '身份证'
|
|
|
|
+ },
|
|
|
|
+ {
|
|
|
|
+ pattern: '/^\\d{4}-\\d{1,2}-\\d{1,2}$/',
|
|
|
|
+ message: '请输入格式为YYYY-MM-DD的日期',
|
|
|
|
+ label: '年日日'
|
|
|
|
+ },
|
|
|
|
+ {
|
|
|
|
+ pattern: '/^\\d{4}-\\d{1,2}-\\d{1,2} \\d{2}:\\d{2}:\\d{2}$/',
|
|
|
|
+ message: '请输入格式为YYYY-MM-DD HH:mm:ss的日期',
|
|
|
|
+ label: '年日日 时分秒'
|
|
|
|
+ },
|
|
|
|
+ {
|
|
|
|
+ pattern: '/^\\d{4}-\\d{1,2}-\\d{1,2} \\d{2}:\\d{2}$/',
|
|
|
|
+ message: '请输入格式为HH:mm:ss的时间',
|
|
|
|
+ label: '时分秒'
|
|
|
|
+ },
|
|
|
|
+ {
|
|
|
|
+ pattern: '/^\\d{2}:\\d{2}:\\d{2}$/',
|
|
|
|
+ message: '请输入格式为HH:mm的时间',
|
|
|
|
+ label: '时分'
|
|
|
|
+ },
|
|
|
|
+ {
|
|
|
|
+ pattern: '/^\\d{2}:\\d{2}$/',
|
|
|
|
+ message: '请输入格式为HH的时间',
|
|
|
|
+ label: '时'
|
|
|
|
+ }
|
|
|
|
+ ],
|
|
|
|
+ allVarList: [],
|
|
|
|
+ apiVarList: [],
|
|
|
|
+ varTypeList: [],
|
|
|
|
+ cascaderTypeshow: false,
|
|
|
|
+
|
|
|
|
+ treeData: [],
|
|
|
|
+ dataInterfaceSelector: [],
|
|
|
|
+ sysVarList: [], //系统变量
|
|
|
|
+ previewShow: false,
|
|
|
|
+ previewArr: [],
|
|
|
|
+ showFields: [],
|
|
|
|
+ apiJoinName: ''
|
|
|
|
+ }
|
|
|
|
+ },
|
|
|
|
+ created() {
|
|
|
|
+ this.allVarListChange(true)
|
|
|
|
+ this.getDataInterfaceSelector()
|
|
|
|
+ if (this.activeData.__config__.dataType === 'dynamic' && this.activeData.__config__.propsUrl) {
|
|
|
|
+ this.propsUrlChange(this.activeData.__config__.propsUrl)
|
|
|
|
+ }
|
|
|
|
+ },
|
|
|
|
+ methods: {
|
|
|
|
+ varchange() {
|
|
|
|
+ this.cascaderTypeshow = false
|
|
|
|
+ this.activeData.cascaderType = ''
|
|
|
|
+ let vardata = this.$refs['varCascader'].getCheckedNodes()[0].data
|
|
|
|
+ if (vardata && vardata.cascaderType) {
|
|
|
|
+ this.activeData.cascaderType = ''
|
|
|
|
+ this.cascaderTypeshow = true
|
|
|
|
+ }
|
|
|
|
+ },
|
|
|
|
+ getAllVarList() {
|
|
|
|
+ //获取表单内变量
|
|
|
|
+ let mapList = this.activeData.__config__.relationTable ? loopActiveTabelList(this.drawList, this.activeData.__config__.relationTable) : loopRelationList(this.drawList)
|
|
|
|
+ this.allVarList = mapList
|
|
|
|
+ .map((o) => {
|
|
|
|
+ if (o.allVar) {
|
|
|
|
+ return {
|
|
|
|
+ label: o.__config__.label,
|
|
|
|
+ value: o.__vModel__
|
|
|
|
+ }
|
|
|
|
+ }
|
|
|
|
+ })
|
|
|
|
+ .filter((l) => l !== undefined)
|
|
|
|
+ },
|
|
|
|
+ getAllapiVarList() {
|
|
|
|
+ //获取API返回变量
|
|
|
|
+ this.apiVarList = []
|
|
|
|
+ let mapList = this.activeData.__config__.relationTable ? loopActiveTabelList(this.drawList, this.activeData.__config__.relationTable) : loopRelationList(this.drawList)
|
|
|
|
+ mapList.forEach((item, key) => {
|
|
|
|
+ let config = item.__config__
|
|
|
|
+ if (config.ApiReturn && config.ApiReturn.length) {
|
|
|
|
+ let list = []
|
|
|
|
+ if (config.jnpfKey === 'cascader') {
|
|
|
|
+ list = config.ApiReturn.map((o) => {
|
|
|
|
+ return {
|
|
|
|
+ label: o.varName,
|
|
|
|
+ value: o.varName,
|
|
|
|
+ cascaderType: true
|
|
|
|
+ }
|
|
|
|
+ }).filter((l) => l !== undefined)
|
|
|
|
+ } else {
|
|
|
|
+ list = config.ApiReturn.map((o) => {
|
|
|
|
+ return {
|
|
|
|
+ label: o.varName,
|
|
|
|
+ value: o.varName
|
|
|
|
+ }
|
|
|
|
+ }).filter((l) => l !== undefined)
|
|
|
|
+ }
|
|
|
|
+ this.apiVarList = [...this.apiVarList, ...list]
|
|
|
|
+ }
|
|
|
|
+ })
|
|
|
|
+ },
|
|
|
|
+ //相同组件切换时 表单内全局变量数据不会及时更新 利用下拉框出现时刷新一下
|
|
|
|
+ allVarListChange(val) {
|
|
|
|
+ if (val) {
|
|
|
|
+ this.getAllVarList()
|
|
|
|
+ this.getAllapiVarList()
|
|
|
|
+ this.varTypeList = [
|
|
|
|
+ { value: 1, label: '默认值' },
|
|
|
|
+ { value: 2, label: '系统全局变量', children: this.sysVarList || [] },
|
|
|
|
+ { value: 3, label: '表单全局变量', children: this.allVarList || [] },
|
|
|
|
+ { value: 4, label: 'api全局变量', children: this.apiVarList || [] }
|
|
|
|
+ ]
|
|
|
|
+ }
|
|
|
|
+ },
|
|
|
|
+ openIconsDialog(model) {
|
|
|
|
+ this.iconsVisible = true
|
|
|
|
+ this.currentIconModel = model
|
|
|
|
+ },
|
|
|
|
+ setIcon(val) {
|
|
|
|
+ this.activeData[this.currentIconModel] = val
|
|
|
|
+ },
|
|
|
|
+ addHandle(row) {
|
|
|
|
+ this.activeData.__config__.regList.push({
|
|
|
|
+ pattern: row.pattern,
|
|
|
|
+ message: row.message
|
|
|
|
+ })
|
|
|
|
+ },
|
|
|
|
+
|
|
|
|
+ dataTypeChange(val) {
|
|
|
|
+ this.activeData.__config__.defaultValue = this.activeData.multiple ? [] : ''
|
|
|
|
+ // this.activeData.__slot__.options = []
|
|
|
|
+ this.activeData.__config__.props.value = 'id'
|
|
|
|
+ this.activeData.__config__.props.label = 'fullName'
|
|
|
|
+ if (val === 'static') {
|
|
|
|
+ this.activeData.__config__.dictionaryType = ''
|
|
|
|
+ this.activeData.__config__.propsUrl = ''
|
|
|
|
+ this.activeData.__config__.ApiParams = []
|
|
|
|
+ this.activeData.__slot__.options = []
|
|
|
|
+ }
|
|
|
|
+ if (val === 'dynamic') {
|
|
|
|
+ this.activeData.__config__.dictionaryType = ''
|
|
|
|
+ }
|
|
|
|
+ if (val === 'dictionary') {
|
|
|
|
+ this.activeData.__config__.propsUrl = ''
|
|
|
|
+ this.activeData.__config__.ApiParams = []
|
|
|
|
+ }
|
|
|
|
+ this.$nextTick(() => {
|
|
|
|
+ this.$forceUpdate()
|
|
|
|
+ })
|
|
|
|
+ },
|
|
|
|
+ previewClick() {
|
|
|
|
+ if (!this.activeData.__config__.propsUrl)
|
|
|
|
+ return this.$message({
|
|
|
|
+ message: '当前未选择API接口,不支持数据预览',
|
|
|
|
+ type: 'warning'
|
|
|
|
+ })
|
|
|
|
+ dataapiDetail(this.activeData.__config__.propsUrl).then((res) => {
|
|
|
|
+ let { apiKey } = res.data.data
|
|
|
|
+ this.apiJoinName = res.data.data.apiName
|
|
|
|
+ let resJson = JSON.parse(res.data.data.note || '{}')
|
|
|
|
+ let formVarObj = {}
|
|
|
|
+ if (resJson.params && resJson.params.length) {
|
|
|
|
+ resJson.params.forEach((i, k) => {
|
|
|
|
+ formVarObj[i.key] = i.def
|
|
|
|
+ })
|
|
|
|
+ }
|
|
|
|
+ console.log(apiKey)
|
|
|
|
+ openurl(apiKey, { ...param, ...formVarObj }).then((res) => {
|
|
|
|
+ let { data } = res.data
|
|
|
|
+ console.log(1111, data)
|
|
|
|
+ try {
|
|
|
|
+ let arr = []
|
|
|
|
+ this.previewShow = true
|
|
|
|
+ this.jsonPath(arr, data, '$')
|
|
|
|
+ this.previewArr = arr
|
|
|
|
+ console.log(arr)
|
|
|
|
+ } catch (e) {
|
|
|
|
+ this.$message({ message: '接口返回数据格式不支持', type: 'warning' })
|
|
|
|
+ }
|
|
|
|
+ })
|
|
|
|
+ })
|
|
|
|
+ },
|
|
|
|
+ jsonPath(arr, json, basePath) {
|
|
|
|
+ const type = this.validateType(json)
|
|
|
|
+ if (type === 'object') {
|
|
|
|
+ for (let key in json) {
|
|
|
|
+ const item = {
|
|
|
|
+ key,
|
|
|
|
+ path: `${basePath}.${key}`
|
|
|
|
+ }
|
|
|
|
+ const childType = this.validateType(json[key])
|
|
|
|
+ item.type = childType
|
|
|
|
+ if (childType === 'object' || childType === 'array') {
|
|
|
|
+ item.leaf = true
|
|
|
|
+ item.children = []
|
|
|
|
+ this.jsonPath(item.children, json[key], item.path)
|
|
|
|
+ } else {
|
|
|
|
+ item.leaf = false
|
|
|
|
+ item.value = json[key]
|
|
|
|
+ }
|
|
|
|
+ arr.push(item)
|
|
|
|
+ }
|
|
|
|
+ } else if (type === 'array') {
|
|
|
|
+ json = json[0]
|
|
|
|
+ if (json === undefined) return
|
|
|
|
+ for (let key in json) {
|
|
|
|
+ const item = {
|
|
|
|
+ key,
|
|
|
|
+ path: `${basePath}[*].${key}`
|
|
|
|
+ }
|
|
|
|
+ const childType = this.validateType(json[key])
|
|
|
|
+ item.type = childType
|
|
|
|
+ if (childType === 'object' || childType === 'array') {
|
|
|
|
+ item.leaf = true
|
|
|
|
+ item.children = []
|
|
|
|
+ this.jsonPath(item.children, json[key], item.path)
|
|
|
|
+ } else {
|
|
|
|
+ item.leaf = false
|
|
|
|
+ item.value = json[key]
|
|
|
|
+ }
|
|
|
|
+ arr.push(item)
|
|
|
|
+ }
|
|
|
|
+ }
|
|
|
|
+ },
|
|
|
|
+ validateType(val) {
|
|
|
|
+ // 校验JSON数据类型
|
|
|
|
+ const type = typeof val
|
|
|
|
+ if (type === 'object') {
|
|
|
|
+ if (Array.isArray(val)) {
|
|
|
|
+ return 'array'
|
|
|
|
+ } else if (val === null) {
|
|
|
|
+ return 'null'
|
|
|
|
+ } else {
|
|
|
|
+ return 'object'
|
|
|
|
+ }
|
|
|
|
+ } else {
|
|
|
|
+ return type
|
|
|
|
+ }
|
|
|
|
+ },
|
|
|
|
+ getDataInterfaceSelector() {
|
|
|
|
+ this.getAllVarList()
|
|
|
|
+ this.getAllapiVarList()
|
|
|
|
+ //获取api列表
|
|
|
|
+ dataapicategoryList().then((res) => {
|
|
|
|
+ let category = res.data.data
|
|
|
|
+ dataapiList({ apiFormal: 1, apiTypes: '1,2' }).then((res) => {
|
|
|
|
+ let list = res.data.data
|
|
|
|
+ this.dataInterfaceSelector = category
|
|
|
|
+ .map((i) => ({
|
|
|
|
+ label: i.categoryName,
|
|
|
|
+ value: i.id,
|
|
|
|
+ children: list.filter((j) => j.categoryId === i.id).map((k) => ({ label: k.apiName, value: k.id, key: k.apiKey }))
|
|
|
|
+ }))
|
|
|
|
+ .filter((i) => i.children.length)
|
|
|
|
+ })
|
|
|
|
+ this.getSysparamList()
|
|
|
|
+ })
|
|
|
|
+ },
|
|
|
|
+ getSysparamList() {
|
|
|
|
+ //获取全局系统变量
|
|
|
|
+ paramList({ paramType: 'SYSTEM' }).then((res) => {
|
|
|
|
+ let arr = res.data.data.records
|
|
|
|
+ getparamsys({ dateFormat: 'yyyy_MM_dd' }).then((r) => {
|
|
|
|
+ let sysVarValue = r.data.data
|
|
|
|
+ if (sysVarValue) {
|
|
|
|
+ this.sysVarList = arr
|
|
|
|
+ .map((i) => {
|
|
|
|
+ return {
|
|
|
|
+ label: i.paramName,
|
|
|
|
+ value: sysVarValue[i.paramKey] || null
|
|
|
|
+ }
|
|
|
|
+ })
|
|
|
|
+ .filter((l) => l !== undefined)
|
|
|
|
+ }
|
|
|
|
+ })
|
|
|
|
+ this.varTypeList = [
|
|
|
|
+ { value: 1, label: '默认值' },
|
|
|
|
+ { value: 2, label: '系统全局变量', children: this.sysVarList || [] },
|
|
|
|
+ { value: 3, label: '表单全局变量', children: this.allVarList || [] },
|
|
|
|
+ { value: 4, label: 'api全局变量', children: this.apiVarList || [] }
|
|
|
|
+ ]
|
|
|
|
+ this.$nextTick(() => {
|
|
|
|
+ this.allVarListChange(true)
|
|
|
|
+ })
|
|
|
|
+ })
|
|
|
|
+ },
|
|
|
|
+ varNamefitlte(row, val) {
|
|
|
|
+ if (this.activeData.__config__.ApiReturn.find((i) => i.varName === val && i.keyName !== row.keyName)) {
|
|
|
|
+ this.activeData.varRepeat = true
|
|
|
|
+ return this.$message({
|
|
|
|
+ message: '检测到变量命名重复,请重新输入',
|
|
|
|
+ type: 'warning'
|
|
|
|
+ })
|
|
|
|
+ }
|
|
|
|
+ if (this.apiVarList.find((i) => i.label === val)) {
|
|
|
|
+ this.activeData.varRepeat = true
|
|
|
|
+ return this.$message({
|
|
|
|
+ message: '检测到变量命名重复,请重新输入',
|
|
|
|
+ type: 'warning'
|
|
|
|
+ })
|
|
|
|
+ }
|
|
|
|
+ this.activeData.varRepeat = false
|
|
|
|
+ this.getAllapiVarList()
|
|
|
|
+ this.varTypeList[3].children = this.apiVarList
|
|
|
|
+ },
|
|
|
|
+ varNamefitlteclass(row, val) {
|
|
|
|
+ let flag = false
|
|
|
|
+ if (this.activeData.__config__.ApiReturn.find((i) => i.varName === val && i.keyName !== row.keyName)) {
|
|
|
|
+ flag = true
|
|
|
|
+ }
|
|
|
|
+ if (this.apiVarList.filter((i) => i.label === val).length > 1) {
|
|
|
|
+ flag = true
|
|
|
|
+ }
|
|
|
|
+ return flag
|
|
|
|
+ },
|
|
|
|
+ apiFilterMethod(node, keyword) {
|
|
|
|
+ let { label, key } = node.data
|
|
|
|
+ keyword = keyword.toLowerCase()
|
|
|
|
+ return label.includes(keyword) || key.toLowerCase().includes(keyword)
|
|
|
|
+ },
|
|
|
|
+ fitLabelChange() {
|
|
|
|
+ if (!this.activeData.__config__.apiProps.fitLabel.length) {
|
|
|
|
+ this.activeData.__config__.apiProps.labelSeparator = ''
|
|
|
|
+ }
|
|
|
|
+ },
|
|
|
|
+ propsUrlChange(val) {
|
|
|
|
+ if (!val) {
|
|
|
|
+ this.activeData.__slot__.options = []
|
|
|
|
+ return
|
|
|
|
+ }
|
|
|
|
+ // this.activeData.__config__.ApiParams = []
|
|
|
|
+ // this.activeData.__config__.apiProps = {label: '',value: ''}
|
|
|
|
+ this.activeData.__config__.defaultValue = this.activeData.multiple ? [] : ''
|
|
|
|
+ //获取api信息
|
|
|
|
+ dataapiDetail(val).then((res) => {
|
|
|
|
+ //获取api值
|
|
|
|
+ getAPIData(this.activeData.__slot__, val, [], [], '', this.activeData.__config__.apiProps).then((res) => {
|
|
|
|
+ this.$set(this.activeData.__slot__, 'options', res)
|
|
|
|
+ })
|
|
|
|
+ let resJson = JSON.parse(res.data.data.note || '{}')
|
|
|
|
+ this.showFields = resJson.showFields || []
|
|
|
|
+ if (resJson.params && resJson.params.length) {
|
|
|
|
+ //添加变量类型 1:默认 2:全局系统变量 3:表单内全局变量
|
|
|
|
+ if (!this.activeData.__config__.ApiParams.length) {
|
|
|
|
+ resJson.params.forEach((i, k) => [Object.assign(i, { varType: [1] })])
|
|
|
|
+ this.activeData.__config__.ApiParams = resJson.params
|
|
|
|
+ } else {
|
|
|
|
+ let APIKeylist = resJson.params.map((i) => {
|
|
|
|
+ return i.key
|
|
|
|
+ })
|
|
|
|
+ let paramsList = this.activeData.__config__.ApiParams.filter((l) => APIKeylist.includes(l.key))
|
|
|
|
+ paramsList.forEach((i, k) => {
|
|
|
|
+ if (!i.varType) {
|
|
|
|
+ Object.assign(i, { varType: [1] })
|
|
|
|
+ }
|
|
|
|
+ })
|
|
|
|
+ this.activeData.__config__.ApiParams = paramsList
|
|
|
|
+ }
|
|
|
|
+ } else {
|
|
|
|
+ this.activeData.__config__.ApiParams = []
|
|
|
|
+ }
|
|
|
|
+ })
|
|
|
|
+ },
|
|
|
|
+ getPath(item) {
|
|
|
|
+ this.getAPiPath(item)
|
|
|
|
+ },
|
|
|
|
+ getAllPath(array) {
|
|
|
|
+ array.children.forEach((item) => this.getAPiPath(item))
|
|
|
|
+ },
|
|
|
|
+ getAPiPath({ key }) {
|
|
|
|
+ if (this.activeData.__config__.ApiReturn.find((i) => i.keyName === key)) return
|
|
|
|
+ this.activeData.__config__.ApiReturn.push({ keyName: key, varName: key, apiName: this.apiJoinName })
|
|
|
|
+ this.getAllapiVarList()
|
|
|
|
+ this.varTypeList[2].children = this.apiVarList
|
|
|
|
+ }
|
|
|
|
+ }
|
|
|
|
+}
|
|
|
|
+</script>
|