Browse Source

[客商行业] 添加“排序”功能

liangyan0105 3 years ago
parent
commit
2a2c4ac63e

+ 30 - 8
src/app/routes/basedata/merchants-industry/add/add.component.html

@@ -1,27 +1,49 @@
 <form nz-form [formGroup]="validateForm" (ngSubmit)="submitForm()">
   <nz-form-item>
     <nz-form-label [nzSm]="6" [nzXs]="24" nzRequired nzFor="code">客商编码</nz-form-label>
-    <nz-form-control [nzSm]="14" [nzXs]="24" >
-      <input placeholder="自动生成" nz-input formControlName="code" id="code" [(ngModel)]="baseCustomerIndustry.code"/>
+    <nz-form-control [nzSm]="14" [nzXs]="24">
+      <input placeholder="自动生成" nz-input formControlName="code" id="code" [(ngModel)]="baseCustomerIndustry.code" />
       <!-- <nz-form-explain *ngIf="validateForm.get('code')?.dirty && validateForm.get('code')?.errors">
         请输入项目编码   BaseCustomerIndustry
       </nz-form-explain> -->
     </nz-form-control>
   </nz-form-item>
+
   <nz-form-item>
     <nz-form-label [nzSm]="6" [nzXs]="24" nzRequired nzFor="name">客商名称</nz-form-label>
-    <nz-form-control [nzSm]="14" [nzXs]="24" >
-      <input nz-input formControlName="name" id="name" [(ngModel)]="baseCustomerIndustry.name" maxlength=20/>
+    <nz-form-control [nzSm]="14" [nzXs]="24">
+      <input nz-input formControlName="name" id="name" [(ngModel)]="baseCustomerIndustry.name" maxlength="20" />
       <nz-form-explain *ngIf="validateForm.get('name')?.dirty && validateForm.get('name')?.errors">
         请输入客商名称
       </nz-form-explain>
     </nz-form-control>
   </nz-form-item>
+
+  <nz-form-item>
+    <nz-form-label nzRequired [nzSm]="6" [nzXs]="24">是否启用 </nz-form-label>
+    <nz-form-control [nzSm]="14" [nzXs]="24">
+      <nz-switch
+        [ngModelOptions]="{ standalone: true }"
+        [(ngModel)]="status"
+        name="status"
+        nzCheckedChildren="是"
+        nzUnCheckedChildren="否"
+      ></nz-switch>
+    </nz-form-control>
+  </nz-form-item>
+
   <nz-form-item>
-    <nz-form-label nzRequired [nzSm]="6" [nzXs]="24">是否启用
-    </nz-form-label>
+    <nz-form-label nzRequired [nzSm]="6" [nzXs]="24" nzRequired nzFor="sort">序号</nz-form-label>
     <nz-form-control [nzSm]="14" [nzXs]="24">
-      <nz-switch [ngModelOptions]="{standalone: true}" [(ngModel)]="status" name="status" nzCheckedChildren="是" nzUnCheckedChildren="否"></nz-switch>
+      <nz-input-number
+        [(ngModel)]="baseCustomerIndustry.sort"
+        [nzMin]="1"
+        [nzMax]="120"
+        [nzStep]="1"
+        [nzPlaceHolder]="'请输入该商客序号'"
+        formControlName="sort"
+        id="sort"
+      ></nz-input-number>
     </nz-form-control>
   </nz-form-item>
-</form>
+</form>

+ 19 - 1
src/app/routes/basedata/merchants-industry/add/add.component.ts

@@ -8,6 +8,7 @@ import { FormBuilder, Validators, FormGroup } from '@angular/forms';
 import { BaseCustomerIndustry } from 'app/entity/basedata/base-customer-industry';
 import { BaseCustomerIndustryService } from 'app/services/basedata/base-customer-industry.service';
 import { I18NService } from '@core';
