Переглянути джерело

Merge branch 'deploy' of jianguan-web/jg-ocs-html into master

陈瑞 4 роки тому
батько
коміт
3c87695e43

+ 30 - 0
src/libs/getDate.js

@@ -16,6 +16,16 @@ export default {
     obj.endtime = moment(moment().valueOf()).format('YYYY-MM-DD')
     return obj
   },
+  // 获取今日的开始结束时间  年月日时分秒
+  getTodayTime () {
+    const obj = {
+      starttime: '',
+      endtime: ''
+    }
+    obj.starttime = moment(moment().startOf('day').valueOf()).format('YYYY-MM-DD HH:mm:ss')
+    obj.endtime = moment(moment().valueOf()).format('YYYY-MM-DD HH:mm:ss')
+    return obj
+  },
   //  近7天
   getRecentday () {
     const obj = {
@@ -26,6 +36,26 @@ export default {
     obj.endtime = moment(moment().valueOf()).format('YYYY-MM-DD')
     return obj
   },
+  //  近7天  年月日时分秒
+  getRecentTime () {
+    const obj = {
+      starttime: '',
+      endtime: ''
+    }
+    obj.starttime = moment().subtract('days', 6).format('YYYY-MM-DD HH:mm:ss')
+    obj.endtime = moment(moment().valueOf()).format('YYYY-MM-DD HH:mm:ss')
+    return obj
+  },
+  //  近3天
+  getThreeday () {
+    const obj = {
+      starttime: '',
+      endtime: ''
+    }
+    obj.starttime = moment().subtract('days', 2).format('YYYY-MM-DD')
+    obj.endtime = moment(moment().valueOf()).format('YYYY-MM-DD')
+    return obj
+  },
   // 获取昨日的开始结束时间
   getYesterday () {
     const obj = {

+ 62 - 0
src/views/common/rangeDateTime.vue

@@ -0,0 +1,62 @@
+<template>
+  <a-range-picker
+    style="width:100%"
+    :value="date"
+    show-time
+    :disabledDate="disabledDate"
+    :format="dateFormat"
+    @change="dateChange"
+    @calendarChange="dateCalendarChange"
+    :placeholder="['开始时间', '结束时间']" />
+</template>
+<script>
+import moment from 'moment'
+export default {
+  props: {
+    value: {
+      type: Array,
+      default: () => {
+        return []
+      }
+    }
+  },
+  data () {
+    return {
+      date: this.value,
+      dateFormat: 'YYYY-MM-DD HH:mm:ss',
+      selectPriceDate: ''
+    }
+  },
+  methods: {
+    // 不可选日期
+    disabledDate (current) {
+      //  最早可倒推选择两年数据,最晚为今天
+      const minYearVs = moment().subtract(2, 'years') //  两年前   负值
+      const maxYearVs = moment().endOf('day') //  今天,包含今天
+      //  限制最多只能查一年区间的数据
+      if (this.selectPriceDate) {
+        const oMinYearVs = moment(this.selectPriceDate, 'YYYY-MM-DD HH:mm:ss').subtract(1, 'years') //  当前选中开始日期前推一年
+        const oMaxYearVs = moment(this.selectPriceDate, 'YYYY-MM-DD HH:mm:ss').add(1, 'years') //  当前选中开始日期后推一年
+        // 判断两个时间段是否相差m天  第二个参数指相差单位,第三个参数指是否返回浮点形式(小数)
+        const beginDate = minYearVs.diff(oMinYearVs, 'days') > 0 ? minYearVs : oMinYearVs // 若当前选中开始日期前推一年超出最多倒推两年数据时,则以两年为标准
+        const endDate = maxYearVs.diff(oMaxYearVs, 'days') > 0 ? oMaxYearVs : maxYearVs // 若当前选中开始日期后推一年超出今天时,则以今天为标准
+        return current && current < beginDate || current && current > endDate
+      } else {
+        return current && current > maxYearVs || current && current < minYearVs
+      }
+    },
+    // 日期  change
+    dateChange (date, dateStrings) {
+      this.selectPriceDate = ''
+      this.date = date
+      this.$emit('change', dateStrings)
+    },
+    dateCalendarChange (date, dateStrings) {
+      this.selectPriceDate = date[0]
+    },
+    resetDate (val) {
+      this.date = val || []
+    }
+  }
+}
+</script>

+ 63 - 75
src/views/power/OperateJournal/OperateJournal.vue

@@ -3,25 +3,33 @@
     <div class="operateJournal">
       <!-- 搜索框 -->
       <div class="table-page-search-wrapper">
-        <a-form layout="inline">
-          <a-row :gutter="48">
-            <a-col :md="8" :sm="24">
+        <a-form layout="inline" @keyup.enter.native="$refs.table.refresh(true)">
+          <a-row :gutter="15">
+            <a-col :md="6" :sm="24">
               <a-form-item label="操作时间">
-                <a-range-picker :format="dateFormat" show-time :placeholder="['开始时间', '结束时间']" v-model="time" @change="onChange" />
+                <rangeDate ref="rangeDate" :value="time" @change="dateChange" />
               </a-form-item>
             </a-col>
             <a-col :md="6" :sm="24">
-              <a-form-item label="操作人"><a-input allowClear v-model.trim="searchData.queryWord" placeholder="请输入" /></a-form-item>
+              <a-form-item label="操作信息">
+                <a-input allowClear v-model.trim="queryParam.actDesc" placeholder="请输入操作信息" />
+              </a-form-item>
             </a-col>
             <a-col :md="6" :sm="24">
-              <a-button style="margin-right: 10px;" type="primary" @click="$refs.table.refresh(true)">查询</a-button>
-              <a-button type="" @click="resetForm">重置</a-button>
+              <a-form-item label="操作人">
+                <a-input allowClear v-model.trim="queryParam.actorName" placeholder="请输入操作人" />
+              </a-form-item>
+            </a-col>
+            <a-col :md="6" :sm="24">
+              <a-button type="primary" @click="$refs.table.refresh(true)" :disabled="disabled" id="operateJournal-refresh">查询</a-button>
+              <a-button style="margin-left: 5px" @click="resetSearchForm" :disabled="disabled" id="operateJournal-reset">重置</a-button>
             </a-col>
           </a-row>
         </a-form>
       </div>
       <!-- 列表 -->
       <s-table
+        class="sTable"
         ref="table"
         size="default"
         rowKey="id"
@@ -36,95 +44,75 @@
 </template>
 
 <script>
+import moment from 'moment'
+import getDate from '@/libs/getDate'
 import { STable } from '@/components'
 import { journalList } from '@/api/OperateJournal.js'
-import getDate from '@/libs/getDate'
-import moment from 'moment'
+import rangeDate from '@/views/common/rangeDate.vue'
 export default {
   name: 'OperateJournal',
-  components: { STable },
+  components: { STable, rangeDate },
   data () {
     return {
-      // 列表
-      form: this.$form.createForm(this, {
-        name: 'OperateJournal'
-      }),
-      time: [moment(getDate.getToday().starttime, this.dateFormat), moment(getDate.getToday().endtime, this.dateFormat)],
-      searchData: {
-        beginDate: null, // 查询的开始时间
-        endDate: null, // 查询的结束时间
-        queryWord: '' // 操作人
+      advanced: false, // 高级搜索 展开/关闭
+      disabled: false, //  查询、重置按钮是否可操作
+      time: [
+        moment(getDate.getThreeday().starttime, this.dateFormat),
+        moment(getDate.getThreeday().endtime, this.dateFormat)
+      ],
+      queryParam: {
+        beginDate: getDate.getThreeday().starttime, // 查询的开始时间
+        endDate: getDate.getThreeday().endtime, // 查询的结束时间
+        actDesc: '',
+        actorName: ''
       },
-      dateFormat: 'YYYY-MM-DD HH:mm:ss',
+      dateFormat: 'YYYY-MM-DD',
       columns: [
-        {
-          title: '序号',
-          dataIndex: 'no',
-          minWidth: '40',
-          align: 'center'
-        },
-        {
-          title: '操作人',
-          dataIndex: 'actorName',
-          minWidth: '100',
-          align: 'center',
-          scopedSlots: { customRender: 'actorName' }
-        },
-        {
-          title: 'IP',
-          dataIndex: 'ip',
-          minWidth: '100',
-          align: 'center'
-        },
-        {
-          title: '日志明细',
-          dataIndex: 'actDesc',
-          minWidth: '100',
-          align: 'center',
-          scopedSlots: { customRender: 'actDesc' }
-        }
+        { title: '序号', dataIndex: 'no', width: 80, align: 'center', fixed: 'left' },
+        { title: '操作时间', dataIndex: 'actDate', width: 160, align: 'center', customRender: function (text) { return text || '--' } },
+        { title: 'IP', dataIndex: 'ip', width: 200, align: 'center', customRender: function (text) { return text || '--' } },
+        { title: '操作人', dataIndex: 'actorName', align: 'center', customRender: function (text) { return text || '--' }, ellipsis: true },
+        { title: '操作信息', dataIndex: 'actDesc', align: 'left', customRender: function (text) { return text || '--' }, ellipsis: true }
       ],
       // 加载数据方法 必须为 Promise 对象
       loadData: parameter => {
-        this.searchData.beginDate == null ? (this.searchData.beginDate = getDate.getToday().starttime) : null
-        this.searchData.endDate == null ? (this.searchData.endDate = getDate.getToday().endtime) : null
-        return journalList(Object.assign(parameter, this.searchData)).then(res => {
-          const no = (res.data.data.pageNo - 1) * res.data.data.pageSize
-          for (let i = 0; i < res.data.data.list.length; i++) {
-            const _item = res.data.data.list[i]
-            _item.no = no + i + 1
+        this.disabled = true
+        this.queryParam.beginDate = this.queryParam.beginDate + ' 00:00:00'
+        this.queryParam.endDate = this.queryParam.endDate + ' 23:59:59'
+        return journalList(Object.assign(parameter, this.queryParam)).then(res => {
+          const data = res.data
+          const no = (data.pageNo - 1) * data.pageSize
+          for (var i = 0; i < data.list.length; i++) {
+            data.list[i].no = no + i + 1
           }
-          return res.data.data
+          this.disabled = false
+          return data
         })
       }
     }
   },
   methods: {
-    moment,
-    // 操作时间change
-    onChange (dates, dateStrings) {
-      this.searchData.beginDate = dateStrings[0]
-      this.searchData.endDate = dateStrings[1]
+    //  时间  change
+    dateChange (date) {
+      this.queryParam.beginDate = date[0]
+      this.queryParam.endDate = date[1]
     },
     // 重置
-    resetForm () {
-      this.searchData.beginDate = getDate.getToday().starttime
-      this.searchData.endDate = getDate.getToday().endtime
-      this.time = [moment(getDate.getToday().starttime, this.dateFormat), moment(getDate.getToday().endtime, this.dateFormat)]
-      this.searchData.queryWord = ''
+    resetSearchForm () {
+      this.$refs.rangeDate.resetDate(this.time)
+      this.queryParam.beginDate = getDate.getThreeday().starttime
+      this.queryParam.endDate = getDate.getThreeday().endtime
+      this.queryParam.actDesc = ''
+      this.queryParam.actorName = ''
       this.$refs.table.refresh(true)
     }
   }
-  // beforeRouteEnter (to, from, next) {
-  //   next(vm => {
-  //     // const todayDate= [getDate.getToday().starttime, getDate.getToday().endtime]
-  // 	// console.log(todayDate)
-  // 	// vm.searchData.beginDate = getDate.getToday().starttime
-  // 	// vm.searchData.endDate = getDate.getToday().endtime
-  // 	// console.log(vm.searchData.beginDate, '--------------',  vm.searchData.endDate )
-  //   })
-  // }
 }
 </script>
-
-<style></style>
+<style lang="less">
+  .operateJournal{
+    .sTable{
+      margin-top: 10px;
+    }
+  }
+</style>

+ 57 - 32
src/views/salesManagement/salesReturn/chooseCustomModal.vue

@@ -5,7 +5,7 @@
     centered
     :maskClosable="false"
     :confirmLoading="confirmLoading"
-    width="80%"
+    :width="960"
     :footer="null"
     @cancel="cancel"
   >
@@ -21,7 +21,19 @@
         <a-row :gutter="15">
           <a-col :span="8">
             <a-form-model-item label="客户名称" required>
-              <custList id="chooseCustom-dealerName" ref="custList" @dealerDetail="dealerDetail" @change="custChange"></custList>
+              <a-select
+                show-search
+                id="chooseCustom-buyerSn"
+                v-model="form.buyerSn"
+                placeholder="请选择"
+                :filter-option="false"
+                :not-found-content="fetching ? undefined : null"
+                @search="fetchUser"
+                @change="handleChange"
+              >
+                <a-spin v-if="fetching" slot="notFoundContent" size="small" />
+                <a-select-option v-for="item in dealerData" :key="item.dealerSn" :value="item.dealerSn">{{ item.dealerName }}</a-select-option>
+              </a-select>
             </a-form-model-item>
           </a-col>
         </a-row>
@@ -38,7 +50,7 @@
           </a-col>
           <a-col :span="10">
             <a-form-model-item label="客户地址">
-              <p style="line-height: 1.5em;margin: 0;">{{ form.provinceName }}{{ form.cityName }}{{ form.countyName }}{{ form.customerAddr }}</p>
+              {{ form.provinceName }}{{ form.cityName }}{{ form.countyName }}{{ form.customerAddr }}
             </a-form-model-item>
           </a-col>
         </a-row>
@@ -62,12 +74,12 @@
 </template>
 
 <script>
-import { salesReturnInsert } from '@/api/salesReturn'
 import { VSelect } from '@/components'
-import custList from '@/views/common/custList.vue'
+import { dealerSubareaScopeList, dealerFindUpdateInfoBySn } from '@/api/dealer'
+import { salesReturnInsert } from '@/api/salesReturn'
 export default {
   name: 'ChooseCustomModal',
-  components: { VSelect, custList },
+  components: { VSelect },
   props: {
     show: [Boolean]
   },
@@ -96,35 +108,49 @@ export default {
         customerAddr: '', //  详细地址
         grabFlag: '1' // 是否抓单
       },
-      rules: {}
+      rules: {},
+      fetching: false,
+      dealerData: []
     }
   },
   methods: {
-    custChange (val) {
-      this.form.buyerSn = val.key
-      this.$refs.custList.getDetail(val.key)
+    // 搜索经销商
+    fetchUser (value) {
+      console.log('fetching user', value)
+      this.fetching = true
+      dealerSubareaScopeList({ nameLike: value, pageNo: 1, pageSize: 20 }).then(res => {
+        if (res.status == 200) {
+          this.dealerData = res.data.list
+          this.fetching = false
+        } else {
+          this.dealerData = []
+          this.fetching = false
+        }
+      })
     },
-    //  获取详情
-    dealerDetail (data) {
-      console.log(data)
-      if (data) {
-        this.form = Object.assign(this.form, {
-          buyerName: data.dealerName, // 客户名称
-          buyerSn: data.dealerSn, // 客户sn
-          contactTel: data.contactMobile, //  联系电话
-          contactName: data.contact, //  联系人
-          provinceSn: data.provinceSn, //  省
-          provinceName: data.provinceName,
-          citySn: data.citySn, // 市
-          cityName: data.cityName,
-          countySn: data.districtSn, // 区
-          countyName: data.districtName,
-          customerAddr: data.address //  详细地址
-        })
-      } else {
-        this.$message.error('获取客户信息失败')
-        this.$refs.ruleForm.resetFields()
-      }
+    // 客户  change
+    handleChange (value) {
+      dealerFindUpdateInfoBySn({ sn: this.form.buyerSn }).then(res => {
+        if (res.data) {
+          const data = res.data
+          this.form = Object.assign(this.form, {
+            buyerName: data.dealerName, // 客户名称
+            buyerSn: data.dealerSn, // 客户sn
+            contactTel: data.contactMobile, //  联系电话
+            contactName: data.contact, //  联系人
+            provinceSn: data.provinceSn, //  省
+            provinceName: data.provinceName,
+            citySn: data.citySn, // 市
+            cityName: data.cityName,
+            countySn: data.districtSn, // 区
+            countyName: data.districtName,
+            customerAddr: data.address //  详细地址
+          })
+        } else {
+          this.$message.error('获取客户信息失败')
+          this.$refs.ruleForm.resetFields()
+        }
+      })
     },
     //  保存
     handleSubmit (e) {
@@ -178,7 +204,6 @@ export default {
         customerAddr: '', //  详细地址
         grabFlag: '1' // 是否抓单
       }
-      this.$refs.custList.resetForm()
       this.$emit('cancel')
     }
   },