Commit 2a3a18b3 by 李伟康

feat(OrderScreen): 新增订单筛选功能

- 添加转化人员、销售顾问、订单时间、支付时间、订单状态、支付方式等筛选条件
- 实现筛选条件的动态加载和展开收起功能
- 优化筛选界面样式,增加全选和自定义日期选项
- 重构部分组件,提高代码复用性和可维护性
1 parent a7d2adb2
...@@ -63,4 +63,23 @@ module.exports = { ...@@ -63,4 +63,23 @@ module.exports = {
...data ...data
}) })
}, },
/**获取订单列表筛选转化人员&销售顾问 */
getOrderScreenEmployeeList (data) {
return http.post({
method: 'dj.api.smartcarlife.employee.getByMerchantId',
projectName: 'boutique',
...data
})
},
/**
* 获取园区店配置
*/
getYqStoreConfig(data){
return http.get({
method: 'dj.api.smarcarlife.yqMerchantConfig.detail',
projectName: 'boutique',
...data
})
}
} }
\ No newline at end of file \ No newline at end of file
...@@ -25,8 +25,7 @@ export default { ...@@ -25,8 +25,7 @@ export default {
}, },
props: { props: {
params: Object, params: Object,
data: Object, data: Object
cacheData: Array
}, },
mounted () { mounted () {
}, },
......
...@@ -37,7 +37,6 @@ export default { ...@@ -37,7 +37,6 @@ export default {
props: { props: {
params: Object, params: Object,
data: [Object, Array], data: [Object, Array],
cacheData: Array,
dataKey: String dataKey: String
}, },
mounted () { mounted () {
......
...@@ -54,7 +54,6 @@ export default { ...@@ -54,7 +54,6 @@ export default {
props: { props: {
params: Object, params: Object,
data: [Object, Array], data: [Object, Array],
cacheData: Array,
dataKey: String dataKey: String
}, },
mounted () { mounted () {
......
...@@ -101,7 +101,6 @@ export default { ...@@ -101,7 +101,6 @@ export default {
props: { props: {
params: Object, params: Object,
data: [Object, Array], data: [Object, Array],
cacheData: Array,
dataKey: String dataKey: String
}, },
mounted () { mounted () {
......
...@@ -55,7 +55,7 @@ ...@@ -55,7 +55,7 @@
</template> </template>
<script type='text/ecmascript-6'> <script type='text/ecmascript-6'>
import Popup from './Popup.vue' import Popup from '@/components/Popup.vue'
export default { export default {
components: { components: {
Popup, Popup,
......
...@@ -73,7 +73,7 @@ ...@@ -73,7 +73,7 @@
</template> </template>
<script type='text/ecmascript-6'> <script type='text/ecmascript-6'>
import Popup from './components/Popup.vue' import Popup from '@/components/Popup.vue'
import config from './config' import config from './config'
import EmployeeList from './components/EmployeeList.vue' import EmployeeList from './components/EmployeeList.vue'
import DiversionMerchant from './components/DiversionMerchant.vue' import DiversionMerchant from './components/DiversionMerchant.vue'
...@@ -193,7 +193,7 @@ export default { ...@@ -193,7 +193,7 @@ export default {
confirm () { confirm () {
try { try {
let { chooseContent, popupType, componentObject } = this let { chooseContent, popupType, componentObject } = this
if (popupType === 13) { if (popupType == 13) {
chooseContent = this.componentRef().getResult() chooseContent = this.componentRef().getResult()
} }
if (chooseContent) { if (chooseContent) {
......
<template>
<view class="employee-list">
<view
@click="currentIds = []"
:class="['item flex',{active:!currentIds.length}]"
>
<view class="sprite-icon icon-tag-checked"></view>
全部
</view>
<template v-for="(i, index) in list">
<view
:key="index"
@click="choose(i)"
:class="['item flex',{active:checkActive(i)}]"
>
<view class="sprite-icon icon-tag-checked"></view>
{{i.staffName}}
</view>
</template>
</view>
</template>
<script type='text/ecmascript-6'>
export default {
name: 'EmployeeList',
inject: ['userInfo'],
data () {
return {
list: [],
currentIds: []
}
},
props: {
params: Object,
data: [Array, Object],
},
watch: {
currentIds: {
handler (val) {
let { params: { idKey } } = this
this.$emit('choose', {
key: idKey,
value: val.length ? val : null
})
},
deep: true
}
},
mounted () {
this.getList()
},
methods: {
async getList () {
const { userInfo, params } = this,
{ cacheData } = params
if (cacheData && cacheData.length) {
this.initList(cacheData)
return
}
const { shopMerchantId, sceneType, merchantId } = userInfo,
data = await uni.$api.popupApi.getOrderScreenEmployeeList({
merchantId: params.idKey == 'sellerUserIdList' ? merchantId : shopMerchantId,
sceneList: params.idKey == 'sellerUserIdList' ? '' : [sceneType]
})
if (data && data.length) {
this.initList(data)
params.cacheData = data
this.$emit('update:params', params)
}
},
initList (list) {
let { data, params: {idKey} } = this
this.list = list
let paramsData = idKey ? data[idKey] : data
if (paramsData && paramsData.length) paramsData.map(e => {
this.currentIds.push(e)
})
this.$emit('onComplete')
},
choose (i) {
if (i) {
let { uuid } = i,
{ currentIds } = this,
index = currentIds.indexOf(uuid)
if (index == -1) this.currentIds.push(uuid)
else this.currentIds.splice(index, 1)
}
},
checkActive (i) {
let { currentIds } = this,
active = false
if (currentIds.length) active = currentIds.includes(i.uuid)
return active
// return this.currentIds.includes(i.uuid)
},
}
}
</script>
<style scoped lang='scss'>
.employee-list {
display: grid;
grid-template-columns: repeat(6, 1fr);
gap: 32rpx;
margin: 0 48rpx;
.item {
justify-content: center;
height: 72rpx;
border-radius: 8rpx;
border: 2rpx solid #dce0e6;
box-sizing: border-box;
position: relative;
color: #333333;
font-size: 32rpx;
.sprite-icon {
display: none;
position: absolute;
top: 0;
right: 0;
}
}
.active {
border-color: #2c66f7;
background: #ecf1ff;
color: #2c66f7;
.sprite-icon {
display: block;
}
}
}
</style>
\ No newline at end of file \ No newline at end of file
<template>
<view class="list">
<view
@click="currentId = ''"
:class="['item flex',{active:!currentId}]"
>
<view class="sprite-icon icon-tag-checked"></view>
全部
</view>
<template v-for="(i, index) in list">
<view
:key="index"
@click="currentId = i.id"
:class="['item flex',{active:currentId == i.id}]"
>
<view class="sprite-icon icon-tag-checked"></view>
{{i.name}}
</view>
</template>
</view>
</template>
<script type='text/ecmascript-6'>
export default {
name: 'OrderStatusList',
inject: ['userInfo'],
data () {
return {
list: Object.freeze([
{
name: '待跟进',
value: [1],
id: 1
},
{
name: '已支付',
value: [4],
id: 2
},
{
name: '待支付',
value: [3],
id: 3
},
{
name: '已撤销',
value: [9],
id: 4
},
{
name: '战败',
value: [2],
id: 5
},
{
name: '已评价',
value: [6],
id: 6
},
{
name: '已关闭',
value: [10],
id: 7
},
{
name: '已失效',
value: [11],
id: 8
},
{
name: '未施工',
value: ['N'],
id: 9
},
{
name: '已施工',
value: ['Y'],
id: 10
},
{
name: '已退款',
value: [5, 12],
id: 11
}
]),
currentId: '',
}
},
props: {
params: Object,
data: [Array, Object],
},
watch: {
currentId: {
handler (val) {
let { params: { idKey } } = this,
{ list } = this,
item = list.find(item => item.id == val)
this.$emit('choose', {
key: idKey,
value: item ? item.value : null
})
},
deep: true
}
},
mounted () {
this.initList()
},
methods: {
initList () {
let { data, params: { idKey } } = this
this.currentId = data[idKey]
this.$emit('onComplete')
}
}
}
</script>
<style scoped lang='scss'>
.list {
display: grid;
grid-template-columns: repeat(6, 1fr);
gap: 32rpx;
margin: 0 48rpx;
.item {
justify-content: center;
height: 72rpx;
border-radius: 8rpx;
border: 2rpx solid #dce0e6;
box-sizing: border-box;
position: relative;
color: #333333;
font-size: 32rpx;
.sprite-icon {
display: none;
position: absolute;
top: 0;
right: 0;
}
}
.splice {
color: #333333;
font-size: 32rpx;
margin: 0 8rpx;
}
.active {
border-color: #2c66f7;
background: #ecf1ff;
color: #2c66f7;
.sprite-icon {
display: block;
}
}
}
</style>
\ No newline at end of file \ No newline at end of file
<template>
<view class="list">
<view
@click="currentId = ''"
:class="['item flex',{active:!currentId}]"
>
<view class="sprite-icon icon-tag-checked"></view>
全部
</view>
<template v-for="(i, index) in list">
<view
:key="index"
@click="currentId = i.value"
:class="['item flex',{active:currentId == i.value}]"
>
<view class="sprite-icon icon-tag-checked"></view>
{{i.name}}
</view>
</template>
</view>
</template>
<script type='text/ecmascript-6'>
const payTypeList = [{
name: '门店收款',
value: 2
},
{
name: '微信支付',
value: 1
},
{
name: 'POS机支付',
value: 3
},
{
name: '支付宝支付',
value: 4
},
{
name: '嘀加收款',
value: 5
}
]
export default {
name: 'PayList',
inject: ['userInfo'],
data () {
return {
list: [],
currentId: '',
}
},
props: {
params: Object,
data: [Object, Array],
},
watch: {
currentId: {
handler (value) {
let { params: { idKey } } = this
this.$emit('choose', {
key: idKey,
value
})
},
deep: true
}
},
mounted () {
this.getList()
},
methods: {
async getList () {
const { userInfo, params } = this,
{ cacheData } = params
if (cacheData && cacheData.length) {
this.initList(cacheData)
return
}
const { merchantId } = userInfo,
data = await uni.$api.popupApi.getYqStoreConfig({
yqMerchantId: merchantId
})
if (data) {
let obj = data || {}
let m = obj.supportPayTypes || []
let n = JSON.parse(JSON.stringify(payTypeList))
let payList = n.filter(k => {
let idx = m.find(j => j == k.value)
return idx >= 0
})
payList = [
...payList,
{
name: '对公转账',
value: '6'
},
{
name: '其它收款',
value: '7'
}
]
this.initList(payList)
params.cacheData = payList
this.$emit('update:params', params)
}
},
initList (list) {
this.list = list
let { data, params: { idKey } } = this
this.currentId = data[idKey]
this.$emit('onComplete')
},
}
}
</script>
<style scoped lang='scss'>
.list {
display: grid;
grid-template-columns: repeat(6, 1fr);
gap: 32rpx;
margin: 0 48rpx;
.item {
justify-content: center;
height: 72rpx;
border-radius: 8rpx;
border: 2rpx solid #dce0e6;
box-sizing: border-box;
position: relative;
color: #333333;
font-size: 32rpx;
.sprite-icon {
display: none;
position: absolute;
top: 0;
right: 0;
}
}
.splice {
color: #333333;
font-size: 32rpx;
margin: 0 8rpx;
}
.active {
border-color: #2c66f7;
background: #ecf1ff;
color: #2c66f7;
.sprite-icon {
display: block;
}
}
}
</style>
\ No newline at end of file \ No newline at end of file
<template>
<view class="list">
<view
@click="currentId = ''"
:class="['item flex',{active:!currentId}]"
>
<view class="sprite-icon icon-tag-checked"></view>
全部
</view>
<template v-for="(i, index) in list">
<view
:key="index"
@click="choose(i.id)"
:class="['item flex',{active:currentId == i.id}]"
>
<view class="sprite-icon icon-tag-checked"></view>
{{i.name}}
</view>
</template>
<template v-if="currentId == 3 && customDate.startDate && customDate.endDate">
<view
class="calendar flex"
@click="$refs.calendar.open()"
>
<view class="item flex active">
{{customDate.startDate}}
</view>
<view class="splice">-</view>
<view class="item flex active">
{{customDate.endDate}}
</view>
</view>
</template>
<template v-else>
<view
@click="$refs.calendar.open()"
:class="['item flex']"
>
自定义
</view>
</template>
<uni-calendar
ref="calendar"
:insert="false"
range
:clearDate="false"
startDate="2020-10-01"
:endDate="endDate"
@confirm="confirmCalendar"
:rangeValue="rangeValue"
/>
</view>
</template>
<script type='text/ecmascript-6'>
import dayjs from 'dayjs'
export default {
name: 'TimeList',
inject: ['userInfo'],
data () {
return {
list: Object.freeze([
{
name: '今日',
startDate: dayjs().format('YYYY-MM-DD'),
endDate: dayjs().format('YYYY-MM-DD'),
id: 1
}, {
name: '本月',
startDate: dayjs().startOf('month').format('YYYY-MM-DD'),
endDate: dayjs().format('YYYY-MM-DD'),
id: 2
}
]),
currentId: '',
endDate: dayjs().format('YYYY-MM-DD'),
customDate: {
startDate: '',
endDate: ''
},
rangeValue: {}
}
},
props: {
params: Object,
data: [Array, Object],
},
watch: {
currentId: {
handler (val) {
let { params: { idKey, currentIdKey } } = this
let { list } = this,
value = {}
if (val) {
let [startDateName, endDateName] = idKey
if (val == 3) {
value = {
[startDateName]: this.customDate.startDate,
[endDateName]: this.customDate.endDate
}
} else {
let item = list.find(e => e.id == val)
value = {
[startDateName]: item.startDate,
[endDateName]: item.endDate
}
}
}
this.$emit('choose', {
currentIdKey,
currentId: val,
keys: idKey,
value
})
},
deep: true
}
},
mounted () {
this.initList()
},
methods: {
async initList () {
let { data, params: { idKey, currentIdKey } } = this
if (data[currentIdKey] == 3) {
this.customDate = {
startDate: data[idKey[0]],
endDate: data[idKey[1]]
}
this.rangeValue = {
before: data[idKey[0]],
after: data[idKey[1]]
}
}
this.currentId = data[currentIdKey]
this.$emit('onComplete')
},
choose (i) {
this.currentId = i
},
confirmCalendar ({range}) {
let { data } = range
this.customDate = {
startDate: data[0] || dayjs().format('YYYY-MM-DD'),
endDate: data[data.length - 1] || dayjs().format('YYYY-MM-DD')
}
this.rangeValue = range
if (this.currentId == 3) {
let { params: { idKey } } = this,
[startDateName, endDateName] = idKey
this.$emit('choose', {
currentId: 3,
keys: idKey,
value: {
[startDateName]: this.customDate.startDate,
[endDateName]: this.customDate.endDate
}
})
} else this.currentId = 3
}
}
}
</script>
<style scoped lang='scss'>
.list {
display: flex;
gap: 32rpx;
margin: 0 48rpx;
.item {
justify-content: center;
width: 348rpx;
height: 72rpx;
border-radius: 8rpx;
border: 2rpx solid #dce0e6;
box-sizing: border-box;
position: relative;
color: #333333;
font-size: 32rpx;
.sprite-icon {
display: none;
position: absolute;
top: 0;
right: 0;
}
}
.splice {
color: #333333;
font-size: 32rpx;
margin: 0 8rpx;
}
.active {
border-color: #2c66f7;
background: #ecf1ff;
color: #2c66f7;
.sprite-icon {
display: block;
}
}
}
</style>
\ No newline at end of file \ No newline at end of file
const screenList = [
{
title: '转化人员',
suffix: 'merchantName',
componentName: 'EmployeeList',
params: {
cacheData: [],
idKey: 'sellerUserIdList'
},
hasToggle: true,
toggle: false
},
{
title: '销售顾问',
suffix: 'shopMerchantName',
componentName: 'EmployeeList',
params: {
cacheData: [],
idKey: 'userIdList'
},
hasToggle: true,
toggle: false
},
{
title: '订单时间',
componentName: 'TimeList',
params: {
idKey: ['orderStartDate', 'orderEndDate'],
currentIdKey: 'orderTimeId',
},
},
{
title: '支付时间',
componentName: 'TimeList',
params: {
idKey: ['payStartDate', 'payEndDate'],
currentIdKey: 'payTimeId',
},
},
{
title: '订单状态',
componentName: 'OrderStatusList',
params: {
idKey: 'statusList'
}
},
{
title: '支付方式',
componentName: 'PayList',
params: {
idKey: 'payType'
}
},
]
export default { screenList }
\ No newline at end of file \ No newline at end of file
<template>
<popup
ref="popup"
@onConfirm="confirm"
@onCancel="clear"
cancelText="清除"
>
<view class="popup-title flex">
工单筛选
<view
class="popup-close flex"
@click="close"
>
<uni-icons
type="closeempty"
size="16"
></uni-icons>
</view>
</view>
<view class="popup-body">
<scroll-view
scroll-y
:class="['popup-scroll-view',{show:loadComplete}]"
>
<template v-for="(i, index) in screenList">
<view
class="item-box"
:key="index"
>
<view class="title flex">
{{i.title}}
<template v-if="i.suffix">
({{userInfo[i.suffix]}})
</template>
<template v-if="i.hasToggle">
<view class="toggle-btn" @click="i.toggle = !i.toggle">{{i.toggle ? '收起' : '展开'}}</view>
</template>
</view>
<view :class="['box',{'fold':i.hasToggle},{'show':i.toggle}]">
<component
:ref="`${i.componentName}_${index}`"
:is="i.componentName"
:params.sync="i.params"
@choose="choose"
:data="chooseContent"
/>
</view>
</view>
</template>
</scroll-view>
<image
v-if="!loadComplete"
class="loading"
src="../../assets/images/common/loadding.gif"
/>
</view>
</popup>
</template>
<script type='text/ecmascript-6'>
import Popup from '@/components/Popup.vue'
import config from './config'
import EmployeeList from './components/EmployeeList.vue'
import TimeList from './components/TimeList.vue'
import OrderStatusList from './components/OrderStatusList.vue'
import PayList from './components/PayList.vue'
export default {
components: {
Popup,
EmployeeList,
TimeList,
OrderStatusList,
PayList
},
name: 'OrderScreen',
props: {
},
data () {
return {
screenList: config.screenList,
loadComplete: true,
chooseContent: {},
}
},
provide () {
return {
userInfo: this.userInfo,
}
},
computed: {
userInfo () {
return uni.$storage.get("userInfo")
},
},
mounted () {
},
methods: {
open (data) {
this.$refs.popup.open()
},
clear () {
},
close () {
this.$refs.popup.close()
},
choose (i) {
let { key, value, keys, currentIdKey, currentId } = i,
{ chooseContent } = this
if (keys) {
if (currentIdKey) chooseContent[currentIdKey] = currentId || ''
keys.map(e => {
if (value[e]) chooseContent[e] = value[e]
else delete chooseContent[e]
})
} else {
if (value) chooseContent[key] = value
else delete chooseContent[key]
}
},
confirm () {
let chooseContent = JSON.parse(JSON.stringify(this.chooseContent))
delete chooseContent.payTimeId
delete chooseContent.orderTimeId
Object.keys(chooseContent).map(e => {
if (e == 'orderStartDate' || e == 'payStartDate') chooseContent[e] = `${chooseContent[e]} 00:00:00`
if (e == 'orderEndDate' || e == 'payEndDate') chooseContent[e] = `${chooseContent[e]} 23:59:59`
})
this.$emit('onConfirm', chooseContent)
this.close()
},
}
}
</script>
<style scoped lang='scss'>
.popup-box {
border-radius: 32rpx 32rpx 0 0;
background: #ffffff;
height: 70vh;
.popup-title {
height: 104rpx;
justify-content: center;
position: relative;
color: #333333;
font-size: 36rpx;
font-weight: 500;
.popup-close {
position: absolute;
height: 100%;
top: 0;
right: 0;
padding: 0 48rpx;
font-weight: 400;
color: #1a1a1a;
}
}
.popup-tips {
color: #999ea8;
font-size: 28rpx;
padding-left: 48rpx;
}
.popup-body {
height: calc(100% - 312rpx);
position: relative;
.popup-scroll-view {
height: 100%;
padding-top: 8rpx;
.item-box {
margin-bottom: 32rpx;
.title {
color: #888888;
font-size: 28rpx;
height: 40rpx;
background: #f5f7fa;
padding-left: 48rpx;
margin-bottom: 16rpx;
line-height: 40rpx;
.toggle-btn {
margin-left: auto;
padding: 0 48rpx;
color: #4673ff;
font-size: 24rpx;
}
}
.box{
overflow: hidden;
}
.fold{
height: 72rpx;
}
.show{
height: auto !important;
}
}
}
.loading {
position: absolute;
top: 50%;
left: 50%;
transform: translate(-50%, -50%);
width: toRpx(64);
height: toRpx(64);
}
.show {
opacity: 1;
}
}
}
</style>
\ No newline at end of file \ No newline at end of file
...@@ -11,11 +11,11 @@ ...@@ -11,11 +11,11 @@
<view <view
class="popup-btn popup-cancel" class="popup-btn popup-cancel"
@click="cancel" @click="cancel"
>取消</view> >{{cancelText}}</view>
<view <view
class="popup-btn popup-confirm" class="popup-btn popup-confirm"
@click="confirm" @click="confirm"
>确定</view> >{{confirmText}}</view>
</view> </view>
</view> </view>
...@@ -38,7 +38,16 @@ export default { ...@@ -38,7 +38,16 @@ export default {
position:{ position:{
type: String, type: String,
default: 'bottom' default: 'bottom'
},
cancelText: {
type: String,
default: '取消'
},
confirmText:{
type: String,
default: '确定'
} }
}, },
data () { data () {
...@@ -54,7 +63,6 @@ export default { ...@@ -54,7 +63,6 @@ export default {
this.$refs.popup.open() this.$refs.popup.open()
}, },
cancel () { cancel () {
this.$refs.popup.close()
this.$emit('onCancel') this.$emit('onCancel')
}, },
close () { close () {
......
<template> <template>
<view class="uni-calendar"> <view class="uni-calendar">
<view v-if="!insert&&show" class="uni-calendar__mask" :class="{'uni-calendar--mask-show':aniMaskShow}" @click="clean"></view> <view
<view v-if="insert || show" class="uni-calendar__content" :class="{'uni-calendar--fixed':!insert,'uni-calendar--ani-show':aniMaskShow}"> v-if="!insert&&show"
<view v-if="!insert" class="uni-calendar__header uni-calendar--fixed-top"> class="uni-calendar__mask"
<view class="uni-calendar__header-btn-box" @click="close"> :class="{'uni-calendar--mask-show':aniMaskShow}"
@click="clean"
></view>
<view
v-if="insert || show"
class="uni-calendar__content"
:class="{'uni-calendar--fixed':!insert,'uni-calendar--ani-show':aniMaskShow}"
>
<view
v-if="!insert"
class="uni-calendar__header uni-calendar--fixed-top"
>
<view
class="uni-calendar__header-btn-box"
@click="close"
>
<text class="uni-calendar__header-text uni-calendar--fixed-width">{{cancelText}}</text> <text class="uni-calendar__header-text uni-calendar--fixed-width">{{cancelText}}</text>
</view> </view>
<view class="uni-calendar__header-btn-box" @click="confirm"> <view
class="uni-calendar__header-btn-box"
@click="confirm"
>
<text class="uni-calendar__header-text uni-calendar--fixed-width">{{okText}}</text> <text class="uni-calendar__header-text uni-calendar--fixed-width">{{okText}}</text>
</view> </view>
</view> </view>
<view class="uni-calendar__header"> <view class="uni-calendar__header">
<view class="uni-calendar__header-btn-box" @click.stop="pre"> <view
class="uni-calendar__header-btn-box"
@click.stop="pre"
>
<view class="uni-calendar__header-btn uni-calendar--left"></view> <view class="uni-calendar__header-btn uni-calendar--left"></view>
</view> </view>
<picker mode="date" :value="date" fields="month" @change="bindDateChange"> <picker
mode="date"
:value="date"
fields="month"
@change="bindDateChange"
>
<text class="uni-calendar__header-text">{{ (nowDate.year||'') +' / '+( nowDate.month||'')}}</text> <text class="uni-calendar__header-text">{{ (nowDate.year||'') +' / '+( nowDate.month||'')}}</text>
</picker> </picker>
<view class="uni-calendar__header-btn-box" @click.stop="next"> <view
class="uni-calendar__header-btn-box"
@click.stop="next"
>
<view class="uni-calendar__header-btn uni-calendar--right"></view> <view class="uni-calendar__header-btn uni-calendar--right"></view>
</view> </view>
<text class="uni-calendar__backtoday" @click="backToday">{{todayText}}</text> <!-- <text class="uni-calendar__backtoday" @click="backToday">{{todayText}}</text> -->
</view> </view>
<view class="uni-calendar__box"> <view class="uni-calendar__box">
<view v-if="showMonth" class="uni-calendar__box-bg"> <view
v-if="showMonth"
class="uni-calendar__box-bg"
>
<text class="uni-calendar__box-bg-text">{{nowDate.month}}</text> <text class="uni-calendar__box-bg-text">{{nowDate.month}}</text>
</view> </view>
<view class="uni-calendar__weeks"> <view class="uni-calendar__weeks">
...@@ -50,9 +82,24 @@ ...@@ -50,9 +82,24 @@
<text class="uni-calendar__weeks-day-text">{{SATText}}</text> <text class="uni-calendar__weeks-day-text">{{SATText}}</text>
</view> </view>
</view> </view>
<view class="uni-calendar__weeks" v-for="(item,weekIndex) in weeks" :key="weekIndex"> <view
<view class="uni-calendar__weeks-item" v-for="(weeks,weeksIndex) in item" :key="weeksIndex"> class="uni-calendar__weeks"
<calendar-item class="uni-calendar-item--hook" :weeks="weeks" :calendar="calendar" :selected="selected" :lunar="lunar" @change="choiceDate"></calendar-item> v-for="(item,weekIndex) in weeks"
:key="weekIndex"
>
<view
class="uni-calendar__weeks-item"
v-for="(weeks,weeksIndex) in item"
:key="weeksIndex"
>
<calendar-item
class="uni-calendar-item--hook"
:weeks="weeks"
:calendar="calendar"
:selected="selected"
:lunar="lunar"
@change="choiceDate"
></calendar-item>
</view> </view>
</view> </view>
</view> </view>
...@@ -61,14 +108,14 @@ ...@@ -61,14 +108,14 @@
</template> </template>
<script> <script>
import Calendar from './util.js'; import Calendar from './util.js';
import CalendarItem from './uni-calendar-item.vue' import CalendarItem from './uni-calendar-item.vue'
import { initVueI18n } from '@dcloudio/uni-i18n' import { initVueI18n } from '@dcloudio/uni-i18n'
import i18nMessages from './i18n/index.js' import i18nMessages from './i18n/index.js'
const { t } = initVueI18n(i18nMessages) const { t } = initVueI18n(i18nMessages)
/** /**
* Calendar 日历 * Calendar 日历
* @description 日历组件可以查看日期,选择任意范围内的日期,打点操作。常用场景如:酒店日期预订、火车机票选择购买日期、上下班打卡等 * @description 日历组件可以查看日期,选择任意范围内的日期,打点操作。常用场景如:酒店日期预订、火车机票选择购买日期、上下班打卡等
* @tutorial https://ext.dcloud.net.cn/plugin?id=56 * @tutorial https://ext.dcloud.net.cn/plugin?id=56
...@@ -88,11 +135,11 @@ ...@@ -88,11 +135,11 @@
* @event {Function} monthSwitch 切换月份时触发 * @event {Function} monthSwitch 切换月份时触发
* @example <uni-calendar :insert="true":lunar="true" :start-date="'2019-3-2'":end-date="'2019-5-20'"@change="change" /> * @example <uni-calendar :insert="true":lunar="true" :start-date="'2019-3-2'":end-date="'2019-5-20'"@change="change" />
*/ */
export default { export default {
components: { components: {
CalendarItem CalendarItem
}, },
emits:['close','confirm','change','monthSwitch'], emits: ['close', 'confirm', 'change', 'monthSwitch'],
props: { props: {
date: { date: {
type: String, type: String,
...@@ -131,9 +178,13 @@ ...@@ -131,9 +178,13 @@
clearDate: { clearDate: {
type: Boolean, type: Boolean,
default: true default: true
},
rangeValue: {
type: Object,
default: () => { { } }
} }
}, },
data() { data () {
return { return {
show: false, show: false,
weeks: [], weeks: [],
...@@ -142,63 +193,63 @@ ...@@ -142,63 +193,63 @@
aniMaskShow: false aniMaskShow: false
} }
}, },
computed:{ computed: {
/** /**
* for i18n * for i18n
*/ */
okText() { okText () {
return t("uni-calender.ok") return t("uni-calender.ok")
}, },
cancelText() { cancelText () {
return t("uni-calender.cancel") return t("uni-calender.cancel")
}, },
todayText() { todayText () {
return t("uni-calender.today") return t("uni-calender.today")
}, },
monText() { monText () {
return t("uni-calender.MON") return t("uni-calender.MON")
}, },
TUEText() { TUEText () {
return t("uni-calender.TUE") return t("uni-calender.TUE")
}, },
WEDText() { WEDText () {
return t("uni-calender.WED") return t("uni-calender.WED")
}, },
THUText() { THUText () {
return t("uni-calender.THU") return t("uni-calender.THU")
}, },
FRIText() { FRIText () {
return t("uni-calender.FRI") return t("uni-calender.FRI")
}, },
SATText() { SATText () {
return t("uni-calender.SAT") return t("uni-calender.SAT")
}, },
SUNText() { SUNText () {
return t("uni-calender.SUN") return t("uni-calender.SUN")
}, },
}, },
watch: { watch: {
date(newVal) { date (newVal) {
// this.cale.setDate(newVal) // this.cale.setDate(newVal)
this.init(newVal) this.init(newVal)
}, },
startDate(val){ startDate (val) {
this.cale.resetSatrtDate(val) this.cale.resetSatrtDate(val)
this.cale.setDate(this.nowDate.fullDate) this.cale.setDate(this.nowDate.fullDate)
this.weeks = this.cale.weeks this.weeks = this.cale.weeks
}, },
endDate(val){ endDate (val) {
this.cale.resetEndDate(val) this.cale.resetEndDate(val)
this.cale.setDate(this.nowDate.fullDate) this.cale.setDate(this.nowDate.fullDate)
this.weeks = this.cale.weeks this.weeks = this.cale.weeks
}, },
selected(newVal) { selected (newVal) {
this.cale.setSelectInfo(this.nowDate.fullDate, newVal) this.cale.setSelectInfo(this.nowDate.fullDate, newVal)
this.weeks = this.cale.weeks this.weeks = this.cale.weeks
} }
}, },
created() { created () {
this.cale = new Calendar({ this.cale = new Calendar({
selected: this.selected, selected: this.selected,
startDate: this.startDate, startDate: this.startDate,
...@@ -209,12 +260,12 @@ ...@@ -209,12 +260,12 @@
}, },
methods: { methods: {
// 取消穿透 // 取消穿透
clean() {}, clean () { },
bindDateChange(e) { bindDateChange (e) {
const value = e.detail.value + '-1' const value = e.detail.value + '-1'
this.setDate(value) this.setDate(value)
const { year,month } = this.cale.getDate(value) const { year, month } = this.cale.getDate(value)
this.$emit('monthSwitch', { this.$emit('monthSwitch', {
year, year,
month month
...@@ -224,7 +275,7 @@ ...@@ -224,7 +275,7 @@
* 初始化日期显示 * 初始化日期显示
* @param {Object} date * @param {Object} date
*/ */
init(date) { init (date) {
this.cale.setDate(date) this.cale.setDate(date)
this.weeks = this.cale.weeks this.weeks = this.cale.weeks
this.nowDate = this.calendar = this.cale.getInfo(date) this.nowDate = this.calendar = this.cale.getInfo(date)
...@@ -232,13 +283,30 @@ ...@@ -232,13 +283,30 @@
/** /**
* 打开日历弹窗 * 打开日历弹窗
*/ */
open() { open () {
// 弹窗模式并且清理数据 // 弹窗模式并且清理数据
if (this.clearDate && !this.insert) { if (this.clearDate && !this.insert) {
this.cale.cleanMultipleStatus() this.cale.cleanMultipleStatus()
// this.cale.setDate(this.date) // this.cale.setDate(this.date)
this.init(this.date) this.init(this.date)
} }
let { rangeValue } = this
if (Object.keys(rangeValue).length) {
uni.showLoading({
mask: true
})
let before = {
fullDate: rangeValue.before
},
after = {
fullDate: rangeValue.after
}
this.choiceDate(before)
setTimeout(() => {
uni.hideLoading()
this.choiceDate(after)
}, 100)
}
this.show = true this.show = true
this.$nextTick(() => { this.$nextTick(() => {
setTimeout(() => { setTimeout(() => {
...@@ -249,7 +317,7 @@ ...@@ -249,7 +317,7 @@
/** /**
* 关闭日历弹窗 * 关闭日历弹窗
*/ */
close() { close () {
this.aniMaskShow = false this.aniMaskShow = false
this.$nextTick(() => { this.$nextTick(() => {
setTimeout(() => { setTimeout(() => {
...@@ -261,21 +329,21 @@ ...@@ -261,21 +329,21 @@
/** /**
* 确认按钮 * 确认按钮
*/ */
confirm() { confirm () {
this.setEmit('confirm') this.setEmit('confirm')
this.close() this.close()
}, },
/** /**
* 变化触发 * 变化触发
*/ */
change() { change () {
if (!this.insert) return if (!this.insert) return
this.setEmit('change') this.setEmit('change')
}, },
/** /**
* 选择月份触发 * 选择月份触发
*/ */
monthSwitch() { monthSwitch () {
let { let {
year, year,
month month
...@@ -289,7 +357,7 @@ ...@@ -289,7 +357,7 @@
* 派发事件 * 派发事件
* @param {Object} name * @param {Object} name
*/ */
setEmit(name) { setEmit (name) {
let { let {
year, year,
month, month,
...@@ -312,7 +380,7 @@ ...@@ -312,7 +380,7 @@
* 选择天触发 * 选择天触发
* @param {Object} weeks * @param {Object} weeks
*/ */
choiceDate(weeks) { choiceDate (weeks) {
if (weeks.disable) return if (weeks.disable) return
this.calendar = weeks this.calendar = weeks
// 设置多选 // 设置多选
...@@ -323,14 +391,14 @@ ...@@ -323,14 +391,14 @@
/** /**
* 回到今天 * 回到今天
*/ */
backToday() { backToday () {
const nowYearMonth = `${this.nowDate.year}-${this.nowDate.month}` const nowYearMonth = `${this.nowDate.year}-${this.nowDate.month}`
const date = this.cale.getDate(new Date()) const date = this.cale.getDate(new Date())
const todayYearMonth = `${date.year}-${date.month}` const todayYearMonth = `${date.year}-${date.month}`
this.init(date.fullDate) this.init(date.fullDate)
if(nowYearMonth !== todayYearMonth) { if (nowYearMonth !== todayYearMonth) {
this.monthSwitch() this.monthSwitch()
} }
...@@ -339,7 +407,7 @@ ...@@ -339,7 +407,7 @@
/** /**
* 上个月 * 上个月
*/ */
pre() { pre () {
const preDate = this.cale.getDate(this.nowDate.fullDate, -1, 'month').fullDate const preDate = this.cale.getDate(this.nowDate.fullDate, -1, 'month').fullDate
this.setDate(preDate) this.setDate(preDate)
this.monthSwitch() this.monthSwitch()
...@@ -348,7 +416,7 @@ ...@@ -348,7 +416,7 @@
/** /**
* 下个月 * 下个月
*/ */
next() { next () {
const nextDate = this.cale.getDate(this.nowDate.fullDate, +1, 'month').fullDate const nextDate = this.cale.getDate(this.nowDate.fullDate, +1, 'month').fullDate
this.setDate(nextDate) this.setDate(nextDate)
this.monthSwitch() this.monthSwitch()
...@@ -357,32 +425,35 @@ ...@@ -357,32 +425,35 @@
* 设置日期 * 设置日期
* @param {Object} date * @param {Object} date
*/ */
setDate(date) { setDate (date) {
this.cale.setDate(date) this.cale.setDate(date)
this.weeks = this.cale.weeks this.weeks = this.cale.weeks
this.nowDate = this.cale.getInfo(date) this.nowDate = this.cale.getInfo(date)
} }
} }
} }
</script> </script>
<style lang="scss" scoped> <style lang="scss" scoped>
$uni-bg-color-mask: rgba($color: #000000, $alpha: 0.4); $uni-bg-color-mask: rgba(
$uni-border-color: #EDEDED; $color: #000000,
$uni-text-color: #333; $alpha: 0.4
$uni-bg-color-hover:#f1f1f1; );
$uni-font-size-base:14px; $uni-border-color: #ededed;
$uni-text-color-placeholder: #808080; $uni-text-color: #333;
$uni-color-subtitle: #555555; $uni-bg-color-hover: #f1f1f1;
$uni-text-color-grey:#999; $uni-font-size-base: 14px;
.uni-calendar { $uni-text-color-placeholder: #808080;
$uni-color-subtitle: #555555;
$uni-text-color-grey: #999;
.uni-calendar {
/* #ifndef APP-NVUE */ /* #ifndef APP-NVUE */
display: flex; display: flex;
/* #endif */ /* #endif */
flex-direction: column; flex-direction: column;
} }
.uni-calendar__mask { .uni-calendar__mask {
position: fixed; position: fixed;
bottom: 0; bottom: 0;
top: 0; top: 0;
...@@ -395,13 +466,13 @@ ...@@ -395,13 +466,13 @@
/* #ifndef APP-NVUE */ /* #ifndef APP-NVUE */
z-index: 99; z-index: 99;
/* #endif */ /* #endif */
} }
.uni-calendar--mask-show { .uni-calendar--mask-show {
opacity: 1 opacity: 1;
} }
.uni-calendar--fixed { .uni-calendar--fixed {
position: fixed; position: fixed;
/* #ifdef APP-NVUE */ /* #ifdef APP-NVUE */
bottom: 0; bottom: 0;
...@@ -415,17 +486,17 @@ ...@@ -415,17 +486,17 @@
bottom: calc(var(--window-bottom)); bottom: calc(var(--window-bottom));
z-index: 99; z-index: 99;
/* #endif */ /* #endif */
} }
.uni-calendar--ani-show { .uni-calendar--ani-show {
transform: translateY(0); transform: translateY(0);
} }
.uni-calendar__content { .uni-calendar__content {
background-color: #fff; background-color: #fff;
} }
.uni-calendar__header { .uni-calendar__header {
position: relative; position: relative;
/* #ifndef APP-NVUE */ /* #ifndef APP-NVUE */
display: flex; display: flex;
...@@ -437,9 +508,9 @@ ...@@ -437,9 +508,9 @@
border-bottom-color: $uni-border-color; border-bottom-color: $uni-border-color;
border-bottom-style: solid; border-bottom-style: solid;
border-bottom-width: 1px; border-bottom-width: 1px;
} }
.uni-calendar--fixed-top { .uni-calendar--fixed-top {
/* #ifndef APP-NVUE */ /* #ifndef APP-NVUE */
display: flex; display: flex;
/* #endif */ /* #endif */
...@@ -448,13 +519,13 @@ ...@@ -448,13 +519,13 @@
border-top-color: $uni-border-color; border-top-color: $uni-border-color;
border-top-style: solid; border-top-style: solid;
border-top-width: 1px; border-top-width: 1px;
} }
.uni-calendar--fixed-width { .uni-calendar--fixed-width {
width: 50px; width: 50px;
} }
.uni-calendar__backtoday { .uni-calendar__backtoday {
position: absolute; position: absolute;
right: 0; right: 0;
top: 25rpx; top: 25rpx;
...@@ -467,16 +538,16 @@ ...@@ -467,16 +538,16 @@
border-bottom-left-radius: 25px; border-bottom-left-radius: 25px;
color: $uni-text-color; color: $uni-text-color;
background-color: $uni-bg-color-hover; background-color: $uni-bg-color-hover;
} }
.uni-calendar__header-text { .uni-calendar__header-text {
text-align: center; text-align: center;
width: 100px; width: 100px;
font-size: $uni-font-size-base; font-size: $uni-font-size-base;
color: $uni-text-color; color: $uni-text-color;
} }
.uni-calendar__header-btn-box { .uni-calendar__header-btn-box {
/* #ifndef APP-NVUE */ /* #ifndef APP-NVUE */
display: flex; display: flex;
/* #endif */ /* #endif */
...@@ -485,9 +556,9 @@ ...@@ -485,9 +556,9 @@
justify-content: center; justify-content: center;
width: 50px; width: 50px;
height: 50px; height: 50px;
} }
.uni-calendar__header-btn { .uni-calendar__header-btn {
width: 10px; width: 10px;
height: 10px; height: 10px;
border-left-color: $uni-text-color-placeholder; border-left-color: $uni-text-color-placeholder;
...@@ -496,30 +567,29 @@ ...@@ -496,30 +567,29 @@
border-top-color: $uni-color-subtitle; border-top-color: $uni-color-subtitle;
border-top-style: solid; border-top-style: solid;
border-top-width: 2px; border-top-width: 2px;
} }
.uni-calendar--left { .uni-calendar--left {
transform: rotate(-45deg); transform: rotate(-45deg);
} }
.uni-calendar--right { .uni-calendar--right {
transform: rotate(135deg); transform: rotate(135deg);
} }
.uni-calendar__weeks { .uni-calendar__weeks {
position: relative; position: relative;
/* #ifndef APP-NVUE */ /* #ifndef APP-NVUE */
display: flex; display: flex;
/* #endif */ /* #endif */
flex-direction: row; flex-direction: row;
} }
.uni-calendar__weeks-item { .uni-calendar__weeks-item {
flex: 1; flex: 1;
} }
.uni-calendar__weeks-day { .uni-calendar__weeks-day {
flex: 1; flex: 1;
/* #ifndef APP-NVUE */ /* #ifndef APP-NVUE */
display: flex; display: flex;
...@@ -528,20 +598,20 @@ ...@@ -528,20 +598,20 @@
justify-content: center; justify-content: center;
align-items: center; align-items: center;
height: 45px; height: 45px;
border-bottom-color: #F5F5F5; border-bottom-color: #f5f5f5;
border-bottom-style: solid; border-bottom-style: solid;
border-bottom-width: 1px; border-bottom-width: 1px;
} }
.uni-calendar__weeks-day-text { .uni-calendar__weeks-day-text {
font-size: 14px; font-size: 14px;
} }
.uni-calendar__box { .uni-calendar__box {
position: relative; position: relative;
} }
.uni-calendar__box-bg { .uni-calendar__box-bg {
/* #ifndef APP-NVUE */ /* #ifndef APP-NVUE */
display: flex; display: flex;
/* #endif */ /* #endif */
...@@ -552,9 +622,9 @@ ...@@ -552,9 +622,9 @@
left: 0; left: 0;
right: 0; right: 0;
bottom: 0; bottom: 0;
} }
.uni-calendar__box-bg-text { .uni-calendar__box-bg-text {
font-size: 200px; font-size: 200px;
font-weight: bold; font-weight: bold;
color: $uni-text-color-grey; color: $uni-text-color-grey;
...@@ -563,5 +633,5 @@ ...@@ -563,5 +633,5 @@
/* #ifndef APP-NVUE */ /* #ifndef APP-NVUE */
line-height: 1; line-height: 1;
/* #endif */ /* #endif */
} }
</style> </style>
Markdown is supported
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!