Skip to content

Commit 0b347b3

Browse files
committed
entity custoemr实体
1 parent 79849cf commit 0b347b3

File tree

6 files changed

+174
-106
lines changed

6 files changed

+174
-106
lines changed

src/api/blogs.ts

Lines changed: 0 additions & 75 deletions
This file was deleted.

src/api/customer.ts

Lines changed: 33 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,33 @@
1+
import request from '@/utils/request'
2+
// eslint-disable-next-line no-unused-vars
3+
import { CustomerContent } from '@/entity/Customer'
4+
const mockNum = '/mock/89/api/'
5+
6+
export const getCustomerList = ():Promise<{contents:Array<CustomerContent>, totalElements:number}> => {
7+
return request({
8+
url: mockNum + 'customer/list',
9+
method: 'get'
10+
})
11+
}
12+
export const createCustomer = (data:CustomerContent) => {
13+
return request({
14+
url: mockNum + 'customer',
15+
method: 'post',
16+
data
17+
})
18+
}
19+
20+
export const updateCustomer = (data:CustomerContent) => {
21+
return request({
22+
url: mockNum + 'customer',
23+
method: 'put',
24+
data
25+
})
26+
}
27+
export const deleteCustomer = (id:string) => {
28+
return request({
29+
url: mockNum + 'customer/' + id,
30+
method: 'delete'
31+
})
32+
}
33+

src/components/HeaderMenu/Modules.vue

Lines changed: 14 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,15 @@
1818
v-for="item in moduleMenu"
1919
:key="item.name"
2020
>
21-
<span rel="noopener noreferrer"> <a-icon type="folder" />&nbsp;&nbsp;{{ $t(`menu.${ item.name }`) }}</span>
21+
<div class="module-menu-item">
22+
<span rel="noopener noreferrer"> <a-icon type="folder" />&nbsp;&nbsp;{{ $t(`menu.${ item.name }`) }}</span>
23+
<span v-if="activeModule === item.name">
24+
<a-icon
25+
type="environment"
26+
theme="twoTone"
27+
two-tone-color="#52c41a"
28+
/></span>
29+
</div>
2230
</a-menu-item>
2331
</a-menu>
2432
</a-dropdown>
@@ -91,6 +99,10 @@
9199
.module-icon:hover {
92100
background: rgba(0, 0, 0, 0.025);
93101
}
94-
}
95102
103+
}
104+
.module-menu-item{
105+
display: flex;
106+
justify-content: space-between;
107+
}
96108
</style>

src/entity/Customer.ts

Lines changed: 35 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,35 @@
1+
import { getCustomerList, createCustomer, updateCustomer, deleteCustomer } from '@/api/customer'
2+
3+
export interface CustomerContent {
4+
id?:string
5+
name:string
6+
code:string
7+
address:string
8+
state:boolean
9+
phone:string
10+
}
11+
12+
export class Customer {
13+
content:CustomerContent
14+
constructor(customer?:CustomerContent) {
15+
this.content = customer || {
16+
name: '',
17+
code: '',
18+
address: '',
19+
state: true,
20+
phone: ''
21+
}
22+
}
23+
create() {
24+
return createCustomer(this.content)
25+
}
26+
update() {
27+
return updateCustomer((this.content))
28+
}
29+
delete(customerId?:string) {
30+
return deleteCustomer(customerId || this.content.id as string)
31+
}
32+
static getAllCustoemrList() {
33+
return getCustomerList()
34+
}
35+
}

src/model/CustomerModel.ts

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
interface Model {
2+
[key:string]:any
3+
}
4+
// 策略模式
5+
export const CustomerCodeType:Model = {
6+
'1': { tagColor: '#87d068', name: '1级客户' },
7+
'2': { tagColor: '#2db7f5', name: '2级客户' },
8+
'3': { tagColor: '#108ee9', name: '3级客户' }
9+
}

src/views/business/customer/index.vue

