tianheng-ui 0.0.24 → 0.0.27

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,7 +1,7 @@
1
1
  {
2
2
  "name": "tianheng-ui",
3
3
  "description": "A Vue.js project",
4
- "version": "0.0.24",
4
+ "version": "0.0.27",
5
5
  "author": "shu lang <403732931@qq.com>",
6
6
  "license": "MIT",
7
7
  "private": false,
@@ -8,7 +8,7 @@
8
8
  <slot v-if="$slots.description" name="description"></slot>
9
9
  <p v-else>{{ description }}</p>
10
10
  </div>
11
- <div v-if="$slots.default" class="th-empty-bottom">
11
+ <div v-if="$slots.default" class="th-empty-bottom">
12
12
  <slot></slot>
13
13
  </div>
14
14
  </div>
@@ -53,9 +53,11 @@
53
53
  <el-dropdown
54
54
  v-else-if="item.act === 'more'"
55
55
  :key="index"
56
- trigger="click"
56
+ :trigger="item.trigger || 'click'"
57
+ :placement="item.placement || 'bottom-end'"
58
+ :disabled="btnDisabled(item)"
57
59
  @command="
58
- (value) => {
60
+ value => {
59
61
  doMore(value, index, item);
60
62
  }
61
63
  "
@@ -74,6 +76,7 @@
74
76
  :style="btnItem.style"
75
77
  :command="btnItem.act"
76
78
  :icon="btnItem.icon"
79
+ :disabled="btnItem.disabled"
77
80
  >{{ btnItem.name }}</el-dropdown-item
78
81
  >
79
82
  </el-dropdown-menu>
@@ -100,29 +103,29 @@ export default {
100
103
  type: Array,
101
104
  default: () => {
102
105
  return [];
103
- },
106
+ }
104
107
  },
105
108
  scope: {
106
- type: Object | String,
109
+ type: Object | String
107
110
  },
108
111
  permission: {
109
112
  type: Object,
110
- required: false,
113
+ required: false
111
114
  },
112
115
  msg: {
113
116
  type: String,
114
- default: "确定删除本条数据吗?",
115
- },
117
+ default: "确定删除本条数据吗?"
118
+ }
116
119
  },
117
120
  data() {
118
121
  return {
119
122
  pop: false,
120
- loadingDel: false,
123
+ loadingDel: false
121
124
  };
122
125
  },
123
126
  computed: {
124
127
  btnDisabled() {
125
- return (item) => {
128
+ return item => {
126
129
  if (item.disabled instanceof Boolean) {
127
130
  return item.disabled;
128
131
  }
@@ -130,7 +133,7 @@ export default {
130
133
  return item.disabled(this.scope);
131
134
  }
132
135
  };
133
- },
136
+ }
134
137
  },
135
138
  methods: {
136
139
  toDelete() {
@@ -150,7 +153,7 @@ export default {
150
153
  },
151
154
  doDelete(item) {
152
155
  this.loadingDel = true;
153
- const callback = (bool) => {
156
+ const callback = bool => {
154
157
  this.loadingDel = false;
155
158
  this.pop = !bool;
156
159
  };
@@ -164,8 +167,8 @@ export default {
164
167
  break;
165
168
  }
166
169
  }
167
- },
168
- },
170
+ }
171
+ }
169
172
  };
170
173
  </script>
171
174
 
@@ -57,6 +57,15 @@
57
57
  :scope="scope"
58
58
  :option="item"
59
59
  />
60
+ <div v-else-if="item.format">
61
+ {{
62
+ handleFormatTime(
63
+ scope.row[item.alias || item.prop],
64
+ item.format
65
+ )
66
+ }}
67
+ </div>
68
+ <div v-else-if="item.alias">{{ scope.row[item.alias] }}</div>
60
69
  <div v-else>{{ scope.row[item.prop] }}</div>
61
70
  </template>
62
71
  </el-table-column>
@@ -238,6 +247,51 @@ export default {
238
247
  },
239
248
  getTable() {
240
249
  return this.$refs["th_table"];
250
+ },
251
+ handleFormatTime(time, cFormat) {
252
+ console.log(time, cFormat);
253
+ if (arguments.length === 0) {
254
+ return null;
255
+ }
256
+ const format = cFormat || "yyyy-MM-dd HH:mm:ss";
257
+ let date;
258
+ if (typeof time === "undefined" || time === null || time === "null") {
259
+ return "";
260
+ } else if (typeof time === "object") {
261
+ date = time;
262
+ } else {
263
+ if (typeof time === "string" && /^[0-9]+$/.test(time)) {
264
+ time = parseInt(time);
265
+ }
266
+ if (typeof time === "number" && time.toString().length === 10) {
267
+ time = time * 1000;
268
+ }
269
+ date = new Date(time);
270
+ }
271
+ const formatObj = {
272
+ yyyy: date.getFullYear(),
273
+ MM: date.getMonth() + 1,
274
+ dd: date.getDate(),
275
+ HH: date.getHours(),
276
+ mm: date.getMinutes(),
277
+ ss: date.getSeconds(),
278
+ a: date.getDay()
279
+ };
280
+ const time_str = format.replace(
281
+ /(yyyy|MM|dd|HH|mm|ss|a)/g,
282
+ (result, key) => {
283
+ let value = formatObj[key];
284
+ // Note: getDay() returns 0 on Sunday
285
+ if (key === "a") {
286
+ return ["日", "一", "二", "三", "四", "五", "六"][value];
287
+ }
288
+ if (result.length > 0 && value < 10) {
289
+ value = "0" + value;
290
+ }
291
+ return value || 0;
292
+ }
293
+ );
294
+ return time_str;
241
295
  }
242
296
  }
243
297
  };