diff --git a/src/api/question/title/types.ts b/src/api/question/title/types.ts
index 2d66ac8..7b6e401 100644
--- a/src/api/question/title/types.ts
+++ b/src/api/question/title/types.ts
@@ -16,8 +16,7 @@ export interface TitleVO {
labelName : string;
- // optionVoList : OptionVoList[];
-
+ optionVoList : OptionVoList[];
}
export interface TitleForm extends BaseEntity {
@@ -61,13 +60,8 @@ export interface TitleQuery extends PageQuery {
}
export interface OptionVoList {
-
- id : number,
-
serial : number;
- questionId : number;
-
optionContent : string;
}
diff --git a/src/components/Options/index.vue b/src/components/Options/index.vue
index 98691e1..bcbe60f 100644
--- a/src/components/Options/index.vue
+++ b/src/components/Options/index.vue
@@ -4,7 +4,7 @@
:prop="`gearValue[${index}]`" :rules="ruleValidate" align="center" prop="options">
-
+
diff --git a/src/views/question/title/index.vue b/src/views/question/title/index.vue
index da24bd3..ccef061 100644
--- a/src/views/question/title/index.vue
+++ b/src/views/question/title/index.vue
@@ -49,9 +49,9 @@
-
+
@@ -71,24 +71,43 @@
v-model:limit="queryParams.pageSize" @pagination="getList" />
-
+
-
-
+
+
-
-
-
-
-
+
+
+
+
+
+
+
+
+
@@ -118,7 +137,10 @@ const ids = ref>([]);
const single = ref(true);
const multiple = ref(true);
const total = ref(0);
-const labelList = ref([]); let posNum = 20
+const labelList = ref([]);
+const isSee = ref(false);
+const maxPosLen = ref(20);
+const posNum = ref(1);
const queryFormRef = ref();
const titleFormRef = ref();
@@ -133,7 +155,12 @@ const initFormData: TitleForm = {
question: undefined,
labelId: undefined,
labelName: "",
- optionVoList: [],
+ optionVoList: [
+ {
+ serial:1,
+ optionContent:"",
+ }
+ ],
}
const data = reactive>({
form: { ...initFormData },
@@ -155,6 +182,9 @@ const data = reactive>({
labelId: [
{ required: true, message: "标签不能为空", trigger: "change" }
],
+ optionVoList: [
+ { required: true, message: "标签不能为空", trigger: "change" }
+ ],
}
});
@@ -172,7 +202,7 @@ const getList = async () => {
const getLabelList = async () => {
loading.value = true;
queryAllLabel().then((resp) => {
- labelList.value = resp.data.map((p: any): DictDataOption => ({ label: p.label, value: p.value, elTagType: "", elTagClass: "" }));
+ labelList.value = resp.data.map((p: any): DictDataOption => ({ label: p.label, value: p.value, elTagType: "", elTagClass: "primary" }));
});
loading.value = false;
}
@@ -181,6 +211,7 @@ function handleLabelChange(val: string) {
const selectedLabel = labelList.value.find(item => item.value === val);
if (selectedLabel) {
form.value.labelName = selectedLabel.label;
+ form.value.labelId = selectedLabel.value;
}
}
@@ -193,6 +224,7 @@ const cancel = () => {
/** 表单重置 */
const reset = () => {
form.value = { ...initFormData };
+ posNum.value = 1;
titleFormRef.value?.resetFields();
}
@@ -229,6 +261,8 @@ const handleUpdate = async (row?: TitleVO) => {
const res = await getTitle(_id);
Object.assign(form.value, res.data);
dialog.visible = true;
+ form.value.optionVoList = res.data.optionVoList;
+ posNum.value = form.value.optionVoList.length;
dialog.title = "修改题目";
}
@@ -273,39 +307,19 @@ const handleExport = () => {
const changePos = (idx: number, actType: string) => {
if (actType === 'add') {
if (form.value.optionVoList.length < 20) {
- posNum++;
+ posNum.value++;
+ form.value.optionVoList.push({
+ serial:posNum.value,
+ optionContent:"",
+ });
form.value.optionVoList.splice(idx + 1, 0);
}
} else {
form.value.optionVoList.splice(idx, 1);
- posNum--;
+ posNum.value--;
}
}
-/**
- * 提交的校验
- */
-const handleValidate = () =>{
- return new Promise((resolve, reject) => {
- $refs.formPosition.validate((valid) => {
- if (valid) {
- // 数据转换为接口所需要的形式
- let obj = {};
- if (form.value.optionVoList) {
- if (form.value.optionVoList.length[0] === null) {
- obj.optionVoList = null;
- } else {
- obj.optionVoList = form.value.optionVoList.join();
- }
- } else {
- obj.optionVoList = null;
- }
- resolve(obj)
- }
- })
- })
-}
-
onMounted(() => {
getList();
getLabelList();
@@ -317,7 +331,7 @@ onMounted(() => {
display: inline-block;
vertical-align: middle;
margin-left: 10px;
- width: 20px;
+ width: 30px;
cursor: pointer;
}