Kaynağa Gözat

分配查核人和计划时间不能为空

yuwenfen 4 yıl önce
ebeveyn
işleme
bf0d17ddac

+ 28 - 5
pages/allocationPerson/allocationPerson.vue

@@ -72,6 +72,8 @@
         // 服务器时间
         dateStr: '',
         timer: null,
+        // 点击确定按钮是否直接保存
+        isSubmit: false
 			}
     },
     onLoad({ details }){
@@ -141,18 +143,33 @@
       // 开始时间和结束时间对比
       diffDateTime(startTime, endTime){
         if (moment(startTime).valueOf() > moment(endTime).valueOf()) {
-          uni.showModal({
-            content: '开始时间不能大于结束时间',
-            showCancel: false
-          });
+          this.showModal('开始时间不能大于结束时间');
         }
       },
       // 点击确定
       sure() {
+        const { empId, startDate, endDate} = this.details;
+        if(this.isSubmit === true) {
+         return this.changeCheckList(this.checkList);
+        }
         if(this.title === '指派查核人员'){
+          if(!empId){
+            return this.showModal('请选择查核人');
+          }
           this.setNavigationBarTitle('设置查核时间');
         }else {
-          this.changeCheckList(this.checkList);
+          if(!startDate){
+            return this.showModal('请选择开始时间');
+          }
+          if(!endDate){
+            return this.showModal('请选择结束时间');
+          }
+          if(!empId){
+            this.setNavigationBarTitle('指派查核人员');
+            this.isSubmit = true;
+          }else {
+            this.changeCheckList(this.checkList);
+          }
         }
       },
       // 更改查核列表数据
@@ -194,6 +211,12 @@
           }
         });
       },
+      showModal(content) {
+        uni.showModal({
+          content,
+          showCancel: false
+        });
+      },
       // 清除定时器
       clearTimer(){
         if(this.timer){

+ 18 - 9
pages/editCheckList/editCheckList.vue

@@ -1,6 +1,6 @@
 <template>
 	<view class="check-map-list">
-    <scroll-view class="scroll-y" scroll-y="true">
+    <scroll-view class="scroll-y" scroll-y="true" v-if="checkList.length > 0">
       <view class="item"
 	    	v-for="(item, index) in checkList"
 	    	:key="index">
@@ -43,8 +43,8 @@
 	    	</view>
 	    </view>
     </scroll-view>
-		<view class="null" v-if="checkList.length === 0">暂无数据</view>
-    <view class="fixed-buttom-btn" @click="submit">
+		<view class="null" v-else>暂无数据</view>
+    <view class="fixed-buttom-btn" @click="submit" v-if="checkList.length > 0">
 			<text class="btn-text">完成</text>
 		</view>
 	</view>
@@ -94,7 +94,7 @@
         let planStartTimestamp = this.dateToTimestamp(this.startDate);
         this.checkList.map((item, i) => {
           const {checkId, deptId, empId, empName, startDate, endDate} = item;
-          if(empId || empName || startDate || endDate){
+          if(empId && startDate && endDate){
             baseEmpList.push({
               checkId,
               deptId,
@@ -174,18 +174,25 @@
       },
       // 分配单位查核人员
       batchDistribute(empList) {
+        if(empList.length === 0) { // 未作修改直接跳转页面
+          return this.redirectToPlanList();
+        }
         this.$store.dispatch({
           type: 'editCheckList/commActions',
           key: "batchDistribute",
           data: { empList }
         }).then(data => {
           if(data){
-            uni.redirectTo({
-              url: `/pages/planList/planList?situationId=${this.situationId}&checkGroupId=${this.checkGroupId}`
-            });
+            this.redirectToPlanList();
           }
         });
       },
+      // 跳转页面
+      redirectToPlanList() {
+        uni.redirectTo({
+          url: `/pages/planList/planList?situationId=${this.situationId}&checkGroupId=${this.checkGroupId}`
+        });
+      },
       // 日期时间转换为时间戳
       dateToTimestamp(dataStr) {
         return dataStr ? moment(dataStr).valueOf() : 0
@@ -300,7 +307,8 @@
 	    				flex: 1;
 	    				line-height: 62.5rpx;
 	    				color: #B8BECC;
-	    				font-weight: normal;
+              font-weight: normal;
+              margin-bottom: 0;
 	    			}
 
 	    			.center-text {
@@ -322,8 +330,9 @@
     }
 
 		.null {
+			margin-top: 375rpx;
 			text-align: center;
-			color: #999;
+      color: #999;
 		}
 	}
 </style>