From e8c0b3c2c024b0ed12fa371fc69019c0849083c9 Mon Sep 17 00:00:00 2001
From: shuishen <1109946754@qq.com>
Date: Mon, 28 Apr 2025 19:38:39 +0800
Subject: [PATCH] Merge branch 'test' of http://139.196.74.78:10010/r/drone/drone-web-manage into test
---
src/views/tickets/ticket.vue | 123 ++++++++++++++++++++++--------
src/views/system/dept.vue | 91 ++++++++++++++--------
2 files changed, 148 insertions(+), 66 deletions(-)
diff --git a/src/views/system/dept.vue b/src/views/system/dept.vue
index e2f6e33..589c603 100644
--- a/src/views/system/dept.vue
+++ b/src/views/system/dept.vue
@@ -482,31 +482,39 @@
this.selectionList = [];
this.$refs.crud.toggleSelection();
},
- beforeOpen(done, type) {
- if (['add', 'edit'].includes(type)) {
- this.initData();
- }
- if (['edit', 'view'].includes(type)) {
- getDept(this.form.id).then((res) => {
- const areaCode = res.data.data.areaCode;
- const areaName = res.data.data.areaName;
-
- // 生成完整的行政区划代码
- const fullAreaCode = this.getFullAreaCode(areaCode);
-
- this.form = Object.assign({}, res.data.data, {
- hasChildren: this.form.hasChildren,
- // 使用完整的行政区划代码
- areaCode: fullAreaCode,
- areaName: areaName || '',
- });
- });
- } else if (type === 'add') {
- this.form.areaCode = '';
- this.form.areaName = '';
- }
- done();
- },
+// 修改 beforeOpen 方法
+beforeOpen(done, type) {
+ if (['add', 'edit'].includes(type)) {
+ this.initData();
+ }
+ if (['edit', 'view'].includes(type)) {
+ getDept(this.form.id).then((res) => {
+ const data = res.data.data;
+ const areaCode = data.areaCode;
+ const areaName = data.areaName;
+
+ // 生成完整的行政区划代码(考虑不同级别)
+ const fullAreaCode = this.getFullAreaCode(areaCode);
+
+ this.form = Object.assign({}, data, {
+ hasChildren: this.form.hasChildren,
+ areaCode: fullAreaCode,
+ areaName: areaName || '',
+ });
+
+ // 调试输出
+ console.log('回显数据:', {
+ originalAreaCode: areaCode,
+ fullAreaCode: fullAreaCode,
+ areaName: areaName
+ });
+ });
+ } else if (type === 'add') {
+ this.form.areaCode = '';
+ this.form.areaName = '';
+ }
+ done();
+},
beforeClose(done) {
this.parentId = '';
const column = this.findObject(this.option.column, 'parentId');
@@ -559,14 +567,31 @@
resolve(res.data.data);
});
},
- // 新增:获取完整的行政区划代码
- getFullAreaCode(countyCode) {
- if (!countyCode) return '';
- // 县级代码是12位,省级代码取前2位,市级代码取前4位
- const provinceCode = countyCode.substring(0, 2) + '0000000000';
- const cityCode = countyCode.substring(0, 4) + '00000000';
- return `${provinceCode},${cityCode},${countyCode}`;
- },
+// 修改 getFullAreaCode 方法
+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}`;
+ }
+},
},
};
</script>
diff --git a/src/views/tickets/ticket.vue b/src/views/tickets/ticket.vue
index aa7ed55..f0d8e07 100644
--- a/src/views/tickets/ticket.vue
+++ b/src/views/tickets/ticket.vue
@@ -980,7 +980,7 @@
startTime: item.create_time,
aiType: item.ai_types,
content: item.content, // 将后端返回的 content 映射为 content
- type: this.types.find(t => t.value === item.event_dict_key)?.label,
+ type: this.types.find(t => t.value === item.work_order_type_dict_key)?.label,
keyData: (!isNaN(longitude) && !isNaN(latitude))
? `${longitude.toFixed(6)}, ${latitude.toFixed(6)}`
: '未知位置',
@@ -1032,7 +1032,7 @@
return;
}
- // 验证图片上传
+ // 修改图片验证逻辑
if (!this.form.photos || this.form.photos.length === 0) {
this.$message.warning('请上传工单图片');
return;
@@ -1045,7 +1045,7 @@
longitude: String(this.form.location[0]),
latitude: String(this.form.location[1]),
address: this.form.address,
- eventDictKey: this.form.type,
+ workOrderTypeDictKey: this.form.type,
aiType: Array.isArray(this.form.algorithm) ? this.form.algorithm : [this.form.algorithm], // 传数组
updateUser: this.form.handler,
createDept: this.form.department,
@@ -1056,9 +1056,17 @@
submitData.id = this.form.id;
}
- // 获取文件对象
- const file = this.form.photos[0].raw;
- if (!file) {
+ // 修改获取文件的逻辑
+ let file = null;
+ const photoInfo = this.form.photos[0];
+
+ if (photoInfo.raw) {
+ // 如果有新上传的文件,使用新文件
+ file = photoInfo.raw;
+ } else if (photoInfo.existingUrl) {
+ // 如果是已存在的图片,将URL添加到提交数据中
+ submitData.photoUrl = photoInfo.existingUrl;
+ } else {
this.$message.warning('图片文件无效,请重新上传');
return;
}
@@ -1099,8 +1107,10 @@
longitude: this.form.location?.[0] ? String(this.form.location[0]) : undefined,
latitude: this.form.location?.[1] ? String(this.form.location[1]) : undefined,
address: this.form.address || undefined,
- eventDictKey: this.form.type || undefined,
- aiType: Array.isArray(this.form.algorithm) ? this.form.algorithm : [this.form.algorithm], // 传数组
+ workOrderTypeDictKey: this.form.type || undefined,
+ aiType: this.form.algorithm && this.form.algorithm.length > 0
+ ? this.form.algorithm
+ : undefined, // 传数组
updateUser: handlerValue,
createDept: this.form.department || undefined,
isDraft: 1
@@ -1461,7 +1471,7 @@
发起时间: item.create_time || '',
关联算法: item.ai_types || '',
工单内容: item.address || '',
- 工单类型: this.types.find(t => t.value === item.event_dict_key)?.label || '',
+ 工单类型: this.types.find(t => t.value === item.work_order_type_dict_key)?.label || '',
经纬度: (!isNaN(longitude) && !isNaN(latitude)) ? `${longitude.toFixed(6)}, ${latitude.toFixed(6)}` : '',
创建人: item.create_user || '',
处理人: item.update_user || '',
@@ -1508,8 +1518,12 @@
// 文件改变时的钩子
handleFileChange(file, fileList) {
- this.form.photos = fileList;
- this.currentDetail.photos = fileList;
+ // 保持最新的文件列表
+ this.form.photos = fileList.map(item => ({
+ ...item,
+ existingUrl: item.url && !item.raw ? item.url : null // 标记已存在的图片URL
+ }));
+ this.currentDetail.photos = this.form.photos;
},
// 文件移除时的钩子
@@ -1803,7 +1817,7 @@
}
// 获取工单类型值 - 从types中找到匹配的值
- const typeValue = this.types.find(t => t.label === row.type)?.value || row.event_dict_key;
+ const typeValue = this.types.find(t => t.label === row.type)?.value || row.work_order_type_dict_key;
// 获取处理人ID - 使用userNameToIdMap映射
const handlerId = this.userNameToIdMap[row.handler] || row.handler;
@@ -1817,26 +1831,47 @@
映射后类型值: typeValue
});
+ // 修改算法数组的处理逻辑
let algorithmArr = [];
- if (Array.isArray(row.aiType)) {
- algorithmArr = row.aiType;
- } else if (typeof row.aiType === 'string' && row.aiType) {
- algorithmArr = row.aiType.split(',').map(i => i.trim());
- }
- this.form = {
- id: row.id,
- name: row.orderName,
- type: typeValue,
- department: deptId,
- handler: handlerId, // 使用映射后的处理人ID
- algorithm: algorithmArr, // 回显为数组
- location: Array.isArray(row.location) && row.location.length >= 2
- ? [Number(row.location[0]), Number(row.location[1])]
- : [],
- address: row.address || '',
- content: row.content,
- photos: [],
- };
+ if (Array.isArray(row.aiType)) {
+ algorithmArr = row.aiType;
+ } else if (typeof row.aiType === 'string' && row.aiType) {
+ // 首先尝试将字符串按照逗号或顿号分割
+ algorithmArr = row.aiType.split(/[,、]/).map(item => item.trim());
+ }
+
+ // 确保算法值与选项匹配
+ algorithmArr = algorithmArr.map(item => {
+ // 如果是字符串值,尝试找到对应的 dict_key
+ if (typeof item === 'string') {
+ const matchedAlgorithm = this.algorithms.find(
+ algo => algo.dict_value === item || algo.dict_key === item
+ );
+ return matchedAlgorithm ? matchedAlgorithm.dict_key : item;
+ }
+ return item;
+ }).filter(Boolean); // 过滤掉无效值
+
+ console.log('算法处理:', {
+ 原始值: row.aiType,
+ 分割后: algorithmArr,
+ });
+
+ this.form = {
+ id: row.id,
+ name: row.orderName,
+ type: typeValue,
+ department: deptId,
+ handler: handlerId,
+ algorithm: algorithmArr,
+ location: Array.isArray(row.location) && row.location.length >= 2
+ ? [Number(row.location[0]), Number(row.location[1])]
+ : [],
+ address: row.address || '',
+ content: row.content,
+ photos: [],
+ };
+
this.form.location = Array.isArray(row.location) && row.location.length >= 2
? [
Number(row.location[0]),
@@ -1853,14 +1888,36 @@
}
// 如果有图片,添加到表单中
if (row.photo_url) {
+ // 创建一个带有必要信息的文件对象
this.form.photos = [{
- name: 'existing-photo',
- url: row.photo_url
+ name: 'existing-photo.jpg', // 添加默认扩展名
+ url: row.photo_url, // 用于预览的URL
+ status: 'success', // 标记为已上传成功
+ raw: null, // 初始化为null
+ existingUrl: row.photo_url // 保存原始URL,用于区分是否为已存在的图片
}];
}
+ // 调试输出
+ console.log('编辑表单数据:', {
+ 原始算法值: row.aiType,
+ 处理后算法值: algorithmArr,
+ 表单数据: this.form
+ });
+
this.dialogVisible = true;
},
+
+ // 添加数据监听以确保算法数据的响应性
+ watch: {
+ 'form.algorithm': {
+ handler(newVal) {
+ console.log('算法值变化:', newVal);
+ },
+ deep: true
+ }
+ },
+
// 添加删除方法
handleDelete(row) {
this.$confirm('确认删除该工单?', '提示', {
--
Gitblit v1.9.3