locationList.vue 2.1 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788
  1. /*
  2. 等级列表
  3. author: zsy
  4. date: 2024-1-19
  5. */
  6. <template>
  7. <div class="location-list">
  8. <el-table :data="tableData" style="width: 100%">
  9. <el-table-column type="index" width="50"> </el-table-column>
  10. <el-table-column prop="addressid" label="地址ID" width="180">
  11. </el-table-column>
  12. <el-table-column prop="addressname" label="地址" width="180">
  13. </el-table-column>
  14. <el-table-column prop="longitude" label="经度"> </el-table-column>
  15. <el-table-column prop="latitude" label="纬度"> </el-table-column>
  16. <el-table-column fixed="right" label="操作" width="120">
  17. <template slot-scope="scope">
  18. <el-button
  19. @click.native.prevent="deleteRow(scope.row)"
  20. type="text"
  21. size="small"
  22. >
  23. 移除
  24. </el-button>
  25. </template>
  26. </el-table-column>
  27. </el-table>
  28. </div>
  29. </template>
  30. <script>
  31. import { getLocation, delLocation } from "@/api/location";
  32. export default {
  33. data() {
  34. return {
  35. tableData: [],
  36. };
  37. },
  38. methods: {
  39. /* 获取接口信息 */
  40. getLocationList() {
  41. getLocation().then((res) => {
  42. this.tableData = res.data;
  43. });
  44. },
  45. //删除地址信息
  46. deleteRow(row) {
  47. console.log(row);
  48. this.$confirm("此操作将永久删除该地址, 是否继续?", "提示", {
  49. confirmButtonText: "确定",
  50. cancelButtonText: "取消",
  51. type: "warning",
  52. })
  53. .then(() => {
  54. delLocation({
  55. addressid: row.addressid,
  56. })
  57. .then((res) => {
  58. this.$message({
  59. type: "success",
  60. message: "删除成功!",
  61. });
  62. this.getLocationList()
  63. })
  64. .catch((err) => {
  65. this.$message.error('删除失败');
  66. });
  67. })
  68. .catch(() => {
  69. this.$message({
  70. type: "info",
  71. message: "已取消删除",
  72. });
  73. });
  74. },
  75. },
  76. created() {
  77. this.getLocationList();
  78. },
  79. };
  80. </script>
  81. <style scoped>
  82. .location-list {
  83. width: 70%;
  84. margin: 100px auto;
  85. }
  86. </style>