|
@@ -0,0 +1,125 @@
|
|
|
+<template>
|
|
|
+ <div id="index">
|
|
|
+ <el-row>
|
|
|
+ <el-col :span="24" class="info">
|
|
|
+ <el-col :span="24" class="top">
|
|
|
+ <topInfo :topTitle="topTitle"></topInfo>
|
|
|
+ </el-col>
|
|
|
+ <el-col :span="24" class="search" style="text-align:right">
|
|
|
+ <el-button size="mini" type="primary" @click="toAdd" icon="el-icon-plus">添加礼物</el-button>
|
|
|
+ </el-col>
|
|
|
+ <el-col :span="24" class="main">
|
|
|
+ <!-- <mainData :tableData="tableData" :total="total" @delete="deleteData"></mainData> -->
|
|
|
+ <data-table :fields="fields" @delete="toDelete" :data="list" :opera="opera" @edit="toEdit" :total="total" @query="search"></data-table>
|
|
|
+ </el-col>
|
|
|
+ </el-col>
|
|
|
+ </el-row>
|
|
|
+ <el-drawer title=";礼物信息" :visible.sync="drawer" direction="rtl" @closed="handleClose" :destroy-on-close="true">
|
|
|
+ <data-form :fields="fields" :data="form" :rules="{}" @save="drawerSave" :isNew="drawerIsNew"></data-form>
|
|
|
+ </el-drawer>
|
|
|
+ </div>
|
|
|
+</template>
|
|
|
+
|
|
|
+<script>
|
|
|
+import topInfo from '@/layout/public/top.vue';
|
|
|
+import dataForm from '@/components/form.vue';
|
|
|
+import dataTable from '@/components/data-table.vue';
|
|
|
+import { mapActions, mapState, createNamespacedHelpers } from 'vuex';
|
|
|
+const { mapActions: present } = createNamespacedHelpers('present');
|
|
|
+export default {
|
|
|
+ name: 'index',
|
|
|
+ props: {},
|
|
|
+ components: {
|
|
|
+ topInfo, //头部标题
|
|
|
+ dataTable,
|
|
|
+ dataForm,
|
|
|
+ },
|
|
|
+ data: () => ({
|
|
|
+ drawer: false,
|
|
|
+ form: {},
|
|
|
+ drawerIsNew: true,
|
|
|
+ topTitle: '礼物管理',
|
|
|
+ opera: [
|
|
|
+ {
|
|
|
+ label: '编辑',
|
|
|
+ icon: 'el-icon-edit',
|
|
|
+ method: 'edit',
|
|
|
+ },
|
|
|
+ {
|
|
|
+ label: '删除',
|
|
|
+ icon: 'el-icon-delete',
|
|
|
+ method: 'delete',
|
|
|
+ confirm: true,
|
|
|
+ },
|
|
|
+ ],
|
|
|
+ fields: [
|
|
|
+ { label: '礼物', prop: 'name', model: 'name', filter: 'input' },
|
|
|
+ { label: '金额', prop: 'price', model: 'price' },
|
|
|
+ ],
|
|
|
+ list: [],
|
|
|
+ total: 0,
|
|
|
+ }),
|
|
|
+ created() {
|
|
|
+ this.search();
|
|
|
+ },
|
|
|
+ computed: {},
|
|
|
+ methods: {
|
|
|
+ ...present(['query', 'delete', 'update', 'create']),
|
|
|
+ async search({ skip = 0, limit = 10, ...info } = {}) {
|
|
|
+ const res = await this.query({ skip, limit, ...info });
|
|
|
+ if (this.$checkRes(res)) {
|
|
|
+ this.$set(this, `list`, res.data);
|
|
|
+ this.$set(this, `total`, res.total);
|
|
|
+ }
|
|
|
+ },
|
|
|
+ toAdd() {
|
|
|
+ this.drawer = true;
|
|
|
+ },
|
|
|
+ toEdit({ data }) {
|
|
|
+ this.$set(this, 'form', data);
|
|
|
+ this.drawer = true;
|
|
|
+ this.drawerIsNew = false;
|
|
|
+ },
|
|
|
+ async drawerSave({ data, isNew }) {
|
|
|
+ let res;
|
|
|
+ let msg;
|
|
|
+ if (isNew) {
|
|
|
+ res = await this.create(data);
|
|
|
+ msg = '礼物创建成功';
|
|
|
+ } else {
|
|
|
+ res = await this.update(data);
|
|
|
+ msg = '礼物修改成功';
|
|
|
+ }
|
|
|
+ if (this.$checkRes(res, msg, res.errmsg)) {
|
|
|
+ this.handleClose();
|
|
|
+ this.search();
|
|
|
+ }
|
|
|
+ },
|
|
|
+ handleClose() {
|
|
|
+ this.drawer = false;
|
|
|
+ this.form = {};
|
|
|
+ this.drawerIsNew = true;
|
|
|
+ },
|
|
|
+ async toDelete({ data }) {
|
|
|
+ const res = await this.delete(data.id);
|
|
|
+ if (this.$checkRes(res, '删除成功', res.errmsg || '删除失败')) this.search();
|
|
|
+ },
|
|
|
+ },
|
|
|
+};
|
|
|
+</script>
|
|
|
+
|
|
|
+<style lang="less" scoped>
|
|
|
+.top {
|
|
|
+ height: 40px;
|
|
|
+ background-color: #f5f5f5;
|
|
|
+}
|
|
|
+.search {
|
|
|
+ height: 40px;
|
|
|
+ line-height: 40px;
|
|
|
+ padding: 0 15px;
|
|
|
+}
|
|
|
+.main {
|
|
|
+ width: 97%;
|
|
|
+ margin: 0 15px;
|
|
|
+}
|
|
|
+</style>
|