Просмотр исходного кода

满意度调查增加未选项的统计

luoaoxuan 1 год назад
Родитель
Сommit
076af0c143

+ 11 - 1
src/views/platform/examination/survey/itemTable.vue

@@ -79,16 +79,26 @@ export default {
                 if (this.statisItemData[0].xuan_xiang_) {
                     let ind = 1
                     const t = JSON.parse(this.statisItemData[0].xuan_xiang_)
+                    const notChoice = this.statisItemData.filter(item => !item.da_an_).length // 未选项
+                    const validCnt = this.statisItemData.length - notChoice
                     for (const key in t) {
                         const cnt = this.statisItemData.filter(item => item.da_an_ === key).length
                         arr.push({
                             xx: `选项${ind}`,
                             xuan_xiang_: t[key],
                             xiao_ji_: cnt,
-                            bi_li_: (cnt / this.statisItemData.length * 100).toFixed(2) + ' %'
+                            bi_li_: validCnt > 0 ? (cnt / (validCnt) * 100).toFixed(2) + '%' : '0.00%'
                         })
                         ind++
                     }
+                    if (notChoice > 0) {
+                        arr.push({
+                            xx: `未选`,
+                            xuan_xiang_: '/',
+                            xiao_ji_: notChoice,
+                            bi_li_: '/'
+                        })
+                    }
                 }
             } else {
                 arr = this.statisItemData.map(item => ({ hui_da_: item.da_an_ }))

+ 3 - 3
src/views/platform/examination/survey/statistics.vue

@@ -53,13 +53,13 @@
                     <All :statis-item-data="showData" />
                 </div>
                 <div class="title" style="margin-left:8px">统计详情</div>
-                <div v-for="(v,k) in showData" :key="k" class="every">
+                <div v-for="(v,k,ind) in showData" :key="k" class="every">
                     <div class="table-title">
                         <div class="desc">
-                            {{ Object.keys(showData).findIndex(i=>i===k)+1 }}.{{ v[0].ti_gan_ }}
+                            {{ ind+1 }}.{{ v[0].ti_gan_ }}
                         </div>
                         <div class="shown">
-                            填写人数:{{ v.length }}
+                            有效数量/总数量:{{ v.filter(i=>i.da_an_).length }}/{{ v.length }}
                         </div>
                     </div>
                     <div class="item-table">