|
@@ -32,18 +32,21 @@
|
|
|
collapse-tags
|
|
|
filterable
|
|
|
></el-cascader>
|
|
|
- <el-button type="primary" @click="search" >查询</el-button>
|
|
|
+ <el-button type="primary" @click="search">查询</el-button>
|
|
|
|
|
|
<download-excel
|
|
|
class="export-excel-wrapper"
|
|
|
:data="tableData"
|
|
|
:fields="json_fields"
|
|
|
:name="excelTitle"
|
|
|
- :disabled='disabled'
|
|
|
+ :disabled="disabled"
|
|
|
>
|
|
|
<!-- 上面可以自定义自己的样式,还可以引用其他组件button -->
|
|
|
<el-button type="primary">导出EXCEL</el-button>
|
|
|
</download-excel>
|
|
|
+ <el-button type="primary" @click="Formdialog = true"
|
|
|
+ >保存到数据库</el-button
|
|
|
+ >
|
|
|
</div>
|
|
|
<el-table :data="tableData" style="width: 100%">
|
|
|
<el-table-column
|
|
@@ -55,6 +58,19 @@
|
|
|
>
|
|
|
</el-table-column>
|
|
|
</el-table>
|
|
|
+ <el-dialog title="选择数据库表" :visible.sync="Formdialog" width="45%">
|
|
|
+ <el-select v-model="value2" placeholder="请选择" filterable>
|
|
|
+ <el-option
|
|
|
+ v-for="item in tableList"
|
|
|
+ :key="item.value"
|
|
|
+ :label="item.label"
|
|
|
+ :value="item.value"
|
|
|
+ >
|
|
|
+ </el-option>
|
|
|
+ </el-select>
|
|
|
+ <el-button type="primary" @click="saveUnionTable">确认保存</el-button>
|
|
|
+ <el-button @click="Formdialog = false">取消</el-button>
|
|
|
+ </el-dialog>
|
|
|
</div>
|
|
|
</template>
|
|
|
<script>
|
|
@@ -62,14 +78,16 @@ import XLSX from "xlsx";
|
|
|
export default {
|
|
|
data() {
|
|
|
return {
|
|
|
- disabled:true,
|
|
|
- excelTitle:'' || 'excel',
|
|
|
+ Formdialog: false,
|
|
|
+ disabled: true,
|
|
|
+ excelTitle: "" || "excel",
|
|
|
props: { multiple: true },
|
|
|
tableData: [{}],
|
|
|
excelData: [],
|
|
|
arr: [],
|
|
|
value: "",
|
|
|
value1: "",
|
|
|
+ value2: "",
|
|
|
tableList: [],
|
|
|
options: [],
|
|
|
json_fields: {},
|
|
@@ -144,16 +162,16 @@ export default {
|
|
|
}
|
|
|
}
|
|
|
this.arr = arr;
|
|
|
- console.log(arr)
|
|
|
+ console.log(arr);
|
|
|
var cluHead = {};
|
|
|
- for(let i in arr){
|
|
|
- cluHead[arr[i]] = arr[i]
|
|
|
+ for (let i in arr) {
|
|
|
+ cluHead[arr[i]] = arr[i];
|
|
|
}
|
|
|
- console.log(cluHead)
|
|
|
- this.json_fields = cluHead
|
|
|
+ console.log(cluHead);
|
|
|
+ this.json_fields = cluHead;
|
|
|
this.$nextTick(() => {
|
|
|
this.tableData = json;
|
|
|
- this.disabled = false
|
|
|
+ this.disabled = false;
|
|
|
});
|
|
|
})
|
|
|
.catch(function (error) {
|
|
@@ -162,7 +180,7 @@ export default {
|
|
|
},
|
|
|
|
|
|
handleChange(file, fileList) {
|
|
|
- this.excelTitle = file.name
|
|
|
+ this.excelTitle = file.name;
|
|
|
const fileReader = new FileReader();
|
|
|
fileReader.onload = (ev) => {
|
|
|
try {
|
|
@@ -182,6 +200,26 @@ export default {
|
|
|
};
|
|
|
fileReader.readAsBinaryString(file.raw);
|
|
|
},
|
|
|
+ saveUnionTable() {
|
|
|
+ this.$http
|
|
|
+ .post("UnionTable/saveData", this.value2 )
|
|
|
+ .then((res) => {
|
|
|
+ console.log(res.data);
|
|
|
+ if (res.data == "保存成功") {
|
|
|
+ this.$message({
|
|
|
+ type: "success",
|
|
|
+ message: "保存成功!",
|
|
|
+ });
|
|
|
+ this.Formdialog = false;
|
|
|
+ } else {
|
|
|
+ this.$message({
|
|
|
+ type: "fail",
|
|
|
+ message: "保存失败!",
|
|
|
+ });
|
|
|
+ }
|
|
|
+ });
|
|
|
+ this.Formdialog = false;
|
|
|
+ },
|
|
|
},
|
|
|
};
|
|
|
</script>
|