Browse Source

fix:统计文件上传显示问题 文件上传路径问题

old
wangqing 4 years ago
parent
commit
61e4ed219b
  1. 2
      src/components/generator/config.js
  2. 19
      src/utils/index.js
  3. 21
      src/views/form/statistics.vue

2
src/components/generator/config.js

@ -501,7 +501,7 @@ export const selectComponents = [
__slot__: { __slot__: {
'list-type': true 'list-type': true
}, },
action: '/tduck-api/project/file/upload/', action: process.env.VUE_APP_API_ROOT + '/project/file/upload/',
disabled: false, disabled: false,
accept: '', accept: '',
name: 'file', name: 'file',

19
src/utils/index.js

@ -270,10 +270,10 @@ export function openUrl(url) {
var a = document.createElement('a') var a = document.createElement('a')
a.setAttribute('href', url) a.setAttribute('href', url)
a.setAttribute('target', '_blank') a.setAttribute('target', '_blank')
a.setAttribute('id', 'tduck-link-temp') a.setAttribute('id', 'd2admin-link-temp')
document.body.appendChild(a) document.body.appendChild(a)
a.click() a.click()
document.body.removeChild(document.getElementById('tduck-link-temp')) document.body.removeChild(document.getElementById('d2admin-link-temp'))
} }
/** /**
@ -290,3 +290,18 @@ export function jsonToParam(json) {
'=' + encodeURIComponent(json[key]) '=' + encodeURIComponent(json[key])
}).join('&') }).join('&')
} }
/**
* 是否是json
* @param str
* @returns {boolean}
*/
function isJsonString(str) {
try {
if (typeof JSON.parse(str) == 'object') {
return true
}
} catch (e) {
}
return false
}

21
src/views/form/statistics.vue

@ -71,7 +71,15 @@
<div> <div>
<div v-for="item in projectItemList"> <div v-for="item in projectItemList">
<h4>{{ item.label }}</h4> <h4>{{ item.label }}</h4>
<el-tag> {{ <!-- 如果是文件输入-->
<div v-if="item.type==17 &&activeResultRow">
<el-link
:href="file.url" target="_blank" type="primary"
v-for="file in JSON.parse(activeResultRow['processData'][`field${item.formItemId}`]['files'])">
{{file.fileName}}
</el-link>
</div>
<el-tag v-else> {{
activeResultRow ? activeResultRow ?
activeResultRow['processData'][`field${item.formItemId}`] : '' activeResultRow['processData'][`field${item.formItemId}`] : ''
}} }}
@ -127,7 +135,7 @@
<script> <script>
import _ from 'lodash' import _ from 'lodash'
import {jsonToParam} from '@/utils/index' import {jsonToParam, isJsonString} from '@/utils/index'
import {getCheckedColumn, saveCheckedColumn} from '@/utils/db' import {getCheckedColumn, saveCheckedColumn} from '@/utils/db'
@ -163,7 +171,7 @@ export default {
projectItemColumns: {}, projectItemColumns: {},
total: 0, total: 0,
detailDrawer: false, detailDrawer: false,
activeResultRow: false, activeResultRow: null,
// //
queryConditions: { queryConditions: {
current: 1, current: 1,
@ -180,6 +188,7 @@ export default {
onClick={() => this.customColumnDialogVisible = true}></i> onClick={() => this.customColumnDialogVisible = true}></i>
) )
}, },
openDetailDrawerHandle(row) { openDetailDrawerHandle(row) {
this.activeResultRow = row this.activeResultRow = row
this.detailDrawer = true this.detailDrawer = true
@ -222,8 +231,8 @@ export default {
} }
}, },
exportProjectResult() { exportProjectResult() {
if(!this.total){ if (!this.total) {
this.$message.error("无表单有效反馈结果,无法导出") this.$message.error('无表单有效反馈结果,无法导出')
return return
} }
this.$api.get('user/project/result/export', { this.$api.get('user/project/result/export', {
@ -234,7 +243,7 @@ export default {
let downloadElement = document.createElement('a') let downloadElement = document.createElement('a')
let href = window.URL.createObjectURL(blob) // let href = window.URL.createObjectURL(blob) //
downloadElement.href = href downloadElement.href = href
downloadElement.download = this.projectData.name +this.$dayjs().format('YYYYMMDDHHMM')+ '.xls' // downloadElement.download = this.projectData.name + this.$dayjs().format('YYYYMMDDHHMM') + '.xls' //
document.body.appendChild(downloadElement) document.body.appendChild(downloadElement)
downloadElement.click() // downloadElement.click() //
document.body.removeChild(downloadElement) // document.body.removeChild(downloadElement) //

Loading…
Cancel
Save