@94ai/nf-search-form 100.1.9 → 100.1.17
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/lib/index.d.ts +34 -34
- package/lib/nf-column-check-dialog.vue.d.ts +9 -9
- package/lib/nf-column-check-drawer.vue.d.ts +28 -20
- package/lib/nf-search-form.cjs.js +192 -121
- package/lib/nf-search-form.esm-bundler.js +186 -115
- package/lib/nf-search-form.vue.d.ts +13 -13
- package/package/index.ts +0 -6
- package/package/nf-column-check-dialog.vue +12 -8
- package/package/nf-column-check-drawer.vue +24 -17
- package/package/nf-search-form.vue +143 -100
- package/package.json +18 -18
- package/package/README.md +0 -137
|
@@ -2,8 +2,8 @@ import { defineComponent, ref, getCurrentInstance, computed, watch, onBeforeMoun
|
|
|
2
2
|
import { normalizeComponent } from "@94ai/vue2-runtime-helpers";
|
|
3
3
|
import { createUniqueString, deepClone } from "@94ai/common-utils";
|
|
4
4
|
import ResizeObserver from "resize-observer-polyfill";
|
|
5
|
+
import { set as set$1 } from "vue";
|
|
5
6
|
import NfMessage from "@94ai/nf-message";
|
|
6
|
-
import VueCookies from "vue-cookies";
|
|
7
7
|
const __sfc_main$5 = defineComponent({
|
|
8
8
|
name: "NfNumberRange"
|
|
9
9
|
});
|
|
@@ -744,6 +744,40 @@ var _sfc_render$3 = function render3() {
|
|
|
744
744
|
var _sfc_staticRenderFns$3 = [];
|
|
745
745
|
var __component__$3 = /* @__PURE__ */ normalizeComponent(__sfc_main$3, _sfc_render$3, _sfc_staticRenderFns$3, false, null, null, null, null);
|
|
746
746
|
const SearchFormItem = __component__$3.exports;
|
|
747
|
+
function promisifyRequest(request) {
|
|
748
|
+
return new Promise((resolve, reject) => {
|
|
749
|
+
request.oncomplete = request.onsuccess = () => resolve(request.result);
|
|
750
|
+
request.onabort = request.onerror = () => reject(request.error);
|
|
751
|
+
});
|
|
752
|
+
}
|
|
753
|
+
function createStore(dbName, storeName) {
|
|
754
|
+
const request = indexedDB.open(dbName);
|
|
755
|
+
request.onupgradeneeded = () => request.result.createObjectStore(storeName);
|
|
756
|
+
const dbp = promisifyRequest(request);
|
|
757
|
+
return (txMode, callback) => dbp.then((db) => callback(db.transaction(storeName, txMode).objectStore(storeName)));
|
|
758
|
+
}
|
|
759
|
+
let defaultGetStoreFunc;
|
|
760
|
+
function defaultGetStore() {
|
|
761
|
+
if (!defaultGetStoreFunc) {
|
|
762
|
+
defaultGetStoreFunc = createStore("keyval-store", "keyval");
|
|
763
|
+
}
|
|
764
|
+
return defaultGetStoreFunc;
|
|
765
|
+
}
|
|
766
|
+
function get(key, customStore = defaultGetStore()) {
|
|
767
|
+
return customStore("readonly", (store) => promisifyRequest(store.get(key)));
|
|
768
|
+
}
|
|
769
|
+
function set(key, value, customStore = defaultGetStore()) {
|
|
770
|
+
return customStore("readwrite", (store) => {
|
|
771
|
+
store.put(value, key);
|
|
772
|
+
return promisifyRequest(store.transaction);
|
|
773
|
+
});
|
|
774
|
+
}
|
|
775
|
+
function del(key, customStore = defaultGetStore()) {
|
|
776
|
+
return customStore("readwrite", (store) => {
|
|
777
|
+
store.delete(key);
|
|
778
|
+
return promisifyRequest(store.transaction);
|
|
779
|
+
});
|
|
780
|
+
}
|
|
747
781
|
const __sfc_main$2 = defineComponent({
|
|
748
782
|
name: "NfColumnCheckDialog"
|
|
749
783
|
});
|
|
@@ -754,6 +788,12 @@ __sfc_main$2.props = {
|
|
|
754
788
|
type: String,
|
|
755
789
|
default: "nf-table-columns-cached-key"
|
|
756
790
|
},
|
|
791
|
+
columnEdit: {
|
|
792
|
+
key: "columnEdit",
|
|
793
|
+
required: false,
|
|
794
|
+
type: Boolean,
|
|
795
|
+
default: false
|
|
796
|
+
},
|
|
757
797
|
show: {
|
|
758
798
|
key: "show",
|
|
759
799
|
required: false,
|
|
@@ -790,12 +830,6 @@ __sfc_main$2.props = {
|
|
|
790
830
|
type: Array,
|
|
791
831
|
default: () => []
|
|
792
832
|
},
|
|
793
|
-
showColumns: {
|
|
794
|
-
key: "showColumns",
|
|
795
|
-
required: false,
|
|
796
|
-
type: Array,
|
|
797
|
-
default: () => []
|
|
798
|
-
},
|
|
799
833
|
modalAppendToBody: {
|
|
800
834
|
key: "modalAppendToBody",
|
|
801
835
|
required: false,
|
|
@@ -890,7 +924,7 @@ __sfc_main$2.setup = (__props, __ctx) => {
|
|
|
890
924
|
});
|
|
891
925
|
const fields = computed(() => {
|
|
892
926
|
const obj = {};
|
|
893
|
-
props.tableColumns.map((item) => {
|
|
927
|
+
props.tableColumns.filter((item) => !item.destory).map((item) => {
|
|
894
928
|
const key = item.category || "基础查询框";
|
|
895
929
|
if (!obj[key]) {
|
|
896
930
|
obj[key] = [];
|
|
@@ -909,9 +943,8 @@ __sfc_main$2.setup = (__props, __ctx) => {
|
|
|
909
943
|
onMounted(() => {
|
|
910
944
|
addInitValue();
|
|
911
945
|
});
|
|
912
|
-
|
|
913
|
-
const submit = () => {
|
|
914
|
-
var _a2, _b;
|
|
946
|
+
(_a = getCurrentInstance()) == null ? void 0 : _a.proxy;
|
|
947
|
+
const submit = async () => {
|
|
915
948
|
visible.value = false;
|
|
916
949
|
const columnState = {};
|
|
917
950
|
props.tableColumns.map((i, index2) => {
|
|
@@ -921,15 +954,15 @@ __sfc_main$2.setup = (__props, __ctx) => {
|
|
|
921
954
|
index: index2
|
|
922
955
|
};
|
|
923
956
|
});
|
|
924
|
-
(_a2 = instance == null ? void 0 : instance.$cookies) == null ? void 0 : _a2.remove(props.storageKey);
|
|
925
|
-
(_b = instance == null ? void 0 : instance.$cookies) == null ? void 0 : _b.set(props.storageKey, JSON.stringify(columnState), -1, "/xxxx/xxxx/xxxx");
|
|
926
957
|
emit("save", tableData.value);
|
|
958
|
+
if (props.columnEdit) {
|
|
959
|
+
await set(props.storageKey, columnState);
|
|
960
|
+
}
|
|
927
961
|
};
|
|
928
962
|
const addInitValue = () => {
|
|
929
963
|
const obj = {};
|
|
930
964
|
props.tableColumns.forEach((v) => {
|
|
931
|
-
|
|
932
|
-
obj[v.prop] = ((_a2 = props.showColumns) == null ? void 0 : _a2.length) ? props.showColumns.includes(v.prop) : true;
|
|
965
|
+
obj[v.prop] = !v.initHidden;
|
|
933
966
|
});
|
|
934
967
|
tableData.value = obj;
|
|
935
968
|
};
|
|
@@ -6021,6 +6054,12 @@ __sfc_main$1.props = {
|
|
|
6021
6054
|
required: false,
|
|
6022
6055
|
type: Function,
|
|
6023
6056
|
default: (length) => "全选(" + length + ")"
|
|
6057
|
+
},
|
|
6058
|
+
columnEdit: {
|
|
6059
|
+
key: "columnEdit",
|
|
6060
|
+
required: false,
|
|
6061
|
+
type: Boolean,
|
|
6062
|
+
default: false
|
|
6024
6063
|
}
|
|
6025
6064
|
};
|
|
6026
6065
|
__sfc_main$1.setup = (__props, __ctx) => {
|
|
@@ -6133,8 +6172,8 @@ __sfc_main$1.setup = (__props, __ctx) => {
|
|
|
6133
6172
|
});
|
|
6134
6173
|
updateColumn();
|
|
6135
6174
|
};
|
|
6136
|
-
const syncTableColumnsToCookies = () => {
|
|
6137
|
-
var _a2
|
|
6175
|
+
const syncTableColumnsToCookies = async () => {
|
|
6176
|
+
var _a2;
|
|
6138
6177
|
const newTableColumns = [...fixedColumn.value, ...unFixedColumn.value];
|
|
6139
6178
|
if (newTableColumns.filter((item) => !item.initHidden).length === 0) {
|
|
6140
6179
|
(_a2 = instance == null ? void 0 : instance.$openMessage) == null ? void 0 : _a2.warning({
|
|
@@ -6155,8 +6194,9 @@ __sfc_main$1.setup = (__props, __ctx) => {
|
|
|
6155
6194
|
};
|
|
6156
6195
|
obj[i.prop] = !columnState[i.prop].initHidden;
|
|
6157
6196
|
});
|
|
6158
|
-
|
|
6159
|
-
|
|
6197
|
+
if (props.columnEdit) {
|
|
6198
|
+
await set(props.storageKey, columnState);
|
|
6199
|
+
}
|
|
6160
6200
|
return obj;
|
|
6161
6201
|
};
|
|
6162
6202
|
const drag = ref(false);
|
|
@@ -7009,7 +7049,7 @@ __sfc_main.props = {
|
|
|
7009
7049
|
}
|
|
7010
7050
|
};
|
|
7011
7051
|
__sfc_main.setup = (__props, __ctx) => {
|
|
7012
|
-
var _a
|
|
7052
|
+
var _a;
|
|
7013
7053
|
const props = __props;
|
|
7014
7054
|
const emit = __ctx.emit;
|
|
7015
7055
|
const instance = (_a = getCurrentInstance()) == null ? void 0 : _a.proxy;
|
|
@@ -7028,7 +7068,9 @@ __sfc_main.setup = (__props, __ctx) => {
|
|
|
7028
7068
|
}
|
|
7029
7069
|
return !item.initHidden;
|
|
7030
7070
|
}).map((item) => item.prop);
|
|
7031
|
-
|
|
7071
|
+
nextTick(() => {
|
|
7072
|
+
props.formOptions._skip = false;
|
|
7073
|
+
});
|
|
7032
7074
|
if (result.length) {
|
|
7033
7075
|
return result;
|
|
7034
7076
|
}
|
|
@@ -7038,13 +7080,15 @@ __sfc_main.setup = (__props, __ctx) => {
|
|
|
7038
7080
|
watch(() => {
|
|
7039
7081
|
var _a2;
|
|
7040
7082
|
return (_a2 = localShowItems.value) == null ? void 0 : _a2.length;
|
|
7041
|
-
}, () => {
|
|
7083
|
+
}, async () => {
|
|
7042
7084
|
emit("update:showItems", localShowItems.value);
|
|
7085
|
+
if (Object.keys(nfSearchFormModel.value).length) {
|
|
7086
|
+
await refreshNfSearchFormModel(false);
|
|
7087
|
+
}
|
|
7043
7088
|
}, {
|
|
7044
7089
|
immediate: true
|
|
7045
7090
|
});
|
|
7046
|
-
const syncLocalShowColumnToCookies = () => {
|
|
7047
|
-
var _a2, _b2;
|
|
7091
|
+
const syncLocalShowColumnToCookies = async () => {
|
|
7048
7092
|
if (props.columnEdit) {
|
|
7049
7093
|
const columnState = {};
|
|
7050
7094
|
props.formOptions.map((i, index2) => {
|
|
@@ -7055,26 +7099,28 @@ __sfc_main.setup = (__props, __ctx) => {
|
|
|
7055
7099
|
index: index2
|
|
7056
7100
|
};
|
|
7057
7101
|
});
|
|
7058
|
-
|
|
7059
|
-
(_b2 = instance == null ? void 0 : instance.$cookies) == null ? void 0 : _b2.set(props.storageKey, JSON.stringify(columnState), -1, "/xxxx/xxxx/xxxx");
|
|
7102
|
+
await set(props.storageKey, columnState);
|
|
7060
7103
|
}
|
|
7061
7104
|
};
|
|
7062
|
-
const syncCookiesToLocalShowColumn = () => {
|
|
7063
|
-
var _a2;
|
|
7105
|
+
const syncCookiesToLocalShowColumn = async () => {
|
|
7064
7106
|
if (props.columnEdit) {
|
|
7065
|
-
|
|
7066
|
-
|
|
7067
|
-
if (
|
|
7068
|
-
columnState
|
|
7069
|
-
|
|
7070
|
-
const showColumnItems = [];
|
|
7071
|
-
for (const key in columnState) {
|
|
7072
|
-
if (!columnState[key].initHidden) {
|
|
7073
|
-
showColumnItems.push(columnState[key].prop);
|
|
7107
|
+
try {
|
|
7108
|
+
let columnState = await get(props.storageKey);
|
|
7109
|
+
if (columnState) {
|
|
7110
|
+
if (typeof columnState === "string") {
|
|
7111
|
+
columnState = JSON.parse(columnState);
|
|
7074
7112
|
}
|
|
7113
|
+
const showColumnItems = [];
|
|
7114
|
+
for (const key in columnState) {
|
|
7115
|
+
if (!columnState[key].initHidden) {
|
|
7116
|
+
showColumnItems.push(columnState[key].prop);
|
|
7117
|
+
}
|
|
7118
|
+
}
|
|
7119
|
+
setLocalShowItems(showColumnItems, true);
|
|
7075
7120
|
}
|
|
7076
|
-
|
|
7077
|
-
|
|
7121
|
+
} catch (e) {
|
|
7122
|
+
console.log(e);
|
|
7123
|
+
await del(props.storageKey);
|
|
7078
7124
|
}
|
|
7079
7125
|
}
|
|
7080
7126
|
};
|
|
@@ -7088,61 +7134,74 @@ __sfc_main.setup = (__props, __ctx) => {
|
|
|
7088
7134
|
item.initHidden = true;
|
|
7089
7135
|
}
|
|
7090
7136
|
});
|
|
7091
|
-
|
|
7137
|
+
nextTick(() => {
|
|
7138
|
+
props.formOptions._skip = false;
|
|
7139
|
+
});
|
|
7092
7140
|
};
|
|
7093
|
-
|
|
7094
|
-
|
|
7095
|
-
|
|
7096
|
-
|
|
7097
|
-
|
|
7098
|
-
|
|
7099
|
-
|
|
7141
|
+
const initCachedData = async () => {
|
|
7142
|
+
var _a2, _b;
|
|
7143
|
+
if (props.columnEdit) {
|
|
7144
|
+
try {
|
|
7145
|
+
const cached = await get(props.storageKey);
|
|
7146
|
+
const cachedPriority = props.priority === "cached";
|
|
7147
|
+
if (cachedPriority ? cached : (_a2 = localShowItems.value) == null ? void 0 : _a2.length) {
|
|
7148
|
+
cachedPriority ? await syncCookiesToLocalShowColumn() : await syncLocalShowColumnToCookies();
|
|
7149
|
+
} else if (cachedPriority ? (_b = localShowItems.value) == null ? void 0 : _b.length : cached) {
|
|
7150
|
+
cachedPriority ? await syncLocalShowColumnToCookies() : await syncCookiesToLocalShowColumn();
|
|
7151
|
+
}
|
|
7152
|
+
} catch (e) {
|
|
7153
|
+
await del(props.storageKey);
|
|
7154
|
+
}
|
|
7100
7155
|
}
|
|
7101
|
-
}
|
|
7156
|
+
};
|
|
7157
|
+
initCachedData();
|
|
7102
7158
|
const configNfSearchItemVisibleDialog = ref(false);
|
|
7103
7159
|
const newColumns = ref(3);
|
|
7104
7160
|
const isShowBtnBoxSlot = computed(() => {
|
|
7105
7161
|
return instance == null ? void 0 : instance.$slots.btnBox;
|
|
7106
7162
|
});
|
|
7107
7163
|
const renderSearchFormItemOptions = ref([]);
|
|
7108
|
-
const syncCookiesToSearchFormItemOptions = (readCached = true) => {
|
|
7109
|
-
var _a2;
|
|
7164
|
+
const syncCookiesToSearchFormItemOptions = async (readCached = true) => {
|
|
7110
7165
|
props.formOptions._skip = true;
|
|
7111
7166
|
const columns = props.formOptions.map((item, index2) => {
|
|
7112
7167
|
item.key = item.key || createUniqueString();
|
|
7113
7168
|
item._index = index2;
|
|
7114
7169
|
item.__index = index2;
|
|
7170
|
+
set$1(item, "initHidden", !!item.initHidden);
|
|
7171
|
+
set$1(item, "destory", !!item.destory);
|
|
7115
7172
|
return item;
|
|
7116
7173
|
});
|
|
7117
7174
|
if (readCached && props.columnEdit) {
|
|
7118
|
-
|
|
7119
|
-
|
|
7120
|
-
|
|
7121
|
-
|
|
7122
|
-
|
|
7123
|
-
|
|
7124
|
-
|
|
7125
|
-
|
|
7126
|
-
|
|
7127
|
-
|
|
7128
|
-
i.
|
|
7129
|
-
|
|
7130
|
-
|
|
7131
|
-
|
|
7132
|
-
|
|
7175
|
+
try {
|
|
7176
|
+
let columnState = await get(props.storageKey);
|
|
7177
|
+
props.formOptions._skip = true;
|
|
7178
|
+
if (columnState) {
|
|
7179
|
+
if (typeof columnState === "string") {
|
|
7180
|
+
columnState = JSON.parse(columnState);
|
|
7181
|
+
}
|
|
7182
|
+
for (const key in columnState) {
|
|
7183
|
+
const state = columnState[key];
|
|
7184
|
+
columns.every((i) => {
|
|
7185
|
+
if (i.prop === key) {
|
|
7186
|
+
i.initHidden = state.initHidden;
|
|
7187
|
+
i._index = state.index;
|
|
7188
|
+
return false;
|
|
7189
|
+
}
|
|
7190
|
+
return true;
|
|
7191
|
+
});
|
|
7192
|
+
}
|
|
7133
7193
|
}
|
|
7194
|
+
} catch (e) {
|
|
7195
|
+
console.log(e);
|
|
7134
7196
|
}
|
|
7135
7197
|
}
|
|
7136
|
-
|
|
7198
|
+
await nextTick();
|
|
7137
7199
|
props.formOptions._skip = false;
|
|
7200
|
+
renderSearchFormItemOptions.value = columns.sort((a, b) => a._index - b._index < 0 ? -1 : a._index - b._index > 0 ? 1 : 0);
|
|
7138
7201
|
};
|
|
7139
7202
|
syncCookiesToSearchFormItemOptions();
|
|
7140
7203
|
const itemIsShow = (item) => {
|
|
7141
|
-
|
|
7142
|
-
if (!((_a2 = localShowItems.value) == null ? void 0 : _a2.length)) {
|
|
7143
|
-
return !item.initHidden && !item.destory;
|
|
7144
|
-
}
|
|
7145
|
-
return localShowItems.value.includes(item.prop) && !item.initHidden && !item.destory;
|
|
7204
|
+
return !item.initHidden && !item.destory;
|
|
7146
7205
|
};
|
|
7147
7206
|
watch(() => nfSearchFormModel.value, () => {
|
|
7148
7207
|
emit("onChange", nfSearchFormModel.value);
|
|
@@ -7157,32 +7216,52 @@ __sfc_main.setup = (__props, __ctx) => {
|
|
|
7157
7216
|
}, {
|
|
7158
7217
|
immediate: true
|
|
7159
7218
|
});
|
|
7219
|
+
const setLocalShowItems = (list, syncToInitHidden = false) => {
|
|
7220
|
+
if (JSON.stringify(list.sort()) !== JSON.stringify(localShowItems.value.sort())) {
|
|
7221
|
+
localShowItems.value = list;
|
|
7222
|
+
if (syncToInitHidden) {
|
|
7223
|
+
syncShowItemToInitHidden();
|
|
7224
|
+
}
|
|
7225
|
+
}
|
|
7226
|
+
};
|
|
7160
7227
|
onBeforeMount(() => {
|
|
7161
7228
|
watch(() => {
|
|
7162
7229
|
return props.formOptions;
|
|
7163
|
-
}, () => {
|
|
7230
|
+
}, async () => {
|
|
7164
7231
|
if (props.formOptions._skip) {
|
|
7165
7232
|
return;
|
|
7166
7233
|
}
|
|
7167
|
-
|
|
7234
|
+
setLocalShowItems(initLocalShow());
|
|
7235
|
+
await syncCookiesToSearchFormItemOptions(false);
|
|
7168
7236
|
}, {
|
|
7169
7237
|
deep: true
|
|
7170
7238
|
});
|
|
7239
|
+
refreshNfSearchFormModel(false, true);
|
|
7240
|
+
});
|
|
7241
|
+
const refreshNfSearchFormModel = async (outEmit = true, init = false) => {
|
|
7171
7242
|
const obj = {};
|
|
7172
|
-
props.formOptions.forEach((v) => {
|
|
7173
|
-
if (v.
|
|
7174
|
-
|
|
7175
|
-
|
|
7176
|
-
|
|
7243
|
+
props.formOptions.filter((item) => !item.destory).forEach((v) => {
|
|
7244
|
+
if (localShowItems.value.includes(v.prop)) {
|
|
7245
|
+
if (init) {
|
|
7246
|
+
if (v.initValue !== void 0) {
|
|
7247
|
+
obj[v.prop] = v.initValue;
|
|
7248
|
+
} else {
|
|
7249
|
+
obj[v.prop] = void 0;
|
|
7250
|
+
}
|
|
7251
|
+
} else {
|
|
7252
|
+
obj[v.prop] = nfSearchFormModel.value[v.prop];
|
|
7253
|
+
}
|
|
7177
7254
|
}
|
|
7178
7255
|
});
|
|
7179
|
-
|
|
7180
|
-
|
|
7181
|
-
|
|
7256
|
+
if (JSON.stringify(nfSearchFormModel.value) !== JSON.stringify(obj)) {
|
|
7257
|
+
nfSearchFormModel.value = obj;
|
|
7258
|
+
if (outEmit) {
|
|
7259
|
+
emit("onChange", nfSearchFormModel.value);
|
|
7260
|
+
await nextTick();
|
|
7261
|
+
emit("itemsChange", localShowItems.value);
|
|
7182
7262
|
}
|
|
7183
7263
|
}
|
|
7184
|
-
|
|
7185
|
-
});
|
|
7264
|
+
};
|
|
7186
7265
|
const isCollapseChange = async (val) => {
|
|
7187
7266
|
emit("isCollapseChange", val);
|
|
7188
7267
|
await nextTick();
|
|
@@ -7268,26 +7347,23 @@ __sfc_main.setup = (__props, __ctx) => {
|
|
|
7268
7347
|
});
|
|
7269
7348
|
};
|
|
7270
7349
|
const hiddenNfSearchFormItemOptionField = async (prop) => {
|
|
7271
|
-
|
|
7272
|
-
|
|
7273
|
-
|
|
7274
|
-
|
|
7275
|
-
|
|
7276
|
-
syncCookiesToSearchFormItemOptions();
|
|
7277
|
-
refreshNfSearchFormModel();
|
|
7278
|
-
await nextTick();
|
|
7279
|
-
refreshLabel();
|
|
7280
|
-
}
|
|
7281
|
-
};
|
|
7282
|
-
const refreshNfSearchFormModel = async () => {
|
|
7283
|
-
for (const key in nfSearchFormModel.value) {
|
|
7284
|
-
if (!localShowItems.value.includes(key)) {
|
|
7285
|
-
delete nfSearchFormModel.value[key];
|
|
7350
|
+
prop.formOptions._skip = true;
|
|
7351
|
+
prop.formOptions.every((item) => {
|
|
7352
|
+
if (item.prop === prop) {
|
|
7353
|
+
item.initHidden = true;
|
|
7354
|
+
return false;
|
|
7286
7355
|
}
|
|
7287
|
-
|
|
7288
|
-
|
|
7356
|
+
return true;
|
|
7357
|
+
});
|
|
7358
|
+
nextTick(() => {
|
|
7359
|
+
props.formOptions._skip = false;
|
|
7360
|
+
});
|
|
7361
|
+
localShowItems.value = prop.formOptions.filter((item) => !item.initHidden).map((item) => item.prop);
|
|
7362
|
+
await syncLocalShowColumnToCookies();
|
|
7363
|
+
await syncCookiesToSearchFormItemOptions();
|
|
7364
|
+
await refreshNfSearchFormModel();
|
|
7289
7365
|
await nextTick();
|
|
7290
|
-
|
|
7366
|
+
refreshLabel();
|
|
7291
7367
|
};
|
|
7292
7368
|
const columnCheckConfirmFeedback = (value) => {
|
|
7293
7369
|
if (!props.columnEdit) {
|
|
@@ -7297,17 +7373,16 @@ __sfc_main.setup = (__props, __ctx) => {
|
|
|
7297
7373
|
itemsList.push(key);
|
|
7298
7374
|
}
|
|
7299
7375
|
}
|
|
7300
|
-
|
|
7301
|
-
syncShowItemToInitHidden();
|
|
7376
|
+
setLocalShowItems(itemsList, true);
|
|
7302
7377
|
}
|
|
7303
7378
|
};
|
|
7304
7379
|
const columnCheckConfirm = async (cb, error) => {
|
|
7305
7380
|
try {
|
|
7306
|
-
const value = columnCheckDrawer.value.syncTableColumnsToCookies();
|
|
7381
|
+
const value = await columnCheckDrawer.value.syncTableColumnsToCookies();
|
|
7307
7382
|
columnCheckConfirmFeedback(value);
|
|
7308
|
-
syncCookiesToLocalShowColumn();
|
|
7309
|
-
syncCookiesToSearchFormItemOptions();
|
|
7310
|
-
refreshNfSearchFormModel();
|
|
7383
|
+
await syncCookiesToLocalShowColumn();
|
|
7384
|
+
await syncCookiesToSearchFormItemOptions();
|
|
7385
|
+
await refreshNfSearchFormModel();
|
|
7311
7386
|
await nextTick();
|
|
7312
7387
|
refreshLabel();
|
|
7313
7388
|
cb();
|
|
@@ -7318,9 +7393,9 @@ __sfc_main.setup = (__props, __ctx) => {
|
|
|
7318
7393
|
};
|
|
7319
7394
|
const nfSearchFormItemOptionFieldsSave = async (value) => {
|
|
7320
7395
|
columnCheckConfirmFeedback(value);
|
|
7321
|
-
syncCookiesToLocalShowColumn();
|
|
7322
|
-
syncCookiesToSearchFormItemOptions();
|
|
7323
|
-
refreshNfSearchFormModel();
|
|
7396
|
+
await syncCookiesToLocalShowColumn();
|
|
7397
|
+
await syncCookiesToSearchFormItemOptions();
|
|
7398
|
+
await refreshNfSearchFormModel();
|
|
7324
7399
|
await nextTick();
|
|
7325
7400
|
refreshLabel();
|
|
7326
7401
|
};
|
|
@@ -7331,7 +7406,6 @@ __sfc_main.setup = (__props, __ctx) => {
|
|
|
7331
7406
|
columnCheckDrawer,
|
|
7332
7407
|
columnCheckDialog,
|
|
7333
7408
|
nfSearchFormModel,
|
|
7334
|
-
localShowItems,
|
|
7335
7409
|
configNfSearchItemVisibleDialog,
|
|
7336
7410
|
newColumns,
|
|
7337
7411
|
isShowBtnBoxSlot,
|
|
@@ -7666,7 +7740,6 @@ var _sfc_render = function render6() {
|
|
|
7666
7740
|
"table-columns": _vm.formOptions,
|
|
7667
7741
|
"title": _vm.moreDialogTitle,
|
|
7668
7742
|
"width": _vm.moreDialogWidth,
|
|
7669
|
-
"show-columns": _vm.localShowItems,
|
|
7670
7743
|
"modal-append-to-body": _vm.modalAppendToBody,
|
|
7671
7744
|
"modal": _vm.modal,
|
|
7672
7745
|
"fullscreen": _vm.fullscreen,
|
|
@@ -7730,6 +7803,7 @@ var _sfc_render = function render6() {
|
|
|
7730
7803
|
}), _c("column-check-drawer", {
|
|
7731
7804
|
ref: "columnCheckDrawer",
|
|
7732
7805
|
attrs: {
|
|
7806
|
+
"column-edit": _vm.columnEdit,
|
|
7733
7807
|
"search-placeholder": _vm.columnCheckSearchPlaceholder,
|
|
7734
7808
|
"fixed-left-desc": _vm.columnCheckFixedLeftDesc,
|
|
7735
7809
|
"clear-desc": _vm.columnCheckClearDesc,
|
|
@@ -7746,9 +7820,6 @@ var _sfc_staticRenderFns = [];
|
|
|
7746
7820
|
var __component__ = /* @__PURE__ */ normalizeComponent(__sfc_main, _sfc_render, _sfc_staticRenderFns, false, null, null, null, null);
|
|
7747
7821
|
const NfSearchForm = __component__.exports;
|
|
7748
7822
|
NfSearchForm.install = (app) => {
|
|
7749
|
-
if (!app.$cookies) {
|
|
7750
|
-
app.use(VueCookies);
|
|
7751
|
-
}
|
|
7752
7823
|
if (!app.$openMessage) {
|
|
7753
7824
|
app.use(NfMessage);
|
|
7754
7825
|
}
|
|
@@ -5,6 +5,10 @@ declare const _default: __VLS_WithTemplateSlots<import("vue-demi").DefineCompone
|
|
|
5
5
|
type: import("vue-demi").PropType<string>;
|
|
6
6
|
default: string;
|
|
7
7
|
};
|
|
8
|
+
columnEdit: {
|
|
9
|
+
type: import("vue-demi").PropType<boolean>;
|
|
10
|
+
default: boolean;
|
|
11
|
+
};
|
|
8
12
|
modalAppendToBody: {
|
|
9
13
|
type: import("vue-demi").PropType<boolean>;
|
|
10
14
|
default: boolean;
|
|
@@ -179,10 +183,6 @@ declare const _default: __VLS_WithTemplateSlots<import("vue-demi").DefineCompone
|
|
|
179
183
|
type: import("vue-demi").PropType<boolean>;
|
|
180
184
|
default: boolean;
|
|
181
185
|
};
|
|
182
|
-
columnEdit: {
|
|
183
|
-
type: import("vue-demi").PropType<boolean>;
|
|
184
|
-
default: boolean;
|
|
185
|
-
};
|
|
186
186
|
showItems: {
|
|
187
187
|
type: import("vue-demi").PropType<string[]>;
|
|
188
188
|
default: () => never[];
|
|
@@ -407,11 +407,11 @@ declare const _default: __VLS_WithTemplateSlots<import("vue-demi").DefineCompone
|
|
|
407
407
|
};
|
|
408
408
|
}, {
|
|
409
409
|
localShowItems: import("vue-demi").Ref<string[]>;
|
|
410
|
-
syncLocalShowColumnToCookies: () => void
|
|
411
|
-
syncCookiesToLocalShowColumn: () => void
|
|
410
|
+
syncLocalShowColumnToCookies: () => Promise<void>;
|
|
411
|
+
syncCookiesToLocalShowColumn: () => Promise<void>;
|
|
412
412
|
syncShowItemToInitHidden: () => void;
|
|
413
413
|
hiddenNfSearchFormItemOptionField: (prop: any) => Promise<void>;
|
|
414
|
-
refreshNfSearchFormModel: () => Promise<void>;
|
|
414
|
+
refreshNfSearchFormModel: (outEmit?: boolean, init?: boolean) => Promise<void>;
|
|
415
415
|
renderSearchFormItemOptions: import("vue-demi").Ref<{
|
|
416
416
|
key?: string | undefined;
|
|
417
417
|
_index?: number | undefined;
|
|
@@ -471,7 +471,7 @@ declare const _default: __VLS_WithTemplateSlots<import("vue-demi").DefineCompone
|
|
|
471
471
|
columnCheckDialog: import("vue-demi").Ref<any>;
|
|
472
472
|
columnCheckDrawer: import("vue-demi").Ref<any>;
|
|
473
473
|
configNfSearchItemVisibleDialog: import("vue-demi").Ref<boolean>;
|
|
474
|
-
syncCookiesToSearchFormItemOptions: (readCached?: boolean) => void
|
|
474
|
+
syncCookiesToSearchFormItemOptions: (readCached?: boolean) => Promise<void>;
|
|
475
475
|
onResize: (params?: Record<string, any>) => Promise<void>;
|
|
476
476
|
visibleChange: () => void;
|
|
477
477
|
}, {}, {}, {}, import("vue/types/v3-component-options").ComponentOptionsMixin, import("vue/types/v3-component-options").ComponentOptionsMixin, {
|
|
@@ -487,6 +487,10 @@ declare const _default: __VLS_WithTemplateSlots<import("vue-demi").DefineCompone
|
|
|
487
487
|
type: import("vue-demi").PropType<string>;
|
|
488
488
|
default: string;
|
|
489
489
|
};
|
|
490
|
+
columnEdit: {
|
|
491
|
+
type: import("vue-demi").PropType<boolean>;
|
|
492
|
+
default: boolean;
|
|
493
|
+
};
|
|
490
494
|
modalAppendToBody: {
|
|
491
495
|
type: import("vue-demi").PropType<boolean>;
|
|
492
496
|
default: boolean;
|
|
@@ -661,10 +665,6 @@ declare const _default: __VLS_WithTemplateSlots<import("vue-demi").DefineCompone
|
|
|
661
665
|
type: import("vue-demi").PropType<boolean>;
|
|
662
666
|
default: boolean;
|
|
663
667
|
};
|
|
664
|
-
columnEdit: {
|
|
665
|
-
type: import("vue-demi").PropType<boolean>;
|
|
666
|
-
default: boolean;
|
|
667
|
-
};
|
|
668
668
|
showItems: {
|
|
669
669
|
type: import("vue-demi").PropType<string[]>;
|
|
670
670
|
default: () => never[];
|
|
@@ -889,6 +889,7 @@ declare const _default: __VLS_WithTemplateSlots<import("vue-demi").DefineCompone
|
|
|
889
889
|
};
|
|
890
890
|
}>>, {
|
|
891
891
|
storageKey: string;
|
|
892
|
+
columnEdit: boolean;
|
|
892
893
|
modalAppendToBody: boolean;
|
|
893
894
|
modal: boolean;
|
|
894
895
|
fullscreen: boolean;
|
|
@@ -931,7 +932,6 @@ declare const _default: __VLS_WithTemplateSlots<import("vue-demi").DefineCompone
|
|
|
931
932
|
labelWidth: number;
|
|
932
933
|
formOptions: NfSearchFormItemOption[] | any;
|
|
933
934
|
closable: boolean;
|
|
934
|
-
columnEdit: boolean;
|
|
935
935
|
showItems: string[];
|
|
936
936
|
priority: 'cached' | 'value';
|
|
937
937
|
checkMode: 'dialog' | 'drawer';
|
package/package/index.ts
CHANGED
|
@@ -1,14 +1,8 @@
|
|
|
1
1
|
import NfSearchForm from './nf-search-form.vue'
|
|
2
2
|
import { Vue2, PluginObject } from 'vue-demi'
|
|
3
3
|
import NfMessage from '@94ai/nf-message'
|
|
4
|
-
import VueCookies from 'vue-cookies'
|
|
5
4
|
|
|
6
5
|
NfSearchForm.install = (app: typeof Vue2) => {
|
|
7
|
-
// @ts-ignore
|
|
8
|
-
if (!app.$cookies) {
|
|
9
|
-
// @ts-ignore
|
|
10
|
-
app.use(VueCookies)
|
|
11
|
-
}
|
|
12
6
|
// @ts-ignore
|
|
13
7
|
if (!app.$openMessage) {
|
|
14
8
|
// @ts-ignore
|
|
@@ -56,16 +56,20 @@ import {
|
|
|
56
56
|
ref
|
|
57
57
|
} from 'vue-demi'
|
|
58
58
|
import { NfSearchFormItemOption } from 'packages/nf-search-form/lib/types'
|
|
59
|
+
import { set as cachedSet } from 'idb-keyval'
|
|
59
60
|
|
|
60
61
|
const props = withDefaults(defineProps<{
|
|
61
62
|
storageKey?: string
|
|
63
|
+
/**
|
|
64
|
+
* 列编辑,是否显示按钮配置表单项显示
|
|
65
|
+
*/
|
|
66
|
+
columnEdit?: boolean,
|
|
62
67
|
show?: boolean,
|
|
63
68
|
title?: string,
|
|
64
69
|
width?: string,
|
|
65
70
|
confirmText?: string
|
|
66
71
|
cancelText?: string
|
|
67
72
|
tableColumns?: NfSearchFormItemOption[],
|
|
68
|
-
showColumns?: string[],
|
|
69
73
|
modalAppendToBody?: boolean,
|
|
70
74
|
modal?: boolean,
|
|
71
75
|
fullscreen?: boolean,
|
|
@@ -80,6 +84,7 @@ const props = withDefaults(defineProps<{
|
|
|
80
84
|
center?: boolean,
|
|
81
85
|
destroyOnClose?: boolean,
|
|
82
86
|
}>(), {
|
|
87
|
+
columnEdit: false,
|
|
83
88
|
storageKey: 'nf-table-columns-cached-key',
|
|
84
89
|
show: false,
|
|
85
90
|
width: '600',
|
|
@@ -87,7 +92,6 @@ const props = withDefaults(defineProps<{
|
|
|
87
92
|
cancelText: '取 消',
|
|
88
93
|
confirmText: '保 存',
|
|
89
94
|
tableColumns: () => [],
|
|
90
|
-
showColumns: () => [],
|
|
91
95
|
modalAppendToBody: true,
|
|
92
96
|
modal: true,
|
|
93
97
|
fullscreen: false,
|
|
@@ -125,7 +129,7 @@ const visible = computed({
|
|
|
125
129
|
*/
|
|
126
130
|
const fields = computed(() => {
|
|
127
131
|
const obj: Record<string, any> = {}
|
|
128
|
-
props.tableColumns.map(item => {
|
|
132
|
+
props.tableColumns.filter(item => !item.destory).map(item => {
|
|
129
133
|
const key = item.category || '基础查询框'
|
|
130
134
|
if (!obj[key]) {
|
|
131
135
|
obj[key] = []
|
|
@@ -150,7 +154,7 @@ onMounted(() => {
|
|
|
150
154
|
})
|
|
151
155
|
const instance = getCurrentInstance()?.proxy
|
|
152
156
|
|
|
153
|
-
const submit = () => {
|
|
157
|
+
const submit = async () => {
|
|
154
158
|
visible.value = false
|
|
155
159
|
const columnState = {}
|
|
156
160
|
props.tableColumns.map((i, index) => {
|
|
@@ -160,16 +164,16 @@ const submit = () => {
|
|
|
160
164
|
index
|
|
161
165
|
}
|
|
162
166
|
})
|
|
163
|
-
|
|
164
|
-
instance?.$cookies?.remove(props.storageKey)
|
|
165
|
-
instance?.$cookies?.set(props.storageKey, JSON.stringify(columnState), -1, '/xxxx/xxxx/xxxx')
|
|
166
167
|
emit('save', tableData.value)
|
|
168
|
+
if (props.columnEdit) {
|
|
169
|
+
await cachedSet(props.storageKey, columnState)
|
|
170
|
+
}
|
|
167
171
|
}
|
|
168
172
|
|
|
169
173
|
const addInitValue = () => {
|
|
170
174
|
const obj: Record<string, any> = {}
|
|
171
175
|
props.tableColumns.forEach(v => {
|
|
172
|
-
obj[v.prop!] =
|
|
176
|
+
obj[v.prop!] = !v.initHidden
|
|
173
177
|
})
|
|
174
178
|
tableData.value = obj
|
|
175
179
|
}
|