| | |
| | | package com.zy.common.web; |
| | | |
| | | import com.baomidou.mybatisplus.annotation.TableId; |
| | | import com.baomidou.mybatisplus.annotation.TableField; |
| | | import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper; |
| | | import com.core.common.BaseRes; |
| | |
| | | || Modifier.isTransient(field.getModifiers())){ |
| | | continue; |
| | | } |
| | | String column = null; |
| | | if (field.isAnnotationPresent(TableField.class)) { |
| | | column = field.getAnnotation(TableField.class).value(); |
| | | } |
| | | String column = resolveColumn(field); |
| | | if (Cools.isEmpty(column)) { |
| | | column = field.getName(); |
| | | continue; |
| | | } |
| | | if (!set.contains(column) && !set.contains(field.getName())) { |
| | | columns.add(column); |
| | |
| | | } |
| | | }); |
| | | } |
| | | |
| | | private String resolveColumn(Field field) { |
| | | String column = null; |
| | | if (field.isAnnotationPresent(TableField.class)) { |
| | | TableField tableField = field.getAnnotation(TableField.class); |
| | | if (!tableField.exist()) { |
| | | return null; |
| | | } |
| | | column = tableField.value(); |
| | | } else if (field.isAnnotationPresent(TableId.class)) { |
| | | column = field.getAnnotation(TableId.class).value(); |
| | | } |
| | | if (Cools.isEmpty(column)) { |
| | | column = humpToLine(field.getName()); |
| | | } |
| | | return column; |
| | | } |
| | | } |
| | |
| | | |
| | | private void convert(Map<String, Object> map, QueryWrapper wrapper){ |
| | | for (Map.Entry<String, Object> entry : map.entrySet()){ |
| | | if (entry.getKey().endsWith(">")) { |
| | | wrapper.ge(Cools.deleteChar(entry.getKey()), DateUtils.convert(String.valueOf(entry.getValue()))); |
| | | } else if (entry.getKey().endsWith("<")) { |
| | | wrapper.le(Cools.deleteChar(entry.getKey()), DateUtils.convert(String.valueOf(entry.getValue()))); |
| | | String val = String.valueOf(entry.getValue()); |
| | | String column = humpToLine(entry.getKey()); |
| | | if (val.contains(" - ")) { |
| | | String[] dates = val.split(" - "); |
| | | wrapper.ge(column, DateUtils.convert(dates[0])); |
| | | wrapper.le(column, DateUtils.convert(dates[1])); |
| | | } else { |
| | | wrapper.like(entry.getKey(), String.valueOf(entry.getValue())); |
| | | wrapper.like(column, val); |
| | | } |
| | | } |
| | | } |
| | |
| | | |
| | | private void convert(Map<String, Object> map, QueryWrapper wrapper){ |
| | | for (Map.Entry<String, Object> entry : map.entrySet()){ |
| | | if (entry.getKey().endsWith(">")) { |
| | | wrapper.ge(Cools.deleteChar(entry.getKey()), DateUtils.convert(String.valueOf(entry.getValue()))); |
| | | } else if (entry.getKey().endsWith("<")) { |
| | | wrapper.le(Cools.deleteChar(entry.getKey()), DateUtils.convert(String.valueOf(entry.getValue()))); |
| | | String val = String.valueOf(entry.getValue()); |
| | | String column = humpToLine(entry.getKey()); |
| | | if (val.contains(" - ")) { |
| | | String[] dates = val.split(" - "); |
| | | wrapper.ge(column, DateUtils.convert(dates[0])); |
| | | wrapper.le(column, DateUtils.convert(dates[1])); |
| | | } else { |
| | | wrapper.like(entry.getKey(), String.valueOf(entry.getValue())); |
| | | wrapper.like(column, val); |
| | | } |
| | | } |
| | | } |
| | |
| | | |
| | | private void convert(Map<String, Object> map, QueryWrapper wrapper){ |
| | | for (Map.Entry<String, Object> entry : map.entrySet()){ |
| | | if (entry.getKey().endsWith(">")) { |
| | | wrapper.ge(Cools.deleteChar(entry.getKey()), DateUtils.convert(String.valueOf(entry.getValue()))); |
| | | } else if (entry.getKey().endsWith("<")) { |
| | | wrapper.le(Cools.deleteChar(entry.getKey()), DateUtils.convert(String.valueOf(entry.getValue()))); |
| | | String val = String.valueOf(entry.getValue()); |
| | | String column = humpToLine(entry.getKey()); |
| | | if (val.contains(" - ")) { |
| | | String[] dates = val.split(" - "); |
| | | wrapper.ge(column, DateUtils.convert(dates[0])); |
| | | wrapper.le(column, DateUtils.convert(dates[1])); |
| | | } else { |
| | | wrapper.like(entry.getKey(), String.valueOf(entry.getValue())); |
| | | wrapper.like(column, val); |
| | | } |
| | | } |
| | | } |
| | |
| | | |
| | | private void convert(Map<String, Object> map, QueryWrapper wrapper){ |
| | | for (Map.Entry<String, Object> entry : map.entrySet()){ |
| | | if (entry.getKey().endsWith(">")) { |
| | | wrapper.ge(Cools.deleteChar(entry.getKey()), DateUtils.convert(String.valueOf(entry.getValue()))); |
| | | } else if (entry.getKey().endsWith("<")) { |
| | | wrapper.le(Cools.deleteChar(entry.getKey()), DateUtils.convert(String.valueOf(entry.getValue()))); |
| | | String val = String.valueOf(entry.getValue()); |
| | | String column = humpToLine(entry.getKey()); |
| | | if (val.contains(" - ")) { |
| | | String[] dates = val.split(" - "); |
| | | wrapper.ge(column, DateUtils.convert(dates[0])); |
| | | wrapper.le(column, DateUtils.convert(dates[1])); |
| | | } else { |
| | | wrapper.like(entry.getKey(), String.valueOf(entry.getValue())); |
| | | wrapper.like(column, val); |
| | | } |
| | | } |
| | | } |
| | |
| | | |
| | | private void convert(Map<String, Object> map, QueryWrapper wrapper){ |
| | | for (Map.Entry<String, Object> entry : map.entrySet()){ |
| | | if (entry.getKey().endsWith(">")) { |
| | | wrapper.ge(Cools.deleteChar(entry.getKey()), DateUtils.convert(String.valueOf(entry.getValue()))); |
| | | } else if (entry.getKey().endsWith("<")) { |
| | | wrapper.le(Cools.deleteChar(entry.getKey()), DateUtils.convert(String.valueOf(entry.getValue()))); |
| | | String val = String.valueOf(entry.getValue()); |
| | | String column = humpToLine(entry.getKey()); |
| | | if (val.contains(" - ")) { |
| | | String[] dates = val.split(" - "); |
| | | wrapper.ge(column, DateUtils.convert(dates[0])); |
| | | wrapper.le(column, DateUtils.convert(dates[1])); |
| | | } else { |
| | | wrapper.like(entry.getKey(), String.valueOf(entry.getValue())); |
| | | wrapper.like(column, val); |
| | | } |
| | | } |
| | | } |
| | |
| | | |
| | | private void convert(Map<String, Object> map, QueryWrapper wrapper){ |
| | | for (Map.Entry<String, Object> entry : map.entrySet()){ |
| | | if (entry.getKey().endsWith(">")) { |
| | | wrapper.ge(Cools.deleteChar(entry.getKey()), DateUtils.convert(String.valueOf(entry.getValue()))); |
| | | } else if (entry.getKey().endsWith("<")) { |
| | | wrapper.le(Cools.deleteChar(entry.getKey()), DateUtils.convert(String.valueOf(entry.getValue()))); |
| | | String val = String.valueOf(entry.getValue()); |
| | | String column = humpToLine(entry.getKey()); |
| | | if (val.contains(" - ")) { |
| | | String[] dates = val.split(" - "); |
| | | wrapper.ge(column, DateUtils.convert(dates[0])); |
| | | wrapper.le(column, DateUtils.convert(dates[1])); |
| | | } else { |
| | | wrapper.eq(entry.getKey(), String.valueOf(entry.getValue())); |
| | | wrapper.eq(column, val); |
| | | } |
| | | } |
| | | } |
| | |
| | | |
| | | private void convert(Map<String, Object> map, QueryWrapper wrapper){ |
| | | for (Map.Entry<String, Object> entry : map.entrySet()){ |
| | | if (entry.getKey().endsWith(">")) { |
| | | wrapper.ge(Cools.deleteChar(entry.getKey()), DateUtils.convert(String.valueOf(entry.getValue()))); |
| | | } else if (entry.getKey().endsWith("<")) { |
| | | wrapper.le(Cools.deleteChar(entry.getKey()), DateUtils.convert(String.valueOf(entry.getValue()))); |
| | | String val = String.valueOf(entry.getValue()); |
| | | String column = humpToLine(entry.getKey()); |
| | | if (val.contains(" - ")) { |
| | | String[] dates = val.split(" - "); |
| | | wrapper.ge(column, DateUtils.convert(dates[0])); |
| | | wrapper.le(column, DateUtils.convert(dates[1])); |
| | | } else { |
| | | wrapper.like(entry.getKey(), String.valueOf(entry.getValue())); |
| | | wrapper.like(column, val); |
| | | } |
| | | } |
| | | } |
| | |
| | | |
| | | private void convert(Map<String, Object> map, QueryWrapper wrapper){ |
| | | for (Map.Entry<String, Object> entry : map.entrySet()){ |
| | | if (entry.getKey().endsWith(">")) { |
| | | wrapper.ge(Cools.deleteChar(entry.getKey()), DateUtils.convert(String.valueOf(entry.getValue()))); |
| | | } else if (entry.getKey().endsWith("<")) { |
| | | wrapper.le(Cools.deleteChar(entry.getKey()), DateUtils.convert(String.valueOf(entry.getValue()))); |
| | | String val = String.valueOf(entry.getValue()); |
| | | String column = humpToLine(entry.getKey()); |
| | | if (val.contains(" - ")) { |
| | | String[] dates = val.split(" - "); |
| | | wrapper.ge(column, DateUtils.convert(dates[0])); |
| | | wrapper.le(column, DateUtils.convert(dates[1])); |
| | | } else { |
| | | wrapper.like(entry.getKey(), String.valueOf(entry.getValue())); |
| | | wrapper.like(column, val); |
| | | } |
| | | } |
| | | } |
| | |
| | | |
| | | private void convert(Map<String, Object> map, QueryWrapper wrapper){ |
| | | for (Map.Entry<String, Object> entry : map.entrySet()){ |
| | | if (entry.getKey().endsWith(">")) { |
| | | wrapper.ge(Cools.deleteChar(entry.getKey()), DateUtils.convert(String.valueOf(entry.getValue()))); |
| | | } else if (entry.getKey().endsWith("<")) { |
| | | wrapper.le(Cools.deleteChar(entry.getKey()), DateUtils.convert(String.valueOf(entry.getValue()))); |
| | | String val = String.valueOf(entry.getValue()); |
| | | String column = humpToLine(entry.getKey()); |
| | | if (val.contains(" - ")) { |
| | | String[] dates = val.split(" - "); |
| | | wrapper.ge(column, DateUtils.convert(dates[0])); |
| | | wrapper.le(column, DateUtils.convert(dates[1])); |
| | | } else { |
| | | wrapper.like(entry.getKey(), String.valueOf(entry.getValue())); |
| | | wrapper.like(column, val); |
| | | } |
| | | } |
| | | } |
| | |
| | | } |
| | | ]; |
| | | |
| | | function applySelectTypeOptions(options) { |
| | | var normalizedOptions = []; |
| | | (options || []).forEach(function (item) { |
| | | var rawValue = ''; |
| | | var label = ''; |
| | | if (item && typeof item === 'object') { |
| | | rawValue = item.value !== undefined ? item.value : (item.rawValue !== undefined ? item.rawValue : (item.label !== undefined ? item.label : '')); |
| | | label = item.label !== undefined ? item.label : rawValue; |
| | | } else { |
| | | rawValue = item; |
| | | label = item; |
| | | } |
| | | rawValue = isEmptyValue(rawValue) ? '' : String(rawValue); |
| | | label = isEmptyValue(label) ? rawValue : String(label); |
| | | if (!rawValue) { |
| | | return; |
| | | } |
| | | normalizedOptions.push({ |
| | | rawValue: rawValue, |
| | | label: label |
| | | }); |
| | | }); |
| | | fieldMeta.forEach(function (field) { |
| | | if (field.field !== 'selectType') { |
| | | return; |
| | | } |
| | | field.kind = 'enum'; |
| | | field.enumOptions = normalizedOptions; |
| | | }); |
| | | } |
| | | |
| | | function isEmptyValue(value) { |
| | | return value === null || value === undefined || value === ''; |
| | | } |
| | |
| | | } |
| | | }, |
| | | created: function () { |
| | | this.fetchSelectTypeOptions(); |
| | | this.loadTable(); |
| | | }, |
| | | mounted: function () { |
| | |
| | | } |
| | | }); |
| | | }, |
| | | fetchSelectTypeOptions: function () { |
| | | var self = this; |
| | | $.ajax({ |
| | | url: baseUrl + '/config/getSelectTypes', |
| | | method: 'POST', |
| | | headers: self.authHeaders(), |
| | | success: function (res) { |
| | | if (self.handleForbidden(res)) { |
| | | return; |
| | | } |
| | | if (!res || res.code !== 200) { |
| | | return; |
| | | } |
| | | applySelectTypeOptions(Array.isArray(res.data) ? res.data : []); |
| | | self.fieldMeta = fieldMeta.slice(); |
| | | self.allColumns = fieldMeta.slice(); |
| | | self.requestTableLayout(80); |
| | | } |
| | | }); |
| | | }, |
| | | handleSearch: function () { |
| | | this.page.curr = 1; |
| | | this.loadTable(); |
| | |
| | | } |
| | | }, |
| | | methods: { |
| | | displayCellValue: function (row, column) { |
| | | var value; |
| | | if (!row || !column) { |
| | | return ""; |
| | | } |
| | | value = row[column.prop]; |
| | | return value === null || value === undefined || value === "" ? "" : value; |
| | | }, |
| | | buildQueryParams: function () { |
| | | var data = { |
| | | curr: this.currentPage, |
| | |
| | | line-height: 34px; |
| | | } |
| | | |
| | | .search-form .el-button { |
| | | display: inline-flex; |
| | | align-items: center; |
| | | justify-content: center; |
| | | } |
| | | |
| | | .search-form .el-button [class^="el-icon"] { |
| | | line-height: 1; |
| | | } |
| | | |
| | | .table-wrap { |
| | | padding: 12px 18px 16px; |
| | | } |
| | |
| | | </el-tag> |
| | | </template> |
| | | </el-table-column> |
| | | <el-table-column label="状态" width="130" align="center"> |
| | | <el-table-column label="状态" width="88" align="center"> |
| | | <template slot-scope="scope"> |
| | | <div class="status-switch"> |
| | | <el-switch |
| | | v-model="scope.row.status" |
| | | :active-value="1" |
| | | :inactive-value="0" |
| | | active-text="正常" |
| | | inactive-text="禁用" |
| | | @change="toggleStatus(scope.row)"> |
| | | </el-switch> |
| | | </div> |
| | |
| | | :sortable="column.sortable ? 'custom' : false" |
| | | :show-overflow-tooltip="column.showOverflow !== false" |
| | | :align="column.align || 'left'"> |
| | | <template v-if="column.key === 'systemMsg'" slot-scope="scope"> |
| | | <span class="payload-cell">{{ scope.row.systemMsg || '--' }}</span> |
| | | <template slot-scope="scope"> |
| | | <span :class="column.key === 'systemMsg' ? 'payload-cell' : ''"> |
| | | {{ displayCellValue(scope.row, column) }} |
| | | </span> |
| | | </template> |
| | | </el-table-column> |
| | | <el-table-column label="操作" fixed="right" width="100" align="center"> |