hookehuyr

✨ feat(评分控件): 样式和功能调整

...@@ -45,6 +45,7 @@ declare module '@vue/runtime-core' { ...@@ -45,6 +45,7 @@ declare module '@vue/runtime-core' {
45 NutPopup: typeof import('@nutui/nutui-taro')['Popup'] 45 NutPopup: typeof import('@nutui/nutui-taro')['Popup']
46 NutRadio: typeof import('@nutui/nutui-taro')['Radio'] 46 NutRadio: typeof import('@nutui/nutui-taro')['Radio']
47 NutRadioGroup: typeof import('@nutui/nutui-taro')['RadioGroup'] 47 NutRadioGroup: typeof import('@nutui/nutui-taro')['RadioGroup']
48 + NutRate: typeof import('@nutui/nutui-taro')['Rate']
48 NutSwiper: typeof import('@nutui/nutui-taro')['Swiper'] 49 NutSwiper: typeof import('@nutui/nutui-taro')['Swiper']
49 NutSwiperItem: typeof import('@nutui/nutui-taro')['SwiperItem'] 50 NutSwiperItem: typeof import('@nutui/nutui-taro')['SwiperItem']
50 NutTextarea: typeof import('@nutui/nutui-taro')['Textarea'] 51 NutTextarea: typeof import('@nutui/nutui-taro')['Textarea']
......
1 <!-- 1 <!--
2 * @Date: 2022-09-08 15:47:54 2 * @Date: 2022-09-08 15:47:54
3 * @LastEditors: hookehuyr hookehuyr@gmail.com 3 * @LastEditors: hookehuyr hookehuyr@gmail.com
4 - * @LastEditTime: 2023-01-31 22:57:40 4 + * @LastEditTime: 2023-04-10 16:01:09
5 - * @FilePath: /data-table/src/components/RatePickerField/index.vue 5 + * @FilePath: /custom_form/src/components/RatePickerField/index.vue
6 * @Description: 评分选择控件 6 * @Description: 评分选择控件
7 --> 7 -->
8 <template> 8 <template>
9 <div v-if="HideShow" class="rate-field"> 9 <div v-if="HideShow" class="rate-field">
10 <div class="label"> 10 <div class="label">
11 - <span v-if="item.component_props.required">&nbsp;*</span> 11 + <text v-if="item.component_props.required">&nbsp;*</text>
12 {{ item.component_props.label }} 12 {{ item.component_props.label }}
13 </div> 13 </div>
14 - <van-rate 14 + <nut-rate
15 v-model="rate_value" 15 v-model="rate_value"
16 :count="item.component_props.data_length" 16 :count="item.component_props.data_length"
17 :readonly="item.component_props.readonly" 17 :readonly="item.component_props.readonly"
18 - :color="styleColor.baseColor" 18 + :active-color="styleColor.baseColor"
19 @change="onChange" 19 @change="onChange"
20 - style="padding: 1rem" 20 + style="overflow: scroll; width: 100%;"
21 /> 21 />
22 <div 22 <div
23 - v-if="show_empty" 23 + v-if="show_error"
24 - class="van-field__error-message" 24 + style="padding: 5px; color: red; font-size: 12px;"
25 - style="padding: 0 1rem 1rem 1rem"
26 > 25 >
27 - 评分不能为空 26 + {{ error_msg }}
28 </div> 27 </div>
29 - <van-divider /> 28 + <nut-divider :style="{ color: '#ebedf0' }" />
30 </div> 29 </div>
31 </template> 30 </template>
32 31
33 <script setup> 32 <script setup>
33 +import { ref, computed, watch, onMounted, reactive } from "vue";
34 import { styleColor } from "@/constant.js"; 34 import { styleColor } from "@/constant.js";
35 35
36 const props = defineProps({ 36 const props = defineProps({
...@@ -41,7 +41,9 @@ const HideShow = computed(() => { ...@@ -41,7 +41,9 @@ const HideShow = computed(() => {
41 return !props.item.component_props.disabled 41 return !props.item.component_props.disabled
42 }) 42 })
43 const emit = defineEmits(["active"]); 43 const emit = defineEmits(["active"]);
44 -const show_empty = ref(false); 44 +// 错误提示
45 +const show_error = ref(false);
46 +const error_msg = ref('');
45 const rate_value = ref(props.item.component_props.default); 47 const rate_value = ref(props.item.component_props.default);
46 48
47 const onChange = (value) => { 49 const onChange = (value) => {
...@@ -56,27 +58,30 @@ onMounted(() => { ...@@ -56,27 +58,30 @@ onMounted(() => {
56 58
57 const validRate = () => { 59 const validRate = () => {
58 // 必填项 60 // 必填项
59 - if (props.item.component_props.required && !rate_value.value) { 61 + if (props.item.component_props.required && !+rate_value.value) {
60 - show_empty.value = true; 62 + show_error.value = true;
63 + error_msg.value = '必填项不能为空'
61 } else { 64 } else {
62 - show_empty.value = false; 65 + show_error.value = false;
66 + error_msg.value = ''
63 } 67 }
64 - return !show_empty.value; 68 + return !show_error.value;
65 }; 69 };
66 70
67 defineExpose({ validRate }); 71 defineExpose({ validRate });
68 </script> 72 </script>
69 73
70 -<style lang="less" scoped> 74 +<style lang="less">
71 .rate-field { 75 .rate-field {
76 + margin: 1rem;
72 .label { 77 .label {
73 - padding: 1rem 1rem 0 1rem; 78 + padding-bottom: 20px;
74 - font-size: 0.9rem; 79 + font-size: 26px;
75 font-weight: bold; 80 font-weight: bold;
76 81
77 - span { 82 + text {
78 color: red; 83 color: red;
79 } 84 }
80 - } 85 +}
81 } 86 }
82 </style> 87 </style>
......
...@@ -13,7 +13,7 @@ import DateTimePickerField from '@/components/DateTimePickerField/index.vue' ...@@ -13,7 +13,7 @@ import DateTimePickerField from '@/components/DateTimePickerField/index.vue'
13 import PhoneField from '@/components/PhoneField/index.vue' 13 import PhoneField from '@/components/PhoneField/index.vue'
14 import EmailField from '@/components/EmailField/index.vue' 14 import EmailField from '@/components/EmailField/index.vue'
15 // import SignField from '@/components/SignField/index.vue' 15 // import SignField from '@/components/SignField/index.vue'
16 -// import RatePickerField from '@/components/RatePickerField/index.vue' 16 +import RatePickerField from '@/components/RatePickerField/index.vue'
17 // import CalendarField from '@/components/CalendarField/index.vue' 17 // import CalendarField from '@/components/CalendarField/index.vue'
18 import IdentityField from '@/components/IdentityField/index.vue' 18 import IdentityField from '@/components/IdentityField/index.vue'
19 import NumberField from '@/components/NumberField/index.vue' 19 import NumberField from '@/components/NumberField/index.vue'
...@@ -123,10 +123,10 @@ export function createComponentType(data) { ...@@ -123,10 +123,10 @@ export function createComponentType(data) {
123 // item.name = item.key 123 // item.name = item.key
124 // item.component = SignField 124 // item.component = SignField
125 // } 125 // }
126 - // if (item.component_props.tag === 'rate') { 126 + if (item.component_props.tag === 'rate') {
127 - // item.name = item.key 127 + item.name = item.key
128 - // item.component = RatePickerField 128 + item.component = RatePickerField
129 - // } 129 + }
130 // if (item.component_props.tag === 'calendar') { 130 // if (item.component_props.tag === 'calendar') {
131 // item.name = item.key 131 // item.name = item.key
132 // item.component = CalendarField 132 // item.component = CalendarField
......
1 <!-- 1 <!--
2 * @Date: 2023-03-24 09:19:27 2 * @Date: 2023-03-24 09:19:27
3 * @LastEditors: hookehuyr hookehuyr@gmail.com 3 * @LastEditors: hookehuyr hookehuyr@gmail.com
4 - * @LastEditTime: 2023-04-10 14:38:57 4 + * @LastEditTime: 2023-04-10 15:58:46
5 * @FilePath: /custom_form/src/pages/table/index.vue 5 * @FilePath: /custom_form/src/pages/table/index.vue
6 * @Description: 文件描述 6 * @Description: 文件描述
7 --> 7 -->
...@@ -202,7 +202,7 @@ const setRefMap = (el, item) => { ...@@ -202,7 +202,7 @@ const setRefMap = (el, item) => {
202 if (item.component_props.tag === "sign") { 202 if (item.component_props.tag === "sign") {
203 sign.value.push(el); 203 sign.value.push(el);
204 } 204 }
205 - if (item.component_props.tag === "rate_picker") { 205 + if (item.component_props.tag === "rate") {
206 rate_picker.value.push(el); 206 rate_picker.value.push(el);
207 } 207 }
208 } 208 }
...@@ -483,7 +483,7 @@ const onActive = (item) => { ...@@ -483,7 +483,7 @@ const onActive = (item) => {
483 postData.value[item.filed_name] = item.value; 483 postData.value[item.filed_name] = item.value;
484 } 484 }
485 if (item.type === "rate") { 485 if (item.type === "rate") {
486 - postData.value = _.assign(postData.value, { [item.key]: item.value }); 486 + postData.value = Object.assign(postData.value, { [item.key]: item.value });
487 } 487 }
488 if (item.key === "picker") { // 下拉框控件 488 if (item.key === "picker") { // 下拉框控件
489 postData.value = Object.assign(postData.value, { [item.filed_name]: item.value }); 489 postData.value = Object.assign(postData.value, { [item.filed_name]: item.value });
......