oa_app仓库初始化
This commit is contained in:
@@ -0,0 +1,65 @@
|
||||
<template>
|
||||
<view v-if="files.length || editable" class="wrap">
|
||||
<text v-if="label" class="lab">{{ label }}</text>
|
||||
<view class="list">
|
||||
<view v-for="(f, i) in files" :key="fileKey(f, i)" class="chip" @click="open(f)">
|
||||
<text class="name">{{ displayName(f) }}</text>
|
||||
<text v-if="editable" class="del" @click.stop="$emit('remove', i)">×</text>
|
||||
</view>
|
||||
<view v-if="editable" class="add" @click="add">+ {{ files.length ? '再加一份' : '上传附件' }}</view>
|
||||
</view>
|
||||
<text v-if="!files.length && !editable" class="empty">无附件</text>
|
||||
</view>
|
||||
</template>
|
||||
|
||||
<script>
|
||||
import { store } from '../utils/store.js'
|
||||
import { fileId, fileName, pickAndUpload, openFile } from '../utils/files.js'
|
||||
import { toast } from '../utils/format.js'
|
||||
|
||||
export default {
|
||||
name: 'FyFiles',
|
||||
props: {
|
||||
files: { type: Array, default: () => [] },
|
||||
label: { type: String, default: '附件' },
|
||||
editable: { type: Boolean, default: false },
|
||||
kind: { type: String, default: 'attach' }
|
||||
},
|
||||
methods: {
|
||||
fileKey(f, i) { return fileId(f) || fileName(f) + i },
|
||||
displayName(f) { return fileName(f) },
|
||||
async add() {
|
||||
try {
|
||||
const rows = await pickAndUpload(store.token, this.kind)
|
||||
if (rows.length) this.$emit('update:files', [...this.files, ...rows])
|
||||
} catch (e) {
|
||||
toast((e && e.message) || '上传失败')
|
||||
}
|
||||
},
|
||||
open(f) {
|
||||
openFile(f, store.token)
|
||||
}
|
||||
}
|
||||
}
|
||||
</script>
|
||||
|
||||
<style scoped>
|
||||
.wrap { margin: 12rpx 0; }
|
||||
.lab { font-size: 24rpx; color: #434655; display: block; margin-bottom: 8rpx; }
|
||||
.list { display: flex; flex-wrap: wrap; gap: 12rpx; }
|
||||
.chip, .add {
|
||||
font-size: 22rpx;
|
||||
padding: 10rpx 16rpx;
|
||||
border-radius: 12rpx;
|
||||
background: #fff;
|
||||
border: 1rpx solid #dbe1ff;
|
||||
color: #2563eb;
|
||||
display: flex;
|
||||
align-items: center;
|
||||
max-width: 100%;
|
||||
}
|
||||
.name { max-width: 360rpx; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
|
||||
.del { color: #ba1a1a; margin-left: 10rpx; font-size: 28rpx; line-height: 1; }
|
||||
.add { color: #434655; border-style: dashed; }
|
||||
.empty { font-size: 22rpx; color: #737686; }
|
||||
</style>
|
||||
@@ -0,0 +1,68 @@
|
||||
<template>
|
||||
<view class="hd" :style="{ paddingTop: status + 'px' }">
|
||||
<view class="bar">
|
||||
<view class="left" @click="onLeft">
|
||||
<text v-if="leftLabel" class="leftlab">{{ leftLabel }}</text>
|
||||
<text v-else-if="back" class="back">‹</text>
|
||||
<text class="title">{{ title }}</text>
|
||||
</view>
|
||||
<view class="right">
|
||||
<slot name="right" />
|
||||
</view>
|
||||
</view>
|
||||
</view>
|
||||
</template>
|
||||
|
||||
<script>
|
||||
export default {
|
||||
name: 'FyHeader',
|
||||
props: {
|
||||
title: { type: String, default: '' },
|
||||
back: { type: Boolean, default: false },
|
||||
leftLabel: { type: String, default: '' }
|
||||
},
|
||||
data() {
|
||||
return { status: 20 }
|
||||
},
|
||||
created() {
|
||||
try {
|
||||
this.status = uni.getSystemInfoSync().statusBarHeight || 20
|
||||
} catch (_) {}
|
||||
},
|
||||
methods: {
|
||||
onLeft() {
|
||||
if (this.leftLabel) {
|
||||
this.$emit('left')
|
||||
return
|
||||
}
|
||||
if (this.back) {
|
||||
const pages = getCurrentPages()
|
||||
if (pages.length > 1) uni.navigateBack()
|
||||
else uni.switchTab({ url: '/pages/tabs/messages' })
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
</script>
|
||||
|
||||
<style scoped>
|
||||
.hd {
|
||||
background: rgba(250, 248, 255, 0.96);
|
||||
border-bottom: 1rpx solid rgba(0, 0, 0, 0.04);
|
||||
position: sticky;
|
||||
top: 0;
|
||||
z-index: 20;
|
||||
}
|
||||
.bar {
|
||||
height: 88rpx;
|
||||
padding: 0 24rpx;
|
||||
display: flex;
|
||||
align-items: center;
|
||||
justify-content: space-between;
|
||||
}
|
||||
.left { display: flex; align-items: center; min-width: 0; }
|
||||
.back { font-size: 48rpx; line-height: 1; margin-right: 8rpx; color: #131b2e; width: 48rpx; }
|
||||
.leftlab { font-size: 30rpx; color: #131b2e; margin-right: 16rpx; }
|
||||
.title { font-size: 36rpx; font-weight: 600; color: #131b2e; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; max-width: 420rpx; }
|
||||
.right { display: flex; align-items: center; gap: 8rpx; }
|
||||
</style>
|
||||
Reference in New Issue
Block a user