-
Notifications
You must be signed in to change notification settings - Fork 4
/
UploadVideo.tsx
169 lines (159 loc) · 4.28 KB
/
UploadVideo.tsx
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
import { FormRules, NButton, NDivider, NForm, NFormItem, NInput, NModal, NSelect, NSpace, NUpload } from 'naive-ui';
import NA from '../a';
import { defineComponent, ref } from 'vue';
import { RouterLink } from 'vue-router';
import UploadImageMain from '../image/UploadImageMain';
import '../styles/upload.scss';
export default defineComponent({
name: 'UploadVideo',
setup () {
const showModal = ref(false);
const formRef = ref();
const modelRef = ref({
video: '',
name: '',
group_id: null,
thumb: '',
});
const rules: FormRules = {
video: [
{
required: true,
message: '请上传视频',
}
],
name: [
{
required: true,
message: '请输入视频名称',
}
],
group_id: [
{
required: true,
message: '请选择分组',
}
]
};
const confirm = () => {
showModal.value = false;
};
const cancel = () => {
showModal.value = false;
};
const handleHide = () => {
modelRef.value = {
video: '',
name: '',
group_id: null,
thumb: '',
};
};
return {
confirm,
cancel,
handleHide,
rules,
form: formRef,
model: modelRef,
showModal,
style: {
minWidth: '620px',
width: '828px',
},
headerStyle: {
padding: '15px 16px',
borderBottom: '1px solid var(--n-border-color)'
},
contentStyle: {
padding: '16px',
},
footerStyle: {
padding: '0 16px 16px',
}
};
},
render () {
const {
handleHide,
confirm,
cancel,
rules,
model,
style,
headerStyle,
contentStyle,
footerStyle,
} = this;
return (
<>
<NButton onClick={() => this.showModal = !this.showModal}>
上传视频
</NButton>
<NModal
class="upload-modal"
show={this.showModal}
maskClosable={false}
style={style}
headerStyle={headerStyle}
contentStyle={contentStyle}
footerStyle={footerStyle}
preset="card"
title="上传视频"
size="huge"
bordered={false}
onEsc={() => {}}
onClose={() => this.showModal = false}
onBeforeLeave={handleHide}
>
{{
default: () => (
<div class="upload-main">
<NForm
ref={this.form}
labelPlacement="left"
labelWidth="120"
model={model}
rules={rules}
requireMarkPlacement="left"
>
<NFormItem label='本地视频:' path='video'>
<NUpload listType='image-card' />
</NFormItem>
<NFormItem label='视频名称:' path='name'>
<NInput style={{width: '300px'}} placeholder="请输入视频名称" v-model:value={model.name} />
</NFormItem>
<NFormItem label='所在分组:' path='group_id'>
<NSpace align='center'>
<NSelect style={{width: '300px'}} v-model:value={model.group_id} placeholder="请选择分组" />
<div>
<RouterLink
to="/"
custom>
<NA href="/" target="_blank">新建</NA>
</RouterLink>
<NDivider vertical />
<NA>刷新</NA>
</div>
</NSpace>
</NFormItem>
<NFormItem label='视频封面:' path='thumb'>
<UploadImageMain />
</NFormItem>
</NForm>
</div>
),
footer: () => (
<NSpace style={{flexDirection: 'row-reverse'}}>
<NSpace>
<NButton onClick={cancel}>返回</NButton>
<NButton type='primary' onClick={confirm}>确定</NButton>
</NSpace>
</NSpace>
),
}}
</NModal>
</>
);
}
});