更新的条件支持选择列
This commit is contained in:
@@ -1 +1 @@
|
|||||||
<!DOCTYPE html><html lang=en><head><meta charset=utf-8><meta http-equiv=X-UA-Compatible content="IE=edge"><meta name=viewport content="width=device-width,initial-scale=1"><link rel=icon href=favicon-db.png><title>数据库文档管理</title><link href=css/app.b6b9fe42.css rel=preload as=style><link href=css/chunk-vendors.8924efc6.css rel=preload as=style><link href=js/app.c876342e.js rel=preload as=script><link href=js/chunk-vendors.d40f789d.js rel=preload as=script><link href=css/chunk-vendors.8924efc6.css rel=stylesheet><link href=css/app.b6b9fe42.css rel=stylesheet></head><body><noscript><strong>We're sorry but zyplayer-db-ui doesn't work properly without JavaScript enabled. Please enable it to continue.</strong></noscript><div id=app></div><script src=js/chunk-vendors.d40f789d.js></script><script src=js/app.c876342e.js></script></body></html>
|
<!DOCTYPE html><html lang=en><head><meta charset=utf-8><meta http-equiv=X-UA-Compatible content="IE=edge"><meta name=viewport content="width=device-width,initial-scale=1"><link rel=icon href=favicon-db.png><title>数据库文档管理</title><link href=css/app.b6b9fe42.css rel=preload as=style><link href=css/chunk-vendors.8924efc6.css rel=preload as=style><link href=js/app.8fdb52a2.js rel=preload as=script><link href=js/chunk-vendors.d40f789d.js rel=preload as=script><link href=css/chunk-vendors.8924efc6.css rel=stylesheet><link href=css/app.b6b9fe42.css rel=stylesheet></head><body><noscript><strong>We're sorry but zyplayer-db-ui doesn't work properly without JavaScript enabled. Please enable it to continue.</strong></noscript><div id=app></div><script src=js/chunk-vendors.d40f789d.js></script><script src=js/app.8fdb52a2.js></script></body></html>
|
||||||
File diff suppressed because one or more lines are too long
@@ -96,6 +96,19 @@
|
|||||||
</el-tabs>
|
</el-tabs>
|
||||||
</div>
|
</div>
|
||||||
</el-drawer>
|
</el-drawer>
|
||||||
|
<!--选择导出为update的条件列弹窗-->
|
||||||
|
<el-dialog :visible.sync="exportConditionVisible" width="500px" title="选择更新语句条件">
|
||||||
|
<div>
|
||||||
|
更新条件列:
|
||||||
|
<el-select v-model="conditionDataColsChoice" multiple placeholder="请选择" style="width: 370px;">
|
||||||
|
<el-option v-for="item in conditionDataCols" :key="item.prop" :label="item.prop" :value="item.prop"></el-option>
|
||||||
|
</el-select>
|
||||||
|
</div>
|
||||||
|
<span slot="footer" class="dialog-footer">
|
||||||
|
<el-button @click="exportConditionVisible = false">取 消</el-button>
|
||||||
|
<el-button type="primary" @click="doCopyCheckLineUpdate">确 定</el-button>
|
||||||
|
</span>
|
||||||
|
</el-dialog>
|
||||||
<span id="widthCalculate" style="visibility: hidden; white-space: nowrap;position: fixed;"></span>
|
<span id="widthCalculate" style="visibility: hidden; white-space: nowrap;position: fixed;"></span>
|
||||||
</div>
|
</div>
|
||||||
</template>
|
</template>
|
||||||
@@ -139,6 +152,10 @@
|
|||||||
myHistoryListList: [],
|
myHistoryListList: [],
|
||||||
// 选择复制
|
// 选择复制
|
||||||
choiceResultObj: {},
|
choiceResultObj: {},
|
||||||
|
//
|
||||||
|
exportConditionVisible: false,
|
||||||
|
conditionDataCols: [],
|
||||||
|
conditionDataColsChoice: [],
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
mounted: function () {
|
mounted: function () {
|
||||||
@@ -442,10 +459,29 @@
|
|||||||
handleSelectionChange(val) {
|
handleSelectionChange(val) {
|
||||||
this.$set(this.choiceResultObj, this.executeShowTable, val);
|
this.$set(this.choiceResultObj, this.executeShowTable, val);
|
||||||
},
|
},
|
||||||
|
doCopyCheckLineUpdate() {
|
||||||
|
let choiceData = this.choiceResultObj[this.executeShowTable] || [];
|
||||||
|
if (choiceData.length > 0) {
|
||||||
|
let dataCols = this.executeResultList.find(item => item.name === this.executeShowTable).dataCols;
|
||||||
|
let copyData = copyFormatter.format('update', this.editorDbProduct, dataCols, choiceData, this.conditionDataColsChoice);
|
||||||
|
this.conditionDataColsChoice = [];
|
||||||
|
this.exportConditionVisible = false;
|
||||||
|
this.$copyText(copyData).then(
|
||||||
|
res => this.$message.success("内容已复制到剪切板!"),
|
||||||
|
err => this.$message.error("抱歉,复制失败!")
|
||||||
|
);
|
||||||
|
}
|
||||||
|
},
|
||||||
handleCopyCheckLineCommand(type) {
|
handleCopyCheckLineCommand(type) {
|
||||||
let choiceData = this.choiceResultObj[this.executeShowTable] || [];
|
let choiceData = this.choiceResultObj[this.executeShowTable] || [];
|
||||||
if (choiceData.length > 0) {
|
if (choiceData.length > 0) {
|
||||||
let dataCols = this.executeResultList.find(item => item.name === this.executeShowTable).dataCols;
|
let dataCols = this.executeResultList.find(item => item.name === this.executeShowTable).dataCols;
|
||||||
|
if (type === 'update') {
|
||||||
|
// 选择更新的条件列
|
||||||
|
this.conditionDataCols = dataCols;
|
||||||
|
this.exportConditionVisible = true;
|
||||||
|
return;
|
||||||
|
}
|
||||||
let copyData = copyFormatter.format(type, this.editorDbProduct, dataCols, choiceData);
|
let copyData = copyFormatter.format(type, this.editorDbProduct, dataCols, choiceData);
|
||||||
this.$copyText(copyData).then(
|
this.$copyText(copyData).then(
|
||||||
res => this.$message.success("内容已复制到剪切板!"),
|
res => this.$message.success("内容已复制到剪切板!"),
|
||||||
|
|||||||
@@ -28,7 +28,7 @@ export default {
|
|||||||
});
|
});
|
||||||
return copyData;
|
return copyData;
|
||||||
},
|
},
|
||||||
update(dataCols, choiceData) {
|
update(dataCols, choiceData, condition=[]) {
|
||||||
// 复制为update语句
|
// 复制为update语句
|
||||||
let copyData = '';
|
let copyData = '';
|
||||||
choiceData.forEach(item => {
|
choiceData.forEach(item => {
|
||||||
@@ -39,12 +39,20 @@ export default {
|
|||||||
let val = item[col.prop];
|
let val = item[col.prop];
|
||||||
if (typeof val === 'number' && !isNaN(val)) {
|
if (typeof val === 'number' && !isNaN(val)) {
|
||||||
values += val;
|
values += val;
|
||||||
if (col.prop === 'id') where = ' where id = ' + val;
|
if (condition.indexOf(col.prop) >= 0) {
|
||||||
|
if (where.length > 0) where += ' and ';
|
||||||
|
where += col.prop + ' = ' + val;
|
||||||
|
}
|
||||||
} else {
|
} else {
|
||||||
val = val.replaceAll('\'', '\'\'');
|
val = val.replaceAll('\'', '\'\'');
|
||||||
values += "'" + val + "'";
|
values += "'" + val + "'";
|
||||||
|
if (condition.indexOf(col.prop) >= 0) {
|
||||||
|
if (where.length > 0) where += ' and ';
|
||||||
|
where += col.prop + ' = ' + "'" + val + "'";
|
||||||
|
}
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
if (where.length > 0) where = ' where ' + where;
|
||||||
copyData += 'update `table` set ' + values + where + ';\n';
|
copyData += 'update `table` set ' + values + where + ';\n';
|
||||||
});
|
});
|
||||||
return copyData;
|
return copyData;
|
||||||
|
|||||||
@@ -1,14 +1,14 @@
|
|||||||
import base from './base'
|
import base from './base'
|
||||||
|
|
||||||
export default {
|
export default {
|
||||||
format(type, product, dataCols, choiceData) {
|
format(type, product, dataCols, choiceData, condition) {
|
||||||
let formatter = this.getProduct(product);
|
let formatter = this.getProduct(product);
|
||||||
if (type === 'insert') {
|
if (type === 'insert') {
|
||||||
// 复制为insert语句
|
// 复制为insert语句
|
||||||
return formatter.insert(dataCols, choiceData);
|
return formatter.insert(dataCols, choiceData);
|
||||||
} else if (type === 'update') {
|
} else if (type === 'update') {
|
||||||
// 复制为update语句
|
// 复制为update语句
|
||||||
return formatter.update(dataCols, choiceData);
|
return formatter.update(dataCols, choiceData, condition);
|
||||||
} else if (type === 'json') {
|
} else if (type === 'json') {
|
||||||
// 复制为json
|
// 复制为json
|
||||||
return formatter.json(dataCols, choiceData);
|
return formatter.json(dataCols, choiceData);
|
||||||
|
|||||||
Reference in New Issue
Block a user