Quellcode durchsuchen

工序内容编辑优化

NULL1222 vor 17 Stunden
Ursprung
Commit
4bfb5625d8
2 geänderte Dateien mit 36 neuen und 68 gelöschten Zeilen
  1. 26 58
      bgj/workOrder/nodes/update/update.js
  2. 10 10
      bgj/workOrder/nodes/update/update.wxml

+ 26 - 58
bgj/workOrder/nodes/update/update.js

@@ -43,7 +43,8 @@ Page({
       });
       return;
     }
-    const isEditing = workDetail.status == '进行中' && detail.status != '1';
+    //工单状态为进行中可以编辑,不管工序是进行中还是已完成
+    const isEditing = workDetail.status == '进行中' ;
     const workpresetjson = detail.workpresetjson || {};
     const attinfos = detail.attinfos || [];
     // 按usetype分组
@@ -90,7 +91,7 @@ Page({
 
   // 页面销毁时刷新父页面
   onUnload() {
-    if (this.data.detail.status == '2') {
+    if (this.data.detail.status != '0') {
       const pages = getCurrentPages();
       const detailPage = pages.find(v => v.__route__ == 'bgj/workOrder/detail');
       if (detailPage && detailPage.getDetail) detailPage.getDetail();
@@ -450,12 +451,21 @@ Page({
     if (this.data.saving) return;
     this.setData({ saving: true });
 
+    // 校验必填项是否有值,决定工序状态
+    const hasRequired = !this.validateRequired();
+    const isconfirm = hasRequired ? 1 : 0;
+
     _Http.basic({
       id: 2026052615154602,
-      content: this.buildContent(0),
+      content: this.buildContent(isconfirm),
     }).then(res => {
-      if (res.code == 1 && this.data.detail.status == '0') {
-        this.setData({ 'detail.status': '2' });
+      if (res.code == 1) {
+        const newStatus = hasRequired ? '1' : '2';        
+        if (this.data.detail.status != newStatus) {
+          this.setData({
+            'detail.status': newStatus,
+          });
+        }
       }
       this.setData({ saving: false });
     }).catch(() => {
@@ -468,15 +478,22 @@ Page({
     if (this.data.saving) return;
     this.setData({ saving: true });
 
+    // 校验必填项是否有值,决定工序状态
+    const hasRequired = !this.validateRequired();
+    const isconfirm = hasRequired ? 1 : 0;
+
     _Http.basic({
       id: 2026052615154602,
-      content: this.buildContent(0),
+      content: this.buildContent(isconfirm),
     }).then(res => {
-      if (res.code == 1 && this.data.detail.status == '0') {
-        this.setData({ 'detail.status': '2' });
+      if (res.code == 1) {
+        const newStatus = hasRequired ? '1' : '2';
+        this.setData({
+          'detail.status': newStatus,
+        });
+        wx.showToast({ title: '已保存', icon: 'success' });
       }
       this.setData({ saving: false });
-      wx.showToast({ title: '已保存', icon: 'success' });
     }).catch(() => {
       this.setData({ saving: false });
       wx.showToast({ title: '保存失败', icon: 'none' });
@@ -526,53 +543,4 @@ Page({
     return '';
   },
 
-  save() {
-    if (this.data.loading) return;
-
-    const msg = this.validateRequired();
-    if (msg) {
-      wx.showToast({ title: msg, icon: 'none', duration: 2000 });
-      return;
-    }
-
-    Dialog.confirm({
-      title: '确认完成',
-      message: '确认完成后将不可再修改此工序,请确认信息无误后再提交。',
-      confirmButtonText: '确认提交',
-      cancelButtonText: '再检查下',
-      zIndex: 9999,
-      confirmButtonColor: '#3874F6'
-    }).then(() => {
-      this.doConfirmSave();
-    }).catch(() => {});
-  },
-
-  async doConfirmSave() {
-    this.setData({ loading: true });
-
-    try {
-      const confirmRes = await _Http.basic({
-        id: 2026052615154602,
-        content: this.buildContent(1),
-      });
-
-      if (confirmRes.code != 1) {
-        this.setData({ loading: false });
-        Dialog.alert({
-          title: '完成工单失败',
-          message: confirmRes.msg,
-          zIndex: 9999
-        });
-        return;
-      }
-
-      this.setData({ loading: false });
-      // 设置标记,让详情页显示完成成功提示
-      getApp().globalData._nodeCompleteSuccess = true;
-      wx.navigateBack();
-    } catch (e) {
-      this.setData({ loading: false });
-      wx.showToast({ title: '保存失败', icon: 'none' });
-    }
-  },
 });

+ 10 - 10
bgj/workOrder/nodes/update/update.wxml

@@ -175,23 +175,23 @@
   </view>
   <view style="height: 160rpx;"  />
 
-  <!-- 施工日志汇报按钮(悬浮,独立区域) -->
-  <view class="report-box-fixed" wx:if="{{ workpresetjson.logreport && detail.status == '1'}}">
-    <van-button custom-class="save-btn" type="primary" block catchtap="toReport">
-      施工日志汇报
-    </van-button>
-  </view>
-  <!-- 底部按钮(悬浮) -->
+  <!-- 编辑状态下底部按钮:保存 + 施工日志汇报 -->
   <view class="but-box-fixed" wx:if="{{isEditing}}">
     <view class="btn-half">
       <van-button custom-class="draft-btn" block loading="{{saving}}" disabled="{{saving}}" bindtap="manualSave">
         保存
       </van-button>
     </view>
-    <view class="btn-half">
-      <van-button custom-class="save-btn" type="primary" block loading="{{loading}}" disabled="{{loading}}" bindtap="save">
-        确认完成
+    <view class="btn-half" wx:if="{{workpresetjson.logreport}}">
+      <van-button custom-class="save-btn" type="primary" block catchtap="toReport">
+        施工日志汇报
       </van-button>
     </view>
   </view>
+  <!-- 非编辑状态下:仅施工日志汇报 -->
+  <view class="report-box-fixed" wx:if="{{!isEditing && workpresetjson.logreport}}">
+    <van-button custom-class="save-btn" type="primary" block catchtap="toReport">
+      施工日志汇报
+    </van-button>
+  </view>
 </view>