Przeglądaj źródła

区域管理

gzb
guozhongbo 10 miesięcy temu
rodzic
commit
b7373f8b82

+ 8
- 0
src/api/admin.js Wyświetl plik

@@ -4,6 +4,10 @@ import { setRequest } from "@/utils/httpRequest";
4 4
  * 1.1管理员--平台管理员列表
5 5
  */
6 6
 export const admin_list_pt = (data) => setRequest("admin/list_pt", data);
7
+/**
8
+ * 1.1管理员--区域管理员列表
9
+ */
10
+export const admin_list_qy = (data) => setRequest("admin/list_qy", data);
7 11
 /**
8 12
  * 1.2管理员--添加
9 13
  */
@@ -24,3 +28,7 @@ export const admin_disabled = (data) => setRequest("admin/disabled", data);
24 28
  * 1.4管理员--删除
25 29
  */
26 30
 export const admin_delete = (data) => setRequest("admin/delete", data);
31
+/**
32
+ * 1.5管理员--详情
33
+ */
34
+export const admin_detail = (data) => setRequest("admin/detail", data);

+ 30
- 0
src/api/school.js Wyświetl plik

@@ -0,0 +1,30 @@
1
+import { setRequest } from "@/utils/httpRequest";
2
+
3
+/**
4
+ * 3.1.1学校--列表
5
+ */
6
+export const school_list = (data) => setRequest("school/list", data);
7
+/**
8
+ * 3.1.2学校--添加
9
+ */
10
+export const school_add = (data) => setRequest("school/add", data);
11
+/**
12
+ * 3.1.3学校--更新
13
+ */
14
+export const school_edit = (data) => setRequest("school/edit", data);
15
+/**
16
+ * 3.1.3.2学校--启用
17
+ */
18
+export const school_enable = (data) => setRequest("school/enable", data);
19
+/**
20
+ * 3.1.3.3学校--禁用
21
+ */
22
+export const school_disabled = (data) => setRequest("school/disabled", data);
23
+/**
24
+ * 3.1.4学校--删除
25
+ */
26
+export const school_delete = (data) => setRequest("school/delete", data);
27
+/**
28
+ * 3.1.5学校--详情
29
+ */
30
+export const school_detail = (data) => setRequest("school/detail", data);

+ 710
- 4
src/views/regionSection/regionManage/adminManage.vue Wyświetl plik

@@ -1,14 +1,720 @@
1 1
 <template>
2
-  <div class="main_root">管理员</div>
2
+  <div class="main_root">
3
+    <div class="search_header">
4
+      <div class="search_left">
5
+        <Select
6
+          :transfer="true"
7
+          v-model="searchForm.regionid"
8
+          @on-change="searchList()"
9
+          style="margin-right: 10px; width: 150px"
10
+        >
11
+          <Option :value="0">所有区域</Option>
12
+          <Option
13
+            v-for="item in searchForm.dropList"
14
+            :value="item.regionid"
15
+            :key="item.regionid"
16
+            >{{ item.regionName }}</Option
17
+          >
18
+        </Select>
19
+        <Select
20
+          :transfer="true"
21
+          v-model="searchForm.enabled"
22
+          @on-change="searchList()"
23
+          style="margin-right: 10px; width: 150px"
24
+        >
25
+          <Option :value="0">所有状态</Option>
26
+          <Option :value="1">启用</Option>
27
+          <Option :value="2">禁用</Option>
28
+        </Select>
29
+        <Input
30
+          v-model="searchForm.aname"
31
+          placeholder="请输入名称"
32
+          search
33
+          @on-search="searchList()"
34
+          style="width: 150px"
35
+        />
36
+      </div>
37
+      <Button type="primary" class="primary_btn" @click="toAdd()">新建</Button>
38
+    </div>
39
+    <div class="table_wrap">
40
+      <Table :columns="columns" :data="searchForm.list">
41
+        <template slot-scope="{ row }" slot="enabledSlot">
42
+          <i-switch
43
+            size="large"
44
+            v-model="row.enabled"
45
+            :true-value="1"
46
+            :false-value="2"
47
+            @on-change="enabledChange(row)"
48
+          >
49
+            <span slot="open">启用</span>
50
+            <span slot="close">禁用</span>
51
+          </i-switch>
52
+        </template>
53
+        <template slot-scope="{ row }" slot="actionSlot">
54
+          <div class="action_list">
55
+            <div @click="toView(row)">查看</div>
56
+            <div @click="toEdit(row)">编辑</div>
57
+            <div class="action_del" @click="toDel(row)">删除</div>
58
+          </div>
59
+        </template>
60
+      </Table>
61
+    </div>
62
+    <div class="page_wrap">
63
+      <Page
64
+        :transfer="true"
65
+        :total="searchForm.total"
66
+        :current="searchForm.page"
67
+        :page-size="searchForm.size"
68
+        :page-size-opts="[10, 20, 40, 60]"
69
+        @on-change="pageChange"
70
+        @on-page-size-change="pageSizeChange"
71
+        show-total
72
+        show-sizer
73
+      ></Page>
74
+    </div>
75
+    <!-- 新建/编辑 -->
76
+    <Modal
77
+      class="modal1"
78
+      :mask-closable="false"
79
+      v-model="adminInfo.show"
80
+      :title="adminInfo.adminid ? '编辑' : '新建'"
81
+    >
82
+      <Form
83
+        v-if="adminInfo.show"
84
+        ref="addForm"
85
+        :model="adminInfo"
86
+        :rules="rules"
87
+        :label-width="110"
88
+        inline
89
+      >
90
+        <FormItem label="管理员名称" prop="aname" style="width: 100%">
91
+          <Input
92
+            v-model="adminInfo.aname"
93
+            placeholder="请输入管理员名称"
94
+          ></Input>
95
+        </FormItem>
96
+        <FormItem label="登录账号" prop="loginname" style="width: 100%">
97
+          <Input
98
+            v-model="adminInfo.loginname"
99
+            placeholder="请输入登录账号"
100
+          ></Input>
101
+        </FormItem>
102
+        <template v-if="!adminInfo.adminid">
103
+          <FormItem
104
+            label="密码"
105
+            prop="loginpwd"
106
+            style="width: calc(50% - 10px)"
107
+          >
108
+            <Input
109
+              v-model="adminInfo.loginpwd"
110
+              placeholder="请输入密码"
111
+            ></Input>
112
+          </FormItem>
113
+          <FormItem
114
+            label="确认密码"
115
+            prop="loginpwd1"
116
+            style="width: calc(50% - 10px)"
117
+          >
118
+            <Input
119
+              v-model="adminInfo.loginpwd1"
120
+              placeholder="请输入确认密码"
121
+            ></Input>
122
+          </FormItem>
123
+        </template>
124
+        <template v-else>
125
+          <FormItem label="密码" style="width: calc(50% - 10px)">
126
+            <Input
127
+              v-model="adminInfo.loginpwd"
128
+              placeholder="请输入密码"
129
+            ></Input>
130
+          </FormItem>
131
+          <FormItem label="确认密码" style="width: calc(50% - 10px)">
132
+            <Input
133
+              v-model="adminInfo.loginpwd1"
134
+              placeholder="请输入确认密码"
135
+            ></Input>
136
+          </FormItem>
137
+        </template>
138
+        <FormItem label="手机号码" prop="phone" style="width: calc(50% - 10px)">
139
+          <Input v-model="adminInfo.phone" placeholder="请输入手机号码"></Input>
140
+        </FormItem>
141
+        <FormItem label="短信验证码" style="width: calc(50% - 10px)">
142
+          <Input
143
+            style="width: calc(100% - 102px)"
144
+            v-model="adminInfo.msgcode"
145
+            placeholder="请输入短信验证码"
146
+          ></Input>
147
+          <div
148
+            :class="['code_btn', adminInfo.second === 60 ? '' : 'disabled']"
149
+            @click="getMsgCode()"
150
+          >
151
+            {{
152
+              adminInfo.second === 60 ? "获取验证码" : `${adminInfo.second}s`
153
+            }}
154
+          </div>
155
+        </FormItem>
156
+        <FormItem label="状态" prop="enabled" style="width: 100%">
157
+          <RadioGroup v-model="adminInfo.enabled">
158
+            <Radio :label="1">启用</Radio>
159
+            <Radio :label="2">禁用</Radio>
160
+          </RadioGroup>
161
+        </FormItem>
162
+        <FormItem label="所属区域" prop="regionid" style="width: 100%">
163
+          <Select
164
+            :transfer="true"
165
+            v-model="adminInfo.regionid"
166
+            style="width: calc(50% - 65px)"
167
+          >
168
+            <Option
169
+              v-for="item in searchForm.dropList"
170
+              :value="item.regionid"
171
+              :key="item.regionid"
172
+              >{{ item.regionName }}</Option
173
+            >
174
+          </Select>
175
+        </FormItem>
176
+      </Form>
177
+      <div
178
+        slot="footer"
179
+        style="
180
+          display: flex;
181
+          justify-content: space-between;
182
+          align-items: center;
183
+        "
184
+      >
185
+        <div style="color: #b50000">
186
+          注:密码必须包含大小写字母和数字的组合,长度在8-32之间。
187
+        </div>
188
+        <div>
189
+          <Button @click="adminInfo.show = false">取消</Button>
190
+          <Button @click="saveAddInfo()" type="primary">保存</Button>
191
+        </div>
192
+      </div>
193
+    </Modal>
194
+    <!-- 查看 -->
195
+    <Modal
196
+      class="modal1"
197
+      :mask-closable="false"
198
+      v-model="viewInfo.show"
199
+      title="查看"
200
+    >
201
+      <div class="view_title">
202
+        <div>{{ viewInfo.aname }}</div>
203
+        <div v-if="viewInfo.enabled === 1" class="enabled_1">启用</div>
204
+        <div v-if="viewInfo.enabled === 2" class="enabled_2">禁用</div>
205
+      </div>
206
+      <Form :label-width="80" inline>
207
+        <FormItem
208
+          label="登录账号"
209
+          style="margin-bottom: 0; width: calc(50% - 10px)"
210
+          >{{ viewInfo.loginname }}</FormItem
211
+        >
212
+        <FormItem
213
+          label="手机号码"
214
+          style="margin-bottom: 0; width: calc(50% - 10px)"
215
+          >{{ viewInfo.phone }}</FormItem
216
+        >
217
+        <FormItem label="所属区域" style="margin-bottom: 0; width: 100%">{{
218
+          viewInfo.regionName
219
+        }}</FormItem>
220
+      </Form>
221
+      <div slot="footer" style="text-align: center">
222
+        <Button @click="viewInfo.show = false">关闭</Button>
223
+      </div>
224
+    </Modal>
225
+  </div>
3 226
 </template>
