2023西安数博会CIM演示-【前端】-Web
AdaKing88
2023-08-21 bc03b832caa49bbcd2674fe4cae3701b5059bf95
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
<template>
    <div class="new" v-show="projectWindowShow">
        <el-header style="height:20px"><div class="title">新增应用</div></el-header>
        <el-main>
            <div class="elgroup">
            <el-radio-group v-model="radio">
                <el-radio-button label="交通应用" class="radioLabel" type="text"></el-radio-button>
                <el-radio-button label="城管城市安全" class="radioLabel" type="text"></el-radio-button>
                <el-radio-button label="规建审批" class="radioLabel" type="text"></el-radio-button>
                <el-radio-button label="园区应用" class="radioLabel" type="text"></el-radio-button>
                <el-radio-button label="应急城市级消防" class="radioLabel" type="text"></el-radio-button>
                <el-radio-button label="智慧工地" class="radioLabel" type="text"></el-radio-button>
                <el-radio-button label="智慧房管" class="radioLabel" type="text"></el-radio-button>
                <el-radio-button label="文物保护文旅应用" class="radioLabel" type="text"></el-radio-button>
                <el-radio-button label="能源应用" class="radioLabel" type="text"></el-radio-button>
                <el-radio-button label="水务水利应用" class="radioLabel" type="text"></el-radio-button>
            </el-radio-group>
            </div>
            <div class="peizhi">
            <div class="peizhiLine">
                <span class="titleBlock">应用名称:</span><span class="content" style="width: 320px;display: inline-block;"><el-input v-model="applyName"></el-input></span>
            </div>
            <div class="peizhiLine">
                <span class="titleBlock">应用类型:</span><span class="content">{{ radio }}</span>
            </div>
            <div class="peizhiLine">
                <span class="titleBlock">数据配置:</span><span class="content">
                    已选{{checkedKeys.length}}个
                    <el-button type="primary" plain @click="treeDirectory = !treeDirectory">点我进行配置</el-button>
                    
                </span>
            </div>
            <div class="peizhiLine">
                <span class="titleBlock">应用状态:</span><span class="content">
                    <el-radio-group v-model="status">
                        <el-radio label="公开">公开</el-radio>
                        <el-radio label="私有">私有</el-radio>
                    </el-radio-group></span>
            </div>
            <div class="peizhiLine">
                <span class="titleBlock">服务配置:</span>
                <span class="content">
                    <el-checkbox-group v-model="checkList">
                        <el-checkbox label="BIM指标审查服务包"></el-checkbox>
                        <el-checkbox label="CIM指标技术审查服务包"></el-checkbox>
                        <el-checkbox label="项目管理服务包"></el-checkbox>
                        <el-checkbox label="辅助分析服务包" ></el-checkbox>
                        <el-checkbox label="规则库管理服务包" ></el-checkbox>
                    </el-checkbox-group>
                </span>
            </div>
            <div class="peizhiLine">
                <span class="titleBlock" style="display: inline-block;">应用配图:</span>
                <span class="content" style="position: absolute;">
                    <el-upload class="avatar-uploader" action="/dataapi/file/upload"
                        :show-file-list="false" :on-success="handleAvatarSuccess"
                        :before-upload="beforeAvatarUpload" :headers="headers">
                        <img v-if="imageUrl" :src="imageUrl" class="avatar">
                        <i v-else class="el-icon-plus avatar-uploader-icon"></i>
                    </el-upload>
                </span>
            </div>
            </div>
        </el-main>
        <el-footer>
            <el-button @click="close()">取 消</el-button>
            <el-button type="primary" @click="upload()">确 定</el-button>
        </el-footer>
        <div class="treeDirectory" v-show="treeDirectory">
            <el-header style="height:20px"><div class="title">数据源</div></el-header>
            <el-main>
                <el-tree :data="treeData" :props="defaultProps" show-checkbox class="treeDirectoryTree"
                 ref="treeDirectoryTree" node-key="id" @check-change="getCheckId"></el-tree>
            </el-main>
        <el-main>
        </el-main>
        </div>
    </div>
</template>
 
