| 123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202 |
- <template>
- <!--
- 统一成员选择弹出控件(底部弹出面板)
- 位置:pages/health/components/ —— 位于 pages/health 分包内,
- 仅供该分包页面引用;主包/其他分包页面不可引用(分包组件不支持跨分包/主包引用)。
- 当前使用方:pages/health/report-list.vue(「调整报告归属」面板)。
- 蓝本:components/wuxing-sandbox.vue 的 member-picker-mask / member-picker-panel
- (首页能量沙盘「切换视角」成员选择弹出页)。
- 用途:替换「需要弹出选择成员」的自定义底部弹出场景。
- 约定:
- · options 由调用方构建,每项形如 { key, label, memberId, active, member, ...ext }
- —— active 为布尔,由调用方或本组件 activeKey 预计算,避免模板 :class 方法调用。
- · 选中项显示右侧 check 图标;「取消归属」等特殊操作经 showCancel 呈现为顶部红色行。
- · emit('select', option) 携带整项,由调用方决定后续动作(如 reassignReport)。
- · emit('close'):遮罩点击 / 右上角 ×。
- · emit('cancel-bind'):点击「取消归属」行。
- -->
- <view v-if="visible" class="member-picker-mask" @click="emitClose">
- <view class="member-picker-panel" @click.stop>
- <view class="member-picker-title">{{ title }}</view>
- <!-- 特殊操作:取消归属(可选) -->
- <view class="member-picker-cancel" v-if="showCancel" @click="emitCancelBind">
- <text class="member-picker-cancel-text">{{ cancelText }}</text>
- <text class="member-picker-cancel-arrow">×</text>
- </view>
- <!-- 成员选项列表 -->
- <view
- v-for="option in renderedOptions"
- :key="option.key"
- class="member-picker-item"
- :class="{ 'member-picker-item--active': option.active }"
- @click="emitSelect(option)"
- >
- <text class="member-picker-label">{{ option.label }}</text>
- <image class="member-picker-check" v-if="option.active" :src="checkIcon" mode="aspectFit"></image>
- </view>
- <!-- 空态 -->
- <view class="member-picker-empty" v-if="renderedOptions.length === 0">
- <text class="member-picker-empty-text">{{ emptyText }}</text>
- </view>
- </view>
- </view>
- </template>
- <script>
- /** 选中 check 图标(内联 SVG data URI,品牌深橙 #C2410C,与蓝本 member-picker-check 一致) */
- function svgUri(paths, color) {
- var inner = ''
- for (var i = 0; i < paths.length; i++) {
- inner += '<path d="' + paths[i] + '"/>'
- }
- var svg = '<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 24 24" fill="none" stroke="' +
- color + '" stroke-width="1.8" stroke-linecap="round" stroke-linejoin="round">' + inner + '</svg>'
- return 'data:image/svg+xml,' + encodeURIComponent(svg)
- }
- var CHECK_ICON = svgUri(['M5 12.8 9.6 17.4 19 7.6'], '#C2410C')
- export default {
- name: 'MemberPickerPopup',
- props: {
- /** 是否显示 */
- visible: { type: Boolean, default: false },
- /** 面板标题 */
- title: { type: String, default: '选择成员' },
- /** 选项数组:{ key, label, memberId, active, member, ...ext } */
- options: { type: Array, default: function() { return [] } },
- /** 当前选中 key(可选)。传入后组件自动为匹配项计算 active,调用方可不预计算 */
- activeKey: { type: [String, Number], default: null },
- /** 是否显示「取消归属」等特殊操作行 */
- showCancel: { type: Boolean, default: false },
- /** 特殊操作行文案 */
- cancelText: { type: String, default: '取消归属' },
- /** 空态文案 */
- emptyText: { type: String, default: '暂无成员' }
- },
- data() {
- return {
- checkIcon: CHECK_ICON
- }
- },
- computed: {
- renderedOptions: function() {
- var list = this.options instanceof Array ? this.options : []
- if (this.activeKey === null || this.activeKey === undefined || this.activeKey === '') {
- return list
- }
- var target = String(this.activeKey)
- return list.map(function(option) {
- // 保留调用方附加字段(viewMode/member/...),仅覆盖 active —— 供 select 回调按需读取
- var copy = {}
- for (var k in option) {
- if (Object.prototype.hasOwnProperty.call(option, k)) copy[k] = option[k]
- }
- copy.active = option.active === true || String(option.key) === target
- return copy
- })
- }
- },
- methods: {
- emitClose: function() {
- this.$emit('close')
- },
- emitCancelBind: function() {
- this.$emit('cancel-bind')
- },
- emitSelect: function(option) {
- this.$emit('select', option)
- }
- }
- }
- </script>
- <style lang="scss" scoped>
- /* ---- 统一成员选择弹出面板(蓝本:wuxing-sandbox member-picker) ---- */
- .member-picker-mask {
- position: fixed;
- top: 0;
- right: 0;
- bottom: 0;
- left: 0;
- z-index: 999;
- display: flex;
- align-items: flex-end;
- background: rgba(0, 0, 0, 0.42);
- }
- .member-picker-panel {
- width: 100%;
- max-height: 70vh;
- overflow-y: auto;
- box-sizing: border-box;
- padding: 28rpx 28rpx calc(24rpx + env(safe-area-inset-bottom));
- background: $app-surface;
- border-radius: 24rpx 24rpx 0 0;
- box-shadow: 0 -8rpx 32rpx rgba(0, 0, 0, 0.12);
- }
- .member-picker-title {
- padding-bottom: 16rpx;
- font-size: calc(26rpx * var(--font-scale, 1));
- font-weight: 700;
- color: $app-text;
- text-align: center;
- }
- /* 「取消归属」特殊操作行(红色强调,呼应 report-list 原 cancel-bind-option) */
- .member-picker-cancel {
- display: flex;
- align-items: center;
- justify-content: space-between;
- padding: 24rpx 0;
- border-bottom: 1rpx solid $facade-fill;
- margin-bottom: 8rpx;
- }
- .member-picker-cancel-text {
- font-size: calc(28rpx * var(--font-scale, 1));
- color: $el-danger;
- }
- .member-picker-cancel-arrow {
- font-size: calc(32rpx * var(--font-scale, 1));
- color: $facade-text-ghost;
- }
- .member-picker-item {
- display: flex;
- align-items: center;
- justify-content: space-between;
- min-height: 88rpx;
- padding: 0 24rpx;
- margin-top: 8rpx;
- border-radius: 16rpx;
- background: $app-bg;
- }
- .member-picker-item--active {
- background: $brand-primary-soft;
- }
- .member-picker-label {
- font-size: calc(28rpx * var(--font-scale, 1));
- color: $app-text;
- }
- .member-picker-item--active .member-picker-label {
- color: $brand-primary-deep;
- font-weight: 700;
- }
- .member-picker-check {
- width: 34rpx;
- height: 34rpx;
- flex-shrink: 0;
- }
- .member-picker-empty {
- padding: 40rpx 0;
- text-align: center;
- }
- .member-picker-empty-text {
- font-size: calc(26rpx * var(--font-scale, 1));
- color: $facade-text-ghost;
- }
- </style>
|