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
| <template>
| <el-bus-crud ref="crud" v-bind="tableConfig" />
| </template>
|
| <script>
| export default {
| data() {
| return {
| tableConfig: {
| url: 'flower/api/supplierSub/page',
| editUrl: 'flower/api/supplierSub/addOrUpdate',
| deleteUrl: 'flower/api/supplierSub/delete',
| deleteOnPath: true,
| deleteMethodType: 'post',
| hasNew: false,
| hasDelete: true,
| operationAttrs: {
| width: '200px',
| fixed: 'right',
| },
| columns: [
| { label: '序号', type: 'index' },
| { label: '供应商ID', prop: 'supplierId', minWidth: '120px' },
| {
| label: '供应商名称',
| prop: 'supplierName',
| minWidth: '120px',
| },
| { label: '供应商联系人', prop: 'contactName', minWidth: '100px' },
| { label: '主账号手机号', prop: 'contactTel', minWidth: '120px' },
| { label: '子账号手机号', prop: 'phone', minWidth: '120px' },
| { label: '子账号名', prop: 'name', minWidth: '120px' },
| { label: '子账号联系人', prop: 'contact', minWidth: '120px' },
| { label: '创建时间', prop: 'createTime', minWidth: '120px' },
| {
| label: '启用/禁用',
| formatter: (row) => (
| <el-switch
| value={row.isEnabled}
| onChange={this.onEnabledChange.bind(this, row)}
| ></el-switch>
| ),
| minWidth: 120,
| fixed: 'right',
| },
| ],
| searchForm: [
| {
| type: 'row',
| items: [
| {
| label: '供应商ID', id: 'supplierId', type: 'input',
| rules: {
| required: false,
| pattern: /^\d*$/,
| message: '请输入合法的供应商ID',
| trigger: 'blur',
| },
| },
| { label: '供应商名称', id: 'supplierName', type: 'input' },
| { label: '主账号手机号', id: 'supplierPhone', type: 'input',
| rules: {
| required: false,
| pattern: this.$elBusUtil.REG.MOBILEPHONE,
| message: '请输入合法的手机号',
| trigger: 'blur',
| },
| },
| { label: '子账号手机号', id: 'phone', type: 'input',
| rules: {
| required: false,
| pattern: this.$elBusUtil.REG.MOBILEPHONE,
| message: '请输入合法的手机号',
| trigger: 'blur',
| },
| },
| {
| label: '启用/禁用',
| id: 'isEnabled',
| type: 'bus-select-dict',
| default: '1',
| el: {
| code: 'USER_ENABLED_OR_DISABLED',
| clearable: true,
| style: 'width:100%',
| },
| },
| ],
| },
| ],
| form: [
| {
| label: '供应商ID:',
| id: 'supplierId',
| type: 'input',
| span: 12,
| hidden: (row, item, mode) => mode !== 'view',
| },
| {
| label: '供应商名称:',
| id: 'supplierName',
| type: 'input',
| span: 12,
| hidden: (row, item, mode) => mode !== 'view',
| },
| {
| label: '供应商联系人:',
| id: 'contactName',
| type: 'input',
| span: 12,
| hidden: (row, item, mode) => mode !== 'view',
| },
| {
| label: '主账号手机号:',
| id: 'contactTel',
| type: 'input',
| span: 12,
| hidden: (row, item, mode) => mode !== 'view',
| },
| {
| type: 'row',
| span: 12,
| items: [
| {
| label: '子账号手机号:',
| id: 'phone',
| type: 'input',
| rules: {
| required: true,
| pattern: this.$elBusUtil.REG.MOBILEPHONE,
| message: '请输入合法的手机号',
| trigger: 'blur',
| },
| },
| {
| label: '子账号名:',
| id: 'name',
| type: 'input',
| rules: {
| required: true,
| message: '请输入子账号名',
| trigger: 'blur',
| },
| },
| {
| label: '子账号联系人:',
| id: 'contact',
| type: 'input',
| rules: {
| required: true,
| message: '请输入子账号联系人',
| trigger: 'blur',
| },
| },
| {
| id: 'type',
| default: '1',
| },
| ],
| },
|
| ],
| extraButtons: [
| {
| text: '密码修改',
| atClick: (row) => {
| this.$refs.crud.$refs.extraDialog[0].show(row)
| return false
| },
| },
| ],
| extraDialogs: [
| {
| title: '密码修改',
| hiddenReverseItems: [],
| form: [
| {
| label: '请输入新密码:',
| id: 'password',
| type: 'input',
| rules: {
| required: true,
| pattern: /^(?:(?=\S*\d)(?=\S*[A-Z])(?=\S*[a-z])(?=\S*[-_!@#$%^&*? ]))\S{8,20}$/,
| message: '请输入正确的密码(8-20位,包括至少1个大写字母,1个小写字母,1个数字,1个特殊字符)',
| trigger: 'blur',
| },
| },
| {
| id: 'type',
| default: '1',
| },
| ],
| atConfirm: async (val) => {
| const { code } = await this.$elBusHttp.request(
| 'flower/api/supplierSub/addOrUpdate',
| {
| method: 'post',
| data: val,
| }
| )
| if (code === 0) {
| this.$message.success('操作成功')
| }
| },
| },
| ],
| },
| }
| },
| head() {
| return {
| title: '子账号列表',
| }
| },
| methods: {
| onEnabledChange(row, e) {
| const url = 'flower/api/supplierSub/page/isEnable'
| const text = e ? '启用' : '禁用'
| this.$elBusUtil
| .confirm(`确定要${text}这个供应商吗?`)
| .then(async () => {
| const { code } = await this.$elBusHttp.request(url, {
| params: {
| id: row.id,
| },
| })
| if (code === 0) {
| this.$message.success(`${text}成功`)
| this.$refs.crud.getList()
| }
| })
| .catch(() => {})
| },
| },
| }
| </script>
|
|