centaline-data-driven-v3 0.0.97 → 0.0.99

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/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "centaline-data-driven-v3",
3
- "version": "0.0.97",
3
+ "version": "0.0.99",
4
4
  "private": false,
5
5
  "description": "centaline-data-driven-v3",
6
6
  "main": "dist/centaline-data-driven-v3.umd.js",
@@ -38,6 +38,21 @@
38
38
  <div>{{ model.controlLabel }}</div>
39
39
  <div class="subText">{{ model.subText }}</div>
40
40
  </el-button>
41
+ <!-- <ct-selectfile v-else-if="model.isOpenFileDialog" :form="model" :vmodel="model"></ct-selectfile> -->
42
+ <template v-else-if="model.isOpenFileDialog" :form="model" :vmodel="model">
43
+ <input type="file" multiple ref="fileInput" @change="handleFileChange" style="display: none"
44
+ :accept="model.fileAccept" />
45
+ <el-button type="primary" @click="triggerUpload" v-bind="model.attrs"
46
+ :style="{ color: model.textColor, backgroundColor: model.imgUrl ? 'transparent' : model.bgColor, borderColor: model.imgUrl ? 'transparent' : model.borderColor, padding: model.imgUrl ? '0px' : null }"
47
+ :disabled="model.disabled || model.locked" class="btn-add">
48
+ <template #icon v-if="model.icon">
49
+ <el-icon>
50
+ <component :is="model.icon"></component>
51
+ </el-icon>
52
+ </template>
53
+ {{ model.controlLabel }}</el-button>
54
+ </template>
55
+
41
56
  <el-button v-else type="primary" :loading="model.loading" v-bind="model.attrs" @click="clickHandle"
42
57
  :style="{ color: model.textColor, backgroundColor: model.imgUrl ? 'transparent' : model.bgColor, borderColor: model.imgUrl ? 'transparent' : model.borderColor, padding: model.imgUrl ? '0px' : null }"
43
58
  :disabled="model.disabled || model.locked">
@@ -55,13 +70,13 @@
55
70
  </el-button>
56
71
  </template>
57
72
  <script setup lang="ts">
58
- import { computed } from 'vue'
73
+ import { computed, ref } from 'vue'
59
74
  import { initData } from '../../utils/mixins';
60
75
  import Button from '../../loader/src/Button';
61
76
  import Enum from '../../utils/Enum'
62
77
  import common from '../../utils/common'
63
78
  import request from '../../utils/request'
64
- import { ElMessage } from 'element-plus'
79
+ import { ElMessage, UploadFile } from 'element-plus'
65
80
  const emit = defineEmits(['input', 'fieldClick', 'importComplete'])
