seimin il y a 1 an
Parent
commit
812b76b493

+ 1 - 1
proxy.conf.json

@@ -1,6 +1,6 @@
1 1
 {
2 2
   "/service": {
3
-    "target": "http://192.168.3.108",
3
+    "target": "http://192.168.4.105",
4 4
     "logLevel": "debug",
5 5
     "changeOrigin": true,
6 6
     "pathRewrite": {

+ 5 - 0
src/app/views/main/main-routing.module.ts

@@ -358,6 +358,11 @@ const routes: Routes = [
358 358
         path: "quiltDepartmentBind",
359 359
         loadChildren: () => import("../quilt-department-bind/quilt-department-bind.module").then((m) => m.QuiltDepartmentBindModule),
360 360
       },
361
+      // 序号设置
362
+      {
363
+        path: "serialNumberSetting",
364
+        loadChildren: () => import("../serial-number-setting/serial-number-setting.module").then((m) => m.SerialNumberSettingModule),
365
+      },
361 366
       // 检查自动建单
362 367
       {
363 368
         path: "inspectAuto",

Fichier diff supprimé car celui-ci est trop grand
+ 8 - 1
src/app/views/main/main.component.html


+ 14 - 0
src/app/views/serial-number-setting-detail/serial-number-setting-detail-routing.module.ts

@@ -0,0 +1,14 @@
1
+import { NgModule } from '@angular/core';
2
+import { Routes, RouterModule } from '@angular/router';
3
+import { SerialNumberSettingDetailComponent } from './serial-number-setting-detail.component';
4
+
5
+
6
+const routes: Routes = [
7
+  { path: '', component: SerialNumberSettingDetailComponent }
8
+];
9
+
10
+@NgModule({
11
+  imports: [RouterModule.forChild(routes)],
12
+  exports: [RouterModule]
13
+})
14
+export class SerialNumberSettingDetailRoutingModule { }

+ 46 - 0
src/app/views/serial-number-setting-detail/serial-number-setting-detail.component.html

@@ -0,0 +1,46 @@
1
+<div class="detail display_flex justify-content_flex-center align-items_center" *ngIf="!maskFlag">
2
+  <div class="modalBody">
3
+    <div class="title">查看<i class="icon_transport transport-guanbi" (click)="hideModal()"></i></div>
4
+    <div class="content">
5
+      <div class="top display_flex justify-content_space-between align-items_center">
6
+        <span>{{info.title}}</span>
7
+        <span></span>
8
+      </div>
9
+      <div class="info">
10
+        <div nz-row>
11
+          <div class="left" nz-col nzSpan="12">
12
+            <div class="item display_flex  justify-content_space-between align-items_flex-start">
13
+              <span>开头字母</span>
14
+              <span>{{info.prefix}}</span>
15
+            </div>
16
+          </div>
17
+          <div class="right" nz-col nzSpan="12">
18
+            <div class="item display_flex  justify-content_space-between align-items_flex-start">
19
+              <span>生成方案</span>
20
+              <span>{{info.generateType ? info.generateType.name : ''}}</span>
21
+            </div>
22
+          </div>
23
+        </div>
24
+        <div nz-row>
25
+          <div class="left" nz-col nzSpan="12">
26
+            <div class="item display_flex  justify-content_space-between align-items_flex-start">
27
+              <span>日期方案</span>
28
+              <span>{{info.dateType ? info.dateType.name : ''}}</span>
29
+            </div>
30
+          </div>
31
+          <div class="right" nz-col nzSpan="12">
32
+            <div class="item display_flex  justify-content_space-between align-items_flex-start">
33
+              <span>自增长位数</span>
34
+              <span>{{info.length}}</span>
35
+            </div>
36
+          </div>
37
+        </div>
38
+      </div>
39
+    </div>
40
+    <div class="display_flex justify-content_flex-center">
41
+      <button class="know" nz-button nzType="primary" nzGhost (click)="hideModal()">知道了</button>
42
+    </div>
43
+  </div>
44
+</div>
45
+<!-- 遮罩 -->
46
+<app-mask *ngIf="maskFlag"></app-mask>

+ 151 - 0
src/app/views/serial-number-setting-detail/serial-number-setting-detail.component.less

@@ -0,0 +1,151 @@
1
+@import '../../../../src/theme.less';
2
+
3
+.detail {
4
+  position: fixed;
5
+  left: 0;
6
+  top: 0;
7
+  width: 100%;
8
+  height: 100%;
9
+  background: rgba(0, 0, 0, .4);
10
+  z-index: 99;
11
+
12
+  .modalBody {
13
+    width: 600px;
14
+    background: #fff;
15
+    border-radius: 5px;
16
+    padding: 10px 20px;
17
+    color: #333;
18
+
19
+    .title {
20
+      width: 100%;
21
+      text-align: center;
22
+      font-size: 18px;
23
+      position: relative;
24
+
25
+      i {
26
+        position: absolute;
27
+        right: 0;
28
+        top: 0;
29
+        font-size: 20px;
30
+        color: #666;
31
+        cursor: pointer;
32
+        padding: 0 5px;
33
+      }
34
+    }
35
+
36
+    .content {
37
+      width: 100%;
38
+      background: #f9fafb;
39
+      border: 1px solid #e5e9ed;
40
+      border-radius: 5px;
41
+      overflow: hidden;
42
+      margin-top: 12px;
43
+      padding: 9px 24px;
44
+
45
+      .top {
46
+        height: 35px;
47
+        border-bottom: 2px solid #eff2f4;
48
+
49
+        span:nth-child(1) {
50
+          font-size: 14px;
51
+          color: @primary-color;
52
+        }
53
+
54
+        span:nth-child(2) {
55
+          font-size: 12px;
56
+          color: #999;
57
+        }
58
+      }
59
+
60
+      .info {
61
+        margin-top: 15px;
62
+        margin-bottom: 4px;
63
+
64
+        .left {
65
+          border-right: 2px dashed #eff2f4;
66
+          padding-right: 23px;
67
+        }
68
+
69
+        .right {
70
+          padding-left: 23px;
71
+        }
72
+
73
+        .item {
74
+          // display: flex;
75
+          // justify-content: space-between;
76
+          // align-items: flex-start;
77
+          margin-bottom: 5px;
78
+
79
+          &>span:nth-child(1) {
80
+            color: #666;
81
+            min-width: 70px;
82
+          }
83
+
84
+          &>span:nth-child(2) {
85
+            color: #333;
86
+          }
87
+        }
88
+
89
+
90
+      }
91
+
92
+    }
93
+
94
+    .know {
95
+      margin-top: 10px;
96
+
97
+    }
98
+
99
+  }
100
+
101
+  // 新增
102
+  &.add {
103
+    .modalBody {
104
+      width: 480px;
105
+      height: auto;
106
+
107
+      .content {
108
+        width: 100%;
109
+        height: auto;
110
+        padding: 18px 14px 0 14px;
111
+
112
+        .addForm {
113
+          .ant-form-item {
114
+            margin-bottom: 14px;
115
+
116
+            .ant-form-item-label {
117
+              line-height: 0;
118
+            }
119
+          }
120
+        }
121
+
122
+        .editForm {
123
+          .ant-form-item {
124
+            margin-bottom: 14px;
125
+
126
+            .ant-form-item-label {
127
+              line-height: 0;
128
+            }
129
+          }
130
+        }
131
+
132
+      }
133
+
134
+      .btn {
135
+        button {
136
+          // width: 80px;
137
+
138
+          &:nth-child(1) {
139
+            margin-right: 20px;
140
+
141
+          }
142
+        }
143
+      }
144
+    }
145
+  }
146
+
147
+}
148
+
149
+.txtC {
150
+  text-align: center;
151
+}

+ 42 - 0
src/app/views/serial-number-setting-detail/serial-number-setting-detail.component.ts

@@ -0,0 +1,42 @@
1
+import { Component, OnInit } from "@angular/core";
2
+import { Router, ActivatedRoute } from "@angular/router";
3
+import { NzMessageService } from "ng-zorro-antd";
4
+
5
+import { MainService } from "../../services/main.service";
6
+
7
+@Component({
8
+  selector: "app-serial-number-setting-detail",
9
+  templateUrl: "./serial-number-setting-detail.component.html",
10
+  styleUrls: ["./serial-number-setting-detail.component.less"],
11
+})
12
+export class SerialNumberSettingDetailComponent implements OnInit {
13
+  constructor(
14
+    private message: NzMessageService,
15
+    private router: Router,
16
+    private mainService: MainService,
17
+    private routerInfo: ActivatedRoute
18
+  ) {}
19
+
20
+  id: number;
21
+  info: any = {};
22
+  ngOnInit() {
23
+    this.getDetail();
24
+  }
25
+  hideModal() {
26
+    history.go(-1);
27
+  }
28
+
29
+  // 获取详情
30
+  maskFlag: any = false;
31
+  getDetail() {
32
+    this.id = this.routerInfo.snapshot.params["id"];
33
+    this.maskFlag = this.message.loading("正在加载中..", {
34
+      nzDuration: 0,
35
+    }).messageId;
36
+    this.mainService.getFetchData("simple/data", "serialnumberConfig", this.id).subscribe((data) => {
37
+      this.message.remove(this.maskFlag);
38
+      this.maskFlag = false;
39
+      this.info = data.data;
40
+    });
41
+  }
42
+}

+ 19 - 0
src/app/views/serial-number-setting-detail/serial-number-setting-detail.module.ts

@@ -0,0 +1,19 @@
1
+import { NgModule } from '@angular/core';
2
+import { CommonModule } from '@angular/common';
3
+
4
+import { SerialNumberSettingDetailRoutingModule } from './serial-number-setting-detail-routing.module';
5
+import { SerialNumberSettingDetailComponent } from './serial-number-setting-detail.component';
6
+import { ShareModule } from 'src/app/share/share.module';
7
+
8
+
9
+@NgModule({
10
+  declarations: [
11
+    SerialNumberSettingDetailComponent
12
+  ],
13
+  imports: [
14
+    CommonModule,
15
+    SerialNumberSettingDetailRoutingModule,
16
+    ShareModule
17
+  ]
18
+})
19
+export class SerialNumberSettingDetailModule { }

+ 24 - 0
src/app/views/serial-number-setting/serial-number-setting-routing.module.ts

@@ -0,0 +1,24 @@
1
+import { NgModule } from '@angular/core';
2
+import { Routes, RouterModule } from '@angular/router';
3
+import { SerialNumberSettingComponent } from './serial-number-setting.component';
4
+
5
+
6
+const routes: Routes = [
7
+  {
8
+    path: '',
9
+    component: SerialNumberSettingComponent,
10
+    children: [
11
+      {
12
+        // 查看详情
13
+        path: 'serialNumberSettingDetail/:id',
14
+        loadChildren: () => import('../serial-number-setting-detail/serial-number-setting-detail.module').then(m => m.SerialNumberSettingDetailModule),
15
+      }
16
+    ]
17
+  }
18
+];
19
+
20
+@NgModule({
21
+  imports: [RouterModule.forChild(routes)],
22
+  exports: [RouterModule]
23
+})
24
+export class SerialNumberSettingRoutingModule { }

+ 116 - 0
src/app/views/serial-number-setting/serial-number-setting.component.html

@@ -0,0 +1,116 @@
1
+<div class="list-template">
2
+  <div class="list-template__content">
3
+    <div class="list-template__top" nz-row>
4
+      <div nz-col nzXl='18' class="list-template__searchBox"></div>
5
+      <div nz-col nzXl='6' class="list-template__btns">
6
+        <button nz-button *ngIf="coopBtns.add" class="btn ml8 default" (click)="showModal()">新增</button>
7
+      </div>
8
+    </div>
9
+    <div class="list-template__bottom">
10
+      <nz-table class="list-template__nzTable" [nzData]="listOfData" nzSize="middle" [nzShowPagination]="false"
11
+        [nzLoading]="loading1">
12
+        <thead>
13
+          <tr class="thead">
14
+            <th nzWidth="16%">序号名称</th>
15
+            <th nzWidth="16%">开头字母</th>
16
+            <th nzWidth="16%">生成方案</th>
17
+            <th nzWidth="16%">日期方案</th>
18
+            <th nzWidth="16%">自增长位数</th>
19
+            <th nzWidth="20%">操作</th>
20
+          </tr>
21
+        </thead>
22
+        <tbody>
23
+          <tr *ngFor="let data of listOfData;let index=index;">
24
+            <td>{{ data.title }}</td>
25
+            <td>{{ data.prefix }}</td>
26
+            <td>{{ data.generateType ? data.generateType.name : '' }}</td>
27
+            <td>{{ data.dateType ? data.dateType.name : '' }}</td>
28
+            <td>{{ data.length }}</td>
29
+            <td>
30
+              <div class="coop">
31
+                <span *ngIf="coopBtns.look" (click)="detail(data.id)">查看</span>
32
+                <span *ngIf="coopBtns.edit" (click)="edit(data)">修改</span>
33
+                <span *ngIf="coopBtns.del" (click)="del(data)">删除</span>
34
+              </div>
35
+            </td>
36
+          </tr>
37
+        </tbody>
38
+      </nz-table>
39
+      <div class="list-template__pagination">
40
+        <nz-pagination [(nzPageIndex)]="pageIndex" [(nzTotal)]="listLength" nzShowSizeChanger [(nzPageSize)]="pageSize"
41
+          (nzPageIndexChange)="getList()" (nzPageSizeChange)="getList()">
42
+        </nz-pagination>
43
+      </div>
44
+    </div>
45
+  </div>
46
+</div>
47
+<!-- 新增/编辑模态框 -->
48
+<div class="save add display_flex align-items_center justify-content_flex-center" *ngIf="modal">
49
+  <div class="modalBody">
50
+    <div class="title">{{add?"新增":"编辑"}}序号设置<i class="icon_transport transport-guanbi" (click)="hideModal()"></i>
51
+    </div>
52
+    <overlay-scrollbars #osComponentRef1 class="content">
53
+      <form nz-form [formGroup]="validateForm" class="addForm" (ngSubmit)="submitForm()">
54
+        <nz-form-item>
55
+          <nz-form-label [nzSm]="6" [nzXs]="24" nzRequired nzFor="title">序号名称</nz-form-label>
56
+          <nz-form-control nzErrorTip="请填写序号名称!">
57
+            <nz-input-group>
58
+              <input nz-input formControlName="title" placeholder="请填写序号名称" />
59
+            </nz-input-group>
60
+          </nz-form-control>
61
+        </nz-form-item>
62
+        <nz-form-item>
63
+          <nz-form-label [nzSm]="6" [nzXs]="24" nzRequired nzFor="prefix">开头字母</nz-form-label>
64
+          <nz-form-control nzErrorTip="请填写开头字母!">
65
+            <nz-input-group>
66
+              <input nz-input formControlName="prefix" placeholder="请填写开头字母" />
67
+            </nz-input-group>
68
+          </nz-form-control>
69
+        </nz-form-item>
70
+        <nz-form-item>
71
+          <nz-form-label [nzSm]="6" [nzXs]="24" nzRequired nzFor="length">自增长位数</nz-form-label>
72
+          <nz-form-control nzErrorTip="请填写自增长位数!">
73
+            <nz-input-group>
74
+              <nz-input-number nz-input formControlName="length" nzPlaceHolder="请填写自增长位数" [nzMin]="1" [nzStep]="1" [nzPrecision]="0"></nz-input-number>
75
+            </nz-input-group>
76
+          </nz-form-control>
77
+        </nz-form-item>
78
+        <nz-form-item>
79
+          <nz-form-label style="line-height:40px;" [nzSm]="5" [nzXs]="24" nzRequired nzFor="generateType">生成方案</nz-form-label>
80
+          <nz-form-control nzErrorTip="请选择生成方案!">
81
+            <nz-radio-group formControlName="generateType" (ngModelChange)="generateTypeChange()">
82
+              <label nz-radio [nzValue]="data.id" *ngFor="let data of generateTypes">{{data.name}}</label>
83
+            </nz-radio-group>
84
+          </nz-form-control>
85
+        </nz-form-item>
86
+        <nz-form-item *ngIf="isShowDateType">
87
+          <nz-form-label [nzSm]="6" [nzXs]="24" nzRequired nzFor="dateType">日期方案</nz-form-label>
88
+          <nz-form-control nzErrorTip="请选择日期方案!">
89
+            <nz-select [nzDropdownMatchSelectWidth]="false" nzShowSearch nzAllowClear
90
+              formControlName="dateType" nzPlaceHolder="请选择日期方案">
91
+              <nz-option [nzLabel]="data.name" [nzValue]="data.id" *ngFor="let data of dateTypes">
92
+              </nz-option>
93
+            </nz-select>
94
+          </nz-form-control>
95
+        </nz-form-item>
96
+      </form>
97
+    </overlay-scrollbars>
98
+    <div class="display_flex justify-content_flex-center">
99
+      <button nzType="primary" nz-button (click)="submitForm()" [nzLoading]="btnLoading">确认</button>
100
+      <button class="btn cancel" nz-button nzType="default" (click)="hideModal()">取消</button>
101
+    </div>
102
+  </div>
103
+</div>
104
+<!-- 删除模态框 -->
105
+<app-dialog-delete [delModal]="delModal" (hideDelModalEvent)="hideDelModal()" [btnLoading]="btnLoading"
106
+  (confirmDelEvent)="confirmDel()" content="您确认要删除吗?">
107
+</app-dialog-delete>
108
+<!-- 操作成功/失败提示框 -->
109
+<app-prompt-modal *ngIf="promptModalShow" [content]="promptContent" [success]="ifSuccess" [show]="promptModalShow"
110
+  [info]="promptInfo"></app-prompt-modal>
111
+
112
+<!-- 查看详情 -->
113
+<router-outlet (deactivate)="getList()"></router-outlet>
114
+
115
+<!-- 遮罩 -->
116
+<app-mask *ngIf="maskFlag"></app-mask>

+ 126 - 0
src/app/views/serial-number-setting/serial-number-setting.component.less

@@ -0,0 +1,126 @@
1
+@import "../../../../src/theme.less";
2
+.save {
3
+  position: fixed;
4
+  left: 0;
5
+  top: 0;
6
+  width: 100%;
7
+  height: 100%;
8
+  background: rgba(0, 0, 0, 0.4);
9
+  z-index: 99;
10
+
11
+  .modalBody {
12
+    width: 350px;
13
+    background: #fff;
14
+    border-radius: 5px;
15
+    padding: 10px 20px;
16
+    color: #333;
17
+
18
+    .title {
19
+      width: 100%;
20
+      text-align: center;
21
+      font-size: 18px;
22
+      position: relative;
23
+
24
+      i {
25
+        position: absolute;
26
+        right: 0;
27
+        top: 0;
28
+        font-size: 20px;
29
+        color: #666;
30
+        cursor: pointer;
31
+        padding: 0 5px;
32
+      }
33
+    }
34
+
35
+    .content {
36
+      width: 100%;
37
+      height: 117px;
38
+      background: #f9fafb;
39
+      border: 1px solid #e5e9ed;
40
+      border-radius: 5px;
41
+      overflow: hidden;
42
+      margin-top: 12px;
43
+
44
+      div {
45
+        text-align: center;
46
+        margin: 0;
47
+
48
+        &.icon {
49
+          margin-top: 17px;
50
+
51
+          i {
52
+            color: #34b349;
53
+            font-size: 30px !important;
54
+
55
+            &.transport-wenhao {
56
+              color: #f5a523;
57
+            }
58
+
59
+            &.transport-shibai {
60
+              color: #ff3a52;
61
+            }
62
+          }
63
+        }
64
+
65
+        &.defeat {
66
+          color: #333;
67
+          font-size: 18px;
68
+        }
69
+
70
+        &:nth-child(3) {
71
+          font-size: 14px;
72
+          color: #666;
73
+        }
74
+      }
75
+    }
76
+
77
+    button {
78
+      margin-top: 10px;
79
+
80
+      &.btn {
81
+        margin-left: 8px;
82
+      }
83
+    }
84
+  }
85
+
86
+  // 新增
87
+  &.add {
88
+    .modalBody {
89
+      width: 480px;
90
+      height: auto;
91
+
92
+      .content {
93
+        width: 100%;
94
+        height: auto;
95
+        padding: 19px 14px 0 14px;
96
+        max-height: 500px;
97
+        overflow-y: auto;
98
+
99
+        .addForm {
100
+          .ant-form-item {
101
+            margin-bottom: 8px;
102
+
103
+            .ant-form-item-label {
104
+              line-height: 14px;
105
+              text-align: left;
106
+            }
107
+          }
108
+        }
109
+
110
+        .editForm {
111
+          .ant-form-item {
112
+            margin-bottom: 14px;
113
+
114
+            .ant-form-item-label {
115
+              line-height: 0;
116
+            }
117
+          }
118
+        }
119
+      }
120
+
121
+      button:nth-child(1) {
122
+        margin-right: 20px;
123
+      }
124
+    }
125
+  }
126
+}

+ 242 - 0
src/app/views/serial-number-setting/serial-number-setting.component.ts

@@ -0,0 +1,242 @@
1
+import { Component, OnInit, ViewChild } from "@angular/core";
2
+import { ActivatedRoute, Router } from "@angular/router";
3
+import { FormBuilder, Validators, FormGroup } from "@angular/forms";
4
+
5
+import { MainService } from "../../services/main.service";
6
+import { OverlayScrollbarsComponent } from "overlayscrollbars-ngx";
7
+import { ToolService } from "../../services/tool.service";
8
+import { NzMessageService } from "ng-zorro-antd";
9
+
10
+@Component({
11
+  selector: "app-serial-number-setting",
12
+  templateUrl: "./serial-number-setting.component.html",
13
+  styleUrls: ["./serial-number-setting.component.less"],
14
+})
15
+export class SerialNumberSettingComponent implements OnInit {
16
+  @ViewChild("osComponentRef1", {
17
+    read: OverlayScrollbarsComponent,
18
+    static: false,
19
+  })
20
+  osComponentRef1: OverlayScrollbarsComponent;
21
+  constructor(
22
+    private message: NzMessageService,
23
+    private fb: FormBuilder,
24
+    private route: ActivatedRoute,
25
+    private router: Router,
26
+    private mainService: MainService,
27
+    private tool: ToolService
28
+  ) {}
29
+
30
+  listOfData: any[] = []; //表格数据
31
+
32
+  modal: boolean = false; //新增/编辑模态框
33
+  add: boolean; //true:新增;false:编辑
34
+  validateForm: FormGroup; //新增/编辑表单
35
+  coopId: number; //表格中执行操作的id
36
+  hosId: any; //院区(搜索)
37
+  dateTypes: Array<any> = []; //所有日期方案
38
+  pageIndex: number = 1; //页码
39
+  listLength: number = 10; //总条数
40
+  pageSize: number = 10; //每页条数
41
+
42
+  promptContent: string; //操作提示框提示信息
43
+  ifSuccess: boolean; //操作成功/失败
44
+  promptInfo: string; //操作结果提示信息
45
+  promptModalShow: boolean; //操作提示框是否展示
46
+
47
+  btnLoading: boolean = false; //提交按钮loading状态
48
+  isShowDateType = false; //是否显示日期方案
49
+
50
+  ngOnInit() {
51
+    this.coopBtns = this.tool.initCoopBtns(this.route);
52
+    this.initForm();
53
+    this.getUserTypes();
54
+    this.getGender();
55
+  }
56
+
57
+  // 初始化增删改按钮
58
+  coopBtns: any = {};
59
+  // 表格数据
60
+  loading1 = false;
61
+  getList() {
62
+    let data = {
63
+      idx: this.pageIndex - 1,
64
+      sum: this.pageSize,
65
+      serialnumberConfig: {
66
+        hosId: this.hosId,
67
+      },
68
+    };
69
+    this.loading1 = true;
70
+    this.mainService
71
+      .getFetchDataList("simple/data", "serialnumberConfig", data)
72
+      .subscribe((data) => {
73
+        this.loading1 = false;
74
+        this.listOfData = data.list;
75
+        this.listLength = data.totalNum;
76
+      });
77
+  }
78
+
79
+  // 获取所有日期类型
80
+  getUserTypes() {
81
+    this.mainService.getDictionary("list", "serialnumber_date_type").subscribe((data) => {
82
+      this.dateTypes = data;
83
+      this.getAllHospital();
84
+    });
85
+  }
86
+
87
+  // 获取相应的院区
88
+  getAllHospital() {
89
+    this.hosId = this.tool.getCurrentHospital().id;
90
+    this.getList();
91
+  }
92
+
93
+  // 获取生成方案
94
+  generateTypes: Array<any> = [];
95
+  getGender() {
96
+    var that = this;
97
+    that.mainService.getDictionary("list", "serialnumber_generate_type").subscribe((data) => {
98
+      that.generateTypes = data;
99
+    });
100
+  }
101
+
102
+  // 新增弹框
103
+  showModal() {
104
+    this.add = true;
105
+    this.initForm();
106
+    this.modal = true;
107
+  }
108
+  hideModal() {
109
+    this.modal = false;
110
+    this.initForm();
111
+  }
112
+
113
+  // 初始化新增form表单
114
+  initForm() {
115
+    this.validateForm = this.fb.group({
116
+      title: [null, [Validators.required]],
117
+      prefix: [null, [Validators.required]],
118
+      length: [1, [Validators.required]],
119
+      generateType: [null, [Validators.required]],
120
+      dateType: [null, [Validators.required]],
121
+    });
122
+  }
123
+  // 选择生成方案
124
+  generateTypeChange(dateType) {
125
+    if(dateType){
126
+      this.validateForm.controls.dateType.setValue(dateType.id);
127
+    }else{
128
+      this.validateForm.controls.dateType.setValue(null);
129
+    }
130
+    let value = this.generateTypes.find(v => v.id == this.validateForm.value.generateType).value;
131
+    this.isShowDateType = value == 2;
132
+    if(this.isShowDateType){
133
+      this.validateForm.get("dateType")!.setValidators(Validators.required);
134
+      this.validateForm.get("dateType")!.markAsDirty();
135
+    }else{
136
+      this.validateForm.get("dateType")!.clearValidators();
137
+      this.validateForm.get("dateType")!.markAsPristine();
138
+    }
139
+  }
140
+  // 表单提交
141
+  submitForm(): void {
142
+    var that = this;
143
+    for (const i in that.validateForm.controls) {
144
+      that.validateForm.controls[i].markAsDirty({ onlySelf: true });
145
+      that.validateForm.controls[i].updateValueAndValidity();
146
+    }
147
+    if (that.validateForm.invalid) return;
148
+    that.btnLoading = true;
149
+    let data:any = {
150
+      title: that.validateForm.value.title,
151
+      prefix: that.validateForm.value.prefix,
152
+      length: that.validateForm.value.length,
153
+      generateType: { id: that.validateForm.value.generateType },
154
+      dateType: that.validateForm.value.dateType ? { id: that.validateForm.value.dateType } : undefined,
155
+      hosId: that.hosId,
156
+    };
157
+    if (!that.add) {
158
+      data.id = that.coopId;
159
+    }
160
+    that.mainService
161
+      .simplePost("addData", "serialnumberConfig", data)
162
+      .subscribe((data) => {
163
+        that.btnLoading = false;
164
+        that.hideModal();
165
+        that.initForm();
166
+        if (data.status == 200) {
167
+          if(data.data && data.data.prefix){
168
+            that.showPromptModal(that.add ? "新增" : "编辑", true, "");
169
+          }else{
170
+            that.showPromptModal(that.add ? "新增" : "编辑", false, '开头字母不能重复!');
171
+          }
172
+        } else {
173
+          that.showPromptModal(that.add ? "新增" : "编辑", false, data.msg);
174
+        }
175
+      });
176
+  }
177
+
178
+  // 编辑
179
+  maskFlag: any = false;
180
+  edit(data) {
181
+    this.modal = true;
182
+    this.add = false;
183
+    this.coopId = data.id;
184
+    this.validateForm.controls.title.setValue(data.title);
185
+    this.validateForm.controls.prefix.setValue(data.prefix);
186
+    this.validateForm.controls.length.setValue(data.length);
187
+    this.validateForm.controls.generateType.setValue(data.generateType.id);
188
+    this.generateTypeChange(data.dateType);
189
+  }
190
+
191
+  // 删除
192
+  delModal: boolean = false; //删除模态框
193
+  del(data) {
194
+    this.coopId = data.id;
195
+    this.delModal = true;
196
+  }
197
+  // 确认删除
198
+  confirmDel() {
199
+    let that = this;
200
+    that.btnLoading = true;
201
+    that.mainService
202
+      .simplePost("rmvData", "serialnumberConfig", [that.coopId])
203
+      .subscribe((data) => {
204
+        that.btnLoading = false;
205
+        that.hideDelModal();
206
+        if (data["status"] == 200) {
207
+          if (
208
+            that.listOfData.length == 1 &&
209
+            that.pageIndex == Math.ceil(that.listLength / that.pageSize)
210
+          ) {
211
+            that.listLength--;
212
+            that.pageIndex = Math.ceil(that.listLength / that.pageSize);
213
+          }
214
+          that.showPromptModal("删除", true, "");
215
+        } else {
216
+          that.showPromptModal("删除", false, data["msg"]);
217
+        }
218
+      });
219
+  }
220
+  // 关闭删除模态框
221
+  hideDelModal() {
222
+    this.delModal = false;
223
+  }
224
+
225
+  // 展示信息提示框(con:提示信息,success:操作是否成功,promptInfo:操作结果提示信息)
226
+  showPromptModal(con, success, promptInfo?) {
227
+    this.promptModalShow = false;
228
+    this.promptContent = con;
229
+    this.ifSuccess = success;
230
+    this.promptInfo = promptInfo;
231
+    setTimeout(() => {
232
+      this.promptModalShow = true;
233
+    }, 100);
234
+    this.getList();
235
+  }
236
+
237
+  // 查看
238
+  detail(id) {
239
+    this.router.navigateByUrl("/main/serialNumberSetting/serialNumberSettingDetail/" + id);
240
+  }
241
+  isLoading = false;
242
+}

+ 19 - 0
src/app/views/serial-number-setting/serial-number-setting.module.ts

@@ -0,0 +1,19 @@
1
+import { NgModule } from '@angular/core';
2
+import { CommonModule } from '@angular/common';
3
+
4
+import { SerialNumberSettingRoutingModule } from './serial-number-setting-routing.module';
5
+import { SerialNumberSettingComponent } from './serial-number-setting.component';
6
+import { ShareModule } from 'src/app/share/share.module';
7
+
8
+
9
+@NgModule({
10
+  declarations: [
11
+    SerialNumberSettingComponent,
12
+  ],
13
+  imports: [
14
+    CommonModule,
15
+    SerialNumberSettingRoutingModule,
16
+    ShareModule
17
+  ]
18
+})
19
+export class SerialNumberSettingModule { }