|
@@ -1,7 +1,7 @@
|
|
|
<template>
|
|
|
<div id="form-1">
|
|
|
<el-row>
|
|
|
- <el-col :span="24" class="main">
|
|
|
+ <el-col :span="24" class="main" v-loading="loadings" element-loading-text="拼命加载中" element-loading-spinner="el-icon-loading">
|
|
|
<el-col class="top-btn">
|
|
|
<el-button type="primary" size="mini" @click="toBack()">返回</el-button>
|
|
|
</el-col>
|
|
@@ -9,7 +9,7 @@
|
|
|
<data-search :fields="searchFields" v-model="searchInfo" @query="search"> </data-search>
|
|
|
</el-col>
|
|
|
<el-col class="top-btn">
|
|
|
- <el-button type="warning" size="mini" @click="toGrant()">批量发放</el-button>
|
|
|
+ <el-button type="warning" size="mini" @click="toGrants()">批量发放</el-button>
|
|
|
</el-col>
|
|
|
<el-col :span="24" class="four">
|
|
|
<data-table
|
|
@@ -27,6 +27,11 @@
|
|
|
</el-col>
|
|
|
</el-col>
|
|
|
</el-row>
|
|
|
+ <e-dialog :dialog="dialog" @toClose="toClose">
|
|
|
+ <template v-slot:info>
|
|
|
+ <data-form :fields="infoFields" :rules="rules" v-model="form" labelWidth="150px" @save="onSubmit"> </data-form>
|
|
|
+ </template>
|
|
|
+ </e-dialog>
|
|
|
</div>
|
|
|
</template>
|
|
|
|
|
@@ -36,12 +41,14 @@ const moment = require('moment');
|
|
|
import { mapState, mapGetters, createNamespacedHelpers } from 'vuex';
|
|
|
const { mapActions } = createNamespacedHelpers('users');
|
|
|
const { mapActions: dictData } = createNamespacedHelpers('dictData');
|
|
|
+const { mapActions: giveCoupon } = createNamespacedHelpers('giveCoupon');
|
|
|
export default {
|
|
|
name: 'form-1',
|
|
|
props: { id: { type: String } },
|
|
|
components: {},
|
|
|
data: function () {
|
|
|
return {
|
|
|
+ loadings: true,
|
|
|
// 列表
|
|
|
opera: [{ label: '发放', method: 'grant', confirm: true }],
|
|
|
// 多选值
|
|
@@ -76,10 +83,16 @@ export default {
|
|
|
// 查询
|
|
|
searchInfo: {},
|
|
|
searchFields: [{ label: '用户姓名', model: 'name' }],
|
|
|
+ // 弹框
|
|
|
+ dialog: { title: '信息管理', show: false, type: '1' },
|
|
|
+ form: {},
|
|
|
+ infoFields: [{ label: '发放数量', model: 'num' }],
|
|
|
+ rules: { num: [{ required: true, message: '发放数量', trigger: 'blur' }] },
|
|
|
// 性别
|
|
|
genderList: [],
|
|
|
// 用户状态
|
|
|
useList: [],
|
|
|
+ user: [],
|
|
|
};
|
|
|
},
|
|
|
async created() {
|
|
@@ -89,6 +102,7 @@ export default {
|
|
|
methods: {
|
|
|
...dictData({ dictQuery: 'query' }),
|
|
|
...mapActions(['query', 'delete', 'fetch', 'update', 'create']),
|
|
|
+ ...giveCoupon({ giveCreate: 'create' }),
|
|
|
// 查询
|
|
|
async search({ skip = 0, limit = this.$limit, ...info } = {}) {
|
|
|
let condition = _.cloneDeep(this.searchForm);
|
|
@@ -97,18 +111,42 @@ export default {
|
|
|
this.$set(this, 'list', res.data);
|
|
|
this.$set(this, 'total', res.total);
|
|
|
}
|
|
|
+ this.loadings = false;
|
|
|
},
|
|
|
// 返回
|
|
|
toBack() {
|
|
|
this.$emit('toBack');
|
|
|
},
|
|
|
// 多选
|
|
|
- handleSelect(data) {},
|
|
|
- toGrant() {},
|
|
|
+ handleSelect(data) {
|
|
|
+ let arr = [];
|
|
|
+ for (const p1 of data) {
|
|
|
+ arr.push(p1._id);
|
|
|
+ }
|
|
|
+ this.$set(this, 'user', arr);
|
|
|
+ },
|
|
|
+ toGrant({ data }) {
|
|
|
+ if (data) this.user = [data._id];
|
|
|
+ this.dialog = { title: '信息管理', show: true, type: '1' };
|
|
|
+ },
|
|
|
+ toGrants() {
|
|
|
+ this.dialog = { title: '信息管理', show: true, type: '1' };
|
|
|
+ },
|
|
|
+ async onSubmit({ data }) {
|
|
|
+ data.users = this.user;
|
|
|
+ data.coupon = this.id;
|
|
|
+ let res = await this.giveCreate(data);
|
|
|
+ if (this.$checkRes(res)) {
|
|
|
+ this.$message({ type: `success`, message: `发放成功` });
|
|
|
+ this.toClose();
|
|
|
+ }
|
|
|
+ },
|
|
|
// 重置
|
|
|
toClose() {
|
|
|
- this.fieldform = {};
|
|
|
+ this.form = {};
|
|
|
this.search();
|
|
|
+ this.user = [];
|
|
|
+ this.dialog = { title: '信息管理', show: false, type: '1' };
|
|
|
},
|
|
|
async searchOther() {
|
|
|
let res;
|