Przeglądaj źródła

1、修改pop弹出事件,编辑关闭,新建清空

zhoux 1 rok temu
rodzic
commit
acafffa32f

+ 50 - 16
components/dkbase/dk-popup/dk-popup.js

@@ -19,9 +19,15 @@ Component({
       type: Boolean,
       observer: function (newVal) {
         // 说明
-        if (newVal && this.data.formSocail) {
+        if (newVal) {
+          if(this.data.formSocail){
+            this.setData({
+              form: { ...this.data.formSocail }
+            })
+          }
+        }else{
           this.setData({
-            form: { ...this.data.formSocail }
+            loading:false
           })
         }
       }
@@ -95,7 +101,7 @@ Component({
     popupTopObj: {
       type: Array
     },
-    popupTopObjUnit:{
+    popupTopObjUnit: {
       type: Array
     },
     // 是否开启校验,默认不开启
@@ -112,6 +118,11 @@ Component({
       type: Boolean,
       value: true
     },
+    // // 加载标识
+    // loading:{
+    //   type:Boolean,
+    //   value:false,
+    // },
     // 结果集
     value: {
       type: String,
@@ -131,6 +142,7 @@ Component({
    * 组件的初始数据
    */
   data: {
+    loading: false,
     // 记录初始值
     formSocail: null,
     showDrop: false,
@@ -178,10 +190,17 @@ Component({
      * @date : 2024/2/19 12:16
      */
     commit() {
+      // 说明加载中
+      if (this.data.loading) {
+        return;
+      }
       // 校验
       if (this.data.validFlag && !this.validData()) {
         return false;
       }
+      this.setData({
+        loading: true
+      })
       this.triggerEvent("commit", {
         form: this.data.form
       })
@@ -374,7 +393,7 @@ Component({
       this.triggerEvent("changeStep", {
         key: key,
         value: e.detail,
-        keyType:keyType
+        keyType: keyType
       })
     },
     /**
@@ -444,8 +463,6 @@ Component({
       this.setData({
         form: form
       })
-
-
     },
 
     setFlgGift(code, checkFlag, key) {
@@ -458,28 +475,45 @@ Component({
       })
     },
     /**
-  * @desc   : 清楚数据
-  * @author : 于继渤
-  * @date   : 2024/2/2 11:46
-  */
+    * @desc   : 清除数据
+    * @author : 于继渤
+    * @date   : 2024/2/2 11:46
+    */
     setFormNull() {
+      let value = this.data.value;
+      let filters = this.data.contentObj.filter(it=>it.notClear);
+      value = value?JSON.parse(value):{}
+      let form = this.data.form
+      console.log('filters',this.data.contentObj,filters);
+      if(filters && filters.length > 0){
+        filters.forEach(it=>{
+          if(form[it.code]){
+            value[it.code] = form[it.code]
+          }
+          if(form[it.name]){
+            value[it.name] = form[it.name]
+          }
+        })
+      }
+
       this.setData({
-        form: {}
+        form: value,
+        loading: false
       })
     },
 
     /**
-* @desc   : 清楚数据指定
-* @author : 于继渤
-* @date   : 2024/2/2 11:46
-*/
+    * @desc   : 清除数据指定
+    * @author : 于继渤
+    * @date   : 2024/2/2 11:46
+    */
     setFormIsNull() {
       console.log('form清楚数据指定', this.data.form)
       let form = this.data.form
       form['catName'] = ''
       form['remark'] = ''
       this.setData({
-        form:form
+        form: form
       })
     },
     /**

+ 1 - 1
components/dkbase/dk-popup/dk-popup.wxml

@@ -81,7 +81,7 @@
   <view style="height: 30rpx;background-color: #FFFFFF;"></view>
 
   <view wx:if="{{!readonly}}" style="text-align: center;background-color: #FFFFFF">
-    <van-button round size="large" color="#3E69F6" custom-style="height:88rpx;width:640rpx;margin-bottom:40rpx;border-radius:15rpx" type="info" size="small" bindtap="commit">确定</van-button>
+    <van-button round size="large" color="#3E69F6" custom-style="height:88rpx;width:640rpx;margin-bottom:40rpx;border-radius:15rpx" type="info" size="small" disabled="{{loading}}" loading="{{loading}}" bindtap="commit">确定</van-button>
   </view>
 </van-popup>
 

+ 1 - 1
mixins/index.js

@@ -846,7 +846,7 @@ module.exports = {
           this.setData({
             pageInfo: {
               currentPage: 1,
-              pageSize: 5
+              pageSize: Constants.PAGE_SIZE
             }
           })
           // 重新查询

+ 8 - 4
package-basic-data/pages/basic-data/basic-data.js

@@ -601,7 +601,10 @@ Page({
           })
           // 执行查询方法
           this.searchData()
-
+          // 编辑关闭弹出pop
+          this.setData({
+            showPop: false
+          })
         }
       });
     } else { //新建
@@ -621,6 +624,8 @@ Page({
                 })
                 // 重新查询
                 this.searchData()
+                //清除组件数据
+                this.selectComponent('#popup').setFormNull()
               }
             })
           }).catch(() => {
@@ -648,14 +653,13 @@ Page({
               })
               // 执行查询方法
               this.searchData()
-
+              //清除组件数据
+              this.selectComponent('#popup').setFormNull()
             }
           });
         }
       })
-
     }
-
   },
   /**
    * @desc : 编辑默认设置提示

+ 13 - 11
package-basic-data/pages/product-attribute/product-attribute.js

@@ -209,7 +209,10 @@ Page({
           })
           // 执行查询方法
           this.searchData()
-
+          // 编辑后关闭窗体
+          this.setData({
+            showPop:false
+          })
         }
       });;
     } else { //新建
@@ -221,16 +224,18 @@ Page({
             duration: 2000
           })
 
-          console.log('dataItem', this.data.dataItem)
+          // console.log('dataItem', this.data.dataItem)
           this.setData({
             dataItem:null
           })
+          // 商品种类
+          if(this.data.formDataName == mixins.$t('goodsCategorySys')){
+            console.log('dddttt',this.data.dataItem);
+          }
           //清除组件数据
           this.selectComponent('#popup').setFormNull()
-          
           // 执行查询方法
           this.searchData()
-
         }
       });;
     }
@@ -397,8 +402,6 @@ Page({
             // { code: 'brandCode', type: 'str', title: mixins.$t('brandCode'), required: false, readonly: true, },
             { code: 'brandName', type: 'str', title: mixins.$t('brandName'), required: true },
             // { code: 'shortName', type: 'str', title: mixins.$t('abbreviation'), required: false },
-      
-  
             { code: 'remarks', type: 'str', title: mixins.$t('remarks'), required: false }
           ]
         }else{
@@ -407,8 +410,7 @@ Page({
             // { code: 'brandCode', type: 'str', title: mixins.$t('brandCode'), required: false, readonly: true, },
             { code: 'brandName', type: 'str', title: mixins.$t('brandName'), required: true },
             // { code: 'shortName', type: 'str', title: mixins.$t('abbreviation'), required: false },
-            { code: 'supplierIds', name: 'supplierNames', title: 'supplier', type: 'choose', required: true, dropType: 'supplier', required: true, urlKey: 'selectProductAttributeSuppliers', code: 'supplierIds', formMode: 'index', idKey: 'roleId', title: mixins.$t('supplier') },
-  
+            { code: 'supplierIds', name: 'supplierNames', title: 'supplier', type: 'choose', required: true, dropType: 'supplier', required: true, urlKey: 'selectProductAttributeSuppliers', code: 'supplierIds', formMode: 'index', idKey: 'roleId', title: mixins.$t('supplier') }, 
             { code: 'remarks', type: 'str', title: mixins.$t('remarks'), required: false }
           ]
         }
@@ -420,8 +422,8 @@ Page({
       if(dataItem){
         popContent =
         [
-          { code: 'catCode', type: 'str', title: mixins.$t('catCode'), required: false, readonly: true, },
-          { code: 'parentId', name: 'parentName', title: mixins.$t('parent'), type: 'choose', required: false, urlKey: 'selectProductTypes', },
+          { code: 'catCode', type: 'str', title: mixins.$t('catCode'), required: false, readonly: true },
+          { code: 'parentId', name: 'parentName', title: mixins.$t('parent'), type: 'choose', required: false, urlKey: 'selectProductTypes',notClear:true },
           { code: 'catName', type: 'str', title: mixins.$t('catName'), required: true },
           { code: 'remarks', type: 'str', title: mixins.$t('remarks'), required: false }
         ]
@@ -429,7 +431,7 @@ Page({
         popContent =
         [
           // { code: 'catCode', type: 'str', title: mixins.$t('catCode'), required: false, readonly: true, },
-          { code: 'parentId', name: 'parentName', title: mixins.$t('parent'), type: 'choose', required: false, urlKey: 'selectProductTypes', },
+          { code: 'parentId', name: 'parentName', title: mixins.$t('parent'), type: 'choose', required: false, urlKey: 'selectProductTypes',notClear:true },
           { code: 'catName', type: 'str', title: mixins.$t('catName'), required: true },
           { code: 'remarks', type: 'str', title: mixins.$t('remarks'), required: false }
         ]

+ 0 - 1
package-basic-data/pages/product-attribute/product-attribute.wxml

@@ -43,6 +43,5 @@
 
 
 
-
 <!-- 底部信息 -->
 <dk-save-button model:value="{{btnFormData}}" btnAutoWidthFlag="{{true}}" btnRightFlag="{{true}}" buttonList="{{buttonSaveList}}" contentList="{{contentSaveList}}" bind:open="toAdd"></dk-save-button>

+ 1 - 1
utils/Constants.js

@@ -3,7 +3,7 @@
  */
 module.exports = {
   //一页条数
-  PAGE_SIZE: 5,
+  PAGE_SIZE: 10,
   //最大条数(导出excel使用)
   MAX_PAGE_SIZE: 100000,
   // 成功的code