| | |
| | | const currentRs = ref<AmisDockConfig>(null); |
| | | |
| | | const getWithTemplateDataCommentSql = (sql: string, data: any) => { |
| | | const reg = new RegExp(`^\\s*(\\s*--\\s*".*"\\s*:.*\\n)+`); |
| | | const isMatchReg = reg.test(sql); |
| | | if (!Array.isArray(data)) { |
| | | return sql; |
| | | return isMatchReg ? sql.replace(reg, '') : sql; |
| | | } |
| | | const first = data[0]; |
| | | if (!_.isObjectLike(first)) { |
| | | return sql; |
| | | return isMatchReg ? sql.replace(reg, '') : sql; |
| | | } |
| | | const firstKeyList = Object.keys(first); |
| | | // 值为对象 |
| | | if (_.isObjectLike(first[firstKeyList[0]])) { |
| | | return sql; |
| | | return isMatchReg ? sql.replace(reg, '') : sql; |
| | | } |
| | | |
| | | |
| | | |
| | | let comment = ''; |
| | | firstKeyList.map((key, index, array) => { |
| | |
| | | comment += `-- "${key}": ${value}\n`; |
| | | }); |
| | | |
| | | const reg = new RegExp(`^\\s*(\\s*--\\s*".*"\\s*:.*\\n)+`) |
| | | // 已经存在,一定要替换成最新的 |
| | | if (reg.test(sql)) { |
| | | const replaceStr = sql.replace(reg,comment); |
| | | if (isMatchReg) { |
| | | const replaceStr = sql.replace(reg, comment); |
| | | return replaceStr; |
| | | } |
| | | |
| | | const result = comment+sql; |
| | | const result = comment + sql; |
| | | return result; |
| | | }; |
| | | const dockRowChange = (row) => { |
| | |
| | | }; |
| | | const templateData = extraInfoMap.value.get(row.recordId).templateData; |
| | | |
| | | currentDockConfig.value.sql = getWithTemplateDataCommentSql(currentDockConfig.value.sql,templateData) |
| | | currentDockConfig.value.sql = getWithTemplateDataCommentSql(currentDockConfig.value.sql, templateData); |
| | | }; |
| | | const currentDockConfig = ref(null); |
| | | /** @description 路径分隔符 */ |