Lines changed: 83 additions & 29 deletions
Original file line numberDiff line numberDiff line change
@@ -14,26 +14,53 @@
1414
<div>
1515
<a-table
1616
:columns="columns"
17-
:data-source="data"
18-
:row-key="record => record._id"
17+
:data-source="customerList"
18+
:row-key="record => record.id"
1919
:pagination="false"
2020
:loading="loading"
2121
>
22+
<a
23+
slot="name"
24+
slot-scope="name"
25+
>
26+
{{ name }}
27+
</a>
2228
<template
23-
slot="avatar"
24-
slot-scope="avatar"
29+
slot="code"
30+
slot-scope="code"
2531
>
26-
<a-avatar
27-
:src="avatar"
28-
:size="23"
29-
/>
32+
<a-tag
33+
:color="getCustomerType(code).tagColor"
34+
>
35+
{{ getCustomerType(code).name }}
36+
</a-tag>
3037
</template>
3138
<template
32-
slot="name"
33-
slot-scope="name"
39+
slot="state"
40+
slot-scope="state"
3441
>
35-
{{ name }}
42+
<a-tag
43+
v-if="!state"
44+
color="red"
45+
>
46+
冻结
47+
</a-tag>
48+
<a-tag
49+
v-else
50+
color="cyan"
51+
>
52+
激活
53+
</a-tag>
3654
</template>
55+
<span
56+
slot="action"
57+
slot-scope=""
58+
>
59+
<a>编辑</a>
60+
<a-divider type="vertical" />
61+
<a>删除</a>
62+
63+
</span>
3764
</a-table>
3865
</div>
3966
</div>
@@ -43,43 +70,70 @@
4370
<script lang="ts">
4471
4572
import { Vue, Component, Prop } from 'vue-property-decorator'
73+
import { Tag, Divider } from 'ant-design-vue'
4674
import WxFilter from './components/filter.vue'
75+
// eslint-disable-next-line no-unused-vars
76+
import { Customer, CustomerContent } from '@/entity/Customer'
77+
import { CustomerCodeType } from '@/model/CustomerModel'
4778
const CustomerImg = require('../../../assets/images/customer.jpg')
4879
const columns = [
4980
{
50-
title: 'avatar',
51-
dataIndex: 'avatar',
52-
width: '20%',
53-
scopedSlots: { customRender: 'avatar' }
54-
},
55-
{
56-
title: 'Name',
81+
title: '客户名称',
5782
dataIndex: 'name',
5883
sorter: true,
5984
width: '20%',
6085
scopedSlots: { customRender: 'name' }
6186
},
6287
{
63-
title: 'Role',
64-
dataIndex: 'role',
65-
width: '20%'
88+
title: 'code',
89+
dataIndex: 'code',
90+
scopedSlots: { customRender: 'code' }
91+
},
92+
{
93+
title: 'state',
94+
dataIndex: 'state',
95+
scopedSlots: { customRender: 'state' }
6696
},
6797
{
68-
title: 'Email',
69-
dataIndex: 'email'
98+
title: '电话',
99+
dataIndex: 'phone'
100+
},
101+
{
102+
title: '地址',
103+
dataIndex: 'address'
104+
},
105+
{
106+
title: '操作',
107+
key: 'action',
108+
scopedSlots: { customRender: 'action' }
70109
}
71110
]
111+
// eslint-disable-next-line no-unused-vars
112+
enum CustomerTypes { first, second, thrid}
113+
72114
@Component({
73115
components: {
74-
'wx-filter': WxFilter
116+
'wx-filter': WxFilter,
117+
'a-tag': Tag,
118+
'a-divider': Divider
75119
}
76120
})
77-
export default class Customer extends Vue {
78-
customerImg = CustomerImg
79-
visible: boolean = false;
80-
columns:Array<object> = columns
81-
@Prop() data!:Array<object>
121+
export default class extends Vue {
122+
private customerImg = CustomerImg
123+
private visible: boolean = false;
124+
private columns:Array<object> = columns
125+
private customerList:Array<CustomerContent> = []
126+
private total:number = 0
82127
@Prop() loading!:boolean
128+
129+
getCustomerType(code:string) {
130+
return CustomerCodeType[code]
131+
}
132+
async mounted() {
133+
const customerListContent = await Customer.getAllCustoemrList()
134+
this.customerList = customerListContent.contents
135+
this.total = customerListContent.totalElements
136+
}
83137
}
84138
</script>
85139

0 commit comments

Comments
 (0)