<div class="content-heading justify-content-between">
  <div>框架配置 - 字典管理</div>
  <div>
    <a href="#" frameRole   (click)="showDictDetail()"><em class="fa-lg fas icon-plus "></em></a>
    <a class="ml-3" frameRole res="1032" href="#" title="刷新字典缓存" (click)="frameDict.optr('frame/dict/reload.htm',{RequestLoading: true}, '确定重新加载框架字典吗？该操作将会消耗较多系统资源，请勿在系统繁忙时间进行此操作！','框架字典已重新加载，重新登录可生效！')"><em
        class="fa-lg fas icon-refresh "></em></a>
    <a class="ml-3" frameRole res="1032" href="#" title="刷新考生端字典缓存" (click)="freshSesEnrolCache();"><em
      class="fa-lg fas icon-refresh "></em></a>
  </div>
</div>
<div class="row " [hidden]="mode !== 'page'">

  <div [class]="!show?'col-lg-12':'col-lg-7'">
    <table class="table table-striped table-hover table-bordered">
      <thead>
        <tr>
          <th>#</th>
          <th><a (click)="frameDictType.sort('a.dict_name')">字典名{{dictDetail}}</a></th>
          <th>描述信息</th>
          <th>允许修改</th>
          <th>框架字典</th>
          <th>配置数量</th>
          <th style="width:80px;"></th>
        </tr>
      </thead>
      <tbody>
        <tr *ngFor="let dict of frameDictType.getRecords(); let i = index">
          <td>{{i + 1}}</td>
          <td>{{dict.dict_name}}</td>
          <td>{{dict.dict_desc}}</td>
          <td [innerHTML]="dict.modify_flag | frameStatus"></td>
          <td [innerHTML]="dict.frame_flag | frameStatus"></td>
          <td>{{dict.dict_total}}</td>
          <td>
            <a href="#" (click)="listFrameDict(dict)"><em class="fa-lg fas fa-list "></em></a>
            <a  class="ml-2" href="#" (click)="deleteDictType(dict.dict_name)">
              <em class="fa-lg fas fa-trash text-danger"></em></a>
          </td>
        </tr>
      </tbody>
    </table>
    <frame-pager [url]="'frame/dict/type/page.htm'" #frameDictType></frame-pager>
  </div>

  <div class="col-lg-5" [hidden]="!show">
    <div class="col-lg-12">
      <form [formGroup]="typeForm" class="form-validate form-horizontal" novalidate>
      <div class="card card-default">
        <div class="card-header">
          <h3 class="card-title">新增字典类型</h3>
        </div>
          <div class="card-body">
            <div class="form-group row">
              <label class="col-lg-4 col-form-label text-lg-right">字典名</label>
              <div class="col-lg-8">
                <input class="form-control" type="text" formControlName="dict_name" [formControl]="typeForm.controls['dict_name']"  [(ngModel)]="dictTypes.dict_name" />
                <span class="text-danger" *ngIf="typeForm.controls['dict_name'].hasError('required') && (typeForm.controls['dict_name'].dirty || typeForm.controls['dict_name'].touched)">字典名不允许为空</span>
              </div>
            </div>
            <div class="form-group row">
              <label class="col-lg-4 col-form-label text-lg-right">允许修改</label>
              <div class="col-lg-8">
                <select class="custom-select" formControlName="modify_flag" [formControl]="typeForm.controls['modify_flag']"
                  [(ngModel)]="dictTypes.modify_flag"  frameDict [dictName]="'FrameStatus'"  [(dictValue)]="dictTypes.modify_flag">
                </select>
                <span class="text-danger" *ngIf="typeForm.controls['modify_flag'].hasError('required') && (typeForm.controls['modify_flag'].dirty || typeForm.controls['modify_flag'].touched)">请选择允许修改标志</span>
              </div>
            </div>
            <div class="form-group row">
              <label class="col-lg-4 col-form-label text-lg-right">框架字典</label>
              <div class="col-lg-8">
                <select class="custom-select" formControlName="frame_flag" [formControl]="typeForm.controls['frame_flag']"
                  [(ngModel)]="dictTypes.frame_flag" frameDict [dictName]="'FrameStatus'" [(dictValue)]="dictTypes.frame_flag">
                </select>
                <span class="text-danger" *ngIf="typeForm.controls['frame_flag'].hasError('required') && (typeForm.controls['frame_flag'].dirty || typeForm.controls['frame_flag'].touched)">请选择框架字典标志</span>
              </div>
            </div>
            <div class="form-group row">
              <label class="col-lg-4 col-form-label text-lg-right">描述信息</label>
              <div class="col-lg-8">
                <textarea class="form-control" formControlName="dict_desc" [formControl]="typeForm.controls['dict_desc']"  [(ngModel)]="dictTypes.dict_desc"
                  rows="5"></textarea>
              </div>
            </div>
            <div class="card-footer text-center">
              <button class="btn btn-info" (click)="submitTypeForm(typeForm.value)">保存</button>&nbsp;&nbsp;&nbsp;
              <button class="btn btn-default" (click)="show = false">取消</button>
            </div>
          </div>
        </div>
      </form>
      </div>
      
    </div>
