提交代码
This commit is contained in:
		
							parent
							
								
									35a8146d97
								
							
						
					
					
						commit
						bd2ad482b7
					
				| 
						 | 
				
			
			@ -7,3 +7,10 @@ export const getConfig = () => {
 | 
			
		|||
    method: 'get'
 | 
			
		||||
  })
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
export const getMinIoUrl = () => {
 | 
			
		||||
  return request({
 | 
			
		||||
    url: '/ai/getConfig',
 | 
			
		||||
    method: 'get'
 | 
			
		||||
  })
 | 
			
		||||
}
 | 
			
		||||
| 
						 | 
				
			
			
 | 
			
		|||
| 
						 | 
				
			
			@ -42,6 +42,7 @@ import { mapState } from 'vuex'
 | 
			
		|||
import variables from '@/assets/styles/variables.scss'
 | 
			
		||||
import { validateNewPassword } from '@/utils/validate'
 | 
			
		||||
import { updateUserPwd, checkPasswordStatus } from '@/api/system/user'
 | 
			
		||||
import {getMinioUrl } from '@/utils/config'
 | 
			
		||||
import { handleNoWarningLog } from '@/api/system/log'
 | 
			
		||||
import {MessageBox} from "element-ui";
 | 
			
		||||
 | 
			
		||||