66
81
  const props = defineProps({
67
82
  parameterAction: String,
@@ -71,6 +86,16 @@ const props = defineProps({
71
86
  flagAppMode: Boolean,
72
87
  parentModel: Object,
73
88
  })
89
+
90
+ interface FileItem {
91
+ name: string;
92
+ raw: File;
93
+ }
94
+
95
+ const fileInput = ref(null); // 获取 input 元素的引用
96
+ const fileList = ref<FileItem[]>([]);
97
+
98
+
74
99
  const model = initData(props, Button)
75
100
  if (model.value.controlType == Enum.ControlType.ButtonAdvancedSearch) {
76
101
  model.value.icon = 'ico-open';
@@ -96,35 +121,35 @@ const headers = computed(() => {
96
121
  return common.getDataDrivenOpts().handler.getRequestHeaders();
97
122
  })
98
123
  function clickHandle() {
99
- emit('fieldClick', model.value);
124
+ emit('fieldClick', model.value);
100
125
  }
101
126
 
102
127
  function handleAvatarBeforeUpload(file) {
103
- if (model.value.form && model.value.form.$vue) {
104
- let submitData = model.value.form.$vue.getFileData(model.value);
105
- for (var key in submitData) {
106
- if (typeof submitData[key] === "object") {
107
- uploadData.value[key] = JSON.stringify(submitData[key]);
108
- }
109
- else {
110
- uploadData.value[key] = submitData[key];
111
- }
128
+ if (model.value.form && model.value.form.$vue) {
129
+ let submitData = model.value.form.$vue.getFileData(model.value);
130
+ for (var key in submitData) {
131
+ if (typeof submitData[key] === "object") {
132
+ uploadData.value[key] = JSON.stringify(submitData[key]);
133
+ }
134
+ else {
135
+ uploadData.value[key] = submitData[key];
136
+ }
137
+ }
112
138
  }
113
- }
114
- if(props.parentModel && props.parentModel.is && props.parentModel.is=="ct-formlist" && props.parentModel.form && props.parentModel.form.$vue){
115
- let submitData = props.parentModel.form.$vue.getFileData(model.value);
116
- for (var key in submitData) {
117
- if (typeof submitData[key] === "object") {
118
- uploadData.value[key] = JSON.stringify(submitData[key]);
119
- }
120
- else {
121
- uploadData.value[key] = submitData[key];
122
- }
139
+ if (props.parentModel && props.parentModel.is && props.parentModel.is == "ct-formlist" && props.parentModel.form && props.parentModel.form.$vue) {
140
+ let submitData = props.parentModel.form.$vue.getFileData(model.value);
141
+ for (var key in submitData) {
142
+ if (typeof submitData[key] === "object") {
143
+ uploadData.value[key] = JSON.stringify(submitData[key]);
144
+ }
145
+ else {
146
+ uploadData.value[key] = submitData[key];
147
+ }
148
+ }
123
149
  }
124
- }
125
150
  }
126
151
  function handleAvatarSuccess(res) {
127
- emit('importComplete', res, model.value);
152
+ emit('importComplete', res, model.value);
128
153
  }
129
154
  function handleAvatarError(info) {
130
155
  ElMessage({
@@ -141,8 +166,41 @@ function dropClick() {
141
166
  }
142
167
  }
143
168
  function commandClick(code) {
144
- model.value.selectOptionCode = code;
145
- emit('fieldClick', model.value);
169
+ model.value.selectOptionCode = code;
170
+ emit('fieldClick', model.value);
171
+ }
172
+
173
+ // 触发文件选择
174
+ const triggerUpload = () => {
175
+ fileInput.value.click();
176
+ };
177
+
178
+ // 处理文件选择
179
+ const handleFileChange = (event) => {
180
+ const input = event.target as HTMLInputElement;
181
+
182
+ // 安全检查
183
+ if (!input?.files?.length) {
184
+ console.warn('未选择文件');
185
+ return;
186
+ }
187
+
188
+ // 更新文件列表
189
+ fileList.value = Array.from(input.files).map(file => ({
190
+ name: file.name,
191
+ raw: file
192
+ }));
193
+
194
+ model.value.fileList = fileList.value;
195
+ emit('fieldClick', model.value);
196
+ event.target.value = '';
197
+
198
+ };
199
+
200
+ function generateUUID() {
201
+ return ([1e7] + -1e3 + -4e3 + -8e3 + -1e11).replace(/[018]/g, c =>
202
+ (c ^ crypto.getRandomValues(new Uint8Array(1))[0] & 15 >> c / 4).toString(16)
203
+ );
146
204
  }
147
205
  </script>
148
206
  <style scoped>
@@ -157,13 +157,13 @@
157
157
 
158
158
  </div>
159
159
  <template v-if="model?.aiAttr?.showAI">
160
- <div :style="{ flex: ' 0 0 ' + model.aiAttr.width + 'px', position: 'sticky', top: '0' ,'box-shadow': '-10px 0 5px -9px rgba(0, 0, 0, 0.3)' }"
160
+ <div :style="{ flex: ' 0 0 ' + model.aiAttr.width + 'px', position: 'sticky', top: '0', 'box-shadow': '-10px 0 5px -9px rgba(0, 0, 0, 0.3)' }"
161
161
  v-show="showAI">
162
162
  <div
163
163
  :style="{ position: 'sticky', top: '0', height: dialogHeight + 'px', overflow: 'hidden', 'border-bottom-right-radius': '4px' }">
164
164
  <AIChat :height="dialogHeight"
165
- :style="{ position: 'sticky', top: '0', height: dialogHeight + 'px' }"
166
- :field="model.aiChat" :router="model.aiRouter" :actionRouter="model.actionRouters" :form="model"
165
+ :style="{ position: 'sticky', top: '0', height: dialogHeight + 'px' }" :field="model.aiChat"
166
+ :router="model.aiRouter" :actionRouter="model.actionRouters" :form="model"
167
167
  @hideAI="AIToggle" :isVisible="showAI" :tablewidth="model.aiAttr.width">
168
168
 
169
169
  </AIChat>
@@ -174,8 +174,8 @@
174
174
  </div>
175
175
  <template v-if="model?.aiAttr?.showAI && !showAI">
176
176
  <div class="btn-avatar" @click.stop="AIToggle">
177
- <img class="avatar-img" @click.stop="AIToggle" :src="util.getAssetsImage('AIChat.png')" :alt="model?.aiRouter.controlLabel"
178
- :title="model?.aiRouter.controlLabel">
177
+ <img class="avatar-img" @click.stop="AIToggle" :src="util.getAssetsImage('AIChat.png')"
178
+ :alt="model?.aiRouter.controlLabel" :title="model?.aiRouter.controlLabel">
179
179
  </div>
180
180
  </template>
181
181
  <div style="min-height:200px" v-if="loading"></div>
@@ -193,6 +193,7 @@ import { useRouter } from 'vue-router';
193
193
  import util from '../../utils/pub-use'
194
194
  import Enum from '../../utils/Enum';
195
195
  import AIChat from '../web/AIChat.vue';
196
+ import { fi } from 'element-plus/es/locale';
196
197
  const emit = defineEmits(['loaded', 'failLoad', 'submit', 'AIToggle'])
197
198
  const props = defineProps({
198
199
  api: String,
@@ -259,25 +260,25 @@ const showAI = ref(false);
259
260
  const dialogHeight = ref(props.dialogHeight || (window.innerHeight - 60));
260
261
 
261
262
  const qrtimer1 = ref(null)
262
- const qrtimer2=ref(null)
263
- onBeforeUnmount(()=>{
264
- if (model.value && typeof model.value.scripts !== 'undefined') {
265
- model.value.scripts.formData.form = null;
266
- model.value.scripts.formData.excuteData = null;
267
- model.value.scripts.formData.fieldsDic = null;
268
- model.value.scripts.formData = null;
269
- }
270
- Fields.value = null;
271
- refForm.value = null;
272
- model.value = null;
273
- if (qrtimer1.value) {
274
- clearTimeout(qrtimer1.value);
275
- qrtimer1.value = null;
276
- }
277
- if (qrtimer2.value) {
278
- clearTimeout(qrtimer2.value);
279
- qrtimer2.value = null;
280
- }
263
+ const qrtimer2 = ref(null)
264
+ onBeforeUnmount(() => {
265
+ if (model.value && typeof model.value.scripts !== 'undefined') {
266
+ model.value.scripts.formData.form = null;
267
+ model.value.scripts.formData.excuteData = null;
268
+ model.value.scripts.formData.fieldsDic = null;
269
+ model.value.scripts.formData = null;
270
+ }
271
+ Fields.value = null;
272
+ refForm.value = null;
273
+ model.value = null;
274
+ if (qrtimer1.value) {
275
+ clearTimeout(qrtimer1.value);
276
+ qrtimer1.value = null;
277
+ }
278
+ if (qrtimer2.value) {
279
+ clearTimeout(qrtimer2.value);
280
+ qrtimer2.value = null;
281
+ }
281
282
  })
282
283
 
283
284
  onUpdated(() => {
@@ -351,7 +352,7 @@ function doAction(data) {
351
352
  //判断是否有滚动条
352
353
  function getisScroll() {
353
354
  if (Fields.value) {
354
- if(qrtimer1.value)clearTimeout(qrtimer1.value);
355
+ if (qrtimer1.value) clearTimeout(qrtimer1.value);
355
356
  if (refForm.value) {
356
357
  let parentDom = refForm.value.parentElement;
357
358
  if (parentDom.id == "app-form" && parentDom.scrollHeight > window.innerHeight) {
@@ -374,9 +375,15 @@ function fieldClickHandler(field) {
374
375
  let data = Form.getRouterAndSubmitData(field, model.value);
375
376
  clickHandler(data.router, data.submitData);
376
377
  }
377
- function clickHandler(field, submitData) {
378
- RouterClickHandler(field, submitData, null, model.value, 'form')
378
+ function clickHandler(field, submitData,formList) {
379
+ if (field.isOpenFileDialog) {
380
+ common.excuteFunStr.call(model.value.scripts, field.onChanged, {files: field.fileList,columns: formList?.source?.rows[0].columns });
381
+ }
382
+ else {
383
+ RouterClickHandler(field, submitData, null, model.value, 'form');
384
+ }
379
385
  }
386
+
380
387
  //组件数据验证
381
388
  function validExcute() {
382
389
  var rtnBool = true;
@@ -667,7 +674,7 @@ function buttonsWidth() {
667
674
  }
668
675
  return rtn;
669
676
  }
670
-
677
+
671
678
  </script>
672
679
 
673
680
  <style scoped>
@@ -2,6 +2,11 @@
2
2
  <div v-if="model">
3
3
  <template v-if="model.flagTemplate">
4
4
  <div class="list-button">
5
+ <template v-for="(v, i) in model.toolButtonsShow">
6
+ <component :is="v.is" :vmodel="v" :parentModel="model" @fieldClick="toolButtonsClick"
7
+ @importComplete="importComplete" @change="toolButtonsChangeHandler(v, $event)">
8
+ </component>
9
+ </template>
5
10
  <component v-if="model.selectRouter !== null" :is="model.selectRouter.is" :vmodel="model.selectRouter"
6
11
  @click="popupSearchListHandle(model.selectRouter)"></component>
7
12
  <el-button v-if="model.create" :disabled="model.disabled" class="btn-add" type="success"
@@ -439,7 +444,7 @@ function fieldsValidExcute() {
439
444
  if (model.value.form && model.value.form.fields) {
440
445
  const currentIndex = model.value.form.fields.findIndex(v => v.fieldName1 === model.value.fieldName1);
441
446
  if (currentIndex - 1 >= 0) {
442
- if (model.value.form.fields[currentIndex - 1].controlType == Enum.ControlType.Group){
447
+ if (model.value.form.fields[currentIndex - 1].controlType == Enum.ControlType.Group) {
443
448
  controlLabel = model.value.form.fields[currentIndex - 1].controlLabel;
444
449
  }
445
450
  }
@@ -531,7 +536,13 @@ function rolRouterClickHandler(field, rowData, rowindex) {
531
536
  buttonClick(rowData, field);
532
537
  }
533
538
  function toolButtonsClick(field) {
534
- emit('tableButtonClick', field, null);
539
+ if (field.isOpenFileDialog) {
540
+ emit('tableButtonClick', field, null,model.value);
541
+ } else {
542
+ emit('tableButtonClick', field, null);
543
+
544
+
545
+ }
535
546
  }
536
547
  function toolButtonsChangeHandler(field) {
537
548
  emit('change', field);
@@ -13,13 +13,12 @@
13
13
  <div style="width: 100%;position: relative" ref="refct_Photo" class="block ct-file"
14
14
  :style="{ 'width': (model.maxValue1 || 100) + 'px', 'height': (model.minValue1 || 100) + 'px' }"
15
15
  :class="[model.attrs.size ? 'ct-checkbox-' + model.attrs.size : '']">
16
-
17
16
  <el-upload :class="model.disableUpload ? 'ct-upload-display-none' : ''" v-bind="UploadhttpRequest"
18
- :uploadStatus="!model.disableUpload && !model.locked ? 'upload' : 'lock'" ref="refupload" :disabled="model.locked"
19
- :accept="model.fileAccept1" :on-change="handleChange" :multiple="false" :auto-upload="true"
20
- :action="action()" :headers="headers" :before-upload="beforeUploadProcess" :on-success="handleAvatarSuccess"
21
- :on-error="handleAvatarError" :on-progress="uploadProcess" :on-exceed="handleExceed"
22
- :show-file-list="false">
17
+ :uploadStatus="!model.disableUpload && !model.locked ? 'upload' : 'lock'" ref="refupload"
18
+ :disabled="model.locked" :accept="model.fileAccept1" :on-change="handleChange" :multiple="false"
19
+ :auto-upload="true" :action="action()" :headers="headers" :before-upload="beforeUploadProcess"
20
+ :on-success="handleAvatarSuccess" :on-error="handleAvatarError" :on-progress="uploadProcess"
21
+ :on-exceed="handleExceed" :show-file-list="false">
23
22
 
24
23
 
25
24
  <el-icon class="avatar-uploader-icon"
@@ -126,7 +125,7 @@
126
125
  </template>
127
126
  </template>
128
127
  <script setup lang="ts">
129
- import { ref, nextTick, computed, onBeforeUnmount } from 'vue'
128
+ import { ref, nextTick, computed, onBeforeUnmount, watch } from 'vue'
130
129
  import { ElMessage, UploadProps } from 'element-plus'
131
130
  import common from '../../utils/common'
132
131
  import { changeHandler } from '../../utils/mixins';
@@ -146,15 +145,12 @@ const refupload = ref()
146
145
  const QRCodeRef = ref()
147
146
  const UploadhttpRequest = ref({})
148
147
  const model = ref(null)
149
- const qrtimer1=ref(null)
150
- const qrtimer2=ref(null)
148
+ const qrtimer1 = ref(null)
149
+ const qrtimer2 = ref(null)
151
150
 
152
151
  const headers = computed(() => {
153
152
  return common.getDataDrivenOpts().handler.getRequestHeaders();
154
153
  })
155
- const previewZIndex = computed(() => {
156
- return common.getDataDrivenOpts().zindex + 100;
157
- })
158
154
 
159
155
  init()
160
156
  //初始化数据
@@ -204,6 +200,23 @@ function load(data) {
204
200
  });
205
201
  }
206
202
  }
203
+
204
+ // 深度监听 model
205
+ watch(
206
+ () => model.value, // 监听的源
207
+ (newValue, oldValue) => {
208
+ console.log('Model changed:', newValue);
209
+ console.log('Old value:', oldValue);
210
+ if (newValue?.file && newValue?.file != oldValue?.file) {
211
+ // 处理文件上传
212
+ var options = {
213
+ file: newValue.file.raw
214
+ }
215
+ SliceUpload(options);
216
+ }
217
+ },
218
+ { deep: true } // 启用深度监听
219
+ );
207
220
  //校验上传数量
208
221
  const handleExceed: UploadProps['onExceed'] = (files) => {
209
222
  // model.value.validMessage = "附件数量最多" + model.value.maxValue1 + "张";
@@ -217,8 +230,8 @@ const handleExceed: UploadProps['onExceed'] = (files) => {
217
230
  function handleRemove(file) {
218
231
 
219
232
 
220
- common.confirm(common.LocalizedString("确定删除该附件?","確定刪除該附件?"), "提示", {
221
- confirmButtonText: common.LocalizedString("确定","確認"),
233
+ common.confirm(common.LocalizedString("确定删除该附件?", "確定刪除該附件?"), "提示", {
234
+ confirmButtonText: common.LocalizedString("确定", "確認"),
222
235
  cancelButtonText: "取消",
223
236
  //type: 'warning'
224
237
  }).then(() => {
@@ -321,7 +334,6 @@ async function SliceUpload(options) {
321
334
  });
322
335
  }
323
336
  // data是上传时附带的额外参数,file是文件
324
-
325
337
  let uid = Photo.uploadguid();
326
338
  try {
327
339
  file.uid = file.uid || uid;
@@ -492,7 +504,7 @@ function PasteUpload(event) {
492
504
  ++fileSum;
493
505
  }
494
506
  }
495
-
507
+
496
508
  if (fileSum == items.length) {
497
509
  for (let index in items) {
498
510
  const item = items[index];
@@ -514,7 +526,7 @@ function PasteUpload(event) {
514
526
  function ListenerPaste(event) {
515
527
 
516
528
  const uploads = document.querySelectorAll('[uploadStatus="upload"]');
517
- if (uploads.length == 1) {
529
+ if (uploads.length == 1) {
518
530
  PasteUpload(event);
519
531
  }
520
532
 
@@ -17,6 +17,13 @@ const Button = function (source) {
17
17
  // return '#519DA6'
18
18
  // }
19
19
  return source.borderColor
20
+ },
21
+ //允许的文件类型(针对上传控件)
22
+ get fileAccept1() {
23
+ return source.fileAccept1 || '';
24
+ },
25
+ set fileAccept1(v) {
26
+ source.fileAccept1 = v;
20
27
  },
21
28
  get action() {
22
29
  if (source.controlType == Enum.ControlType.ButtonSearch) {
@@ -263,8 +263,9 @@ function loadFromModel(source, isFormList) {
263
263
  }
264
264
  },
265
265
  //设置表格某行某列的值
266
- setListFieldValue(value, tableName, rowNum, fiedlId, attrName, flagTemplate) {
267
- value = value == undefined ? "" : value.toString();
266
+ setListFieldValue(value, tableName, rowNum, fiedlId, attrName, flagTemplate, flagTostring) {
267
+ value = value == undefined ? "" : flagTostring == false ? value : value.toString();
268
+
268
269
  tableName = tableName ? tableName : this.form.scripts.$fd;
269
270
  let data = this.getListField(tableName, rowNum, fiedlId);
270
271
 
@@ -23,16 +23,16 @@ function loadFromModel(source, SourceList, router, optionApi, videoPlayIconUrl)
23
23
  QRCodeStatusAction: '',
24
24
  fileSource: SourceList,//原始数据
25
25
  valid: true,//验证是否通过
26
- validMessage: '',//验证提示
27
-
28
- get action() {
29
- return router && router.action ? router.action : "";//上传完整地址
30
- },
26
+ validMessage: '',//验证提示
27
+ uploadFiles:[],
31
28
  get QRCodeAction() {
32
29
  return router && router.actionForSearchRightPageKey ? router.actionForSearchRightPageKey : "";
33
30
  },
34
31
  get videoPlayIconUrl() {
35
32
  return videoPlayIconUrl;
33
+ },
34
+ get action() {
35
+ return router && router.action ? router.action : "";//上传完整地址
36
36
  },
37
37
  set action(v) {
38
38
  router.action = v;//上传完整地址
@@ -64,6 +64,18 @@ function loadFromModel(source, SourceList, router, optionApi, videoPlayIconUrl)
64
64
  }
65
65
  return rtn._fileList;
66
66
  },
67
+ get file() {
68
+ return this.uploadFiles;//上传完整地址
69
+ },
70
+ set file(v) {
71
+ if (this.uploadFiles?.length > 0) {
72
+ this.uploadFiles[0] = v;
73
+ }
74
+ else {
75
+ this.uploadFiles = [];
76
+ this.uploadFiles.push(v);
77
+ }
78
+ },
67
79
  jsClearFile(model) {
68
80
  model.fileList = [];
69
81
  },
@@ -91,6 +103,10 @@ function loadFromModel(source, SourceList, router, optionApi, videoPlayIconUrl)
91
103
  rtn.fileList[0] = FileData;
92
104
  });
93
105
  },
106
+ //外部增加上传文件
107
+ jsAddFile(data, model) {
108
+ model.file = data;
109
+ },
94
110
  getFormObj() {
95
111
  var rtnFormObj = {};
96
112
  var that = this;
@@ -342,7 +358,7 @@ function updateFile(file, model) {
342
358
  model.fileSource[0].mediaUrl = file.mediaUrl;
343
359
  model.fileSource[0].savedFileName = file.savedFileName;
344
360
  model.fileSource[0].mediaDate = file.mediaDate;
345
- model.fileSource[0].mediaCode = file.mediaCode;
361
+ model.fileSource[0].mediaCode = file.mediaCode;
346
362
 
347
363
  }
348
364
  function uploadguid() {
@@ -380,7 +396,7 @@ function viewerfile(file, model) {
380
396
  function selfValidExcute(eventName, model) {
381
397
  if (model.required) {
382
398
  if (Photo.getfileListLength(model) === 0) {
383
- model.validMessage = common.LocalizedString("必须上传附件","必須上傳附件");
399
+ model.validMessage = common.LocalizedString("必须上传附件", "必須上傳附件");
384
400
  model.valid = false;
385
401
  model.displayValidMessage = model.validMessage;
386
402
  return false;
@@ -14,7 +14,7 @@ const Router = function (source) {
14
14
  return source.text;
15
15
  },
16
16
  set controlLabel(v) {
17
- return source.text=v;
17
+ return source.text = v;
18
18
  },
19
19
  //动作对应的 控制器
20
20
  get action() {
@@ -23,6 +23,13 @@ const Router = function (source) {
23
23
  set action(v) {
24
24
  return source.action = v;
25
25
  },
26
+ //允许的文件类型(应用于 ButtonType 为 openFileDialog 的类型)
27
+ get fileAccept() {
28
+ return source.fileAccept || '';
29
+ },
30
+ set fileAccept(v) {
31
+ source.fileAccept = v;
32
+ },
26
33
  // action的url对应的FieldName,如果此处有值,则忽略action
27
34
  get actionField() {
28
35
  return source.actionField;
@@ -63,6 +70,10 @@ const Router = function (source) {
63
70
  get isCheckbox() {
64
71
  return source.buttonType === Enum.ButtonType.Checkbox;
65
72
  },
73
+ //按钮类型为openFileDialog
74
+ get isOpenFileDialog() {
75
+ return source.buttonType === Enum.ButtonType.openFileDialog;
76
+ },
66
77
 
67
78
  //是否需要警示标志
68
79
  get flagAlert() {
package/src/utils/Enum.js CHANGED
@@ -588,7 +588,11 @@ const Enum = {
588
588
  /// <summary>
589
589
  /// Checkbox
590
590
  /// </summary>
591
- Checkbox: 4
591
+ Checkbox: 4,
592
+ /// <summary>
593
+ /// file
594
+ /// </summary>
595
+ openFileDialog: 5,
592
596
  },
593
597
 
594
598
  /// <summary>
@@ -598,8 +598,9 @@ const common = {
598
598
  strCharLen(str) {
599
599
  var len = 0;
600
600
  if (str) {
601
- for (var i = 0; i < str.length; i++) {
602
- var c = str.charCodeAt(i);
601
+ let newstr = common.extractTagContent(str);
602
+ for (var i = 0; i < newstr.length; i++) {
603
+ var c = newstr.charCodeAt(i);
603
604
  //单字节加1
604
605
  if ((c >= 0x0001 && c <= 0x007e) || (0xff60 <= c && c <= 0xff9f)) {
605
606
  len++;
@@ -611,6 +612,22 @@ const common = {
611
612
 
612
613
  return len;
613
614
  },
615
+ /**
616
+ * @method
617
+ * @param {String} str 需要计算的字符串
618
+ * @desc 获取文字。
619
+ * @returns {obj} 返回值
620
+ */
621
+ extractTagContent(htmlContent) {
622
+
623
+ if (typeof htmlContent === 'string') {
624
+ const result = htmlContent.replace(/<[^>]*>/g, '').trim();
625
+ return result || htmlContent;
626
+ } else {
627
+ return htmlContent;
628
+ }
629
+
630
+ },
614
631
  /**
615
632
  * @method
616
633
  * @param {Object} obj 需要克隆的对象