zsydgithub 1 éve
szülő
commit
7bf570f144

+ 19 - 1
vue-admin-template-master/src/api/level.js

@@ -6,4 +6,22 @@ export function getLevel() {
     url: '/showLevel',
     method: 'get'
   })
-}
+}
+
+/* 添加等级信息 */
+export function addLevel(data) {
+  return request({
+    url: '/insertOneLevel',
+    method: 'post',
+    data
+  })
+}
+
+/* 删除等级信息 */
+export function delLevel(params) {
+  return request({
+    url: '/delOneLevel',
+    method: 'get',
+    params
+  })
+}

+ 27 - 0
vue-admin-template-master/src/api/location.js

@@ -0,0 +1,27 @@
+import request from '@/utils/request'
+
+/* 获取全部地址信息 */
+export function getLocation() {
+  return request({
+    url: '/showAddresses',
+    method: 'get'
+  })
+}
+
+/* 添加地址信息 */
+export function addLocation(data) {
+  return request({
+    url: '/insertOneAddress',
+    method: 'post',
+    data
+  })
+}
+
+/* 删除地址信息 */
+export function delLocation(params) {
+  return request({
+    url: '/delOneAddress',
+    method: 'get',
+    params
+  })
+}

+ 1 - 0
vue-admin-template-master/src/icons/svg/location.svg

@@ -0,0 +1 @@
+<svg t="1705642630778" class="icon" viewBox="0 0 1035 1024" version="1.1" xmlns="http://www.w3.org/2000/svg" p-id="4223" width="64" height="64"><path d="M1035.52 1024H0l74.56-448h123.2v64H128.96L75.52 960H960l-53.44-320h-68.8v-64h123.2l74.56 448zM517.76 448a128 128 0 1 1 128-128 128 128 0 0 1-128 128z m0-192a64 64 0 1 0 64 64 64 64 0 0 0-64-64z" fill="#ffffff" p-id="4224"></path><path d="M517.76 889.92L236.48 464A291.2 291.2 0 0 1 197.76 320a320 320 0 0 1 640 0A289.6 289.6 0 0 1 800 464c-18.88 29.12-256 385.6-256 385.6z m0-825.92a256 256 0 0 0-256 256 224 224 0 0 0 29.44 110.72l226.56 343.36c62.08-96 212.8-322.24 227.52-344.96a224 224 0 0 0 28.48-109.12 256 256 0 0 0-256-256z" fill="#ffffff" p-id="4225"></path></svg>

+ 18 - 0
vue-admin-template-master/src/router/index.js

@@ -107,6 +107,24 @@ export const constantRoutes = [
       }
     ]
   },
+  {
+    path: '/location',
+    component: Layout,
+    meta: { title: 'Location', icon: 'location' },
+    children: [
+      {
+        path: 'locationList',
+        name: 'locationList',
+        component: () => import('@/views/location/locationList'),
+        meta: { title: '地址列表', icon: 'location' }
+      },{
+        path: 'addLocation',
+        name: 'addLocation',
+        component: () => import('@/views/location/addLocation'),
+        meta: { title: '添加地址', icon: 'location' }
+      }
+    ]
+  },
 
   {
     path: '/nested',

+ 63 - 6
vue-admin-template-master/src/views/level/addLevel.vue

@@ -4,17 +4,74 @@
   date: 2024-1-18
 */
 <template>
-  <div>
-    添加等级
+  <div class="add-level">
+    <el-form
+      :model="ruleForm"
+      :rules="rules"
+      ref="ruleForm"
+      label-width="100px"
+      class="demo-ruleForm"
+    >
+      <el-form-item label="等级名称" prop="name">
+        <el-input v-model="ruleForm.name"></el-input>
+      </el-form-item>
+      <el-form-item>
+        <el-button type="primary" @click="submitForm('ruleForm')"
+          >提交</el-button
+        >
+        <el-button @click="resetForm('ruleForm')">重置</el-button>
+      </el-form-item>
+    </el-form>
   </div>
 </template>
 
 <script>
+import { addLevel } from "@/api/level";
 export default {
-
-}
+  data() {
+    return {
+      ruleForm: {
+        name: "",
+      },
+      rules: {
+        name: [{ required: true, message: "请输入等级", trigger: "blur" }],
+      },
+    };
+  },
+  methods: {
+    submitForm(formName) {
+      this.$refs[formName].validate((valid) => {
+        if (valid) {
+          addLevel({
+            levelname: this.ruleForm.name,
+          })
+            .then((res) => {
+              this.$message({
+                message: "提交成功",
+                type: "success",
+              });
+              this.$refs[formName].resetFields();
+              this.$router.push('/level/levelList')
+            })
+            .catch((err) => {
+              console.log(err);
+            });
+        } else {
+          console.log("error submit!!");
+          return false;
+        }
+      });
+    },
+    resetForm(formName) {
+      this.$refs[formName].resetFields();
+    },
+  },
+};
 </script>
 
-<style>
-
+<style scoped>
+.add-level{
+  width: 70%;
+  margin: 100px auto
+}
 </style>

+ 40 - 1
vue-admin-template-master/src/views/level/levelList.vue

@@ -9,12 +9,23 @@
       <el-table-column type="index" width="50"> </el-table-column>
       <el-table-column prop="jrid" label="等级ID"> </el-table-column>
       <el-table-column prop="levelname" label="等级名称"> </el-table-column>
+      <el-table-column fixed="right" label="操作" width="120">
+        <template slot-scope="scope">  
+          <el-button
+            @click.native.prevent="deleteRow(scope.row)"
+            type="text"
+            size="small"
+          >
+            移除
+          </el-button>
+        </template>
+      </el-table-column>
     </el-table>
   </div>
 </template>
 
 <script>
