doum
10 小时以前 c384e04f81caf681647c602d5896cc10b289582e
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
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
<template>
  <TableLayout :permissions="['business:shop:query']">
    <!-- 搜索表单 -->
    <el-form ref="searchForm" slot="search-form" :model="searchForm" label-width="100px" inline>
      <el-form-item label="名称" prop="name">
        <el-input v-model="searchForm.name" placeholder="请输入名称" @keypress.enter.native="search"></el-input>
      </el-form-item>
      <el-form-item label="门店ID" prop="code">
        <el-input v-model="searchForm.code" placeholder="请输入门店ID" @keypress.enter.native="search"></el-input>
      </el-form-item>
      <el-form-item label="登录账号" prop="name">
        <el-input v-model="searchForm.username" placeholder="请输入登录账号" @keypress.enter.native="search"></el-input>
      </el-form-item>
      <el-form-item label="销售模式" prop="saleType" >
        <!-- 0正常 1禁用 -->
        <el-select     v-model="searchForm.saleType"  placeholder="销售模式"  style="width: 100px"  @change="search"  >
          <el-option  :key="0" :value="0"  label="平台铺货"  ></el-option>
          <el-option   :key="1" :value="1" label="自主采购"  ></el-option>
        </el-select>
      </el-form-item>
      <el-form-item label="省市区" prop="provinceId" >
      <el-select v-model="searchForm.provinceId" placeholder="省份" style="width: 100px" filterable @change="selectProvince">
        <el-option
            v-for="item in provinces"
            :key="item.id"
            :value="item.id"
            :label="item.name"
        ></el-option>
      </el-select>
      </el-form-item>
      <el-form-item label="" prop="cityId" >
      <el-select v-model="searchForm.cityId" filterable placeholder="城市"  @change="selectCity" style="width: 100px" >
        <el-option
            v-for="item in cities"
            :key="item.id"
            :value="item.id"
            :label="item.name"
        ></el-option>
      </el-select>
      </el-form-item>
      <el-form-item label="" prop="areaId" >
      <el-select v-model="searchForm.areaId" filterable placeholder="区域"  style="width: 100px" >
        <el-option
            v-for="item in areas"
            :key="item.id"
            :value="item.id"
            :label="item.name"
        ></el-option>
      </el-select>
      </el-form-item>
      <el-form-item label="状态" prop="status">
        <!-- 0正常 1禁用 -->
        <el-select     v-model="searchForm.status"  placeholder="请选择状态"  style="width: 100px"    @change="search"   >
          <el-option  :key="0" :value="0"  label="正常"  ></el-option>
          <el-option   :key="1" :value="1" label="禁用"  ></el-option>
        </el-select>
      </el-form-item>
      <section>
        <el-button type="primary" @click="search">搜索</el-button>
        <el-button @click="reset">重置</el-button>
      </section>
    </el-form>
    <!-- 表格和分页 -->
    <template v-slot:table-wrap>
      <ul class="toolbar" >
        <li><el-button type="primary" @click="$refs.operaShopWindow.open('新建经销商')" icon="el-icon-plus" v-permissions="['business:shop:create']">新建</el-button></li>
        <!-- <li><el-button @click="deleteByIdInBatch" icon="el-icon-delete" v-permissions="['business:shop:delete']">删除</el-button></li> -->
        <li><p class="tip-warn" style="width: 100%;margin-left: 20px;"><i class="el-icon-warning"></i>提示:【供货价设置】只统计上架状态的商品价格设置数据,(已定价商品数/全部商品数)</p></li>
      </ul>
      <el-table
        v-loading="isWorking.search"
        :data="tableData.list"
        stripe
        border
        @selection-change="handleSelectionChange"
      >
        <!-- <el-table-column type="selection" width="55"></el-table-column> -->
        <el-table-column prop="name" label="名称" fixed align="center" min-width="100px">
          <template slot-scope="{row}">
            <el-button type="text" @click="showDetail(row)">{{row.name}}</el-button>
          </template>
        </el-table-column>
        <el-table-column prop="code" label="门店ID" align="center" min-width="100px"></el-table-column>
        <el-table-column prop="integral" label="现有积分" align="center" min-width="100px">
          <template slot-scope="{row}">
            <span class="orange">{{(row.integral || 0).toFixed(0)}}</span>
          </template>
        </el-table-column>
        <el-table-column prop="totalIntegral" label="累计积分" align="center" min-width="100px">
          <template slot-scope="{row}">
            <span class="orange">  {{(row.totalIntegral || 0).toFixed(0)}}</span>
          </template>
        </el-table-column>
        <el-table-column prop="username" label="登录账号" align="center" min-width="100px"></el-table-column>
        <el-table-column prop="bigAreaName" label="所属区域" align="center" min-width="100px"></el-table-column>
        <el-table-column prop="areaFullName" label="省市区" align="center" min-width="150px" show-overflow-tooltip>
          <template slot-scope="{row}">
            <span v-if="row.areas!=null">{{(row.areas.provinceName||'') + (row.areas.cityName||'') + (row.areas.name||'')}}</span>
          </template>
        </el-table-column>
