配置
This commit is contained in:
@@ -15,6 +15,19 @@
|
||||
</el-form-item>
|
||||
</el-form>
|
||||
|
||||
<el-row :gutter="10" class="mb8">
|
||||
<el-col :span="1.5">
|
||||
<el-button
|
||||
type="primary"
|
||||
plain
|
||||
icon="el-icon-plus"
|
||||
size="mini"
|
||||
@click="handleAdd"
|
||||
>新增</el-button>
|
||||
</el-col>
|
||||
<right-toolbar :showSearch.sync="showSearch" @queryTable="getList"></right-toolbar>
|
||||
</el-row>
|
||||
|
||||
<el-table v-loading="loading" :data="giftList" @selection-change="handleSelectionChange">
|
||||
<!-- <el-table-column type="selection" width="55" align="center"/>-->
|
||||
<el-table-column label="礼物ID" align="center" prop="id" v-if="true"/>
|
||||
@@ -96,6 +109,13 @@ export default {
|
||||
this.getList();
|
||||
},
|
||||
methods: {
|
||||
/** 新增按钮操作 */
|
||||
handleAdd() {
|
||||
this.updateGiftDialogVisible = true
|
||||
this.$nextTick(() => {
|
||||
this.$refs.updateGiftDialog.init()
|
||||
})
|
||||
},
|
||||
handleUpdate(row){
|
||||
this.updateGiftDialogVisible = true
|
||||
this.$nextTick(() => {
|
||||
|
||||
@@ -2,7 +2,10 @@
|
||||
<el-dialog :title="title" :close-on-click-modal="false" :visible.sync="open" width="700px" append-to-body>
|
||||
<el-form ref="form" :model="form" :rules="rules" label-width="120px">
|
||||
<el-form-item label="礼物图片" prop="img">
|
||||
<image-preview :src="form.img" :width="50" :height="50"/>
|
||||
<image-upload2 v-model="form.img"/>
|
||||
</el-form-item>
|
||||
<el-form-item label="动态文件" prop="svga">
|
||||
<file-upload v-model="form.svga" :file-size="50" :file-type="['svga']" :limit="1"/>
|
||||
</el-form-item>
|
||||
<el-form-item label="礼物名称" prop="name">
|
||||
<el-input v-model="form.name" />
|
||||
@@ -10,6 +13,9 @@
|
||||
<el-form-item label="礼物价格" prop="price">
|
||||
<el-input v-model="form.price" />
|
||||
</el-form-item>
|
||||
<el-form-item label="描述" prop="desc">
|
||||
<el-input v-model="form.desc" />
|
||||
</el-form-item>
|
||||
<el-form-item label="排序" prop="sort">
|
||||
<el-input v-model="form.sort" />
|
||||
</el-form-item>
|
||||
@@ -24,7 +30,7 @@
|
||||
<script>
|
||||
import ImageUpload from '@/components/ImageUpload/index'
|
||||
import {getAnchor, updateAnchor} from "@/api/cai/anchor";
|
||||
import {getGift, updateGift} from "@/api/cai/gift";
|
||||
import {addGift, getGift, updateGift} from "@/api/cai/gift";
|
||||
|
||||
export default {
|
||||
components: {
|
||||
@@ -39,6 +45,8 @@ export default {
|
||||
id: undefined,
|
||||
img: undefined,
|
||||
name: undefined,
|
||||
desc: undefined,
|
||||
svga: undefined,
|
||||
price: undefined,
|
||||
sort: undefined,
|
||||
},
|
||||
@@ -61,15 +69,17 @@ export default {
|
||||
},
|
||||
methods: {
|
||||
init (row) {
|
||||
let id = row.id
|
||||
let id = row ? row.id : undefined;
|
||||
this.form.id = id || undefined;
|
||||
this.title = "修改礼物信息";
|
||||
this.title = id ? "修改礼物信息" : "新增礼物信息";
|
||||
this.open = true;
|
||||
this.$nextTick(() => {
|
||||
this.$refs['form'].resetFields();
|
||||
getGift(id).then(response => {
|
||||
this.form = response.data;
|
||||
});
|
||||
if(this.form.id){
|
||||
getGift(id).then(response => {
|
||||
this.form = response.data;
|
||||
});
|
||||
}
|
||||
})
|
||||
},
|
||||
// 表单提交
|
||||
@@ -77,19 +87,32 @@ export default {
|
||||
this.$refs['form'].validate((valid) => {
|
||||
if (valid) {
|
||||
this.buttonLoading = true;
|
||||
updateGift({
|
||||
id: this.form.id,
|
||||
name: this.form.name,
|
||||
price: this.form.price,
|
||||
sort: this.form.sort,
|
||||
}).then(data => {
|
||||
this.$modal.msgSuccess("修改成功");
|
||||
this.buttonLoading = false;
|
||||
this.open = false
|
||||
this.$emit('refreshDataList')
|
||||
}).finally(() => {
|
||||
this.buttonLoading = false;
|
||||
});
|
||||
if (this.form.id != null) {
|
||||
updateGift({
|
||||
id: this.form.id,
|
||||
name: this.form.name,
|
||||
price: this.form.price,
|
||||
desc: this.form.desc,
|
||||
svga: this.form.svga,
|
||||
sort: this.form.sort,
|
||||
}).then(data => {
|
||||
this.$modal.msgSuccess("修改成功");
|
||||
this.buttonLoading = false;
|
||||
this.open = false
|
||||
this.$emit('refreshDataList')
|
||||
}).finally(() => {
|
||||
this.buttonLoading = false;
|
||||
});
|
||||
}else{
|
||||
addGift(this.form).then(data => {
|
||||
this.$modal.msgSuccess("修改成功");
|
||||
this.buttonLoading = false;
|
||||
this.open = false
|
||||
this.$emit('refreshDataList')
|
||||
}).finally(() => {
|
||||
this.buttonLoading = false;
|
||||
});
|
||||
}
|
||||
}
|
||||
})
|
||||
},
|
||||
|
||||
Reference in New Issue
Block a user