widget.qw 1.0.78 → 1.0.80

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/.env.development CHANGED
@@ -7,4 +7,4 @@ VITE_NEED_LOGIN_CODE=401
7
7
  # 注意:发布时 VITE_IS_DEBUG必须配置为false
8
8
  # 本地开发时 VITE_IS_DEBUG必须配置为true
9
9
  VITE_IS_DEBUG=true
10
- VITE_DEBUG_TOKEN= 'eyJ0eXAiOiJKV1QiLCJhbGciOiJIUzI1NiJ9.eyJsb2dpblR5cGUiOiJsb2dpbiIsImxvZ2luSWQiOiJIb3VNdSIsInJuU3RyIjoiWWo2V3NLRWdKYU9kb2FzMEZFOUFKZWxyTTJzMGVJQWkifQ.wiKRQYqs2lbFC8_56qnLzfKV9H0vbn2qyGG56qmNlwg'
10
+ VITE_DEBUG_TOKEN= 'eyJ0eXAiOiJKV1QiLCJhbGciOiJIUzI1NiJ9.eyJsb2dpblR5cGUiOiJsb2dpbiIsImxvZ2luSWQiOiJIb3VNdSIsInJuU3RyIjoiY0hNaG1ZU1JsdlRWdlZkZHZMaHR6dVlGWXFCN3lGZkgifQ.CCwMRLeLNpgkstsB80c5-ywekZu9fuM3i-U35tJEvb0'
package/build/style.css CHANGED
@@ -394,13 +394,13 @@
394
394
  cursor: not-allowed;
395
395
  opacity: 1;
396
396
  -webkit-text-fill-color: #000;
397
- }.image-box .cover[data-v-572cd71d] {
397
+ }.image-box .cover[data-v-d4977d2c] {
398
398
  width: 80px;
399
399
  height: 80px;
400
- }[data-v-df75f4fa] .label {
400
+ }[data-v-cf8ec8a0] .label {
401
401
  color: #000 !important;
402
402
  }