| 
						 | 
				
			
			@ -116,6 +117,7 @@ export default {
 | 
			
		|||
    }
 | 
			
		||||
  },
 | 
			
		||||
  created() {
 | 
			
		||||
    getMinioUrl();
 | 
			
		||||
    this.checkPasswordStatus()
 | 
			
		||||
    if (this.roles.includes("audit") || this.roles.includes("systemAdmin")) {
 | 
			
		||||
      this.connectWebSocket();
 | 
			
		||||
| 
						 | 
				
			
			
 | 
			
		|||
| 
						 | 
				
			
			@ -1,11 +1,21 @@
 | 
			
		|||
import { getConfig } from '@/api/config';
 | 
			
		||||
import { getConfig,getMinIoUrl } from '@/api/config'
 | 
			
		||||
 | 
			
		||||
export function get() {
 | 
			
		||||
  getConfig()
 | 
			
		||||
    .then(response => {
 | 
			
		||||
      console.log(response)
 | 
			
		||||
      localStorage.setItem('systemConfig', JSON.stringify(response.data));
 | 
			
		||||
      localStorage.setItem('systemConfig', JSON.stringify(response.data))
 | 
			
		||||
    })
 | 
			
		||||
    .catch(error => {
 | 
			
		||||
      console.error('Failed to fetch config:', error);
 | 
			
		||||
    });
 | 
			
		||||
      console.error('Failed to fetch config:', error)
 | 
			
		||||
    })
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
export function getMinioUrl() {
 | 
			
		||||
  getMinIoUrl()
 | 
			
		||||
    .then(response => {
 | 
			
		||||
      localStorage.setItem('minIoUrl', JSON.stringify(response.data))
 | 
			
		||||
    })
 | 
			
		||||
    .catch(error => {
 | 
			
		||||
      console.error('Failed to fetch config:', error)
 | 
			
		||||
    })
 | 
			
		||||
}
 | 
			
		||||
| 
						 | 
				
			
			
 | 
			
		|||
| 
						 | 
				
			
			@ -28,12 +28,13 @@ export default {
 | 
			
		|||
        return this.itemIndex;
 | 
			
		||||
      },
 | 
			
		||||
      set(value) {
 | 
			
		||||
        this.$parent.updateItemIndex(value); // 更新父组件的索引
 | 
			
		||||
        this.$parent.updateItemIndex(value,this.label); // 更新父组件的索引
 | 
			
		||||
      }
 | 
			
		||||
    }
 | 
			
		||||
  },
 | 
			
		||||
  data() {
 | 
			
		||||
    return {
 | 
			
		||||
      label:null,
 | 
			
		||||
      labelStudio: null,
 | 
			
		||||
      annotationsList: [] // 用于存储当前标注的结果
 | 
			
		||||
    };
 | 
			
		||||
| 
						 | 
				
			
			@ -130,6 +131,7 @@ export default {
 | 
			
		|||
          annotation: JSON.stringify(formattedAnnotations),
 | 
			
		||||
          url: this.fileUrl
 | 
			
		||||
        });
 | 
			
		||||
        this.label = JSON.stringify(formattedAnnotations)
 | 
			
		||||
        this.index++; // 更新索引
 | 
			
		||||
      } catch (error) {
 | 
			
		||||
        console.error('Failed to submit annotation:', error);
 | 
			
		||||
| 
						 | 
				
			
			
 | 
			
		|||
| 
						 | 
				
			
			@ -72,7 +72,7 @@
 | 
			
		|||
              <ul>
 | 
			
		||||
                <li v-for="(item, index) in images" :key="item.fileId" class="list-item">
 | 
			
		||||
                  <div @click="setItem(item, index)">
 | 
			
		||||
                    <input type="checkbox" :checked="item.fileAnnotationStatus==='1'" disabled>
 | 
			
		||||
                    <input type="checkbox" :checked="item.fileAnnotationStatus!=='0'" disabled>
 | 
			
		||||
                    <span :class="{'highlighted': itemIndex === index}" style="font-size: 14px; margin-left: 5px;"
 | 
			
		||||
                    >{{ item.fileName }}</span>
 | 
			
		||||
                  </div>
 | 
			
		||||
| 
						 | 
				
			
			@ -83,7 +83,7 @@
 | 
			
		|||
        </div>
 | 
			
		||||
        <div class="bottom-content-center">
 | 
			
		||||
          <div>
 | 
			
		||||
            <custom-label-studio :annotations="annotationResult" :taskId="taskId" :item-index="itemIndex"
 | 
			
		||||
            <custom-label-studio :annotations="annotationResult" :taskId="taskId || 0" :item-index="itemIndex"
 | 
			
		||||
                                 :config="labelConfig" :id="task.id" :file-url="task.data.image"
 | 
			
		||||
                                 @update-itemIndex="updateItemIndex"
 | 
			
		||||
            ></custom-label-studio>
 | 
			
		||||
| 
						 | 
				
			
			@ -114,13 +114,6 @@ export default {
 | 
			
		|||
        }
 | 
			
		||||
      },
 | 
			
		||||
      labelConfig: `
 | 
			
		||||
        <View>
 | 
			
		||||
          <Image name="image" value="$image"/>
 | 
			
		||||
          <RectangleLabels name="label" toName="image">
 | 
			
		||||
            <Label value="人" background="#ff0000"/>
 | 
			
		||||
            <Label value="车" background="#00ff00"/>
 | 
			
		||||
          </RectangleLabels>
 | 
			
		||||
        </View>
 | 
			
		||||
      `,
 | 
			
		||||
      taskId: undefined, // 当前选中的任务 ID
 | 
			
		||||
      leftIcons: [
 | 
			
		||||
| 
						 | 
				
			
			@ -137,67 +130,87 @@ export default {
 | 
			
		|||
    }
 | 
			
		||||
  },
 | 
			
		||||
  created() {
 | 
			
		||||
    this.loadTaskList(); // 初始化时加载任务列表
 | 
			
		||||
    this.loadTaskList() // 初始化时加载任务列表
 | 
			
		||||
  },
 | 
			
		||||
  methods: {
 | 
			
		||||
    // 更新项的索引并切换任务数据
 | 
			
		||||
    updateItemIndex(val) {
 | 
			
		||||
      const item = this.images[val];
 | 
			
		||||
      this.images[val - 1].fileAnnotationStatus = '1';
 | 
			
		||||
      this.itemIndex = val;
 | 
			
		||||
      this.updateTaskData(item);
 | 
			
		||||
    updateItemIndex(val, data) {
 | 
			
		||||
      const item = this.images[val]
 | 
			
		||||
      this.images[val - 1].fileAnnotationStatus = '1'
 | 
			
		||||
      this.images[val - 1].annotationResult = data
 | 
			
		||||
      this.itemIndex = val
 | 
			
		||||
      this.updateTaskData(item)
 | 
			
		||||
    },
 | 
			
		||||
 | 
			
		||||
    // 加载未标注的任务列表
 | 
			
		||||
    loadTaskList() {
 | 
			
		||||
      getMyNoAnnotatedTask().then(res => {
 | 
			
		||||
        this.taskList = res.data;
 | 
			
		||||
      });
 | 
			
		||||
        this.taskList = res.data
 | 
			
		||||
      })
 | 
			
		||||
    },
 | 
			
		||||
 | 
			
		||||
    // 根据任务ID选择任务并加载对应的文件
 | 
			
		||||
    selectTask(id) {
 | 
			
		||||
      this.resetImages();
 | 
			
		||||
      this.taskId = id;
 | 
			
		||||
      this.fetchImages();
 | 
			
		||||
      this.resetImages()
 | 
			
		||||
      const result = this.taskList.find(item => item.taskId === id)
 | 
			
		||||
      const labels = result.labels.split(',').map(role => role.trim())
 | 
			
		||||
      const labelElements = labels
 | 
			
		||||
        .map((label, index) => `<Label value="${label}" background="${this.getColor(index)}"/>`)
 | 
			
		||||
        .join('')
 | 
			
		||||
      this.labelConfig = `<View>
 | 
			
		||||
    <Image name="image" value="$image"/>
 | 
			
		||||
    <RectangleLabels name="label" toName="image">
 | 
			
		||||
      ${labelElements}
 | 
			
		||||
    </RectangleLabels>
 | 
			
		||||
  </View>`
 | 
			
		||||
      this.taskId = id
 | 
			
		||||
      this.fetchImages()
 | 
			
		||||
    },
 | 
			
		||||
    getColor(index) {
 | 
			
		||||
      const randomColor = () => {
 | 
			
		||||
        const r = Math.floor(Math.random() * 256); // 0-255
 | 
			
		||||
        const g = Math.floor(Math.random() * 256); // 0-255
 | 
			
		||||
        const b = Math.floor(Math.random() * 256); // 0-255
 | 
			
		||||
        return `rgb(${r}, ${g}, ${b})`;
 | 
			
		||||
      };
 | 
			
		||||
      return randomColor();
 | 
			
		||||
    },
 | 
			
		||||
 | 
			
		||||
    // 切换标注类型并加载任务文件
 | 
			
		||||
    toggleSelected(type) {
 | 
			
		||||
      if (this.annotationType === type) return;
 | 
			
		||||
      this.annotationType = type;
 | 
			
		||||
      this.resetImages();
 | 
			
		||||
      this.fetchImages();
 | 
			
		||||
      if (this.annotationType === type) return
 | 
			
		||||
      this.annotationType = type
 | 
			
		||||
      this.resetImages()
 | 
			
		||||
      this.fetchImages()
 | 
			
		||||
    },
 | 
			
		||||
 | 
			
		||||
    // 设置标注项,更新任务数据和标注结果
 | 
			
		||||
    setItem(item, index) {
 | 
			
		||||
      this.annotationResult = JSON.parse(item.annotationResult);
 | 
			
		||||
      this.itemIndex = index;
 | 
			
		||||
      this.updateTaskData(item);
 | 
			
		||||
      this.annotationResult = JSON.parse(item.annotationResult)
 | 
			
		||||
      this.itemIndex = index
 | 
			
		||||
      this.updateTaskData(item)
 | 
			
		||||
    },
 | 
			
		||||
 | 
			
		||||
    // 重置图像数据
 | 
			
		||||
    resetImages() {
 | 
			
		||||
      this.images = [];
 | 
			
		||||
      //this.annotationType = 0;
 | 
			
		||||
      this.images = []
 | 
			
		||||
    },
 | 
			
		||||
 | 
			
		||||
    // 获取当前任务ID和标注类型的图像数据
 | 
			
		||||
    fetchImages() {
 | 
			
		||||
      if (!this.taskId) return;
 | 
			
		||||
      if (!this.taskId) return
 | 
			
		||||
      getMyAnnotationFiles(this.annotationType, this.taskId).then(response => {
 | 
			
		||||
        this.itemIndex = 0;
 | 
			
		||||
        this.images = response.data;
 | 
			
		||||
        this.updateTaskData(this.images[this.itemIndex]);
 | 
			
		||||
      });
 | 
			
		||||
        this.itemIndex = 0
 | 
			
		||||
        this.images = response.data
 | 
			
		||||
        this.updateTaskData(this.images[this.itemIndex])
 | 
			
		||||
      })
 | 
			
		||||
    },
 | 
			
		||||
 | 
			
		||||
    // 更新任务的数据
 | 
			
		||||
    updateTaskData(item) {
 | 
			
		||||
      this.task.data.image = `http://192.168.0.14:9090/bonus/${item.fileUrl}`;
 | 
			
		||||
      this.task.id = item.fileId;
 | 
			
		||||
      this.annotationResult = JSON.parse(item.annotationResult);
 | 
			
		||||
      let url = JSON.parse(localStorage.getItem('minIoUrl'))
 | 
			
		||||
      this.task.data.image = `${url.minioUrl}${item.fileUrl}`
 | 
			
		||||
      this.task.id = item.fileId
 | 
			
		||||
      this.annotationResult = JSON.parse(item.annotationResult)
 | 
			
		||||
    }
 | 
			
		||||
  }
 | 
			
		||||
}
 | 
			
		||||
