centaline-data-driven-v3 0.1.10 → 0.1.12

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,20 +1,22 @@
1
1
  <template>
2
2
  <ct-field :vmodel="model">
3
3
  <template #Control>
4
- <div v-if="model.controlType === Enum.ControlType.MultiLineText" style="width: 100%;">
5
- <el-input :type="model.inputType" v-model="model.code1" v-bind="model.attrs" @input="input()" @change="change()"
6
- :disabled="model.locked" :rows="model.rows" :readonly="model.readonly"
7
- :show-password="model.inputType == 'password'" autocomplete="on" :maxlength="model.maxValue1"
8
- :show-word-limit="model.showWordLimit" clearable @keyup.enter.native="search()" class="fieldControl">
9
- <template #suffix>
10
- <span v-if="model.unitName1">{{ model.unitName1 }}</span>
11
- </template>
12
- </el-input>
13
- <span v-if="model.sufLabel1" class="sufLabel" v-html="model.sufLabel1"></span>
14
- </div>
15
- <el-input v-else :type="model.inputType" v-model="model.code1" v-bind="model.attrs" @input="input()" @change="change()"
16
- :disabled="model.locked" :rows="model.rows" :readonly="model.readonly"
17
- :show-password="model.inputType == 'password'" autocomplete="on" :maxlength="model.maxValue1"
4
+ <div v-if="model.controlType === Enum.ControlType.MultiLineText" style="width: 100%;">
5
+ <el-input :type="model.inputType" v-model="model.code1" v-bind="model.attrs" @input="input()"
6
+ @change="change()" :disabled="model.locked" :rows="model.rows" :readonly="model.readonly"
7
+ :show-password="model.inputType == 'password'" autocomplete="on" :maxlength="model.maxValue1"
8
+ :show-word-limit="model.showWordLimit" clearable @keyup.enter.native="search()"
9
+ class="fieldControl">
10
+ <template #suffix>
11
+ <span v-if="model.unitName1">{{ model.unitName1 }}</span>
12
+ </template>
13
+ </el-input>
14
+ <span v-if="model.sufLabel1" class="sufLabel" v-html="model.sufLabel1"></span>
15
+ </div>
16
+ <el-input v-else :type="model.inputType" v-model="model.code1" v-bind="model.attrs" @input="input()"
17
+ @change="change()" :disabled="model.locked" :rows="model.rows" :readonly="model.readonly"
18
+ :show-password="model.inputType == 'password'" autocomplete="on"
19
+ :maxlength="model.controlType !== Enum.ControlType.NumericTextBox ? model.maxValue1 : ''"
18
20
  :show-word-limit="model.showWordLimit" clearable @keyup.enter.native="search()" class="fieldControl">
19
21
  <template #suffix>
20
22
  <span v-if="model.unitName1">{{ model.unitName1 }}</span>
@@ -35,7 +37,7 @@
35
37
  import { initData, changeHandler } from '../../utils/mixins';
36
38
  import TextBox from '../../loader/src/TextBox';
37
39
  import Enum from '../../utils/Enum'
