12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879 |
- <template>
- <el-form
- ref="form"
- :model="form"
- label-width="80px"
- @submit.stop.native="submit"
- >
- <el-form-item
- label="相册名称"
- prop="name"
- :rules="[{required: true, message: '请输入相册名称'}]"
- >
- <el-input v-model="form.name" placeholder="请输入相册名称"/>
- </el-form-item>
- <div class="dialog-footer">
- <el-button @click="$emit('close')">取 消</el-button>
- <el-button
- type="primary"
- native-type="submit"
- >确 定</el-button>
- </div>
- </el-form>
- </template>
- <script>
- import { photoAlbumAdd, photoAlbumUpdate } from '../api'
- export default {
- props: {
- detail: {
- type: Object,
- }
- },
- data() {
- return {
- form: {
- name: ''
- }
- }
- },
- mounted() {
- if (this.detail) {
- this.form.name = this.detail.name
- }
- },
- methods: {
- async submit(evt) {
- evt.stopPropagation()
- evt.stopImmediatePropagation()
- evt.preventDefault()
- this.$refs.form.validate(async (valid) => {
- if (valid) {
- try {
- if (this.detail) {
- await photoAlbumUpdate({
- ...this.form,
- musicGroupId: this.$route.query.id,
- id: this.detail.id
- })
- this.$message.success('修改成功')
- } else {
- await photoAlbumAdd({
- ...this.form,
- musicGroupId: this.$route.query.id
- })
- this.$message.success('添加成功')
- }
- this.$emit('close')
- this.$emit('submited')
- } catch (error) {}
- }
- })
- },
- }
- }
- </script>
- <style lang="less" scoped>
- .dialog-footer{
- text-align: right;
- }
- </style>
|