GaoYuPeng 3 years ago
parent
commit
06f8183741

+ 10 - 0
shanXiPlatform/src/api/grainCheck/index.js

@@ -129,6 +129,16 @@ export function getDateTimeNow(){
129 129
   return today
130 130
 }
131 131
 
132
+export function getYearWeek(date){
133
+	var date2=new Date(date.getFullYear(), 0, 1);
134
+	var day1=date.getDay();
135
+	if(day1==0) day1=7;
136
+	var day2=date2.getDay();
137
+	if(day2==0) day2=7;
138
+	var d = Math.round((date.getTime() - date2.getTime()+(day2-day1)*(24*60*60*1000)) / 86400000);
139
+	return Math.ceil(d /7)+1;
140
+}
141
+
132 142
 //根据id查询(更多纪录)
133 143
 /* export function getAllGrainInfo(params) {
134 144
   return request({

+ 37 - 1
shanXiPlatform/src/views/reservesManagement/grainCheck/newGrain/addNewGrain.vue

@@ -244,7 +244,7 @@ import {
244 244
   getDateTimeNow,
245 245
   haveDone, //处理待办
246 246
   haveDone1,
247
-  getGrainItems
247
+  getGrainItems,getYearWeek
248 248
 } from "@/api/grainCheck/index"
249 249
 export default {
250 250
   name: "AddNewGrain",
@@ -291,6 +291,8 @@ export default {
291 291
       checkPerson: "",
292 292
       data2: {}, //待办传参过来的数据
293 293
       uid: "",
294
+      date:new Date(),
295
+      week:0, //今年的第几周
294 296
       // 先自定义后台接收数据的模板然后拼接
295 297
       data3: {
296 298
         checkTime: "",
@@ -393,9 +395,40 @@ export default {
393 395
 
394 396
     // 新增初始化数据
395 397
     this.getinfo()
398
+    this.getdate()
396 399
   },
397 400
 
398 401
   methods: {
402
+
403
+    getdate() {
404
+            var myDate = new Date()
405
+            var year = myDate.getFullYear() //获取完整的年份(4位,1970-????)
406
+            var mon = myDate.getMonth() + 1 //获取当前月份(0-11,0代表1月)
407
+            var date = myDate.getDate() //获取当前日(1-31)
408
+            var week = myDate.getDay() //获取当前星期X(0-6,0代表星期天)
409
+            let d1 = new Date()
410
+            let d2 = new Date()
411
+            d2.setMonth(0)
412
+            d2.setDate(1)
413
+            let rq = d1 - d2
414
+            let s1 = Math.ceil(rq / (24 * 60 * 60 * 1000))
415
+            let s2 = Math.ceil(s1 / 7)
416
+            this.week = s2;
417
+
418
+            this.datastr =
419
+                year +
420
+                "年" +
421
+                mon +
422
+                "月" +
423
+                date +
424
+                "日" +
425
+                "\xa0\xa0\xa0" +
426
+                "第" +
427
+                s2 +
428
+                "周"
429
+        },
430
+
431
+
399 432
     showHandler(val) {
400 433
       // console.log(val, "val...")
401 434
       if (val.enumId == 189) {
@@ -696,6 +729,9 @@ export default {
696 729
       // this.data3.grainAbnormalDescribe = this.form
697 730
       // this.data3.checkTime = getDateTimeNow()
698 731
       this.data5.grainConditionRecord.operationTime = getDateTimeNow()
732
+      this.data5.grainConditionRecord.checkYearWeek = this.week
733
+
734
+      // console.log(this.data5.grainConditionRecord.checkYearWeek,'this.data5.grainConditionRecord.checkYearWeek')
699 735
       /* this.data5.grainConditionRecord.depotId = this.depot_id
700 736
        this.data5.grainConditionRecord.houseId = this.house_id */
701 737
       // console.log(this.data3.checkTime,'this.data3.checkTime')

+ 1 - 1
shanXiPlatform/src/views/reservesManagement/grainCheck/newGrain/index.vue

@@ -259,7 +259,7 @@ export default {
259 259
           anomalousStatus: 0, //异常状态(0无异常,1有异常)
260 260
           checkPerson: null, //检查人
261 261
           // checkYear: 0,//检查年份(用于粮情异常等,做年统计)
262
-          // checkYearWeek: 0,//检查所在年第几周
262
+          checkYearWeek: 0,//检查所在年第几周
263 263
           depotId: null, //库id
264 264
           enumId: null, //检查类型
265 265
           enumOrder: 0, //用于同公共枚举同步顺序