quanwei
18 hours ago c441dea81bd86bdfb12dff35821fed51f4cc91c2
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
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
<template>
  <!--
      作者:yj
      时间:2023-11-17
      描述:门店管理
  -->
  <div class="product-list">
    <!--搜索表单-->
    <div class="common-seach-wrap">
      <el-form size="small" :inline="true" :model="searchForm" class="demo-form-inline">
        <!-- <el-form-item label="自营类目">
          <el-select size="small" v-model="searchForm.category_id" placeholder="所有分类">
            <el-option label="全部" value="0"></el-option>
            <el-option v-for="(item, index) in categoryList" :key="index" :label="item.name" :value="item.category_id">
            </el-option>
          </el-select>
        </el-form-item> -->
        <el-form-item label="门店名称">
          <el-input size="small" v-model="searchForm.store_name" placeholder="请输入门店名称"></el-input>
        </el-form-item>
        <el-form-item>
          <el-button size="small" type="primary" icon="el-icon-search" @click="onSubmit">查询</el-button>
        </el-form-item>
      </el-form>
    </div>
    <!--内容-->
    <div class="product-content">
      <el-tabs v-model="activeName" @tab-click="handleClick">
        <el-tab-pane label="全部" name="-1">
          <span slot="label">全部</span>
        </el-tab-pane>
        <el-tab-pane label="参与" name="1">
          <span slot="label">参与</span>
        </el-tab-pane>
        <el-tab-pane label="不参与" name="0">
          <span slot="label">不参与</span>
        </el-tab-pane>
      </el-tabs>
      <div class="table-wrap">
        <div style="margin-bottom: 20px">
          <el-checkbox v-model="selectAll" @change="allSelection"></el-checkbox>
          <span class="mr10">当页全选</span>
          <el-button size="mini" type="primary" v-if="activeName!='1'" @click="change(1)">参与好店</el-button>
          <el-button size="mini" v-if="activeName!='0'" @click="change(0)">不参与好店</el-button>
        </div>
        <el-table size="small" :data="tableData" border style="width: 100%" v-loading="loading" ref="multipleTable">
          <el-table-column type="selection" width="55">
          </el-table-column>
          <el-table-column prop="store_name" label="门店" width="300px">
            <template slot-scope="scope">
              <div class="product-info">
                <div class="info">
                  <div class="name">{{ scope.row.store_name }}</div>
                </div>
              </div>
            </template>
          </el-table-column>
          <el-table-column prop="store_name" label="加盟商" width="300px">
            <template slot-scope="scope">
              <div class="product-info" v-if="scope.row.supplier">
                <div class="info">
                  <div class="name">{{ scope.row.supplier.name }}</div>
                </div>
              </div>
            </template>
          </el-table-column>
          <el-table-column prop="is_good" label="是否参与好店">
            <template slot-scope="scope">
              <div class="green" v-if="scope.row.is_good==1">是</div>
              <div class="gray3" v-else>否</div>
            </template>
          </el-table-column>
          <el-table-column fixed="right" label="操作" width="80">
            <template slot-scope="scope">
              <div class="table-btn-column">
                <el-button @click="click(scope.row)" type="text" size="small">设置</el-button>
              </div>
            </template>
          </el-table-column>
        </el-table>
        <div style="margin-top: 20px">
          <el-checkbox v-model="selectAll" @change="allSelection"></el-checkbox>
          <span class="mr10">当页全选</span>
          <el-button size="mini" type="primary" v-if="activeName!='0'" @click="change(1)">参与好店</el-button>
          <el-button size="mini" v-if="activeName!='1'" @click="change(0)">不参与好店</el-button>
        </div>
      </div>
    </div>
    <!--分页-->
    <div class="pagination">
      <el-pagination @size-change="handleSizeChange" @current-change="handleCurrentChange" background
        :current-page="curPage" :page-size="pageSize" layout="total, prev, pager, next, jumper"
        :total="totalDataNumber"></el-pagination>
    </div>
    <!--添加-->
    <Edit v-if="open_edit" :open_edit="open_edit" :storeModel="storeModel"
      @closeDialog="closeDialogFunc($event, 'Store')"></Edit>
  </div>
</template>
 
 
<script>
  import GoodStoreApi from '@/api/plus/goodstore/store.js';
  import Edit from './dialog/Edit.vue';
  export default {
    components: {
      Edit
    },
    data() {
      return {
        /*切换菜单*/
        activeName: '-1',
        /*切换选中值*/
        activeIndex: '0',
        /*是否正在加载*/
        loading: true,
        /*一页多少条*/
        pageSize: 10,
        /*一共多少条数据*/
        totalDataNumber: 0,
        /*当前是第几页*/
        curPage: 1,
        /*搜索参数*/
        searchForm: {
          store_name: '',
          category_id: ''
        },
        /*列表数据*/
        tableData: [],
        /*全部分类*/
        categoryList: [],
        open_edit: false,
        storeModel: {},
        selectAll: false
      };
    },
    created() {
      /*获取列表*/
      this.getData();
    },
    methods: {
      /*选择第几页*/
      handleCurrentChange(val) {
        let self = this;
        self.loading = true;
        self.curPage = val;
        self.getData();
      },
 
      /*每页多少条*/
      handleSizeChange(val) {
        this.pageSize = val;
        this.getData();
      },
 
      /*切换菜单*/
      handleClick(tab, event) {
        let self = this;
        self.curPage = 1;
        self.getData();
      },
 
      /*获取列表*/
      getData() {
        let self = this;
        let Params = self.searchForm;
        Params.page = self.curPage;
        Params.list_rows = self.pageSize;
        Params.is_good = self.activeName;
        self.loading = true;
        GoodStoreApi.getList(Params, true)
          .then(data => {
            self.loading = false;
            self.selectAll=false;
            self.tableData = data.data.list.data;
            self.categoryList = data.data.category;
            self.totalDataNumber = data.data.list.total;
          })
          .catch(error => {
            self.loading = false;
          });
      },
      /*搜索查询*/
      onSubmit() {
        this.curPage = 1;
        this.getData();
      },
      click(row) {
        this.storeModel = {
          'store_id': row.store_id,
          'store_name': row.store_name,
          'is_good': row.is_good,
        };
        this.open_edit = true;
      },
      /*关闭弹窗*/
      closeDialogFunc(e, f) {
        if (f == 'Store') {
          this.open_edit = e.openDialog;
          if (e.type == 'success') {
            this.getData();
          }
        }
      },
      allSelection(rows) {
        this.$refs.multipleTable.toggleAllSelection();
      },
      change(type) {
        let self = this;
        let list = this.$refs.multipleTable.selection;
        if (list.length <= 0) {
          return
        }
        let params = [];
        list.forEach((item, index) => {
          params.push(item.store_id);
        })
        GoodStoreApi.setStatus({
            storeIds: params.join(','),
            is_good: type
          }, true)
          .then(res => {
            self.loading = false;
            self.$message({
              message: res.msg,
              type: 'success'
            });
            self.getData();
          })
          .catch(error => {
            self.loading = false;
          });
      }
    }
  };
</script>
 
<style></style>