jiangping
2024-08-13 6765787baa5e0b771d71f865c4deb776367410c4
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
<template>
    <GlobalWindow
        :title="title"
        width="100%"
        :visible.sync="visible"
        :withFooter="false"
    >
        <ul style="width: 100%; display: flex; align-items: center; margin-bottom: 20px;">
            <li style="margin-right: 10px;"><el-button type="primary" @click="$refs.operaMemberCardWindow.open('新建人员开卡', { memberId: memberId, isType: 1 })" v-permissions="['business:membercard:create']">新建</el-button></li>
            <li style="margin-right: 10px;"><el-button type="primary" @click="batchLossReporting">挂失</el-button></li>
            <li><el-button type="primary" @click="batchDecoupling">解挂</el-button></li>
        </ul>
        <el-table
            v-loading="loading"
            :data="list"
            stripe
            @selection-change="handleSelectionChange"
        >
            <el-table-column type="selection" width="55"></el-table-column>
            <el-table-column prop="code" label="卡号" min-width="100px"></el-table-column>
            <el-table-column prop="cardTypeName" label="卡类型" min-width="100px"></el-table-column>
            <el-table-column label="状态" min-width="100px">
                <template slot-scope="{row}">
                    <span v-if="row.status === 0">禁用</span>
                    <span v-if="row.status === 1">启用</span>
                    <span v-if="row.status === 2">退卡</span>
                    <span v-if="row.status === 3">挂失</span>
                </template>
            </el-table-column>
            <el-table-column label="用户类型" min-width="100px">
                <template slot-scope="{row}">
                    <span v-if="row.memberType === 0">劳务访客</span>
                    <span v-if="row.memberType === 2">内部人员</span>
                </template>
            </el-table-column>
            <el-table-column prop="memberName" label="员工姓名" min-width="100px"></el-table-column>
            <el-table-column prop="memberPhone" label="手机号" min-width="100px"></el-table-column>
            <el-table-column prop="companyName" label="公司/部门" min-width="100px"></el-table-column>
            <el-table-column prop="createDate" label="开卡时间" min-width="100px"></el-table-column>
            <el-table-column prop="editDate" label="更新时间" min-width="100px"></el-table-column>
            <el-table-column
                label="操作"
                min-width="120"
                fixed="right"
            >
                <template slot-scope="{row}">
                    <el-button type="text" v-if="row.status === 3" @click="jiegua(row.id)">解挂</el-button>
                    <el-button type="text" v-if="row.status !== 3 && row.status !== 2" @click="tui(row.id)">退卡</el-button>
                    <el-button type="text" v-if="row.status !== 3 && row.status !== 2" @click="guashi(row.id)">挂失</el-button>
                </template>
            </el-table-column>
        </el-table>
        <!-- 新建/修改 -->
        <OperaMemberCardWindow ref="operaMemberCardWindow" @success="search()"/>
    </GlobalWindow>
</template>
 
<script>
  import BaseOpera from '@/components/base/BaseOpera'
  import GlobalWindow from '@/components/common/GlobalWindow'
  import OperaMemberCardWindow from '@/components/business/OperaMemberCardWindow'
  import { refundCard, batchLoss, batchUnLoss, fetchList } from '@/api/business/memberCard'
  export default {
    name: 'cardOpeningRecord',
    extends: BaseOpera,
    components: { GlobalWindow, OperaMemberCardWindow },
    data () {
      return {
        memberId: null,
        list: [],
        tableData: {
          selectedRows: []
        },
        loading: false
      }
    },
    created () {
      this.config({
        api: '/business/memberCard',
        'field.id': 'id'
      })
    },
    methods: {
      open (title, memberId) {
        this.title = title
        this.visible = true
        this.list = []
        this.memberId = memberId
        this.search()
      },
      handleSelectionChange (e) {
        this.tableData.selectedRows = e
      },
      search() {
        fetchList({
          capacity: 9999,
          page: 1,
          model: {
            memberId: this.memberId
          }
        }).then(res => {
          this.list = res.records
        })
      },
      // 批量解挂
      batchDecoupling () {
        let arr = []
        this.tableData.selectedRows.forEach(item => {
          arr.push({ id: item.id, status: 1 })
        })
        batchUnLoss(arr)
          .then(res => {
            this.$message.success('操作成功')
            this.search()
          })
      },
      // 批量挂失
      batchLossReporting() {
        let arr = []
        this.tableData.selectedRows.forEach(item => {
          arr.push({ id: item.id, status: 3 })
        })
        batchLoss(arr)
          .then(res => {
            this.$message.success('操作成功')
            this.search()
          })
      },
      // 退卡
      tui(id) {
        refundCard({ id, status: 2 })
          .then(res => {
            this.$message.success('操作成功')
            this.search()
          })
      },
      // 挂失
      guashi(id) {
        batchLoss([{ id, status: 3 }])
          .then(res => {
            this.$message.success('操作成功')
            this.search()
          })
      },
      // 解挂
      jiegua(id) {
        batchUnLoss([{ id, status: 1 }])
          .then(res => {
            this.$message.success('操作成功')
            this.search()
          })
      }
    }
  }
</script>