diff --git a/cdTMP/src/api/project/dut.js b/cdTMP/src/api/project/dut.js index 187eed2..687f871 100644 --- a/cdTMP/src/api/project/dut.js +++ b/cdTMP/src/api/project/dut.js @@ -7,9 +7,42 @@ export default { */ getDutList(params = {}) { return request({ - url: `project/getDutList`, + url: `/project/getDutList`, method: "get", params }) - } + }, + /** + * 添加被测件 + * @returns + */ + save(params = {}) { + return request({ + url: "/project/dut/save", + method: "post", + data: params + }) + }, + /** + * 更新dut + * @returns + */ + update(id, data = {}) { + return request({ + url: "/project/dut/update/" + id, + method: "put", + data + }) + }, + /** + * 删除dut + * @returns + */ + delete(data) { + return request({ + url: "/project/dut/delete", + method: "delete", + data + }) + }, } diff --git a/cdTMP/src/components/ma-crud/components/form.vue b/cdTMP/src/components/ma-crud/components/form.vue index b7dd732..3f7ca00 100644 --- a/cdTMP/src/components/ma-crud/components/form.vue +++ b/cdTMP/src/components/ma-crud/components/form.vue @@ -65,13 +65,24 @@ const submit = async () => { } let response + // 在这里添加我们自定义的parameters,注意判断options中是否有parameters-key if (currentAction.value === "add") { isFunction(options.beforeAdd) && (await options.beforeAdd(formData)) - response = await options.add.api(formData) + // 首先判断是否options.parameters存在 + if (!options.parameters) { + response = await options.add.api(formData) + } else { + response = await options.add.api({ ...formData, ...options.parameters }) + } isFunction(options.afterAdd) && (await options.afterAdd(response, formData)) } else { isFunction(options.beforeEdit) && (await options.beforeEdit(formData)) - response = await options.edit.api(formData[options.pk], formData) + // 编辑也需要更新 + if (!options.parameters) { + response = await options.edit.api(formData[options.pk], formData) + } else { + response = await options.edit.api(formData[options.pk], { ...formData, ...options.parameters }) + } isFunction(options.afterEdit) && (await options.afterEdit(response, formData)) } if (response.success) { diff --git a/cdTMP/src/layout/project-layout.vue b/cdTMP/src/layout/project-layout.vue index 0ab9858..22cfa78 100644 --- a/cdTMP/src/layout/project-layout.vue +++ b/cdTMP/src/layout/project-layout.vue @@ -255,7 +255,6 @@ const handleRoundDelClick = async (value) => { } /// Ma-form-Modal的提交按钮 const handleRoundSubmit = async (value) => { - console.log(value) if (title.value.slice(0, 1) === "编") { try { await roundApi.update(value.id, value) diff --git a/cdTMP/src/views/project/round/index.vue b/cdTMP/src/views/project/round/index.vue index fe52e61..fa100fd 100644 --- a/cdTMP/src/views/project/round/index.vue +++ b/cdTMP/src/views/project/round/index.vue @@ -47,20 +47,21 @@ import { useRoute, useRouter } from "vue-router" import dutApi from "@/api/project/dut" const route = useRoute() const router = useRouter() +const roundNumber = route.query.key.split("-")[0] // crud组件 const crudOptions = ref({ api: dutApi.getDutList, + add: { show: true, api: dutApi.save }, + edit: { show: true, api: dutApi.update }, + delete: { show: true, api: dutApi.delete }, parameters: { projectId: route.query.id, - round: route.query.key + round: roundNumber, }, - operationWidth: 200, + operationWidth: 500, showIndex: false, rowSelection: { showCheckedAll: true }, - add: { show: true }, - edit: { show: true }, - delete: { show: true }, searchColNumber: 3, tablePagination: false, operationColumn: true,