Commit 2735007c by 张立顺

feat 功能联调修改

1 parent 11f2b5d5
...@@ -22,7 +22,7 @@ export const RECRUIT_MENU_ENABLED = false ...@@ -22,7 +22,7 @@ export const RECRUIT_MENU_ENABLED = false
* 4预发布 * 4预发布
* 5cdptest * 5cdptest
*/ */
let index = 1; let index = 2;
const accountInfo = wx.getAccountInfoSync(); const accountInfo = wx.getAccountInfoSync();
const systemInfo = getSystemInfoSync(); const systemInfo = getSystemInfoSync();
const envName = accountInfo.miniProgram.envVersion; const envName = accountInfo.miniProgram.envVersion;
......
/**
* 动态表单分钟 datetime 一体选择(日/时/分三列滚轮)
* @file 参考 tabRepairOrder/timeSelect,输出 YYYY-MM-DD HH:mm,无页面耦合
*/
const {
endOfToday,
formatMinutePickerValue,
parseMinutePickerDefaultTime
} = require('../../form-engine/datetime-picker-mode.js')
const DATE_START_FALLBACK = '1970-01-01'
function pad2(n) {
return `${n}`.padStart(2, '0')
}
function formatYmd(date) {
return `${date.getFullYear()}-${pad2(date.getMonth() + 1)}-${pad2(date.getDate())}`
}
function buildDayList(startDay, endDay) {
const start = new Date(String(startDay).replace(/-/g, '/'))
const end = new Date(String(endDay).replace(/-/g, '/'))
const days = []
const cursor = new Date(start.getFullYear(), start.getMonth(), start.getDate())
const endTime = new Date(end.getFullYear(), end.getMonth(), end.getDate()).getTime()
while (cursor.getTime() <= endTime) {
days.push(formatYmd(cursor))
cursor.setDate(cursor.getDate() + 1)
}
return days
}
Component({
properties: {
show: {
type: Boolean,
observer(visible) {
if (visible) {
this.initPicker()
}
}
},
title: {
type: String,
value: ''
},
defaultTime: {
type: String,
value: ''
},
/** now | today | 空 — 对齐 resolveMaxDateKind */
maxDateKind: {
type: String,
value: ''
}
},
data: {
days: [],
hours: [],
minutes: [],
dateValues: [0],
hourValues: [0],
minuteValues: [0],
loading: true
},
methods: {
shouldCapTimeToNow() {
return this.properties.maxDateKind === 'now'
},
shouldCapDateToToday() {
const kind = this.properties.maxDateKind
return kind === 'now' || kind === 'today'
},
parseDefaultTime() {
return parseMinutePickerDefaultTime(this.properties.defaultTime)
},
buildHourList(dateStr) {
const todayStr = endOfToday()
const isToday = dateStr === todayStr
if (this.shouldCapTimeToNow() && isToday) {
const now = new Date()
const limit = now.getHours() + 1
return Array.from({ length: limit }, (_, hour) => pad2(hour))
}
return Array.from({ length: 24 }, (_, hour) => pad2(hour))
},
buildMinuteList(dateStr, hourStr) {
const todayStr = endOfToday()
const isToday = dateStr === todayStr
if (this.shouldCapTimeToNow() && isToday) {
const now = new Date()
const currentHour = pad2(now.getHours())
if (hourStr !== currentHour) {
return Array.from({ length: 60 }, (_, minute) => pad2(minute))
}
const limit = now.getMinutes() + 1
return Array.from({ length: limit }, (_, minute) => pad2(minute))
}
return Array.from({ length: 60 }, (_, minute) => pad2(minute))
},
syncCurrentSelection(days, hours, minutes, defaultTime) {
const dateIndex = Math.max(0, days.findIndex(day => day === defaultTime.dateStr))
const hourStr = pad2(defaultTime.hour)
const minuteStr = pad2(defaultTime.minute)
let hourIndex = hours.findIndex(hour => hour === hourStr)
if (hourIndex < 0) {
hourIndex = Math.max(0, hours.length - 1)
}
let minuteIndex = minutes.findIndex(minute => minute === minuteStr)
if (minuteIndex < 0) {
minuteIndex = Math.max(0, minutes.length - 1)
}
this.currentDate = days[dateIndex]
this.currentHour = hours[hourIndex]
this.currentMinute = minutes[minuteIndex]
this.setData({
days,
hours,
minutes,
dateValues: [dateIndex],
hourValues: [hourIndex],
minuteValues: [minuteIndex],
loading: false
})
},
initPicker() {
this.setData({ loading: true })
const defaultTime = this.parseDefaultTime()
const todayStr = endOfToday()
let endDay = todayStr
if (!this.shouldCapDateToToday()) {
const defaultDate = new Date(defaultTime.dateStr.replace(/-/g, '/'))
const todayDate = new Date(todayStr.replace(/-/g, '/'))
if (!Number.isNaN(defaultDate.getTime()) && defaultDate.getTime() > todayDate.getTime()) {
endDay = defaultTime.dateStr
} else {
const future = new Date()
future.setFullYear(future.getFullYear() + 10)
endDay = formatYmd(future)
}
}
const startDay = this.shouldCapDateToToday() ? DATE_START_FALLBACK : DATE_START_FALLBACK
const days = buildDayList(startDay, endDay)
const hours = this.buildHourList(defaultTime.dateStr)
const minutes = this.buildMinuteList(defaultTime.dateStr, pad2(defaultTime.hour))
this.syncCurrentSelection(days, hours, minutes, defaultTime)
},
refreshHourMinuteColumns() {
const hours = this.buildHourList(this.currentDate)
const hourIndex = Math.max(
0,
hours.findIndex(hour => hour === this.currentHour)
)
this.currentHour = hours[hourIndex] || hours[hours.length - 1] || '00'
const minutes = this.buildMinuteList(this.currentDate, this.currentHour)
const minuteIndex = Math.max(
0,
minutes.findIndex(minute => minute === this.currentMinute)
)
this.currentMinute = minutes[minuteIndex] || minutes[minutes.length - 1] || '00'
this.setData({
hours,
minutes,
hourValues: [hourIndex],
minuteValues: [minuteIndex]
})
},
changeDate(e) {
const index = e.detail.value[0]
this.currentDate = this.data.days[index]
this.refreshHourMinuteColumns()
},
changeHour(e) {
const index = e.detail.value[0]
this.currentHour = this.data.hours[index]
const minutes = this.buildMinuteList(this.currentDate, this.currentHour)
const minuteIndex = Math.max(
0,
minutes.findIndex(minute => minute === this.currentMinute)
)
this.currentMinute = minutes[minuteIndex] || minutes[minutes.length - 1] || '00'
this.setData({
minutes,
minuteValues: [minuteIndex]
})
},
changeMinutes(e) {
const index = e.detail.value[0]
this.currentMinute = this.data.minutes[index]
},
confirm() {
const value = formatMinutePickerValue(
this.currentDate,
this.currentHour,
this.currentMinute
)
this.triggerEvent('confirm', { value })
},
cancel() {
this.triggerEvent('cancel')
}
}
})
<popup show="{{ show }}" title="{{ title }}" bindconfirm="confirm" height="50%" bindcancel="cancel">
<view class="minute-picker__body">
<picker-view
class="minute-picker__col minute-picker__col--date"
value="{{ dateValues }}"
indicator-class="minute-picker__indicator"
bindchange="changeDate"
>
<picker-view-column>
<view wx:for="{{ days }}" wx:key="*this" class="minute-picker__item">{{ item }}</view>
</picker-view-column>
</picker-view>
<picker-view
class="minute-picker__col"
value="{{ hourValues }}"
indicator-class="minute-picker__indicator"
bindchange="changeHour"
>
<picker-view-column>
<view wx:for="{{ hours }}" wx:key="*this" class="minute-picker__item">{{ item }}时</view>
</picker-view-column>
</picker-view>
<picker-view
wx:if="{{ !loading }}"
class="minute-picker__col"
value="{{ minuteValues }}"
indicator-class="minute-picker__indicator"
bindchange="changeMinutes"
>
<picker-view-column>
<view wx:for="{{ minutes }}" wx:key="*this" class="minute-picker__item">{{ item }}分</view>
</picker-view-column>
</picker-view>
</view>
</popup>
.minute-picker__body {
display: flex;
height: 100%;
}
.minute-picker__col {
width: 27.5%;
height: 100%;
}
.minute-picker__col--date {
width: 45%;
}
.minute-picker__item {
display: flex;
align-items: center;
justify-content: center;
font-size: 32rpx;
font-weight: 500;
color: #222222;
}
const { const {
buildDatetimePickerState, buildDatetimePickerState,
mergeDateTimeValue,
clampDateTimeToNow, clampDateTimeToNow,
resolveNotAfterNow resolveNotAfterNow
} = require('../../form-engine/datetime-picker-mode.js') } = require('../../form-engine/datetime-picker-mode.js')
...@@ -22,13 +21,11 @@ Component({ ...@@ -22,13 +21,11 @@ Component({
data: { data: {
useMinutePicker: false, useMinutePicker: false,
displayLabel: '', displayLabel: '',
maxDateKind: '',
minutePickerVisible: false,
pickerMode: 'date', pickerMode: 'date',
pickerValue: '', pickerValue: '',
dateValue: '',
timeValue: '',
dateStart: '', dateStart: '',
dateEnd: '',
timeEnd: '',
endDate: '', endDate: '',
arrowIconUrl: '' arrowIconUrl: ''
}, },
...@@ -63,7 +60,10 @@ Component({ ...@@ -63,7 +60,10 @@ Component({
emitMergedValue(nextValue) { emitMergedValue(nextValue) {
const field = this.properties.field const field = this.properties.field
const state = buildDatetimePickerState(field, nextValue) const state = buildDatetimePickerState(field, nextValue)
this.setData(state) this.setData({
...state,
minutePickerVisible: false
})
this.triggerEvent('change', this.buildChangeDetail(nextValue)) this.triggerEvent('change', this.buildChangeDetail(nextValue))
}, },
...@@ -85,22 +85,19 @@ Component({ ...@@ -85,22 +85,19 @@ Component({
return merged return merged
}, },
onDateChange(e) { onOpenMinutePicker() {
if (this.data.disabled) return if (this.data.disabled) return
const date = e.detail.value this.setData({ minutePickerVisible: true })
const merged = this.normalizeMergedValue(
mergeDateTimeValue(date, this.data.timeValue)
)
this.emitMergedValue(merged)
}, },
onTimeChange(e) { onMinutePickerConfirm(e) {
if (this.data.disabled) return if (this.data.disabled) return
const time = e.detail.value const merged = this.normalizeMergedValue(e.detail?.value || '')
const merged = this.normalizeMergedValue(
mergeDateTimeValue(this.data.dateValue, time)
)
this.emitMergedValue(merged) this.emitMergedValue(merged)
},
onMinutePickerCancel() {
this.setData({ minutePickerVisible: false })
} }
} }
}) })
{ {
"component": true, "component": true,
"usingComponents": {} "usingComponents": {
"datetime-minute-picker": "../datetime-minute-picker/datetime-minute-picker"
}
} }
...@@ -4,32 +4,21 @@ ...@@ -4,32 +4,21 @@
<text class="form-info-row__required" wx:if="{{ field.required }}">*</text> <text class="form-info-row__required" wx:if="{{ field.required }}">*</text>
</view> </view>
<block wx:if="{{ useMinutePicker }}"> <block wx:if="{{ useMinutePicker }}">
<view class="form-info-row__pickers form-info-row__pickers--minute"> <view
<picker class="form-info-row__value {{ displayLabel ? '' : 'is-placeholder' }}"
mode="date" bindtap="onOpenMinutePicker"
value="{{ dateValue }}" >
start="{{ dateStart }}" <text>{{ displayLabel || '请选择' }}</text>
end="{{ dateEnd }}" <image class="form-info-row__arrow" src="{{ arrowIconUrl }}" mode="aspectFit" />
disabled="{{ disabled }}"
bindchange="onDateChange"
>
<view class="form-info-row__picker-part {{ dateValue ? '' : 'is-placeholder' }}">
<text>{{ dateValue || '日期' }}</text>
</view>
</picker>
<picker
mode="time"
value="{{ timeValue }}"
end="{{ timeEnd }}"
disabled="{{ disabled }}"
bindchange="onTimeChange"
>
<view class="form-info-row__picker-part {{ timeValue ? '' : 'is-placeholder' }}">
<text>{{ timeValue || '时间' }}</text>
<image class="form-info-row__arrow" src="{{ arrowIconUrl }}" mode="aspectFit" />
</view>
</picker>
</view> </view>
<datetime-minute-picker
show="{{ minutePickerVisible }}"
title="{{ field.label }}"
defaultTime="{{ displayLabel }}"
maxDateKind="{{ maxDateKind }}"
bind:confirm="onMinutePickerConfirm"
bind:cancel="onMinutePickerCancel"
/>
</block> </block>
<picker <picker
wx:else wx:else
......
# DEVLOG — packageDynamicForm # DEVLOG — packageDynamicForm
## 2026-06-25 — 分钟 datetime 一体选择器
- **问题**:洽谈 F3「触客时间」等 `datetime` 字段使用 date + time 双原生 picker,操作繁琐。
- **修复**:`form-field-datetime` 分钟模式改为单行点击 + [`datetime-minute-picker`](../components/datetime-minute-picker/)(日/时/分三列滚轮弹层,对齐出库 `time-select` 交互);值仍为 `YYYY-MM-DD HH:mm`。
- **仅日期**(`type: date`)仍为原生单日 picker;`maxDateKind`(`now`/`today`)由 [`datetime-picker-mode.js`](../form-engine/datetime-picker-mode.js) 驱动弹层上限。
- **单测**:`datetime-picker-mode.test.mjs`(`IT-DATE-MINUTE-*`)
## 2026-06-24 — 洽谈明细今日计划到店客户 ## 2026-06-24 — 洽谈明细今日计划到店客户
- **能力**:当天入口条展示待接待客户数;「查看客户」打开多选弹层;批量导入到可见 F3 subform(`applyCustomersToEngine` + `engine.appendGroupRows`) - **能力**:当天入口条展示待接待客户数;「查看客户」打开多选弹层;批量导入到可见 F3 subform(`applyCustomersToEngine` + `engine.appendGroupRows`)
......
...@@ -49,6 +49,7 @@ ...@@ -49,6 +49,7 @@
| 校验 | 可见字段才校验必填;数字默认 ≥0 整数;金额字段加 `rules.decimal: true` | | 校验 | 可见字段才校验必填;数字默认 ≥0 整数;金额字段加 `rules.decimal: true` |
| 子表 subform | 可增删行,最多 20 行;门店 / 洽谈常用 | | 子表 subform | 可增删行,最多 20 行;门店 / 洽谈常用 |
| 远程下拉 | `select` / `multipleSelect` 配 `optionsKey` 从接口拉选项 | | 远程下拉 | `select` / `multipleSelect` 配 `optionsKey` 从接口拉选项 |
| 日期时间 | `date` 单日原生 picker;`datetime` 分钟精度为日/时/分三列弹层(`datetime-minute-picker`) |
| 保存 | 驻店、门店、洽谈保存格式略有不同;门店支持草稿;非当天一般只读 | | 保存 | 驻店、门店、洽谈保存格式略有不同;门店支持草稿;非当天一般只读 |
联调时在 [`config/apiSwitch.js`](../config/apiSwitch.js) 把各能力切 `'mock'` 或 `'real'`。 联调时在 [`config/apiSwitch.js`](../config/apiSwitch.js) 把各能力切 `'mock'` 或 `'real'`。
......
...@@ -50,13 +50,16 @@ Loader mock 数据:[`car-brand-merchant-mock.js`](../fixtures/car-brand-mercha ...@@ -50,13 +50,16 @@ Loader mock 数据:[`car-brand-merchant-mock.js`](../fixtures/car-brand-mercha
## 校验 ## 校验
- `carBrandSelect` 必填:`vehicleShapeId` 必须有值(四级选满) - 手动点选 / 导入后点「车型配置」编辑:须选满款型(`vehicleShapeId`);`openCarBrandForField` 打开选车前会清除 `partialFromPlanImport`
- 计划到店客户导入且**未点车型编辑**:三级车系 + `partialFromPlanImport` 可提交
- 详情回显三级数组:自动还原 `partialFromPlanImport`(与 `car-brand-value.js` / `app-subform-json.js` 同步)
## 手工用例 ## 手工用例
1. 洽谈明细 F3 新增行 → 点「车型配置」→ 走完四级选择 → 展示四级名称拼接。 1. 洽谈明细 F3 新增行 → 点「车型配置」→ 走完四级选择 → 展示四级名称拼接。
2. 未选款型提交 → 提示「车型配置不能为空」。 2. 手动新增行未选车型提交 → 提示「车型配置不能为空」;从「今日待接待客户」导入含车系客户且不点车型 → 三级可提交。
3. 返回洽谈页后切换「是否成交」,已填车型与其它字段仍在。 3. 导入后点车型编辑但未选满四级 → 提交仍提示「车型配置不能为空」。
4. 返回洽谈页后切换「是否成交」,已填车型与其它字段仍在。
## 与旧能力区别 ## 与旧能力区别
......
...@@ -78,6 +78,8 @@ function coerceMultipleSelectValue(rawValue) { ...@@ -78,6 +78,8 @@ function coerceMultipleSelectValue(rawValue) {
return [String(rawValue)] return [String(rawValue)]
} }
const PARTIAL_FROM_PLAN_IMPORT_KEY = 'partialFromPlanImport'
const CAR_BRAND_FIELD_KEYS = [ const CAR_BRAND_FIELD_KEYS = [
'vehicleBrandId', 'vehicleBrandId',
'vehicleBrandName', 'vehicleBrandName',
...@@ -127,6 +129,13 @@ function cascadeLevelsToCarInfo(levels = []) { ...@@ -127,6 +129,13 @@ function cascadeLevelsToCarInfo(levels = []) {
return null return null
} }
next.displayText = buildDisplayText(next) next.displayText = buildDisplayText(next)
if (
next.vehicleSeriesId != null &&
next.vehicleSeriesId !== '' &&
(next.vehicleShapeId == null || next.vehicleShapeId === '')
) {
next[PARTIAL_FROM_PLAN_IMPORT_KEY] = true
}
return next return next
} }
...@@ -145,6 +154,9 @@ function normalizeCarBrandObject(obj = {}) { ...@@ -145,6 +154,9 @@ function normalizeCarBrandObject(obj = {}) {
} else { } else {
next.displayText = buildDisplayText(next) next.displayText = buildDisplayText(next)
} }
if (obj[PARTIAL_FROM_PLAN_IMPORT_KEY] === true) {
next[PARTIAL_FROM_PLAN_IMPORT_KEY] = true
}
return next return next
} }
......
...@@ -7,6 +7,9 @@ const CAR_BRAND_SUBMIT_KEY_MAP = { ...@@ -7,6 +7,9 @@ const CAR_BRAND_SUBMIT_KEY_MAP = {
// 示例: 'F3-1-6': ['vehicleBrandId', 'vehicleBrandName', ...] // 示例: 'F3-1-6': ['vehicleBrandId', 'vehicleBrandName', ...]
} }
/** 计划到店客户导入:三级车系可提交标记(点车型编辑后须清除) */
export const PARTIAL_FROM_PLAN_IMPORT_KEY = 'partialFromPlanImport'
const CAR_BRAND_FIELD_KEYS = [ const CAR_BRAND_FIELD_KEYS = [
'vehicleBrandId', 'vehicleBrandId',
'vehicleBrandName', 'vehicleBrandName',
...@@ -68,6 +71,9 @@ function normalizeCarBrandObject(obj = {}) { ...@@ -68,6 +71,9 @@ function normalizeCarBrandObject(obj = {}) {
} else { } else {
next.displayText = buildDisplayText(next) next.displayText = buildDisplayText(next)
} }
if (obj[PARTIAL_FROM_PLAN_IMPORT_KEY] === true) {
next[PARTIAL_FROM_PLAN_IMPORT_KEY] = true
}
return next return next
} }
...@@ -81,11 +87,68 @@ export function normalizeCarInfoFromPick(carInfo = {}) { ...@@ -81,11 +87,68 @@ export function normalizeCarInfoFromPick(carInfo = {}) {
return next return next
} }
/** 判断车型值是否完整(需 vehicleShapeId) */ /**
* 是否为计划到店导入的三级车型(未点编辑前可提交)
* @param {*} value
* @returns {boolean}
*/
export function hasPartialPlanImportMarker(value) {
return (
value != null &&
typeof value === 'object' &&
!Array.isArray(value) &&
value[PARTIAL_FROM_PLAN_IMPORT_KEY] === true
)
}
/**
* 清除导入标记(用户点车型编辑时调用,此后须四级选满)
* @param {Object} [carInfo]
* @returns {Object|undefined|null}
*/
export function clearPartialPlanImportMarker(carInfo) {
if (!hasPartialPlanImportMarker(carInfo)) {
return carInfo
}
const next = { ...carInfo }
delete next[PARTIAL_FROM_PLAN_IMPORT_KEY]
return next
}
function applyPartialPlanImportMarkerIfPartial(carInfo) {
if (!carInfo) {
return carInfo
}
if (
carInfo.vehicleSeriesId != null &&
carInfo.vehicleSeriesId !== '' &&
(carInfo.vehicleShapeId == null || carInfo.vehicleShapeId === '')
) {
return { ...carInfo, [PARTIAL_FROM_PLAN_IMPORT_KEY]: true }
}
return carInfo
}
/**
* 判断车型值是否满足必填校验
* 手动四级选车需 vehicleShapeId;计划到店导入(带标记且未点编辑)允许三级车系
*/
export function isCarBrandComplete(value) { export function isCarBrandComplete(value) {
const normalized = normalizeCarBrandValue(value) const normalized = normalizeCarBrandValue(value)
if (!normalized) return false if (!normalized) return false
return normalized.vehicleShapeId != null && normalized.vehicleShapeId !== '' if (normalized.vehicleShapeId != null && normalized.vehicleShapeId !== '') {
return true
}
const raw =
value != null && typeof value === 'object' && !Array.isArray(value) ? value : null
if (
raw?.[PARTIAL_FROM_PLAN_IMPORT_KEY] === true &&
normalized.vehicleSeriesId != null &&
normalized.vehicleSeriesId !== ''
) {
return true
}
return false
} }
/** /**
...@@ -147,7 +210,7 @@ export function cascadeLevelsToCarInfo(levels = []) { ...@@ -147,7 +210,7 @@ export function cascadeLevelsToCarInfo(levels = []) {
return null return null
} }
next.displayText = buildDisplayText(next) next.displayText = buildDisplayText(next)
return next return applyPartialPlanImportMarkerIfPartial(next)
} }
/** /**
......
...@@ -130,6 +130,36 @@ export function mergeDateTimeValue(date, time) { ...@@ -130,6 +130,36 @@ export function mergeDateTimeValue(date, time) {
return `${d} ${t}` return `${d} ${t}`
} }
/** 分钟弹层确认值:YYYY-MM-DD HH:mm */
export function formatMinutePickerValue(date, hour, minute) {
const d = date == null ? '' : String(date).trim()
const h = hour == null ? '' : String(hour).trim()
const m = minute == null ? '' : String(minute).trim()
if (!d || !h || !m) {
return ''
}
return mergeDateTimeValue(d, `${h}:${m}`)
}
/** 解析分钟弹层 defaultTime → 选中项 */
export function parseMinutePickerDefaultTime(defaultTime = '') {
const { date, time } = splitDateTimeValue(defaultTime)
if (!date) {
const now = new Date()
return {
dateStr: endOfToday(),
hour: now.getHours(),
minute: now.getMinutes()
}
}
const timeMatch = (time || '00:00').match(/^(\d{2}):(\d{2})/)
return {
dateStr: date,
hour: timeMatch ? Number(timeMatch[1]) : 0,
minute: timeMatch ? Number(timeMatch[2]) : 0
}
}
function resolveDateRange(field = {}) { function resolveDateRange(field = {}) {
const kind = resolveMaxDateKind(field) const kind = resolveMaxDateKind(field)
if (kind === 'now' || kind === 'today') { if (kind === 'now' || kind === 'today') {
...@@ -154,6 +184,7 @@ function resolveTimeEnd(field = {}, datePart = '') { ...@@ -154,6 +184,7 @@ function resolveTimeEnd(field = {}, datePart = '') {
export function buildDatetimePickerState(field = {}, value) { export function buildDatetimePickerState(field = {}, value) {
const useMinutePicker = resolveWithTime(field) const useMinutePicker = resolveWithTime(field)
const maxDateKind = resolveMaxDateKind(field)
const normalizedValue = const normalizedValue =
useMinutePicker && resolveNotAfterNow(field) ? clampDateTimeToNow(value) : value useMinutePicker && resolveNotAfterNow(field) ? clampDateTimeToNow(value) : value
const displayLabel = formatDateValue(normalizedValue, useMinutePicker) const displayLabel = formatDateValue(normalizedValue, useMinutePicker)
...@@ -164,6 +195,7 @@ export function buildDatetimePickerState(field = {}, value) { ...@@ -164,6 +195,7 @@ export function buildDatetimePickerState(field = {}, value) {
return { return {
useMinutePicker: true, useMinutePicker: true,
displayLabel, displayLabel,
maxDateKind: maxDateKind || '',
dateValue: date, dateValue: date,
timeValue: time, timeValue: time,
dateStart: dateRange.start, dateStart: dateRange.start,
...@@ -194,7 +226,9 @@ export default { ...@@ -194,7 +226,9 @@ export default {
resolveWithTime, resolveWithTime,
splitDateTimeValue, splitDateTimeValue,
mergeDateTimeValue, mergeDateTimeValue,
buildDatetimePickerState buildDatetimePickerState,
formatMinutePickerValue,
parseMinutePickerDefaultTime
} }
if (typeof module !== 'undefined' && module.exports) { if (typeof module !== 'undefined' && module.exports) {
...@@ -210,6 +244,8 @@ if (typeof module !== 'undefined' && module.exports) { ...@@ -210,6 +244,8 @@ if (typeof module !== 'undefined' && module.exports) {
splitDateTimeValue, splitDateTimeValue,
mergeDateTimeValue, mergeDateTimeValue,
buildDatetimePickerState, buildDatetimePickerState,
formatMinutePickerValue,
parseMinutePickerDefaultTime,
default: { default: {
formatDateValue, formatDateValue,
endOfToday, endOfToday,
...@@ -221,7 +257,9 @@ if (typeof module !== 'undefined' && module.exports) { ...@@ -221,7 +257,9 @@ if (typeof module !== 'undefined' && module.exports) {
resolveWithTime, resolveWithTime,
splitDateTimeValue, splitDateTimeValue,
mergeDateTimeValue, mergeDateTimeValue,
buildDatetimePickerState buildDatetimePickerState,
formatMinutePickerValue,
parseMinutePickerDefaultTime
} }
} }
} }
...@@ -18,6 +18,11 @@ const { isDailyReportFormDisabled } = require('../../utils/daily-report-edit-sta ...@@ -18,6 +18,11 @@ const { isDailyReportFormDisabled } = require('../../utils/daily-report-edit-sta
const vinOcrBridge = require('../../services/vinOcrBridge.js') const vinOcrBridge = require('../../services/vinOcrBridge.js')
const { resolveVinFieldContext } = require('../../services/vin-ocr-context.js') const { resolveVinFieldContext } = require('../../services/vin-ocr-context.js')
const carBrandPickerBridge = require('../../services/carBrandPickerBridge.js') const carBrandPickerBridge = require('../../services/carBrandPickerBridge.js')
const {
clearPartialPlanImportMarker,
hasPartialPlanImportMarker,
resolveCarBrandValueForValidation
} = require('../../form-engine/car-brand-value.js')
const { getSubformRowTemplateForAdd } = require('../../form-engine/field-types.js') const { getSubformRowTemplateForAdd } = require('../../form-engine/field-types.js')
const { const {
buildCompleteFunAssignments, buildCompleteFunAssignments,
...@@ -821,6 +826,35 @@ Page({ ...@@ -821,6 +826,35 @@ Page({
/** 打开品牌选择页:四级车型走真实 merchant.info + scrm 接口(与 Loader brand mock 无关) */ /** 打开品牌选择页:四级车型走真实 merchant.info + scrm 接口(与 Loader brand mock 无关) */
openCarBrandForField({ childKey, groupKey, rowIndex } = {}) { openCarBrandForField({ childKey, groupKey, rowIndex } = {}) {
if (this.data.formDisabled || !childKey) return if (this.data.formDisabled || !childKey) return
// 导入三级车型点编辑后须四级选满:打开选车前清除导入豁免标记
if (this.engine) {
const viewState = this.engine.getViewState()
let currentValue
if (groupKey != null && rowIndex != null) {
const row = viewState.values?.[groupKey]?.[rowIndex]
const rowFields = viewState.groupRowsCache?.[groupKey]?.[rowIndex]
const rowField = rowFields?.find(field => field.key === childKey)
currentValue = resolveCarBrandValueForValidation(rowField, childKey, row?.[childKey])
} else {
currentValue = viewState.values?.[childKey]
}
if (hasPartialPlanImportMarker(currentValue)) {
const cleared = clearPartialPlanImportMarker(currentValue)
let clearedViewState
if (groupKey != null && rowIndex != null) {
clearedViewState = this.engine.mutateSubform(
groupKey,
rowIndex,
childKey,
{ metaValue: cleared },
{ appDualKey: true }
)
} else {
clearedViewState = this.engine.setFieldValue(childKey, cleared)
}
this.applyEngineView(clearedViewState, { structureChanged: false })
}
}
const page = this const page = this
const userInfo = wx.$util?.getUserInfo?.() || {} const userInfo = wx.$util?.getUserInfo?.() || {}
const merchantId = carBrandPickerBridge.resolveMerchantId( const merchantId = carBrandPickerBridge.resolveMerchantId(
......
...@@ -2,6 +2,7 @@ ...@@ -2,6 +2,7 @@
* 洽谈明细 — 从计划到店客户批量导入 subform 行 * 洽谈明细 — 从计划到店客户批量导入 subform 行
* @file 纯业务映射与容量校验,通过 engine.appendGroupRows 写入 * @file 纯业务映射与容量校验,通过 engine.appendGroupRows 写入
*/ */
const { PARTIAL_FROM_PLAN_IMPORT_KEY } = require('../form-engine/car-brand-value.js')
const { resolveSubformMaxRows } = require('../form-engine/subform-limits.js') const { resolveSubformMaxRows } = require('../form-engine/subform-limits.js')
const { formatCustomerCarSeriesLabel } = require('./today-plan-date.js') const { formatCustomerCarSeriesLabel } = require('./today-plan-date.js')
...@@ -86,7 +87,8 @@ function buildCustomerCarInfo(customer = {}) { ...@@ -86,7 +87,8 @@ function buildCustomerCarInfo(customer = {}) {
vehicleSubBrandName: carChildsBrandName, vehicleSubBrandName: carChildsBrandName,
vehicleSeriesId: carSeriesId, vehicleSeriesId: carSeriesId,
vehicleSeriesName: carSeriesName, vehicleSeriesName: carSeriesName,
displayText displayText,
[PARTIAL_FROM_PLAN_IMPORT_KEY]: true
} }
} }
......
...@@ -7,7 +7,9 @@ describe('car-brand-value', async () => { ...@@ -7,7 +7,9 @@ describe('car-brand-value', async () => {
normalizeCarBrandValue, normalizeCarBrandValue,
normalizeCarInfoFromPick, normalizeCarInfoFromPick,
isCarBrandComplete, isCarBrandComplete,
flattenCarBrandForSubmit flattenCarBrandForSubmit,
clearPartialPlanImportMarker,
PARTIAL_FROM_PLAN_IMPORT_KEY
} = await import('../form-engine/car-brand-value.js') } = await import('../form-engine/car-brand-value.js')
const sample = { const sample = {
...@@ -25,8 +27,22 @@ describe('car-brand-value', async () => { ...@@ -25,8 +27,22 @@ describe('car-brand-value', async () => {
assert.equal(buildDisplayText(sample), '岚图/岚图汽车/FREE/2024款') assert.equal(buildDisplayText(sample), '岚图/岚图汽车/FREE/2024款')
}) })
it('IT-CAR-VAL-002: isCarBrandComplete requires vehicleShapeId', () => { it('IT-CAR-VAL-002: isCarBrandComplete requires marker for import three levels', () => {
assert.equal(isCarBrandComplete(sample), true) assert.equal(isCarBrandComplete(sample), true)
const importPartial = {
vehicleBrandId: 3454,
vehicleBrandName: '问界',
vehicleSubBrandId: 1,
vehicleSubBrandName: '问界',
vehicleSeriesId: 101,
vehicleSeriesName: 'M7 Plus',
displayText: '问界-问界-M7 Plus',
[PARTIAL_FROM_PLAN_IMPORT_KEY]: true
}
assert.equal(isCarBrandComplete(importPartial), true)
const unmarkedPartial = { ...importPartial }
delete unmarkedPartial[PARTIAL_FROM_PLAN_IMPORT_KEY]
assert.equal(isCarBrandComplete(unmarkedPartial), false)
assert.equal(isCarBrandComplete({ vehicleBrandId: 1 }), false) assert.equal(isCarBrandComplete({ vehicleBrandId: 1 }), false)
assert.equal(isCarBrandComplete(null), false) assert.equal(isCarBrandComplete(null), false)
}) })
...@@ -119,4 +135,26 @@ describe('car-brand-value', async () => { ...@@ -119,4 +135,26 @@ describe('car-brand-value', async () => {
assert.equal(restored.vehicleShapeId, '4') assert.equal(restored.vehicleShapeId, '4')
assert.equal(restored.vehicleShapeName, '2024款') assert.equal(restored.vehicleShapeName, '2024款')
}) })
it('IT-CAR-VAL-008: cascadeLevelsToCarInfo restores partialFromPlanImport for 3 levels', async () => {
const { cascadeLevelsToCarInfo } = await import('../form-engine/car-brand-value.js')
const restored = cascadeLevelsToCarInfo([
{ id: '3454', name: '问界' },
{ id: '1', name: '问界' },
{ id: '101', name: 'M7 Plus' }
])
assert.equal(restored.partialFromPlanImport, true)
assert.equal(isCarBrandComplete(restored), true)
})
it('IT-CAR-VAL-009: clearPartialPlanImportMarker requires full pick after edit', () => {
const importPartial = {
vehicleSeriesId: 101,
vehicleSeriesName: 'M7 Plus',
[PARTIAL_FROM_PLAN_IMPORT_KEY]: true
}
const cleared = clearPartialPlanImportMarker(importPartial)
assert.equal(cleared.partialFromPlanImport, undefined)
assert.equal(isCarBrandComplete(cleared), false)
})
}) })
...@@ -11,10 +11,12 @@ describe('datetime-picker-mode', async () => { ...@@ -11,10 +11,12 @@ describe('datetime-picker-mode', async () => {
buildDatetimePickerState, buildDatetimePickerState,
clampDateTimeToNow, clampDateTimeToNow,
parseDateTimeLocal, parseDateTimeLocal,
endOfToday endOfToday,
formatMinutePickerValue,
parseMinutePickerDefaultTime
} = await import('../form-engine/datetime-picker-mode.js') } = await import('../form-engine/datetime-picker-mode.js')
it('IT-DATE-MINUTE-001: pickerPrecision minute uses dual date+time pickers', () => { it('IT-DATE-MINUTE-001: pickerPrecision minute uses minute popup mode', () => {
assert.equal(resolveWithTime({ pickerPrecision: 'minute', rules: { format: 'datetime' } }), true) assert.equal(resolveWithTime({ pickerPrecision: 'minute', rules: { format: 'datetime' } }), true)
const state = buildDatetimePickerState( const state = buildDatetimePickerState(
{ pickerPrecision: 'minute', rules: { maxDate: 'today' } }, { pickerPrecision: 'minute', rules: { maxDate: 'today' } },
...@@ -22,6 +24,7 @@ describe('datetime-picker-mode', async () => { ...@@ -22,6 +24,7 @@ describe('datetime-picker-mode', async () => {
) )
assert.equal(state.useMinutePicker, true) assert.equal(state.useMinutePicker, true)
assert.equal(state.pickerMode, undefined) assert.equal(state.pickerMode, undefined)
assert.equal(state.maxDateKind, 'today')
assert.equal(state.dateValue, '2026-06-01') assert.equal(state.dateValue, '2026-06-01')
assert.equal(state.timeValue, '14:30') assert.equal(state.timeValue, '14:30')
assert.equal(state.displayLabel, '2026-06-01 14:30') assert.equal(state.displayLabel, '2026-06-01 14:30')
...@@ -127,6 +130,18 @@ describe('datetime-picker-mode', async () => { ...@@ -127,6 +130,18 @@ describe('datetime-picker-mode', async () => {
) )
assert.equal(state.displayLabel, `${endOfToday()} 23:59`) assert.equal(state.displayLabel, `${endOfToday()} 23:59`)
}) })
it('IT-DATE-MINUTE-005: formatMinutePickerValue outputs YYYY-MM-DD HH:mm', () => {
assert.equal(formatMinutePickerValue('2026-06-01', '14', '30'), '2026-06-01 14:30')
assert.equal(formatMinutePickerValue('2026-06-01', '09', '05'), '2026-06-01 09:05')
})
it('IT-DATE-MINUTE-006: parseMinutePickerDefaultTime splits value', () => {
const parsed = parseMinutePickerDefaultTime('2026-06-01 14:30')
assert.equal(parsed.dateStr, '2026-06-01')
assert.equal(parsed.hour, 14)
assert.equal(parsed.minute, 30)
})
}) })
describe('datetime validation not after now', async () => { describe('datetime validation not after now', async () => {
......
...@@ -9,6 +9,7 @@ const { ...@@ -9,6 +9,7 @@ const {
validateCustomerImportCapacity, validateCustomerImportCapacity,
applyCustomersToEngine applyCustomersToEngine
} = require('../services/negotiationCustomerImport.js') } = require('../services/negotiationCustomerImport.js')
const { clearPartialPlanImportMarker } = require('../form-engine/car-brand-value.js')
const sampleCustomer = { const sampleCustomer = {
inviteDate: '2026-06-10', inviteDate: '2026-06-10',
...@@ -33,7 +34,7 @@ const subformGroup = { ...@@ -33,7 +34,7 @@ const subformGroup = {
{ key: 'F3-2-1', type: 'date', label: '交车日期' }, { key: 'F3-2-1', type: 'date', label: '交车日期' },
{ key: 'F3-2-4', type: 'input', label: '客户名称' }, { key: 'F3-2-4', type: 'input', label: '客户名称' },
{ key: 'F3-2-5', type: 'phoneInput', label: '客户手机号' }, { key: 'F3-2-5', type: 'phoneInput', label: '客户手机号' },
{ key: 'F3-2-6', type: 'carBrandSelect', label: '车型配置' }, { key: 'F3-2-6', type: 'carBrandSelect', label: '车型配置', required: true },
{ {
key: 'F3-2-8', key: 'F3-2-8',
type: 'select', type: 'select',
...@@ -52,6 +53,7 @@ describe('negotiationCustomerImport', () => { ...@@ -52,6 +53,7 @@ describe('negotiationCustomerImport', () => {
assert.equal(map['F3-2-1'], '2026-06-10') assert.equal(map['F3-2-1'], '2026-06-10')
assert.equal(map['F3-2-8'].id, 'staff-1') assert.equal(map['F3-2-8'].id, 'staff-1')
assert.equal(map['F3-2-6'].vehicleSeriesName, 'M7 Plus') assert.equal(map['F3-2-6'].vehicleSeriesName, 'M7 Plus')
assert.equal(map['F3-2-6'].partialFromPlanImport, true)
}) })
it('IT-PLAN-IMPORT-002: validateCustomerImportCapacity blocks over 20', () => { it('IT-PLAN-IMPORT-002: validateCustomerImportCapacity blocks over 20', () => {
...@@ -83,4 +85,69 @@ describe('negotiationCustomerImport', () => { ...@@ -83,4 +85,69 @@ describe('negotiationCustomerImport', () => {
const state = engine.getViewState() const state = engine.getViewState()
assert.equal((state.groupRowsCache['F3-2'] || []).length, 2) assert.equal((state.groupRowsCache['F3-2'] || []).length, 2)
}) })
it('IT-PLAN-IMPORT-005: imported partial carInfo passes carBrandSelect validation', async () => {
const { validateForm } = await import('../form-engine/validator.js')
const engine = createFormEngine({
list: [subformGroup],
version: 1
})
engine.init({ list: [subformGroup] }, { initialValues: {} })
const result = applyCustomersToEngine(engine, [sampleCustomer])
assert.equal(result.ok, true)
const state = engine.getViewState()
const validation = validateForm(
[subformGroup],
{},
state.values,
state.groupRowsCache
)
const carErrors = validation.errors.filter(e => e.label?.includes('车型配置'))
assert.equal(carErrors.length, 0)
})
it('IT-PLAN-IMPORT-006: unmarked three-level carInfo fails validation', async () => {
const { validateForm } = await import('../form-engine/validator.js')
const engine = createFormEngine({
list: [subformGroup],
version: 1
})
engine.init({ list: [subformGroup] }, { initialValues: {} })
const result = applyCustomersToEngine(engine, [sampleCustomer])
assert.equal(result.ok, true)
const carInfo = engine.getViewState().values['F3-2'][0]['F3-2-6']
const cleared = clearPartialPlanImportMarker(carInfo)
const state = engine.mutateSubform(
'F3-2',
0,
'F3-2-6',
{ metaValue: cleared },
{ appDualKey: true }
)
const validation = validateForm([subformGroup], {}, state.values, state.groupRowsCache)
const carErrors = validation.errors.filter(e => e.message?.includes('车型配置不能为空'))
assert.equal(carErrors.length, 1)
})
it('IT-PLAN-IMPORT-007: clearing import marker simulates tap-to-edit requiring level 4', async () => {
const { validateForm } = await import('../form-engine/validator.js')
const engine = createFormEngine({
list: [subformGroup],
version: 1
})
engine.init({ list: [subformGroup] }, { initialValues: {} })
applyCustomersToEngine(engine, [sampleCustomer])
const carInfo = engine.getViewState().values['F3-2'][0]['F3-2-6']
const cleared = clearPartialPlanImportMarker(carInfo)
assert.equal(cleared.partialFromPlanImport, undefined)
const state = engine.mutateSubform(
'F3-2',
0,
'F3-2-6',
{ metaValue: cleared },
{ appDualKey: true }
)
const validation = validateForm([subformGroup], {}, state.values, state.groupRowsCache)
assert.equal(validation.ok, false)
})
}) })
...@@ -23,7 +23,9 @@ Page({ ...@@ -23,7 +23,9 @@ Page({
lineSize: 3, // 笔记倍数 lineSize: 3, // 笔记倍数
radius: 1.5, //画圆的半径 radius: 1.5, //画圆的半径
showPlaceHoder: true, showPlaceHoder: true,
signImage: '' signImage: '',
exportWidth: 0,
exportHeight: 0
}, },
onRoute(options) { onRoute(options) {
let id = options.id || '' let id = options.id || ''
...@@ -136,6 +138,46 @@ Page({ ...@@ -136,6 +138,46 @@ Page({
tempFilePath: this.data.tempFilePath tempFilePath: this.data.tempFilePath
} }
}, },
/**
* 全屏横屏书写导出为竖图,逆时针旋转 90° 后供文档横向展示
* @param {string} tempFilePath 原画布临时路径
* @returns {Promise<string>} 旋转后的临时路径
*/
rotateSignatureImage(tempFilePath) {
const that = this
const { canvasWidth, canvasHeight } = this.data
const exportWidth = canvasHeight
const exportHeight = canvasWidth
return new Promise((resolve, reject) => {
this.setData({ exportWidth, exportHeight }, () => {
const ctx = wx.createCanvasContext('exportCanvas', that)
ctx.setFillStyle('#ffffff')
ctx.fillRect(0, 0, exportWidth, exportHeight)
ctx.translate(0, exportHeight)
ctx.rotate(-Math.PI / 2)
ctx.drawImage(tempFilePath, 0, 0, canvasWidth, canvasHeight)
ctx.draw(false, () => {
wx.canvasToTempFilePath({
x: 0,
y: 0,
width: exportWidth,
height: exportHeight,
destWidth: exportWidth,
destHeight: exportHeight,
canvasId: 'exportCanvas',
fileType: 'png',
success(res) {
resolve(res.tempFilePath)
},
fail(err) {
reject(err)
}
}, that)
})
})
})
},
saveToImage() { saveToImage() {
let { hasDraw, canvasHeight, canvasWidth } = this.data let { hasDraw, canvasHeight, canvasWidth } = this.data
let that = this let that = this
...@@ -156,19 +198,18 @@ Page({ ...@@ -156,19 +198,18 @@ Page({
canvasId: 'signature', canvasId: 'signature',
fileType: 'png', fileType: 'png',
success(res) { success(res) {
// //将图片保存到本地相册
// wx.saveImageToPhotosAlbum({
// filePath: res.tempFilePath,
// success(res) {
// // wx.$util.showToast('已将图片保存到本地相册', res)
// },
// fail(err) {
// wx.$util.showToast('失败', err)
// console.log(err)
// }
// })
if (res.tempFilePath) { if (res.tempFilePath) {
that.toUploadImage(res.tempFilePath) that.rotateSignatureImage(res.tempFilePath)
.then(rotatedPath => {
that.toUploadImage(rotatedPath)
})
.catch(err => {
console.log(err)
wx.showToast({
title: '签名处理失败',
icon: 'none'
})
})
} }
}, },
fail(err) { fail(err) {
......
...@@ -19,5 +19,8 @@ ...@@ -19,5 +19,8 @@
bindtouchend="scaleEnd" /> bindtouchend="scaleEnd" />
</view> </view>
<view wx:if="{{showPlaceHoder}}" class="placehoder">签字区</view> <view wx:if="{{showPlaceHoder}}" class="placehoder">签字区</view>
<canvas
canvas-id="exportCanvas"
style="position:fixed;left:-9999px;top:0;width:{{exportWidth}}px;height:{{exportHeight}}px;" />
</view> </view>
Markdown is supported
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!