From aee67ef5bf2e57a148bfded1cb986378e35e7e01 Mon Sep 17 00:00:00 2001 From: ludc Date: 星期四, 18 四月 2024 00:49:22 +0800 Subject: [PATCH] Merge remote-tracking branch 'origin/master' --- Source/UBCS-WEB/src/views/integration/integrationIndex.vue | 177 ++++++++++++++++++++++++++++++++++++++++++++++++++-------- 1 files changed, 152 insertions(+), 25 deletions(-) diff --git a/Source/UBCS-WEB/src/views/integration/integrationIndex.vue b/Source/UBCS-WEB/src/views/integration/integrationIndex.vue index 9e77493..083d865 100644 --- a/Source/UBCS-WEB/src/views/integration/integrationIndex.vue +++ b/Source/UBCS-WEB/src/views/integration/integrationIndex.vue @@ -50,20 +50,26 @@ @row-click="handleMapingClick" @row-dblclick="handleMapingRowClick" @selection-change="selectionChange" @select-all="handleSelectAll"> + <template slot="radio" + slot-scope="{row}"> + + <el-radio v-model="selectRow" :label="row.$index">-</el-radio> + </template> <template slot="menuLeft"> <!-- <el-button :disabled="disabledPush" icon="el-icon-plus" size="small" type="primary"--> <!-- @click="dialogPush = true">鏂� 澧�--> <!-- </el-button>--> - <el-button icon="el-icon-check" size="small" type="primary" @click="handleSave">淇� 瀛� + <el-button v-if="permissionList.saveBtn" icon="el-icon-check" size="small" type="primary" + @click="handleSave">淇� 瀛� </el-button> - <el-button icon="el-icon-connection" size="small" type="primary" - @click="handleSync('all')">鍚屾涓绘ā鍨� + <el-button v-if="permissionList.allSyncBtn" icon="el-icon-connection" size="small" + type="primary" @click="handleSync('all')">鍚屾涓绘ā鍨� </el-button> - <el-button icon="el-icon-connection" size="small" type="primary" - @click="handleSync('one')">鍚屾璇︾粏妯″瀷 + <el-button v-if="permissionList.oneSyncBtn" icon="el-icon-connection" size="small" + type="primary" @click="handleSync('one')">鍚屾璇︾粏妯″瀷 </el-button> - <el-button icon="el-icon-coordinate" size="small" type="primary" - @click="handlerAuto">鑷姩濉厖 + <el-button v-if="permissionList.autoBtn" icon="el-icon-coordinate" size="small" + type="primary" @click="handlerAuto">鑷姩濉厖 </el-button> </template> </avue-crud> @@ -73,8 +79,8 @@ @row-update="handleUpdate" @row-dblclick="handleRowClick"> <template slot="menuLeft"> - <el-button icon="el-icon-coordinate" size="small" type="primary" - @click="handlerAuto">鑷姩濉厖 + <el-button v-if="permissionList.bottomAutoBtn" icon="el-icon-coordinate" size="small" + type="primary" @click="handlerBottomAuto">鑷姩濉厖 </el-button> </template> </avue-crud> @@ -89,6 +95,7 @@ <script> import integrationTransfer from './integrationTransfer.vue' import pinyin from 'js-pinyin' +import {mapGetters} from "vuex"; import { referCodeClassifyTree, referTree, @@ -98,7 +105,7 @@ listCodeAttributeByClassId, syncClassifyModel } from '@/api/integration/integration.js' -import {getPage} from "@/api/omd/OmdAttribute"; +import {getByGroupAttrMapping, getEnumAttrByClsOidAndAttrId} from "@/api/vciAttrbute"; export default { components: { @@ -122,6 +129,7 @@ highlightCurrentRow: true, } return { + selectRow: "", targetNameList: [], // 鍏冩暟鎹繑鍥炲悕绉� defaultCheckedKeys: [], isNodeDisabled: true, @@ -179,7 +187,6 @@ refreshBtn: false, delBtn: false, addBtn: false, - index: true, columnBtn: false, searchShow: true, emptyBtn: false, @@ -191,6 +198,7 @@ highlightCurrentRow: true, $cellEdit: true, column: [ + {label: '', prop: 'radio', width: 60, hide: false}, {label: '闆嗗洟鍒嗙被', prop: 'sourceClassifyName', minWidth: 80}, {label: '鎵�灞炶鍥�', prop: 'viewName', minWidth: 80}, {label: '闆嗗洟灞炴��', prop: 'sourceAttrName', minWidth: 80}, @@ -245,7 +253,8 @@ mappingForm: {}, // 瀹氭椂鍣� times: null, - TreeSelectOid: "" + TreeOid: "", + tableSelectId: '' } }, @@ -274,9 +283,115 @@ }, targetColumn() { return this.optionMapping.column.find(column => column.prop === 'targetAttrName'); - } + }, + ...mapGetters(["permission"]), + permissionList() { + return { + allSyncBtn: this.vaildData(this.permission.integration.integration_allSync, false), + autoBtn: this.vaildData(this.permission.integration.integration_auto, false), + bottomAutoBtn: this.vaildData(this.permission.integration.integration_bottomAuto, false), + oneSyncBtn: this.vaildData(this.permission.integration.integration_oneSync, false), + saveBtn: this.vaildData(this.permission.integration.integration_save, false), + } + }, }, methods: { + handlerAuto() { + if (!this.TreeOid || this.TreeOid === "") { + return; + } + // 杩囨护鍑洪泦鍥㈠睘鎬х殑key鍊� + const groupArray = this.mappingData ? this.mappingData.map(obj => obj.sourceAttrKey) : []; + // 鑾峰彇鍒伴渶瑕佽嚜鍔ㄥ~鍏呯殑鍊� + getByGroupAttrMapping({classifyId: this.TreeOid, groupAttrKeyList: groupArray}) + .then(res => { + // 鍗曠嫭鎶婅繑鍥炲�肩殑groupAttrKey鏀句竴涓暟缁勶紝鐒跺悗杩囨护鍑鸿繑鍥炲�肩殑groupAttrKey鏄惁绛変簬琛ㄦ牸鏁版嵁涓殑sourceAttrKey + // const groupReturnData = res.data && res.data.data ? res.data.data.map(item => item.groupAttrKey) : []; + const groupReturnData = res.data.data; + // 杩囨护鍖归厤 + // console.log(groupReturnData) + this.mappingData.forEach(mappingItem => { + groupReturnData.forEach(groupItem => { + if (mappingItem.sourceAttrKey === groupItem.groupAttrKey) { + const result = this.transferData.find(obj => obj.id.toLowerCase() === groupItem.codeMetaAttrKey.toLowerCase()); + if (result) { + mappingItem.targetAttrId = groupItem.codeMetaAttrOid.toLowerCase(); + mappingItem.targetAttrName = groupItem.codeMetaAttrName.toLowerCase(); + mappingItem.targetAttrKey = groupItem.codeMetaAttrKey.toLowerCase(); + } else { + mappingItem.targetAttrId = ''; + mappingItem.targetAttrName = ''; + mappingItem.targetAttrKey = ''; + } + } + }) + }) + this.$message.success('鑷姩濉厖鎴愬姛锛岃纭灞炴�у悗鐐瑰嚮淇濆瓨锛�'); + }) + .catch(error => { + console.log(error) + this.$message.error('濉厖澶辫触锛岃绋嶅悗鍐嶈瘯锛�'); + }); + }, + handlerBottomAuto() { + if (this.rangeData.length <= 0) { + this.$message.warning('璇烽�夋嫨涓�鏉℃灇涓剧被鍨嬪睘鎬�!') + return + } + getEnumAttrByClsOidAndAttrId({classifyId: this.TreeOid, codeMetaAttrKey: this.tableSelectId}).then(res => { + const data = res.data.data; + this.rangeData.forEach(rangeItem => { + data.forEach(dataItem => { + const similarity = this.calculateSimilarity(rangeItem.numText, dataItem.itemName); + if (similarity > 70) { + rangeItem.targetNumTextValue = rangeItem.numTextValue; + rangeItem.targetNumText = dataItem.itemName; + } + }) + }) + this.$message.success('鑷姩濉厖鎴愬姛锛岃纭灞炴�у悗鐐瑰嚮淇濆瓨锛�') + }) + }, + calculateSimilarity(str1, str2) { + // 璁$畻缂栬緫璺濈 + function editDistance(s1, s2) { + s1 = s1.toLowerCase(); + s2 = s2.toLowerCase(); + + const costs = []; + for (let i = 0; i <= s1.length; i++) { + let lastValue = i; + for (let j = 0; j <= s2.length; j++) { + if (i === 0) + costs[j] = j; + else { + if (j > 0) { + let newValue = costs[j - 1]; + if (s1.charAt(i - 1) !== s2.charAt(j - 1)) + newValue = Math.min(Math.min(newValue, lastValue), + costs[j]) + 1; + costs[j - 1] = lastValue; + lastValue = newValue; + } + } + } + if (i > 0) + costs[s2.length] = lastValue; + } + return costs[s2.length]; + } + + // 璁$畻鐩镐技搴︾櫨鍒嗘瘮 + function similarityPercent(s1, s2) { + let maxLength = Math.max(s1.length, s2.length); + let distance = editDistance(s1, s2); + return ((maxLength - distance) / maxLength) * 100; + } + + // 璋冪敤鐩镐技搴﹁绠楀嚱鏁板苟杩斿洖鐧惧垎姣斿舰寮忕殑鐩镐技搴� + const similarity = similarityPercent(str1, str2); + return similarity; + }, getTargetName(data) { this.targetColumn.dicData = data.filter(item => item.name && item.name.trim() !== "") // 杩囨护鎺塶ame涓虹┖鐨勫睘鎬� .map(item => { @@ -284,7 +399,7 @@ targetAttrId: item.oid, targetAttrKey: item.id, targetAttrName: item.name, - disabled: false + // disabled: false } }); }, @@ -312,12 +427,12 @@ this.loading = false this.mappingData = response.data.data - for (const item of this.mappingData) { - if (item.targetAttrName && item.targetAttrId && item.targetAttrKey) { - const targetObject = this.targetColumn.dicData.find(obj => obj.targetAttrName === item.targetAttrName); - targetObject.disabled = true; - } - } + // for (const item of this.mappingData) { + // if (item.targetAttrName && item.targetAttrId && item.targetAttrKey) { + // const targetObject = this.targetColumn.dicData.find(obj => obj.targetAttrName === item.targetAttrName); + // targetObject.disabled = true; + // } + // } } }, // 鎺ュ彛鑾峰彇灞炴�ф槧灏勫彇鍊艰寖鍥� @@ -429,11 +544,12 @@ } for (const item of this.mappingData) { item.$cellEdit = false; - if (item.targetAttrName) { + if (item.targetAttrName && !item.targetAttrId && !item.targetAttrKey) { const {targetAttrId, targetAttrKey, targetAttrName} = await getTargetCorresponding(item); Object.assign(item, {targetAttrId, targetAttrKey, targetAttrName}); } } + this.mappingData[this.selectRow].dockingPreAttrRangeVoList = (this.rangeData) const response = await batchAddSave({dockingPreAttrMappingVOList: this.mappingData}) if (response.status === 200) { this.$message({ @@ -484,6 +600,7 @@ }, // 宸︿晶鏍戠偣鍑� handelTreeCell(event) { + this.TreeOid = event.oid; this.treeParam.codeClassifyId = event.oid this.form.groupValue = '' this.groupVal = '' @@ -517,6 +634,9 @@ }, // 闆嗗洟鏄犲皠灞炴�ц閫夋嫨锛堝崟鍑伙級 handleMapingClick(row) { + // console.log(row) + this.tableSelectId = row.targetAttrKey || ""; + this.selectRow = row.$index; clearTimeout(this.times) this.mappingForm = row this.times = setTimeout(() => { @@ -556,10 +676,15 @@ // 鑾峰彇鐩爣灞炴�т俊鎭� const {targetAttrId, targetAttrKey, targetAttrName} = await getTargetCorresponding(row); - // 鏇存柊琛屾暟鎹� - Object.assign(row, {targetAttrId, targetAttrKey, targetAttrName}); - const response = await batchAddSave({dockingPreAttrMappingVOList: this.mappingData}); + // 鏇存柊琛屾暟鎹� + Object.assign(row, { + targetAttrId: targetAttrId.toLowerCase(), + targetAttrKey: targetAttrKey.toLowerCase(), + targetAttrName: targetAttrName.toLowerCase() + }); + + const response = await batchAddSave({dockingPreAttrMappingVOList: [row]}); if (response.status === 200) { this.$message({ @@ -585,12 +710,14 @@ } }, setCurrentRow(selection, row) { + console.log(selection, row) this.mappingForm = row this.disabledPush = false }, handleSelectAll(selection) { this.$refs.crudMapping.toggleSelection() - } + }, + } } </script> -- Gitblit v1.9.3