mirror of
https://github.com/Kuingsmile/PicList.git
synced 2026-05-30 12:40:02 +08:00
Added: plugin config save
This commit is contained in:
@@ -9,10 +9,10 @@
|
||||
>
|
||||
<el-form-item
|
||||
v-for="(item, index) in configList"
|
||||
:key="index"
|
||||
:label="item.name"
|
||||
:required="item.required"
|
||||
:prop="item.name"
|
||||
:key="item.name + index"
|
||||
>
|
||||
<el-input
|
||||
v-if="item.type === 'input' || item.type === 'password'"
|
||||
@@ -44,6 +44,7 @@
|
||||
</div>
|
||||
</template>
|
||||
<script>
|
||||
import { cloneDeep } from 'lodash'
|
||||
export default {
|
||||
name: 'config-form',
|
||||
props: {
|
||||
@@ -58,23 +59,36 @@ export default {
|
||||
}
|
||||
},
|
||||
created () {
|
||||
this.configList = JSON.parse(JSON.stringify(this.config)).map(item => {
|
||||
this.configList = cloneDeep(this.config).map(item => {
|
||||
const defaultValue = item.default !== undefined ? item.default : null
|
||||
this.$set(this.ruleForm, item.name, defaultValue)
|
||||
return item
|
||||
})
|
||||
},
|
||||
mounted () {
|
||||
console.log(this.$refs.form)
|
||||
watch: {
|
||||
config: {
|
||||
deep: true,
|
||||
handler (val) {
|
||||
this.ruleForm = Object.assign({}, {})
|
||||
this.configList = cloneDeep(val).map(item => {
|
||||
const defaultValue = item.default !== undefined ? item.default : null
|
||||
this.$set(this.ruleForm, item.name, defaultValue)
|
||||
return item
|
||||
})
|
||||
}
|
||||
}
|
||||
},
|
||||
methods: {
|
||||
validate () {
|
||||
this.$refs.form.validate(valid => {
|
||||
if (valid) {
|
||||
console.log(this.ruleForm)
|
||||
} else {
|
||||
return false
|
||||
}
|
||||
async validate () {
|
||||
return new Promise((resolve, reject) => {
|
||||
this.$refs.form.validate(valid => {
|
||||
if (valid) {
|
||||
resolve(this.ruleForm)
|
||||
} else {
|
||||
resolve(false)
|
||||
return false
|
||||
}
|
||||
})
|
||||
})
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user