@qynpm/ui 0.0.2 → 1.0.2
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.
- package/README.md +183 -8
- package/dist/index-1ocyh-Ge.js +1 -0
- package/dist/index-BYAIkGVF.js +1 -0
- package/dist/index-BaU5rDMh.js +1 -0
- package/dist/index-BddPsC3s.mjs +384 -0
- package/dist/index-BzzxlJ2O.mjs +205 -0
- package/dist/index-C02naY8D.mjs +276 -0
- package/dist/index-CEg8yYrg.mjs +142 -0
- package/dist/index-CibtL3Up.mjs +325 -0
- package/dist/index-Cuwe7RLf.mjs +88 -0
- package/dist/index-CzJWU89H.js +1 -0
- package/dist/index-DQ-EEZgS.js +1 -0
- package/dist/index-Dg93AsO_.mjs +216 -0
- package/dist/index-Djj-T8oy.mjs +137 -0
- package/dist/index-DlwgfuD9.mjs +55 -0
- package/dist/index-Do5SZ8yS.js +1 -0
- package/dist/index-DooOsQ9d.js +1 -0
- package/dist/index-DzX3lxdp.js +1 -0
- package/dist/index-tC70xKe_.js +1 -0
- package/dist/index.cjs +1 -0
- package/dist/install-CxBnxbuN.mjs +8 -0
- package/dist/install-c8il9DQv.js +1 -0
- package/dist/js.cookie-XvHV2tha.js +1 -0
- package/dist/js.cookie-tagl12-O.mjs +74 -0
- package/dist/plugin-vue_export-helper-BHFhmbuH.js +1 -0
- package/dist/plugin-vue_export-helper-CHgC5LLL.mjs +9 -0
- package/dist/qy-action-bar/index.cjs +1 -0
- package/dist/qy-dialog/index.cjs +1 -0
- package/dist/qy-form-section/index.cjs +1 -0
- package/dist/qy-input/index.cjs +1 -0
- package/dist/qy-record-quote-search/index.cjs +1 -0
- package/dist/qy-remark-image/index.cjs +2 -0
- package/dist/qy-search-input/index.cjs +1 -0
- package/dist/qy-select/index.cjs +1 -0
- package/dist/qy-upload/index.cjs +1 -0
- package/index.d.ts +16 -4
- package/package.json +60 -7
- package/qy-action-bar/index.d.ts +5 -0
- package/qy-action-bar/index.js +4 -0
- package/qy-dialog/index.d.ts +5 -0
- package/qy-dialog/index.js +4 -0
- package/qy-form-section/index.d.ts +5 -0
- package/qy-form-section/index.js +4 -0
- package/qy-input/index.d.ts +5 -0
- package/qy-input/index.js +4 -0
- package/qy-record-quote-search/index.d.ts +5 -0
- package/qy-record-quote-search/index.js +4 -0
- package/qy-remark-image/index.d.ts +5 -0
- package/qy-remark-image/index.js +4 -0
- package/qy-search-input/index.d.ts +5 -0
- package/qy-search-input/index.js +4 -0
- package/qy-select/index.d.ts +5 -0
- package/qy-select/index.js +4 -0
- package/qy-upload/index.d.ts +5 -0
- package/qy-upload/index.js +4 -0
- package/dist/ui.es.js +0 -994
- package/dist/ui.umd.js +0 -2
- package/index.js +0 -9
package/README.md
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
# @qynpm/ui
|
|
2
2
|
|
|
3
|
-
起印体系内抽离出来的 Vue 3 UI
|
|
3
|
+
起印体系内抽离出来的 Vue 3 UI 组件包,当前主要包含基础输入组件、选择器组件、区块容器、底部操作栏,以及上传、弹窗、备注图文等通用能力。
|
|
4
4
|
|
|
5
5
|
## 安装
|
|
6
6
|
|
|
@@ -32,12 +32,36 @@ app.use(QyUI)
|
|
|
32
32
|
也可以按需引入:
|
|
33
33
|
|
|
34
34
|
```ts
|
|
35
|
-
import {
|
|
35
|
+
import {
|
|
36
|
+
QyUpload,
|
|
37
|
+
QyDialog,
|
|
38
|
+
QyRemarkImage,
|
|
39
|
+
QyInput,
|
|
40
|
+
QySelect,
|
|
41
|
+
QyFormSection,
|
|
42
|
+
QyActionBar,
|
|
43
|
+
QySearchInput,
|
|
44
|
+
QyRecordQuoteSearch
|
|
45
|
+
} from '@qynpm/ui'
|
|
46
|
+
```
|
|
47
|
+
|
|
48
|
+
也可以按需引入单个组件入口:
|
|
49
|
+
|
|
50
|
+
```ts
|
|
51
|
+
import QyInput from '@qynpm/ui/qy-input'
|
|
52
|
+
import QySelect from '@qynpm/ui/qy-select'
|
|
53
|
+
import QyFormSection from '@qynpm/ui/qy-form-section'
|
|
54
|
+
import QyActionBar from '@qynpm/ui/qy-action-bar'
|
|
55
|
+
import QySearchInput from '@qynpm/ui/qy-search-input'
|
|
56
|
+
import QyRecordQuoteSearch from '@qynpm/ui/qy-record-quote-search'
|
|
57
|
+
import QyDialog from '@qynpm/ui/qy-dialog'
|
|
58
|
+
import QyUpload from '@qynpm/ui/qy-upload'
|
|
59
|
+
import QyRemarkImage from '@qynpm/ui/qy-remark-image'
|
|
36
60
|
```
|
|
37
61
|
|
|
38
62
|
## 组件说明
|
|
39
63
|
|
|
40
|
-
### `
|
|
64
|
+
### `QyUpload`
|
|
41
65
|
|
|
42
66
|
上传组件,支持:
|
|
43
67
|
|
|
@@ -70,6 +94,74 @@ import { Upload, QyDialog } from '@qynpm/ui'
|
|
|
70
94
|
- 自定义 footer
|
|
71
95
|
- 移动端自动全屏
|
|
72
96
|
|
|
97
|
+
### `QyInput`
|
|
98
|
+
|
|
99
|
+
输入组件,第一版定位为 `ElInput` 的轻量包装层,重点支持:
|
|
100
|
+
|
|
101
|
+
- 保持和 `ElInput` 接近的使用方式
|
|
102
|
+
- `removeSpace`
|
|
103
|
+
- `trimMode`
|
|
104
|
+
- `enter`
|
|
105
|
+
- `textarea`
|
|
106
|
+
- 兼容常见 slots 与 expose 方法
|
|
107
|
+
|
|
108
|
+
### `QySelect`
|
|
109
|
+
|
|
110
|
+
选择器组件,第一版定位为 `ElSelect` 的轻量包装层,重点支持:
|
|
111
|
+
|
|
112
|
+
- `options` 直出
|
|
113
|
+
- `labelKey / valueKey / disabledKey` 映射
|
|
114
|
+
- 单选 / 多选
|
|
115
|
+
- `collapse-tags`
|
|
116
|
+
- 默认弹层挂载策略
|
|
117
|
+
- 保留原生 slot 扩展
|
|
118
|
+
|
|
119
|
+
### `QyFormSection`
|
|
120
|
+
|
|
121
|
+
区块容器组件,适合录单页面的表单区块外壳,重点支持:
|
|
122
|
+
|
|
123
|
+
- 标题
|
|
124
|
+
- 描述
|
|
125
|
+
- 操作区 slot
|
|
126
|
+
- 提示区
|
|
127
|
+
- 简单折叠
|
|
128
|
+
- 统一边框、背景和间距
|
|
129
|
+
|
|
130
|
+
### `QyActionBar`
|
|
131
|
+
|
|
132
|
+
底部操作栏组件,适合录单页面底部按钮区,重点支持:
|
|
133
|
+
|
|
134
|
+
- sticky 吸底
|
|
135
|
+
- 左右分区
|
|
136
|
+
- 窄屏换行
|
|
137
|
+
- 边框 / 阴影
|
|
138
|
+
- 底部安全区适配
|
|
139
|
+
|
|
140
|
+
### `QySearchInput`
|
|
141
|
+
|
|
142
|
+
搜索输入组件,支持:
|
|
143
|
+
|
|
144
|
+
- 基于 `ElAutocomplete` 的等价封装
|
|
145
|
+
- 搜索按钮
|
|
146
|
+
- 回车搜索
|
|
147
|
+
- 本地建议项
|
|
148
|
+
- 远程建议项
|
|
149
|
+
- 兼容 `fetch-suggestions(queryString, cb)` 回调风格
|
|
150
|
+
- 高亮匹配词
|
|
151
|
+
- 默认使用 Element Plus 弹层挂载策略,避免被父级裁剪
|
|
152
|
+
- 平铺项和分组项两种建议结构
|
|
153
|
+
|
|
154
|
+
### `QyRecordQuoteSearch`
|
|
155
|
+
|
|
156
|
+
录单报价单号搜索组件,支持:
|
|
157
|
+
|
|
158
|
+
- 报价单号输入
|
|
159
|
+
- 报价单号提取与规范化
|
|
160
|
+
- 搜索触发
|
|
161
|
+
- 建议项选择
|
|
162
|
+
- 局部状态提示
|
|
163
|
+
- `loading-change / success / error` 事件
|
|
164
|
+
|
|
73
165
|
## 样式说明
|
|
74
166
|
|
|
75
167
|
- 包内样式会跟随构建产物一起注入
|
|
@@ -78,11 +170,11 @@ import { Upload, QyDialog } from '@qynpm/ui'
|
|
|
78
170
|
|
|
79
171
|
## 使用示例
|
|
80
172
|
|
|
81
|
-
###
|
|
173
|
+
### QyUpload
|
|
82
174
|
|
|
83
175
|
```vue
|
|
84
176
|
<template>
|
|
85
|
-
<
|
|
177
|
+
<QyUpload
|
|
86
178
|
api="/permission-api/common/uploads"
|
|
87
179
|
token-key="Admin-Token"
|
|
88
180
|
@change="handleChange"
|
|
@@ -94,9 +186,86 @@ import { Upload, QyDialog } from '@qynpm/ui'
|
|
|
94
186
|
|
|
95
187
|
```vue
|
|
96
188
|
<template>
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
189
|
+
<QyDialog title="标题" @confirm="handleConfirm">
|
|
190
|
+
内容区域
|
|
191
|
+
</QyDialog>
|
|
192
|
+
</template>
|
|
193
|
+
```
|
|
194
|
+
|
|
195
|
+
### QyInput
|
|
196
|
+
|
|
197
|
+
```vue
|
|
198
|
+
<template>
|
|
199
|
+
<QyInput
|
|
200
|
+
v-model="quoteOrderCode"
|
|
201
|
+
remove-space
|
|
202
|
+
trim-mode="blur"
|
|
203
|
+
placeholder="填写报价单,回车搜索"
|
|
204
|
+
@enter="handleSearch"
|
|
205
|
+
/>
|
|
206
|
+
</template>
|
|
207
|
+
```
|
|
208
|
+
|
|
209
|
+
### QySelect
|
|
210
|
+
|
|
211
|
+
```vue
|
|
212
|
+
<template>
|
|
213
|
+
<QySelect
|
|
214
|
+
v-model="shopCode"
|
|
215
|
+
:options="shopOptions"
|
|
216
|
+
placeholder="请选择店铺"
|
|
217
|
+
/>
|
|
218
|
+
</template>
|
|
219
|
+
```
|
|
220
|
+
|
|
221
|
+
### QyFormSection
|
|
222
|
+
|
|
223
|
+
```vue
|
|
224
|
+
<template>
|
|
225
|
+
<QyFormSection title="订单信息" description="这里放订单表单区块">
|
|
226
|
+
<el-form>...</el-form>
|
|
227
|
+
</QyFormSection>
|
|
228
|
+
</template>
|
|
229
|
+
```
|
|
230
|
+
|
|
231
|
+
### QyActionBar
|
|
232
|
+
|
|
233
|
+
```vue
|
|
234
|
+
<template>
|
|
235
|
+
<QyActionBar>
|
|
236
|
+
<template #left>
|
|
237
|
+
<el-button plain>开票</el-button>
|
|
238
|
+
</template>
|
|
239
|
+
<template #right>
|
|
240
|
+
<el-button>保存</el-button>
|
|
241
|
+
<el-button type="primary">提交</el-button>
|
|
242
|
+
</template>
|
|
243
|
+
</QyActionBar>
|
|
244
|
+
</template>
|
|
245
|
+
```
|
|
246
|
+
|
|
247
|
+
### QySearchInput
|
|
248
|
+
|
|
249
|
+
```vue
|
|
250
|
+
<template>
|
|
251
|
+
<QySearchInput
|
|
252
|
+
v-model="keyword"
|
|
253
|
+
:fetch-suggestions-method="querySearch"
|
|
254
|
+
@search="handleSearch"
|
|
255
|
+
/>
|
|
256
|
+
</template>
|
|
257
|
+
```
|
|
258
|
+
|
|
259
|
+
### QyRecordQuoteSearch
|
|
260
|
+
|
|
261
|
+
```vue
|
|
262
|
+
<template>
|
|
263
|
+
<QyRecordQuoteSearch
|
|
264
|
+
v-model="quoteOrderCode"
|
|
265
|
+
:fetch-suggestions="fetchQuoteSuggestions"
|
|
266
|
+
:search-method="handleQuoteSearch"
|
|
267
|
+
@search="handleSearch"
|
|
268
|
+
/>
|
|
100
269
|
</template>
|
|
101
270
|
```
|
|
102
271
|
|
|
@@ -104,6 +273,12 @@ import { Upload, QyDialog } from '@qynpm/ui'
|
|
|
104
273
|
|
|
105
274
|
- 当前版本更适合体系内拆包复用
|
|
106
275
|
- 上传默认值仍然保留了现有项目约定,后续如果完全独立对外,可以再继续抽离
|
|
276
|
+
- `QyInput` 第一版优先兼容 `ElInput`,后续再逐步补统一输入规则
|
|
277
|
+
- `QySelect` 第一版优先兼容 `ElSelect`,不内置远程字典或复杂请求能力
|
|
278
|
+
- `QyFormSection` 只负责区块壳,不替代 `@qiyin/form` 的 schema / 校验能力
|
|
279
|
+
- `QyActionBar` 只负责底部布局壳,不负责编排按钮业务逻辑
|
|
280
|
+
- `QySearchInput` 第一版已经覆盖建议搜索场景,但仍然不承接页面级副作用
|
|
281
|
+
- `QyRecordQuoteSearch` 只承接报价单搜索入口逻辑,不直接改整页录单状态
|
|
107
282
|
|
|
108
283
|
## 当前联调说明
|
|
109
284
|
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
"use strict";const e=require("vue"),a=require("./plugin-vue_export-helper-BHFhmbuH.js"),l={key:0,class:"qy-action-bar__left"},n={key:1,class:"qy-action-bar__center"},d={key:2,class:"qy-action-bar__right"},i=e.defineComponent({name:"QyActionBar",__name:"index",props:{sticky:{type:Boolean,default:!0},offsetBottom:{default:0},bordered:{type:Boolean,default:!0},shadow:{type:Boolean,default:!1},wrap:{type:Boolean,default:!0},justify:{default:"between"},background:{default:"#fff"}},setup(r){const o=r,s=e.computed(()=>({bottom:`${o.offsetBottom}px`,background:o.background}));return(t,u)=>(e.openBlock(),e.createElementBlock("div",{class:e.normalizeClass(["qy-action-bar",[`is-justify-${t.justify}`,{"is-sticky":t.sticky,"is-bordered":t.bordered,"is-shadow":t.shadow,"is-wrap":t.wrap}]]),style:e.normalizeStyle(s.value)},[t.$slots.left?(e.openBlock(),e.createElementBlock("div",l,[e.renderSlot(t.$slots,"left",{},void 0,!0)])):e.createCommentVNode("",!0),t.$slots.default?(e.openBlock(),e.createElementBlock("div",n,[e.renderSlot(t.$slots,"default",{},void 0,!0)])):e.createCommentVNode("",!0),t.$slots.right?(e.openBlock(),e.createElementBlock("div",d,[e.renderSlot(t.$slots,"right",{},void 0,!0)])):e.createCommentVNode("",!0)],6))}}),c=a._export_sfc(i,[["__scopeId","data-v-86002d5a"]]);exports.QyActionBar=c;
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
"use strict";const w=require("element-plus/es"),e=require("vue"),A=require("@element-plus/icons-vue"),v=require("element-plus"),oe=require("./js.cookie-XvHV2tha.js"),ie=require("./plugin-vue_export-helper-BHFhmbuH.js"),se="Admin-Token";function ne(p=se){return oe.api.get(p)}const re={class:"qy-upload__hint"},ue=["src"],de={key:1,class:"qy-upload__tip"},ce={class:"error"},pe={class:"error"},fe=Object.assign({name:"QyUpload"},{__name:"index",props:{defaultValue:{type:Object,default:()=>({files:"",text:""})},multiple:{type:Boolean,default:!0},disabled:{type:Boolean,default:!1},fileType:{type:Array,default:()=>[]},fileSize:{type:Number,default:10},limit:{type:Number,default:9},isShowTip:{type:Boolean,default:!1},api:{type:String,default:"/permission-api/common/uploads"},name:{type:String,default:"file"},tokenKey:{type:String,default:"Admin-Token"},supportVideo:{type:Boolean,default:!1},size:{type:String,default:"default"},disableDrag:{type:Boolean,default:!1},callBack:{type:Function,default:null},extraData:{type:Object,default:()=>({})}},emits:["change","success","error","remove"],setup(p,{expose:O,emit:I}){const s=p,g=I,k=e.ref(null),u=e.ref([]),T=e.ref(null),x=[],q=e.ref(!1),S=e.ref([]),E=e.ref(0),V=e.ref(!1),L=e.ref(""),M=e.ref(""),h=new Set,B=e.ref(!1),f=e.ref(""),U=e.ref(!1);e.onMounted(()=>{const l=s.defaultValue;if(!l)return;f.value=l.text??"";const t=l.files??"",o=Array.isArray(t)?t.filter(Boolean):String(t).split(",").filter(Boolean);o.length&&(u.value=o.map((a,i)=>({name:a.split("/").pop()||`file-${i}`,url:a,status:"success",uid:Date.now()+i})))});const P=e.computed(()=>({large:"160px",default:"140px",small:"80px"})[s.size]??s.size),H=e.computed(()=>s.disabled),K=e.computed(()=>{var l;return s.isShowTip&&(s.fileSize||((l=m.value)==null?void 0:l.length))}),m=e.computed(()=>{var l;return(l=s.fileType)!=null&&l.length?s.fileType.map(t=>t.toLowerCase()):s.supportVideo?["mp4","mov","avi"]:["jpg","jpeg","png","gif","webp"]}),N=e.computed(()=>{const l=s.supportVideo?1:s.limit;return u.value.length>=l}),Q=e.computed(()=>m.value.map(l=>`.${l}`).join(",")),W=e.computed(()=>({"qy-upload--reached-limit":N.value,"qy-upload--disabled":s.disabled,"qy-upload--video":s.supportVideo}));e.watch(f,()=>b());function X(){var l;(l=T.value)==null||l.focus()}function b(l){const a={files:(l??u.value).filter(i=>i.status==="success"&&i.url).map(i=>i.url),text:f.value};g("change",a),s.callBack&&s.callBack(a)}function J(l,t){b(t)}function G(l){var a;if(!(l.size/1024/1024<s.fileSize))return v.ElMessage.warning(`文件大小不能超过${s.fileSize}M`),!1;const o=((a=l.name.split(".").pop())==null?void 0:a.toLowerCase())||"";return m.value.includes(o)?!0:(v.ElMessage.warning(`格式不支持,仅允许: ${m.value.join("/")}`),!1)}function z(l,t,o,a){var $,F;const i=s.api.startsWith("http")?s.api:window.location.origin+s.api.replace(/^([^/])/,"/$1"),d=new FormData;d.append(s.name,l),s.extraData&&Object.entries(s.extraData).forEach(([r,ae])=>d.append(r,ae));const n=new XMLHttpRequest;x.push(n);const y=(($=k.value)==null?void 0:$.$el.querySelector(".el-upload--picture-card"))||((F=k.value)==null?void 0:F.$el),C=v.ElLoading.service({target:y,text:"上传中",background:"rgba(255,255,255,0.7)"}),c=()=>{const r=x.indexOf(n);r!==-1&&x.splice(r,1),C.close()};n.open("POST",i);const j=ne(s.tokenKey);j&&n.setRequestHeader("Authorization",`Bearer ${j}`),n.upload.onprogress=r=>{r.total>0&&(t==null||t({percent:r.loaded/r.total*100}))},n.onload=()=>{if(c(),n.status<200||n.status>=300){const r=`上传失败 (HTTP ${n.status})`;v.ElMessage.error(r),g("error",{msg:r,status:n.status}),a==null||a(new Error(r));return}try{const r=JSON.parse(n.responseText);r.code===200&&r.urls?(v.ElMessage.success("上传成功"),o==null||o({...r,url:r.urls})):(v.ElMessage.error(r.msg||"上传失败"),g("error",r),a==null||a(r))}catch{v.ElMessage.error("上传失败,响应格式错误"),g("error",new Error("Response parse error")),a==null||a(new Error("Response parse error"))}},n.onerror=()=>{c(),v.ElMessage.error("上传失败,网络异常"),g("error",new Error("Network error")),a==null||a(new Error("Network error"))},n.send(d)}function R(l){return s.disabled?!1:G(l)}function Y(l){z(l.file,l.onProgress,t=>{l.onSuccess(t),b(),g("success",t)},t=>l.onError(t))}function Z(l){var a;if(!l.url)return;const t=((a=l.url.split(".").pop())==null?void 0:a.toLowerCase())||"";if(["mp4","mov","avi","webm"].includes(t)){L.value=l.url,M.value=l.name||"视频预览",V.value=!0;return}const o=u.value.filter(i=>{var d;return i.status==="success"&&i.url&&!["mp4","mov","avi","webm"].includes((d=i.url.split(".").pop())==null?void 0:d.toLowerCase())});S.value=o.map(i=>i.url),E.value=o.findIndex(i=>i.uid===l.uid)||0,q.value=!0}function ee(){q.value=!1,S.value=[]}function _(l){for(let t=0;t<l.length;t++){const o=l[t];if(!R(o))continue;const a=Date.now()+t,i=URL.createObjectURL(o);h.add(i),u.value.push({uid:a,name:o.name||`file-${a}`,status:"uploading",percentage:0,url:i}),z(o,d=>{const n=u.value.find(y=>y.uid===a);n&&(n.percentage=d.percent)},d=>{const n=u.value.find(y=>y.uid===a);n&&(n.status="success",n.url=d.url,b(),g("success",d))},()=>le(a))}}function D(l){var a;if(s.disabled)return;const t=(a=l.clipboardData)==null?void 0:a.items;if(!t)return;const o=[];for(let i=0;i<t.length;i++){const d=t[i];if(d.kind==="file"&&d.type.startsWith("image/")){const n=d.getAsFile();n&&o.push(n)}}o.length&&(l.preventDefault(),_(o))}function te(l){var o;if(B.value=!1,s.disabled||N.value)return;const t=Array.from(((o=l.dataTransfer)==null?void 0:o.files)||[]).filter(a=>{var i;return m.value.includes((i=a.name.split(".").pop())==null?void 0:i.toLowerCase())});t.length&&_(t)}function le(l){var o;const t=u.value.findIndex(a=>a.uid===l);t!==-1&&((o=u.value[t].url)!=null&&o.startsWith("blob:")&&(URL.revokeObjectURL(u.value[t].url),h.delete(u.value[t].url)),u.value.splice(t,1))}return e.onBeforeUnmount(()=>{x.forEach(l=>l.abort()),x.length=0,h.forEach(l=>URL.revokeObjectURL(l)),h.clear()}),O({openFileDialog:()=>{var l,t;s.disabled||N.value||(t=(l=k.value)==null?void 0:l.$el.querySelector('input[type="file"]'))==null||t.click()},getPathList:()=>u.value.filter(l=>l.status==="success").map(l=>l.url),clearFiles:()=>{u.value=[],f.value="",b()},getValue:()=>({files:u.value.filter(l=>l.status==="success"&&l.url).map(l=>l.url),text:f.value})}),(l,t)=>{var C;const o=w.ElIcon,a=w.ElInput,i=w.ElPopover,d=w.ElUpload,n=w.ElImageViewer,y=w.ElDialog;return e.openBlock(),e.createElementBlock("div",{class:e.normalizeClass(["qy-upload",W.value]),style:e.normalizeStyle({"--qy-upload-size":P.value})},[e.createVNode(d,{ref_key:"uploadRef",ref:k,"file-list":u.value,"onUpdate:fileList":t[6]||(t[6]=c=>u.value=c),action:"#",multiple:p.supportVideo?!1:p.multiple,limit:p.supportVideo?1:p.limit,"list-type":p.supportVideo?"text":"picture-card",accept:Q.value,disabled:H.value,"http-request":Y,"before-upload":R,"on-preview":Z,"on-remove":J},{default:e.withCtx(()=>[N.value?e.createCommentVNode("",!0):(e.openBlock(),e.createElementBlock("div",{key:0,class:e.normalizeClass(["qy-upload__trigger",{"is-dragover":B.value}]),onPaste:D,onDragover:t[4]||(t[4]=e.withModifiers(c=>B.value=!0,["prevent"])),onDragleave:t[5]||(t[5]=e.withModifiers(c=>B.value=!1,["prevent"])),onDrop:e.withModifiers(te,["prevent"])},[e.createVNode(o,{class:"qy-upload__icon"},{default:e.withCtx(()=>[e.createVNode(e.unref(A.Plus))]),_:1}),p.supportVideo?(e.openBlock(),e.createElementBlock(e.Fragment,{key:0},[t[9]||(t[9]=e.createElementVNode("span",{class:"qy-upload__label"},"点击上传视频",-1)),e.createElementVNode("span",re,"支持 "+e.toDisplayString(m.value.join(" / "))+",不超过 "+e.toDisplayString(p.fileSize)+"MB",1)],64)):e.createCommentVNode("",!0),e.createElementVNode("div",{class:"qy-upload__text",onClick:t[3]||(t[3]=e.withModifiers(()=>{},["stop"])),onPaste:e.withModifiers(D,["stop"])},[e.createVNode(i,{visible:U.value,"onUpdate:visible":t[2]||(t[2]=c=>U.value=c),placement:"bottom-start",width:220,trigger:"click","popper-class":"qy-upload__text-popover",onAfterEnter:X},{reference:e.withCtx(()=>[e.createElementVNode("div",{class:e.normalizeClass(["qy-upload__text-preview",{"is-placeholder":!f.value}])},e.toDisplayString(f.value||"输入文字"),3)]),default:e.withCtx(()=>[e.createVNode(a,{ref_key:"inputRef",ref:T,modelValue:f.value,"onUpdate:modelValue":t[0]||(t[0]=c=>f.value=c),type:"textarea",autosize:{minRows:2,maxRows:5},placeholder:"输入文字或粘贴图片",disabled:p.disabled,onBlur:t[1]||(t[1]=c=>U.value=!1),onPaste:e.withModifiers(D,["stop"])},null,8,["modelValue","disabled"])]),_:1},8,["visible"])],32)],34))]),_:1},8,["file-list","multiple","limit","list-type","accept","disabled"]),q.value?(e.openBlock(),e.createBlock(n,{key:0,"url-list":S.value,"initial-index":E.value,onClose:ee},null,8,["url-list","initial-index"])):e.createCommentVNode("",!0),e.createVNode(y,{modelValue:V.value,"onUpdate:modelValue":t[7]||(t[7]=c=>V.value=c),title:M.value,width:"640px","append-to-body":"","destroy-on-close":"",onClose:t[8]||(t[8]=c=>V.value=!1)},{default:e.withCtx(()=>[V.value?(e.openBlock(),e.createElementBlock("video",{key:0,src:L.value,controls:"",autoplay:"",style:{width:"100%","max-height":"400px","border-radius":"4px"}},null,8,ue)):e.createCommentVNode("",!0)]),_:1},8,["modelValue","title"]),K.value?(e.openBlock(),e.createElementBlock("div",de,[e.createVNode(o,null,{default:e.withCtx(()=>[e.createVNode(e.unref(A.InfoFilled))]),_:1}),e.createElementVNode("span",null,[t[12]||(t[12]=e.createTextVNode(" 请上传 ",-1)),p.fileSize?(e.openBlock(),e.createElementBlock(e.Fragment,{key:0},[t[10]||(t[10]=e.createTextVNode("大小不超过 ",-1)),e.createElementVNode("b",ce,e.toDisplayString(p.fileSize)+"MB",1)],64)):e.createCommentVNode("",!0),(C=m.value)!=null&&C.length?(e.openBlock(),e.createElementBlock(e.Fragment,{key:1},[t[11]||(t[11]=e.createTextVNode(",格式为 ",-1)),e.createElementVNode("b",pe,e.toDisplayString(m.value.join("/")),1)],64)):e.createCommentVNode("",!0),t[13]||(t[13]=e.createTextVNode(" 的文件。 ",-1))])])):e.createCommentVNode("",!0)],6)}}}),me=ie._export_sfc(fe,[["__scopeId","data-v-c1472320"]]);exports.QyUpload=me;
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
"use strict";const n=require("vue"),w=require("element-plus"),X=require("./plugin-vue_export-helper-BHFhmbuH.js"),Y={class:"qy-search-input__item"},Z=["innerHTML"],ee={key:0,class:"qy-search-input__item-description"},te=n.defineComponent({name:"QySearchInput",inheritAttrs:!1,__name:"index",props:{modelValue:{default:""},loading:{type:Boolean,default:!1},disabled:{type:Boolean,default:!1},placeholder:{default:"请输入搜索内容"},removeSpace:{type:Boolean,default:!1},trimMode:{default:"none"},clearable:{type:Boolean,default:!0},buttonText:{default:"搜索"},buttonProps:{default:()=>({})},suggestions:{default:()=>[]},fetchSuggestions:{type:[Function,null],default:null},fetchSuggestionsMethod:{type:[Function,null],default:null},debounce:{default:300},minLength:{default:1},triggerOnFocus:{type:Boolean,default:!1},searchOnEnter:{type:Boolean,default:!0},searchOnSelect:{type:Boolean,default:!1},highlightKeyword:{type:Boolean,default:!0},teleported:{type:Boolean,default:!0},appendTo:{default:"body"},popperClass:{default:""},fitInputWidth:{type:Boolean,default:!0}},emits:["update:modelValue","search","clear","input","change","focus","blur","enter","select","visible-change","suggestions-change","error"],setup(B,{expose:k,emit:C}){const o=B,a=C,$=n.useAttrs(),s=n.ref(null),c=n.ref(u(o.modelValue)),p=n.computed(()=>u(o.modelValue)),E=n.computed(()=>["qy-search-input__popper",o.popperClass].filter(Boolean).join(" ")),F=n.computed(()=>u(o.modelValue)),f=n.ref("");n.watch(()=>o.modelValue,e=>{c.value=u(e)});function u(e){return e==null?"":String(e)}function I(e){return o.removeSpace?e.replace(/\s+/g,""):e}function y(e,t){return o.trimMode!==t?e:e.trim()}function g(e){return I(u(e))}function h(e){c.value=e,a("update:modelValue",e)}function v(e,t=""){return{...e,label:e.label||e.value,value:e.value||e.label,description:e.description||t}}function m(e=[]){return e.flatMap(t=>{if(Array.isArray(t.items)){const l=t;return l.items.map(r=>v(r,l.groupLabel))}return v(t)})}function M(e){const t=e.toLowerCase();return l=>[l.label,l.value,l.description].filter(Boolean).some(r=>String(r).toLowerCase().includes(t))}function L(e){return e?e.length>=o.minLength:o.triggerOnFocus}function i(e){a("suggestions-change",e),a("visible-change",e.length>0)}async function T(e){if(!L(e))return i([]),[];if(o.fetchSuggestionsMethod){const r=await new Promise(d=>{var S;(S=o.fetchSuggestionsMethod)==null||S.call(o,e,J=>{d(m(J))})});return i(r),r}if(o.fetchSuggestions){const r=await o.fetchSuggestions(e),d=m(Array.isArray(r)?r:[]);return i(d),d}const t=m(o.suggestions),l=e?t.filter(M(e)):t;return i(l),l}async function P(e,t){f.value=e;try{const l=await T(e);t(l)}catch(l){a("error",l),i([]),t([])}}function _(){var e,t;f.value&&((t=(e=s.value)==null?void 0:e.getData)==null||t.call(e,f.value))}function A(e){const t=g(e);h(t)}function O(e){const t=g(e);c.value=t,a("input",t)}function z(e){const t=y(g(e),"change");t!==u(o.modelValue)&&h(t),a("change",t)}function q(e){a("focus",e)}function x(e){const t=y(c.value,"blur");t!==u(o.modelValue)&&h(t),a("blur",e),a("visible-change",!1)}function D(){c.value="",a("update:modelValue",""),a("clear"),i([])}function H(e){a("enter",e),o.searchOnEnter&&b()}function b(){a("search",u(o.modelValue))}function K(e){a("select",e),o.searchOnSelect&&a("search",e.value)}function V(e){return e.replace(/&/g,"&").replace(/</g,"<").replace(/>/g,">").replace(/"/g,""").replace(/'/g,"'")}function N(e){return e.replace(/[.*+?^${}()|[\]\\]/g,"\\$&")}function Q(e){const t=V(e||"");if(!o.highlightKeyword||!p.value)return t;const l=N(V(p.value));return l?t.replace(new RegExp(`(${l})`,"ig"),'<mark class="qy-search-input__mark">$1</mark>'):t}function R(){var e,t;(t=(e=s.value)==null?void 0:e.focus)==null||t.call(e)}function U(){var e,t;(t=(e=s.value)==null?void 0:e.blur)==null||t.call(e)}function W(){var e,t,l;(l=(t=(e=s.value)==null?void 0:e.inputRef)==null?void 0:t.select)==null||l.call(t)}function j(){var e,t;(t=(e=s.value)==null?void 0:e.clear)==null||t.call(e)}function G(){var e,t;(t=(e=s.value)==null?void 0:e.close)==null||t.call(e)}return k({focus:R,blur:U,select:W,clear:j,closePanel:G,retryFetch:_}),(e,t)=>(n.openBlock(),n.createElementBlock("div",{class:n.normalizeClass(["qy-search-input",{"is-disabled":e.disabled}])},[n.createVNode(n.unref(w.ElAutocomplete),n.mergeProps({ref_key:"autocompleteRef",ref:s},n.unref($),{"model-value":F.value,disabled:e.disabled,placeholder:e.placeholder,clearable:e.clearable,debounce:e.debounce,"fetch-suggestions":P,"trigger-on-focus":e.triggerOnFocus,teleported:e.teleported,"fit-input-width":e.fitInputWidth,"popper-class":E.value,"append-to":e.appendTo,"value-key":"value","onUpdate:modelValue":A,onInput:O,onChange:z,onFocus:q,onBlur:x,onClear:D,onSelect:K,onKeydown:n.withKeys(H,["enter"])}),n.createSlots({append:n.withCtx(()=>[e.$slots.append?n.renderSlot(e.$slots,"append",{key:0},void 0,!0):(n.openBlock(),n.createBlock(n.unref(w.ElButton),n.mergeProps({key:1},e.buttonProps,{loading:e.loading,disabled:e.disabled,onClick:b}),{default:n.withCtx(()=>[n.createTextVNode(n.toDisplayString(e.buttonText),1)]),_:1},16,["loading","disabled"]))]),default:n.withCtx(({item:l})=>[n.renderSlot(e.$slots,"item",{item:l,keyword:p.value},()=>[n.createElementVNode("div",Y,[n.createElementVNode("div",{class:"qy-search-input__item-label",innerHTML:Q(l.label||l.value||"")},null,8,Z),l.description?(n.openBlock(),n.createElementBlock("div",ee,n.toDisplayString(l.description),1)):n.createCommentVNode("",!0)])],!0)]),_:2},[e.$slots.prefix?{name:"prefix",fn:n.withCtx(()=>[n.renderSlot(e.$slots,"prefix",{},void 0,!0)]),key:"0"}:void 0,e.$slots.suffix?{name:"suffix",fn:n.withCtx(()=>[n.renderSlot(e.$slots,"suffix",{},void 0,!0)]),key:"1"}:void 0,e.$slots.prepend?{name:"prepend",fn:n.withCtx(()=>[n.renderSlot(e.$slots,"prepend",{},void 0,!0)]),key:"2"}:void 0]),1040,["model-value","disabled","placeholder","clearable","debounce","trigger-on-focus","teleported","fit-input-width","popper-class","append-to"])],2))}}),ne=X._export_sfc(te,[["__scopeId","data-v-47c6430a"]]);exports.QySearchInput=ne;
|
|
@@ -0,0 +1,384 @@
|
|
|
1
|
+
import { ElUpload as me, ElIcon as ye, ElPopover as ge, ElInput as be, ElImageViewer as xe, ElDialog as we } from "element-plus/es";
|
|
2
|
+
import { ref as c, onMounted as he, computed as x, watch as ke, onBeforeUnmount as Ve, createElementBlock as w, openBlock as m, normalizeStyle as Ue, normalizeClass as I, createVNode as y, createBlock as Be, createCommentVNode as h, withCtx as U, withModifiers as B, createElementVNode as k, unref as Y, Fragment as M, toDisplayString as R, createTextVNode as $ } from "vue";
|
|
3
|
+
import { Plus as Le, InfoFilled as Se } from "@element-plus/icons-vue";
|
|
4
|
+
import { ElMessage as V, ElLoading as De } from "element-plus";
|
|
5
|
+
import { a as Re } from "./js.cookie-tagl12-O.mjs";
|
|
6
|
+
import { _ as Te } from "./plugin-vue_export-helper-CHgC5LLL.mjs";
|
|
7
|
+
const qe = "Admin-Token";
|
|
8
|
+
function ze(p = qe) {
|
|
9
|
+
return Re.get(p);
|
|
10
|
+
}
|
|
11
|
+
const _e = { class: "qy-upload__hint" }, je = ["src"], $e = {
|
|
12
|
+
key: 1,
|
|
13
|
+
class: "qy-upload__tip"
|
|
14
|
+
}, Ce = { class: "error" }, Ae = { class: "error" }, Fe = Object.assign({
|
|
15
|
+
name: "QyUpload"
|
|
16
|
+
}, {
|
|
17
|
+
__name: "index",
|
|
18
|
+
props: {
|
|
19
|
+
/**
|
|
20
|
+
* 初始值,结构为 { files: '逗号分隔的URL', text: '文字内容' }
|
|
21
|
+
* 非受控模式,仅初始化时读取一次
|
|
22
|
+
*/
|
|
23
|
+
defaultValue: { type: Object, default: () => ({ files: "", text: "" }) },
|
|
24
|
+
/** 是否多选 */
|
|
25
|
+
multiple: { type: Boolean, default: !0 },
|
|
26
|
+
/** 是否禁用 */
|
|
27
|
+
disabled: { type: Boolean, default: !1 },
|
|
28
|
+
/** 允许的文件类型后缀(如 ['jpg', 'mp4']) */
|
|
29
|
+
fileType: { type: Array, default: () => [] },
|
|
30
|
+
/** 单个文件大小限制(MB) */
|
|
31
|
+
fileSize: { type: Number, default: 10 },
|
|
32
|
+
/** 文件数量限制 */
|
|
33
|
+
limit: { type: Number, default: 9 },
|
|
34
|
+
/** 是否显示格式/大小提示 */
|
|
35
|
+
isShowTip: { type: Boolean, default: !1 },
|
|
36
|
+
/** 接口路径 */
|
|
37
|
+
api: { type: String, default: "/permission-api/common/uploads" },
|
|
38
|
+
/** FormData 中文件字段名 */
|
|
39
|
+
name: { type: String, default: "file" },
|
|
40
|
+
tokenKey: { type: String, default: "Admin-Token" },
|
|
41
|
+
/** 是否支持视频模式(强制 limit=1) */
|
|
42
|
+
supportVideo: { type: Boolean, default: !1 },
|
|
43
|
+
/**
|
|
44
|
+
* 卡片尺寸
|
|
45
|
+
* 预设:'large'(160px) | 'default'(140px) | 'small'(80px)
|
|
46
|
+
* 自定义:任意 CSS 单位,如 '60px'、'8vw'
|
|
47
|
+
*/
|
|
48
|
+
size: { type: String, default: "default" },
|
|
49
|
+
/** 禁用拖拽(默认在触发区开启) */
|
|
50
|
+
disableDrag: { type: Boolean, default: !1 },
|
|
51
|
+
/** 成功回调(用于复杂业务联动) */
|
|
52
|
+
callBack: { type: Function, default: null },
|
|
53
|
+
/** 上传时附加的额外 FormData 字段 */
|
|
54
|
+
extraData: { type: Object, default: () => ({}) }
|
|
55
|
+
},
|
|
56
|
+
emits: ["change", "success", "error", "remove"],
|
|
57
|
+
setup(p, { expose: Z, emit: ee }) {
|
|
58
|
+
const o = p, g = ee, T = c(null), u = c([]), N = c(null), L = [], C = c(!1), A = c([]), P = c(0), S = c(!1), E = c(""), H = c(""), q = /* @__PURE__ */ new Set(), z = c(!1), f = c(""), F = c(!1);
|
|
59
|
+
he(() => {
|
|
60
|
+
const t = o.defaultValue;
|
|
61
|
+
if (!t) return;
|
|
62
|
+
f.value = t.text ?? "";
|
|
63
|
+
const e = t.files ?? "", a = Array.isArray(e) ? e.filter(Boolean) : String(e).split(",").filter(Boolean);
|
|
64
|
+
a.length && (u.value = a.map((l, i) => ({
|
|
65
|
+
name: l.split("/").pop() || `file-${i}`,
|
|
66
|
+
url: l,
|
|
67
|
+
status: "success",
|
|
68
|
+
uid: Date.now() + i
|
|
69
|
+
})));
|
|
70
|
+
});
|
|
71
|
+
const te = x(() => ({ large: "160px", default: "140px", small: "80px" })[o.size] ?? o.size), le = x(() => o.disabled), ae = x(
|
|
72
|
+
() => {
|
|
73
|
+
var t;
|
|
74
|
+
return o.isShowTip && (o.fileSize || ((t = v.value) == null ? void 0 : t.length));
|
|
75
|
+
}
|
|
76
|
+
), v = x(() => {
|
|
77
|
+
var t;
|
|
78
|
+
return (t = o.fileType) != null && t.length ? o.fileType.map((e) => e.toLowerCase()) : o.supportVideo ? ["mp4", "mov", "avi"] : ["jpg", "jpeg", "png", "gif", "webp"];
|
|
79
|
+
}), _ = x(() => {
|
|
80
|
+
const t = o.supportVideo ? 1 : o.limit;
|
|
81
|
+
return u.value.length >= t;
|
|
82
|
+
}), ie = x(
|
|
83
|
+
() => v.value.map((t) => `.${t}`).join(",")
|
|
84
|
+
), oe = x(() => ({
|
|
85
|
+
"qy-upload--reached-limit": _.value,
|
|
86
|
+
"qy-upload--disabled": o.disabled,
|
|
87
|
+
"qy-upload--video": o.supportVideo
|
|
88
|
+
}));
|
|
89
|
+
ke(f, () => D());
|
|
90
|
+
function se() {
|
|
91
|
+
var t;
|
|
92
|
+
(t = N.value) == null || t.focus();
|
|
93
|
+
}
|
|
94
|
+
function D(t) {
|
|
95
|
+
const l = { files: (t ?? u.value).filter((i) => i.status === "success" && i.url).map((i) => i.url), text: f.value };
|
|
96
|
+
g("change", l), o.callBack && o.callBack(l);
|
|
97
|
+
}
|
|
98
|
+
function ne(t, e) {
|
|
99
|
+
D(e);
|
|
100
|
+
}
|
|
101
|
+
function ue(t) {
|
|
102
|
+
var l;
|
|
103
|
+
if (!(t.size / 1024 / 1024 < o.fileSize))
|
|
104
|
+
return V.warning(`文件大小不能超过${o.fileSize}M`), !1;
|
|
105
|
+
const a = ((l = t.name.split(".").pop()) == null ? void 0 : l.toLowerCase()) || "";
|
|
106
|
+
return v.value.includes(a) ? !0 : (V.warning(
|
|
107
|
+
`格式不支持,仅允许: ${v.value.join("/")}`
|
|
108
|
+
), !1);
|
|
109
|
+
}
|
|
110
|
+
function K(t, e, a, l) {
|
|
111
|
+
var J, G;
|
|
112
|
+
const i = o.api.startsWith("http") ? o.api : window.location.origin + o.api.replace(/^([^/])/, "/$1"), r = new FormData();
|
|
113
|
+
r.append(o.name, t), o.extraData && Object.entries(o.extraData).forEach(([n, ve]) => r.append(n, ve));
|
|
114
|
+
const s = new XMLHttpRequest();
|
|
115
|
+
L.push(s);
|
|
116
|
+
const b = ((J = T.value) == null ? void 0 : J.$el.querySelector(".el-upload--picture-card")) || ((G = T.value) == null ? void 0 : G.$el), j = De.service({
|
|
117
|
+
target: b,
|
|
118
|
+
text: "上传中",
|
|
119
|
+
background: "rgba(255,255,255,0.7)"
|
|
120
|
+
}), d = () => {
|
|
121
|
+
const n = L.indexOf(s);
|
|
122
|
+
n !== -1 && L.splice(n, 1), j.close();
|
|
123
|
+
};
|
|
124
|
+
s.open("POST", i);
|
|
125
|
+
const X = ze(o.tokenKey);
|
|
126
|
+
X && s.setRequestHeader("Authorization", `Bearer ${X}`), s.upload.onprogress = (n) => {
|
|
127
|
+
n.total > 0 && (e == null || e({ percent: n.loaded / n.total * 100 }));
|
|
128
|
+
}, s.onload = () => {
|
|
129
|
+
if (d(), s.status < 200 || s.status >= 300) {
|
|
130
|
+
const n = `上传失败 (HTTP ${s.status})`;
|
|
131
|
+
V.error(n), g("error", { msg: n, status: s.status }), l == null || l(new Error(n));
|
|
132
|
+
return;
|
|
133
|
+
}
|
|
134
|
+
try {
|
|
135
|
+
const n = JSON.parse(s.responseText);
|
|
136
|
+
n.code === 200 && n.urls ? (V.success("上传成功"), a == null || a({ ...n, url: n.urls })) : (V.error(n.msg || "上传失败"), g("error", n), l == null || l(n));
|
|
137
|
+
} catch {
|
|
138
|
+
V.error("上传失败,响应格式错误"), g("error", new Error("Response parse error")), l == null || l(new Error("Response parse error"));
|
|
139
|
+
}
|
|
140
|
+
}, s.onerror = () => {
|
|
141
|
+
d(), V.error("上传失败,网络异常"), g("error", new Error("Network error")), l == null || l(new Error("Network error"));
|
|
142
|
+
}, s.send(r);
|
|
143
|
+
}
|
|
144
|
+
function Q(t) {
|
|
145
|
+
return o.disabled ? !1 : ue(t);
|
|
146
|
+
}
|
|
147
|
+
function re(t) {
|
|
148
|
+
K(
|
|
149
|
+
t.file,
|
|
150
|
+
t.onProgress,
|
|
151
|
+
(e) => {
|
|
152
|
+
t.onSuccess(e), D(), g("success", e);
|
|
153
|
+
},
|
|
154
|
+
(e) => t.onError(e)
|
|
155
|
+
);
|
|
156
|
+
}
|
|
157
|
+
function de(t) {
|
|
158
|
+
var l;
|
|
159
|
+
if (!t.url) return;
|
|
160
|
+
const e = ((l = t.url.split(".").pop()) == null ? void 0 : l.toLowerCase()) || "";
|
|
161
|
+
if (["mp4", "mov", "avi", "webm"].includes(e)) {
|
|
162
|
+
E.value = t.url, H.value = t.name || "视频预览", S.value = !0;
|
|
163
|
+
return;
|
|
164
|
+
}
|
|
165
|
+
const a = u.value.filter(
|
|
166
|
+
(i) => {
|
|
167
|
+
var r;
|
|
168
|
+
return i.status === "success" && i.url && !["mp4", "mov", "avi", "webm"].includes(
|
|
169
|
+
(r = i.url.split(".").pop()) == null ? void 0 : r.toLowerCase()
|
|
170
|
+
);
|
|
171
|
+
}
|
|
172
|
+
);
|
|
173
|
+
A.value = a.map((i) => i.url), P.value = a.findIndex((i) => i.uid === t.uid) || 0, C.value = !0;
|
|
174
|
+
}
|
|
175
|
+
function pe() {
|
|
176
|
+
C.value = !1, A.value = [];
|
|
177
|
+
}
|
|
178
|
+
function W(t) {
|
|
179
|
+
for (let e = 0; e < t.length; e++) {
|
|
180
|
+
const a = t[e];
|
|
181
|
+
if (!Q(a)) continue;
|
|
182
|
+
const l = Date.now() + e, i = URL.createObjectURL(a);
|
|
183
|
+
q.add(i), u.value.push({
|
|
184
|
+
uid: l,
|
|
185
|
+
name: a.name || `file-${l}`,
|
|
186
|
+
status: "uploading",
|
|
187
|
+
percentage: 0,
|
|
188
|
+
url: i
|
|
189
|
+
}), K(
|
|
190
|
+
a,
|
|
191
|
+
(r) => {
|
|
192
|
+
const s = u.value.find((b) => b.uid === l);
|
|
193
|
+
s && (s.percentage = r.percent);
|
|
194
|
+
},
|
|
195
|
+
(r) => {
|
|
196
|
+
const s = u.value.find((b) => b.uid === l);
|
|
197
|
+
s && (s.status = "success", s.url = r.url, D(), g("success", r));
|
|
198
|
+
},
|
|
199
|
+
() => fe(l)
|
|
200
|
+
);
|
|
201
|
+
}
|
|
202
|
+
}
|
|
203
|
+
function O(t) {
|
|
204
|
+
var l;
|
|
205
|
+
if (o.disabled) return;
|
|
206
|
+
const e = (l = t.clipboardData) == null ? void 0 : l.items;
|
|
207
|
+
if (!e) return;
|
|
208
|
+
const a = [];
|
|
209
|
+
for (let i = 0; i < e.length; i++) {
|
|
210
|
+
const r = e[i];
|
|
211
|
+
if (r.kind === "file" && r.type.startsWith("image/")) {
|
|
212
|
+
const s = r.getAsFile();
|
|
213
|
+
s && a.push(s);
|
|
214
|
+
}
|
|
215
|
+
}
|
|
216
|
+
a.length && (t.preventDefault(), W(a));
|
|
217
|
+
}
|
|
218
|
+
function ce(t) {
|
|
219
|
+
var a;
|
|
220
|
+
if (z.value = !1, o.disabled || _.value) return;
|
|
221
|
+
const e = Array.from(((a = t.dataTransfer) == null ? void 0 : a.files) || []).filter(
|
|
222
|
+
(l) => {
|
|
223
|
+
var i;
|
|
224
|
+
return v.value.includes((i = l.name.split(".").pop()) == null ? void 0 : i.toLowerCase());
|
|
225
|
+
}
|
|
226
|
+
);
|
|
227
|
+
e.length && W(e);
|
|
228
|
+
}
|
|
229
|
+
function fe(t) {
|
|
230
|
+
var a;
|
|
231
|
+
const e = u.value.findIndex((l) => l.uid === t);
|
|
232
|
+
e !== -1 && ((a = u.value[e].url) != null && a.startsWith("blob:") && (URL.revokeObjectURL(u.value[e].url), q.delete(u.value[e].url)), u.value.splice(e, 1));
|
|
233
|
+
}
|
|
234
|
+
return Ve(() => {
|
|
235
|
+
L.forEach((t) => t.abort()), L.length = 0, q.forEach((t) => URL.revokeObjectURL(t)), q.clear();
|
|
236
|
+
}), Z({
|
|
237
|
+
openFileDialog: () => {
|
|
238
|
+
var t, e;
|
|
239
|
+
o.disabled || _.value || (e = (t = T.value) == null ? void 0 : t.$el.querySelector('input[type="file"]')) == null || e.click();
|
|
240
|
+
},
|
|
241
|
+
getPathList: () => u.value.filter((t) => t.status === "success").map((t) => t.url),
|
|
242
|
+
clearFiles: () => {
|
|
243
|
+
u.value = [], f.value = "", D();
|
|
244
|
+
},
|
|
245
|
+
getValue: () => ({
|
|
246
|
+
files: u.value.filter((t) => t.status === "success" && t.url).map((t) => t.url),
|
|
247
|
+
text: f.value
|
|
248
|
+
})
|
|
249
|
+
}), (t, e) => {
|
|
250
|
+
var j;
|
|
251
|
+
const a = ye, l = be, i = ge, r = me, s = xe, b = we;
|
|
252
|
+
return m(), w("div", {
|
|
253
|
+
class: I(["qy-upload", oe.value]),
|
|
254
|
+
style: Ue({ "--qy-upload-size": te.value })
|
|
255
|
+
}, [
|
|
256
|
+
y(r, {
|
|
257
|
+
ref_key: "uploadRef",
|
|
258
|
+
ref: T,
|
|
259
|
+
"file-list": u.value,
|
|
260
|
+
"onUpdate:fileList": e[6] || (e[6] = (d) => u.value = d),
|
|
261
|
+
action: "#",
|
|
262
|
+
multiple: p.supportVideo ? !1 : p.multiple,
|
|
263
|
+
limit: p.supportVideo ? 1 : p.limit,
|
|
264
|
+
"list-type": p.supportVideo ? "text" : "picture-card",
|
|
265
|
+
accept: ie.value,
|
|
266
|
+
disabled: le.value,
|
|
267
|
+
"http-request": re,
|
|
268
|
+
"before-upload": Q,
|
|
269
|
+
"on-preview": de,
|
|
270
|
+
"on-remove": ne
|
|
271
|
+
}, {
|
|
272
|
+
default: U(() => [
|
|
273
|
+
_.value ? h("", !0) : (m(), w("div", {
|
|
274
|
+
key: 0,
|
|
275
|
+
class: I(["qy-upload__trigger", { "is-dragover": z.value }]),
|
|
276
|
+
onPaste: O,
|
|
277
|
+
onDragover: e[4] || (e[4] = B((d) => z.value = !0, ["prevent"])),
|
|
278
|
+
onDragleave: e[5] || (e[5] = B((d) => z.value = !1, ["prevent"])),
|
|
279
|
+
onDrop: B(ce, ["prevent"])
|
|
280
|
+
}, [
|
|
281
|
+
y(a, { class: "qy-upload__icon" }, {
|
|
282
|
+
default: U(() => [
|
|
283
|
+
y(Y(Le))
|
|
284
|
+
]),
|
|
285
|
+
_: 1
|
|
286
|
+
}),
|
|
287
|
+
p.supportVideo ? (m(), w(M, { key: 0 }, [
|
|
288
|
+
e[9] || (e[9] = k("span", { class: "qy-upload__label" }, "点击上传视频", -1)),
|
|
289
|
+
k("span", _e, "支持 " + R(v.value.join(" / ")) + ",不超过 " + R(p.fileSize) + "MB", 1)
|
|
290
|
+
], 64)) : h("", !0),
|
|
291
|
+
k("div", {
|
|
292
|
+
class: "qy-upload__text",
|
|
293
|
+
onClick: e[3] || (e[3] = B(() => {
|
|
294
|
+
}, ["stop"])),
|
|
295
|
+
onPaste: B(O, ["stop"])
|
|
296
|
+
}, [
|
|
297
|
+
y(i, {
|
|
298
|
+
visible: F.value,
|
|
299
|
+
"onUpdate:visible": e[2] || (e[2] = (d) => F.value = d),
|
|
300
|
+
placement: "bottom-start",
|
|
301
|
+
width: 220,
|
|
302
|
+
trigger: "click",
|
|
303
|
+
"popper-class": "qy-upload__text-popover",
|
|
304
|
+
onAfterEnter: se
|
|
305
|
+
}, {
|
|
306
|
+
reference: U(() => [
|
|
307
|
+
k("div", {
|
|
308
|
+
class: I(["qy-upload__text-preview", { "is-placeholder": !f.value }])
|
|
309
|
+
}, R(f.value || "输入文字"), 3)
|
|
310
|
+
]),
|
|
311
|
+
default: U(() => [
|
|
312
|
+
y(l, {
|
|
313
|
+
ref_key: "inputRef",
|
|
314
|
+
ref: N,
|
|
315
|
+
modelValue: f.value,
|
|
316
|
+
"onUpdate:modelValue": e[0] || (e[0] = (d) => f.value = d),
|
|
317
|
+
type: "textarea",
|
|
318
|
+
autosize: { minRows: 2, maxRows: 5 },
|
|
319
|
+
placeholder: "输入文字或粘贴图片",
|
|
320
|
+
disabled: p.disabled,
|
|
321
|
+
onBlur: e[1] || (e[1] = (d) => F.value = !1),
|
|
322
|
+
onPaste: B(O, ["stop"])
|
|
323
|
+
}, null, 8, ["modelValue", "disabled"])
|
|
324
|
+
]),
|
|
325
|
+
_: 1
|
|
326
|
+
}, 8, ["visible"])
|
|
327
|
+
], 32)
|
|
328
|
+
], 34))
|
|
329
|
+
]),
|
|
330
|
+
_: 1
|
|
331
|
+
}, 8, ["file-list", "multiple", "limit", "list-type", "accept", "disabled"]),
|
|
332
|
+
C.value ? (m(), Be(s, {
|
|
333
|
+
key: 0,
|
|
334
|
+
"url-list": A.value,
|
|
335
|
+
"initial-index": P.value,
|
|
336
|
+
onClose: pe
|
|
337
|
+
}, null, 8, ["url-list", "initial-index"])) : h("", !0),
|
|
338
|
+
y(b, {
|
|
339
|
+
modelValue: S.value,
|
|
340
|
+
"onUpdate:modelValue": e[7] || (e[7] = (d) => S.value = d),
|
|
341
|
+
title: H.value,
|
|
342
|
+
width: "640px",
|
|
343
|
+
"append-to-body": "",
|
|
344
|
+
"destroy-on-close": "",
|
|
345
|
+
onClose: e[8] || (e[8] = (d) => S.value = !1)
|
|
346
|
+
}, {
|
|
347
|
+
default: U(() => [
|
|
348
|
+
S.value ? (m(), w("video", {
|
|
349
|
+
key: 0,
|
|
350
|
+
src: E.value,
|
|
351
|
+
controls: "",
|
|
352
|
+
autoplay: "",
|
|
353
|
+
style: { width: "100%", "max-height": "400px", "border-radius": "4px" }
|
|
354
|
+
}, null, 8, je)) : h("", !0)
|
|
355
|
+
]),
|
|
356
|
+
_: 1
|
|
357
|
+
}, 8, ["modelValue", "title"]),
|
|
358
|
+
ae.value ? (m(), w("div", $e, [
|
|
359
|
+
y(a, null, {
|
|
360
|
+
default: U(() => [
|
|
361
|
+
y(Y(Se))
|
|
362
|
+
]),
|
|
363
|
+
_: 1
|
|
364
|
+
}),
|
|
365
|
+
k("span", null, [
|
|
366
|
+
e[12] || (e[12] = $(" 请上传 ", -1)),
|
|
367
|
+
p.fileSize ? (m(), w(M, { key: 0 }, [
|
|
368
|
+
e[10] || (e[10] = $("大小不超过 ", -1)),
|
|
369
|
+
k("b", Ce, R(p.fileSize) + "MB", 1)
|
|
370
|
+
], 64)) : h("", !0),
|
|
371
|
+
(j = v.value) != null && j.length ? (m(), w(M, { key: 1 }, [
|
|
372
|
+
e[11] || (e[11] = $(",格式为 ", -1)),
|
|
373
|
+
k("b", Ae, R(v.value.join("/")), 1)
|
|
374
|
+
], 64)) : h("", !0),
|
|
375
|
+
e[13] || (e[13] = $(" 的文件。 ", -1))
|
|
376
|
+
])
|
|
377
|
+
])) : h("", !0)
|
|
378
|
+
], 6);
|
|
379
|
+
};
|
|
380
|
+
}
|
|
381
|
+
}), He = /* @__PURE__ */ Te(Fe, [["__scopeId", "data-v-c1472320"]]);
|
|
382
|
+
export {
|
|
383
|
+
He as Q
|
|
384
|
+
};
|