|
@@ -1,7 +1,7 @@
|
|
|
<!--
|
|
|
* @Author: ql
|
|
|
* @Date: 2022-01-11 14:46:04
|
|
|
- * @LastEditTime: 2022-01-14 15:18:59
|
|
|
+ * @LastEditTime: 2022-01-24 16:10:38
|
|
|
* @LastEditors: Please set LastEditors
|
|
|
* @FilePath: \adm-frontend\src\components\cadDrawingManage\index.vue
|
|
|
-->
|
|
@@ -30,13 +30,12 @@
|
|
|
<el-upload
|
|
|
class="upload"
|
|
|
ref="upload"
|
|
|
+ action=''
|
|
|
+ accept=".dwg"
|
|
|
:multiple="true"
|
|
|
- action="https://jsonplaceholder.typicode.com/posts/"
|
|
|
- :file-list="fileList"
|
|
|
- :show-file-list="false"
|
|
|
- :on-change='fileChange'
|
|
|
- :on-progress='progressHandle'
|
|
|
- :auto-upload="false">
|
|
|
+ :http-request='uploadHandle'
|
|
|
+ :before-upload="beforeUpload"
|
|
|
+ :show-file-list="false">
|
|
|
<Button slot="trigger" type="primary" icon="el-icon-download">上传.dwg CAD文件</Button>
|
|
|
</el-upload>
|
|
|
</div>
|
|
@@ -49,11 +48,8 @@
|
|
|
tooltip-effect="dark"
|
|
|
v-loading="tableLoading"
|
|
|
style="width: 100%"
|
|
|
- @selection-change="handleSelectionChange">
|
|
|
- <el-table-column
|
|
|
- type="selection"
|
|
|
- width="55">
|
|
|
- </el-table-column>
|
|
|
+ >
|
|
|
+
|
|
|
<el-table-column
|
|
|
label="文件名称"
|
|
|
prop="fileName"
|
|
@@ -62,7 +58,7 @@
|
|
|
<el-table-column
|
|
|
label="最新上传时间"
|
|
|
>
|
|
|
- <template slot-scope="scope">{{ scope.row.modifiedTime }}</template>
|
|
|
+ <template slot-scope="scope">{{ scope.row.modifiedTime | timeFormat }}</template>
|
|
|
</el-table-column>
|
|
|
<el-table-column
|
|
|
prop="creator"
|
|
@@ -93,6 +89,9 @@ import { Tree, Tabs, Button } from 'meri-design'
|
|
|
import { MENU_MAP } from '@/data/cadConst'
|
|
|
import BuildController from "@/controller/old-adm/buildController"
|
|
|
import cadDrawingController from '@/controller/cadDarwingController'
|
|
|
+import moment from 'moment'
|
|
|
+import { mapState, mapMutations } from 'vuex'
|
|
|
+import { logicConfig } from "@/logicConfig";
|
|
|
export default {
|
|
|
components: {
|
|
|
Tree,
|
|
@@ -100,16 +99,38 @@ export default {
|
|
|
Button,
|
|
|
},
|
|
|
watch: {
|
|
|
+ async successList(nv, ov) {
|
|
|
+ if (nv?.length) {
|
|
|
+ const files = this.successList.map(item => ({
|
|
|
+ fileKey: item.fileId,
|
|
|
+ fileName: item.fileName
|
|
|
+ }))
|
|
|
+ const params = {
|
|
|
+ buildingId: this.buildingId,
|
|
|
+ floorId: this.floorId,
|
|
|
+ majorCode: this.currentTab,
|
|
|
+ files
|
|
|
+ }
|
|
|
+ const res = cadDrawingController.addFile(params);
|
|
|
+ this.getFileList();
|
|
|
+ this.$message({
|
|
|
+ type: 'success',
|
|
|
+ message: '上传成功!'
|
|
|
+ });
|
|
|
+ }
|
|
|
+ },
|
|
|
currentTab(nv, ov) {
|
|
|
- console.log({nv, ov})
|
|
|
+ this.getFileList()
|
|
|
}
|
|
|
},
|
|
|
data() {
|
|
|
return {
|
|
|
- currentTab: 'id1',
|
|
|
+ currentTab: 'CF',
|
|
|
MENU_MAP,
|
|
|
options: [],
|
|
|
tableList: [], //文件列表数据
|
|
|
+ floorId: '', //当前楼层
|
|
|
+ buildingId: '', //当前建筑
|
|
|
tableLoading: false,
|
|
|
fileList: [], //已选择文件
|
|
|
// 基础表格表头列表
|
|
@@ -133,7 +154,19 @@ export default {
|
|
|
],
|
|
|
}
|
|
|
},
|
|
|
+ computed: {
|
|
|
+ ...mapState('uploadFile', ['successList', 'uploadVisible', 'errorList'])
|
|
|
+ },
|
|
|
+ filters: {
|
|
|
+ timeFormat(timestr) {
|
|
|
+ if(timestr) {
|
|
|
+ return moment(timestr).format('YYYY-MM-DD HH:mm:ss')
|
|
|
+ }
|
|
|
+ return '--'
|
|
|
+ }
|
|
|
+ },
|
|
|
methods: {
|
|
|
+ ...mapMutations('uploadFile', ['updata']),
|
|
|
// 获取楼层信息
|
|
|
async getCascader() {
|
|
|
let param = {
|
|
@@ -143,39 +176,71 @@ export default {
|
|
|
};
|
|
|
|
|
|
this.options = await BuildController.buildDataFormat(param);
|
|
|
+ if(this.options.length) {
|
|
|
+ this.floorId = this.options[0]?.children[0].id
|
|
|
+ this.buildingId = this.options[0].id
|
|
|
+ }
|
|
|
|
|
|
},
|
|
|
// 选择楼层
|
|
|
- selectFloorHandle(id) {
|
|
|
- console.log({id})
|
|
|
+ selectFloorHandle(obj) {
|
|
|
+ const { buildingId, id: floorId } = obj;
|
|
|
+ this.buildingId = buildingId;
|
|
|
+ this.floorId = floorId;
|
|
|
+ this.getFileList()
|
|
|
},
|
|
|
// 获取文件列表数据
|
|
|
async getFileList () {
|
|
|
this.tableLoading = true
|
|
|
- this.tableList = await cadDrawingController.queryFileList();
|
|
|
+ const res = await cadDrawingController.queryFileList({
|
|
|
+ buildingId: this.buildingId,
|
|
|
+ floorId: this.floorId,
|
|
|
+ majorCode: this.currentTab
|
|
|
+ });
|
|
|
+ this.tableList = res?.data
|
|
|
this.tableLoading = false
|
|
|
- console.log({res})
|
|
|
},
|
|
|
- fileChange(file, fileList) {
|
|
|
- console.log({file, fileList})
|
|
|
+ async uploadHandle(option) {
|
|
|
+ const isHas = this.fileList.find(item => option.file.name === item.name);
|
|
|
+ // if(isHas) {
|
|
|
+ // this.$message.closeAll();
|
|
|
+ // this.$message({ type: 'error', message: '当前文件已存在,请重新选择' });
|
|
|
+ // return;
|
|
|
+ // }
|
|
|
+ const file = {
|
|
|
+ fileName: option.file.name,
|
|
|
+ file: option.file
|
|
|
+ }
|
|
|
+ this.fileList.push(file);
|
|
|
+ this.updata({uploadVisible: true, fileList: this.fileList})
|
|
|
+
|
|
|
+
|
|
|
},
|
|
|
- progressHandle(e, file, fileList) {
|
|
|
- console.log({file, fileList})
|
|
|
+ beforeUpload(file) {
|
|
|
+ console.log(file)
|
|
|
+ // if()
|
|
|
+ // return false
|
|
|
},
|
|
|
+
|
|
|
delHandle(row) {
|
|
|
+ const id = row.id
|
|
|
this.$confirm('此操作将永久删除该文件, 是否继续?', '提示', {
|
|
|
confirmButtonText: '确定',
|
|
|
cancelButtonText: '取消',
|
|
|
type: 'warning'
|
|
|
}).then(async() => {
|
|
|
this.tableLoading = true
|
|
|
- await cadDrawingController.delFile(row);
|
|
|
- this.tableLoading = false;
|
|
|
- this.getFileList();
|
|
|
- this.$message({
|
|
|
- type: 'success',
|
|
|
- message: '删除成功!'
|
|
|
- });
|
|
|
+ const res = await cadDrawingController.delFile({id});
|
|
|
+ if(res.result === logicConfig.resultObj.success) {
|
|
|
+ this.tableLoading = false;
|
|
|
+ this.getFileList();
|
|
|
+ this.$message({
|
|
|
+ type: 'success',
|
|
|
+ message: '删除成功!'
|
|
|
+ });
|
|
|
+ }
|
|
|
+
|
|
|
+
|
|
|
}).catch(() => {
|
|
|
this.$message({
|
|
|
type: 'info',
|
|
@@ -185,8 +250,8 @@ export default {
|
|
|
}
|
|
|
|
|
|
},
|
|
|
- mounted() {
|
|
|
- this.getCascader()
|
|
|
+ async mounted() {
|
|
|
+ await this.getCascader()
|
|
|
this.getFileList()
|
|
|
}
|
|
|
|