马宇豪
2024-11-21 cc3e08bda13360c88b7189e8f8d043b60783c7fb
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
<template>
    <div class="app-container">
        <div style="margin-bottom: 10px">
<!--          <el-button type="primary" plain icon="Open">开启专家申请</el-button>-->
<!--          <el-button type="danger" plain icon="TurnOff">关闭专家申请</el-button>-->
          <el-switch
              v-model="applyStatus"
              inline-prompt
              style="--el-switch-on-color: #ff4949; --el-switch-off-color: #13ce66"
              active-text="关闭专家申请"
              inactive-text="开启专家申请"
              active-value="2"
              inactive-value="1"
              @change="handleChange"
          />
        </div>
        <!-- 表格数据 -->
        <el-table v-loading="loading" :data="dataList" :border="true">
          <el-table-column label="序号" type="index" align="center"  />
          <el-table-column label="开启时间" prop="startTime" align="center"  />
          <el-table-column label="结束时间" prop="endTime" align="center"  />
        </el-table>
 
        <div class="pag-container">
            <el-pagination
                v-model:current-page="data.queryParams.pageNum"
                v-model:page-size="data.queryParams.pageSize"
                :page-sizes="[10,15,20,25]"
                layout="total, sizes, prev, pager, next, jumper"
                :total="total"
                @size-change="handleSizeChange"
                @current-change="handleCurrentChange"
            />
        </div>
    </div>
</template>
 
<script setup>
import {getCurrentInstance, onMounted, reactive, ref, toRefs} from "vue";
import {ElMessage, ElMessageBox} from "element-plus";
import {getApplyList, getSettings, updateSettings} from "@/api/backManage/evaluate";
const { proxy } = getCurrentInstance();
const loading = ref(false);
const busRef = ref();
const dictType = ref("sys_major_orientation")
const data = reactive({
    queryParams: {
        pageNum: 1,
        pageSize: 10
    },
    total: 0,
    dataList: [
    ]
 
 
});
 
const { queryParams, total, dataList } = toRefs(data);
 
onMounted(() => {
  getList()
  getApplyStatus()
});
const applyStatus = ref()
const isInitialized = ref(false)
 
const getApplyStatus = async ()=>{
  const res = await getSettings()
  if(res.code == 200){
    applyStatus.value = res.data
    isInitialized.value = true
  }else{
    ElMessage.warning(res.msg)
  }
}
 
const handleChange = (val)=>{
  if (!isInitialized.value) return
  changeStatus(val);
}
 
const changeStatus = async (val) => {
  const res = await updateSettings({ sysSettings: val });
  if (res.code == 200) {
    ElMessage.success('专家申请设置已更新');
    await getList()
  } else {
    ElMessage.warning(res.msg);
  }
}
 
const getList = async () => {
    loading.value = true;
    const res = await getApplyList(data.queryParams);
    if(res.code === 200){
        dataList.value = res.rows
        total.value = res.total
    }else{
        ElMessage.warning(res.msg)
    }
    loading.value = false;
}
const handleSizeChange = (val) => {
    data.queryParams.pageNum = 1;
    data.queryParams.pageSize = val
    getList()
}
const handleCurrentChange = (val) => {
    data.queryParams.pageNum = val
    getList()
}
 
/** 重置新增的表单以及其他数据  */
function reset() {
    proxy.resetForm("roleRef");
}
const handleDelete = (val) => {
    ElMessageBox.confirm(
        '确定删除此条数据?',
        '提示',
        {
            confirmButtonText: '确定',
            cancelButtonText: '取消',
            type: 'warning',
        })
        .then( async() => {
            const res = await delDict(val);
            if(res.code === 200){
                ElMessage({
                    type: 'success',
                    message: '删除成功'
                });
                getList();
            }else{
                ElMessage.warning(res.message)
            }
        })
}
 
</script>
<style>
.pag-container{
  float: right;
  margin-top: 10px;
}
.el-switch__core{
  height: 32px;
  padding: 10px 30px;
  border-radius: 16px;
 
  .el-switch__inner{
    height: 32px;
  }
  .el-switch__action{
    width: 24px;
    height: 24px;
    left: 4px;
  }
}
 
.el-switch.is-checked .el-switch__core .el-switch__action{
  left: calc(100% - 28px);
}
 
</style>