.
This commit is contained in:
@@ -8,8 +8,14 @@ const table = {
|
||||
sheetMySql({dbPlatId, catalog}) {
|
||||
return table._sheets({cate: "mysql", dbPlatId, catalog})
|
||||
},
|
||||
sheetInfo({filePath, sheetName}) {
|
||||
return red.postX('/_table/sheet_info', {cate: 'excel', filePath, sheetName})
|
||||
},
|
||||
|
||||
saveTable({dbPlatId, catalog, tableArr}) {
|
||||
return red.postX('/_table/table_save', {dbPlatId, catalog, tableArr: JSON.stringify(tableArr)})
|
||||
saveTable({dbPlatId, catalog, tableArr}) { //
|
||||
return red.postX('/_table/table_save', {cate: 'mysql', dbPlatId, catalog, tableArr: JSON.stringify(tableArr)})
|
||||
},
|
||||
saveSheet({filePath, sheetNames}) {
|
||||
return red.postX('/_table/table_save', {cate: 'excel', filePath, sheetNames: JSON.stringify(sheetNames)})
|
||||
}
|
||||
}
|
||||
@@ -56,13 +56,13 @@
|
||||
</div>
|
||||
|
||||
<ul class="nav nav-tabs">
|
||||
<li @click="cate = 'excel'"><a href="###" data-target="#tab2Content1" data-toggle="tab">从本地上传</a></li>
|
||||
<li @click="cate = 'mysql'" class="active"><a href="###" data-target="#tab2Content2" data-toggle="tab">从数据源导入</a></li>
|
||||
<li @click="cate = 'oth'"><a href="###" data-target="#tab2Content3" data-toggle="tab">其他</a></li>
|
||||
<li @click="cate = 'excel'" :class="{active: cate=='excel'}"><a href="javascript:;">从本地上传</a></li>
|
||||
<li @click="cate = 'mysql'" :class="{active: cate=='mysql'}"><a href="javascript:;">从数据源导入</a></li>
|
||||
<li @click="cate = 'oth'" :class="{active: cate=='oth'}"><a href="javascript:;">其他</a></li>
|
||||
</ul>
|
||||
<div class="tab-content">
|
||||
<!-- 本地excel导入 -->
|
||||
<div class="tab-pane fade" id="tab2Content1">
|
||||
<div :class="['tab-pane', 'fade','in',{active: cate=='excel'}]">
|
||||
<div id="tableUploader" class="uploader">
|
||||
<!--<div class="uploader-message text-center">
|
||||
<div class="content"></div>
|
||||
@@ -83,7 +83,7 @@
|
||||
<td style="width: 38px; padding: 3px"><div class="file-icon"></div></td>
|
||||
<td style="padding: 0">
|
||||
<div style="position: relative; padding: 8px;">
|
||||
<strong class="file-field"></strong>
|
||||
<strong class="file-name"></strong>
|
||||
<div class="file-progress-bar"></div>
|
||||
</div>
|
||||
</td>
|
||||
@@ -120,7 +120,7 @@
|
||||
<li class="checkbox-inline clearfix" v-for="item in sheetArr" >
|
||||
<input type="checkbox"
|
||||
v-model="ck"
|
||||
:value="sheetData[item]['field']"
|
||||
:value="sheetData[item]['name']"
|
||||
:disabled="item=='表说明' || item=='表名称' || sheetData[item]['hv']==1"
|
||||
>
|
||||
<a :class="[{hv: sheetData[item]['hv']==1 }]" href="javascript:;" @click="sheet=item" data-target="#tab3Content1" data-toggle="tab" v-text="item"></a>
|
||||
@@ -156,7 +156,7 @@
|
||||
</thead>
|
||||
<tbody>
|
||||
<tr v-for="(item, index) in metaTable.items">
|
||||
<td v-text="item.field"></td>
|
||||
<td v-text="item.name"></td>
|
||||
<td v-text="item.label"></td>
|
||||
<td v-text="item.type"></td>
|
||||
<td v-text="item.inType"></td>
|
||||
@@ -182,7 +182,7 @@
|
||||
</div>
|
||||
|
||||
<!-- 从数据源导入 -->
|
||||
<div class="tab-pane fade active in" id="tab2Content2">
|
||||
<div :class="['tab-pane', 'fade','in',{active: cate=='mysql'}]">
|
||||
<div class="form-group">
|
||||
<label class="col-md-1 col-sm-1" style="padding-bottom: 10px;padding-top: 5px;">数据源选择</label>
|
||||
<div class="col-md-2 col-sm-10" style="padding-bottom: 10px">
|
||||
@@ -250,7 +250,7 @@
|
||||
</div>
|
||||
|
||||
<!-- 其他导入 -->
|
||||
<div class="tab-pane fade" id="tab2Content3">
|
||||
<div :class="['tab-pane', 'fade','in',{active: cate=='oth'}]">
|
||||
<p>其他一些定制的特殊格式的 实体数据形式</p>
|
||||
</div>
|
||||
</div>
|
||||
@@ -258,7 +258,7 @@
|
||||
<div class="modal-footer" v-show="cate=='excel'">
|
||||
<button @click="ck=[]" type="button" class="btn btn-default" data-dismiss="modal">取消选择</button>
|
||||
<button @click="back()" type="button" class="btn btn-default" data-dismiss="modal">取消</button>
|
||||
<button @click="saveSheet()" type="button" class="btn btn-primary">确定</button>
|
||||
<button @click="saveTable()" type="button" class="btn btn-primary">确定</button>
|
||||
</div>
|
||||
<div class="modal-footer" v-show="cate=='mysql'">
|
||||
<button @click="ckTable=[]" type="button" class="btn btn-default" data-dismiss="modal">取消选择</button>
|
||||
@@ -270,12 +270,12 @@
|
||||
<script>
|
||||
let {dbList} = plat
|
||||
let {catalogList, tableList, tableInfo} = db
|
||||
let {sheetMySql, saveTable} = table
|
||||
let {sheetsExcel, sheetMySql, sheetInfo, saveTable, saveSheet} = table
|
||||
|
||||
var vm = new Vue({
|
||||
el: ".importDev",
|
||||
data: {
|
||||
cate: 'mysql',
|
||||
cate: 'excel',
|
||||
|
||||
filePath: '',
|
||||
importStatus: false,
|
||||
@@ -289,7 +289,7 @@
|
||||
dbPlats: red.getData('dbPlats'),
|
||||
catalogs: [],
|
||||
tableData: {},
|
||||
tableArr:[],
|
||||
tableArr: [],
|
||||
dbPlat: red.getData("dbPlat",{}),
|
||||
dbPlatId: red.getData("dbPlatId",''),
|
||||
catalog: '',
|
||||
@@ -302,7 +302,7 @@
|
||||
var arr = [];
|
||||
var ck = [];
|
||||
for (k in v) {
|
||||
let field = v[k]['field'];
|
||||
let field = v[k]['name'];
|
||||
if (k!='表说明' && k!='表名称' && v[k]['hv'] != 1) {
|
||||
ck.push(field);
|
||||
}
|
||||
@@ -318,7 +318,6 @@
|
||||
},
|
||||
sheet: function (v) { // 查询sheet详情
|
||||
this.metaTable = this.sheetData[v];
|
||||
console.log(this.metaTable)
|
||||
if (this.metaTable['load'] != 1) {
|
||||
this.loadSheetData();
|
||||
}
|
||||
@@ -344,22 +343,29 @@
|
||||
if(!filePath) {
|
||||
return false;
|
||||
}
|
||||
red.post("/file/data",{filePath: filePath}, function (json) {
|
||||
console.log(json)
|
||||
vm.sheetData = json;
|
||||
sheetsExcel({filePath}).then(res => {
|
||||
vm.sheetData = res
|
||||
})
|
||||
},
|
||||
loadSheetData: function() {
|
||||
let sheetName = this.sheet;
|
||||
red.post("/file/sheet_data",{filePath: this.filePath, sheetName: sheetName}, function (json) {
|
||||
let sheetName = this.sheet
|
||||
sheetInfo({filePath: this.filePath, sheetName: this.sheet}).then(res => {
|
||||
res["hv"] = vm.sheetData[sheetName]["hv"]
|
||||
res["load"] = 1
|
||||
this.sheetData[sheetName] = res
|
||||
if (this.sheet == sheetName) {
|
||||
this.metaTable = res
|
||||
}
|
||||
})
|
||||
|
||||
/*red.post("/file/sheet_data",{filePath: this.filePath, sheetName}, function (json) {
|
||||
json["hv"] = vm.sheetData[sheetName]["hv"];
|
||||
json["load"] = 1;
|
||||
vm.sheetData[sheetName] = json;
|
||||
if (vm.sheet == sheetName) {
|
||||
vm.metaTable = json;
|
||||
}
|
||||
|
||||
})
|
||||
})*/
|
||||
},
|
||||
getSheetName: function (tableName) {
|
||||
for(k in this.sheetData) {
|
||||
@@ -416,12 +422,31 @@
|
||||
}
|
||||
},
|
||||
saveTable() { // 保存数据
|
||||
let [dbPlatId, catalog, tableArr] = [this.dbPlatId, this.catalog, this.ckTable]
|
||||
if (this.cate == 'mysql') {
|
||||
let [dbPlatId, catalog, tableArr] = [this.dbPlatId, this.catalog, this.ckTable]
|
||||
saveTable({dbPlatId, catalog, tableArr}).then(res => {
|
||||
red.showOk()
|
||||
this.loadTables()
|
||||
})
|
||||
} else if (this.cate == 'excel') {
|
||||
if (!this.ck || this.ck.length == 0) {
|
||||
red.showMsg({msg: "请选择导入数据", type: "danger", placement: "top"});
|
||||
return false;
|
||||
}
|
||||
saveSheet({filePath: this.filePath, sheetNames: this.ck}).then(res => {
|
||||
red.showOk()
|
||||
|
||||
saveTable({dbPlatId, catalog, tableArr}).then(res => {
|
||||
red.showOk()
|
||||
this.loadTables()
|
||||
})
|
||||
// 刷新列表
|
||||
let sheetData = this.sheetData
|
||||
for (let i in this.ck) {
|
||||
if (sheetData[this.ck[i]]) {
|
||||
sheetData[this.ck[i]]['hv'] = 1
|
||||
}
|
||||
}
|
||||
this.sheetData = sheetData
|
||||
this.ck = []
|
||||
})
|
||||
}
|
||||
}
|
||||
},
|
||||
mounted: function () {
|
||||
|
||||
@@ -94,14 +94,12 @@ var red = {
|
||||
method: 'post',
|
||||
data: params,
|
||||
transformRequest: [data => {
|
||||
console.log(data)
|
||||
let _data = ''
|
||||
for (k in data) {
|
||||
if (data[k] != undefined) {
|
||||
_data += k + '=' + data[k] + '&'
|
||||
}
|
||||
}
|
||||
console.log(_data)
|
||||
return _data
|
||||
}
|
||||
]
|
||||
|
||||
Reference in New Issue
Block a user