mooho-base-admin-plus 2.4.43 → 2.4.45

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,7 +1,7 @@
1
1
  {
2
2
  "name": "mooho-base-admin-plus",
3
3
  "description": "MOOHO basic framework for admin by Vue3",
4
- "version": "2.4.43",
4
+ "version": "2.4.45",
5
5
  "author": "jinyifan <jinyifan@mooho.com.cn>",
6
6
  "license": "MIT",
7
7
  "private": false,
@@ -0,0 +1,218 @@
1
+ <template>
2
+ <div>
3
+ <Select
4
+ ref="select"
5
+ :size="size"
6
+ :model-value="parseComboData()"
7
+ @update:model-value="$event => setComboData($event)"
8
+ :disabled="readonly"
9
+ :clearable="true"
10
+ :multiple="multi"
11
+ filterable
12
+ remote
13
+ :remote-method="remoteMethod"
14
+ :style="{ width: column.controlWidth == null ? null : column.controlWidth + 'px' }"
15
+ :placeholder="column.placeholder"
16
+ :transfer="true"
17
+ @on-change="selected => onChange(selected)"
18
+ @on-query-change="query => onComboQueryChange(query)"
19
+ @on-clear="remoteMethod"
20
+ >
21
+ <Option v-for="(item, index) in getDataSource(data, column)" :key="index" :value="item.id">{{ item.name }}</Option>
22
+ </Select>
23
+ </div>
24
+ </template>
25
+ <script>
26
+ import mixinPage from '../../mixins/page';
27
+ import modelApi from '../../api/model';
28
+ import customModelApi from '../../api/customModel';
29
+
30
+ /**
31
+ * @displayName combo-select 可筛选选择框
32
+ */
33
+ export default {
34
+ mixins: [mixinPage],
35
+ data() {
36
+ return {
37
+ selected: null,
38
+ selectedData: null
39
+ };
40
+ },
41
+ props: {
42
+ /**
43
+ * @model
44
+ */
45
+ modelValue: {
46
+ type: [Array, Number, String]
47
+ },
48
+ /**
49
+ * 大小
50
+ * @values small, default, large
51
+ */
52
+ size: {
53
+ type: String
54
+ },
55
+ /**
56
+ * 数据源数据列名
57
+ */
58
+ remoteMethod: {
59
+ type: Function
60
+ },
61
+ /**
62
+ * 只读
63
+ */
64
+ readonly: {
65
+ type: Boolean,
66
+ default: false
67
+ },
68
+ /**
69
+ * 数据
70
+ */
71
+ data: {
72
+ type: Object,
73
+ default() {
74
+ return {};
75
+ }
76
+ },
77
+ /**
78
+ * 参数
79
+ */
80
+ param: {
81
+ type: Object,
82
+ default() {
83
+ return {};
84
+ }
85
+ },
86
+ /**
87
+ * 列
88
+ */
89
+ column: {
90
+ type: Object,
91
+ default() {
92
+ return {};
93
+ }
94
+ },
95
+ /**
96
+ * 能否多选
97
+ */
98
+ multi: {
99
+ type: Boolean,
100
+ default: false
101
+ }
102
+ },
103
+ computed: {},
104
+ watch: {
105
+ modelValue(value) {
106
+ this.selected = value;
107
+ this.showSelected();
108
+ }
109
+ },
110
+ mounted() {
111
+ //this.showSelected();
112
+ },
113
+ methods: {
114
+ parseComboData() {},
115
+ setComboData(value) {
116
+ /**
117
+ * 输入事件
118
+ * @property {object} value 选中的值 }
119
+ */
120
+ this.$emit('update:modelValue', value);
121
+ },
122
+ // 加载可筛选选择框显示内容
123
+ async showSelected() {
124
+ if (this.column.isStaticItem || (this.column.dataType && this.column.dataType.startsWith('Enum:'))) {
125
+ return;
126
+ }
127
+
128
+ if (this.$refs.select) {
129
+ let values = this.$refs.select.values;
130
+ //values.length = 0;
131
+
132
+ let pendings = [];
133
+ if (this.multi) {
134
+ values.length = 0;
135
+ this.selected.forEach(value => {
136
+ if (!values.some(v => v.value == value)) {
137
+ // 不在选中项中
138
+ let newValue = { value, label: null, disabled: false };
139
+
140
+ values.push(newValue);
141
+ pendings.push(newValue);
142
+ }
143
+ });
144
+ } else {
145
+ values.length = 0;
146
+ this.$refs.select.query = '';
147
+ if (!values.some(v => v.value == this.selected)) {
148
+ // 不在选中项中
149
+ let newValue = { value: this.selected, label: null, disabled: false };
150
+
151
+ values.push(newValue);
152
+
153
+ if (this.selected != null && this.selected != '') {
154
+ pendings.push(newValue);
155
+ }
156
+ }
157
+ }
158
+
159
+ // 读取显示内容
160
+ setTimeout(async () => {
161
+ if (pendings.length > 0) {
162
+ let param = this.param;
163
+ param[this.column.sourceDataCode] = pendings.map(item => item.value).join(',');
164
+ let res;
165
+
166
+ if (this.column.isSourceCustom) {
167
+ res = await customModelApi.query(this.column.source, param);
168
+ } else {
169
+ res = await modelApi.query(this.column.source, param);
170
+ }
171
+
172
+ res.data.forEach(item => {
173
+ let v = this.parseData(item, this.column.sourceDataCode);
174
+ let label = this.parseData(item, this.column.sourceDisplayCode);
175
+
176
+ if (!this.multi) {
177
+ // 添加筛选内容
178
+ this.$refs.select.query = label;
179
+ }
180
+
181
+ let newValue = pendings.find(i => i.value == v);
182
+
183
+ if (newValue) {
184
+ newValue.label = label;
185
+ }
186
+ });
187
+
188
+ this.$forceUpdate();
189
+ }
190
+ });
191
+ }
192
+ },
193
+ // 可筛选下拉框搜索条件变化
194
+ onComboQueryChange(query) {
195
+ if (!(query || '').trim()) {
196
+ this.remoteMethod(query);
197
+ }
198
+ },
199
+ // 数据变化
200
+ onChange(selected) {
201
+ /**
202
+ * 选中项变化事件
203
+ * @property {object} row 选中项 }
204
+ */
205
+ this.$emit('on-change', selected);
206
+ },
207
+ // 获取数据源
208
+ getDataSource() {
209
+ if (!this.column.isStaticItem && this.column.dataType.startsWith('Enum:')) {
210
+ // 枚举
211
+ return this.getEnumList(this.column.dataType.split(':')[1]);
212
+ } else {
213
+ return this.column.dataSource == null ? [] : this.column.dataSource;
214
+ }
215
+ }
216
+ }
217
+ };
218
+ </script>
@@ -14,7 +14,7 @@
14
14
  <Button :size="size" custom-icon="fa fa-search" @click="dialogSelectOpen()"></Button>
15
15
  </template>
16
16
  </Input>
17
- <modal-table ref="dialogTable" :view-code="source" :selectEnable="multi" :check-cross-page="true" :footer-enable="multi" :load-data-enable="loadDataEnable" v-if="dialogActive">
17
+ <modal-table ref="dialogTable" :view-code="source" :autoLoad="false" :selectEnable="multi" :check-cross-page="true" :footer-enable="multi">
18
18
  <template #command="{ row }">
19
19
  <Button size="small" v-if="!multi" type="primary" custom-icon="fa fa-check" @click="dialogCheck(row)">{{ $t('Front_Btn_Select') }}</Button>
20
20
  </template>
@@ -42,7 +42,6 @@
42
42
  //changed: false,
43
43
  selected: null,
44
44
  selectedData: null,
45
- dialogActive: false,
46
45
  loadDataEnable: true
47
46
  };