4 227
 
5 228
 <script>
229
+import {
230
+  admin_list_pt,
231
+  admin_add,
232
+  admin_edit,
233
+  admin_delete,
234
+  admin_enable,
235
+  admin_disabled, admin_list_qy, admin_detail
236
+} from "@/api/admin";
237
+import { region_list_sel_pt } from "@/api/region";
238
+import { login_msg_code } from "@/api/login";
239
+import { generateRandomString } from "@/utils";
6 240
 export default {
7 241
   data() {
8
-    return {};
242
+    const reg = /^(?=.*[a-z])(?=.*[A-Z])(?=.*\d)[a-zA-Z\d]{8,32}$/;
243
+    // 密码验证
244
+    const pwdCheck = (rule, value, callback) => {
245
+      if (!reg.test(this.adminInfo.loginpwd)) {
246
+        return callback(
247
+            new Error("密码格式不正确!")
248
+        );
249
+      } else {
250
+        callback();
251
+      }
252
+    };
253
+    // 重复密码验证
254
+    const pwdAgainCheck = async (rule, value, callback) => {
255
+      if (!reg.test(this.adminInfo.loginpwd1)) {
256
+        return callback(
257
+            new Error("密码格式不正确!")
258
+        );
259
+      } else if (this.adminInfo.loginpwd != this.adminInfo.loginpwd1) {
260
+        return callback(new Error("两次输入密码不一致!"));
261
+      } else {
262
+        callback();
263
+      }
264
+    };
265
+    return {
266
+      searchForm: {
267
+        dropList: [],
268
+        aname: "",
269
+        // 0所有区域
270
+        regionid: 0,
271
+        // 是否启用0所有 1启用 2禁用
272
+        enabled: 0,
273
+        page: 1,
274
+        size: 10,
275
+        list: [],
276
+        total: 0
277
+      },
278
+      rules: {
279
+        regionName: [
280
+          {
281
+            required: true,
282
+            message: "请输入区域名称",
283
+            trigger: "blur"
284
+          }
285
+        ],
286
+        aname: [
287
+          {
288
+            required: true,
289
+            message: "请输入管理员名称",
290
+            trigger: "blur"
291
+          }
292
+        ],
293
+        loginname: [
294
+          {
295
+            required: true,
296
+            message: "请输入请输入登录账号",
297
+            trigger: "blur"
298
+          }
299
+        ],
300
+        loginpwd: [
301
+          {
302
+            required: true,
303
+            validator: pwdCheck,
304
+            trigger: "blur"
305
+          }
306
+        ],
307
+        loginpwd1: [
308
+          {
309
+            required: true,
310
+            validator: pwdAgainCheck,
311
+            trigger: "blur"
312
+          }
313
+        ],
314
+        enabled: [
315
+          {
316
+            required: true,
317
+            type: "number",
318
+            message: "请选择状态",
319
+            trigger: "change"
320
+          }
321
+        ],
322
+        regionid: [
323
+          {
324
+            required: true,
325
+            type: "number",
326
+            message: "请选择区域",
327
+            trigger: "change"
328
+          }
329
+        ]
330
+      },
331
+      // 新建/编辑
332
+      adminInfo: {
333
+        show: false,
334
+        timer: null,
335
+        second: 60,
336
+        adminid: null,
337
+        aname: "",
338
+        loginname: "",
339
+        loginpwd: "",
340
+        loginpwd1: "",
341
+        phone: "",
342
+        msgcode: "",
343
+        enabled: 1,
344
+        regionid: null
345
+      },
346
+      // 查看
347
+      viewInfo: {
348
+        show: false,
349
+        enabled: "",
350
+        aname: "",
351
+        loginname: "",
352
+        phone: "",
353
+        regionName: ""
354
+      },
355
+      columns: [
356
+        {
357
+          title: "序号",
358
+          align: "center",
359
+          width: 70,
360
+          render: (h, params) => {
361
+            return h(
362
+              "span",
363
+              params.index +
364
+                (this.searchForm.page - 1) * this.searchForm.size +
365
+                1
366
+            );
367
+          }
368
+        },
369
+        {
370
+          title: "名称",
371
+          key: "aname",
372
+          align: "center"
373
+        },
374
+        {
375
+          title: "登录账号",
376
+          key: "loginname",
377
+          align: "center"
378
+        },
379
+        {
380
+          title: "手机号码",
381
+          key: "phone",
382
+          width: 135,
383
+          align: "center"
384
+        },
385
+        {
386
+          title: "状态",
387
+          slot: "enabledSlot",
388
+          width: 80,
389
+          align: "center"
390
+        },
391
+        {
392
+          title: "区域名称",
393
+          key: "regionName",
394
+          align: "center"
395
+        },
396
+        {
397
+          title: "最后登录IP",
398
+          key: "lastip",
399
+          width: 150,
400
+          align: "center"
401
+        },
402
+        {
403
+          title: "最后登录时间",
404
+          key: "updatetime",
405
+          width: 190,
406
+          align: "center"
407
+        },
408
+        {
409
+          title: "操作",
410
+          slot: "actionSlot",
411
+          width: 180,
412
+          align: "center"
413
+        }
414
+      ],
415
+      userInfo: {}
416
+    };
9 417
   },
10
-  methods: {}
418
+  created() {
419
+    this.userInfo = JSON.parse(
420
+        localStorage.getItem("xh_control_userInfo")
421
+    ).content;
422
+    this.getSearchRegionList();
423
+    this.searchList();
424
+  },
425
+  methods: {
426
+    // 获取搜索区域列表
427
+    getSearchRegionList() {
428
+      region_list_sel_pt({}).then((data) => {
429
+        if (data.code === 0) {
430
+          this.searchForm.dropList = data.obj;
431
+        } else {
432
+          this.$Message.error(data.msg);
433
+        }
434
+      });
435
+    },
436
+    // 搜索
437
+    searchList() {
438
+      this.searchForm.page = 1;
439
+      this.getList();
440
+    },
441
+    // 页码改变
442
+    pageChange(page) {
443
+      this.searchForm.page = page;
444
+      this.getList();
445
+    },
446
+    // 每页显示数量改变
447
+    pageSizeChange(size) {
448
+      this.searchForm.size = size;
449
+      this.searchForm.page = 1;
450
+      this.getList();
451
+    },
452
+    // 获取列表
453
+    getList() {
454
+      admin_list_qy({
455
+        page: this.searchForm.page,
456
+        size: this.searchForm.size,
457
+        enabled: this.searchForm.enabled,
458
+        aname: this.searchForm.aname,
459
+        regionid: this.searchForm.regionid
460
+      }).then((data) => {
461
+        if (data.code === 0) {
462
+          this.searchForm.list = data.obj.data;
463
+          this.searchForm.total = data.obj.total;
464
+          console.log(this.searchForm.list)
465
+        } else {
466
+          this.$Message.error(data.msg);
467
+        }
468
+      });
469
+    },
470
+    // 新建
471
+    toAdd() {
472
+      this.adminInfo = {
473
+        show: true,
474
+        timer: null,
475
+        second: 60,
476
+        adminid: null,
477
+        aname: "",
478
+        loginname: "",
479
+        loginpwd: generateRandomString(8),
480
+        loginpwd1: "",
481
+        phone: "",
482
+        msgcode: "",
483
+        enabled: 1,
484
+        regionid: null
485
+      };
486
+    },
487
+    // 获取短信验证码
488
+    getMsgCode() {
489
+      if (this.adminInfo.second < 60) {
490
+        return;
491
+      }
492
+      // 手机号验证
493
+      if (!this.adminInfo.phone) {
494
+        this.$Message.error("手机号码不能为空");
495
+        return;
496
+      }
497
+      let filter = /^[1][3,4,5,6,7,8,9][0-9]{9}$/;
498
+      if (!filter.test(this.adminInfo.phone)) {
499
+        this.$Message.error("手机号码格式不正确");
500
+        return;
501
+      }
502
+      this.setRegionSecond();
503
+      login_msg_code({
504
+        phone: this.adminInfo.phone
505
+      }).then((data) => {
506
+        if (data.code === 0) {
507
+          this.$Message.success(data.msg);
508
+        } else {
509
+          this.$Message.error(data.msg);
510
+        }
511
+      });
512
+    },
513
+    setRegionSecond() {
514
+      this.adminInfo.second = 59;
515
+      this.adminInfo.timer = setInterval(() => {
516
+        this.adminInfo.second--;
517
+        if (this.adminInfo.second <= 0) {
518
+          clearInterval(this.adminInfo.timer);
519
+          this.adminInfo.timer = null;
520
+          this.adminInfo.second = 60;
521
+        }
522
+      }, 1000);
523
+    },
524
+    // 保存新建
525
+    saveAddInfo() {
526
+      this.$refs.addForm.validate((valid) => {
527
+        if (valid) {
528
+          if (
529
+            this.adminInfo.adminid &&
530
+            (this.adminInfo.loginpwd || this.adminInfo.loginpwd1)
531
+          ) {
532
+            const reg = /^(?=.*[a-z])(?=.*[A-Z])(?=.*\d)[a-zA-Z\d]{8,32}$/;
533
+            if (!reg.test(this.adminInfo.loginpwd)) {
534
+              this.$Message.error(
535
+                "密码格式不正确!"
536
+              );
537
+              return;
538
+            }
539
+            if (this.adminInfo.loginpwd != this.adminInfo.loginpwd1) {
540
+              this.$Message.error("两次输入密码不一致!");
541
+              return;
542
+            }
543
+          }
544
+          let filter = /^[1][3,4,5,6,7,8,9][0-9]{9}$/;
545
+          if (this.adminInfo.phone && !filter.test(this.adminInfo.phone)) {
546
+            this.$Message.error("手机号码格式不正确");
547
+            return;
548
+          }
549
+          if (this.adminInfo.phone && !this.adminInfo.msgcode) {
550
+            this.$Message.error("请输入短信验证码");
551
+            return;
552
+          }
553
+          if (this.adminInfo.timer) {
554
+            clearInterval(this.adminInfo.timer);
555
+            this.adminInfo.timer = null;
556
+          }
557
+          this.adminInfo.show = false;
558
+          let api = this.adminInfo.adminid ? admin_edit : admin_add;
559
+          let form = {
560
+            aname: this.adminInfo.aname,
561
+            loginname: this.adminInfo.loginname,
562
+            loginpwd: this.adminInfo.loginpwd,
563
+            phone: this.adminInfo.phone,
564
+            msgcode: this.adminInfo.msgcode,
565
+            enabled: this.adminInfo.enabled,
566
+            regionid: this.adminInfo.regionid
567
+          };
568
+          //编辑
569
+          if (this.adminInfo.adminid) {
570
+            form.adminid = this.adminInfo.adminid;
571
+            form.rversion = this.adminInfo.rversion;
572
+          }
573
+          api(form).then((data) => {
574
+            if (data.code === 0) {
575
+              this.searchList();
576
+              this.$Message.success(data.msg);
577
+            } else {
578
+              this.$Message.error(data.msg);
579
+            }
580
+          });
581
+        }
582
+      });
583
+    },
584
+    // 查看
585
+    toView(row) {
586
+      this.viewInfo = {
587
+        show: true,
588
+        enabled: row.enabled,
589
+        aname: row.aname,
590
+        loginname: row.loginname,
591
+        phone: row.phone,
592
+        regionName: row.regionName
593
+      };
594
+    },
595
+    // 编辑
596
+    toEdit(row) {
597
+      admin_detail({adminid:row.adminid}).then(res=>{
598
+        if(res.code === 0){
599
+          this.adminInfo = {
600
+            show: true,
601
+            timer: null,
602
+            second: 60,
603
+            adminid: res.obj.adminid,
604
+            aname: res.obj.aname,
605
+            loginname: res.obj.loginname,
606
+            loginpwd: "",
607
+            loginpwd1: "",
608
+            phone: res.obj.phone,
609
+            msgcode: "",
610
+            enabled: res.obj.enabled,
611
+            regionid: res.obj.regionid,
612
+            rversion: row.rversion
613
+          };
614
+          console.log( this.adminInfo)
615
+        }else {
616
+          this.$Message.error(res.msg)
617
+        }
618
+      })
619
+
620
+    },
621
+    // 删除
622
+    toDel(row) {
623
+      this.$Modal.confirm({
624
+        title: "提示",
625
+        content: "您确定删除选中数据吗?",
626
+        onOk: () => {
627
+          admin_delete({
628
+            adminid: row.adminid,
629
+            rversion: row.rversion
630
+          }).then((data) => {
631
+            if (data.code === 0) {
632
+              this.searchList();
633
+              this.$Message.success(data.msg);
634
+            } else {
635
+              this.$Message.error(data.msg);
636
+            }
637
+          });
638
+        },
639
+        onCancel: () => {}
640
+      });
641
+    },
642
+    enabledChange(row) {
643
+      let api = row.enabled === 1 ? admin_enable : admin_disabled;
644
+      api({
645
+        adminid: row.adminid,
646
+        rversion: row.rversion
647
+      }).then((data) => {
648
+        this.getList();
649
+        if (data.code === 0) {
650
+          this.$Message.success(data.msg);
651
+        } else {
652
+          this.$Message.error(data.msg);
653
+        }
654
+      });
655
+    }
656
+  }
11 657
 };
