zhangzeli
2022-01-05 1b98ab0d3d007a5a65bdd446483853df34b8919c
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
<template>
  <div class="order-table">
    <Card :padding="20">
      <div class="title">最新订单详情</div>
      <Table :columns="columns" :data="data"></Table>
    </Card>
  </div>
</template>
 
<script>
export default {
  name: "order-table",
  components: {},
  props: {},
  data() {
    return {
      columns: [
        {
          type: "index",
          width: 60,
          align: "center",
        },
        {
          title: "订单ID",
          key: "id",
          minWidth: 150,
          sortable: true,
        },
        {
          title: "用户",
          key: "name",
          minWidth: 100,
          sortable: true,
        },
        {
          title: "订单总价",
          key: "total",
          minWidth: 100,
        },
        {
          title: "支付方式",
          key: "payType",
          sortable: true,
          minWidth: 150,
          align: "center",
          render: (h, params) => {
            let img = "";
            if (params.row.payType == 0) {
              img = require("@/assets/icon/alipay.png");
            } else if (params.row.payType == 1) {
              img = require("@/assets/icon/wechatpay.png");
            } else if (params.row.payType == 2) {
              img = require("@/assets/icon/applepay.png");
            } else if (params.row.payType == 3) {
              img = require("@/assets/icon/paypal.png");
            } else if (params.row.payType == 4) {
              img = require("@/assets/icon/yinlian.png");
            }
            return h("img", {
              attrs: {
                src: img,
              },
              style: {
                width: "40px",
                height: "40px",
                margin: "5px 0",
                "object-fit": "contain",
              },
            });
          },
        },
        {
          title: "状态",
          key: "status",
          align: "center",
          minWidth: 150,
          render: (h, params) => {
            let color = "",
              text = "";
            if (params.row.status == 0) {
              color = "default";
              text = "待支付";
            } else if (params.row.status == 1) {
              color = "blue";
              text = "已支付";
            } else if (params.row.status == 2) {
              color = "green";
              text = "已完成";
            } else if (params.row.status == 3) {
              color = "orange";
              text = "已发货";
            } else if (params.row.status == 4) {
              color = "red";
              text = "已取消";
            }
            return h("div", [
              h(
                "Tag",
                {
                  props: {
                    color: color,
                  },
                },
                text
              ),
            ]);
          },
          filters: [
            {
              label: "待支付",
              value: 0,
            },
            {
              label: "已支付",
              value: 1,
            },
            {
              label: "已完成",
              value: 2,
            },
            {
              label: "已发货",
              value: 3,
            },
            {
              label: "已取消",
              value: 4,
            },
          ],
          filterMultiple: false,
          filterMethod(value, row) {
            return row.status == value;
          },
        },
        {
          title: "创建时间",
          key: "createTime",
          sortable: true,
          sortType: "desc",
          width: 180,
        },
        {
          title: "操作",
          key: "action",
          width: 200,
          align: "center",
          render: (h, params) => {
            return h("div", [
              h(
                "a",
                {
                  on: {
                    click: () => {
                      this.$Message.info("点击了" + params.row.id);
                    },
                  },
                },
                "查看详情"
              ),
            ]);
          },
        },
      ],
      data: [
        {
          id: "1338061428384468992",
          name: "XBoot",
          total: "5998.00",
          payType: 0,
          status: 0,
          createTime: "2021-08-08 00:08:00",
        },
        {
          id: "2838061428384468992",
          name: "Exrick",
          total: "568.80",
          payType: 1,
          status: 1,
          createTime: "2021-08-08 00:08:00",
        },
        {
          id: "3338066255608942592",
          name: "Exrick",
          total: "168.00",
          payType: 2,
          status: 2,
          createTime: "2021-08-08 00:08:00",
        },
        {
          id: "1344692740297986048",
          name: "Exrick",
          total: "68.50",
          payType: 3,
          status: 3,
          createTime: "2021-08-08 00:08:00",
        },
        {
          id: "5344708212645040128",
          name: "Exrick",
          total: "1068.00",
          payType: 4,
          status: 4,
          createTime: "2021-08-08 00:08:00",
        },
      ],
    };
  },
  methods: {
    init() {},
  },
  mounted() {
    this.init();
  },
};
</script>
<style lang="less" scoped>
.order-table {
  .title {
    font-size: 16px;
    font-weight: 600;
    color: #495057;
    margin-bottom: 24px;
  }
}
</style>