import { getVModelHtml, formItemWrapper, colWrapper } from './common/htmlWrapper'
// 创建“el-time-picker”
function createTimePickerHtml(formJson, timeRange, parent) {
const vModel = getVModelHtml(formJson, timeRange, parent)
const width = timeRange.style && timeRange.style.width ? ':style="{width: \'100%\'}"' : ''
const disabled = timeRange.disabled ? ':disabled=\'true\'' : ''
const format = timeRange.format ? `format="${timeRange.format}"` : ''
const valueFormat = timeRange['value-format'] ? `value-format="${timeRange['value-format']}"` : ''
const startPlaceholder = timeRange['start-placeholder'] ? `start-placeholder="${timeRange['start-placeholder']}"` : ''
const endPlaceholder = timeRange['end-placeholder'] ? `end-placeholder="${timeRange['end-placeholder']}"` : ''
const rangeSeparator = timeRange['range-separator'] ? `range-separator="${timeRange['range-separator']}"` : ''
const isRange = timeRange['is-range'] ? 'is-range' : ''
return ``
}
/**
* 获取“时间范围”HTML
* @param formJson 表单结构
* @param timeRange “时间范围”组件
* @param parent 父组件(dialog, table...)
* @param isSomeSpanUnequal24 是否有的组件“span”不等于“24”
* @returns {string} “时间范围”HTML
*/
export default function getTimeRangeHtml(formJson, timeRange, parent, isSomeSpanUnequal24) {
// 创建“el-time-picker”
const timePickerHtml = createTimePickerHtml(formJson, timeRange, parent)
// 用“el-form-item”包裹“el-time-picker”
let formItemHtml = formItemWrapper(formJson, timeRange, timePickerHtml)
// span不为24的用“el-col”包裹组件
if (isSomeSpanUnequal24) {
formItemHtml = colWrapper(timeRange, formItemHtml)
}
return formItemHtml
}