|
@@ -2,9 +2,10 @@
|
|
|
<div id="handsonStep1">
|
|
|
<div class="btns-view">
|
|
|
<el-button>获取原始点位当前值</el-button>
|
|
|
- <el-button>导出Excel模板</el-button>
|
|
|
- <el-button>导入Excel</el-button>
|
|
|
+ <el-button @click="downloadExcel = true">导出Excel模板</el-button>
|
|
|
+ <el-button @click="updateExcel = true">导入Excel</el-button>
|
|
|
<el-button @click="addRow">新增行</el-button>
|
|
|
+ <el-button @click="downData">下载数据</el-button>
|
|
|
<el-button @click="saveData">保存</el-button>
|
|
|
<el-checkbox v-model="checked">只显示使用的原始点位</el-checkbox>
|
|
|
</div>
|
|
@@ -20,6 +21,8 @@
|
|
|
<el-button type="text" @click="download">下载模板</el-button>
|
|
|
</div>
|
|
|
</own-dialog>
|
|
|
+ <own-dialog :width="'580px'" :index="true" title="导出excel模板" :dialogVisible="updateExcel" @cancel="close">
|
|
|
+ </own-dialog>
|
|
|
<div class="center">
|
|
|
<pagination :page="pages" @change="changePage"></pagination>
|
|
|
</div>
|
|
@@ -45,6 +48,7 @@
|
|
|
createPoint,
|
|
|
downloadTemplete
|
|
|
} from "@/fetch/point_http"
|
|
|
+ import axios from 'axios'
|
|
|
export default {
|
|
|
data() {
|
|
|
return {
|
|
@@ -55,7 +59,7 @@
|
|
|
localtionDialog: false,
|
|
|
renderData: {},
|
|
|
allData: [],
|
|
|
- pages:{
|
|
|
+ pages: {
|
|
|
size: 10,
|
|
|
sizes: [10, 30, 50, 100],
|
|
|
total: 0,
|
|
@@ -65,8 +69,9 @@
|
|
|
currentPage: 0,
|
|
|
size: 10
|
|
|
},
|
|
|
- downloadExcel: true,
|
|
|
- isLoading: false
|
|
|
+ downloadExcel: false,
|
|
|
+ isLoading: false,
|
|
|
+ updateExcel: false,
|
|
|
}
|
|
|
},
|
|
|
computed: {
|
|
@@ -88,21 +93,49 @@
|
|
|
},
|
|
|
methods: {
|
|
|
//关闭弹窗
|
|
|
- close(){
|
|
|
+ close() {
|
|
|
this.localtionDialog = false
|
|
|
this.downloadExcel = false
|
|
|
+ this.updateExcel = false
|
|
|
+ },
|
|
|
+ downData() {
|
|
|
+ axios({
|
|
|
+ method: 'post',
|
|
|
+ url: `/pointconfig/point/${this.protocolType}/pointlist-export`,
|
|
|
+ data: {DataSourceId: this.datasourceId},
|
|
|
+ responseType: 'blob',
|
|
|
+ headers:{ProjectId: this.projectId}
|
|
|
+ }).then(function(res) {
|
|
|
+ var blob = new Blob([res.data], {
|
|
|
+ type: 'application/vnd.openxmlformats-officedocument.spreadsheetml.sheet;charset=utf-8'
|
|
|
+ });
|
|
|
+ var fileName = res.headers['content-disposition'];
|
|
|
+ if (fileName)
|
|
|
+ fileName = fileName.substring(fileName.indexOf('=') + 1);
|
|
|
+ if ('download' in document.createElement('a')) { // 非IE下载
|
|
|
+ const elink = document.createElement('a')
|
|
|
+ elink.download = fileName
|
|
|
+ elink.style.display = 'none'
|
|
|
+ elink.href = URL.createObjectURL(blob)
|
|
|
+ document.body.appendChild(elink)
|
|
|
+ elink.click()
|
|
|
+ URL.revokeObjectURL(elink.href) // 释放URL 对象
|
|
|
+ document.body.removeChild(elink)
|
|
|
+ } else { // IE10+下载
|
|
|
+ navigator.msSaveBlob(blob, fileName)
|
|
|
+ }
|
|
|
+ }).catch(function(err) {
|
|
|
+ console.dirxml(err);
|
|
|
+ })
|
|
|
},
|
|
|
-
|
|
|
//下载excel模板
|
|
|
- download(){
|
|
|
- downloadTemplete({
|
|
|
- data: {
|
|
|
- DataSourceId: this.datasourceId,
|
|
|
- },
|
|
|
- type: this.protocolType
|
|
|
- },{
|
|
|
+ download() {
|
|
|
+ axios({
|
|
|
+ method: 'post',
|
|
|
+ url: `/pointconfig/point/${this.protocolType}/template-export`,
|
|
|
+ data: {},
|
|
|
responseType: 'blob'
|
|
|
- },res => {
|
|
|
+ }).then(function(res) {
|
|
|
var blob = new Blob([res.data], {
|
|
|
type: 'application/vnd.openxmlformats-officedocument.spreadsheetml.sheet;charset=utf-8'
|
|
|
});
|
|
@@ -121,33 +154,62 @@
|
|
|
} else { // IE10+下载
|
|
|
navigator.msSaveBlob(blob, fileName)
|
|
|
}
|
|
|
+ }).catch(function(err) {
|
|
|
+ console.dirxml(err);
|
|
|
})
|
|
|
+ // downloadTemplete({
|
|
|
+ // data: {
|
|
|
+ // DataSourceId: this.datasourceId,
|
|
|
+ // },
|
|
|
+ // type: this.protocolType
|
|
|
+ // },{
|
|
|
+ // responseType: 'blob'
|
|
|
+ // },res => {
|
|
|
+ // var blob = new Blob([res.data], {
|
|
|
+ // type: 'application/vnd.openxmlformats-officedocument.spreadsheetml.sheet;charset=utf-8'
|
|
|
+ // });
|
|
|
+ // var fileName = res.headers['content-disposition'];
|
|
|
+ // if (fileName)
|
|
|
+ // fileName = fileName.substring(fileName.indexOf('=') + 1);
|
|
|
+ // if ('download' in document.createElement('a')) { // 非IE下载
|
|
|
+ // const elink = document.createElement('a')
|
|
|
+ // elink.download = fileName
|
|
|
+ // elink.style.display = 'none'
|
|
|
+ // elink.href = URL.createObjectURL(blob)
|
|
|
+ // document.body.appendChild(elink)
|
|
|
+ // elink.click()
|
|
|
+ // URL.revokeObjectURL(elink.href) // 释放URL 对象
|
|
|
+ // document.body.removeChild(elink)
|
|
|
+ // } else { // IE10+下载
|
|
|
+ // navigator.msSaveBlob(blob, fileName)
|
|
|
+ // }
|
|
|
+ // })
|
|
|
},
|
|
|
//点击表格
|
|
|
- clickTable(info,row){
|
|
|
+ clickTable(info, row) {
|
|
|
let activeCell = this.hot.getActiveEditor()
|
|
|
this.renderData = info
|
|
|
console.log(activeCell)
|
|
|
- if(activeCell.prop == "LocationFlag"){
|
|
|
+ if (activeCell.prop == "LocationFlag") {
|
|
|
this.localtionDialog = true
|
|
|
}
|
|
|
},
|
|
|
addRow() {
|
|
|
- if(!!this.allData.length){
|
|
|
+ if (!!this.allData.length) {
|
|
|
let data = this.hot.getSourceData()
|
|
|
data.unshift({})
|
|
|
this.hot.loadData(data)
|
|
|
this.hot.updateSettings({
|
|
|
maxRows: data.length
|
|
|
- })
|
|
|
- }else{
|
|
|
+ })
|
|
|
+ } else {
|
|
|
this.allData = [{}]
|
|
|
this.createHot()
|
|
|
}
|
|
|
},
|
|
|
//页面发生更改
|
|
|
- changePage(){
|
|
|
- if(!this.changeFlag){
|
|
|
+ changePage() {
|
|
|
+ if (!this.changeFlag) {
|
|
|
//发生更改,提示是否保存
|
|
|
this.$confirm('存在数据未保存, 是否继续?', '提示', {
|
|
|
confirmButtonText: '确定',
|
|
@@ -160,7 +222,7 @@
|
|
|
this.pages.size = this.oldPage.size
|
|
|
return false
|
|
|
});
|
|
|
- }else{
|
|
|
+ } else {
|
|
|
this.getData()
|
|
|
}
|
|
|
},
|
|
@@ -191,7 +253,7 @@
|
|
|
})
|
|
|
},
|
|
|
//创建实例
|
|
|
- createHot(){
|
|
|
+ createHot() {
|
|
|
let header, width, settings
|
|
|
header = getHeaderSetting(this.protocolType)
|
|
|
settings = {
|
|
@@ -202,10 +264,10 @@
|
|
|
rowHeights: 30,
|
|
|
maxRows: this.allData.length
|
|
|
}
|
|
|
- if(!this.allData.length){
|
|
|
+ if (!this.allData.length) {
|
|
|
return false
|
|
|
}
|
|
|
- this.$nextTick( _ => {
|
|
|
+ this.$nextTick(_ => {
|
|
|
this.hot = this.$refs.handsontable.init(settings)
|
|
|
console.log(this.hot)
|
|
|
})
|
|
@@ -222,7 +284,8 @@
|
|
|
if (!!this.hot) {
|
|
|
console.log(this.hot.getSourceData())
|
|
|
let data = this.hot.getSourceData(),
|
|
|
- updateList = [],arr1 = [],
|
|
|
+ updateList = [],
|
|
|
+ arr1 = [],
|
|
|
createList = [];
|
|
|
data.map(item => {
|
|
|
// console.log(item.LocationFlag,1111)
|
|
@@ -240,7 +303,7 @@
|
|
|
createList.push(item)
|
|
|
}
|
|
|
})
|
|
|
- console.log(updateList,arr1, "updateList")
|
|
|
+ console.log(updateList, arr1, "updateList")
|
|
|
if (updateList.length) {
|
|
|
this.update(updateList)
|
|
|
}
|
|
@@ -263,11 +326,11 @@
|
|
|
},
|
|
|
async create(obj) {
|
|
|
console.log(obj)
|
|
|
- for(let key in obj){
|
|
|
- if(key == "LocationFlag" && obj[key] == ""){
|
|
|
+ for (let key in obj) {
|
|
|
+ if (key == "LocationFlag" && obj[key] == "") {
|
|
|
obj[key] = []
|
|
|
}
|
|
|
- if(obj[key] === ""){
|
|
|
+ if (obj[key] === "") {
|
|
|
obj[key] = null
|
|
|
}
|
|
|
}
|