@das-fed/utils 1.0.0
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/api-services/index.js +19846 -0
- package/api-services/modules/app-manage.js +6 -0
- package/api-services/modules/authentication.js +6 -0
- package/api-services/modules/bems.js +11 -0
- package/api-services/modules/contract.js +6 -0
- package/api-services/modules/duty-manage.js +15 -0
- package/api-services/modules/enterpriseright.js +6 -0
- package/api-services/modules/file.js +409 -0
- package/api-services/modules/gateway-edge.js +6 -0
- package/api-services/modules/index.js +494 -0
- package/api-services/modules/iot.js +19 -0
- package/api-services/modules/justauth.js +7 -0
- package/api-services/modules/knowledge.js +6 -0
- package/api-services/modules/link.js +6 -0
- package/api-services/modules/permission.js +6 -0
- package/api-services/modules/platformManage.js +14 -0
- package/api-services/modules/portal.js +6 -0
- package/api-services/modules/space-manage.js +6 -0
- package/api-services/modules/super-admin.js +9 -0
- package/api-services/modules/supplier.js +8 -0
- package/api-services/modules/supplychain-manage.js +6 -0
- package/api-services/modules/systemConfiguration.js +6 -0
- package/api-services/modules/tool.js +6 -0
- package/api-services/src/create-service.js +19846 -0
- package/api-services/src/sso.js +200 -0
- package/api-services/src/util.js +23 -0
- package/atob/index.js +12 -0
- package/common-info/getIframeUrl.js +13 -0
- package/common-info/index.js +311 -0
- package/common-info/setInfoFromUrl.js +156 -0
- package/common-tools/arr-tools.js +15 -0
- package/common-tools/date-format.js +22 -0
- package/common-tools/get-url-params.js +92 -0
- package/common-tools/handle-data.js +5 -0
- package/common-tools/index.js +213 -0
- package/common-tools/nest-tree-format.js +53 -0
- package/common-tools/obj-tools.js +21 -0
- package/common-tools/setHtmlMinWH.js +11 -0
- package/common-tools/throttled.js +19 -0
- package/config/index.js +26 -0
- package/curring-http/index.js +17310 -0
- package/directive/auth.js +114 -0
- package/directive/clickOutside.js +53 -0
- package/directive/hoverInside.js +40 -0
- package/directive/index.js +183 -0
- package/directive/utils.js +12 -0
- package/dom-check-in/index.js +16 -0
- package/dom-watcher/index.js +10 -0
- package/hooks/popup-manager/use-zindex.js +41 -0
- package/index.js +215 -0
- package/load-js/index.js +23 -0
- package/oss/index.js +16 -0
- package/package.json +44 -0
- package/pinyin-first-character/index.js +12223 -0
- package/process-engine-info/index.js +12 -0
- package/pure-image-src/index.js +30 -0
- package/set-personal-info/index.js +24 -0
- package/size-watcher/index.js +27 -0
- package/style/index.js +115 -0
- package/style/math.js +32 -0
- package/style/style.js +84 -0
- package/token-tools/index.js +179 -0
- package/vue/hooks/use-model-value.js +11 -0
- package/vue/index.js +11 -0
- package/webSocket-service/index.js +170 -0
- package/with-install/index.js +8 -0
|
@@ -0,0 +1,494 @@
|
|
|
1
|
+
import { createService } from '@das-fed/utils/api-services';
|
|
2
|
+
import crypto from 'crypto';
|
|
3
|
+
import { ref } from 'vue';
|
|
4
|
+
|
|
5
|
+
const version$j = "v1";
|
|
6
|
+
const appManage = createService(`/api/app-manager/application/${version$j}`);
|
|
7
|
+
|
|
8
|
+
const version$i = "v1";
|
|
9
|
+
const authentication = createService(`/api/license/admin/${version$i}`);
|
|
10
|
+
|
|
11
|
+
const version$h = "v1";
|
|
12
|
+
const bemsBase = `/api/bems/data-manage/${version$h}`;
|
|
13
|
+
const bemsModules = {
|
|
14
|
+
energyType: createService(`${bemsBase}/energy-type`),
|
|
15
|
+
energyObject: createService(`${bemsBase}/energy-object`),
|
|
16
|
+
energyDimension: createService(`${bemsBase}/energy-dimension`)
|
|
17
|
+
};
|
|
18
|
+
|
|
19
|
+
const version$g = "v1";
|
|
20
|
+
const contract = createService(`/api/supply/contract/${version$g}`);
|
|
21
|
+
|
|
22
|
+
const version$f = "v1";
|
|
23
|
+
const dutyModules = {
|
|
24
|
+
classes: createService(`/api/duty-manage/classes/${version$f}`),
|
|
25
|
+
// 班次管理
|
|
26
|
+
group: createService(`/api/duty-manage/group/${version$f}`),
|
|
27
|
+
// 分组管理
|
|
28
|
+
scheduling: createService(`/api/duty-manage/scheduling/${version$f}`),
|
|
29
|
+
// 排班管理
|
|
30
|
+
shift: createService(`/api/duty-manage/shift/${version$f}`)
|
|
31
|
+
// 交接班管理
|
|
32
|
+
};
|
|
33
|
+
|
|
34
|
+
const version$e = "v1";
|
|
35
|
+
const enterpriseright = createService(`/api/enterpriseright/permission/${version$e}`);
|
|
36
|
+
|
|
37
|
+
const version$d = "v1";
|
|
38
|
+
const iot = createService(`/api/iot/${version$d}`);
|
|
39
|
+
const iotModules = {
|
|
40
|
+
thingmodel: createService(`/api/iot-device/thingmodel/${version$d}`),
|
|
41
|
+
deviceManage: createService(`/api/iot-device/devicemanage/${version$d}`),
|
|
42
|
+
product: createService(`/api/iot-device/product/${version$d}`),
|
|
43
|
+
productStorage: createService(`/api/iot-device/product-storage/${version$d}`)
|
|
44
|
+
};
|
|
45
|
+
const iotRelationModules = {
|
|
46
|
+
projectDevice: createService(`/api/device-relation/deviceproject/${version$d}`),
|
|
47
|
+
deviceRules: createService(`/api/device-relation/devicerule/${version$d}`),
|
|
48
|
+
project: createService(`/api/device-relation/project/${version$d}`)
|
|
49
|
+
};
|
|
50
|
+
const iotMinio = createService(`/api/oss/minio/${version$d}`);
|
|
51
|
+
const iotProgress = createService(`/api/progress/accessor/${version$d}`);
|
|
52
|
+
|
|
53
|
+
let urlAlphabet =
|
|
54
|
+
'useandom-26T198340PX75pxJACKVERYMINDBUSHWOLF_GQZbfghjklqvwyzrict';
|
|
55
|
+
|
|
56
|
+
const POOL_SIZE_MULTIPLIER = 128;
|
|
57
|
+
let pool, poolOffset;
|
|
58
|
+
let fillPool = bytes => {
|
|
59
|
+
if (!pool || pool.length < bytes) {
|
|
60
|
+
pool = Buffer.allocUnsafe(bytes * POOL_SIZE_MULTIPLIER);
|
|
61
|
+
crypto.randomFillSync(pool);
|
|
62
|
+
poolOffset = 0;
|
|
63
|
+
} else if (poolOffset + bytes > pool.length) {
|
|
64
|
+
crypto.randomFillSync(pool);
|
|
65
|
+
poolOffset = 0;
|
|
66
|
+
}
|
|
67
|
+
poolOffset += bytes;
|
|
68
|
+
};
|
|
69
|
+
let nanoid = (size = 21) => {
|
|
70
|
+
fillPool((size -= 0));
|
|
71
|
+
let id = '';
|
|
72
|
+
for (let i = poolOffset - size; i < poolOffset; i++) {
|
|
73
|
+
id += urlAlphabet[pool[i] & 63];
|
|
74
|
+
}
|
|
75
|
+
return id
|
|
76
|
+
};
|
|
77
|
+
|
|
78
|
+
var commonjsGlobal = typeof globalThis !== 'undefined' ? globalThis : typeof window !== 'undefined' ? window : typeof global !== 'undefined' ? global : typeof self !== 'undefined' ? self : {};
|
|
79
|
+
|
|
80
|
+
function getDefaultExportFromCjs (x) {
|
|
81
|
+
return x && x.__esModule && Object.prototype.hasOwnProperty.call(x, 'default') ? x['default'] : x;
|
|
82
|
+
}
|
|
83
|
+
|
|
84
|
+
var dayjs_min = {exports: {}};
|
|
85
|
+
|
|
86
|
+
(function (module, exports) {
|
|
87
|
+
!function(t,e){module.exports=e();}(commonjsGlobal,(function(){var t=1e3,e=6e4,n=36e5,r="millisecond",i="second",s="minute",u="hour",a="day",o="week",c="month",f="quarter",h="year",d="date",l="Invalid Date",$=/^(\d{4})[-/]?(\d{1,2})?[-/]?(\d{0,2})[Tt\s]*(\d{1,2})?:?(\d{1,2})?:?(\d{1,2})?[.:]?(\d+)?$/,y=/\[([^\]]+)]|Y{1,4}|M{1,4}|D{1,2}|d{1,4}|H{1,2}|h{1,2}|a|A|m{1,2}|s{1,2}|Z{1,2}|SSS/g,M={name:"en",weekdays:"Sunday_Monday_Tuesday_Wednesday_Thursday_Friday_Saturday".split("_"),months:"January_February_March_April_May_June_July_August_September_October_November_December".split("_"),ordinal:function(t){var e=["th","st","nd","rd"],n=t%100;return "["+t+(e[(n-20)%10]||e[n]||e[0])+"]"}},m=function(t,e,n){var r=String(t);return !r||r.length>=e?t:""+Array(e+1-r.length).join(n)+t},v={s:m,z:function(t){var e=-t.utcOffset(),n=Math.abs(e),r=Math.floor(n/60),i=n%60;return (e<=0?"+":"-")+m(r,2,"0")+":"+m(i,2,"0")},m:function t(e,n){if(e.date()<n.date())return -t(n,e);var r=12*(n.year()-e.year())+(n.month()-e.month()),i=e.clone().add(r,c),s=n-i<0,u=e.clone().add(r+(s?-1:1),c);return +(-(r+(n-i)/(s?i-u:u-i))||0)},a:function(t){return t<0?Math.ceil(t)||0:Math.floor(t)},p:function(t){return {M:c,y:h,w:o,d:a,D:d,h:u,m:s,s:i,ms:r,Q:f}[t]||String(t||"").toLowerCase().replace(/s$/,"")},u:function(t){return void 0===t}},g="en",D={};D[g]=M;var p="$isDayjsObject",S=function(t){return t instanceof _||!(!t||!t[p])},w=function t(e,n,r){var i;if(!e)return g;if("string"==typeof e){var s=e.toLowerCase();D[s]&&(i=s),n&&(D[s]=n,i=s);var u=e.split("-");if(!i&&u.length>1)return t(u[0])}else {var a=e.name;D[a]=e,i=a;}return !r&&i&&(g=i),i||!r&&g},O=function(t,e){if(S(t))return t.clone();var n="object"==typeof e?e:{};return n.date=t,n.args=arguments,new _(n)},b=v;b.l=w,b.i=S,b.w=function(t,e){return O(t,{locale:e.$L,utc:e.$u,x:e.$x,$offset:e.$offset})};var _=function(){function M(t){this.$L=w(t.locale,null,!0),this.parse(t),this.$x=this.$x||t.x||{},this[p]=!0;}var m=M.prototype;return m.parse=function(t){this.$d=function(t){var e=t.date,n=t.utc;if(null===e)return new Date(NaN);if(b.u(e))return new Date;if(e instanceof Date)return new Date(e);if("string"==typeof e&&!/Z$/i.test(e)){var r=e.match($);if(r){var i=r[2]-1||0,s=(r[7]||"0").substring(0,3);return n?new Date(Date.UTC(r[1],i,r[3]||1,r[4]||0,r[5]||0,r[6]||0,s)):new Date(r[1],i,r[3]||1,r[4]||0,r[5]||0,r[6]||0,s)}}return new Date(e)}(t),this.init();},m.init=function(){var t=this.$d;this.$y=t.getFullYear(),this.$M=t.getMonth(),this.$D=t.getDate(),this.$W=t.getDay(),this.$H=t.getHours(),this.$m=t.getMinutes(),this.$s=t.getSeconds(),this.$ms=t.getMilliseconds();},m.$utils=function(){return b},m.isValid=function(){return !(this.$d.toString()===l)},m.isSame=function(t,e){var n=O(t);return this.startOf(e)<=n&&n<=this.endOf(e)},m.isAfter=function(t,e){return O(t)<this.startOf(e)},m.isBefore=function(t,e){return this.endOf(e)<O(t)},m.$g=function(t,e,n){return b.u(t)?this[e]:this.set(n,t)},m.unix=function(){return Math.floor(this.valueOf()/1e3)},m.valueOf=function(){return this.$d.getTime()},m.startOf=function(t,e){var n=this,r=!!b.u(e)||e,f=b.p(t),l=function(t,e){var i=b.w(n.$u?Date.UTC(n.$y,e,t):new Date(n.$y,e,t),n);return r?i:i.endOf(a)},$=function(t,e){return b.w(n.toDate()[t].apply(n.toDate("s"),(r?[0,0,0,0]:[23,59,59,999]).slice(e)),n)},y=this.$W,M=this.$M,m=this.$D,v="set"+(this.$u?"UTC":"");switch(f){case h:return r?l(1,0):l(31,11);case c:return r?l(1,M):l(0,M+1);case o:var g=this.$locale().weekStart||0,D=(y<g?y+7:y)-g;return l(r?m-D:m+(6-D),M);case a:case d:return $(v+"Hours",0);case u:return $(v+"Minutes",1);case s:return $(v+"Seconds",2);case i:return $(v+"Milliseconds",3);default:return this.clone()}},m.endOf=function(t){return this.startOf(t,!1)},m.$set=function(t,e){var n,o=b.p(t),f="set"+(this.$u?"UTC":""),l=(n={},n[a]=f+"Date",n[d]=f+"Date",n[c]=f+"Month",n[h]=f+"FullYear",n[u]=f+"Hours",n[s]=f+"Minutes",n[i]=f+"Seconds",n[r]=f+"Milliseconds",n)[o],$=o===a?this.$D+(e-this.$W):e;if(o===c||o===h){var y=this.clone().set(d,1);y.$d[l]($),y.init(),this.$d=y.set(d,Math.min(this.$D,y.daysInMonth())).$d;}else l&&this.$d[l]($);return this.init(),this},m.set=function(t,e){return this.clone().$set(t,e)},m.get=function(t){return this[b.p(t)]()},m.add=function(r,f){var d,l=this;r=Number(r);var $=b.p(f),y=function(t){var e=O(l);return b.w(e.date(e.date()+Math.round(t*r)),l)};if($===c)return this.set(c,this.$M+r);if($===h)return this.set(h,this.$y+r);if($===a)return y(1);if($===o)return y(7);var M=(d={},d[s]=e,d[u]=n,d[i]=t,d)[$]||1,m=this.$d.getTime()+r*M;return b.w(m,this)},m.subtract=function(t,e){return this.add(-1*t,e)},m.format=function(t){var e=this,n=this.$locale();if(!this.isValid())return n.invalidDate||l;var r=t||"YYYY-MM-DDTHH:mm:ssZ",i=b.z(this),s=this.$H,u=this.$m,a=this.$M,o=n.weekdays,c=n.months,f=n.meridiem,h=function(t,n,i,s){return t&&(t[n]||t(e,r))||i[n].slice(0,s)},d=function(t){return b.s(s%12||12,t,"0")},$=f||function(t,e,n){var r=t<12?"AM":"PM";return n?r.toLowerCase():r};return r.replace(y,(function(t,r){return r||function(t){switch(t){case"YY":return String(e.$y).slice(-2);case"YYYY":return b.s(e.$y,4,"0");case"M":return a+1;case"MM":return b.s(a+1,2,"0");case"MMM":return h(n.monthsShort,a,c,3);case"MMMM":return h(c,a);case"D":return e.$D;case"DD":return b.s(e.$D,2,"0");case"d":return String(e.$W);case"dd":return h(n.weekdaysMin,e.$W,o,2);case"ddd":return h(n.weekdaysShort,e.$W,o,3);case"dddd":return o[e.$W];case"H":return String(s);case"HH":return b.s(s,2,"0");case"h":return d(1);case"hh":return d(2);case"a":return $(s,u,!0);case"A":return $(s,u,!1);case"m":return String(u);case"mm":return b.s(u,2,"0");case"s":return String(e.$s);case"ss":return b.s(e.$s,2,"0");case"SSS":return b.s(e.$ms,3,"0");case"Z":return i}return null}(t)||i.replace(":","")}))},m.utcOffset=function(){return 15*-Math.round(this.$d.getTimezoneOffset()/15)},m.diff=function(r,d,l){var $,y=this,M=b.p(d),m=O(r),v=(m.utcOffset()-this.utcOffset())*e,g=this-m,D=function(){return b.m(y,m)};switch(M){case h:$=D()/12;break;case c:$=D();break;case f:$=D()/3;break;case o:$=(g-v)/6048e5;break;case a:$=(g-v)/864e5;break;case u:$=g/n;break;case s:$=g/e;break;case i:$=g/t;break;default:$=g;}return l?$:b.a($)},m.daysInMonth=function(){return this.endOf(c).$D},m.$locale=function(){return D[this.$L]},m.locale=function(t,e){if(!t)return this.$L;var n=this.clone(),r=w(t,e,!0);return r&&(n.$L=r),n},m.clone=function(){return b.w(this.$d,this)},m.toDate=function(){return new Date(this.valueOf())},m.toJSON=function(){return this.isValid()?this.toISOString():null},m.toISOString=function(){return this.$d.toISOString()},m.toString=function(){return this.$d.toUTCString()},M}(),k=_.prototype;return O.prototype=k,[["$ms",r],["$s",i],["$m",s],["$H",u],["$W",a],["$M",c],["$y",h],["$D",d]].forEach((function(t){k[t[1]]=function(e){return this.$g(e,t[0],t[1])};})),O.extend=function(t,e){return t.$i||(t(e,_,O),t.$i=!0),O},O.locale=w,O.isDayjs=S,O.unix=function(t){return O(1e3*t)},O.en=D[g],O.Ls=D,O.p={},O}));
|
|
88
|
+
} (dayjs_min));
|
|
89
|
+
|
|
90
|
+
var dayjs_minExports = dayjs_min.exports;
|
|
91
|
+
var dayjs = /*@__PURE__*/getDefaultExportFromCjs(dayjs_minExports);
|
|
92
|
+
|
|
93
|
+
const getConfig = () => {
|
|
94
|
+
let windowConfig = window?.config || {};
|
|
95
|
+
let config = { ...windowConfig };
|
|
96
|
+
if (!config.rootContainer)
|
|
97
|
+
config.rootContainer = "#app";
|
|
98
|
+
if (!config.baseURL)
|
|
99
|
+
config.baseURL = location.origin;
|
|
100
|
+
if (!config.ossBaseURL)
|
|
101
|
+
config.ossBaseURL = "/oss";
|
|
102
|
+
if (config.ossBaseURL.startsWith("/"))
|
|
103
|
+
config.ossBaseURL = `${config.baseURL}/oss`;
|
|
104
|
+
if (!config.ssoBaseURL)
|
|
105
|
+
config.ssoBaseURL = config.baseURL;
|
|
106
|
+
let { microAppName, publicPath, mainAppName } = config;
|
|
107
|
+
const isPro = import.meta.env.PROD;
|
|
108
|
+
if (microAppName && isPro && !publicPath)
|
|
109
|
+
publicPath = `/${microAppName}/`.replace(/\/\//g, "/");
|
|
110
|
+
if (!publicPath)
|
|
111
|
+
publicPath = "/";
|
|
112
|
+
config.publicPath = publicPath;
|
|
113
|
+
if (!config.autoOssBucket)
|
|
114
|
+
config.autoOssBucket = mainAppName || microAppName;
|
|
115
|
+
return config;
|
|
116
|
+
};
|
|
117
|
+
|
|
118
|
+
const getMinioToken = iotMinio.get(`token`);
|
|
119
|
+
const importMinio = iotMinio.post(`putObject`, (config) => {
|
|
120
|
+
if (!config.headers)
|
|
121
|
+
config.headers = {};
|
|
122
|
+
config.headers["Content-Type"] = "multipart/form-data";
|
|
123
|
+
config.responseType = "blob";
|
|
124
|
+
return config;
|
|
125
|
+
});
|
|
126
|
+
const importMultiMinio = iotMinio.post(`upload-objects`, (config) => {
|
|
127
|
+
if (!config.headers)
|
|
128
|
+
config.headers = {};
|
|
129
|
+
config.headers["Content-Type"] = "multipart/form-data";
|
|
130
|
+
config.responseType = "blob";
|
|
131
|
+
return config;
|
|
132
|
+
});
|
|
133
|
+
const getTaskProgress = iotProgress.get(`progress`);
|
|
134
|
+
const useFile = () => {
|
|
135
|
+
let showProgressDialog = ref(false);
|
|
136
|
+
let progressTitle = ref("");
|
|
137
|
+
let percent = ref(0);
|
|
138
|
+
let progressStatus = ref("normal");
|
|
139
|
+
let progressLoading = ref(false);
|
|
140
|
+
let progressTimer;
|
|
141
|
+
let progressResult = ref("");
|
|
142
|
+
let errorFileName = ref("");
|
|
143
|
+
let errorFileSize = ref("");
|
|
144
|
+
let errorMessage = ref("");
|
|
145
|
+
let errorImport = ref(false);
|
|
146
|
+
let errorFilePath = ref("");
|
|
147
|
+
let tempErrPathName = "";
|
|
148
|
+
let fileInfo;
|
|
149
|
+
const resetStataus = () => {
|
|
150
|
+
errorFileName.value = "";
|
|
151
|
+
errorFileSize.value = "";
|
|
152
|
+
errorMessage.value = "";
|
|
153
|
+
errorImport.value = false;
|
|
154
|
+
errorFilePath.value = "";
|
|
155
|
+
};
|
|
156
|
+
const getMinioConfig = async () => {
|
|
157
|
+
const [error, data] = await getMinioToken().run();
|
|
158
|
+
if (error) {
|
|
159
|
+
return { stauts: false };
|
|
160
|
+
}
|
|
161
|
+
return { status: true, data };
|
|
162
|
+
};
|
|
163
|
+
const readFileAndAddToMap = (file) => {
|
|
164
|
+
return new Promise((resolve, reject) => {
|
|
165
|
+
const chunkSize = 1024 * 1024;
|
|
166
|
+
const chunks = [];
|
|
167
|
+
let offset = 0;
|
|
168
|
+
while (offset < file.size) {
|
|
169
|
+
const chunk = file.slice(offset, offset + chunkSize);
|
|
170
|
+
chunks.push(chunk);
|
|
171
|
+
offset += chunkSize;
|
|
172
|
+
}
|
|
173
|
+
const mergedBlob = new Blob(chunks, { type: file.type });
|
|
174
|
+
resolve(mergedBlob);
|
|
175
|
+
});
|
|
176
|
+
};
|
|
177
|
+
const fileImport = async (importFunc, file, options, needProgress = true, errPathName = "", isBatch = false) => {
|
|
178
|
+
tempErrPathName = errPathName;
|
|
179
|
+
if (needProgress) {
|
|
180
|
+
progressStatus.value = "normal";
|
|
181
|
+
percent.value = 0;
|
|
182
|
+
progressTitle.value = "\u5BFC\u5165\u8FDB\u5EA6";
|
|
183
|
+
showProgressDialog.value = true;
|
|
184
|
+
progressResult.value = "";
|
|
185
|
+
}
|
|
186
|
+
fileInfo = file;
|
|
187
|
+
const tokenResult = await getMinioConfig();
|
|
188
|
+
if (!tokenResult.status)
|
|
189
|
+
return;
|
|
190
|
+
let minioConfig = tokenResult.data;
|
|
191
|
+
let params = null;
|
|
192
|
+
let { autoContentType, bucketName, importFileName } = options;
|
|
193
|
+
const fn = isBatch ? importMultiMinio : importMinio;
|
|
194
|
+
if (isBatch) {
|
|
195
|
+
let blobList = [];
|
|
196
|
+
await file.forEach(async (ele) => {
|
|
197
|
+
let blob = await readFileAndAddToMap(ele);
|
|
198
|
+
blobList.push(blob);
|
|
199
|
+
});
|
|
200
|
+
params = new FormData();
|
|
201
|
+
params.append("accessKeyId", minioConfig.accessKeyId);
|
|
202
|
+
params.append("secretAccessKey", minioConfig.secretAccessKey);
|
|
203
|
+
params.append("sessionToken", minioConfig.sessionToken);
|
|
204
|
+
params.append("bucketName", bucketName);
|
|
205
|
+
file.forEach((v, i) => {
|
|
206
|
+
params.append("file", blobList[i]);
|
|
207
|
+
});
|
|
208
|
+
importFileName.forEach((v) => {
|
|
209
|
+
params.append("filePaths", v);
|
|
210
|
+
});
|
|
211
|
+
} else {
|
|
212
|
+
const blob = await readFileAndAddToMap(file);
|
|
213
|
+
params = {
|
|
214
|
+
accessKeyId: minioConfig.accessKeyId,
|
|
215
|
+
secretAccessKey: minioConfig.secretAccessKey,
|
|
216
|
+
sessionToken: minioConfig.sessionToken,
|
|
217
|
+
file: blob,
|
|
218
|
+
bucketName,
|
|
219
|
+
filePath: importFileName,
|
|
220
|
+
autoContentType
|
|
221
|
+
};
|
|
222
|
+
}
|
|
223
|
+
const [error, data] = await fn(params).run();
|
|
224
|
+
if (error)
|
|
225
|
+
return;
|
|
226
|
+
const toStringData = await toStringObject(data.data);
|
|
227
|
+
const importResult = await importFunc?.(toStringData);
|
|
228
|
+
if (needProgress) {
|
|
229
|
+
if (!importResult.status) {
|
|
230
|
+
showProgressDialog.value = false;
|
|
231
|
+
progressStatus.value = "error";
|
|
232
|
+
return;
|
|
233
|
+
}
|
|
234
|
+
progressTitle.value = "\u5BFC\u5165\u8FDB\u5EA6";
|
|
235
|
+
showProgressDialog.value = true;
|
|
236
|
+
checkProgress(importResult.taskId, "import", "");
|
|
237
|
+
} else {
|
|
238
|
+
if (!importResult.status)
|
|
239
|
+
return;
|
|
240
|
+
progressStatus.value = "success";
|
|
241
|
+
}
|
|
242
|
+
};
|
|
243
|
+
const fileAction = async (exportFunc, fileName = "", actionTitle = "") => {
|
|
244
|
+
progressStatus.value = "normal";
|
|
245
|
+
percent.value = 0;
|
|
246
|
+
progressTitle.value = actionTitle || "\u5BFC\u51FA\u8FDB\u5EA6";
|
|
247
|
+
showProgressDialog.value = true;
|
|
248
|
+
const importResult = await exportFunc?.();
|
|
249
|
+
if (!importResult.status) {
|
|
250
|
+
showProgressDialog.value = false;
|
|
251
|
+
progressStatus.value = "error";
|
|
252
|
+
return;
|
|
253
|
+
}
|
|
254
|
+
checkProgress(importResult.taskId, "action", "");
|
|
255
|
+
};
|
|
256
|
+
const fileExport = async (exportFunc, fileName = "", fileSuffix = "") => {
|
|
257
|
+
progressStatus.value = "normal";
|
|
258
|
+
percent.value = 0;
|
|
259
|
+
progressTitle.value = "\u5BFC\u51FA\u8FDB\u5EA6";
|
|
260
|
+
showProgressDialog.value = true;
|
|
261
|
+
const importResult = await exportFunc?.();
|
|
262
|
+
if (!importResult.status) {
|
|
263
|
+
showProgressDialog.value = false;
|
|
264
|
+
progressStatus.value = "error";
|
|
265
|
+
return;
|
|
266
|
+
}
|
|
267
|
+
dayjs().format("YYYYMMDDHHmmss") + ".xlsx";
|
|
268
|
+
checkProgress(importResult.taskId, "export", fileName ? fileName : "", fileSuffix);
|
|
269
|
+
};
|
|
270
|
+
const checkProgress = async (taskId, type, fileName, fileSuffix = "") => {
|
|
271
|
+
progressLoading.value = true;
|
|
272
|
+
getProgress(taskId, type, fileName, fileSuffix);
|
|
273
|
+
progressTimer = setTimeout(() => {
|
|
274
|
+
}, 50);
|
|
275
|
+
};
|
|
276
|
+
const clearTimer = () => {
|
|
277
|
+
clearTimeout(progressTimer);
|
|
278
|
+
progressTimer = null;
|
|
279
|
+
showProgressDialog.value = false;
|
|
280
|
+
};
|
|
281
|
+
const getProgress = async (taskId, type = "export", fileName, fileSuffix = "") => {
|
|
282
|
+
const [error, data] = await getTaskProgress("", {
|
|
283
|
+
url: `progress/${taskId}`
|
|
284
|
+
}).run();
|
|
285
|
+
if (error) {
|
|
286
|
+
progressLoading.value = false;
|
|
287
|
+
return;
|
|
288
|
+
}
|
|
289
|
+
percent.value = data.percentage;
|
|
290
|
+
const tip = type == "export" ? "\u5BFC\u51FA" : "\u5BFC\u5165";
|
|
291
|
+
if (percent.value == 100) {
|
|
292
|
+
progressResult.value = data;
|
|
293
|
+
progressLoading.value = false;
|
|
294
|
+
clearTimer();
|
|
295
|
+
if (type == "export") {
|
|
296
|
+
if (data.status == 1) {
|
|
297
|
+
progressStatus.value = "success";
|
|
298
|
+
downloadFile(`${getConfig().baseURL}/oss${data.filePath}`, fileName, fileSuffix);
|
|
299
|
+
progressLoading.value = false;
|
|
300
|
+
} else if (data.status == 2) {
|
|
301
|
+
errorMessage.value = data.message || `${tip}\u5931\u8D25`;
|
|
302
|
+
}
|
|
303
|
+
} else if (type == "import") {
|
|
304
|
+
if (!!data.filePath) {
|
|
305
|
+
progressStatus.value = "error";
|
|
306
|
+
const matchName = fileInfo.name?.match(/(.*?)(\.[^.]*$|$)/);
|
|
307
|
+
const suffix = matchName.length ? matchName[2] : "";
|
|
308
|
+
errorImport.value = true;
|
|
309
|
+
const pathName = data.filePath?.replace(/(.*\/)*([^.]+).*/gi, "$2");
|
|
310
|
+
errorFileName.value = tempErrPathName ? tempErrPathName : `${pathName}${suffix}`;
|
|
311
|
+
errorFileSize.value = fileInfo.sizeText;
|
|
312
|
+
errorMessage.value = "\u90E8\u5206\u6570\u636E\u6821\u9A8C\u4E0D\u901A\u8FC7\uFF0C\u8BF7\u4E0B\u8F7D\u9644\u4EF6\u5E76\u4FEE\u6539\uFF0C\u91CD\u65B0\u5BFC\u5165\uFF01";
|
|
313
|
+
errorFilePath.value = `${getConfig().baseURL}/oss${data.filePath}`;
|
|
314
|
+
}
|
|
315
|
+
tipHandle(data.status, tip, data.message);
|
|
316
|
+
} else if (type == "action") {
|
|
317
|
+
progressStatus.value = "success";
|
|
318
|
+
}
|
|
319
|
+
} else {
|
|
320
|
+
if (progressTimer && data.status != 2) {
|
|
321
|
+
progressTimer = setTimeout(() => {
|
|
322
|
+
getProgress(taskId, type, fileName, fileSuffix);
|
|
323
|
+
}, 50);
|
|
324
|
+
} else {
|
|
325
|
+
progressResult.value = data;
|
|
326
|
+
progressLoading.value = false;
|
|
327
|
+
tipHandle(data.status, tip, data.message);
|
|
328
|
+
clearTimer();
|
|
329
|
+
errorImport.value = true;
|
|
330
|
+
errorMessage.value = data?.message || "";
|
|
331
|
+
}
|
|
332
|
+
}
|
|
333
|
+
};
|
|
334
|
+
const tipHandle = (status, tip, message) => {
|
|
335
|
+
if (status == 1) {
|
|
336
|
+
progressStatus.value = "success";
|
|
337
|
+
errorFileName.value = "";
|
|
338
|
+
errorFileSize.value = "";
|
|
339
|
+
errorMessage.value = "";
|
|
340
|
+
} else if (status == 2) {
|
|
341
|
+
progressStatus.value = "error";
|
|
342
|
+
errorMessage.value = message ? message : "\u90E8\u5206\u6570\u636E\u6821\u9A8C\u4E0D\u901A\u8FC7\uFF0C\u8BF7\u4E0B\u8F7D\u9644\u4EF6\u5E76\u4FEE\u6539\uFF0C\u91CD\u65B0\u5BFC\u5165\uFF01";
|
|
343
|
+
} else if (status == 3) {
|
|
344
|
+
progressStatus.value = "error";
|
|
345
|
+
}
|
|
346
|
+
};
|
|
347
|
+
const generateUniqueName = (fileName) => {
|
|
348
|
+
const matchName = fileName?.match(/(.*?)(\.[^.]*$|$)/);
|
|
349
|
+
const suffix = matchName.length ? matchName[2] : "";
|
|
350
|
+
const name = matchName.length ? matchName[1] : fileName;
|
|
351
|
+
return `${name}${nanoid()}${suffix}`;
|
|
352
|
+
};
|
|
353
|
+
return {
|
|
354
|
+
showProgressDialog,
|
|
355
|
+
progressTitle,
|
|
356
|
+
percent,
|
|
357
|
+
progressStatus,
|
|
358
|
+
progressLoading,
|
|
359
|
+
progressResult,
|
|
360
|
+
errorFileName,
|
|
361
|
+
errorFileSize,
|
|
362
|
+
errorMessage,
|
|
363
|
+
errorImport,
|
|
364
|
+
errorFilePath,
|
|
365
|
+
fileImport,
|
|
366
|
+
fileExport,
|
|
367
|
+
fileAction,
|
|
368
|
+
generateUniqueName,
|
|
369
|
+
downloadFile,
|
|
370
|
+
resetStataus,
|
|
371
|
+
checkProgress
|
|
372
|
+
};
|
|
373
|
+
};
|
|
374
|
+
const fileBobType = (type) => {
|
|
375
|
+
let tempType = type?.toLocaleLowerCase();
|
|
376
|
+
let typeList = {
|
|
377
|
+
excel: "application/vnd.openxmlformats-officedocument.spreadsheetml.sheet",
|
|
378
|
+
pdf: "application/pdf",
|
|
379
|
+
doc: "application/msword",
|
|
380
|
+
docx: "application/vnd.openxmlformats-officedocument.wordprocessingml.document",
|
|
381
|
+
xls: "application/vnd.ms-excel",
|
|
382
|
+
xlsx: "application/vnd.openxmlformats-officedocument.spreadsheetml.sheet",
|
|
383
|
+
zip: "application/zip",
|
|
384
|
+
txt: "text/plain",
|
|
385
|
+
html: "text/html",
|
|
386
|
+
xml: "application/xml",
|
|
387
|
+
json: "application/json",
|
|
388
|
+
css: "text/css",
|
|
389
|
+
js: "application/javascript",
|
|
390
|
+
svg: "image/svg+xml",
|
|
391
|
+
jpg: "image/jpeg",
|
|
392
|
+
jpeg: "image/jpeg",
|
|
393
|
+
gif: "image/gif",
|
|
394
|
+
bmp: "image/bmp",
|
|
395
|
+
ico: "image/x-icon",
|
|
396
|
+
mp3: "audio/mpeg",
|
|
397
|
+
mp4: "video/mp4",
|
|
398
|
+
pem: "application/x-pem-file",
|
|
399
|
+
crt: "application/x-x509-ca-cert",
|
|
400
|
+
der: "application/x-x509-ca-cert",
|
|
401
|
+
cer: "application/pkix-cert"
|
|
402
|
+
};
|
|
403
|
+
return typeList[tempType];
|
|
404
|
+
};
|
|
405
|
+
const downloadFile = (path, filename, fileSuffix = "excel") => {
|
|
406
|
+
const xhr = new XMLHttpRequest();
|
|
407
|
+
xhr.open("get", path);
|
|
408
|
+
xhr.setRequestHeader("Content-Type", "application/json; charset=UTF-8");
|
|
409
|
+
xhr.responseType = "blob";
|
|
410
|
+
xhr.onload = function(e) {
|
|
411
|
+
const blob = new Blob([this.response], {
|
|
412
|
+
type: fileBobType(fileSuffix)
|
|
413
|
+
});
|
|
414
|
+
const objectUrl = URL.createObjectURL(blob);
|
|
415
|
+
if (window.navigator.msSaveOrOpenBlob) {
|
|
416
|
+
navigator.msSaveBlob(blob, filename);
|
|
417
|
+
} else {
|
|
418
|
+
const element = document.createElement("a");
|
|
419
|
+
element.href = objectUrl;
|
|
420
|
+
element.download = filename;
|
|
421
|
+
element.click();
|
|
422
|
+
window.URL.revokeObjectURL(objectUrl);
|
|
423
|
+
}
|
|
424
|
+
};
|
|
425
|
+
xhr.send();
|
|
426
|
+
};
|
|
427
|
+
const toStringObject = (blob) => {
|
|
428
|
+
return new Promise((resolve, reject) => {
|
|
429
|
+
var reader = new FileReader();
|
|
430
|
+
reader.onload = function(event) {
|
|
431
|
+
let data = "";
|
|
432
|
+
if (typeof reader.result == "string") {
|
|
433
|
+
data = JSON.parse(reader.result);
|
|
434
|
+
}
|
|
435
|
+
resolve(data);
|
|
436
|
+
};
|
|
437
|
+
reader.readAsText(blob);
|
|
438
|
+
});
|
|
439
|
+
};
|
|
440
|
+
|
|
441
|
+
const version$c = "v2";
|
|
442
|
+
const gatewayEdge = createService(`/api/edge/${version$c}`);
|
|
443
|
+
|
|
444
|
+
const version$b = "v1";
|
|
445
|
+
const justauth = createService(`/api/justauth/oauth-server/${version$b}/visitor`);
|
|
446
|
+
const oauthServer = createService(`/api/justauth/oauth-server/${version$b}`);
|
|
447
|
+
|
|
448
|
+
const version$a = "v1";
|
|
449
|
+
const knowledgeBase = createService(`/api/knowledge-base/knowledge/${version$a}`);
|
|
450
|
+
|
|
451
|
+
const version$9 = "v1";
|
|
452
|
+
const daslink = createService(`/api/custom-datasource/custom/${version$9}`);
|
|
453
|
+
|
|
454
|
+
const version$8 = "v1";
|
|
455
|
+
const permission = createService(`/api/permission/${version$8}`);
|
|
456
|
+
|
|
457
|
+
const version$7 = "v1";
|
|
458
|
+
const customer = createService(`/api/customer/customer/${version$7}`);
|
|
459
|
+
const company = createService(`/api/customer/company/${version$7}`);
|
|
460
|
+
const customerGrade = createService(`/api/customer/customer-grade/${version$7}`);
|
|
461
|
+
const customerType = createService(`/api/customer/customer-type/${version$7}`);
|
|
462
|
+
const projectManage = {
|
|
463
|
+
list: createService(`/api/project/${version$7}/list`),
|
|
464
|
+
app: createService(`/api/project/${version$7}/app`),
|
|
465
|
+
people: createService(`/api/project/${version$7}/people`)
|
|
466
|
+
};
|
|
467
|
+
|
|
468
|
+
const version$6 = "v1";
|
|
469
|
+
const portal = createService(`/api/portal/user/${version$6}`);
|
|
470
|
+
|
|
471
|
+
const version$5 = "v1";
|
|
472
|
+
const spaceManage = createService(`/api/space-manage/space-tree/${version$5}`);
|
|
473
|
+
|
|
474
|
+
const version$4 = "v1";
|
|
475
|
+
const superadminPortal = createService(`/api/superadmin/portal/${version$4}`);
|
|
476
|
+
const superadminPermission = createService(`/api/superadmin/permission/${version$4}`);
|
|
477
|
+
const superadminResource = createService(`/api/superadmin/resource/${version$4}`);
|
|
478
|
+
const superadminLicense = createService(`/api/superadmin/license/${version$4}`);
|
|
479
|
+
|
|
480
|
+
const version$3 = "v1";
|
|
481
|
+
const supplier = createService(`/api/supply/supplier/${version$3}`);
|
|
482
|
+
const supplierManage = createService(`/api/supplier/${version$3}`);
|
|
483
|
+
const supplierClassification = createService(`/api/supplier/${version$3}/classification`);
|
|
484
|
+
|
|
485
|
+
const version$2 = "v1";
|
|
486
|
+
const enterpriseadminBrandModel = createService(`/api/supply/brand/${version$2}`);
|
|
487
|
+
|
|
488
|
+
const version$1 = "v2";
|
|
489
|
+
const tool = createService(`/api/tool/${version$1}`);
|
|
490
|
+
|
|
491
|
+
const version = "v1";
|
|
492
|
+
const systemConfiguration = createService(`/api/system-config/${version}`);
|
|
493
|
+
|
|
494
|
+
export { appManage, authentication, bemsModules, company, contract, customer, customerGrade, customerType, daslink, downloadFile, dutyModules, enterpriseadminBrandModel, enterpriseright, gatewayEdge, iot, iotMinio, iotModules, iotProgress, iotRelationModules, justauth, knowledgeBase, oauthServer, permission, portal, projectManage, spaceManage, superadminLicense, superadminPermission, superadminPortal, superadminResource, supplier, supplierClassification, supplierManage, systemConfiguration, tool, useFile };
|
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
import { createService } from '@das-fed/utils/api-services';
|
|
2
|
+
|
|
3
|
+
const version = "v1";
|
|
4
|
+
const iot = createService(`/api/iot/${version}`);
|
|
5
|
+
const iotModules = {
|
|
6
|
+
thingmodel: createService(`/api/iot-device/thingmodel/${version}`),
|
|
7
|
+
deviceManage: createService(`/api/iot-device/devicemanage/${version}`),
|
|
8
|
+
product: createService(`/api/iot-device/product/${version}`),
|
|
9
|
+
productStorage: createService(`/api/iot-device/product-storage/${version}`)
|
|
10
|
+
};
|
|
11
|
+
const iotRelationModules = {
|
|
12
|
+
projectDevice: createService(`/api/device-relation/deviceproject/${version}`),
|
|
13
|
+
deviceRules: createService(`/api/device-relation/devicerule/${version}`),
|
|
14
|
+
project: createService(`/api/device-relation/project/${version}`)
|
|
15
|
+
};
|
|
16
|
+
const iotMinio = createService(`/api/oss/minio/${version}`);
|
|
17
|
+
const iotProgress = createService(`/api/progress/accessor/${version}`);
|
|
18
|
+
|
|
19
|
+
export { iot, iotMinio, iotModules, iotProgress, iotRelationModules };
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
import { createService } from '@das-fed/utils/api-services';
|
|
2
|
+
|
|
3
|
+
const version = "v1";
|
|
4
|
+
const justauth = createService(`/api/justauth/oauth-server/${version}/visitor`);
|
|
5
|
+
const oauthServer = createService(`/api/justauth/oauth-server/${version}`);
|
|
6
|
+
|
|
7
|
+
export { justauth, oauthServer };
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
import { createService } from '@das-fed/utils/api-services';
|
|
2
|
+
|
|
3
|
+
const version = "v1";
|
|
4
|
+
const customer = createService(`/api/customer/customer/${version}`);
|
|
5
|
+
const company = createService(`/api/customer/company/${version}`);
|
|
6
|
+
const customerGrade = createService(`/api/customer/customer-grade/${version}`);
|
|
7
|
+
const customerType = createService(`/api/customer/customer-type/${version}`);
|
|
8
|
+
const projectManage = {
|
|
9
|
+
list: createService(`/api/project/${version}/list`),
|
|
10
|
+
app: createService(`/api/project/${version}/app`),
|
|
11
|
+
people: createService(`/api/project/${version}/people`)
|
|
12
|
+
};
|
|
13
|
+
|
|
14
|
+
export { company, customer, customerGrade, customerType, projectManage };
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
import { createService } from '@das-fed/utils/api-services';
|
|
2
|
+
|
|
3
|
+
const version = "v1";
|
|
4
|
+
const superadminPortal = createService(`/api/superadmin/portal/${version}`);
|
|
5
|
+
const superadminPermission = createService(`/api/superadmin/permission/${version}`);
|
|
6
|
+
const superadminResource = createService(`/api/superadmin/resource/${version}`);
|
|
7
|
+
const superadminLicense = createService(`/api/superadmin/license/${version}`);
|
|
8
|
+
|
|
9
|
+
export { superadminLicense, superadminPermission, superadminPortal, superadminResource };
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
import { createService } from '@das-fed/utils/api-services';
|
|
2
|
+
|
|
3
|
+
const version = "v1";
|
|
4
|
+
const supplier = createService(`/api/supply/supplier/${version}`);
|
|
5
|
+
const supplierManage = createService(`/api/supplier/${version}`);
|
|
6
|
+
const supplierClassification = createService(`/api/supplier/${version}/classification`);
|
|
7
|
+
|
|
8
|
+
export { supplier, supplierClassification, supplierManage };
|