Эх сурвалжийг харах

Merge branch 'dev' into 'purchaseDev'

Dev

See merge request new-business/drp-web!328
黄梓星 1 жил өмнө
parent
commit
8cb26fd34f

+ 46 - 38
src/views/business/spd/fillin/dailysale_quantity_assess/detail.vue

@@ -27,7 +27,7 @@
             <el-form-item label="月份" prop="month">
             <el-form-item label="月份" prop="month">
               <el-date-picker
               <el-date-picker
                 v-model="form.month"
                 v-model="form.month"
-                value-format="yyyy-MM-dd"
+                value-format="yyyy-MM"
                 type="month"
                 type="month"
                 clearable
                 clearable
               >
               >
@@ -52,14 +52,12 @@
           </el-col>
           </el-col>
           <el-col :span="1.5">
           <el-col :span="1.5">
             <el-form-item label="创建日期" prop="createTime">
             <el-form-item label="创建日期" prop="createTime">
-              <el-date-picker
+              <el-input
                 v-model="form.createTime"
                 v-model="form.createTime"
+                style="width: 200px"
                 clearable
                 clearable
-                type="date"
-                value-format="yyyy-MM-dd"
                 readonly
                 readonly
-              >
-              </el-date-picker>
+              />
             </el-form-item>
             </el-form-item>
           </el-col>
           </el-col>
           <el-col :span="1.5">
           <el-col :span="1.5">
@@ -709,6 +707,7 @@ export default {
   data() {
   data() {
     return {
     return {
       form: {
       form: {
+        month: null,
         customer: null,
         customer: null,
         customerName: null,
         customerName: null,
         items: [],
         items: [],
@@ -726,20 +725,15 @@ export default {
     };
     };
   },
   },
   watch: {
   watch: {
-	'form.month': {
-        handler(newVal) {
-            var curDate = new Date(newVal);
-            console.log('curDate',curDate);
-            /* 获取当前月份 */
-            var curMonth = curDate.getMonth();
-            /*  生成实际的月份: 由于curMonth会比实际月份小1, 故需加1 */
-            curDate.setMonth(curMonth + 1);
-            /* 将日期设置为0, 这里为什么要这样设置, 我不知道原因, 这是从网上学来的 */
-            curDate.setDate(0);
-            /* 返回当月的天数 */
-            this.numDay = curDate.getDate();
-        },
-        immediate:true,
+    'form.month': {
+      handler(newVal) {
+          console.log('newVal',newVal);
+          let arr = newVal.split('-');
+          console.log('arr.[1]',arr[1]);
+          this.numDay = this.getDays(arr[0],arr[1]);
+          console.log('this.numDay',this.numDay);
+      },
+      immediate:true,
     }
     }
   },
   },
   computed: {
   computed: {
@@ -750,11 +744,8 @@ export default {
   async created() {
   async created() {
     switch (this.openMode) {
     switch (this.openMode) {
       case "add":
       case "add":
-        var now = new Date(); // 当前日期
-        var nowYear = now.getFullYear(); //当前年
-        var nowMonth = now.getMonth() ;
-        this.form.month = new Date(nowYear,nowMonth,1,"00","00");
-        // this.form.createTime = new Date();
+        this.form.createTime = this.getCurrentTime();
+        this.form.month = this.getCurrentMonth();
         this.form.createByName = this.$store.state.user.nickName;
         this.form.createByName = this.$store.state.user.nickName;
         this.form.dept = this.$store.state.user.deptId;
         this.form.dept = this.$store.state.user.deptId;
         this.form.deptName = this.$store.state.user.deptName;
         this.form.deptName = this.$store.state.user.deptName;
@@ -855,19 +846,36 @@ export default {
       this.$parent.useOpenDetail();
       this.$parent.useOpenDetail();
       this.$parent.useSearch();
       this.$parent.useSearch();
     },
     },
-    //获取当月天数
-    getCountDays(val) {
-        console.log('val',val);
-        var curDate = new Date(val);
-        console.log('curDate',curDate);
-        /* 获取当前月份 */
-        var curMonth = curDate.getMonth();
-        /*  生成实际的月份: 由于curMonth会比实际月份小1, 故需加1 */
-        curDate.setMonth(curMonth + 1);
-        /* 将日期设置为0, 这里为什么要这样设置, 我不知道原因, 这是从网上学来的 */
-        curDate.setDate(0);
-        /* 返回当月的天数 */
-        return curDate.getDate();
+    //获取当月
+    getCurrentMonth () {
+      const date = new Date()
+      let year = date.getFullYear()
+      let month = date.getMonth() + 1
+      month = month > 9 ? month : '0' + month
+      return `${year}-${month}`
+    },
+    getDays(year, month){
+      return new Date(year, month, 0).getDate()
+    },
+    getCurrentTime() {
+      var date = new Date();//当前时间
+      var year = date.getFullYear() //年
+      var month = this.repair(date.getMonth() + 1);//月
+      var day = this.repair(date.getDate());//日
+      var hour = this.repair(date.getHours());//时
+      var minute = this.repair(date.getMinutes());//分
+      var second = this.repair(date.getSeconds());//秒
+      //当前时间 
+      var curTime = year + "-" + month + "-" + day
+              + " " + hour + ":" + minute + ":" + second;
+      return curTime;
+    },
+    repair(i){
+      if (i >= 0 && i <= 9) {
+          return "0" + i;
+      } else {
+          return i;
+      }
     }
     }
   },
   },
 };
 };

+ 2 - 5
src/views/business/spd/fillin/dailysale_quantity_assess/index.vue

@@ -61,11 +61,7 @@
           <el-table-column label="序号" type="index" width="50" align="center" fixed/>
           <el-table-column label="序号" type="index" width="50" align="center" fixed/>
           <el-table-column show-overflow-tooltip label="编码" align="center" width="200" prop="code"/>
           <el-table-column show-overflow-tooltip label="编码" align="center" width="200" prop="code"/>
           <el-table-column show-overflow-tooltip label="客户名称" align="center" width="200" prop="customerName"/>
           <el-table-column show-overflow-tooltip label="客户名称" align="center" width="200" prop="customerName"/>
-          <el-table-column show-overflow-tooltip label="月度" align="center" width="200" prop="month">
-            <template slot-scope="scope">
-              {{scope.row.month.substring(0,7)}}
-            </template>
-          </el-table-column>
+          <el-table-column show-overflow-tooltip label="月度" align="center" width="200" prop="month"/>
           <el-table-column show-overflow-tooltip label="部门" align="center" width="200" prop="deptName"/>
           <el-table-column show-overflow-tooltip label="部门" align="center" width="200" prop="deptName"/>
           <el-table-column show-overflow-tooltip label="创建人" align="center" width="200" prop="createByName" />
           <el-table-column show-overflow-tooltip label="创建人" align="center" width="200" prop="createByName" />
           <el-table-column show-overflow-tooltip label="创建时间" align="center" width="200" prop="createTime" />
           <el-table-column show-overflow-tooltip label="创建时间" align="center" width="200" prop="createTime" />
@@ -157,6 +153,7 @@ export default {
     },
     },
     //查询列表
     //查询列表
     getList(params){
     getList(params){
+      console.log('params',params);
       listAssess(params).then(res => {
       listAssess(params).then(res => {
         if (res.code === 200) {
         if (res.code === 200) {
           this.tableList = res.rows
           this.tableList = res.rows