12 658
 </script>
13 659
 
14
-<style lang="less" scoped></style>
660
+<style lang="less" scoped>
661
+.search_header {
662
+  display: flex;
663
+  justify-content: space-between;
664
+  align-items: center;
665
+  margin: 16px 16px;
666
+  .search_left {
667
+    display: flex;
668
+    justify-content: flex-start;
669
+    align-items: center;
670
+  }
671
+}
672
+.code_btn {
673
+  display: inline-block;
674
+  margin-left: 10px;
675
+  width: 92px;
676
+  font-size: 14px;
677
+  text-align: center;
678
+  color: #339dff;
679
+  line-height: 30px;
680
+  border: 1px solid #339dff;
681
+  border-radius: 6px;
682
+  background-color: #fff;
683
+  cursor: pointer;
684
+  &.disabled {
685
+    color: #c5c8ce;
686
+    background-color: #f7f7f7;
687
+    border-color: #dcdee2;
688
+    cursor: not-allowed;
689
+  }
690
+}
691
+.view_title {
692
+  display: flex;
693
+  justify-content: center;
694
+  align-items: center;
695
+  margin-bottom: 16px;
696
+  font-size: 18px;
697
+  font-weight: bold;
698
+  text-align: center;
699
+  .enabled_1 {
700
+    margin-left: 10px;
701
+    padding: 0 10px;
702
+    line-height: 20px;
703
+    color: #52c41a;
704
+    font-weight: normal;
705
+    font-size: 12px;
706
+    border-radius: 4px;
707
+    background-color: #eefae9;
708
+  }
709
+  .enabled_2 {
710
+    margin-left: 10px;
711
+    padding: 0 10px;
712
+    line-height: 20px;
713
+    color: #f0153f;
714
+    font-weight: normal;
715
+    font-size: 12px;
716
+    border-radius: 4px;
717
+    background-color: #fee8ec;
718
+  }
719
+}
720
+</style>

