@tongfun/tf-widget 0.1.4 → 0.1.8-beta

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.
Files changed (35) hide show
  1. package/.browserslistrc +3 -3
  2. package/.editorconfig +5 -5
  3. package/.eslintrc.js +17 -17
  4. package/README.md +36 -24
  5. package/dist/css/chunk-vendors.a16c4353.css +1 -0
  6. package/dist/css/index.f35459d8.css +1 -0
  7. package/dist/fonts/element-icons.535877f5.woff +0 -0
  8. package/dist/fonts/element-icons.732389de.ttf +0 -0
  9. package/dist/js/chunk-vendors.c86d3e60.js +41 -0
  10. package/dist/js/index.36f35563.js +1 -0
  11. package/lib/tf-widget.common.js +1461 -357
  12. package/lib/tf-widget.css +1 -1
  13. package/lib/tf-widget.umd.js +1461 -357
  14. package/lib/tf-widget.umd.min.js +3 -3
  15. package/package/tf-layout/README.md +2 -0
  16. package/package/tf-layout/index.js +8 -0
  17. package/package/tf-layout/src/components/tf-labelbar.vue +361 -0
  18. package/package/tf-layout/src/components/tf-menu.vue +167 -0
  19. package/package/tf-layout/src/components/tf-right-menu.vue +89 -0
  20. package/package/tf-layout/src/components/tf-rotate-box.vue +50 -0
  21. package/package/tf-layout/src/tf-layout.vue +104 -0
  22. package/package/tf-widget/src/assets/common-input.less +11 -0
  23. package/package/tf-widget/src/children/basic-data/basic-data.vue +31 -4
  24. package/package/tf-widget/src/children/date-time.vue +1 -1
  25. package/package/tf-widget/src/children/date.vue +1 -0
  26. package/package/tf-widget/src/children/decimal.vue +20 -1
  27. package/package/tf-widget/src/children/integer.vue +31 -12
  28. package/package/tf-widget/src/children/single-line-text.vue +15 -7
  29. package/package/tf-widget/src/children/small-pictures.vue +5 -1
  30. package/package/tf-widget/src/children/text-area.vue +5 -4
  31. package/package/tf-widget/src/children/tf-select.vue +16 -7
  32. package/package.json +1 -1
  33. package/postinstall.js +10 -10
  34. package/src/index.js +5 -3
  35. package/src/utils/request.js +4 -1
