@gonsin/gview 1.0.1

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.
Files changed (70) hide show
  1. package/.browserslistrc +2 -0
  2. package/README.md +26 -0
  3. package/babel.config.js +5 -0
  4. package/gonsin-gview-1.0.1.tgz +0 -0
  5. package/package.json +29 -0
  6. package/postcss.config.js +5 -0
  7. package/public/css/theme/animate.min.css +7 -0
  8. package/public/css/theme/brownishTheme.css +10 -0
  9. package/public/css/theme/coffeeTheme.css +10 -0
  10. package/public/css/theme/cyanTheme.css +10 -0
  11. package/public/css/theme/defaultTheme.css +10 -0
  12. package/public/css/theme/greenTheme.css +16 -0
  13. package/public/css/theme/greyTheme.css +10 -0
  14. package/public/css/theme/orangeTheme.css +10 -0
  15. package/public/css/theme/purpleTheme.css +10 -0
  16. package/public/css/theme/skyblueTheme.css +10 -0
  17. package/public/favicon.ico +0 -0
  18. package/public/imgs/antOutline-border.png +0 -0
  19. package/public/imgs/bg.png +0 -0
  20. package/public/imgs/logo.png +0 -0
  21. package/public/imgs/menu.png +0 -0
  22. package/public/index.html +17 -0
  23. package/src/App.vue +143 -0
  24. package/src/api/api.js +28 -0
  25. package/src/api/index.js +31 -0
  26. package/src/api/request.js +210 -0
  27. package/src/assets/font/font.scss +12 -0
  28. package/src/assets/font/font_dev.scss +12 -0
  29. package/src/assets/font/icon.scss +179 -0
  30. package/src/assets/images/svg/color.svg +1 -0
  31. package/src/assets/logo.png +0 -0
  32. package/src/assets/scss/common.scss +338 -0
  33. package/src/assets/scss/themeColor.scss +35 -0
  34. package/src/components/MyDialog.vue +251 -0
  35. package/src/components/MyForm.vue +324 -0
  36. package/src/components/MyFormAutocomplete.vue +135 -0
  37. package/src/components/MyFormCascader.vue +107 -0
  38. package/src/components/MyFormCheckBox.vue +67 -0
  39. package/src/components/MyFormEditor.vue +85 -0
  40. package/src/components/MyFormInput.vue +68 -0
  41. package/src/components/MyFormLine.vue +49 -0
  42. package/src/components/MyFormRadio.vue +92 -0
  43. package/src/components/MyFormSelect.vue +122 -0
  44. package/src/components/MyFormSelectDate.vue +72 -0
  45. package/src/components/MyFormSelectDateTime.vue +82 -0
  46. package/src/components/MyFormSelectTime.vue +84 -0
  47. package/src/components/MyFormSwitch.vue +60 -0
  48. package/src/components/MyFormTag.vue +67 -0
  49. package/src/components/MyFormTree.vue +137 -0
  50. package/src/components/MyFormUploads.vue +91 -0
  51. package/src/components/MyHeader.vue +176 -0
  52. package/src/components/MyMenus.vue +150 -0
  53. package/src/components/MyPageHeader.vue +344 -0
  54. package/src/components/MyTab.vue +69 -0
  55. package/src/components/MyTable.vue +244 -0
  56. package/src/components/Templatess.vue +630 -0
  57. package/src/index.js +23 -0
  58. package/src/main.js +86 -0
  59. package/src/router.js +52 -0
  60. package/src/store/index.js +71 -0
  61. package/src/utils/common.js +96 -0
  62. package/src/utils/permission.js +36 -0
  63. package/src/views/GView.vue +185 -0
  64. package/src/views/Home.vue +26 -0
  65. package/src/views/Login.vue +249 -0
  66. package/src/websocket/test.js +140 -0
  67. package/src/websocket/websocket.js +141 -0
  68. package/src/websocket/websocket1.js +117 -0
  69. package/src/websocket/websocket2.js +128 -0
  70. package/vue.config.js +42 -0
