starfish-form-custom 1.0.28 → 1.0.29
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/package.json
CHANGED
|
@@ -9,7 +9,7 @@
|
|
|
9
9
|
</div>
|
|
10
10
|
<div class="control" :style="{marginLeft: labelalign != 'top'?labelWidth + 'px': ''}">
|
|
11
11
|
<!-- 只读的时候就只展示文本 -->
|
|
12
|
-
<span v-if="!drag && data[item.data.fieldName] && (item.data.state === 'readonly' || readonly)">{{ data[item.data.fieldName].join(',') || '--' }}</span>
|
|
12
|
+
<span v-if="!drag && data[item.data.fieldName] && (item.data.state === 'readonly' || readonly)">{{ Array.isArray(data[item.data.fieldName]) ? data[item.data.fieldName].join(',') || '--' : data[item.data.fieldName] || '--' }}</span>
|
|
13
13
|
<el-checkbox-group v-model="data[item.data.fieldName]" :class="{'vertical-group': item.data.arrangeMent === 'vertical'}" v-else-if="!drag && data[item.data.fieldName]" :size="size" :disabled="item.data.state === 'disabled' || item.data.state === 'readonly'">
|
|
14
14
|
<el-checkbox v-for="(sitem, sindex) in item.data.itemConfig.items" :key="sindex" :label="sitem.value">{{ sitem.label }}</el-checkbox>
|
|
15
15
|
</el-checkbox-group>
|
|
@@ -9,7 +9,8 @@
|
|
|
9
9
|
</div>
|
|
10
10
|
<div class="control" :style="{marginLeft: labelalign != 'top'?labelWidth + 'px': ''}">
|
|
11
11
|
<el-date-picker v-model="item.data.default" type="datetime" :placeholder="item.data.placeholder" v-if="drag" :size="size" :disabled="item.data.state === 'disabled'" :readonly="item.data.state === 'readonly'"> </el-date-picker>
|
|
12
|
-
<
|
|
12
|
+
<span v-if="!drag && (item.data.state === 'readonly' || readonly)">{{ formatReadonlyDate(data[item.data.fieldName], item.data.format) }}</span>
|
|
13
|
+
<el-date-picker v-model="data[item.data.fieldName]" type="datetime" :placeholder="item.data.placeholder" v-else-if="!drag" :size="size" :disabled="item.data.state === 'disabled'" :readonly="item.data.state === 'readonly'"> </el-date-picker>
|
|
13
14
|
</div>
|
|
14
15
|
</div>
|
|
15
16
|
</template>
|
|
@@ -34,6 +35,42 @@
|
|
|
34
35
|
},
|
|
35
36
|
setup(props) {
|
|
36
37
|
useWatch(props);
|
|
38
|
+
// 格式化只读日期显示
|
|
39
|
+
const formatReadonlyDate = (dateValue: any, format: string) => {
|
|
40
|
+
if (!dateValue) return '--';
|
|
41
|
+
|
|
42
|
+
// 如果已经是格式化好的字符串,直接返回
|
|
43
|
+
if (typeof dateValue === 'string') {
|
|
44
|
+
return dateValue;
|
|
45
|
+
}
|
|
46
|
+
|
|
47
|
+
// 如果是日期对象,进行格式化
|
|
48
|
+
if (dateValue instanceof Date) {
|
|
49
|
+
const year = dateValue.getFullYear();
|
|
50
|
+
const month = String(dateValue.getMonth() + 1).padStart(2, '0');
|
|
51
|
+
const day = String(dateValue.getDate()).padStart(2, '0');
|
|
52
|
+
const hours = String(dateValue.getHours()).padStart(2, '0');
|
|
53
|
+
const minutes = String(dateValue.getMinutes()).padStart(2, '0');
|
|
54
|
+
const seconds = String(dateValue.getSeconds()).padStart(2, '0');
|
|
55
|
+
|
|
56
|
+
const formatMap: Record<string, string> = {
|
|
57
|
+
'YYYY': `${year}`,
|
|
58
|
+
'YYYY-MM': `${year}-${month}`,
|
|
59
|
+
'YYYY-MM-DD': `${year}-${month}-${day}`,
|
|
60
|
+
'YYYY-MM-DD HH': `${year}-${month}-${day} ${hours}`,
|
|
61
|
+
'YYYY-MM-DD HH:mm': `${year}-${month}-${day} ${hours}:${minutes}`,
|
|
62
|
+
'YYYY-MM-DD HH:mm:ss': `${year}-${month}-${day} ${hours}:${minutes}:${seconds}`
|
|
63
|
+
};
|
|
64
|
+
|
|
65
|
+
return formatMap[format] || `${year}-${month}-${day}`;
|
|
66
|
+
}
|
|
67
|
+
|
|
68
|
+
// 其他情况返回原始值
|
|
69
|
+
return String(dateValue);
|
|
70
|
+
};
|
|
71
|
+
return {
|
|
72
|
+
formatReadonlyDate
|
|
73
|
+
};
|
|
37
74
|
},
|
|
38
75
|
});
|
|
39
76
|
</script>
|
|
@@ -44,7 +44,7 @@
|
|
|
44
44
|
:value="items.value"
|
|
45
45
|
/>
|
|
46
46
|
</el-select>
|
|
47
|
-
<span v-if="!drag && (item.data.state === 'readonly' || readonly)">{{ data[item.data.fieldName].join(',') || '--' }}</span>
|
|
47
|
+
<span v-if="!drag && (item.data.state === 'readonly' || readonly)">{{ Array.isArray(data[item.data.fieldName]) ? data[item.data.fieldName].join(',') || '--' : data[item.data.fieldName] || '--' }}</span>
|
|
48
48
|
<el-select
|
|
49
49
|
v-model="data[item.data.fieldName]"
|
|
50
50
|
style="width: 320px;"
|