From 92610ba4eedbc06062240c2f2967b7e1f691797e Mon Sep 17 00:00:00 2001 From: riku <risaku@163.com> Date: 星期二, 02 九月 2025 12:24:55 +0800 Subject: [PATCH] 补全设备匹配功能 --- src/views/fysp/config/device/CompDeviceMatchEdit.vue | 163 ++++++++++++++++++++++++++++++++++++++++++++++++++--- 1 files changed, 152 insertions(+), 11 deletions(-) diff --git a/src/views/fysp/config/device/CompDeviceMatchEdit.vue b/src/views/fysp/config/device/CompDeviceMatchEdit.vue index ee429b8..a981b43 100644 --- a/src/views/fysp/config/device/CompDeviceMatchEdit.vue +++ b/src/views/fysp/config/device/CompDeviceMatchEdit.vue @@ -1,4 +1,9 @@ <template> + <el-row justify="end"> + <el-button icon="check" type="success" @click="save" :loading="saveLoading" + >淇濆瓨</el-button + > + </el-row> <el-row :gutter="20"> <el-col :span="8"> <CompInfoSearch @@ -11,12 +16,20 @@ <div> <el-text>缂栧彿锛歿{ row.deviceCode }}</el-text> </div> - <div> + <el-space> <el-text>鍚嶇О锛歿{ row.deviceName }}</el-text> - </div> + <el-button + v-show="row.deviceName" + type="primary" + icon="DocumentCopy" + text + circle + @click="copyDeviceName(row.deviceName)" + /> + </el-space> </template> <template #default="{ row, click }"> - <el-text>deviceInfo</el-text> + <ItemDevice :item="row" @add="selectDevice(row, click)" /> </template> </CompInfoSearch> </el-col> @@ -31,9 +44,17 @@ <div> <el-text>缂栧彿锛歿{ row.svUserId }}</el-text> </div> - <div> + <el-space> <el-text>鍚嶇О锛歿{ row.svUserName }}</el-text> - </div> + <el-button + v-show="row.svUserName" + type="primary" + icon="DocumentCopy" + text + circle + @click="copySVUser(row.svUserName)" + /> + </el-space> </template> <template #default="{ row, click }"> <ItemUser :item="row" @add="selectSVUser(row, click)" /> @@ -51,9 +72,17 @@ <div> <el-text>缂栧彿锛歿{ row.tzUserId }}</el-text> </div> - <div> + <el-space> <el-text>鍚嶇О锛歿{ row.tzUserName }}</el-text> - </div> + <el-button + v-show="row.tzUserName" + type="primary" + icon="DocumentCopy" + text + circle + @click="copyTZUser(row.tzUserName)" + /> + </el-space> </template> <template #default="{ row, click }"> <ItemUser :item="row" @add="selectTZUser(row, click)" /> @@ -68,7 +97,9 @@ import CompInfoSearch from './CompInfoSearch.vue'; import tzUserApi from '@/api/fytz/userApi'; import svUserApi from '@/api/fysp/userApi'; +import userMapApi from '@/api/fysp/userMapApi'; import { svToTz } from '@/enum/scene'; +import { saveAs } from 'file-saver'; export default { components: { CompInfoSearch }, @@ -78,6 +109,7 @@ // 妫�绱㈣寖鍥达紙鍖呭惈琛屾斂鍖哄垝銆佸満鏅被鍨嬶級 area: Object }, + emits: ['save'], data() { return { // 鐩戞祴璁惧 @@ -85,7 +117,9 @@ // 鐩戠鐢ㄦ埛 svUser: {}, // 鐜鐢ㄦ埛 - tzUser: {} + tzUser: {}, + // 淇濆瓨loading + saveLoading: false }; }, watch: { @@ -111,7 +145,27 @@ }, methods: { // 鏌ヨ鐩戞祴璁惧 - searchDevice() {}, + searchDevice(param, callback) { + const { text, page, pageSize } = param; + const { cloned: area } = useCloned(this.area); + return userMapApi + .searchThirdPartyDevice(area.value, text, page, pageSize) + .then((res) => { + if (res.success) { + const l = res.data.map((value) => { + return { + deviceCode: value.mnCode, + deviceName: value.name, + district: area.value.districtname + }; + }); + callback({ + data: l, + total: res.head.totalCount + }); + } + }); + }, // 鏌ヨ鐩戠鐢ㄦ埛 searchSVUser(param, callback) { const { text, page, pageSize } = param; @@ -153,7 +207,7 @@ area.townCode = this.area.towncode; area.townName = this.area.townname; // 鍦烘櫙绫诲瀷 - const tzSceneType = svToTz(this.area.scensetypeid) + const tzSceneType = svToTz(this.area.scensetypeid); area.sceneTypes = [tzSceneType.value]; // 涓婁笅绾跨姸鎬� area.online = this.area.online; @@ -182,7 +236,13 @@ callback(); }); }, - selectDevice() {}, + selectDevice(row, click) { + const p = { + deviceCode: row.deviceCode, + deviceName: row.deviceName + }; + click(p); + }, selectSVUser(row, click) { const p = { svUserId: row.guid, @@ -196,6 +256,87 @@ tzUserName: row.realname }; click(p); + }, + // 澶嶅埗鐩戠鐢ㄦ埛 + copySVUser(svUserName) { + // 浣跨敤Clipboard API灏嗙敤鎴峰悕绉板鍒跺埌鍓创鏉� + navigator.clipboard + .writeText(svUserName) + .then(() => { + this.$message({ + message: '鐩戠鐢ㄦ埛鍚嶇О宸插鍒跺埌鍓创鏉�', + type: 'success' + }); + }) + .catch((err) => { + this.$message({ + message: '澶嶅埗澶辫触锛岃鎵嬪姩澶嶅埗', + type: 'error' + }); + console.error('澶嶅埗澶辫触:', err); + }); + }, + // 澶嶅埗鐜鐢ㄦ埛 + copyTZUser(tzUserName) { + // 浣跨敤Clipboard API灏嗙敤鎴峰悕绉板鍒跺埌鍓创鏉� + navigator.clipboard + .writeText(tzUserName) + .then(() => { + this.$message({ + message: '鐜鐢ㄦ埛鍚嶇О宸插鍒跺埌鍓创鏉�', + type: 'success' + }); + }) + .catch((err) => { + this.$message({ + message: '澶嶅埗澶辫触锛岃鎵嬪姩澶嶅埗', + type: 'error' + }); + console.error('澶嶅埗澶辫触:', err); + }); + }, + // 澶嶅埗鐩戞祴璁惧鍚嶇О + copyDeviceName(deviceName) { + // 浣跨敤Clipboard API灏嗙敤鎴峰悕绉板鍒跺埌鍓创鏉� + navigator.clipboard + .writeText(deviceName) + .then(() => { + this.$message({ + message: '鐩戞祴璁惧鍚嶇О宸插鍒跺埌鍓创鏉�', + type: 'success' + }); + }) + .catch((err) => { + this.$message({ + message: '澶嶅埗澶辫触锛岃鎵嬪姩澶嶅埗', + type: 'error' + }); + console.error('澶嶅埗澶辫触:', err); + }); + }, + // 淇濆瓨 + save() { + const deviceMap = { + id: this.data.id, + ...this.device, + ...this.svUser, + ...this.tzUser + }; + this.saveLoading = true; + userMapApi + .insertOrUpdate(this.area, deviceMap) + .then((res) => { + if (res.success) { + this.$message({ + message: '淇濆瓨鎴愬姛', + type: 'success' + }); + this.$emit('save', deviceMap); + } + }) + .finally(() => { + this.saveLoading = false; + }); } } }; -- Gitblit v1.9.3