48
47
  },
@@ -218,7 +217,15 @@
218
217
  // 弹出选择框
219
218
  dialogSelectOpen() {
220
219
  if (!this.readonly && this.source) {
221
- this.dialogActive = true;
220
+ if (this.param) {
221
+ // 参数完整
222
+ this.loadDataEnable = true;
223
+ } else {
224
+ // 参数不完整
225
+ this.loadDataEnable = false;
226
+ }
227
+
228
+ this.$refs.dialogTable.loadData();
222
229
 
223
230
  setTimeout(async () => {
224
231
  if (this.multi) {
@@ -229,14 +236,6 @@
229
236
  }
230
237
  }
231
238
 
232
- if (this.param) {
233
- // 参数完整
234
- this.loadDataEnable = true;
235
- } else {
236
- // 参数不完整
237
- this.loadDataEnable = false;
238
- }
239
-
240
239
  this.$refs.dialogTable.open(this.param);
241
240
  });
242
241
  }
@@ -125,46 +125,31 @@
125
125
  />
126
126
  </template>
127
127
  <template v-else-if="column.controlType === 'ComboSelect'">
128
- <Select
129
- :ref="'control_' + column.code"
128
+ <combo-select
130
129
  size="small"
131
- :model-value="parseComboData(data, column)"
130
+ :model-value="parseFilterData(data, column)"
132
131
  @update:model-value="$event => setFilterData(data, column, $event)"
133
- :clearable="true"
134
- filterable
135
- remote
132
+ :multi="false"
136
133
  :remote-method="search => loadOption(data, column, search)"
