import { getAllDictType } from '@/api/user' const state = { imuStatus: {}, imuStatusOptions: [], enableStatus: {}, enableStatusOptions: [], successStatus: {}, successStatusOptions: [], sarWorkStatus: {}, sarWorkStatusOptions: [], taskFlightMode: {}, taskFlightModeOptions: [], jobStatus: {}, jobStatusOptions: [], sarResolution: {}, sarResolutionOptions: [], detectType: {}, jobMode: {}, jobModeOptions: [ { label: '快速模式', value: '1' }, { label: '巡航模式', value: '2' }, { label: '创建航线', value: '3' }, ], polarization: {}, polarizationOptions: {}, sarImageMode: {}, sarImageModeOptions: [] } const mutations = { SET_IMU_STATUS: (state, info) => { state.imuStatus = info }, SET_IMU_STATUS_OPTIONS: (state, info) => { state.imuStatusOptions = info }, SET_ENABLE_STATUS: (state, info) => { state.enableStatus = info }, SET_ENABLE_STATUS_OPTIONS: (state, info) => { state.enableStatusOptions = info }, SET_SUCCESS_STATUS: (state, info) => { state.successStatus = info }, SET_SUCCESS_STATUS_OPTIONS: (state, info) => { state.successStatusOptions = info }, SET_SAR_WORK_STATUS: (state, info) => { state.sarWorkStatus = info }, SET_SAR_WORK_STATUS_OPTIONS: (state, info) => { state.sarWorkStatusOptions = info }, SET_TASK_FLIGHT_MODE: (state, info) => { state.taskFlightMode = info }, SET_TASK_FLIGHT_MODE_OPTIONS: (state, info) => { state.taskFlightModeOptions = info }, SET_JOB_STATUS: (state, info) => { state.jobStatus = info }, SET_JOB_STATUS_OPTIONS: (state, info) => { state.jobStatusOptions = info }, SET_SAR_RESOLUTION: (state, info) => { state.sarResolution = info }, SET_SAR_RESOLUTION_OPTIONS: (state, info) => { state.sarResolutionOptions = info }, SET_DETECT_TYPE: (state, info) => { window.detectType = info state.detectType = info }, SET_JOB_MODE: (state, info) => { state.jobMode = info }, SET_JOB_MODE_OPTIONS: (state, info) => { state.jobModeOptions = info }, SET_POLARIZATION: (state, info) => { state.polarization = info }, SET_POLARIZATION_OPTIONS: (state, info) => { state.polarizationOptions = info }, SET_SAR_IMAGE_MODE: (state, info) => { state.sarImageMode = info }, SET_SAR_IMAGE_MODE_OPTIONS: (state, info) => { state.sarImageModeOptions = info }, } const actions = { getDict({ commit }) { return new Promise((resolve, reject) => { getAllDictType().then(res => { console.log('字典数据', res) if (res.data.code === 200) { console.log('字典数据1', res.data.data) let imuStatus = {} let imuStatusOptions = [] let enableStatus = {} let enableStatusOptions = [] let successStatus = {} let successStatusOptions = [] let sarWorkStatus = {} let sarWorkStatusOptions = [] let taskFlightMode = {} let taskFlightModeOptions = [] let jobStatus = {} let jobStatusOptions = [] let sarResolution = {} let sarResolutionOptions = [] let detectType = {} let jobMode = {} let jobModeOptions = [] let polarization = {} let polarizationOptions = [] let sarImageMode = {} let sarImageModeOptions = [] res.data.data.forEach(item => { switch (item.dictType) { case 'imu_status': imuStatus[item.dictValue] = item.dictLabel imuStatusOptions.push({ label: item.dictLabel, value: item.dictValue }) break case 'enable_status': enableStatus[item.dictValue] = item.dictLabel enableStatusOptions.push({ label: item.dictLabel, value: item.dictValue }) break case 'success_status': successStatus[item.dictValue] = item.dictLabel successStatusOptions.push({ label: item.dictLabel, value: item.dictValue }) break case 'sar_work_status': sarWorkStatus[item.dictValue] = item.dictLabel sarWorkStatusOptions.push({ label: item.dictLabel, value: item.dictValue }) break case 'task_flight_mode': taskFlightMode[item.dictValue] = item.dictLabel taskFlightModeOptions.push({ label: item.dictLabel, value: item.dictValue }) break case 'job_status': jobStatus[item.dictValue] = item.dictLabel jobStatusOptions.push({ label: item.dictLabel, value: item.dictValue }) break case 'sar_resolution': sarResolution[item.dictValue] = item.dictLabel sarResolutionOptions.push({ label: item.dictLabel, value: item.dictValue }) break case 'py_detect_type': detectType[item.dictValue] = item.dictLabel break case 'job_mode': jobMode[item.dictValue] = item.dictLabel jobModeOptions.push({ label: item.dictLabel, value: item.dictValue }) break case 'sar_polarization': polarization[item.dictValue] = item.dictLabel polarizationOptions.push({ label: item.dictLabel, value: item.dictValue }) break case 'sar_image_mode': sarImageMode[item.dictValue] = item.dictLabel sarImageModeOptions.push({ label: item.dictLabel, value: item.dictValue }) break } }) commit('SET_SAR_IMAGE_MODE', sarImageMode) commit('SET_SAR_IMAGE_MODE_OPTIONS', sarImageModeOptions) // 适配机场类型 commit('SET_IMU_STATUS', imuStatus) commit('SET_IMU_STATUS_OPTIONS', imuStatusOptions) // 适配机型 commit('SET_ENABLE_STATUS', enableStatus) commit('SET_ENABLE_STATUS_OPTIONS', enableStatusOptions) // 航点类型 commit('SET_SUCCESS_STATUS', successStatus) commit('SET_SUCCESS_STATUS_OPTIONS', successStatusOptions) // 机库状态 commit('SET_SAR_WORK_STATUS', sarWorkStatus) commit('SET_SAR_WORK_STATUS_OPTIONS', sarWorkStatusOptions) // 任务类型 commit('SET_TASK_FLIGHT_MODE', taskFlightMode) commit('SET_TASK_FLIGHT_MODE_OPTIONS', taskFlightModeOptions) // 任务状态 commit('SET_JOB_STATUS', jobStatus) commit('SET_JOB_STATUS_OPTIONS', jobStatusOptions) // sar 分辨率 commit('SET_SAR_RESOLUTION', sarResolution) commit('SET_SAR_RESOLUTION_OPTIONS', sarResolutionOptions) // 识别类型 commit('SET_DETECT_TYPE', detectType) // 任务类型 commit('SET_JOB_MODE', jobMode) commit('SET_JOB_MODE_OPTIONS', jobModeOptions) // 极化方式 commit('SET_POLARIZATION', polarization) commit('SET_POLARIZATION_OPTIONS', polarizationOptions) commit('SET_POLARIZATION_OPTIONS', sarImageModeOptions) resolve() } else { this.$message.error(res.data.message) reject() } }) }) } } export default { namespaced: true, state, mutations, actions, }