|
|
@@ -141,6 +141,7 @@
|
|
|
<el-table-column label="模考次数" prop="simulate" align="center" min-width="100" :fixed="hideActions ? 'right' : undefined">
|
|
|
<template #default="scope">
|
|
|
<el-button type="primary" link @click="handleShowSimulate(scope.row.cardId)">查看</el-button>
|
|
|
+ <el-button type="warning" link @click="handleClearDirectedStudy(scope.row)" v-if="scope.row.userId && scope.row.directedStudy">清空定向</el-button>
|
|
|
</template>
|
|
|
</el-table-column>
|
|
|
<el-table-column v-if="!hideActions" label="操作" min-width="110" fixed="right" align="center">
|
|
|
@@ -209,8 +210,8 @@
|
|
|
<script setup>
|
|
|
import DictTag from '@/components/DictTag/index.vue';
|
|
|
import { getCurrentInstance, ref } from 'vue';
|
|
|
-import { getUserSimulateList, updateUserEvalCounts } from '@/api/dz/cards';
|
|
|
-import { ElMessage } from 'element-plus';
|
|
|
+import { getUserSimulateList, updateUserEvalCounts, clearUserDirectedStudy } from '@/api/dz/cards';
|
|
|
+import { ElMessage, ElMessageBox } from 'element-plus';
|
|
|
const { proxy } = getCurrentInstance();
|
|
|
const { card_type, exam_type, card_distribute_status, card_status, card_settlement_status, card_time_status, card_pay_status } =
|
|
|
proxy.useDict("card_type", "exam_type", "card_distribute_status", "card_status", "card_settlement_status", "card_time_status", "card_pay_status");
|
|
|
@@ -232,7 +233,7 @@ const props = defineProps({
|
|
|
default: false,
|
|
|
},
|
|
|
});
|
|
|
-const emit = defineEmits(['selectionChange', 'delete']);
|
|
|
+const emit = defineEmits(['selectionChange', 'delete', 'refresh']);
|
|
|
const handleSelectionChange = (selection) => {
|
|
|
emit('selectionChange', selection);
|
|
|
};
|
|
|
@@ -419,6 +420,38 @@ const handleSaveCount = async () => {
|
|
|
savingCount.value = false
|
|
|
}
|
|
|
};
|
|
|
+
|
|
|
+// 清空定向
|
|
|
+const handleClearDirectedStudy = async (row) => {
|
|
|
+ if (!row || !row.userId) {
|
|
|
+ ElMessage.warning('用户ID不存在')
|
|
|
+ return
|
|
|
+ }
|
|
|
+
|
|
|
+ try {
|
|
|
+ await ElMessageBox.confirm('确定要清空该用户的定向信息吗?', '提示', {
|
|
|
+ confirmButtonText: '确定',
|
|
|
+ cancelButtonText: '取消',
|
|
|
+ type: 'warning'
|
|
|
+ })
|
|
|
+
|
|
|
+ await clearUserDirectedStudy(row.userId)
|
|
|
+ ElMessage.success('清空定向成功')
|
|
|
+
|
|
|
+ // 更新本地数据,将 directedStudy 设置为 null
|
|
|
+ if (row) {
|
|
|
+ row.directedStudy = null
|
|
|
+ }
|
|
|
+
|
|
|
+ // 触发刷新,通知父组件更新数据
|
|
|
+ emit('refresh')
|
|
|
+ } catch (error) {
|
|
|
+ if (error !== 'cancel') {
|
|
|
+ console.error('清空定向失败:', error)
|
|
|
+ ElMessage.error('清空定向失败')
|
|
|
+ }
|
|
|
+ }
|
|
|
+};
|
|
|
</script>
|
|
|
<style lang="scss" scoped>
|
|
|
/* 在弹窗中使用时的样式 */
|