<!--        <el-table-column prop="imgurl" label="门头图" align="center" min-width="100px">
          <template slot-scope="{row}">
            <el-image v-if=" row.imgurl" :scr="row.imgFullUrl + row.imgurl" :preview-src-list="[row.imgFullUrl + row.imgurl]"></el-image>
          </template>
        </el-table-column>-->
        <el-table-column prop="addr" label="详细地址" align="center" min-width="150px" show-overflow-tooltip></el-table-column>
        <el-table-column prop="realname" label="联系人" align="center" min-width="100px"></el-table-column>
        <el-table-column prop="phone" label="联系电话" align="center" min-width="150px"></el-table-column>
        <el-table-column prop="saleType"  label="销售模式" align="center" min-width="150px">
          <template slot-scope="{row}">
            {{ row.saleType == 1?'自主采购':'平台铺货'}}
          </template>
        </el-table-column>
        <el-table-column prop="shopPrice" label="供货价设置" min-width="100px" align="center">
          <template slot-scope="{row}" >
            <div title="针对上架商品价格设置统计" @click="goPriceSet(row)" style="cursor:pointer;"><span  class="red"> {{row.pricedGoodsNum||0}}</span> / <span class="green"> {{row.goodsNum||0}}</span>  </div>
          </template>
        </el-table-column>
        <el-table-column prop="createDate" label="创建时间" align="center" min-width="140px"></el-table-column>
        <el-table-column prop="status" label="状态" align="center" min-width="100px" fixed="right">
          <template slot-scope="{row}">
            <el-switch
              v-model="row.status"
              active-color="#13ce66"
              inactive-color="#999"
              :active-value="0"
              :inactive-value="1"
              @change="statusChange(row)"
            ></el-switch>
          </template>
        </el-table-column>
        <el-table-column
          v-if="containPermissions(['business:shop:update', 'business:shop:delete'])"
          label="操作"
          min-width="280"
          fixed="right"
          align="center"
        >
          <template slot-scope="{row}">
            <el-button type="text" @click="$refs.operaShopWindow.open('编辑经销商', row)" icon="el-icon-edit" v-permissions="['business:shop:update']">编辑</el-button>
            <el-button type="text" v-permissions="['business:shop:update']" icon="el-icon-edit" @click="goPriceSet(row)">供货价</el-button>
            <el-button type="text" @click="resetPwd(row)" icon="el-icon-edit"  v-permissions="['business:shop:update']">重置密码</el-button>
            <el-button type="text" style="color: red" @click="deleteById(row)" icon="el-icon-delete" v-permissions="['business:shop:delete']">删除</el-button>
          </template>
        </el-table-column>
      </el-table>
      <pagination
        @size-change="handleSizeChange"
        @current-change="handlePageChange"
        :pagination="tableData.pagination"
      >
      </pagination>
    </template>
    <!-- 新建/修改 -->
    <OperaShopWindow ref="operaShopWindow" @success="handlePageChange"/>
    <OperaShopInfoWindow ref="OperaShopInfoWindow" />
    <ResetPwdShopWindow ref="resetPwdWindow"/>
    <OperaGoodsShopWindow ref="OperaGoodsShopWindow" @success="handlePageChange"/>
  </TableLayout>