137
- :style="{ width: column.controlWidth == null ? null : column.controlWidth + 'px' }"
138
- :placeholder="column.description"
139
- :transfer="true"
134
+ :data="data"
135
+ :param="getParam(data, column)"
136
+ :column="column"
140
137
  @on-change="selected => onSelectDataChange(column, selected)"
141
- @on-query-change="query => onComboQueryChange(column, query)"
142
- @on-clear="loadOption(data, column, null)"
143
- >
144
- <Option v-for="item in getDataSource(data, column)" :key="item.id" :value="item.id">{{ item.name }}</Option>
145
- </Select>
138
+ ></combo-select>
146
139
  </template>
147
140
  <template v-else-if="column.controlType === 'MultiComboSelect'">
148
- <Select
149
- :ref="'control_' + column.code"
141
+ <combo-select
150
142
  size="small"
151
- :model-value="parseMultiComboData(data, column)"
143
+ :model-value="parseArrayFilterData(data, column)"
152
144
  @update:model-value="$event => setArrayFilterData(data, column, $event)"
153
- :clearable="true"
154
- :multiple="true"
155
- filterable
156
- remote
145
+ :multi="true"
157
146
  :remote-method="search => loadOption(data, column, search)"
158
- :style="{ width: column.controlWidth == null ? null : column.controlWidth + 'px' }"
159
- :placeholder="column.description"
160
- :transfer="true"
147
+ :data="data"
148
+ :param="getParam(data, column)"
149
+ :column="column"
161
150
  @on-change="selected => onSelectDataChange(column, selected)"
162
- @on-query-change="query => onComboQueryChange(column, query)"
163
- >
164
- <Option v-for="item in getDataSource(data, column)" :key="item.id" :value="item.id">{{ item.name }}</Option>
165
- </Select>
151
+ ></combo-select>
166
152
  </template>
167
-
168
153
  <template v-else-if="column.controlType === 'DialogSelect'">
169
154
  <dialog-select
170
155
  size="small"
@@ -178,6 +163,20 @@
178
163
  @on-change="selected => onSelectDataChange(column, selected)"
179
164
  ></dialog-select>
180
165
  </template>
166
+ <template v-else-if="column.controlType === 'MultiDialogSelect'">
167
+ <dialog-select
168
+ size="small"
169
+ :model-value="parseFilterData(data, column)"
170
+ @update:model-value="$event => setFilterData(data, column, $event)"
171
+ :multi="true"
172
+ :source="column.source"
173
+ :source-data-code="column.sourceDataCode"
174
+ :source-display-code="column.sourceDisplayCode"
175
+ :param="getParam(data, column)"
176
+ :controlWidth="column.controlWidth"
177
+ @on-change="selected => onSelectDataChange(column, selected)"
178
+ ></dialog-select>
179
+ </template>
181
180
  <template
182
181
  v-else-if="
183
182
  column.controlType === 'Date' ||
@@ -817,97 +816,6 @@
817
816
  item.needClear = true;
818
817
  });
819
818
  }
820
- },
821
- // 根据表达式取值(可筛选选择框)
822
- parseComboData(model, column) {
823
- let value = this.parseFilterData(model, column);
824
-
825
- setTimeout(() => {
826
- this.loadComboDataLabel(model, column, value);
827
- });
828
-
829
- return value;
830
- },
831
- // 根据表达式取值(可筛选多选选择框)
832
- parseMultiComboData(model, column) {
833
- let data = [];
834
- let value = this.parseFilterData(model, column);
835
-
836
- if (this.isJSON(value)) {
837
- data = JSON.parse(value);
838
- }
839
-
840
- this.loadComboDataLabel(model, column, data);
841
-
842
- return data;
843
- },
844
- // 加载可筛选选择框显示内容
845
- async loadComboDataLabel(model, column, data) {
846
- if (column.isStaticItem || (column.dataType && column.dataType.startsWith('Enum:'))) {
847
- return;
848
- }
849
-
850
- if (this.$refs['control_' + column.code] && data) {
851
- let values = this.$refs['control_' + column.code][0].$data.values;
852
-
853
- let pendings = [];
854
- if (column.controlType == 'MultiComboSelect') {
855
- data.forEach(value => {
856
- if (!values.some(v => v.value == value)) {
857
- // 不在选中项中
858
- let newValue = { value, label: null, disabled: false };
859
- values.push(newValue);
860
- pendings.push(newValue);
861
- }
862
- });
863
- } else {
864
- if (!values.some(v => v.value == data)) {
865
- // 不在选中项中
866
- let newValue = { value: data, label: null, disabled: false };
867
- values.push(newValue);
868
- pendings.push(newValue);
869
- }
870
- }
871
-
872
- // 读取显示内容
873
- setTimeout(async () => {
874
- if (pendings.length > 0) {
875
- let param = this.getParam(model, column);
876
- param[column.sourceDataCode] = pendings.map(item => item.value).join(',');
877
- let res;
878
-
879
- if (column.isSourceCustom) {
880
- res = await customModelApi.query(column.source, param);
881
- } else {
882
- res = await modelApi.query(column.source, param);
883
- }
884
-
885
- res.data.forEach(item => {
886
- let v = this.parseData(item, column.sourceDataCode);
887
- let label = this.parseData(item, column.sourceDisplayCode);
888
-
889
- if (column.controlType == 'ComboSelect') {
890
- // 添加筛选内容
891
- //this.$refs['control_' + column.code][0].$data.query = label;
892
- }
893
-
894
- let newValue = pendings.find(i => i.value == v);
895
-
896
- if (newValue) {
897
- newValue.label = label;
898
- }
899
- });
900
-
901
- this.$forceUpdate();
902
- }
903
- });
904
- }
905
- },
906
- // 可筛选下拉框搜索条件变化
907
- onComboQueryChange(column, query) {
908
- if (!(query || '').trim()) {
909
- this.loadOption(this.data, column, null);
910
- }
911
819
  }
