Browse Source

新增调拨单 添加“起止时间”字段

chenrui 3 years ago
parent
commit
534ac30e91
1 changed files with 40 additions and 1 deletions
  1. 40 1
      src/views/allocationManagement/transferOut/basicInfoModal.vue

+ 40 - 1
src/views/allocationManagement/transferOut/basicInfoModal.vue

@@ -44,6 +44,17 @@
             <a-select-option v-for="item in allocateTypeList" :key="item.allocateTypeSn" :value="item.allocateTypeSn">{{ item.name }}</a-select-option>
           </a-select>
         </a-form-model-item>
+        <a-form-model-item label="起止时间" prop="time">
+          <a-range-picker
+            style="width:100%"
+            v-model="form.time"
+            show-time
+            :disabledDate="disabledDate"
+            :format="dateFormat"
+            @change="dateChange"
+            @calendarChange="dateCalendarChange"
+            :placeholder="['开始时间', '结束时间']" />
+        </a-form-model-item>
         <a-form-model-item label="备注" prop="remark">
           <a-textarea id="allocateBill-basicInfo-remark" :maxLength="120" v-model="form.remark" placeholder="请输入备注(最多120个字符)" allowClear />
         </a-form-model-item>
@@ -57,6 +68,7 @@
 </template>
 
 <script>
+import moment from 'moment'
 import debounce from 'lodash/debounce'
 import { VSelect } from '@/components'
 import { allocateBillSave } from '@/api/allocateBill'
@@ -87,6 +99,9 @@ export default {
         targetSn: undefined,
         targetName: '',
         allocateTypeSn: undefined,
+        time: [],
+        promoStartDate: '',
+        promoEndDate: '',
         remark: ''
       },
       rules: {
@@ -98,7 +113,9 @@ export default {
       fetching: false,
       dealerData: [], //  经销商  下拉数据
       targetTypeList: [], //  调往对象类型
-      allocateTypeList: [] //  调拨类型
+      allocateTypeList: [], //  调拨类型
+      dateFormat: 'YYYY-MM-DD HH:mm:ss',
+      selectPriceDate: ''
     }
   },
   computed: {
@@ -108,6 +125,28 @@ export default {
     }
   },
   methods: {
+	  // 不可选日期
+	  disabledDate (current) {
+      // 可选今天以后的时间(包含今天),所选时间跨度最多可为一年
+      const minYearVs = moment().subtract(1, 'day') // 今天以后,包含今天
+	    // //  限制最多只能查一年区间的数据
+	    if (this.selectPriceDate) {
+        const maxYearVs = moment(this.selectPriceDate, 'YYYY-MM-DD HH:mm:ss').add(1, 'years') //  当前选中开始日期后推一年
+        return current && current < minYearVs || current && current > maxYearVs
+      } else {
+        return current && current < minYearVs
+	    }
+	  },
+    // 日期  change
+    dateChange (date, dateStrings) {
+      this.selectPriceDate = ''
+      this.form.time = dateStrings
+      this.form.promoStartDate = dateStrings[0] || ''
+      this.form.promoEndDate = dateStrings[1] || ''
+    },
+    dateCalendarChange (date, dateStrings) {
+      this.selectPriceDate = date[0]
+    },
     // 搜索经销商
     fetchUser (value) {
       console.log('fetching user', value)