|
@@ -46,20 +46,18 @@
|
|
dataIndex: 'action',
|
|
dataIndex: 'action',
|
|
slots: { customRender: 'action' },
|
|
slots: { customRender: 'action' },
|
|
}"
|
|
}"
|
|
- @edit-change="handelDetailChange"
|
|
|
|
>
|
|
>
|
|
<template #action="{ record, index }">
|
|
<template #action="{ record, index }">
|
|
<TableAction :actions="createActions(record, field, index)" />
|
|
<TableAction :actions="createActions(record, field, index)" />
|
|
</template>
|
|
</template>
|
|
<template #toolbar>
|
|
<template #toolbar>
|
|
- <Button type="primary" ghost @click="addDetailRow(model, field)" block>
|
|
|
|
- 添加一行
|
|
|
|
- </Button>
|
|
|
|
|
|
+ <Button type="primary" ghost @click="addDetailRow(field)" block> 添加一行 </Button>
|
|
</template>
|
|
</template>
|
|
</BasicTable>
|
|
</BasicTable>
|
|
</div>
|
|
</div>
|
|
</template>
|
|
</template>
|
|
</BasicForm>
|
|
</BasicForm>
|
|
|
|
+ <FormEdit @register="registerEditModal" @success="handleSuccess" />
|
|
</BasicDrawer>
|
|
</BasicDrawer>
|
|
</template>
|
|
</template>
|
|
<script setup lang="ts">
|
|
<script setup lang="ts">
|
|
@@ -79,6 +77,10 @@
|
|
} from '/@/services/apis/EvaluateItemController';
|
|
} from '/@/services/apis/EvaluateItemController';
|
|
|
|
|
|
import { buildUUID } from '/@/utils/uuid';
|
|
import { buildUUID } from '/@/utils/uuid';
|
|
|
|
+ import FormEdit from './termEdit.vue';
|
|
|
|
+ import { useModal } from '/@/components/Modal';
|
|
|
|
+
|
|
|
|
+ const [registerEditModal, { openModal }] = useModal();
|
|
|
|
|
|
const isUpdate = ref(true);
|
|
const isUpdate = ref(true);
|
|
const modelRef = ref({});
|
|
const modelRef = ref({});
|
|
@@ -131,6 +133,8 @@
|
|
problem: ic.problem,
|
|
problem: ic.problem,
|
|
score: ic.score,
|
|
score: ic.score,
|
|
inputNotNull: ic.inputNotNull === 1,
|
|
inputNotNull: ic.inputNotNull === 1,
|
|
|
|
+ type: ic.type,
|
|
|
|
+ optionJson: ic.optionJson,
|
|
});
|
|
});
|
|
});
|
|
});
|
|
formData[`table${index}`] = tableData;
|
|
formData[`table${index}`] = tableData;
|
|
@@ -185,54 +189,74 @@
|
|
// rowTotal.value--;
|
|
// rowTotal.value--;
|
|
};
|
|
};
|
|
|
|
|
|
- const addDetailRow = (model, field) => {
|
|
|
|
- const item = model[field] || [];
|
|
|
|
- item.push({
|
|
|
|
|
|
+ const addDetailRow = (field) => {
|
|
|
|
+ const item = {
|
|
key: buildUUID(),
|
|
key: buildUUID(),
|
|
problem: '',
|
|
problem: '',
|
|
score: 0,
|
|
score: 0,
|
|
|
|
+ type: 1,
|
|
inputNotNull: true,
|
|
inputNotNull: true,
|
|
|
|
+ };
|
|
|
|
+
|
|
|
|
+ openModal(true, {
|
|
|
|
+ isUpdate: false,
|
|
|
|
+ baseData: {
|
|
|
|
+ field: field,
|
|
|
|
+ item: item,
|
|
|
|
+ index: -1,
|
|
|
|
+ },
|
|
});
|
|
});
|
|
- model[field] = item;
|
|
|
|
- setFieldsValue(model);
|
|
|
|
|
|
+ // setFieldsValue(model);
|
|
};
|
|
};
|
|
|
|
|
|
- const createActions = (record: EditRecordRow, field: String, index: Number): ActionItem[] => {
|
|
|
|
- if (!record.editable) {
|
|
|
|
- return [
|
|
|
|
- {
|
|
|
|
- label: '编辑',
|
|
|
|
- disabled: currentEditKeyRef.value ? currentEditKeyRef.value !== record.key : false,
|
|
|
|
- onClick: handleDetailEdit.bind(null, record),
|
|
|
|
- },
|
|
|
|
- {
|
|
|
|
- label: '上移',
|
|
|
|
- disabled: currentEditKeyRef.value ? currentEditKeyRef.value !== record.key : false,
|
|
|
|
- onClick: handelDetailMove.bind(null, field, index, 1),
|
|
|
|
- },
|
|
|
|
- {
|
|
|
|
- label: '下移',
|
|
|
|
- disabled: currentEditKeyRef.value ? currentEditKeyRef.value !== record.key : false,
|
|
|
|
- onClick: handelDetailMove.bind(null, field, index, 2),
|
|
|
|
- },
|
|
|
|
- {
|
|
|
|
- label: '删除',
|
|
|
|
- disabled: currentEditKeyRef.value ? currentEditKeyRef.value !== record.key : false,
|
|
|
|
- onClick: handleDetailDelete.bind(null, record, field),
|
|
|
|
- },
|
|
|
|
- ];
|
|
|
|
|
|
+ const editDetailRow = (record, field, index) => {
|
|
|
|
+ openModal(true, {
|
|
|
|
+ isUpdate: true,
|
|
|
|
+ baseData: {
|
|
|
|
+ field: field,
|
|
|
|
+ index: index,
|
|
|
|
+ item: { ...record },
|
|
|
|
+ },
|
|
|
|
+ });
|
|
|
|
+ // setFieldsValue(model);
|
|
|
|
+ };
|
|
|
|
+
|
|
|
|
+ const handleSuccess = async (baseData, isUpdate) => {
|
|
|
|
+ const formData = getFieldsValue();
|
|
|
|
+ const { field, item, index } = baseData;
|
|
|
|
+
|
|
|
|
+ if (!isUpdate) {
|
|
|
|
+ const dataRow = formData[`${field}`] || [];
|
|
|
|
+ dataRow.push({ ...item });
|
|
|
|
+ formData[`${field}`] = dataRow;
|
|
|
|
+ setFieldsValue(formData);
|
|
|
|
+ } else {
|
|
|
|
+ formData[`${field}`][index] = { ...item };
|
|
|
|
+ setFieldsValue(formData);
|
|
}
|
|
}
|
|
|
|
+ };
|
|
|
|
+
|
|
|
|
+ const createActions = (record: EditRecordRow, field: String, index: Number): ActionItem[] => {
|
|
return [
|
|
return [
|
|
{
|
|
{
|
|
- label: '保存',
|
|
|
|
- onClick: handleDetailSave.bind(null, record),
|
|
|
|
|
|
+ label: '编辑',
|
|
|
|
+ disabled: currentEditKeyRef.value ? currentEditKeyRef.value !== record.key : false,
|
|
|
|
+ onClick: editDetailRow.bind(null, record, field, index),
|
|
},
|
|
},
|
|
{
|
|
{
|
|
- label: '取消',
|
|
|
|
- popConfirm: {
|
|
|
|
- title: '是否取消编辑',
|
|
|
|
- confirm: handleDetailCancel.bind(null, record),
|
|
|
|
- },
|
|
|
|
|
|
+ label: '上移',
|
|
|
|
+ disabled: currentEditKeyRef.value ? currentEditKeyRef.value !== record.key : false,
|
|
|
|
+ onClick: handelDetailMove.bind(null, field, index, 1),
|
|
|
|
+ },
|
|
|
|
+ {
|
|
|
|
+ label: '下移',
|
|
|
|
+ disabled: currentEditKeyRef.value ? currentEditKeyRef.value !== record.key : false,
|
|
|
|
+ onClick: handelDetailMove.bind(null, field, index, 2),
|
|
|
|
+ },
|
|
|
|
+ {
|
|
|
|
+ label: '删除',
|
|
|
|
+ disabled: currentEditKeyRef.value ? currentEditKeyRef.value !== record.key : false,
|
|
|
|
+ onClick: handleDetailDelete.bind(null, record, field),
|
|
},
|
|
},
|
|
];
|
|
];
|
|
};
|
|
};
|
|
@@ -262,16 +286,6 @@
|
|
setFieldsValue(formData);
|
|
setFieldsValue(formData);
|
|
};
|
|
};
|
|
|
|
|
|
- const handleDetailEdit = (record: EditRecordRow) => {
|
|
|
|
- currentEditKeyRef.value = record.key;
|
|
|
|
- record.onEdit?.(true);
|
|
|
|
- };
|
|
|
|
-
|
|
|
|
- const handleDetailCancel = (record: EditRecordRow) => {
|
|
|
|
- currentEditKeyRef.value = '';
|
|
|
|
- record.onEdit?.(false, false);
|
|
|
|
- };
|
|
|
|
-
|
|
|
|
const handleDetailDelete = (record: EditRecordRow, field: string) => {
|
|
const handleDetailDelete = (record: EditRecordRow, field: string) => {
|
|
currentEditKeyRef.value = '';
|
|
currentEditKeyRef.value = '';
|
|
const formData = getFieldsValue();
|
|
const formData = getFieldsValue();
|
|
@@ -279,37 +293,6 @@
|
|
setFieldsValue(formData);
|
|
setFieldsValue(formData);
|
|
};
|
|
};
|
|
|
|
|
|
- const handleDetailSave = async (record: EditRecordRow) => {
|
|
|
|
- // 校验
|
|
|
|
- // createMessage.loading({ content: '正在保存...', duration: 0, key: 'saving' });
|
|
|
|
- const valid = await record.onValid?.();
|
|
|
|
- if (valid) {
|
|
|
|
- try {
|
|
|
|
- // const data = cloneDeep(record.editValueRefs);
|
|
|
|
- const pass = await record.onEdit?.(false, true);
|
|
|
|
- if (pass) {
|
|
|
|
- currentEditKeyRef.value = '';
|
|
|
|
- // const formData = getFieldsValue();
|
|
|
|
- // console.log('handleDetailSave', data, field);
|
|
|
|
- // formData[field] = data;
|
|
|
|
- // setFieldsValue({})
|
|
|
|
- // console.log('handleDetailSave from', formData);
|
|
|
|
- }
|
|
|
|
- // createMessage.success({ content: '数据已保存', key: 'saving' });
|
|
|
|
- } catch (error) {
|
|
|
|
- // createMessage.error({ content: '保存失败', key: 'saving' });
|
|
|
|
- }
|
|
|
|
- } else {
|
|
|
|
- // createMessage.error({ content: '请完善数据', key: 'saving' });
|
|
|
|
- }
|
|
|
|
- };
|
|
|
|
-
|
|
|
|
- const handelDetailChange = ({ column, value, record }) => {
|
|
|
|
- if (column.dataIndex === 'id') {
|
|
|
|
- // record.editValueRefs.name4.value = `${value}`;
|
|
|
|
- }
|
|
|
|
- };
|
|
|
|
-
|
|
|
|
const getTitle = computed(() => (!unref(isUpdate) ? '评价项' : '评价项'));
|
|
const getTitle = computed(() => (!unref(isUpdate) ? '评价项' : '评价项'));
|
|
const handleSubmit = async () => {
|
|
const handleSubmit = async () => {
|
|
try {
|
|
try {
|
|
@@ -327,6 +310,8 @@
|
|
score: item.score,
|
|
score: item.score,
|
|
inputNotNull: item.inputNotNull ? 1 : 0,
|
|
inputNotNull: item.inputNotNull ? 1 : 0,
|
|
problem: item.problem,
|
|
problem: item.problem,
|
|
|
|
+ type: item.type,
|
|
|
|
+ optionJson: item.optionJson,
|
|
});
|
|
});
|
|
});
|
|
});
|
|
}
|
|
}
|