+ 23
- 68
src/views/regionSection/regionManage/regionManage.vue Wyświetl plik

@@ -113,19 +113,6 @@
113 113
             }}
114 114
           </div>
115 115
         </FormItem>
116
-        <FormItem label="地址" prop="address" style="width: 100%">
117
-          <Input
118
-            v-model="regionInfo.admin.address"
119
-            placeholder="请输入地址"
120
-          ></Input>
121
-        </FormItem>
122
-        <FormItem label="描述信息" prop="comm" style="width: 100%">
123
-          <Input
124
-            type="textarea"
125
-            v-model="regionInfo.admin.comm"
126
-            placeholder="请输入描述信息"
127
-          ></Input>
128
-        </FormItem>
129 116
       </Form>
130 117
       <div
131 118
         slot="footer"
@@ -165,19 +152,6 @@
165 152
             placeholder="请输入区域名称"
166 153
           ></Input>
167 154
         </FormItem>
168
-        <FormItem label="地址" prop="address" style="width: 100%">
169
-          <Input
170
-            v-model="modifyRegion.address"
171
-            placeholder="请输入地址"
172
-          ></Input>
173
-        </FormItem>
174
-        <FormItem label="描述信息" prop="comm" style="width: 100%">
175
-          <Input
176
-            type="textarea"
177
-            v-model="modifyRegion.comm"
178
-            placeholder="请输入描述信息"
179
-          ></Input>
180
-        </FormItem>
181 155
       </Form>
182 156
       <div slot="footer">
183 157
         <Button @click="modifyRegion.show = false">取消</Button>
@@ -192,12 +166,6 @@
192 166
       title="查看"
193 167
     >
194 168
       <div class="view_title">{{ viewInfo.regionName }}</div>
195
-      <Form :label-width="80">
196
-        <FormItem label="地址" style="margin-bottom: 0">{{
197
-          viewInfo.address
198
-        }}</FormItem>
199
-        <FormItem label="描述信息">{{ viewInfo.comm }}</FormItem>
200
-      </Form>
201 169
       <Table
202 170
         style="border: 1px solid #e8eaec; border-bottom: none"
203 171
         :columns="viewInfo.columns"
@@ -216,7 +184,9 @@ import {
216 184
   region_list_admin,
217 185
   region_delete,
218 186
   region_add,
219
-  region_edit, region_list_qy, region_detail
187
+  region_edit,
188
+  region_list_qy,
189
+  region_detail
220 190
 } from "@/api/region";
221 191
 import { login_msg_code } from "@/api/login";