</div>


<div class="row" [hidden]="mode !== 'list'">
  <div [class]="detail===undefined?'col-lg-12':'col-lg-7'">
    <div class="card card-default">
      <div class="card-header">
        <div class="float-left">
          <h3 class="card-title">{{dictType.dict_name}}（{{dictType.dict_desc}}）</h3>
        </div>
        <div class="float-right">

          <a href="#" (click)="mode = 'page';frameDictType.reload(); "><em class="fa-lg fas icon-arrow-up "></em></a>&nbsp;&nbsp;&nbsp;&nbsp;
          <a href="#" (click)="showDetail({},'add')"><em class="fa-lg fas icon-plus "></em></a></div>
      </div>
      <div class="card-body">
        <div class="ml-0 table-responsive bg-white">
          <table class="table table-striped table-hover table-bordered">
            <thead>
              <tr>
                <th>#</th>
                <th>字典中文值</th>
                <th>字典唯一值</th>
                <th>配置顺序</th>
                <th style="width:80px;"></th>
              </tr>
            </thead>
            <tbody>
              <tr *ngFor="let dict of frameDict.getRecords(); let i = index">
                <td>{{i + 1}}</td>
                <td>{{dict.dict_text}}</td>
                <td>{{dict.dict_value}}</td>
                <td>{{dict.dict_order}}</td>
                <td>
                  <a href="#" (click)="showDetail(dict,'edit')"><em class="fa-lg fas fa-edit "></em></a>
                  <a *ngIf="dictType.modify_flag === 'Active'" class="ml-2" href="#" (click)="frameDict.optr('frame/dict/delete.htm',{dict_name:dict.dict_name,key:dict.dict_value},'确定要删除该字典项目吗？此操作不可恢复！','字典项已成功删除！')"><em
                      class="fa-lg fas fa-trash text-danger"></em></a>
                </td>
              </tr>
            </tbody>
          </table>
          <frame-pager [url]="'frame/dict/page.htm'" [pageParams]="{'dict_name':dict.dict_name}" [autoLoad]="false"
            [hidePager]="true" [pageLimit]="9999" #frameDict></frame-pager>
        </div>
      </div>
    </div>
  </div>

  <div class="col-lg-5" [hidden]="detail === undefined ">
    <div class="col-lg-12">
      <form [formGroup]="valForm" class="form-validate form-horizontal" novalidate="">
        <div class="card card-default">
          <div class="card-header">
            <h3 class="card-title">{{dictType.dict_name}}（{{dictType.dict_desc}}）</h3>
          </div>
          <div class="card-body">

            <div class="form-group row">
              <label class="col-lg-4 col-form-label text-lg-right">字典中文值</label>
              <div class="col-lg-8">
                <input class="form-control" type="text" #elDictText formControlName="dict_text" [formControl]="valForm.controls['dict_text']"
                  [(ngModel)]="dict.dict_text" />
                <span class="text-danger" *ngIf="valForm.controls['dict_text'].hasError('required') && (valForm.controls['dict_text'].dirty || valForm.controls['dict_text'].touched)">字典中文值不允许为空</span>
              </div>
            </div>
            <div class="form-group row">
              <label class="col-lg-4 col-form-label text-lg-right">字典唯一值</label>
              <div class="col-lg-8">
                <input class="form-control" type="text" [readonly]="detail === 'edit' " formControlName="dict_value"
                  [formControl]="valForm.controls['dict_value']" [(ngModel)]="dict.dict_value" />
                <span class="text-danger" *ngIf="valForm.controls['dict_value'].hasError('required') && (valForm.controls['dict_value'].dirty || valForm.controls['dict_value'].touched)">字典唯一值不允许为空</span>
              </div>
            </div>
            <div class="form-group row">
              <label class="col-lg-4 col-form-label text-lg-right">排序顺序</label>
              <div class="col-lg-8">
                <input class="form-control" type="number" max="100" maxlength="2" formControlName="dict_order"
                  [formControl]="valForm.controls['dict_order']" [(ngModel)]="dict.dict_order" />
                <span class="text-danger" *ngIf="valForm.controls['dict_order'].hasError('required') && (valForm.controls['dict_order'].dirty || valForm.controls['dict_order'].touched)">排序顺序不允许为空</span>
                <span class="text-danger" *ngIf="valForm.controls['dict_order'].hasError('number') && (valForm.controls['dict_order'].dirty || valForm.controls['dict_order'].touched)">请输入正确的顺序（数字）</span>
              </div>
            </div>
          </div>
          <div class="card-footer text-center">
            <button class="btn btn-info" (click)="submitForm(valForm.value)">{{detail + '字典项'}}</button>&nbsp;&nbsp;&nbsp;
            <button class="btn btn-default" (click)="detail = undefined">取消操作</button>
          </div>
        </div>
      </form>
    </div>
  </div>

</div>