Browse Source

bug 修改1

old
jiangyy 4 years ago
parent
commit
c5a7f5f718
  1. 13
      src/api/index.js
  2. 611
      src/views/form/statistics/list.vue
  3. 40
      src/views/form/write/index.vue

13
src/api/index.js

@ -69,7 +69,7 @@ api.interceptors.response.use(
*/
let errCodes = [500, 405, 403]
const res = response.data
if (res.code === 200) {
if (res.code === 0) {
return Promise.resolve(res)
} else if (errCodes.includes(res.code)) {
// 这里做错误提示,如果使用了 element ui 则可以使用 Message 进行提示
@ -112,8 +112,15 @@ api.interceptors.response.use(
result = await api.request(response.config)
})
return Promise.resolve(result)
}
return Promise.resolve(res)
}else {
Message({
message: res.msg || 'Error',
type: 'error',
duration: 5 * 1000
})
return Promise.reject(res)
}
// return Promise.resolve(res)
},
error => {
Message({

611
src/views/form/statistics/list.vue

@ -1,332 +1,342 @@
<template>
<div class="statistics-container">
<div class="filter-table-view">
<el-form ref="filterForm" :inline="true">
<el-form-item label="提交时间" prop="endDateTime">
<el-date-picker
v-model="queryConditions.beginDateTime"
placeholder="开始时间"
type="datetime"
value-format="yyyy-MM-dd HH:mm:ss"
/>
<span> </span>
<el-date-picker
v-model="queryConditions.endDateTime"
:default-time="'23:59:59'"
placeholder="结束时间"
type="datetime"
value-format="yyyy-MM-dd HH:mm:ss"
/>
</el-form-item>
<el-form-item>
<el-button type="primary" @click="queryProjectResult">查询</el-button>
<el-button type="primary" @click="conditionFilterHandle">条件</el-button>
<el-button type="success" @click="exportProjectResult">导出</el-button>
<el-button type="success" @click="downloadProjectResultFile">下载附件</el-button>
</el-form-item>
</el-form>
</div>
<div class="result-table-view">
<el-table
:data="projectResultList"
<div class="statistics-container">
<div class="filter-table-view">
<el-form ref="filterForm"
:inline="true">
<el-form-item label="提交时间"
prop="endDateTime">
<el-date-picker v-model="queryConditions.beginDateTime"
placeholder="开始时间"
type="datetime"
value-format="yyyy-MM-dd HH:mm:ss" />
<span> </span>
<el-date-picker v-model="queryConditions.endDateTime"
:default-time="'23:59:59'"
placeholder="结束时间"
type="datetime"
value-format="yyyy-MM-dd HH:mm:ss" />
</el-form-item>
<el-form-item>
<el-button type="primary"
@click="queryProjectResult">查询</el-button>
<el-button type="primary"
@click="conditionFilterHandle">条件</el-button>
<el-button type="success"
@click="exportProjectResult">导出</el-button>
<el-button type="success"
@click="downloadProjectResultFile">下载附件</el-button>
</el-form-item>
</el-form>
</div>
<div class="result-table-view">
<el-table :data="projectResultList"
header-cell-class-name="data-table-header"
stripe
@row-dblclick="(row, column, event)=>{
this.openDetailDrawerHandle(row)
}"
>
<el-table-column
type="selection"
width="55"
/>
<el-table-column
v-for="col in fixedCustomColumns" :key="`t${col}`"
:label="fixedDefaultLabelFormColumn[col]"
>
<template slot-scope="scope">
{{ scope.row[col] }}
</template>
</el-table-column>
<el-table-column label="填写人" prop="realName" />
<el-table-column label="组织/部门/网格" prop="orgName" />
<el-table-column label="来源" prop="clientType" />
<!-- <el-table-column label="填写时间" prop="createdTime" /> -->
}">
<el-table-column type="selection"
width="55" />
<el-table-column v-for="col in fixedCustomColumns"
:key="`t${col}`"
:label="fixedDefaultLabelFormColumn[col]">
<template slot-scope="scope">
{{ scope.row[col] }}
</template>
</el-table-column>
<el-table-column
v-for="col in otherCustomColumns"
:key="col" :label="projectItemColumns[col]"
show-overflow-tooltip
>
<template slot-scope="scope">
{{ scope.row['processData'][col] }}
</template>
</el-table-column>
<el-table-column label="填写人"
prop="realName" />
<el-table-column label="组织/部门/网格"
prop="orgName" />
<el-table-column label="来源"
prop="clientType" />
<!-- <el-table-column label="填写时间" prop="createdTime" /> -->
<el-table-column
v-for="col in fixedFormTailColumns" :key="`t${col}`"
:label="fixedDefaultLabelFormTailColumn[col]"
>
<template slot-scope="scope">
{{ scope.row[col] }}
</template>
</el-table-column>
<!-- :render-header="renderHeader" -->
<el-table-column
<el-table-column v-for="col in otherCustomColumns"
:key="col"
:label="projectItemColumns[col]"
show-overflow-tooltip>
<template slot-scope="scope">
{{ scope.row['processData'][col] }}
</template>
</el-table-column>
fixed="right"
width="50"
>
<template slot-scope="scope">
<el-button size="small" type="text" @click="openDetailDrawerHandle(scope.row)">查看</el-button>
</template>
</el-table-column>
</el-table>
<el-drawer
v-if="activeResultRow"
:visible.sync="detailDrawer"
:with-header="false"
>
<el-scrollbar style="height: 100%;">
<el-card class="detail-container">
<div slot="header" class="clearfix">
<span>提交详情</span>
</div>
<div>
<div v-for="item in projectItemList" :key="item.id">
<h4>{{ item.label }}</h4>
<result-item :field-item-id="Number(item.formItemId)" :project-item-data="item"
:result-data="activeResultRow"
/>
<el-divider />
</div>
</div>
</el-card>
</el-scrollbar>
</el-drawer>
<div style="display: flex; justify-content: center; margin-top: 10px;">
<el-pagination
v-if="total>10"
:current-page.sync="queryConditions.current"
:page-size.sync="queryConditions.size"
:total="total"
background
layout="total, prev, pager, next"
@current-change="queryProjectResult"
/>
<el-table-column v-for="col in fixedFormTailColumns"
:key="`t${col}`"
:label="fixedDefaultLabelFormTailColumn[col]">
<template slot-scope="scope">
{{ scope.row[col] }}
</template>
</el-table-column>
<!-- :render-header="renderHeader" -->
<el-table-column fixed="right"
width="50">
<template slot-scope="scope">
<el-button size="small"
type="text"
@click="openDetailDrawerHandle(scope.row)">查看</el-button>
</template>
</el-table-column>
</el-table>
<el-drawer v-if="activeResultRow"
:visible.sync="detailDrawer"
:with-header="false">
<el-scrollbar style="height: 100%;">
<el-card class="detail-container">
<div slot="header"
class="clearfix">
<span>提交详情</span>
</div>
</div>
<div class="custom-col-container">
<el-dialog :visible.sync="customColumnDialogVisible" center title="自定义显示列">
<el-row>
<el-col :span="3">
<span>显示列</span>
</el-col>
</el-row>
<el-divider />
<el-checkbox-group v-model="checkedFixedCustomColumns">
<el-row>
<el-col v-for="(val, key) in fixedDefaultLabelFormColumn" :key="key" :span="4">
<el-checkbox :label="key">{{ val }}</el-checkbox>
</el-col>
</el-row>
</el-checkbox-group>
<div>
<div v-for="item in projectItemList"
:key="item.id">
<h4>{{ item.label }}</h4>
<result-item :field-item-id="Number(item.formItemId)"
:project-item-data="item"
:result-data="activeResultRow" />
<el-divider />
<el-checkbox-group v-model="checkOtherCustomColumns">
<el-row>
<el-col v-for="(val, key) in projectItemColumns" :key="key" :span="8">
<el-checkbox :label="key">{{ val }}</el-checkbox>
</el-col>
</el-row>
</el-checkbox-group>
<el-divider />
<el-checkbox-group v-model="checkedFixedTailCustomColumns">
<el-row>
<el-col v-for="(val, key) in fixedDefaultLabelFormTailColumn" :key="key" :span="4">
<el-checkbox :label="key">{{ val }}</el-checkbox>
</el-col>
</el-row>
</el-checkbox-group>
<span slot="footer" class="dialog-footer">
<el-button @click="customColumnDialogVisible = false"> </el-button>
<el-button type="primary" @click="saveStatisticsCheckedColumns"> </el-button>
</span>
</el-dialog>
</div>
<data-filter ref="dataFilter" :fields="projectItemList" @filter="dataFilterHandle" />
</div>
</div>
</el-card>
</el-scrollbar>
</el-drawer>
<div style="display: flex; justify-content: center; margin-top: 10px;">
<el-pagination v-if="total>10"
:current-page.sync="queryConditions.current"
:page-size.sync="queryConditions.size"
:total="total"
background
layout="total, prev, pager, next"
@current-change="queryProjectResult" />
</div>
</div>
<div class="custom-col-container">
<el-dialog :visible.sync="customColumnDialogVisible"
center
title="自定义显示列">
<el-row>
<el-col :span="3">
<span>显示列</span>
</el-col>
</el-row>
<el-divider />
<el-checkbox-group v-model="checkedFixedCustomColumns">
<el-row>
<el-col v-for="(val, key) in fixedDefaultLabelFormColumn"
:key="key"
:span="4">
<el-checkbox :label="key">{{ val }}</el-checkbox>
</el-col>
</el-row>
</el-checkbox-group>
<el-divider />
<el-checkbox-group v-model="checkOtherCustomColumns">
<el-row>
<el-col v-for="(val, key) in projectItemColumns"
:key="key"
:span="8">
<el-checkbox :label="key">{{ val }}</el-checkbox>
</el-col>
</el-row>
</el-checkbox-group>
<el-divider />
<el-checkbox-group v-model="checkedFixedTailCustomColumns">
<el-row>
<el-col v-for="(val, key) in fixedDefaultLabelFormTailColumn"
:key="key"
:span="4">
<el-checkbox :label="key">{{ val }}</el-checkbox>
</el-col>
</el-row>
</el-checkbox-group>
<span slot="footer"
class="dialog-footer">
<el-button @click="customColumnDialogVisible = false"> </el-button>
<el-button type="primary"
@click="saveStatisticsCheckedColumns"> </el-button>
</span>
</el-dialog>
</div>
<data-filter ref="dataFilter"
:fields="projectItemList"
@filter="dataFilterHandle" />
</div>
</template>
<script>
import _ from 'lodash'
import ResultItem from './item'
import DataFilter from './filter'
import {getCheckedColumn, saveCheckedColumn} from '@/utils/db'
import { getCheckedColumn, saveCheckedColumn } from '@/utils/db'
//
const fixedDefaultFormColumn = ['serialNumber']
const fixedDefaultLabelFormColumn = {serialNumber: '提交序号'}
const fixedDefaultLabelFormColumn = { serialNumber: '提交序号' }
//
const fixedDefaultFormTailColumn = ['submitAddress', 'createdTime']
const fixedDefaultLabelFormTailColumn = { submitAddress: '提交地址', createdTime: '提交时间'}
const fixedDefaultLabelFormTailColumn = { submitAddress: '提交地址', createdTime: '提交时间' }
export default {
name: 'ProjectStatisticsList',
components: {
ResultItem,
DataFilter
name: 'ProjectStatisticsList',
components: {
ResultItem,
DataFilter
},
data () {
return {
projectKey: null,
customFilterDialogVisible: false,
customColumnDialogVisible: false,
checkedFilterColumns: [],
//
fixedCustomColumns: fixedDefaultFormColumn,
fixedFormTailColumns: fixedDefaultFormTailColumn,
//
checkedFixedCustomColumns: fixedDefaultFormColumn,
fixedDefaultLabelFormColumn: fixedDefaultLabelFormColumn,
checkedFixedTailCustomColumns: fixedDefaultFormTailColumn,
fixedDefaultLabelFormTailColumn: fixedDefaultLabelFormTailColumn,
//
checkOtherCustomColumns: [],
otherCustomColumns: [],
projectResultList: [],
projectItemList: [],
projectData: null,
projectItemColumns: {},
total: 0,
detailDrawer: false,
activeResultRow: null,
//
queryConditions: {
current: 1,
size: 10,
projectKey: '',
beginDateTime: '',
endDateTime: '',
extParams: null,
extComparisons: null
}
}
},
mounted () {
this.projectKey = this.$route.query.key
this.queryConditions.projectKey = this.projectKey
this.queryProjectResult()
this.queryProjectItems()
this.queryProject()
},
methods: {
renderHeader () {
return (
<i class="el-icon-setting" style="color:currentColor"
onClick={() => this.customColumnDialogVisible = true}></i>
)
},
data() {
return {
projectKey: null,
customFilterDialogVisible: false,
customColumnDialogVisible: false,
checkedFilterColumns: [],
//
fixedCustomColumns: fixedDefaultFormColumn,
fixedFormTailColumns: fixedDefaultFormTailColumn,
//
checkedFixedCustomColumns: fixedDefaultFormColumn,
fixedDefaultLabelFormColumn: fixedDefaultLabelFormColumn,
checkedFixedTailCustomColumns: fixedDefaultFormTailColumn,
fixedDefaultLabelFormTailColumn: fixedDefaultLabelFormTailColumn,
//
checkOtherCustomColumns: [],
otherCustomColumns: [],
projectResultList: [],
projectItemList: [],
projectData: null,
projectItemColumns: {},
total: 0,
detailDrawer: false,
activeResultRow: null,
//
queryConditions: {
current: 1,
size: 10,
projectKey: '',
beginDateTime: '',
endDateTime: '',
extParams: null,
extComparisons: null
}
}
openDetailDrawerHandle (row) {
this.activeResultRow = row
this.detailDrawer = true
},
queryProject () {
this.$api.get(`${process.env.VUE_APP_API_ROOT_TDUCK}/user/project/${this.projectKey}`).then(res => {
this.projectData = res.data
})
},
conditionFilterHandle () {
this.$refs.dataFilter.showDialogHandle()
},
mounted() {
this.projectKey = this.$route.query.key
this.queryConditions.projectKey = this.projectKey
this.queryProjectResult()
this.queryProjectItems()
this.queryProject()
dataFilterHandle (params, comparisons) {
this.queryConditions.extParams = params
this.queryConditions.extComparisons = comparisons
this.queryProjectResult()
},
methods: {
renderHeader() {
return (
<i class="el-icon-setting" style="color:currentColor"
onClick={() => this.customColumnDialogVisible = true}></i>
)
},
openDetailDrawerHandle(row) {
this.activeResultRow = row
this.detailDrawer = true
},
queryProject() {
this.$api.get(`${process.env.VUE_APP_API_ROOT_TDUCK}/user/project/${this.projectKey}`).then(res => {
this.projectData = res.data
})
},
conditionFilterHandle() {
this.$refs.dataFilter.showDialogHandle()
},
dataFilterHandle(params, comparisons) {
this.queryConditions.extParams = params
this.queryConditions.extComparisons = comparisons
this.queryProjectResult()
},
queryProjectResult() {
this.$api.get(`${process.env.VUE_APP_API_ROOT_TDUCK}/user/project/result/page`, {params: this.queryConditions}).then(res => {
let {records, total, size} = res.data
this.projectResultList = records
this.total = total
this.queryConditions.size = size
})
},
saveStatisticsCheckedColumns() {
this.customColumnDialogVisible = false
this.fixedCustomColumns = this.checkedFixedCustomColumns
this.otherCustomColumns = this.checkOtherCustomColumns
this.fixedFormTailColumns = this.checkedFixedTailCustomColumns
saveCheckedColumn(this.projectKey, {
fixedCustomColumns: this.fixedCustomColumns,
otherCustomColumns: this.otherCustomColumns,
fixedCustomTailColumns: this.fixedFormTailColumns
})
},
getDbCheckedColumns() {
let checkedColumn = getCheckedColumn(this.projectKey)
if (!checkedColumn) {
return
}
let {fixedCustomColumns, otherCustomColumns, fixedCustomTailColumns} = checkedColumn
if (fixedCustomColumns) {
this.fixedCustomColumns = fixedCustomColumns
this.checkedFixedCustomColumns = fixedCustomColumns
}
if (otherCustomColumns) {
this.otherCustomColumns = otherCustomColumns
this.checkOtherCustomColumns = otherCustomColumns
}
if (fixedCustomTailColumns) {
this.fixedCustomTailColumns = fixedCustomTailColumns
this.checkedFixedTailCustomColumns = fixedCustomTailColumns
}
},
downloadProjectResultFile() {
if (!this.total) {
this.$message.error('无附件,无法导出')
return
}
this.$api.get(`${process.env.VUE_APP_API_ROOT_TDUCK}/user/project/result/download/file`, {
params: this.queryConditions
}).then(res => {
this.$process({
message: '附件导出中',
key: res.data
})
})
},
exportProjectResult() {
if (!this.total) {
this.$message.error('无表单有效反馈结果,无法导出')
return
}
this.$api.get(`${process.env.VUE_APP_API_ROOT_TDUCK}/user/project/result/export`, {
params: this.queryConditions,
responseType: 'blob'
}).then(res => {
let blob = res
let downloadElement = document.createElement('a')
let href = window.URL.createObjectURL(blob) //
downloadElement.href = href
downloadElement.download = this.projectData.name + this.$dayjs().format('YYYYMMDDHHMM') + '.xls' //
document.body.appendChild(downloadElement)
downloadElement.click() //
document.body.removeChild(downloadElement) //
window.URL.revokeObjectURL(href) // blob
})
},
queryProjectItems() {
this.$api.get(`${process.env.VUE_APP_API_ROOT_TDUCK}/user/project/item/list`, {params: {key: this.projectKey, displayType: false}}).then(res => {
if (res.data) {
res.data.map(item => {
_.set(this.projectItemColumns, `field${item.formItemId}`, item.label)
})
}
this.projectItemList = res.data
this.getDbCheckedColumns()
})
queryProjectResult () {
this.$api.get(`${process.env.VUE_APP_API_ROOT_TDUCK}/user/project/result/page`, { params: this.queryConditions }).then(res => {
let { records, total, size } = res.data
this.projectResultList = records
this.total = total
this.queryConditions.size = size
})
},
saveStatisticsCheckedColumns () {
this.customColumnDialogVisible = false
this.fixedCustomColumns = this.checkedFixedCustomColumns
this.otherCustomColumns = this.checkOtherCustomColumns
this.fixedFormTailColumns = this.checkedFixedTailCustomColumns
saveCheckedColumn(this.projectKey, {
fixedCustomColumns: this.fixedCustomColumns,
otherCustomColumns: this.otherCustomColumns,
fixedCustomTailColumns: this.fixedFormTailColumns
})
},
getDbCheckedColumns () {
let checkedColumn = getCheckedColumn(this.projectKey)
if (!checkedColumn) {
return
}
let { fixedCustomColumns, otherCustomColumns, fixedCustomTailColumns } = checkedColumn
if (fixedCustomColumns) {
this.fixedCustomColumns = fixedCustomColumns
this.checkedFixedCustomColumns = fixedCustomColumns
}
if (otherCustomColumns) {
this.otherCustomColumns = otherCustomColumns
this.checkOtherCustomColumns = otherCustomColumns
}
if (fixedCustomTailColumns) {
this.fixedCustomTailColumns = fixedCustomTailColumns
this.checkedFixedTailCustomColumns = fixedCustomTailColumns
}
},
downloadProjectResultFile () {
if (!this.total) {
this.$message.error('无附件,无法导出')
return
}
this.$api.get(`${process.env.VUE_APP_API_ROOT_TDUCK}/user/project/result/download/file`, {
params: this.queryConditions
}).then(res => {
this.$process({
message: '附件导出中',
key: res.data
})
})
},
exportProjectResult () {
if (!this.total) {
this.$message.error('无表单有效反馈结果,无法导出')
return
}
this.$api.get(`${process.env.VUE_APP_API_ROOT_TDUCK}/user/project/result/export`, {
params: this.queryConditions,
responseType: 'blob'
}).then(res => {
let blob = res
let downloadElement = document.createElement('a')
let href = window.URL.createObjectURL(blob) //
downloadElement.href = href
downloadElement.download = this.projectData.name + this.$dayjs().format('YYYYMMDDHHMM') + '.xls' //
document.body.appendChild(downloadElement)
downloadElement.click() //
document.body.removeChild(downloadElement) //
window.URL.revokeObjectURL(href) // blob
})
},
queryProjectItems () {
this.$api.get(`${process.env.VUE_APP_API_ROOT_TDUCK}/user/project/item/list`, { params: { key: this.projectKey, displayType: false } }).then(res => {
if (res.data) {
res.data.map(item => {
_.set(this.projectItemColumns, `field${item.formItemId}`, item.label)
})
}
this.projectItemList = res.data
this.getDbCheckedColumns()
})
}
}
}
</script>
@ -386,5 +396,4 @@ export default {
::v-deep .el-drawer__container ::-webkit-scrollbar {
display: none;
}
</style>

40
src/views/form/write/index.vue

@ -47,6 +47,7 @@ import loadWXJs from '@/utils/loadWxSdk'
import defaultValue from '@/utils/defaultValue'
import { getQueryString } from '@/utils'
import constants from '@/utils/constants'
import ELEMENT from 'element-ui'
const uaParser = require('ua-parser-js')
const ua = uaParser(navigator.userAgent)
@ -288,10 +289,18 @@ export default {
let projectKey = this.projectConfig.projectKey
this.$router.replace({ path: '/project/public/result', query: { projectKey } })
},
submitForm (data) {
async submitForm (data) {
const loading = ELEMENT.Loading.service({
fullscreen: true,
lock: true,
text: '提交中',
spinner: 'el-icon-loading',
background: 'rgba(255, 255, 255, 0.5)'
})
//
let inActiveTime = document.getElementById('inActiveTime').innerText
this.$api.post(`${process.env.VUE_APP_API_ROOT_TDUCK}/user/project/result/create?access_key=${this.accessKey}`, {
await this.$api.post(`${process.env.VUE_APP_API_ROOT_TDUCK}/user/project/result/create?access_key=${this.accessKey}`, {
'completeTime': inActiveTime,
'projectKey': this.projectConfig.projectKey,
'submitOs': ua.os.name,
@ -309,24 +318,19 @@ export default {
//'accessKey':this.accessKey
}).then((res) => {
if (res.code !== 0) {
this.$message(
{
message: res.msg,
type: 'warning'
}
)
} else {
this.writeStatus = 2
if (this.userProjectSetting.submitJumpUrl) {
setTimeout(() => {
window.location.replace(this.userProjectSetting.submitJumpUrl)
}, 1000)
}
this.writeStatus = 2
if (this.userProjectSetting.submitJumpUrl) {
setTimeout(() => {
window.location.replace(this.userProjectSetting.submitJumpUrl)
}, 1000)
}
})
},
(msg) => {
// debugger
})
// debugger
loading.close()
}
}
}

Loading…
Cancel
Save