提交 935d6cba 作者: 方治民

style: 代码格式调整

上级 f594f7fd
...@@ -2,6 +2,7 @@ ...@@ -2,6 +2,7 @@
import { getData } from './data' import { getData } from './data'
interface Params { interface Params {
title?: string
multiple?: boolean multiple?: boolean
} }
...@@ -10,7 +11,7 @@ ...@@ -10,7 +11,7 @@
search: '', search: '',
data: [] as Recordable[], data: [] as Recordable[],
show: false, show: false,
permissions: [], buttons: [],
}) })
const data = computed(() => { const data = computed(() => {
...@@ -32,22 +33,24 @@ ...@@ -32,22 +33,24 @@
} }
}) })
const permissionButtonWidth = computed(() => { onLoad(({ multiple, title }) => {
const len = model.permissions.length model.params.title = title
return (750 - 60) / len - (len - 1) * (30 / len)
})
onLoad(({ multiple }) => {
model.params.multiple = multiple === 'true' model.params.multiple = multiple === 'true'
// 自定义设置标题
if (title) {
uni.setNavigationBarTitle({ title })
}
// 获取人员列表 // 获取人员列表
Message.loading('加载中...') Message.loading('加载中...')
model.data = getData() model.data = getData()
Message.hideLoading() Message.hideLoading()
model.permissions = [] // 操作项
model.buttons = []
if (model.params.multiple) { if (model.params.multiple) {
model.permissions.push({ model.buttons.push({
name: '确定', name: '确定',
value: 'SUBMIT', value: 'SUBMIT',
type: 'primary', type: 'primary',
...@@ -80,6 +83,11 @@ ...@@ -80,6 +83,11 @@
uni.$emit('chooseShootOrderReceiverUser', result) uni.$emit('chooseShootOrderReceiverUser', result)
uni.navigateBack() uni.navigateBack()
} }
const buttonWidth = computed(() => {
const len = model.buttons.length
return (750 - 60) / len - (len - 1) * (30 / len)
})
</script> </script>
<template> <template>
...@@ -111,13 +119,13 @@ ...@@ -111,13 +119,13 @@
<!-- 操作按钮 --> <!-- 操作按钮 -->
<view class="opts-wrap"> <view class="opts-wrap">
<fui-button <fui-button
v-for="opt in model.permissions" v-for="opt in model.buttons"
:key="opt.value" :key="opt.value"
@tap="opt.onClick" @tap="opt.onClick"
:text="opt.name" :text="opt.name"
:type="opt.type" :type="opt.type"
radius="96rpx" radius="96rpx"
:width="`${permissionButtonWidth}rpx`" :width="`${buttonWidth}rpx`"
height="96rpx" height="96rpx"
/> />
</view> </view>
......
Markdown 格式
0%
您添加了 0 到此讨论。请谨慎行事。
请先完成此评论的编辑!
注册 或者 后发表评论