Merge branch 'master' of e.coding.yili.com:yldc/ylst/ylst-survey-web

This commit is contained in:
steven
2022-10-13 17:05:32 +08:00
5 changed files with 94 additions and 45 deletions

View File

@@ -10,7 +10,7 @@
<template #content>
<div v-html="label"></div>
</template>
<div v-html="label"></div>
<div class="drag-item" v-html="label"></div>
</a-popover>
</div>
</div>
@@ -21,14 +21,14 @@
</div>
<template #overlay>
<a-menu>
<a-menu-item>
<a href="javascript:" @click="exportData">导出当前图表数据</a>
<a-menu-item @click="exportData">
<a href="javascript:">导出当前图表数据</a>
</a-menu-item>
<a-menu-item>
<a href="javascript:" @click="downloadImg" v-if="hasChart">导出图片</a>
<a-menu-item @click="downloadImg" v-if="hasChart">
<a href="javascript:">导出图片</a>
</a-menu-item>
<a-menu-item>
<a href="javascript:" @click="removeChart">删除图表</a>
<a-menu-item @click="removeChart">
<a href="javascript:">删除图表</a>
</a-menu-item>
</a-menu>
</template>
@@ -131,6 +131,11 @@ export default defineComponent({
font-size: 14px;
margin-bottom: 0;
color: #70b936;
.drag-item {
text-overflow: ellipsis;
white-space: nowrap;
overflow: hidden;
}
}
}
.action {

View File

@@ -24,9 +24,9 @@
</template>
<script setup>
import { ref, computed, provide} from 'vue'
import { ref, computed, provide, nextTick } from 'vue'
import { useStore } from "vuex";
import { getDiagramAnalysis } from "@/api/data-analyse";
import Header from '@/views/DataAnalyse/diagram/components/Layouts/Header'
import Main from '@/views/DataAnalyse/diagram/components/Layouts/Main'
import Footer from '@/views/DataAnalyse/diagram/components/Layouts/Footer'
@@ -107,44 +107,78 @@ function removeChart() {
function getDateName() {
const date = new Date()
const year = date.getFullYear()
const month = (date.getMonth()+1)<10?'0'+(date.getMonth()+1):date.getMonth()+1
const day =(date.getDate())<10?'0'+(date.getDate()):date.getDate()
const hour = (date.getHours())<10?'0'+(date.getHours()):date.getHours()
const min = (date.getMinutes())<10?'0'+(date.getMinutes()):date.getMinutes()
const month = (date.getMonth() + 1) < 10 ? '0' + (date.getMonth() + 1) : date.getMonth() + 1
const day = (date.getDate()) < 10 ? '0' + (date.getDate()) : date.getDate()
const hour = (date.getHours()) < 10 ? '0' + (date.getHours()) : date.getHours()
const min = (date.getMinutes()) < 10 ? '0' + (date.getMinutes()) : date.getMinutes()
return `${year}${month}${day}${hour}${min}`
}
const surveyName = computed(() => {
return store.state.common.surveyName;
});
function exportData() {
let date = Date.now();
date = date -= date % (60 * 1000);
let imageUrl = ''
if(chartInstance.value) {
imageUrl = chartInstance.value.ImageUrl
}
// 图片单选 多选 文件上传 不显示table数据
let isSpecial
if(!is_quick.value) {
if([13, 14, 18].includes(props.data.question_type)) {
isSpecial = true
var tabledata = ref(null)
function exportData () {
let params = {
...searchParams.value,
question_index: props.data.question_index,
type: 1
};
getDiagramAnalysis(props.sn, params).then((res) => {
let date = Date.now();
date = date -= date % (60 * 1000);
let imageUrl = ''
if (chartInstance.value) {
imageUrl = chartInstance.value.ImageUrl
}
}
const colums = isSpecial ? [] :tableInstance.value.columns
const data = isSpecial ? [] : tableInstance.value.data
const html = generatorTable(imageUrl, colums, data, props.data);
const title = `${props.data.title}_数据详情表_${getDateName()}`;
exportChart(props.sn,{
html,
title
}).then((res) => {
const {title,url} = res.data.url;
const subdata = {
fileURL:url,
fileName:title
// 图片单选 多选 文件上传 不显示table数据
let isSpecial
if (!is_quick.value) {
if ([13, 14].includes(props.data.question_type)) {
isSpecial = false
res.data[0].option.map(item => {
if (item.title.indexOf('<img') > -1) {
item.title = item.title.slice(0, item.title.length - 2) + `width="100" ` + item.title.slice(item.title.length - 2);
}
})
}
}
store.dispatch('common/fileDown',subdata)
if ([18].includes(props.data.question_type)) {
res.data[0].option.map((el) => {
if (el.title.indexOf('img') != -1) {
el.title = el.title.slice(5)
} else {
el.title = el.title.substring(0, el.title.lastIndexOf('.'))
}
delete el.data
delete el.answer
return res.data[0].option
})
}
const colums = isSpecial ? [] : res.data[0].head
const data = isSpecial ? [] : res.data[0].option
if ([5, 9, 11, 26, 15, 16, 10, 17].includes(props.data.question_type)) {
if (data[0].option) {
colums[0].key = 'option_title'
data.map((item, index) => {
item.option.map((e, i) => {
item[e.index] = e.number
})
})
}
}
const html = generatorTable(imageUrl, colums, data, props.data);
const title = `${props.data.title}_数据详情表_${getDateName()}`;
exportChart(props.sn, {
html,
title
}).then((res) => {
const { title, url } = res.data.url;
const subdata = {
fileURL: url,
fileName: title
}
store.dispatch('common/fileDown', subdata)
})
});
}
@@ -161,6 +195,7 @@ function fullScreen() {
position: relative;
height: 640px;
padding: 24px 32px 24px 32px;
background: #fff;
border-radius: 6px;
box-shadow: 0px 0px 6px 0px rgba(0,0,0,0.1);
}

View File

@@ -1,4 +1,5 @@
export default function (imgUrl, columns, data, propsData) {
console.log('imgUrl, columns, data, propsData','---',imgUrl,'---', columns,'---', data,'---', propsData);
const str = []
@@ -17,8 +18,13 @@ export default function (imgUrl, columns, data, propsData) {
data = data.map(item => {
const arr = []
header.forEach(head => {
const value = item[head]
arr.push(value)
let value
if(item.value){
value = item.value[head]
}else{
value = item[head]
}
arr.push(value)
})
return arr
})
@@ -34,6 +40,7 @@ export default function (imgUrl, columns, data, propsData) {
const thead = columns.map(item => `<th>${item.title}</th>`).join('')
str.push(thead)
str.push('</tr>')
console.log('data',data);
data.forEach(row => {
let tbody = ['<tr>']
for (let k of row) {

View File

@@ -194,6 +194,7 @@ export default function useChartOption(source, type, enableLabel = true, other =
show: true,
minValueSpan: 5,
maxValueSpan: 8,
width: 10,
handleSize: 4,
filterMode: 'filter',
backgroundColor: '#fff',
@@ -278,7 +279,7 @@ export default function useChartOption(source, type, enableLabel = true, other =
}
})
const seriesData = sourceData.map(item =>item.number)
const tooltipText = sourceData.map(item =>item.title + ': ' + '\xa0' + item.number + '<br />')
const tooltipText = sourceData.map(item =>item.title + ': ' + '\xa0' + item.number + '\xa0' + '' + item.rate + '' + '<br />')
defaultOption = {
// legend: {
// data: legendData

View File

@@ -637,8 +637,9 @@ export default defineComponent({
verifyCode: data.verify,
}
const res = await store.dispatch('redpacket/offeringPrizes', subData)
if (res.error_code === 0) {
message.success(res.message);
if (res.code === 0) {
// message.success(res.message);
message.success('操作成功');
actLists()
loading.value = true
const data = await store.dispatch('DocumentLibraryApi/getKey')