From c832bf2e80ac465e71b7a1c1f7a59d4252030989 Mon Sep 17 00:00:00 2001
From: 张含笑 <zhx18749296735@163.com>
Date: Tue, 05 Aug 2025 17:33:08 +0800
Subject: [PATCH] feat:事件工单滚动条
---
src/views/device/addDevice.vue | 147 ++++++++++++++++++++++++++++++++++++------------
1 files changed, 110 insertions(+), 37 deletions(-)
diff --git a/src/views/device/addDevice.vue b/src/views/device/addDevice.vue
index 88a8a89..b4d7684 100644
--- a/src/views/device/addDevice.vue
+++ b/src/views/device/addDevice.vue
@@ -194,6 +194,64 @@
format: 'YYYY-MM-DD HH:mm:ss',
},
+ {
+ label: '行政区划',
+ prop: 'area_code',
+ type: 'cascader',
+ labelWidth: 130,
+ hide: true,
+ editDisplay: true,
+ viewDisplay: false,
+ props: {
+ label: 'title',
+ value: 'value',
+ emitPath: false,
+ checkStrictly: true,
+ multiple: false,
+ expandTrigger: 'hover',
+ },
+ dataType: 'string',
+ rules: [
+ {
+ required: true,
+ message: '请选择行政区划',
+ trigger: 'change',
+ },
+ ],
+ lazy: true,
+ lazyLoad (node, resolve) {
+ let level = node.level
+ let list = []
+ let callback = () => {
+ resolve(
+ (list || []).map(ele => ({
+ ...ele,
+ value: ele.value,
+ leaf: level >= 2,
+ }))
+ )
+ }
+
+ if (level === 0) {
+ getLazyTree('000000000000').then(res => {
+ list = res.data.data
+ callback()
+ })
+ } else if (level === 1) {
+ getLazyTree(node.value).then(res => {
+ list = res.data.data
+ callback()
+ })
+ } else if (level === 2) {
+ getLazyTree(node.value).then(res => {
+ list = res.data.data
+ callback()
+ })
+ } else {
+ callback()
+ }
+ },
+ },
],
},
@@ -231,41 +289,22 @@
methods: {
copyInfo (row, index) {
- if (import.meta.env.VITE_APP_ENV === 'development') {
- // alert('地址'+import.meta.env.VITE_APP_ENV);
- let params = `
- host: tcp://139.196.74.78:1883
- 账号:drone
- 密码:123456
- 组织id:${row.bing_id}
- 设备码:${row.bind_code}
- 机场名称:${row.workspace_name}
- aircrattName:${row.workspace_desc}`
- $Clipboard({
- text: params,
- }).then(() => {
- this.$message.success("复制成功")
- }).catch(() => {
- this.$message.error("复制失败")
- })
- } else {
- // alert('地址'+import.meta.env.VITE_APP_ENV);
- let params = `
- host: tcp://101.132.85.201:1883
- 账号:drone
+ const ipAddress = import.meta.env.VITE_APP_DEVICE_IP
+ let params = `
+ host: tcp://${ipAddress}
+ 账号:drone
密码:drone@123
- 组织id:${row.bing_id}
- 设备码:${row.bind_code}
- 机场名称:${row.workspace_name}
+ 组织id:${row.bing_id}
+ 设备码:${row.bind_code}
+ 机场名称:${row.workspace_name}
aircrattName:${row.workspace_desc}`
- $Clipboard({
- text: params,
- }).then(() => {
- this.$message.success("复制成功")
- }).catch(() => {
- this.$message.error("复制失败")
- })
- }
+ $Clipboard({
+ text: params,
+ }).then(() => {
+ this.$message.success("复制成功")
+ }).catch(() => {
+ this.$message.error("复制失败")
+ })
},
init () {
this.onLoad(this.page)
@@ -277,6 +316,14 @@
},
rowSave (row, done, loading) {
+ let areaCode = row.area_code
+ if (Array.isArray(areaCode)) {
+ areaCode = areaCode[areaCode.length - 1]
+ } else if (typeof areaCode === 'string' && areaCode.includes(',')) {
+ const codes = areaCode.split(',')
+ areaCode = codes[codes.length - 1]
+ }
+ row.area_code = areaCode || null
add(row).then(
() => {
this.onLoad(this.page)
@@ -293,7 +340,11 @@
)
},
rowUpdate (row, index, done, loading) {
- update(row).then(
+ const submitData = {
+ ...row,
+ area_code: row.area_code.split(',').pop(),
+ }
+ update(submitData).then(
() => {
this.onLoad(this.page)
this.$message({
@@ -364,10 +415,32 @@
this.$refs.crud.toggleSelection()
})
},
+ async getFullAreaCode (areaCode) {
+ if (!areaCode) return ''
+
+ const code = areaCode.toString()
+
+ if (code.includes(',')) return code
+
+ if (code.endsWith('0000000000')) {
+ return code
+ } else if (code.endsWith('00000000') && !code.endsWith('0000000000')) {
+ const provinceCode = code.substring(0, 2) + '0000000000'
+ return `${provinceCode},${code}`
+ } else {
+ const provinceCode = code.substring(0, 2) + '0000000000'
+ const cityCode = code.substring(0, 4) + '00000000'
+ return `${provinceCode},${cityCode},${code}`
+ }
+ },
beforeOpen (done, type) {
if (['edit', 'view'].includes(type)) {
- getDetail(this.form.id).then(res => {
- this.form = res.data.data
+ getDetail(this.form.id).then(async res => {
+ const data = res.data.data
+ this.form = {
+ ...data,
+ area_code: await this.getFullAreaCode(data.area_code),
+ }
})
}
done()
@@ -443,4 +516,4 @@
border-color: #409eff;
}
}
-</style>
\ No newline at end of file
+</style>
--
Gitblit v1.9.3