xianniu-ui 0.6.3 → 0.7.0

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.6.3",
3
+ "version": "0.7.0",
4
4
  "private": false,
5
5
  "main": "lib/xianniu-ui.umd.min.js",
6
6
  "scripts": {
@@ -0,0 +1,7 @@
1
+ import XnCard from './main.vue'
2
+
3
+ XnCard.install = function (Vue) {
4
+ Vue.component(XnCard.name, XnCard)
5
+ }
6
+
7
+ export default XnCard
@@ -0,0 +1,47 @@
1
+ <template>
2
+ <div class="xn-card">
3
+ <div class="xn-card-header flex justify-content-between">
4
+ <slot name="title" v-if="title">
5
+ <slot name="title">
6
+ <h3><span>{{title}}</span></h3>
7
+ </slot>
8
+ </slot>
9
+ <div class="xn-card-header__more">
10
+ <slot name="more"></slot>
11
+ </div>
12
+ </div>
13
+ <div class="xn-card-body" :style="styles">
14
+ <slot></slot>
15
+ </div>
16
+ </div>
17
+ </template>
18
+
19
+ <script>
20
+ export default {
21
+ name: "XnCard",
22
+ props: {
23
+ title: {
24
+ type: String,
25
+ default: "",
26
+ },
27
+ bodyStyle: {
28
+ type: Object,
29
+ default: () => {
30
+ return {
31
+ padding: "18px",
32
+ };
33
+ },
34
+ },
35
+ },
36
+ computed: {
37
+ styles() {
38
+ return {
39
+ ...this.bodyStyle,
40
+ };
41
+ },
42
+ },
43
+ };
44
+ </script>
45
+
46
+ <style>
47
+ </style>
@@ -17,7 +17,7 @@
17
17
  </template>
18
18
 
19
19
  <script>
20
- const ZXCITY = ['北京市','天津市','上海市','重庆市']
20
+ const ZXCITY = ["北京市", "天津市", "上海市", "重庆市"];
21
21
  import citys from "xn-ui/src/area/index.js";
22
22
  export default {
23
23
  name: "XnCity",
@@ -251,19 +251,24 @@ export default {
251
251
  getCity(data, nameList) {
252
252
  if (nameList.length === 0) return [];
253
253
  const [cityName, ...rest] = nameList;
254
- const item = data.find((i) => i.cityName === cityName || i.cityName.indexOf(cityName.substring(0,2)) > -1);
255
- if(item){
254
+ const item =
255
+ data &&
256
+ data.find((i) => i.cityName === cityName || cityName.indexOf(i.cityName) > -1);
257
+ if (item) {
256
258
  return [item.cityCode, ...this.getCity(item.subCitys, rest)];
257
- }else{
258
- return [...this.getCity([], rest)]
259
+ } else {
260
+ return [...this.getCity([], rest)];
259
261
  }
260
262
  },
261
263
  str2Code(val) {
262
264
  if (!val) return;
265
+ val = val.replace(/[^\u4e00-\u9fa5]/g, "");
263
266
  const cityArr = val.match(this.$reg.getCity) || [];
264
- const newarr = cityArr.length&&cityArr.map((item,idx,arr)=>{
265
- return ZXCITY.includes(item) && idx === 0 ? [item,...arr] : arr
266
- })[0]
267
+ const newarr =
268
+ cityArr.length &&
269
+ cityArr.map((item, idx, arr) => {
270
+ return ZXCITY.includes(item) && idx === 0 ? [item, ...arr] : arr;
271
+ })[0];
267
272
  const arr = this.getCity(this.cityList, newarr);
268
273
  return arr[arr.length - 1];
269
274
  },
@@ -1,6 +1,13 @@
1
1
  <template>
2
2
  <div class="xn-search">
3
- <el-form ref="form" inline :model="form" :label-width="labelWidth">
3
+ <el-form
4
+ ref="form"
5
+ inline
6
+ :model="form"
7
+ :label-width="labelWidth"
8
+ @submit.native.prevent
9
+ @keyup.enter.native="onSearch"
10
+ >
4
11
  <el-row :gutter="0" class="xn-search--row">
5
12
  <template v-for="(item, idx) in form.value">
6
13
  <el-col v-bind="{ ...col }" :key="idx" v-show="item.isShow || isColl">
@@ -16,6 +23,7 @@
16
23
  :data-level="(item.options && item.options.dataLevel) || 2"
17
24
  v-model="item.modelVal"
18
25
  @on-city="handleChangeCity"
26
+
19
27
  />
20
28
  </el-form-item>
21
29
  <el-form-item
@@ -53,6 +61,7 @@
53
61
  :reserve-keyword="isRemote(item.remote)"
54
62
  :default-first-option="isRemote(item.remote)"
55
63
  :remote-method="item.remote"
64
+
56
65
  >
57
66
  <el-option
58
67
  v-for="(itemData, idxData) in item.data"
@@ -302,12 +311,12 @@ export default {
302
311
  setValue(key, value) {
303
312
  if (Object.prototype.toString.call(key) === "[object Object]") {
304
313
  const list = this.form.value;
305
- const keys = Object.keys(key)
314
+ const keys = Object.keys(key);
306
315
  for (let i = 0; i < list.length; i++) {
307
316
  const item = list[i];
308
- if(keys.includes(item.prop)){
309
- console.log(item,key[item.prop]);
310
- item.modelVal = key[item.prop]
317
+ if (keys.includes(item.prop)) {
318
+ console.log(item, key[item.prop]);
319
+ item.modelVal = key[item.prop];
311
320
  }
312
321
  }
313
322
  return;
@@ -0,0 +1,16 @@
1
+ .xn-card {
2
+ background-color: #fff;
3
+ padding: 0 38px;
4
+ &-header {
5
+ padding: 24px 0 13px 0;
6
+ border-bottom: 1px solid #f2f2f2;
7
+ h3 {
8
+ margin: 0;
9
+ padding: 0;
10
+ font-size: 18px;
11
+ font-weight: 500;
12
+ color: #202131;
13
+ line-height: 25px;
14
+ }
15
+ }
16
+ }
@@ -12,6 +12,7 @@
12
12
  @import './footer.scss';
13
13
  @import './tag.scss';
14
14
  @import './ellipsis.scss';
15
+ @import './card.scss';
15
16
 
16
17
 
17
18
 
@@ -19,4 +20,5 @@
19
20
  @import './theme/variables.scss';
20
21
  @import './theme/mixin.scss';
21
22
  @import './theme/transition.scss';
22
- @import './theme/sidebar.scss';
23
+ @import './theme/sidebar.scss';
24
+ @import './theme/element-ui.scss';
@@ -0,0 +1,8 @@
1
+ .el-descriptions{
2
+ .el-descriptions-item__label:not(.is-bordered-label){
3
+ color: #909097;
4
+ }
5
+ &--small{
6
+ font-size: 14px;
7
+ }
8
+ }
@@ -116,7 +116,7 @@
116
116
  </el-table-column>
117
117
  <el-table-column
118
118
  width="50px"
119
- label="No."
119
+ label="序号"
120
120
  v-if="index && data.length"
121
121
  type="index"
122
122
  ></el-table-column>
@@ -61,7 +61,7 @@ export default {
61
61
  if (
62
62
  data.parentId &&
63
63
  data.parentId !== 0 &&
64
- !data[this.defaultProps.children].length
64
+ (data[this.defaultProps.children] && !data[this.defaultProps.children].length)
65
65
  ) {
66
66
  className = 'especially'
67
67
  }
@@ -277,21 +277,7 @@ export default {
277
277
  },
278
278
  async handleDownload(file) {
279
279
  const { url, name } = file;
280
- const x = new XMLHttpRequest();
281
- x.open("GET", url, true);
282
- x.responseType = "blob";
283
- x.onload = function () {
284
- const _url = window.URL.createObjectURL(x.response);
285
- const elt = document.createElement("a");
286
- elt.setAttribute("href", _url);
287
- elt.setAttribute("download", name);
288
- elt.style.display = "none";
289
- elt.target = "_blank";
290
- document.body.appendChild(elt);
291
- elt.click();
292
- document.body.removeChild(elt);
293
- };
294
- x.send();
280
+ return this.$utils.download({url, name})
295
281
  },
296
282
  handleRemove(file, fileList) {
297
283
  fileList.forEach((item, idx) => {
package/src/index.js CHANGED
@@ -15,6 +15,7 @@ import XnFooter from '../packages/footer/index'
15
15
  import XnEmpty from '../packages/empty/index'
16
16
  import XnTag from '../packages/tag/index'
17
17
  import XnEllipsis from '../packages/ellipsis/index'
18
+ import XnCard from '../packages/card/index'
18
19
 
19
20
  import Utils from 'xn-ui/src/utils/index'
20
21
  const doc = 'http://lzwr.gitee.io/xn-ui/#/'
@@ -34,7 +35,8 @@ const components = [
34
35
  XnFooter,
35
36
  XnEmpty,
36
37
  XnTag,
37
- XnEllipsis
38
+ XnEllipsis,
39
+ XnCard
38
40
  ]
39
41
  const version = require('../package.json').version
40
42
  const install = function (Vue) {
@@ -80,5 +82,6 @@ export default {
80
82
  XnFooter,
81
83
  XnEmpty,
82
84
  XnTag,
83
- XnEllipsis
85
+ XnEllipsis,
86
+ XnCard
84
87
  }
@@ -65,27 +65,23 @@ const download = (params = { name: '', url: '' }) => {
65
65
  name: '下载模板'
66
66
  }
67
67
  const _params = Object.assign(defaultParams, params)
68
+ console.log('_params: ', _params);
68
69
  const { url, name } = _params
69
- var x = new XMLHttpRequest()
70
- x.open('GET', url, true)
71
- // x.responseType = 'blob'
72
- // x.responseType = 'blob'
73
- x.onprogress = function () {
74
- }
70
+ const x = new XMLHttpRequest();
71
+ x.open("GET", url, true);
72
+ x.responseType = "blob";
75
73
  x.onload = function () {
76
- var _url = ''
77
- try {
78
- _url = window.URL.createObjectURL(x.response)
79
- } catch (error) {
80
- _url = url
81
- }
82
- var a = document.createElement('a')
83
- a.href = _url
84
- a.target = '_blank'
85
- a.download = name
86
- a.click()
87
- }
88
- x.send()
74
+ const _url = window.URL.createObjectURL(x.response);
75
+ const elt = document.createElement("a");
76
+ elt.setAttribute("href", _url);
77
+ elt.setAttribute("download", name);
78
+ elt.style.display = "none";
79
+ elt.target = "_blank";
80
+ document.body.appendChild(elt);
81
+ elt.click();
82
+ document.body.removeChild(elt);
83
+ };
84
+ x.send();
89
85
  }
90
86
  /**
91
87
  * 根据某个key 对数组去重合并
@@ -97,7 +93,7 @@ const arrMerge = (arr = [], key = '') => {
97
93
  if (!key) {
98
94
  throw new Error('error arguments: key is required')
99
95
  }
100
- if(!arr.length) return
96
+ if (!arr.length) return
101
97
  var map = {}; var result = []
102
98
 
103
99
  for (var i = 0; i < arr.length; i++) {