123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527 |
- <template>
- <div style="height:100%;padding:0 20px;">
- <el-tabs class="impTabs" v-model="activeTab">
- <el-tab-pane label="导入批次" name="import">
- <tf-page class="pagePanel">
- <template #action>
- <el-form :inline="true">
- <el-form-item label="所属项目">
- <el-select v-model="searchInfo.project" size="small" clearable>
- <el-option v-for="item of projects" :key="item.id" :value="item.id" :label="item.name"></el-option>
- </el-select>
- </el-form-item>
-
- <el-form-item label="导入时间">
- <el-date-picker value-format='yyyy-MM-dd HH:mm:ss' type="datetimerange" size="small" v-model="searchInfo.timeRange" range-separator="至" start-placeholder="开始日期" end-placeholder="结束日期">
- </el-date-picker>
- </el-form-item>
- <el-form-item>
- <el-button type="primary" size="mini" icon="el-icon-search" @click="batchinfoPage">查询</el-button>
- </el-form-item>
- <el-form-item>
- <el-button type="primary" size="mini" @click="showAddDialog">数据导入</el-button>
-
- </el-form-item>
- </el-form>
- </template>
- <tf-table :pagination="batchPagination" @page-change="batchOnPageChange" :columns="columns" :data="list">
- <el-table-column label="操作">
- <template slot-scope="scope">
- <el-button type="text" size="small" @click="viewProjectInfo(scope.row)">详情</el-button>
-
- </template>
- </el-table-column>
- </tf-table>
- </tf-page>
- </el-tab-pane>
- <el-tab-pane label="检测数据" name="list">
- <tf-page class="pagePanel">
- <template #action>
- <el-form :inline="true" class="dataSearchForm">
- <el-form-item label="所属项目">
- <el-select v-model="dataSeachInfo.project" size="small" clearable>
- <el-option v-for="item of projects" :key="item.id" :value="item.id" :label="item.name"></el-option>
- </el-select>
- </el-form-item>
- <el-form-item label="批次号">
- <el-input v-model="dataSeachInfo.pici" size="small"></el-input>
- </el-form-item>
- <el-form-item label="行政区">
- <el-select v-model="dataSeachInfo.region" size="small" clearable>
- <el-option v-for="item of districts" :key="item.id" :value="item.id" :label="item.name"></el-option>
- </el-select>
- </el-form-item>
-
- <el-form-item label="起点编号">
- <el-input v-model="dataSeachInfo.s_code" size="small"></el-input>
- </el-form-item>
- <el-form-item label="终点编号">
- <el-input v-model="dataSeachInfo.e_code" size="small"></el-input>
- </el-form-item>
- <el-form-item label="导入时间">
- <el-date-picker value-format='yyyy-MM-dd HH:mm:ss' type="datetimerange" size="small" v-model="dataSeachInfo.timeRange" range-separator="至" start-placeholder="开始日期" end-placeholder="结束日期">
- </el-date-picker>
- </el-form-item>
- <el-form-item>
- <el-button type="primary" size="mini" icon="el-icon-search" @click="getDataList">查询</el-button>
- </el-form-item>
- </el-form>
- </template>
- <tf-table :columns="dataColumns" :data="dataList" :pagination="pagination" @page-change="onPageChange">
-
- </tf-table>
- </tf-page>
- </el-tab-pane>
- </el-tabs>
- <tf-dialog :close-on-click-modal='false' :close-on-press-escape='false' height="600px" title="检测数据导入" :visible.sync='isAddDialogShow' class="addDialog" width="1000px">
- <el-steps simple :active="importStep" finish-status="success" v-if="formType==='add'">
- <el-step title="上传导入文件"></el-step>
- <el-step title="导入数据"></el-step>
- <el-step title="导入完成"></el-step>
- </el-steps>
- <div v-if="importStep==0">
- <el-form :model="addForm" ref='addForm' label-width="100px" :rules="addRules" :disabled="formType==='edit'">
- <tf-title>项目信息</tf-title>
- <el-row>
- <el-col :span="12">
- <el-form-item label="数据类型" prop="type">
- <el-select v-model="addForm.type" size="small" clearable>
- <el-option label="检测数据" value="tc"></el-option>
- </el-select>
- </el-form-item>
- </el-col>
- <el-col :span="12">
- <el-form-item label="所属项目" prop="project">
- <el-select v-model="addForm.project" size="small" clearable>
- <el-option v-for="item of projects" :key="item.id" :value="item.id" :label="item.name"></el-option>
- </el-select>
- </el-form-item>
- </el-col>
- </el-row>
- <el-row>
- <el-col :span="12">
- <el-form-item label="行政区" prop="district">
- <el-select v-model="addForm.district" size="small" clearable>
- <el-option v-for="item of districts" :key="item.id" :value="item.id" :label="item.name"></el-option>
- </el-select>
- </el-form-item>
- </el-col>
- <el-col :span="12">
- <el-form-item label="单位" prop="tcUnit">
- <el-select v-model="addForm.tcUnit" size="small" clearable>
- <el-option v-for="item of departments" :key="item.id" :value="item.id" :label="item.name"></el-option>
- </el-select>
- </el-form-item>
- </el-col>
- </el-row>
- <tf-title>附件</tf-title>
- <el-row>
- <el-upload class="upload-demo" action="https://jsonplaceholder.typicode.com/posts/" :on-preview="handlePreview" :on-remove="handleRemove" :before-remove="beforeRemove" :on-change="beforeAvatarUpload" :on-success="handleAvatarSuccess" accept=".jpg,.jpeg,.png,.pdf,.doc,.xls,.xlsx" :file-list="fileList" :auto-upload="false" multiple :limit="3" :on-exceed="handleExceed" size="small">
- <el-button size="small" type="primary" style="margin-top: 3px; left:0px; float:left; ">点击上传</el-button>
- <div slot="tip" class="el-upload__tip">
- ⚠️注意:请上传jpg,png,jpeg,pdf,excel,word格式的文件,且大小不能超过10MB!最多3个文件!
- </div>
- </el-upload>
- </el-row>
- </el-form>
- </div>
- <div v-else-if="importStep==1">
- <el-result title="导入中......" subTitle="">
- <template slot="icon">
- <i class="el-icon-loading"></i>
- </template>
- </el-result>
- </div>
- <div v-else-if="importStep==2">
- <el-result icon="success" title="导入成功" subTitle="">
- <template slot="extra">
- <el-button type="primary" size="medium" @click="isAddDialogShow = false">关闭</el-button>
- </template>
- </el-result>
- </div>
- <div slot="footer" style="text-align:right;" v-show="importStep===0&&formType==='add'">
- <el-button @click="isAddDialogShow = false" size="small">取 消</el-button>
- <el-button type="primary" @click="addSubmit()" size="small">确 定</el-button>
- </div>
- </tf-dialog>
- </div>
- </template>
- <script lang="ts">
- import { Vue, Component,Watch } from 'vue-property-decorator'
- import { batchinfoPage, checkDataImport,checkdataPage } from '@/api/dataCheckModule/dataImport'
- import { uploadFile, getAllDepartments } from '@/api/base'
- import { projectPage } from '@/api/dataCheckModule/projectList'
- import { getDefaultPagination } from '@/utils/constant'
- import { districts } from '@/views/zhpt/dataImport/common/constant'
- import { ElForm } from 'element-ui/types/form'
- @Component({
- name: 'JianCeDataImport'
- })
- export default class JianCeDataImport extends Vue {
-
- columns = [
- { type: 'index', label: '序号' },
- { prop: 'prjName', label: '所属项目' },
- { prop: 'district', label: '行政区' },
- { prop: 'batchNo', label: '批次号' },
- { prop: 'departmentName', label: '单位' },
- { prop: 'dataCount', label: '总数据量' },
-
-
- { prop: 'createUser', label: '操作人' },
- { prop: 'createTime', label: '操作时间' }
- ]
-
- dataColumns = [
- { type: 'index', label: '序号' },
- { prop: 'batchinfo.prjName', label: '所属项目', width: '100px' },
- { prop: 'batchinfo.batchNo', label: '批次号', width: '150px' },
- { prop: 'area', label: '行政区' },
- { prop: 'testingZone', label: '测区' },
- { prop: 'pipeProperties', label: '管段属性' },
- { prop: 'roadName', label: '道路名称', showOverflowTooltip: true },
- { prop: 'startCode', label: '起点编码', showOverflowTooltip: true },
- { prop: 'endCode', label: '终点编码', showOverflowTooltip: true },
- { prop: 'pipeLength', label: '管道长度(m)', width: '150px' },
- { prop: 'sectionDataOne', label: '断面数据1', width: '150px' },
- { prop: 'sectionDataTwo', label: '断面数据2', width: '150px' },
- { prop: 'videoTime', label: '视频显示时间', width: '150px' },
- { prop: 'videoSectionDataOne', label: '视频显示断面数据1', width: '150px' },
- { prop: 'videoSectionDataTwo', label: '视频显示断面数据2', width: '150px' },
- { prop: 'pdCheckLength', label: '判读检测长度', width: '150px' },
- { prop: 'noHandleLength', label: '暂无法预处理长度', width: '150px' },
- { prop: 'pdRemark', label: '判读备注', showOverflowTooltip: true, width: '150px' },
- { prop: 'isCheck', label: '是否检测' },
- { prop: 'rainTask', label: '雨水任务单', showOverflowTooltip: true, width: '100px' },
- { prop: 'remark', label: '探测备注', showOverflowTooltip: true },
- { prop: 'batchinfo.createTime', label: '导入时间', showOverflowTooltip: true }
- ]
-
- dataList = []
-
- list = []
-
- addForm = {
- project: '',
- type: '',
- tcUnit: '',
- district: ''
- }
-
- addRules = {
- type: [{ required: true, message: '请选择数据类型', trigger: 'change' }],
- project: [{ required: true, message: '请选择项目', trigger: 'change' }],
- tcUnit: [{ required: true, message: '请选择单位', trigger: 'change' }]
- }
-
- activeTab = 'import'
-
- pagination = getDefaultPagination()
-
- batchPagination= getDefaultPagination()
-
- districts = districts
-
- formType = 'add'
-
- searchInfo = {
- project: '',
- status: '',
- timeRange: []
- }
-
- dataSeachInfo = {
- project: '',
- pici: '',
- region: '',
- status: '',
- s_code: '',
- e_code: '',
- timeRange: []
- }
-
- projects = []
-
- status = []
-
- importStep = 0
-
- isAddDialogShow = false
-
- prjTypes = []
-
- fileList = []
- files = []
-
- departments = []
- mounted() {
- this.batchinfoPage()
- this.getDataList()
- this.getProjectList()
- this.getDepartments()
- }
-
- handleRemove(file, fileList) {
- console.log('文件列表移除文件时的钩子', file, fileList)
- this.fileList = fileList
- }
- handlePreview(file) {
- console.log('点击文件列表中已上传的文件时的钩子', file)
- }
- handleExceed(files, fileList) {
- this.$message.warning(
- `当前限制选择 3 个文件,本次选择了 ${files.length} 个文件,共选择了 ${files.length + fileList.length} 个文件`
- )
- }
- beforeRemove(file, fileList) {
- return this.$confirm(`确定移除 ${file.name}?`)
- }
- onBeforeUpload(file) {
- console.log('图片格式', file.type)
- let fileName = file.name
- let esuffixt = fileName.substr(fileName.lastIndexOf('.') + 1)
- const isIMAGE = esuffixt === 'xls' || esuffixt === 'xlsx'
- const isLt1M = file.size / 1024 / 1024 < 10
- if (!isIMAGE) {
- this.$message.error('上传文件只能是jpg,png,jpeg,pdf,excel,word格式!')
- }
- if (!isLt1M) {
- this.$message.error('上传文件大小不能超过 10MB!')
- }
- return isIMAGE && isLt1M
- }
-
- beforeAvatarUpload(response, file, fileList) {
- console.log(response, file)
- var isTrue = this.onBeforeUpload(response.raw)
- if (isTrue) {
- this.fileMap(file)
- } else {
- file.pop()
- }
- }
- fileMap(file) {
- if (file.length !== 0) {
- const files = file.map((v) => {
- return v.raw
- })
- this.files = files
- }
- }
- handleAvatarSuccess(res, file, fileList) {
- console.log('文件上传成功时的钩子', res, file, fileList)
- }
-
- showAddDialog() {
- this.isAddDialogShow = true
- this.formType = 'add'
- this.fileList = []
- this.files = []
- this.importStep=0
- this.addForm = {
- project: '',
- district: '',
- type: 'tc',
- tcUnit: ''
- }
- }
-
- getDepartments() {
- getAllDepartments()
- .then((result) => {
- if (result.code === 1) {
- this.departments = result.result || []
- }
- })
- .catch((err) => {
- console.log(err)
- })
- }
-
- addSubmit() {
- ;(this.$refs['addForm'] as ElForm).validate((valid) => {
- if (!valid) {
- return
- }
- if (this.files.length === 0) {
- this.$message.warning('请上传文件')
- return
- }
- if (this.files.length === 1) {
- this.importStep = 1
- const formdata = new FormData()
- this.files.forEach((file) => {
- formdata.append('file', file)
- })
- uploadFile(formdata)
- .then((result) => {
- if (result.code !== 1) {
- this.$message.error('上传文件失败')
- return
- }
- if (!result.result || result.result.length === 0) {
- console.log('上传文件未返回fileId')
- return
- }
- const fileID = result.result[0].fileId
- const data = {
- prjId: this.addForm.project,
- district: this.addForm.district,
- departmentId: this.addForm.tcUnit,
- fileId: fileID
- }
- checkDataImport(data)
- .then((addResult) => {
- if (addResult.code === 1) {
- this.$message.success('保存成功')
- this.importStep = 2
-
- this.batchinfoPage()
- }
- })
- .catch((err) => {
- this.$message.error('保存失败')
- console.log(err)
- })
- })
- .catch((err) => {
- this.$message.error('上传文件失败')
- console.log(err)
- })
- } else {
- this.$message.warning('单次只允许上传一个文件')
- }
- })
- }
-
- viewProjectInfo(row) {
- this.isAddDialogShow = true
- this.formType = 'edit'
- this.addForm = {
- project: row.prjId,
- district: row.district,
- tcUnit: row.departmentId,
- type: 'tc'
- }
-
-
-
- }
-
- batchinfoPage() {
- let parames = {
- prjId: this.searchInfo.project,
- stage: 4,
- startTime:this.searchInfo.timeRange&&this.searchInfo.timeRange.length>=1?this.searchInfo.timeRange[0]:'',
- endTime:this.searchInfo.timeRange&&this.searchInfo.timeRange.length==2?this.searchInfo.timeRange[1]:''
- }
- parames = { ...parames, ...this.batchPagination }
- batchinfoPage(parames)
- .then((result) => {
- if (result.code === 1) {
- this.list = result.result.records
- const { current, size, total } = result.result
- this.batchPagination = { current, size, total }
- }
- })
- .catch((err) => {
- console.log(err)
- })
- }
-
- getDataList() {
- let parames = {
- 'batchinfo.batchNo': this.dataSeachInfo.pici,
- 'batchinfo.prjId': this.dataSeachInfo.project,
- area: this.dataSeachInfo.region,
- startCode: this.dataSeachInfo.s_code,
- endCode: this.dataSeachInfo.e_code,
- 'batchinfo.startTime':this.dataSeachInfo.timeRange&&this.dataSeachInfo.timeRange.length>=1?this.dataSeachInfo.timeRange[0]:'',
- 'batchinfo.endTime':this.dataSeachInfo.timeRange&&this.dataSeachInfo.timeRange.length==2?this.dataSeachInfo.timeRange[1]:''
- }
- parames = { ...parames, ...this.pagination }
- checkdataPage(parames)
- .then((result) => {
- if (result.code === 1) {
- this.dataList = result.result.records
- const { current, size, total } = result.result
- this.pagination = { current, size, total }
- }
- })
- .catch((err) => {
- console.log(err)
- })
- }
-
- getProjectList() {
- projectPage({})
- .then((result) => {
- if (result.code === 1) {
- this.projects = result.result.records.map((item) => {
- return { id: item.id, name: item.name }
- })
- }
- })
- .catch((err) => {
- console.log(err)
- })
- }
-
- onPageChange(pagination) {
- this.pagination = { ...this.pagination, ...pagination }
- this.getDataList()
- }
-
- batchOnPageChange(batchPagination) {
- this.batchPagination = { ...this.batchPagination, ...batchPagination }
- this.batchinfoPage()
- }
- }
- </script>
- <style lang="scss" scoped>
- @import '@/views/zhpt/dataImport/common/index.scss';
- .addDialog {
- >>> .el-form-item {
- .el-select {
- width: 100%;
- }
- }
- }
- .impTabs {
- height: 100%;
- >>> .el-tabs__content {
- height: calc(100% - 55px);
- .el-tab-pane {
- height: 100%;
- }
- }
- }
- // .dataSearchForm{
- // >>> .el-form-item{
- // .el-input{max-width: 150px;}
- // .el-select{max-width: 250px;}
- // }
- // }
- </style>
|