2019-07-25 10:30:30 +08:00
|
|
|
import { getDetailList } from '@/api/management/dictionary';
|
|
|
|
|
|
|
|
function loadDictionary() {
|
2019-11-01 13:51:00 +08:00
|
|
|
function queryData(code, that, field) {
|
|
|
|
return new Promise((resolve, reject) => {
|
|
|
|
if (that[field].length) {
|
|
|
|
resolve(that[field]);
|
|
|
|
}
|
|
|
|
getDetailList(code).then(response => {
|
|
|
|
that[field] = response.data;
|
|
|
|
resolve(that[field]);
|
|
|
|
}).catch(error => {
|
|
|
|
console.log('获取字典失败:' + error.message);
|
|
|
|
reject(error);
|
|
|
|
});
|
|
|
|
});
|
|
|
|
}
|
2019-07-25 10:30:30 +08:00
|
|
|
|
2019-11-01 13:51:00 +08:00
|
|
|
function Dictionary() { }
|
2019-07-25 10:30:30 +08:00
|
|
|
|
2019-11-01 13:51:00 +08:00
|
|
|
Dictionary.prototype = {
|
|
|
|
_TrainingType: [],
|
2019-07-25 10:30:30 +08:00
|
|
|
|
2019-11-01 13:51:00 +08:00
|
|
|
_SectionType: [],
|
2019-07-25 10:30:30 +08:00
|
|
|
|
2019-11-01 13:51:00 +08:00
|
|
|
_SectionSepType: [],
|
2019-07-25 10:30:30 +08:00
|
|
|
|
2019-11-01 13:51:00 +08:00
|
|
|
_SignalPotLampType: [],
|
|
|
|
_SignalLampPostType: [],
|
|
|
|
_SignalLampPositionType: [],
|
|
|
|
_SignalDirectionType: [],
|
|
|
|
_SignalPositionType: [],
|
|
|
|
_SignalUseType: [],
|
2019-07-25 10:30:30 +08:00
|
|
|
|
2019-11-01 13:51:00 +08:00
|
|
|
_DoorLocationType: [],
|
2019-07-25 10:30:30 +08:00
|
|
|
|
2019-11-01 13:51:00 +08:00
|
|
|
_WhetherType: [], // 是/否
|
|
|
|
_EffectiveType: [], // 生效/失效
|
2019-07-25 10:30:30 +08:00
|
|
|
|
2019-11-01 13:51:00 +08:00
|
|
|
_RouteNatureType: [],
|
|
|
|
_RouteAutoType: [],
|
|
|
|
_SwitchLocateType: [],
|
2019-07-25 10:30:30 +08:00
|
|
|
|
2019-11-01 13:51:00 +08:00
|
|
|
_BizType: [],
|
|
|
|
_OrderType: [],
|
|
|
|
_PayType: [],
|
|
|
|
_PayStatus: [],
|
2019-07-25 10:30:30 +08:00
|
|
|
|
2019-11-01 13:51:00 +08:00
|
|
|
_LogicalViewType: {},
|
|
|
|
_PhysicalViewType: [],
|
2019-07-25 10:30:30 +08:00
|
|
|
|
2019-11-01 13:51:00 +08:00
|
|
|
_PermissionType: [],
|
|
|
|
_ProductPostType: [],
|
2019-07-25 10:30:30 +08:00
|
|
|
|
2019-11-01 13:51:00 +08:00
|
|
|
_ProductType: [],
|
2019-07-25 10:30:30 +08:00
|
|
|
|
2019-11-01 13:51:00 +08:00
|
|
|
_TimeStyle: [],
|
2019-07-25 10:30:30 +08:00
|
|
|
|
2019-11-01 13:51:00 +08:00
|
|
|
_RunDirectionType: [],
|
2019-07-25 10:30:30 +08:00
|
|
|
|
2019-11-01 13:51:00 +08:00
|
|
|
_TrainPositionType: [],
|
2019-07-25 10:30:30 +08:00
|
|
|
|
2019-11-01 13:51:00 +08:00
|
|
|
_CityType: [],
|
2019-07-25 10:30:30 +08:00
|
|
|
|
2019-11-01 13:51:00 +08:00
|
|
|
_LineType: [],
|
2019-07-25 10:30:30 +08:00
|
|
|
|
2019-11-01 13:51:00 +08:00
|
|
|
_TaskList: [], // 任务类型列表
|
2019-07-25 10:30:30 +08:00
|
|
|
|
2019-11-01 13:51:00 +08:00
|
|
|
_TaskStatus: [], // 任务状态
|
2019-07-25 10:30:30 +08:00
|
|
|
|
2019-11-01 13:51:00 +08:00
|
|
|
_StationControl: [], // 控制权操作类型
|
2019-07-25 10:30:30 +08:00
|
|
|
|
2019-11-01 13:51:00 +08:00
|
|
|
_SignalOperation: [], // 信号灯操作类型
|
2019-07-25 10:30:30 +08:00
|
|
|
|
2019-11-01 13:51:00 +08:00
|
|
|
_SwitchOperation: [], // 道岔操作类型
|
2019-07-25 10:30:30 +08:00
|
|
|
|
2019-11-01 13:51:00 +08:00
|
|
|
_SectionOperation: [], // 区段操作类型
|
2019-07-25 10:30:30 +08:00
|
|
|
|
2019-11-01 13:51:00 +08:00
|
|
|
_StationStandOperation: [], // 站台操作类型
|
2019-07-25 10:30:30 +08:00
|
|
|
|
2019-11-01 13:51:00 +08:00
|
|
|
_TrainPlanOperation: [], // 行车计划操作类型
|
2019-07-25 10:30:30 +08:00
|
|
|
|
2019-11-01 13:51:00 +08:00
|
|
|
_TrainOperation: [], // 列车操作类型
|
|
|
|
|
|
|
|
_RegionTypeList: [], // 区间类型列表
|
|
|
|
|
|
|
|
_LimitOperation: [],
|
|
|
|
|
|
|
|
regionTypeList: function () {
|
|
|
|
return queryData('region_type_list', this, '_RegionTypeList');
|
|
|
|
},
|
|
|
|
|
|
|
|
limitOperation: function () {
|
|
|
|
return queryData('limit_operation', this, '_LimitOperation');
|
|
|
|
},
|
|
|
|
|
|
|
|
stationControl: function () {
|
|
|
|
return queryData('station_control', this, '_StationControl');
|
|
|
|
},
|
|
|
|
|
|
|
|
signalOperation: function () {
|
|
|
|
return queryData('signal_operation', this, '_SignalOperation');
|
|
|
|
},
|
|
|
|
|
|
|
|
switchOperation: function () {
|
|
|
|
return queryData('switch_operation', this, '_SwitchOperation');
|
|
|
|
},
|
|
|
|
|
|
|
|
sectionOperation: function () {
|
|
|
|
return queryData('section_operation', this, '_SectionOperation');
|
|
|
|
},
|
|
|
|
|
|
|
|
stationStandOperation: function () {
|
|
|
|
return queryData('station_stand_operation', this, '_StationStandOperation');
|
|
|
|
},
|
|
|
|
|
|
|
|
trainPlanOperation: function () {
|
|
|
|
return queryData('train_plan_operation', this, '_TrainPlanOperation');
|
|
|
|
},
|
|
|
|
|
|
|
|
trainOperation: function () {
|
|
|
|
return queryData('train_operation', this, '_TrainOperation');
|
|
|
|
},
|
|
|
|
|
|
|
|
taskList: function () {
|
|
|
|
return queryData('task_type', this, '_TaskList');
|
|
|
|
},
|
|
|
|
taskStatus: function () {
|
|
|
|
return queryData('task_status', this, '_TaskStatus');
|
|
|
|
},
|
|
|
|
trainingType: function () {
|
|
|
|
return queryData('training_type', this, '_TrainingType');
|
|
|
|
},
|
|
|
|
|
|
|
|
sectionType: function () {
|
|
|
|
return queryData('section_type', this, '_SectionType');
|
|
|
|
},
|
|
|
|
|
|
|
|
sectionSepType: function () {
|
|
|
|
return queryData('section_sep_type', this, '_SectionSepType');
|
|
|
|
},
|
|
|
|
|
|
|
|
signalPotLampType: function () {
|
|
|
|
return queryData('signal_pot_lamp_type', this, '_SignalPotLampType');
|
|
|
|
},
|
|
|
|
signalLampPostType: function () {
|
|
|
|
return queryData('signal_lamp_post_type', this, '_SignalLampPostType');
|
|
|
|
},
|
|
|
|
signalLampPositionType: function () {
|
|
|
|
return queryData('signal_lamp_position_type', this, '_SignalLampPositionType');
|
|
|
|
},
|
|
|
|
signalDirectionType: function () {
|
|
|
|
return queryData('signal_direction_type', this, '_SignalDirectionType');
|
|
|
|
},
|
|
|
|
signalPositionType: function () {
|
|
|
|
return queryData('signal_position_type', this, '_SignalPositionType');
|
|
|
|
},
|
|
|
|
signalUseType: function () {
|
|
|
|
return queryData('signal_use_type', this, '_SignalUseType');
|
|
|
|
},
|
|
|
|
|
|
|
|
doorLocationType: function () {
|
|
|
|
return queryData('door_location_type', this, '_DoorLocationType');
|
|
|
|
},
|
|
|
|
|
|
|
|
whetherType: function () {
|
|
|
|
return queryData('whether_type', this, '_WhetherType');
|
|
|
|
},
|
|
|
|
effectiveType: function () {
|
|
|
|
return queryData('effective_type', this, '_EffectiveType');
|
|
|
|
},
|
|
|
|
|
|
|
|
routeNatureType: function () {
|
|
|
|
return queryData('route_nature_type', this, '_RouteNatureType');
|
|
|
|
},
|
|
|
|
routeAutoType: function () {
|
|
|
|
return queryData('route_auto_type', this, '_RouteAutoType');
|
|
|
|
},
|
|
|
|
switchLocateType: function () {
|
|
|
|
return queryData('switch_locate_type', this, '_SwitchLocateType');
|
|
|
|
},
|
|
|
|
productPostType: function () {
|
|
|
|
return queryData('product_post_type', this, '_ProductPostType');
|
|
|
|
},
|
|
|
|
bizType: function () {
|
|
|
|
return queryData('biz_type', this, '_BizType');
|
|
|
|
},
|
|
|
|
orderType: function () {
|
|
|
|
return queryData('order_type', this, '_OrderType');
|
|
|
|
},
|
|
|
|
payType: function () {
|
|
|
|
return queryData('pay_type', this, '_PayType');
|
|
|
|
},
|
|
|
|
payStatus: function () {
|
|
|
|
return queryData('pay_status', this, '_PayStatus');
|
|
|
|
},
|
|
|
|
|
|
|
|
permissionType: function () {
|
|
|
|
return queryData('permission_type', this, '_PermissionType');
|
|
|
|
},
|
|
|
|
|
|
|
|
productType: function () {
|
|
|
|
return queryData('product_type', this, '_ProductType');
|
|
|
|
},
|
|
|
|
|
|
|
|
timeStyleType: function () {
|
|
|
|
return queryData('time_style', this, '_TimeStyle');
|
|
|
|
},
|
|
|
|
|
|
|
|
runDirectionType: function () {
|
|
|
|
return queryData('run_direction_type', this, '_RunDirectionType');
|
|
|
|
},
|
|
|
|
|
|
|
|
logicalViewType: function () {
|
|
|
|
return queryData('logical_view_Type', this, '_LogicalViewType');
|
|
|
|
},
|
|
|
|
physicalViewType: function () {
|
|
|
|
return queryData('physical_view_Type', this, '_PhysicalViewType');
|
|
|
|
},
|
|
|
|
|
|
|
|
trainPositionType: function () {
|
|
|
|
return queryData('train_position_type', this, '_TrainPositionType');
|
|
|
|
},
|
|
|
|
|
|
|
|
cityType: function () {
|
|
|
|
return queryData('city_type', this, '_CityType');
|
|
|
|
},
|
|
|
|
|
|
|
|
lineType: function () {
|
|
|
|
return queryData('line_type', this, '_LineType');
|
|
|
|
},
|
|
|
|
|
|
|
|
translate: function (value, dic) {
|
|
|
|
return new Promise((resolve, reject) => {
|
|
|
|
if (this[dic] instanceof Function) {
|
|
|
|
this[dic]().then(list => {
|
|
|
|
if (list && list.length) {
|
|
|
|
const obj = list.filter(function (item) {
|
|
|
|
return item.value === value;
|
|
|
|
})[0];
|
|
|
|
const label = obj && obj.label;
|
|
|
|
resolve(label);
|
|
|
|
} else {
|
|
|
|
console.warn('字典列表为空:"' + dic + '"');
|
|
|
|
resolve('');
|
|
|
|
}
|
|
|
|
}).catch(error => {
|
|
|
|
console.error('字典翻译异常:' + error.message);
|
|
|
|
reject(error);
|
|
|
|
});
|
|
|
|
} else {
|
|
|
|
const error = new Error('"' + dic + '" 对象不存在');
|
|
|
|
console.error('字典翻译异常:' + error.message);
|
|
|
|
reject(error);
|
|
|
|
}
|
|
|
|
});
|
|
|
|
}
|
|
|
|
};
|
|
|
|
return new Dictionary();
|
2019-07-25 10:30:30 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
// export function addCityNodeByTree(cityList, tree) {
|
|
|
|
// let cityNode = {
|
|
|
|
// children: [],
|
|
|
|
// id: "6",
|
|
|
|
// name: '',
|
|
|
|
// type: 'city',
|
|
|
|
// };
|
|
|
|
// }
|
|
|
|
|
|
|
|
export default loadDictionary();
|