<script>
import {supplementFile,saveData,getResourceCatalogs} from "@/api/usercenter.js"
import { getToken } from "@/utils/auth";
export default {
    data() {
        return {
            radio:"交通应用",
            status:"公开",
            applyName:"",
            checkList:[],
            configuration: '',
            imageUrl:"",
            headers: { Authorization: "Bearer " + getToken() },
            projectWindowShow:false,
            defaultProps: {
                children: 'children',
                label: 'label'
            },
            treeData:[],
            treeDirectory:false,
            checkedKeys:[],
            loading:""
        }
    },
    methods: {
        getCheckId(){
            this.checkedKeys = this.$refs.treeDirectoryTree.getCheckedKeys(true)
        },
        upload(){
            let option ={
                "appType": "",
                "createBy": this.$store.state.username,
                "dataId": this.$refs.treeDirectoryTree.getCheckedKeys(true),
                "name": this.applyName,
                "picUrl": this.imageUrl,
                "serverId": [
                    0
                ],
                "status": this.status == "公开"? 1:2
            }
            let appType = ""
            switch (this.radio) {
                case "交通应用": appType = 1;break;
                case "城管城市安全": appType = 2;break;
                case "规建审批": appType = 3;break;
                case "园区应用": appType = 4;break;
                case "应急城市级消防": appType = 5;break;
                case "智慧工地": appType = 6;break;
                case "智慧房管": appType = 7;break;
                case "文物保护文旅应用": appType = 8;break;
                case "能源应用": appType = 9;break;
                case "水务水利应用": appType = 10;break;
            };
            option.appType = appType
            let serverId = []
            this.checkList.forEach((item)=>{
                switch (item) {
                    case "BIM指标审查服务包":serverId.push(1);break;
                    case "CIM指标技术审查服务包":serverId.push(2);break;
                    case "项目管理服务包":serverId.push(3);break;
                    case "辅助分析服务包":serverId.push(4);break;
                    case "规则库管理服务包":serverId.push(5);break;
                }
            })
            option.serverId = serverId
            saveData(option).then((res)=>{
                console.log(res)
                if(res.code == 200 ){
                    {this.$message.success("上传成功");this.close()}
                }else this.$message.error("上传失败")
            })
        },
        handleAvatarSuccess(res, file) {
            console.log("console",res)
            setTimeout(() => {
                this.loading.close();
            }, 500);
            if(res.code == 200){
                this.imageUrl = res.data.url
            }            
        },
        beforeAvatarUpload(file) {
            const isJPG = file.type === 'image/jpeg' || 'image/png';
            const isLt2M = file.size / 1024 / 1024 < 10;
 
            if (!isJPG) {
            this.$message.error('上传头像图片只能是 JPG,png 格式!');
            }
            if (!isLt2M) {
            this.$message.error('上传头像图片大小不能超过 10MB!');
            }
 
            supplementFile()
            this.loading = this.$loading({
                lock: true,
                text: 'Loading',
                spinner: 'el-icon-loading',
                background: 'rgba(0, 0, 0, 0.7)'
            });
            return isJPG && isLt2M;
        },
        close(){
            this.projectWindowShow = false
        }
    },
    mounted() {
        getResourceCatalogs().then((res)=>{
            if(res.code == 200){
                res.data.forEach((item)=>{
                    let node = {label:item.name,children:[],id:item.id}
                    if(item.resourceDataChildren.length>0)
                    {
                        item.resourceDataChildren.forEach((data)=>{
                            node.children.push({label:data.name,id:data.id,data:data})
                        })
                    }
                    this.treeData.push(node)
                })
            }else this.$message.error("数据源加载失败")
        })
    },
}
</script>
 
<style lang="less" scoped>
.new{
    width: 500px;
    height: 720px;
    background-color: #3c6187;
    position: absolute;
    z-index: 12;
    right: 40px;
    top: 30px;
    border-radius: 10px;
    color: #fff;
    .elgroup{
        width: 100%;
        margin-bottom:15px;
        /deep/ .el-radio-button__inner {
            border: 1px solid #ffffff !important;
            background-color: #3a789d !important;
            border-radius: 5px !important;
            color: #fff !important;
        }
    }
    .title{
        margin:10px 10px;
        margin-top:15px;
        font-size: 20px;
    }
    .radioLabel{
        margin-top:10px;
        margin-right:5px;
    }
    .peizhi{
        width: 450px;
        height:420px;
        // background-color: #fff;
        border-radius: 12px;
        // margin:auto;
        border: 1px rgb(255, 255, 255) solid;
        .peizhiLine{
            margin-left: 20px;
            margin-top:10px;
            .titleBlock{
                font-size: 16px;
            }
            .content{
                margin-left:10px;
                font-size: 16px;
            }
            .el-checkbox-group {
                margin-left: 80px;
                margin-top: -20px;
            }
            /deep/ .el-radio__label {
                color: #fff !important;
            }
            /deep/ .el-checkbox {
                color: #ffffff !important;
                display: inherit !important;
            }
            /deep/ .el-button--primary.is-plain:focus, .el-button--primary.is-plain:hover {
                background: #3a6fa5;
                color: #fff;
                border-color: #3381d4;
            }
            /deep/ .el-button--primary.is-plain {
                color: #fff;
                background: #43668f;
                border-color: #4778ac;
            }
            /deep/ .el-input__inner {
                background-color: #427ea1 !important;
                color:#fff !important;
                border:1px solid #fff !important;
 
            }
            /deep/ .avatar-uploader .el-upload {
                border: 1px dashed #ffffff !important;
                border-radius: 6px !important;
                cursor: pointer !important;
                position: relative !important;
                overflow: hidden !important;
            }
            /deep/ .avatar-uploader .el-upload:hover {
                border-color: #409EFF !important;
            }
            /deep/ .avatar-uploader-icon {
                font-size: 28px !important;
                color: #ffffff !important;
                width: 130px !important;
                height: 130px !important;
                line-height: 130px !important;
                text-align: center !important;
            }
            .avatar {
                width: 130px;
                height: 130px;
                display: block;
            }
        }
        
    }
    .treeDirectory {
        position: absolute;
        right: 510px;
        width: 300px;
        height: 670px;
        top: 0px;
        border-radius: 10px;
        background-color: #3c6187;
        color: #fff;
        .treeDirectoryTree{
            margin-top:25px;
            color: #fff;
            background-color:#3c6187 ;
            /deep/ .el-tree-node__content:hover{
                background-color:rgba(0, 166, 226, 0.6) !important
            }
        }
    }
}
</style>