|
|
@@ -52,6 +52,18 @@
|
|
|
@keyup.enter.native="handleQuery"
|
|
|
/>
|
|
|
</el-form-item>
|
|
|
+ <el-form-item label="创建时间" prop="createTimeText">
|
|
|
+ <el-date-picker
|
|
|
+ v-model="createTimeText"
|
|
|
+ type="datetimerange"
|
|
|
+ range-separator="至"
|
|
|
+ start-placeholder="开始日期"
|
|
|
+ end-placeholder="结束日期"
|
|
|
+ value-format="yyyy-MM-dd HH:mm:ss"
|
|
|
+ @change="createChange"
|
|
|
+ :default-time="['00:00:00', '23:59:59']"
|
|
|
+ />
|
|
|
+ </el-form-item>
|
|
|
<el-form-item>
|
|
|
<el-button type="cyan" icon="el-icon-search" size="mini" @click="handleQuery">搜索</el-button>
|
|
|
<el-button icon="el-icon-refresh" size="mini" @click="resetQuery">重置</el-button>
|
|
|
@@ -153,6 +165,7 @@ export default {
|
|
|
name: "CustomerTransfer",
|
|
|
data() {
|
|
|
return {
|
|
|
+ createTimeText: '',
|
|
|
loading: true,
|
|
|
ids: [],
|
|
|
single: true,
|
|
|
@@ -175,6 +188,8 @@ export default {
|
|
|
pageSize: 10,
|
|
|
salesName: null,
|
|
|
phoneNumber: null,
|
|
|
+ sTime:null,
|
|
|
+ eTime:null,
|
|
|
},
|
|
|
projectOptions: [],
|
|
|
selectedUser: [],
|
|
|
@@ -194,6 +209,66 @@ export default {
|
|
|
},
|
|
|
methods: {
|
|
|
parseTime,
|
|
|
+ formatDate(date) {
|
|
|
+ if (!date) return ''
|
|
|
+
|
|
|
+ // 确保 date 是 Date 对象
|
|
|
+ let dateObj = date
|
|
|
+ if (typeof date === 'string') {
|
|
|
+ dateObj = new Date(date)
|
|
|
+ }
|
|
|
+
|
|
|
+ // 如果转换失败,返回空字符串
|
|
|
+ if (!(dateObj instanceof Date) || isNaN(dateObj.getTime())) {
|
|
|
+ return ''
|
|
|
+ }
|
|
|
+
|
|
|
+ // 使用更安全的格式化方法
|
|
|
+ const year = dateObj.getFullYear()
|
|
|
+ const month = String(dateObj.getMonth() + 1).padStart(2, '0')
|
|
|
+ const day = String(dateObj.getDate()).padStart(2, '0')
|
|
|
+ const hours = String(dateObj.getHours()).padStart(2, '0')
|
|
|
+ const minutes = String(dateObj.getMinutes()).padStart(2, '0')
|
|
|
+ const seconds = String(dateObj.getSeconds()).padStart(2, '0')
|
|
|
+
|
|
|
+ return `${year}-${month}-${day} ${hours}:${minutes}:${seconds}`
|
|
|
+ },
|
|
|
+ createChange(createTime) {
|
|
|
+ if (createTime && createTime.length >= 2) {
|
|
|
+ if(!this.checkDateRangeLimit(createTime)){
|
|
|
+ this.createTimeText = null;
|
|
|
+ this.queryParams.sTime=null;
|
|
|
+ this.queryParams.eTime=null;
|
|
|
+ return;
|
|
|
+ }
|
|
|
+ // this.createTimeText = this.formatDateRange(createTime);
|
|
|
+ this.queryParams.sTime = this.formatDate(createTime[0]) || null;
|
|
|
+ this.queryParams.eTime = this.formatDate(createTime[1]) || null;
|
|
|
+ } else {
|
|
|
+ this.createTimeText = '';
|
|
|
+ this.queryParams.sTime = null;
|
|
|
+ this.queryParams.eTime = null;
|
|
|
+ }
|
|
|
+ },
|
|
|
+ checkDateRangeLimit(dateRange) {
|
|
|
+ if (dateRange && dateRange.length >= 2) {
|
|
|
+ const startDate = new Date(dateRange[0]);
|
|
|
+ const endDate = new Date(dateRange[1]);
|
|
|
+
|
|
|
+ // 设置时间为当天开始,避免时间部分影响计算
|
|
|
+ startDate.setHours(0, 0, 0, 0);
|
|
|
+ endDate.setHours(0, 0, 0, 0);
|
|
|
+
|
|
|
+ const timeDiff = Math.abs(endDate - startDate);
|
|
|
+ const diffDays = Math.ceil(timeDiff / (1000 * 60 * 60 * 24));
|
|
|
+
|
|
|
+ if (diffDays > 31) { // maxDays-1 因为包含起始日
|
|
|
+ this.$message.warning('时间区间不能超过一个月');
|
|
|
+ return false;
|
|
|
+ }
|
|
|
+ }
|
|
|
+ return true;
|
|
|
+ },
|
|
|
/** 查询客户列表 */
|
|
|
getList() {
|
|
|
this.loading = true;
|
|
|
@@ -225,6 +300,9 @@ export default {
|
|
|
/** 重置按钮操作 */
|
|
|
resetQuery() {
|
|
|
this.resetForm("queryForm");
|
|
|
+ this.createTimeText = '';
|
|
|
+ this.queryParams.sTime = null;
|
|
|
+ this.queryParams.eTime = null;
|
|
|
this.handleQuery();
|
|
|
},
|
|
|
// 多选框选中数据
|