formui-vue2-vistastory 0.3.0 → 0.5.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/FormUiForm.vue CHANGED
@@ -42,7 +42,7 @@
42
42
  <!--{{fieldItem.name}}_{{ruleForm[fieldItem.name]}}-->
43
43
  <!--v-bind:multiple="'DEFAULT'==fieldItem.valueType?true:false"-->
44
44
  <component v-bind:is="'formUiStyleSelect'"
45
- ref="formUiStyleSelect"
45
+ :ref="'formUiFieldRef_'+fieldItem.name"
46
46
  v-bind:inputType="fieldItem.valueType=='CHECKBOX'?'checkbox':'select'"
47
47
  v-bind:defaultLabel="'请选择'"
48
48
  v-bind:disabled="fieldItem.disabled"
@@ -57,7 +57,7 @@
57
57
  <span v-else-if="fieldItem.foreignServiceClass!='FormUiForeignService'">
58
58
 
59
59
  <component v-bind:is="'formUiForeignSelect'"
60
- :ref="'formUiForeignSelect'+fieldItem.name"
60
+ :ref="'formUiFieldRef_'+fieldItem.name"
61
61
  v-bind:multiple="'DEFAULT'==fieldItem.valueType?true:false"
62
62
  v-bind:defaultLabel="'无'"
63
63
  v-bind:disabled="fieldItem.disabled"
@@ -240,6 +240,14 @@
240
240
 
241
241
  </el-form>
242
242
  </div>
243
+ <!-- <FormUiFormValidate :ref="'fromValidate_'+props.beanName" @setFieldValue="setFieldValue" @submitFormFocus="submitForm(ruleFormRef)"></FormUiFormValidate>-->
244
+ <component
245
+ v-bind:is="'FormUiFormValidate'"
246
+ :ref="'fromValidate_'+beanName"
247
+ :formuiFields="formuiFields"
248
+ @submitFormFocus="submitForm('ruleForm')"
249
+ @setFieldValue="setFieldValue">
250
+ </component>
243
251
  </div>
244
252
  </template>
245
253
 
@@ -251,6 +259,7 @@
251
259
  import formUiForeignSelect from './widget/FormUiForeignSelect.vue'
252
260
  import FormUiFileUpload from './widget/FormUiFileUpload.vue'
253
261
  import FormUiRichText from './widget/FormUiRichText.vue'
262
+ import FormUiFormValidate from './FormUiFormValidate.vue'
254
263
  import moment from 'moment'
255
264
 
256
265
  // 组件导入
