From 67cb0df5b96671a2bc7ba5ffd24b33d646716330 Mon Sep 17 00:00:00 2001 From: ks3356143 <314298729@qq.com> Date: Wed, 28 Jun 2023 21:02:31 +0800 Subject: [PATCH] =?UTF-8?q?round=E5=AE=8C=E6=88=90?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- cdTMP/src/api/common.js | 2 +- cdTMP/src/api/project/designDemand.js | 11 +++ cdTMP/src/api/project/round.js | 35 +++++++++ cdTMP/src/api/system/user.js | 13 +++- cdTMP/src/api/testmanage/project.js | 35 ++++++++- cdTMP/src/layout/project-layout.vue | 77 +++++++++++++++---- cdTMP/src/store/modules/user.js | 2 +- cdTMP/src/store/project/treeData.js | 10 ++- .../src/views/dashboard/usermanage/index.vue | 20 ++++- cdTMP/src/views/login.vue | 6 +- cdTMP/src/views/project/dut/index.vue | 10 ++- .../src/views/testmanage/projmanage/index.vue | 12 +-- 12 files changed, 198 insertions(+), 35 deletions(-) diff --git a/cdTMP/src/api/common.js b/cdTMP/src/api/common.js index 381d979..2c15cc6 100644 --- a/cdTMP/src/api/common.js +++ b/cdTMP/src/api/common.js @@ -7,7 +7,7 @@ export default { */ getNoticeList(params = {}) { return request({ - url: "common/getNoticeList", + url: "system/getNoticeList", method: "get", params }) diff --git a/cdTMP/src/api/project/designDemand.js b/cdTMP/src/api/project/designDemand.js index 8209383..1fbc07b 100644 --- a/cdTMP/src/api/project/designDemand.js +++ b/cdTMP/src/api/project/designDemand.js @@ -11,5 +11,16 @@ export default { method: "get", params }) + }, + /** + * 传入id以及data编辑设计需求 + * @returns 成功编辑或失败 + */ + editDesignDemand(id, data = {}) { + return request({ + url: `project/editDesignDemand/` + id, + method: "put", + data + }) } } diff --git a/cdTMP/src/api/project/round.js b/cdTMP/src/api/project/round.js index 016bbf8..28d923a 100644 --- a/cdTMP/src/api/project/round.js +++ b/cdTMP/src/api/project/round.js @@ -10,5 +10,40 @@ export default { method: "get", params }) + }, + /** + * 添加轮次 + * @returns + */ + save(project_id, params = {}) { + return request({ + url: "project/round/save", + method: "post", + data: params, + params: { project_id } + }) + }, + /** + * 更新轮次 + * @returns + */ + update(id, data = {}) { + return request({ + url: "project/round/update/" + id, + method: "put", + data + }) + }, + /** + * 更新轮次 + * @returns + */ + delete(project_id, data = {}) { + return request({ + url: "project/round/delete", + method: "delete", + data, + params: { project_id } + }) } } diff --git a/cdTMP/src/api/system/user.js b/cdTMP/src/api/system/user.js index 6b95035..123eb3f 100644 --- a/cdTMP/src/api/system/user.js +++ b/cdTMP/src/api/system/user.js @@ -90,5 +90,16 @@ export default { method: "put", data }) - } + }, + /** + * 请求所有user信息 + * @returns + */ + getUserDict(params = {}) { + return request({ + url: "system/user/dict", + method: "get", + params + }) + }, } diff --git a/cdTMP/src/api/testmanage/project.js b/cdTMP/src/api/testmanage/project.js index 29bc5ab..4b587ba 100644 --- a/cdTMP/src/api/testmanage/project.js +++ b/cdTMP/src/api/testmanage/project.js @@ -10,5 +10,38 @@ export default { method: "get", params }) - } + }, + /** + * 添加用户 + * @returns + */ + save(params = {}) { + return request({ + url: "testmanage/project/save", + method: "post", + data: params + }) + }, + /** + * 更新数据 + * @returns + */ + update(id, data = {}) { + return request({ + url: "testmanage/project/update/" + id, + method: "put", + data + }) + }, + /** + * 删除项目 + * @returns + */ + delete(data) { + return request({ + url: "testmanage/project/delete", + method: "delete", + data + }) + }, } diff --git a/cdTMP/src/layout/project-layout.vue b/cdTMP/src/layout/project-layout.vue index 7168ba7..2e8a52b 100644 --- a/cdTMP/src/layout/project-layout.vue +++ b/cdTMP/src/layout/project-layout.vue @@ -41,17 +41,23 @@ @click="() => handleRoundAddClick(nodeData)" /> - + + + + + @@ -92,10 +99,12 @@ import PageLayout from "@/layout/page-layout.vue" import MaFormModal from "@/components/ma-form-modal/index.vue" import projectApi from "@/api/project/project" import roundApi from "@/api/project/round" +import { Message } from "@arco-design/web-vue" import { useRoute } from "vue-router" import { useRouter } from "vue-router" import { useTreeDataStore } from "@/store" import { storeToRefs } from "pinia" +import dayjs from "dayjs" //~~~~ 缩小后的menu菜单 const drawerVisible = ref(false) provide("toggleDrawerMenu", () => { @@ -139,7 +148,7 @@ const { treeData, currentNode } = storeToRefs(treeDataStore) const projectInfo = ref({ ...route.query }) const projectId = ref(route.query.id) onMounted(async () => { - treeDataStore.initTreeData(projectId) + treeDataStore.initTreeData(projectId.value) }) /// 点击树状节点-参数1:节点数组,参数2:树node对象 const pointNode = (value, data) => { @@ -209,10 +218,17 @@ const maFormModalRef = ref() const title = ref("") /// 点击新增轮次按钮 const handleRoundAddClick = (nodeData) => { - // 这里是文档写错了 - console.log(maFormModalRef.value.form); + // 这里是文档写错了,调用form是里面组件绑定的数据 maFormModalRef.value.form = {} - maFormModalRef.value.open({}) + maFormModalRef.value.open({ + beginTime: dayjs().format("YYYY-MM-DD"), + grade: "1", + key: `${treeDataStore.treeData.length}`, + name: `第${treeDataStore.treeData.length + 1}轮测试`, + ident: `${route.query.ident}-R${treeDataStore.treeData.length + 1}`, + project: projectId.value + }) + title.value = "新增轮次" } /// 点击编辑轮次按钮 const handleRoundEditClick = async (nodeData) => { @@ -224,8 +240,35 @@ const handleRoundEditClick = async (nodeData) => { title.value = `编辑轮次:${data.data.name}` } /// 点击删除轮次按钮 -const handleRoundDelClick = () => { - console.log("删除轮次") +const handleRoundDelClick = async (value) => { + try { + await roundApi.delete(projectId.value, value) + Message.success("删除成功!") + treeDataStore.resetTreeData(projectId.value) + } catch { + Message.error("删除失败!") + } +} +/// Ma-form-Modal的提交按钮 +const handleRoundSubmit = async (value) => { + console.log(value) + if (title.value.slice(0, 1) === "编") { + try { + await roundApi.update(value.id, value) + Message.success("编辑成功!") + } catch { + Message.error("编辑失败!") + } + } + if (title.value.slice(0, 1) === "新") { + try { + await roundApi.save(projectId.value, value) + Message.success("新增成功!") + treeDataStore.resetTreeData(projectId.value) + } catch { + Message.error("新增失败!") + } + } } /// 设置轮次弹窗的列信息 const roundColumn = ref([ diff --git a/cdTMP/src/store/modules/user.js b/cdTMP/src/store/modules/user.js index a59aeb6..cd44d5e 100644 --- a/cdTMP/src/store/modules/user.js +++ b/cdTMP/src/store/modules/user.js @@ -70,7 +70,7 @@ const useUserStore = defineStore("user", { return loginAPI .login(form) .then((res) => { - if (res.success) { + if (res.data.success === true) { this.setToken(res.data.token) return true } else { diff --git a/cdTMP/src/store/project/treeData.js b/cdTMP/src/store/project/treeData.js index 6cbdc5e..91e89da 100644 --- a/cdTMP/src/store/project/treeData.js +++ b/cdTMP/src/store/project/treeData.js @@ -14,10 +14,16 @@ const useTreeDataStore = defineStore("treeDataStore", { async initTreeData(projectId) { if (this.treeData.length === 0) { const roundData = await projectApi.getRoundInfo(projectId) - this.treeData = roundData - this.originTreeData = roundData + this.treeData = roundData.data + this.originTreeData = roundData.data } }, + // 用于新增轮次后显示 + async resetTreeData(projectId) { + const roundData = await projectApi.getRoundInfo(projectId) + this.treeData = roundData.data + this.originTreeData = roundData.data + }, setCurrentNode(nodeKey) { this.currentNode = nodeKey } diff --git a/cdTMP/src/views/dashboard/usermanage/index.vue b/cdTMP/src/views/dashboard/usermanage/index.vue index 6c829ee..bd5443d 100644 --- a/cdTMP/src/views/dashboard/usermanage/index.vue +++ b/cdTMP/src/views/dashboard/usermanage/index.vue @@ -29,6 +29,7 @@ import { reactive, ref, onMounted } from "vue" import MaTreeSlider from "@/components/ma-treeSlider/index.vue" import userApi from "@/api/system/user" import user from "@/api/system/user" +import { Message } from "@arco-design/web-vue" // 切换状态按钮 const changeStatus = (e, id) => { console.log("当前值:", e) @@ -183,9 +184,24 @@ const crudOptions = reactive({ viewType: "modal" // isFull: true }, + // 用户点击编辑/删除前的hook + beforeOpenEdit: (record) => { + if (record.id === 1) { + Message.error("创始人不可编辑,请关闭窗口!") + return false + } + return true + }, + beforeDelete: (ids) => { + if (ids.includes(1)) { + Message.error("创始人不可删除") + return false + } + return true + } }) const crudColumns = reactive([ - { title: "ID", dataIndex: "id", addDisplay: false, editDisplay: false, width: 50, hide: false, search: true }, + { title: "ID", dataIndex: "id", addDisplay: false, editDisplay: false, width: 50, hide: false }, { title: "名称", align: "center", @@ -235,7 +251,7 @@ const crudColumns = reactive([ }, { title: "注册时间", - dataIndex: "created_at", + dataIndex: "create_datetime", align: "center", width: 180, addDisplay: false, diff --git a/cdTMP/src/views/login.vue b/cdTMP/src/views/login.vue index 611dffa..27aa3a8 100644 --- a/cdTMP/src/views/login.vue +++ b/cdTMP/src/views/login.vue @@ -100,9 +100,11 @@ const handleSubmit = async ({ values, errors }) => { await userStore.login(form) const { redirect, ...otherQuery } = router.currentRoute.value.query router.push({ - name: redirect || "Workplace" + name: redirect || "Workplace", + query:{ + ...otherQuery // 将退出时的查询参数放入,这样就不会错误 + } }) - Message.success("登录成功,等待跳转") } catch (err) { errorMessage.value = err.message } finally { diff --git a/cdTMP/src/views/project/dut/index.vue b/cdTMP/src/views/project/dut/index.vue index fe2d421..ddddca1 100644 --- a/cdTMP/src/views/project/dut/index.vue +++ b/cdTMP/src/views/project/dut/index.vue @@ -26,18 +26,20 @@ const crudOptions = ref({ showIndex: false, rowSelection: { showCheckedAll: true }, add: { show: true }, - edit: { show: true }, + edit: { show: true, api: designDemandApi.editDesignDemand }, delete: { show: true }, searchColNumber: 3, tablePagination: true, operationColumn: true, + operationColumnAlign:'center', formOption: { - width: 1200 + width: 1200, } }) const crudColumns = ref([ { title: "ID", + align:'center', width: 50, dataIndex: "id", search: true, @@ -46,6 +48,7 @@ const crudColumns = ref([ }, { title: "标识", + align:'center', width: 120, dataIndex: "ident", search: true, @@ -54,6 +57,7 @@ const crudColumns = ref([ }, { title: "需求名称", + align:'center', width: 150, dataIndex: "name", search: true, @@ -63,6 +67,7 @@ const crudColumns = ref([ { title: "需求类型", width: 150, + align:'center', dataIndex: "demandType", formType: "radio", search: true, @@ -73,6 +78,7 @@ const crudColumns = ref([ { title: "需求描述", dataIndex: "description", + hide:true, width: 300, formType: "editor", height: 300 diff --git a/cdTMP/src/views/testmanage/projmanage/index.vue b/cdTMP/src/views/testmanage/projmanage/index.vue index a9108d2..377b131 100644 --- a/cdTMP/src/views/testmanage/projmanage/index.vue +++ b/cdTMP/src/views/testmanage/projmanage/index.vue @@ -23,9 +23,9 @@ const crudRef = ref() const crudOptions = ref({ rowSelection: { showCheckedAll: true }, api: projectApi.getPageList, - add: { show: true }, - edit: { show: true }, - delete: { show: true }, + add: { show: true,api: projectApi.save}, + edit: { show: true,api: projectApi.update}, + delete: { show: true ,api:projectApi.delete}, searchColNumber: 3, tablePagination: true, operationColumn: true, @@ -193,7 +193,7 @@ const crudColumns = ref([ search: true, commonRules: [{ required: true, message: "责任人必选" }], formType: "select", - dict: { url: "system/user/index", props: { label: "name", value: "name" }, translation: true } + dict: { url: "system/user/list", props: { label: "name", value: "name" }, translation: true } }, { title: "成员", @@ -202,7 +202,7 @@ const crudColumns = ref([ search: true, formType: "select", multiple: true, - dict: { url: "system/user/index", props: { label: "name", value: "name" }, translation: true }, + dict: { url: "system/user/list", props: { label: "name", value: "name" }, translation: true }, commonRules: [{ required: true, message: "成员至少选择一个" }] }, { @@ -213,7 +213,7 @@ const crudColumns = ref([ commonRules: [{ required: true, message: "关键等级必填" }], search: true, formType: "radio", - dict: { name: "security_level", props: { label: "value", value: "key" } } + dict: { name: "security_level", props: { label: "title", value: "key" } } }, { title: "测试级别",