index.vue 8.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268
  1. <template>
  2. <div class="app-container">
  3. <div class="filter-container">
  4. <div class="filter-control">
  5. <span>供应商名称:</span>
  6. <el-input v-model="listQuery.shopName" placeholder="供应商名称" @keyup.enter.native="handleFilter" />
  7. </div>
  8. <div class="filter-control">
  9. <span>供应商类型:</span>
  10. <el-select
  11. v-model="listQuery.shopType"
  12. placeholder="供应商类型"
  13. clearable
  14. style="width: 200px"
  15. class="filter-item"
  16. @change="getList()"
  17. >
  18. <el-option label="所有类型" value="" />
  19. <el-option label="代理商" :value="2" />
  20. <el-option label="品牌方" :value="1" />
  21. </el-select>
  22. </div>
  23. <div class="filter-control">
  24. <span>登录账号:</span>
  25. <el-input v-model="listQuery.loginAccount" placeholder="登录账号" @keyup.enter.native="handleFilter" />
  26. </div>
  27. <div class="filter-control">
  28. <span>手机号:</span>
  29. <el-input
  30. v-model="listQuery.mobile"
  31. placeholder="手机号"
  32. style="width: 200px;"
  33. class="filter-item"
  34. @keyup.enter.native="handleFilter"
  35. />
  36. </div>
  37. <div class="filter-control">
  38. <span>联系人:</span>
  39. <el-input
  40. v-model="listQuery.linkMan"
  41. placeholder="联系人"
  42. style="width: 200px;"
  43. class="filter-item"
  44. @keyup.enter.native="handleFilter"
  45. />
  46. </div>
  47. <div class="filter-control">
  48. <el-button type="primary" @click="getList(listQuery)">查询</el-button>
  49. <el-button type="primary" @click="$_navigationTo('supplier-add')">添加供应商</el-button>
  50. </div>
  51. </div>
  52. <!-- 表格区域 -->
  53. <el-table
  54. :key="tableKey"
  55. v-loading="listLoading"
  56. :data="list"
  57. border
  58. fit
  59. highlight-current-row
  60. style="width: 100%;"
  61. header-row-class-name="tableHeader"
  62. >
  63. <el-table-column label="序号" :index="indexMethod" type="index" sortable="custom" align="center" width="80" />
  64. <el-table-column label="供应商名称" align="center" prop="name" />
  65. <el-table-column label="供应商类型" width="100px" align="center">
  66. <template v-slot="{ row }">
  67. <span v-if="row.shopType === 1">品牌方</span>
  68. <span v-if="row.shopType === 2">代理商</span>
  69. </template>
  70. </el-table-column>
  71. <el-table-column label="登录账号" width="120px" align="center">
  72. <template slot-scope="{ row }">
  73. <span v-if="row.loginAccount">{{ row.loginAccount }}</span>
  74. <span v-else>未绑定</span>
  75. </template>
  76. </el-table-column>
  77. <el-table-column label="手机号" width="120px" align="center" prop="mobile" />
  78. <el-table-column label="联系人" width="100px" align="center" prop="linkMan" />
  79. <el-table-column label="供应商状态" align="center" width="100px">
  80. <template v-slot="{ row }">
  81. <el-switch v-model="row.shopStatus" @change="handleChangeStatus(row)" />
  82. </template>
  83. </el-table-column>
  84. <el-table-column label="创建时间" class-name="status-col" width="160px">
  85. <template slot-scope="{ row }">
  86. <span>{{ row.createTime | formatTime }}</span>
  87. </template>
  88. </el-table-column>
  89. <!-- <el-table-column label="创建人" class-name="status-col" width="100px" prop="createBy" /> -->
  90. <el-table-column label="操作" align="center" width="360" class-name="small-padding fixed-width">
  91. <template slot-scope="{ row }">
  92. <el-button size="mini" type="primary" @click="$_navigationTo(`supplier-edit?id=${row.authUserId}&type=edit`)">
  93. 编辑
  94. </el-button>
  95. <el-button size="mini" type="primary" @click="handleProxy(row)">
  96. 代他操作
  97. </el-button>
  98. <el-button size="mini" type="primary" @click="$_navigationTo(`club-list?id=${row.authUserId}`)">
  99. 查看机构认证
  100. </el-button>
  101. <el-button size="mini" type="primary" @click="handleResetPwd(row)">
  102. 重置密码
  103. </el-button>
  104. </template>
  105. </el-table-column>
  106. </el-table>
  107. <!-- 页码 -->
  108. <pagination
  109. :total="total"
  110. :page.sync="listQuery.pageNum"
  111. :limit.sync="listQuery.pageSize"
  112. @pagination="getList(listQuery)"
  113. />
  114. </div>
  115. </template>
  116. <script>
  117. import { fetchSupplierList, supplierStatusChange } from '@/api/supplier'
  118. import { resetPassword } from '@/api/user'
  119. import { fetchBrandList } from '@/api/brand'
  120. export default {
  121. name: 'ComplexTable',
  122. // mixins: [scrollTo],
  123. data() {
  124. return {
  125. slider: 1,
  126. listLoading: true,
  127. tableKey: '',
  128. total: 0, // 条数统计
  129. listQuery: {
  130. brandId: '', // 品牌id
  131. linkMan: '', // 联系人
  132. mobile: '', // 手机号
  133. pageNum: 0, // 页码
  134. pageSize: 10, // 分页大小
  135. shopName: '', // 供应商名称
  136. shopType: '', // 供应商类型
  137. loginAccount: '' // 登录账号
  138. },
  139. list: [],
  140. brandList: [], // 品牌列表
  141. prevData: ''
  142. }
  143. },
  144. created() {
  145. this.getList()
  146. this.getBrandList()
  147. },
  148. methods: {
  149. // 获取列表数据
  150. getList() {
  151. this.listLoading = true
  152. fetchSupplierList(this.listQuery)
  153. .then(res => {
  154. if (res.code !== 0) {
  155. return this.$message.error('获取数据失败~')
  156. }
  157. const { total, list } = res.data
  158. this.total = total
  159. this.formatList(list)
  160. this.list = list
  161. console.log(this.list)
  162. })
  163. .catch(err => {
  164. console.log(err)
  165. })
  166. .finally(() => {
  167. this.listLoading = false
  168. })
  169. },
  170. // 格式化数组
  171. formatList(list = []) {
  172. list.forEach(i => {
  173. i.shopStatus = i.shopStatus === 1
  174. })
  175. },
  176. // 获取品牌列表
  177. getBrandList() {
  178. // 获取品牌列表
  179. fetchBrandList()
  180. .then(res => {
  181. if (res.code === 0) {
  182. this.brandList = res.data
  183. }
  184. })
  185. .catch(err => console.log(err))
  186. },
  187. // 供应商状态改变
  188. handleChangeStatus(item) {
  189. const params = {
  190. status: item.shopStatus ? 1 : 0,
  191. authUserId: item.authUserId
  192. }
  193. supplierStatusChange(params)
  194. .then(res => {
  195. if (res.code === 0) {
  196. this.getList()
  197. this.$message({
  198. message: '操作成功',
  199. duration: 500,
  200. type: 'success'
  201. })
  202. }
  203. })
  204. .catch(() => {
  205. this.getList()
  206. this.$message({
  207. message: '操作失败',
  208. duration: 500,
  209. type: 'danger'
  210. })
  211. })
  212. },
  213. // 重置密码
  214. async handleResetPwd(item) {
  215. const text = await this.$confirm('此操作将重置该供应商的密码, 是否继续?', '提示', {
  216. confirmButtonText: '确定',
  217. cancelButtonText: '取消',
  218. type: 'warning'
  219. }).catch(() => {
  220. this.$message.info('已取消操作')
  221. })
  222. if (text !== 'confirm') return
  223. // 要执行的操作
  224. resetPassword({ authUserId: item.authUserId }).then(res => {
  225. if (res.code !== 0) return
  226. const h = this.$createElement
  227. this.$notify.success({
  228. title: '重置密码',
  229. message: h('i', { style: 'color: #333' }, `已重置供应商"${item.name}"的密码`),
  230. duration: 2000
  231. })
  232. })
  233. },
  234. // 代他操作
  235. async handleProxy(item) {
  236. const text = await this.$confirm('此操作将临时登录该供应商账号, 是否继续?', '提示', {
  237. confirmButtonText: '确定',
  238. cancelButtonText: '取消',
  239. type: 'warning'
  240. }).catch(() => {
  241. this.$message.info('已取消操作')
  242. })
  243. if (text !== 'confirm') return
  244. console.log(item)
  245. // 要执行的操作
  246. this.$store.commit('proxy/OPEN_PROXY', item)
  247. this.$store.dispatch('user/proxyLogin')
  248. this.$router.push('/proxy')
  249. },
  250. // 过滤列表
  251. handleFilter() {
  252. this.listQuery.page = 1
  253. this.getList()
  254. },
  255. indexMethod(index) {
  256. return index + this.listQuery.pageSize * (this.listQuery.pageNum - 1) + 1
  257. }
  258. }
  259. }
  260. </script>
  261. <style lang="scss" scoped>
  262. </style>