@@ -260,7 +269,7 @@
260
269
  export default {
261
270
  name: 'FormUiForm',
262
271
  props: ['beanName','removeFileds','ruleFormSrc','btnTitle','labelWidth'],
263
- components:{FormUiFileUpload,formUiStyleSelect,formUiForeignSelect,FormUiRichText},
272
+ components:{FormUiFileUpload,formUiStyleSelect,formUiForeignSelect,FormUiRichText,FormUiFormValidate},
264
273
  data () {
265
274
  return {
266
275
  labelWidthCurrent:'auto',
@@ -367,8 +376,8 @@ export default {
367
376
  // alert(1)
368
377
  that.formuiFields[i].joinItems[j].value=value
369
378
  // console.log('formUiForeignSelect'+that.formuiFields[i].name+'<<<<')
370
- if(that.$refs['formUiForeignSelect'+that.formuiFields[i].name]){
371
- that.$refs['formUiForeignSelect'+that.formuiFields[i].name][0].updateJsonList(that.formuiFields[i].joinItems)
379
+ if(that.$refs['formUiFieldRef_'+that.formuiFields[i].name]){
380
+ that.$refs['formUiFieldRef_'+that.formuiFields[i].name][0].updateJsonList(that.formuiFields[i].joinItems)
372
381
 
373
382
  }
374
383
 
@@ -383,9 +392,18 @@ export default {
383
392
 
384
393
  }
385
394
 
386
-
387
395
  this.loadSuccess=true
388
396
 
397
+ // let ctx2=getCurrentInstance()
398
+ // console.log('->',ctx,ctx2)
399
+ let refKey='formUiFieldRef_'+key;
400
+
401
+ if(that.$refs[refKey]){
402
+ that.$refs[refKey][0].setFieldValue(key,value)
403
+ // ctx.refs[refKey].method.setFieldValue(key,value)
404
+ }
405
+
406
+ // console.log('setValue_flag3')
389
407
  //手动验证
390
408
  // let kv={}
391
409
  // kv['publish']=value
@@ -473,6 +491,10 @@ export default {
473
491
  }
474
492
  this.inputVisible = false;
475
493
  this.inputValue = '';
494
+ },
495
+ validateRes (res,formObj) {
496
+ console.log('validateRes:')
497
+ return this.$refs['fromValidate_'+this.beanName].showValidateDialog(res,formObj)
476
498
  }
477
499
  },
478
500
 
@@ -0,0 +1,108 @@
1
+ <template>
2
+ <div class="form-ui-form-validate">
3
+ <el-dialog :visible.sync="state.dialogVilidate" v-if="state.validateRes">
4
+ 表单验证错误
5
+ <hr />
6
+ <div v-for="item in state.validateRes.validateItemList" :key="item.fieldName">
7
+ <table style="width:100%">
8
+ <tbody>
9
+ <tr>
10
+ <td>字段</td>
11
+ <td>填入值</td>
12
+ <td>消息</td>
13
+ <td>等级</td>
14
+ </tr>
15
+ <tr>
16
+ <td>
17
+ <span v-for="fieldItem in formuiFields" v-if="fieldItem.name==item.fieldName ">
18
+ {{fieldItem.title}}({{fieldItem.name}})
19
+ </span>
20
+ </td>
21
+ <td>{{ state.formObj[item.fieldName] }}</td>
22
+ <td>{{ item.message }}</td>
23
+ <td>
24
+ <span v-if="item.validateStatus === 'warn'" style="color: orange">警告</span>
25
+ <span v-if="item.validateStatus === 'error'" style="color: red">错误</span>
26
+ </td>
27
+ </tr>
28
+ </tbody>
29
+ </table>
30
+ </div>
31
+ <hr />
32
+ <div style="padding: 10px 0;">
33
+ 等级说明:<span style="color: orange">警告</span>为建议修改,<span style="color: red">错误</span>为必须修改
34
+ </div>
35
+
36
+ <br/>
37
+ <el-button @click="state.dialogVilidate = false"
38
+ v-if="state.validateRes.validateStatus !== 'pass'">
39
+ 返回修改
40
+ </el-button>
41
+ <el-button @click="submitFormObjFocus" type="warning"
42
+ v-if="state.validateRes.validateStatus === 'warn'">
43
+ 强行提交
44
+ </el-button>
45
+ </el-dialog>
46
+
47
+ </div>
48
+ </template>
49
+
50
+ <script>
51
+ import FormUiForm from './FormUiForm.vue';
52
+ // import formuiService from './service/formui/FormuiService.js';
53
+ // import httpUtil from './service/base/httpUtil.js';
54
+
55
+ export default {
56
+ name: 'FormUiFormValidate',
57
+ props: {
58
+ simpleFormName: String,
59
+ id: [String, Number],
60
+ formData: Object,
61
+ formuiFields: Object
62
+ },
63
+ components: {
64
+ FormUiForm
65
+ },
66
+ data() {
67
+ return {
68
+ route: null, // 如果有实际使用再初始化
69
+ state: {
70
+ ruleForm: {},
71
+ simpleFormResp: {},
72
+ removeFields: '',
73
+ dialogVilidate: false,
74
+ validateRes: null,
75
+ formObj: {}
76
+ }
77
+ };
78
+ },
79
+ methods: {
80
+ showValidateDialog(res, formObj) {
81
+ if (!res || !res.validateStatus ||res.validateStatus === 'pass') {
82
+ return true;
83
+ }
84
+ this.state.validateRes = res;
85
+ this.state.dialogVilidate = true;
86
+ this.state.formObj = formObj;
87
+ console.log('show---dialog')
88
+ },
89
+ submitFormObjFocus() {
90
+ this.$emit('setFieldValue', 'formuiValidationForcePass', 1);
91
+ this.$emit('submitFormFocus');
92
+ setTimeout(() => {
93
+ this.$emit('setFieldValue', 'formuiValidationForcePass', '');
94
+ }, 0);
95
+ this.state.dialogVilidate = false;
96
+ }
97
+ },
98
+ mounted() {
99
+ // 可以在这里调用 useRoute()
100
+ // 或者通过注入方式获取路由对象(需全局引入 vue-router 并注册)
101
+ // 示例:this.route = this.$route
102
+ }
103
+ };
104
+ </script>
105
+
106
+ <style scoped>
107
+ /* 保留原有样式 */
108
+ </style>
@@ -4,7 +4,7 @@
4
4
 
5
5
  <component v-if="loadSuccess"
6
6
  v-bind:is="'FormUiForm'"
7
- ref="FormUiForm"
7
+ ref="FormUiFormRef"
8
8
  v-bind:removeFileds="removeFields"
9
9
  v-bind:ruleFormSrc="ruleForm"
10
10
  v-bind:beanName="simpleFormResp.beanName"
@@ -45,6 +45,9 @@ export default {
45
45
 
46
46
  if(that.simpleFormResp.method=='POST'){
47
47
  httpUtil.httpPost(that,that.simpleFormResp.url, formObj,function (res) {
48
+ if(!that.$refs['FormUiFormRef'].validateRes(res,formObj)){
49
+ return
50
+ }
48
51
  that.$emit('submitCallback', res)
49
52
  // callback(res)
50
53
  },function (err) {
@@ -57,6 +60,9 @@ export default {
57
60
  alert('暂不支持get');
58
61
  }else if(that.simpleFormResp.method=='PUT'){
59
62
  httpUtil.httpPut(that,that.simpleFormResp.url, formObj,function (res) {
63
+ if(!that.$refs['FormUiFormRef'].validateRes(res,formObj)){
64
+ return
65
+ }
60
66
  that.$emit('submitCallback', res)
61
67
  },function (err) {
62
68
  console.log('err get' + err)
@@ -65,6 +71,9 @@ export default {
65
71
  }
66
72
  })
67
73
  }else if(that.simpleFormResp.method=='DELETE'){
74
+ if(!that.$refs['FormUiFormRef'].validateRes(res,formObj)){
75
+ return
76
+ }
68
77
  alert('暂不支持delete');
69
78
  }
70
79
 
@@ -113,6 +113,13 @@ export default {
113
113
  this.tableConfig = resp
114
114
  }, (err) => {})
115
115
  },
116
+ loadTableData(queryParamsUpdate) {
117
+ if (queryParamsUpdate) {
118
+ this.queryParams = queryParamsUpdate
119
+ }
120
+ this.$refs['formUiTableRef'].loadData(this.queryParams)
121
+
122
+ },
116
123
  filterClear() {
117
124
  for (let i = 0; i < this.formuiTableRowList.length; i++) {
118
125
  if (typeof this.formuiTableRowList[i]['isShow'] === 'undefined') {
@@ -67,6 +67,9 @@ export default {
67
67
  formObj.fuTableName = this.tableName
68
68
  if (this.simpleFormResp.method === 'POST') {
69
69
  httpUtil.httpPost(that, '/formui/table/process_simple_table_form', formObj, (res) => {
70
+ if(!that.$refs['FormUiFormRef'].validateRes(res,formObj)){
71
+ return
72
+ }
70
73
  if (res.status.code !== 1) {
71
74
  alert(res.status.msg) // 修改: ElMessage 改为 alert
72
75
  } else {
@@ -82,6 +85,9 @@ export default {
82
85
  console.log('暂不支持get')
83
86
  } else if (this.simpleFormResp.method === 'PUT') {
84
87
  httpUtil.httpPut(that, '/formui/table/process_simple_table_form', formObj, (res) => {
88
+ if(!that.$refs['FormUiFormRef'].validateRes(res,formObj)){
89
+ return
90
+ }
85
91
  if (res.status.code !== 1) {
86
92
  alert(res.status.msg) // 修改: ElMessage 改为 alert
87
93
  } else {
@@ -95,6 +101,9 @@ export default {
95
101
  })
96
102
  } else if (this.simpleFormResp.method === 'DELETE') {
97
103
  httpUtil.httpDelete(that, '/formui/table/process_simple_table_form', formObj, (res) => {
104
+ if(!that.$refs['FormUiFormRef'].validateRes(res,formObj)){
105
+ return
106
+ }
98
107
  that.$emit('submitCallback', res)
99
108
  that.$emit('closeDialog')
100
109
  alert('删除完成.') // 修改: ElMessage 改为 alert
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "formui-vue2-vistastory",
3
- "version": "0.3.0",
3
+ "version": "0.5.0",
4
4
  "description": "formui-vue2-vistastory",
5
5
  "author": "vistastory <vistastory@126.com>",
6
6
  "private": false,
@@ -11,7 +11,7 @@
11
11
  "dependencies": {
12
12
  "tinymce-plugin-formatpainter":"^1.0.1",
13
13
  "axios": "^0.18.1",
14
- "element-ui": "^2.15.10",
14
+ "element-ui": "^2.15.14",
15
15
  "js-md5": "^0.7.3",
16
16
  "moment": "^2.24.0",
17
17
  "qs": "^6.6.0",
@@ -193,7 +193,7 @@
193
193
  ossService.ostObjectPolicy(this,{
194
194
  // 'dir': window.UEDITOR_CONFIG.OSSDIR,
195
195
  'dir': this.dir,
196
- 'srcname': param.file.name
196
+ 'srcname': encodeURIComponent(param.file.name)
197
197
  },function (resp) {
198
198
  var sign = resp;
199
199
  var form = new FormData();
@@ -46,7 +46,11 @@
46
46
  methods: {
47
47
  changeSelect:function () {
48
48
  // alert(22)
49
+ // console.log('change-select',this.fieldName+'->'+this.fieldValueSrc.toString())
50
+ // setTimeout( ()=>{
49
51
  this.$emit('setFieldValue', this.fieldName, this.fieldValueSrc.toString())
52
+ // },1000)
53
+
50
54
  },
51
55
  updateJsonList:function(jsonList){
52
56
  this.jsonList=jsonList
@@ -79,8 +83,23 @@
79
83
  // that.selectItems=resp.selectItems
80
84
  // })
81
85
  // this.isMainStore=field
86
+ },setFieldValue:function(key,value){
87
+ // console.log('select_setvalue',key,value)
88
+ if(value.indexOf(',')){
89
+ this.fieldValueSrc=[]
90
+
91
+ let valArr=value.split(',')
92
+ for(var i=0;i<valArr.length;i++){
93
+ this.fieldValueSrc.push(parseInt(valArr[i]))
94
+ }
95
+ }else{
96
+ this.fieldValueSrc=parseInt(value)
82
97
  }
83
98
 
99
+
100
+ // loadData()
101
+ }
102
+
84
103
  },
85
104
 
86
105
  data () {
@@ -101,6 +120,7 @@
101
120
  let that = this
102
121
  // alert(that.beanName)
103
122
 
123
+ // console.log('this.fieldValue',this.fieldValue)
104
124
  if(Array.isArray(this.fieldValue)) {
105
125
  this.fieldValueSrc = (this.fieldValue)
106
126
  }else if((this.fieldValue&&Number.isInteger(this.fieldValue)==false&&this.fieldValue.indexOf(',')!=-1)||this.fieldItem.valueType=='CHECKBOX'){
@@ -44,7 +44,11 @@
44
44
 
45
45
  })
46
46
 
47
- }
47
+ },setFieldValue:function(key,value){
48
+
49
+ this.fieldValueSrc=(value)
50
+ // loadData()
51
+ }
48
52
 
49
53
  },
50
54
 
@@ -75,7 +75,7 @@
75
75
  ossService.ostObjectPolicy(that,{
76
76
  // 'dir': window.UEDITOR_CONFIG.OSSDIR,
77
77
  'dir': 'formui',
78
- 'srcname': blobInfo.filename()
78
+ 'srcname': encodeURIComponent(blobInfo.filename())
79
79
  },function (resp) {
80
80
  // alert(22)
81
81
  var sign = resp;
@@ -113,6 +113,11 @@
113
113
  // }
114
114
 
115
115
  },
116
+ setFieldValue:function(key,value){
117
+
118
+ this.fieldValueSrc=parseInt(value)
119
+ // loadData()
120
+ }
116
121
 
117
122
  },
118
123