Commit 0ab7e767 authored by leon's avatar leon

fix:datePicker add link

parent 6d6bbb98
...@@ -27,7 +27,6 @@ const install = (Vue, vm) => { ...@@ -27,7 +27,6 @@ const install = (Vue, vm) => {
config.header.Authorization = vm.vuex_token config.header.Authorization = vm.vuex_token
config.header.requestId = vm.$u.guid() config.header.requestId = vm.$u.guid()
config.header.source = "wechat" config.header.source = "wechat"
return config return config
}, (config) => { }, (config) => {
return Promise.reject(config) return Promise.reject(config)
......
...@@ -3,22 +3,21 @@ ...@@ -3,22 +3,21 @@
<NormalTitle :elementInfo="elementInfo"></NormalTitle> <NormalTitle :elementInfo="elementInfo"></NormalTitle>
<view class="date-wrap"> <view class="date-wrap">
<u-input <u-input
style="width:'100%'" :style="[inputStyle]"
placeholder="请输入日期" placeholder="请输入日期"
input-align="center" input-align="center"
v-model="elementInfo.option.dateTime.date" v-model="pickerValue"
type="select" type="select"
:select-open="pickerTime" :select-open="show"
:border="true" :border="true"
@click="pickerTime = true" @click="show = true"
:custom-style="{color: '#fff'}"
></u-input> ></u-input>
</view> </view>
<u-picker <u-picker
mode="time" mode="time"
v-model="pickerTime" v-model="show"
@confirm="timeConfirm" @confirm="timeConfirm"
:default-time="elementInfo.option.dateTime.date ? elementInfo.option.dateTime.date : null" :default-time="pickerValue ? pickerValue : ''"
:params="elementInfo.option.dateTime.showTime ? timeParams : dateParams" :params="elementInfo.option.dateTime.showTime ? timeParams : dateParams"
></u-picker> ></u-picker>
</view> </view>
...@@ -50,14 +49,23 @@ ...@@ -50,14 +49,23 @@
minute: true, minute: true,
second: true second: true
}, },
pickerTime: false show: false,
pickerValue: ''
}; };
}, },
onReady() { computed: {
inputStyle() {
const { color, borderColor} = this.elementInfo.option.dateTime
return {
'width': '100%',
'color': color,
'border-color': borderColor
}
}
}, },
onUnLoad() { mounted() {
this.pickerValue = this.dateTimeFormat(this.elementInfo.option.dateTime.date)
}, },
methods: { methods: {
timeConfirm(e){ timeConfirm(e){
...@@ -67,11 +75,32 @@ ...@@ -67,11 +75,32 @@
const hour =e.hour const hour =e.hour
const minute = e.minute const minute = e.minute
const second = e.second const second = e.second
const dateTime = `${year}-${month}-${day} ${hour}:${minute}:${second}` if(this.elementInfo.option.dateTime.showTime) {
this.$emit('changeDateTime', { this.pickerValue = `${year}-${month}-${day} ${hour}:${minute}:${second}`
id: this.elementInfo.id, } else {
time: dateTime this.pickerValue = `${year}-${month}-${day}`
}) }
const { index, paramName, data } = this.elementInfo.child
if(index.length) {
uni.$emit('handleLinkParams', { index, paramName, value: this.pickerValue })
}
},
// 日期时间格式化
dateTimeFormat(val){
const date = new Date(val)
const year = date.getFullYear()
// 在日期格式中,月份是从0开始的,因此要加0,使用三元表达式在小于10的前面加0,以达到格式统一 如 09:11:05
const month = date.getMonth() + 1 < 10 ? "0" + (date.getMonth() + 1) : date.getMonth() + 1;
const day = date.getDate() < 10 ? "0" + date.getDate() : date.getDate();
const hours = date.getHours() < 10 ? "0" + date.getHours() : date.getHours();
const minutes = date.getMinutes() < 10 ? "0" + date.getMinutes() : date.getMinutes();
const seconds = date.getSeconds() < 10 ? "0" + date.getSeconds() : date.getSeconds();
// 拼接
if(this.elementInfo.option.dateTime.showTime) {
return year + "-" + month + "-" + day + " " + hours + ":" + minutes + ":" + seconds;
}
return year + "-" + month + "-" + day;
}, },
} }
} }
...@@ -85,7 +114,7 @@ ...@@ -85,7 +114,7 @@
flex-flow: column; flex-flow: column;
justify-content: center; justify-content: center;
width: 100%; width: 100%;
color: #fff; // color: #fff;
} }
</style> </style>
...@@ -11,7 +11,7 @@ ...@@ -11,7 +11,7 @@
height: `${parseInt(element.height * scale)}px`, height: `${parseInt(element.height * scale)}px`,
left: `${parseInt(element.left * scale)}px`, left: `${parseInt(element.left * scale)}px`,
top: `${parseInt(element.top * scale)}px`, top: `${parseInt(element.top * scale)}px`,
zIndex: `${element.type == 'NormalTabs' ? 999999 : index + 1}` zIndex: `${element.type == 'NormalTabs' || element.type == 'DateTimePicker' ? 999999 : index + 1}`
}" }"
> >
<DatePicker v-if="element.type == 'DateTimePicker'" @changeDateTime = "changeDateTime" :elementInfo="element"></DatePicker> <DatePicker v-if="element.type == 'DateTimePicker'" @changeDateTime = "changeDateTime" :elementInfo="element"></DatePicker>
...@@ -141,23 +141,6 @@ ...@@ -141,23 +141,6 @@
clearInterval(this.timename) clearInterval(this.timename)
}, },
methods: { methods: {
changeDateTime ({id, time}){
const obj = this.reportInfo.list.find(item => item.id === id)
obj.option.dateTime.date = time
},
// 日期时间格式化
dateTimeFormat(val){
let date = new Date(val)
let year = date.getFullYear()
// 在日期格式中,月份是从0开始的,因此要加0,使用三元表达式在小于10的前面加0,以达到格式统一 如 09:11:05
let month = date.getMonth() + 1 < 10 ? "0" + (date.getMonth() + 1) : date.getMonth() + 1;
let day = date.getDate() < 10 ? "0" + date.getDate() : date.getDate();
let hours = date.getHours() < 10 ? "0" + date.getHours() : date.getHours();
let minutes = date.getMinutes() < 10 ? "0" + date.getMinutes() : date.getMinutes();
let seconds = date.getSeconds() < 10 ? "0" + date.getSeconds() : date.getSeconds();
// 拼接
return year + "-" + month + "-" + day + " " + hours + ":" + minutes + ":" + seconds;
},
/** /**
* 递归 - 隐藏子项为NormalTabs的所有关联组件 * 递归 - 隐藏子项为NormalTabs的所有关联组件
*/ */
...@@ -227,11 +210,6 @@ ...@@ -227,11 +210,6 @@
}, parseInt(info.dataPollingInterval) * 1000) }, parseInt(info.dataPollingInterval) * 1000)
} }
} }
res.data.Result.list.forEach(item => {
if(item.type === 'DateTimePicker') {
item.option.dateTime.date = this.dateTimeFormat(item.option.dateTime.date)
}
})
that.reportInfo = res.data.Result that.reportInfo = res.data.Result
} }
}, },
......
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