sohelp-eleplus 1.1.22 → 1.1.25

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.
@@ -274,11 +274,11 @@
274
274
 
275
275
  <!-- 数据表格 -->
276
276
  <SohelpTableSelect
277
- v-if="item.type === 'SohelpTableSelect'"
278
277
  v-bind="item.props || {}"
279
278
  @="item.props || {}"
280
279
  v-model="model[item.prop]"
281
280
  :data="data"
281
+ v-if="item.type === 'SohelpTableSelect'"
282
282
  style="width: 100%"
283
283
  >
284
284
  <template
@@ -334,18 +334,17 @@
334
334
  <!-- 上传附件 -->
335
335
  <SohelpFileUpload
336
336
  v-if="item.type === 'SohelpFileUpload'"
337
- v-bind="item.props || {}"
337
+ v-bind="{ ...item.props, ...saveParams }"
338
338
  v-model="model[item.prop]"
339
339
  :readonly="readonly"
340
340
  @="item.props || {}"
341
341
  :data="data"
342
342
  >
343
343
  </SohelpFileUpload>
344
-
345
344
  <!-- 上传图片 -->
346
345
  <SohelpImageUpload
347
346
  v-if="item.type === 'SohelpImageUpload'"
348
- v-bind="item.props || {}"
347
+ v-bind="{ ...item.props, ...saveParams }"
349
348
  @="item.props || {}"
350
349
  v-model="model[item.prop]"
351
350
  :readonly="readonly"
@@ -1073,9 +1072,12 @@
1073
1072
  readonly: {
1074
1073
  type: Boolean,
1075
1074
  default: false
1075
+ },
1076
+ saveParams: {
1077
+ type: Object,
1078
+ default: () => ({})
1076
1079
  }
1077
1080
  });
1078
-
1079
1081
  const emit = defineEmits(['updateValue']);
1080
1082
 
1081
1083
  /** 更新值 */
@@ -22,6 +22,7 @@
22
22
  :data="data[item.prop]"
23
23
  :disabled="disabled"
24
24
  :readonly="readonly"
25
+ :saveParams="saveParams"
25
26
  :ref="(el) => setFormItemRef(el, item.prop)"
26
27
  @updateValue="(value) => updateValue(item.prop, value)"
27
28
  >
@@ -69,6 +70,7 @@
69
70
  :data="data[item.prop]"
70
71
  :disabled="disabled"
71
72
  :readonly="readonly"
73
+ :saveParams="saveParams"
72
74
  :ref="(el) => setFormItemRef(el, item.prop)"
73
75
  @updateValue="(value) => updateValue(item.prop, value)"
74
76
  >
@@ -165,6 +167,10 @@
165
167
  readonly: {
166
168
  type: Boolean,
167
169
  default: false
170
+ },
171
+ saveParams: {
172
+ type: Object,
173
+ default: () => ({})
168
174
  }
169
175
  });
170
176
 
@@ -3,11 +3,17 @@
3
3
  <ele-text v-if="type === 'select'">
4
4
  <sohelp-select :datasource="datasource" v-model="value" v-bind="$attrs" />
5
5
  </ele-text>
6
- <el-rate v-model="value" v-else v-bind="$attrs" :texts="['1 分', '2 分', '3 分', '4 分', '5 分']" show-text></el-rate>
6
+ <el-rate
7
+ v-model="value"
8
+ v-else
9
+ v-bind="$attrs"
10
+ :texts="['1 分', '2 分', '3 分', '4 分', '5 分']"
11
+ show-text
12
+ ></el-rate>
7
13
  </div>
8
14
  </template>
9
15
  <script>
10
- import { reactive, ref, watch } from 'vue';
16
+ import { ref, watch } from 'vue';
11
17
  import SohelpDynSelect from '../sohelp-dyn-select/index.vue';
12
18
  export default {
13
19
  name: 'SohelpRate',
@@ -15,7 +21,7 @@
15
21
  props: {
16
22
  type: {
17
23
  type: String,
18
- default: "rate"
24
+ default: 'rate'
19
25
  },
20
26
  modelValue: [Number, String, Array]
21
27
  },
@@ -46,11 +52,9 @@
46
52
  };
47
53
  </script>
48
54
  <style lang="scss" scoped>
