Przeglądaj źródła

fixed: 修改数据格式

liuyang 2 lat temu
rodzic
commit
3bb4f39e85

+ 0 - 52
src/api/common.ts

@ -1,52 +0,0 @@
1
/*
2
 * @Author: Devin
3
 * @Date: 2022-11-21 17:09:09
4
 * @LastEditors: Devin
5
 * @LastEditTime: 2022-11-28 14:28:17
6
 * @Description: 公共接口
7
 */
8
import { AIotRequest } from './index';
9
10
export const CommonAPI = {
11
  getValueTypeList:
12
    '/characteristicSpecValue/findSpecValueByCharSpecId?charSpecId=101002',
13
  getUnitList:
14
    '/characteristicSpecValue/findSpecValueByCharSpecId?charSpecId=701004',
15
  getNodeTypeList:
16
    '/characteristicSpecValue/findSpecValueByCharSpecId?charSpecId=701003',
17
  getAlarmLevel:
18
    '/characteristicSpecValue/findSpecValueByCharSpecId?charSpecId=802001',
19
  getDeviceState:
20
    '/characteristicSpecValue/findSpecValueByCharSpecId?charSpecId=701008',
21
  uploadFile: `${import.meta.env.VITE_BASE_URL}/dmp/file/uploadFile`
22
};
23
24
export function getValueTypeList() {
25
  return AIotRequest.get({
26
    url: CommonAPI.getValueTypeList
27
  });
28
}
29
30
export function getUnitList() {
31
  return AIotRequest.get({
32
    url: CommonAPI.getUnitList
33
  });
34
}
35
36
export function getNodeTypeList() {
37
  return AIotRequest.get({
38
    url: CommonAPI.getNodeTypeList
39
  });
40
}
41
42
export function getAlarmLevel() {
43
  return AIotRequest.get({
44
    url: CommonAPI.getAlarmLevel
45
  });
46
}
47
48
export function getDeviceState() {
49
  return AIotRequest.get({
50
    url: CommonAPI.getDeviceState
51
  });
52
}

+ 2 - 2
src/api/flow.ts

@ -227,14 +227,14 @@ export function getServiceDetail(data: any) {
227 227
}
228 228
229 229
export const otherApi = {
230
  getSqlList: '/df/ipu/sql/getSqlWithPage',
230
  getSqlList: '/ipu/sqlMgmt/sql',
231 231
  downloadTemplate: 'ipu/file/databusTemplate/download',
232 232
  getSystemConfig: 'ipu/config/value'
233 233
};
234 234
235 235
// 获取接口详情
236 236
export function getSqlServiceList(data: any): Promise<any> {
237
  return AIotRequest.post({
237
  return AIotRequest.get({
238 238
    url: otherApi.getSqlList,
239 239
    data
240 240
  });

+ 34 - 2
src/views/_components/panel/PanelGlobal.vue

@ -121,7 +121,10 @@
121 121
    ></custom-detail-list>
122 122
123 123
    <!-- 上传下载 -->
124
    <custom-import v-if="dialogType === 'fileImport'"></custom-import>
124
    <custom-import
125
      v-if="dialogType === 'fileImport'"
126
      ref="batchCreateCustomRef"
127
    ></custom-import>
125 128
  </dialog-panel>
126 129
</template>
127 130
@ -369,6 +372,18 @@ function setModelInfo() {
369 372
}
370 373
371 374
const { importModel } = setModelInfo();
375
376
// 导入导出
377
const batchCreateCustomRef = ref(null);
378
function batchCreateCustom() {
379
  const data = batchCreateCustomRef.value.tableData;
380
  table.value.customAttrs.data = [...data, ...table.value.customAttrs.data];
381
  table.value.customAttrs.data.map((item) => {
382
    item.actions = btns;
383
    return item;
384
  });
385
  closeDialog();
386
}
372 387
/** 模型声明 end */
373 388
374 389
function confirmDialog() {
@ -381,6 +396,9 @@ function confirmDialog() {
381 396
    case 'viewCustomDetail':
382 397
      closeDialog();
383 398
      break;
399
    case 'fileImport':
400
      batchCreateCustom();
401
      break;
384 402
    default:
385 403
      break;
386 404
  }
@ -392,6 +410,11 @@ function closeDialog() {
392 410
}
393 411
394 412
const customDetail = ref(null);
413
const btns = [
414
  // { label: '编辑', name: 'edit', onClick: editFn },
415
  { label: '删除', name: 'delete', onClick: confirmEvent }
416
];
417
395 418
// 自定义属性表格操作
396 419
function customAttrFn() {
397 420
  // if (attrInfo.value.type === 'add') {
@ -407,8 +430,17 @@ function customAttrFn() {
407 430
  //     }
408 431
  //     return item;
409 432
  //   });
433
410 434
  const data = customDetail.value.attrList;
411
  table.value.customAttrs.data = [...data, ...table.value.customAttrs.data];
435
  const newData = [...data, ...table.value.customAttrs.data];
436
  newData.filter(
437
    (item, index) => newData.findIndex((t) => t.id === item.id) === index
438
  );
439
  table.value.customAttrs.data = newData;
440
  table.value.customAttrs.data.map((item) => {
441
    item.actions = btns;
442
    return item;
443
  });
412 444
413 445
  closeDialog();
414 446
}

+ 11 - 0
src/views/_components/panel/global/CustomImport.vue

@ -21,6 +21,11 @@
21 21
        <el-button type="success">文件导入</el-button>
22 22
      </el-upload>
23 23
    </div>
24
    <common-table
25
      class="global-table"
26
      :table-header="tableHeader"
27
      :table-data="tableData"
28
    ></common-table>
24 29
  </div>
25 30
</template>
26 31
@ -33,6 +38,12 @@ function downTemplate() {
33 38
  window.open(downloadTemplaye());
34 39
}
35 40
41
const tableHeader = ref([
42
  { label: '属性名称', name: 'name', 'min-width': '150' },
43
  { label: '属性ID', name: 'id', 'min-width': '150' },
44
  { label: '属性类型', name: 'type', 'min-width': '150' }
45
]);
46
36 47
// excel表数据处理
37 48
const tableData = ref([]);
38 49
function useExcelHooks(e: any) {

+ 0 - 1
src/views/_components/right-panel/PanelSql.vue

@ -208,7 +208,6 @@ const sqlPropsMap = ref<any>({
208 208
});
209 209
function getSQLList() {
210 210
  const params = <any>{
211
    name: '',
212 211
    pageNumber: 1,
213 212
    pageSize: 1000
214 213
  };

+ 59 - 58
src/views/_components/right-panel/_components/PanelDataAssembly.vue

@ -29,7 +29,6 @@
29 29
            <template #default="{ node, data }">
30 30
              <div class="tree-item">
31 31
                <span class="label">{{ data.name }}</span>
32
33 32
                <span class="type">
34 33
                  {{ data.id }}
35 34
                </span>
@ -69,7 +68,10 @@
69 68
      <h5 class="title">属性</h5>
70 69
      <ul class="tag-list">
71 70
        <li v-for="(item, index) in tagList" :key="index">
72
          <h5 class="tag-title">{{ item.label }}</h5>
71
          <h5 class="tag-title">
72
            <span class="dian" :style="{ background: item.color }"></span>
73
            <span>{{ item.label }}</span>
74
          </h5>
73 75
          <div class="tag-content">
74 76
            <template v-for="(tag, tagIndex) in item.tags" :key="tagIndex">
75 77
              <span
@ -77,9 +79,10 @@
77 79
                :class="`${tag?.['type']}-color`"
78 80
                @click.stop="handleClickTag(tag)"
79 81
              >
80
                {{ tag.label }}
82
                {{ tag.name }}
81 83
              </span>
82 84
            </template>
85
            <!-- <el-button size="small" @click.stop="">快速创建</el-button> -->
83 86
          </div>
84 87
        </li>
85 88
      </ul>
@ -98,65 +101,36 @@ import {
98 101
} from 'vue';
99 102
import JsonEditor from 'json-editor-vue3';
100 103
import { v4 as uuidv4 } from 'uuid';
104
import { useRoute } from 'vue-router';
101 105
102 106
const { proxy } = getCurrentInstance();
107
const route = useRoute();
108
109
const systemId = route.query.id;
110
111
const dataBus = JSON.parse(localStorage.getItem('panelGlobal'))?.[
112
  `${systemId}`
113
];
114
const customAttrs = dataBus?.customAttrs?.data || [];
115
console.log(customAttrs);
116
103 117
const props = defineProps({
104 118
  dataSource: {
105 119
    type: Array,
106 120
    default: () => []
107 121
  }
108 122
});
123
// 源数据
109 124
const tagList = ref<any>([
110
  {
111
    label: '字符串',
112
    type: 'string',
113
    uuid: 1,
114
    tags: [
115
      { label: '姓名', name: 'name', type: 'string', uuid: 2 },
116
      { label: '电话号码', name: 'tel', type: 'string', uuid: 3 },
117
      { label: '邮箱', name: 'email', type: 'string', uuid: 4 }
118
    ]
119
  },
120
  {
121
    label: '整数',
122
    type: 'int',
123
    uuid: 5,
124
    tags: [
125
      { label: '年龄', name: 'age', type: 'int', uuid: 6 },
126
      { label: '性别', name: 'sex', type: 'int', uuid: 7 },
127
      { label: '班级', name: 'class', type: 'int', uuid: 8 }
128
    ]
129
  },
130
131
  {
132
    label: '布尔类型',
133
    type: 'boolean',
134
    uuid: 9,
135
    tags: [
136
      { label: '婚姻状况', name: 'marry', type: 'boolean', uuid: 10 },
137
      { label: '生育状况', name: 'sex', type: 'boolean', uuid: 11 }
138
    ]
139
  },
140
141
  {
142
    label: '对象',
143
    type: 'object',
144
    uuid: 12,
145
    tags: [
146
      { label: '结果', name: 'result', type: 'object', uuid: 13 },
147
      { label: '学生', name: 'student', type: 'object', uuid: 14 },
148
      { label: '员工', name: 'staff', type: 'object', uuid: 15 }
149
    ]
150
  },
151
  {
152
    label: '数组',
153
    type: 'array',
154
    uuid: 16,
155
    tags: [
156
      { label: '兴趣', name: 'likes', type: 'array', uuid: 17 },
157
      { label: '作品', name: 'works', type: 'array', uuid: 18 }
158
    ]
159
  }
125
  { label: '对象', color: '#ff956f', type: 'object', tags: [] },
126
  { label: '数组', color: '#ffb95b', type: 'array', tags: [] },
127
  { label: '字符串', color: '#31cf9a', type: 'string', tags: [] },
128
  { label: '整数', color: '#169bfa', type: 'int', tags: [] },
129
  { label: '布尔类型', color: '#ff956f', type: 'boolean', tags: [] },
130
  { label: '长整数', color: '#ff5f5f', type: 'long', tags: [] },
131
  { label: '小数', color: '#21c5db', type: 'decimal', tags: [] },
132
  { label: '日期', color: '#c084fc', type: 'date', tags: [] },
133
  { label: '时间', color: '#f471b7', type: 'datetime', tags: [] }
160 134
]);
161 135
const treeData = ref<any>([...props.dataSource] || []);
162 136
const jsonData = ref<any>({});
@ -164,6 +138,20 @@ const jsonData = ref<any>({});
164 138
const currentNode = ref<any>({});
165 139
const myTree = ref<any>(null);
166 140
141
// 源数据处理
142
function formateSourceData(data: any) {
143
  tagList.value.map((item: any) => {
144
    data.forEach((tag: any) => {
145
      if (tag.type === item.type) {
146
        tag.alias = '';
147
        item.tags.push(tag);
148
      }
149
    });
150
    return item;
151
  });
152
}
153
154
formateSourceData(customAttrs);
167 155
/**
168 156
 * el-tree拖拽start
169 157
 */
@ -212,10 +200,9 @@ function getCurrentNode(node: any) {
212 200
// 标签点击,添加至左边树
213 201
function handleClickTag(tag: any) {
214 202
  const newChild = <any>{
215
    label: tag.label,
216
    name: tag.label,
217
    id: tag.name,
218
    alias: '',
203
    id: tag.id,
204
    name: tag.name,
205
    alias: tag.alias,
219 206
    uuid: uuidv4(),
220 207
    type: tag.type,
221 208
    children: []
@ -231,11 +218,13 @@ function handleClickTag(tag: any) {
231 218
        currentNode.value.children.push(newChild);
232 219
        treeData.value = [...treeData.value];
233 220
      } else {
234
        proxy.$message.error(`${currentNode.value?.label}中已存在属性!`);
221
        proxy.$message.error(`${currentNode.value?.name}中已存在属性!`);
235 222
      }
236 223
    } else {
237 224
      proxy.$message.error(`${currentNode.value?.type}类型不能有子类!`);
238 225
    }
226
  } else if (treeData.value.find((item: any) => item.id === newChild.id)) {
227
    proxy.$message.error('根节点中中已存在该属性!');
239 228
  } else {
240 229
    treeData.value.push(newChild);
241 230
  }
@ -391,8 +380,18 @@ onMounted(() => {
391 380
      padding: 15px;
392 381
      box-sizing: border-box;
393 382
      overflow-y: auto;
383
      li {
384
        margin-bottom: 5px;
385
      }
394 386
      .tag-title {
395 387
        line-height: 32px;
388
        display: flex;
389
        align-items: center;
390
        .dian {
391
          width: 10px;
392
          height: 10px;
393
          margin-right: 10px;
394
        }
396 395
      }
397 396
      .tag-content {
398 397
        display: flex;
@ -408,6 +407,7 @@ onMounted(() => {
408 407
          border-radius: 4px;
409 408
          position: relative;
410 409
          padding-left: 26px;
410
          margin-bottom: 10px;
411 411
          cursor: pointer;
412 412
          &:after {
413 413
            content: '';
@ -492,6 +492,7 @@ onMounted(() => {
492 492
  color: #606266;
493 493
  font-weight: 400;
494 494
}
495
495 496
:deep(.el-tree-node) {
496 497
  line-height: 30px;
497 498
  padding: 3px 0;