jiangping
2024-06-20 09da100729793848bc01b51f7b05ca3f1e7ec64f
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
<template>
    <TableLayout :permissions="['business:company:queryShop']">
        <!-- 搜索表单 -->
        <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>
            <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" v-permissions="['business:company:createShop']">
                <li><el-button type="primary" @click="$refs.operaShopWindow.open('新建商户')" v-permissions="['business:company:createShop']">新建商户</el-button></li>
            </ul>
            <el-table
                v-loading="isWorking.search"
                :data="tableData.list"
                stripe
            >
                <el-table-column prop="name" label="商户名称" min-width="100px"></el-table-column>
                <el-table-column prop="code" label="统一信用代码" min-width="100px"></el-table-column>
                <el-table-column prop="createDate" label="添加时间" min-width="100px"></el-table-column>
                <el-table-column prop="phone" label="绑定手机号" min-width="100px"></el-table-column>
                <el-table-column label="启用状态" min-width="100px">
                    <template slot-scope="{row}">
                        <el-switch
                            @change="changeStatus($event, row)"
                            v-model="row.status"
                            active-color="#13ce66"
                            inactive-color="#ff4949"
                            :active-value="0"
                            :inactive-value="1">
                        </el-switch>
                    </template>
                </el-table-column>
                <el-table-column label="电子签认证状态" min-width="100px">
                    <template slot-scope="{row}">
                      <span v-if="row.signStatus === 0">待认证</span>
                      <span v-if="row.signStatus === 1">认证中</span>
                      <span v-if="row.signStatus === 2">认证失败</span>
                      <span v-if="row.signStatus === 3">认证通过</span>
                    </template>
                </el-table-column>
                <el-table-column
                    v-if="containPermissions(['business:company:updateShop', 'business:company:deleteShop'])"
                    label="操作"
                    min-width="120"
                    fixed="right"
                >
                    <template slot-scope="{row}">
                        <el-button type="text" @click="$refs.operaShopDescWindow.open('商户详情', row)"  v-permissions="['business:company:updateShop']">查看详情</el-button>
                        <el-button type="text" @click="edit(row)" v-permissions="['business:company:updateShop']">修改</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" />
        <!-- 详情 -->
        <OperaShopDescWindow ref="operaShopDescWindow" @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 OperaShopDescWindow from '@/components/business/OperaShopDescWindow'
import { updateStatus, getById } from '@/api/business/company'
export default {
  name: 'Company',
  extends: BaseTable,
  components: { TableLayout, Pagination, OperaShopWindow, OperaShopDescWindow },
  data () {
    return {
      // 搜索
      searchForm: {
        name: '',
        username: '',
        type: 1
      }
    }
  },
  created () {
    this.config({
      module: '商户信息表',
      api: '/business/company',
      'field.id': 'id',
      'field.main': 'id'
    })
    this.search()
  },
  methods: {
    edit (row) {
      getById(row.id)
        .then(res => {
          const form = res
          form.type = 1
          form.file = {
            imgurl: '',
            imgurlfull: ''
          }
          form.file1 = {
            imgurl: '',
            imgurlfull: ''
          }
          form.file2 = {
            imgurl: '',
            imgurlfull: ''
          }
          form.file3 = {
            imgurl: '',
            imgurlfull: ''
          }
 
          form.file.imgurl = res.businessImg? res.businessImg.fileurl:null
          form.file.imgurlfull = res.businessImg?res.businessImg.fileurlFull:null
          if (res.idcardImgList == null) {
            res.idcardImgList = new Array()
          }
          if (res.idcardImgList && res.idcardImgList.length > 0) {
            form.file1.imgurl = res.idcardImgList[0].fileurl
            form.file1.imgurlfull = res.idcardImgList[0].fileurlFull
          }
          if (res.idcardImgList && res.idcardImgList.length > 1) {
            form.file2.imgurl = res.idcardImgList[1].fileurl
            form.file2.imgurlfull = res.idcardImgList[1].fileurlFull
          }
          form.file3.imgurl = res.signImg?res.signImg.fileurl:null
          form.file3.imgurlfull = res.signImg?res.signImg.fileurlFull:null
          this.$refs.operaShopWindow.open('编辑商户', form)
        })
    },
    // 修改状态
    changeStatus (status, row) {
      updateStatus({ id: row.id, status })
        .then(res => {
          this.search()
        })
        .catch(err => {
          row.status = row.status === 0 ? 1 : 0
        })
    }
  }
}
</script>