-import { getLevel } from "@/api/level";
+import { getLevel, delLevel } from "@/api/level";
 export default {
   data() {
     return {
@@ -28,6 +39,34 @@ export default {
         this.tableData = res.data;
       });
     },
+    /* 删除等级 */
+    deleteRow(row) {
+      console.log(row);
+      this.$confirm("此操作将永久删除该等级, 是否继续?", "提示", {
+        confirmButtonText: "确定",
+        cancelButtonText: "取消",
+        type: "warning",
+      })
+        .then(() => {
+          delLevel({
+            levelid: row.jrid,
+          }).then((res) => {
+            this.$message({
+              type: "success",
+              message: "删除成功!",
+            });
+            this.getLevelList()
+          }).catch((err)=>{
+            console.log(err)
+          })
+        })
+        .catch(() => {
+          this.$message({
+            type: "info",
+            message: "已取消删除",
+          });
+        });
+    },
   },
   created() {
     this.getLevelList();

+ 91 - 0
vue-admin-template-master/src/views/location/addLocation.vue

@@ -0,0 +1,91 @@
+/* 
+  添加地址
+  author:zsy
+  date: 2024-1-19
+*/
+<template>
+  <div class="add-location">
+    <el-form
+      :model="ruleForm"
+      :rules="rules"
+      ref="ruleForm"
+      label-width="100px"
+      class="demo-ruleForm"
+    >
+      <el-form-item label="地址名称" prop="address">
+        <el-input v-model="ruleForm.address"></el-input>
+      </el-form-item>
+      <el-form-item label="经度" prop="longitude">
+        <el-input v-model="ruleForm.longitude"></el-input>
+      </el-form-item>
+      <el-form-item label="纬度" prop="latitude">
+        <el-input v-model="ruleForm.latitude"></el-input>
+      </el-form-item>
+      <el-form-item>
+        <el-button type="primary" @click="submitForm('ruleForm')"
+          >立即创建</el-button
+        >
+        <el-button @click="resetForm('ruleForm')">重置</el-button>
+      </el-form-item>
+    </el-form>
+  </div>
+</template>
+
+<script>
+import { addLocation } from "@/api/location";
+export default {
+  data() {
+    return {
+      ruleForm: {
+        address: "",
+        longitude: "",
+        latitude: "",
+      },
+      rules: {
+        address: [
+          { required: true, message: "请输入地址名称", trigger: "blur" },
+        ],
+        longitude: [{ required: true, message: "请输入经度", trigger: "blur" }],
+        latitude: [{ required: true, message: "请输入纬度", trigger: "blur" }],
+      },
+    };
+  },
+  methods: {
+    submitForm(formName) {
+      this.$refs[formName].validate((valid) => {
+        if (valid) {
+          addLocation({
+            address: this.ruleForm.address,
+            longitude: this.ruleForm.longitude,
+            latitude: this.ruleForm.latitude,
+          })
+            .then((res) => {
+              this.$message({
+                message: "恭喜你,添加地址成功",
+                type: "success",
+              });
+              this.$refs[formName].resetFields();
+              this.$router.push('/location/locationList')
+            })
+            .catch((err) => {
+              this.$message.error('错了哦,添加地址错误');
+            });
+        } else {
+          console.log("error submit!!");
+          return false;
+        }
+      });
+    },
+    resetForm(formName) {
+      this.$refs[formName].resetFields();
+    },
+  },
+};
+</script>
+
+<style scoped>
+.add-location{
+  width: 70%;
+  margin: 100px auto
+}
+</style>

+ 88 - 0
vue-admin-template-master/src/views/location/locationList.vue

@@ -0,0 +1,88 @@
+/* 
+等级列表
+author: zsy
+date: 2024-1-19
+*/
+<template>
+  <div class="location-list">
+    <el-table :data="tableData" style="width: 100%">
+      <el-table-column type="index" width="50"> </el-table-column>
+      <el-table-column prop="addressid" label="地址ID" width="180">
+      </el-table-column>
+      <el-table-column prop="addressname" label="地址" width="180">
+      </el-table-column>
+      <el-table-column prop="longitude" label="经度"> </el-table-column>
+      <el-table-column prop="latitude" label="纬度"> </el-table-column>
+      <el-table-column fixed="right" label="操作" width="120">
+        <template slot-scope="scope">
+          <el-button
+            @click.native.prevent="deleteRow(scope.row)"
+            type="text"
+            size="small"
+          >
+            移除
+          </el-button>
+        </template>
+      </el-table-column>
+    </el-table>
+  </div>
+</template>
+
+<script>
+import { getLocation, delLocation } from "@/api/location";
+export default {
+  data() {
+    return {
+      tableData: [],
+    };
+  },
+  methods: {
+    /* 获取接口信息 */
+    getLocationList() {
+      getLocation().then((res) => {
+        this.tableData = res.data;
+      });
+    },
+    //删除地址信息
+    deleteRow(row) {
+      console.log(row);
+      this.$confirm("此操作将永久删除该地址, 是否继续?", "提示", {
+        confirmButtonText: "确定",
+        cancelButtonText: "取消",
+        type: "warning",
+      })
+        .then(() => {
+          delLocation({
+            addressid: row.addressid,
+          })
+            .then((res) => {
+              this.$message({
+                type: "success",
+                message: "删除成功!",
+              });
+              this.getLocationList()
+            })
+            .catch((err) => {
+              this.$message.error('删除失败');
+            });
+        })
+        .catch(() => {
+          this.$message({
+            type: "info",
+            message: "已取消删除",
+          });
+        });
+    },
+  },
+  created() {
+    this.getLocationList();
+  },
+};
+</script>
+
+<style scoped>
+.location-list {
+  width: 70%;
+  margin: 100px auto;
+}
+</style>