three-trees-ui 1.1.6 → 1.1.7
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/lib/three-trees-ui.common.js +347 -205
- package/lib/three-trees-ui.css +1 -1
- package/lib/three-trees-ui.umd.js +347 -205
- package/lib/three-trees-ui.umd.min.js +1 -1
- package/package.json +1 -1
- package/packages/CustomDialog/src/customMobileDialog.vue +18 -9
- package/packages/SubEditModeDialog/src/main.vue +145 -4
- package/packages/UserSelector/src/main.vue +4 -0
- package/packages/UserSelectorInput/src/main.vue +5 -0
- package/src/mixins/onlineSubtable.js +3 -1
- package/src/utils.js +18 -2
package/package.json
CHANGED
|
@@ -1001,10 +1001,10 @@
|
|
|
1001
1001
|
this.$emit('updateInput', _val)
|
|
1002
1002
|
}
|
|
1003
1003
|
let bindPath = `${pInst.data ? 'data.' : 'model.'}${path}`
|
|
1004
|
-
if (this.subDialogMode ==
|
|
1004
|
+
if (this.subDialogMode == 3) {
|
|
1005
1005
|
bindPath = `row.${configAttr[configAttr.length - 1]}`
|
|
1006
1006
|
}
|
|
1007
|
-
if (this.subDialogMode ==
|
|
1007
|
+
if (this.subDialogMode == 3) {
|
|
1008
1008
|
this.$set(pInst.row, configAttr[configAttr.length - 1], _val)
|
|
1009
1009
|
} else {
|
|
1010
1010
|
utils.setValueByPath(pInst, bindPath, _val, thisIndex)
|
|
@@ -1284,11 +1284,20 @@
|
|
|
1284
1284
|
this.sunIndex || this.sunIndex === 0 ? this.sunIndex : null
|
|
1285
1285
|
)
|
|
1286
1286
|
} else {
|
|
1287
|
-
|
|
1288
|
-
|
|
1289
|
-
|
|
1290
|
-
|
|
1291
|
-
|
|
1287
|
+
// 子表弹窗编辑模式时,获取参数特殊处理
|
|
1288
|
+
if (this.subDialogMode == 3 && bind.split('.').length === 4) {
|
|
1289
|
+
value = utils.getValueByPath(
|
|
1290
|
+
pInst,
|
|
1291
|
+
'row.' + bind.split('.')[3],
|
|
1292
|
+
this.subIndex || this.subIndex === 0 ? this.subIndex : null
|
|
1293
|
+
)
|
|
1294
|
+
} else {
|
|
1295
|
+
value = utils.getValueByPath(
|
|
1296
|
+
pInst,
|
|
1297
|
+
bind,
|
|
1298
|
+
this.subIndex || this.subIndex === 0 ? this.subIndex : null
|
|
1299
|
+
)
|
|
1300
|
+
}
|
|
1292
1301
|
}
|
|
1293
1302
|
return value
|
|
1294
1303
|
},
|
|
@@ -1549,10 +1558,10 @@
|
|
|
1549
1558
|
this.$emit('updateInput', _val)
|
|
1550
1559
|
}
|
|
1551
1560
|
let bindPath = `${pInst.data ? 'data.' : 'model.'}${path}`
|
|
1552
|
-
if (this.subDialogMode ==
|
|
1561
|
+
if (this.subDialogMode == 3) {
|
|
1553
1562
|
bindPath = `row.${configAttr[configAttr.length - 1]}`
|
|
1554
1563
|
}
|
|
1555
|
-
if (this.subDialogMode ==
|
|
1564
|
+
if (this.subDialogMode == 3) {
|
|
1556
1565
|
this.$set(pInst.row, configAttr[configAttr.length - 1], _val)
|
|
1557
1566
|
} else {
|
|
1558
1567
|
utils.setValueByPath(pInst, bindPath, _val, thisIndex)
|
|
@@ -31,20 +31,35 @@
|
|
|
31
31
|
</van-popup>
|
|
32
32
|
</template>
|
|
33
33
|
<script>
|
|
34
|
-
import { cloneDeep } from 'lodash'
|
|
34
|
+
import { cloneDeep, debounce } from 'lodash'
|
|
35
35
|
import utils from '@/utils.js'
|
|
36
|
+
import CustomQuery from '@/services/CustomQuery.js'
|
|
37
|
+
import { decode } from '@/util/base64'
|
|
36
38
|
|
|
37
39
|
export default {
|
|
38
40
|
name: 'HtSubEditModeDialog',
|
|
39
|
-
props: {
|
|
41
|
+
props: {
|
|
42
|
+
queryJson: {
|
|
43
|
+
type: Array,
|
|
44
|
+
default: () => {
|
|
45
|
+
return []
|
|
46
|
+
},
|
|
47
|
+
},
|
|
48
|
+
scriptValue: {
|
|
49
|
+
type: String,
|
|
50
|
+
default: '',
|
|
51
|
+
},
|
|
52
|
+
},
|
|
40
53
|
data() {
|
|
41
54
|
return {
|
|
55
|
+
subQueryJson: [],
|
|
42
56
|
dialogVisible: false,
|
|
43
57
|
dialogType: 'add',
|
|
44
58
|
row: {},
|
|
45
59
|
orgRow: {}, // 存储原始数据,用来修改子表的数据
|
|
46
60
|
data: {}, // 主表数据,用来处理参数绑定、值回显等问题
|
|
47
61
|
permission: {},
|
|
62
|
+
subTabPath: '', // 子表path
|
|
48
63
|
}
|
|
49
64
|
},
|
|
50
65
|
computed: {
|
|
@@ -52,14 +67,129 @@
|
|
|
52
67
|
return `Form${utils.guid()}`
|
|
53
68
|
},
|
|
54
69
|
},
|
|
70
|
+
|
|
55
71
|
methods: {
|
|
56
|
-
|
|
57
|
-
|
|
72
|
+
getBindValue(data, key) {
|
|
73
|
+
//当系统接到触发请求要带出数据时,发现有多个查询结果,此时将多个结果以逗号分隔的模式全部都带出来
|
|
74
|
+
let value = []
|
|
75
|
+
data.forEach((item) => {
|
|
76
|
+
if (!utils.isEmpty(item[key])) {
|
|
77
|
+
value.push(item[key])
|
|
78
|
+
}
|
|
79
|
+
})
|
|
80
|
+
return value.join(',')
|
|
81
|
+
},
|
|
82
|
+
doQuery(alias, params, resultBind, index) {
|
|
83
|
+
try {
|
|
84
|
+
let _this = this
|
|
85
|
+
let queryParams = {}
|
|
86
|
+
if (params && params.length > 0) {
|
|
87
|
+
params.forEach((item) => {
|
|
88
|
+
queryParams[item.field] = null
|
|
89
|
+
if (!item.defaultValue && item.fieldPath) {
|
|
90
|
+
const fieldPathArr = item.fieldPath.split('.')
|
|
91
|
+
const fieldPath =
|
|
92
|
+
fieldPathArr.length === 4
|
|
93
|
+
? 'row.' + fieldPathArr[3]
|
|
94
|
+
: item.fieldPath
|
|
95
|
+
const val = utils.getValueByPath(this, fieldPath, index)
|
|
96
|
+
queryParams[item.field] = val || item.emptyValue // emptyValue-关联查询绑定参数为空时的绑定值
|
|
97
|
+
}
|
|
98
|
+
})
|
|
99
|
+
}
|
|
100
|
+
CustomQuery.load(alias, queryParams).then((data) => {
|
|
101
|
+
if (
|
|
102
|
+
data &&
|
|
103
|
+
data.constructor == Array &&
|
|
104
|
+
resultBind &&
|
|
105
|
+
resultBind.constructor == Object
|
|
106
|
+
) {
|
|
107
|
+
// 关联查询值回绑时,默认获取返回的第一条记录
|
|
108
|
+
Object.keys(resultBind).forEach((k) => {
|
|
109
|
+
const path =
|
|
110
|
+
resultBind[k].split('.').length === 4
|
|
111
|
+
? 'row.' + resultBind[k].split('.')[3]
|
|
112
|
+
: resultBind[k]
|
|
113
|
+
const value = _this.getBindValue(data, k)
|
|
114
|
+
|
|
115
|
+
utils.setValueByPath(this, path, value)
|
|
116
|
+
})
|
|
117
|
+
}
|
|
118
|
+
})
|
|
119
|
+
} catch (error) {
|
|
120
|
+
console.error('获取关联查询出错:' + error)
|
|
121
|
+
}
|
|
122
|
+
},
|
|
123
|
+
initRelationQuery() {
|
|
124
|
+
if (!this.subQueryJson.length) {
|
|
125
|
+
return
|
|
126
|
+
}
|
|
127
|
+
let _this = this
|
|
128
|
+
this.subQueryJson.forEach((item) => {
|
|
129
|
+
if (!item.triggerTime) {
|
|
130
|
+
return
|
|
131
|
+
}
|
|
132
|
+
let triggerAlias = item.triggerField.split('.')[
|
|
133
|
+
item.triggerField.split('.').length - 1
|
|
134
|
+
]
|
|
135
|
+
let resultBind = {}
|
|
136
|
+
if (item.resultfield && item.resultfield.length > 0) {
|
|
137
|
+
item.resultfield.forEach((field) => {
|
|
138
|
+
resultBind[field.field] = field.fieldPath
|
|
139
|
+
})
|
|
140
|
+
}
|
|
141
|
+
if (item.triggerTime.indexOf('change') != -1 && item.triggerField) {
|
|
142
|
+
//值变化触发
|
|
143
|
+
_this.$watch(
|
|
144
|
+
'row.' + triggerAlias,
|
|
145
|
+
debounce(function(newVal, oldVal) {
|
|
146
|
+
if (
|
|
147
|
+
(newVal != '' || oldVal != undefined) &&
|
|
148
|
+
newVal !== oldVal
|
|
149
|
+
) {
|
|
150
|
+
_this.doQuery(
|
|
151
|
+
item.alias,
|
|
152
|
+
item.conditionfield,
|
|
153
|
+
resultBind,
|
|
154
|
+
null
|
|
155
|
+
)
|
|
156
|
+
}
|
|
157
|
+
}, 500)
|
|
158
|
+
)
|
|
159
|
+
}
|
|
160
|
+
if (item.triggerTime.indexOf('load') != -1) {
|
|
161
|
+
//加载时触发 & 不包含子表
|
|
162
|
+
if (item.noValuabletrigger && item.noValuableField) {
|
|
163
|
+
//有值不触发
|
|
164
|
+
const noValueField = item.noValuableField.split('.')[
|
|
165
|
+
item.noValuableField.split('.').length - 1
|
|
166
|
+
]
|
|
167
|
+
const val = utils.getValueByPath(this, noValueField)
|
|
168
|
+
if (val != '' && val != undefined && val != null) {
|
|
169
|
+
return
|
|
170
|
+
}
|
|
171
|
+
}
|
|
172
|
+
setTimeout(() => {
|
|
173
|
+
_this.doQuery(item.alias, item.conditionfield, resultBind, null)
|
|
174
|
+
}, 100)
|
|
175
|
+
}
|
|
176
|
+
})
|
|
177
|
+
},
|
|
178
|
+
showDialog({ type, data, mainData, subTabPath }) {
|
|
179
|
+
this.subTabPath = subTabPath
|
|
180
|
+
this.subQueryJson = this.queryJson.filter((item) => {
|
|
181
|
+
return (
|
|
182
|
+
item.entType === 'sub' && item.triggerField.includes(subTabPath)
|
|
183
|
+
)
|
|
184
|
+
})
|
|
58
185
|
this.permission = utils.getOnlineFormInstance(this).permission || {}
|
|
59
186
|
this.dialogType = type
|
|
60
187
|
this.orgRow = data
|
|
61
188
|
this.data = mainData
|
|
62
189
|
this.row = cloneDeep(data)
|
|
190
|
+
this.initRelationQuery()
|
|
191
|
+
this.dialogVisible = true
|
|
192
|
+
this.handleJs()
|
|
63
193
|
},
|
|
64
194
|
handleConfirm() {
|
|
65
195
|
utils
|
|
@@ -77,6 +207,17 @@
|
|
|
77
207
|
})
|
|
78
208
|
.catch(() => {})
|
|
79
209
|
},
|
|
210
|
+
// 执行js脚本
|
|
211
|
+
handleJs() {
|
|
212
|
+
if (!this.scriptValue) {
|
|
213
|
+
return
|
|
214
|
+
}
|
|
215
|
+
const diyJs = decode(this.scriptValue)
|
|
216
|
+
let row = this.row
|
|
217
|
+
let data = this.data
|
|
218
|
+
let _this = this
|
|
219
|
+
eval(diyJs)
|
|
220
|
+
},
|
|
80
221
|
},
|
|
81
222
|
}
|
|
82
223
|
</script>
|
|
@@ -25,6 +25,7 @@
|
|
|
25
25
|
select-label="fullname"
|
|
26
26
|
:quick-search-props="quickSearchProps"
|
|
27
27
|
:mode="mode"
|
|
28
|
+
:sub-dialog-mode="subDialogMode"
|
|
28
29
|
@filter-type-change="handleFilterTypeChange"
|
|
29
30
|
@valueChange="valueChange"
|
|
30
31
|
@change="handleChange"
|
|
@@ -76,6 +77,10 @@
|
|
|
76
77
|
type: Number,
|
|
77
78
|
default: 20,
|
|
78
79
|
},
|
|
80
|
+
subDialogMode: {
|
|
81
|
+
type: String,
|
|
82
|
+
default: '',
|
|
83
|
+
},
|
|
79
84
|
},
|
|
80
85
|
data() {
|
|
81
86
|
return {
|
|
@@ -81,11 +81,12 @@ export default {
|
|
|
81
81
|
)
|
|
82
82
|
this.subDataArr.push(data)
|
|
83
83
|
},
|
|
84
|
-
editSubRow(row, name) {
|
|
84
|
+
editSubRow(row, name, subTabPath) {
|
|
85
85
|
this.$refs[`HtSubEditModeDialog_${name}`].showDialog({
|
|
86
86
|
data: row,
|
|
87
87
|
mainData: this.data,
|
|
88
88
|
type: 'edit',
|
|
89
|
+
subTabPath,
|
|
89
90
|
})
|
|
90
91
|
},
|
|
91
92
|
//合计计算
|
|
@@ -537,6 +538,7 @@ export default {
|
|
|
537
538
|
data: fillObj,
|
|
538
539
|
mainData: this.data,
|
|
539
540
|
type: 'add',
|
|
541
|
+
subTabPath,
|
|
540
542
|
})
|
|
541
543
|
return
|
|
542
544
|
}
|
package/src/utils.js
CHANGED
|
@@ -922,7 +922,7 @@ var utils = {
|
|
|
922
922
|
if (!config.hasOwnProperty(key)) {
|
|
923
923
|
throw `config对象中未找到属性${key}`
|
|
924
924
|
}
|
|
925
|
-
|
|
925
|
+
let keyPath = config[key]
|
|
926
926
|
// 获取当前组件所在的表单
|
|
927
927
|
const formInst = utils.getOnlineFormInstance(inst.$parent)
|
|
928
928
|
// 获取当前组件是否在子表中的某一行
|
|
@@ -948,6 +948,14 @@ var utils = {
|
|
|
948
948
|
let wholeKeyPath = utils.getWholePathOfSub(keyPath, paths, index)
|
|
949
949
|
return utils.getValueByPath(formInst, wholeKeyPath)
|
|
950
950
|
} else {
|
|
951
|
+
if (
|
|
952
|
+
formInst &&
|
|
953
|
+
formInst.$options &&
|
|
954
|
+
formInst.$options.name == 'HtSubEditModeDialog'
|
|
955
|
+
) {
|
|
956
|
+
keyPath =
|
|
957
|
+
'row.' + config[key].split('.')[config[key].split('.').length - 1]
|
|
958
|
+
}
|
|
951
959
|
return utils.getValueByPath(formInst, keyPath)
|
|
952
960
|
}
|
|
953
961
|
},
|
|
@@ -956,7 +964,7 @@ var utils = {
|
|
|
956
964
|
if (!config.hasOwnProperty(key)) {
|
|
957
965
|
return
|
|
958
966
|
}
|
|
959
|
-
|
|
967
|
+
let keyPath = config[key]
|
|
960
968
|
// 获取当前组件所在的表单
|
|
961
969
|
const formInst = utils.getOnlineFormInstance(inst)
|
|
962
970
|
// 获取当前组件是否在子表中的某一行
|
|
@@ -982,6 +990,14 @@ var utils = {
|
|
|
982
990
|
let wholeKeyPath = utils.getWholePathOfSub(keyPath, paths, index)
|
|
983
991
|
utils.setValueByPath(formInst, wholeKeyPath, value)
|
|
984
992
|
} else {
|
|
993
|
+
if (
|
|
994
|
+
formInst &&
|
|
995
|
+
formInst.$options &&
|
|
996
|
+
formInst.$options.name == 'HtSubEditModeDialog'
|
|
997
|
+
) {
|
|
998
|
+
keyPath =
|
|
999
|
+
'row.' + config[key].split('.')[config[key].split('.').length - 1]
|
|
1000
|
+
}
|
|
985
1001
|
utils.setValueByPath(formInst, keyPath, value)
|
|
986
1002
|
}
|
|
987
1003
|
},
|