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
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
<template>
  <!--
          作者
          时间:2025-09-12
          描述:用户-激活码列表
      -->
  <div class="user">
    <!-- 搜索区域 -->
    <div class="common-level-rail">
      <el-form :inline="true" :model="formInline" class="demo-form-inline">
        <el-form-item label="激活码">
          <el-input v-model="formInline.activation_code" placeholder="激活码"></el-input>
        </el-form-item>
        <el-form-item label="状态">
          <el-select v-model="formInline.status" placeholder="请选择状态">
            <el-option label="全部" value="-1"></el-option>
            <el-option label="未使用" value="0"></el-option>
            <el-option label="已使用" value="1"></el-option>
          </el-select>
        </el-form-item>
        <el-form-item label="类型">
          <el-select v-model="formInline.type" placeholder="请选择类型">
            <el-option label="全部" value="-1"></el-option>
            <el-option label="产品" value="10"></el-option>
            <el-option label="项目" value="20"></el-option>
          </el-select>
        </el-form-item>
        <el-form-item>
          <el-button size="small" type="primary" @click="onSubmit">查询</el-button>
          <el-button size="small" @click="onReset">重置</el-button>
        </el-form-item>
      </el-form>
    </div>
 
    <!--内容-->
    <div class="product-content">
      <div class="table-wrap">
        <el-table size="small" :data="tableData" border style="width: 100%" v-loading="loading">
          <el-table-column prop="activation_code_id" label="ID"></el-table-column>
          <el-table-column prop="activation_code" label="激活码"></el-table-column>
          <el-table-column prop="status" label="状态">
            <template slot-scope="scope">
              <el-tag :type="scope.row.status == 0 ? 'primary' : 'success'">
                {{ scope.row.status == 0 ? '未使用' : '已使用' }}
              </el-tag>
            </template>
          </el-table-column>
          <el-table-column prop="type" label="类型">
            <template slot-scope="scope">
              <el-tag :type="scope.row.type == 10 ? 'primary' : 'warning'">
                {{ scope.row.type == 10 ? '产品' : '项目' }}
              </el-tag>
            </template>
          </el-table-column>
          <el-table-column prop="is_shipment" label="发货状态">
            <template slot-scope="scope">
              <el-tag :type="scope.row.is_shipment == 1 ? 'primary' : 'warning'">
                {{ scope.row.is_shipment == 1 ? '已发货' : '未发货' }}
              </el-tag>
            </template>
          </el-table-column>
          <el-table-column prop="" label="所属用户">
            <template slot-scope="scope">
              <div>{{ scope.row.user?scope.row.user.nickName:'--' }}</div>
              <div class="gray9">ID:({{ scope.row.user?scope.row.user.user_id:'--' }})</div>
            </template>
          </el-table-column>
          <el-table-column prop="" label="所属订单">
            <template slot-scope="scope">
              <div>{{ scope.row.order?scope.row.order.order_no:'--' }}</div>
              <div class="gray9">ID:({{ scope.row.order?scope.row.order.order_id:'--' }})</div>
            </template>
          </el-table-column>
 
          <el-table-column prop="" label="使用用户">
            <template slot-scope="scope">
              <div>{{ scope.row.useUser?scope.row.useUser.nickName:'--' }}</div>
              <div class="gray9">{{ scope.row.useUser?'ID:('+scope.row.useUser.user_id+')':'--' }}</div>
            </template>
          </el-table-column>
          <el-table-column prop="" label="使用订单">
            <template slot-scope="scope">
              <div>{{ scope.row.useOrder?scope.row.useOrder.order_no:'--' }}</div>
              <div class="gray9">{{ scope.row.useOrder?'ID:('+scope.row.useOrder.order_id+')':'--' }}</div>
            </template>
          </el-table-column>
          <el-table-column prop="use_time" label="使用时间">
            <template slot-scope="scope">
              {{ scope.row.use_time ? scope.row.use_time : '-' }}
            </template>
          </el-table-column>
          <el-table-column prop="create_time" label="创建时间">
            <template slot-scope="scope">
              {{ scope.row.create_time }}
            </template>
          </el-table-column>
          <el-table-column fixed="right" label="操作" width="170">
            <template slot-scope="scope">
              <el-button  v-if="scope.row.status == 0 "  @click="changeStatus(scope.row)" type="text" size="small" v-auth="'/user/activation/markAsUsed'">已使用</el-button>
              <el-button  v-if="scope.row.status == 0&&scope.row.status == 0"  @click="upIsShipment(scope.row)" type="text" size="small" v-auth="'/user/activation/upIsShipment'">{{scope.row.is_shipment == 0 ? '发货' : '不发货'}}</el-button>
            </template>
          </el-table-column>
        </el-table>
      </div>
 
      <!--分页-->
      <div class="pagination">
        <el-pagination @size-change="handleSizeChange" @current-change="handleCurrentChange" background
          :current-page="curPage" :page-size="pageSize" layout="total, sizes, prev, pager, next, jumper"
          :total="totalDataNumber" :page-sizes="[10, 20, 50, 100]">
        </el-pagination>
      </div>
    </div>
  </div>
