123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886887888889890891892893894895896897898899900901902903904905906907908909910911912913914915916917918919920921922923924925926927928929930931932933934935936937938939940941942943944945946947948949950951952953954955956957958959960961962963964965966967968969970971972973974975976977978979980981982983984985986987988989990991992993994995996997998999100010011002100310041005100610071008100910101011101210131014101510161017101810191020102110221023102410251026102710281029103010311032103310341035103610371038103910401041104210431044104510461047104810491050105110521053105410551056105710581059106010611062106310641065106610671068106910701071107210731074107510761077107810791080108110821083108410851086108710881089109010911092109310941095 |
- <template>
- <div class="uploadCost">
- <el-dialog
- v-loading="loading"
- :before-close="closeUpload"
- :close-on-click-modal="false"
- :close-on-press-escape="false"
- :title="importTitle"
- :visible.sync="dialogVisible"
- append-to-body
- width="50%"
- >
- <!-- :title="isImport?'导入结果':'批量导入'"-->
- <div v-if="!isImport">
- <!-- <p v-for="(item, index) in uploadTitle" :key="index" class="uploadtitle">-->
- <!-- {{ item }}-->
- <!-- </p>-->
- <el-card style="padding-top: 10px;padding-bottom: 10px">
- <div style="width: 50%;float:left;">
- <p class="uploadtitle txtcenter">1.下载模板按要求填写</p>
- <img class="mtmb16 mgauto" src="@/assets/excelicon.png" width="50px">
- <div style="width: 100%">
- <el-button class="mtmb16 mgauto" size="small" type="primary" @click="downloadTemplate()">下载模板
- </el-button>
- </div>
- </div>
- <div style="width: 50%;float:left;">
- <p class="uploadtitle txtcenter">2.上传填写好的文件</p>
- <img class="mtmb16 mgauto" src="@/assets/excelicon.png" width="50px">
- <div class="mgauto2">
- <el-upload
- :file-list="fileUrlList"
- :http-request="uploadFile"
- :limit="1"
- accept=".xlsx"
- action="#"
- >
- <el-button class="mtmb16" size="small" style="margin-top: 0;height: 33px" type="primary">上传文件</el-button>
- <div slot="file" slot-scope="{file}">
- <a :href="file.url">{{ file.name }}</a>
- <span class="el-upload-list__item-actions">
- <i class="el-icon-delete" @click="handlePictureRemove(file,fileUrlList)" />
- </span>
- </div>
- </el-upload>
- </div>
- </div>
- </el-card>
- </div>
- <div v-if="isImport" style="margin:10px">
- <p>导入成功 <span>{{ successCount }} 条</span> ,失败 <span>{{ errorCount }}</span> 条 </p>
- <p>您可以下载失败记录,修改后重新上传。以下标红为校验失败项</p>
- <el-table
- :data="tableData"
- style="width: 100%;"
- >
- <el-table-column align="center" label="楼盘/小区名称" prop="groupName">
- <template v-slot="scope">
- <span>{{ scope.row.groupName }}</span>
- </template>
- </el-table-column>
- <el-table-column align="center" label="分期名称" prop="discName">
- <template v-slot="scope">
- <span>{{ scope.row.discName }}</span>
- </template>
- </el-table-column>
- <el-table-column align="center" label="单元/楼栋号" prop="buildNum">
- <template v-slot="scope">
- <span>{{ scope.row.buildNum }}</span>
- </template>
- </el-table-column>
- <el-table-column align="center" label="户室号" prop="roomNo">
- <template v-slot="scope">
- <span>{{ scope.row.roomNo }}</span>
- </template>
- </el-table-column>
- <el-table-column align="center" label="异常原因" prop="reason">
- <template v-slot="scope">
- <span style="color: red">{{ scope.row.reason }}</span>
- </template>
- </el-table-column>
- </el-table>
- </div>
- <span slot="footer" class="dialog-footer">
- <el-button @click="closeUpload()">取 消</el-button>
- <el-button
- v-if="!isImport"
- :disabled="fileUrlList.length===0"
- type="primary"
- @click="importFile()"
- class="ch-button-else"
- >导入</el-button>
- <el-button
- v-if="isImport"
- type="primary"
- @click="exportError()"
- >
- 下载失败记录
- </el-button>
- </span>
- </el-dialog>
- </div>
- </template>
- <script>
- // import XLSX from 'xlsx'
- // import XLSXStyle from 'xlsx-style-fixedver'
- const XLSX = require('xlsx')
- const XLSXStyle = require('xlsx-style-fixedver')
- const defaultTitle = '批量导入'
- export default {
- props: {
- // 弹框状态
- dialogVisible: { type: Boolean, default: false },
- // 类型
- importType: { type: String, default: '' },
- // 上传说明
- uploadTitle: { type: Array, default: () => ([]) },
- // 名称
- importTitle: { type: String, default: '' }
- },
- data() {
- return {
- fileUrlList: [],
- tableData: [],
- title: defaultTitle.repeat(1),
- loading: false,
- isImport: false,
- file: null,
- successCount: 0,
- errorCount: ''
- }
- },
- methods: {
- importFile() {
- if (this.importType === 'groupInsert') {
- this.importGroup()
- }
- if (this.importType === 'FQInsert') {
- this.importFQ()
- }
- if (this.importType === 'buildInsert') {
- this.importBuild()
- }
- if (this.importType === 'roomInsert') {
- this.importRoom()
- }
- },
- importGroup() {
- this.loading = true
- this.$axios({
- headers: {
- 'Content-Type': 'multipart/form-data'
- },
- method: 'post',
- url: this.$constant.BASE_URI + '/ParkInfoController/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)
- })
- },
- importFQ() {
- this.loading = true
- this.$axios({
- headers: {
- 'Content-Type': 'multipart/form-data'
- },
- method: 'post',
- url: this.$constant.BASE_URI + '/ParkFloorDiscController/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)
- })
- },
- 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')
- },
- uploadFile(param) {
- const formParam = new FormData()
- formParam.append('file', param.file)
- this.file = formParam
- this.fileUrlList.push({ name: param.file.name })
- },
- handlePictureRemove(file, fileUrlList) {
- const index = fileUrlList.indexOf(file)
- fileUrlList.splice(index, 1)
- this.file = null
- },
- exportError() {
- if (this.importType === 'groupInsert') {
- this.exportErrorGroup()
- }
- if (this.importType === 'FQInsert') {
- this.exportErrorFQ()
- }
- if (this.importType === 'buildInsert') {
- this.exportErrorBuild()
- }
- if (this.importType === 'roomInsert') {
- this.exportErrorRoom()
- }
- },
- exportErrorGroup() {
- if (!this.tableData.length) {
- this.$message.error('失败记录为空!')
- return
- }
- 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('行政区划')
- title.push('详细地址')
- title.push('备注')
- title.push('异常原因')
- outData.push(title)
- const errorFiled = []
- this.tableData.forEach((item, index) => {
- const jsonArray = []
- jsonArray.push(item.groupName)
- jsonArray.push(item.nature)
- jsonArray.push(item.preSalesLicenseNumber)
- jsonArray.push(item.companyName)
- jsonArray.push(item.buildArea)
- jsonArray.push(item.landArea)
- jsonArray.push(item.projectApprovalDocument)
- jsonArray.push(item.engineeringPlanningPermit)
- jsonArray.push(item.constructionPermit)
- jsonArray.push(item.landCertificateNumber)
- jsonArray.push(item.landUsePermitNumber)
- jsonArray.push(item.volumeRatio)
- jsonArray.push(item.greenRatio)
- jsonArray.push(item.price)
- jsonArray.push(item.exceededPrice)
- jsonArray.push(item.areaStatus)
- jsonArray.push(item.saleStatus)
- jsonArray.push(item.regionalismCode)
- jsonArray.push(item.address)
- jsonArray.push(item.introduction)
- jsonArray.push(item.reason)
- outData.push(jsonArray)
- })
- const outSize = []
- title.forEach(item => {
- if (item.length > 4) {
- outSize.push({
- wch: 30
- })
- } else {
- outSize.push({
- wch: 15
- })
- }
- })
- const fileName = '失败记录导出 ' + new Date().Format('yyyy-MM-dd hh:mm')
- const ws = XLSX.utils.aoa_to_sheet(outData)
- ws['!cols'] = outSize
- ws['!rows'] = []
- if (errorFiled.length) {
- errorFiled.forEach(item => {
- if (!ws[item]) {
- ws[item] = {
- v: '',
- t: 's',
- s: {
- fill: {
- bgColor: { indexed: 64 }, fgColor: { rgb: 'FF0000' }
- },
- font: {
- color: { rgb: 'FFFFFF' }
- }
- }
- }
- } else {
- ws[item].s = {
- fill: {
- bgColor: { indexed: 64 }, fgColor: { rgb: 'FF0000' }
- },
- font: {
- color: { rgb: 'FFFFFF' }
- }
- }
- }
- })
- }
- 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)
- },
- exportErrorFQ() {
- if (!this.tableData.length) {
- this.$message.error('失败记录为空!')
- return
- }
- const outData = []
- const title = []
- title.push('楼盘/小区名称')
- title.push('分期名称')
- title.push('房屋买卖单价(元/㎡)')
- title.push('物业费单价(元/㎡)')
- title.push('住宅专项维修资金(元/㎡)')
- title.push('认购金(元)')
- title.push('共持比例')
- title.push('支付方式')
- title.push('异常原因')
- outData.push(title)
- const errorFiled = []
- this.tableData.forEach((item, index) => {
- const jsonArray = []
- jsonArray.push(item.groupName)
- jsonArray.push(item.name)
- jsonArray.push(item.unitPrice)
- jsonArray.push(item.propertyUnitPrice)
- jsonArray.push(item.maintenanceFunds)
- jsonArray.push(item.subscriptionFunds)
- jsonArray.push(item.proportion)
- jsonArray.push(item.paymentMethods)
- jsonArray.push(item.reason)
- outData.push(jsonArray)
- })
- const outSize = []
- title.forEach(item => {
- if (item.length > 4) {
- outSize.push({
- wch: 30
- })
- } else {
- outSize.push({
- wch: 15
- })
- }
- })
- const fileName = '失败记录导出 ' + new Date().Format('yyyy-MM-dd hh:mm')
- const ws = XLSX.utils.aoa_to_sheet(outData)
- ws['!cols'] = outSize
- ws['!rows'] = []
- if (errorFiled.length) {
- errorFiled.forEach(item => {
- if (!ws[item]) {
- ws[item] = {
- v: '',
- t: 's',
- s: {
- fill: {
- bgColor: { indexed: 64 }, fgColor: { rgb: 'FF0000' }
- },
- font: {
- color: { rgb: 'FFFFFF' }
- }
- }
- }
- } else {
- ws[item].s = {
- fill: {
- bgColor: { indexed: 64 }, fgColor: { rgb: 'FF0000' }
- },
- font: {
- color: { rgb: 'FFFFFF' }
- }
- }
- }
- })
- }
- 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)
- },
- exportErrorBuild() {
- if (!this.tableData.length) {
- this.$message.error('失败记录为空!')
- return
- }
- 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('标准价格参考层及差价系数备注说明')
- title.push('异常原因')
- outData.push(title)
- const errorFiled = []
- this.tableData.forEach((item, index) => {
- const jsonArray = []
- jsonArray.push(item.groupName)
- jsonArray.push(item.discName)
- jsonArray.push(item.buildNum)
- jsonArray.push(item.area)
- jsonArray.push(item.residentialArea)
- jsonArray.push(item.unResidentialArea)
- jsonArray.push(item.coverAnArea)
- jsonArray.push(item.undergroundArea)
- jsonArray.push(item.roomNum)
- jsonArray.push(item.numberInfo)
- jsonArray.push(item.floors)
- jsonArray.push(item.overgroundFloors)
- jsonArray.push(item.undergroundFloors)
- jsonArray.push(item.structure)
- jsonArray.push(item.regionalismCode)
- jsonArray.push(item.landCode)
- jsonArray.push(item.remark)
- jsonArray.push(item.priceRemark)
- jsonArray.push(item.reason)
- outData.push(jsonArray)
- })
- const outSize = []
- title.forEach(item => {
- if (item.length > 4) {
- outSize.push({
- wch: 30
- })
- } else {
- outSize.push({
- wch: 15
- })
- }
- })
- const fileName = '失败记录导出 ' + new Date().Format('yyyy-MM-dd hh:mm')
- const ws = XLSX.utils.aoa_to_sheet(outData)
- ws['!cols'] = outSize
- ws['!rows'] = []
- if (errorFiled.length) {
- errorFiled.forEach(item => {
- if (!ws[item]) {
- ws[item] = {
- v: '',
- t: 's',
- s: {
- fill: {
- bgColor: { indexed: 64 }, fgColor: { rgb: 'FF0000' }
- },
- font: {
- color: { rgb: 'FFFFFF' }
- }
- }
- }
- } else {
- ws[item].s = {
- fill: {
- bgColor: { indexed: 64 }, fgColor: { rgb: 'FF0000' }
- },
- font: {
- color: { rgb: 'FFFFFF' }
- }
- }
- }
- })
- }
- 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)
- },
- exportErrorRoom() {
- if (!this.tableData.length) {
- this.$message.error('失败记录为空!')
- return
- }
- 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('可售状态')
- title.push('异常原因')
- outData.push(title)
- const errorFiled = []
- this.tableData.forEach((item, index) => {
- const jsonArray = []
- jsonArray.push(item.groupName)
- jsonArray.push(item.discName)
- jsonArray.push(item.buildNum)
- jsonArray.push(item.roomNo)
- jsonArray.push(item.floor)
- jsonArray.push(item.predictionInternalArea)
- jsonArray.push(item.predictionShareArea)
- jsonArray.push(item.predictionBuildArea)
- jsonArray.push(item.predictionLandArea)
- jsonArray.push(item.actualInternalArea)
- jsonArray.push(item.actualShareArea)
- jsonArray.push(item.actualBuildArea)
- jsonArray.push(item.actualLandArea)
- jsonArray.push(item.roomUse)
- jsonArray.push(item.roomNumber)
- jsonArray.push(item.decorationSituation)
- jsonArray.push(item.twoPointTwo)
- jsonArray.push(item.houseType)
- jsonArray.push(item.remark)
- jsonArray.push(item.saleStatus)
- jsonArray.push(item.reason)
- outData.push(jsonArray)
- })
- const outSize = []
- title.forEach(item => {
- if (item.length > 4) {
- outSize.push({
- wch: 30
- })
- } else {
- outSize.push({
- wch: 15
- })
- }
- })
- const fileName = '失败记录导出 ' + new Date().Format('yyyy-MM-dd hh:mm')
- const ws = XLSX.utils.aoa_to_sheet(outData)
- ws['!cols'] = outSize
- ws['!rows'] = []
- if (errorFiled.length) {
- errorFiled.forEach(item => {
- if (!ws[item]) {
- ws[item] = {
- v: '',
- t: 's',
- s: {
- fill: {
- bgColor: { indexed: 64 }, fgColor: { rgb: 'FF0000' }
- },
- font: {
- color: { rgb: 'FFFFFF' }
- }
- }
- }
- } else {
- ws[item].s = {
- fill: {
- bgColor: { indexed: 64 }, fgColor: { rgb: 'FF0000' }
- },
- font: {
- color: { rgb: 'FFFFFF' }
- }
- }
- }
- })
- }
- 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)
- },
- s2ab(s) {
- var cuf
- var i
- if (typeof ArrayBuffer !== 'undefined') {
- cuf = new ArrayBuffer(s.length)
- var view = new Uint8Array(cuf)
- for (i = 0; i !== s.length; i++) {
- view[i] = s.charCodeAt(i) & 0xFF
- }
- return cuf
- } else {
- cuf = new Array(s.length)
- for (i = 0; i !== s.length; ++i) {
- cuf[i] = s.charCodeAt(i) & 0xFF
- }
- return cuf
- }
- },
- downloadTemplate() {
- if (this.importType === 'groupInsert') {
- this.downloadGroupTemplate()
- }
- if (this.importType === 'FQInsert') {
- this.downloadFQTemplate()
- }
- if (this.importType === 'buildInsert') {
- this.downloadBuildTemplate()
- }
- if (this.importType === 'roomInsert') {
- this.downloadRoomTemplate()
- }
- },
- downloadGroupTemplate() {
- 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('行政区划')
- 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.includes('批量导入')) {
- fileName = '楼盘导入模版'
- }
- // if (this.importTitle.includes('批量更新')) {
- // 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)
- },
- downloadFQTemplate() {
- const outData = []
- const title = []
- 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.includes('批量导入')) {
- 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)
- },
- 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.includes('批量导入')) {
- 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.includes('批量导入')) {
- 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
- }
- }
- }
- </script>
- <style lang="scss">
- .uploadCost {
- .el-card__body {
- padding: 0 !important;
- }
- .uploadtitle {
- color: #C5C5C5;
- }
- .el-dialog__body {
- padding: 15px !important;
- color: #606266 !important;
- font-size: 14px !important;
- word-break: break-all !important;
- }
- .el-upload {
- width: 100%;
- }
- .el-upload-list {
- li {
- text-align: center;
- }
- }
- .mgauto {
- display: block;
- margin: 0 auto;
- }
- .mtmb16 {
- margin-top: 16px;
- margin-bottom: 16px;
- }
- .txtcenter {
- text-align: center;
- }
- }
- </style>
|