@@ -0,0 +1,104 @@
1
+ <template>
2
+ <div class="tf-layout">
3
+ <TfMenu :menu-info="menuInfo" />
4
+ <div class="tf-layout-subject">
5
+ <TfLaberBar @setCache="setCache" @deleteCache="deleteCache" />
6
+ <div class="tf-layout-subject-content">
7
+ <keep-alive :include="secondCacheArray">
8
+ <router-view />
9
+ </keep-alive>
10
+ </div>
11
+ </div>
12
+ </div>
13
+ </template>
14
+
15
+ <script>
16
+ import TfMenu from './components/tf-menu'
17
+ import TfLaberBar from './components/tf-labelbar'
18
+ export default {
19
+ name: 'TfLayout',
20
+ components: {
21
+ TfMenu,
22
+ TfLaberBar
23
+ },
24
+ props: {
25
+ menuInfo: {
26
+ type: Array,
27
+ default: function () {
28
+ return []
29
+ }
30
+ }
31
+ },
32
+ data () {
33
+ return {
34
+ cacheMap: new Map(),
35
+ secondCacheArray: [],
36
+ thirdCacheArr: []
37
+ }
38
+ },
39
+ methods: {
40
+ setCache (value) {
41
+ this.cacheMap.set(value[2] || value[1], value[1])
42
+ this.initCacheArr()
43
+ },
44
+ initCacheArr () {
45
+ this.secondCacheArray.push(
46
+ ...this.arrayDiff([...this.cacheMap.values()], this.secondCacheArray)
47
+ )
48
+ this.thirdCacheArr.push(
49
+ ...this.arrayDiff([...this.cacheMap.keys()], this.thirdCacheArr)
50
+ )
51
+ this.$emit('setSecondCache', this.secondCacheArray)
52
+ this.$emit('setThirdCache', this.thirdCacheArr)
53
+ },
54
+ arrayDiff (arr, arrRaw) {
55
+ if (Array.isArray(arr)) {
56
+ return arr.filter((i) => {
57
+ return arrRaw.indexOf(i) < 0
58
+ })
59
+ }
60
+ return []
61
+ },
62
+ deleteCache (value) {
63
+ if (Array.isArray(value)) {
64
+ value.forEach((item) => {
65
+ console.log(item)
66
+ this.cacheMap.delete(item[2] || item[1])
67
+ this.thirdCacheArr.splice(
68
+ this.thirdCacheArr.indexOf(item[2] || item[1]),
69
+ 1
70
+ )
71
+ if ([...this.cacheMap.values()].indexOf(item[1]) === -1) {
72
+ this.secondCacheArray.splice(
73
+ this.secondCacheArray.indexOf(item[2]),
74
+ 1
75
+ )
76
+ }
77
+ console.log(this.cacheMap.get(item[2] || item[1]))
78
+ })
79
+ this.$emit('setSecondCache', this.secondCacheArray)
80
+ this.$emit('setThirdCache', this.thirdCacheArr)
81
+ }
82
+ }
83
+ }
84
+ }
85
+ </script>
86
+
87
+ <style lang="less" scoped>
88
+ .tf-layout {
89
+ height: 100vh;
90
+ width: 100vw;
91
+ display: flex;
92
+ .tf-layout-subject {
93
+ flex: 1;
94
+ height: 100%;
95
+ width: 100vw;
96
+ .tf-layout-subject-content {
97
+ height: calc(100% - 35px);
98
+ background: rgb(241, 241, 241);
99
+ box-sizing: border-box;
100
+ padding: 5px 0 0 0;
101
+ }
102
+ }
103
+ }
104
+ </style>
@@ -0,0 +1,11 @@
1
+ // 颜色定义
2
+ @disabledBgColor: #f0f0f5;
3
+
4
+ ::v-deep .el-input__inner[disabled = 'disabled']{
5
+ background: @disabledBgColor;
6
+ border-color: @disabledBgColor;
7
+ }
8
+ ::v-deep .el-textarea__inner[disabled = 'disabled']{
9
+ background: @disabledBgColor;
10
+ border-color: @disabledBgColor;
11
+ }
@@ -12,7 +12,7 @@
12
12
  @select="handleSelect"
13
13
  @keydown.delete.native="handleDeleteKeyDown"
14
14
  >
15
- <i slot="suffix" class="el-icon-search" style="cursor: pointer" @click="showDialog" />
15
+ <i slot="suffix" :class=" disabled ? 'el-icon-lock' : 'el-icon-search' " style="cursor: pointer" @click="showDialog" />
16
16
  <template slot-scope="{item}">
17
17
  <div>{{ item[displayField] + ' ' + '[' + item.head__code + ']' }}</div>
18
18
  </template>
@@ -35,7 +35,7 @@
35
35
  </div>
36
36
  </template>
37
37
  <script>
38
- import { getBasicDataSearchAdvice } from '@/api/edit.js'
38
+ import { getBasicDataSearchAdvice, getFormData } from '@/api/edit.js'
39
39
  import BasicDataSelector from './dependcy/basic-data-selector.vue'