38
- const emit = defineEmits(['input', 'change', 'click','search','popupSearchList'])
40
+ const emit = defineEmits(['input', 'change', 'click', 'search', 'popupSearchList'])
39
41
  const props = defineProps({
40
42
  parameterAction: String,
41
43
  vmodel: Object,
@@ -46,25 +48,37 @@ const props = defineProps({
46
48
  },
47
49
  })
48
50
  const model = initData(props, TextBox)
51
+ model.value.selfValidExcute = () => {
52
+ model.value.valid = true;
53
+ if (model.value.controlType === Enum.ControlType.NumericTextBox) {
54
+ if (model.value.minValue1 && model.value.code1 < parseFloat(model.value.minValue1)) {
55
+ model.value.validMessage = "最小值为" + model.value.minValue1 + "";
56
+ model.value.valid = false;
57
+ return false;
58
+ }
59
+
60
+ }
61
+ return model.value.valid;
62
+ }
49
63
  function search() {
50
- if (model.value.autoSearch||props.from=='tree') {
64
+ if (model.value.autoSearch || props.from == 'tree') {
51
65
  emit('search');
52
66
  }
53
67
  }
54
68
  function input() {
55
- if(model.value.controlType===Enum.ControlType.MultiLineText || model.value.controlType===Enum.ControlType.TextBox){
56
- }
57
- else{
58
- change();
59
- }
60
- }
69
+ if (model.value.controlType === Enum.ControlType.MultiLineText || model.value.controlType === Enum.ControlType.TextBox) {
70
+ }
71
+ else {
72
+ change();
73
+ }
74
+ }
61
75
  function change() {
62
- changeHandler(model.value, emit);
63
- if (props.from == 'tree') { emit('search'); }
76
+ changeHandler(model.value, emit);
77
+ if (props.from == 'tree') { emit('search'); }
64
78
  }
65
79
  //弹出选择列表
66
80
  function popupSearchListHandle() {
67
- let isSingle=model.value.moreActionRouter.isSingle
81
+ let isSingle = model.value.moreActionRouter.isSingle
68
82
  emit('popupSearchList', isSingle, model, model.value.moreActionRouter);
69
83
  }
70
84
  defineExpose({
@@ -93,6 +93,20 @@ const Base = function (source, moreActionRouter) {
93
93
  set hiddenRelationFieldValue(v) {
94
94
  source.hiddenRelationFieldValue = v;
95
95
  },
96
+ //决定其显示相关的字段
97
+ get displayRelationField() {
98
+ return source.displayRelationField;
99
+ },
100
+ set displayRelationField(v) {
101
+ source.displayRelationField = v;
102
+ },
103
+ //决定其显示相关字段的值
104
+ get displayRelationFieldValue() {
105
+ return source.displayRelationFieldValue;
106
+ },
107
+ set displayRelationFieldValue(v) {
108
+ source.displayRelationFieldValue = v;
109
+ },
96
110
  //决定其必填相关的字段
97
111
  get requiredRelationField() {
98
112
  return source.requiredRelationField;
@@ -801,11 +815,21 @@ const Base = function (source, moreActionRouter) {
801
815
  if (typeof source.show !== "undefined") {
802
816
  return source.show;
803
817
  }
818
+ if (source.hidden) {
819
+ return !source.hidden;
820
+ }
804
821
  return true;
805
822
  },
806
823
  set show(v) {
807
824
  source.show = v;
808
825
  },
826
+ //是否显示
827
+ get hidden() {
828
+ return source.hidden;
829
+ },
830
+ set hidden(v) {
831
+ source.hidden = v;
832
+ },
809
833
  //重置
810
834
  reset() {
811
835
  if (this.controlType === Enum.ControlType.Hidden
@@ -829,10 +853,10 @@ const Base = function (source, moreActionRouter) {
829
853
  }
830
854
  else {
831
855
  this.value = this.defaultCode1
832
- if(this.searchName){
833
- this.searchName=''
834
- this.searchValue=''
835
- this.searchValue1=''
856
+ if (this.searchName) {
857
+ this.searchName = ''
858
+ this.searchValue = ''
859
+ this.searchValue1 = ''
836
860
  }
837
861
  }
838
862
 
@@ -853,8 +877,8 @@ const Base = function (source, moreActionRouter) {
853
877
  this.code1 = this.defaultCode1 || '';
854
878
  this.code2 = this.defaultCode2 || '';
855
879
  this.name1 = this.defaultName1 || '';
856
- if(this.controlType === Enum.ControlType.SearchListBox && this.defaultCode1 && this.defaultName1){
857
- this.options=[{ value: this.code1, label: this.name1 }]
880
+ if (this.controlType === Enum.ControlType.SearchListBox && this.defaultCode1 && this.defaultName1) {
881
+ this.options = [{ value: this.code1, label: this.name1 }]
858
882
  }
859
883
  }
860
884
  else {
@@ -971,7 +995,7 @@ const Base = function (source, moreActionRouter) {
971
995
  getFormParentFieldPara() {
972
996
  if (rtn.form && typeof rtn.parentFields !== 'undefined' && rtn.parentFields.length > 0) {
973
997
  if (typeof rtn.form.getRefFieldPara === 'function') {
974
- return rtn.form.getParentFieldPara(rtn.parentFields,rtn.form);
998
+ return rtn.form.getParentFieldPara(rtn.parentFields, rtn.form);
975
999
  }
976
1000
  }
977
1001
  return null;
@@ -93,7 +93,12 @@ function loadFromModel(source, isFormList) {
93
93
  && attrValue != undefined && attrValue != null && attrValue != '') {
94
94
  rtn1.jsSetFile(attrValue, rtn1);
95
95
  }
96
+ if (attrKey == 'hidden') {
97
+ rtn1['show'] = !attrValue
98
+ }
99
+
96
100
  rtn1[attrKey] = attrValue;
101
+
97
102
  if (rtn1.controlType === Enum.ControlType.Tags) {
98
103
  rtn1["value"] = JSON.parse(attrValue);
99
104
  }
@@ -139,6 +144,7 @@ function loadFromModel(source, isFormList) {
139
144
  }
140
145
  }
141
146
  hiddenHandle(rtn1, this.form);
147
+ displayHandle(rtn1, this.form);
142
148
  requiredHandle(rtn1, this.form);
143
149
  }
144
150
  },
@@ -155,6 +161,7 @@ function loadFromModel(source, isFormList) {
155
161
  if (typeof rtn1.code1 !== 'undefined') {
156
162
  rtn1.code1 = code1;
157
163
  hiddenHandle(rtn1);//隐藏关联的
164
+ displayHandle(rtn1);
158
165
  }
159
166
  if (typeof rtn1.code2 !== 'undefined') {
160
167
  rtn1.code2 = code2;
@@ -552,6 +559,7 @@ function loadFromModel(source, isFormList) {
552
559
 
553
560
  }
554
561
  allhiddenHandle(rtn);
562
+ alldisplayHandle(rtn);
555
563
  allRequiredHandle(rtn);//必填关联组件
556
564
  return rtn._fields;
557
565
  },
@@ -723,7 +731,7 @@ function loadFromModel(source, isFormList) {
723
731
  return rtn._scripts;
724
732
  }
725
733
  else {
726
- if (source&&typeof source.scripts !== 'undefined') {
734
+ if (source && typeof source.scripts !== 'undefined') {
727
735
  rtn._scripts = base.common.eval(source.scripts);
728
736
  return rtn._scripts;
729
737
  }
@@ -881,12 +889,28 @@ function hiddenHandle(item, model) {
881
889
  field = model.fields[i];
882
890
  if (field) {
883
891
  let hiddenValueArr = field.hiddenRelationFieldValue.split(',');
884
- if (hiddenValueArr.indexOf(item.code1) > -1) {
885
- field.show = false;
892
+ if (item.controlType == Enum.ControlType.MultiSelectWithSearch || item.controlType == Enum.ControlType.MultiSelectNoSearch) {
893
+ field.show = true;
894
+ var value = item.code1 === '' ? [''] : JSON.parse(item.code1)
895
+ if (value.length > 0) {
896
+ value.forEach((v) => {
897
+ if (v.flagDeleted !== true) {
898
+ if (hiddenValueArr.indexOf(v.code) > -1) {
899
+ field.show = false;
900
+ }
901
+ }
902
+ });
903
+ }
886
904
  }
887
905
  else {
888
- field.show = true;
906
+ if (hiddenValueArr.indexOf(item.code1) > -1) {
907
+ field.show = false;
908
+ }
909
+ else {
910
+ field.show = true;
911
+ }
889
912
  }
913
+
890
914
  //本组件隐藏,子组件必须隐藏
891
915
  hiddenHandlesource(field, model);
892
916
  if (!item.show && item.controlType !== Enum.ControlType.Hidden) field.show = false;
@@ -898,12 +922,28 @@ function hiddenHandle(item, model) {
898
922
  field1 = model.fields[i].fields[i1];
899
923
  if (field1) {
900
924
  let hiddenValueArr1 = field1.hiddenRelationFieldValue.split(',');
901
- if (hiddenValueArr1.indexOf(item.code1) > -1) {
902
- field1.show = false;
925
+ if (item.controlType == Enum.ControlType.MultiSelectWithSearch || item.controlType == Enum.ControlType.MultiSelectNoSearch) {
926
+ field1.show = true;
927
+ var value = item.code1 === '' ? [''] : JSON.parse(item.code1)
928
+ if (value.length > 0) {
929
+ value.forEach((v) => {
930
+ if (v.flagDeleted !== true) {
931
+ if (hiddenValueArr1.indexOf(v.code) > -1) {
932
+ field1.show = false;
933
+ }
934
+ }
935
+ });
936
+ }
903
937
  }
904
938
  else {
905
- field1.show = true;
939
+ if (hiddenValueArr1.indexOf(item.code1) > -1) {
940
+ field1.show = false;
941
+ }
942
+ else {
943
+ field1.show = true;
944
+ }
906
945
  }
946
+
907
947
  }
908
948
  }
909
949
  }
@@ -921,6 +961,88 @@ function hiddenHandlesource(item, model) {
921
961
  hiddenHandle(field[0], model);
922
962
  }
923
963
  }
964
+ //初始化显示关联组件
965
+ function alldisplayHandle(model) {
966
+ model.fields.forEach(v => {
967
+ displayHandle(v, model);
968
+ if (v.controlType == Enum.ControlType.Compound || v.controlType == Enum.ControlType.ContainerControl) {
969
+ v.fields.forEach(v1 => {
970
+ displayHandle(v1, model);
971
+ });
972
+ }
973
+ });
974
+ }
975
+ //显示关联组件
976
+ function displayHandle(item, model) {
977
+ if (item.fieldName1) {
978
+ let field = null;
979
+ let field1 = null;
980
+ for (var i in model.fields) {
981
+ if (!model.fields[i].hiddenRelationField && model.fields[i].displayRelationField === item.fieldName1) {
982
+ field = model.fields[i];
983
+ if (field) {
984
+ let displayValueArr = field.displayRelationFieldValue.split(',');
985
+ if (item.controlType == Enum.ControlType.MultiSelectWithSearch || item.controlType == Enum.ControlType.MultiSelectNoSearch) {
986
+ field.show = false;
987
+ var value = item.code1 === '' ? [''] : JSON.parse(item.code1)
988
+ if (value.length > 0) {
989
+ value.forEach((v) => {
990
+ if (v.flagDeleted !== true) {
991
+ if (displayValueArr.indexOf(v.code) > -1) {
992
+ field.show = true;
993
+ }
994
+ }
995
+ });
996
+ }
997
+ }
998
+ else {
999
+ if (displayValueArr.indexOf(item.code1) > -1) {
1000
+ field.show = true;
1001
+ }
1002
+ else {
1003
+ field.show = false;
1004
+ }
1005
+ }
1006
+ if (!item.show && item.controlType !== Enum.ControlType.Hidden) field.show = false;
1007
+ }
1008
+ }
1009
+ if (model.fields[i].controlType == Enum.ControlType.Compound || model.fields[i].controlType == Enum.ControlType.ContainerControl) {
1010
+ for (var i1 in model.fields[i].fields) {
1011
+ if (!model.fields[i].fields[i1].hiddenRelationField && model.fields[i].fields[i1].displayRelationField === item.fieldName1) {
1012
+ field1 = model.fields[i].fields[i1];
1013
+ if (field1) {
1014
+ let displayValueArr1 = field1.displayRelationFieldValue.split(',');
1015
+ if (item.controlType == Enum.ControlType.MultiSelectWithSearch || item.controlType == Enum.ControlType.MultiSelectNoSearch) {
1016
+ field1.show = false;
1017
+ var value = item.code1 === '' ? [''] : JSON.parse(item.code1)
1018
+ if (value.length > 0) {
1019
+ value.forEach((v) => {
1020
+ if (v.flagDeleted !== true) {
1021
+ if (displayValueArr1.indexOf(v.code) > -1) {
1022
+ field1.show = true;
1023
+ }
1024
+ }
1025
+ });
1026
+ }
1027
+ }
1028
+ else {
1029
+ if (displayValueArr1.indexOf(item.code1) > -1) {
1030
+ field1.show = true;
1031
+ }
1032
+ else {
1033
+ field1.show = false;
1034
+ }
1035
+ }
1036
+
1037
+ }
1038
+ }
1039
+ }
1040
+ }
1041
+
1042
+ }
1043
+
1044
+ }
1045
+ }
924
1046
  //初始化必填关联组件
925
1047
  function allRequiredHandle(model) {
926
1048
  model.fields.forEach(v => {
@@ -938,11 +1060,26 @@ function requiredHandle(item, model) {
938
1060
  field = model.fields[i];
939
1061
  if (field) {
940
1062
  let requiredValueArr = field.requiredRelationFieldValue.split(',');
941
- if (requiredValueArr.indexOf(value) > -1) {
942
- field.required = true;
1063
+ if (item.controlType == Enum.ControlType.MultiSelectWithSearch || item.controlType == Enum.ControlType.MultiSelectNoSearch) {
1064
+ field.required = false;
1065
+ var arrValue = item.code1 === '' ? [''] : JSON.parse(item.code1)
1066
+ if (arrValue.length > 0) {
1067
+ arrValue.forEach((v) => {
1068
+ if (v.flagDeleted !== true) {
1069
+ if (requiredValueArr.indexOf(v.code) > -1) {
1070
+ field.required = true;
1071
+ }
1072
+ }
1073
+ });
1074
+ }
943
1075
  }
944
1076
  else {
945
- field.required = false;
1077
+ if (requiredValueArr.indexOf(value) > -1) {
1078
+ field.required = true;
1079
+ }
1080
+ else {
1081
+ field.required = false;
1082
+ }
946
1083
  }
947
1084
  }
948
1085
  }
@@ -952,12 +1089,28 @@ function requiredHandle(item, model) {
952
1089
  field1 = model.fields[i].fields[i1];
953
1090
  if (field1) {
954
1091
  let requiredValueArr = field1.requiredRelationFieldValue.split(',');
955
- if (requiredValueArr.indexOf(item.code1) > -1) {
956
- field1.required = true;
1092
+ if (item.controlType == Enum.ControlType.MultiSelectWithSearch || item.controlType == Enum.ControlType.MultiSelectNoSearch) {
1093
+ field1.required = false;
1094
+ var arrValue = item.code1 === '' ? [''] : JSON.parse(item.code1)
1095
+ if (arrValue.length > 0) {
1096
+ arrValue.forEach((v) => {
1097
+ if (v.flagDeleted !== true) {
1098
+ if (requiredValueArr.indexOf(v.code) > -1) {
1099
+ field1.required = true;
1100
+ }
1101
+ }
1102
+ });
1103
+ }
957
1104
  }
958
1105
  else {
959
- field1.required = false;
1106
+ if (requiredValueArr.indexOf(item.code1) > -1) {
1107
+ field1.required = true;
1108
+ }
1109
+ else {
1110
+ field1.required = false;
1111
+ }
960
1112
  }
1113
+
961
1114
  }
962
1115
  }
963
1116
  }
@@ -1254,6 +1407,7 @@ function getFileData(field, model) {
1254
1407
  }
1255
1408
  function changeHandler(field, model) {
1256
1409
  hiddenHandle(field, model);
1410
+ displayHandle(field, model);
1257
1411
  requiredHandle(field, model);
1258
1412
  clearRelatedHandle(field, model.fields)
1259
1413
  if (field.onChanged) {
@@ -1331,6 +1485,7 @@ const Form = {
1331
1485
  loadFormApi,
1332
1486
  loadFromModel,
1333
1487
  hiddenHandle,
1488
+ displayHandle,
1334
1489
  requiredHandle,
1335
1490
  clearRelatedHandle,
1336
1491
  doAction,