Browse Source

feat(生成查询页面):生成查询页面开发

xu 1 year ago
parent
commit
4d284f6410

+ 8 - 1
admin.ui.plus-master/package.json

@@ -13,24 +13,30 @@
     "gen:api": "node ./gen/gen-api"
   },
   "dependencies": {
+    "@element-plus/icons": "^0.0.11",
     "@element-plus/icons-vue": "^2.1.0",
+    "@types/date-fns": "^2.6.0",
     "@wangeditor/editor": "^5.1.23",
     "@wangeditor/editor-for-vue": "^5.1.12",
     "axios": "^1.4.0",
+    "clipboard": "^2.0.11",
     "countup.js": "^2.6.2",
     "cropperjs": "^1.5.13",
+    "date-fns": "^3.6.0",
     "echarts": "^5.4.2",
     "echarts-gl": "^2.0.9",
     "echarts-wordcloud": "^2.1.0",
     "element-plus": "^2.4.3",
     "exceljs": "^4.4.0",
     "file-saver": "^2.0.5",
+    "fs-extra": "^11.2.0",
     "js-cookie": "^3.0.5",
     "js-table2excel": "^1.1.2",
     "jsplumb": "^2.15.6",
     "lodash": "^4.17.21",
     "mitt": "^3.0.0",
     "nprogress": "^0.2.0",
+    "path": "^0.12.7",
     "pinia": "^2.1.4",
     "print-js": "^1.6.0",
     "qrcodejs2-fixes": "^0.0.2",
@@ -56,11 +62,12 @@
     "dotenv": "16.3.0",
     "eslint": "^8.43.0",
     "eslint-plugin-vue": "^9.14.1",
+    "fs": "^0.0.1-security",
     "prettier": "^2.8.8",
     "sass": "^1.63.4",
     "swagger-typescript-api": "12.0.4",
     "typescript": "^5.1.3",
-    "vite": "^4.3.9",
+    "vite": "^4.5.1",
     "vite-plugin-compression": "0.5.1",
     "vite-plugin-vue-setup-extend-plus": "^0.1.0",
     "vue-eslint-parser": "^9.3.1"

+ 15 - 1
admin.ui.plus-master/src/router/route.ts

@@ -1290,7 +1290,21 @@ export const dynamicRoutes: Array<RouteRecordRaw> = [
                   },
                 ],
               },
-
+              {
+                path: '/example/codeGeneration',
+                name: '代码生成',
+                component: () => import('/@/views/example/codeGeneration/index.vue'),
+                meta: {
+                  title: '代码生成',
+                  isLink: '',
+                  isHide: false,
+                  isKeepAlive: true,
+                  isAffix: false,
+                  isIframe: false,
+                  roles: ['admin', 'common'],
+                  icon: 'iconfont icon-ico_shuju',
+                },
+              },
             ],
           },
           {

+ 25 - 0
admin.ui.plus-master/src/views/example/codeGeneration/index.vue

@@ -187,6 +187,14 @@ const onQuery = async () => {
 const onChange=(api)=>{
   state.selectVal=[]
   state.tableVal=[]
+  state.selectBtn=state.selectBtn.map(item=>{
+    item.value=false
+    return item
+  })
+  state.tableBtn=state.tableBtn.map(item=>{
+    item.value=false
+    return item
+  })
   let data=dataJson.value.paths[api]
   const tableData=dataJson.value.components.schemas
   //console.log(data)
@@ -620,6 +628,23 @@ const onsubmit=()=>{
   indexCode=indexCode+`\n</`+`script>`+`\n<style scoped lang="scss">
   </style>`
   //console.log(indexCode)
+  getCodeFile('api.ts',apiCode)
+  getCodeFile('dto.ts',dataCode)
+  getCodeFile('index.vue',indexCode)
+}
+const getCodeFile=(fileName,code) =>{
+  const blob = new Blob([code], { type: 'text/plain' });
+  const url = URL.createObjectURL(blob);
+  // 创建一个a标签并设置href为新文件的URL
+  const downloadLink = document.createElement('a');
+  downloadLink.href = url;
+  downloadLink.download = fileName; // 设置下载文件名
+  // 触发下载
+  document.body.appendChild(downloadLink);
+  downloadLink.click();
+  // 清理
+  document.body.removeChild(downloadLink);
+  URL.revokeObjectURL(url);
 }
 </script>