@tongfun/tf-widget 0.1.81 → 0.1.84
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/.browserslistrc +3 -3
- package/.editorconfig +5 -5
- package/.env +4 -4
- package/.eslintignore +10 -10
- package/.eslintrc.js +62 -62
- package/README.md +395 -395
- package/lib/tf-widget.common.js +768 -745
- package/lib/tf-widget.css +1 -1
- package/lib/tf-widget.umd.js +768 -745
- package/lib/tf-widget.umd.min.js +52 -52
- package/package.json +49 -49
- package/postinstall.js +10 -10
- package/dist/css/chunk-vendors.75ec1ba3.css +0 -1
- package/dist/css/index.d1a92f6c.css +0 -1
- package/dist/fonts/element-icons.f1a45d74.ttf +0 -0
- package/dist/fonts/element-icons.ff18efd1.woff +0 -0
- package/dist/js/chunk-vendors-legacy.8062375b.js +0 -54
- package/dist/js/chunk-vendors.32ae2509.js +0 -52
- package/dist/js/index-legacy.a20e505f.js +0 -1
- package/dist/js/index.2db423f4.js +0 -1
- package/dist.zip +0 -0
package/README.md
CHANGED
|
@@ -1,395 +1,395 @@
|
|
|
1
|
-
# TF-Widget
|
|
2
|
-
|
|
3
|
-
## 目录
|
|
4
|
-
- [版本更新说明](#1-版本更新记录)
|
|
5
|
-
- [使用文档](#2-组件使用文档)
|
|
6
|
-
- [tinput](#21-tinput组件)
|
|
7
|
-
- [FormBody](#22-formbody单据体组件)
|
|
8
|
-
- [FormBodyItem](#23-formbodyitem-组件)
|
|
9
|
-
- [FormBodyItemCustom](#24-formBodyItem组件)
|
|
10
|
-
|
|
11
|
-
## 1 版本更新记录
|
|
12
|
-
|
|
13
|
-
## 🌿 0.1.35
|
|
14
|
-
- 新增formBodyItemcustom组件,用来加入插槽内容
|
|
15
|
-
- 单据体加入modelAdditionalProperties属性,用来配置不列出的属性
|
|
16
|
-
- 单据体的复选框可以隐藏
|
|
17
|
-
## 单据体若干bug 0.1.34
|
|
18
|
-
- 单据体复选框永远在左侧,并可选择不显示复选框
|
|
19
|
-
- 基础资料控件弹窗对外开放是否添加到body的选项
|
|
20
|
-
## 🍎 0.1.30
|
|
21
|
-
|
|
22
|
-
⭐ tinput适配单据体封装,加入打开前钩子函数,可选关闭自动属性创建
|
|
23
|
-
|
|
24
|
-
## 🍎 0.1.29
|
|
25
|
-
|
|
26
|
-
⭐ 更新基础资料建议弹框宽度
|
|
27
|
-
|
|
28
|
-
## 🍎 0.1.27
|
|
29
|
-
⭐ 修复基础资料输入控件使用搜索建议后不选定内容,打开弹窗显示了搜索建议
|
|
30
|
-
|
|
31
|
-
⭐ 修复基础资料控件使用搜索建议的时候,会调用两次数据查询接口
|
|
32
|
-
|
|
33
|
-
⭐ 修改工程watch的启动逻辑,启动后立即进行打包和外链,不必等到文件更改
|
|
34
|
-
|
|
35
|
-
## 🍎 0.1.25
|
|
36
|
-
⭐ 修复Tinput基础资料弹窗,因解决单据体抖动的代码导致的数据查询在布局查询之前,从而导致搜索范围限定失效,的,问题
|
|
37
|
-
|
|
38
|
-
## 🍎 0.1.24
|
|
39
|
-
⭐ 1,修复关闭当前页标签缓存异常问题
|
|
40
|
-
|
|
41
|
-
⭐ 2,修复第三版通用列表,表头过滤器不显示的问题
|
|
42
|
-
|
|
43
|
-
## 🍎 0.1.23
|
|
44
|
-
⭐ 1,t-input type = 'group' 控件无法展示分组数据
|
|
45
|
-
|
|
46
|
-
## 🍎 0.1.20
|
|
47
|
-
|
|
48
|
-
⭐ 1.第三版通用列表脱离测试阶段,开始进入使用
|
|
49
|
-
|
|
50
|
-
⭐ 2.通用列表中的防抖指令使用局部引入方式,避免和应用的冲突和重复注册
|
|
51
|
-
|
|
52
|
-
## 🍎 0.1.18
|
|
53
|
-
|
|
54
|
-
⭐ 1.列表表头输入框搜索建议bug修复
|
|
55
|
-
|
|
56
|
-
## 🍎 0.1.7
|
|
57
|
-
|
|
58
|
-
⭐ 1.去除小数,整数组件禁用状态下的Lock图标
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
## 🍎 0.1.6
|
|
62
|
-
|
|
63
|
-
⭐ 1.input组件添加可清空选项
|
|
64
|
-
|
|
65
|
-
⭐ 2.input,select,text-area,date等组件更新禁用状态下输入框的背景色
|
|
66
|
-
|
|
67
|
-
⭐ 3.添加proxy代理以便本地测试组件
|
|
68
|
-
|
|
69
|
-
## 🍎 0.1.5
|
|
70
|
-
|
|
71
|
-
⭐ 1.新增基础资料组件默认值参数
|
|
72
|
-
|
|
73
|
-
## 🍎 0.1.4
|
|
74
|
-
|
|
75
|
-
⭐ 1.新增图片组件
|
|
76
|
-
|
|
77
|
-
## 🍎 0.1.3
|
|
78
|
-
|
|
79
|
-
⭐ 1.优化基础资料组件(默认展示head__name字段,但此字段可控)
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
## 2 组件使用文档
|
|
84
|
-
|
|
85
|
-
### **2.1 tinput组件**
|
|
86
|
-
|
|
87
|
-
此组件包含除了基础资料外的常见基本组件,提供统一的样式,和统一入口,基本配置</br>
|
|
88
|
-
组件默认在el-form表单中使用,也可以在表单之外使用
|
|
89
|
-
|
|
90
|
-
#### (1)基本使用
|
|
91
|
-
|
|
92
|
-
```html
|
|
93
|
-
<el-form :model='form'>
|
|
94
|
-
<!-- 文本输入框 -->
|
|
95
|
-
<Tinput v-model="form.test" title="输入框" type="input" />
|
|
96
|
-
<!-- 文本输入框 input可以省略 -->
|
|
97
|
-
<Tinput v-model="form.test" title="输入框" />
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
<!-- 文本域输入 -->
|
|
101
|
-
<Tinput v-model="form.test2" title="文本" type="text" />
|
|
102
|
-
<!-- 可以通过rows指定文本域的行数,默认3行 -->
|
|
103
|
-
<Tinput v-model="form.test2" title="文本" type="text" :rows='5' />
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
<!-- 日期和日期时间输入 -->
|
|
107
|
-
<Tinput v-model="form.test3" title="日期" type="date" />
|
|
108
|
-
<Tinput v-model="form.test4" title="日期时间" type="datetime" />
|
|
109
|
-
|
|
110
|
-
<!-- 数字输入 数字输入必须保障双向绑定到的属性值是undefined -->
|
|
111
|
-
<Tinput v-model="form.test5" title="整数" type="integer" />
|
|
112
|
-
<Tinput v-model="form.test6" title="小数" type="decimal" :percision='4' />
|
|
113
|
-
|
|
114
|
-
<!-- 选择框 绑定的对象必须{name:null,id:null} 格式-->
|
|
115
|
-
<!-- enumType是获取选项的参数 可查看租户管理枚举配置中获取 -->
|
|
116
|
-
<Tinput v-model="form.test7" title="下拉选择框" type="select" enumType='UP_DOWN'/>
|
|
117
|
-
|
|
118
|
-
<!--基础资料展示字段 用于创建人,创建时间等永远不会被更改的字段,可以节省性能和内存-->
|
|
119
|
-
<Tinput v-model="form.test8" title="基础资料展示字段" type="basicDisplay" />
|
|
120
|
-
<!--使用老版本的通用crud的基础资料,需要提供表名称-->
|
|
121
|
-
<Tinput v-model="form.test9" title="通用的基础资料" type="basicData" :table-config="{enum:tableEnum,name:'b_basic_brand'}"/>
|
|
122
|
-
<!--定制的基础资料 -->
|
|
123
|
-
<Tinput title="定制的基础资料" type="basicCus" >
|
|
124
|
-
<BasicData v-model="form.test10" type='employy' @dataConfirm="handleEmployyConfirm"/>
|
|
125
|
-
</Tinput>
|
|
126
|
-
<!--新的通用列表组成的基础资料组件 target是接口的地址 的一部分,后端用于区分不同表单的依据 -->
|
|
127
|
-
<Tinput title="新版通用基础资料" v-model="form.test8" type="basic" target="/stock/material"></Tinput>
|
|
128
|
-
<!-- 附件上传 -->
|
|
129
|
-
<Tinput v-model="form.test11" label-width="0" type="file" :file-list="fileList"/>
|
|
130
|
-
</el-form>
|
|
131
|
-
```
|
|
132
|
-
|
|
133
|
-
```javascript
|
|
134
|
-
// in vue template file
|
|
135
|
-
data(){
|
|
136
|
-
return {
|
|
137
|
-
// 以下仅仅是解释,对应类型的数据是什么样子,实际开发中也可以不在form中添加对应的属性,tinput 控件会根据绑定的属性自动创建
|
|
138
|
-
// 为了代码的可维护性,在form加入明确的字段是明智的选择
|
|
139
|
-
form:{
|
|
140
|
-
test:null,
|
|
141
|
-
test2:null,
|
|
142
|
-
test3:null,
|
|
143
|
-
test4:null,
|
|
144
|
-
// 数字类型的值初始值必须是undefined
|
|
145
|
-
test5:undefined,
|
|
146
|
-
test6:undefined,
|
|
147
|
-
// 下拉框和基础资料的初始值必须是以下的对象格式
|
|
148
|
-
test7:{name:null,id:null},
|
|
149
|
-
test8:{name:null,id:null},
|
|
150
|
-
test9:{name:null,id:null},
|
|
151
|
-
test10:{name:null,id:null},
|
|
152
|
-
/**
|
|
153
|
-
* 附件类型需要是数组格式
|
|
154
|
-
* v-model:向后端传递的参数
|
|
155
|
-
* fileList:上传附件的列表
|
|
156
|
-
*/
|
|
157
|
-
test11:[],
|
|
158
|
-
},
|
|
159
|
-
// 实际开发中只需要添加一饿空对象即可
|
|
160
|
-
form:{},
|
|
161
|
-
// 附件的文件列表
|
|
162
|
-
fileList:[],
|
|
163
|
-
// 存储tableID的地方
|
|
164
|
-
tableEnum:{
|
|
165
|
-
'b_basic_brand':null
|
|
166
|
-
}
|
|
167
|
-
}
|
|
168
|
-
}
|
|
169
|
-
```
|
|
170
|
-
|
|
171
|
-
#### (2)在表单中加入校验
|
|
172
|
-
|
|
173
|
-
使用方式element一致,对于基础资料和下拉选择框的校验和平时稍有不同
|
|
174
|
-
|
|
175
|
-
```html
|
|
176
|
-
|
|
177
|
-
<el-form model="form" :rules="formRules">
|
|
178
|
-
<Tinput v-model="form.test" title="输入框" prop="test" type="input"/>
|
|
179
|
-
<Tinput v-model="form.test2" title="文本" prop="test2" type="text"/>
|
|
180
|
-
<Tinput v-model="form.test3" title="日期" type="date"/>
|
|
181
|
-
<Tinput v-model="form.test4" title="日期时间" type="datetime"/>
|
|
182
|
-
<Tinput v-model="form.test5" title="整数" type="integer"/>
|
|
183
|
-
<Tinput v-model="form.test6" title="小数" type="decimal"/>
|
|
184
|
-
</el-form>
|
|
185
|
-
```
|
|
186
|
-
|
|
187
|
-
todo:添加校验细节
|
|
188
|
-
|
|
189
|
-
#### (3)其他属性
|
|
190
|
-
|
|
191
|
-
not-form: 不在表单中使用,仅仅是使用控件,忽略prop title等属性
|
|
192
|
-
|
|
193
|
-
entity: 在单据体中使用,添加该属性后,效果也与not-form相同,此外样式上也没有底部边框
|
|
194
|
-
|
|
195
|
-
disabled: 关闭
|
|
196
|
-
|
|
197
|
-
placeholder : 提示信息
|
|
198
|
-
|
|
199
|
-
label-width: 就是label-width,感觉没什么卵用,默认150px
|
|
200
|
-
|
|
201
|
-
notFormBasicAppendBody: tinput基础资料控件的弹窗是否添加到body元素
|
|
202
|
-
|
|
203
|
-
#### (4) 其他说明
|
|
204
|
-
|
|
205
|
-
鉴于基础资料多个租户下不能兼容存在,基础资料的处理没有加入到input组件中
|
|
206
|
-
|
|
207
|
-
但是有basicDisplay类型仅仅用于展示基础资料类型
|
|
208
|
-
|
|
209
|
-
|
|
210
|
-
|
|
211
|
-
### **2.2 FormBody单据体组件**
|
|
212
|
-
|
|
213
|
-
#### 全属性案例
|
|
214
|
-
```html
|
|
215
|
-
<FormBody
|
|
216
|
-
ref="formBodyRef"
|
|
217
|
-
height="40vh"
|
|
218
|
-
:data="data"
|
|
219
|
-
:calculations="calculations"
|
|
220
|
-
:before-add-row="beforeAddRow"
|
|
221
|
-
:after-add-row="afterAddRow"
|
|
222
|
-
>
|
|
223
|
-
<FormBodyItem
|
|
224
|
-
title="所在省"
|
|
225
|
-
field="province"
|
|
226
|
-
type="basic"
|
|
227
|
-
target="/basic/province"
|
|
228
|
-
:before-input="beforeProvinceInput"
|
|
229
|
-
:after-basic-selected="afterProvinceSelected"
|
|
230
|
-
/>
|
|
231
|
-
<FormBodyItem
|
|
232
|
-
title="邮政编码"
|
|
233
|
-
field="code"
|
|
234
|
-
disabled
|
|
235
|
-
/>
|
|
236
|
-
<FormBodyItem
|
|
237
|
-
title="所在市"
|
|
238
|
-
field="city"
|
|
239
|
-
type="basic"
|
|
240
|
-
target="/basic/city"
|
|
241
|
-
:limitation="[{key:'inProvince',value:'province',type:'field'}]"
|
|
242
|
-
/>
|
|
243
|
-
<!-- precision默认值是2 -->
|
|
244
|
-
<FormBodyItem title="数量" field="number" type="decimal" :percision="4" />
|
|
245
|
-
<FormBodyItem title="单价" field="price" type="decimal" :percision="2" />
|
|
246
|
-
<FormBodyItem title="总额" field="amount" type="decimal" :percision="2" />
|
|
247
|
-
<FormBodyItem title="是否启用" field="isActive" type="select" enum-type='YES_OR_NO'/>
|
|
248
|
-
<!-- 默认类型就是input,可以省略 -->
|
|
249
|
-
<FormBodyItem title="姓名" field="name" type="input" />
|
|
250
|
-
<FormBodyItem title="出生日期" field="birthDate" type="date" />
|
|
251
|
-
<FormBodyItem title="审核时间" field="auditTime" type="datetime" />
|
|
252
|
-
<!--
|
|
253
|
-
对于一些需要操作列,即没有实际数据的列,常见于列的相关操作
|
|
254
|
-
不要使用ux-table-column,会导致不能将字段添加到模版,新增行属性不全面
|
|
255
|
-
使用formBodyItemCustom
|
|
256
|
-
|
|
257
|
-
不要在这属性上添加field属性,对于custom组件来说,这是一个无效的属性
|
|
258
|
-
-->
|
|
259
|
-
<FormBodyItemCustom title="操作">
|
|
260
|
-
<template v-slot="{row}">
|
|
261
|
-
<el-button type="danger" size="mini" @click="deleteRow(row.id)">删除</el-button>
|
|
262
|
-
</template>
|
|
263
|
-
</FormBodyItemCustom>
|
|
264
|
-
|
|
265
|
-
<!-- 插槽 -->
|
|
266
|
-
<template v-slot:buttons="{currentRow}">
|
|
267
|
-
<el-button @click="dialogVisible = true">使用说明</el-button>
|
|
268
|
-
<!-- 这个弹窗可以不放在插槽中,如果需要访问scope中的数据,也可以通过函数的参数来传递-->
|
|
269
|
-
<el-dialog :visible.sync="dialogVisible">
|
|
270
|
-
<div class="dialog-content">
|
|
271
|
-
<span>大概率,这个地方可能还会要一些数据的</span>
|
|
272
|
-
<p>
|
|
273
|
-
注意:因为在template模版中,js的编译没有使用转译,所以不能使用可选链(?.)高级语法
|
|
274
|
-
而且当前作用域的空指针报错,会直接导致子组件不渲染
|
|
275
|
-
在访问插槽作用域属性时,要考虑空指针问题,建议使用如下方式避免
|
|
276
|
-
</p>
|
|
277
|
-
<span>{{ currentRow && currentRow.material }}</span>
|
|
278
|
-
</div>
|
|
279
|
-
</el-dialog>
|
|
280
|
-
</template>
|
|
281
|
-
</Formbody>
|
|
282
|
-
```
|
|
283
|
-
```javascript
|
|
284
|
-
export default {
|
|
285
|
-
data(){
|
|
286
|
-
return {
|
|
287
|
-
caculations:{
|
|
288
|
-
amount:'#{number} * #{price}'
|
|
289
|
-
}
|
|
290
|
-
|
|
291
|
-
}
|
|
292
|
-
},
|
|
293
|
-
methods:{
|
|
294
|
-
beforePrivinceInput(done){
|
|
295
|
-
if(some condition){
|
|
296
|
-
done()
|
|
297
|
-
}
|
|
298
|
-
},
|
|
299
|
-
afterPrinvceSelected(row,selected){
|
|
300
|
-
row.code = selected.code
|
|
301
|
-
}
|
|
302
|
-
|
|
303
|
-
}
|
|
304
|
-
}
|
|
305
|
-
|
|
306
|
-
```
|
|
307
|
-
|
|
308
|
-
#### props
|
|
309
|
-
- **data:Array** 编辑的列表数据,编辑的目标数据
|
|
310
|
-
- **disalbeButtons:Array['add','del']** 不需要显示的按钮,和关闭的功能耦合了
|
|
311
|
-
- **height** 列表的高度,支持vh 和px,其中px作为单位的时候可以省略
|
|
312
|
-
- **calculations** 列表行字段之间的计算关联 数学表达式
|
|
313
|
-
- **before-add-row:function(row)** 添加数据行(点击单据体新增按钮)之前执行
|
|
314
|
-
- **after-add-row:function(row)** 添加数据行之后执行
|
|
315
|
-
- **disable-checked:boolean** 不显示单据体复选框
|
|
316
|
-
- **disable-sum:boolean** 关闭底部合计行
|
|
317
|
-
- **rules:Array** 单据体校验规则,格式和el-form的校验规则保持一致
|
|
318
|
-
|
|
319
|
-
#### data
|
|
320
|
-
data中有的数据可以直接获取,没有提供方法<br>
|
|
321
|
-
例如:this.$refs.xxx.deleteIds<br>
|
|
322
|
-
- **deleteIds** 单据体中被删除的数据的id,这个id是存入数据库的id,点击新增行生成的数据没有id,删除的时候也不会添加到deleteIds
|
|
323
|
-
|
|
324
|
-
|
|
325
|
-
#### methods
|
|
326
|
-
- **getFormateData(filter)** : 输出格式化之后的数据 <br>
|
|
327
|
-
参数是可选的函数类型,参数是row,其实就是Array.filter中的参数形式,函数的返回值为true的结果,将会被输出到结果中<br>
|
|
328
|
-
默认的过滤行为是:一行中所有的字段的值,都是false等价的值,那么将不会输出
|
|
329
|
-
- **calculate(row)** 针对某一行,重新进行列之间的数学表达式计算
|
|
330
|
-
- **calculateRow(rows)** 批量进行计算
|
|
331
|
-
- **validate** 对整个单据体进行校验,在调用后端接口保存数据之前进行调用,校验通过返回true,失败返回false,并会自动提示错误信息
|
|
332
|
-
|
|
333
|
-
### **2.3 FormBodyItem** 组件
|
|
334
|
-
|
|
335
|
-
#### props
|
|
336
|
-
- 列属性
|
|
337
|
-
- **title:string** 可编辑列表的列标题,
|
|
338
|
-
- **field:string** 数据模型的字段
|
|
339
|
-
- **width:string** 列的默认宽度
|
|
340
|
-
- **readOnly:boolean** 不可编辑列
|
|
341
|
-
- **sum** 当前列需要进行合计,开启这个功能的列,必须是数值类型 type= 'integer/decimal'
|
|
342
|
-
- 控件属性 (主要是tiput 属性的再封装)
|
|
343
|
-
- **type:string** 编辑状态下的输入控件类型,具体参考tinput<br>
|
|
344
|
-
强烈不建议在单据体中使用text文本域
|
|
345
|
-
- **disable:boolean** tinput 属性,禁用
|
|
346
|
-
- **placeholder:string** tinput 属性,占位符内容
|
|
347
|
-
- **target:string** 言午的基础资料控件,发送请求必须的参数
|
|
348
|
-
- **limitations:Array** 言午的基础资料属性,限定基础资料的查询范围
|
|
349
|
-
- **afterBaiscSelected:Function(currentRow,selected)** 基础资料单选或者多选之后要执行的动作 <br>
|
|
350
|
-
- 使用场景:<br>
|
|
351
|
-
当基础资料选择单行或者多行后,,会自动修改当前行并填充下面的行<br>
|
|
352
|
-
这个过程中,被新添加的行(也包括被修改的行),因为业务需求,可能会根据选中的基础资料,调用一些接口,来获取行中另外一些字段的数据<br>
|
|
353
|
-
可以将这个业务行为通过函数来确定,fucntion(selectedRows)<br>
|
|
354
|
-
这个钩子函数可以是异步的,建议 属性携带的业务,放到同步中,但是需要访问接口查询的数据放到异步中
|
|
355
|
-
- 注意事项<br>
|
|
356
|
-
多选行为会导致插入新的数据行
|
|
357
|
-
|
|
358
|
-
这个插入数据行会触发单据体的after-add-row的钩子函数
|
|
359
|
-
|
|
360
|
-
因为多个操作同时操作单据体数据,可能存在冲突
|
|
361
|
-
```javascript
|
|
362
|
-
const after-add-row = function(row){
|
|
363
|
-
row.number = 3
|
|
364
|
-
}
|
|
365
|
-
```
|
|
366
|
-
```javascript
|
|
367
|
-
const after-basic-selected = function(row,selectedRow){
|
|
368
|
-
row.name = selectedRow.name
|
|
369
|
-
row.number = 3
|
|
370
|
-
}
|
|
371
|
-
|
|
372
|
-
```
|
|
373
|
-
所以如果要减弱了各个钩子函数之间互相影响,开启单据体的disableAffterAddRowAlways
|
|
374
|
-
|
|
375
|
-
但是开启这个属性后,除了点击新增行按钮之外,其他地方不会触发after-add-row 钩子
|
|
376
|
-
|
|
377
|
-
|
|
378
|
-
- **beforeInput:Function** 编辑状态下输入前要进行的钩子,但是目前只有言午的基础资料控件提供了实现,basic,其他的控件不生效
|
|
379
|
-
- **enumType:string** 枚举类型的获取枚举值的接口参数
|
|
380
|
-
- **percision** 小数保留的位数
|
|
381
|
-
#### event
|
|
382
|
-
- change => function(row,value) 值发生改变
|
|
383
|
-
- delete => function(row) 基础资料的删除事件
|
|
384
|
-
|
|
385
|
-
#### methods
|
|
386
|
-
|
|
387
|
-
### **2.4 FormBodyItemCustom组件**
|
|
388
|
-
该组件的源码,仅仅提供一个插槽,通过插槽来定义一些右侧的操作类型的固定列<br>
|
|
389
|
-
也可以指定field和title等字段,也会显示出来相关的数据<br>
|
|
390
|
-
但是这个组件指定列,在新增行的时候,不会给新行添加field相关的属性<br>
|
|
391
|
-
如果需要每一行都有额外的属性(不在formBodyItem中,即不需要显示出来)<br>
|
|
392
|
-
有两种方式,一个是通过affterAddRow来进行动态添加属性(不建议)<br>
|
|
393
|
-
另一种是通过modelAddtionalProperties的formbody属性来添加<br>
|
|
394
|
-
|
|
395
|
-
|
|
1
|
+
# TF-Widget
|
|
2
|
+
|
|
3
|
+
## 目录
|
|
4
|
+
- [版本更新说明](#1-版本更新记录)
|
|
5
|
+
- [使用文档](#2-组件使用文档)
|
|
6
|
+
- [tinput](#21-tinput组件)
|
|
7
|
+
- [FormBody](#22-formbody单据体组件)
|
|
8
|
+
- [FormBodyItem](#23-formbodyitem-组件)
|
|
9
|
+
- [FormBodyItemCustom](#24-formBodyItem组件)
|
|
10
|
+
|
|
11
|
+
## 1 版本更新记录
|
|
12
|
+
|
|
13
|
+
## 🌿 0.1.35
|
|
14
|
+
- 新增formBodyItemcustom组件,用来加入插槽内容
|
|
15
|
+
- 单据体加入modelAdditionalProperties属性,用来配置不列出的属性
|
|
16
|
+
- 单据体的复选框可以隐藏
|
|
17
|
+
## 单据体若干bug 0.1.34
|
|
18
|
+
- 单据体复选框永远在左侧,并可选择不显示复选框
|
|
19
|
+
- 基础资料控件弹窗对外开放是否添加到body的选项
|
|
20
|
+
## 🍎 0.1.30
|
|
21
|
+
|
|
22
|
+
⭐ tinput适配单据体封装,加入打开前钩子函数,可选关闭自动属性创建
|
|
23
|
+
|
|
24
|
+
## 🍎 0.1.29
|
|
25
|
+
|
|
26
|
+
⭐ 更新基础资料建议弹框宽度
|
|
27
|
+
|
|
28
|
+
## 🍎 0.1.27
|
|
29
|
+
⭐ 修复基础资料输入控件使用搜索建议后不选定内容,打开弹窗显示了搜索建议
|
|
30
|
+
|
|
31
|
+
⭐ 修复基础资料控件使用搜索建议的时候,会调用两次数据查询接口
|
|
32
|
+
|
|
33
|
+
⭐ 修改工程watch的启动逻辑,启动后立即进行打包和外链,不必等到文件更改
|
|
34
|
+
|
|
35
|
+
## 🍎 0.1.25
|
|
36
|
+
⭐ 修复Tinput基础资料弹窗,因解决单据体抖动的代码导致的数据查询在布局查询之前,从而导致搜索范围限定失效,的,问题
|
|
37
|
+
|
|
38
|
+
## 🍎 0.1.24
|
|
39
|
+
⭐ 1,修复关闭当前页标签缓存异常问题
|
|
40
|
+
|
|
41
|
+
⭐ 2,修复第三版通用列表,表头过滤器不显示的问题
|
|
42
|
+
|
|
43
|
+
## 🍎 0.1.23
|
|
44
|
+
⭐ 1,t-input type = 'group' 控件无法展示分组数据
|
|
45
|
+
|
|
46
|
+
## 🍎 0.1.20
|
|
47
|
+
|
|
48
|
+
⭐ 1.第三版通用列表脱离测试阶段,开始进入使用
|
|
49
|
+
|
|
50
|
+
⭐ 2.通用列表中的防抖指令使用局部引入方式,避免和应用的冲突和重复注册
|
|
51
|
+
|
|
52
|
+
## 🍎 0.1.18
|
|
53
|
+
|
|
54
|
+
⭐ 1.列表表头输入框搜索建议bug修复
|
|
55
|
+
|
|
56
|
+
## 🍎 0.1.7
|
|
57
|
+
|
|
58
|
+
⭐ 1.去除小数,整数组件禁用状态下的Lock图标
|
|
59
|
+
|
|
60
|
+
|
|
61
|
+
## 🍎 0.1.6
|
|
62
|
+
|
|
63
|
+
⭐ 1.input组件添加可清空选项
|
|
64
|
+
|
|
65
|
+
⭐ 2.input,select,text-area,date等组件更新禁用状态下输入框的背景色
|
|
66
|
+
|
|
67
|
+
⭐ 3.添加proxy代理以便本地测试组件
|
|
68
|
+
|
|
69
|
+
## 🍎 0.1.5
|
|
70
|
+
|
|
71
|
+
⭐ 1.新增基础资料组件默认值参数
|
|
72
|
+
|
|
73
|
+
## 🍎 0.1.4
|
|
74
|
+
|
|
75
|
+
⭐ 1.新增图片组件
|
|
76
|
+
|
|
77
|
+
## 🍎 0.1.3
|
|
78
|
+
|
|
79
|
+
⭐ 1.优化基础资料组件(默认展示head__name字段,但此字段可控)
|
|
80
|
+
|
|
81
|
+
|
|
82
|
+
|
|
83
|
+
## 2 组件使用文档
|
|
84
|
+
|
|
85
|
+
### **2.1 tinput组件**
|
|
86
|
+
|
|
87
|
+
此组件包含除了基础资料外的常见基本组件,提供统一的样式,和统一入口,基本配置</br>
|
|
88
|
+
组件默认在el-form表单中使用,也可以在表单之外使用
|
|
89
|
+
|
|
90
|
+
#### (1)基本使用
|
|
91
|
+
|
|
92
|
+
```html
|
|
93
|
+
<el-form :model='form'>
|
|
94
|
+
<!-- 文本输入框 -->
|
|
95
|
+
<Tinput v-model="form.test" title="输入框" type="input" />
|
|
96
|
+
<!-- 文本输入框 input可以省略 -->
|
|
97
|
+
<Tinput v-model="form.test" title="输入框" />
|
|
98
|
+
|
|
99
|
+
|
|
100
|
+
<!-- 文本域输入 -->
|
|
101
|
+
<Tinput v-model="form.test2" title="文本" type="text" />
|
|
102
|
+
<!-- 可以通过rows指定文本域的行数,默认3行 -->
|
|
103
|
+
<Tinput v-model="form.test2" title="文本" type="text" :rows='5' />
|
|
104
|
+
|
|
105
|
+
|
|
106
|
+
<!-- 日期和日期时间输入 -->
|
|
107
|
+
<Tinput v-model="form.test3" title="日期" type="date" />
|
|
108
|
+
<Tinput v-model="form.test4" title="日期时间" type="datetime" />
|
|
109
|
+
|
|
110
|
+
<!-- 数字输入 数字输入必须保障双向绑定到的属性值是undefined -->
|
|
111
|
+
<Tinput v-model="form.test5" title="整数" type="integer" />
|
|
112
|
+
<Tinput v-model="form.test6" title="小数" type="decimal" :percision='4' />
|
|
113
|
+
|
|
114
|
+
<!-- 选择框 绑定的对象必须{name:null,id:null} 格式-->
|
|
115
|
+
<!-- enumType是获取选项的参数 可查看租户管理枚举配置中获取 -->
|
|
116
|
+
<Tinput v-model="form.test7" title="下拉选择框" type="select" enumType='UP_DOWN'/>
|
|
117
|
+
|
|
118
|
+
<!--基础资料展示字段 用于创建人,创建时间等永远不会被更改的字段,可以节省性能和内存-->
|
|
119
|
+
<Tinput v-model="form.test8" title="基础资料展示字段" type="basicDisplay" />
|
|
120
|
+
<!--使用老版本的通用crud的基础资料,需要提供表名称-->
|
|
121
|
+
<Tinput v-model="form.test9" title="通用的基础资料" type="basicData" :table-config="{enum:tableEnum,name:'b_basic_brand'}"/>
|
|
122
|
+
<!--定制的基础资料 -->
|
|
123
|
+
<Tinput title="定制的基础资料" type="basicCus" >
|
|
124
|
+
<BasicData v-model="form.test10" type='employy' @dataConfirm="handleEmployyConfirm"/>
|
|
125
|
+
</Tinput>
|
|
126
|
+
<!--新的通用列表组成的基础资料组件 target是接口的地址 的一部分,后端用于区分不同表单的依据 -->
|
|
127
|
+
<Tinput title="新版通用基础资料" v-model="form.test8" type="basic" target="/stock/material"></Tinput>
|
|
128
|
+
<!-- 附件上传 -->
|
|
129
|
+
<Tinput v-model="form.test11" label-width="0" type="file" :file-list="fileList"/>
|
|
130
|
+
</el-form>
|
|
131
|
+
```
|
|
132
|
+
|
|
133
|
+
```javascript
|
|
134
|
+
// in vue template file
|
|
135
|
+
data(){
|
|
136
|
+
return {
|
|
137
|
+
// 以下仅仅是解释,对应类型的数据是什么样子,实际开发中也可以不在form中添加对应的属性,tinput 控件会根据绑定的属性自动创建
|
|
138
|
+
// 为了代码的可维护性,在form加入明确的字段是明智的选择
|
|
139
|
+
form:{
|
|
140
|
+
test:null,
|
|
141
|
+
test2:null,
|
|
142
|
+
test3:null,
|
|
143
|
+
test4:null,
|
|
144
|
+
// 数字类型的值初始值必须是undefined
|
|
145
|
+
test5:undefined,
|
|
146
|
+
test6:undefined,
|
|
147
|
+
// 下拉框和基础资料的初始值必须是以下的对象格式
|
|
148
|
+
test7:{name:null,id:null},
|
|
149
|
+
test8:{name:null,id:null},
|
|
150
|
+
test9:{name:null,id:null},
|
|
151
|
+
test10:{name:null,id:null},
|
|
152
|
+
/**
|
|
153
|
+
* 附件类型需要是数组格式
|
|
154
|
+
* v-model:向后端传递的参数
|
|
155
|
+
* fileList:上传附件的列表
|
|
156
|
+
*/
|
|
157
|
+
test11:[],
|
|
158
|
+
},
|
|
159
|
+
// 实际开发中只需要添加一饿空对象即可
|
|
160
|
+
form:{},
|
|
161
|
+
// 附件的文件列表
|
|
162
|
+
fileList:[],
|
|
163
|
+
// 存储tableID的地方
|
|
164
|
+
tableEnum:{
|
|
165
|
+
'b_basic_brand':null
|
|
166
|
+
}
|
|
167
|
+
}
|
|
168
|
+
}
|
|
169
|
+
```
|
|
170
|
+
|
|
171
|
+
#### (2)在表单中加入校验
|
|
172
|
+
|
|
173
|
+
使用方式element一致,对于基础资料和下拉选择框的校验和平时稍有不同
|
|
174
|
+
|
|
175
|
+
```html
|
|
176
|
+
|
|
177
|
+
<el-form model="form" :rules="formRules">
|
|
178
|
+
<Tinput v-model="form.test" title="输入框" prop="test" type="input"/>
|
|
179
|
+
<Tinput v-model="form.test2" title="文本" prop="test2" type="text"/>
|
|
180
|
+
<Tinput v-model="form.test3" title="日期" type="date"/>
|
|
181
|
+
<Tinput v-model="form.test4" title="日期时间" type="datetime"/>
|
|
182
|
+
<Tinput v-model="form.test5" title="整数" type="integer"/>
|
|
183
|
+
<Tinput v-model="form.test6" title="小数" type="decimal"/>
|
|
184
|
+
</el-form>
|
|
185
|
+
```
|
|
186
|
+
|
|
187
|
+
todo:添加校验细节
|
|
188
|
+
|
|
189
|
+
#### (3)其他属性
|
|
190
|
+
|
|
191
|
+
not-form: 不在表单中使用,仅仅是使用控件,忽略prop title等属性
|
|
192
|
+
|
|
193
|
+
entity: 在单据体中使用,添加该属性后,效果也与not-form相同,此外样式上也没有底部边框
|
|
194
|
+
|
|
195
|
+
disabled: 关闭
|
|
196
|
+
|
|
197
|
+
placeholder : 提示信息
|
|
198
|
+
|
|
199
|
+
label-width: 就是label-width,感觉没什么卵用,默认150px
|
|
200
|
+
|
|
201
|
+
notFormBasicAppendBody: tinput基础资料控件的弹窗是否添加到body元素
|
|
202
|
+
|
|
203
|
+
#### (4) 其他说明
|
|
204
|
+
|
|
205
|
+
鉴于基础资料多个租户下不能兼容存在,基础资料的处理没有加入到input组件中
|
|
206
|
+
|
|
207
|
+
但是有basicDisplay类型仅仅用于展示基础资料类型
|
|
208
|
+
|
|
209
|
+
|
|
210
|
+
|
|
211
|
+
### **2.2 FormBody单据体组件**
|
|
212
|
+
|
|
213
|
+
#### 全属性案例
|
|
214
|
+
```html
|
|
215
|
+
<FormBody
|
|
216
|
+
ref="formBodyRef"
|
|
217
|
+
height="40vh"
|
|
218
|
+
:data="data"
|
|
219
|
+
:calculations="calculations"
|
|
220
|
+
:before-add-row="beforeAddRow"
|
|
221
|
+
:after-add-row="afterAddRow"
|
|
222
|
+
>
|
|
223
|
+
<FormBodyItem
|
|
224
|
+
title="所在省"
|
|
225
|
+
field="province"
|
|
226
|
+
type="basic"
|
|
227
|
+
target="/basic/province"
|
|
228
|
+
:before-input="beforeProvinceInput"
|
|
229
|
+
:after-basic-selected="afterProvinceSelected"
|
|
230
|
+
/>
|
|
231
|
+
<FormBodyItem
|
|
232
|
+
title="邮政编码"
|
|
233
|
+
field="code"
|
|
234
|
+
disabled
|
|
235
|
+
/>
|
|
236
|
+
<FormBodyItem
|
|
237
|
+
title="所在市"
|
|
238
|
+
field="city"
|
|
239
|
+
type="basic"
|
|
240
|
+
target="/basic/city"
|
|
241
|
+
:limitation="[{key:'inProvince',value:'province',type:'field'}]"
|
|
242
|
+
/>
|
|
243
|
+
<!-- precision默认值是2 -->
|
|
244
|
+
<FormBodyItem title="数量" field="number" type="decimal" :percision="4" />
|
|
245
|
+
<FormBodyItem title="单价" field="price" type="decimal" :percision="2" />
|
|
246
|
+
<FormBodyItem title="总额" field="amount" type="decimal" :percision="2" />
|
|
247
|
+
<FormBodyItem title="是否启用" field="isActive" type="select" enum-type='YES_OR_NO'/>
|
|
248
|
+
<!-- 默认类型就是input,可以省略 -->
|
|
249
|
+
<FormBodyItem title="姓名" field="name" type="input" />
|
|
250
|
+
<FormBodyItem title="出生日期" field="birthDate" type="date" />
|
|
251
|
+
<FormBodyItem title="审核时间" field="auditTime" type="datetime" />
|
|
252
|
+
<!--
|
|
253
|
+
对于一些需要操作列,即没有实际数据的列,常见于列的相关操作
|
|
254
|
+
不要使用ux-table-column,会导致不能将字段添加到模版,新增行属性不全面
|
|
255
|
+
使用formBodyItemCustom
|
|
256
|
+
|
|
257
|
+
不要在这属性上添加field属性,对于custom组件来说,这是一个无效的属性
|
|
258
|
+
-->
|
|
259
|
+
<FormBodyItemCustom title="操作">
|
|
260
|
+
<template v-slot="{row}">
|
|
261
|
+
<el-button type="danger" size="mini" @click="deleteRow(row.id)">删除</el-button>
|
|
262
|
+
</template>
|
|
263
|
+
</FormBodyItemCustom>
|
|
264
|
+
|
|
265
|
+
<!-- 插槽 -->
|
|
266
|
+
<template v-slot:buttons="{currentRow}">
|
|
267
|
+
<el-button @click="dialogVisible = true">使用说明</el-button>
|
|
268
|
+
<!-- 这个弹窗可以不放在插槽中,如果需要访问scope中的数据,也可以通过函数的参数来传递-->
|
|
269
|
+
<el-dialog :visible.sync="dialogVisible">
|
|
270
|
+
<div class="dialog-content">
|
|
271
|
+
<span>大概率,这个地方可能还会要一些数据的</span>
|
|
272
|
+
<p>
|
|
273
|
+
注意:因为在template模版中,js的编译没有使用转译,所以不能使用可选链(?.)高级语法
|
|
274
|
+
而且当前作用域的空指针报错,会直接导致子组件不渲染
|
|
275
|
+
在访问插槽作用域属性时,要考虑空指针问题,建议使用如下方式避免
|
|
276
|
+
</p>
|
|
277
|
+
<span>{{ currentRow && currentRow.material }}</span>
|
|
278
|
+
</div>
|
|
279
|
+
</el-dialog>
|
|
280
|
+
</template>
|
|
281
|
+
</Formbody>
|
|
282
|
+
```
|
|
283
|
+
```javascript
|
|
284
|
+
export default {
|
|
285
|
+
data(){
|
|
286
|
+
return {
|
|
287
|
+
caculations:{
|
|
288
|
+
amount:'#{number} * #{price}'
|
|
289
|
+
}
|
|
290
|
+
|
|
291
|
+
}
|
|
292
|
+
},
|
|
293
|
+
methods:{
|
|
294
|
+
beforePrivinceInput(done){
|
|
295
|
+
if(some condition){
|
|
296
|
+
done()
|
|
297
|
+
}
|
|
298
|
+
},
|
|
299
|
+
afterPrinvceSelected(row,selected){
|
|
300
|
+
row.code = selected.code
|
|
301
|
+
}
|
|
302
|
+
|
|
303
|
+
}
|
|
304
|
+
}
|
|
305
|
+
|
|
306
|
+
```
|
|
307
|
+
|
|
308
|
+
#### props
|
|
309
|
+
- **data:Array** 编辑的列表数据,编辑的目标数据
|
|
310
|
+
- **disalbeButtons:Array['add','del']** 不需要显示的按钮,和关闭的功能耦合了
|
|
311
|
+
- **height** 列表的高度,支持vh 和px,其中px作为单位的时候可以省略
|
|
312
|
+
- **calculations** 列表行字段之间的计算关联 数学表达式
|
|
313
|
+
- **before-add-row:function(row)** 添加数据行(点击单据体新增按钮)之前执行
|
|
314
|
+
- **after-add-row:function(row)** 添加数据行之后执行
|
|
315
|
+
- **disable-checked:boolean** 不显示单据体复选框
|
|
316
|
+
- **disable-sum:boolean** 关闭底部合计行
|
|
317
|
+
- **rules:Array** 单据体校验规则,格式和el-form的校验规则保持一致
|
|
318
|
+
|
|
319
|
+
#### data
|
|
320
|
+
data中有的数据可以直接获取,没有提供方法<br>
|
|
321
|
+
例如:this.$refs.xxx.deleteIds<br>
|
|
322
|
+
- **deleteIds** 单据体中被删除的数据的id,这个id是存入数据库的id,点击新增行生成的数据没有id,删除的时候也不会添加到deleteIds
|
|
323
|
+
|
|
324
|
+
|
|
325
|
+
#### methods
|
|
326
|
+
- **getFormateData(filter)** : 输出格式化之后的数据 <br>
|
|
327
|
+
参数是可选的函数类型,参数是row,其实就是Array.filter中的参数形式,函数的返回值为true的结果,将会被输出到结果中<br>
|
|
328
|
+
默认的过滤行为是:一行中所有的字段的值,都是false等价的值,那么将不会输出
|
|
329
|
+
- **calculate(row)** 针对某一行,重新进行列之间的数学表达式计算
|
|
330
|
+
- **calculateRow(rows)** 批量进行计算
|
|
331
|
+
- **validate** 对整个单据体进行校验,在调用后端接口保存数据之前进行调用,校验通过返回true,失败返回false,并会自动提示错误信息
|
|
332
|
+
|
|
333
|
+
### **2.3 FormBodyItem** 组件
|
|
334
|
+
|
|
335
|
+
#### props
|
|
336
|
+
- 列属性
|
|
337
|
+
- **title:string** 可编辑列表的列标题,
|
|
338
|
+
- **field:string** 数据模型的字段
|
|
339
|
+
- **width:string** 列的默认宽度
|
|
340
|
+
- **readOnly:boolean** 不可编辑列
|
|
341
|
+
- **sum** 当前列需要进行合计,开启这个功能的列,必须是数值类型 type= 'integer/decimal'
|
|
342
|
+
- 控件属性 (主要是tiput 属性的再封装)
|
|
343
|
+
- **type:string** 编辑状态下的输入控件类型,具体参考tinput<br>
|
|
344
|
+
强烈不建议在单据体中使用text文本域
|
|
345
|
+
- **disable:boolean** tinput 属性,禁用
|
|
346
|
+
- **placeholder:string** tinput 属性,占位符内容
|
|
347
|
+
- **target:string** 言午的基础资料控件,发送请求必须的参数
|
|
348
|
+
- **limitations:Array** 言午的基础资料属性,限定基础资料的查询范围
|
|
349
|
+
- **afterBaiscSelected:Function(currentRow,selected)** 基础资料单选或者多选之后要执行的动作 <br>
|
|
350
|
+
- 使用场景:<br>
|
|
351
|
+
当基础资料选择单行或者多行后,,会自动修改当前行并填充下面的行<br>
|
|
352
|
+
这个过程中,被新添加的行(也包括被修改的行),因为业务需求,可能会根据选中的基础资料,调用一些接口,来获取行中另外一些字段的数据<br>
|
|
353
|
+
可以将这个业务行为通过函数来确定,fucntion(selectedRows)<br>
|
|
354
|
+
这个钩子函数可以是异步的,建议 属性携带的业务,放到同步中,但是需要访问接口查询的数据放到异步中
|
|
355
|
+
- 注意事项<br>
|
|
356
|
+
多选行为会导致插入新的数据行
|
|
357
|
+
|
|
358
|
+
这个插入数据行会触发单据体的after-add-row的钩子函数
|
|
359
|
+
|
|
360
|
+
因为多个操作同时操作单据体数据,可能存在冲突
|
|
361
|
+
```javascript
|
|
362
|
+
const after-add-row = function(row){
|
|
363
|
+
row.number = 3
|
|
364
|
+
}
|
|
365
|
+
```
|
|
366
|
+
```javascript
|
|
367
|
+
const after-basic-selected = function(row,selectedRow){
|
|
368
|
+
row.name = selectedRow.name
|
|
369
|
+
row.number = 3
|
|
370
|
+
}
|
|
371
|
+
|
|
372
|
+
```
|
|
373
|
+
所以如果要减弱了各个钩子函数之间互相影响,开启单据体的disableAffterAddRowAlways
|
|
374
|
+
|
|
375
|
+
但是开启这个属性后,除了点击新增行按钮之外,其他地方不会触发after-add-row 钩子
|
|
376
|
+
|
|
377
|
+
|
|
378
|
+
- **beforeInput:Function** 编辑状态下输入前要进行的钩子,但是目前只有言午的基础资料控件提供了实现,basic,其他的控件不生效
|
|
379
|
+
- **enumType:string** 枚举类型的获取枚举值的接口参数
|
|
380
|
+
- **percision** 小数保留的位数
|
|
381
|
+
#### event
|
|
382
|
+
- change => function(row,value) 值发生改变
|
|
383
|
+
- delete => function(row) 基础资料的删除事件
|
|
384
|
+
|
|
385
|
+
#### methods
|
|
386
|
+
|
|
387
|
+
### **2.4 FormBodyItemCustom组件**
|
|
388
|
+
该组件的源码,仅仅提供一个插槽,通过插槽来定义一些右侧的操作类型的固定列<br>
|
|
389
|
+
也可以指定field和title等字段,也会显示出来相关的数据<br>
|
|
390
|
+
但是这个组件指定列,在新增行的时候,不会给新行添加field相关的属性<br>
|
|
391
|
+
如果需要每一行都有额外的属性(不在formBodyItem中,即不需要显示出来)<br>
|
|
392
|
+
有两种方式,一个是通过affterAddRow来进行动态添加属性(不建议)<br>
|
|
393
|
+
另一种是通过modelAddtionalProperties的formbody属性来添加<br>
|
|
394
|
+
|
|
395
|
+
|