| 
						 | 
				
			
			
 | 
			
		|||
| 
						 | 
				
			
			@ -72,7 +72,7 @@
 | 
			
		|||
              <ul>
 | 
			
		||||
                <li v-for="(item, index) in images" :key="item.fileId" class="list-item">
 | 
			
		||||
                  <div @click="setItem(item, index)">
 | 
			
		||||
                    <input type="checkbox" :checked="item.fileAnnotationStatus==='1'" disabled>
 | 
			
		||||
                    <input type="checkbox" :checked="item.fileAnnotationStatus==='2' || item.fileAnnotationStatus==='3' " disabled>
 | 
			
		||||
                    <span :class="{'highlighted': itemIndex === index}" style="font-size: 14px; margin-left: 5px;"
 | 
			
		||||
                    >{{ item.fileName }}</span>
 | 
			
		||||
                  </div>
 | 
			
		||||
| 
						 | 
				
			
			@ -83,7 +83,7 @@
 | 
			
		|||
        </div>
 | 
			
		||||
        <div class="bottom-content-center">
 | 
			
		||||
          <div>
 | 
			
		||||
            <custom-label-studio :annotations="annotationResult" :taskId="taskId" :item-index="itemIndex"
 | 
			
		||||
            <custom-label-studio :annotations="annotationResult" :taskId="taskId || 0" :item-index="itemIndex"
 | 
			
		||||
                                 :config="labelConfig" :id="task.id" :file-url="task.data.image"
 | 
			
		||||
                                 @update-itemIndex="updateItemIndex"
 | 
			
		||||
            ></custom-label-studio>
 | 
			
		||||
