Преглед изворни кода

1、修改编辑查询数据

zhoux пре 2 година
родитељ
комит
7df22b366a

+ 16 - 0
components/dkbase/dk-form-bill/dk-form-bill.js

@@ -54,9 +54,11 @@ Component({
     // 是否显示pop
     show: false,
     showDate:false,
+    showPop:false,
     $t: app.globalData.lang,
     routeUrl: app.globalData['routeUrl'],
     item: null,
+    dataItem:null,
     index: null,
     card: null,
     key:null,
@@ -97,6 +99,20 @@ Component({
    */
   methods: {
     /**
+     * @desc   : 打开Pop进行修改
+     * @author : 周兴
+     * @date   : 2024/1/26 11:46
+     */
+    openChoosedItemInfo(e){
+      console.log('eeee',e);
+      let dataItem = e.currentTarget.dataset.item
+
+      this.setData({
+        dataItem:JSON.stringify(dataItem) ,
+        showPop:true,
+      })
+    },
+    /**
      * @desc   : 打开下拉/跳转选择页面
      * @author : 周兴
      * @date   : 2024/1/26 11:46

+ 5 - 1
components/dkbase/dk-form-bill/dk-form-bill.wxml

@@ -132,4 +132,8 @@
 
 <van-popup show="{{ showDate }}" custom-style="border-radius:30rpx 30rpx 0 0;" position="bottom" bind:close="cancelDatePop">
   <van-datetime-picker type="date" bind:confirm="chooseDate" bind:cancel="cancelDatePop" loading="{true}" />
-</van-popup>
+</van-popup>
+
+
+<dk-popup model:value="{{dataItem}}" show="{{showPop}}">
+</dk-popup>

+ 4 - 1
components/dkbase/dk-popup/dk-popup.js

@@ -13,6 +13,10 @@ Component({
    * 组件的属性列表
    */
   properties: {
+    // 是否显示
+    show:{
+      type:Boolean
+    },
 		// 结果集
     value: {
       type: String,
@@ -30,7 +34,6 @@ Component({
    * 组件的初始数据
    */
   data: {
-    show:false,
     // $t: app.globalData.lang,
     form:{}
   },

+ 56 - 3
components/dkbase/dk-popup/dk-popup.wxml

@@ -1,25 +1,78 @@
 <!-- 弹窗 编辑/新建-->
 <van-popup show="{{show}}" position="bottom" bind:close="onClosePopup" custom-class="dk-popup">
   <view style="position:relative; top:280rpx;z-index:  1;background-color: transparent; height: 44rpx;"></view>
+
+  <!--标题-->
   <view class="special-topic">
     <!-- 图片 -->
     <view class="special-topic-content">
       <van-image radius="15rpx" custom-class="goods-pop-image" fit="fill" src="{{ form.iconThumPath }}"></van-image>
     </view>
-
     <view class="special-topic-title">
       <!-- 标签 标题-->
       <dk-title titleTag="{{form.titleTag}}" title="{{form.title}}"></dk-title>
       <view style="padding-top: 10rpx;">
-        <dk-text fontWeight="normal" value="{{form.skuName}}"></dk-text>
+        <dk-text fontWeight="normal" value="{{form.desc}}"></dk-text>
       </view>
       <view style="display: flex;padding-top: 5rpx;">
         <view class="price-pop-class">
-          <dk-cell height="46rpx" spaceWidth="1rpx" left="0" fontSize="14" contentColor="#CAA977" fontWeight="bold" title="标价:" content="{{form.priceStandard}}"></dk-cell>
+          <dk-cell height="46rpx" spaceWidth="1rpx" left="0" fontSize="14" contentColor="#CAA977" fontWeight="bold" title="标价:" content="{{form.pricePromotion}}"></dk-cell>
         </view>
       </view>
+      <view style="padding-right: 30rpx;float: right;">
+        <dk-text fontWeight="normal" value="{{form.desc}}"></dk-text>
+      </view>
     </view>
+  </view>
+
+  <!--内容-->
+  <view class="pop-content-class">
+    <van-cell-group border="{{ false }}">
+
+      <!--销售价格-->
+      <van-cell border="{{ false }}" title-width="410rpx">
+        <view slot="title">
+          销售价格
+        </view>
+        <view Cell Slot="value">
+          <dk-number-input center="right" data-key="priceSale" inputValue="{{currentSkuChoosedItem.priceSale}}" bind:triggerBindValue="changeSalesPriceField"></dk-number-input>
+        </view>
+      </van-cell>
+      <van-cell border="{{ false }}" title-width="410rpx">
+        <view slot="title">
+          销售金额
+        </view>
+        <view Cell Slot="value">
+          <dk-number-input center="right" data-key="itemAmount" inputValue="{{currentSkuChoosedItem.itemAmount}}" bind:triggerBindValue="changeItemAmountField"></dk-number-input>
+        </view>
+      </van-cell>
+
+      <!--正常品显示-->
+      <van-cell wx:if="{{currentSkuChoosedItem.promotionType==0}}" border="{{ false }}" title-width="410rpx" disabled="{{currentSkuChoosedItem.flgGift}}">
+        <view slot="title" style="color:#95A8CB">
+          标价折扣
+        </view>
+        <dk-text color="#1B365D" fontSize="13px" fontWeight="nomal" value="{{(currentSkuChoosedItem.discountStandard  || currentSkuChoosedItem.discountStandard ==0)?(currentSkuChoosedItem.discountStandard+ '%'):'' }}"></dk-text>
+      </van-cell>
 
+      <!--促销品显示-->
+      <van-cell wx:if="{{currentSkuChoosedItem.promotionType !=0 }}" border="{{ false }}" title-width="410rpx">
+        <view slot="title" style="color:#95A8CB">
+          标准售价折扣
+        </view>
+        <dk-text color="#1B365D" fontSize="13px" fontWeight="nomal" value="{{currentSkuChoosedItem.discountPromotion?(currentSkuChoosedItem.discountPromotion+ '%'):'' }}"></dk-text>
+      </van-cell>
+
+      <!--赠品标识-->
+      <van-cell title-class="nomal-label" title="赠品标识" border="{{ false }}" value-class="value-class">
+        <van-checkbox shape="round" value="{{ currentSkuChoosedItem.flgGift}}" data-index="{{index}}" data-key="flgGift" bind:change="changeSkuFlgGift" />
+      </van-cell>
+      <view style="height: 100rpx;"></view>
+
+      <view style="text-align: center;">
+        <van-button round size="large" color="#1B365D" custom-style="height:88rpx;width:640rpx;" type="info" data-item="{{currentSkuChoosedItem}}" size="small" bindtap="updateCurrentSkuChoosedItem">确定</van-button>
+      </view>
+    </van-cell-group>
   </view>
 
   <view style="display: flex; padding:35rpx 34rpx 62rpx 34rpx;">

+ 14 - 2
components/dkbase/dk-popup/dk-popup.wxss

@@ -7,7 +7,7 @@
 /**pop弹出框的表头样式*/
 .special-topic {
   width: 96%;
-  height: 223rpx;
+  height: 185rpx;
   display: flex;
   padding-left: 4%;
   /* 从最下面开始布局 */
@@ -20,9 +20,21 @@
 .special-topic-title{
   width: 90%;
   height: 165rpx;
-  padding: 1rpx 0 0 20rpx !important;
+  padding: 10rpx 0 0 10rpx !important;
 }
 
 .price-pop-class{
   width: 75%;
+}
+
+/**pop弹出框的表头图片样式*/
+.goods-pop-image{
+  width: 163rpx;
+  height: 163rpx;
+  display: flex;
+  align-items: center;
+  text-align: center;
+  border: 1px solid #606EB2;
+  border-radius: 15rpx !important;
+  margin-bottom: 47rpx;
 }

+ 67 - 8
mixins/index.js

@@ -46,6 +46,10 @@ module.exports = {
     formName: 'dkForm',
     // 表单实体
     formData: null,
+    // 表单类型
+    formMode: null,
+    // id
+    id: null,
     // 语言包
     $t: app.globalData.lang,
   },
@@ -79,9 +83,9 @@ module.exports = {
       })
       if (res == null) {
         return;
-      } 
+      }
 
-      console.log('re', res,e,e != 'more');
+      console.log('re', res, e, e != 'more');
 
       if (res && res.data.code === Constants.SUCESS_CODE) {
         let tableData = this.data.tableData;
@@ -95,7 +99,7 @@ module.exports = {
             tableData: tableData,
             pageInfo
           })
-        } 
+        }
         // if (!list || list.length === 0) {
         //   this.setData({
         //     noMore: true
@@ -106,7 +110,7 @@ module.exports = {
           this.setData({
             noMore: false
           })
-        }else{
+        } else {
           this.setData({
             noMore: true
           })
@@ -261,7 +265,7 @@ module.exports = {
    * @date : 2024/1/22
    */
   _handleSaveData() {
-    console.log("this.data.params",this.data.params);
+    console.log("this.data.params", this.data.params);
     this._saveData(this.data.params).then(result => {
       this.setData({
         loading: false
@@ -277,7 +281,7 @@ module.exports = {
         if (this.handleData) {
           this.handleData();
         }
-      }  
+      }
     });
   },
   /**
@@ -291,7 +295,7 @@ module.exports = {
     if (this.data.formData) {
       params = JSON.parse(this.data.formData);
     }
-    params.cpId = 1 
+    params.cpId = 1
     this.setData({
       params: params
     })
@@ -356,6 +360,33 @@ module.exports = {
     })
   },
   /**
+   * @desc   : 查询明细的方法(不给外部调用)
+   * @author : 周兴
+   * @date   : 2022/12/8 17:56
+   */
+  _detail(id) {
+    this.loading = true;
+    this.detail(id)?.then(res => {
+      if (res.data.code === Constants.SUCESS_CODE && res.data.data) {
+        // 给变量赋值
+        if (this.setValuesByEdit) {
+          this.setValuesByEdit(res.data.data)
+        }
+      }
+      setTimeout(() => {
+        this.loading = false
+      }, 300)
+    })
+  },
+  /**
+   * @desc : 根据id查询数据
+   * @date : 2024/2/26 15:49
+   * @author : 周兴
+   */
+  detail(id) {
+    return this.excute(this.data.service, id, null);
+  },
+  /**
    * @desc : 执行方法
    * @author : 周兴
    * @date : 2024/1/22
@@ -415,7 +446,35 @@ module.exports = {
       }
     }
 
-    this.searchData();
+    // 接收父页面传递的参数
+    const eventChannel = this.getOpenerEventChannel();
+    if (eventChannel) {
+      let _this = this;
+      // 指定类型
+      eventChannel.on('params', function (data) {
+        // 获取参数
+        if (data.formMode) {
+          _this.setData({
+            id: data.id,
+            formMode: data.formMode
+          })
+        }
+      })
+    }
+    let formMode = this.data.formMode;
+    formMode = formMode ? formMode : Constants.formMode.index
+    // 列表
+    if (formMode == Constants.formMode.index) {
+      // 默认查询
+      this.searchData();
+      // 编辑
+    } else if (formMode == Constants.formMode.edit) {
+      let id = this.data.id;
+      if (id) {
+        // 调用明细
+        this._detail(id);
+      }
+    }
   },
   /**
  * @desc : 页面上拉触底事件的处理函数

+ 6 - 6
package-basic-data/pages/staff/add/add.js

@@ -82,16 +82,16 @@ Page({
      
     return this.excute(this.data.service, this.data.service.insert, this.data.params);
   },
-
-    /**
-   * @desc : 编辑查询
+  /**
+   * @desc : 给表单赋值
    * @date : 2024/2/1 15:49
    * @author : 姜永辉
    */
-  selectById(params) {
-    return this.excute(this.data.service, params.id, null);
+  setValuesByEdit(data){
+    this.setData({
+      formData:JSON.stringify(data)
+    })
   },
-
   /**
  * 生命周期函数--监听页面加载
  */

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

@@ -63,7 +63,7 @@ Page({
       },
       success: function (res) {
         // 通过eventChannel向被打开页面传送数据 TODO 测试例子url是写死的,实际中,需要从route中读取
-        res.eventChannel.emit('params', { id: staffId, type: Constants.formMode.update })
+        res.eventChannel.emit('params', { id: staffId, formMode: Constants.formMode.edit })
       }
     })
   },

+ 10 - 5
utils/Constants.js

@@ -56,6 +56,16 @@ module.exports = {
     staff:'staff'
   },
 
+  // 表单类型
+  formMode:{
+    // 列表
+    index:'index',
+    // 新建
+    add:'add',
+    // 编辑
+    edit:'edit',
+  },
+
   // 查询条件日期数据源
   searchDateSource:[
     { text: '本日', value: 1 },
@@ -95,11 +105,6 @@ module.exports = {
     }
   ],
 
-  formMode:{
-    add:'add',
-    update:'update'
-  },
-
   // 对象类型
   objType:{
     customer:'customer',