|
@@ -2,39 +2,44 @@
|
|
<el-form
|
|
<el-form
|
|
v-bind="{...$attrs, ...$props}"
|
|
v-bind="{...$attrs, ...$props}"
|
|
v-on="$listeners"
|
|
v-on="$listeners"
|
|
|
|
+ ref="form"
|
|
>
|
|
>
|
|
<slot/>
|
|
<slot/>
|
|
</el-form>
|
|
</el-form>
|
|
</template>
|
|
</template>
|
|
<script>
|
|
<script>
|
|
-import { saveToStorage, getSearchs } from '@/helpers'
|
|
|
|
|
|
+import { saveToStorage, getSearchs, Searchs } from '@/helpers'
|
|
export default {
|
|
export default {
|
|
name: 'save-form',
|
|
name: 'save-form',
|
|
props: ['model'],
|
|
props: ['model'],
|
|
|
|
+ data() {
|
|
|
|
+ return {
|
|
|
|
+ searchs: null
|
|
|
|
+ }
|
|
|
|
+ },
|
|
mounted() {
|
|
mounted() {
|
|
- const searchs = getSearchs(this.$route.fullPath)
|
|
|
|
- for (const key in searchs) {
|
|
|
|
- if (searchs.hasOwnProperty(key)) {
|
|
|
|
- const item = searchs[key]
|
|
|
|
|
|
+ const searchs = new Searchs(this.$route.fullPath)
|
|
|
|
+ this.searchs = searchs
|
|
|
|
+ const active = searchs.get()
|
|
|
|
+ for (const key in active.form) {
|
|
|
|
+ if (active.form.hasOwnProperty(key)) {
|
|
|
|
+ const item = active.form[key]
|
|
this.model[key] = item
|
|
this.model[key] = item
|
|
}
|
|
}
|
|
}
|
|
}
|
|
- console.log(this)
|
|
|
|
- console.log(getSearchs(this.$route.fullPath))
|
|
|
|
},
|
|
},
|
|
methods: {
|
|
methods: {
|
|
validate(FC) {
|
|
validate(FC) {
|
|
this.$refs.form.validate(valid => {
|
|
this.$refs.form.validate(valid => {
|
|
FC(valid)
|
|
FC(valid)
|
|
if (valid) {
|
|
if (valid) {
|
|
- console.log(this.$route, this.model)
|
|
|
|
- saveToStorage(this.$route.fullPath, this.model)
|
|
|
|
|
|
+ this.searchs.update(this.model, undefined, 'form')
|
|
}
|
|
}
|
|
})
|
|
})
|
|
},
|
|
},
|
|
resetFields() {
|
|
resetFields() {
|
|
this.$refs.form.resetFields()
|
|
this.$refs.form.resetFields()
|
|
- saveToStorage(this.$route.fullPath, this.model)
|
|
|
|
|
|
+ this.searchs.update(this.model, undefined, 'form')
|
|
}
|
|
}
|
|
},
|
|
},
|
|
}
|
|
}
|