912
820
  }
913
821
  };
@@ -170,60 +170,31 @@
170
170
  @on-change="onDataChange(column)"
171
171
  />
172
172
  </template>
173
- <!-- <template v-else-if="column.controlType === 'AutoComplete'">
174
- <AutoComplete :value="parseData(data, column.code) ? parseData(data, column.code) : ''"
175
- @update:model-value="$event => setData(data, column.code, $event)"
176
- :disabled="column.isReadonly"
177
- clearable
178
- @on-search="search => loadOption(data, column, search)"
179
- @on-clear="() => loadOption(data, column)"
180
- :style="{ width: column.controlWidth == null ? null : column.controlWidth + 'px' }"
181
- :placeholder="column.description"
182
- :transfer="true"
183
- @on-change="selected => onDataChange(column, selected)">
184
- <Option v-for="item in getDataSource(data, column)"
185
- :key="item.id"
186
- :value="item.name">{{ item.name }}</Option>
187
- </AutoComplete>
188
- </template> -->
189
173
  <template v-else-if="column.controlType === 'ComboSelect'">
190
- <Select
191
- :ref="'control_' + column.code"
192
- :model-value="parseComboData(data, column)"
174
+ <combo-select
175
+ :model-value="parseData(data, column.code)"
193
176
  @update:model-value="$event => setData(data, column.code, $event)"
194
- :disabled="column.isReadonly"
195
- :clearable="true"
196
- filterable
197
- remote
177
+ :multi="false"
178
+ :readonly="column.isReadonly"
198
179
  :remote-method="search => loadOption(data, column, search)"
199
- :style="{ width: column.controlWidth == null ? null : column.controlWidth + 'px' }"
200
- :placeholder="column.description"
201
- :transfer="true"
180
+ :data="data"
181
+ :param="getParam(data, column)"
182
+ :column="column"
202
183
  @on-change="selected => onSelectDataChange(column, selected)"
203
- @on-query-change="query => onComboQueryChange(column, query)"
204
- @on-clear="loadOption(data, column, null)"
205
- >
206
- <Option v-for="item in getDataSource(data, column)" :key="item.id" :value="item.id">{{ item.name }}</Option>
207
- </Select>
184
+ ></combo-select>
208
185
  </template>
209
186
  <template v-else-if="column.controlType === 'MultiComboSelect'">
210
- <Select
211
- :ref="'control_' + column.code"
212
- :model-value="parseMultiComboData(data, column)"
187
+ <combo-select
188
+ :model-value="parseArrayData(data, column.code)"
213
189
  @update:model-value="$event => setArrayData(data, column.code, $event)"
214
- :clearable="true"
215
- :multiple="true"
216
- filterable
217
- remote
190
+ :multi="true"
191
+ :readonly="column.isReadonly"
218
192
  :remote-method="search => loadOption(data, column, search)"
219
- :style="{ width: column.controlWidth == null ? null : column.controlWidth + 'px' }"
220
- :placeholder="column.description"
221
- :transfer="true"
193
+ :data="data"
194
+ :param="getParam(data, column)"
195
+ :column="column"
222
196
  @on-change="selected => onSelectDataChange(column, selected)"
223
- @on-query-change="query => onComboQueryChange(column, query)"
224
- >
225
- <Option v-for="item in getDataSource(data, column)" :key="item.id" :value="item.id">{{ item.name }}</Option>
226
- </Select>
197
+ ></combo-select>
227
198
  </template>
228
199
  <template v-else-if="column.controlType === 'DialogSelect'">
229
200
  <dialog-select