hejianhao
2025-04-16 dab2d210ca06c1faa514c6388fbd5de1ab355360
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
<template>
  <div class="cor-bus">
    <v-header
      title="服务分类"
      search
      :bar="bar"
      @on-search="onSearch"
    ></v-header>
    <div class="but">
      <el-button
        @click="edit()"
        size="small"
        type="primary"
      >新增</el-button>
    </div>
    <div>
      <v-tool-table
        :trs="trs"
        :tds="tds"
      >
        <template v-slot:logo="{scope}">
          <div class="table_flex">
            <img
              :src="scope.logo"
              alt=""
            >
          </div>
        </template>
        <template v-slot:btn="{scope}">
          <el-button
            type="text"
            @click="edit1(scope.id)"
          >编辑</el-button>
          <el-button
            type="text"
            @click="clear(scope.id)"
          >删除</el-button>
        </template>
      </v-tool-table>
    </div>
    <v-tool-page
      :item="paged"
      @on-page="onPage"
    ></v-tool-page>
    <!-- 新增弹窗 -->
    <AddModel v-model="isShow" @change="isShow = false" />
  </div>
</template>
<script>
import AddModel from "./components/AddModel.vue"
export default {
  name: "index",
  props: [],
  components: {AddModel},
  data() {
    return {
      bar: [{ title: "分类名称", name: "name", value: "" }],
      trs: [
        { text: "分类名称", val: "", slot: "logo" },
        { text: "备注", val: "", width: "" },
        { text: "权重(数字越大排序越靠前)", val: ""},
        { text: "操作", val: "btn" },
      ],
      os: {},
      tds: [],
      paged: { page: 0, total: 10, r: 0, limit: 10 },
      isShow:false
    };
  },
  created() {
    this.init();
  },
  mounted() {},
  methods: {
    clear(id) {
      //删除
      let t = this;
      t.$js.model("删除商家", "是否删除服务商家", (res) => {
        if (res) {
          t.$api.del("convenient/business/delete?id=" + id, {}, (e) => {
            demo.toast("删除成功");
            t.init();
          });
        }
      });
    },
    edit1(id) {
      //编辑
      this.$router.push({
        path: "/cor_bus_edit",
        query: {
          id: id,
        },
      });
    },
    onSearch(e) {
      //筛选
      this.os = e;
      this.init();
    },
    onPage(v) {
      //分页
      if (v.page === this.paged.page && v.page && !v.reset) {
        return 0;
      }
      this.paged.page = v.page;
      this.paged.limit = v.limit;
      this.init();
    },
    init() {
      Object.assign(this.paged, this.os);
      this.$api.post("convenient/business/page", this.paged, (e) => {
        this.tds = e.records;
        this.paged.total = e.total;
      });
    },
    //新增
    edit() {
     this.isShow = true;
    },
  },
  watch: {},
  computed: {},
};
</script>
<style scoped>
  .cor-bus{
    overflow: scroll;
  }
.but {
  padding-bottom: 20px;
  display: flex;
}
</style>