</template>
 
<script>
import BaseTable from '@/components/base/BaseTable'
import TableLayout from '@/layouts/TableLayout'
import Pagination from '@/components/common/Pagination'
import OperaShopWindow from '@/components/business/OperaShopWindow'
import OperaShopInfoWindow from '@/components/business/OperaShopInfoWindow'
import OperaGoodsShopWindow from '@/components/business/OperaGoodsShopWindow'
import { resetPwd, updateIsRecById } from '@/api/business/shop'
import ResetPwdShopWindow from '@/components/business/ResetPwdShopWindow'
import { listByParentId } from '@/api/business/areas'
export default {
  name: 'Shop',
  extends: BaseTable,
  components: { TableLayout, Pagination, OperaShopWindow, OperaShopInfoWindow, ResetPwdShopWindow, OperaGoodsShopWindow },
  data () {
    return {
 
      // 搜索
      searchForm: {
        name: '',
        code: '',
        username: '',
        status: '',
        saleType: '',
        isrec: '',
        provinceId: '',
        cityId: '',
        areaId: ''
      },
      provinces: [],
      cities: [],
      areas: []
    }
  },
  created () {
    this.config({
      module: '经销商基本信息表',
      api: '/business/shop',
      'field.id': 'id',
      'field.main': 'id'
    })
    listByParentId({ type: 0, parentId: '' })
      .then(data => {
        this.provinces = data
      })
    this.search()
  },
  methods: {
    selectProvince (val) {
      this.searchForm.cityId = null
      this.searchForm.areaId = null
      this.cities = []
      this.areas = []
      listByParentId({ type: 1, parentId: val })
        .then(data => {
          this.cities = data
        })
        .catch(e => {
          this.$tip.error(e)
        })
    },
    selectCity (val) {
      this.searchForm.areaId = null
      this.areas = []
      listByParentId({ type: 2, parentId: val })
        .then(data => {
          this.areas = data
        })
        .catch(e => {
          this.$tip.error(e)
        })
    },
    initCityArea (proid, cityid) {
      listByParentId({ type: 1, parentId: proid })
        .then(data => {
          this.cities = data
        })
        .catch(e => {
          this.$tip.error(e)
        })
      listByParentId({ type: 2, parentId: cityid })
        .then(data => {
          this.areas = data
        })
        .catch(e => {
          this.$tip.error(e)
        })
    },
    goPriceSet (row) {
      this.$refs.OperaGoodsShopWindow.open('设置供货价 - ' + row.name, row)
    },
    resetPwd (row) {
      this.$dialog.messageWaring('确认重置该经销商【' + row.name + '】的登录密码吗?')
        .then(() => {
          resetPwd({
            id: row.id
          })
            .then(() => {
              this.$tip.apiSuccess('密码重置成功')
            })
            .catch(e => {
              this.$tip.apiFailed(e)
            })
            .finally(() => {
 
            })
        })
    },
    statusChange (row) {
      updateIsRecById(row)
        .then(() => {
          this.$message.success('操作成功')
        })
        .catch(e => {
          this.$message.error('操作成功')
        })
        .then(() => {
          this.handlePageChange()
        })
    },
    showDetail (row) {
      this.$refs.OperaShopInfoWindow.open('经销商详情【' + row.name + '】', row)
    }
  }
}
</script>