Browse Source

【物料档案】 样式醒悟调整等(完结)

liangyan0105 3 years ago
parent
commit
21fd687041

+ 17 - 22
src/app/routes/basedata/material-file/material-file.component.html

@@ -66,7 +66,7 @@
                 <li nz-menu-item (click)="delMaterial()">
                   {{ 'table.delete' | translate }}
                 </li>
-                <li nz-menu-item (click)="addProduct()">{{ 'button.add' | translate }}{{ 'product' | translate }}</li>
+                <li nz-menu-item (click)="addProduct('')">{{ 'button.add' | translate }}{{ 'product' | translate }}</li>
                 <li nz-menu-item (click)="cancel()">{{ 'button.cancel' | translate }}</li>
               </ul>
             </ng-template>
@@ -112,11 +112,12 @@
           </div>
         </div>
       </form>
+
       <!-- 产品数据 表 -->
       <div nz-row nzGutter="24">
         <div nz-col nzMd="24" nzLg="24">
           <nz-table
-            nzBordered
+            nzSize="small"
             class="tableTdPadding"
             #basicTable
             [nzData]="proTable"
@@ -134,12 +135,11 @@
                 </th>
                 <!-- 名称 -->
                 <th nzAlign="center" nzLeft="8vw">{{ 'contract.name' | translate }}</th>
-                <!-- 排序 -->
-                <th nzAlign="center">{{ 'sort' | translate }}</th>
-                <!-- 状态 -->
-                <th nzAlign="center">{{ 'state' | translate }}</th>
+
                 <!-- 属性 -->
                 <th nzAlign="center">{{ 'property' | translate }}</th>
+                <!-- 状态 -->
+                <th nzAlign="center">{{ 'state' | translate }}</th>
                 <!-- 操作 -->
                 <th nzAlign="center" nzRight="0px">
                   {{ 'table.operation' | translate }}
@@ -151,34 +151,29 @@
               <tr *ngFor="let data of basicTable.data">
                 <td style="width: 8vw" nzAlign="center" nzLeft="0px">{{ data.code }}</td>
                 <td nzAlign="center" nzLeft="8vw">{{ data.name }}</td>
-                <td nzAlign="center">{{ data.sort }}</td>
-                <!-- 状态  0未启用    1启用-->
+
+                <!-- 属性  1采购   2销售 -->
                 <td nzAlign="center">
-                  <ng-container *ngIf="data.status == 0">
-                    {{ 'enabled.not' | translate }}
+                  <ng-container *ngIf="data.attribute == 1">
+                    <nz-tag [nzColor]="'#f50'">{{ 'procurement' | translate }}</nz-tag>
                   </ng-container>
-                  <ng-container *ngIf="data.status == 1">
-                    {{ 'enabled' | translate }}
+                  <ng-container *ngIf="data.attribute == 2">
+                    <nz-tag [nzColor]="'#108ee9'"> {{ 'sales' | translate }}</nz-tag>
                   </ng-container>
                 </td>
 
-                <!-- 属性  1采购   2销售 -->
+                <!-- 状态  0未启用    1启用-->
                 <td nzAlign="center">
-                  <ng-container *ngIf="data.attribute == 1">
-                    {{ 'procurement' | translate }}
+                  <ng-container *ngIf="data.status == 0">
+                    <nz-tag [nzColor]="'orange'">{{ 'enabled.not' | translate }}</nz-tag>
                   </ng-container>
-                  <ng-container *ngIf="data.attribute == 2">
-                    {{ 'sales' | translate }}
+                  <ng-container *ngIf="data.status == 1">
+                    <nz-tag [nzColor]="'green'">{{ 'enabled' | translate }}</nz-tag>
                   </ng-container>
                 </td>
 
                 <!-- 操作按钮 -->
                 <td nzAlign="center" nzRight="0px" style="width: 20%;">
-                  <!-- 详情 -->
-                  <!-- <a href="javascript:void(0);" (click)="detailsPro(data.id)">
-                    {{ 'table.view' | translate }}
-                  </a>
-                  <nz-divider nzType="vertical"></nz-divider> -->
                   <!-- 修改 跟新增同一个抽屉-->
                   <a href="javascript:void(0);" (click)="addProduct(data.id)">
                     {{ 'table.update' | translate }}

