diff --git a/web/src/js/component/table/index.js b/web/src/js/component/table/index.js
index 350c6b1a73..5def7449c0 100644
--- a/web/src/js/component/table/index.js
+++ b/web/src/js/component/table/index.js
@@ -15,7 +15,7 @@
*
*/
-import WeTable from './table.vue';
+import WeTable from './resultTable/table.vue';
import historyTable from './historyTable/historyTable.vue';
export default { WeTable,
diff --git a/web/src/js/component/table/resultTable/body.vue b/web/src/js/component/table/resultTable/body.vue
new file mode 100644
index 0000000000..502a4aa3f2
--- /dev/null
+++ b/web/src/js/component/table/resultTable/body.vue
@@ -0,0 +1,285 @@
+
+
+
+
+
diff --git a/web/src/js/component/table/resultTable/header.vue b/web/src/js/component/table/resultTable/header.vue
new file mode 100644
index 0000000000..f8bfc2fec5
--- /dev/null
+++ b/web/src/js/component/table/resultTable/header.vue
@@ -0,0 +1,128 @@
+
+
+
+
diff --git a/web/src/js/component/table/resultTable/list.vue b/web/src/js/component/table/resultTable/list.vue
new file mode 100644
index 0000000000..aab7cf4e1e
--- /dev/null
+++ b/web/src/js/component/table/resultTable/list.vue
@@ -0,0 +1,102 @@
+
+
+
+
diff --git a/web/src/js/component/table/resultTable/table.vue b/web/src/js/component/table/resultTable/table.vue
new file mode 100644
index 0000000000..faa5693b04
--- /dev/null
+++ b/web/src/js/component/table/resultTable/table.vue
@@ -0,0 +1,188 @@
+
+
+
+
+
+
diff --git a/web/src/js/module/hiveSidebar/hiveSidebar.vue b/web/src/js/module/hiveSidebar/hiveSidebar.vue
index 4479c4d27b..2edfe52691 100644
--- a/web/src/js/module/hiveSidebar/hiveSidebar.vue
+++ b/web/src/js/module/hiveSidebar/hiveSidebar.vue
@@ -307,8 +307,8 @@ export default {
this.dispatch('Workbench:pasteInEditor', value, this.node);
},
queryTable() {
- const tabName = `${this.currentAcitved.dbName}.${this.currentAcitved.name}`;
- const code = `select * from ${tabName} limit 100`;
+ const tabName = `${this.currentAcitved.dbName}_${this.currentAcitved.name}`;
+ const code = `select * from ${this.currentAcitved.dbName}.${this.currentAcitved.name} limit 100`;
const filename = `${tabName}_select.hql`;
const md5Path = util.md5(filename);
this.dispatch('Workbench:add', {
diff --git a/web/src/js/module/process/module.vue b/web/src/js/module/process/module.vue
index 5b734c3bbd..06846caa42 100644
--- a/web/src/js/module/process/module.vue
+++ b/web/src/js/module/process/module.vue
@@ -797,7 +797,7 @@ export default {
'msgName': '',
'queryFrequency': 10,
'maxReceiveHours': 12,
- 'msgSavekey': '',
+ 'msgSavekey': 'msg.body',
'onlyReceiveToday': 'true',
},
});
@@ -1635,7 +1635,7 @@ export default {
const fileName = `${time.getTime()}${match.ext}`;
const params = {
fileName,
- scriptContent: rst.fileContent,
+ scriptContent: rst.fileContent[0][0],
metadata: rst.params,
};
api.fetch('/filesystem/saveScriptToBML', params, 'post')
diff --git a/web/src/js/module/workbench/container.vue b/web/src/js/module/workbench/container.vue
index 64c7dd8e2f..68773e0067 100644
--- a/web/src/js/module/workbench/container.vue
+++ b/web/src/js/module/workbench/container.vue
@@ -441,13 +441,13 @@ export default {
api.fetch('/filesystem/openFile', {
path: option.path,
}, 'get').then((rst) => {
- const ismodifyByOldTab = option.code && !rst.fileContent;
+ const ismodifyByOldTab = option.code && !rst.fileContent[0][0];
const params = ismodifyByOldTab ? option.params : this.convertSettingParams(rst.params);
this[methodName]({
id: md5Path,
filename: option.filename,
filepath: option.path,
- code: rst.fileContent || option.code,
+ code: rst.fileContent[0][0] || option.code,
params,
type: option.type,
saveAs: option.saveAs || false,
diff --git a/web/src/js/module/workbench/script/result.vue b/web/src/js/module/workbench/script/result.vue
index 30c0458a87..b0b6842d10 100644
--- a/web/src/js/module/workbench/script/result.vue
+++ b/web/src/js/module/workbench/script/result.vue
@@ -36,6 +36,7 @@
:height="tableData.height"
:columns="data.headRows"
:data="data.bodyRows"
+ @on-sort-change="sortChange"
@on-current-change="onRowClick"
class="result-normal-table">
@@ -58,7 +59,8 @@
@on-scroll="saveOffset"
@dbl-click="copyLabel"
@on-click="onWeTableRowClick"
- @change-status="changeStatus"/>
+ @change-status="changeStatus"
+ @handleSortClick="handleSortClick"/>
+ v-html="result.bodyRows[0][0]"/>
{{ $t('message.workBench.body.script.result.emptyText') }}
@@ -111,6 +113,7 @@ import WeWaterMask from '@js/component/watermark';
import WeToolbar from './toolbar.vue';
import elementResizeEvent from '@js/helper/elementResizeEvent';
import resultSetList from './resultSetList.vue';
+import pinyin from 'pinyin';
export default {
components: {
WeTable: Table.WeTable,
@@ -243,6 +246,146 @@ export default {
'Workbench:setParseAction'(id) {
this.resize();
},
+ handleSortClick(args) {
+ let { reverse,col, colIndex, cb } = args;
+ let order = 'normal';
+ if (args.reverse === -1) {
+ order = 'desc'
+ } else if (args.reverse === 1) {
+ order = 'asc'
+ }
+ // 先通过表头的内容找到对应全数据数据的index
+ let sortIndex
+ this.data.headRows.map((head, index) => {
+ if (head.content === col.content) {
+ sortIndex = index
+ }
+ })
+ // 大于50列排序现将要排序的列和原始index保持
+ let sortColumnAll = this.originRows.map((row, index) => {
+ return {
+ originIndex: index,
+ value: row[sortIndex]
+ }
+ })
+ // 将找出的列排序
+ sortColumnAll = this.arraySortByName(sortColumnAll, col.columnType, 'value');// 从小到大
+ let newRow = [];
+ if (order === 'asc') {// 升序
+ sortColumnAll.map((item, index) => {
+ newRow[index] = this.originRows[item.originIndex];
+ })
+ this.originRows = newRow;
+ } else if (order === 'desc') {// 降序
+ sortColumnAll.reverse();
+ sortColumnAll.map((item, index) => {
+ newRow[index] = this.originRows[item.originIndex];
+ })
+ this.originRows = newRow;
+ } else if (order === 'normal') {// 恢复原来数据
+ this.originRows = this.result.bodyRows || [];
+ this.data.originRows = this.originRows;
+ }
+ this.pageingData();
+ },
+ addCellClassName() {
+ // 需要将每一行中的NULL挑选出来
+ if (this.tableData.type === 'normal') {
+ this.originRows = this.originRows.map((row) => {
+ row.cellClassName = {};
+ Object.keys(row).forEach((key)=> {
+ if (row[key] === 'NULL') {
+ row.cellClassName[key] = 'is-null';
+ }
+ })
+ return row;
+ })
+ }
+ },
+ sortChange({column, key, order}) {
+ this.originRows = this.arraySortByName(this.originRows, column.columnType, key);// 从小到大
+ if (order === 'asc') {// 升序
+ this.addCellClassName();
+ } else if (order === 'desc') {// 降序
+ this.originRows.reverse();
+ this.addCellClassName();
+ } else if (order === 'normal') {// 恢复原来数据
+ if (this.tableData.type === 'normal') {
+ this.originRows = this.result.bodyRows.map((row) => {
+ let newItem = {};
+ const NullList = [];
+ row.forEach((item, index) => {
+ Object.assign(newItem, {
+ [this.result.headRows[index]]: item,
+ });
+ if (item === 'NULL') {
+ NullList.push(this.result.headRows[index]);
+ }
+ });
+ // 对于NULL值加上高亮样式
+ if (NullList.length) {
+ newItem.cellClassName = {};
+ NullList.forEach((item) => {
+ newItem.cellClassName[item] = 'is-null';
+ });
+ }
+ return newItem;
+ });
+ } else {
+ this.originRows = this.result.bodyRows || [];
+ }
+ this.data.originRows = this.originRows;
+ }
+ this.pageingData();
+ },
+ arraySortByName(list, valueType, key) {
+ if (list === undefined || list === null) return [];
+ list.sort((a, b) => {
+ let strA = a[key];
+ let strB = b[key];
+ // 谁为非法值谁在前面
+ if (strA === undefined || strA === null || strA === '' || strA === ' ' || strA === ' ' || strA === 'NULL') {
+ return -1;
+ }
+ if (strB === undefined || strB === null || strB === '' || strB === ' ' || strB === ' ' || strB === 'NULL') {
+ return 1;
+ }
+ // 如果为整数型大小
+ if (['int', 'float', 'double', 'long', 'short', 'bigInt', 'decimal'].includes(valueType.toLowerCase())) {
+
+ return strA - strB;
+ }
+ const charAry = strA.split('');
+ for (const i in charAry) {
+ if ((this.charCompare(strA[i], strB[i]) !== 0)) {
+ return this.charCompare(strA[i], strB[i]);
+ }
+ }
+ // 如果通过上面的循环对比还比不出来,就无解了,直接返回-1
+ return -1;
+ });
+ return list;
+ },
+ charCompare(charA, charB) {
+ // 谁为非法值谁在前面
+ if (charA === undefined || charA === null || charA === '' || charA === ' ' || charA === ' ') {
+ return -1;
+ }
+ if (charB === undefined || charB === null || charB === '' || charB === ' ' || charB === ' ') {
+ return 1;
+ }
+ if (!this.notChinese(charA)) {
+ charA = pinyin(charA)[0][0];
+ }
+ if (!this.notChinese(charB)) {
+ charB = pinyin(charB)[0][0];
+ }
+ return charA.localeCompare(charB);
+ },
+ notChinese(char) {
+ const charCode = char.charCodeAt(0);
+ return charCode >= 0 && charCode <= 128;
+ },
initOffset() {
let cache = this.script.result.cache;
let x = 0;
@@ -279,6 +422,7 @@ export default {
let headRows = this.result.headRows || [];
this.data.headRows = [];
this.data.bodyRows = [];
+
this.originRows = this.result.bodyRows || [];
this.tableData.total = this.result.total;
if (this.tableData.type === 'normal') {
@@ -289,10 +433,7 @@ export default {
this.data.headRows.push({
title,
key: item,
- sortable: 'true',
- sortMethod: function(a, b, type) {
- return util.sort(a, b, type);
- },
+ sortable: 'custom',
columnType,
renderHeader: (h, params) => {
return h('span', {
@@ -362,7 +503,7 @@ export default {
this.data.bodyRows = newArr;
}
},
- change(page) {
+ change(page = 1) {
this.hightLightRow = null;
this.page.current = page;
this.pageingData();