-
Notifications
You must be signed in to change notification settings - Fork 4
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge branch 'master' of github.com:szuprefix/vue-django
- Loading branch information
Showing
18 changed files
with
302 additions
and
125 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,35 +1,48 @@ | ||
<template> | ||
<span class="el-input-group" style="width:6rem;"> | ||
<el-input-number v-model="number" :controls="false" style="width:6rem;" | ||
@change="onChange"></el-input-number><span class="el-input-group__append">%</span> | ||
@change="onChange"></el-input-number><span class="el-input-group__append percent-input">%</span> | ||
</span> | ||
</template> | ||
<script> | ||
import {options_without_time} from '../../../utils/date_picker_options' | ||
import dateUtil from 'element-ui/src/utils/date' | ||
export default{ | ||
props: { | ||
value: String, | ||
field: Object | ||
}, | ||
data () { | ||
return { | ||
number: this.value * 100 | ||
number: 0 | ||
} | ||
}, | ||
components: {}, | ||
created () { | ||
this.number = this.value * 100 | ||
this.calNumber(this.value) | ||
}, | ||
methods: { | ||
calNumber (v) { | ||
this.number = (v * 100).toFixed(this.fixed) | ||
}, | ||
onChange(v) { | ||
this.$emit('input', v / 100) | ||
let rv = (v / 100).toFixed(this.fixed+2) | ||
this.calNumber(rv) | ||
this.$emit('input', rv) | ||
} | ||
}, | ||
computed: { | ||
fixed () { | ||
return this.field.fixed || 2 | ||
} | ||
}, | ||
watch: { | ||
value (v) { | ||
this.number = this.value * 100 | ||
this.calNumber(v) | ||
} | ||
} | ||
} | ||
</script> | ||
<style> | ||
.el-input-group__append.percent-input{ | ||
padding: 0 10px; | ||
} | ||
</style> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,40 @@ | ||
<template> | ||
<el-select v-model="tags" multiple placeholder="请选择"> | ||
<el-option | ||
v-for="item in field.tags" | ||
:key="item" | ||
:label="item" | ||
:value="item"> | ||
</el-option> | ||
</el-select> | ||
</template> | ||
<script> | ||
export default{ | ||
props: { | ||
value: String, | ||
field: Object | ||
}, | ||
data () { | ||
return { | ||
tags: [] | ||
} | ||
}, | ||
components: {}, | ||
created () { | ||
this.tags = this.value.split(',').filter(a => a.trim().length>0) | ||
}, | ||
methods: { | ||
onChange(v) { | ||
this.$emit('input', v / 100) | ||
} | ||
}, | ||
watch: { | ||
value (v) { | ||
this.tags = this.value.split(',').filter(a => a.trim().length>0) | ||
}, | ||
tags () { | ||
this.$emit('input', this.tags.join(',')) | ||
} | ||
} | ||
} | ||
</script> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,99 @@ | ||
<template> | ||
<json-display v-model="value" :field="jsonField" v-if="loaded"></json-display> | ||
</template> | ||
<script> | ||
import Model from './Model' | ||
import ServerResponse from '../../mixins/server_response' | ||
import arrayNormalize from '../../utils/array_normalize' | ||
import JsonDisplay from '../widgets/JsonDisplay.vue' | ||
import {get} from 'lodash' | ||
export default{ | ||
mixins: [ServerResponse], | ||
components: {JsonDisplay}, | ||
props: { | ||
appModel: String, | ||
items: Array, | ||
value: Object, | ||
field: Object | ||
}, | ||
data () { | ||
return { | ||
mid: undefined, | ||
formItems: [], | ||
formValue: {}, | ||
loaded : false, | ||
model: Model(this.appModel || this.field.model, this.defaults, this.$store.state.bus) | ||
} | ||
}, | ||
created () { | ||
this.init() | ||
this.$on("model-delete", this.onDelete) | ||
}, | ||
methods: { | ||
init(){ | ||
this.mid = this.model.id = this.getId() | ||
this.model.load().then((data, options) => { | ||
this.mid = this.model.id | ||
this.formValue = Object.assign({}, this.model.data) | ||
this.normalizeItems() | ||
this.loaded = true | ||
this.$emit('loaded', this.model) | ||
}).catch(this.onServerResponseError) | ||
}, | ||
getId(){ | ||
let id = this.value && this.value.id || | ||
this.$route.path.startsWith(this.model.getListUrl()) && this.$route.params.id | ||
|| undefined | ||
return id === 'create' ? undefined : id | ||
}, | ||
defaultWidget (f) { | ||
if (f.type == 'field' && f.model) { | ||
return RelatedSelect | ||
} else if (['field', 'choice'].includes(f.type) && f.choices) { | ||
return f.choices.length <= 2 ? (f.multiple ? 'checkbox' : 'radio') : 'select' | ||
} | ||
}, | ||
getItems () { | ||
if (this.items) { | ||
return Promise.resolve(this.items) | ||
} | ||
return import(`@/views${this.model.getListUrl()}config.js`).then(m => { | ||
let c = m.default | ||
return this.mid && c.update || c.create || c.form || {} | ||
}).catch(() => { | ||
return {} | ||
}).then(config => { | ||
return config.items || Object.values(this.model.options.actions.POST).filter(a => a.read_only !== true) | ||
}) | ||
}, | ||
normalizeItems() { | ||
this.getItems().then(items => { | ||
this.formItems = arrayNormalize(items, this.model.fieldConfigs) | ||
}) | ||
}, | ||
clear () { | ||
this.model.clear() | ||
this.mid = this.model.id = undefined | ||
this.formValue = Object.assign({}, this.model.data, this.defaults) | ||
this.$nextTick(this.$refs.form.$refs.form.clearValidate) | ||
}, | ||
}, | ||
computed: { | ||
jsonField () { | ||
return {...this.field, items: this.formItems} | ||
} | ||
}, | ||
watch: { | ||
value(val){ | ||
this.formValue = val | ||
}, | ||
formValue(val){ | ||
this.model.data = val | ||
}, | ||
items () { | ||
this.normalizeItems() | ||
} | ||
} | ||
} | ||
</script> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.