tianheng-ui 0.0.25 → 0.0.28

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.25",
4
+ "version": "0.0.28",
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>
@@ -183,8 +183,4 @@ export default {
183
183
  margin-left: 0px;
184
184
  }
185
185
  }
186
-
187
- // .el-button + .action-popover {
188
- // margin-left: 10px !important;
189
- // }
190
186
  </style>
@@ -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,50 @@ export default {
238
247
  },
239
248
  getTable() {
240
249
  return this.$refs["th_table"];
250
+ },
251
+ handleFormatTime(time, cFormat) {
252
+ if (arguments.length === 0) {
253
+ return null;
254
+ }
255
+ const format = cFormat || "yyyy-MM-dd HH:mm:ss";
256
+ let date;
257
+ if (typeof time === "undefined" || time === null || time === "null") {
258
+ return "";
259
+ } else if (typeof time === "object") {
260
+ date = time;
261
+ } else {
262
+ if (typeof time === "string" && /^[0-9]+$/.test(time)) {
263
+ time = parseInt(time);
264
+ }
265
+ if (typeof time === "number" && time.toString().length === 10) {
266
+ time = time * 1000;
267
+ }
268
+ date = new Date(time);
269
+ }
270
+ const formatObj = {
271
+ yyyy: date.getFullYear(),
272
+ MM: date.getMonth() + 1,
273
+ dd: date.getDate(),
274
+ HH: date.getHours(),
275
+ mm: date.getMinutes(),
276
+ ss: date.getSeconds(),
277
+ a: date.getDay()
278
+ };
279
+ const time_str = format.replace(
280
+ /(yyyy|MM|dd|HH|mm|ss|a)/g,
281
+ (result, key) => {
282
+ let value = formatObj[key];
283
+ // Note: getDay() returns 0 on Sunday
284
+ if (key === "a") {
285
+ return ["日", "一", "二", "三", "四", "五", "六"][value];
286
+ }
287
+ if (result.length > 0 && value < 10) {
288
+ value = "0" + value;
289
+ }
290
+ return value || 0;
291
+ }
292
+ );
293
+ return time_str;
241
294
  }
242
295
  }
243
296
  };
@@ -0,0 +1,8 @@
1
+ import Tools from "./tools.vue";
2
+
3
+ /* istanbul ignore next */
4
+ Tools.install = function(Vue) {
5
+ Vue.component(Tools.name, Tools);
6
+ };
7
+
8
+ export default Tools;
@@ -1,99 +1,43 @@
1
1
  <template>
2
- <div class="tableTools">
3
- <template v-for="(item, index) in options">
4
- <el-button
5
- v-if="item.act_type === 'add'"
6
- :key="index"
7
- :style="{ color: item.btn_color }"
8
- :type="item.btn_type"
9
- :icon="item.btn_icon"
10
- :disabled="item.btn_disabled"
11
- @click="doAdd(item)"
12
- >{{ item.btn_name }}</el-button
13
- >
14
- <el-button
15
- v-if="item.act_type === 'refresh'"
16
- :key="index"
17
- :style="{ color: item.btn_color }"
18
- :type="item.btn_type"
19
- :icon="item.btn_icon"
20
- :disabled="item.btn_disabled"
21
- @click="doRefresh(item)"
22
- >{{ item.btn_name }}</el-button
23
- >
24
- <el-button
25
- v-if="item.act_type === 'export'"
26
- :key="index"
27
- :style="{ color: item.btn_color }"
28
- :type="item.btn_type"
29
- :icon="item.btn_icon"
30
- :disabled="item.btn_disabled"
31
- @click="doExport(item)"
32
- >{{ item.btn_name }}</el-button
33
- >
34
- <el-button
35
- v-if="item.act_type === 'batch'"
36
- :key="index"
37
- :style="{ color: item.btn_color }"
38
- :type="item.btn_type"
39
- :icon="item.btn_icon"
40
- :disabled="item.btn_disabled || selectionDisabled"
41
- :loading="loadingDel"
42
- @click="doBatch(item)"
43
- >{{ item.btn_name }}</el-button
44
- >
45
- </template>
2
+ <div class="th-Tools">
3
+ <el-button
4
+ v-for="(item, index) in options"
5
+ :key="index"
6
+ :style="item.style"
7
+ :type="item.type"
8
+ :icon="item.icon"
9
+ :disabled="item.disabled || disabled[item.act]"
10
+ :loading="item.loading"
11
+ @click="handleClick(item)"
12
+ >{{ item.name }}</el-button
13
+ >
46
14
  </div>
47
15
  </template>
48
16
 
49
17
  <script>
50
18
  export default {
51
- name: "ThTableTools",
19
+ name:'ThTools',
52
20
  props: {
53
21
  options: {
54
22
  type: Array,
55
23
  default: () => {
56
24
  return [];
57
- }
25
+ },
58
26
  },
59
- selectionDisabled: {
60
- type: Boolean,
27
+ disabled: {
28
+ type: Object,
61
29
  default: () => {
62
- return true;
63
- }
64
- }
30
+ return {};
31
+ },
32
+ },
65
33
  },
66
34
  data() {
67
- return {
68
- loadingDel: false
69
- };
35
+ return {};
70
36
  },
71
37
  methods: {
72
- doEval(item) {
73
- this.$emit("on-eval", item);
74
- },
75
- doAdd(item) {
76
- this.$emit("on-add", item);
77
- },
78
- doRefresh(item) {
79
- this.$emit("on-refresh", item);
38
+ handleClick(item) {
39
+ this.$emit("on-click", item);
80
40
  },
81
- doExport(item) {
82
- this.$emit("on-export", item);
83
- },
84
- doBatch(item) {
85
- this.loadingDel = true;
86
- const callback = bool => {
87
- this.loadingDel = false;
88
- };
89
- this.$emit("on-batch", item, callback);
90
- }
91
- }
41
+ },
92
42
  };
93
43
  </script>
94
-
95
- <style lang="less">
96
- .tableTools {
97
- margin-bottom: 10px;
98
- }
99
- </style>