resolver-egretimp-plus 0.0.124 → 0.0.126

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": "resolver-egretimp-plus",
3
- "version": "0.0.124",
3
+ "version": "0.0.126",
4
4
  "description": "交付体验渲染",
5
5
  "main": "./dist/web/index.js",
6
6
  "module": "./dist/web/index.js",
@@ -49,9 +49,10 @@
49
49
  "vue-loader": "^17.4.2",
50
50
  "vue-style-loader": "^4.1.3",
51
51
  "vue3-quill": "^0.3.1",
52
+ "vue3-sfc-loader": "^0.9.5",
52
53
  "webpack": "^5.90.0",
53
- "webpack-cli": "^5.1.4",
54
- "vue3-sfc-loader": "^0.9.5"
54
+ "json-rules-engine": "^7.2.1",
55
+ "webpack-cli": "^5.1.4"
55
56
  },
56
57
  "dependencies": {}
57
58
  }
@@ -49,6 +49,7 @@ export default {
49
49
  delete ret.onClick
50
50
  return ret
51
51
  })
52
+ const ruleExecuter = inject('_ruleExecuter')
52
53
  const dialogReq = inject('_dialogReq', {})
53
54
  const requestTraceId = inject('requestTraceId')
54
55
  const polyfillConfigs = inject('_polyfillConfigs', {})
@@ -113,9 +114,21 @@ export default {
113
114
  })
114
115
  penddingRules[hireRelat] = null
115
116
  }
117
+ // 使用json-rules-engine书写的规则,打开这边,需要对之前的规则进行注释,并且需要再index.js文件中进行开启 ====start====
118
+ if (ruleExecuter?.penddingRules?.[hireRelat]?.length) {
119
+ ruleExecuter?.penddingRules[hireRelat].forEach(context => {
120
+ const rules = context.rules
121
+ delete context.rules
122
+ setTimeout(() => {
123
+ rulesDriver.call(context, rules)
124
+ }, 0)
125
+ })
126
+ ruleExecuter.penddingRules[hireRelat] = null
127
+ }
116
128
  if (props.config?.immediateClickEvent) {
117
129
  executeClickEvents()
118
130
  }
131
+ // 使用json-rules-engine书写的规则,打开这边,需要对之前的规则进行注释,并且需要再index.js文件中进行开启 ====end====
119
132
  }
