{"id":1954,"date":"2025-09-24T20:01:11","date_gmt":"2025-09-24T12:01:11","guid":{"rendered":"https:\/\/zero-zl.cn\/?p=1954"},"modified":"2025-09-24T20:01:12","modified_gmt":"2025-09-24T12:01:12","slug":"17-springboot3vue3%e5%ae%9e%e7%8e%b0%e6%8f%90%e4%ba%a4%e5%ae%a1%e6%a0%b8%e4%b8%9a%e5%8a%a1%e5%8a%9f%e8%83%bd%ef%bc%8c%e8%af%b7%e5%81%87%e7%94%b3%e8%af%b7%e3%80%81%e5%8f%91%e5%b8%83%e5%b8%96%e5%ad%90","status":"publish","type":"post","link":"https:\/\/zero-zl.cn\/index.php\/2025\/09\/24\/17-springboot3vue3%e5%ae%9e%e7%8e%b0%e6%8f%90%e4%ba%a4%e5%ae%a1%e6%a0%b8%e4%b8%9a%e5%8a%a1%e5%8a%9f%e8%83%bd%ef%bc%8c%e8%af%b7%e5%81%87%e7%94%b3%e8%af%b7%e3%80%81%e5%8f%91%e5%b8%83%e5%b8%96%e5%ad%90\/","title":{"rendered":"17. Springboot3+Vue3\u5b9e\u73b0\u63d0\u4ea4\u5ba1\u6838\u4e1a\u52a1\u529f\u80fd\uff0c\u8bf7\u5047\u7533\u8bf7\u3001\u53d1\u5e03\u5e16\u5b50\u5ba1\u6838\u3001\u4f5c\u4e1a\u63d0\u4ea4\u7b49\u7b49"},"content":{"rendered":"\n<h2 class=\"wp-block-heading\">\u4e1a\u52a1\u7533\u8bf7\u6a21\u5757<\/h2>\n\n\n\n<h3 class=\"wp-block-heading\">\u5173\u952e\u4ee3\u7801<\/h3>\n\n\n\n<pre class=\"wp-block-code\"><code>CREATE TABLE `apply` (\n  `id` int(11) NOT NULL AUTO_INCREMENT COMMENT '\u4e3b\u952eID',\n  `user_id` int(11) DEFAULT NULL COMMENT '\u7528\u6237ID',\n  `title` varchar(255) COLLATE utf8mb4_unicode_ci DEFAULT NULL COMMENT '\u7533\u8bf7\u6807\u9898',\n  `content` text COLLATE utf8mb4_unicode_ci COMMENT '\u7533\u8bf7\u5185\u5bb9',\n  `time` varchar(255) COLLATE utf8mb4_unicode_ci DEFAULT NULL COMMENT '\u7533\u8bf7\u65f6\u95f4',\n  `status` varchar(255) COLLATE utf8mb4_unicode_ci DEFAULT NULL COMMENT '\u5ba1\u6838\u72b6\u6001',\n  `reason` varchar(255) COLLATE utf8mb4_unicode_ci DEFAULT NULL COMMENT '\u5ba1\u6838\u8bf4\u660e',\n  PRIMARY KEY (`id`)\n) ENGINE=MyISAM DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci COMMENT='\u4e1a\u52a1\u7533\u8bf7\u8868';<\/code><\/pre>\n\n\n\n<pre class=\"wp-block-code\"><code>public void add(Apply apply) {\n    Account currentUser = TokenUtils.getCurrentUser();\n    apply.setUserId(currentUser.getId());\n    apply.setTime(DateUtil.now());\n    apply.setStatus(\"\u5f85\u5ba1\u6838\");\n    applyMapper.insert(apply);\n}<\/code><\/pre>\n\n\n\n<pre class=\"wp-block-code\"><code>      &lt;el-table :data=\"data.tableData\" style=\"width: 100%\"\n                :header-cell-style=\"{ color: '#333',backgroundColor: '#eaf4ff' }\">\n        &lt;el-table-column prop=\"title\" label=\"\u4e1a\u52a1\u6807\u9898\" \/>\n        &lt;el-table-column prop=\"content\" label=\"\u4e1a\u52a1\u5185\u5bb9\" \/>\n        &lt;el-table-column prop=\"userName\" label=\"\u7533\u8bf7\u4eba\" \/>\n        &lt;el-table-column prop=\"time\" label=\"\u7533\u8bf7\u65f6\u95f4\" \/>\n        &lt;el-table-column prop=\"status\" label=\"\u5ba1\u6838\u72b6\u6001\" >\n          &lt;template v-slot=\"scope\">\n            &lt;el-tag type=\"warning\" v-if=\"scope.row.status === '\u5f85\u5ba1\u6838'\">{{ scope.row.status }}&lt;\/el-tag>\n            &lt;el-tag type=\"success\" v-if=\"scope.row.status === '\u5ba1\u6838\u901a\u8fc7'\">{{ scope.row.status }}&lt;\/el-tag>\n            &lt;el-tag type=\"danger\" v-if=\"scope.row.status === '\u5ba1\u6838\u4e0d\u901a\u8fc7'\">{{ scope.row.status }}&lt;\/el-tag>\n          &lt;\/template>\n        &lt;\/el-table-column>\n        &lt;el-table-column prop=\"reason\" label=\"\u5ba1\u6838\u8bf4\u660e\" \/>\n        &lt;el-table-column label=\"\u64cd\u4f5c\" width=\"100\" >\n          &lt;template #default=\"scope\" v-if=\"data.user.role === 'USER'\">\n            &lt;el-button :disabled=\"scope.row.status !== '\u5f85\u5ba1\u6838'\" type=\"primary\" icon=\"Edit\" circle @click=\"handleEdit(scope.row)\">&lt;\/el-button>\n            &lt;el-button :disabled=\"scope.row.status !== '\u5f85\u5ba1\u6838'\" type=\"danger\" icon=\"Delete\" circle @click=\"del(scope.row.id)\">&lt;\/el-button>\n          &lt;\/template>\n          &lt;template #default=\"scope\" v-if=\"data.user.role === 'ADMIN'\">\n            &lt;el-button :disabled=\"scope.row.status !== '\u5f85\u5ba1\u6838'\" type=\"primary\" @click=\"handleEdit(scope.row)\">\u5ba1\u6838&lt;\/el-button>\n          &lt;\/template>\n        &lt;\/el-table-column>\n      &lt;\/el-table><\/code><\/pre>\n\n\n\n<pre class=\"wp-block-code\"><code>&lt;el-form ref=\"formRef\" :model=\"data.form\" :rules=\"data.rules\" label-width=\"80px\" style=\"padding: 20px 30px 10px 0\">\n        &lt;el-form-item prop=\"title\" label=\"\u4e1a\u52a1\u6807\u9898\" v-if=\"data.user.role === 'USER'\">\n          &lt;el-input v-model=\"data.form.title\" autocomplete=\"off\" placeholder=\"\u8bf7\u8f93\u5165\u4e1a\u52a1\u6807\u9898\"\/>\n        &lt;\/el-form-item>\n        &lt;el-form-item prop=\"content\" label=\"\u4e1a\u52a1\u5185\u5bb9\" v-if=\"data.user.role === 'USER'\">\n          &lt;el-input type=\"textarea\" :rows=\"3\" v-model=\"data.form.content\" autocomplete=\"off\" placeholder=\"\u8bf7\u8f93\u5165\u4e1a\u52a1\u5185\u5bb9\"\/>\n        &lt;\/el-form-item>\n        &lt;el-form-item prop=\"status\" label=\"\u5ba1\u6838\u72b6\u6001\" v-if=\"data.user.role === 'ADMIN'\">\n          &lt;el-radio-group v-model=\"data.form.status\">\n            &lt;el-radio-button label=\"\u5f85\u5ba1\u6838\" value=\"\u5f85\u5ba1\u6838\" \/>\n            &lt;el-radio-button label=\"\u5ba1\u6838\u901a\u8fc7\" value=\"\u5ba1\u6838\u901a\u8fc7\" \/>\n            &lt;el-radio-button label=\"\u5ba1\u6838\u4e0d\u901a\u8fc7\" value=\"\u5ba1\u6838\u4e0d\u901a\u8fc7\" \/>\n          &lt;\/el-radio-group>\n        &lt;\/el-form-item>\n        &lt;el-form-item prop=\"reason\" label=\"\u5ba1\u6838\u8bf4\u660e\" v-if=\"data.user.role === 'ADMIN' &amp;&amp; data.form.status === '\u5ba1\u6838\u4e0d\u901a\u8fc7'\">\n          &lt;el-input v-model=\"data.form.reason\" autocomplete=\"off\" placeholder=\"\u8bf7\u8f93\u5165\u62d2\u7edd\u8bf4\u660e\"\/>\n        &lt;\/el-form-item>\n      &lt;\/el-form><\/code><\/pre>\n\n\n\n<h2 class=\"wp-block-heading\">\u6838\u5fc3\u603b\u7ed3<\/h2>\n\n\n\n<ol class=\"wp-block-list\">\n<li>\u63d0\u4ea4\u5ba1\u6838\u4e1a\u52a1\u5fc5\u987b\u8981\u6709\u89d2\u8272id\u548cstatus\u5b57\u6bb5<\/li>\n\n\n\n<li>\u5728\u63d0\u4ea4\u7684\u63a5\u53e3\u91cc\u9762\u9700\u8981\u7ed1\u5b9a\u597d\u89d2\u8272id\u4ee5\u53ca\u521d\u59cb\u5316\u72b6\u6001\uff08\u5f85\u5ba1\u6838\uff09<\/li>\n\n\n\n<li>\u7528\u6237\u53ea\u80fd\u770b\u5230\u81ea\u5df1\u63d0\u4ea4\u7684\u7533\u8bf7<\/li>\n\n\n\n<li>\u7ba1\u7406\u5458\u5ba1\u6838\u540e\u9700\u8981\u8ddf\u65b0\u72b6\u6001<\/li>\n\n\n\n<li>\u63d0\u4ea4\u89d2\u8272\u7684\u64cd\u4f5c\u6309\u94ae\u548c\u5ba1\u6838\u89d2\u8272\u7684\u64cd\u4f5c\u6309\u94ae\u53ef\u4ee5\u901a\u8fc7\u72b6\u6001\u5b57\u6bb5\u8fdb\u884c\u63a7\u5236<\/li>\n<\/ol>\n","protected":false},"excerpt":{"rendered":"<p>\u4e1a\u52a1\u7533\u8bf7\u6a21\u5757 \u5173\u952e\u4ee3\u7801 \u6838\u5fc3\u603b\u7ed3<\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[114,102],"tags":[],"class_list":["post-1954","post","type-post","status-publish","format-standard","hentry","category-spring-boot3vue3","category-102"],"_links":{"self":[{"href":"https:\/\/zero-zl.cn\/index.php\/wp-json\/wp\/v2\/posts\/1954","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/zero-zl.cn\/index.php\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/zero-zl.cn\/index.php\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/zero-zl.cn\/index.php\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/zero-zl.cn\/index.php\/wp-json\/wp\/v2\/comments?post=1954"}],"version-history":[{"count":1,"href":"https:\/\/zero-zl.cn\/index.php\/wp-json\/wp\/v2\/posts\/1954\/revisions"}],"predecessor-version":[{"id":1955,"href":"https:\/\/zero-zl.cn\/index.php\/wp-json\/wp\/v2\/posts\/1954\/revisions\/1955"}],"wp:attachment":[{"href":"https:\/\/zero-zl.cn\/index.php\/wp-json\/wp\/v2\/media?parent=1954"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/zero-zl.cn\/index.php\/wp-json\/wp\/v2\/categories?post=1954"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/zero-zl.cn\/index.php\/wp-json\/wp\/v2\/tags?post=1954"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}