49
-
50
- .sohelp-rate{
51
- .el-rate{
52
- margin-top: 0;
55
+ .sohelp-rate {
56
+ .el-rate {
57
+ margin-top: 0 !important;
53
58
  }
54
59
  }
55
-
56
60
  </style>
@@ -18,7 +18,7 @@
18
18
  </el-select>
19
19
  </template>
20
20
  <script>
21
- import { onMounted, ref, watch } from 'vue';
21
+ import { onMounted, ref, computed } from 'vue';
22
22
  import { useI18n } from 'vue-i18n';
23
23
 
24
24
  export default {
@@ -50,7 +50,6 @@
50
50
  setup(props, { emit, attrs }) {
51
51
  const { t } = useI18n();
52
52
  const data = ref([]);
53
- const dataValue = ref('');
54
53
 
55
54
  const mapData = (items) => {
56
55
  return items?.map((item) => ({
@@ -71,27 +70,25 @@
71
70
  }
72
71
  });
73
72
 
74
- watch(
75
- () => props.modelValue,
76
- (val) => {
77
- let value = val + '';
78
- if (props.multiple) {
79
- // 转换成数组
80
- if (!Array.isArray(value)) {
81
- value = value
82
- ?.toString()
83
- .split(',')
84
- ?.filter((item) => item);
85
- }
86
- } else {
87
- value = value?.split(',')[0];
73
+ // 使用 computed 替代 watch,性能更好
74
+ const dataValue = computed(() => {
75
+ let value = props.modelValue + '';
76
+ if (props.multiple) {
77
+ if (!Array.isArray(value)) {
78
+ value = value
79
+ ?.toString()
80
+ .split(',')
81
+ ?.filter((item) => item);
88
82
  }
89
- dataValue.value = value;
90
- },
91
- {
92
- immediate: true
83
+ // 验证数组中的每个值是否在 data 中存在
84
+ return value.filter((v) => data.value.some((item) => item.value === v));
85
+ } else {
86
+ value = value?.split(',')[0];
87
+ // 验证单个值是否在 data 中存在
88
+ const isValid = data.value.some((item) => item.value === value);
89
+ return isValid ? value : '';
93
90
  }
94
- );
91
+ });
95
92
 
96
93
  const optionClick = (val) => {
97
94
  emit('optionClick', val);
@@ -9,10 +9,11 @@
9
9
  :where="where"
10
10
  :show-overflow-tooltip="true"
11
11
  v-model:selections="selections"
12
- highlight-current-row>
12
+ highlight-current-row
13
+ >
13
14
  <slot>
14
15
  <template v-for="(slotProps, slotName) in $scopedSlots" :key="slotName">
15
- <slot :name="slotName" v-bind="slotProps"/>
16
+ <slot :name="slotName" v-bind="slotProps" />
16
17
  </template>
17
18
  </slot>
18
19
  <template #toolbar="{ row }">
@@ -25,127 +26,124 @@
25
26
  </ele-pro-table>
26
27
  </template>
27
28
  <script>
28
- import {reactive, ref} from 'vue';
29
- import {moduleCache} from '../cache/ModuleCache';
30
- import {EleMessage} from "@/components/ele-admin-plus/components";
29
+ import { reactive, ref } from 'vue';
30
+ import { moduleCache } from '../cache/ModuleCache';
31
+ import { EleMessage } from '@/components/ele-admin-plus/components';
31
32
 
32
-
33
- export default {
34
- name: "SohelpTable",
35
- props: {
36
- /**网格列表配置ID*/
37
- refid: {
38
- type: String,
39
- default: "",
40
- required: true
41
- },
42
- /**数据源URL**/
43
- url: {
44
- type: String,
45
- default: ""
33
+ export default {
34
+ name: 'SohelpTable',
35
+ props: {
36
+ /**网格列表配置ID*/
37
+ refid: {
38
+ type: String,
39
+ default: '',
40
+ required: true
41
+ },
42
+ /**数据源URL**/
43
+ url: {
44
+ type: String,
45
+ default: ''
46
+ },
47
+ /**数据源URL**/
48
+ where: {
49
+ type: Object,
50
+ default: {}
51
+ }
46
52
  },
47
- /**数据源URL**/
48
- where: {
49
- type: Object,
50
- default: {}
51
- }
52
- },
53
- setup(props, {emit}) {
54
- /**列表实例*/
55
- const sohelpTableRef = ref(null);
56
- /**存储表格配置*/
57
- const sohelpConfig = reactive({});
58
- /**在放选中数据列表**/
59
- const selections = ref([]);
60
- /**默认加载数据**/
61
- const loadOnCreated = ref(false);
53
+ setup(props, { emit }) {
54
+ /**列表实例*/
55
+ const sohelpTableRef = ref(null);
56
+ /**存储表格配置*/
57
+ const sohelpConfig = reactive({});
58
+ /**在放选中数据列表**/
59
+ const selections = ref([]);
60
+ /**默认加载数据**/
61
+ const loadOnCreated = ref(false);
62
62
 
63
- /**自定义列配置 **/
64
- const columns = reactive([{
65
- type: 'selection',
66
- columnKey: 'selection',
67
- width: 50,
68
- align: 'center',
69
- fixed: 'left'
70
- }, {
71
- type: 'index',
72
- columnKey: 'index',
73
- width: 50,
74
- align: 'center',
75
- fixed: 'left'
76
- }]);
63
+ /**自定义列配置 **/
64
+ const columns = reactive([
65
+ {
66
+ type: 'selection',
67
+ columnKey: 'selection',
68
+ width: 50,
69
+ align: 'center',
70
+ fixed: 'left'
71
+ },
72
+ {
73
+ type: 'index',
74
+ columnKey: 'index',
75
+ width: 50,
76
+ align: 'center',
77
+ fixed: 'left'
78
+ }
79
+ ]);
77
80
 
78
- /** 表格数据源 */
79
- const datasource = async ({page, limit, where, orders}) => {
80
- if (!loadOnCreated.value) {
81
- return {total: 0, results: []}
82
- }
83
- const res = await SohelpHttp.get(props.url || sohelpConfig.requestValue, {
84
- page,
85
- limit,
86
- ...where,
87
- ...props.where,
88
- orders
89
- }).catch(e => {
90
- EleMessage.error(e.message);
91
- });
92
- return res.data;
93
- };
81
+ /** 表格数据源 */
82
+ const datasource = async ({ page, limit, where, orders }) => {
83
+ if (!loadOnCreated.value) {
84
+ return { total: 0, results: [] };
85
+ }
86
+ const res = await SohelpHttp.get(props.url || sohelpConfig.requestValue, {
87
+ page,
88
+ limit,
89
+ ...where,
90
+ ...props.where,
91
+ orders
92
+ }).catch((e) => {
93
+ EleMessage.error(e.message);
94
+ });
95
+ return res.data;
96
+ };
94
97
 
95
- /**根据配置列转成ProTable格式的列*/
96
- const switchProperty = (property) => {
97
- return {
98
- prop: property.name,
99
- columnKey: property.name,
100
- label: property.label,
101
- width: property.width || 100
102
- }
103
- }
98
+ /**根据配置列转成ProTable格式的列*/
99
+ const switchProperty = (property) => {
100
+ return {
101
+ prop: property.name,
102
+ columnKey: property.name,
103
+ label: property.label,
104
+ width: property.width || 100
105
+ };
106
+ };
104
107
 
105
- /***初始化网格列表配置**/
106
- const initProTableConfiguration = (cfg) => {
107
- loadOnCreated.value = true;
108
- reload();
109
- }
110
- /**获取列表配置*/
111
- moduleCache.getGrid(props.refid).then(data => {
112
- Object.assign(sohelpConfig, {...data});
113
- //初始化属性列表配置
114
- data.properties.map(property => {
115
- columns.push(switchProperty(property));
116
- });
117
- /**添加操作列**/
118
- columns.push({
119
- columnKey: 'action',
120
- label: '操作',
121
- width: 200,
122
- align: 'center',
123
- slot: 'action'
108
+ /***初始化网格列表配置**/
109
+ const initProTableConfiguration = (cfg) => {
110
+ loadOnCreated.value = true;
111
+ reload();
112
+ };
113
+ /**获取列表配置*/
114
+ moduleCache.getGrid(props.refid).then((data) => {
115
+ Object.assign(sohelpConfig, { ...data });
116
+ //初始化属性列表配置
117
+ data.properties.map((property) => {
118
+ columns.push(switchProperty(property));
119
+ });
120
+ /**添加操作列**/
121
+ columns.push({
122
+ field: 'action',
123
+ label: '操作',
124
+ width: 200,
125
+ align: 'center',
126
+ slot: 'action'
127
+ });
128
+ //初始化表格配置
129
+ initProTableConfiguration();
124
130
  });
125
- //初始化表格配置
126
- initProTableConfiguration();
127
- });
128
131
 
132
+ const reload = (param) => {
133
+ sohelpTableRef.value?.reload?.(param);
134
+ };
135
+ const getData = () => {
136
+ return sohelpTableRef.value?.getData?.();
137
+ };
138
+ const getTableRef = () => {
139
+ return sohelpTableRef.value?.getTableRef?.();
140
+ };
129
141
 
130
- const reload = (param) => {
131
- sohelpTableRef.value?.reload?.(param);
132
- }
133
- const getData = () => {
134
- return sohelpTableRef.value?.getData?.();
135
- }
136
- const getTableRef = () => {
137
- return sohelpTableRef.value?.getTableRef?.();
142
+ // defineExpose({
143
+ // reload, getData,getTableRef,datasource
144
+ // })
145
+ return { columns, reload, getData, getTableRef, datasource, selections, sohelpTableRef, sohelpConfig };
138
146
  }
139
-
140
- // defineExpose({
141
- // reload, getData,getTableRef,datasource
142
- // })
143
- return {columns, reload, getData, getTableRef, datasource, selections, sohelpTableRef, sohelpConfig}
144
- }
145
-
146
- };
147
-
147
+ };
148
148
  </script>
149
- <style scoped>
150
-
151
- </style>
149
+ <style scoped></style>