three-trees-ui 1.1.5 → 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/LICENSE +21 -21
- package/lib/three-trees-ui.common.js +522 -354
- package/lib/three-trees-ui.css +1 -1
- package/lib/three-trees-ui.umd.js +522 -354
- package/lib/three-trees-ui.umd.min.js +1 -1
- package/package.json +1 -1
- package/packages/CustomDialog/src/customMobileDialog.vue +41 -22
- package/packages/CustomDialog/src/main.vue +5 -0
- 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 +4 -1
- package/src/utils.js +18 -2
package/package.json
CHANGED
|
@@ -92,22 +92,22 @@
|
|
|
92
92
|
<ht-input
|
|
93
93
|
v-model="queryParams[index].startDate"
|
|
94
94
|
placeholder="开始日期"
|
|
95
|
-
@click.native="showDate(index, 'startDate')"
|
|
96
95
|
readonly
|
|
96
|
+
@click.native="showDate(index, 'startDate')"
|
|
97
97
|
></ht-input>
|
|
98
98
|
<span style="margin:0 10px;">至</span>
|
|
99
99
|
<ht-input
|
|
100
100
|
v-model="queryParams[index].endDate"
|
|
101
101
|
placeholder="结束日期"
|
|
102
|
-
@click.native="showDate(index, 'endDate')"
|
|
103
102
|
readonly
|
|
103
|
+
@click.native="showDate(index, 'endDate')"
|
|
104
104
|
></ht-input>
|
|
105
105
|
</div>
|
|
106
106
|
<ht-input
|
|
107
107
|
v-else
|
|
108
108
|
v-model="queryParams[index][condition.field]"
|
|
109
|
-
@click.native="showDate(index, condition.field)"
|
|
110
109
|
readonly
|
|
110
|
+
@click.native="showDate(index, condition.field)"
|
|
111
111
|
></ht-input>
|
|
112
112
|
</div>
|
|
113
113
|
<!-- 选择器 -->
|
|
@@ -172,7 +172,7 @@
|
|
|
172
172
|
<ht-custom-dialog
|
|
173
173
|
v-model="queryParams[index][condition.field]"
|
|
174
174
|
:model-name="condition.config.keyBind"
|
|
175
|
-
|
|
175
|
+
dialog-type="search"
|
|
176
176
|
:custdialog="{
|
|
177
177
|
name: '请选择',
|
|
178
178
|
icon: '',
|
|
@@ -349,8 +349,8 @@
|
|
|
349
349
|
</van-action-sheet>
|
|
350
350
|
<!-- 修改时间 -->
|
|
351
351
|
<van-popup
|
|
352
|
-
v-model="isShowDatePop"
|
|
353
352
|
v-if="isShowDatePop"
|
|
353
|
+
v-model="isShowDatePop"
|
|
354
354
|
position="bottom"
|
|
355
355
|
round
|
|
356
356
|
>
|
|
@@ -390,6 +390,10 @@
|
|
|
390
390
|
currentSubData: Array,
|
|
391
391
|
dialogConfig: Object,
|
|
392
392
|
dialogType: String,
|
|
393
|
+
subDialogMode: {
|
|
394
|
+
type: String,
|
|
395
|
+
default: '',
|
|
396
|
+
},
|
|
393
397
|
},
|
|
394
398
|
data() {
|
|
395
399
|
return {
|
|
@@ -996,12 +1000,15 @@
|
|
|
996
1000
|
// this.$emit('input', _val)
|
|
997
1001
|
this.$emit('updateInput', _val)
|
|
998
1002
|
}
|
|
999
|
-
|
|
1000
|
-
|
|
1001
|
-
|
|
1002
|
-
|
|
1003
|
-
|
|
1004
|
-
|
|
1003
|
+
let bindPath = `${pInst.data ? 'data.' : 'model.'}${path}`
|
|
1004
|
+
if (this.subDialogMode == 3) {
|
|
1005
|
+
bindPath = `row.${configAttr[configAttr.length - 1]}`
|
|
1006
|
+
}
|
|
1007
|
+
if (this.subDialogMode == 3) {
|
|
1008
|
+
this.$set(pInst.row, configAttr[configAttr.length - 1], _val)
|
|
1009
|
+
} else {
|
|
1010
|
+
utils.setValueByPath(pInst, bindPath, _val, thisIndex)
|
|
1011
|
+
}
|
|
1005
1012
|
}
|
|
1006
1013
|
}
|
|
1007
1014
|
})
|
|
@@ -1277,11 +1284,20 @@
|
|
|
1277
1284
|
this.sunIndex || this.sunIndex === 0 ? this.sunIndex : null
|
|
1278
1285
|
)
|
|
1279
1286
|
} else {
|
|
1280
|
-
|
|
1281
|
-
|
|
1282
|
-
|
|
1283
|
-
|
|
1284
|
-
|
|
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
|
+
}
|
|
1285
1301
|
}
|
|
1286
1302
|
return value
|
|
1287
1303
|
},
|
|
@@ -1541,12 +1557,15 @@
|
|
|
1541
1557
|
if (this.modelName && this.modelName.endsWith(path)) {
|
|
1542
1558
|
this.$emit('updateInput', _val)
|
|
1543
1559
|
}
|
|
1544
|
-
|
|
1545
|
-
|
|
1546
|
-
|
|
1547
|
-
|
|
1548
|
-
|
|
1549
|
-
|
|
1560
|
+
let bindPath = `${pInst.data ? 'data.' : 'model.'}${path}`
|
|
1561
|
+
if (this.subDialogMode == 3) {
|
|
1562
|
+
bindPath = `row.${configAttr[configAttr.length - 1]}`
|
|
1563
|
+
}
|
|
1564
|
+
if (this.subDialogMode == 3) {
|
|
1565
|
+
this.$set(pInst.row, configAttr[configAttr.length - 1], _val)
|
|
1566
|
+
} else {
|
|
1567
|
+
utils.setValueByPath(pInst, bindPath, _val, thisIndex)
|
|
1568
|
+
}
|
|
1550
1569
|
}
|
|
1551
1570
|
}
|
|
1552
1571
|
})
|
|
@@ -100,6 +100,7 @@
|
|
|
100
100
|
:current-sub-data="currentSubData"
|
|
101
101
|
:dialog-config="dialogConfig"
|
|
102
102
|
:dialog-type="dialogType"
|
|
103
|
+
:sub-dialog-mode="subDialogMode"
|
|
103
104
|
@calacInputSuffixHeight="calacInputSuffixHeight"
|
|
104
105
|
@updateInput="updateInput"
|
|
105
106
|
></custom-mobile-dialog>
|
|
@@ -183,6 +184,10 @@
|
|
|
183
184
|
type: String,
|
|
184
185
|
default: 'form',
|
|
185
186
|
},
|
|
187
|
+
subDialogMode: {
|
|
188
|
+
type: String,
|
|
189
|
+
default: '',
|
|
190
|
+
},
|
|
186
191
|
},
|
|
187
192
|
data() {
|
|
188
193
|
return {
|
|
@@ -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
|
}
|
|
@@ -616,6 +618,7 @@ export default {
|
|
|
616
618
|
this.data[boAlias]['sub_' + subTableName] &&
|
|
617
619
|
this.data[boAlias]['sub_' + subTableName].length < 1
|
|
618
620
|
) {
|
|
621
|
+
subInitData.sub_guid = this.guid()
|
|
619
622
|
this.data[boAlias]['sub_' + subTableName].push(
|
|
620
623
|
JSON.parse(JSON.stringify(subInitData))
|
|
621
624
|
)
|
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
|
},
|