You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
1356 lines
53 KiB
1356 lines
53 KiB
<template>
|
|
<div class='flex'>
|
|
<div :class="['flex', 'flex-y', 'flex1', 'luckysheet-wrap-all']" v-loading.fullscreen.lock="luckysheetLoading">
|
|
<div class="top_btn flex flex-end">
|
|
<div>
|
|
<el-button type="text" round @click="handelClickBack" icon="el-icon-back">返回</el-button>
|
|
<el-button type="warning" @click="handleClickUploadTemplate" v-if="pageType !== 'info'">上传统计模板
|
|
</el-button>
|
|
<el-button type="success" @click="onClickUplond" v-if="pageType !== 'info'"> 数据列表导出</el-button>
|
|
<el-button type="success" @click="onClickShowCondition" v-if="pageType === 'info' && this.infoObj.reportType === 0"> 查看数据统计条件</el-button>
|
|
<el-button type="warning" v-if="pageType === 'info' && this.infoObj.reportType === 0" @click="handleClickInspect"> 自动检查</el-button>
|
|
<span class="red">(操作提示:可双击单元格进行设置统计条件)</span>
|
|
</div>
|
|
<div>
|
|
<el-button type="primary" @click="handleClickExport()"> 导出</el-button>
|
|
</div>
|
|
</div>
|
|
<div id="luckysheet-export"></div>
|
|
</div>
|
|
<el-dialog title="数据列表导出" v-if="showUploadData" :visible.sync="showUploadData" width="60%"
|
|
:close-on-click-modal="false">
|
|
<excelUploadData @handleUploadDataHide="handleUploadDataHide" :currentTable="currentTable"
|
|
:btnLoading="btnLoading" :pageType='`report`' :workBookId="dataForm.workbookId" @saveLuckysheetHead="saveLuckysheetHead">
|
|
</excelUploadData>
|
|
</el-dialog>
|
|
<el-dialog title="查看数据统计条件" v-if="showCondition" :visible.sync="showCondition" width="60%"
|
|
:close-on-click-modal="false">
|
|
<resi-search ref="resi_form" :infoObj="infoObj.searchForm" :disabled="true"></resi-search>
|
|
</el-dialog>
|
|
<el-dialog title="上传统计模板" v-if="showTemplate" :visible.sync="showTemplate" width="60%"
|
|
:close-on-click-modal="false">
|
|
<el-form :model="dataForm" :rules="dataRule" ref="dataForm" :label-width="'120px'">
|
|
<el-form-item label="报表名称" prop="reportName">
|
|
<el-input v-model.trim="dataForm.reportName" placeholder="请输入报表名称,5-30个字符"></el-input>
|
|
</el-form-item>
|
|
<el-form-item label="上传模板" prop="moduleUrl">
|
|
<el-upload :headers="$getElUploadHeaders()" ref="upload" class="upload-btn" :action="uploadUlr"
|
|
v-if="!dataForm.moduleUrl" :limit="1" :accept="'.xlsx'" :with-credentials="true" :show-file-list="false"
|
|
:auto-upload="true" :on-success="handleExcelSuccess" :before-upload="beforeExcelUpload">
|
|
<template #trigger>
|
|
<el-button type="primary" v-loading.fullscreen.lock="fullscreenLoading">上传报表模板</el-button>
|
|
</template>
|
|
</el-upload>
|
|
<section v-else >
|
|
<img :src="require(`@/assets/images/index/Excel.png`)" class="upload-img" alt="">
|
|
<span>{{ fileName }}</span>
|
|
<el-button type="text" @click="removeFile(file)" style="margin-left: 16px;"> 删除</el-button>
|
|
</section>
|
|
</el-form-item>
|
|
</el-form>
|
|
<div slot="footer" class="dialog-footer">
|
|
<el-button @click="handleCloseTemplate">取 消</el-button>
|
|
<el-button type="primary" @click="handleSaveTemplate">确 认</el-button>
|
|
</div>
|
|
</el-dialog>
|
|
<el-drawer title="单元格统计条件设置" :size="'50%'" :visible.sync="drawer" :direction="direction" :before-close="handleClose"
|
|
v-loading="statisticsLoading" v-if="drawer">
|
|
<el-container v-if="!showConditionDetailsDialog ">
|
|
<el-main>
|
|
<el-row>
|
|
<el-col :span="24">
|
|
选中单元格:{{ selectedCell }}
|
|
</el-col>
|
|
</el-row>
|
|
<el-tabs v-model="activeName" style="margin-top: 20px;">
|
|
<el-tab-pane label="新建统计条件" name="add">
|
|
<el-table border :data="tableData" style="width: 100%" height="200">
|
|
<el-table-column label="选择数据源" align="center" width="120">
|
|
<template slot-scope="scope">
|
|
<el-select v-model.trim="scope.row.dataSource" placeholder="请选择"
|
|
@change="handleChangeSource(scope.row, scope.$index)" clearable>
|
|
<el-option v-for="item in dataSourceOpction" :label="item.label" :value="item.value"
|
|
:key="item.value">
|
|
</el-option>
|
|
</el-select>
|
|
</template>
|
|
</el-table-column>
|
|
<el-table-column label="字段类别" align="center" width="120">
|
|
<template slot-scope="scope" v-if="scope.row.dataSource == 'resi' || scope.row.dataSource == 'house'">
|
|
<el-select v-model.trim="scope.row.itemGroupId" placeholder="请选择" clearable
|
|
@change="handleChangeFieldsType(scope.row, scope.$index)">
|
|
<el-option v-for="item in scope.row.itemGroupIdOpction" :label="item.label" :value="item.id"
|
|
:key="item.id">
|
|
</el-option>
|
|
</el-select>
|
|
</template>
|
|
</el-table-column>
|
|
<el-table-column label="字段名称" align="center" width="120">
|
|
<template slot-scope="scope">
|
|
<el-select v-model.trim="scope.row.itemId" placeholder="请选择"
|
|
@change="handleChangeFieldsName(scope.row, scope.$index)"
|
|
@clear="handleClearItemId(scope.row, scope.$index)" clearable>
|
|
<el-option v-for="item in scope.row.itemIdOpction" :label="item.label" :value="scope.row.dataSource == 'resi' || scope.row.dataSource == 'house' ? item.itemId : item.colKey
|
|
"
|
|
:key="scope.row.dataSource == 'resi' || scope.row.dataSource == 'house' ? item.itemId : item.colKey">
|
|
</el-option>
|
|
</el-select>
|
|
</template>
|
|
</el-table-column>
|
|
<el-table-column label="比较符" align="center" width="120">
|
|
<template slot-scope="scope">
|
|
<el-select v-model.trim="scope.row.queryType" placeholder="请选择" clearable>
|
|
<el-option v-for="item in queryTypeOpction" :label="item.label" :value="item.value"
|
|
:key="item.value">
|
|
</el-option>
|
|
</el-select>
|
|
</template>
|
|
</el-table-column>
|
|
<el-table-column label="对应值" align="center" width="120">
|
|
<template slot-scope="scope">
|
|
<template v-for="item in scope.row.correspondingOpction">
|
|
<el-select v-if="
|
|
item.itemType == 'select' ||
|
|
item.itemType == 'radio' ||
|
|
item.itemType == 'checkbox'
|
|
" v-model.trim="scope.row.colVal" placeholder="请选择" clearable>
|
|
<el-option v-for="items in item.options" :label="items.label" :value="items.value"
|
|
:key="items.label">
|
|
</el-option>
|
|
</el-select>
|
|
<el-input v-else-if="
|
|
item.itemType === 'input' || item.itemType === 'textarea'
|
|
" v-model.trim="scope.row.colVal" placeholder="请输入" clearable>
|
|
</el-input>
|
|
<el-input-number v-else-if="item.itemType === 'inputNum'" class="item_width_2"
|
|
v-model.trim="scope.row.colVal" :min="0" size="mini" label="请输入"></el-input-number>
|
|
<el-date-picker v-else-if="
|
|
item.itemType === 'datepicker' || item.itemType === 'date'
|
|
" v-model.trim="scope.row.colVal" class="item_width_2" type="datetime"
|
|
value-format="yyyy-MM-dd HH:mm:ss" value="yyyy-MM-dd HH:mm:ss" placeholder="开始时间">
|
|
</el-date-picker>
|
|
<el-input v-else class="item_width_2" size="mini" placeholder="请输入"
|
|
v-model.trim="scope.row.colVal">
|
|
</el-input>
|
|
</template>
|
|
</template>
|
|
</el-table-column>
|
|
<el-table-column label="条件关系" align="center" width="120">
|
|
<template slot-scope="scope" v-if="scope.$index != tableData.length - 1">
|
|
<el-select v-model.trim="scope.row.nextLogicalRel" placeholder="请选择" clearable>
|
|
<el-option v-for="item in nextLogicalRelOpction" :label="item.label" :value="item.value"
|
|
:key="item.value">
|
|
</el-option>
|
|
</el-select>
|
|
</template>
|
|
</el-table-column>
|
|
<el-table-column fixed="right" label="操作" align="center" width="120">
|
|
<template slot-scope="scope">
|
|
<el-button type="primary" @click="handleClickAddRow" v-if="scope.$index == tableData.length - 1"
|
|
size="small" icon="el-icon-plus" circle></el-button>
|
|
<el-button type="danger" @click="handleClickDelete(scope.$index)" v-if="
|
|
scope.$index != tableData.length - 1 ||
|
|
(tableData.length - 1 >= 1 && scope.$index != '0')
|
|
" size="small" icon="el-icon-minus" circle>
|
|
</el-button>
|
|
</template>
|
|
</el-table-column>
|
|
</el-table>
|
|
</el-tab-pane>
|
|
<el-tab-pane label="使用已有标签" name="history">
|
|
<el-row>
|
|
<el-col :span="18">
|
|
使用常用标签:
|
|
</el-col>
|
|
<el-col :span="6">
|
|
<el-autocomplete v-model.trim="tagForm.tagName" value-key="tagName" :fetch-suggestions="querySearchAsync"
|
|
placeholder="请输入内容进行搜索" @select="handleSelect"></el-autocomplete>
|
|
</el-col>
|
|
</el-row>
|
|
<el-row type="flex" style="flex-wrap: wrap;">
|
|
<el-col :span="5" style="margin-right: 10px;" v-for="(item, index) in tagList" :key="index">
|
|
<el-button :class="{ highlight: item.isHighlighted }" type="primary" plain round
|
|
style="white-space: nowrap;text-overflow: ellipsis;word-wrap: normal; width: 100%;" size="small"
|
|
@click="handelClickTag(item)">
|
|
{{ item.tagName }}
|
|
</el-button>
|
|
</el-col>
|
|
</el-row>
|
|
<el-table border :data="tableData" style="width: 100%" height="200">
|
|
<el-table-column label="选择数据源" align="center" width="120">
|
|
<template slot-scope="scope">
|
|
<el-select v-model.trim="scope.row.dataSource" placeholder="请选择"
|
|
@change="handleChangeSource(scope.row, scope.$index)" disabled>
|
|
<el-option v-for="item in dataSourceOpction" :label="item.label" :value="item.value"
|
|
:key="item.value">
|
|
</el-option>
|
|
</el-select>
|
|
</template>
|
|
</el-table-column>
|
|
<el-table-column label="字段类别" align="center" width="120">
|
|
<template slot-scope="scope" v-if="scope.row.dataSource == 'resi' || scope.row.dataSource == 'house'">
|
|
<el-select v-model.trim="scope.row.itemGroupId" placeholder="请选择" disabled
|
|
@change="handleChangeFieldsType(scope.row, scope.$index)">
|
|
<el-option v-for="item in scope.row.itemGroupIdOpction" :label="item.label" :value="item.id"
|
|
:key="item.id">
|
|
</el-option>
|
|
</el-select>
|
|
</template>
|
|
</el-table-column>
|
|
<el-table-column label="字段名称" align="center" width="120">
|
|
<template slot-scope="scope">
|
|
<el-select v-model.trim="scope.row.itemId" placeholder="请选择"
|
|
@change="handleChangeFieldsName(scope.row, scope.$index)"
|
|
@clear="handleClearItemId(scope.row, scope.$index)" disabled>
|
|
<el-option v-for="item in scope.row.itemIdOpction" :label="item.label" :value="scope.row.dataSource == 'resi' || scope.row.dataSource == 'house' ? item.itemId : item.colKey
|
|
"
|
|
:key="scope.row.dataSource == 'resi' || scope.row.dataSource == 'house' ? item.itemId : item.colKey"
|
|
disabled>
|
|
</el-option>
|
|
</el-select>
|
|
</template>
|
|
</el-table-column>
|
|
<el-table-column label="比较符" align="center" width="120">
|
|
<template slot-scope="scope">
|
|
<el-select v-model.trim="scope.row.queryType" placeholder="请选择" disabled>
|
|
<el-option v-for="item in queryTypeOpction" :label="item.label" :value="item.value"
|
|
:key="item.value">
|
|
</el-option>
|
|
</el-select>
|
|
</template>
|
|
</el-table-column>
|
|
<el-table-column label="对应值" align="center" width="120">
|
|
<template slot-scope="scope">
|
|
<template v-for="item in scope.row.correspondingOpction">
|
|
<el-select v-if="
|
|
item.itemType == 'select' ||
|
|
item.itemType == 'radio' ||
|
|
item.itemType == 'checkbox'
|
|
" v-model.trim="scope.row.colVal" placeholder="请选择" disabled>
|
|
<el-option v-for="items in item.options" :label="items.label" :value="items.value"
|
|
:key="items.label">
|
|
</el-option>
|
|
</el-select>
|
|
<el-input v-else-if="
|
|
item.itemType === 'input' || item.itemType === 'textarea'
|
|
" v-model.trim="scope.row.colVal" placeholder="请输入" disabled>
|
|
</el-input>
|
|
<el-input-number v-else-if="item.itemType === 'inputNum'" class="item_width_2"
|
|
v-model.trim="scope.row.colVal" :min="0" size="mini" label="请输入" disabled></el-input-number>
|
|
<el-date-picker v-else-if="
|
|
item.itemType === 'datepicker' || item.itemType === 'date'
|
|
" v-model.trim="scope.row.colVal" class="item_width_2" type="datetime"
|
|
value-format="yyyy-MM-dd HH:mm:ss" value="yyyy-MM-dd HH:mm:ss" placeholder="开始时间" disabled>
|
|
</el-date-picker>
|
|
<el-input v-else class="item_width_2" size="mini" placeholder="请输入"
|
|
v-model.trim="scope.row.colVal" disabled>
|
|
</el-input>
|
|
</template>
|
|
</template>
|
|
</el-table-column>
|
|
<el-table-column label="条件关系" align="center" width="120">
|
|
<template slot-scope="scope" v-if="scope.$index != tableData.length - 1">
|
|
<el-select v-model.trim="scope.row.nextLogicalRel" placeholder="请选择" clearable disabled>
|
|
<el-option v-for="item in nextLogicalRelOpction" :label="item.label" :value="item.value"
|
|
:key="item.value">
|
|
</el-option>
|
|
</el-select>
|
|
</template>
|
|
</el-table-column>
|
|
|
|
</el-table>
|
|
</el-tab-pane>
|
|
<el-tab-pane label="管理我的标签" name="tagManage">
|
|
<el-tag
|
|
v-for="tag in myLabelList"
|
|
:key="tag.name"
|
|
closable
|
|
:type="tag.type" @close="handelRemoveTag(tag)" style="margin-right: 10px;">
|
|
{{tag.tagName}}
|
|
</el-tag>
|
|
</el-tab-pane>
|
|
</el-tabs>
|
|
<el-form :model="tagForm" :rules="tagRule" label-width="100px" style="margin-top: 16px;">
|
|
<el-form-item label="标签名称" prop="tagName" v-if="activeName === 'add'">
|
|
<el-input v-model.trim="tagForm.tagName" style="width: 200px;" size="small"></el-input>
|
|
</el-form-item>
|
|
<!-- <el-form-item label="标签名称" label-width="120px" prop="tagName" v-if="activeName === 'history'">
|
|
<el-autocomplete v-model.trim="tagForm.tagName" value-key="tagName" :fetch-suggestions="querySearchAsync"
|
|
placeholder="请输入内容进行搜索" @select="handleSelect"></el-autocomplete>
|
|
</el-form-item> -->
|
|
</el-form>
|
|
</el-main>
|
|
<el-footer>
|
|
<el-col :span="24" align="right">
|
|
<el-button style="margin-left: 10px" type="default" @click="handleTagsCloseAnClear">清除</el-button>
|
|
<el-button style="margin-left: 20px" type="primary" @click="handleTagsComfirm">确定</el-button>
|
|
</el-col>
|
|
</el-footer>
|
|
</el-container>
|
|
<el-container v-else>
|
|
<el-footer>
|
|
<el-main>
|
|
<div>标签名称:{{this.tagForm.tagName}}</div>
|
|
<el-table border :data="tableData" style="width: 100%" height="200">
|
|
<el-table-column label="选择数据源" align="center" width="120">
|
|
<template slot-scope="scope">
|
|
<el-select v-model.trim="scope.row.dataSource" placeholder="请选择"
|
|
@change="handleChangeSource(scope.row, scope.$index)" disabled>
|
|
<el-option v-for="item in dataSourceOpction" :label="item.label" :value="item.value"
|
|
:key="item.value">
|
|
</el-option>
|
|
</el-select>
|
|
</template>
|
|
</el-table-column>
|
|
<el-table-column label="字段类别" align="center" >
|
|
<template slot-scope="scope" v-if="scope.row.dataSource == 'resi' || scope.row.dataSource == 'house'">
|
|
<el-select v-model.trim="scope.row.itemGroupId" placeholder="请选择" disabled
|
|
@change="handleChangeFieldsType(scope.row, scope.$index)">
|
|
<el-option v-for="item in scope.row.itemGroupIdOpction" :label="item.label" :value="item.id"
|
|
:key="item.id">
|
|
</el-option>
|
|
</el-select>
|
|
</template>
|
|
</el-table-column>
|
|
<el-table-column label="字段名称" align="center" >
|
|
<template slot-scope="scope">
|
|
<el-select v-model.trim="scope.row.itemId" placeholder="请选择"
|
|
@change="handleChangeFieldsName(scope.row, scope.$index)"
|
|
@clear="handleClearItemId(scope.row, scope.$index)" disabled>
|
|
<el-option v-for="item in scope.row.itemIdOpction" :label="item.label" :value="scope.row.dataSource == 'resi' || scope.row.dataSource == 'house' ? item.itemId : item.colKey
|
|
"
|
|
:key="scope.row.dataSource == 'resi' || scope.row.dataSource == 'house' ? item.itemId : item.colKey"
|
|
disabled>
|
|
</el-option>
|
|
</el-select>
|
|
</template>
|
|
</el-table-column>
|
|
<el-table-column label="比较符" align="center" width="120">
|
|
<template slot-scope="scope">
|
|
<el-select v-model.trim="scope.row.queryType" placeholder="请选择" disabled>
|
|
<el-option v-for="item in queryTypeOpction" :label="item.label" :value="item.value"
|
|
:key="item.value">
|
|
</el-option>
|
|
</el-select>
|
|
</template>
|
|
</el-table-column>
|
|
<el-table-column label="对应值" align="center" width="120">
|
|
<template slot-scope="scope">
|
|
<template v-for="item in scope.row.correspondingOpction">
|
|
<el-select v-if="
|
|
item.itemType == 'select' ||
|
|
item.itemType == 'radio' ||
|
|
item.itemType == 'checkbox'
|
|
" v-model.trim="scope.row.colVal" placeholder="请选择" disabled>
|
|
<el-option v-for="items in item.options" :label="items.label" :value="items.value"
|
|
:key="items.label">
|
|
</el-option>
|
|
</el-select>
|
|
<el-input v-else-if="
|
|
item.itemType === 'input' || item.itemType === 'textarea'
|
|
" v-model.trim="scope.row.colVal" placeholder="请输入" disabled>
|
|
</el-input>
|
|
<el-input-number v-else-if="item.itemType === 'inputNum'" class="item_width_2"
|
|
v-model.trim="scope.row.colVal" :min="0" size="mini" label="请输入" disabled></el-input-number>
|
|
<el-date-picker v-else-if="
|
|
item.itemType === 'datepicker' || item.itemType === 'date'
|
|
" v-model.trim="scope.row.colVal" class="item_width_2" type="datetime"
|
|
value-format="yyyy-MM-dd HH:mm:ss" value="yyyy-MM-dd HH:mm:ss" placeholder="开始时间" disabled>
|
|
</el-date-picker>
|
|
<el-input v-else class="item_width_2" size="mini" placeholder="请输入"
|
|
v-model.trim="scope.row.colVal" disabled>
|
|
</el-input>
|
|
</template>
|
|
</template>
|
|
</el-table-column>
|
|
<el-table-column label="条件关系" align="center" width="120">
|
|
<template slot-scope="scope" v-if="scope.$index != tableData.length - 1">
|
|
<el-select v-model.trim="scope.row.nextLogicalRel" placeholder="请选择" clearable disabled>
|
|
<el-option v-for="item in nextLogicalRelOpction" :label="item.label" :value="item.value"
|
|
:key="item.value">
|
|
</el-option>
|
|
</el-select>
|
|
</template>
|
|
</el-table-column>
|
|
</el-table>
|
|
</el-main>
|
|
<el-col :span="24" align="right">
|
|
<el-button style="margin-left: 10px" type="default" @click="handleTagsCloseAnClear">关闭</el-button>
|
|
</el-col>
|
|
</el-footer>
|
|
</el-container>
|
|
</el-drawer>
|
|
</div>
|
|
</template>
|
|
<script>
|
|
import excelUploadData from './excel-upload-data.vue';
|
|
import LuckyExcel from 'luckyexcel';
|
|
import options from "@/utils/luckysheetConfig.js";
|
|
import { mapGetters } from 'vuex'
|
|
import { requestPost, requestGet } from "@/js/dai/request";
|
|
import nextTick from "dai-js/tools/nextTick";
|
|
import { exportSheetExcel } from "@/utils/export";
|
|
import resiSearch from "./export-search.vue";
|
|
export default {
|
|
data() {
|
|
return {
|
|
uploadUlr: window.SITE_CONFIG["apiURL"] +
|
|
"/oss/file/upload",
|
|
fullscreenLoading: false,
|
|
showUploadData: false,
|
|
menuList: [],
|
|
menuActive: 0,
|
|
socket: null,
|
|
currentTable: null,
|
|
currentId: '',
|
|
btnLoading: false,
|
|
infoObj: {},
|
|
showCondition: false,
|
|
showTemplate: false,
|
|
dataForm: {
|
|
reportType: 1,//报表类型。0:数据列表,1:统计数据
|
|
reportName: '',//报表名称
|
|
workbookId: '',
|
|
formCode: "",
|
|
columnsJson: [],
|
|
searchForm: {},
|
|
moduleUrl:''
|
|
},
|
|
dataRule: {
|
|
reportName: [{ required: true, message: '报表名称长度5-10个字符', trigger: 'blur',max:30,min:5 }],
|
|
moduleUrl:[{ required: true, message: this.$t('validate.required'), trigger: 'blur' }]
|
|
|
|
},
|
|
tagRule: {
|
|
tagName: [{ required: true, message: this.$t('validate.required'), trigger: 'blur' }]
|
|
},
|
|
tagForm: {
|
|
tagName: '',
|
|
tagId: ''
|
|
},
|
|
exportJson: null,
|
|
importType: '',//template 上传统计模板 list 列表导出
|
|
drawer: false,
|
|
direction: 'rtl',
|
|
activeName: 'add', //add 新建统计条件 history 使用已有标签
|
|
radio1: '1',
|
|
radio2: '1',
|
|
queryTypeOpction: [],
|
|
tableData: [
|
|
{
|
|
dataSource: "", //数据源
|
|
itemGroupId: "", //字段类别
|
|
itemId: "", //字段名称
|
|
queryType: "", //比较符
|
|
colVal: "", //对应值
|
|
nextLogicalRel: "", //条件关系,
|
|
tableName: "", //数据库表名
|
|
colKey: "",
|
|
itemIdOpction: [],
|
|
itemGroupIdOpction: [],
|
|
correspondingOpction: [],
|
|
},
|
|
],
|
|
nextLogicalRelOpction: [
|
|
{ label: "并且", value: "and" },
|
|
{ label: "或者", value: "or" },
|
|
],
|
|
dataSourceOpction: [
|
|
{ label: "人员信息", value: "resi" },
|
|
{ label: "房屋信息", value: "house" },
|
|
{ label: "统计信息", value: "stat" },
|
|
],
|
|
selectedCell: '',
|
|
selectedCellNumberType: [],
|
|
statisticsLoading: false,
|
|
tagList: [],
|
|
searchList: [],
|
|
myLabelList:[],
|
|
showConditionDetailsDialog:false,
|
|
luckysheetLoading:false,
|
|
reportId:'',
|
|
fileName:''
|
|
};
|
|
},
|
|
props: {
|
|
pageType: {
|
|
type: String,
|
|
default: ''
|
|
},
|
|
infoIds: {
|
|
type: Object,
|
|
default: () => { }
|
|
}
|
|
},
|
|
computed: {
|
|
tableHeight() {
|
|
return (this.clientHeight - 140) + 'px'
|
|
},
|
|
...mapGetters(['clientHeight', 'resolution']),
|
|
},
|
|
created() { },
|
|
watch: {},
|
|
async mounted() {
|
|
this.reportId = this.infoIds.id
|
|
await this.getLabelList();
|
|
this.$nextTick(async () => {
|
|
if (this.pageType === 'info') {
|
|
this.luckysheetLoading = true;
|
|
await this.getSheetList()
|
|
this.loadWorkBook()
|
|
await nextTick(500)
|
|
if (this.infoObj.reportType === 0) {
|
|
let heading = this.infoObj.columnsJson[0].children.map(item => ({ label: item.label }))
|
|
for (let i in heading) {
|
|
luckysheet.setCellValue(0, i, heading[i].label)
|
|
}
|
|
let list = await this.getListData(this.reportId);
|
|
let newArrar = luckysheet.getAllSheets();
|
|
this.currentTable = newArrar.filter(item => item.status == '1');
|
|
if(list){
|
|
if(this.currentTable[0].data.length <= list.length){
|
|
luckysheet.insertRow(this.currentTable[0].data.length, { number: list.length - this.currentTable[0].data.length + 5 });
|
|
}else if(list.length !== 0 && this.currentTable[0].data.length !== 1){
|
|
luckysheet.deleteRow(list.length, this.currentTable[0].data.length )
|
|
}
|
|
}else{
|
|
if(this.currentTable[0].data.length !== 1){
|
|
luckysheet.deleteRow(1, this.currentTable[0].data.length)
|
|
}else{
|
|
return
|
|
}
|
|
}
|
|
await nextTick(500)
|
|
let newArray = list.map(obj => {
|
|
return Object.keys(obj).map(key => {
|
|
return { m: obj[key], "ct": { "fa": "General", "t": "g" }, v: obj[key] };
|
|
});
|
|
});
|
|
let bottomRightCorner = this.numberToLetter(Object.keys(list[0]).length)//选区右下角数字
|
|
// 只有一条数据问题解决,luckysheet源码有问题先这样搞吧
|
|
if(list.length === 1){
|
|
for(let i in list[0]){
|
|
luckysheet.setCellValue(1,i-1,list[0][i])
|
|
}
|
|
}else if(list.length > 1){
|
|
luckysheet.setRangeValue(newArray, {
|
|
range: `A2:${bottomRightCorner}${list.length}`,
|
|
})
|
|
}
|
|
this.luckysheetLoading = false;
|
|
} else {
|
|
this.loadWorkBook(this.infoObj.workbookId)
|
|
await nextTick(500)
|
|
this.allReportValue()
|
|
}
|
|
} else {
|
|
this.loadWorkBook()
|
|
await nextTick(500)
|
|
let newArrar = luckysheet.getAllSheets();
|
|
this.currentTable = newArrar.filter(item => item.status == '1');
|
|
luckysheet.deleteRow(1, this.currentTable[0].data.length );
|
|
for (let i in this.currentTable[0].data[0]) {
|
|
luckysheet.setCellValue(0, i, '')
|
|
}
|
|
}
|
|
})
|
|
},
|
|
methods: {
|
|
removeFile() {
|
|
this.dataForm.moduleUrl = '';
|
|
this.fileName = '';
|
|
},
|
|
async handleClickInspect() {
|
|
// 获取celldata并转换为list
|
|
const list = luckysheet.getAllSheets()[0].celldata.map(item => ({
|
|
r: item.r,
|
|
c: item.c,
|
|
v: item.v.v || ''
|
|
}));
|
|
// 发送请求获取异常数据
|
|
let { data, code, msg } = await requestPost('/actual/base/intelligentImportData/checkData', list);
|
|
if (code === 0) {
|
|
if (data && data.length > 0) {
|
|
for (const { r, c } of data) {
|
|
luckysheet.setCellFormat(r, c, 'bg', '#f5504a');
|
|
}
|
|
const findArr = this.findUniqueElements(luckysheet.getAllSheets()[0].celldata, data);
|
|
findArr.forEach(({ r, c, v }) => {
|
|
if (v.bg === "#f5504a") {
|
|
luckysheet.setCellFormat(r, c, 'bg', '#ffffff');
|
|
}
|
|
});
|
|
} else {
|
|
console.log(luckysheet.getAllSheets()[0].celldata);
|
|
luckysheet.getAllSheets()[0].celldata.forEach(item=>{
|
|
if(item.v.bg==="#f5504a"){
|
|
luckysheet.setCellFormat(item.r, item.c, 'bg', '#ffffff');
|
|
}
|
|
})
|
|
this.$message.success('没有找到异常');
|
|
}
|
|
}
|
|
},
|
|
findUniqueElements(A, B) {
|
|
// 创建B中r和c组合的键集合
|
|
const bCombinations = new Set(B.map(item => `${item.r},${item.c}`));
|
|
// 过滤A中不存在于B的组合
|
|
return A.filter(item => !bCombinations.has(`${item.r},${item.c}`));
|
|
},
|
|
async handelRemoveTag(row){
|
|
const url = `/governance/resiSearchTag/deleteResiSearchTag/${row.tagId}`;
|
|
let { code, msg } = await requestPost(url);
|
|
if (code == 0) {
|
|
this.$message.success("删除成功");
|
|
this.getLabelList()
|
|
} else {
|
|
this.$message.error(msg);
|
|
}
|
|
},
|
|
async allReportValue() {
|
|
let url = '/actual/base/intellgentizeReport/calculateStatsResult4Report'
|
|
const { data, code, msg } = await requestGet(url, { reportId: this.reportId })
|
|
if (code === 0) {
|
|
for (let key in data) {
|
|
const [col, row] = key.match(/^([A-Z]+)(\d+)$/).slice(1);
|
|
let col1 = this.lettersToNumber(col)
|
|
luckysheet.setCellValue(row - 1,col1 , data[key])
|
|
}
|
|
this.luckysheetLoading = false;
|
|
}else{
|
|
this.luckysheetLoading = false;
|
|
}
|
|
},
|
|
lettersToNumber(str) {
|
|
let result = 0;
|
|
for (let i = 0; i < str.length; i++) {
|
|
result = result * 26 + (str.charCodeAt(i) - 65);
|
|
// charCodeAt(i) - 65:计算字母的数值,例如 A -> 0, B -> 1
|
|
}
|
|
return result;
|
|
},
|
|
|
|
async initForm(type, row) {
|
|
if (type == "view") {
|
|
await this.getFormEdit(row.tagId);
|
|
this.tagForm.tagName = row.tagName;
|
|
} else if (type == "edit") {
|
|
await this.getFormEdit(row.tagId);
|
|
}
|
|
this.tagForm.tagId = row.tagId;
|
|
for (let i in this.tableData) {
|
|
await this.handleChangeSource(this.tableData[i], [i], type, true);
|
|
await this.handleChangeFieldsType(this.tableData[i], [i], type, true);
|
|
await this.handleChangeFieldsName(this.tableData[i], [i], type, true);
|
|
}
|
|
},
|
|
async getFormEdit(id) {
|
|
const url = `/governance/resiSearchTag/getResiSearchTagDetail?tagId=${id}`;
|
|
let { code, msg, data } = await requestGet(url);
|
|
if (code == 0) {
|
|
this.tableData = data.rules;
|
|
} else if (code >= 8000) {
|
|
this.$message.error(msg);
|
|
}
|
|
},
|
|
handelClickTag(item) {
|
|
this.tagList.forEach(tag => {
|
|
tag.isHighlighted = false;
|
|
});
|
|
item.isHighlighted = true;
|
|
this.initForm("view", item);
|
|
},
|
|
async fetchData(url, params) {
|
|
try {
|
|
let { data, msg, code } = await requestPost(url, params);
|
|
if (code === 0) {
|
|
return data.list;
|
|
} else {
|
|
this.$message.error(msg);
|
|
return null;
|
|
}
|
|
} catch (error) {
|
|
this.$message.error("请求失败");
|
|
return null;
|
|
}
|
|
},
|
|
async getLabelList() {
|
|
const url1 = "/governance/resiSearchTag/listResiSearchTags";
|
|
const params1 = {
|
|
pageSize: 99,
|
|
source: 1,
|
|
};
|
|
const url2 = "/governance/resiSearchTag/listResiSearchTags";
|
|
const params2 = {
|
|
pageSize: 99,
|
|
source: 1,
|
|
creatorId:this.$store.state.user.id
|
|
};
|
|
|
|
this.searchList = await this.fetchData(url1, params1);
|
|
this.myLabelList = await this.fetchData(url2, params2);
|
|
},
|
|
|
|
querySearchAsync(val, cb) {
|
|
var searchList = this.searchList;
|
|
var results = val
|
|
? searchList.filter(this.createStateFilter(val))
|
|
: searchList;
|
|
clearTimeout(this.timeout);
|
|
this.timeout = setTimeout(() => {
|
|
cb(results);
|
|
}, 3000 * Math.random());
|
|
},
|
|
handleTagsComfirm() {
|
|
if (this.activeName === 'add') {
|
|
this.addSubmit()
|
|
} else {
|
|
this.saveConditions4Cell()
|
|
}
|
|
},
|
|
handleTagsCloseAnClear() {
|
|
if(!this.showConditionDetailsDialog){
|
|
this.$confirm('确认清空条件?')
|
|
.then(_ => {
|
|
this.removeConditions4Cell()
|
|
this.drawer = false;
|
|
})
|
|
.catch(_ => { });
|
|
}else{
|
|
this.drawer = false;
|
|
}
|
|
this.showConditionDetailsDialog = false;
|
|
this.restDrawerData()
|
|
},
|
|
async removeConditions4Cell() {
|
|
let url = '/actual/base/intellgentizeReport/removeConditions4Cell'
|
|
const parm = {
|
|
axis: this.selectedCell,
|
|
reportId: this.reportId
|
|
}
|
|
const { code } = await requestPost(url, parm)
|
|
if (code === 0) {
|
|
$('#luckysheet-rich-text-editor').text(' ');
|
|
}
|
|
},
|
|
async addSubmit() {
|
|
var url = "";
|
|
var params = {};
|
|
url = "/governance/resiSearchTag/addResiSearchTag";
|
|
params = {
|
|
tagName: this.tagForm.tagName,
|
|
rules: this.tableData,
|
|
source: 1
|
|
};
|
|
const { data, msg, code } = await requestPost(url, params);
|
|
if (code == 0) {
|
|
this.tagForm.tagId = data.id;
|
|
this.saveConditions4Cell()
|
|
} else if (code >= 8000) {
|
|
this.$message.error(msg);
|
|
}
|
|
},
|
|
async saveConditions4Cell() {
|
|
this.statisticsLoading = true;
|
|
let url = '/actual/base/intellgentizeReport/saveConditions4Cell';
|
|
let parm = {
|
|
axis: this.selectedCell,
|
|
tagId: this.tagForm.tagId,
|
|
reportId: this.reportId
|
|
}
|
|
const { data, code, msg } = await requestPost(url, parm)
|
|
if (code === 0) {
|
|
this.statisticsLoading = false;
|
|
this.drawer = false;
|
|
$('#luckysheet-rich-text-editor').text(data);
|
|
}else{
|
|
this.statisticsLoading = false;
|
|
this.$message.error(msg)
|
|
}
|
|
},
|
|
// 获取已选择条件
|
|
async getConditions4Cell(type) {
|
|
let url = '/actual/base/intellgentizeReport/getConditions4Cell';
|
|
let parm = {
|
|
axis: this.selectedCell,
|
|
reportId: this.reportId
|
|
}
|
|
const { data, code, msg } = await requestGet(url, parm)
|
|
if (code === 0) {
|
|
this.initForm(type,data)
|
|
}
|
|
},
|
|
|
|
hadeleClearForm(row, index) {
|
|
let obj = {};
|
|
obj = {
|
|
dataSource: row.dataSource ? row.dataSource : "",
|
|
itemId: row.itemId ? row.itemId : "",
|
|
queryType: row.queryType ? row.queryType : "",
|
|
colVal: row.colVal ? row.colVal : "",
|
|
colKey: row.colKey ? row.colKey : "",
|
|
nextLogicalRel: row.nextLogicalRel ? row.nextLogicalRel : "",
|
|
tableName: row.tableName ? row.tableName : "",
|
|
itemGroupId: row.itemGroupId ? row.itemGroupId : "",
|
|
itemIdOpction: row.itemIdOpction ? row.itemIdOpction : [],
|
|
itemGroupIdOpction: row.itemGroupIdOpction
|
|
? row.itemGroupIdOpction
|
|
: [],
|
|
};
|
|
this.$set(this.tableData, index, obj);
|
|
},
|
|
restDrawerData(){
|
|
this.tagForm.tagName = '';
|
|
this.tagForm.tagId = '';
|
|
this.tableData = [
|
|
{
|
|
dataSource: "", //数据源
|
|
itemGroupId: "", //字段类别
|
|
itemId: "", //字段名称
|
|
queryType: "", //比较符
|
|
colVal: "", //对应值
|
|
nextLogicalRel: "", //条件关系,
|
|
tableName: "", //数据库表名
|
|
colKey: "",
|
|
itemIdOpction: [],
|
|
itemGroupIdOpction: [],
|
|
correspondingOpction: [],
|
|
}
|
|
];
|
|
},
|
|
handleClose(done) {
|
|
this.restDrawerData()
|
|
done();
|
|
|
|
},
|
|
// 删除一行
|
|
handleClickDelete(index) {
|
|
this.tableData.splice(index, 1);
|
|
},
|
|
handleClickAddRow() {
|
|
if (this.tableData === undefined) this.tableData = [];
|
|
let obj = {};
|
|
obj.dataSource = "";
|
|
obj.itemGroupId = "";
|
|
obj.itemId = "";
|
|
obj.queryType = "";
|
|
obj.colVal = "";
|
|
obj.nextLogicalRel = "";
|
|
obj.itemIdOpction = [];
|
|
this.tableData.push(obj);
|
|
},
|
|
// 字段类别修改
|
|
async handleChangeFieldsType(row, index, type, state) {
|
|
|
|
// console.log(row, index, "字段类别row");
|
|
if (row.dataSource == "stat") return;
|
|
const url = "/oper/customize/icformitem/getItemListV2";
|
|
let params = {
|
|
groupId: row.itemGroupId,
|
|
policyFlag: "1"
|
|
};
|
|
this.hadeleClearForm(this.tableData[index], index);
|
|
if (!type) {
|
|
this.tableData[index].itemId = "";
|
|
this.tableData[index].colKey = "";
|
|
this.tableData[index].colVal = "";
|
|
this.tableData[index].nextLogicalRel = "";
|
|
this.tableData[index].queryType = "";
|
|
this.tableData[index].itemIdOpction = [];
|
|
}
|
|
let { data, code, msg } = await requestPost(url, params);
|
|
if (code == 0) {
|
|
this.$set(this.tableData[index], "itemIdOpction", data);
|
|
} else {
|
|
this.$message.error(msg);
|
|
}
|
|
},
|
|
// 字段名称修改
|
|
async handleChangeFieldsName(row, index, type, state) {
|
|
|
|
var arr = [];
|
|
// 人的信息中colKey的字段是columnName要做一下判断
|
|
if (row.dataSource == "stat") {
|
|
arr = row.itemIdOpction.filter((item) => item.colKey == row.itemId);
|
|
this.tableData[index].tableName = arr[0].tableName;
|
|
this.tableData[index].colKey = arr[0].colKey;
|
|
if (!type) {
|
|
this.tableData[index].colVal = "";
|
|
this.tableData[index].nextLogicalRel = "";
|
|
this.tableData[index].queryType = "";
|
|
}
|
|
// this.tableData[index].colVal = ''
|
|
// this.tableData[index].queryType = ''
|
|
} else if ((row.dataSource == "resi" || row.dataSource == "house") && row.itemId != "") {
|
|
arr = row.itemIdOpction.filter((item) => item.itemId == row.itemId);
|
|
this.tableData[index].tableName = arr[0].tableName;
|
|
this.tableData[index].colKey = arr[0].columnName;
|
|
if (!type) {
|
|
this.tableData[index].colVal = "";
|
|
this.tableData[index].nextLogicalRel = "";
|
|
this.tableData[index].queryType = "";
|
|
}
|
|
// this.tableData[index].colVal = ''
|
|
// this.tableData[index].queryType = ''
|
|
}
|
|
if (row.itemId == "") return;
|
|
// 列表对应值的option有的是通过接口获取的就需要再通过optionSourceType判断下
|
|
if (arr[0].optionSourceType == "remote") {
|
|
let url = "";
|
|
let params = {};
|
|
url = arr[0].optionSourceValue;
|
|
if (url == '/gov/org/customergrid/gridoption') {
|
|
params = {
|
|
agencyId: this.$store.state.user.agencyId,
|
|
}
|
|
} else {
|
|
url = "/sys/dict/data/dictlist";
|
|
params = {
|
|
dictType: arr[0].optionSourceValue,
|
|
}
|
|
}
|
|
const { data, code, msg } = await requestPost(url, params);
|
|
if (code == 0) {
|
|
arr[0].options = data;
|
|
this.$set(this.tableData[index], "correspondingOpction", arr);
|
|
} else {
|
|
this.$message.error(msg);
|
|
}
|
|
} else {
|
|
this.$set(this.tableData[index], "correspondingOpction", arr);
|
|
}
|
|
},
|
|
async handleChangeSource(row, index, type, state) {
|
|
|
|
if (row.dataSource == "resi" || row.dataSource == "house") {
|
|
let url = "/oper/customize/icformitemgroup/list";
|
|
let params = {
|
|
formCode: row.dataSource == 'resi' ? "resident_base_info" : 'community_info',
|
|
};
|
|
let { data, code, msg } = await requestPost(url, params);
|
|
if (code == 0) {
|
|
this.$set(this.tableData[index], "itemGroupIdOpction", data);
|
|
} else {
|
|
this.$message.error(msg);
|
|
}
|
|
this.hadeleClearForm(this.tableData[index], index);
|
|
if (!type) {
|
|
this.tableData[index].itemGroupId = "";
|
|
this.tableData[index].itemId = "";
|
|
this.tableData[index].colKey = "";
|
|
this.tableData[index].colVal = "";
|
|
this.tableData[index].nextLogicalRel = "";
|
|
this.tableData[index].queryType = "";
|
|
this.tableData[index].itemIdOpction = [];
|
|
}
|
|
} else if (row.dataSource == "stat") {
|
|
let url = "/heart/policy/item-list/stat";
|
|
let params = {};
|
|
let { data, code, msg } = await requestPost(url, params);
|
|
if (code == 0) {
|
|
this.tableData[index].itemIdOpction = data;
|
|
} else {
|
|
this.$message.error(msg);
|
|
}
|
|
this.hadeleClearForm(this.tableData[index], index);
|
|
if (!type) {
|
|
this.tableData[index].itemGroupId = "";
|
|
this.tableData[index].itemId = "";
|
|
this.tableData[index].colKey = "";
|
|
this.tableData[index].colVal = "";
|
|
this.tableData[index].nextLogicalRel = "";
|
|
this.tableData[index].queryType = "";
|
|
}
|
|
} else {
|
|
this.hadeleClearForm(this.tableData[index], index);
|
|
this.tableData[index].itemGroupId = "";
|
|
this.tableData[index].itemId = "";
|
|
this.tableData[index].colKey = "";
|
|
this.tableData[index].colVal = "";
|
|
this.tableData[index].nextLogicalRel = "";
|
|
this.tableData[index].queryType = "";
|
|
this.tableData[index].itemIdOpction = [];
|
|
}
|
|
this.getCompareList();
|
|
},
|
|
async getCompareList() {
|
|
const url = "/sys/dict/data/dictlist";
|
|
let params = {
|
|
dictType: "sql_query_type",
|
|
};
|
|
let { data, code, msg } = await requestPost(url, params);
|
|
if (code == 0) {
|
|
this.queryTypeOpction = data;
|
|
} else if (code >= 8000) {
|
|
this.$message.error(msg);
|
|
}
|
|
},
|
|
handleClearItemId(row, index) {
|
|
this.tableData[index].colVal = "";
|
|
this.tableData[index].queryType = "";
|
|
},
|
|
handleExcelSuccess(e) {
|
|
if (e.code === 0) {
|
|
this.dataForm.moduleUrl = e.data.url;
|
|
this.fullscreenLoading = false;
|
|
}
|
|
},
|
|
handleSaveTemplate(){
|
|
this.$refs['dataForm'].validate(valid=>{
|
|
if (!valid) {
|
|
return false
|
|
}
|
|
const newUrl = this.dataForm.moduleUrl.replace(
|
|
/^https:\/\/elink-esua-epdc\.oss-cn-qingdao\.aliyuncs\.com/,
|
|
`${location.origin}`
|
|
);
|
|
// this.urlToFile('http://localhost:9001/epmet-work-pc/test1.xlsx')
|
|
this.urlToFile(`${process.env.NODE_ENV === "development" ?'http://localhost:9001/epmet-work-pc/test1.xlsx':newUrl}`)
|
|
this.showTemplate = false;
|
|
})
|
|
},
|
|
handleCloseTemplate(){
|
|
this.$refs['dataForm'].resetFields();
|
|
this.showTemplate = false;
|
|
},
|
|
async urlToFile(url, fileName = 'file') {
|
|
try {
|
|
// 使用 fetch 获取文件数据
|
|
const response = await fetch(url);
|
|
// 检查请求是否成功
|
|
if (!response.ok) {
|
|
throw new Error(`HTTP error! status: ${response.status}`);
|
|
}
|
|
// 转换为 Blob 对象
|
|
const blob = await response.blob();
|
|
// 根据 Blob 创建 File 对象
|
|
const file = new File([blob], fileName, { type: 'excel/xlsx' });
|
|
|
|
this.uploadExcel(file)
|
|
} catch (error) {
|
|
console.error('Error fetching or converting file:', error);
|
|
throw error;
|
|
}
|
|
},
|
|
async uploadExcel(files) {
|
|
if (!files) return alert('没有文件等待导入');
|
|
let that = this
|
|
LuckyExcel.transformExcelToLucky(files, function (exportJson, luckysheetfile) {
|
|
if (exportJson.sheets == null || exportJson.sheets.length == 0) return alert('读取excel文件内容失败, 目前不支持XLS文件!');
|
|
window.luckysheet.destroy();
|
|
options.container = 'luckysheet-export'
|
|
options.loadUrl = ''
|
|
window.luckysheet.create({
|
|
...options,
|
|
data: exportJson.sheets,//暂时支持上传一个sheet页,因为插件bug有点多
|
|
title: exportJson.info.name,
|
|
hook: {
|
|
cellEditBefore: that.handleCellEditBefore,
|
|
cellUpdateBefore: that.handleCellUpdateBefore,
|
|
},
|
|
});
|
|
|
|
});
|
|
await nextTick(500)
|
|
await this.saveLuckysheetHead()
|
|
},
|
|
async handleSelect(item) {
|
|
item.isHighlighted = true;
|
|
this.tagList.unshift(item);
|
|
await this.initForm("edit", item);
|
|
},
|
|
handleCellEditBefore(e) {
|
|
if ((this.pageType === 'info' && this.infoObj.reportType === 1)|| (this.pageType === 'add'&& this.reportId && this.importType === 'template')) {
|
|
this.drawer = true;
|
|
let column = parseInt(e[0].column[0]) + 1, row = parseInt(e[0].row[0]) + 1;
|
|
this.selectedCellNumberType = [parseInt(e[0].row[0]), parseInt(e[0].column[0])]
|
|
this.selectedCell = this.numberToLetter(column) + row;
|
|
this.getFrequentlyTags();
|
|
if((this.$store.state.user.id === this.infoObj.creatorId) || this.importType === 'template'){
|
|
this.showConditionDetailsDialog = false;
|
|
let statisticalValue = luckysheet.getCellValue(row-1,column-1)
|
|
console.log(statisticalValue);
|
|
if(statisticalValue || statisticalValue === 0){
|
|
this.activeName = 'history';
|
|
this.getConditions4Cell('edit');
|
|
}
|
|
}else{
|
|
this.activeName = 'add';
|
|
this.showConditionDetailsDialog = true;
|
|
this.getConditions4Cell('view')
|
|
}
|
|
}
|
|
},
|
|
// 获取最近标签
|
|
async getFrequentlyTags() {
|
|
let url = '/actual/base/intellgentizeReport/listFrequentlyTags';
|
|
let parm = {
|
|
reportId: this.reportId
|
|
};
|
|
const { data, msg, code } = await requestGet(url, parm);
|
|
if (code === 0) {
|
|
const uniqueData = data.filter((item, index, array) =>
|
|
array.findIndex(i => i.tagId === item.tagId) === index
|
|
);
|
|
this.tagList = uniqueData;
|
|
}
|
|
},
|
|
|
|
handleCellUpdateBefore(r, c, value, isRefresh) {
|
|
this.selectedCell = "";
|
|
},
|
|
|
|
|
|
beforeExcelUpload(file) {
|
|
this.fullscreenLoading = true;
|
|
const isType = file.type === "application/vnd.ms-excel";
|
|
const isTypeComputer =
|
|
file.type === "application/vnd.openxmlformats-officedocument.spreadsheetml.sheet";
|
|
const fileType = isType || isTypeComputer;
|
|
const isLt1M = file.size / 1024 / 1024 < 10;
|
|
if (!fileType) {
|
|
this.$message.error("上传文件只能是xls/xlsx格式!");
|
|
}
|
|
|
|
if (!isLt1M) {
|
|
this.$message.error("上传文件大小不能超过 10MB!");
|
|
}
|
|
this.fileName = file.name
|
|
return fileType && isLt1M;
|
|
},
|
|
onClickShowCondition() {
|
|
this.showCondition = true;
|
|
},
|
|
async getSheetList() {
|
|
const { data, code } = await requestGet('/actual/base/intellgentizeReport/detail', { id: this.reportId })
|
|
if (code === 0) {
|
|
this.infoObj = data;
|
|
}
|
|
},
|
|
async handleClickExport() {
|
|
exportSheetExcel(luckysheet.getAllSheets(), '导出文件')
|
|
const {code} = await requestPost('/actual/base/intellgentizeReport/createExportRecord',{reportId:this.reportId})
|
|
if(code === 0){
|
|
this.$message.success('导出成功')
|
|
}
|
|
},
|
|
// 上传模板
|
|
async handleClickUploadTemplate() {
|
|
this.showTemplate = true;
|
|
this.importType = 'template'
|
|
},
|
|
|
|
onClickUplond() {
|
|
this.showUploadData = true;
|
|
let list = luckysheet.getAllSheets()
|
|
this.currentTable = list.filter(item => item.status == '1')
|
|
this.importType = 'list'
|
|
},
|
|
async handleUploadDataHide(val) {
|
|
this.luckysheetLoading = true;
|
|
const listData = await this.getListData(val.id)
|
|
luckysheet.insertRow(this.currentTable[0].data.length, 1)
|
|
this.showUploadData = false;
|
|
if (!listData) {
|
|
this.luckysheetLoading = false;
|
|
return;
|
|
}
|
|
luckysheet.insertRow(this.currentTable[0].data.length, { number: listData.length });
|
|
await nextTick(500)
|
|
let newArray = listData.map(obj => {
|
|
return Object.keys(obj).map(key => {
|
|
return { m: obj[key], "ct": { "fa": "General", "t": "g" }, v: obj[key] };
|
|
});
|
|
});
|
|
let bottomRightCorner = this.numberToLetter(Object.keys(listData[0]).length)//选区右下角数字
|
|
luckysheet.setRangeValue(newArray, {
|
|
range: `A2:${bottomRightCorner}${listData.length}`,
|
|
})
|
|
this.reportId = val.id;
|
|
this.infoObj.reportType = 0;
|
|
this.pageType = 'info';
|
|
this.getSheetList();
|
|
this.luckysheetLoading = false;
|
|
},
|
|
async saveLuckysheetHead(head) {
|
|
if (head && this.importType === 'list') {
|
|
let temp = head.map(item => item.children).flat();
|
|
for (let i in temp) {
|
|
luckysheet.setCellValue(0, i, temp[i].label)
|
|
}
|
|
}
|
|
let luckysheetJson = luckysheet.getAllSheets()
|
|
const { data, code, msg } = await requestPost(`/actual/base/luckySheet/workbook/createByJson?fileName=${this.dataForm.reportName}`, luckysheetJson)
|
|
if (code === 0) {
|
|
this.dataForm.workbookId = data.workbookId;
|
|
if (this.importType === 'template') {
|
|
this.createdReport()
|
|
}
|
|
} else {
|
|
console.log(msg);
|
|
}
|
|
},
|
|
async createdReport() {
|
|
const url = '/actual/base/intellgentizeReport/create'
|
|
let { data, code, msg } = await requestPost(url, this.dataForm)
|
|
if (code === 0) {
|
|
this.reportId = data;
|
|
} else {
|
|
console.log(msg);
|
|
}
|
|
},
|
|
async getListData(id) {
|
|
const { data, code } = await requestGet('/actual/base/intellgentizeReport/listDatasById', { id })
|
|
if (code === 0 && data.length>0) {
|
|
return data
|
|
}else{
|
|
this.luckysheetLoading = false;
|
|
}
|
|
},
|
|
// 数字转换对应顺序英文
|
|
numberToLetter(num) {
|
|
let letter = '';
|
|
while (num > 0) {
|
|
num -= 1; // 调整为从 0 开始(即 1 -> 'A',2 -> 'B',...)
|
|
letter = String.fromCharCode(num % 26 + 65) + letter; // 65 是 'A' 的 Unicode 编码
|
|
num = Math.floor(num / 26);
|
|
}
|
|
return letter;
|
|
},
|
|
loadWorkBook(workbookId) {
|
|
let that = this;
|
|
options.container = 'luckysheet-export';
|
|
options.gridKey = this.pageType === 'info' ? this.infoIds.workbookId : null;
|
|
options.loadUrl = workbookId ? `${process.env.VUE_APP_API_SERVER}/actual/base/luckySheet/workbook/load?workbookId=${workbookId}` : null;
|
|
options.allowUpdate = false;
|
|
window.luckysheet.create({
|
|
...options,
|
|
hook: {
|
|
cellEditBefore: that.handleCellEditBefore,
|
|
cellUpdateBefore: that.handleCellUpdateBefore,
|
|
}
|
|
});
|
|
},
|
|
handelClickBack() {
|
|
this.reportId = '';
|
|
$('#luckysheet-input-box').css('display', 'none');
|
|
this.$emit('close')
|
|
},
|
|
},
|
|
components: {
|
|
excelUploadData,
|
|
resiSearch
|
|
},
|
|
beforeDestroy() {
|
|
this.$store.state.sidebarFold = false;
|
|
if (this.socket) {
|
|
this.socket.close();
|
|
}
|
|
},
|
|
};
|
|
</script>
|
|
<style lang="scss" scoped>
|
|
.highlight {
|
|
background-color: #0056d6; /* 高亮背景颜色 */
|
|
color: #fff; /* 高亮文字颜色 */
|
|
}
|
|
/deep/ .el-tabs__item.is-active{
|
|
font-weight: 600;
|
|
}
|
|
.el-card {
|
|
margin: 10px auto;
|
|
padding: 0 16px;
|
|
box-sizing: border-box;
|
|
width: calc(100% - 40px);
|
|
border: none;
|
|
}
|
|
|
|
.luckysheet-wrap {
|
|
margin: 10px;
|
|
padding: 0px;
|
|
z-index: 2;
|
|
width: calc(100vw - 400px);
|
|
height: calc(100vh - 220px);
|
|
}
|
|
|
|
.luckysheet-wrap-all {
|
|
margin:0 10px 10px;
|
|
padding: 0px;
|
|
z-index: 2;
|
|
width: calc(100vw - 100px);
|
|
height: calc(100vh - 190px);
|
|
}
|
|
|
|
#luckysheet-export {
|
|
width: 100%;
|
|
padding: 0px;
|
|
z-index: 2;
|
|
height: calc(100% - 80px);
|
|
margin: 10px;
|
|
}
|
|
|
|
.top_btn {
|
|
height: 48px;
|
|
width: 100%;
|
|
}
|
|
|
|
.upload-img{
|
|
width: 30px;
|
|
height: 30px;
|
|
margin-right: 10px;
|
|
}
|
|
|
|
.right-slider {
|
|
position: absolute;
|
|
z-index: 999999;
|
|
border: 1px solid #eeeeee;
|
|
box-shadow: -5px 0px 5px 0px rgba(0, 0, 0, 0.2);
|
|
background: #ffffff;
|
|
margin: 10px 0 0 22px;
|
|
right: 10px;
|
|
width: 36%;
|
|
height: calc(100% - 20px);
|
|
}
|
|
|
|
.el-header,
|
|
.el-footer {
|
|
text-align: left;
|
|
line-height: 40px;
|
|
padding-top: 0;
|
|
padding-bottom: 0;
|
|
}
|
|
|
|
.el-main {
|
|
text-align: left;
|
|
line-height: 40px;
|
|
padding-top: 0;
|
|
padding-bottom: 0;
|
|
}
|
|
|
|
.el-container {
|
|
display: flex;
|
|
height: 100%;
|
|
flex-direction: column;
|
|
}
|
|
|
|
.left_menu {
|
|
width: 240px;
|
|
|
|
.menu_item {
|
|
cursor: pointer;
|
|
padding: 10px 16px;
|
|
box-sizing: border-box;
|
|
margin-bottom: 5px;
|
|
background-color: #f2f8fd;
|
|
border-radius: 5px;
|
|
font-size: 14px;
|
|
}
|
|
|
|
.active {
|
|
color: #3989eb;
|
|
}
|
|
}
|
|
.red{
|
|
color: red
|
|
}
|
|
</style>
|