ソースを参照

测试问题修改

ysc 2 年 前
コミット
d93f2dd567
2 ファイル変更29 行追加9 行削除
  1. 6 0
      src/utils/date.js
  2. 23 9
      src/views/material/receive.vue

+ 6 - 0
src/utils/date.js

@@ -88,5 +88,11 @@ export default {
   },
   getMonthDays(date) {
     return moment(date).daysInMonth();
+  },
+  afterWeek(date, num = 1) {
+    if (date) {
+      return moment(date).add(num, 'weeks').format(DATE_FORMAT)
+    }
+    return moment().add(num, 'weeks').format(DATE_FORMAT)
   }
 }

+ 23 - 9
src/views/material/receive.vue

@@ -85,7 +85,7 @@
         </template>
       </el-table-column>
       <el-table-column label="领用人" prop="receiveUserName"/>
-      <el-table-column label="周期" prop="recordDate" width="150"/>
+      <el-table-column label="周期" prop="recordDate" width="155"/>
       <el-table-column label="操作" align="center" width="200">
         <template slot-scope="scope">
           <el-button
@@ -131,7 +131,7 @@
     </div>
 
     <!-- 添加或修改物料配置对话框 -->
-    <el-dialog :title="title" :visible.sync="open" width="500px" append-to-body>
+    <el-dialog :title="title" :visible.sync="open" @close="dialogClose" width="500px" append-to-body>
       <el-form ref="form" :model="form" :rules="rules" label-width="100px">
         <el-form-item label="数据周期">
           <div v-if="form.monthOrWeek==='1'">
@@ -140,7 +140,7 @@
               type="month"
               value-format="yyyy-MM"
               placeholder="选择月份"
-              :picker-options="{ disabledDate: time => time.getTime() < Date.now() }"
+              :picker-options="getPickerOptions('month')"
               clearable>
             </el-date-picker>
           </div>
@@ -150,7 +150,7 @@
               type="week"
               format="yyyy 第 WW 周"
               placeholder="选择周"
-              :picker-options="{ disabledDate: time => time.getTime() < Date.now() }"
+              :picker-options="getPickerOptions('week')"
               clearable>
             </el-date-picker>
           </div>
@@ -272,9 +272,9 @@ export default {
       this.open = false;
       this.reset();
     },
-    // 取消按钮(数据权限)
-    cancelDataScope() {
-      this.openDataScope = false;
+    // 对话框关闭回调
+    dialogClose() {
+      this.open = false;
       this.reset();
     },
     // 表单重置
@@ -312,6 +312,18 @@ export default {
       this.pageNum = val;
       this.getList();
     },
+    getPickerOptions(type) {
+      if (type === 'month') {
+        return {
+          disabledDate: time => time.getTime() < DateUtil.unix(DateUtil.afterMonth()) * 1000
+        }
+      }
+      if (type === 'week') {
+        return {
+          disabledDate: time => time.getTime() < DateUtil.unix(DateUtil.afterWeek()) * 1000
+        }
+      }
+    },
     /** 新增按钮操作 */
     handleAdd() {
       this.reset();
@@ -324,7 +336,7 @@ export default {
     },
     /** 周数据填报操作 */
     handleSplit(row) {
-      this.form = row;
+      this.form = _.cloneDeep(row);
       this.form.parentId = row.id;
       this.form.id = undefined;
       this.form.num = undefined;
@@ -338,12 +350,14 @@ export default {
       this.reset();
       getMaterial(row.id).then(res => {
         this.form = res.data;
+        if (this.form.monthOrWeek === '2') {
+          this.form.recordDate = this.form.recordDate.split("~")[0]
+        }
         this.open = true;
         this.title = "修改物料计划";
       });
     },
 
-
     /** 提交按钮 */
     submitForm() {
       this.$refs["form"].validate(valid => {