Ver Fonte

1、修改选择数据共通页面

zhoux há 1 ano atrás
pai
commit
7736d4c868

+ 1 - 0
i18n/zh-CN.js

@@ -447,6 +447,7 @@ const customer = {
   spaceName: '空间名称',
   uploadDrawings: '上传图纸',
   addDrawings: '添加空间图纸',
+  defaultInfo:'已存在默认,是否替换默认',
 }
 // 提示信息
 const messages = {

+ 150 - 20
package-base-select/pages/select-data/select-data.js

@@ -8,6 +8,8 @@ Page({
    * 页面的初始数据
    */
   data: {
+    showPop: false,
+    gradeCode: app.globalData.company.gradeCode,
     active: 0,
     // 选择数据
     choosedData: [],
@@ -18,6 +20,8 @@ Page({
     searchContent: null,
     // 路由
     routeObjName: 'common',
+    // pop使用
+    routeObjNamePop: '',
     // 列表区(内容)
     contentList: null,
     // 方法名
@@ -26,6 +30,8 @@ Page({
     dictCode: null,
     // 标题
     title: null,
+    // 弹出pop的标题
+    popTitle: null,
     // 需要调到的新建路由
     addUrl: null,
     // 是否多选
@@ -41,6 +47,10 @@ Page({
     repeatFlag: false,
     // 简单标识
     simpleFlag: false,
+    // 弹出新建
+    popContent: null,
+    // 是否有默认值
+    defaultFlag: false,
     // 确定按钮
     buttonList: [{
       name: 'confirm',
@@ -56,20 +66,23 @@ Page({
     if (!this.data.addUrl) {
       return;
     }
-    let _this = this
-    wx.navigateTo({
-      url: this.data.addUrl,
-      events: {
-        // // 回调后,在这里给页面赋值
-        // bandData: function (e) {
-
-        // }
-      },
-      success: function (res) {
-        // 通过eventChannel向被打开页面传送数据 TODO 测试例子url是写死的,实际中,需要从route中读取
-        res.eventChannel.emit('params', {})
-      }
+    this.setData({
+      showPop: true
     })
+    // let _this = this
+    // wx.navigateTo({
+    //   url: this.data.addUrl,
+    //   events: {
+    //     // // 回调后,在这里给页面赋值
+    //     // bandData: function (e) {
+
+    //     // }
+    //   },
+    //   success: function (res) {
+    //     // 通过eventChannel向被打开页面传送数据 TODO 测试例子url是写死的,实际中,需要从route中读取
+    //     res.eventChannel.emit('params', {})
+    //   }
+    // })
   },
   /**
    * @desc : 选择数据
@@ -106,6 +119,7 @@ Page({
         choosedData: choosedData
       })
     }
+    console.log('ddddd', this.data.choosedData);
   },
   /**
    * @desc : 确定事件-返回数据
@@ -148,8 +162,8 @@ Page({
     this.setData({
       tableData: tableData
     })
-    item.id = item.channelId,
-    item.name = item.channelName,
+    item.id = item.channelId
+    item.name = item.channelName
     item.code = item.channelCode
     const eventChannel = this.getOpenerEventChannel();
     eventChannel.emit('bindData', {
@@ -178,8 +192,18 @@ Page({
     this.setData({
       tableData: tableData
     })
+    // 执行点击事件
+    this._toDetail(item);
+  },
+  /**
+   * @desc :  执行点击事件(私有方法)
+   * @author : 周兴
+   * @date : 2024/5/9 15:16
+   */
+  _toDetail(item) {
     // 读取传入的单据类型
     let route = this.data.chooseRoute
+    console.log('dddf', route);
     let data = {}
     switch (route.type) {
       // 部门
@@ -373,6 +397,96 @@ Page({
     let service = app.globalData[this.data.routeObjName + 'Service'];
     return this.excute(service, service[this.data.method], params);
   },
+  /** 
+   * @desc : 保存数据
+   * @date : 2024年5月9日
+   * @author : 周兴
+   */
+  editItems(e) {
+    let data = e.detail.form
+    this.setData({
+      formData: JSON.stringify(data)
+    })
+    //执行保存编辑操作
+    this.save({})
+  },
+  /** 
+   * @desc : 执行保存
+   * @date : 2024年5月9日
+   * @author : 周兴
+   */
+  saveData(params) {
+    let routeObjNamePop = this.data.routeObjNamePop
+    if (!routeObjNamePop) return;
+    let service = app.globalData[routeObjNamePop + 'Service']
+    let defaultFlag = this.data.defaultFlag;
+    // 没有默认值就直接保存
+    if (!defaultFlag) {
+      return this.excute(service, service.insert, params).then(res => {
+        if (res.data.code === Constants.SUCESS_CODE) {
+          wx.showToast({
+            title: '保存成功',
+            image: '/static/image/success.png',
+            duration: 2000
+          })
+          if (res.data.data) {
+            setTimeout(() => {
+              // 执行点击事件
+              this._toDetail(res.data.data)
+            }, 2000)
+          }
+        }
+      })
+    }else{
+      this.isFlgDefaultSave(service).then(it => {
+         //存在默认
+         Dialog.confirm({
+          message: mixins.$t('defaultInfo'),
+        }).then(() => {
+          return this.excute(service, service.insert, params).then(res => {
+            if (res.data.code === Constants.SUCESS_CODE) {
+              wx.showToast({
+                title: '保存成功',
+                image: '/static/image/success.png',
+                duration: 2000
+              })
+              if (res.data.data) {
+                setTimeout(() => {
+                  // 执行点击事件
+                  this._toDetail(res.data.data)
+                }, 2000)
+              }
+            }
+          })
+        }).catch(() => {
+          // this.setData({
+          //   dataItem: null
+          // })
+          // //清除组件数据
+          // this.selectComponent('#popup').setFormNull()
+          return
+        });
+      })
+    }
+  },
+  /**
+   * @desc : 新建默认设置提示
+   * @author : 于继渤
+   * @date : 2022/5/26 20:16
+   */
+  isFlgDefaultSave(service) {
+    return new Promise((resolve, reject) => {
+      this.excute(service, service.selectByCond, {
+        flgDefault: true
+      }).then(res => {
+        if (res.data.data.list && res.data.data.list.length > 0) {
+          resolve(false)
+        } else {
+          resolve(true)
+        }
+      })
+    })
+  },
   /**
    * @desc : tab切换(列表和已选)
    * @date : 2024/3/25 15:49
@@ -593,9 +707,6 @@ Page({
               name: 'freezeQty',
               title: '冻结量'
             },
-
-
-
           ],
           placeholder: ['whName']
         })
@@ -606,9 +717,11 @@ Page({
         this.setData({
           addUrl: '/package-basic-data/pages/product-attribute/product-attribute',
           routeObjName: 'common',
+          routeObjNamePop: 'goodsBrand',
           method: 'goodsBrandListBy',
           chooseFlag: route.chooseFlag,
           repeatFlag: route.repeatFlag,
+          popTitle: mixins.$t('add') + title,
           title: 'brandName',
           contentList: [{
             name: 'brandCode',
@@ -621,6 +734,23 @@ Page({
           ],
           placeholder: ['brandName']
         })
+        // 标准版没有供应商
+        if (this.data.gradeCode == Constants.gradeCode.STD) {
+          this.setData({
+            popContent: [
+              { code: 'brandName', type: 'str', title: mixins.$t('brandName'), required: true },
+              { code: 'remarks', type: 'str', title: mixins.$t('remarks'), required: false }
+            ],
+          })
+        } else {
+          this.setData({
+            popContent: [
+              { code: 'brandName', type: 'str', title: mixins.$t('brandName'), required: true },
+              { 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 }
+            ],
+          })
+        }
         break;
       // 数据字典
       case Constants.chooseType.dictionary:
@@ -632,7 +762,7 @@ Page({
           dictCode: route.dictCode,
           chooseFlag: route.chooseFlag,
           repeatFlag: route.repeatFlag,
-          pageFlag:false,
+          pageFlag: false,
           valueKey: 'dataId',
           title: 'dataValue',
           contentList: [{
@@ -673,7 +803,7 @@ Page({
       // 对象类型
       case Constants.chooseType.objectType:
         title = "对象类型"
-        this.setData({ 
+        this.setData({
           routeObjName: 'common',
           method: 'getSupplierAndCustomerData',
           title: 'objName',

+ 5 - 1
package-base-select/pages/select-data/select-data.wxml

@@ -40,4 +40,8 @@
   <view bind:tap="toAdd" class="btn-add-class">
     <van-icon name="plus" color="#FFFFFF" size="60rpx" />
   </view>
-</view>
+</view>
+
+
+<dk-popup id="popup" type="basic" validFlag="{{true}}" priceTitle=""  title="{{popTitle}}" value="{{dataItem}}" show="{{showPop}}" routeObjName="{{routeObjNamePop}}" contentObj="{{popContent}}" bind:commit="editItems">
+</dk-popup>

+ 1 - 1
package-basic-data/pages/basic-data/basic-data.js

@@ -598,7 +598,7 @@ Page({
         if (!it && params.flgDefault) {
           //存在默认
           Dialog.confirm({
-            message: '已存在默认,是否要新作默认',
+            message: mixins.$t('defaultInfo'),
           }).then(() => {
             return this.excute(service, service.insert, params).then(res => {
               if (res.data.code === Constants.SUCESS_CODE) {