centaline-data-driven 1.2.18 → 1.2.21

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.
@@ -1,237 +1,309 @@
1
1
  <template>
2
- <div style="width:100%" class="ct-photoSelect">
3
-
2
+ <div style="width: 100%" class="ct-photoSelect">
4
3
  <ul class="el-upload-list el-upload-list--picture-card">
5
- <draggable v-model="fileList" v-bind="dragOptions" @end="onEnd" class="card">
6
- <li class="el-upload-list__item is-success" v-for="(item, index) in fileList">
4
+ <draggable
5
+ v-model="photoList"
6
+ v-bind="dragOptions"
7
+ @end="onEnd"
8
+ class="card"
9
+ ><li
10
+ class="el-upload-list__item is-success"
11
+ v-bind:key="index"
12
+ v-for="(item, index) in photoList"
13
+ >
7
14
  <div class="cover-list-item">
8
- <el-image fit="fill" :src="item.mediaUrl"
9
- style="width: 100px; height: 100px"
10
- :z-index="previewZIndex"
11
- @click="viewerOpen(fileList,index)">
15
+ <el-image
16
+ fit="fill"
17
+ :src="item.thumbnailUrl"
18
+ style="width: 100px; height: 100px"
19
+ :z-index="previewZIndex"
20
+ @click="viewerOpen(photoList, index)"
21
+ >
12
22
  </el-image>
13
23
  <span class="cover-list-item-span-delete">
14
24
  <i class="el-icon-delete" @click="handleRemove(index)"></i>
15
25
  </span>
16
26
  <span class="cover-list-item-span" v-if="item.mediaLabelName">
17
27
  <span class="el-dropdown-link">
18
- &nbsp;{{item.mediaLabelName}}
28
+ &nbsp;{{ item.mediaLabelName }}
19
29
  </span>
20
30
  </span>
21
31
  </div>
22
32
  </li>
23
33
  </draggable>
24
34
  </ul>
25
- <div class="el-upload el-upload--picture-card" v-if="!modelPhotoselect.lock" @click="handleOpen()">
35
+ <div
36
+ class="el-upload el-upload--picture-card"
37
+ v-if="!modelPhotoselect.lock&&photoList.length<max"
38
+ @click="handleOpen()"
39
+ >
26
40
  <i class="el-icon-plus"></i>
27
41
  </div>
28
-
42
+ <div slot="tip" class="el-upload__tip errorMessage" v-show="!valid">
43
+ {{ validMessage }}
44
+ </div>
29
45
  <ct-viewer ref="photoSelectViewer" />
30
46
  </div>
31
-
32
47
  </template>
33
48
 
34
49
  <script>
