lilinfeng 2 months ago
parent
commit
64590abf17

+ 5 - 2
.env.production

@@ -1,6 +1,9 @@
 # 生产默认配置
 ENV = 'production'
 
-VUE_APP_BASE_API = 'http://192.168.103.104:58080'
-# VUE_APP_BASE_API =  "https://api.shidaiyun.net"
+VUE_APP_BASE_API = 'http://192.168.103.104:58080' #测试地址
+
+# VUE_APP_BASE_API = 'http://28.168.123.222:58080' #双活地址
+
+# VUE_APP_BASE_API =  "https://api.shidaiyun.net" #正式地址
 

+ 1 - 1
package.json

@@ -47,7 +47,7 @@
     "dayjs": "^1.8.29",
     "driver.js": "0.9.5",
     "dropzone": "5.5.1",
-    "echarts": "^5.4.0",
+    "echarts": "^5.5.1",
     "echarts-stat": "^1.1.1",
     "element-resize-detector": "^1.2.1",
     "element-ui": "2.15.5",

+ 19 - 1
src/api/governmentCloud/questionnaireInvestigation/questionnaireInvestigation.js

@@ -47,7 +47,7 @@ export const getQuestionnaireDetail = id => {
 };
 
 
-// 获取问卷
+// 获取之前下发过的人员
 export const getQuestionnaireUser = id => {
   return request({
     url: `/api/BaseQuestionnaire/BaseQuestionnaire/user?id=${id}`,
@@ -57,3 +57,21 @@ export const getQuestionnaireUser = id => {
 };
 
 
+// 获取问卷统计
+export const getQuestionnaireStats = (data) => {
+  return request({
+    url: `/api/BaseQuestionnaire/BaseQuestionnaire/stats`,
+    method: "POST",
+    data: data
+  });
+};
+
+// 查询统计详情
+export const getStatsDetail = (data) => {
+  return request({
+    url: `/api/BaseQuestionnaire/BaseQuestionnaire/stats/detail`,
+    method: "POST",
+    data: data
+  });
+};
+

+ 6 - 0
src/main.js

@@ -22,6 +22,12 @@ import { message } from './utils/message';
 
 import * as filters from './filters' // global filters
 
+
+//引入echarts
+import * as echarts from 'echarts'
+Vue.prototype.$echarts = echarts
+
+
 // 自定义按钮权限指令
 import permission from "@/directive/permission";
 Vue.use(permission)

+ 3 - 5
src/utils/apiUrl.js

@@ -1,13 +1,11 @@
 module.exports = {
   // 开发环境接口配置
-  // APIURl: "http://10.0.0.64:30000",
+  // APIURl: "http://10.0.0.95:30000",
   // APIURl: "http://10.21.12.137:30000",
   // APIURl: "http://192.168.103.104:58080",
   APIURl: "https://test.api.shidaiyun.net",
   // APIURl: "https://api.shidaiyun.net",
   minioPath: process.env.NODE_ENV === 'development' ? 'https://oss.shidaiyun.net/' : 'http://192.168.103.105:18000/'
+  // minioPath: process.env.NODE_ENV === 'development' ? 'https://oss.shidaiyun.net/' : 'http://28.168.105.206:9000/' //双活
   // minioPath: 'https://oss.shidaiyun.net/'
-};
-
-
-
+};

+ 185 - 39
src/views/governmentCloud/questionnaireInvestigation/Statistics.vue

@@ -3,21 +3,22 @@
         :show-close="false" :modal="false">
 
         <div class="JNPF-common-layout">
-            <div class="JNPF-common-layout-center">
+            <div class="JNPF-common-layout-center" v-if="visible">
                 <div class="top">
-                    <div class="top-title" v-if="visible">
+                    <div class="top-title">
                         <div style="opacity: 0.5;">问卷统计</div> /
                         <div style="font-size: 20px;font-weight: bold;margin-right: 30px;">
-                            {{questionnaire.name}}
+                            {{questionnaire.topic}}
                         </div>
-                        <el-tag style="margin-right: 20px;">匿名</el-tag>
+                        <el-tag style="margin-right: 20px;"
+                            v-if="questionnaire.anonymity">匿名</el-tag>
                         <div>
                             <span>下发数量:</span>
-                            <span>100</span>
+                            <span>{{ questionnaire.pushCount }}</span>
                         </div>
                         <div>
                             <span>收回数量:</span>
-                            <span>100</span>
+                            <span>{{ questionnaire.retractCount }}</span>
                         </div>
                         <div>
                             <span>结束倒计时:</span>
@@ -30,25 +31,69 @@
                         </el-button>
                     </div>
                 </div>
+                <el-row class="JNPF-common-search-box" :gutter="16">
+                    <el-form @submit.native.prevent>
+                        <el-col :span="6">
+                            <el-form-item label="题目标题">
+                                <el-input v-model="query.title" placeholder="请输入问卷标题" clearable>
+                                </el-input>
+                            </el-form-item>
+                        </el-col>
+                        <el-col :span="6">
+                            <el-form-item>
+                                <el-button type="primary" icon="el-icon-search"
+                                    @click="getList()">查询</el-button>
+                                <el-button icon="el-icon-refresh-right"
+                                    @click="reset()">重置</el-button>
+                            </el-form-item>
+                        </el-col>
+                    </el-form>
+                </el-row>
                 <div class="JNPF-common-layout-main JNPF-flex-main">
-                    <JNPF-table v-loading="listLoading" :data="tableData">
-                        <el-table-column prop="num" label="题号" align="left" show-overflow-tooltip>
+                    <JNPF-table v-loading="listLoading" :data="tableData" :hasNO="false">
+                        <el-table-column prop="questionNumber" label="题号" align="center" width="100"
+                            show-overflow-tooltip>
                         </el-table-column>
                         <el-table-column prop="title" label="题目" align="left" show-overflow-tooltip>
                         </el-table-column>
-                        <el-table-column prop="" label="题目类型" align="left" show-overflow-tooltip>
+                        <el-table-column prop="" label="题目类型" align="center" show-overflow-tooltip>
+                            <template slot-scope="scope">
+                                <span>{{ getQuestionType(scope.row.code.split('_')[0]) }}</span>
+                            </template>
                         </el-table-column>
                         <el-table-column prop="" label="选项" align="left" show-overflow-tooltip>
+                            <template slot-scope="scope">
+                                <span v-if="!scope.row.questionnaireOption.length">--</span>
+                                <template v-else>
+                                    <div v-for="(item,index) in scope.row.questionnaireOption"
+                                        :key="index">{{  item.optionContent}}</div>
+                                </template>
+                            </template>
                         </el-table-column>
-                        <el-table-column prop="" label="各选项数量" align="left" show-overflow-tooltip>
+                        <el-table-column prop="" label="各选项数量" align="center" show-overflow-tooltip>
+                            <template slot-scope="scope">
+                                <span v-if="!scope.row.questionnaireOption.length">--</span>
+                                <template v-else>
+                                    <div v-for="(item,index) in scope.row.questionnaireOption"
+                                        :key="index">{{  item.questionnaireOptionSubCount}}</div>
+                                </template>
+                            </template>
                         </el-table-column>
-                        <el-table-column prop="" label="百分比" align="left" show-overflow-tooltip>
+                        <el-table-column prop="" label="百分比" align="center" show-overflow-tooltip>
+                            <template slot-scope="scope">
+                                <span v-if="!scope.row.questionnaireOption.length">--</span>
+                                <template v-else>
+                                    <div v-for="(item,index) in scope.row.questionnaireOption"
+                                        :key="index">{{  item.percentage}}</div>
+                                </template>
+                            </template>
                         </el-table-column>
                         <el-table-column label="操作" fixed="right" width="150">
                             <template slot-scope="scope">
-                                <el-button type="text" @click="openChart(scope.row)">预览
+                                <el-button type="text" v-if="scope.row.questionnaireOption.length"
+                                    @click="openChart(scope.row)">预览
                                 </el-button>
-                                <el-button type="text" @click="openStatistics(scope.row.id)">详情
+                                <el-button type="text" @click="openAnswerList(scope.row)">详情
                                 </el-button>
                             </template>
                         </el-table-column>
@@ -59,10 +104,12 @@
             </div>
         </div>
         <div class="dialogChart">
-            <el-dialog title="收货地址" :visible.sync="dialogChartVisible" :modal="false">
-                <div class="" style="height: 300px"></div>
+            <el-dialog title="题目预览" :visible.sync="dialogChartVisible" :modal="false">
+                <div id="basic_dashboard" style="width: 100%;height: 400px;"></div>
             </el-dialog>
         </div>
+        <titleDetails v-if="titleDetailsVisible" ref="titleDetails" @close="closeTitleDetails" />
+
     </el-dialog>
 </template>
 
@@ -70,44 +117,105 @@
 
 import mixin from '@/mixins/generator/form'
 import dayjs from 'dayjs'
+import titleDetails from './titleDetails.vue'
+
 
 import {
-    getSuggestionsList
-} from "@/api/governmentCloud/suggestions/suggestions";
-import { getDictionaryDataSelector } from '@/api/systemData/dictionary'
+    getQuestionnaireStats
+} from "@/api/governmentCloud/questionnaireInvestigation/questionnaireInvestigation";
 
 
 export default {
     mixins: [mixin],
-    components: {},
+    components: { titleDetails },
     data() {
         return {
             visible: false,
             showContent: false,
-            questionnaire: {
-                name: '默认问卷'
-            },
             countSecond: null,
-            endDate: 1725089581000,
+            endDate: null,
             listLoading: false,
-            tableData: [{
-                title: '123',
-                num: 1
-            }],
+            tableData: [],
             total: 0,
             query: {
                 currentPage: 1,
                 pageSize: 20,
-                dataType: "0"
+                dataType: "0",
+                sidx: "-createTime",
+                title: null
             },
-            dialogChartVisible: false
+            titleDetailsVisible: false,
+            dialogChartVisible: false,
+            questionnaire: null,
         }
     },
     async created() {
-
-
     },
     methods: {
+        openAnswerList(item) {
+            this.titleDetailsVisible = true
+            this.$nextTick(() => {
+                this.$refs.titleDetails.init(item, this.questionnaire.id)
+            })
+        },
+        closeTitleDetails() {
+            this.titleDetailsVisible = false
+        },
+        basic_dashboard_type(item) {
+            var chartDom = document.getElementById('basic_dashboard');
+            var myChart = this.$echarts.init(chartDom);
+
+            // 组装选项数据
+            let data = []
+            item.questionnaireOption.forEach(element => {
+                data.push(
+                    { value: element.questionnaireOptionSubCount, name: element.optionContent },
+                )
+            });
+
+
+            var option = {
+                title: {
+                    text: item.title,
+                    subtext: '选项比例',
+                    left: 'center'
+                },
+                tooltip: {
+                    trigger: 'item'
+                },
+                legend: {
+                    orient: 'horizontal',
+                    right: 'center',
+                    bottom: '5%'
+                },
+                series: [
+                    {
+                        name: '题目预览',
+                        type: 'pie',
+                        radius: '50%',
+                        data: data,
+                        emphasis: {
+                            itemStyle: {
+                                shadowBlur: 10,
+                                shadowOffsetX: 0,
+                                shadowColor: 'rgba(0, 0, 0, 0.5)'
+                            }
+                        }
+                    }
+                ]
+            };
+            myChart.setOption(option);
+        },
+        reset() {
+            this.query = {
+                currentPage: 1,
+                pageSize: 20,
+                dataType: "0",
+                sidx: "-createTime",
+                title: null
+            }
+            this.getList()
+        },
         getDate(time) {
             let str = time ? dayjs(time).format('YYYY-MM-DD HH:mm:ss') : '无数据'
             return str
@@ -119,6 +227,7 @@ export default {
             let end = Number(endDate);
             //let endDate = new Date(this.assistActivityEndTime); // this.assistActivityEndTime需要倒计时的日期
             let leftTime = end - now; // 倒计时时间差
+
             // 定义变量 d,h,m,s保存倒计时的时间
             if (leftTime >= 0) {
                 // 天
@@ -141,7 +250,7 @@ export default {
                 this.min = "00";
                 this.second = "00";
                 this.countSecond = this.hour + ':' + this.min + ':' + this.second
-
+                this.countSecond = '已结束'
             }
             // 等于0的时候不调用
             if (
@@ -159,23 +268,60 @@ export default {
                 setTimeout(this.countTime, 1000);
             }
         },
-        async init(id) {
-            this.visible = true
+        getQuestionType(type) {
+            console.log(type)
+            let str = ''
+            if (type == 'TEXTAREA') {
+                str = '多行输入'
+            } else if (type == 'RADIO') {
+                str = '单选'
+            } else if (type == 'CHECKBOX') {
+                str = '多选'
+            }
+            return str
+        },
+        async init(questionnaire) {
+            this.questionnaire = questionnaire
+            console.log(this.questionnaire)
             this.getList()
-            this.countTime()
         },
         //返回列表页面
         closeDialog() {
             this.$emit("close");
         },
         getList() {
+            let params = {
+                ...this.query,
+                id: this.questionnaire.id
+            }
             this.listLoading = true;
-            setTimeout(() => {
-                this.listLoading = false
-            }, 1000)
+            getQuestionnaireStats(params).then(res => {
+                console.log(res)
+                if (res.code == 200) {
+                    this.tableData = res.data.questionnaireTopic
+
+                    console.log(this.tableData)
+
+                    this.questionnaire.retractCount = res.data.retractCount
+                    this.questionnaire.pushCount = res.data.pushCount
+                    this.total = res.data.total
+                    this.endDate = res.data.endTime
+                    this.listLoading = false
+                    this.visible = true
+
+                    this.countTime()
+
+                } else {
+                    this.listLoading = false
+                }
+            })
+
         },
-        openChart() {
+        openChart(questionnaire) {
             this.dialogChartVisible = true
+            this.$nextTick(() => {
+                this.basic_dashboard_type(questionnaire)
+            })
         }
     },
 }

+ 53 - 18
src/views/governmentCloud/questionnaireInvestigation/index.vue

@@ -5,17 +5,17 @@
                 <el-form @submit.native.prevent>
                     <el-col :span="6">
                         <el-form-item label="问卷标题">
-                            <el-input v-model="query.title" placeholder="请输入问卷标题" clearable>
+                            <el-input v-model="query.topic" placeholder="请输入问卷标题" clearable>
                             </el-input>
                         </el-form-item>
                     </el-col>
-                    <!-- <el-col :span="6">
+                    <el-col :span="6">
                         <el-form-item label="状态">
-                            <JnpfSelect v-model="query.method" placeholder="请选择" clearable
-                                :options="methodOptions" :props="methodProps" multiple>
+                            <JnpfSelect v-model="query.status" placeholder="请选择问卷状态" clearable
+                                :options="typeList" :props="methodProps">
                             </JnpfSelect>
                         </el-form-item>
-                    </el-col> -->
+                    </el-col>
                     <el-col :span="6">
                         <el-form-item>
                             <el-button type="primary" icon="el-icon-search"
@@ -71,14 +71,22 @@
                         </template>
                     </el-table-column>
                     <el-table-column prop="status" label="状态" align="left" show-overflow-tooltip>
+                        <template slot-scope="scope" sortable>
+                            <span></span>
+                            <el-tag v-if="scope.row.status === '1'"
+                                type="info">{{ getTypeLabel(scope.row.status) }}</el-tag>
+                            <el-tag v-else-if="scope.row.status == '2'"
+                                type="warning">{{ getTypeLabel(scope.row.status) }}</el-tag>
+                            <el-tag v-else-if="scope.row.status === '3'"
+                                type="success">{{ getTypeLabel(scope.row.status) }}</el-tag>
+                            <el-tag v-else-if="scope.row.status === '4'"
+                                type="danger">{{ getTypeLabel(scope.row.status) }}</el-tag>
+                        </template>
                     </el-table-column>
                     <el-table-column label="操作" fixed="right" width="200">
                         <template slot-scope="scope">
                             <el-button type="text" @click="openAllocation(scope.row.id)">编辑
                             </el-button>
-                            <el-button type="text" style="color: #f56c6c;"
-                                @click="deleteQuestionnaire(scope.row.id)">删除
-                            </el-button>
                             <el-button type="text" style="color: #e6a23c;"
                                 @click="openIssuedForm(scope.row)"
                                 v-if="scope.row.status === '1'">下发
@@ -89,7 +97,9 @@
                                 v-if="( scope.row.endTime - 600000)  > nowTime  && scope.row.status !== '1'">补发
                             </el-button>
 
-                            <el-button type="text" @click="openStatistics(scope.row.id)">统计
+                            <el-button type="text"
+                                v-if="scope.row.status === '3' || scope.row.status === '4'"
+                                @click="openStatistics(scope.row)">统计
                             </el-button>
                         </template>
                     </el-table-column>
@@ -129,7 +139,9 @@ export default {
                 currentPage: 1,
                 pageSize: 10,
                 dataType: "0",
-                title: "",
+                topic: "",
+                sidx: "-createTime",
+                status: null
             },
             selectProps: { "label": "fullName", "value": "enCode" },
             total: 0,
@@ -144,7 +156,8 @@ export default {
             issuedFormVisible: false,
             selectedData: [],
             timer: null,
-            nowTime: null
+            nowTime: null,
+            methodProps: { "label": "fullName", "value": "enCode" },
         }
     },
     async created() {
@@ -153,7 +166,7 @@ export default {
             //dayjs获取当前时间时间戳
             this.nowTime = new Date().getTime();
         }, 1000);
-
+        await this.getQuestionType()
         this.getList()
     },
     beforeDestroy() {
@@ -161,6 +174,31 @@ export default {
         clearInterval(this.timer);
     },
     methods: {
+        reset() {
+            this.query = {
+                currentPage: 1,
+                pageSize: 10,
+                dataType: "0",
+                title: "",
+                sidx: "-createTime",
+                status: null
+            }
+            this.getList()
+        },
+        getQuestionType() {
+            return new Promise((resolve, reject) => {
+                getDictionaryDataSelector('603485116668316293').then(res => {
+                    this.typeList = res.data.list
+                    resolve(true)
+                })
+            })
+        },
+        getTypeLabel(value) {
+            let item = this.typeList.find(item => {
+                return item.enCode == value
+            })
+            return item ? item.fullName : value
+        },
         handleSelectionChange(val) {
             this.selectedData = val;
         },
@@ -180,10 +218,10 @@ export default {
                 }
             })
         },
-        openStatistics(id) {
+        openStatistics(questionnaire) {
             this.statisticsVisible = true
             this.$nextTick(() => {
-                this.$refs.Statistics.init(id || '')
+                this.$refs.Statistics.init(questionnaire || '')
             })
         },
         openAllocation(id) {
@@ -217,10 +255,7 @@ export default {
         },
         getList() {
             this.listLoading = true;
-            let params = {
-                title: this.query.title
-            }
-            getQuestionnaireList(params).then(res => {
+            getQuestionnaireList(this.query).then(res => {
                 if (res.code == 200) {
                     this.tableData = res.data.list
                     this.total = res.data.pagination.total

+ 172 - 0
src/views/governmentCloud/questionnaireInvestigation/titleDetails.vue

@@ -0,0 +1,172 @@
+<template>
+    <el-dialog :visible.sync="visible" fullscreen lock-scroll class="JNPF-full-dialog"
+        :show-close="false" :modal="false">
+        <div class="JNPF-common-layout">
+            <div class="JNPF-common-layout-center" v-if="visible">
+                <div class="top">
+                    <div class="" style="display: flex;align-items: center;">
+                        <div style="margin-right: 20px;">题目选项</div>
+                        <div>
+                            <span style="margin-right: 10px;" v-for="item,index in questionnOptions"
+                                :key="index">{{ item.optionContent }}</span>
+                        </div>
+                    </div>
+                    <el-button @click="closeDialog">返回</el-button>
+                </div>
+                <el-row class="JNPF-common-search-box" :gutter="16">
+                    <el-form @submit.native.prevent>
+                        <el-col :span="6">
+                            <jnpf-form-tip-item label="用户" align="left" prop="userId">
+                                <JnpfUserSelect v-model="query.userId" class="item"
+                                    placeholder="请选择用户" clearable :ableIds="[]" :multiple="false" />
+                            </jnpf-form-tip-item>
+                        </el-col>
+                        <el-col :span="6">
+                            <el-form-item>
+                                <el-button type="primary" icon="el-icon-search"
+                                    @click="getList()">查询</el-button>
+                                <el-button icon="el-icon-refresh-right"
+                                    @click="reset()">重置</el-button>
+                            </el-form-item>
+                        </el-col>
+                    </el-form>
+                </el-row>
+                <div class="JNPF-common-layout-main JNPF-flex-main">
+                    <JNPF-table v-loading="listLoading" :data="tableData">
+                        <el-table-column prop="username" label="用户" align="left"
+                            show-overflow-tooltip>
+                        </el-table-column>
+                        <el-table-column prop="" label="回答" align="center" show-overflow-tooltip>
+                            <template slot-scope="scope">
+                                <template v-if="scope.row.answerOption.length ">
+                                    <span v-for=" (item,index) in
+                                    scope.row.answerOption" :key="index"
+                                        style="margin-right: 10px;">{{  item}}</span>
+                                </template>
+                                <span
+                                    v-else-if="scope.row.textResponse">{{ scope.row.textResponse }}</span>
+                                <span v-else>--</span>
+                            </template>
+                        </el-table-column>
+                    </JNPF-table>
+                    <pagination :total="total" :page.sync="query.currentPage"
+                        :limit.sync="query.pageSize" @pagination="getList" />
+                </div>
+            </div>
+        </div>
+        <div class="dialogChart">
+            <el-dialog title="题目预览" :visible.sync="dialogChartVisible" :modal="false">
+                <div id="basic_dashboard" style="width: 100%;height: 400px;"></div>
+            </el-dialog>
+        </div>
+    </el-dialog>
+</template>
+
+<script>
+
+import mixin from '@/mixins/generator/form'
+
+
+import {
+    getStatsDetail
+} from "@/api/governmentCloud/questionnaireInvestigation/questionnaireInvestigation";
+
+
+export default {
+    mixins: [mixin],
+    components: {},
+    data() {
+        return {
+            visible: false,
+            showContent: false,
+            countSecond: null,
+            endDate: 1725089581000,
+            listLoading: false,
+            tableData: [],
+            total: 0,
+            query: {
+                currentPage: 1,
+                pageSize: 20,
+                userId: null
+            },
+
+            dialogChartVisible: false,
+            questionnaire: null,
+
+            questionnaireTopicId: null,
+            id: null
+        }
+    },
+    async created() {
+    },
+    methods: {
+        //返回列表页面
+        closeDialog() {
+            this.$emit("close");
+        },
+        reset() {
+            this.query = {
+                currentPage: 1,
+                pageSize: 20,
+                userId: null
+            }
+            this.getList()
+        },
+        async init(item, id) {
+            this.id = id
+            this.questionnaireTopicId = item.id
+            this.getList()
+        },
+        getList(item, i) {
+            let params = {
+                ...this.query,
+                questionnaireTopicId: this.questionnaireTopicId,
+                id: this.id
+            }
+            this.listLoading = true;
+            getStatsDetail(params).then(res => {
+                if (res.code == 200) {
+                    this.tableData = res.data.stats
+                    this.questionnOptions = res.data.questionnaireOptionIds
+                    this.total = res.data.total
+                    this.listLoading = false
+                    this.visible = true
+                } else {
+                    this.$message.error(res.msg)
+                    this.showType = '1'
+                }
+            })
+
+        },
+    },
+}
+</script>
+
+<style lang="scss" scoped>
+.JNPF-common-layout {
+    padding: 20px;
+    background-color: #fff;
+}
+.top {
+    background-color: #fff;
+    width: 100%;
+    margin-bottom: 20px;
+    display: flex;
+    align-items: center;
+    justify-content: space-between;
+    .top-title {
+        margin-left: 0px;
+        display: flex;
+        font-size: 18px;
+        align-items: center;
+        div {
+            margin: 0 10px;
+        }
+    }
+}
+.dialogChart {
+    ::v-deep .el-dialog__header {
+        padding: 20px 20px 10px !important;
+    }
+}
+</style>