xufenglei
2018-04-10 fb73a14c658ce113721542c415402321a985d25b
注册码 管理
2 files added
4 files modified
119 ■■■■■ changed files
src/app/routes/systems/organization/organization-list/organization-list.component.html 2 ●●●●● patch | view | raw | blame | history
src/app/routes/systems/organization/organization-list/organization-list.component.ts 4 ●●●● patch | view | raw | blame | history
src/app/routes/systems/registration/registration.component.html 27 ●●●●● patch | view | raw | blame | history
src/app/routes/systems/registration/registration.component.ts 72 ●●●●● patch | view | raw | blame | history
src/app/routes/systems/systems.module.ts 7 ●●●● patch | view | raw | blame | history
src/assets/app-data.json 7 ●●●● patch | view | raw | blame | history
src/app/routes/systems/organization/organization-list/organization-list.component.html
@@ -58,6 +58,8 @@
                              <nz-popconfirm [nzTitle]="'确定要删除该'+grid.title+'吗?'" [nzOkText]="'Yes'" [nzCancelText]="'No'" (nzOnConfirm)="delete(row.id)" >
                                <a nz-popconfirm>删除</a>
                              </nz-popconfirm>
                            <span nz-table-divider></span>
                            <a [routerLink]="['/systems/registration']" (click)="registration(row)">注册码</a>
                     </td>
                </tr>
              </tbody>
src/app/routes/systems/organization/organization-list/organization-list.component.ts
@@ -227,4 +227,8 @@
      this.organizationService.title = '组织配置';
    });
  }
  registration(row){
      sessionStorage.setItem("organization", JSON.stringify(row));
  }
}
src/app/routes/systems/registration/registration.component.html
New file
@@ -0,0 +1,27 @@
<div class="content__title">
    <h1>注册码管理({{organization.name}})</h1>
</div>
<nz-card [nzBordered]="false">
    <div class="mb-md">
        <button nz-button [nzType]="'primary'" [nzSize]="'large'" (click)="isVisible=true">
            <i class="anticon anticon-plus"></i><span>新建</span>
        </button>
    </div>
    <simple-table #simpleTable [data]="dataUrl" [extraParams]="extraParams" [columns]="columns" [showTotal]="true" [ps]="10" [reqReName]="{pi: 'pageIndex',ps: 'pageSize'}" [resReName]="{list: 'data',total: 'total'}">
    </simple-table>
</nz-card>
<nz-modal [nzVisible]="isVisible" [nzTitle]="'新建注册码'" [nzContent]="modalContent" (nzOnCancel)="isVisible=false" (nzOnOk)="registrationOk()">
    <ng-template #modalContent>
        <form nz-form >
            <div nz-form-item nz-row>
                <div nz-form-label nz-col [nzSm]="6" [nzXs]="24">
                    <label nz-form-item-required>失效日期</label>
                </div>
                <div nz-col [nzSm]="14" [nzXs]="24">
                    <nz-datepicker style="width: 100%;" [(ngModel)]="_date" name='_date' [nzFormat]="'YYYY-MM-DD'" [nzDisabledDate]="_disabledDate" [nzAllowClear]="false"></nz-datepicker>
                </div>
            </div>
        </form>
    </ng-template>
</nz-modal>
src/app/routes/systems/registration/registration.component.ts
New file
@@ -0,0 +1,72 @@
import {environment} from "../../../../environments/environment";
import {Component, OnInit, ViewChild} from '@angular/core';
import {SimpleTableColumn} from "@delon/abc";
import {_HttpClient} from '@delon/theme';
import {Subject} from "rxjs";
import * as moment from 'moment';
import {NzMessageService} from "ng-zorro-antd";
@Component({
  selector: 'app-registration',
  templateUrl: './registration.component.html',
})
export class RegistrationComponent implements OnInit {
  constructor(
    public msgSrv: NzMessageService,
    private http: _HttpClient
  ) {}
  @ViewChild('simpleTable') simpleTable: {load: Function};
  dataUrl = environment.SERVER_BASH_URL + 'machineactivate/list';
  queryTextStream: Subject<string> = new Subject<string>();
  extraParams: any = {};
  organization: any = {};
  columns: SimpleTableColumn[] = [
    {title: '注册码', index: 'activationCode'},
    {
      title: '是否使用', index: 'isUsed', format: function(machineActivate) {
        return machineActivate.isUsed == 1 ? '是' : '否';
      }
    },
    {
      title: '生成时间', type: 'date', index: 'createTime', format: function(machineActivate) {
        return moment(machineActivate.createTime).format('YYYY-MM-DD HH:mm:ss');
      }
    },
    {
      title: '失效日期', type: 'date', index: 'expireDate', format: function(machineActivate) {
        return moment(machineActivate.expireDate).format('YYYY-MM-DD');
      }
    },
  ];
  isVisible: boolean = false;
  _date = new Date(Date.now() + 3600 * 24 * 1 * 1000);
  ngOnInit() {
    const organization = this.organization = JSON.parse(sessionStorage.getItem("organization"));
    this.extraParams.organizationId = organization.id;
    this.queryTextStream.debounceTime(900).distinctUntilChanged().subscribe(value => {
      this.load();
    });
  }
  load() {
    this.simpleTable.load();
  }
  _disabledDate(current: Date): boolean {
    return current && current.getTime() < Date.now();
  }
  registrationOk() {
    this.http.get(environment.SERVER_BASH_URL + '/machineactivate/machine', {organizationId: this.organization.id, expireDate: moment(this._date).format('YYYY-MM-DD')}).subscribe((res: any) => {
      if (res.code == 1 && res.data == 1) {
        this.isVisible = false;
        this.msgSrv.success('新建注册码成功!');
        this.load();
      }
    });
  }
}
src/app/routes/systems/systems.module.ts
@@ -15,6 +15,7 @@
import { AreacodeService } from '@business/services/http/areacode.service';
import { OrganizationConfigComponent } from './organization/organization-config/organization-config.component';
import { OrganizationListComponent } from './organization/organization-list/organization-list.component';
import { RegistrationComponent } from "./registration/registration.component";
import { SensorsService } from '@business/services/http/sensors.service';
import { BusinessModule } from '@business/business.module';
@@ -23,7 +24,8 @@
    path: '',
    children: [
      { path: 'account', component: AccountComponent },
      { path: 'organization', component: OrganizationComponent }
      { path: 'organization', component: OrganizationComponent },
      { path: 'registration', component: RegistrationComponent }
    ]
  }
];
@@ -45,7 +47,8 @@
    AccountEditComponent,
    OrganizationComponent,
    OrganizationConfigComponent,
    OrganizationListComponent
    OrganizationListComponent,
    RegistrationComponent
  ],
  providers: [ToolsService, SensorsService, OrganizationService, _HttpClient, FormBuilder, AreacodeService],
  entryComponents: COMPONENTS_NOROUNT
src/assets/app-data.json
@@ -79,7 +79,12 @@
                  {
                    "text": "组织管理",
                    "link": "/systems/organization"
                    }
                    },
                    {
                        "text": "注册码管理",
                        "link": "/systems/registration",
                        "hide": true
                    }
                ]
              }
            ]