xianniu-ui 0.7.5 → 0.8.1

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": "xianniu-ui",
3
- "version": "0.7.5",
3
+ "version": "0.8.1",
4
4
  "private": false,
5
5
  "main": "lib/xianniu-ui.umd.min.js",
6
6
  "scripts": {
@@ -0,0 +1,7 @@
1
+ import XnDescription from './main.vue'
2
+
3
+ XnDescription.install = function (Vue) {
4
+ Vue.component(XnDescription.name, XnDescription)
5
+ }
6
+
7
+ export default XnDescription
@@ -0,0 +1,91 @@
1
+ <template>
2
+ <div class="xn-desc" :class="{ 'xn-desc-border': border }">
3
+ <div
4
+ v-if="title || $slots.more"
5
+ class="xn-desc-header flex justify-content-between align-items-center"
6
+ >
7
+ <h1 v-if="title" class="xn-desc-title" v-html="title" />
8
+ <div class="xn-desc__more" v-if="$slots.more">
9
+ <slot name="more"></slot>
10
+ </div>
11
+ </div>
12
+ <slot name="title" />
13
+ <el-row class="xn-desc__row" :style="bodyStyle">
14
+ <slot />
15
+ </el-row>
16
+ </div>
17
+ </template>
18
+
19
+ <script>
20
+ export default {
21
+ name: "XnDescription",
22
+ provide() {
23
+ return {
24
+ labelWidth: this.labelWidth,
25
+ column: this.column,
26
+ span: this.span,
27
+ size: this.size,
28
+ middle: this.middle,
29
+ colon:this.colon
30
+ };
31
+ },
32
+ props: {
33
+ // // 数据源,监听数据重绘
34
+ // 标题
35
+ title: {
36
+ type: String,
37
+ default: "",
38
+ },
39
+ colon:{
40
+ type:Boolean,
41
+ default:true
42
+ },
43
+ border: Boolean,
44
+ // 边距
45
+ // margin: {
46
+ // type: String,
47
+ // default: "0",
48
+ // },
49
+ // label宽度
50
+ labelWidth: {
51
+ type: String,
52
+ default: "80px",
53
+ },
54
+ column: {
55
+ // 每行显示的项目个数
56
+ type: [Number, String],
57
+ default: 3,
58
+ },
59
+ span: {
60
+ // 每行显示的项目个数
61
+ type: [Number, String],
62
+ default: 3,
63
+ },
64
+ size: {
65
+ // 大小
66
+ type: String,
67
+ default: "",
68
+ },
69
+ bodyStyle: {
70
+ type: Object,
71
+ default: () => {
72
+ return {
73
+ padding: "20px",
74
+ };
75
+ },
76
+ },
77
+ middle: {
78
+ type: Boolean,
79
+ default: false,
80
+ },
81
+ },
82
+ watch: {
83
+
84
+ },
85
+ };
86
+ </script>
87
+
88
+ <style scoped lang="scss">
89
+
90
+
91
+ </style>
@@ -0,0 +1,7 @@
1
+ import XnDescriptionItem from './main.vue'
2
+
3
+ XnDescriptionItem.install = function (Vue) {
4
+ Vue.component(XnDescriptionItem.name, XnDescriptionItem)
5
+ }
6
+
7
+ export default XnDescriptionItem
@@ -0,0 +1,65 @@
1
+ <template>
2
+ <el-col :span="computedSpan" class="xn-desc-item">
3
+ <div class="xn-desc-item__content" :class="size">
4
+ <label
5
+ class="xn-desc-item__label"
6
+ :class="{ 'has-colon': colon }"
7
+ :style="{ width: labelWidth, ...middleStyl }"
8
+ v-html="label"
9
+ />
10
+ <div class="xn-desc-item__value" :style="middleStyl">
11
+ <slot></slot>
12
+ </div>
13
+ </div>
14
+ </el-col>
15
+ </template>
16
+
17
+ <script>
18
+ export default {
19
+ name: "XnDescriptionItem",
20
+ inject: ["labelWidth", "column", "size", "middle",'colon'],
21
+ props: {
22
+ span: {
23
+ type: [Number, String],
24
+ required: false,
25
+ default: 0,
26
+ },
27
+ label: {
28
+ type: String,
29
+ required: false,
30
+ default: "",
31
+ },
32
+ },
33
+ data() {
34
+ return {
35
+ // 子组件自己的span
36
+ selfSpan: 0,
37
+ };
38
+ },
39
+ computed: {
40
+ middleStyl() {
41
+ return this.middle
42
+ ? {
43
+ "align-items": "center",
44
+ }
45
+ : {};
46
+ },
47
+ isTrue() {
48
+ return JSON.stringify(this.$slots) === "{}";
49
+ },
50
+ computedSpan() {
51
+ // 子组件自己的span,用于父组件计算修改span
52
+ if (this.selfSpan) {
53
+ return (24 / this.column) * this.selfSpan;
54
+ } else if (this.span) {
55
+ // props传递的span
56
+ return (24 / this.column) * this.span;
57
+ } else {
58
+ // 未传递span时,取column
59
+ return 24 / this.column;
60
+ }
61
+ },
62
+ },
63
+ };
64
+ </script>
65
+
@@ -0,0 +1,86 @@
1
+ .xn-desc {
2
+ & + & {
3
+ margin-top: 20px;
4
+ }
5
+ width: 100%;
6
+ background-color: #fff;
7
+
8
+ &-header {
9
+ padding: 10px 20px;
10
+ display: flex;
11
+ border-bottom: 1px solid #e8eaec;
12
+ }
13
+ &-border {
14
+ border: 1px solid #e6ebf5;
15
+ border-radius: 4px;
16
+ }
17
+ &-title {
18
+ margin: 0;
19
+ color: #ff745c;
20
+ font-weight: 700;
21
+ font-size: 15px;
22
+ line-height: 1.5715;
23
+ }
24
+ &__row {
25
+ display: flex;
26
+ flex-wrap: wrap;
27
+ border-radius: 2px;
28
+ width: 100%;
29
+ & > :not([class*="xn-desc-item"]) {
30
+ width: 100%;
31
+ }
32
+ }
33
+ }
34
+ .xn-desc-item {
35
+ margin: 10px 0;
36
+ &__content {
37
+ display: flex;
38
+ justify-content: flex-start;
39
+ align-items: center;
40
+ color: rgba(0, 0, 0, 0.65);
41
+ font-size: 14px;
42
+ line-height: 1.5;
43
+ width: 100%;
44
+ height: 100%;
45
+
46
+ &.small {
47
+ .xn-desc-item__label,
48
+ .xn-desc-item__value {
49
+ padding: 10px 14px;
50
+ }
51
+ }
52
+ }
53
+ &__label {
54
+ text-align: right;
55
+ display: inline-block;
56
+ flex-grow: 0;
57
+ flex-shrink: 0;
58
+ color: #909097;
59
+ font-weight: 400;
60
+ font-size: 14px;
61
+ line-height: 1.5;
62
+ height: 100%;
63
+ display: flex;
64
+ justify-content: flex-end;
65
+ align-items: flex-start;
66
+ margin: 0 10px 0 0;
67
+ &.has-colon::after {
68
+ content: ":";
69
+ position: relative;
70
+ top: -1.5px;
71
+ }
72
+ }
73
+ &__value {
74
+ flex-grow: 1;
75
+ overflow: hidden;
76
+ word-break: break-all;
77
+ height: 100%;
78
+ display: flex;
79
+ align-items: flex-start;
80
+ color: #202131;
81
+
82
+ span {
83
+ color: #aaa;
84
+ }
85
+ }
86
+ }
@@ -13,6 +13,7 @@
13
13
  @import './tag.scss';
14
14
  @import './ellipsis.scss';
15
15
  @import './card.scss';
16
+ @import './description.scss';
16
17
 
17
18
 
18
19
 
package/src/index.js CHANGED
@@ -16,6 +16,8 @@ import XnEmpty from '../packages/empty/index'
16
16
  import XnTag from '../packages/tag/index'
17
17
  import XnEllipsis from '../packages/ellipsis/index'
18
18
  import XnCard from '../packages/card/index'
19
+ import XnDescription from '../packages/description/index'
20
+ import XnDescriptionItem from '../packages/descriptionItem/index'
19
21
 
20
22
  import Utils from 'xn-ui/src/utils/index'
21
23
  const doc = 'http://lzwr.gitee.io/xn-ui/#/'
@@ -36,7 +38,9 @@ const components = [
36
38
  XnEmpty,
37
39
  XnTag,
38
40
  XnEllipsis,
39
- XnCard
41
+ XnCard,
42
+ XnDescription,
43
+ XnDescriptionItem
40
44
  ]
41
45
  const version = require('../package.json').version
42
46
  const install = function (Vue) {
@@ -65,7 +65,6 @@ const download = (params = { name: '', url: '' }) => {
65
65
  name: '下载模板'
66
66
  }
67
67
  const _params = Object.assign(defaultParams, params)
68
- console.log('_params: ', _params);
69
68
  const { url, name } = _params
70
69
  const x = new XMLHttpRequest();
71
70
  x.open("GET", url, true);
@@ -116,10 +115,32 @@ const arrMerge = (arr = [], key = '') => {
116
115
  }
117
116
  return result
118
117
  }
118
+ // 判空
119
+ const isBlank = (str) => {
120
+ if (str === null || (!str && str !== 0)) {
121
+ return true
122
+ }
123
+ return false
124
+ }
125
+ /* 重置方法 */
126
+ const reset = (obj) => {
127
+ for (const key in obj) {
128
+ if (Array.isArray(obj[key])) {
129
+ obj[key] = []
130
+ } else if (typeof obj[key] === 'object') {
131
+ obj[key] = reset(obj[key])
132
+ } else {
133
+ obj[key] = ''
134
+ }
135
+ }
136
+ return obj
137
+ }
119
138
  export default {
120
139
  isEmpty,
121
140
  isImg,
122
141
  deepClone,
123
142
  download,
124
- arrMerge
143
+ arrMerge,
144
+ reset,
145
+ isBlank
125
146
  }