LAPTOP-FO2T5SIU\35838 9 months ago
parent
commit
1ebda6d0d2

+ 206 - 0
src/views/parkAssets/component/uploadCost.vue

@@ -142,6 +142,9 @@ export default {
             if (this.importType === 'FQInsert') {
                 this.importFQ()
             }
+            if (this.importType === 'buildInsert') {
+                this.importBuild()
+            }
         },
         importGroup() {
             this.loading = true
@@ -207,6 +210,70 @@ export default {
                 console.log('biz user list error', err, x)
             })
         },
+        importBuild() {
+            this.loading = true
+            this.$axios({
+                headers: {
+                    'Content-Type': 'multipart/form-data'
+                },
+                method: 'post',
+                url: this.$constant.BASE_URI + '/MnpBuildingController/handleImport',
+                data: this.file
+            }).then((res) => {
+                this.loading = false
+                if (res.data.code === 200) {
+                    this.$message({
+                        message: '上传成功',
+                        type: 'success'
+                    })
+                    // this.$emit('cancelUpload', true)
+                    this.successCount = res.data.data.successCount
+                    this.errorCount = res.data.data.errorCount
+                    this.tableData = res.data.data.errorList || []
+                    this.isImport = true
+                    console.log('上传成功....')
+                } else {
+                    this.$message({
+                        message: res.data.msg,
+                        type: 'error'
+                    })
+                }
+            }).catch((err, x) => {
+                console.log('biz user list error', err, x)
+            })
+        },
+        importRoom() {
+            this.loading = true
+            this.$axios({
+                headers: {
+                    'Content-Type': 'multipart/form-data'
+                },
+                method: 'post',
+                url: this.$constant.BASE_URI + '/ParkRoomController/handleImport',
+                data: this.file
+            }).then((res) => {
+                this.loading = false
+                if (res.data.code === 200) {
+                    this.$message({
+                        message: '上传成功',
+                        type: 'success'
+                    })
+                    // this.$emit('cancelUpload', true)
+                    this.successCount = res.data.data.successCount
+                    this.errorCount = res.data.data.errorCount
+                    this.tableData = res.data.data.errorList || []
+                    this.isImport = true
+                    console.log('上传成功....')
+                } else {
+                    this.$message({
+                        message: res.data.msg,
+                        type: 'error'
+                    })
+                }
+            }).catch((err, x) => {
+                console.log('biz user list error', err, x)
+            })
+        },
         closeUpload() {
             // 关闭弹窗
             this.$emit('cancelUpload')
@@ -345,6 +412,12 @@ export default {
             if (this.importType === 'FQInsert') {
                 this.downloadFQTemplate()
             }
+            if (this.importType === 'buildInsert') {
+                this.downloadBuildTemplate()
+            }
+            if (this.importType === 'roomInsert') {
+                this.downloadRoomTemplate()
+            }
         },
         downloadGroupTemplate() {
             const outData = []
@@ -469,6 +542,139 @@ export default {
             URL.revokeObjectURL(elink.href) // 释放URL 对象
             document.body.removeChild(elink)
         },
+        downloadBuildTemplate() {
+            const outData = []
+            const title = []
+            title.push('楼盘/小区名称')
+            title.push('分期名称')
+            title.push('单元/楼栋号')
+            title.push('总面积(㎡)')
+            title.push('住宅面积(㎡)')
+            title.push('非住宅面积(㎡)')
+            title.push('占地面积(㎡)')
+            title.push('地下面积(㎡)')
+            title.push('房号')
+            title.push('套数')
+            title.push('总层数')
+            title.push('地上层数')
+            title.push('地下层数')
+            title.push('结构')
+            title.push('行政区划')
+            title.push('地号')
+            title.push('备注')
+            title.push('标准价格参考层及差价系数备注说明')
+
+            outData.push(title)
+            const outSize = []
+            title.forEach(item => {
+                if (item.length > 4) {
+                    outSize.push({
+                        wch: 30
+                    })
+                } else {
+                    outSize.push({
+                        wch: 15
+                    })
+                }
+            })
+            let fileName = '模板'
+            if (this.importTitle === '批量导入') {
+                fileName = '导入模板'
+            }
+            if (this.importTitle === '批量更新') {
+                fileName = '更新模板'
+            }
+            const ws = XLSX.utils.aoa_to_sheet(outData)
+            ws['!cols'] = outSize
+            ws['!rows'] = []
+            const wb = XLSX.utils.book_new()
+            XLSX.utils.book_append_sheet(wb, ws, fileName)
+            const tmpDown = new Blob([
+                this.s2ab(
+                    XLSXStyle.write(wb, {
+                        bookType: 'xlsx',
+                        bookSST: true,
+                        type: 'binary',
+                        cellStyles: true
+                    })
+                )
+            ])
+            const elink = document.createElement('a')
+            elink.download = decodeURIComponent(fileName + '.xlsx')
+            elink.style.display = 'none'
+            elink.href = URL.createObjectURL(tmpDown)
+            document.body.appendChild(elink)
+            elink.click()
+            URL.revokeObjectURL(elink.href) // 释放URL 对象
+            document.body.removeChild(elink)
+        },
+        downloadRoomTemplate() {
+            const outData = []
+            const title = []
+            title.push('楼盘/小区名称')
+            title.push('分期名称')
+            title.push('单元/楼栋号')
+            title.push('户室号')
+            title.push('所在层')
+            title.push('预测套内面积')
+            title.push('预测分摊面积')
+            title.push('预测建筑面积')
+            title.push('预测土地面积')
+            title.push('实测套内面积')
+            title.push('实测分摊面积')
+            title.push('实测建筑面积')
+            title.push('实测土地面积')
+            title.push('用途')
+            title.push('户编号')
+            title.push('装修情况')
+            title.push('2.2M以')
+            title.push('户型')
+            title.push('备注')
+            title.push('可售状态')
+            outData.push(title)
+            const outSize = []
+            title.forEach(item => {
+                if (item.length > 4) {
+                    outSize.push({
+                        wch: 30
+                    })
+                } else {
+                    outSize.push({
+                        wch: 15
+                    })
+                }
+            })
+            let fileName = '模板'
+            if (this.importTitle === '批量导入') {
+                fileName = '导入模板'
+            }
+            if (this.importTitle === '批量更新') {
+                fileName = '更新模板'
+            }
+            const ws = XLSX.utils.aoa_to_sheet(outData)
+            ws['!cols'] = outSize
+            ws['!rows'] = []
+            const wb = XLSX.utils.book_new()
+            XLSX.utils.book_append_sheet(wb, ws, fileName)
+            const tmpDown = new Blob([
+                this.s2ab(
+                    XLSXStyle.write(wb, {
+                        bookType: 'xlsx',
+                        bookSST: true,
+                        type: 'binary',
+                        cellStyles: true
+                    })
+                )
+            ])
+            const elink = document.createElement('a')
+            elink.download = decodeURIComponent(fileName + '.xlsx')
+            elink.style.display = 'none'
+            elink.href = URL.createObjectURL(tmpDown)
+            document.body.appendChild(elink)
+            elink.click()
+            URL.revokeObjectURL(elink.href) // 释放URL 对象
+            document.body.removeChild(elink)
+        },
         handleClose() {
             this.dialogVisible = false
         }

+ 29 - 5
src/views/parkAssets/parkBuild/index.vue

@@ -40,7 +40,7 @@
           <el-col :span="20">
             <el-input v-model="queryParam.ldmc" size="small" placeholder="请输入楼栋号" class="ch-input-size" @keyup.enter.native="handleSearch()" />
             <el-button size="small" class="ch-button-export" style="float: right;margin-top: 4px" @click="handleExcel()"><i class="el-icon-menu" />&nbsp;导出Excel</el-button>
-            <el-button size="small" class="ch-button-export" style="float: right;margin-top: 4px" @click="handleImport()"><i class="el-icon-menu" />&nbsp;批量导入</el-button>
+            <el-button size="small" class="ch-button-export" style="float: right;margin-top: 4px" @click="batchImport()"><i class="el-icon-menu" />&nbsp;批量导入</el-button>
             <el-button size="small" class="ch-button-add" style="float: right; margin-right: 10px; margin-top: 4px" @click="handleAdd()"><i class="el-icon-menu" />&nbsp;新增楼栋</el-button>
             <el-button size="small" class="ch-button" style="float: right;margin-top: 4px" @click="handleSearch()"><i class="el-icon-menu" />&nbsp;查询</el-button>
             <el-button size="small" class="ch-button-warning" style="float: right;margin-top: 4px" @click="handleReset()"><i class="el-icon-menu" />&nbsp;重置</el-button>
@@ -251,6 +251,16 @@
       <build-view ref="buildView" @cancel="cancel" />
     </el-dialog>
 
+    <!-- 批量导入 -->
+    <upload-cost
+      v-if="importVisible"
+      :dialog-visible="importVisible"
+      :import-type="importType"
+      :upload-title="uploadTitle"
+      :import-title="importTitle"
+      @cancelUpload="cancelImport"
+    />
+
   </div>
 </template>
 
@@ -260,10 +270,11 @@ import BaseData from '@/views/base/baseData'
 import BaseDept from '@/views/base/baseDept'
 import constant from '../../../static/utils/constant'
 import BuildView from './buildView'
+import uploadCost from '@/views/parkAssets/component/uploadCost.vue'
 // import textEdit from '../../textEdit/index'
 export default {
     name: 'User',
-    components: { BuildView },
+    components: { uploadCost, BuildView },
     mixins: [Base, BaseData, BaseDept],
     data() {
         return {
@@ -309,7 +320,12 @@ export default {
 
             nodeId: '',
             level: '',
-            dialogViewVisible: false
+            dialogViewVisible: false,
+            // 批量导入
+            importVisible: false,
+            importType: '',
+            importTitle: '',
+            uploadTitle: []
 
         }
     },
@@ -366,8 +382,10 @@ export default {
             this.dialogTitle = '新增楼栋'
         },
         // 导入
-        handleImport() {
-
+        batchImport() {
+            this.importVisible = true
+            this.importType = 'buildInsert'
+            this.importTitle = '楼栋批量导入'
         },
         // 导出
         handleExcel: function() {
@@ -509,6 +527,12 @@ export default {
         test(val) {
             // this.$set(this.buildForm, 'introduction', val)
         },
+        cancelImport(refresh) {
+            this.importVisible = false
+            this.importType = ''
+            this.getTreeData()
+            this.getList()
+        },
         // 请求封装,继承类中调用,必须存在
         baseRequest: function(opUrl, postData) {
             return this.$channel.baseRequest('MnpBuildingController', opUrl, postData, 'User')

+ 32 - 1
src/views/parkAssets/parkRoom/index.vue

@@ -130,6 +130,8 @@
 
             <el-col :span="24">
               <el-button size="small" class="ch-button-export" style="float: right; margin-top: 4px" @click="handleExcel"><i class="el-icon-menu" />&nbsp;导出EXCEL</el-button>
+              <el-button size="small" class="ch-button-export" style="float: right;margin-top: 4px" @click="batchImport()"><i class="el-icon-menu" />&nbsp;批量导入</el-button>
+
               <el-button size="small" class="ch-button" style="float: right;  margin-right: 10px; margin-top: 4px" @click="handleAdd()"><i class="el-icon-menu" />&nbsp;新增房间</el-button>
               <el-button size="small" class="ch-button" style="float: right;margin-top: 4px" @click="handleSearch()"><i class="el-icon-menu" />&nbsp;查询</el-button>
               <el-button size="small" class="ch-button-warning" style="float: right;margin-top: 4px" @click="handleReset()"><i class="el-icon-menu" />&nbsp;重置</el-button>
@@ -391,6 +393,16 @@
       <img width="100%" :src="dialogImageUrl" alt="">
     </el-dialog>
 
+    <!-- 批量导入 -->
+    <upload-cost
+      v-if="importVisible"
+      :dialog-visible="importVisible"
+      :import-type="importType"
+      :upload-title="uploadTitle"
+      :import-title="importTitle"
+      @cancelUpload="cancelImport"
+    />
+
   </div>
 </template>
 
@@ -400,9 +412,11 @@ import BaseData from '@/views/base/baseData'
 import BaseDept from '@/views/base/baseDept'
 import Constant from '@/static/utils/constant'
 import { upload } from '@/static/utils/channel'
+import uploadCost from '@/views/parkAssets/component/uploadCost.vue'
 
 export default {
     name: 'User',
+    components: { uploadCost },
     mixins: [Base, BaseData, BaseDept],
     data() {
         return {
@@ -448,7 +462,12 @@ export default {
             houseTypeOption: [],
             // 图片预览及其他
             dialogImageUrl: '',
-            dialogImageVisible: false
+            dialogImageVisible: false,
+            // 批量导入
+            importVisible: false,
+            importType: '',
+            importTitle: '',
+            uploadTitle: []
         }
     },
     mounted() {
@@ -713,6 +732,18 @@ export default {
                 }
             })
         },
+        // 导入
+        batchImport() {
+            this.importVisible = true
+            this.importType = 'roomInsert'
+            this.importTitle = '房间批量导入'
+        },
+        cancelImport(refresh) {
+            this.importVisible = false
+            this.importType = ''
+            this.getTreeData()
+            this.getData()
+        },
         // 请求封装,继承类中调用,必须存在
         baseRequest: function(opUrl, postData) {
             return this.$channel.baseRequest('ParkRoomController', opUrl, postData, 'User')