35
- import draggable from 'vuedraggable';
36
- import dynamicElement from '../../mixins/dynamicElement';
37
- import Enum from '../../loader/src/ctl/lib/Enum';
38
- import dynamicViewer from '../../dynamicViewer/src/dynamicViewer.vue';
39
-
40
-
41
- export default {
42
- name: 'ct-photoselect',
43
- mixins: [dynamicElement],
44
- components: {
45
- 'draggable': draggable,
46
- 'ct-viewer': dynamicViewer,
47
- },
48
- props: {
49
- vmodel: Object,
50
- api: String
50
+ import draggable from "vuedraggable";
51
+ import dynamicElement from "../../mixins/dynamicElement";
52
+ import Enum from "../../loader/src/ctl/lib/Enum";
53
+ import dynamicViewer from "../../dynamicViewer/src/dynamicViewer.vue";
54
+
55
+ export default {
56
+ name: "ct-photoselect",
57
+ mixins: [dynamicElement],
58
+ components: {
59
+ draggable: draggable,
60
+ "ct-viewer": dynamicViewer,
61
+ },
62
+ props: {
63
+ vmodel: Object,
64
+ api: String,
65
+ },
66
+ data() {
67
+ return {
68
+ max:99999,
69
+ validMessage: "",
70
+ photoList: [],
71
+ modelPhotoselect: {},
72
+ };
73
+ },
74
+ computed: {
75
+ previewZIndex: function () {
76
+ return this.$common.getDataDrivenOpts().zindex + 100;
51
77
  },
52
- data() {
78
+ dragOptions() {
53
79
  return {
54
- fileList: [],
55
- modelPhotoselect: {}
56
- }
80
+ animation: 200,
81
+ group: "description",
82
+ disabled: false,
83
+ ghostClass: "ghost",
84
+ dragClass: "drag",
85
+ chosenClass: "chosen",
86
+ forceFallback: true,
87
+ };
57
88
  },
58
- computed: {
59
- previewZIndex: function () {
60
- return this.$common.getDataDrivenOpts().zindex + 100;
61
- },
62
- dragOptions() {
63
- return {
64
- animation: 200,
65
- group: "description",
66
- disabled: false,
67
- ghostClass: "ghost",
68
- dragClass: "drag",
69
- chosenClass: "chosen",
70
- forceFallback: true
71
- };
89
+ },
90
+ created() {
91
+ var self = this;
92
+ this.$nextTick(function () {
93
+ if (self.vmodel) {
94
+ self.load(self.vmodel);
95
+ self.$emit("loaded");
96
+ } else if (typeof self.source !== "undefined") {
97
+ self.loaderObj.PhotoSelect(self.source, (data) => {
98
+ self.load(data);
99
+ });
72
100
  }
101
+ });
102
+ },
103
+ methods: {
104
+ load(data) {
105
+ this.model = data;
106
+ this.max=data.max?data.max:99999;
107
+ this.modelPhotoselect = data;
108
+ this.photoList = data.fileList;
109
+ },
110
+ handleRemove(index) {
111
+ this.modelPhotoselect.delete(index);
112
+ this.photoList.splice(index, 1);
73
113
  },
74
- created() {
114
+ handleOpen() {
75
115
  var self = this;
76
- this.$nextTick(function () {
77
- if (self.vmodel) {
78
- self.load(self.vmodel);
79
- self.$emit('loaded');
80
- }
81
- else if (typeof self.source !== 'undefined') {
82
- self.loaderObj.PhotoSelect(self.source, (data) => {
83
- self.load(data);
84
- });
85
- }
116
+ var chooseList = new Array();
117
+ if (self.modelPhotoselect.action == "") {
118
+ self.$message.warning("请配置parameterAction!");
119
+ return;
120
+ }
121
+ var params = {
122
+ paramName: self.modelPhotoselect.paramName,
123
+ parentValue: self.modelPhotoselect.getFormParentFieldPara(),
124
+ };
125
+ self.photoList.forEach((n) => {
126
+ chooseList.push(n);
86
127
  });
87
- },
88
- methods: {
89
- load(data) {
90
- this.modelPhotoselect = data;
91
- this.fileList = data.fileList;
92
- },
93
- handleRemove(index) {
94
- this.modelPhotoselect.delete(index);
95
- },
96
- handleOpen() {
97
- var self = this;
98
- if (self.modelPhotoselect.action == "") {
99
- self.$message.warning("请配置选择图片路由!");
100
- return;
101
- }
102
- var params = {
103
- paramName: self.modelPhotoselect.paramName,
104
- parentValue: self.modelPhotoselect.getFormParentFieldPara(),
105
- };
106
- var dialogOption = {
107
- title: "选择图片",
108
- pane: self.$common.getParentPane(self),
109
- content: [{
110
- component: 'ct-photoSelectList',
128
+
129
+ var dialogOption = {
130
+ title: "选择图片",
131
+ pane: self.$common.getParentPane(self),
132
+ content: [
133
+ {
134
+ component: "ct-photoSelectList",
111
135
  attrs: {
112
- api: self.modelPhotoselect.action,// self.api,//source.xx
136
+ api: self.modelPhotoselect.action, // self.api,//source.xx
113
137
  showTitle: false,
114
- Selected: self.$common.deepClone(self.modelPhotoselect.fileList),
115
- width: self.modelPhotoselect.router.pageWidth + 'px',
116
- height: self.modelPhotoselect.router.pageHeight+'px',
117
- para: params
118
-
138
+ Selected: chooseList,
139
+ // width: self.modelPhotoselect.router.pageWidth + 'px',
140
+ // height: self.modelPhotoselect.router.pageHeight+'px',
141
+ width: "772px",
142
+ height: "550px",
143
+ para: params,
119
144
  },
120
145
  on: {
121
- handlePhoto(fileList) {
122
- self.modelPhotoselect.setFileList(fileList);
123
- self.$common.closeDialog(dialogOption.dialog);
124
-
125
- }
126
- }
127
- }]
128
- };
129
- self.$common.openDialog(dialogOption);
130
-
131
- },
132
- viewerOpen(list, index) {
133
- var showList = [];
134
- var viewerList = [];
135
- list.forEach((v) => {
136
- showList.push(v.mediaUrl);
137
- viewerList.push({ url: v.mediaUrl, title: v.mediaLabelName });
138
- });
139
- this.$refs.photoSelectViewer.open(showList, index, viewerList);
140
- },
141
- onEnd(a, b) {
142
- var self = this;
143
- self.modelPhotoselect.setFileList(self.fileList);
144
- }
146
+ handlePhoto(photoList) {
147
+ self.$nextTick(function () {
148
+ if (this.modelPhotoselect.max) {
149
+ if (photoList.length > this.modelPhotoselect.max) {
150
+ self.$message.warning(
151
+ "图片最多" + this.modelPhotoselect.max + "张"
152
+ );
153
+ self.valid = false;
154
+ setTimeout(() => {
155
+ self.valid = true;
156
+ }, 3000);
157
+ photoList = photoList.slice(0, this.modelPhotoselect.max);
158
+ }
159
+ }
160
+ self.modelPhotoselect.setFileList(photoList);
161
+ self.photoList = photoList;
162
+
163
+ self.$common.closeDialog(dialogOption.dialog);
164
+ });
165
+ },
166
+ },
167
+ },
168
+ ],
169
+ };
170
+ self.$common.openDialog(dialogOption);
145
171
  },
146
- mounted() {
172
+ viewerOpen(list, index) {
173
+ var showList = [];
174
+ var viewerList = [];
175
+ list.forEach((v) => {
176
+ showList.push(v.mediaUrl);
177
+ viewerList.push({ url: v.mediaUrl, title: v.mediaLabelName });
178
+ });
179
+ this.$refs.photoSelectViewer.open(showList, index, viewerList);
180
+ },
181
+ onEnd(a, b) {
182
+ var self = this;
183
+ self.$nextTick(function () {
184
+ self.modelPhotoselect.setFileList(self.photoList);
185
+ });
186
+ },
187
+ //不能共用的数据校验
188
+ selfValidExcute: function (eventName) {
189
+ if (this.modelPhotoselect.required) {
190
+ if (this.modelPhotoselect.getfileListLength() === 0) {
191
+ this.validMessage = "必须选择图片";
192
+ this.valid = false;
193
+ return false;
194
+ }
195
+ }
196
+
197
+ if (this.modelPhotoselect.max) {
198
+ if (
199
+ this.modelPhotoselect.getfileListLength() > this.modelPhotoselect.max
200
+ ) {
201
+ this.validMessage = "图片最多" + this.modelPhotoselect.max + "张";
202
+ this.valid = false;
203
+ return false;
204
+ }
205
+ }
206
+ if (this.modelPhotoselect.min) {
207
+ if (
208
+ this.modelPhotoselect.getfileListLength() < this.modelPhotoselect.min
209
+ ) {
210
+ this.validMessage = "图片最少" + this.modelPhotoselect.min + "张";
211
+ this.valid = false;
212
+ return false;
213
+ }
214
+ }
147
215
 
148
- }
149
- }
216
+ this.valid = true;
217
+ return this.valid;
218
+ },
219
+ },
220
+ mounted() {},
221
+ };
150
222
  </script>
151
223
  <style>
152
- .ghost {
153
- border: 1px red solid !important;
154
- }
155
- .drag {
156
- background: #eee;
157
- border: 3px #ddd dashed !important;
158
- }
159
- .chosen {
160
- }
161
-
162
- .flip-list-move {
163
- transition: transform 0.5s;
164
- }
165
-
166
- .no-move {
167
- transition: transform 0s;
168
- }
169
-
170
- .ct-upload-display-none .el-upload--picture-card {
171
- display: none;
172
- }
173
-
174
- .el-upload-list__item .is-ready {
175
- width: 100px;
176
- height: 100px;
177
- }
178
-
179
- .ct-photoSelect .cover-list-item {
180
- position: sticky;
181
- }
182
-
183
- .ct-photoSelect .cover-list-item-span {
184
- position: inherit;
185
- bottom: 0px;
186
- left: 0px;
187
- display: block;
188
- background-color: #544f48;
189
- opacity: 0.8;
190
- }
191
-
192
- .ct-photoSelect .cover-list-item-span-delete {
193
- position: inherit;
194
- bottom: 160px;
195
- left: 130px;
196
- color: #000000;
197
- text-align: center;
198
- }
199
-
200
- .cover-list-item-span-delete i {
201
- cursor: pointer;
202
- vertical-align: sub;
203
- margin-right: 4px;
204
- }
205
-
206
- .ct-photoSelect .el-dropdown-link {
207
- cursor: pointer;
208
- color: #fff;
209
- }
210
-
211
- .ct-photoSelect .el-icon-arrow-down {
212
- font-size: 12px;
213
- }
214
-
215
- .el-collapse-item__content {
216
- padding-bottom: 18px;
217
- }
218
-
219
- .el-upload--picture-card {
220
- width: 100px;
221
- height: 100px;
222
- line-height: initial;
223
- padding: 34px;
224
- }
225
-
226
- .el-upload--picture-card i {
227
- font-size: 30px;
228
- }
229
-
230
- .el-upload-list--picture-card .el-upload-list__item {
231
- width: 100px;
232
- height: 100px;
233
- }
234
- .card{
235
- display: inline-block;
236
- }
224
+ .ghost {
225
+ border: 1px red solid !important;
226
+ }
227
+ .drag {
228
+ background: #eee;
229
+ border: 3px #ddd dashed !important;
230
+ }
231
+ .chosen {
232
+ }
233
+
234
+ .flip-list-move {
235
+ transition: transform 0.5s;
236
+ }
237
+
238
+ .no-move {
239
+ transition: transform 0s;
240
+ }
241
+
242
+ .ct-upload-display-none .el-upload--picture-card {
243
+ display: none;
244
+ }
245
+
246
+ .el-upload-list__item .is-ready {
247
+ width: 100px;
248
+ height: 100px;
249
+ }
250
+
251
+ .ct-photoSelect .cover-list-item {
252
+ position: sticky;
253
+ }
254
+
255
+ .ct-photoSelect .cover-list-item-span {
256
+ position: inherit;
257
+ bottom: 0px;
258
+ left: 0px;
259
+ display: block;
260
+ background-color: #544f48;
261
+ opacity: 0.8;
262
+ }
263
+
264
+ .ct-photoSelect .cover-list-item-span-delete {
265
+ position: inherit;
266
+ bottom: 160px;
267
+ left: 130px;
268
+ color: #000000;
269
+ text-align: center;
270
+ }
271
+
272
+ .cover-list-item-span-delete i {
273
+ cursor: pointer;
274
+ vertical-align: sub;
275
+ margin-right: 4px;
276
+ }
277
+
278
+ .ct-photoSelect .el-dropdown-link {
279
+ cursor: pointer;
280
+ color: #fff;
281
+ }
282
+
283
+ .ct-photoSelect .el-icon-arrow-down {
284
+ font-size: 12px;
285
+ }
286
+
287
+ .el-collapse-item__content {
288
+ padding-bottom: 18px;
289
+ }
290
+
291
+ .el-upload--picture-card {
292
+ width: 100px;
293
+ height: 100px;
294
+ line-height: initial;
295
+ padding: 34px;
296
+ }
297
+
298
+ .el-upload--picture-card i {
299
+ font-size: 30px;
300
+ }
301
+
302
+ .el-upload-list--picture-card .el-upload-list__item {
303
+ width: 100px;
304
+ height: 100px;
305
+ }
306
+ .card {
307
+ display: inline-block;
308
+ }
237
309
  </style>