Commit ba093436 authored by zhanglw's avatar zhanglw

文件锁

parent 1ae4ae2b
......@@ -3212,6 +3212,28 @@ var HttpReq = function(){
responseType: 'blob'
})
},
//开采管理-文件锁
isTheFileLocked: function(params){
return request({
url: '/api/miningManagement/isTheFileLocked?' + qs.stringify(params, { indices: false }),
method: 'get'
})
},
//开采管理-文件锁
setFileValidityPeriod: function(params){
return request({
url: '/api/miningManagement/setFileValidityPeriod?' + qs.stringify(params, { indices: false }),
method: 'get'
})
},
//开采管理-文件锁
deleteFileEditingTags: function(data){
return request({
url: '/api/miningManagement/deleteFileEditingTags',
method: 'delete',
data: data,
})
},
//开采管理-删除文件
deleteExcelOrFbx: function(data){
return request({
......@@ -3220,6 +3242,12 @@ var HttpReq = function(){
data: data,
})
},
scQueryByUrl: function(params){
return request({
url: '/api/fileEditingRecord/queryByUrl?' + qs.stringify(params, { indices: false }),
method: 'get'
})
},
//后台首页指标
backgroundHomepage: function(params){
return request({
......
......@@ -43,13 +43,10 @@
<el-table-column prop="modificationTime" label="上传时间" align="center"></el-table-column>
<el-table-column label="操作" align="center" fixed="right">
<template slot-scope="scope">
<el-button v-if="query.type==='excel'" size="mini" type="text" icon="el-icon-view"
@click="viewTable(scope.row)">在线预览
</el-button>
<el-button size="mini" type="text" icon="el-icon-download" @click="downloadFile(scope.row)">下载
</el-button>
<el-button v-if="query.type==='excel'" size="mini" type="text" icon="el-icon-view" @click="viewTable(scope.row)">编辑</el-button>
<el-button size="mini" type="text" icon="el-icon-download" @click="downloadFile(scope.row)">下载</el-button>
<el-button size="mini" type="text" icon="el-icon-delete" @click="toDelete(scope.row)">删除</el-button>
<!-- <el-progress type="dashboard" :percentage="scope.row.percentage||20" :color="colors"></el-progress>-->
<el-button size="mini" type="text" icon="el-icon-tickets" @click="openLog(scope.row)">记录</el-button>
</template>
</el-table-column>
</el-table>
......@@ -71,8 +68,7 @@
<el-button type="primary" @click="updataEcxel">保存</el-button>
</div>
</el-dialog>
<el-dialog append-to-body :close-on-click-modal="false" :before-close="cancelForm" :visible.sync="uploadVisible"
title="文件上传" width="560px">
<el-dialog append-to-body :close-on-click-modal="false" :before-close="cancelForm" :visible.sync="uploadVisible" title="文件上传" width="560px">
<el-form ref="form" :model="form" size="small" label-width="80px">
<!-- 上传文件 -->
<el-form-item label="">
......@@ -97,7 +93,22 @@
<el-button :loading="loading" type="primary" @click="upload">确认</el-button>
</div>
</el-dialog>
<el-dialog append-to-body :close-on-click-modal="false" :before-close="cancelForm" :visible.sync="logVisible" title="编辑日志" width="800px">
<el-table :data="logData" border style="width:auto">
<el-table-column prop="nickName" label="编辑人" align="center"></el-table-column>
<el-table-column prop="phone" label="联系电话" align="center"></el-table-column>
<el-table-column prop="updateTime" label="编辑时间" align="center"></el-table-column>
<el-table-column prop="status" label="状态" align="center">
<template slot-scope="scope">
<span v-if="scope.row.status==='完成'" style="color:gray">{{scope.row.status}}</span>
<span v-else style="color:forestgreen">{{scope.row.status}}</span>
</template>
</el-table-column>
</el-table>
<div slot="footer" class="dialog-footer" style="text-align: center">
<el-button @click="cancelForm">关闭</el-button>
</div>
</el-dialog>
</div>
</template>
......@@ -111,15 +122,13 @@ export default {
name: 'visitPeople',
data() {
return {
colors: [{color: '#f56c6c', percentage: 20}, {color: '#e6a23c', percentage: 40}, {
color: '#5cb87a',
percentage: 60
}, {color: '#1989fa', percentage: 80}, {color: '#6f7ad3', percentage: 100}],
colors: [{color: '#f56c6c', percentage: 20}, {color: '#e6a23c', percentage: 40}, {color: '#5cb87a', percentage: 60}, {color: '#1989fa', percentage: 80}, {color: '#6f7ad3', percentage: 100}],
title: '',
fileUploadApi: '',
headers: {'Authorization': getToken()},
visible: false,
uploadVisible: false,
logVisible: false,
loading: false,
query: {
type: 'excel',
......@@ -137,7 +146,9 @@ export default {
activeTab: 'Sheet1',
excelTableData: [],
form: {},
xs: null
xs: null,
fileSocketTimer: null,
logData: []
}
},
mounted() {
......@@ -146,6 +157,14 @@ export default {
})
},
methods: {
openLog(item) {
this.logVisible = true
HttpReq.truckDispatching.scQueryByUrl({url:item.url}).then((res) => {
if (res.code == 200) {
this.logData = res.data;
}
})
},
stox(wb) {
var out = [];
wb.SheetNames.forEach(function (name) {
......@@ -269,15 +288,21 @@ export default {
})
},
viewTable(item) {
if (item.isLoading) {
this.openFile = item
HttpReq.truckDispatching.isTheFileLocked({
url: this.openFile.url
}).then((res) => {
if (res.data) {
return this.$notify({
title: '正在下载该文件,请勿操作',
type: 'info'
title: '文件已被锁定,暂时无法编辑',
type: 'warning'
})
}
this.openFile = item
} else {
this.visible = true
this.$nextTick(() => {
this.reconnect();
this.fileSocketTimer = setInterval(() => {
this.reconnect();
}, 15000);
HttpReq.truckDispatching.downloadExcelOrFbx({url: item.url, type: this.query.type}).then((res) => {
if(!this.xs){
Spreadsheet.locale('zh-cn');
......@@ -298,8 +323,12 @@ export default {
this.xs.loadData(this.stox(wb))
})
})
}
})
},
reconnect() {
HttpReq.truckDispatching.setFileValidityPeriod({url: this.openFile.url}).then((res) => {})
},
toDelete(item) {
this.$confirm(`确认删除文件:${item.fileName}?`, '提示', {
confirmButtonText: '确定',
......@@ -392,8 +421,17 @@ export default {
})
},
cancelForm() {
if (this.fileSocketTimer) {
HttpReq.truckDispatching.deleteFileEditingTags({
url: this.openFile.url
}).then((res) => {
clearInterval(this.fileSocketTimer);
this.fileSocketTimer = null;
})
}
this.visible = false
this.uploadVisible = false
this.logVisible = false
if (this.$refs.upload) {
this.$refs.upload.clearFiles()
}
......@@ -419,6 +457,12 @@ export default {
this.loadData()
}
},
beforeDestroy() {
if (this.fileSocketTimer) {
clearInterval(this.fileSocketTimer);
this.fileSocketTimer = null;
}
}
}
</script>
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment