From 15744ad56cd9dc04baa48853ea69228f03f1569f Mon Sep 17 00:00:00 2001 From: MEMA <957397192@qq.com> Date: Sun, 8 Sep 2024 01:55:01 +0800 Subject: [PATCH] =?UTF-8?q?=F0=9F=93=A6=20=E9=87=8D=E6=9E=84=E5=B7=A5?= =?UTF-8?q?=E5=85=B7=E9=93=BE=E6=8E=A5=E6=A8=A1=E5=9D=97=EF=BC=8C=E6=9C=AA?= =?UTF-8?q?=E8=81=94=E8=B0=83?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- mock/toolLink.js | 23 +- src/views/canteen/toolLink/editToolLink.vue | 324 +++++++++++++++----- src/views/canteen/toolLink/index.vue | 8 +- vue.config.js | 2 +- 4 files changed, 279 insertions(+), 78 deletions(-) diff --git a/mock/toolLink.js b/mock/toolLink.js index 384d3ca..dc6f6b5 100644 --- a/mock/toolLink.js +++ b/mock/toolLink.js @@ -15,11 +15,26 @@ module.exports = [ platformTable[i] = Mock.mock({ id: i, - nickname: "name"+i, - avatar: "platform"+i, - jump_url: "url"+i, + icon_url: "platform"+i, + links: [], min_request_interval:minTime, - "has_datasource|1": true + "has_datasource|1": true, + localized_name: { + zh_CN: "name"+i, + en_US: "name"+i + }, + localized_description: { + zh_CN: "description"+i, + en_US: "description"+i + }, + localized_slogan: { + zh_CN: "slogan"+i, + en_US: "slogan"+i + }, + localized_tags: { + zh_CN: ["tags"+i], + en_US: ["tags"+i] + } }); } let data = { diff --git a/src/views/canteen/toolLink/editToolLink.vue b/src/views/canteen/toolLink/editToolLink.vue index 547fa5c..87d63ef 100644 --- a/src/views/canteen/toolLink/editToolLink.vue +++ b/src/views/canteen/toolLink/editToolLink.vue @@ -14,30 +14,33 @@ label-position="right" label-width="120px" :rules="toolLinkRules" > - - + + - + + + + - - + + - - + + - - + + - + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + { - this.$message({ - showClose: true, - message: "创建成功", - type: "success", - }); - this.showDraw = false; - this.init(); - }).catch(() =>{ - this.$message({ - showClose: true, - message: "创建失败", - type: "error", + let allPass = true; + this.$refs["toolLinkForm"].validate((valid) => { + if (!valid) { + allPass = false; + return; + } + }); + if (allPass) + this.$store + .dispatch("toolLink/createToolLink",this.toolLinkData) + .then(() => { + this.$message({ + showClose: true, + message: "创建成功", + type: "success", + }); + this.showDraw = false; + this.init(); + }).catch(() =>{ + this.$message({ + showClose: true, + message: "创建失败", + type: "error", + }); + }).finally(()=>{ + this.$emit("uploadDone"); }); - }).finally(()=>{ - this.$emit("uploadDone"); - }); }, updateData() { - this.$store - .dispatch("toolLink/updateToolLink",this.toolLinkData) - .then(() => { - this.$message({ - showClose: true, - message: "修改成功", - type: "success", - }); - this.showDraw = false; - this.init(); - }).catch(() =>{ - this.$message({ - showClose: true, - message: "修改失败", - type: "error", + let allPass = true; + this.$refs["toolLinkForm"].validate((valid) => { + if (!valid) { + allPass = false; + return; + } + }); + if (allPass) + this.$store + .dispatch("toolLink/updateToolLink",this.toolLinkData) + .then(() => { + this.$message({ + showClose: true, + message: "修改成功", + type: "success", + }); + this.showDraw = false; + this.init(); + }).catch(() =>{ + this.$message({ + showClose: true, + message: "修改失败", + type: "error", + }); + }).finally(()=>{ + this.$emit("uploadDone"); }); - }).finally(()=>{ - this.$emit("uploadDone"); - }); }, // 更改跳转链接空为null changeEmptyToNull() { if (this.toolLinkData.jump_url.trim() == '') { this.toolLinkData.jump_url = null; } + }, + addLink() { + this.toolLinkData.links.push(this.initLinks()); + }, + removeLink(index) { + this.toolLinkData.links.splice(index, 1); } } }; @@ -222,4 +378,30 @@ export default { .pl-24 { padding-left: 24px; } + +.add-icon { + cursor: pointer; + font-size: 18px; + + &:hover { + color: #FFBA4B; + } +} + +.collapse-header { + display: flex; + justify-content: space-between; + margin-right: 10px; + width: 100%; +} + +.btn-add { + color: white; + background-color: #67C23A; +} + +.btn-delete { + color: white; + background-color: #F56C6C; +} \ No newline at end of file diff --git a/src/views/canteen/toolLink/index.vue b/src/views/canteen/toolLink/index.vue index 7ac6374..a125335 100644 --- a/src/views/canteen/toolLink/index.vue +++ b/src/views/canteen/toolLink/index.vue @@ -36,11 +36,15 @@ style="width: 100%" > + mock/login // detail: https://cli.vuejs.org/config/#devserver-proxy