rev:出入库流程兼容
This commit is contained in:
33
wms_pro/qd/src/components/TableEnum/TableEnum.js
Normal file
33
wms_pro/qd/src/components/TableEnum/TableEnum.js
Normal file
@@ -0,0 +1,33 @@
|
||||
import Vue from 'vue'
|
||||
import { tableEnum as getEnumDetail } from '@/views/system/dict/enumDetail'
|
||||
|
||||
export default class TableEnum {
|
||||
constructor(tableEnum) {
|
||||
this.tableEnum = tableEnum
|
||||
}
|
||||
|
||||
async init(names, completeCallback) {
|
||||
if (names === undefined || name === null) {
|
||||
throw new Error('need TableEnum names')
|
||||
}
|
||||
const ps = []
|
||||
names.forEach(n => {
|
||||
let split = n.split('#');
|
||||
let code = split[0];
|
||||
let label = split[1];
|
||||
let value = split[2];
|
||||
Vue.set(this.tableEnum.tableEnum, code, {})
|
||||
Vue.set(this.tableEnum.label, code, {})
|
||||
Vue.set(this.tableEnum, code, [])
|
||||
ps.push(getEnumDetail({'code':code,'label':label,'value':value}).then(data => {
|
||||
this.tableEnum[code].splice(0, 0, ...data)
|
||||
data.forEach(d => {
|
||||
Vue.set(this.tableEnum.tableEnum[code], d.value, d)
|
||||
Vue.set(this.tableEnum.label[code], d.value, d.label)
|
||||
})
|
||||
}))
|
||||
})
|
||||
await Promise.all(ps)
|
||||
completeCallback()
|
||||
}
|
||||
}
|
||||
29
wms_pro/qd/src/components/TableEnum/index.js
Normal file
29
wms_pro/qd/src/components/TableEnum/index.js
Normal file
@@ -0,0 +1,29 @@
|
||||
import TableEnum from './TableEnum'
|
||||
|
||||
const install = function(Vue) {
|
||||
Vue.mixin({
|
||||
data() {
|
||||
if (this.$options.tableEnums instanceof Array) {
|
||||
const tableEnum = {
|
||||
tableEnum: {},
|
||||
label: {}
|
||||
}
|
||||
return {
|
||||
tableEnum
|
||||
}
|
||||
}
|
||||
return {}
|
||||
},
|
||||
created() {
|
||||
if (this.$options.tableEnums instanceof Array) {
|
||||
new TableEnum(this.tableEnum).init(this.$options.tableEnums, () => {
|
||||
this.$nextTick(() => {
|
||||
this.$emit('dictReady')
|
||||
})
|
||||
})
|
||||
}
|
||||
}
|
||||
})
|
||||
}
|
||||
|
||||
export default { install }
|
||||
Reference in New Issue
Block a user