120
133
  const onVnodeUnmounted = () => {
121
134
  props.config.vmIsBind = false
@@ -419,6 +419,7 @@ export async function executeDataValid(validConfig, {
419
419
  return
420
420
  }
421
421
  const ret = await buildInRequest(url, {
422
+ aid_language: lang,
422
423
  requestTraceId,
423
424
  ...reqData,
424
425
  pmHandleBusinessIdentity: {
@@ -17,6 +17,9 @@ const props = defineProps({
17
17
  formatter: {
18
18
  type: Function,
19
19
  default: null
20
+ },
21
+ isPointer: {
22
+ type: [String]
20
23
  }
21
24
  })
22
25
  const lang = inject('lang')
@@ -27,7 +30,7 @@ const value = computed(() => {
27
30
  if (
28
31
  isPatchComponent(PLAIN_TYPE_OPTIONS_COLUMNS, props)
29
32
  ) {
30
- return props?.options?.find(item => item.columnValue == modelValue.value)?.[lang?.value?.indexOf('zh') > -1 ? 'columnDesc_zh' : 'columnDesc']
33
+ return selectFormat(modelValue.value)
31
34
  } else {
32
35
  if (isPatchComponent(['ElDatePicker'], props)) {
33
36
  if (!modelValue.value) {
@@ -40,7 +43,8 @@ const value = computed(() => {
40
43
  })
41
44
 
42
45
  const classObj = computed(() => ({
43
- [`custom-component-plain--${props.type}`]: true
46
+ [`custom-component-plain--${props.type}`]: true,
47
+ cursor: props.isPointer == '1'
44
48
  }))
45
49
 
46
50
 
@@ -67,6 +71,20 @@ const clickAction = () => {
67
71
  rootForm
68
72
  }, appContext)
69
73
  }
74
+
75
+ function selectFormat(value) {
76
+ let valList = value
77
+ const multiple = props?.config?.multiple == '1'
78
+ const isStrVal = props.config?.valueType !== 'list'
79
+ // 在满足多选,并且不是str格式的时候,就表示value为数组类型,取反就表示不满足的时候,需要转换成数组格式进行计算
80
+ if (!(multiple && !isStrVal)) {
81
+ valList = valList ? (valList?.split(',') || []) : []
82
+ }
83
+ return valList?.reduce((ret, val) => {
84
+ const str = props?.options?.find(item => item.columnValue == val)?.[lang?.value?.indexOf('zh') > -1 ? 'columnDesc_zh' : 'columnDesc']
85
+ return `${ret}${ret ? ',' : ''}${str}`
86
+ }, '')
87
+ }
70
88
  </script>
71
89
  <style lang="scss" scoped>
72
90
  .custom-component-plain {
@@ -77,4 +95,7 @@ const clickAction = () => {
77
95
  .custom-component-plain--error {
78
96
  color: #F54A45;
79
97
  }
98
+ .cursor {
99
+ cursor: pointer;
100
+ }
80
101
  </style>
@@ -0,0 +1,180 @@
1
+ import { ElInput } from 'element-plus'
2
+ import { computed, defineProps, useAttrs } from 'vue'
3
+ import { commonPropsType, hasOwn, isElement } from '../../utils/index.js'
4
+ import { ref } from 'vue';
5
+ import { onMounted } from 'vue';
6
+ import { getDomWidth } from '../../utils/dom.js';
7
+ import { watch } from 'vue';
8
+ import { nextTick } from 'vue';
9
+ import { resolveComponent } from 'vue';
10
+
11
+ export default {
12
+ inheritAttrs: false,
13
+ props: {
14
+ ...commonPropsType,
15
+ ...ElInput.props
16
+ },
17
+ emits: ['update:modelValue'],
18
+ setup(props, { emit, attrs }) {
19
+ const isOverflow = ref(false)
20
+ const inputWrapRef = ref(null)
21
+ const calcSpanRef = ref(null)
22
+ const inputProps = computed(() => {
23
+ const ret = Object.keys(ElInput.props).reduce((total, key) => {
24
+ total[key] = props[key]
25
+ return total
26
+ }, {})
27
+ if (props.config?.icon) {
28
+ ret.suffixIcon = props.config?.icon
29
+ }
30
+ return ret
31
+ })
32
+ const normalInputProps = computed(() => {
33
+ const ret = {
34
+ ...inputProps.value
35
+ }
36
+ delete ret.suffixIcon
37
+ delete ret.prefixIcon
38
+ return ret
39
+ })
40
+ const showTooltip = computed(() => {
41
+ return props?.config?.showTooltip == '1' && props.disabled
42
+ })
43
+ const modelValue = computed({
44
+ get() {
45
+ return props.modelValue
46
+ },
47
+ set(val) {
48
+ emit('update:modelValue', val)
49
+ }
50
+ })
51
+ const isPagePopup = computed(() => {
52
+ return props.config?.lcpPagePopupMapVO
53
+ })
54
+ // 弹框是否只能支持点击icon进行触发,默认是
55
+ const isOnlyIconClickFlag = computed(() => {
56
+ return hasOwn(props.config, 'onlyIconClickFlag') ? props.config?.onlyIconClickFlag == '1' : true
57
+ })
58
+ // 输入点击弹框的情况下,是否仍然可以编辑
59
+ const isPagePopupAlwayEdit = computed(() => {
60
+ return props.config?.pagePopupEditFlag == '1'
61
+ })
62
+ const vmodelProps = computed(() => {
63
+ const ret = {
64
+ modelValue: modelValue.value
65
+ }
66
+ if (!(isPagePopup.value && !isPagePopupAlwayEdit.value)) {
67
+ ret['onUpdate:modelValue'] = (val) => {
68
+ modelValue.value = val
69
+ }
70
+ } else {
71
+ ret['onClear'] = () => {
72
+ attrs?.onClear?.()
73
+ modelValue.value = ''
74
+ }
75
+ }
76
+ return ret
77
+ })
78
+ const normalAttrs = computed(() => {
79
+ const ret = {
80
+ ...attrs
81
+ }
82
+ if (isPagePopup.value && isOnlyIconClickFlag.value) {
83
+ delete ret.onClick
84
+ }
85
+ return ret
86
+ })
87
+
88
+ const tooltipCalc = (() => {
89
+ let unWatch = null
90
+ let onResize = null
91
+ return {
92
+ clear: () => {
93
+ unWatch && unWatch()
94
+ onResize && window.removeEventListener('resize', onResize)
95
+ },
96
+ calc() {
97
+ this.clear()
98
+ let inputWrapWidth = getDomWidth(inputWrapRef.value, 0)
99
+ let textLengthWidth = getDomWidth(calcSpanRef.value, -22)
100
+ isOverflow.value = inputWrapWidth < textLengthWidth
101
+ unWatch = watch(() => modelValue.value, (val) => {
102
+ nextTick(() => {
103
+ textLengthWidth = getDomWidth(calcSpanRef.value, -22)
104
+ isOverflow.value = inputWrapWidth < textLengthWidth
105
+ })
106
+ })
107
+ onResize = () => {
108
+ inputWrapWidth = getDomWidth(inputWrapRef.value, 0)
109
+ isOverflow.value = inputWrapWidth < textLengthWidth
110
+ console.log('isOverflow==:', isOverflow.value, inputWrapWidth)
111
+ }
112
+ window.addEventListener('resize', onResize)
113
+ }
114
+ }
115
+ })()
116
+
117
+ onMounted(() => {
118
+ watch(showTooltip, (val) => {
119
+ if (val) {
120
+ tooltipCalc?.calc()
121
+ }
122
+ }, {
123
+ immediate: true
124
+ })
125
+ })
126
+ const polyfillInputWrap = (node) => {
127
+ if (isOverflow.value) {
128
+ return (
129
+ <el-tooltip content={modelValue.value} placement="top">
130
+ { node }
131
+ </el-tooltip>
132
+ )
133
+ }
134
+ return node
135
+ }
136
+ const getInputSolts = () => {
137
+ const ret = {}
138
+ if (inputProps.value?.suffixIcon) {
139
+ const suffixIcon = resolveComponent(inputProps.value.suffixIcon)
140
+ ret.suffix = () => {
141
+ const iconProps = {}
142
+ if (isPagePopup.value && inputProps.value.suffixIcon == 'Search') {
143
+ iconProps.onClick = attrs.onClick
144
+ iconProps.style = {
145
+ cursor: 'pointer'
146
+ }
147
+ }
148
+
149
+ return <el-icon {...iconProps}><suffixIcon /></el-icon>
150
+ }
151
+ }
152
+ if (inputProps.value?.prefixIcon) {
153
+ const prefixIcon = resolveComponent(inputProps.value.prefixIcon)
154
+ ret.prefix = () => {
155
+ return <el-icon><prefixIcon /></el-icon>
156
+ }
157
+ }
158
+ return ret
159
+ }
160
+ return () => {
161
+ return (
162
+ <div class="input-contrainer">
163
+ <span ref={(e) => calcSpanRef.value = e} class="calc-span">{ modelValue.value }</span>
164
+ {
165
+ polyfillInputWrap(
166
+ <div v-else class="input-wrap" ref={(e) => inputWrapRef.value = e}>
167
+ <ElInput {...vmodelProps.value} {...{...normalAttrs.value, ...normalInputProps.value}}>
168
+ {
169
+ getInputSolts()
170
+ }
171
+ </ElInput>
172
+ </div>
173
+ )
174
+ }
175
+ </div>
176
+ )
177
+ }
178
+ }
179
+ }
180
+
@@ -0,0 +1,102 @@
1
+ <script setup>
2
+ import { ElInput } from 'element-plus'
3
+ import { computed, defineProps, useAttrs } from 'vue'
4
+ import { commonPropsType, isElement } from '../../utils/index.js'
5
+ import { ref } from 'vue';
6
+ import { onMounted } from 'vue';
7
+ import { getDomWidth } from '../../utils/dom.js';
8
+ import { watch } from 'vue';
9
+ import { nextTick } from 'vue';
10
+
11
+ const isOverflow = ref(false)
12
+ const inputWrapRef = ref(null)
13
+ const calcSpanRef = ref(null)
14
+ const props = defineProps({
15
+ ...commonPropsType,
16
+ ...ElInput.props
17
+ })
18
+ const inputProps = computed(() => {
19
+ const ret = Object.keys(ElInput.props).reduce((total, key) => {
20
+ total[key] = props[key]
21
+ return total
22
+ }, {})
23
+ if (props.config?.icon) {
24
+ ret.suffixIcon = props.config?.icon
25
+ }
26
+ return ret
27
+ })
28
+ const showTooltip = computed(() => {
29
+ return props?.config?.showTooltip == '1' && props.disabled
30
+ })
31
+ const attrs = useAttrs()
32
+ const modelValue = defineModel()
33
+
34
+
35
+ const tooltipCalc = (() => {
36
+ let unWatch = null
37
+ let onResize = null
38
+ return {
39
+ clear: () => {
40
+ unWatch && unWatch()
41
+ onResize && window.removeEventListener('resize', onResize)
42
+ },
43
+ calc() {
44
+ this.clear()
45
+ let inputWrapWidth = getDomWidth(inputWrapRef.value, 0)
46
+ let textLengthWidth = getDomWidth(calcSpanRef.value, -22)
47
+ isOverflow.value = inputWrapWidth < textLengthWidth
48
+ unWatch = watch(() => modelValue.value, (val) => {
49
+ nextTick(() => {
50
+ textLengthWidth = getDomWidth(calcSpanRef.value, -22)
51
+ isOverflow.value = inputWrapWidth < textLengthWidth
52
+ })
53
+ })
54
+ onResize = () => {
55
+ inputWrapWidth = getDomWidth(inputWrapRef.value, 0)
56
+ isOverflow.value = inputWrapWidth < textLengthWidth
57
+ console.log('isOverflow==:', isOverflow.value, inputWrapWidth)
58
+ }
59
+ window.addEventListener('resize', onResize)
60
+ }
61
+ }
62
+ })()
63
+
64
+ onMounted(() => {
65
+ watch(showTooltip, (val) => {
66
+ if (val) {
67
+ tooltipCalc?.calc()
68
+ }
69
+ }, {
70
+ immediate: true
71
+ })
72
+ })
73
+ </script>
74
+ <template>
75
+ <div class="input-contrainer">
76
+ <span ref="calcSpanRef" class="calc-span">{{ modelValue }}</span>
77
+ <el-tooltip v-if="isOverflow" :content="modelValue" placement="top">
78
+ <div class="input-wrap" :ref="(e) => inputWrapRef = e">
79
+ <ElInput v-model="modelValue" v-bind="{...attrs, ...inputProps}"></ElInput>
80
+ </div>
81
+ </el-tooltip>
82
+ <div v-else class="input-wrap" :ref="(e) => inputWrapRef = e">
83
+ <ElInput v-model="modelValue" v-bind="{...attrs, ...inputProps}"></ElInput>
84
+ </div>
85
+ </div>
86
+ </template>
87
+
88
+ <style lang="scss" scoped>
89
+ .input-contrainer {
90
+ width: 100%;
91
+ .calc-span {
92
+ white-space: nowrap;
93
+ position: absolute;
94
+ visibility: hidden;
95
+ padding: 0 11px;
96
+ box-sizing: border-box;
97
+ }
98
+ .input-wrap{
99
+ width: 100%;
100
+ }
101
+ }
102
+ </style>
@@ -9,7 +9,7 @@ export function useVModel(config, props, emit, modelKey = 'update:modelValue') {
9
9
  // const dataLoad = inject('dataLoad')
10
10
  // const dynamicMapComp = inject('dynamicMapComp')
11
11
  // const lang = inject('lang')
12
- const { hireRelatMapRules, dataLoad, dynamicMapComp, lang, _mapComp } = this
12
+ const { hireRelatMapRules, messageInstance, rootValue, ruleExecuter, dataLoad, dynamicMapComp, lang, _mapComp } = this
13
13
  const currentRules = hireRelatMapRules.value[config.hireRelat]
14
14
  let metaCodeKey = config.metaCode
15
15
  if (modelKey !== 'update:modelValue') {
@@ -34,11 +34,22 @@ export function useVModel(config, props, emit, modelKey = 'update:modelValue') {
34
34
  // 事件初始化执行,在dataLoaded请求完成之后,执行一次事件
35
35
  if (dataLoad.value && !config.eventInit && !config.notInit) {
36
36
  setTimeout(() => {
37
+ ruleExecuter?.run({
38
+ rootValue,
39
+ rules: currentRules,
40
+ config,
41
+ dynamicMapComp,
42
+ lang,
43
+ messageInstance,
44
+ _mapComp,
45
+ isInit: true,
46
+ })
37
47
  rulesDriver.call({
38
48
  config,
39
49
  dynamicMapComp,
40
50
  lang,
41
- _mapComp
51
+ _mapComp,
52
+ messageInstance
42
53
  }, currentRules, true)
43
54
  config.eventInit = true
44
55
  }, 0)
@@ -68,11 +79,21 @@ export function useVModel(config, props, emit, modelKey = 'update:modelValue') {
68
79
  }
69
80
  if (config) {
70
81
  setTimeout(() => {
82
+ ruleExecuter?.run({
83
+ rootValue,
84
+ rules: currentRules,
85
+ config,
86
+ dynamicMapComp,
87
+ lang,
88
+ messageInstance,
89
+ _mapComp,
90
+ })
71
91
  rulesDriver.call({
72
92
  config,
73
93
  dynamicMapComp,
74
94
  lang,
75
- _mapComp
95
+ _mapComp,
96
+ messageInstance
76
97
  }, currentRules)
77
98
  }, 0)
78
99
  }
@@ -86,13 +107,19 @@ export function useVmodels(props, emit) {
86
107
  const dynamicMapComp = inject('dynamicMapComp')
87
108
  const lang = inject('lang')
88
109
  const _mapComp = inject('_mapComp')
110
+ const rootValue = inject('rootValue')
111
+ const ruleExecuter = inject('_ruleExecuter')
112
+ const messageInstance = inject('_messageInstance')
89
113
 
90
114
  const thisObj = {
91
115
  hireRelatMapRules,
92
116
  dataLoad,
93
117
  dynamicMapComp,
94
118
  lang,
95
- _mapComp
119
+ rootValue,
120
+ _mapComp,
121
+ ruleExecuter,
122
+ messageInstance: messageInstance?.value
96
123
  }
97
124
 
98
125
  const vModelObjs = reactive({})
package/src/index.jsx CHANGED
@@ -7,8 +7,7 @@ import { MODE } from "./utils/const.js"
7
7
  import { generateRequester } from "./utils/request.js"
8
8
  import { executeLoadServices } from "./components/helper/resolver.js"
9
9
  import { deepMerge } from "./utils/index.js"
10
- // import { useRouter } from "vue-router"
11
- // import { useRoute } from "vue-router"
10
+ // import { RuleExecuter } from "./rulesImp/index.js"
12
11
  export default {
13
12
  name: 'Resolver',
14
13
  props: {
@@ -130,6 +129,8 @@ export default {
130
129
  }
131
130
  },
132
131
  setup(props, { emit, attrs, expose }) {
132
+ const ruleExecuter = null
133
+ // const ruleExecuter = new RuleExecuter()
133
134
  const rootStore = reactive({})
134
135
  const nativeDataLoad = ref(false)
135
136
  // const router = useRouter()
@@ -213,6 +214,7 @@ export default {
213
214
  })
214
215
  toExecuteLoadServices()
215
216
  })
217
+ provide('_ruleExecuter', ruleExecuter)
216
218
  provide('_toExecuteLoadServices', toExecuteLoadServices)
217
219
  provide('_dialogReq', props.dialogReq)
218
220
  provide('_messageCb', props.messageCb)
@@ -342,7 +342,7 @@ const allInitEvents = {
342
342
  setPopup(event, isInit, tabpanelCode) {
343
343
  const { targetMsg, targetMsgEn } = event
344
344
  const msg = this.lang.value.indexOf('zh') > -1 ? targetMsg : targetMsgEn
345
- this.$alert(msg, '', {
345
+ this.messageInstance.warning(msg, '', {
346
346
  showCancelButton: false,
347
347
  });
348
348
  // commModal({