hookehuyr

feat(分页组件): 添加导航按钮和提交按钮的颜色配置

支持自定义导航按钮和提交按钮的背景色和文字颜色
在预览模式下也启用分页功能
1 <!-- 1 <!--
2 * @Date: 2025-11-18 16:17:40 2 * @Date: 2025-11-18 16:17:40
3 * @LastEditors: hookehuyr hookehuyr@gmail.com 3 * @LastEditors: hookehuyr hookehuyr@gmail.com
4 - * @LastEditTime: 2025-11-25 14:48:19 4 + * @LastEditTime: 2025-11-26 17:17:14
5 * @FilePath: /data-table/src/components/PaginationField/index.vue 5 * @FilePath: /data-table/src/components/PaginationField/index.vue
6 * @Description: 分页组件 6 * @Description: 分页组件
7 --> 7 -->
...@@ -15,15 +15,22 @@ ...@@ -15,15 +15,22 @@
15 :disabled="prev_disabled_effective || current === 0" 15 :disabled="prev_disabled_effective || current === 0"
16 round 16 round
17 type="primary" 17 type="primary"
18 + :color="prevBtnColor"
18 class="btn" 19 class="btn"
19 @click="onPrev" 20 @click="onPrev"
20 - >{{ prev_label_effective }}</van-button> 21 + >
22 + <span :style="{ color: prevTextColor }">{{ prevLabel }}</span>
23 + </van-button>
21 </div> 24 </div>
22 <div class="actionsCenter"> 25 <div class="actionsCenter">
23 - <van-button v-if="showSubmit" round type="primary" class="btn" @click="onSubmit">{{ submitButton.text }}</van-button> 26 + <van-button v-if="showSubmit" round type="primary" :color="submitButton.btn_color" class="btn" @click="onSubmit">
27 + <span :style="{ color: submitButton.text_color }">{{ submitButton.text }}</span>
28 + </van-button>
24 </div> 29 </div>
25 <div class="actionsRight"> 30 <div class="actionsRight">
26 - <van-button v-if="showNext" round type="primary" class="btn" @click="onNext">{{ nextLabel }}</van-button> 31 + <van-button v-if="showNext" round type="primary" :color="nextBtnColor" class="btn" @click="onNext">
32 + <span :style="{ color: nextTextColor }">{{ nextLabel }}</span>
33 + </van-button>
27 </div> 34 </div>
28 </div> 35 </div>
29 </div> 36 </div>
...@@ -31,6 +38,7 @@ ...@@ -31,6 +38,7 @@
31 38
32 <script setup> 39 <script setup>
33 import { computed } from 'vue' 40 import { computed } from 'vue'
41 +import { styleColor } from "@/constant.js";
34 42
35 const props = defineProps({ 43 const props = defineProps({
36 current: { type: Number, default: 0 }, 44 current: { type: Number, default: 0 },
...@@ -38,7 +46,11 @@ const props = defineProps({ ...@@ -38,7 +46,11 @@ const props = defineProps({
38 isLast: { type: Boolean, default: false }, 46 isLast: { type: Boolean, default: false },
39 prevLabel: { type: String, default: '上一页' }, 47 prevLabel: { type: String, default: '上一页' },
40 nextLabel: { type: String, default: '下一页' }, 48 nextLabel: { type: String, default: '下一页' },
41 - submitButton: { type: Object, default: { text: '提交', back_title: '上一页', is_back: false } }, 49 + prevBtnColor: { type: String, default: styleColor.baseColor },
50 + nextBtnColor: { type: String, default: styleColor.baseColor },
51 + prevTextColor: { type: String, default: '#fff' },
52 + nextTextColor: { type: String, default: '#fff' },
53 + submitButton: { type: Object, default: { text: '提交', back_title: '上一页', is_back: false, btn_color: styleColor.baseColor, text_color: '#fff' } },
42 prevDisabled: { type: Boolean, default: false }, 54 prevDisabled: { type: Boolean, default: false },
43 }) 55 })
44 56
......
...@@ -6,6 +6,7 @@ ...@@ -6,6 +6,7 @@
6 */ 6 */
7 import { ref, computed, watch, nextTick } from 'vue' 7 import { ref, computed, watch, nextTick } from 'vue'
8 import { showToast } from 'vant' 8 import { showToast } from 'vant'
9 +import { styleColor } from "@/constant.js";
9 10
10 export function usePagination(formDataRef, options = {}) { 11 export function usePagination(formDataRef, options = {}) {
11 const { myFormRef, validOther, afterSwitch } = options 12 const { myFormRef, validOther, afterSwitch } = options
...@@ -53,15 +54,20 @@ export function usePagination(formDataRef, options = {}) { ...@@ -53,15 +54,20 @@ export function usePagination(formDataRef, options = {}) {
53 /** 54 /**
54 * 规范化分页符属性为导航配置 55 * 规范化分页符属性为导航配置
55 * @param {Object} props 分页符的 component_props 56 * @param {Object} props 分页符的 component_props
56 - * @returns {{prev_text: string, next_text: string, prev_disabled: boolean}} 导航配置 57 + * @returns {{prev_text: string, next_text: string, prev_disabled: boolean, prev_btn_color: string, next_btn_color: string, prev_text_color: string, next_text_color: string}} 导航配置
57 */ 58 */
58 const normalizePaginatorProps = (props = {}) => { 59 const normalizePaginatorProps = (props = {}) => {
59 // 中文文案默认值 60 // 中文文案默认值
60 - const nav = { prev_text: '上一页', next_text: '下一页', prev_disabled: false } 61 + const nav = { prev_text: '上一页', next_text: '下一页', prev_disabled: false, prev_btn_color: styleColor.baseColor, next_btn_color: styleColor.baseColor, prev_text_color: '#fff', next_text_color: '#fff' }
61 if (props.back_title) nav.prev_text = props.back_title 62 if (props.back_title) nav.prev_text = props.back_title
62 if (props.next_title) nav.next_text = props.next_title 63 if (props.next_title) nav.next_text = props.next_title
63 // 是否允许返回:true 允许,false 不允许 64 // 是否允许返回:true 允许,false 不允许
64 if (typeof props.is_back === 'boolean') nav.prev_disabled = !props.is_back 65 if (typeof props.is_back === 'boolean') nav.prev_disabled = !props.is_back
66 + // 导航颜色
67 + if (props.back_background_color) nav.prev_btn_color = props.back_background_color
68 + if (props.next_background_color) nav.next_btn_color = props.next_background_color
69 + if (props.back_color) nav.prev_text_color = props.back_color
70 + if (props.next_color) nav.next_text_color = props.next_color
65 return nav 71 return nav
66 } 72 }
67 73
......
1 <!-- 1 <!--
2 * @Date: 2022-07-18 10:22:22 2 * @Date: 2022-07-18 10:22:22
3 * @LastEditors: hookehuyr hookehuyr@gmail.com 3 * @LastEditors: hookehuyr hookehuyr@gmail.com
4 - * @LastEditTime: 2025-11-25 16:20:30 4 + * @LastEditTime: 2025-11-26 19:52:55
5 * @FilePath: /data-table/src/views/index.vue 5 * @FilePath: /data-table/src/views/index.vue
6 * @Description: 首页 6 * @Description: 首页
7 --> 7 -->
...@@ -40,6 +40,10 @@ ...@@ -40,6 +40,10 @@
40 :is-last="current_page_index === filtered_pages.length - 1" 40 :is-last="current_page_index === filtered_pages.length - 1"
41 :prev-label="page_nav.prev_text" 41 :prev-label="page_nav.prev_text"
42 :next-label="page_nav.next_text" 42 :next-label="page_nav.next_text"
43 + :prev-btn-color="page_nav.prev_btn_color"
44 + :next-btn-color="page_nav.next_btn_color"
45 + :prev-text-color="page_nav.prev_text_color"
46 + :next-text-color="page_nav.next_text_color"
43 :submit-button="PCommit" 47 :submit-button="PCommit"
44 :prev-disabled="page_nav.prev_disabled" 48 :prev-disabled="page_nav.prev_disabled"
45 @prev="handlePrev" 49 @prev="handlePrev"
...@@ -48,8 +52,8 @@ ...@@ -48,8 +52,8 @@
48 /> 52 />
49 <!-- 非流程版表单 --> 53 <!-- 非流程版表单 -->
50 <div v-if="formData.length && PCommit.visible && !formSetting.is_flow && !enable_pagination" style="margin: 16px"> 54 <div v-if="formData.length && PCommit.visible && !formSetting.is_flow && !enable_pagination" style="margin: 16px">
51 - <van-button round block type="primary" native-type="submit" :disabled="submitStatus"> 55 + <van-button round block type="primary" :color="PCommit.btn_color" native-type="submit" :disabled="submitStatus">
52 - {{ PCommit.text ? PCommit.text : '提交' }} 56 + <span :style="{ color: PCommit.text_color }">{{ PCommit.text ? PCommit.text : '提交' }}</span>
53 </van-button> 57 </van-button>
54 </div> 58 </div>
55 <!-- 流程表单 --> 59 <!-- 流程表单 -->
...@@ -478,6 +482,8 @@ onMounted(async () => { ...@@ -478,6 +482,8 @@ onMounted(async () => {
478 visible: !page_commit.invisible, 482 visible: !page_commit.invisible,
479 is_back: page_commit.is_back, 483 is_back: page_commit.is_back,
480 back_title: page_commit.back_title, 484 back_title: page_commit.back_title,
485 + btn_color: page_commit.background_color,
486 + text_color: page_commit.color,
481 }; 487 };
482 } 488 }
483 489
...@@ -500,7 +506,7 @@ onMounted(async () => { ...@@ -500,7 +506,7 @@ onMounted(async () => {
500 506
501 formData.value = formatData(page_form); 507 formData.value = formatData(page_form);
502 // TAG: 构建分页组件 508 // TAG: 构建分页组件
503 - if (page_type === 'add' || page_type === undefined) { 509 + if (page_type === 'add' || page_type === undefined || model === 'preview') {
504 buildPages(); 510 buildPages();
505 enable_pagination.value = filtered_pages.value.length > 1; 511 enable_pagination.value = filtered_pages.value.length > 1;
506 } 512 }
......