| | |
| | | latitude: this.form.location?.[1] ? String(this.form.location[1]) : undefined, |
| | | address: this.form.address || undefined, |
| | | workOrderTypeDictKey: this.form.type || undefined, |
| | | aiType: Array.isArray(this.form.algorithm) ? this.form.algorithm : [this.form.algorithm], // 传数组 |
| | | aiType: this.form.algorithm && this.form.algorithm.length > 0 |
| | | ? this.form.algorithm |
| | | : undefined, // 传数组 |
| | | updateUser: handlerValue, |
| | | createDept: this.form.department || undefined, |
| | | isDraft: 1 |
| | |
| | | 映射后类型值: 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]), |
| | |
| | | }]; |
| | | } |
| | | |
| | | // 调试输出 |
| | | console.log('编辑表单数据:', { |
| | | 原始算法值: row.aiType, |
| | | 处理后算法值: algorithmArr, |
| | | 表单数据: this.form |
| | | }); |
| | | |
| | | this.dialogVisible = true; |
| | | }, |
| | | |
| | | // 添加数据监听以确保算法数据的响应性 |
| | | watch: { |
| | | 'form.algorithm': { |
| | | handler(newVal) { |
| | | console.log('算法值变化:', newVal); |
| | | }, |
| | | deep: true |
| | | } |
| | | }, |
| | | |
| | | // 添加删除方法 |
| | | handleDelete(row) { |
| | | this.$confirm('确认删除该工单?', '提示', { |