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

View File

@@ -24,9 +24,9 @@
</template> </template>
<script setup> <script setup>
import { ref, computed, provide} from 'vue' import { ref, computed, provide, nextTick } from 'vue'
import { useStore } from "vuex"; import { useStore } from "vuex";
import { getDiagramAnalysis } from "@/api/data-analyse";
import Header from '@/views/DataAnalyse/diagram/components/Layouts/Header' import Header from '@/views/DataAnalyse/diagram/components/Layouts/Header'
import Main from '@/views/DataAnalyse/diagram/components/Layouts/Main' import Main from '@/views/DataAnalyse/diagram/components/Layouts/Main'
import Footer from '@/views/DataAnalyse/diagram/components/Layouts/Footer' import Footer from '@/views/DataAnalyse/diagram/components/Layouts/Footer'
@@ -107,44 +107,78 @@ function removeChart() {
function getDateName() { function getDateName() {
const date = new Date() const date = new Date()
const year = date.getFullYear() const year = date.getFullYear()
const month = (date.getMonth()+1)<10?'0'+(date.getMonth()+1):date.getMonth()+1 const month = (date.getMonth() + 1) < 10 ? '0' + (date.getMonth() + 1) : date.getMonth() + 1
const day =(date.getDate())<10?'0'+(date.getDate()):date.getDate() const day = (date.getDate()) < 10 ? '0' + (date.getDate()) : date.getDate()
const hour = (date.getHours())<10?'0'+(date.getHours()):date.getHours() const hour = (date.getHours()) < 10 ? '0' + (date.getHours()) : date.getHours()
const min = (date.getMinutes())<10?'0'+(date.getMinutes()):date.getMinutes() const min = (date.getMinutes()) < 10 ? '0' + (date.getMinutes()) : date.getMinutes()
return `${year}${month}${day}${hour}${min}` return `${year}${month}${day}${hour}${min}`
} }
const surveyName = computed(() => { const surveyName = computed(() => {
return store.state.common.surveyName; return store.state.common.surveyName;
}); });
function exportData() { 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(); let date = Date.now();
date = date -= date % (60 * 1000); date = date -= date % (60 * 1000);
let imageUrl = '' let imageUrl = ''
if(chartInstance.value) { if (chartInstance.value) {
imageUrl = chartInstance.value.ImageUrl imageUrl = chartInstance.value.ImageUrl
} }
// 图片单选 多选 文件上传 不显示table数据 // 图片单选 多选 文件上传 不显示table数据
let isSpecial let isSpecial
if(!is_quick.value) { if (!is_quick.value) {
if([13, 14, 18].includes(props.data.question_type)) { if ([13, 14].includes(props.data.question_type)) {
isSpecial = true 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);
}
})
}
}
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 colums = isSpecial ? [] :tableInstance.value.columns
const data = isSpecial ? [] : tableInstance.value.data
const html = generatorTable(imageUrl, colums, data, props.data); const html = generatorTable(imageUrl, colums, data, props.data);
const title = `${props.data.title}_数据详情表_${getDateName()}`; const title = `${props.data.title}_数据详情表_${getDateName()}`;
exportChart(props.sn,{ exportChart(props.sn, {
html, html,
title title
}).then((res) => { }).then((res) => {
const {title,url} = res.data.url; const { title, url } = res.data.url;
const subdata = { const subdata = {
fileURL:url, fileURL: url,
fileName:title fileName: title
} }
store.dispatch('common/fileDown',subdata) store.dispatch('common/fileDown', subdata)
})
}); });
} }
@@ -161,6 +195,7 @@ function fullScreen() {
position: relative; position: relative;
height: 640px; height: 640px;
padding: 24px 32px 24px 32px; padding: 24px 32px 24px 32px;
background: #fff;
border-radius: 6px; border-radius: 6px;
box-shadow: 0px 0px 6px 0px rgba(0,0,0,0.1); 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) { export default function (imgUrl, columns, data, propsData) {
console.log('imgUrl, columns, data, propsData','---',imgUrl,'---', columns,'---', data,'---', propsData);
const str = [] const str = []
@@ -17,7 +18,12 @@ export default function (imgUrl, columns, data, propsData) {
data = data.map(item => { data = data.map(item => {
const arr = [] const arr = []
header.forEach(head => { header.forEach(head => {
const value = item[head] let value
if(item.value){
value = item.value[head]
}else{
value = item[head]
}
arr.push(value) arr.push(value)
}) })
return arr return arr
@@ -34,6 +40,7 @@ export default function (imgUrl, columns, data, propsData) {
const thead = columns.map(item => `<th>${item.title}</th>`).join('') const thead = columns.map(item => `<th>${item.title}</th>`).join('')
str.push(thead) str.push(thead)
str.push('</tr>') str.push('</tr>')
console.log('data',data);
data.forEach(row => { data.forEach(row => {
let tbody = ['<tr>'] let tbody = ['<tr>']
for (let k of row) { for (let k of row) {

View File

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

View File

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