diff --git a/pages/visit/addrecord.vue b/pages/visit/addrecord.vue
index 917f44f..64c6c5f 100644
--- a/pages/visit/addrecord.vue
+++ b/pages/visit/addrecord.vue
@@ -9,11 +9,11 @@
-
-
-
- 确认
-
+
+
+
+ 确认
+
@@ -43,10 +43,13 @@
-
+
拜访信息
-
-
+
+
+
+
+
- 拜访人信息
+
+ 拜访人信息
+
+
@@ -186,12 +193,12 @@
-
-
- 陪同人信息
-
-
+
+
+ 陪同人信息
+
+
{
this.util.request({
api: '/api/mobile/visit/idcard-check',
@@ -826,6 +854,12 @@
if (this.form.credent == 2) {
this.form.idcard = this.form.passcard
}
+
+ // 确保date字段设置为start_date
+ if (this.form.start_date) {
+ this.form.date = this.form.start_date
+ }
+
this.$refs['formdata'].validate().then(res => {
console.log("form", this.form)
// return
@@ -847,8 +881,8 @@
})
},
submitForm() {
- let that = this
- console.log("form",this.form)
+ let that = this
+ console.log("form",this.form)
// return
this.util.request({
api: '/api/admin/visit/save',
@@ -909,7 +943,7 @@
url: '/pages/visit/successform'
})
} else {
- // 用户没有点击“总是保持以上,不再询问”则每次都会调起订阅消息
+ // 用户没有点击"总是保持以上,不再询问"则每次都会调起订阅消息
uni.requestSubscribeMessage({
tmplIds: ['OfDFwAIZyXqvPgmc_czIXhveVtp3n_ftyWJEks1DSi4',
'r8n41lmkGeob15YBuuxhG7MbpgVSsUxKnK9ORPtr5VY'
@@ -928,6 +962,91 @@
}
});
},
+ // 开始日期变化处理
+ onStartDateChange(e) {
+ console.log('开始日期变化:', e)
+ this.calculateDateRange()
+ },
+
+ // 结束日期变化处理
+ onEndDateChange(e) {
+ console.log('结束日期变化:', e)
+ this.calculateDateRange()
+ },
+
+ // 计算日期范围和长期访问状态
+ calculateDateRange() {
+ if (this.form.start_date && this.form.end_date) {
+ // 计算日期差
+ const start = new Date(this.form.start_date)
+ const end = new Date(this.form.end_date)
+ const timeDiff = end.getTime() - start.getTime()
+ const daysDiff = Math.ceil(timeDiff / (1000 * 3600 * 24)) + 1 // +1 因为包含开始和结束日期
+
+ // 如果超过1天,设置为长期访问
+ this.form.long_time = daysDiff > 1 ? 1 : 0
+
+ // 设置date字段为start_date
+ this.form.date = this.form.start_date
+
+ console.log('计算后的值:', {
+ start_date: this.form.start_date,
+ end_date: this.form.end_date,
+ long_time: this.form.long_time,
+ daysDiff: daysDiff
+ })
+ }
+ },
+ // 拉取拜访人信息
+ pullVisitorInfo() {
+ let that = this
+ this.util.request({
+ api: '/api/mobile/user/my-visit',
+ method: "get",
+ data: {
+ page: 1,
+ page_size: 1,
+ type: ""
+ },
+ utilSuccess: function(res) {
+ if (res.data && res.data.length > 0) {
+ // 获取第一条记录
+ const firstRecord = res.data[0]
+ // 自动填充拜访人信息
+ that.form.name = firstRecord.name || ''
+ that.form.mobile = firstRecord.mobile || ''
+ that.form.credent = firstRecord.credent || 1
+ that.form.idcard = firstRecord.idcard || ''
+ that.form.company_name = firstRecord.company_name || ''
+ that.form.cda = firstRecord.cda || ''
+
+ // 根据证件类型设置对应的证件号码
+ if (firstRecord.credent == 2) {
+ that.form.passcard = firstRecord.idcard || ''
+ }
+
+ uni.showToast({
+ title: '拜访人信息已自动填充',
+ duration: 2000,
+ icon: 'success'
+ })
+ } else {
+ uni.showToast({
+ title: '暂无拜访人历史记录,请手动输入!',
+ duration: 2000,
+ icon: 'none'
+ })
+ }
+ },
+ utilFail: function(res) {
+ uni.showToast({
+ title: '拉取失败,请手动输入',
+ duration: 2000,
+ icon: 'none'
+ })
+ }
+ })
+ },
}
}
@@ -959,7 +1078,7 @@
.configtitle {
font-size: 40rpx;
text-align: center;
- margin-top: 36rpx;
+ margin-top: 36rpx;
padding-bottom: 20rpx;
}
@@ -996,8 +1115,6 @@
color: #fff !important
}
- .areavalue {}
-
.areabtn {
background-color: #4f607e;
/* margin-left: 8px; */
@@ -1011,4 +1128,31 @@
/deep/ .areavalue .uni-data-checklist .checklist-group .checklist-box.is--button {
padding: 30rpx
}
+
+ /* 日期选择器样式优化 */
+ /deep/ .uni-datetime-picker {
+ width: 100% !important;
+ min-width: 0 !important;
+ flex: 1 !important;
+ }
+
+ /deep/ .uni-datetime-picker .uni-datetime-picker__input {
+ width: 100% !important;
+ overflow: visible !important;
+ white-space: nowrap !important;
+ min-width: 0 !important;
+ }
+
+ /deep/ .uni-datetime-picker .uni-datetime-picker__input-text {
+ width: 100% !important;
+ overflow: visible !important;
+ text-overflow: ellipsis !important;
+ min-width: 0 !important;
+ }
+
+ /* 确保表单项有足够空间 */
+ /deep/ .uni-forms-item__content {
+ flex: 1 !important;
+ min-width: 0 !important;
+ }
\ No newline at end of file