Commit a9cb3377 authored by leon's avatar leon

Merge branch 'develop' into feature-retail

parents 5e0f73e3 206f8396
...@@ -11,10 +11,6 @@ ...@@ -11,10 +11,6 @@
<u-icon class="close-icon" v-if="tabsValue && elementInfo.option.tabs.allowClear" name="close-circle" <u-icon class="close-icon" v-if="tabsValue && elementInfo.option.tabs.allowClear" name="close-circle"
@click.prevent.stop="handleClearValue"></u-icon> @click.prevent.stop="handleClearValue"></u-icon>
</view> </view>
<!-- <u-select v-model="show" :default-value="defaultValue" :list="elementData.dataList.series"
:safe-area-inset-bottom="true" label-name="name" :z-index="zIndex" @confirm="handleSelectChange">
</u-select> -->
</template> </template>
<swiper v-if="elementInfo.option.tabs.type === 'group'" class="tab-swiper" <swiper v-if="elementInfo.option.tabs.type === 'group'" class="tab-swiper"
...@@ -47,7 +43,6 @@ ...@@ -47,7 +43,6 @@
show: false, show: false,
tabsValue: '', tabsValue: '',
selectValue: '', selectValue: '',
zIndex: 0,
defaultValue: [0] defaultValue: [0]
} }
}, },
...@@ -103,13 +98,16 @@ ...@@ -103,13 +98,16 @@
}, },
methods: { methods: {
initChart() { initChart() {
this.tabsValue = this.elementInfo.option.tabs.defaultValue this.tabsValue = this.elementInfo.option.tabs.defaultValue
if (this.elementData.dataList.defaultValue) {
this.tabsValue = this.elementData.dataList.defaultValue
}
if (this.elementInfo.option.tabs.type === 'select') { if (this.elementInfo.option.tabs.type === 'select') {
for (var i = 0; i < this.elementData.dataList.series.length; i++) { for (var i = 0; i < this.elementData.dataList.series.length; i++) {
const item = this.elementData.dataList.series[i] const item = this.elementData.dataList.series[i]
if (item.value === this.tabsValue || item.value === parseInt(this.tabsValue)) { if (item.value == this.tabsValue || item.value == parseInt(this.tabsValue)) {
this.selectValue = item.name this.selectValue = item.name
this.zIndex = i
} }
} }
} }
...@@ -119,7 +117,12 @@ ...@@ -119,7 +117,12 @@
) )
} }
}, },
handleShowSelect() { handleShowSelect() {
this.defaultValue[0] = [
this.elementData.dataList.series.findIndex(
item => item.value == this.tabsValue
)
]
uni.$emit('showSelect', { uni.$emit('showSelect', {
id: this.elementInfo.id, id: this.elementInfo.id,
show: true, show: true,
...@@ -137,14 +140,9 @@ ...@@ -137,14 +140,9 @@
this.tabsValueChange() this.tabsValueChange()
}, },
handleSelectChange(e) { handleSelectChange(e) {
this.selectValue = e[0].label this.selectValue = e[0].label
this.tabsValue = e[0].value this.tabsValue = e[0].value
this.defaultValue[0] = [
this.elementData.dataList.series.findIndex(
item => item.value === e[0].value
)
]
this.tabsValueChange() this.tabsValueChange()
}, },
handleChangeTabValue(value) { handleChangeTabValue(value) {
......
...@@ -130,6 +130,9 @@ const install = (Vue, vm) => { ...@@ -130,6 +130,9 @@ const install = (Vue, vm) => {
if (paramStr.includes('@month')) { if (paramStr.includes('@month')) {
paramStr = paramStr.replace(/@month/g, monthly()) paramStr = paramStr.replace(/@month/g, monthly())
} }
if (paramStr.includes('@weekly')) {
paramStr = paramStr.replace(/@weekly/g, mweekly())
}
if (paramStr.includes('@day')) { if (paramStr.includes('@day')) {
paramStr = paramStr.replace(/@day/g, day()) paramStr = paramStr.replace(/@day/g, day())
} }
...@@ -139,8 +142,24 @@ const install = (Vue, vm) => { ...@@ -139,8 +142,24 @@ const install = (Vue, vm) => {
} }
if (paramStr.includes('@yesterday')) { if (paramStr.includes('@yesterday')) {
paramStr = paramStr.replace(/@yesterday/g, yesterday()) paramStr = paramStr.replace(/@yesterday/g, yesterday())
}
// 匹配以@开头,空格 或者 " 结尾的的字符串
const pattern = /((?<=@).*?(?=\s))|((?<=@).*?(?="))/g
const match = paramStr.match(pattern)
if (match?.length) {
match.forEach((item) => {
if (item.includes('diffOfNow')) {
// 取出()里面的内容
const regex = /(?<=\()\S+(?=\))/g
const value = item.match(regex)
if (value?.length) {
diffOfNow(parseInt(value[0]))
const str = '@' + item
paramStr = paramStr.replace(str, diffOfNow(parseInt(value[0])))
}
}
})
} }
return JSON.parse(paramStr) return JSON.parse(paramStr)
} }
...@@ -155,6 +174,17 @@ const install = (Vue, vm) => { ...@@ -155,6 +174,17 @@ const install = (Vue, vm) => {
const month = date.getMonth() + 1 < 10 ? "0" + (date.getMonth() + 1) : date.getMonth() + 1; const month = date.getMonth() + 1 < 10 ? "0" + (date.getMonth() + 1) : date.getMonth() + 1;
return month return month
} }
const weekly = () => {
let d1 = new Date();
let d2 = new Date();
d2.setMonth(0);
d2.setDate(3);//3 周一为本周第一天;2 周日为本周第一天;1 周六为本周第一天
let rq = d1 - d2;
let days = Math.ceil(rq / (24 * 60 * 60 * 1000));
let weekly = Math.ceil(days / 7);
return weekly + 1;
}
const day = () => { const day = () => {
const date = new Date(); const date = new Date();
...@@ -173,17 +203,22 @@ const install = (Vue, vm) => { ...@@ -173,17 +203,22 @@ const install = (Vue, vm) => {
} }
const yesterday = () => { const yesterday = () => {
return diffOfNow(-1)
}
const diffOfNow = (diff) => {
const date = new Date() const date = new Date()
const timestamp = date.getTime() - 1000 * 24 * 60 * 60 const timestamp = date.getTime() + diff * 1000 * 24 * 60 * 60
date.setTime(timestamp) date.setTime(timestamp)
const year = date.getFullYear(); const year = date.getFullYear();
// 在日期格式中,月份是从0开始的,因此要加0,使用三元表达式在小于10的前面加0,以达到格式统一 如 09:11:05 // 在日期格式中,月份是从0开始的,因此要加0,使用三元表达式在小于10的前面加0,以达到格式统一 如 09:11:05
const month = date.getMonth() + 1 < 10 ? "0" + (date.getMonth() + 1) : date.getMonth() + 1; const month = date.getMonth() + 1 < 10 ? "0" + (date.getMonth() + 1) : date.getMonth() + 1;
const day = date.getDate() < 10 ? "0" + date.getDate() : date.getDate(); const day = date.getDate() < 10 ? "0" + date.getDate() : date.getDate();
// 拼接 // 拼接
return year + "-" + month + "-" + day; return year + "-" + month + "-" + day;
}
}
vm.$u.common = { vm.$u.common = {
converFunction, converFunction,
fillDigit, fillDigit,
...@@ -193,7 +228,7 @@ const install = (Vue, vm) => { ...@@ -193,7 +228,7 @@ const install = (Vue, vm) => {
rpxToPx, rpxToPx,
chunk, chunk,
getQueryFromString, getQueryFromString,
filterRequestParams filterRequestParams
} }
} }
......
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