40
40
  export default {
41
41
  components: {
@@ -141,14 +141,40 @@ export default {
141
141
  }
142
142
  },
143
143
  created () {
144
- if (this.defaultValue && !this.value) {
145
- return this.handleInput(this.defaultValue)
144
+ if (this.defaultValue && (!this.value || this.value.id === '')) {
145
+ return this.handleDefaultValue()
146
146
  }
147
147
  if (!this.value) {
148
148
  this.$emit('input', { name: '', id: null })
149
149
  }
150
150
  },
151
151
  methods: {
152
+
153
+ /**
154
+ * 根据默认值id获取数据
155
+ */
156
+ handleDefaultValue () {
157
+ const interval = setInterval(async () => {
158
+ if (this.tableId) {
159
+ clearInterval(interval)
160
+ const data = {
161
+ entityMark: '',
162
+ id: this.defaultValue,
163
+ pageNum: 1,
164
+ pageSize: 1,
165
+ tableId: this.tableId
166
+ }
167
+ const res = await getFormData(data)
168
+ if (res.code === 0) {
169
+ const data = {
170
+ id: this.defaultValue,
171
+ name: res.data[res.data.headIdentification].name
172
+ }
173
+ this.$emit('input', data)
174
+ }
175
+ }
176
+ }, 50)
177
+ },
152
178
  /**
153
179
  * dialog关闭和确定处理函数
154
180
  */
@@ -290,6 +316,7 @@ export default {
290
316
 
291
317
  <style lang='less' scoped>
292
318
  @import "@/assets/styles/common-table.less";
319
+ @import '../../assets/common-input.less';
293
320
  .el-autocomplete{
294
321
  display:block;
295
322
  ::v-deep .el-input__inner{
@@ -80,7 +80,7 @@ export default {
80
80
  </script>
81
81
 
82
82
  <style lang="less" scoped>
83
-
83
+ @import '../assets/common-input.less';
84
84
  ::v-deep .el-input__inner{
85
85
  width: 100%;
86
86
  border: none;
@@ -79,6 +79,7 @@ export default {
79
79
  </script>
80
80
 
81
81
  <style lang="less" scoped>
82
+ @import '../assets/common-input.less';
82
83
  ::v-deep .el-input__inner{
83
84
  width: 100%;
84
85
  border: none;
@@ -10,6 +10,7 @@
10
10
  @change="handleInput"
11
11
  v-on="$listeners"
12
12
  />
13
+ <!-- <i v-if="disabled" class="el-icon-lock" /> -->
13
14
  </div>
14
15
  </template>
15
16
  <script>
@@ -45,7 +46,8 @@ export default {
45
46
  },
46
47
  data () {
47
48
  return {
48
-
49
+ // refName: Math.random().toString().slice(3, 9),
50
+ // inputWidth: '0'
49
51
  }
50
52
  },
51
53
  watch: {
@@ -66,6 +68,11 @@ export default {
66
68
  }
67
69
  this.$emit('input', undefined)
68
70
  },
71
+
72
+ // mounted () {
73
+ // this.inputWidth = this.$refs[this.refName].$children[0].$el.clientWidth + 'px'
74
+ // },
75
+
69
76
  methods: {
70
77
  handleInput (value) {
71
78
  this.$emit('input', value)
@@ -76,8 +83,12 @@ export default {
76
83
  </script>
77
84
 
78
85
  <style lang="less" scoped>
86
+ @import '../assets/common-input.less';
79
87
  .decimal{
80
88
  width: 100%;
89
+ display: flex;
90
+ align-items: center;
91
+ position: relative;
81
92
  ::v-deep .el-input{
82
93
  height: 100%;
83
94
  //margin-top: -0.55vh;
@@ -92,5 +103,13 @@ export default {
92
103
  border-radius: 0;
93
104
  text-align: left;
94
105
  }
106
+ // .el-icon-lock{
107
+ // position: absolute;
108
+ // left: calc(var(--inputWidth) - 25px);
109
+ // }
110
+ // .el-icon-lock::before{
111
+ // color: #C0C4CC;
112
+ // font-size: 14px;
113
+ // }
95
114
  }
96
115
  </style>
@@ -11,6 +11,7 @@
11
11
  @change="handleInput"
12
12
  v-on="$listeners"
13
13
  />
14
+ <!-- <i v-if="disabled" class="el-icon-lock" /> -->
14
15
  </div>
15
16
  </template>
16
17
  <script>
@@ -38,7 +39,8 @@ export default {
38
39
  },
39
40
  data () {
40
41
  return {
41
-
42
+ // refName: Math.random().toString().slice(3, 9),
43
+ // inputWidth: '0'
42
44
  }
43
45
  },
44
46
  watch: {
@@ -59,6 +61,11 @@ export default {
59
61
  }
60
62
  this.$emit('input', undefined)
61
63
  },
64
+
65
+ // mounted () {
66
+ // this.inputWidth = this.$refs[this.refName].$children[0].$el.clientWidth + 'px'
67
+ // },
68
+
62
69
  methods: {
63
70
  handleInput (value) {
64
71
  this.$emit('input', value)
@@ -69,17 +76,29 @@ export default {
69
76
  </script>
70
77
 
71
78
  <style lang="less" scoped>
72
- .integer{
79
+ @import '../assets/common-input.less';
80
+ .integer{
81
+ width: 100%;
82
+ display: flex;
83
+ align-items: center;
84
+ position: relative;
85
+ ::v-deep .el-input-number{
73
86
  width: 100%;
74
- ::v-deep .el-input-number{
75
- width: 100%;
76
- }
77
- ::v-deep .el-input__inner{
78
- width: 100%;
79
- border: none;
80
- border-bottom: 1px solid #DCDCDC;
81
- border-radius: 0;
82
- text-align: left;
83
- }
84
87
  }
88
+ ::v-deep .el-input__inner{
89
+ width: 100%;
90
+ border: none;
91
+ border-bottom: 1px solid #DCDCDC;
92
+ border-radius: 0;
93
+ text-align: left;
94
+ }
95
+ // .el-icon-lock{
96
+ // position: absolute;
97
+ // left: calc(var(--inputWidth) - 25px);
98
+ // }
99
+ // .el-icon-lock::before{
100
+ // color: #C0C4CC;
101
+ // font-size: 14px;
102
+ // }
103
+ }
85
104
  </style>
@@ -3,9 +3,12 @@
3
3
  :value="value"
4
4
  :disabled="JSON.parse(disabled) "
5
5
  :placeholder="placeholder"
6
+ :clearable="clearable"
6
7
  @input="handleInput"
7
8
  v-on="$listeners"
8
- />
9
+ >
10
+ <i v-if="disabled" class="el-icon-lock el-input__icon" slot="suffix" />
11
+ </el-input>
9
12
  </template>
10
13
  <script>
11
14
  export default {
@@ -28,6 +31,10 @@ export default {
28
31
  defaultValue: {
29
32
  type: String,
30
33
  default: ''
34
+ },
35
+ clearable: {
36
+ type: Boolean,
37
+ default: true
31
38
  }
32
39
  },
33
40
  data () {
@@ -65,10 +72,11 @@ export default {
65
72
  </script>
66
73
 
67
74
  <style lang="less" scoped>
68
- ::v-deep .el-input__inner{
69
- width: 100%;
70
- border: none;
71
- border-bottom: 1px solid #DCDCDC;
72
- border-radius: 0;
73
- }
75
+ @import '../assets/common-input.less';
76
+ ::v-deep .el-input__inner{
77
+ width: 100%;
78
+ border: none;
79
+ border-bottom: 1px solid #DCDCDC;
80
+ border-radius: 0;
81
+ }
74
82
  </style>
@@ -1,6 +1,6 @@
1
1
  <template>
2
2
  <div class="small-picture">
3
- <el-button size="mini" @click="handleClickUploadPicture">点击上传图片</el-button>
3
+ <el-button size="mini" @click="handleClickUploadPicture" :disabled="disabled">点击上传图片</el-button>
4
4
  <el-dialog
5
5
  title="图片上传"
6
6
  :visible.sync="dialogVisible"
@@ -40,6 +40,10 @@ export default {
40
40
  value: {
41
41
  type: String,
42
42
  default: null
43
+ },
44
+ disabled: {
45
+ type: [Boolean, Object, String],
46
+ default: null
43
47
  }
44
48
  },
45
49
  data () {
@@ -66,8 +66,9 @@ export default {
66
66
  </script>
67
67
 
68
68
  <style lang="less" scoped>
69
- ::v-deep .el-textarea__inner{
70
- width: 100%;
71
- height: 100%;
72
- }
69
+ @import '../assets/common-input.less';
70
+ ::v-deep .el-textarea__inner{
71
+ width: 100%;
72
+ height: 100%;
73
+ }
73
74
  </style>
@@ -1,8 +1,16 @@
1
1
  <template>
2
2
  <div class="tf-select">
3
- <el-select :value="selectId" filterable clearable :placeholder="placeholder" :disabled="JSON.parse(disabled)" style="display:block" @input="change" @change="$emit('change', $event)">
3
+ <el-select v-if="!disabled" :value="selectId" filterable clearable :placeholder="placeholder" :disabled="JSON.parse(disabled)" style="display:block" @input="change" @change="$emit('change', $event)">
4
4
  <el-option v-for="item in options" :key="item.id" :label="item.name" :value="item.id" />
5
5
  </el-select>
6
+ <el-input
7
+ v-else
8
+ :value="value ? value.name : ''"
9
+ :disabled="true"
10
+ :placeholder="placeholder"
11
+ >
12
+ <i class="el-icon-lock el-input__icon" slot="suffix" />
13
+ </el-input>
6
14
  </div>
7
15
  </template>
8
16
  <script>
@@ -95,10 +103,11 @@ export default {
95
103
  </script>
96
104
 
97
105
  <style lang="less" scoped>
98
- ::v-deep .el-input__inner{
99
- width: 100%;
100
- border: none;
101
- border-bottom: 1px solid #DCDCDC;
102
- border-radius: 0;
103
- }
106
+ @import '../assets/common-input.less';
107
+ ::v-deep .el-input__inner{
108
+ width: 100%;
109
+ border: none;
110
+ border-bottom: 1px solid #DCDCDC;
111
+ border-radius: 0;
112
+ }
104
113
  </style>
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@tongfun/tf-widget",
3
- "version": "0.1.4",
3
+ "version": "0.1.8-beta",
4
4
  "description": "tf-widget",
5
5
  "main": "lib/tf-widget.umd.js",
6
6
  "private": false,
package/postinstall.js CHANGED
@@ -1,10 +1,10 @@
1
-
2
- const BANNER = '\u001B[96mThank you for using tf-widget for polyfilling JavaScript standard library!\u001B[0m\n\n' +
3
- '\u001B[96mWe need the best of you! Come and join us\n\n' +
4
- '\u001B[96mWe are waiting for you\n'
5
-
6
- function showBanner () {
7
- console.log(BANNER)
8
- }
9
-
10
- showBanner()
1
+
2
+ const BANNER = '\u001B[96mThank you for using tf-widget for polyfilling JavaScript standard library!\u001B[0m\n\n' +
3
+ '\u001B[96mWe need the best of you! Come and join us\n\n' +
4
+ '\u001B[96mWe are waiting for you\n'
5
+
6
+ function showBanner () {
7
+ console.log(BANNER)
8
+ }
9
+
10
+ showBanner()
package/src/index.js CHANGED
@@ -1,10 +1,11 @@
1
1
 
2
2
  import TfWidget from '../package/tf-widget'
3
3
  import SvgIcon from '../package/svg-icon'
4
-
4
+ import TfLayout from '../package/tf-layout'
5
5
  const components = [
6
6
  TfWidget,
7
- SvgIcon
7
+ SvgIcon,
8
+ TfLayout
8
9
  ]
9
10
 
10
11
  const install = function (Vue) {
@@ -16,5 +17,6 @@ const install = function (Vue) {
16
17
  export default {
17
18
  install,
18
19
  TfWidget,
19
- SvgIcon
20
+ SvgIcon,
21
+ TfLayout
20
22
  }
@@ -14,9 +14,12 @@ const service = axios.create({
14
14
  // request interceptor
15
15
  service.interceptors.request.use(
16
16
  config => {
17
- config.headers.token = 'Bearer ' + getToken()
18
17
  config.headers['client-type'] = 'WEB'
18
+ config.headers.token = 'Bearer ' + getToken()
19
19
  config.headers.Authorization = `Basic ${Base64.encode(`${clientId}:${clientSecret}`)}`
20
+ // 测试组件时使用下方头部信息,过期则修改后再测试
21
+ // config.headers.token = 'Bearer eyJ0eXAiOiJKc29uV2ViVG9rZW4iLCJhbGciOiJIUzI1NiJ9.eyJtb2JpbGUiOiIxMzE1MTYyODY1NyIsIm5hbWUiOiLmnLHmmI7mmI4iLCJ0b2tlbl90eXBlIjoidG9rZW4iLCJwVXNlcmlkIjoiMTM2ODg0NjcxOTU3OTU4NjU2MSIsInVzZXJpZCI6IjE0MTczNjg0NjMwODg4MTIwMzIiLCJ0ZW5hbnQiOiIwMDAxIiwiYWNjb3VudCI6InpodW1pbmdtaW5nIiwiaWF0IjoxNjM2MDgxNzM1LCJuYmYiOjE2MzYwODE3MzUsImV4cCI6MTYzNjExMDUzNX0.TTSbWUYTOd6znNko8sNyKz9KqLyeyO5AC4WgBvVNvBo'
22
+ // config.headers.Authorization = 'Basic dG9uZ2Z1bmNsb3VkX3dlYjp0b25nZnVuY2xvdWRfd2ViX3NlY3JldA=='
20
23
  return config
21
24
  },
22
25
  error => {