| 
						 | 
				
			
			@ -141,7 +141,7 @@ export default {
 | 
			
		|||
    // 更新项的索引并切换任务数据
 | 
			
		||||
    updateItemIndex(val) {
 | 
			
		||||
      const item = this.images[val];
 | 
			
		||||
      this.images[val - 1].fileAnnotationStatus = '1';
 | 
			
		||||
      this.images[val - 1].fileAnnotationStatus = '2';
 | 
			
		||||
      this.itemIndex = val;
 | 
			
		||||
      this.updateTaskData(item);
 | 
			
		||||
    },
 | 
			
		||||
| 
						 | 
				
			
			@ -154,10 +154,32 @@ export default {
 | 
			
		|||
    },
 | 
			
		||||
 | 
			
		||||
    // 根据任务ID选择审核并加载对应的文件
 | 
			
		||||
    // 根据任务ID选择任务并加载对应的文件
 | 
			
		||||
    selectTask(id) {
 | 
			
		||||
      this.resetImages();
 | 
			
		||||
      this.taskId = id;
 | 
			
		||||
      this.fetchImages();
 | 
			
		||||
      this.resetImages()
 | 
			
		||||
      const result = this.taskList.find(item => item.taskId === id)
 | 
			
		||||
      console.log(result)
 | 
			
		||||
      const labels = result.labels.split(',').map(role => role.trim())
 | 
			
		||||
      const labelElements = labels
 | 
			
		||||
        .map((label, index) => `<Label value="${label}" background="${this.getColor(index)}"/>`)
 | 
			
		||||
        .join('')
 | 
			
		||||
      this.labelConfig = `<View>
 | 
			
		||||
    <Image name="image" value="$image"/>
 | 
			
		||||
    <RectangleLabels name="label" toName="image">
 | 
			
		||||
      ${labelElements}
 | 
			
		||||
    </RectangleLabels>
 | 
			
		||||
  </View>`
 | 
			
		||||
      this.taskId = id
 | 
			
		||||
      this.fetchImages()
 | 
			
		||||
    },
 | 
			
		||||
    getColor(index) {
 | 
			
		||||
      const randomColor = () => {
 | 
			
		||||
        const r = Math.floor(Math.random() * 256); // 0-255
 | 
			
		||||
        const g = Math.floor(Math.random() * 256); // 0-255
 | 
			
		||||
        const b = Math.floor(Math.random() * 256); // 0-255
 | 
			
		||||
        return `rgb(${r}, ${g}, ${b})`;
 | 
			
		||||
      };
 | 
			
		||||
      return randomColor();
 | 
			
		||||
    },
 | 
			
		||||
 | 
			
		||||
    // 切换标注类型并加载任务文件
 | 
			
		||||
| 
						 | 
				
			
			@ -197,7 +219,8 @@ export default {
 | 
			
		|||
    // 更新任务的数据
 | 
			
		||||
    updateTaskData(item) {
 | 
			
		||||
      if (item !== undefined){
 | 
			
		||||
        this.task.data.image = `http://192.168.0.14:9090/bonus/${item.fileUrl}`;
 | 
			
		||||
        let url =  JSON.parse(localStorage.getItem('minIoUrl'))
 | 
			
		||||
        this.task.data.image = `${url.minioUrl}${item.fileUrl}`;
 | 
			
		||||
        this.task.id = item.fileId;
 | 
			
		||||
        this.annotationResult = JSON.parse(item.annotationResult);
 | 
			
		||||
      }
 | 
			
		||||
| 
						 | 
				
			
			
 | 
			
		|||
		Loading…
	
		Reference in New Issue