@newview/file-ui 0.0.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -0,0 +1,239 @@
1
+ <!--
2
+ 功能名称:上传文件
3
+ 创 建 人:弋强
4
+ 日 期:2023/02/14 09:42:54
5
+ -->
6
+ <template>
7
+ <div class="uploadFile">
8
+ <template v-if="!single">
9
+ <Card dis-hover v-for="groupName in groups" style="margin-bottom: 8px">
10
+ <template #title v-if="groupName != '默认'">{{ groupName }}</template>
11
+ <!-- 文件列表 -->
12
+ <div
13
+ v-for="(item, index) in getGroupFiles(groupName)"
14
+ :class="
15
+ isImage(item)
16
+ ? 'file-upload-list file-upload-list-bs'
17
+ : 'file-upload-list'
18
+ "
19
+ >
20
+ <div
21
+ class="file-upload-list-content"
22
+ @click="doView(item)"
23
+ :title="item.FileName"
24
+ >
25
+ <Image
26
+ :src="getThumbnailUrl(item)"
27
+ fit="cover"
28
+ width="100%"
29
+ height="100%"
30
+ />
31
+
32
+ <div class="file-upload-list-cover">
33
+ <Space>
34
+ <Icon
35
+ type="md-download"
36
+ @click.stop="doDwonload(item)"
37
+ title="下载"
38
+ ></Icon>
39
+ <Icon
40
+ v-if="!readonly"
41
+ type="md-trash"
42
+ @click.stop="doRemove(item)"
43
+ title="删除"
44
+ ></Icon>
45
+ </Space>
46
+ </div>
47
+ </div>
48
+ </div>
49
+ <!-- 文件列表 END -->
50
+
51
+ <!-- 上传组件 -->
52
+ <Upload
53
+ v-if="!readonly"
54
+ ref="uploadRef"
55
+ type="drag"
56
+ name="FormFile"
57
+ :multiple="multiple"
58
+ :show-upload-list="false"
59
+ :format="format"
60
+ :max-size="maxSize"
61
+ :action="action"
62
+ :headers="headers"
63
+ :data="uploadFilePos[groupName]"
64
+ :on-success="doSuccess"
65
+ :on-format-error="doFormatError"
66
+ :on-exceeded-size="doMaxSize"
67
+ :before-upload="doBeforeUpload"
68
+ style="display: inline-block; width: 78px"
69
+ >
70
+ <div class="file-upload-btn">
71
+ <Icon type="ios-camera" size="20"></Icon>
72
+ </div>
73
+ </Upload>
74
+ <!-- 上传组件 END -->
75
+
76
+ <!-- 无附件信息且只读状态提示 -->
77
+ <div
78
+ v-if="readonly && fileList.length == 0"
79
+ class="nv-flex"
80
+ style="color: #949494; border: 1px dashed #dcdee2;height: 60px;padding: 0 20px;font-size: 16px;justify-content: center;"
81
+ >
82
+ <i class="nv-flex" style="width: 40px;margin-right: 6px;"><svg t="1706683071705" class="icon" viewBox="0 0 1566 1024" version="1.1" xmlns="http://www.w3.org/2000/svg" p-id="4559" style="fill: currentColor;"><path d="M156.661991 699.757959h21.096999a10.443999 10.443999 0 0 1 10.235999 10.443999c0 5.765-4.491 10.443999-10.235999 10.444h-21.096999v21.097999a10.443999 10.443999 0 0 1-10.444 10.234999 10.276999 10.276999 0 0 1-10.443999-10.234999v-21.097999h-21.096999a10.443999 10.443999 0 0 1-10.234999-10.444c0-5.765 4.49-10.443999 10.234999-10.443999h21.096999v-21.096999a10.443999 10.443999 0 0 1 10.443999-10.234999c5.765 0 10.443999 4.49 10.444 10.234999v21.096999z m1378.627919-83.552995v-21.096999a10.276999 10.276999 0 0 0-10.443999-10.234999 10.443999 10.443999 0 0 0-10.444 10.234999v21.096999h-21.096998a10.276999 10.276999 0 0 0-10.235 10.443999c0 5.598 4.595 10.443999 10.235 10.444h21.096998v21.096998c0 5.745 4.679 10.235999 10.444 10.236a10.443999 10.443999 0 0 0 10.443999-10.236v-21.096998h21.097999c5.744 0 10.234999-4.679 10.234999-10.444a10.443999 10.443999 0 0 0-10.234999-10.443999h-21.097999zM776.459955 960.861944H250.596985a20.804999 20.804999 0 0 1-20.825998-20.887999c0-11.529999 9.462999-20.888999 20.825998-20.888999h94.727995a83.009995 83.009995 0 0 1-11.112-41.671997v-605.969965a83.489995 83.489995 0 0 1 83.636996-83.447995h62.580996v-20.992999a83.489995 83.489995 0 0 1 83.636995-83.448995h501.151971a83.448995 83.448995 0 0 1 83.636995 83.448995v605.969965c0 15.184999-4.053 29.409998-11.134 41.671997h115.553994c11.551999 0 20.909999 9.273999 20.909998 20.887999 0 11.529999-9.295999 20.887999-20.888998 20.887999h-250.659986v20.992999c0 15.185999-4.052 29.409998-11.132999 41.671997h11.195999c11.488999 0 20.825999 9.274999 20.825999 20.888999 0 11.529999-9.462999 20.887999-20.825999 20.887999H892.807948a41.657998 41.657998 0 0 1-6.413 50.862997 41.671998 41.671998 0 0 1-59.071996 0l-50.862997-50.862997z m76.367995-41.776998h66.423996c22.977999 0 41.609998-18.589999 41.609998-41.879997V270.460984c0-22.559999-18.047999-40.689998-40.313998-40.689997H416.303976c-22.266999 0-40.314998 18.213999-40.314998 40.689997v606.741965c0 23.123999 18.799999 41.880998 41.589998 41.880997h317.083981l-10.736999-10.756999a41.692998 41.692998 0 0 1-10.862-40.376998l-19.718999-19.739999a146.259991 146.259991 0 0 1-190.980988-220.516987 146.217991 146.217991 0 0 1 220.517987 190.980989l19.738998 19.739999a41.629998 41.629998 0 0 1 40.376998 10.839999l69.829996 69.829996z m149.809991-104.440994h62.852997a41.796998 41.796998 0 0 0 41.589997-41.776997v-605.759965c0-23.144999-18.632999-41.776998-41.589997-41.776997H563.774967a41.796998 41.796998 0 0 0-41.566998 41.775997v20.888999h396.793977a83.448995 83.448995 0 0 1 83.636995 83.448995v543.199968zM266.326984 46.998997h31.122999c8.773999 0 15.875999 6.955 15.875999 15.665999 0 8.647999-7.102 15.665999-15.875999 15.665999h-31.122999v31.123999c0 8.772999-6.956 15.874999-15.665999 15.874999a15.769999 15.769999 0 0 1-15.666999-15.874999V78.329995H203.869988a15.728999 15.728999 0 0 1-15.874999-15.665999c0-8.647999 7.102-15.665999 15.874999-15.665999h31.122998V15.874999C234.992986 7.102 241.949986 0 250.659985 0c8.646999 0 15.665999 7.102 15.665999 15.874999V46.999997zM20.887999 939.973945c0-11.529999 9.462999-20.888999 20.825999-20.888999h125.454992c11.488999 0 20.825999 9.274999 20.825999 20.888999 0 11.529999-9.462999 20.887999-20.825999 20.887999H41.713998a20.804999 20.804999 0 0 1-20.825999-20.887999z m658.733961-135.021992A104.441994 104.441994 0 1 0 531.899969 657.229961a104.441994 104.441994 0 0 0 147.721991 147.721992z m-220.079987-491.626971a20.887999 20.887999 0 0 1 20.867999-20.888999h229.791986a20.887999 20.887999 0 1 1 0 41.776997H480.430972a20.825999 20.825999 0 0 1-20.887999-20.887998z m0 104.440994c0-11.529999 9.295999-20.887999 20.742999-20.887999H814.789952c11.446999 0 20.741999 9.273999 20.741999 20.887999 0 11.529999-9.294999 20.887999-20.741999 20.887998H480.284972a20.762999 20.762999 0 0 1-20.741999-20.887998z m0 104.441993c0-11.529999 9.316999-20.888999 20.846999-20.888998h146.301991c11.509999 0 20.845999 9.274999 20.845999 20.888998 0 11.529999-9.315999 20.887999-20.845999 20.887999H480.388972a20.804999 20.804999 0 0 1-20.845999-20.887999zM62.665996 396.877977a62.664996 62.664996 0 1 1 0-125.329993 62.664996 62.664996 0 0 1 0 125.329993z m0-31.332998a31.331998 31.331998 0 1 0 0-62.664997 31.331998 31.331998 0 0 0 0 62.664997z m1295.074924-93.996995a62.664996 62.664996 0 1 1 0-125.329993 62.664996 62.664996 0 0 1 0 125.329993z m0-31.332998a31.331998 31.331998 0 1 0 0-62.663996 31.331998 31.331998 0 0 0 0 62.663996z" p-id="4560"></path></svg></i>
83
+ <div>{{ nullMsg }}</div>
84
+ </div>
85
+ <!-- 无附件信息且只读状态提示 END -->
86
+ </Card>
87
+ </template>
88
+ <template v-else>
89
+ <div
90
+ v-if="getFirstFile(groups[0])"
91
+ class="file-upload-list-content"
92
+ @click="doView(getFirstFile(groups[0]))"
93
+ style="width: 100%; height: 100%"
94
+ >
95
+ <Image
96
+ :src="getThumbnailUrl(getFirstFile(groups[0]))"
97
+ fit="fill"
98
+ width="100%"
99
+ height="100%"
100
+ />
101
+
102
+ <div class="file-upload-list-cover">
103
+ <Space>
104
+ <Icon
105
+ type="md-download"
106
+ @click.stop="doDwonload(getFirstFile(groups[0]))"
107
+ title="下载"
108
+ ></Icon>
109
+ <Icon
110
+ v-if="!readonly"
111
+ type="md-trash"
112
+ @click.stop="doRemove(getFirstFile(groups[0]))"
113
+ title="删除"
114
+ ></Icon>
115
+ </Space>
116
+ </div>
117
+ </div>
118
+
119
+ <Card
120
+ dis-hover
121
+ style="margin-bottom: 8px"
122
+ v-if="!readonly && !getSingle(groups[0])"
123
+ >
124
+ <Upload
125
+ ref="uploadRef"
126
+ type="drag"
127
+ name="FormFile"
128
+ :multiple="multiple"
129
+ :show-upload-list="false"
130
+ :format="format"
131
+ :max-size="maxSize"
132
+ :action="action"
133
+ :headers="headers"
134
+ :data="uploadFilePos[groups[0]]"
135
+ :on-success="doSuccess"
136
+ :on-format-error="doFormatError"
137
+ :on-exceeded-size="doMaxSize"
138
+ :before-upload="doBeforeUpload"
139
+ style="display: inline-block; width: 78px"
140
+ >
141
+ <div class="file-upload-btn">
142
+ <Icon type="ios-camera" size="20"></Icon>
143
+ </div>
144
+ </Upload>
145
+ </Card>
146
+ </template>
147
+
148
+ <Spin fix v-if="uploading"></Spin>
149
+
150
+ <!-- 预览组件 -->
151
+ <filePreview
152
+ v-model="previewVisible"
153
+ :preview-list="previewList"
154
+ :preview-index="previewIndex"
155
+ :file-info="previewFileInfo"
156
+ />
157
+ <!-- 预览组件 END -->
158
+ </div>
159
+ </template>
160
+
161
+ <script lang="ts" src="./UploadFile.ts"></script>
162
+
163
+ <style scoped lang="scss">
164
+ .uploadFile {
165
+ :deep(.ivu-upload-drag) {
166
+ border: 1px dashed #dcdee2;
167
+ border-radius: 2px;
168
+ }
169
+
170
+ :deep(.ivu-upload-drag:hover) {
171
+ border: 1px dashed #2d8cf0;
172
+ border-radius: 2px;
173
+ color: #2d8cf0;
174
+ }
175
+
176
+ :deep(.ivu-card-body) {
177
+ padding: 0;
178
+ }
179
+
180
+ .file-upload-btn {
181
+ width: 78px;
182
+ height: 78px;
183
+ line-height: 78px;
184
+ text-align: center;
185
+ }
186
+
187
+ .file-upload-list-bs {
188
+ box-shadow: 0 1px 1px rgba(0, 0, 0, 0.2);
189
+ }
190
+
191
+ .file-upload-list {
192
+ display: inline-block;
193
+ width: 80px;
194
+ height: 80px;
195
+ text-align: center;
196
+ line-height: 80px;
197
+ overflow: hidden;
198
+ background: #fff;
199
+ margin-right: 12px;
200
+ border-radius: 4px;
201
+ }
202
+
203
+ .file-upload-list-content {
204
+ position: relative;
205
+ width: 100%;
206
+ height: 100%;
207
+ cursor: pointer;
208
+ }
209
+
210
+ img {
211
+ width: 100%;
212
+ height: 100%;
213
+ }
214
+
215
+ .file-upload-list-cover {
216
+ display: none;
217
+ background: rgba(0, 0, 0, 0.7);
218
+ position: absolute;
219
+ top: 0;
220
+ left: 0px;
221
+ right: 0px;
222
+ line-height: 18px;
223
+ }
224
+
225
+ .file-upload-list-content:hover .file-upload-list-cover {
226
+ display: block;
227
+ }
228
+
229
+ .file-upload-list-cover i {
230
+ color: #ccc;
231
+ font-size: 18px;
232
+ cursor: pointer;
233
+ }
234
+
235
+ .file-upload-list-cover i:hover {
236
+ color: #fff;
237
+ }
238
+ }
239
+ </style>
@@ -0,0 +1,3 @@
1
+ import UploadFile from "./UploadFile.vue"
2
+ import FilePreview from "./FilePreview.vue"
3
+ export { UploadFile, FilePreview };
package/src/index.ts ADDED
@@ -0,0 +1,3 @@
1
+ export * from "./UploadFile"
2
+ export * from "./ComFormUp"
3
+ export * from "./TextEditor"
package/tsconfig.json ADDED
@@ -0,0 +1,19 @@
1
+ {
2
+ "compilerOptions": {
3
+ "target": "ESNext",
4
+ "useDefineForClassFields": true,
5
+ "module": "ESNext",
6
+ "moduleResolution": "Node",
7
+ "strict": true,
8
+ "jsx": "preserve",
9
+ "resolveJsonModule": true,
10
+ "isolatedModules": true,
11
+ "esModuleInterop": true,
12
+ "lib": ["ESNext", "DOM"],
13
+ "skipLibCheck": true,
14
+ "noEmit": true,
15
+ "noImplicitAny": false
16
+ },
17
+ "include": ["src/**/*.ts", "src/**/*.d.ts", "src/**/*.tsx", "src/**/*.vue"],
18
+ "references": [{ "path": "./tsconfig.node.json" }]
19
+ }
@@ -0,0 +1,9 @@
1
+ {
2
+ "compilerOptions": {
3
+ "composite": true,
4
+ "module": "ESNext",
5
+ "moduleResolution": "Node",
6
+ "allowSyntheticDefaultImports": true
7
+ },
8
+ "include": ["vite.config.ts"]
9
+ }
@@ -0,0 +1,27 @@
1
+ import type { DefineComponent } from 'vue';
2
+
3
+ export declare const NvComFormUp: DefineComponent<{
4
+ /**
5
+ * 保存文本
6
+ */
7
+ saveTextData(): void;
8
+
9
+ /**
10
+ * 删除文本
11
+ */
12
+ deleteTextData(): void;
13
+
14
+ /**
15
+ * 清空长文本
16
+ */
17
+ clearTextData(): void;
18
+
19
+ /**
20
+ * 删除文本
21
+ */
22
+ deleteTextDataByToken(Token: string): void;
23
+ /**
24
+ * 获取长文本
25
+ */
26
+ getText(): void;
27
+ }>
@@ -0,0 +1,5 @@
1
+ import type { DefineComponent } from 'vue';
2
+
3
+ export declare const FilePreview: DefineComponent<{
4
+
5
+ }>
@@ -0,0 +1,9 @@
1
+ import { BaseInstance } from "@newview/base-vue";
2
+
3
+ export declare class FilePreviewInstance extends BaseInstance {
4
+ /**
5
+ * 关闭预览
6
+ * @param value
7
+ */
8
+ doClose(value: boolean): void;
9
+ }
@@ -0,0 +1,26 @@
1
+ import type { DefineComponent } from 'vue';
2
+
3
+ export declare const TextEditor: DefineComponent<{
4
+
5
+ /**
6
+ * 保存文本
7
+ */
8
+ saveTextData(): void;
9
+
10
+ /**
11
+ * 删除文本
12
+ */
13
+ deleteTextData(): void;
14
+
15
+ /**
16
+ * 清空长文本
17
+ */
18
+ clearTextData(): void;
19
+
20
+ /**
21
+ * 删除文本
22
+ */
23
+ deleteTextDataByToken(Token: string): void;
24
+
25
+
26
+ }>
@@ -0,0 +1,5 @@
1
+ import type { DefineComponent } from 'vue';
2
+
3
+ export declare const UploadFile: DefineComponent<{
4
+
5
+ }>
@@ -0,0 +1,5 @@
1
+ import { BaseInstance } from "@newview/base-vue";
2
+
3
+ export declare class UploadFileInstance extends BaseInstance {
4
+
5
+ }
@@ -0,0 +1,7 @@
1
+ export * from "./FilePreviewInstance"
2
+ export * from "./UploadFileInstance"
3
+
4
+ export * from "./FilePreview"
5
+ export * from "./UploadFile"
6
+ export * from "./ComFormUp"
7
+ export * from "./TextEditor"
package/vite.config.ts ADDED
@@ -0,0 +1,50 @@
1
+ import { defineConfig } from 'vite'
2
+ import vue from '@vitejs/plugin-vue'
3
+ import path from 'path';
4
+
5
+ // https://vitejs.dev/config/
6
+ export default defineConfig({
7
+ plugins: [vue()],
8
+ build: {
9
+ lib: {
10
+ entry: path.resolve(__dirname, './src/index.ts'),
11
+ name: 'fileui',
12
+ fileName: 'file-ui'
13
+ },
14
+ rollupOptions: {
15
+ // 确保外部化处理那些你不想打包进库的依赖
16
+ external: [
17
+ "@newview/base-vue",
18
+ "@newview/fileservice-api",
19
+ "@newview/infrastructure",
20
+ "@newview/tools",
21
+ "@newview/ui",
22
+ "sass",
23
+ "view-ui-plus",
24
+ "vue",
25
+ "vue-router"
26
+ ],
27
+ output: {
28
+ globals: {
29
+ vue: "Vue",
30
+ 'vue-router': 'VueRouter',
31
+ }
32
+ }
33
+ },
34
+ minify: 'terser',
35
+ terserOptions: { // 在打包代码时移除 console、debugger 和 注释
36
+ compress: {
37
+ /* (default: false) -- Pass true to discard calls to console.* functions.
38
+ If you wish to drop a specific function call such as console.info and/or
39
+ retain side effects from function arguments after dropping the function
40
+ call then use pure_funcs instead
41
+ */
42
+ drop_console: true, // 生产环境时移除console
43
+ drop_debugger: true
44
+ },
45
+ format: {
46
+ comments: false // 删除注释comments
47
+ }
48
+ }
49
+ }
50
+ });