@@ -0,0 +1,630 @@
1
+ <!--
2
+ * @Author: your name
3
+ * @Date: 2022-04-24 14:47:43
4
+ * @LastEditTime: 2022-11-30 16:45:57
5
+ * @LastEditors: lrm lrm@gonsin.cn
6
+ * @Description: 打开koroFileHeader查看配置 进行设置: https://github.com/OBKoro1/koro1FileHeader/wiki/%E9%85%8D%E7%BD%AE
7
+ * @FilePath: \client\src\components\Templatess.vue
8
+ -->
9
+ <template>
10
+ <div class="templatess">
11
+ <myHeader
12
+ :data="board.header"
13
+ :viewName="viewName"
14
+ v-if="board.header"
15
+ @returnFileUrl="activeFile"
16
+ @clickAction="actionByHeader"
17
+ @searchAction="searchByHeader"
18
+ ></myHeader>
19
+ <myTable
20
+ v-if="board.boardType == 'table'"
21
+ :data="board"
22
+ :propsPagination="props"
23
+ @returnAction="retuenSubAction"
24
+ :list="dataList"
25
+ @returnSelect="newSelection"
26
+ @returnProps="reSetProps"
27
+ ></myTable>
28
+ <template v-if="board.boardType == 'form'">
29
+ <el-card shadow="never">
30
+ <myForm
31
+ :viewName="viewName"
32
+ :formData="[board]"
33
+ :selectData="formData"
34
+ @confirmForm="handleConfirmForm"
35
+ @closeDialog="hideMyDialog"
36
+ ></myForm>
37
+ </el-card>
38
+ </template>
39
+ <myTab
40
+ v-if="board.boardType == 'tab'"
41
+ :tabs="board.tabs"
42
+ ></myTab>
43
+ <myDialog
44
+ v-if="dialogModel.isShowDialog"
45
+ :dialogViewData="dialogModel.viewData"
46
+ :dialogFormData="dialogModel.formData"
47
+ @hideDialog="handleCloseDialog"
48
+ @refresh="refreshThisPage"
49
+ ></myDialog>
50
+ </div>
51
+ </template>
52
+
53
+ <script>
54
+ import myHeader from "../components/MyHeader.vue";
55
+ import myTable from "../components/MyTable.vue";
56
+ import myDialog from "../components/MyDialog.vue";
57
+ import myTab from "../components/MyTab.vue";
58
+ import myForm from '../components/MyForm.vue';
59
+ import { onsendregisterWs } from "../websocket/test";
60
+ import { mapActions } from "vuex";
61
+ import * as api from '../api'
62
+
63
+ import Mustache from 'mustache'
64
+
65
+ export default {
66
+ name: "templatess",
67
+ props: {
68
+ board: {
69
+ type: Object,
70
+ },
71
+ queryProps: {
72
+ type: Object
73
+ },
74
+ viewName: {
75
+ type: String,
76
+ },
77
+ dialogFormData: {
78
+ type: Object
79
+ }
80
+ },
81
+ components: {
82
+ myTable,
83
+ myHeader,
84
+ myDialog,
85
+ myTab,
86
+ myForm
87
+ },
88
+ watch:{
89
+ viewName() {
90
+ this.getData();
91
+ },
92
+ '$store.state.isUpdate'(newVal,oldVal){
93
+ //对数据执行操作
94
+ if(newVal){
95
+ this.getData();
96
+ }
97
+ }
98
+ },
99
+ data() {
100
+ return {
101
+ showHeader: false,
102
+ dialogModel: {
103
+ isShowDialog: false,
104
+ viewData: null,
105
+ formData:null
106
+ },
107
+ headerProps:{},
108
+ props: {
109
+ count: 10,
110
+ page: 0,
111
+ totalCount:0,
112
+ pageCount:0,
113
+ },
114
+ formData: {},
115
+ dataList: [],
116
+ selection: [], //选中的数据,
117
+ item: {
118
+ startTime: 9999,
119
+ endTime: 6666
120
+ }
121
+ };
122
+ },
123
+ mounted() {
124
+ this.getData();
125
+
126
+ window.addEventListener('onmessageWS', (event) => {
127
+ let updatedDataId = event.detail.data.args.dataId
128
+ // let currentDataId
129
+ // if (this.board) {
130
+ // currentDataId = this.board?.tableData.dataId || this.board?.data.dataId
131
+ // }
132
+ // if (currentDataId == updatedDataId) {
133
+ this.getData()
134
+ // }
135
+ })
136
+ },
137
+ methods: {
138
+ ...mapActions(["setUpdateFunction"]),
139
+ //顶部搜索的操作
140
+ searchByHeader(model){
141
+ this.headerProps = model;
142
+ this.$store.commit("SetisUpdate", true);
143
+ },
144
+ //刷新页面
145
+ refreshThisPage(){
146
+ this.$emit("refreshPage");
147
+ },
148
+ //最终上传文件的路径
149
+ activeFile(e,item) {
150
+ let arr = [];
151
+ arr.push(e.data[0]);
152
+ api
153
+ .activeFile({
154
+ boardName: this.viewName,
155
+ buttonId: item.buttonId,
156
+ props: {},
157
+ fileUrls: arr,
158
+ })
159
+ .then((res) => {
160
+ if (res.data.state == 200) {
161
+ this.$message({
162
+ type: "success",
163
+ message: "导入成功",
164
+ });
165
+ } else {
166
+ this.$message({
167
+ type: "error",
168
+ message: "导入失败",
169
+ });
170
+ }
171
+ });
172
+ },
173
+ //选中的数据
174
+ newSelection(list) {
175
+ this.selection = list;
176
+ },
177
+ //特殊的数据
178
+ getSelects(item, callback) {
179
+ api
180
+ .getViewData({
181
+ viewName: this.viewName,
182
+ dataId: item.dataId,
183
+ })
184
+ .then((res) => {
185
+ // console.log(res);
186
+ if (res.data.state == 200) {
187
+ if (res.data.data != null) {
188
+ let list = res.data.data;
189
+ if (list.length != 0) {
190
+ let arr = [];
191
+ list.forEach((item) => {
192
+ arr.push({
193
+ label: item,
194
+ value: item,
195
+ });
196
+ });
197
+ callback(arr);
198
+ } else {
199
+ callback([]);
200
+ }
201
+ } else {
202
+ callback([]);
203
+ }
204
+ } else {
205
+ callback([]);
206
+ }
207
+ });
208
+ },
209
+ //获取下拉的数据
210
+ getSelect(item, callback) {
211
+ api
212
+ .getViewData({
213
+ viewName: this.viewName,
214
+ dataId: item.dataId,
215
+ })
216
+ .then((res) => {
217
+ // console.log(res);
218
+ if (res.data.state == 200) {
219
+ onsendregisterWs(this.board.tableData.dataId)
220
+ if (res.data.data != null) {
221
+ let list = res.data.data;
222
+ if (list.length != 0) {
223
+ let arr = [];
224
+ list.forEach((item) => {
225
+ arr.push({
226
+ label: item.name,
227
+ value: item.groupId,
228
+ });
229
+ });
230
+ callback(arr);
231
+ } else {
232
+ callback([]);
233
+ }
234
+ } else {
235
+ callback([]);
236
+ }
237
+ } else {
238
+ callback([]);
239
+ }
240
+ });
241
+ },
242
+ //获取列表
243
+ getData (){
244
+ let that = this;
245
+ let model = {};
246
+ let boardType = this.board.boardType
247
+
248
+ if (boardType == 'table') {
249
+ if(that.$route.query.props){
250
+ model = JSON.parse(this.$route.query.props);
251
+ model.count = that.props.count;
252
+ model.page = that.props.page
253
+ }else{
254
+ model.count = that.props.count;
255
+ model.page = that.props.page;
256
+ }
257
+ // let model = {
258
+ // count: that.props.count,
259
+ // page: that.props.page,
260
+ // }
261
+ if(JSON.stringify(that.headerProps) != "{}"){
262
+ let newModel = {};
263
+ // 非空对象,排除对象中空值
264
+ for(let i in this.headerProps){
265
+ if(this.headerProps[i] != '' && this.headerProps[i] != null){
266
+ newModel[i] = this.headerProps[i]
267
+ }
268
+ }
269
+ Object.assign(model,newModel);
270
+ }else{
271
+ // 空对象
272
+ Object.assign(model,this.headerProps);
273
+ }
274
+
275
+ if (this.queryProps) {
276
+ Object.assign(model, this.queryProps)
277
+ }
278
+
279
+ api
280
+ .getViewData({
281
+ viewName: that.viewName,
282
+ dataId: that.board.tableData.dataId,
283
+ props: model,
284
+ })
285
+ .then((res) => {
286
+ if (res.data.state == 200) {
287
+ that.dataList = [];
288
+ onsendregisterWs(that.board.tableData.dataId)
289
+ // socket.registerMessage(this.board.tableData.dataId,'getData')
290
+ // socket.methods.registerMessage(this.board.tableData.dataId,'getData')
291
+ localStorage.setItem('dataId',that.board.tableData.dataId)
292
+ that.$store.dispatch('setUpdateFunction',{dataId:that.board.tableData.dataId,name:'getData'});
293
+ let list = res.data.data.data;
294
+ that.props.totalCount = res.data.data.totalCount;
295
+ that.props.pageCount = res.data.data.pageCount;
296
+ that.props.page = res.data.data.page;
297
+ that.props.count = res.data.data.count;
298
+
299
+ if (list.length != 0) {
300
+ that.dataList = list;
301
+ }
302
+ this.$store.commit('SetisUpdate',false)
303
+ } else {
304
+ that.$message({
305
+ type: "error",
306
+ message: res.data.message,
307
+ });
308
+ }
309
+ });
310
+ } else if (boardType == 'form') {
311
+ if(that.$route.query.props){
312
+ model = JSON.parse(this.$route.query.props);
313
+ }
314
+
315
+ if(JSON.stringify(that.headerProps) != "{}"){
316
+ let newModel = {};
317
+ // 非空对象,排除对象中空值
318
+ for(let i in this.headerProps){
319
+ if(this.headerProps[i] != '' && this.headerProps[i] != null){
320
+ newModel[i] = this.headerProps[i]
321
+ }
322
+ }
323
+
324
+ Object.assign(model, newModel);
325
+ }else{
326
+ // 空对象
327
+ Object.assign(model, this.headerProps);
328
+ }
329
+
330
+ if (this.queryProps) {
331
+ Object.assign(model, this.queryProps)
332
+ }
333
+
334
+
335
+ if (this.board.data) {
336
+ api
337
+ .getViewData({
338
+ viewName: that.viewName,
339
+ dataId: this.board.data.dataId,
340
+ props: model
341
+ }).then((res) => {
342
+ if (res.data.state == 200) {
343
+ onsendregisterWs(that.board.data.dataId)
344
+ localStorage.setItem('dataId',that.board.data.dataId)
345
+ that.$store.dispatch('setUpdateFunction',{dataId:that.board.data.dataId,name:'getData'});
346
+ that.formData = res.data.data
347
+ // console.log('getViewData that.formData',that.formData)
348
+ this.$store.commit('SetisUpdate',false)
349
+ } else {
350
+ that.$message({
351
+ type: "error",
352
+ message: res.data.message,
353
+ });
354
+ }
355
+ })
356
+ }
357
+ }
358
+ },
359
+ //关闭dialog
360
+ hideMyDialog() {
361
+ this.$emit('closeDialog')
362
+ },
363
+ handleCloseDialog() {
364
+ this.dialogModel.isShowDialog = false;
365
+ },
366
+ //顶部按钮的操作
367
+ actionByHeader(item) {
368
+ if (item.action == "VIEW_BY_DIALOG") {
369
+ //打开dialog并自定义输出
370
+ this.dialogModel.viewData = item;
371
+ this.dialogModel.formData = {};
372
+ this.dialogModel.isShowDialog = true;
373
+ } else if (item.action == "BATCH") {
374
+ //批量操作
375
+ this.$confirm("此操作将" + item.name + ", 是否继续?", "提示", {
376
+ confirmButtonText: "确定",
377
+ cancelButtonText: "取消",
378
+ type: "warning",
379
+ })
380
+ .then(() => {
381
+ if (this.selection.length == 0) {
382
+ this.$message({
383
+ type: "error",
384
+ message: "请选择操作对象!",
385
+ });
386
+ return false;
387
+ }
388
+ this.batchAction(item, this.selection, (bool) => {
389
+ if (bool) {
390
+ this.$message({
391
+ type: "success",
392
+ message: "操作成功!",
393
+ });
394
+ this.refreshThisPage();
395
+ } else {
396
+ this.$message({
397
+ type: "error",
398
+ message: res.data.message,
399
+ });
400
+ }
401
+ });
402
+ })
403
+ .catch(() => {
404
+ this.$message({
405
+ type: "info",
406
+ message: "已取消操作",
407
+ });
408
+ });
409
+ } else if (item.action == "UPLOAD_FILE") {
410
+ //上传文件
411
+ } else if (item.action == "DOWNLOAD") {
412
+ //下载文件
413
+ // /restapi/s08/download?url=xx
414
+ const fileName = "下载";
415
+ const el = document.createElement("a");
416
+ el.style.display = "none";
417
+ el.setAttribute("target", "_blank");
418
+ fileName && el.setAttribut
419
+ e("download", fileName);
420
+ el.href = "http://192.168.2.192:8089" + item.downloadUrl;
421
+ console.log(el);
422
+ document.body.appendChild(el);
423
+ el.click();
424
+ document.body.removeChild(el);
425
+ }else if(item.action == 'LINK'){
426
+ window.open(item.link);
427
+ }
428
+ },
429
+ //批量操作
430
+ batchAction(item, list, callback) {
431
+ let arr = [];
432
+ let params = {}
433
+ list.forEach((item) =>
434
+ arr.push(item[this.board.tableData.keyName])
435
+ );
436
+ if(item.props.length !=0){
437
+ //循环生成需要传递的props
438
+ for(let i in item.props){
439
+ // params[action.props[i].keyName] = row[action.props[i].keyName]
440
+ if(item.props[i].valueName.indexOf('.') >-1){
441
+ let arr = item.props[i].valueName.split('.');
442
+ params[item.props[i].keyName] = row[arr[1]]
443
+ }
444
+ }
445
+ }
446
+ api
447
+ .batchAction({
448
+ viewName: this.viewName,
449
+ buttonId: item.buttonId,
450
+ props: params,
451
+ keys: arr,
452
+ })
453
+ .then((res) => {
454
+ if (res.data.state == 200) {
455
+ callback(true);
456
+ } else {
457
+ callback(false);
458
+ }
459
+ });
460
+ },
461
+ //发送确认完的请求
462
+ sendConfirm(row, action) {
463
+ let params = {};
464
+ // console.log(row);
465
+ // console.log(action.props);
466
+
467
+ //判断action的props是否有东西可以传
468
+ if(action.props.length ==0){
469
+ params[this.board.tableData.keyName] =row[this.board.tableData.keyName];
470
+ }else{
471
+ //循环生成需要传递的props
472
+ for(let i in action.props){
473
+ // params[action.props[i].keyName] = row[action.props[i].keyName]
474
+ if(action.props[i].valueName.indexOf('.') >-1){
475
+ let arr = action.props[i].valueName.split('.');
476
+ params[action.props[i].keyName] = row[arr[1]]
477
+ }else{
478
+ params[action.props[i].keyName] = row[action.props[i].valueName]
479
+ }
480
+ }
481
+ }
482
+
483
+
484
+ api
485
+ .confirm({
486
+ buttonId: action.buttonId,
487
+ props: params,
488
+ viewName: this.viewName,
489
+ })
490
+ .then((res) => {
491
+ if (res.data.state == 200) {
492
+ this.$message({
493
+ type: "success",
494
+ message: "操作成功",
495
+ });
496
+ // this.refreshThisPage();
497
+ } else {
498
+ this.$message({
499
+ type: "error",
500
+ message: res.data.message,
501
+ });
502
+ }
503
+ });
504
+ },
505
+ //表单按钮操作
506
+ retuenSubAction(row, action) {
507
+ if (action.action == "CONFIRM") {
508
+ let message
509
+ if (action.confirmMessage != '') {
510
+ message = Mustache.render(action.confirmMessage, { item: row });
511
+ } else {
512
+ message = `是否确定${action.name}?`
513
+ }
514
+
515
+ this.$confirm(message, {
516
+ confirmButtonText: "确定",
517
+ cancelButtonText: "取消",
518
+ type: "warning",
519
+ })
520
+ .then(() => {
521
+ this.sendConfirm(row, action);
522
+ })
523
+ .catch(() => {
524
+ this.$message({
525
+ type: "info",
526
+ message: `已取消${action.name}`,
527
+ });
528
+ });
529
+ } else if (action.action == "VIEW_BY_DIALOG") {
530
+ //打开dialog并自定义输出
531
+ this.dialogModel.viewData = action;
532
+ this.dialogModel.formData = row;
533
+ this.dialogModel.isShowDialog = true;
534
+ }else if(action.action = "view"){
535
+ //修改view部分,跳转到某个view
536
+ if(action.props.length!=0){
537
+ let model = {};
538
+ action.props.forEach(item=>{
539
+ model[item.keyName] = row[item.keyName];
540
+ })
541
+ this.$router.push({
542
+ path: '/view?viewName='+action.view+'&props='+JSON.stringify(model),
543
+ });
544
+ }else{
545
+ this.$router.push({
546
+ path: '/view?viewName='+action.view,
547
+ });
548
+ }
549
+
550
+ }else if(action.action = "link"){
551
+ //直接修改url跳转某个网页
552
+ window.open(action.link);
553
+ }else if(action.action = "upload_file"){
554
+ //上传文件
555
+ }else if(action.action = "download"){
556
+ //下载文件
557
+ const fileName = "下载";
558
+ const el = document.createElement("a");
559
+ el.style.display = "none";
560
+ el.setAttribute("target", "_blank");
561
+ fileName && el.setAttribute("download", fileName);
562
+ el.href = this.baseIP + item.downloadUrl;
563
+ console.log(el);
564
+ document.body.appendChild(el);
565
+ el.click();
566
+ document.body.removeChild(el);
567
+ }else if(action.action = "close_dialog"){
568
+ //关闭当前dialog(仅对view_by_dialog打开的窗口有效)
569
+ }else if(action.action = "confirm_and_close"){
570
+ //执行confirm操作并关闭当前dialog(仅对view_by_dialog打开的窗口有效)
571
+ }else if(action.action = "none"){
572
+ //什么都不做
573
+ return false;
574
+ }
575
+ },
576
+ //重置页数跟数量
577
+ reSetProps(model){
578
+ this.props = model;
579
+ this.getData();
580
+ },
581
+ // 表单的关闭按钮事件处理
582
+ handleCloseDialog() {
583
+ // this.$router.back()
584
+ this.dialogModel.isShowDialog = false;
585
+ },
586
+ // 表单的提交事件处理
587
+ handleConfirmForm(params, id) {
588
+ let model = {};
589
+ if(this.$route.query.props){
590
+ model = JSON.parse(this.$route.query.props);
591
+ }
592
+ if (this.queryProps != null) {
593
+ Object.assign(model, this.queryProps)
594
+ }
595
+ Object.assign(params, model);
596
+ let confirmModel = {
597
+ buttonId: id,
598
+ props: params,
599
+ viewName: this.$route.query.viewName
600
+ }
601
+
602
+ api.confirm(confirmModel).then((res) => {
603
+ if(res.data.state == 200){
604
+ this.$message({
605
+ type: "success",
606
+ message: "操作成功",
607
+ });
608
+ this.hideMyDialog();
609
+ // this.refreshThisPage();
610
+ }else{
611
+ // console.log('提交失败')
612
+ this.$message({
613
+ type: "error",
614
+ message: `${res.data.state} ${res.data.message}`,
615
+ });
616
+ }
617
+ });
618
+ }
619
+ },
620
+ };
621
+ </script>
622
+ <style lang="scss" scoped>
623
+ .templatess {
624
+ // flex: 1;
625
+ height:100%;
626
+ position: relative;
627
+ display: flex;
628
+ flex-direction: column;
629
+ }
630
+ </style>
package/src/index.js ADDED
@@ -0,0 +1,23 @@
1
+ import GView from './views/GView.vue'
2
+
3
+ // import ElementUI from 'element-ui';
4
+ // import 'element-ui/lib/theme-chalk/index.css';
5
+
6
+ import store from './store'
7
+
8
+ function install (app, options = {}) {
9
+ if (install.installed) return;
10
+ install.installed = true;
11
+ // app.use(ElementUI);
12
+ app.component("GView", GView);
13
+ }
14
+
15
+ GView.install = install
16
+ GView.store = store
17
+
18
+ // 判断是否是直接引入文件
19
+ if (typeof window !== 'undefined' && window.Vue) {
20
+ install(window.Vue)
21
+ }
22
+
23
+ export default GView