+ 6 - 3
src/app/routes/basedata/material-file/material-file.component.ts

@@ -83,7 +83,7 @@ export class BasedataMaterialFileComponent implements OnInit {
       // 根据页面绑定的查询条件进行查询
       this.baseMaterialFileProductService.list(this.baseMaterialFileProduct).then(res => {
         this.proTable = res.result.records;
-        console.log('产品列表', this.proTable);
+        console.log('产品列表(无模块)', this.proTable);
         resolve();
       });
     });
@@ -164,9 +164,11 @@ export class BasedataMaterialFileComponent implements OnInit {
         materialId: this.materialId, //物料分类id (给抽屉的回显树)
       },
     });
-    //回调 添加完关闭抽屉
+    //抽屉关闭 时回调
     drawerAddPro.afterClose.subscribe(clo => {
-      if (clo) {
+      //不成功时 清空 物料分类ID
+      this.materialId = '';
+      if (clo) { //成功
         //判断是否刷新树列表数据
         this.getMaterialTree();
         this.getProductList();
@@ -238,5 +240,6 @@ export class BasedataMaterialFileComponent implements OnInit {
   //右键取消
   cancel() {
     this.dropdown.close();
+    this.baseMaterialFileProduct = {}; //清空
   }
 }

+ 22 - 7
src/app/routes/basedata/material-file/product-add/product-add.component.html

@@ -26,7 +26,7 @@
       </nz-form-control>
     </nz-form-item>
 
-    <!-- 排序 状态 -->
+    <!-- 排序   -->
     <nz-form-item>
       <nz-form-label [nzSm]="3" [nzXs]="24" nzRequired>{{ 'depart.sort' | translate }}</nz-form-label>
       <nz-form-control [nzSm]="8" [nzXs]="12">
@@ -38,22 +38,37 @@
           placeholder="{{ 'placeholder' | translate }}"
         />
       </nz-form-control>
-      <nz-form-label nzRequired [nzSm]="3" [nzXs]="24">{{ 'state' | translate }}</nz-form-label>
+
+      <!--  状态0 未启用    1启用  -->
+      <nz-form-label nzRequired [nzSm]="3" [nzXs]="24">
+       {{'depart.Whether.to.enable' | translate}}
+      </nz-form-label>
+
       <nz-form-control [nzSm]="8" [nzXs]="12">
+        <nz-switch
+          [(ngModel)]="status"
+          name="status"
+          [ngModelOptions]="{ standalone: true }"
+          nzCheckedChildren="{{ 'store.yes' | translate }}"
+          nzUnCheckedChildren="{{ 'store.no' | translate }}"
+        >
+        </nz-switch>
+      </nz-form-control>
+      <!-- <nz-form-label nzRequired [nzSm]="3" [nzXs]="24">{{ 'state' | translate }}</nz-form-label> -->
+      <!-- <nz-form-control [nzSm]="8" [nzXs]="12">
         <nz-select
           nzShowSearch
           nzPlaceHolder="{{ 'select.please.choose' | translate }}"
           [nzDisabled]="false"
           [(ngModel)]="baseMaterialFileProduct.status"
           formControlName="status"
-        >
-          <!-- 第一条请选择 -->
-          <nz-option nzLabel="{{ 'select.please.choose' | translate }}" nzValue="" selected="selected"></nz-option>
-          <!-- 0 未启用    1启用 --->
+        > -->
+      <!-- 第一条请选择 -->
+      <!-- <nz-option nzLabel="{{ 'select.please.choose' | translate }}" nzValue="" selected="selected"></nz-option>
           <nz-option nzLabel="{{ 'enabled.not' | translate }}" nzValue="0"></nz-option>
           <nz-option nzLabel="{{ 'enabled' | translate }}" nzValue="1"></nz-option>
         </nz-select>
-      </nz-form-control>
+      </nz-form-control> -->
     </nz-form-item>
 
     <!-- 产品属性 分类树 -->

+ 21 - 9
src/app/routes/basedata/material-file/product-add/product-add.component.ts

@@ -39,6 +39,7 @@ export class BasedataMaterialFileProductAddComponent implements OnInit {
   id: string = ''; //接收抽屉产品 id
   clickProObj: {}; //点击的产品对象
   sort = 1; //默认
+  status = false; //未启用
   //金额格式化 (标准报价)
   formatterDollar = (value: number) => {
     if (value) {
@@ -67,7 +68,7 @@ export class BasedataMaterialFileProductAddComponent implements OnInit {
       code: [null, [Validators.required]],
       name: [null, [Validators.required]],
       sort: ['number', [Validators.required]], //排序
-      status: [null, [Validators.required]],
+      status: [], //不验证
       attribute: [null, [Validators.required]],
       baseMaterialFileClassificationId: [null, [Validators.required]], //物料分类id
     });
@@ -78,23 +79,28 @@ export class BasedataMaterialFileProductAddComponent implements OnInit {
 
     this.baseMaterialFileProduct.id = this.id;
     //不是修改
-    if (this.baseMaterialFileProduct.id == '') {
+    if (!this.id) {
     } else {
       //修改 查询对应id 产品 回显
       return new Promise(resolve => {
         this.baseMaterialFileProduct.pkOrg = sessionStorage.getItem('pkOrg');
         this.baseMaterialFileProductService.queryMainAndChildById(this.baseMaterialFileProduct.id).then(res => {
-          console.log('所有产品数据', res);
-          let clickProObj = res.result;
-          this.baseMaterialFileProduct = clickProObj;
+          this.baseMaterialFileProduct = res.result;
+          console.log('点击的产品数据', this.baseMaterialFileProduct);
+          if (this.baseMaterialFileProduct.status == '0') {
+            this.status = false; //未启用
+          } else {
+            this.status = true;
+          }
+
           this.baseMaterialFileProduct.status = this.baseMaterialFileProduct.status + '';
-          if (clickProObj.baseMaterialFileModularList) {
+          if (this.baseMaterialFileProduct.baseMaterialFileModularList) {
             // 以下这种写法,只在该方法中赋值,其他地方相互不影响
             // this.modData =JSON.parse(JSON.stringify(clickProObj.baseMaterialFileModularList))
-            this.modData = clickProObj.baseMaterialFileModularList;
+            this.modData = this.baseMaterialFileProduct.baseMaterialFileModularList;
             this.sort = this.modData.length + 1;
           }
-          console.log('点击的产品对象', this.baseMaterialFileProduct.baseMaterialFileModularList);
+          console.log('模块列表', this.baseMaterialFileProduct.baseMaterialFileModularList);
         });
         resolve();
       });
@@ -126,6 +132,11 @@ export class BasedataMaterialFileProductAddComponent implements OnInit {
 
   // 产品 保存(新增/修改)
   proSubForm() {
+    if (this.status) {
+      this.baseMaterialFileProduct.status = '0';
+    } else {
+      this.baseMaterialFileProduct.status = '1';
+    }
     //根据标题判断 新增 or 修改
     if (this.id == '') {
       console.log('空', this.baseMaterialFileProduct);
@@ -162,9 +173,10 @@ export class BasedataMaterialFileProductAddComponent implements OnInit {
       return new Promise(resolve => {
         this.baseMaterialFileProduct.pkOrg = sessionStorage.getItem('pkOrg'); //组织
         this.baseMaterialFileProduct.baseMaterialFileModularList = this.modData;
-        console.log('----->', this.baseMaterialFileProduct.baseMaterialFileModularList);
+        // console.log('点击项模块列表', this.baseMaterialFileProduct.baseMaterialFileModularList);
         this.baseMaterialFileProductService.updateMainAndChild(this.baseMaterialFileProduct).then(res => {
           if (res.success) {
+            // 修改返回数据赋值给 点击的产品对象
             this.clickProObj = res.result;
             this.notification.success(this.i18NService.fanyi('successful.revision'), '');
             this.getProductList();