forked from macrozheng/mall-admin-web
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
zhh
committed
May 16, 2018
1 parent
da35f6d
commit 5f6f46c
Showing
9 changed files
with
468 additions
and
120 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 |
---|---|---|
@@ -0,0 +1,14 @@ | ||
<template> | ||
<brand-detail :is-edit='false'></brand-detail> | ||
</template> | ||
<script> | ||
import brandDetail from './components/brandDetail' | ||
export default { | ||
name: 'addBrand', | ||
components: { brandDetail } | ||
} | ||
</script> | ||
<style> | ||
</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,143 @@ | ||
<template> | ||
<div class="form-container container-frame"> | ||
<el-form :model="brand" :rules="rules" ref="brandFrom" label-width="150px"> | ||
<el-form-item label="品牌名称:" prop="name"> | ||
<el-input v-model="brand.name"></el-input> | ||
</el-form-item> | ||
<el-form-item label="品牌首字母:"> | ||
<el-input v-model="brand.firstLetter"></el-input> | ||
</el-form-item> | ||
<el-form-item label="品牌LOGO:" prop="logo"> | ||
<el-input v-model="brand.logo"></el-input> | ||
</el-form-item> | ||
<el-form-item label="品牌专区大图:"> | ||
<el-input v-model="brand.bigPic"></el-input> | ||
</el-form-item> | ||
<el-form-item label="品牌故事:"> | ||
<el-input | ||
placeholder="请输入内容" | ||
type="textarea" | ||
v-model="brand.brandStory" | ||
autosize="true"></el-input> | ||
</el-form-item> | ||
<el-form-item label="排序:" prop="sort"> | ||
<el-input v-model.number="brand.sort"></el-input> | ||
</el-form-item> | ||
<el-form-item label="是否显示:"> | ||
<el-radio-group v-model="brand.showStatus"> | ||
<el-radio :label="1">是</el-radio> | ||
<el-radio :label="0">否</el-radio> | ||
</el-radio-group> | ||
</el-form-item> | ||
<el-form-item label="品牌制造商:"> | ||
<el-radio-group v-model="brand.factoryStatus"> | ||
<el-radio :label="1">是</el-radio> | ||
<el-radio :label="0">否</el-radio> | ||
</el-radio-group> | ||
</el-form-item> | ||
<el-form-item> | ||
<el-button type="primary" @click="onSubmit('brandFrom')">提交</el-button> | ||
<el-button v-if="!isEdit" @click="resetForm('brandFrom')">重置</el-button> | ||
</el-form-item> | ||
</el-form> | ||
</div> | ||
</template> | ||
<script> | ||
import {createBrand, getBrand, updateBrand} from '@/api/brand' | ||
export default { | ||
name: 'brandDetail', | ||
props: { | ||
isEdit: { | ||
type: Boolean, | ||
default: false | ||
} | ||
}, | ||
data() { | ||
return { | ||
brand: { | ||
bigPic: '', | ||
brandStory: '', | ||
factoryStatus: 0, | ||
firstLetter: '', | ||
logo: '', | ||
name: '', | ||
showStatus: 0, | ||
sort: 0 | ||
}, | ||
rules: { | ||
name: [ | ||
{required: true, message: '请输入品牌名称', trigger: 'blur'}, | ||
{min: 2, max: 140, message: '长度在 2 到 140 个字符', trigger: 'blur'} | ||
], | ||
logo: [ | ||
{required: true, message: '请输入品牌logo', trigger: 'blur'} | ||
], | ||
sort: [ | ||
{type: 'number', message: '排序必须为数字'} | ||
] | ||
} | ||
} | ||
}, | ||
created() { | ||
if (this.isEdit) { | ||
getBrand(this.$route.query.id).then(response => { | ||
this.brand = response.data; | ||
}); | ||
} | ||
}, | ||
methods: { | ||
onSubmit(formName) { | ||
this.$refs[formName].validate((valid) => { | ||
if (valid) { | ||
this.$confirm('是否提交数据', '提示', { | ||
confirmButtonText: '确定', | ||
cancelButtonText: '取消', | ||
type: 'warning' | ||
}).then(() => { | ||
if (this.isEdit) { | ||
updateBrand(this.$route.query.id, this.brand).then(response => { | ||
this.$refs[formName].resetFields(); | ||
this.$message({ | ||
message: '修改成功', | ||
type: 'success' | ||
}); | ||
}); | ||
} else { | ||
createBrand(this.brand).then(response => { | ||
this.$refs[formName].resetFields(); | ||
this.$message({ | ||
message: '提交成功', | ||
type: 'success' | ||
}); | ||
}); | ||
} | ||
}); | ||
} else { | ||
this.$message({ | ||
message: '验证失败', | ||
type: 'error' | ||
}); | ||
return false; | ||
} | ||
}); | ||
}, | ||
resetForm(formName) { | ||
this.$refs[formName].resetFields(); | ||
} | ||
} | ||
} | ||
</script> | ||
<style> | ||
.form-container { | ||
position: absolute; | ||
left: 0; | ||
right: 0; | ||
width: 520px; | ||
padding: 35px 35px 15px 35px; | ||
margin: 20px auto; | ||
} | ||
</style> | ||
|
||
|
Oops, something went wrong.