| | |
| | | <el-button type="primary" @click="addArg">添加</el-button> |
| | | </div> |
| | | <el-table class="flex-auto" :data="args" border> |
| | | <el-table-column prop="name" label="名称" show-overflow-tooltip> |
| | | <el-table-column prop="name" width="150" label="名称" show-overflow-tooltip> |
| | | <template #default="scope"> |
| | | <el-input v-model="scope.row.name" @input="argsInput"></el-input> |
| | | </template> |
| | | </el-table-column> |
| | | <el-table-column prop="prompt" label="提示词" show-overflow-tooltip> |
| | | <el-table-column prop="prompt" width="450" label="提示词" show-overflow-tooltip> |
| | | <template #default="scope"> |
| | | <el-input v-model="scope.row.prompt" @input="argsInput"></el-input> |
| | | <el-input type="textarea" :rows="2" v-model="scope.row.prompt" @input="argsInput"></el-input> |
| | | </template> |
| | | </el-table-column> |
| | | <el-table-column prop="check" label="缺省值" show-overflow-tooltip> |
| | |
| | | </el-select> |
| | | </div> |
| | | <codemirror |
| | | ref="sqlCodemirrorRef" |
| | | class="overflow-auto" |
| | | style="height: calc(100% - 36px)" |
| | | v-model="currentDockConfig.sql" |
| | |
| | | emit('backLastPage'); |
| | | }; |
| | | const currentRs = ref<AmisDockConfig>(null); |
| | | |
| | | const getWithTemplateDataCommentSql = (sql: string, data: any) => { |
| | | if (!Array.isArray(data)) { |
| | | return sql; |
| | | } |
| | | const first = data[0]; |
| | | if (!_.isObjectLike(first)) { |
| | | return sql; |
| | | } |
| | | const firstKeyList = Object.keys(first); |
| | | // 值为对象 |
| | | if (_.isObjectLike(first[firstKeyList[0]])) { |
| | | return sql; |
| | | } |
| | | |
| | | |
| | | |
| | | let comment = ''; |
| | | firstKeyList.map((key, index, array) => { |
| | | const value = JSON.stringify(first[key]); |
| | | comment += `-- "${key}": ${value}\n`; |
| | | }); |
| | | |
| | | const reg = new RegExp(`^\\s*(\\s*--\\s*".*"\\s*:.*\\n)+`) |
| | | // 已经存在,一定要替换成最新的 |
| | | if (reg.test(sql)) { |
| | | const replaceStr = sql.replace(reg,comment); |
| | | return replaceStr; |
| | | } |
| | | |
| | | const result = comment+sql; |
| | | return result; |
| | | }; |
| | | const dockRowChange = (row) => { |
| | | currentRs.value = row; |
| | | currentDockConfig.value = dockConfigList.value.find((item) => item.id === currentRs.value.recordId) ?? { |
| | |
| | | sql: '', |
| | | database: defaultSelectDatabase ?? databaseList.value[0]?.id ?? null, |
| | | }; |
| | | const templateData = extraInfoMap.value.get(row.recordId).templateData; |
| | | |
| | | currentDockConfig.value.sql = getWithTemplateDataCommentSql(currentDockConfig.value.sql,templateData) |
| | | }; |
| | | const currentDockConfig = ref(null); |
| | | /** @description 路径分隔符 */ |
| | |
| | | updateSqlAndRs(); |
| | | } |
| | | }); |
| | | const sqlCodemirrorRef= useCompRef(Codemirror); |
| | | const beforeChange = (cm,change) => { |
| | | |
| | | }; |
| | | |
| | | // watch(() => sqlCodemirrorRef.value, (codeMirrorRef) => { |
| | | // codeMirrorRef. |
| | | // }) |