htui-yllkbz 1.4.9 → 1.4.11

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.
Binary file
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "htui-yllkbz",
3
- "version": "1.4.9",
3
+ "version": "1.4.11",
4
4
  "port": "8082",
5
5
  "typings": "types/index.d.ts",
6
6
  "main": "lib/htui.common.js",
@@ -0,0 +1,242 @@
1
+ <template>
2
+ <el-table-column
3
+ :label="item.title"
4
+ :fixed="item.fixed"
5
+ :align="item.align"
6
+ v-if="fromColumn ? !item.hide : !item.hide && item.checked"
7
+ :resizable="item.resizable"
8
+ :header-align="item.headerAlign"
9
+ :column-key="item.columnKey"
10
+ :class-name="item.className"
11
+ :prop="item.key"
12
+ :show-overflow-tooltip="
13
+ item.type === 'common' || item.type === 'org' || item.type === 'userId'
14
+ ? false
15
+ : item.showOverflowTooltip === false
16
+ ? false
17
+ : true
18
+ "
19
+ :sortable="item.sortable"
20
+ :sort-method="item.sortMethod"
21
+ :sort-orders="item.sortOrders"
22
+ :formatter="item.formatter"
23
+ :sort-by="item.sortBy"
24
+ :min-width="item.minWidth"
25
+ :width="item.width"
26
+ >
27
+ <template v-for="(child, childindex) in item.children">
28
+ <HtTableColumn
29
+ :item="child"
30
+ :fromColumn="true"
31
+ :key="`${child.key}_${childindex}_1`"
32
+ ></HtTableColumn>
33
+ </template>
34
+ <template slot-scope="{ row, column, $index }">
35
+ <slot :name="item.key" :row="row" :column="column" :rowIndex="$index">
36
+ <!-- 处理部门 -->
37
+ <template v-if="item.type === 'org'">
38
+ <HtOrgInfo
39
+ v-if="getPropByPath(row, item.key)"
40
+ :org-id="getPropByPath(row, item.key)"
41
+ type="tag"
42
+ ></HtOrgInfo>
43
+ <span v-else>--</span>
44
+ </template>
45
+ <!-- 处理基础数据 -->
46
+ <template v-else-if="item.type === 'common'">
47
+ <HtShowBaseData
48
+ v-if="getPropByPath(row, item.key)"
49
+ :hide-code="item.hideCode"
50
+ :user-id="
51
+ item.commonType === 'userId'
52
+ ? JSON.stringify([getPropByPath(row, item.key)])
53
+ : '[]'
54
+ "
55
+ :department-id="
56
+ item.commonType === 'departmentId'
57
+ ? JSON.stringify([getPropByPath(row, item.key)])
58
+ : '[]'
59
+ "
60
+ :role-id="
61
+ item.commonType === 'roleId'
62
+ ? JSON.stringify([getPropByPath(row, item.key)])
63
+ : '[]'
64
+ "
65
+ :base-data-id="
66
+ item.commonType === 'baseDataId'
67
+ ? getPropByPath(row, item.key)
68
+ : ''
69
+ "
70
+ :base-data-value="
71
+ item.commonType === 'baseDataValue'
72
+ ? getPropByPath(row, item.key)
73
+ : ''
74
+ "
75
+ :base-data-name="
76
+ item.commonType === 'baseDataName'
77
+ ? getPropByPath(row, item.key)
78
+ : ''
79
+ "
80
+ :base-data-info="true"
81
+ >
82
+ </HtShowBaseData>
83
+
84
+ <span v-else>--</span>
85
+ </template>
86
+ <!-- 处理部门人员 -->
87
+ <template v-else-if="item.type === 'userId'">
88
+ <HtShowBaseData
89
+ v-if="getPropByPath(row, item.key)"
90
+ :user-id="JSON.stringify(getPropByPath(row, item.key))"
91
+ :base-data-info="true"
92
+ >
93
+ </HtShowBaseData>
94
+
95
+ <span v-else>--</span>
96
+ </template>
97
+ <!-- 处理时间 yyyy-mm-dd HH:mm:ss -->
98
+ <template v-else-if="item.type === 'time'">
99
+ <div v-if="getPropByPath(row, item.key)" class="ht-column-cell">
100
+ <span v-if="!item.spread">
101
+ {{
102
+ getPropByPath(row, item.key)
103
+ .replace('T', ' ')
104
+ .slice(0, 19)
105
+ }}</span
106
+ >
107
+ <template v-else>
108
+ <p style="color:var(--primary);margin:0;padding:0">
109
+ {{ getPropByPath(row, item.key).slice(11, 19) }}
110
+ </p>
111
+ <p style="margin:0;padding:0">
112
+ {{
113
+ getPropByPath(row, item.key)
114
+ .replace('T', ' ')
115
+ .slice(0, 10)
116
+ }}
117
+ </p>
118
+ </template>
119
+ </div>
120
+ <span v-else>--</span>
121
+ </template>
122
+ <!-- 处理日期 yyyy-mm-dd -->
123
+ <template v-else-if="item.type === 'date'">
124
+ <div v-if="getPropByPath(row, item.key)" class="ht-column-cell">
125
+ <span>
126
+ {{
127
+ getPropByPath(row, item.key)
128
+ .replace('T', ' ')
129
+ .slice(0, 10)
130
+ }}</span
131
+ >
132
+ </div>
133
+ <span v-else>--</span>
134
+ </template>
135
+ <!-- 处理布尔值显示 -->
136
+ <template v-else-if="item.type === 'boolean'">
137
+ <el-tag
138
+ :type="'success'"
139
+ :size="'small'"
140
+ v-if="getPropByPath(row, item.key)"
141
+ >是</el-tag
142
+ >
143
+ <el-tag type="danger" :size="'small'" v-else>否</el-tag>
144
+ </template>
145
+ <!-- 处理新资产的单位 -->
146
+ <template v-else-if="item.type === 'unit'">
147
+ <HtSelectUnit
148
+ :readonly="true"
149
+ :value="getPropByPath(row, item.key)"
150
+ ></HtSelectUnit>
151
+ </template>
152
+ <!-- 处理新资产的单位 -->
153
+ <template v-else-if="item.type === 'position'">
154
+ <HtSelectPosition
155
+ :readonly="true"
156
+ :value="getPropByPath(row, item.key)"
157
+ ></HtSelectPosition>
158
+ </template>
159
+ <!-- 处理图片显示 -->
160
+ <template v-else-if="item.type === 'img'">
161
+ <span v-if="getPropByPath(row, item.key)">
162
+ <el-image
163
+ style="width: 38px; height: 38px;margin-right:5px"
164
+ :key="fileToken"
165
+ v-for="fileToken in getPropByPath(row, item.key).split(',')"
166
+ :src="'/files/api/filing/file/download/' + fileToken"
167
+ :preview-src-list="[
168
+ '/files/api/filing/file/download/' + fileToken,
169
+ ]"
170
+ >
171
+ </el-image>
172
+ </span>
173
+ </template>
174
+ <!-- 处理附件显示 -->
175
+ <template v-else-if="item.type === 'file'">
176
+ <span v-if="getPropByPath(row, item.key)">
177
+ <i
178
+ class="el-icon-paperclip"
179
+ @click="$emit('showFiles', getPropByPath(row, item.key))"
180
+ style="color:var(--primary);cursor:pointer"
181
+ >{{
182
+ Array.isArray(getPropByPath(row, item.key))
183
+ ? getPropByPath(row, item.key).length
184
+ : getPropByPath(row, item.key).split(',').length
185
+ }}</i
186
+ >
187
+ </span>
188
+ <span v-else>--</span>
189
+ </template>
190
+ <!-- 其他 -->
191
+ <span v-else>{{ getPropByPath(row, item.key) }}</span>
192
+ </slot>
193
+ </template>
194
+ <!-- 处理重定义table头相关信息 header_key -->
195
+ <template slot-scope="{ column, $index }" slot="header">
196
+ <slot :name="'header_' + item.key" :column="column" :$index="$index">{{
197
+ item.title
198
+ }}</slot>
199
+ </template>
200
+ </el-table-column>
201
+ </template>
202
+ <script lang="ts">
203
+ import { Component, Prop, Vue } from 'vue-property-decorator';
204
+ import { Column } from '../type';
205
+ import HtShowBaseData from '@/packages/HtShowBaseData';
206
+ import HtOrgInfo from '@/packages/HtOrgInfo';
207
+ import HtUploadFiles from '@/packages/HtUploadFiles/index.vue';
208
+ import HtSelectUnit from '@/packages/HtSelectUnit';
209
+ import { getPropByPath } from './table-span-method';
210
+ interface State {
211
+ /** 数据状态 */
212
+ loading: boolean;
213
+ }
214
+ @Component({
215
+ components: {
216
+ HtUploadFiles,
217
+ HtShowBaseData,
218
+ HtOrgInfo,
219
+ HtSelectUnit,
220
+ HtTableColumn: () => import('./htTableColumn.vue'),
221
+ // MenuItem: () => import('./menuItem.vue'),
222
+ },
223
+ })
224
+ export default class Index extends Vue {
225
+ /** 单个Column信息 */
226
+ @Prop() item!: Column;
227
+ /** 是否来自循环嵌套 */
228
+ @Prop() fromColumn!: boolean;
229
+ /** 数据 */
230
+ state: State = {
231
+ loading: false,
232
+ };
233
+ /** 生命周期 */
234
+ /** 方法 */
235
+ getPropByPath(obj: any, path: string, strict = true) {
236
+ return getPropByPath(obj, path, strict);
237
+ }
238
+ /** 监听 */
239
+ /** 计算属性 */
240
+ }
241
+ </script>
242
+ <style lang="scss" scoped></style>
@@ -4,9 +4,10 @@
4
4
  * @Author: hutao
