目录代码整合
This commit is contained in:
132
packages/conv/AppConvenienceAddressBook/components/Add.vue
Normal file
132
packages/conv/AppConvenienceAddressBook/components/Add.vue
Normal file
@@ -0,0 +1,132 @@
|
||||
<template>
|
||||
<ai-detail>
|
||||
<template slot="title">
|
||||
<ai-title :title="params.id ? '编辑通讯录' : '添加通讯录'" isShowBack isShowBottomBorder @onBackClick="cancel(false)">
|
||||
</ai-title>
|
||||
</template>
|
||||
<template slot="content">
|
||||
<ai-card title="基本信息">
|
||||
<template #content>
|
||||
<el-form ref="CBookForm" class="ai-form" :model="form" label-width="110px" label-position="right">
|
||||
<el-form-item label="地区" style="width: 100%;" prop="codeName">
|
||||
<span style="color: #666;">{{ form.areaName }}</span>
|
||||
</el-form-item>
|
||||
<el-form-item style="width: 100%" label="名称" prop="name" :rules="[{ required: true, message: '请输入名称', trigger: 'blur' }]">
|
||||
<el-input size="small" placeholder="请输入名称" show-word-limit v-model="form.name" :maxlength="30"></el-input>
|
||||
</el-form-item>
|
||||
<el-form-item style="width: 100%" label="类型" prop="type" :rules="[{ required: true, message: '请输入类型', trigger: 'change' }]">
|
||||
<el-input size="small" placeholder="请输入类型" v-model="form.type"></el-input>
|
||||
</el-form-item>
|
||||
<el-form-item style="width: 100%" label="电话" prop="phone" :rules="[{required: true, validator: regPhone, trigger: 'blur' }]">
|
||||
<el-input size="small" placeholder="请输入电话" show-word-limit maxlength="11" v-model="form.phone"></el-input>
|
||||
</el-form-item>
|
||||
<el-form-item style="width: 100%;" label="是否公开" prop="isPublic" :rules="[{ required: true, message: '请选择是否公开', trigger: 'change' }]">
|
||||
<el-radio-group v-model="form.isPublic">
|
||||
<el-radio label="1">是</el-radio>
|
||||
<el-radio label="0">否</el-radio>
|
||||
</el-radio-group>
|
||||
</el-form-item>
|
||||
</el-form>
|
||||
</template>
|
||||
</ai-card>
|
||||
</template>
|
||||
<template #footer>
|
||||
<el-button @click="cancel">取消</el-button>
|
||||
<el-button type="primary" @click="confirm">提交</el-button>
|
||||
</template>
|
||||
</ai-detail>
|
||||
</template>
|
||||
|
||||
<script>
|
||||
export default {
|
||||
name: 'Add',
|
||||
|
||||
props: {
|
||||
instance: Function,
|
||||
dict: Object,
|
||||
params: Object
|
||||
},
|
||||
|
||||
data () {
|
||||
var regPhone = (rule, value, callback) => {
|
||||
if (!value) {
|
||||
return callback(new Error('请输入电话'))
|
||||
} else {
|
||||
const reg = /^[0-9]{3,11}$/
|
||||
if (reg.test(value)) {
|
||||
callback()
|
||||
} else {
|
||||
return callback(new Error('请输入正确的电话号码'))
|
||||
}
|
||||
}
|
||||
}
|
||||
return {
|
||||
info: {},
|
||||
form: {
|
||||
areaId: '',
|
||||
name: '',
|
||||
areaName: '',
|
||||
phone: '',
|
||||
isPublic: '1',
|
||||
type: '',
|
||||
},
|
||||
id: '',
|
||||
regPhone,
|
||||
}
|
||||
},
|
||||
|
||||
created () {
|
||||
if (this.params && this.params.areaId && !this.params.id) {
|
||||
this.form.areaId = this.params.areaId
|
||||
this.form.areaName = this.params.areaName
|
||||
}
|
||||
|
||||
if (this.params && this.params.id) {
|
||||
this.id = this.params.id
|
||||
this.getInfo(this.params.id)
|
||||
}
|
||||
},
|
||||
|
||||
methods: {
|
||||
getInfo (id) {
|
||||
this.instance.post(`/app/appconvenientaddressbook/queryDetailById?id=${id}`).then(res => {
|
||||
if (res?.data) {
|
||||
this.form = res.data
|
||||
}
|
||||
})
|
||||
},
|
||||
|
||||
onClose () {
|
||||
this.form.explain = ''
|
||||
},
|
||||
|
||||
confirm () {
|
||||
this.$refs.CBookForm.validate((valid) => {
|
||||
if (valid) {
|
||||
this.instance.post(`/app/appconvenientaddressbook/addOrUpdate`, {
|
||||
...this.form,
|
||||
id: this.params.id || ''
|
||||
}).then(res => {
|
||||
if (res.code == 0) {
|
||||
this.$message.success('提交成功')
|
||||
setTimeout(() => {
|
||||
this.cancel(true)
|
||||
}, 600)
|
||||
}
|
||||
})
|
||||
}
|
||||
})
|
||||
},
|
||||
|
||||
cancel (isRefresh) {
|
||||
this.$emit('change', {
|
||||
type: 'list',
|
||||
isRefresh: !!isRefresh
|
||||
})
|
||||
}
|
||||
}
|
||||
}
|
||||
</script>
|
||||
|
||||
<style scoped lang="scss">
|
||||
</style>
|
||||
Reference in New Issue
Block a user