up
This commit is contained in:
parent
d2328a531f
commit
b35f7ef016
@ -16,6 +16,21 @@ export const listLabel = (query?: LabelQuery): AxiosPromise<LabelVO[]> => {
|
|||||||
});
|
});
|
||||||
};
|
};
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 状态修改
|
||||||
|
*/
|
||||||
|
export const changeLabelStatus = (id: string | number, status: number) => {
|
||||||
|
const data = {
|
||||||
|
id,
|
||||||
|
status
|
||||||
|
};
|
||||||
|
return request({
|
||||||
|
url: '/question/label/changeStatus',
|
||||||
|
method: 'put',
|
||||||
|
data: data
|
||||||
|
});
|
||||||
|
};
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 查询题目标签详细
|
* 查询题目标签详细
|
||||||
* @param id
|
* @param id
|
||||||
|
@ -10,7 +10,7 @@ export interface LabelVO {
|
|||||||
label: string;
|
label: string;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 标签状态 1:启用 0:禁用
|
* 标签状态 0:启用 1:禁用
|
||||||
*/
|
*/
|
||||||
status: number;
|
status: number;
|
||||||
|
|
||||||
@ -28,21 +28,19 @@ export interface LabelForm extends BaseEntity {
|
|||||||
label?: string;
|
label?: string;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 标签状态 1:启用 0:禁用
|
* 标签状态 0:启用 1:禁用
|
||||||
*/
|
*/
|
||||||
status?: number;
|
status?: number;
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
export interface LabelQuery extends PageQuery {
|
export interface LabelQuery extends PageQuery {
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 标签名称
|
* 标签名称
|
||||||
*/
|
*/
|
||||||
label?: string;
|
label?: string;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 标签状态 1:启用 0:禁用
|
* 标签状态 0:启用 1:禁用
|
||||||
*/
|
*/
|
||||||
status?: number;
|
status?: number;
|
||||||
|
|
||||||
@ -51,6 +49,3 @@ export interface LabelQuery extends PageQuery {
|
|||||||
*/
|
*/
|
||||||
params?: any;
|
params?: any;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
@ -6,6 +6,11 @@
|
|||||||
<el-form-item label="标签名称" prop="label">
|
<el-form-item label="标签名称" prop="label">
|
||||||
<el-input v-model="queryParams.label" placeholder="请输入标签名称" clearable style="width: 240px" @keyup.enter="handleQuery" />
|
<el-input v-model="queryParams.label" placeholder="请输入标签名称" clearable style="width: 240px" @keyup.enter="handleQuery" />
|
||||||
</el-form-item>
|
</el-form-item>
|
||||||
|
<el-form-item label="状态" prop="status">
|
||||||
|
<el-select v-model="queryParams.status" placeholder="标签状态" clearable style="width: 240px">
|
||||||
|
<el-option v-for="dict in dataStatus" :key="dict.value" :label="dict.label" :value="dict.value"/>
|
||||||
|
</el-select>
|
||||||
|
</el-form-item>
|
||||||
<el-form-item>
|
<el-form-item>
|
||||||
<el-button type="primary" icon="Search" @click="handleQuery">搜索</el-button>
|
<el-button type="primary" icon="Search" @click="handleQuery">搜索</el-button>
|
||||||
<el-button icon="Refresh" @click="resetQuery">重置</el-button>
|
<el-button icon="Refresh" @click="resetQuery">重置</el-button>
|
||||||
@ -21,10 +26,14 @@
|
|||||||
<el-button type="primary" plain icon="Plus" @click="handleAdd" v-hasPermi="['question:label:add']">新增</el-button>
|
<el-button type="primary" plain icon="Plus" @click="handleAdd" v-hasPermi="['question:label:add']">新增</el-button>
|
||||||
</el-col>
|
</el-col>
|
||||||
<el-col :span="1.5">
|
<el-col :span="1.5">
|
||||||
<el-button type="success" plain icon="Edit" :disabled="single" @click="handleUpdate()" v-hasPermi="['question:label:edit']">修改</el-button>
|
<el-button type="success" plain @click="handleUpdate()" :disabled="single" icon="Edit" v-hasPermi="['question:label:edit']"
|
||||||
|
>修改
|
||||||
|
</el-button>
|
||||||
</el-col>
|
</el-col>
|
||||||
<el-col :span="1.5">
|
<el-col :span="1.5">
|
||||||
<el-button type="danger" plain icon="Delete" :disabled="multiple" @click="handleDelete()" v-hasPermi="['question:label:remove']">删除</el-button>
|
<el-button type="danger" plain icon="Delete" :disabled="multiple" @click="handleDelete()" v-hasPermi="['question:label:remove']">
|
||||||
|
删除
|
||||||
|
</el-button>
|
||||||
</el-col>
|
</el-col>
|
||||||
<el-col :span="1.5">
|
<el-col :span="1.5">
|
||||||
<el-button type="warning" plain icon="Download" @click="handleExport" v-hasPermi="['question:label:export']">导出</el-button>
|
<el-button type="warning" plain icon="Download" @click="handleExport" v-hasPermi="['question:label:export']">导出</el-button>
|
||||||
@ -33,11 +42,23 @@
|
|||||||
</el-row>
|
</el-row>
|
||||||
</template>
|
</template>
|
||||||
|
|
||||||
<el-table v-loading="loading" :data="labelList" @selection-change="handleSelectionChange">
|
<el-table ref="labelTableRef" v-loading="loading" :data="labelList" @selection-change="handleSelectionChange">
|
||||||
<el-table-column type="selection" width="55" align="center" />
|
<el-table-column type="selection" width="55" align="center" />
|
||||||
<el-table-column label="" align="center" prop="id" v-if="true" />
|
<el-table-column label="序号" align="center" prop="id" v-if="true" />
|
||||||
<el-table-column label="标签名称" align="center" prop="label" />
|
<el-table-column label="标签名称" align="center" prop="label" />
|
||||||
<el-table-column label="标签状态 1:启用 0:禁用" align="center" prop="status" />
|
<el-table-column label="状态" align="center" width="100">
|
||||||
|
<template #default="scope">
|
||||||
|
<el-switch
|
||||||
|
v-model="scope.row.status"
|
||||||
|
inline-prompt
|
||||||
|
active-text="启用"
|
||||||
|
inactive-text="禁用"
|
||||||
|
:active-value="0"
|
||||||
|
:inactive-value="1"
|
||||||
|
@change="handleStatusChange(scope.row)"
|
||||||
|
></el-switch>
|
||||||
|
</template>
|
||||||
|
</el-table-column>
|
||||||
<el-table-column label="操作" align="center" class-name="small-padding fixed-width">
|
<el-table-column label="操作" align="center" class-name="small-padding fixed-width">
|
||||||
<template #default="scope">
|
<template #default="scope">
|
||||||
<el-tooltip content="修改" placement="top">
|
<el-tooltip content="修改" placement="top">
|
||||||
@ -49,10 +70,9 @@
|
|||||||
</template>
|
</template>
|
||||||
</el-table-column>
|
</el-table-column>
|
||||||
</el-table>
|
</el-table>
|
||||||
|
|
||||||
<pagination
|
<pagination
|
||||||
v-show="total>0"
|
v-if="total > 0"
|
||||||
:total="total"
|
v-model:total="total"
|
||||||
v-model:page="queryParams.pageNum"
|
v-model:page="queryParams.pageNum"
|
||||||
v-model:limit="queryParams.pageSize"
|
v-model:limit="queryParams.pageSize"
|
||||||
@pagination="getList"
|
@pagination="getList"
|
||||||
@ -64,6 +84,13 @@
|
|||||||
<el-form-item label="标签名称" prop="label">
|
<el-form-item label="标签名称" prop="label">
|
||||||
<el-input v-model="form.label" placeholder="请输入标签名称" />
|
<el-input v-model="form.label" placeholder="请输入标签名称" />
|
||||||
</el-form-item>
|
</el-form-item>
|
||||||
|
<el-form-item label="状态">
|
||||||
|
<el-radio-group v-model="form.status">
|
||||||
|
<el-radio v-for="dict in dataStatus" :key="dict.value" :label="dict.value">{{
|
||||||
|
dict.label
|
||||||
|
}}</el-radio>
|
||||||
|
</el-radio-group>
|
||||||
|
</el-form-item>
|
||||||
</el-form>
|
</el-form>
|
||||||
<template #footer>
|
<template #footer>
|
||||||
<div class="dialog-footer">
|
<div class="dialog-footer">
|
||||||
@ -76,11 +103,16 @@
|
|||||||
</template>
|
</template>
|
||||||
|
|
||||||
<script setup name="Label" lang="ts">
|
<script setup name="Label" lang="ts">
|
||||||
import { listLabel, getLabel, delLabel, addLabel, updateLabel } from '@/api/question/label';
|
import { listLabel, getLabel, delLabel, addLabel, updateLabel,changeLabelStatus } from '@/api/question/label';
|
||||||
import { LabelVO, LabelQuery, LabelForm } from '@/api/question/label/types';
|
import { LabelVO, LabelQuery, LabelForm } from '@/api/question/label/types';
|
||||||
|
|
||||||
const { proxy } = getCurrentInstance() as ComponentInternalInstance;
|
const { proxy } = getCurrentInstance() as ComponentInternalInstance;
|
||||||
|
|
||||||
|
const dataStatus = ref([
|
||||||
|
{ value: 0, label: "启用" },
|
||||||
|
{ value: 1, label: "禁用" },
|
||||||
|
])
|
||||||
|
|
||||||
const labelList = ref<LabelVO[]>([]);
|
const labelList = ref<LabelVO[]>([]);
|
||||||
const buttonLoading = ref(false);
|
const buttonLoading = ref(false);
|
||||||
const loading = ref(true);
|
const loading = ref(true);
|
||||||
@ -100,8 +132,8 @@ const dialog = reactive<DialogOption>({
|
|||||||
|
|
||||||
const initFormData: LabelForm = {
|
const initFormData: LabelForm = {
|
||||||
id: undefined,
|
id: undefined,
|
||||||
label: undefined,
|
label: "",
|
||||||
status: undefined,
|
status: 1,
|
||||||
}
|
}
|
||||||
const data = reactive<PageData<LabelForm, LabelQuery>>({
|
const data = reactive<PageData<LabelForm, LabelQuery>>({
|
||||||
form: {...initFormData},
|
form: {...initFormData},
|
||||||
@ -121,7 +153,7 @@ const data = reactive<PageData<LabelForm, LabelQuery>>({
|
|||||||
{ required: true, message: "标签名称不能为空", trigger: "blur" }
|
{ required: true, message: "标签名称不能为空", trigger: "blur" }
|
||||||
],
|
],
|
||||||
status: [
|
status: [
|
||||||
{ required: true, message: "标签状态 1:启用 0:禁用不能为空", trigger: "change" }
|
{ required: true, message: "标签状态不能为空", trigger: "change" }
|
||||||
],
|
],
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
@ -168,6 +200,7 @@ const handleSelectionChange = (selection: LabelVO[]) => {
|
|||||||
multiple.value = !selection.length;
|
multiple.value = !selection.length;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
/** 新增按钮操作 */
|
/** 新增按钮操作 */
|
||||||
const handleAdd = () => {
|
const handleAdd = () => {
|
||||||
reset();
|
reset();
|
||||||
@ -185,6 +218,18 @@ const handleUpdate = async (row?: LabelVO) => {
|
|||||||
dialog.title = "修改题目标签";
|
dialog.title = "修改题目标签";
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/** 状态修改 */
|
||||||
|
const handleStatusChange = async (row: LabelVO) => {
|
||||||
|
let text = row.status === 0 ? "启用" : "停用";
|
||||||
|
try {
|
||||||
|
await proxy?.$modal.confirm('确认要"' + text + '"吗?');
|
||||||
|
await changeLabelStatus(row.id, row.status);
|
||||||
|
proxy?.$modal.msgSuccess(text + "成功");
|
||||||
|
} catch {
|
||||||
|
row.status = row.status === 0 ? 1 : 0;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
/** 提交按钮 */
|
/** 提交按钮 */
|
||||||
const submitForm = () => {
|
const submitForm = () => {
|
||||||
labelFormRef.value?.validate(async (valid: boolean) => {
|
labelFormRef.value?.validate(async (valid: boolean) => {
|
||||||
|
Loading…
x
Reference in New Issue
Block a user