5
5
  * @Date: 2021-11-15 15:00:57
6
6
  * @LastEditors: hutao
7
- * @LastEditTime: 2021-12-19 14:10:11
7
+ * @LastEditTime: 2023-04-09 10:42:47
8
8
  */
9
- import HtTable from "./index.vue";
9
+ // import HtTable from "./index.vue";
10
+ import HtTable from "./table.vue";
10
11
  (HtTable as any).install = function (Vue: any) {
11
12
 
12
13
  Vue.component("HtTable", HtTable);
@@ -4,7 +4,7 @@
4
4
  * @Author: hutao
5
5
  * @Date: 2021-11-11 11:23:24
6
6
  * @LastEditors: hutao
7
- * @LastEditTime: 2023-04-04 09:59:39
7
+ * @LastEditTime: 2023-04-09 10:33:03
8
8
  -->
9
9
  <template>
10
10
  <div v-loading="state.loading" style="background:#fff">
@@ -230,7 +230,7 @@
230
230
 
231
231
  <span v-else>--</span>
232
232
  </template>
233
- <!-- 处理时间 -->
233
+ <!-- 处理时间 yyyy-mm-dd HH:mm:ss -->
234
234
  <template v-else-if="item.type === 'time'">
235
235
  <div
236
236
  v-if="getPropByPath(row, item.key)"
@@ -258,6 +258,22 @@
258
258
  </div>
259
259
  <span v-else>--</span>
260
260
  </template>
261
+ <!-- 处理日期 yyyy-mm-dd -->
262
+ <template v-else-if="item.type === 'date'">
263
+ <div
264
+ v-if="getPropByPath(row, item.key)"
265
+ class="ht-column-cell"
266
+ >
267
+ <span>
268
+ {{
269
+ getPropByPath(row, item.key)
270
+ .replace('T', ' ')
271
+ .slice(0, 10)
272
+ }}</span
273
+ >
274
+ </div>
275
+ <span v-else>--</span>
276
+ </template>
261
277
  <!-- 处理布尔值显示 -->
262
278
  <template v-else-if="item.type === 'boolean'">
263
279
  <el-tag
@@ -0,0 +1,135 @@
1
+ /*
2
+ * @Descripttion:
3
+ * @version:
4
+ * @Author: hutao
5
+ * @Date: 2023-04-09 14:33:12
6
+ * @LastEditors: hutao
7
+ * @LastEditTime: 2023-04-09 15:45:30
8
+ */
9
+ /** 处理table里面根据字段获取对应的值 */
10
+ export function getPropByPath(obj: any, path: string, strict = true) {
11
+ let tempObj = obj;
12
+ path = path.replace(/\[(\w+)\]/g, '.$1');
13
+ path = path.replace(/^\./, '');
14
+
15
+ const keyArr = path.split('.');
16
+ let i = 0;
17
+ for (let len = keyArr.length; i < len - 1; ++i) {
18
+ if (!tempObj && !strict) break;
19
+ const key = keyArr[i];
20
+ if (key in tempObj) {
21
+ tempObj = tempObj[key];
22
+ } else {
23
+ if (strict) {
24
+ throw new Error(`table中${path}字段发生错误,请检查`);
25
+ }
26
+ break;
27
+ }
28
+ }
29
+ // return {
30
+ // o: tempObj,
31
+ // k: keyArr[i],
32
+ // v: tempObj ? tempObj[keyArr[i]] : null,
33
+ // };
34
+ return tempObj ? tempObj[keyArr[i]] : null;
35
+ }
36
+ /**
37
+ * 合并相同数据,导出合并行所需的方法(只适合el-table)
38
+ * @param {Array} dataArray el-table表数据源
39
+ * @param {Array} mergeRowProp 合并行的列prop
40
+ * @param {Array} sameRuleRowProp 相同合并规则行的列prop
41
+ * @param {Object} connentProp 某个字段的合并基于其余字段的key是否相同
42
+ */
43
+ export function getSpanMethod(dataArray: any[], mergeRowProp: string[], sameRuleRowProp: string[], connentProp: any) {
44
+
45
+ /**
46
+ * 要合并行的数据
47
+ */
48
+ const rowspanNumObject: any = {};
49
+
50
+ //初始化 rowspanNumObject
51
+ mergeRowProp.map(item => {
52
+ rowspanNumObject[item] = new Array(dataArray.length).fill(1, 0, 1).fill(0, 1);
53
+ rowspanNumObject[`${item}-index`] = 0;
54
+ });
55
+ function isConnent(strArr: string[], num: number) {
56
+ let isConnn = true;
57
+ for (let i = 0; i < strArr.length; i++) {
58
+ if (getPropByPath(dataArray[num], strArr[i]) !== getPropByPath(dataArray[num - 1], strArr[i])) {
59
+ isConnn = false
60
+ }
61
+ }
62
+ return isConnn
63
+ }
64
+ //计算相关的合并信息
65
+ for (let i = 1; i < dataArray.length; i++) {
66
+ mergeRowProp.map(key => {
67
+ const index = rowspanNumObject[`${key}-index`];
68
+
69
+ // if (dataArray[i][key] === dataArray[i - 1][key]) {
70
+ // rowspanNumObject[key][index]++;
71
+ // } else {
72
+ // rowspanNumObject[`${key}-index`] = i;
73
+ // rowspanNumObject[key][i] = 1;
74
+ // }
75
+ if (getPropByPath(dataArray[i], key) === getPropByPath(dataArray[i - 1], key)) {
76
+ const connetKey = connentProp[key] as any;
77
+
78
+ if (connetKey) {
79
+ const connetKeyArr = connetKey.split(",");
80
+ if (isConnent(connetKeyArr, i)) {
81
+ rowspanNumObject[key][index]++;
82
+ }
83
+ // if (getPropByPath(dataArray[i], connetKey) === getPropByPath(dataArray[i - 1], connetKey)) {
84
+
85
+ // }
86
+ else {
87
+ rowspanNumObject[`${key}-index`] = i;
88
+ rowspanNumObject[key][i] = 1;
89
+ }
90
+
91
+ }
92
+ else {
93
+ rowspanNumObject[key][index]++;
94
+ }
95
+
96
+ } else {
97
+ rowspanNumObject[`${key}-index`] = i;
98
+ rowspanNumObject[key][i] = 1;
99
+ }
100
+
101
+ });
102
+ }
103
+
104
+ /**
105
+ * 添加同规则合并行的数据
106
+ */
107
+ if (sameRuleRowProp !== undefined) {
108
+ const k = Object.keys(rowspanNumObject).filter(key => {
109
+ if (!key.includes('index')) {
110
+ return key
111
+ }
112
+ })[0]
113
+ for (const prop of sameRuleRowProp) {
114
+ rowspanNumObject[prop] = rowspanNumObject[k]
115
+ rowspanNumObject[`${prop}-index`] = rowspanNumObject[`${k}-index`]
116
+ mergeRowProp.push(prop)
117
+ }
118
+ }
119
+
120
+ /**
121
+ * 导出合并方法
122
+ */
123
+ const spanMethod = function ({ row, column, rowIndex, columnIndex }: any) {
124
+ // const colData = getPropByPath(row, column['property'])
125
+ if (mergeRowProp.includes(column['property'])) {
126
+ const rowspan = rowspanNumObject[column['property']][rowIndex];
127
+ if (rowspan > 0) {
128
+ return { rowspan: rowspan, colspan: 1 }
129
+ }
130
+ return { rowspan: 0, colspan: 0 }
131
+ }
132
+ return { rowspan: 1, colspan: 1 }
133
+ };
134
+ return spanMethod;
135
+ }