+// import { NzInputNumberModule } from 'ng-zorro-antd/input-number';
 
 @Component({
   selector: 'app-basedata-merchants-industry-add',
@@ -28,6 +29,7 @@ export class BasedataMerchantsIndustryAddComponent implements OnInit {
       code: [{ value: '', disabled: true }, []], //客商编码
       name: [null, [Validators.required]], //客商名称
       status: [null], //是否启用
+      sort: ['number', [Validators.required]], //数字输入框 客商名称排序
     });
     //新增子集获取父节点id
     // if(this.parentId&&this.parentId!=="0"){
@@ -41,7 +43,7 @@ export class BasedataMerchantsIndustryAddComponent implements OnInit {
 
   // 确定 按钮(添加一级)
   submitForm(): any {
-    console.log('----');
+    // console.log('----');
     return new Promise(resolve => {
       for (const i in this.validateForm.controls) {
         this.validateForm.controls[i].markAsDirty();
@@ -78,4 +80,20 @@ export class BasedataMerchantsIndustryAddComponent implements OnInit {
   }
   //实例化函数
   baseCustomerIndustry: BaseCustomerIndustry = {};
+
+  onInput($event) {
+    // if (!$event) {
+    //   console.log($event);
+    //   return;
+    // }
+    // const target = $event.target;
+    // console.log(target);
+    // const reg = /^(\d)+$/;
+    // target.value = target.value.replace(reg, '');
+    // console.log(target.value);
+  }
+  // 数值改变时回调
+  changeMethod() {
+    console.log('?/?');
+  }
 }

+ 18 - 1
src/app/routes/basedata/merchants-industry/merchants-industry.component.html

@@ -99,6 +99,7 @@
               </nz-form-explain>
             </nz-form-control>
           </nz-form-item>
+
           <nz-form-item>
             <nz-form-label nzRequired [nzSm]="8" [nzXs]="24">是否启用 </nz-form-label>
             <nz-form-control [nzSm]="14" [nzXs]="24">
@@ -112,6 +113,23 @@
             </nz-form-control>
           </nz-form-item>
 
+          <nz-form-item>
+            <nz-form-label nzRequired [nzSm]="8" [nzXs]="24">当前序号</nz-form-label>
+            <nz-form-control [nzSm]="14" [nzXs]="24">
+              <input
+              formControlName="sort"
+              id="sort"
+              [(ngModel)]="baseCustomerIndustry.sort"
+              name="sort"
+              nz-input
+              placeholder="{{ 'placeholder' | translate }}当前序号"
+            />
+            <nz-form-explain *ngIf="validateForm.get('sort')?.dirty && validateForm.get('sort')?.errors">
+              请修改商客序号
+            </nz-form-explain>
+            </nz-form-control>
+          </nz-form-item>
+
           <nz-form-item>
             <nz-form-label [nzSm]="8" [nzXs]="24" [nzNoColon]="true"> </nz-form-label>
             <nz-form-control [nzSm]="14" [nzXs]="24">
@@ -121,7 +139,6 @@
               <button nz-button nzType="primary">保存</button>
             </nz-form-control>
           </nz-form-item>
-
         </form>
       </nz-card>
     </div>

+ 3 - 0
src/app/routes/basedata/merchants-industry/merchants-industry.component.ts

@@ -37,6 +37,7 @@ export class BasedataMerchantsIndustryComponent implements OnInit {
       code: [{ value: '', disabled: true }],
       name: [null, [Validators.required]],
       status: [null],
+      sort:[null, [Validators.required]],
     });
     this.getListIndustryTree();
   }
@@ -46,6 +47,7 @@ export class BasedataMerchantsIndustryComponent implements OnInit {
   searchValue = ''; //搜索框的值
   nodes: any = []; //tree集合
   status = true;
+  sort:''
 
   //  客商行业 字段规范
   baseCustomerIndustry: BaseCustomerIndustry = {};
@@ -95,6 +97,7 @@ export class BasedataMerchantsIndustryComponent implements OnInit {
       code: getdDepart.code,
       id: getdDepart.key,
       parentId: getdDepart.parentId,
+      sort: getdDepart.sort,
     };
   }