Commit ee1b64c3 authored by Facius's avatar Facius

feat: 记工多选日期

parent 86433421
Pipeline #5486 canceled with stages
...@@ -3,6 +3,7 @@ ...@@ -3,6 +3,7 @@
<view class="calendar-popup"> <view class="calendar-popup">
<view class="calendar-popup-top"> <view class="calendar-popup-top">
<text class="calendar-popup-top-left" @click="close">取消</text> <text class="calendar-popup-top-left" @click="close">取消</text>
<text class="calendar-popup-top-middle" v-if="isDateRange">选择日期(已选{{ this.defaultDate.length}}天)</text>
<text class="calendar-popup-top-right" @click="confirm">确定</text> <text class="calendar-popup-top-right" @click="confirm">确定</text>
</view> </view>
<lunc-calendar <lunc-calendar
...@@ -12,6 +13,7 @@ ...@@ -12,6 +13,7 @@
:shouChangeBtn="true" :shouChangeBtn="true"
firstDayOfWeek="sunday" firstDayOfWeek="sunday"
:weekend="true" :weekend="true"
:type="type"
@dayChange="dayChange" @dayChange="dayChange"
></lunc-calendar> ></lunc-calendar>
</view> </view>
...@@ -28,14 +30,24 @@ export default { ...@@ -28,14 +30,24 @@ export default {
default: () => { default: () => {
return parseTime(new Date(), '{y}-{m}-{d}'); return parseTime(new Date(), '{y}-{m}-{d}');
} }
},
// date 单选;daterange 多选
type: {
type: String,
default : 'date'
} }
}, },
data() { data() {
return { return {
show: false, show: false,
defaultDate: parseTime(new Date(), '{y}-{m}-{d}') defaultDate: [parseTime(new Date(), '{y}-{m}-{d}')],
}; };
}, },
computed: {
isDateRange() {
return this.type == 'daterange'
}
},
mounted() { mounted() {
// this.defaultDate=this.date // this.defaultDate=this.date
// this.$refs['lunc-calendar'].init(this.date); // this.$refs['lunc-calendar'].init(this.date);
...@@ -51,12 +63,20 @@ export default { ...@@ -51,12 +63,20 @@ export default {
this.show = false; this.show = false;
}, },
confirm() { confirm() {
this.$emit('confirm', this.defaultDate); this.$emit('confirm', this.isDateRange ? this.defaultDate : this.defaultDate[0]);
this.close(); this.close();
}, },
dayChange(e) { dayChange(e) {
console.log('dayChange', e); console.log('dayChange', e);
this.defaultDate = e.date; if (this.isDateRange) {
var array = []
for (var item of e) {
array.push(item.date)
}
this.defaultDate = array;
} else {
this.defaultDate = [e.date];
}
} }
} }
}; };
...@@ -73,11 +93,19 @@ export default { ...@@ -73,11 +93,19 @@ export default {
justify-content: space-between; justify-content: space-between;
&-left { &-left {
color: rgb(96, 98, 102); color: rgb(96, 98, 102);
flex-shrink: 0;
}
&-middle {
flex: 1;
color: #333333;
font-weight: bold;
text-align: center;
} }
&-right { &-right {
color: rgb(41, 121, 255); color: rgb(41, 121, 255);
&:active { &:active {
opacity: 0.7; opacity: 0.7;
flex-shrink: 0;
} }
} }
} }
......
...@@ -12,7 +12,7 @@ ...@@ -12,7 +12,7 @@
</view> </view>
</view> </view>
</u-form-item> </u-form-item>
<u-form-item label="日期" prop="happenTime" required> <u-form-item label="日期" v-if="!isDateRange" prop="happenTime" required>
<view class="right-view"> <view class="right-view">
<view class="date-view" hover-class="u-hover-class" @click="handleClickShowDateRange"> <view class="date-view" hover-class="u-hover-class" @click="handleClickShowDateRange">
<view class="date-text" v-if="form.happenTime">{{ resetHappenTime(form.happenTime) }}</view> <view class="date-text" v-if="form.happenTime">{{ resetHappenTime(form.happenTime) }}</view>
...@@ -21,7 +21,15 @@ ...@@ -21,7 +21,15 @@
</view> </view>
</view> </view>
</u-form-item> </u-form-item>
<u-form-item label="日期(可多选)" v-else prop="dateRange" required>
<view class="right-view">
<view class="date-view" hover-class="u-hover-class" @click="handleClickShowDateRange">
<view class="date-text" v-if="form.dateRange.length">{{ form.dateRange.length > 1 ? `已选${form.dateRange.length}天` : resetHappenTime(form.dateRange[0]) }}</view>
<view class="placeholder" v-else>选择服务日期</view>
<view class="image-view"><image :src="dateImage"></image></view>
</view>
</view>
</u-form-item>
<u-form-item label="成员" :border-bottom="false" prop="memberId" required> <u-form-item label="成员" :border-bottom="false" prop="memberId" required>
<view class="right-view" v-if="recordId"> <view class="right-view" v-if="recordId">
<text class="placeholder">{{ form.memberName }}</text> <text class="placeholder">{{ form.memberName }}</text>
...@@ -242,7 +250,7 @@ ...@@ -242,7 +250,7 @@
<view class="loading-view" v-if="loading"><u-loading mode="flower"></u-loading></view> <view class="loading-view" v-if="loading"><u-loading mode="flower"></u-loading></view>
<u-toast ref="uToast" /> <u-toast ref="uToast" />
<!-- 日历 --> <!-- 日历 -->
<calendar-popup :date="form.happenTime" ref="calendar-popup" @confirm="calendarChange"></calendar-popup> <calendar-popup :type="dateType" :date="selectedDates" ref="calendar-popup" @confirm="calendarChange"></calendar-popup>
<unit-popup ref="unit-popup" :options="unitOptions" :unit="form.unit" @change="handleChangeUnit"></unit-popup> <unit-popup ref="unit-popup" :options="unitOptions" :unit="form.unit" @change="handleChangeUnit"></unit-popup>
<u-select <u-select
v-if="selectShow" v-if="selectShow"
...@@ -341,6 +349,7 @@ export default { ...@@ -341,6 +349,7 @@ export default {
form: { form: {
projectId: '', projectId: '',
projectName: '', projectName: '',
dateRange: [this.resetHappenTime(new Date())],
happenTime: this.resetHappenTime(new Date()), happenTime: this.resetHappenTime(new Date()),
memberId: [], memberId: [],
remark: '', remark: '',
...@@ -464,7 +473,8 @@ export default { ...@@ -464,7 +473,8 @@ export default {
path: 'workpoint', path: 'workpoint',
notification: 'workpoint-create-remark', notification: 'workpoint-create-remark',
memberId: '', memberId: '',
memberPopupTitle: '未设置工价' memberPopupTitle: '未设置工价',
dateType: 'date'
}; };
}, },
computed: { computed: {
...@@ -527,6 +537,12 @@ export default { ...@@ -527,6 +537,12 @@ export default {
width: '200rpx' width: '200rpx'
}; };
return this.recordId ? cancelStyle : againStyle; return this.recordId ? cancelStyle : againStyle;
},
isDateRange() {
return this.dateType == 'daterange'
},
selectedDates() {
return this.isDateRange ? this.form.dateRange.join(',') : this.form.happenTime
} }
}, },
onLoad(options) { onLoad(options) {
...@@ -553,7 +569,10 @@ export default { ...@@ -553,7 +569,10 @@ export default {
} }
if (options && options.recordId) { if (options && options.recordId) {
this.recordId = options.recordId; this.recordId = options.recordId;
this.dateType = 'date'
this.getBillInfo(); this.getBillInfo();
} else {
this.dateType = this.form.type == 'TIME' ? 'daterange' : 'date'
} }
}, },
onReady() { onReady() {
...@@ -578,12 +597,11 @@ export default { ...@@ -578,12 +597,11 @@ export default {
async getBillInfo() { async getBillInfo() {
try { try {
let { data } = await getBillInfo({ projectId: this.projectId, recordId: this.recordId }); let { data } = await getBillInfo({ projectId: this.projectId, recordId: this.recordId });
let { happenTime, memberId, memberName, type, remark ,attach} = data; let { dateRange,happenTime, memberId, memberName, type, remark ,attach} = data;
let { normalNumber, normalText, normalType, overNumber, overText, overType, number, unit, unitPrice, amount, rewardAmount } = data.data; let { normalNumber, normalText, normalType, overNumber, overText, overType, number, unit, unitPrice, amount, rewardAmount } = data.data;
let form = { let form = {
...this.form, ...this.form,
happenTime,
memberName, memberName,
type: type.code, type: type.code,
remark, remark,
...@@ -943,6 +961,11 @@ export default { ...@@ -943,6 +961,11 @@ export default {
}); });
return; return;
} }
if (this.isDateRange) {
this.form.happenTime = ''
} else {
this.form.dateRange = []
}
this.$refs.uForm.validate(valid => { this.$refs.uForm.validate(valid => {
if (valid) { if (valid) {
console.log('验证通过'); console.log('验证通过');
...@@ -1143,7 +1166,11 @@ export default { ...@@ -1143,7 +1166,11 @@ export default {
}, },
// 日历 // 日历
calendarChange(e) { calendarChange(e) {
if (this.isDateRange) {
this.form.dateRange = e
} else {
this.form.happenTime = e; this.form.happenTime = e;
}
}, },
resetHappenTime(time) { resetHappenTime(time) {
return this.parseTime(time, '{y}-{m}-{d}'); return this.parseTime(time, '{y}-{m}-{d}');
......
...@@ -32,7 +32,7 @@ ...@@ -32,7 +32,7 @@
<view class="day" v-for="(d, j) in item" :key="j" @click="clickDay(d, true)"> <view class="day" v-for="(d, j) in item" :key="j" @click="clickDay(d, true)">
<view class="day-info" :class="[ <view class="day-info" :class="[
d.dayClass, d.dayClass,
selectDate.year === d.sYear && selectDate.month === d.sMonth && selectDate.day === d.day ? 'is-sel' : '', checkDay(d) ? 'is-sel' : '',
today.year === d.sYear && today.month === d.sMonth && today.day === d.day ? 'be-today' : '' today.year === d.sYear && today.month === d.sMonth && today.day === d.day ? 'be-today' : ''
]"> ]">
<text class="day-solar" <text class="day-solar"
...@@ -117,6 +117,11 @@ ...@@ -117,6 +117,11 @@
isShrink: { isShrink: {
type: Boolean, type: Boolean,
default: false default: false
},
// date 单选;daterange 多选
type: {
type: String,
default : 'date'
} }
}, },
data() { data() {
...@@ -125,7 +130,8 @@ ...@@ -125,7 +130,8 @@
allDataArr: [], //轮播数组 allDataArr: [], //轮播数组
tranIndex: 1, //轮播所在位置 tranIndex: 1, //轮播所在位置
selDate: {}, //当前轮播日期信息 -> year, month, day, week selDate: {}, //当前轮播日期信息 -> year, month, day, week
selectDate: {}, //当前选中的日期信息 // selectDate: {}, //当前选中的日期信息
selectDate: [],
today: {}, //今天日期 -> year, month, day, week today: {}, //今天日期 -> year, month, day, week
tranDuration: 500, //轮播时间(单位毫秒) tranDuration: 500, //轮播时间(单位毫秒)
showToday: false, //显示回到今天(非当月才显示) showToday: false, //显示回到今天(非当月才显示)
...@@ -133,6 +139,11 @@ ...@@ -133,6 +139,11 @@
date: '' // picker中的日期 date: '' // picker中的日期
}; };
}, },
computed: {
isDateRange() {
return this.type == 'daterange'
}
},
created() { created() {
let { let {
platform platform
...@@ -140,6 +151,7 @@ ...@@ -140,6 +151,7 @@
this.isIOS = platform === 'ios'; this.isIOS = platform === 'ios';
let nd = new Date(); let nd = new Date();
this.today = { this.today = {
date: this.$u.timeFormat(nd, 'yyyy-mm-dd'),
year: nd.getFullYear(), year: nd.getFullYear(),
month: nd.getMonth() + 1, month: nd.getMonth() + 1,
day: nd.getDate() day: nd.getDate()
...@@ -147,21 +159,34 @@ ...@@ -147,21 +159,34 @@
if (this.firstDayOfWeek == 'sunday') this.weekArr = ['日', '一', '二', '三', '四', '五', '六']; if (this.firstDayOfWeek == 'sunday') this.weekArr = ['日', '一', '二', '三', '四', '五', '六'];
else this.weekArr = ['一', '二', '三', '四', '五', '六', '日']; else this.weekArr = ['一', '二', '三', '四', '五', '六', '日'];
this.initDateTime(this.today); this.initDateTime(this.today);
this.selectDate = JSON.parse(JSON.stringify(this.today)); this.selectDate = [JSON.parse(JSON.stringify(this.today))];
}, },
methods: { methods: {
init(date) { init(date) {
let nd = new Date(); console.log('-------date---------', date)
if (date) { var dateArray = date.split(',')
nd = new Date(date); if (dateArray.length == 0) {
} dateArray.push(new Date())
}
var array = []
var i = 0
for(var item of dateArray) {
console.log('-----item-------', item)
let nd = new Date(item);
let dates = { let dates = {
date: this.$u.timeFormat(nd, 'yyyy-mm-dd'),
year: nd.getFullYear(), year: nd.getFullYear(),
month: nd.getMonth() + 1, month: nd.getMonth() + 1,
day: nd.getDate() day: nd.getDate()
}; };
if (i == dateArray.length - 1) {
this.initDateTime(dates); this.initDateTime(dates);
this.selectDate = JSON.parse(JSON.stringify(dates)); }
array.push(JSON.parse(JSON.stringify(dates)))
i++
}
this.selectDate = array
}, },
initSign() { initSign() {
this.allDataArr.map(item2 => { this.allDataArr.map(item2 => {
...@@ -459,6 +484,7 @@ ...@@ -459,6 +484,7 @@
}, },
//点击日期 //点击日期
clickDay(dayInfo, flag) { clickDay(dayInfo, flag) {
console.log('--------clickDay---------',this.type, dayInfo, flag)
if (this.selDate.day == dayInfo.day && this.selDate.month == dayInfo.month && this.selDate.year == dayInfo if (this.selDate.day == dayInfo.day && this.selDate.month == dayInfo.month && this.selDate.year == dayInfo
.year) return; .year) return;
this.selDate.day = dayInfo.day; this.selDate.day = dayInfo.day;
...@@ -498,10 +524,42 @@ ...@@ -498,10 +524,42 @@
if (this.showLunar) returnData['lunar'] = lunar; if (this.showLunar) returnData['lunar'] = lunar;
// 仅点击天数时返回日期 // 仅点击天数时返回日期
if (flag) { if (flag) {
console.log('-----------returnData------------', returnData)
if (this.isDateRange) {
var hasNo = true
var array = this.selectDate.filter((item)=> {
var has = item.year != returnData.year || item.month != returnData.month || item.day != returnData.day
console.log(item, has)
if (!has) {
hasNo = false
}
return has
})
if (array.length > 0) {
this.selectDate = array
}
console.log('-----------hasNo------------', hasNo)
if (hasNo) {
this.selectDate.push(returnData)
}
console.log('---------selectDate-------', this.isDateRange ? this.selectDate : returnData)
this.$emit('dayChange', this.selectDate);
} else {
this.selectDate = [returnData];
this.$emit('dayChange', returnData); this.$emit('dayChange', returnData);
this.selectDate = returnData; }
// this.selectDate = returnData;
} }
this.setPickValue(); this.setPickValue();
},
checkDay(d) {
for (var item of this.selectDate) {
if (item.year === d.sYear && item.month === d.sMonth && item.day === d.day) {
return true
}
}
return false
} }
} }
}; };
...@@ -608,11 +666,12 @@ ...@@ -608,11 +666,12 @@
height: 96rpx; height: 96rpx;
color: #000; color: #000;
box-sizing: border-box; box-sizing: border-box;
align-items: center;
justify-content: center;
// overflow: hidden; // overflow: hidden;
.day-info { .day-info {
height: 96rpx; height: 88rpx;
width: 96rpx; width: 88rpx;
overflow: hidden; overflow: hidden;
display: flex; display: flex;
flex-direction: column; flex-direction: column;
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment