浏览代码

fixed: 修改数据格式

liuyang 2 年之前
父节点
当前提交
931c0ebcbd

+ 0 - 52
src/api/common.ts

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

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

121
    ></custom-detail-list>
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
  </dialog-panel>
128
  </dialog-panel>
126
</template>
129
</template>
127
130
369
}
372
}
370
373
371
const { importModel } = setModelInfo();
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
/** 模型声明 end */
387
/** 模型声明 end */
373
388
374
function confirmDialog() {
389
function confirmDialog() {
381
    case 'viewCustomDetail':
396
    case 'viewCustomDetail':
382
      closeDialog();
397
      closeDialog();
383
      break;
398
      break;
399
    case 'fileImport':
400
      batchCreateCustom();
401
      break;
384
    default:
402
    default:
385
      break;
403
      break;
386
  }
404
  }
392
}
410
}
393
411
394
const customDetail = ref(null);
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
function customAttrFn() {
419
function customAttrFn() {
397
  // if (attrInfo.value.type === 'add') {
420
  // if (attrInfo.value.type === 'add') {
407
  //     }
430
  //     }
408
  //     return item;
431
  //     return item;
409
  //   });
432
  //   });
433
410
  const data = customDetail.value.attrList;
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
  closeDialog();
445
  closeDialog();
414
}
446
}

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

21
        <el-button type="success">文件导入</el-button>
21
        <el-button type="success">文件导入</el-button>
22
      </el-upload>
22
      </el-upload>
23
    </div>
23
    </div>
24
    <common-table
25
      class="global-table"
26
      :table-header="tableHeader"
27
      :table-data="tableData"
28
    ></common-table>
24
  </div>
29
  </div>
25
</template>
30
</template>
26
31
33
  window.open(downloadTemplaye());
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
// excel表数据处理
47
// excel表数据处理
37
const tableData = ref([]);
48
const tableData = ref([]);
38
function useExcelHooks(e: any) {
49
function useExcelHooks(e: any) {

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

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

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

29
            <template #default="{ node, data }">
29
            <template #default="{ node, data }">
30
              <div class="tree-item">
30
              <div class="tree-item">
31
                <span class="label">{{ data.name }}</span>
31
                <span class="label">{{ data.name }}</span>
32
33
                <span class="type">
32
                <span class="type">
34
                  {{ data.id }}
33
                  {{ data.id }}
35
                </span>
34
                </span>
69
      <h5 class="title">属性</h5>
68
      <h5 class="title">属性</h5>
70
      <ul class="tag-list">
69
      <ul class="tag-list">
71
        <li v-for="(item, index) in tagList" :key="index">
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
          <div class="tag-content">
75
          <div class="tag-content">
74
            <template v-for="(tag, tagIndex) in item.tags" :key="tagIndex">
76
            <template v-for="(tag, tagIndex) in item.tags" :key="tagIndex">
75
              <span
77
              <span
77
                :class="`${tag?.['type']}-color`"
79
                :class="`${tag?.['type']}-color`"
78
                @click.stop="handleClickTag(tag)"
80
                @click.stop="handleClickTag(tag)"
79
              >
81
              >
80
                {{ tag.label }}
82
                {{ tag.name }}
81
              </span>
83
              </span>
82
            </template>
84
            </template>
85
            <!-- <el-button size="small" @click.stop="">快速创建</el-button> -->
83
          </div>
86
          </div>
84
        </li>
87
        </li>
85
      </ul>
88
      </ul>
98
} from 'vue';
101
} from 'vue';
99
import JsonEditor from 'json-editor-vue3';
102
import JsonEditor from 'json-editor-vue3';
100
import { v4 as uuidv4 } from 'uuid';
103
import { v4 as uuidv4 } from 'uuid';
104
import { useRoute } from 'vue-router';
101
105
102
const { proxy } = getCurrentInstance();
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
const props = defineProps({
117
const props = defineProps({
104
  dataSource: {
118
  dataSource: {
105
    type: Array,
119
    type: Array,
106
    default: () => []
120
    default: () => []
107
  }
121
  }
108
});
122
});
123
// 源数据
109
const tagList = ref<any>([
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
const treeData = ref<any>([...props.dataSource] || []);
135
const treeData = ref<any>([...props.dataSource] || []);
162
const jsonData = ref<any>({});
136
const jsonData = ref<any>({});
164
const currentNode = ref<any>({});
138
const currentNode = ref<any>({});
165
const myTree = ref<any>(null);
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
 * el-tree拖拽start
156
 * el-tree拖拽start
169
 */
157
 */
212
// 标签点击,添加至左边树
200
// 标签点击,添加至左边树
213
function handleClickTag(tag: any) {
201
function handleClickTag(tag: any) {
214
  const newChild = <any>{
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
    uuid: uuidv4(),
206
    uuid: uuidv4(),
220
    type: tag.type,
207
    type: tag.type,
221
    children: []
208
    children: []
231
        currentNode.value.children.push(newChild);
218
        currentNode.value.children.push(newChild);
232
        treeData.value = [...treeData.value];
219
        treeData.value = [...treeData.value];
233
      } else {
220
      } else {
234
        proxy.$message.error(`${currentNode.value?.label}中已存在属性!`);
221
        proxy.$message.error(`${currentNode.value?.name}中已存在属性!`);
235
      }
222
      }
236
    } else {
223
    } else {
237
      proxy.$message.error(`${currentNode.value?.type}类型不能有子类!`);
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
  } else {
228
  } else {
240
    treeData.value.push(newChild);
229
    treeData.value.push(newChild);
241
  }
230
  }
391
      padding: 15px;
380
      padding: 15px;
392
      box-sizing: border-box;
381
      box-sizing: border-box;
393
      overflow-y: auto;
382
      overflow-y: auto;
383
      li {
384
        margin-bottom: 5px;
385
      }
394
      .tag-title {
386
      .tag-title {
395
        line-height: 32px;
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
      .tag-content {
396
      .tag-content {
398
        display: flex;
397
        display: flex;
408
          border-radius: 4px;
407
          border-radius: 4px;
409
          position: relative;
408
          position: relative;
410
          padding-left: 26px;
409
          padding-left: 26px;
410
          margin-bottom: 10px;
411
          cursor: pointer;
411
          cursor: pointer;
412
          &:after {
412
          &:after {
413
            content: '';
413
            content: '';
492
  color: #606266;
492
  color: #606266;
493
  font-weight: 400;
493
  font-weight: 400;
494
}
494
}
495
495
:deep(.el-tree-node) {
496
:deep(.el-tree-node) {
496
  line-height: 30px;
497
  line-height: 30px;
497
  padding: 3px 0;
498
  padding: 3px 0;