222 192
 export default {
@@ -225,9 +195,7 @@ export default {
225 195
     // 密码验证
226 196
     const pwdCheck = (rule, value, callback) => {
227 197
       if (!reg.test(this.regionInfo.admin.loginpwd)) {
228
-        return callback(
229
-          new Error("密码不合法!")
230
-        );
198
+        new Error("密码格式不正确!");
231 199
       } else {
232 200
         callback();
233 201
       }
@@ -235,9 +203,7 @@ export default {
235 203
     // 重复密码验证
236 204
     const pwdAgainCheck = async (rule, value, callback) => {
237 205
       if (!reg.test(this.regionInfo.admin.loginpwd1)) {
238
-        return callback(
239
-            new Error("密码不合法!")
240
-        );
206
+        new Error("密码格式不正确!");
241 207
       } else if (
242 208
         this.regionInfo.admin.loginpwd != this.regionInfo.admin.loginpwd1
243 209
       ) {
@@ -267,9 +233,7 @@ export default {
267 233
           loginpwd: "",
268 234
           loginpwd1: "",
269 235
           phone: "",
270
-          msgcode: "",
271
-          address: "",
272
-          comm: ""
236
+          msgcode: ""
273 237
         }
274 238
       },
275 239
       // 编辑
@@ -277,16 +241,12 @@ export default {
277 241
         show: false,
278 242
         regionid: null,
279 243
         regionName: "",
280
-        address: "",
281
-        comm: "",
282 244
         rversion: null
283 245
       },
284 246
       // 查看
285 247
       viewInfo: {
286 248
         show: false,
287 249
         regionName: "",
288
-        address: "",
289
-        comm: "",
290 250
         list: [],
291 251
         columns: [
292 252
           {
@@ -405,7 +365,6 @@ export default {
405 365
     this.userInfo = JSON.parse(
406 366
       localStorage.getItem("xh_control_userInfo")
407 367
     ).content;
408
-    console.log(this.userInfo)
409 368
     this.searchList();
410 369
   },
411 370
   methods: {
@@ -496,9 +455,7 @@ export default {
496 455
           loginpwd: generateRandomString(8),
497 456
           loginpwd1: "",
498 457
           phone: "",
499
-          msgcode: "",
500
-          address: "",
501
-          comm: ""
458
+          msgcode: ""
502 459
         }
503 460
       };
504 461
     },
@@ -531,9 +488,7 @@ export default {
531 488
               loginname: this.regionInfo.admin.loginname,
532 489
               loginpwd: this.regionInfo.admin.loginpwd,
533 490
               phone: this.regionInfo.admin.phone,
534
-              msgcode: this.regionInfo.admin.msgcode,
535
-              address: this.regionInfo.admin.address,
536
-              comm: this.regionInfo.admin.comm
491
+              msgcode: this.regionInfo.admin.msgcode
537 492
             }
538 493
           }).then((data) => {
539 494
             if (data.code === 0) {
@@ -550,14 +505,12 @@ export default {
550 505
     saveModifyInfo() {
551 506
       this.$refs.modifyForm.validate((valid) => {
552 507
         if (valid) {
553
-          this.regionInfo.show = false;
554 508
           region_edit({
555 509
             regionName: this.modifyRegion.regionName,
556
-            address: this.modifyRegion.address,
557
-            comm: this.modifyRegion.comm,
558 510
             regionid: this.modifyRegion.regionid,
559 511
             rversion: this.modifyRegion.rversion
560 512
           }).then((data) => {
513
+            this.modifyRegion.show = false;
561 514
             if (data.code === 0) {
562 515
               this.searchList();
563 516
               this.$Message.success(data.msg);
@@ -575,16 +528,14 @@ export default {
575 528
         query: {}
576 529
       });
577 530
     },
578
-    // 查看
531
+    // 查看管理员列表
579 532
     toView(row) {
580
-      region_detail({
533
+      region_list_admin({
581 534
         regionid: row.regionid
582 535
       }).then((data) => {
583 536
         if (data.code === 0) {
584 537
           this.viewInfo.show = true;
585 538
           this.viewInfo.regionName = row.regionName;
586
-          this.viewInfo.address = row.address;
587
-          this.viewInfo.comm = row.comm;
588 539
           this.viewInfo.list = data.obj;
589 540
         } else {
590 541
           this.$Message.error(data.msg);
@@ -593,14 +544,18 @@ export default {
593 544
     },
594 545
     // 编辑
595 546
     toEdit(row) {
596
-      this.modifyRegion = {
597
-        show: true,
598
-        regionid: row.regionid,
599
-        regionName: row.regionName,
600
-        address: row.address,
601
-        comm: row.comm,
602
-        rversion: row.rversion
603
-      };
547
+      region_detail({ regionid: row.regionid }).then((res) => {
548
+        if (res.code === 0) {
549
+          this.modifyRegion = {
550
+            show: true,
551
+            regionid: row.regionid,
552
+            regionName: row.regionName,
553
+            rversion: row.rversion
554
+          };
555
+        } else {
556
+          this.$Message.error(res.msg);
557
+        }
558
+      });
604 559
     },
605 560
     // 删除
606 561
     toDel(row) {

+ 726
- 4
src/views/regionSection/regionManage/schoolManage.vue Wyświetl plik

@@ -1,14 +1,736 @@
1 1
 <template>
2
-  <div class="main_root">学校管理</div>
2
+  <div class="main_root">
3
+    <div class="search_header">
4
+      <div class="search_left">
5
+        <Select
6
+          :transfer="true"
7
+          v-model="searchForm.regionid"
8
+          @on-change="searchList()"
9
+          style="margin-right: 10px; width: 150px"
10
+        >
11
+          <Option :value="0">所有区域</Option>
12
+          <Option
13
+            v-for="item in searchForm.dropList"
14
+            :value="item.regionid"
15
+            :key="item.regionid"
16
+            >{{ item.regionName }}</Option
17
+          >
18
+        </Select>
19
+        <Select
20
+          :transfer="true"
21
+          v-model="searchForm.areaCode"
22
+          @on-change="searchList()"
23
+          style="margin-right: 10px; width: 150px"
24
+        >
25
+          <Option :value="0">所有状态</Option>
26
+          <Option :value="1">启用</Option>
27
+          <Option :value="2">禁用</Option>
28
+        </Select>
29
+        <Input
30
+          v-model="searchForm.schoolName"
31
+          placeholder="请输入学校名称"
32
+          search
33
+          @on-search="searchList()"
34
+          style="width: 150px"
35
+        />
36
+      </div>
37
+      <Button type="primary" class="primary_btn" @click="toAdd()">新建</Button>
38
+    </div>
39
+    <div class="table_wrap">
40
+      <Table :columns="columns" :data="searchForm.list">
41
+        <template slot-scope="{ row }" slot="enabled">
42
+          <i-switch
43
+            size="large"
44
+            v-model="row.enabled"
45
+            :true-value="1"
46
+            :false-value="2"
47
+            @on-change="enabledChange(row)"
48
+          >
49
+            <span slot="open">启用</span>
50
+            <span slot="close">禁用</span>
51
+          </i-switch>
52
+        </template>
53
+        <template slot-scope="{ row }" slot="actionSlot">
54
+          <div class="action_list">
55
+            <div @click="toSchool(row)">进入</div>
56
+            <div @click="toEdit(row)">编辑</div>
57
+            <div class="action_del" @click="toDel(row)">删除</div>
58
+          </div>
59
+        </template>
60
+      </Table>
61
+    </div>
62
+    <div class="page_wrap">
63
+      <Page
64
+        :transfer="true"
65
+        :total="searchForm.total"
66
+        :current="searchForm.page"
67
+        :page-size="searchForm.size"
68
+        :page-size-opts="[10, 20, 40, 60]"
69
+        @on-change="pageChange"
70
+        @on-page-size-change="pageSizeChange"
71
+        show-total
72
+        show-sizer
73
+      ></Page>
74
+    </div>
75
+    <!-- 新建/编辑 -->
76
+    <Modal
77
+      class="modal1"
78
+      :mask-closable="false"
79
+      v-model="adminInfo.show"
80
+      :title="adminInfo.schoolid ? '编辑' : '新建'"
81
+    >
82
+      <Form
83
+        v-if="adminInfo.show"
84
+        ref="addForm"
85
+        :model="adminInfo"
86
+        :rules="rules"
87
+        :label-width="110"
88
+        inline
89
+      >
90
+        <FormItem label="学校名称" prop="schoolName" style="width: 100%">
91
+          <Input
92
+            v-model="adminInfo.schoolName"
93
+            placeholder="请输入学校名称"
94
+          ></Input>
95
+        </FormItem>
96
+        <FormItem label="学校简称" style="width: 100%">
97
+          <Input
98
+            v-model="adminInfo.schoolAbbr"
99
+            placeholder="请输入学校简称"
100
+          ></Input>
101
+        </FormItem>
102
+        <FormItem label="省市区" style="width: 100%"> </FormItem>
103
+        <FormItem label="地址" style="width: 100%">
104
+          <Input v-model="adminInfo.address" placeholder="请输入地址"></Input>
105
+        </FormItem>
106
+        <FormItem label="所属区域" prop="regionid" style="width: 100%">
107
+          <Select
108
+            :transfer="true"
109
+            v-model="adminInfo.regionid"
110
+            style="width: calc(50% - 65px)"
111
+          >
112
+            <Option
113
+              v-for="item in searchForm.dropList"
114
+              :value="item.regionid"
115
+              :key="item.regionid"
116
+              >{{ item.regionName }}</Option
117
+            >
118
+          </Select>
119
+          <div v-if="!adminInfo.schoolid">
120
+            <Checkbox v-model="adminInfo.createAdmin">创建管理员</Checkbox>
121
+          </div>
122
+        </FormItem>
123
+        <div v-if="adminInfo.createAdmin">
124
+          <FormItem
125
+            label="管理员名称"
126
+            prop="admin.aname"
127
+            style="width: calc(50% - 10px)"
128
+          >
129
+            <Input
130
+              v-model="adminInfo.admin.aname"
131
+              placeholder="请输入管理员名称"
132
+            ></Input>
133
+          </FormItem>
134
+          <FormItem
135
+            label="登录账号"
136
+            prop="admin.loginname"
137
+            style="width: calc(50% - 10px)"
138
+          >
139
+            <Input
140
+              v-model="adminInfo.admin.loginname"
141
+              placeholder="请输入登录账号"
142
+            ></Input>
143
+          </FormItem>
144
+          <FormItem
145
+            label="密码"
146
+            prop="admin.loginpwd"
147
+            style="width: calc(50% - 10px)"
148
+          >
149
+            <Input
150
+              v-model="adminInfo.admin.loginpwd"
151
+              placeholder="请输入密码"
152
+            ></Input>
153
+          </FormItem>
154
+          <FormItem
155
+            label="确认密码"
156
+            prop="admin.loginpwd1"
157
+            style="width: calc(50% - 10px)"
158
+          >
159
+            <Input
160
+              v-model="adminInfo.admin.loginpwd1"
161
+              placeholder="请输入确认密码"
162
+            ></Input>
163
+          </FormItem>
164
+          <FormItem
165
+            label="手机号码"
166
+            prop="admin.phone"
167
+            style="width: calc(50% - 10px)"
168
+          >
169
+            <Input
170
+              v-model="adminInfo.admin.phone"
171
+              placeholder="请输入手机号码"
172
+            ></Input>
173
+          </FormItem>
174
+          <FormItem label="短信验证码" style="width: calc(50% - 10px)">
175
+            <Input
176
+              style="width: calc(100% - 102px)"
177
+              v-model="adminInfo.admin.msgcode"
178
+              placeholder="请输入短信验证码"
179
+            ></Input>
180
+            <div
181
+              :class="['code_btn', adminInfo.second === 60 ? '' : 'disabled']"
182
+              @click="getMsgCode()"
183
+            >
184
+              {{
185
+                adminInfo.second === 60 ? "获取验证码" : `${adminInfo.second}s`
186
+              }}
187
+            </div>
188
+          </FormItem>
189
+        </div>
190
+      </Form>
191
+      <div
192
+        slot="footer"
193
+        style="
194
+          display: flex;
195
+          justify-content: space-between;
196
+          align-items: center;
197
+        "
198
+      >
199
+        <div style="color: #b50000">
200
+          注:密码必须包含大小写字母和数字的组合,长度在8-32之间。
201
+        </div>
202
+        <div>
203
+          <Button @click="adminInfo.show = false">取消</Button>
204
+          <Button @click="saveAddInfo()" type="primary">保存</Button>
205
+        </div>
206
+      </div>
207
+    </Modal>
208
+    <!-- 查看 -->
209
+    <Modal
210
+      class="modal1"
211
+      :mask-closable="false"
212
+      v-model="viewInfo.show"
213
+      title="查看"
214
+    >
215
+      <div class="view_title">
216
+        <div>{{ viewInfo.aname }}</div>
217
+        <div v-if="viewInfo.enabled === 1" class="enabled_1">启用</div>
218
+        <div v-if="viewInfo.enabled === 2" class="enabled_2">禁用</div>
219
+      </div>
220
+      <Form :label-width="80" inline>
221
+        <FormItem
222
+          label="登录账号"
223
+          style="margin-bottom: 0; width: calc(50% - 10px)"
224
+          >{{ viewInfo.loginname }}</FormItem
225
+        >
226
+        <FormItem
227
+          label="手机号码"
228
+          style="margin-bottom: 0; width: calc(50% - 10px)"
229
+          >{{ viewInfo.phone }}</FormItem
230
+        >
231
+        <FormItem label="所属区域" style="margin-bottom: 0; width: 100%">{{
232
+          viewInfo.regionName
233
+        }}</FormItem>
234
+      </Form>
235
+      <div slot="footer" style="text-align: center">
236
+        <Button @click="viewInfo.show = false">关闭</Button>
237
+      </div>
238
+    </Modal>
239
+  </div>
3 240
 </template>
4 241
 
5 242
 <script>
243
+import {
244
+  admin_list_pt,
245
+  admin_add,
246
+  admin_edit,
247
+  admin_delete,
248
+  admin_enable,
249
+  admin_disabled,
250
+  admin_list_qy
251
+} from "@/api/admin";
252
+import { region_list_sel_pt } from "@/api/region";
253
+import { login_msg_code } from "@/api/login";
254
+import { generateRandomString } from "@/utils";
255
+import {
256
+  school_add,
257
+  school_delete,
258
+  school_detail,
259
+  school_disabled,
260
+  school_edit,
261
+  school_enable,
262
+  school_list
263
+} from "@/api/school";
6 264
 export default {
7 265
   data() {
8
-    return {};
266
+    const reg = /^(?=.*[a-z])(?=.*[A-Z])(?=.*\d)[a-zA-Z\d]{8,32}$/;
267
+    // 密码验证
268
+    const pwdCheck = (rule, value, callback) => {
269
+      if (!reg.test(this.adminInfo.admin.loginpwd)) {
270
+        return callback(new Error("密码格式不正确!"));
271
+      } else {
272
+        callback();
273
+      }
274
+    };
275
+    // 重复密码验证
276
+    const pwdAgainCheck = async (rule, value, callback) => {
277
+      if (!reg.test(this.adminInfo.admin.loginpwd1)) {
278
+        return callback(new Error("密码格式不正确!"));
279
+      } else if (
280
+        this.adminInfo.admin.loginpwd != this.adminInfo.admin.loginpwd1
281
+      ) {
282
+        return callback(new Error("两次输入密码不一致!"));
283
+      } else {
284
+        callback();
285
+      }
286
+    };
287
+    return {
288
+      searchForm: {
289
+        dropList: [],
290
+        areaCode: "",
291
+        // 0所有区域
292
+        regionid: 0,
293
+        // 是否启用0所有 1启用 2禁用
294
+        schoolName: "",
295
+        page: 1,
296
+        size: 10,
297
+        list: [],
298
+        total: 0
299
+      },
300
+      // 新建/编辑
301
+      adminInfo: {
302
+        show: false,
303
+        timer: null,
304
+        second: 60,
305
+        schoolid: null,
306
+        schoolName: "",
307
+        areaCode: "",
308
+        areaName: "",
309
+        address: "",
310
+        schoolAbbr: "",
311
+        regionid: null,
312
+        createAdmin: false,
313
+        admin: {
314
+          aname: "",
315
+          loginname: "",
316
+          loginpwd: "",
317
+          phone: "",
318
+          msgcode: ""
319
+        }
320
+      },
321
+      rules: {
322
+        schoolName: [
323
+          {
324
+            required: true,
325
+            message: "请输入学校名称",
326
+            trigger: "blur"
327
+          }
328
+        ],
329
+        "admin.aname": [
330
+          {
331
+            required: true,
332
+            message: "请输入管理员名称",
333
+            trigger: "blur"
334
+          }
335
+        ],
336
+        "admin.loginname": [
337
+          {
338
+            required: true,
339
+            message: "请输入请输入登录账号",
340
+            trigger: "blur"
341
+          }
342
+        ],
343
+        "admin.loginpwd": [
344
+          {
345
+            required: true,
346
+            validator: pwdCheck,
347
+            trigger: "blur"
348
+          }
349
+        ],
350
+        "admin.loginpwd1": [
351
+          {
352
+            required: true,
353
+            validator: pwdAgainCheck,
354
+            trigger: "blur"
355
+          }
356
+        ]
357
+      },
358
+      // 查看
359
+      viewInfo: {
360
+        show: false,
361
+        enabled: "",
362
+        aname: "",
363
+        loginname: "",
364
+        phone: "",
365
+        regionName: ""
366
+      },
367
+      columns: [
368
+        {
369
+          title: "序号",
370
+          align: "center",
371
+          width: 70,
372
+          render: (h, params) => {
373
+            return h(
374
+              "span",
375
+              params.index +
376
+                (this.searchForm.page - 1) * this.searchForm.size +
377
+                1
378
+            );
379
+          }
380
+        },
381
+        {
382
+          title: "学校名称",
383
+          key: "schoolName",
384
+          align: "center"
385
+        },
386
+        {
387
+          title: "状态",
388
+          slot: "enabled",
389
+          align: "center",
390
+          width: 80
391
+        },
392
+        {
393
+          title: "设备数",
394
+          key: "devicenum",
395
+          width: 80,
396
+          align: "center"
397
+        },
398
+        {
399
+          title: "省市区",
400
+          key: "regionName",
401
+          align: "center"
402
+        },
403
+        {
404
+          title: "所属区域",
405
+          key: "regionName",
406
+          width: 150,
407
+          align: "center"
408
+        },
409
+        {
410
+          title: "操作人",
411
+          key: "updatename",
412
+          width: 150,
413
+          align: "center"
414
+        },
415
+        {
416
+          title: "操作时间",
417
+          key: "updatetime",
418
+          width: 190,
419
+          align: "center"
420
+        },
421
+        {
422
+          title: "操作",
423
+          slot: "actionSlot",
424
+          width: 180,
425
+          align: "center"
426
+        }
427
+      ],
428
+      userInfo: {}
429
+    };
9 430
   },
10
-  methods: {}
431
+  created() {
432
+    this.userInfo = JSON.parse(
433
+      localStorage.getItem("xh_control_userInfo")
434
+    ).content;
435
+    this.getSearchRegionList();
436
+    this.searchList();
437
+  },
438
+  mounted() {},
439
+  methods: {
440
+    // 获取搜索区域列表
441
+    getSearchRegionList() {
442
+      region_list_sel_pt({}).then((data) => {
443
+        if (data.code === 0) {
444
+          this.searchForm.dropList = data.obj;
445
+        } else {
446
+          this.$Message.error(data.msg);
447
+        }
448
+      });
449
+    },
450
+    // 搜索
451
+    searchList() {
452
+      this.searchForm.page = 1;
453
+      this.getList();
454
+    },
455
+    // 页码改变
456
+    pageChange(page) {
457
+      this.searchForm.page = page;
458
+      this.getList();
459
+    },
460
+    // 每页显示数量改变
461
+    pageSizeChange(size) {
462
+      this.searchForm.size = size;
463
+      this.searchForm.page = 1;
464
+      this.getList();
465
+    },
466
+    // 获取列表
467
+    getList() {
468
+      school_list({
469
+        page: this.searchForm.page,
470
+        size: this.searchForm.size,
471
+        areaCode: this.searchForm.areaCode,
472
+        schoolName: this.searchForm.schoolName,
473
+        regionid: this.searchForm.regionid
474
+      }).then((data) => {
475
+        if (data.code === 0) {
476
+          this.searchForm.list = data.obj.data;
477
+          this.searchForm.total = data.obj.total;
478
+        } else {
479
+          this.$Message.error(data.msg);
480
+        }
481
+      });
482
+    },
483
+    // 新建
484
+    toAdd() {
485
+      this.adminInfo = {
486
+        show: true,
487
+        timer: null,
488
+        second: 60,
489
+        schoolid: null,
490
+        schoolName: "",
491
+        areaCode: "",
492
+        areaName: "",
493
+        address: "",
494
+        schoolAbbr: "",
495
+        regionid: this.userInfo.regionid,
496
+        createAdmin: false,
497
+        admin: {
498
+          aname: "",
499
+          loginname: "",
500
+          loginpwd: generateRandomString(8),
501
+          loginpwd1: "",
502
+          phone: "",
503
+          msgcode: ""
504
+        }
505
+      };
506
+    },
507
+    // 获取短信验证码
508
+    getMsgCode() {
509
+      if (this.adminInfo.second < 60) {
510
+        return;
511
+      }
512
+      // 手机号验证
513
+      if (!this.adminInfo.admin.phone) {
514
+        this.$Message.error("手机号码不能为空");
515
+        return;
516
+      }
517
+      let filter = /^[1][3,4,5,6,7,8,9][0-9]{9}$/;
518
+      if (!filter.test(this.adminInfo.admin.phone)) {
519
+        this.$Message.error("手机号码格式不正确");
520
+        return;
521
+      }
522
+      this.setRegionSecond();
523
+      login_msg_code({
524
+        phone: this.adminInfo.admin.phone
525
+      }).then((data) => {
526
+        if (data.code === 0) {
527
+          this.$Message.success(data.msg);
528
+        } else {
529
+          this.$Message.error(data.msg);
530
+        }
531
+      });
532
+    },
533
+    setRegionSecond() {
534
+      this.adminInfo.second = 59;
535
+      this.adminInfo.timer = setInterval(() => {
536
+        this.adminInfo.second--;
537
+        if (this.adminInfo.second <= 0) {
538
+          clearInterval(this.adminInfo.timer);
539
+          this.adminInfo.timer = null;
540
+          this.adminInfo.second = 60;
541
+        }
542
+      }, 1000);
543
+    },
544
+    // 保存新建
545
+    saveAddInfo() {
546
+      this.$refs.addForm.validate((valid) => {
547
+        if (valid) {
548
+          //添加学校管理员
549
+          if (this.adminInfo.createAdmin) {
550
+            if (
551
+              this.adminInfo.admin.loginpwd != this.adminInfo.admin.loginpwd1
552
+            ) {
553
+              this.$Message.error("两次输入密码不一致!");
554
+              return;
555
+            }
556
+            let filter = /^[1][3,4,5,6,7,8,9][0-9]{9}$/;
557
+            if (
558
+              this.adminInfo.admin.phone &&
559
+              !filter.test(this.adminInfo.admin.phone)
560
+            ) {
561
+              this.$Message.error("手机号码格式不正确");
562
+              return;
563
+            }
564
+            if (this.adminInfo.admin.phone && !this.adminInfo.admin.msgcode) {
565
+              this.$Message.error("请输入短信验证码");
566
+              return;
567
+            }
568
+            if (this.adminInfo.timer) {
569
+              clearInterval(this.adminInfo.timer);
570
+              this.adminInfo.timer = null;
571
+            }
572
+          }
573
+          this.adminInfo.show = false;
574
+          let api = this.adminInfo.schoolid ? school_edit : school_add;
575
+          let form = {
576
+            schoolName: this.adminInfo.schoolName,
577
+            regionid: this.adminInfo.regionid,
578
+            areaCode: this.adminInfo.areaCode,
579
+            areaName: this.adminInfo.areaName,
580
+            address: this.adminInfo.address,
581
+            schoolAbbr: this.adminInfo.schoolAbbr,
582
+            admin: {}
583
+          };
584
+          //编辑
585
+          if (this.adminInfo.schoolid) {
586
+            form.schoolid = this.adminInfo.schoolid;
587
+            form.rversion = this.adminInfo.rversion;
588
+          }
589
+          console.log(this.adminInfo);
590
+          //添加管理员
591
+          if (this.adminInfo.createAdmin) {
592
+            form.admin = {
593
+              aname: this.adminInfo.admin.aname,
594
+              loginname: this.adminInfo.admin.loginname,
595
+              loginpwd: this.adminInfo.admin.loginpwd,
596
+              phone: this.adminInfo.admin.phone,
597
+              msgcode: this.adminInfo.admin.msgcode
598
+            };
599
+          }
600
+          api(form).then((data) => {
601
+            if (data.code === 0) {
602
+              this.searchList();
603
+              this.$Message.success(data.msg);
604
+            } else {
605
+              this.$Message.error(data.msg);
606
+            }
607
+          });
608
+        }
609
+      });
610
+    },
611
+    // 进入学校
612
+    toSchool(row) {},
613
+    // 编辑
614
+    toEdit(row) {
615
+      school_detail({ schoolid: row.schoolid }).then((res) => {
616
+        if (res.code === 0) {
617
+          this.adminInfo = {
618
+            show: true,
619
+            timer: null,
620
+            second: 0,
621
+            schoolid: res.obj.schoolid,
622
+            schoolName: res.obj.schoolName,
623
+            areaCode: res.obj.areaCode,
624
+            areaName: res.obj.areaName,
625
+            address: res.obj.address,
626
+            schoolAbbr: res.obj.schoolAbbr,
627
+            regionid: res.obj.regionid,
628
+            rversion: res.obj.rversion,
629
+            createAdmin: false,
630
+            admin: {}
631
+          };
632
+        } else {
633
+          this.$Message.error(res.msg);
634
+        }
635
+      });
636
+    },
637
+    // 删除
638
+    toDel(row) {
639
+      this.$Modal.confirm({
640
+        title: "提示",
641
+        content: "您确定删除选中数据吗?",
642
+        onOk: () => {
643
+          school_delete({
644
+            schoolid: row.schoolid,
645
+            rversion: row.rversion
646
+          }).then((data) => {
647
+            if (data.code === 0) {
648
+              this.searchList();
649
+              this.$Message.success(data.msg);
650
+            } else {
651
+              this.$Message.error(data.msg);
652
+            }
653
+          });
654
+        },
655
+        onCancel: () => {}
656
+      });
657
+    },
658
+    enabledChange(row) {
659
+      let api = row.enabled === 1 ? school_enable : school_disabled;
660
+      api({
661
+        schoolid: row.schoolid,
662
+        rversion: row.rversion
663
+      }).then((data) => {
664
+        this.getList();
665
+        if (data.code === 0) {
666
+          this.$Message.success(data.msg);
667
+        } else {
668
+          this.$Message.error(data.msg);
669
+        }
670
+      });
671
+    }
672
+  }
11 673
 };
12 674
 </script>
13 675
 
14
-<style lang="less" scoped></style>
676
+<style lang="less" scoped>
677
+.search_header {
678
+  display: flex;
679
+  justify-content: space-between;
680
+  align-items: center;
681
+  margin: 16px 16px;
682
+  .search_left {
683
+    display: flex;
684
+    justify-content: flex-start;
685
+    align-items: center;
686
+  }
687
+}
688
+.code_btn {
689
+  display: inline-block;
690
+  margin-left: 10px;
691
+  width: 92px;
692
+  font-size: 14px;
693
+  text-align: center;
694
+  color: #339dff;
695
+  line-height: 30px;
696
+  border: 1px solid #339dff;
697
+  border-radius: 6px;
698
+  background-color: #fff;
699
+  cursor: pointer;
700
+  &.disabled {
701
+    color: #c5c8ce;
702
+    background-color: #f7f7f7;
703
+    border-color: #dcdee2;
704
+    cursor: not-allowed;
705
+  }
706
+}
707
+.view_title {
708
+  display: flex;
709
+  justify-content: center;
710
+  align-items: center;
711
+  margin-bottom: 16px;
712
+  font-size: 18px;
713
+  font-weight: bold;
714
+  text-align: center;
715
+  .enabled_1 {
716
+    margin-left: 10px;
717
+    padding: 0 10px;
718
+    line-height: 20px;
719
+    color: #52c41a;
720
+    font-weight: normal;
721
+    font-size: 12px;
722
+    border-radius: 4px;
723
+    background-color: #eefae9;
724
+  }
725
+  .enabled_2 {
726
+    margin-left: 10px;
727
+    padding: 0 10px;
728
+    line-height: 20px;
729
+    color: #f0153f;
730
+    font-weight: normal;
731
+    font-size: 12px;
732
+    border-radius: 4px;
733
+    background-color: #fee8ec;
734
+  }
735
+}
736
+</style>

Ładowanie…
Anuluj
Zapisz