<div class="modal-header">
  <h4 class="modal-title pull-left">字典【{{ResponseEntity?.dict_name}}】详细信息</h4>
</div>
<div class="modal-body">
  <div class="row">
    <div class=" table-responsive bg-white"
         [ngClass]="{'col-xs-12 col-lg-12': !showDetail, 'col-xs-7 col-lg-7': showDetail}">
      <table class="table table-striped table-hover table-bordered">
        <thead>
        <tr>
          <th class="th-index">#</th>
          <th><span href="#" (click)="pager.sort('dict_value')">字典值</span></th>
          <th><span href="#" (click)="pager.sort('dict_text')">中文描述</span></th>
          <th><span href="#" (click)="pager.sort('dict_order')">排序</span></th>
          <th class="th-b-2" *ngIf="ResponseEntity.modify_flag === 'Active'"></th>
        </tr>
        </thead>
        <tbody>
        <tr *ngFor="let v of pager.getRecords(); let i = index">
          <td>{{i + 1}}</td>
          <td>{{v.dict_value}}</td>
          <td>{{v.dict_text}}</td>
          <td>{{v.dict_order}}</td>
          <td *ngIf="ResponseEntity.modify_flag === 'Active'">
            <span class="cursor-hand" (click)="currentDict = v; showDetail = true; dictMode = 'edit'">
              <em class="fa-lg fas fa-edit"></em>
            </span>
            <span class="cursor-hand ml-3 text-danger" (click)="pager.optrRecord('frame/dict/delete.htm', v, {successMsg:'字典成功删除！', confirmMsg: '确定要删除该字典吗？请慎重进行此操作！', successMsgType:'Swal'})">
              <em class="fa-lg fas fa-trash-alt "></em>
            </span>
          </td>
        </tr>
        </tbody>
      </table>
      <frame-pager url="frame/dict/page.htm" [pagerParams]="{dict_name: ResponseEntity?.dict_name}" #pager></frame-pager>
    </div>
    <div class="col-lg-5 col-xs-5" *ngIf="showDetail" [formGroup]="detailForm">
      <div class="card card-default">
        <div class="card-body">
          <div class="form-group row">
            <label class="col-lg-5 col-form-label text-lg-right">数据库值</label>
            <div class="col-lg-7 col-md-7">
              <input class="form-control" type="text" formControlName="dict_value" maxlength="32" [readonly]="dictMode === 'edit'" [(ngModel)]="currentDict.dict_value"/>
              <form-valid [form]="detailForm" fieldName="dict_value"></form-valid>
            </div>
          </div>
          <div class="form-group row">
            <label class="col-lg-5 col-form-label text-lg-right">中文描述</label>
            <div class="col-lg-7 col-md-7">
              <input class="form-control" type="text" formControlName="dict_text" maxlength="32" [(ngModel)]="currentDict.dict_text"/>
              <form-valid [form]="detailForm" fieldName="dict_text"></form-valid>
            </div>
          </div>
          <div class="form-group row">
            <label class="col-lg-5 col-form-label text-lg-right">字典项排序</label>
            <div class="col-lg-7 col-md-7">
              <input class="form-control" type="number" formControlName="dict_order" maxlength="3" [(ngModel)]="currentDict.dict_order"/>
              <form-valid [form]="detailForm" fieldName="dict_order"></form-valid>
            </div>
          </div>
        </div>

        <div class="card-footer text-center">
          <button class="btn btn-primary" type="button" (click)="saveDict()">保存字典项</button>
        </div>
      </div>
    </div>
  </div>

</div>
<div class="modal-footer">
  <button class="btn btn-primary" type="button" (click)="showDetail = true; dictMode = 'add'" *ngIf="ResponseEntity['modify_flag'] === 'Active' && showDetail === false">
    新增字典项
  </button>
  <button class="btn btn-secondary" type="button" (click)="closeWindow()">取消操作</button>
</div>