403
- [data-v-df75f4fa] .van-field__control:disabled {
403
+ [data-v-cf8ec8a0] .van-field__control:disabled {
404
404
  color: #000 !important;
405
405
  cursor: not-allowed;
406
406
  opacity: 1;
@@ -11522,8 +11522,8 @@ const compress_image = (file) => __async(this, null, function* () {
11522
11522
  return new Promise((resolve, reject) => {
11523
11523
  new Compressor(file, {
11524
11524
  quality: 0.7,
11525
- maxWidth: 800,
11526
- maxHeight: 800,
11525
+ maxWidth: 1024,
11526
+ maxHeight: 1024,
11527
11527
  success(result) {
11528
11528
  console.log("\u538B\u7F29\u540E\u7684\u56FE\u7247", result);
11529
11529
  let compress_file = blob2file(result, result.name);
@@ -19943,7 +19943,7 @@ const _sfc_main$j = {
19943
19943
  }
19944
19944
  };
19945
19945
  var ImagePicker = /* @__PURE__ */ _export_sfc(_sfc_main$j, [["__scopeId", "data-v-16be97a4"]]);
19946
- var images_picker_vue_vue_type_style_index_0_scoped_true_lang = /* @__PURE__ */ (() => ".image-box .cover[data-v-572cd71d] {\n width: 80px;\n height: 80px;\n}")();
19946
+ var images_picker_vue_vue_type_style_index_0_scoped_true_lang = /* @__PURE__ */ (() => ".image-box .cover[data-v-d4977d2c] {\n width: 80px;\n height: 80px;\n}")();
19947
19947
  const _hoisted_1$c = {
19948
19948
  class: "image-box"
19949
19949
  };
@@ -20019,24 +20019,49 @@ const _sfc_main$i = {
20019
20019
  });
20020
20020
  onMounted(() => {
20021
20021
  });
20022
- const onAfterRead = (file) => __async(this, null, function* () {
20023
- console.log(file);
20024
- let compress_file = file.file;
20025
- if (props.compress) {
20026
- compress_file = yield util.compress_image(file.file);
20022
+ const onAfterRead = (e) => __async(this, null, function* () {
20023
+ console.log("onAfterRead", e);
20024
+ let files2 = [];
20025
+ if (e && Array.isArray(e) && e.length > 0) {
20026
+ files2 = e;
20027
+ } else {
20028
+ files2 = [e];
20027
20029
  }
20028
- let params = {
20029
- file: compress_file
20030
- };
20031
- return util.file_upload(params).then((res) => {
20032
- let newUrls = [];
20033
- if (props.modelValue && props.modelValue.length > 0)
20034
- newUrls = [...props.modelValue, res.data];
20035
- else
20036
- newUrls = [res.data];
20037
- emit("update:modelValue", newUrls);
20038
- return Promise.resolve(file);
20039
- });
20030
+ if (files2 && files2.length > 0) {
20031
+ for (var i = 0; i < files2.length; i++) {
20032
+ let compress_file = files2[i].file;
20033
+ if (props.compress) {
20034
+ compress_file = yield util.compress_image(compress_file);
20035
+ }
20036
+ let params = {
20037
+ file: compress_file
20038
+ };
20039
+ let res = yield util.file_upload(params);
20040
+ if (res.code == 200) {
20041
+ let newUrls = [];
20042
+ if (props.modelValue && props.modelValue.length > 0)
20043
+ newUrls = [...props.modelValue, res.data];
20044
+ else
20045
+ newUrls = [res.data];
20046
+ emit("update:modelValue", newUrls);
20047
+ }
20048
+ }
20049
+ return Promise.resolve(e);
20050
+ }
20051
+ console.log("onAfterRead", e);
20052
+ for (var i = 0; i < files2.length; i++) {
20053
+ let params = {
20054
+ file: files2[i].file
20055
+ };
20056
+ let res = yield util.file_upload(params);
20057
+ if (res.code == 200) {
20058
+ if (props.multiple)
20059
+ modelValue.value = [...modelValue.value || [], res.data];
20060
+ else
20061
+ modelValue.value = res.data;
20062
+ }
20063
+ }
20064
+ return Promise.resolve(e);
20040
20065
  });
20041
20066
  const onBeforeDelete = (e) => {
20042
20067
  let newUrls = props.modelValue.filter((item) => {
@@ -20124,8 +20149,8 @@ const _sfc_main$i = {
20124
20149
  };
20125
20150
  }
20126
20151
  };
20127
- var ImagesPicker = /* @__PURE__ */ _export_sfc(_sfc_main$i, [["__scopeId", "data-v-572cd71d"]]);
20128
- var FilePicker_vue_vue_type_style_index_0_scoped_true_lang = /* @__PURE__ */ (() => "[data-v-df75f4fa] .label {\n color: #000 !important;\n}\n[data-v-df75f4fa] .van-field__control:disabled {\n color: #000 !important;\n cursor: not-allowed;\n opacity: 1;\n -webkit-text-fill-color: #000;\n}")();
20152
+ var ImagesPicker = /* @__PURE__ */ _export_sfc(_sfc_main$i, [["__scopeId", "data-v-d4977d2c"]]);
20153
+ var FilePicker_vue_vue_type_style_index_0_scoped_true_lang = /* @__PURE__ */ (() => "[data-v-cf8ec8a0] .label {\n color: #000 !important;\n}\n[data-v-cf8ec8a0] .van-field__control:disabled {\n color: #000 !important;\n cursor: not-allowed;\n opacity: 1;\n -webkit-text-fill-color: #000;\n}")();
20129
20154
  const _hoisted_1$b = {
20130
20155
  class: "file-box"
20131
20156
  };
@@ -20202,29 +20227,25 @@ const _sfc_main$h = {
20202
20227
  };
20203
20228
  const onAfterRead = (e) => __async(this, null, function* () {
20204
20229
  console.log("onAfterRead", e);
20205
- if (props.multiple) {
20206
- if (e && e.length > 0) {
20207
- for (var i = 0; i < e.length; i++) {
20208
- let params = {
20209
- file: e[i].file
20210
- };
20211
- let res = yield util.file_upload(params);
20212
- if (res.code == 200) {
20213
- modelValue.value = [...modelValue.value || [], res.data];
20214
- }
20215
- }
20216
- return Promise.resolve(e);
20217
- }
20230
+ let files2 = [];
20231
+ if (e && Array.isArray(e) && e.length > 0) {
20232
+ files2 = e;
20218
20233
  } else {
20234
+ files2 = [e];
20235
+ }
20236
+ for (var i = 0; i < files2.length; i++) {
20219
20237
  let params = {
20220
- file: e.file
20238
+ file: files2[i].file
20221
20239
  };
20222
20240
  let res = yield util.file_upload(params);
20223
20241
  if (res.code == 200) {
20224
- modelValue.value = res.data;
20225
- return Promise.resolve(e);
20242
+ if (props.multiple)
20243
+ modelValue.value = [...modelValue.value || [], res.data];
20244
+ else
20245
+ modelValue.value = res.data;
20226
20246
  }
20227
20247
  }
20248
+ return Promise.resolve(e);
20228
20249
  });
20229
20250
  const onBeforeDelete = (e) => {
20230
20251
  console.log("onBeforeDelete", e);
@@ -20291,7 +20312,7 @@ const _sfc_main$h = {
20291
20312
  };
20292
20313
  }
20293
20314
  };
20294
- var FilePicker = /* @__PURE__ */ _export_sfc(_sfc_main$h, [["__scopeId", "data-v-df75f4fa"]]);
20315
+ var FilePicker = /* @__PURE__ */ _export_sfc(_sfc_main$h, [["__scopeId", "data-v-cf8ec8a0"]]);
20295
20316
  var SingleUserSelector_vue_vue_type_style_index_0_scoped_true_lang = /* @__PURE__ */ (() => "\n.user-popup[data-v-a489ca4c] {\r\n width: 100%;\r\n overflow: hidden;\n}\n.department-selector[data-v-a489ca4c] {\r\n padding: 10px;\n}\n.search-buttons[data-v-a489ca4c] {\r\n display: flex;\r\n gap: 10px;\n}\n.clear-btn[data-v-a489ca4c] {\r\n background-color: #f2f3f5;\r\n border: none;\r\n border-radius: 4px;\r\n padding: 4px 8px;\r\n font-size: 14px;\n}\n.confirm-btn[data-v-a489ca4c] {\r\n background-color: #1989fa;\r\n color: white;\r\n border: none;\r\n border-radius: 4px;\r\n padding: 4px 8px;\r\n font-size: 14px;\n}\n.no-results[data-v-a489ca4c] {\r\n text-align: center;\r\n padding: 20px;\r\n color: #969799;\n}\n.picker-header[data-v-a489ca4c] {\r\n padding: 10px;\r\n border-bottom: 1px solid #ebedf0;\r\n display: flex;\r\n justify-content: space-between;\r\n align-items: center;\n}\n.current-path[data-v-a489ca4c] {\r\n flex: 1;\r\n font-size: 14px;\r\n color: #323233;\r\n white-space: nowrap;\r\n overflow: hidden;\r\n text-overflow: ellipsis;\n}\n.header-right[data-v-a489ca4c] {\r\n display: flex;\r\n gap: 8px;\r\n margin-left: auto;\n}\n.cancel-btn[data-v-a489ca4c] {\r\n color: #969799;\r\n margin-right: 5px;\n}\n.scroll-container[data-v-a489ca4c] {\r\n height: calc(80vh - 150px);\r\n overflow-y: auto;\n}\r\n")();
20296
20317
  const _hoisted_1$a = {
20297
20318
  class: "department-selector"
@@ -11525,8 +11525,8 @@ var __async = (__this, __arguments, generator) => {
11525
11525
  return new Promise((resolve, reject) => {
11526
11526
  new Compressor(file, {
11527
11527
  quality: 0.7,
11528
- maxWidth: 800,
11529
- maxHeight: 800,
11528
+ maxWidth: 1024,
11529
+ maxHeight: 1024,
11530
11530
  success(result) {
11531
11531
  console.log("\u538B\u7F29\u540E\u7684\u56FE\u7247", result);
11532
11532
  let compress_file = blob2file(result, result.name);
@@ -19946,7 +19946,7 @@ var __async = (__this, __arguments, generator) => {
19946
19946
  }
19947
19947
  };
19948
19948
  var ImagePicker = /* @__PURE__ */ _export_sfc(_sfc_main$j, [["__scopeId", "data-v-16be97a4"]]);
19949
- var images_picker_vue_vue_type_style_index_0_scoped_true_lang = /* @__PURE__ */ (() => ".image-box .cover[data-v-572cd71d] {\n width: 80px;\n height: 80px;\n}")();
19949
+ var images_picker_vue_vue_type_style_index_0_scoped_true_lang = /* @__PURE__ */ (() => ".image-box .cover[data-v-d4977d2c] {\n width: 80px;\n height: 80px;\n}")();
19950
19950
  const _hoisted_1$c = {
19951
19951
  class: "image-box"
19952
19952
  };
@@ -20022,24 +20022,49 @@ var __async = (__this, __arguments, generator) => {
20022
20022
  });
20023
20023
  vue.onMounted(() => {
20024
20024
  });
20025
- const onAfterRead = (file) => __async(this, null, function* () {
20026
- console.log(file);
20027
- let compress_file = file.file;
20028
- if (props.compress) {
20029
- compress_file = yield util.compress_image(file.file);
20025
+ const onAfterRead = (e) => __async(this, null, function* () {
20026
+ console.log("onAfterRead", e);
20027
+ let files2 = [];
20028
+ if (e && Array.isArray(e) && e.length > 0) {
20029
+ files2 = e;
20030
+ } else {
20031
+ files2 = [e];
20030
20032
  }
20031
- let params = {
20032
- file: compress_file
20033
- };
20034
- return util.file_upload(params).then((res) => {
20035
- let newUrls = [];
20036
- if (props.modelValue && props.modelValue.length > 0)
20037
- newUrls = [...props.modelValue, res.data];
20038
- else
20039
- newUrls = [res.data];
20040
- emit("update:modelValue", newUrls);
20041
- return Promise.resolve(file);
20042
- });
20033
+ if (files2 && files2.length > 0) {
20034
+ for (var i = 0; i < files2.length; i++) {
20035
+ let compress_file = files2[i].file;
20036
+ if (props.compress) {
20037
+ compress_file = yield util.compress_image(compress_file);
20038
+ }
20039
+ let params = {
20040
+ file: compress_file
20041
+ };
20042
+ let res = yield util.file_upload(params);
20043
+ if (res.code == 200) {
20044
+ let newUrls = [];
20045
+ if (props.modelValue && props.modelValue.length > 0)
20046
+ newUrls = [...props.modelValue, res.data];
20047
+ else
20048
+ newUrls = [res.data];
20049
+ emit("update:modelValue", newUrls);
20050
+ }
20051
+ }
20052
+ return Promise.resolve(e);
20053
+ }
20054
+ console.log("onAfterRead", e);
20055
+ for (var i = 0; i < files2.length; i++) {
20056
+ let params = {
20057
+ file: files2[i].file
20058
+ };
20059
+ let res = yield util.file_upload(params);
20060
+ if (res.code == 200) {
20061
+ if (props.multiple)
20062
+ modelValue.value = [...modelValue.value || [], res.data];
20063
+ else
20064
+ modelValue.value = res.data;
20065
+ }
20066
+ }
20067
+ return Promise.resolve(e);
20043
20068
  });
20044
20069
  const onBeforeDelete = (e) => {
20045
20070
  let newUrls = props.modelValue.filter((item) => {
@@ -20127,8 +20152,8 @@ var __async = (__this, __arguments, generator) => {
20127
20152
  };
20128
20153
  }
20129
20154
  };
20130
- var ImagesPicker = /* @__PURE__ */ _export_sfc(_sfc_main$i, [["__scopeId", "data-v-572cd71d"]]);
20131
- var FilePicker_vue_vue_type_style_index_0_scoped_true_lang = /* @__PURE__ */ (() => "[data-v-df75f4fa] .label {\n color: #000 !important;\n}\n[data-v-df75f4fa] .van-field__control:disabled {\n color: #000 !important;\n cursor: not-allowed;\n opacity: 1;\n -webkit-text-fill-color: #000;\n}")();
20155
+ var ImagesPicker = /* @__PURE__ */ _export_sfc(_sfc_main$i, [["__scopeId", "data-v-d4977d2c"]]);
20156
+ var FilePicker_vue_vue_type_style_index_0_scoped_true_lang = /* @__PURE__ */ (() => "[data-v-cf8ec8a0] .label {\n color: #000 !important;\n}\n[data-v-cf8ec8a0] .van-field__control:disabled {\n color: #000 !important;\n cursor: not-allowed;\n opacity: 1;\n -webkit-text-fill-color: #000;\n}")();
20132
20157
  const _hoisted_1$b = {
20133
20158
  class: "file-box"
20134
20159
  };
@@ -20205,29 +20230,25 @@ var __async = (__this, __arguments, generator) => {
20205
20230
  };
20206
20231
  const onAfterRead = (e) => __async(this, null, function* () {
20207
20232
  console.log("onAfterRead", e);
20208
- if (props.multiple) {
20209
- if (e && e.length > 0) {
20210
- for (var i = 0; i < e.length; i++) {
20211
- let params = {
20212
- file: e[i].file
20213
- };
20214
- let res = yield util.file_upload(params);
20215
- if (res.code == 200) {
20216
- modelValue.value = [...modelValue.value || [], res.data];
20217
- }
20218
- }
20219
- return Promise.resolve(e);
20220
- }
20233
+ let files2 = [];
20234
+ if (e && Array.isArray(e) && e.length > 0) {
20235
+ files2 = e;
20221
20236
  } else {
20237
+ files2 = [e];
20238
+ }
20239
+ for (var i = 0; i < files2.length; i++) {
20222
20240
  let params = {
20223
- file: e.file
20241
+ file: files2[i].file
20224
20242
  };
20225
20243
  let res = yield util.file_upload(params);
20226
20244
  if (res.code == 200) {
20227
- modelValue.value = res.data;
20228
- return Promise.resolve(e);
20245
+ if (props.multiple)
20246
+ modelValue.value = [...modelValue.value || [], res.data];
20247
+ else
20248
+ modelValue.value = res.data;
20229
20249
  }
20230
20250
  }
20251
+ return Promise.resolve(e);
20231
20252
  });
20232
20253
  const onBeforeDelete = (e) => {
20233
20254
  console.log("onBeforeDelete", e);
@@ -20294,7 +20315,7 @@ var __async = (__this, __arguments, generator) => {
20294
20315
  };
20295
20316
  }
20296
20317
  };
20297
- var FilePicker = /* @__PURE__ */ _export_sfc(_sfc_main$h, [["__scopeId", "data-v-df75f4fa"]]);
20318
+ var FilePicker = /* @__PURE__ */ _export_sfc(_sfc_main$h, [["__scopeId", "data-v-cf8ec8a0"]]);
20298
20319
  var SingleUserSelector_vue_vue_type_style_index_0_scoped_true_lang = /* @__PURE__ */ (() => "\n.user-popup[data-v-a489ca4c] {\r\n width: 100%;\r\n overflow: hidden;\n}\n.department-selector[data-v-a489ca4c] {\r\n padding: 10px;\n}\n.search-buttons[data-v-a489ca4c] {\r\n display: flex;\r\n gap: 10px;\n}\n.clear-btn[data-v-a489ca4c] {\r\n background-color: #f2f3f5;\r\n border: none;\r\n border-radius: 4px;\r\n padding: 4px 8px;\r\n font-size: 14px;\n}\n.confirm-btn[data-v-a489ca4c] {\r\n background-color: #1989fa;\r\n color: white;\r\n border: none;\r\n border-radius: 4px;\r\n padding: 4px 8px;\r\n font-size: 14px;\n}\n.no-results[data-v-a489ca4c] {\r\n text-align: center;\r\n padding: 20px;\r\n color: #969799;\n}\n.picker-header[data-v-a489ca4c] {\r\n padding: 10px;\r\n border-bottom: 1px solid #ebedf0;\r\n display: flex;\r\n justify-content: space-between;\r\n align-items: center;\n}\n.current-path[data-v-a489ca4c] {\r\n flex: 1;\r\n font-size: 14px;\r\n color: #323233;\r\n white-space: nowrap;\r\n overflow: hidden;\r\n text-overflow: ellipsis;\n}\n.header-right[data-v-a489ca4c] {\r\n display: flex;\r\n gap: 8px;\r\n margin-left: auto;\n}\n.cancel-btn[data-v-a489ca4c] {\r\n color: #969799;\r\n margin-right: 5px;\n}\n.scroll-container[data-v-a489ca4c] {\r\n height: calc(80vh - 150px);\r\n overflow-y: auto;\n}\r\n")();
20299
20320
  const _hoisted_1$a = {
20300
20321
  class: "department-selector"
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "widget.qw",
3
3
  "private": false,
4
- "version": "1.0.78",
4
+ "version": "1.0.80",
5
5
  "description": "marqstree Vue3组件库",
6
6
  "main": "build/widget.qw.es.js",
7
7
  "keywords": [
@@ -86,32 +86,29 @@ const onClickPreview = (e) => {
86
86
  const onAfterRead = async (e) => {
87
87
  console.log('onAfterRead', e)
88
88
 
89
- if (props.multiple) {
90
- if (e && e.length > 0) {
91
- for (var i = 0; i < e.length; i++) {
92
- let params = {
93
- file: e[i].file
94
- }
95
89
 
96
- let res = await util.file_upload(params)
97
- if (res.code == 200) {
98
- modelValue.value = [...(modelValue.value || []), res.data]
99
- }
100
- }
90
+ let files = []
91
+ if (e && Array.isArray(e) && e.length > 0) {
92
+ files = e
93
+ }else{
94
+ files = [e]
95
+ }
101
96
 
102
- return Promise.resolve(e)
103
- }
104
- } else {
97
+ for (var i = 0; i < files.length; i++) {
105
98
  let params = {
106
- file: e.file
99
+ file: files[i].file
107
100
  }
108
101
 
109
102
  let res = await util.file_upload(params)
110
103
  if (res.code == 200) {
111
- modelValue.value = res.data
112
- return Promise.resolve(e)
104
+ if(props.multiple)
105
+ modelValue.value = [...(modelValue.value || []), res.data]
106
+ else
107
+ modelValue.value = res.data
113
108
  }
114
109
  }
110
+
111
+ return Promise.resolve(e)
115
112
  }
116
113
 
117
114
  const onBeforeDelete = (e) => {
@@ -3,15 +3,18 @@
3
3
  :placeholder="props.placeholder">
4
4
  <template #input>
5
5
  <div class="image-box">
6
- <van-uploader v-if="props.capture && (!isReadonly && !isDisabled)" v-model="files" multiple :max-count="props.max"
7
- :capture="props.capture" accept="image/jpeg,image/png" :disabled="isDisabled"
6
+ <van-uploader v-if="props.capture && (!isReadonly && !isDisabled)" v-model="files" multiple
7
+ :max-count="props.max" :capture="props.capture" accept="image/jpeg,image/png" :disabled="isDisabled"
8
8
  :deletable="!isRequired && !isDisabled" :afterRead="onAfterRead" :before-delete="onBeforeDelete"
9
9
  :show-upload="!isReadonly" />
10
- <van-uploader v-if="!props.capture && (!isReadonly && !isDisabled)" v-model="files" multiple :max-count="props.max"
11
- accept="image/jpeg,image/png" :disabled="isDisabled" :deletable="!isReadonly && !isDisabled"
12
- :afterRead="onAfterRead" :before-delete="onBeforeDelete" :show-upload="!isReadonly" />
13
- <img class="cover" v-if="isReadonly || isDisabled" v-for="(cover, i) in previews" :key="i" :src="cover" @click="onPreview(i)" />
14
- <van-icon v-if="modelValue.length>props.maxPreview && (isReadonly || isDisabled)" name="ellipsis" @click="onToggleMore"/>
10
+ <van-uploader v-if="!props.capture && (!isReadonly && !isDisabled)" v-model="files" multiple
11
+ :max-count="props.max" accept="image/jpeg,image/png" :disabled="isDisabled"
12
+ :deletable="!isReadonly && !isDisabled" :afterRead="onAfterRead" :before-delete="onBeforeDelete"
13
+ :show-upload="!isReadonly" />
14
+ <img class="cover" v-if="isReadonly || isDisabled" v-for="(cover, i) in previews" :key="i" :src="cover"
15
+ @click="onPreview(i)" />
16
+ <van-icon v-if="modelValue.length > props.maxPreview && (isReadonly || isDisabled)" name="ellipsis"
17
+ @click="onToggleMore" />
15
18
  </div>
16
19
  </template>
17
20
  </van-field>
@@ -73,12 +76,12 @@ const emit = defineEmits(['update:modelValue'])
73
76
  const modelValue = useVModel(props, 'modelValue', emit)
74
77
  const { isRequired, isReadonly, isGone, isDisabled } = util.props2auth(props)
75
78
  const files = ref([])
76
- const isPreviewMore=ref(false)
77
- const previews=computed(()=>{
78
- if(!modelValue.value || modelValue.value.length<1)
79
+ const isPreviewMore = ref(false)
80
+ const previews = computed(() => {
81
+ if (!modelValue.value || modelValue.value.length < 1)
79
82
  return []
80
83
 
81
- if(props.maxPreview > modelValue.value.length || isPreviewMore.value)
84
+ if (props.maxPreview > modelValue.value.length || isPreviewMore.value)
82
85
  return modelValue.value
83
86
 
84
87
  return modelValue.value.slice(0, props.maxPreview)
@@ -88,28 +91,62 @@ onMounted(() => {
88
91
 
89
92
  })
90
93
 
91
- const onAfterRead = async (file) => {
92
- console.log(file)
94
+ const onAfterRead = async (e) => {
95
+ console.log('onAfterRead', e)
93
96
 
94
- let compress_file = file.file
95
- if (props.compress) {
96
- compress_file = await util.compress_image(file.file)
97
+ let files = []
98
+ if (e && Array.isArray(e) && e.length > 0) {
99
+ files = e
100
+ }else{
101
+ files = [e]
97
102
  }
98
103
 
99
- let params = {
100
- file: compress_file
104
+ if (files && files.length > 0) {
105
+ for (var i = 0; i < files.length; i++) {
106
+ let compress_file = files[i].file
107
+ if (props.compress) {
108
+ compress_file = await util.compress_image(compress_file)
109
+ }
110
+
111
+ let params = {
112
+ file: compress_file
113
+ }
114
+
115
+ let res = await util.file_upload(params)
116
+ if (res.code == 200) {
117
+ let newUrls = []
118
+ if (props.modelValue && props.modelValue.length > 0)
119
+ newUrls = [...props.modelValue, res.data]
120
+ else
121
+ newUrls = [res.data]
122
+
123
+ emit('update:modelValue', newUrls)
124
+ }
125
+ }
126
+
127
+ return Promise.resolve(e)
101
128
  }
102
129
 
103
- return util.file_upload(params).then(res => {
104
- let newUrls = []
105
- if (props.modelValue && props.modelValue.length > 0)
106
- newUrls = [...props.modelValue, res.data]
107
- else
108
- newUrls = [res.data]
130
+ console.log('onAfterRead', e)
109
131
 
110
- emit('update:modelValue', newUrls)
111
- return Promise.resolve(file)
112
- })
132
+
133
+
134
+
135
+ for (var i = 0; i < files.length; i++) {
136
+ let params = {
137
+ file: files[i].file
138
+ }
139
+
140
+ let res = await util.file_upload(params)
141
+ if (res.code == 200) {
142
+ if(props.multiple)
143
+ modelValue.value = [...(modelValue.value || []), res.data]
144
+ else
145
+ modelValue.value = res.data
146
+ }
147
+ }
148
+
149
+ return Promise.resolve(e)
113
150
  }
114
151
 
115
152
  const onBeforeDelete = (e) => {
@@ -121,10 +158,10 @@ const onBeforeDelete = (e) => {
121
158
  }
122
159
 
123
160
  const onPreview = (i) => {
124
- showImagePreview({images:modelValue.value, startPosition:i})
161
+ showImagePreview({ images: modelValue.value, startPosition: i })
125
162
  }
126
163
 
127
- const onToggleMore=()=>{
164
+ const onToggleMore = () => {
128
165
  isPreviewMore.value = !isPreviewMore.value
129
166
  }
130
167
 
@@ -149,12 +186,11 @@ watch(() => props.modelValue,
149
186
  </script>
150
187
 
151
188
  <style lang="scss" scoped>
189
+ .image-box {
152
190
 
153
- .image-box {
154
-
155
- .cover {
156
- width: 80px;
157
- height: 80px;
158
- }
191
+ .cover {
192
+ width: 80px;
193
+ height: 80px;
159
194
  }
195
+ }
160
196
  </style>
@@ -5,8 +5,8 @@ export const compress_image = async (file) => {
5
5
  return new Promise((resolve, reject) => {
6
6
  new Compressor(file, {
7
7
  quality: 0.7,
8
- maxWidth: 800,
9
- maxHeight: 800,
8
+ maxWidth: 1024,
9
+ maxHeight: 1024,
10
10
  success(result) {
11
11
  console.log('压缩后的图片', result);
12
12
  let compress_file = blob2file(result, result.name)
@@ -8,8 +8,8 @@
8
8
  import { onMounted, reactive, watch } from "vue";
9
9
 
10
10
  const data = reactive({
11
- auth:'readonly',
12
- urls: ['http://www.zjpsjdsb.online/static//HrMi9Q2J.png','http://www.zjpsjdsb.online/static//HrMi9Q2J.png','http://www.zjpsjdsb.online/static//HrMi9Q2J.png','http://www.zjpsjdsb.online/static//HrMi9Q2J.png','http://www.zjpsjdsb.online/static//HrMi9Q2J.png','http://www.zjpsjdsb.online/static//HrMi9Q2J.png']
11
+ auth:'require',
12
+ urls: []
13
13
  })
14
14
 
15
15
  watch(()=>data.url,(newVal,oldVal)=>{