2023-06-09 11:34:06 +00:00
|
|
|
<template>
|
2023-06-12 08:26:27 +00:00
|
|
|
<el-drawer :title="titleMap[mode]" v-model="visible" :size="1000" :close-on-press-escape="false" :close-on-click-modal="false" destroy-on-close @closed="$emit('closed')">
|
2023-06-09 11:34:06 +00:00
|
|
|
<el-container v-loading="loading">
|
|
|
|
<el-main style="padding:0 20px 20px 20px">
|
|
|
|
<sc-form ref="formref" :config="config" v-model="info" :loading="loading"> </sc-form>
|
|
|
|
</el-main>
|
|
|
|
<el-footer>
|
|
|
|
<el-button type="primary" :loading="isSaveing" @click="submit">保存</el-button>
|
|
|
|
<el-button @click="visible=false">取消</el-button>
|
|
|
|
</el-footer>
|
|
|
|
</el-container>
|
|
|
|
</el-drawer>
|
|
|
|
</template>
|
|
|
|
|
|
|
|
<script>
|
2023-06-11 14:57:10 +00:00
|
|
|
|
|
|
|
import api from './api'
|
2023-06-09 11:34:06 +00:00
|
|
|
export default {
|
|
|
|
emits: ['success', 'closed'],
|
|
|
|
data() {
|
|
|
|
return {
|
|
|
|
loading: false,
|
|
|
|
visible: false,
|
|
|
|
mode: "add",
|
|
|
|
titleMap: {
|
2023-06-12 15:07:24 +00:00
|
|
|
add: '新增公寓',
|
|
|
|
edit: '编辑公寓'
|
2023-06-09 11:34:06 +00:00
|
|
|
},
|
|
|
|
info:{},
|
2023-06-12 11:22:59 +00:00
|
|
|
id:0,
|
|
|
|
token:null,
|
2023-06-12 15:07:24 +00:00
|
|
|
config:{},
|
2023-06-09 11:34:06 +00:00
|
|
|
}
|
|
|
|
},
|
|
|
|
mounted() {
|
|
|
|
|
|
|
|
},
|
|
|
|
methods: {
|
|
|
|
submit(){
|
2023-06-12 11:22:59 +00:00
|
|
|
this.$refs.formref.validate( async (valid, obj) => {
|
2023-06-09 11:34:06 +00:00
|
|
|
if (valid) {
|
|
|
|
console.log(this.info)
|
2023-06-12 11:22:59 +00:00
|
|
|
|
|
|
|
var res = await api.post('submit', {info:this.info,id:this.id,token:this.token})
|
|
|
|
if (res.code==200) {
|
|
|
|
this.close();
|
|
|
|
this.$message.success("操作成功")
|
|
|
|
return ;
|
|
|
|
}
|
|
|
|
this.$alert(res.message, "提示", {type: 'error'})
|
2023-06-09 11:34:06 +00:00
|
|
|
}else{
|
|
|
|
this.$refs.formref.scrollToField(Object.keys(obj)[0])
|
|
|
|
return false
|
|
|
|
}
|
|
|
|
})
|
|
|
|
},
|
2023-06-11 08:34:56 +00:00
|
|
|
close(){
|
|
|
|
this.visible = false;
|
|
|
|
},
|
2023-06-09 11:34:06 +00:00
|
|
|
//显示
|
|
|
|
open(mode='add'){
|
|
|
|
this.mode = mode;
|
|
|
|
this.visible = true;
|
|
|
|
return this;
|
|
|
|
},
|
|
|
|
setConfig(){
|
|
|
|
var that = this;
|
2023-06-11 14:57:10 +00:00
|
|
|
api.get('config', {}).then((res) => {
|
2023-06-09 11:34:06 +00:00
|
|
|
console.log(res)
|
|
|
|
that.config = res.data;
|
|
|
|
});
|
|
|
|
return this;
|
|
|
|
},
|
|
|
|
//表单注入数据
|
|
|
|
setData(data){
|
|
|
|
this.loading = true
|
|
|
|
const params = {
|
|
|
|
id: data.id,
|
|
|
|
uniqid: data.uniqid,
|
|
|
|
}
|
2023-06-12 11:22:59 +00:00
|
|
|
this.id = data.id;
|
2023-06-09 11:34:06 +00:00
|
|
|
setTimeout(async ()=>{
|
2023-06-11 14:57:10 +00:00
|
|
|
var res = await api.get('info', params)
|
2023-06-09 11:34:06 +00:00
|
|
|
if (res.code==200) {
|
|
|
|
this.loading = false
|
|
|
|
this.info = res.data.info;
|
2023-06-12 11:22:59 +00:00
|
|
|
this.token = res.data.token;
|
2023-06-09 11:34:06 +00:00
|
|
|
return ;
|
|
|
|
}
|
|
|
|
this.$message.warning(res.message)
|
|
|
|
this.visible = false;
|
|
|
|
},400)
|
|
|
|
|
|
|
|
},
|
|
|
|
|
|
|
|
}
|
|
|
|
}
|
|
|
|
</script>
|
|
|
|
|
|
|
|
<style>
|
|
|
|
</style>
|