</template>
 
<script>
  import UserApi from '@/api/user.js';
  export default {
    name: "ActivationList",
    data() {
      return {
        /*是否加载完成*/
        loading: true,
        /*列表数据*/
        tableData: [],
        /*一页多少条*/
        pageSize: 20,
        /*一共多少条数据*/
        totalDataNumber: 0,
        /*当前是第几页*/
        curPage: 1,
        /*搜索表单数据模型*/
        formInline: {
          activation_code: '',
          status: '',
          type: ''
        }
      };
    },
    created() {
      /*获取列表*/
      this.getTableList();
    },
    methods: {
      /*选择第几页*/
      handleCurrentChange(val) {
        this.curPage = val;
        this.loading = true;
        this.getTableList();
      },
 
      /*每页多少条*/
      handleSizeChange(val) {
        this.curPage = 1;
        this.pageSize = val;
        this.getTableList();
      },
 
      /*获取列表*/
      getTableList() {
        let self = this;
        let Params = {};
        Params.page = self.curPage;
        Params.list_rows = self.pageSize;
 
        // 添加搜索条件
        if (self.formInline.activation_code) {
          Params.activation_code = self.formInline.activation_code;
        }
        if (self.formInline.status !== '') {
          Params.status = self.formInline.status;
        }
        if (self.formInline.type !== '') {
          Params.type = self.formInline.type;
        }
 
        // TODO: 需要添加激活码列表接口
        // 暂时使用用户列表接口作为示例
        UserApi.activationCodelist(Params, true)
          .then(data => {
            self.loading = false;
            self.tableData = data.data.list.data || [];
            self.totalDataNumber = data.data.list.total || 0;
          })
          .catch(error => {
            self.loading = false;
            console.error('获取激活码列表失败:', error);
          });
      },
 
      /*搜索*/
      onSubmit() {
        this.curPage = 1;
        this.getTableList();
      },
 
      /*重置搜索条件*/
      onReset() {
        this.formInline.activation_code = '';
        this.formInline.status = '';
        this.formInline.type = '';
        this.curPage = 1;
        this.getTableList();
      },
      /*修改状态*/
      changeStatus(row, value) {
        let self = this;
        let msg = '';
        let ids = '';
        self.$confirm('确定要将该激活码改为已使用吗?', '提示', {
            type: 'warning'
          })
          .then(() => {
            UserApi.activationChangeStatus({
              activation_code: row.activation_code
            }).then(data => {
              self.$message({
                message: '操作成功',
                type: 'success'
              });
              self.getTableList();
            });
          });
      },
      /*修改发货状态*/
      upIsShipment(row) {
        let self = this;
        let msg = '';
        let ids = '';
        self.$confirm('确定要将该激活码改为'+(row.is_shipment == 0 ? '已发货' : '未发货')+'状态吗?', '提示', {
          type: 'warning'
        })
          .then(() => {
            UserApi.activationUpIsShipment({
              activation_code: row.activation_code
            }).then(data => {
              self.$message({
                message: '操作成功',
                type: 'success'
              });
              self.getTableList();
            });
          });
      },
    }
  };
</script>
 
<style scoped>
  .user {
    background: #fff;
    padding: 20px;
    margin: 20px;
    border-radius: 5px;
  }
 
  .common-level-rail {
    margin-bottom: 20px;
  }
 
  .product-content {
    margin-top: 20px;
  }
 
  .table-wrap {
    margin-bottom: 20px;
  }
 
  .pagination {
    display: flex;
    justify-content: flex-end;
  }
</style>