2019-07-25 10:30:30 +08:00
|
|
|
|
import Vue from 'vue';
|
|
|
|
|
import QueryListPage from '@/components/QueryListPage/QueryListPage';
|
|
|
|
|
import DataForm from '@/components/QueryListPage/DataForm';
|
|
|
|
|
import TurnbackBar from '@/components/TurnbackBar';
|
|
|
|
|
import ConstConfig from '@/scripts/ConstConfig';
|
|
|
|
|
import Dictionary from '@/scripts/DictionaryData';
|
2019-08-08 18:34:35 +08:00
|
|
|
|
import Theme from '@/jmap/theme/factory';
|
2019-07-02 16:29:52 +08:00
|
|
|
|
|
|
|
|
|
// 全局组件
|
2019-07-25 10:30:30 +08:00
|
|
|
|
Vue.component('DataForm', DataForm);
|
|
|
|
|
Vue.component('QueryListPage', QueryListPage);
|
|
|
|
|
Vue.component('TurnbackBar', TurnbackBar);
|
2019-07-02 16:29:52 +08:00
|
|
|
|
|
|
|
|
|
Vue.prototype.$ConstSelect = (function() {
|
|
|
|
|
ConstConfig.ConstSelect.translate = function(value, codeName) {
|
|
|
|
|
if (codeName) {
|
|
|
|
|
const obj = this[codeName].filter(function(item) {
|
2019-07-25 10:30:30 +08:00
|
|
|
|
return item.value === value;
|
|
|
|
|
})[0];
|
|
|
|
|
return obj && obj.label;
|
2019-07-02 16:29:52 +08:00
|
|
|
|
}
|
2019-07-25 10:30:30 +08:00
|
|
|
|
};
|
|
|
|
|
return ConstConfig.ConstSelect;
|
|
|
|
|
})();
|
2019-07-02 16:29:52 +08:00
|
|
|
|
|
2019-07-25 10:30:30 +08:00
|
|
|
|
Vue.prototype.$Dictionary = Dictionary;
|
|
|
|
|
|
|
|
|
|
Vue.prototype.__windowResizeFlag = false;
|
2019-07-02 16:29:52 +08:00
|
|
|
|
Vue.prototype.$addWindowResizeListener = function(cb) {
|
|
|
|
|
window.addEventListener('resize', function() {
|
|
|
|
|
if (!Vue.__windowResizeFlag) {
|
2019-07-25 10:30:30 +08:00
|
|
|
|
Vue.__windowResizeFlag = true;
|
2019-07-02 16:29:52 +08:00
|
|
|
|
setTimeout(function() {
|
2019-07-25 10:30:30 +08:00
|
|
|
|
Vue.__windowResizeFlag = false;
|
|
|
|
|
cb();
|
|
|
|
|
}, 100);
|
2019-07-02 16:29:52 +08:00
|
|
|
|
}
|
2019-07-25 10:30:30 +08:00
|
|
|
|
});
|
|
|
|
|
};
|
2019-08-08 18:34:35 +08:00
|
|
|
|
|
|
|
|
|
Vue.prototype.$theme = new Theme();
|
|
|
|
|
Vue.prototype.$messageBox = function(msge) {
|
|
|
|
|
if (this.$confirm) {
|
2019-09-19 13:19:35 +08:00
|
|
|
|
this.$confirm(`${msge || this.$t('global.processFailure')}!`, this.$t('global.tips'), {
|
|
|
|
|
confirmButtonText: this.$t('global.confirm'),
|
2019-08-08 18:34:35 +08:00
|
|
|
|
type: 'warning',
|
|
|
|
|
showCancelButton: false,
|
|
|
|
|
center: true
|
|
|
|
|
}).then(() => {
|
|
|
|
|
}).catch(() => {
|
|
|
|
|
});
|
|
|
|
|
}
|
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
Vue.prototype.$convertField = function(fieldValue, enumList, converFormat, isList = false) {
|
|
|
|
|
const arr = [];
|
|
|
|
|
if (enumList && converFormat && converFormat.length >= 2) {
|
|
|
|
|
const value = converFormat[0];
|
|
|
|
|
const label = converFormat[1];
|
|
|
|
|
if (isList) {
|
|
|
|
|
enumList.forEach((element, i) => {
|
|
|
|
|
fieldValue.forEach((v, j) => {
|
|
|
|
|
if ('' + fieldValue[j] === '' + enumList[i][value]) {
|
|
|
|
|
arr.push(enumList[i][label]);
|
|
|
|
|
}
|
|
|
|
|
});
|
|
|
|
|
});
|
|
|
|
|
} else {
|
|
|
|
|
for (let i = 0; i < enumList.length; i++) {
|
|
|
|
|
if ('' + fieldValue === '' + enumList[i][value]) {
|
|
|
|
|
return enumList[i][label];
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
return isList ? arr: '';
|
|
|
|
|
};
|
|
|
|
|
|
2019-08-13 16:59:38 +08:00
|
|
|
|
Vue.prototype.$convertSpecifiedField = function(dataDict, enumList, key, value, fieldList) {
|
|
|
|
|
if (dataDict && enumList && fieldList && enumList.length && fieldList.length) {
|
|
|
|
|
fieldList.forEach(field => {
|
|
|
|
|
enumList.forEach(elem => {
|
|
|
|
|
if (elem[key] === dataDict[field]) {
|
|
|
|
|
dataDict[field] = elem[value];
|
|
|
|
|
}
|
|
|
|
|
});
|
|
|
|
|
});
|
|
|
|
|
}
|
2019-10-22 13:41:23 +08:00
|
|
|
|
};
|
2019-08-13 16:59:38 +08:00
|
|
|
|
|
2019-08-08 18:34:35 +08:00
|
|
|
|
Vue.prototype.$convertList = function(FromList, ToList, checktypeFunction) {
|
|
|
|
|
if (FromList) {
|
|
|
|
|
ToList.length = 0;
|
|
|
|
|
FromList.forEach(elem => {
|
|
|
|
|
if (checktypeFunction(elem)) {
|
|
|
|
|
ToList.push({ value: elem.code, label: elem.name });
|
|
|
|
|
}
|
|
|
|
|
});
|
|
|
|
|
}
|
|
|
|
|
};
|