123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259 |
- import { defineComponent, onMounted, reactive, ref } from 'vue';
- import styles from './index.module.less';
- import { List, Popup, DatePicker, Popover, Picker } from 'vant';
- import request from '@/helpers/request';
- import { useRoute, useRouter } from 'vue-router';
- import OEmpty from '@/components/m-empty';
- import MWxTip from '@/components/m-wx-tip';
- import OSearch from '@/components/m-search';
- import positionIcon from './images/position_icon.png';
- import scIcon1 from './images/sc_icon1.png';
- import scIcon2 from './images/sc_icon2.png';
- import scIcon3 from './images/sc_icon3.png';
- import schoolIcon from './images/school_icon.png';
- import gradeIcon from './images/class_icon.png';
- import { number } from 'echarts';
- export default defineComponent({
- name: 'statistics-detail',
- setup() {
- const route = useRoute();
- const router = useRouter();
- const tabName = ref('all');
- const forms = reactive({
- schoolName: '',
- id: route.query.id,
- yearStatus: false,
- schoolId: null,
-
- });
- const refreshing = ref(false);
- const loading = ref(true);
- const state = reactive({
- saveLoading: false,
- image: null as any,
- shareLoading: false,
- schoolInfo: {} as any,
- classList: [] as any,
- currentSort: 1, // 当前选中的排序方式
- currentAsc: false, // 是否生序,默认是降序
- gradeColumns: [],
- gradeStatus: false,
- gradePopShow: false,
- currentGrade: "",
- currentClass: "",
- gradeOptionIndex: [] as any,
- gradeContent: null as any,
- });
- // 获取学校信息
- const queryInfo = async () => {
- try {
- const res = await request.post(
- '/edu-app/open/meetingQuestionSetting/schoolStat',
- {
- data: {
- schoolAreaId: forms.id
- }
- }
- );
- state.schoolInfo = res.data || {}
- // 构建年级、班级及联选择
- const columns: any = []
- res.data.classData.unshift({
- currentClassList: [],
- currentGrade: '全部年级'
- })
- res.data.classData.forEach((grade: any, index: number) => {
- let columnItem: any = {}
- columnItem.text = grade.currentGrade
- columnItem.value = 'grade' + index
- columnItem.children = []
- grade.currentClassList.unshift('全部班级')
- if (grade.currentClassList?.length) {
- grade.currentClassList.forEach((classObj: any, cIdx: number) => {
- columnItem.children.push({
- text: classObj,
- value: 'class' + cIdx
- })
- })
- }
- columns.push(columnItem)
- })
- state.gradeColumns = columns
- // console.log('555',res, state.gradeColumns)
- } catch (error) {
-
- }
- }
- const queryList = async () => {
- try {
- const res = await request.post(
- '/edu-app/open/meetingQuestionSetting/schoolClass',
- {
- data: {
- schoolAreaId: forms.id,
- currentGrade: state.currentGrade,
- currentClass: state.currentClass,
- sortType: state.currentSort,
- asc: state.currentAsc
- }
- }
- );
- state.classList = res.data || []
- // console.log('222',res)
- } catch (error) {
-
- }
- }
- const filterList = (num: number) => {
- if (state.currentSort !== num) {
- state.currentAsc = false
- } else {
- state.currentAsc = !state.currentAsc
- }
- state.currentSort = num;
-
- queryList()
- }
- const formatNumberWithComma = (num: number | string) => {
- // 将数字转换为字符串,去掉小数点后面的部分
- let [integer, decimal] = num.toString().split('.');
-
- // 使用正则表达式添加千分位分隔符
- integer = integer.replace(/\B(?=(\d{3})+(?!\d))/g, ',');
-
- // 如果有小数部分,则保留小数部分
- return decimal ? `${integer}.${decimal}` : integer;
- }
- onMounted(async () => {
- await queryInfo()
- queryList()
- });
- return () => (
- <div class={styles.detailBody}>
- <div class={styles.dbTitle}>
- <div class={styles.dtName}>
- <img src={schoolIcon} />
- <p>{state.schoolInfo.schoolName}</p>
- </div>
- <div class={styles.dtDesc}>共<span> {state.schoolInfo.classNum} </span>个班级,<span>{state.schoolInfo.studentNum}</span>人参与调查</div>
- </div>
- <div class={styles.dbStatic}>
- <div class={styles.dsItem}>
- <div><span>{formatNumberWithComma(state.schoolInfo.supportStudentNum || 0)}</span><i>人</i></div>
- <p>支持学校开展</p>
- <i class={[styles.dsIcon, styles.dsIcon1]}></i>
- </div>
- <div class={styles.dsItem}>
- <div><span>{state.schoolInfo.supportStudentRate}%</span></div>
- <p>支持率</p>
- <i class={[styles.dsIcon, styles.dsIcon2]}></i>
- </div>
- </div>
- {/** 选择年级班级 */}
- <div class={styles.gradeColumn} onClick={() => state.gradeStatus = true}>
- <span class={state.gradeContent && styles.gcText}>{state.gradeContent ? state.gradeContent : '请选择年级班级'}</span>
- <i></i>
- </div>
- {/** 排序栏 */}
- <ul class={styles.sortColumn}>
- <li class={state.currentSort === 1 && styles.sortActive} onClick={() => filterList(1)}>
- <span>参与调查人数</span>
- <i class={[(state.currentSort === 1 && !state.currentAsc) && styles.actDown, (state.currentSort === 1 && state.currentAsc) && styles.actUp]}></i>
- </li>
- <li class={state.currentSort === 2 && styles.sortActive} onClick={() => filterList(2)}>
- <span>支持人数</span>
- <i class={[(state.currentSort === 2 && !state.currentAsc) && styles.actDown, (state.currentSort === 2 && state.currentAsc) && styles.actUp]}></i>
- </li>
- <li class={state.currentSort === 3 && styles.sortActive} onClick={() => filterList(3)}>
- <span>支持率</span>
- <i class={[(state.currentSort === 3 && !state.currentAsc) && styles.actDown, (state.currentSort === 3 && state.currentAsc) && styles.actUp]}></i>
- </li>
- </ul>
- {/** 班级列表 */}
- <div class={styles.scList}>
- {
- state.classList.map((item: any) => (
- <div class={styles.sItem}>
- <div class={styles.itemTile}>
- <img src={gradeIcon} />
- <p>{item.currentGrade||''}{item.currentClass || ''}</p>
- </div>
- <ul class={styles.itemContent}>
- <li>
- <div class={styles.icTop}>
- <span class={styles.sRed}>{formatNumberWithComma(item.studentNum || 0)}</span><i>人</i>
- </div>
- <p>参与调查</p>
- </li>
- <li>
- <div class={styles.icTop}>
- <span class={styles.sBlue}>{formatNumberWithComma(item.supportStudentNum || 0)}</span><i>人</i>
- </div>
- <p>支持学校开展</p>
- </li>
- <li>
- <div class={styles.icTop}>
- <span class={styles.sBlue}>{Number(item.supportStudentRate).toFixed(2)}%</span>
- </div>
- <p>支持率</p>
- </li>
- </ul>
- </div>
- ))
- }
- </div>
- {/* 班级 */}
- <Popup
- v-model:show={state.gradeStatus}
- position="bottom"
- round
- safeAreaInsetBottom
- lazyRender={false}
- class={'popupBottomSearch'}
- onOpen={() => {
- state.gradePopShow = true;
- }}
- onClosed={() => {
- state.gradePopShow = false;
- }}>
- {state.gradePopShow && (
- <Picker
- showToolbar
- v-model={state.gradeOptionIndex}
- columns={state.gradeColumns}
- onCancel={() => (state.gradeStatus = false)}
- onConfirm={(val: any) => {
- console.log('选择1111',val)
- state.currentGrade = val.selectedOptions[0].text === '全部年级' ? '' : val.selectedOptions[0].text
- state.currentClass = val.selectedOptions[1].text === '全部班级' ? '' : val.selectedOptions[1].text
- state.gradeOptionIndex = [val.selectedOptions[0].value, val.selectedOptions[1].value]
- state.gradeContent = state.currentGrade + state.currentClass
- state.gradeStatus = false;
- queryList()
- }}
- />
- )}
- </Popup>
- {/* <MWxTip /> */}
- </div>
- );
- }
- });
|