更新版本
This commit is contained in:
@@ -99,10 +99,15 @@ const submit = async () => {
|
||||
if (isFunction(options.beforeEdit) && !(await options.beforeEdit(formData))) {
|
||||
return false
|
||||
}
|
||||
if (!options.parameters) {
|
||||
response = await options.edit.api(formData[options.pk], formData)
|
||||
} else {
|
||||
response = await options.edit.api(formData[options.pk], { ...formData, ...options.parameters })
|
||||
// 修改源码2025-06-24,使用try...catch捕获信息
|
||||
try {
|
||||
if (!options.parameters) {
|
||||
response = await options.edit.api(formData[options.pk], formData)
|
||||
} else {
|
||||
response = await options.edit.api(formData[options.pk], { ...formData, ...options.parameters })
|
||||
}
|
||||
} catch (e) {
|
||||
return false
|
||||
}
|
||||
isFunction(options.afterEdit) && (await options.afterEdit(response, formData))
|
||||
}
|
||||
|
||||
@@ -61,7 +61,7 @@
|
||||
</a-button>
|
||||
</a-tooltip>
|
||||
<a-button-group shape="round" size="mini">
|
||||
<a-button type="primary" @click="moveUp(index)">
|
||||
<a-button type="primary" @click="moveUp(index)">
|
||||
<icon-arrow-rise />
|
||||
</a-button>
|
||||
<a-button type="primary" @click="moveDown(index)">
|
||||
@@ -100,6 +100,7 @@
|
||||
|
||||
<script setup lang="ts">
|
||||
import { type Ref, nextTick } from "vue"
|
||||
import { cloneDeep } from "lodash-es"
|
||||
|
||||
// 辅助函数:当modelValue不是列表时候
|
||||
function handleIsNotArray() {
|
||||
@@ -129,7 +130,7 @@ const deleteItem = (index: number) => {
|
||||
|
||||
// 复制单项
|
||||
const copyItem = (index: number) => {
|
||||
const newItem = modelValue.value[index]
|
||||
const newItem = cloneDeep(modelValue.value[index])
|
||||
modelValue.value = [...modelValue.value, newItem]
|
||||
}
|
||||
|
||||
|
||||
@@ -261,6 +261,20 @@ function swapItems(idx1, idx2) {
|
||||
;[arr[idx1], arr[idx2]] = [arr[idx2], arr[idx1]]
|
||||
}
|
||||
|
||||
// 辅助函数:触发充分性分析
|
||||
// 2025-06-24:新增子项后需对触发更新
|
||||
function updateChongFen() {
|
||||
if (formModel.value.testContent && formModel.value.testContent.length > 0) {
|
||||
// 如果有testContent则更新“充分性要求”
|
||||
const subItemFormData = formModel.value.testContent
|
||||
const mapRes = subItemFormData.map((subItem) => subItem.subName || "")
|
||||
formModel.value.adequacy &&
|
||||
(formModel.value.adequacy = `测试用例覆盖${mapRes.join(
|
||||
"、"
|
||||
)}子项要求的全部内容。\n所有用例执行完毕,对于未执行的用例说明未执行原因。`)
|
||||
}
|
||||
}
|
||||
|
||||
// 修改源码:上移动和下移动
|
||||
const moveUp = (itemIndex) => {
|
||||
const itemLength = formModel.value[props.component.dataIndex].length
|
||||
@@ -270,6 +284,8 @@ const moveUp = (itemIndex) => {
|
||||
}
|
||||
// 进行移动
|
||||
swapItems(itemIndex, itemIndex - 1)
|
||||
// 2025-06-24修改
|
||||
updateChongFen()
|
||||
}
|
||||
|
||||
const moveDown = (itemIndex) => {
|
||||
@@ -280,6 +296,8 @@ const moveDown = (itemIndex) => {
|
||||
}
|
||||
// 进行移动
|
||||
swapItems(itemIndex, itemIndex + 1)
|
||||
// 2025-06-24修改
|
||||
updateChongFen()
|
||||
}
|
||||
|
||||
const addItem = async (data = {}) => {
|
||||
@@ -289,6 +307,8 @@ const addItem = async (data = {}) => {
|
||||
viewFormList.value[index] = cloneDeep(formList)
|
||||
rv("onAdd", { formList: viewFormList.value[index], newData, index }) // 修改源码:深度复制data->newData
|
||||
formModel.value[props.component.dataIndex].push(newData) // 修改源码:深度复制data->newData
|
||||
// 修改源码,触发充分性更新
|
||||
updateChongFen()
|
||||
}
|
||||
|
||||
const deleteItem = async (index) => {
|
||||
@@ -298,6 +318,8 @@ const deleteItem = async (index) => {
|
||||
await nextTick()
|
||||
formModel.value[props.component.dataIndex].splice(index, 1)
|
||||
}
|
||||
// 2025-06-24修改
|
||||
updateChongFen()
|
||||
}
|
||||
|
||||
const getChildrenDataIndex = (index, dataIndex) => {
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
<template>
|
||||
<a-modal v-model:visible="visible" width="80%" draggable :footer="false" unmount-on-close>
|
||||
<a-modal v-model:visible="visible" width="80%" draggable :footer="false">
|
||||
<template #title>维护数据字典 →【{{ currentRow.name }}】</template>
|
||||
<!-- crud组件 -->
|
||||
<div class="lg:w-full w-full lg:mt-0">
|
||||
@@ -35,6 +35,7 @@ import useOpenChangeModal from "./useOpenChangeModal"
|
||||
|
||||
const currentRow = ref({ id: undefined, name: undefined }) // 当前选择的行
|
||||
const { crudRef, crudOptions, columns } = useCrudRef(currentRow)
|
||||
|
||||
const { visible, changeSort, changeStatus, open } = useOpenChangeModal(crudRef, currentRow)
|
||||
// 暴露自己的open方法
|
||||
defineExpose({ open })
|
||||
|
||||
@@ -24,10 +24,14 @@ export default function (updateApiFunc: Function, updateTreeFunc: Function, widt
|
||||
return false
|
||||
} else {
|
||||
// 成功 **变化**
|
||||
const res = await updateApiFunc(formData.value.id, { project_id, ...formData.value })
|
||||
updateTreeFunc(res.data, project_id) // 刷新树节点信息
|
||||
!(rightViewRef as any).value.refresh()
|
||||
Message.success("修改成功")
|
||||
try {
|
||||
const res = await updateApiFunc(formData.value.id, { project_id, ...formData.value })
|
||||
updateTreeFunc(res.data, project_id) // 刷新树节点信息
|
||||
!(rightViewRef as any).value.refresh()
|
||||
Message.success("修改成功")
|
||||
} catch (e) {
|
||||
return false
|
||||
}
|
||||
}
|
||||
}
|
||||
const modalOptions = {
|
||||
|
||||
Reference in New Issue
Block a user