tianheng-ui 0.1.36 → 0.1.38

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.
@@ -0,0 +1,118 @@
1
+ <template>
2
+ <div class="generateTable-action" @click.stop>
3
+ <template v-for="(item, index) in options">
4
+ <el-popover
5
+ v-if="item.type === 'delete'"
6
+ v-model="pop"
7
+ :key="index"
8
+ placement="top"
9
+ width="180"
10
+ trigger="manual"
11
+ >
12
+ <p>{{ item.delmsg || msg }}</p>
13
+ <div style="text-align: right; margin: 0">
14
+ <el-button type="text" :disabled="loadingDel" @click="handleCancel"
15
+ >取消</el-button
16
+ >
17
+ <el-button
18
+ type="text"
19
+ :loading="loadingDel"
20
+ @click="handleDelete(item)"
21
+ >确定</el-button
22
+ >
23
+ </div>
24
+ <el-button
25
+ slot="reference"
26
+ :style="item.style.customStyle"
27
+ :type="item.style.type"
28
+ :icon="item.style.icon"
29
+ :plain="item.style.plain"
30
+ :round="item.style.round"
31
+ :circle="item.style.circle"
32
+ :size="item.style.size"
33
+ :disabled="item.style.disabled || loadingDel"
34
+ :loading="item.style.loading"
35
+ @click="pop = true"
36
+ >{{ item.name }}</el-button
37
+ >
38
+ </el-popover>
39
+ <el-button
40
+ v-else
41
+ :key="index"
42
+ :style="item.style.customStyle"
43
+ :type="item.style.type"
44
+ :icon="item.style.icon"
45
+ :plain="item.style.plain"
46
+ :round="item.style.round"
47
+ :circle="item.style.circle"
48
+ :size="item.style.size"
49
+ :disabled="item.style.disabled"
50
+ :loading="item.style.loading"
51
+ @click="handleClick(item)"
52
+ >{{ item.name }}</el-button
53
+ >
54
+ </template>
55
+ </div>
56
+ </template>
57
+
58
+ <script>
59
+ export default {
60
+ name: "ThTableAction",
61
+ props: {
62
+ options: Array,
63
+ scope: Object | String,
64
+ permission: {
65
+ type: Object,
66
+ required: false
67
+ },
68
+ msg: {
69
+ type: String,
70
+ default: "确定删除本条数据吗?"
71
+ }
72
+ },
73
+ data() {
74
+ return {
75
+ pop: false,
76
+ loadingDel: false
77
+ };
78
+ },
79
+ methods: {
80
+ handleCancel() {
81
+ this.loadingDel = false;
82
+ this.pop = false;
83
+ },
84
+ handleClick(item, callback) {
85
+ this.$emit("click", item, this.scope.row, callback);
86
+ },
87
+ handleDelete(item) {
88
+ this.loadingDel = true;
89
+ const callback = bool => {
90
+ bool ? this.handleCancel() : (this.loadingDel = false);
91
+ };
92
+ this.handleClick(item, callback);
93
+ },
94
+ handleMore(value, index, item) {
95
+ for (let i = 0; i < item.children.length; i++) {
96
+ const element = item.children[i];
97
+ if (element.type === value) {
98
+ this.handleClick(element);
99
+ break;
100
+ }
101
+ }
102
+ }
103
+ }
104
+ };
105
+ </script>
106
+
107
+ <style lang="scss" scoped>
108
+ .generateTable-action {
109
+ width: 100%;
110
+ display: flex;
111
+ align-items: center;
112
+ justify-content: space-around;
113
+
114
+ .el-button + .el-button {
115
+ margin-left: 0px;
116
+ }
117
+ }
118
+ </style>
@@ -4,16 +4,38 @@
4
4
  :style="config.style.table.customStyle"
5
5
  :data="data"
6
6
  :border="config.style.table.border"
7
- :height="config.style.table.height"
7
+ :height="config.style.table.height || null"
8
+ :empty-text="config.empty.text"
9
+ v-loading="config.loading.show"
10
+ :element-loading-text="config.loading.text"
8
11
  >
9
- <el-table-column
10
- v-for="item in config.options"
11
- :key="item.prop"
12
- :prop="item.prop"
13
- :label="item.label"
14
- :width="item.width || 180"
15
- >
16
- </el-table-column>
12
+ <template v-for="item in config.options">
13
+ <el-table-column
14
+ v-if="item.type"
15
+ :key="item.prop"
16
+ :type="item.type"
17
+ :label="item.label"
18
+ :width="item.width || 50"
19
+ >
20
+ </el-table-column>
21
+ <el-table-column
22
+ v-else
23
+ :key="item.prop"
24
+ :prop="item.prop"
25
+ :label="item.label"
26
+ :width="item.width || 180"
27
+ >
28
+ <template slot-scope="scope">
29
+ <slot
30
+ v-if="item.slot"
31
+ :name="item.slot"
32
+ :scope="scope"
33
+ :option="item"
34
+ />
35
+ <span v-else>{{ scope.row[item.prop] }}</span>
36
+ </template>
37
+ </el-table-column>
38
+ </template>
17
39
  </el-table>
18
40
  </div>
19
41
  </template>
@@ -22,15 +44,18 @@
22
44
  export default {
23
45
  props: {
24
46
  data: Array,
25
- config: Object
47
+ config: {
48
+ type: Object,
49
+ default: () => {
50
+ return { style: {} };
51
+ }
52
+ }
26
53
  },
27
54
  data() {
28
55
  return {};
29
56
  },
30
57
  created() {},
31
- mounted() {
32
- console.log(this.config)
33
- },
58
+ mounted() {},
34
59
  methods: {}
35
60
  };
36
61
  </script>