123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401 |
- <template>
- <div class="subPage">
- <div class="system-table-search">
- <div class="flex-h">
- <div class="flex-item flex-h">
- <el-button size="mini" type="success" @click="addCoupon('')">新增优惠券</el-button>
- <!-- <el-button size="mini" type="success" @click="addCoupon('drink')">新增饮品优惠券</el-button>
- <el-button size="mini" type="success" @click="addCoupon('course')">新增课程优惠券</el-button> -->
- </div>
- <ul>
- <li>
- <!-- <span>选择案场:</span> -->
- <el-select v-model="CaseId" placeholder="请选择案场">
- <el-option
- v-for="item in cases"
- :key="item.CaseId"
- :label="item.CaseName"
- :value="item.CaseId">
- </el-option>
- </el-select>
- </li>
- </ul>
- <el-button
- size="mini"
- type="primary" @click="search">搜索</el-button>
- </div>
- <div class="moreFilter"></div>
- </div>
- <div class="system-table-box">
- <el-table
- :data="couponList.list"
- stripe
- style="width: 100%">
- <el-table-column
- prop="CouponName"
- label="券名称">
- </el-table-column>
- <el-table-column
- prop="CouponType"
- label="券类型">
- <template slot-scope="scope">{{scope.row.CouponType === 'goods' ? '商品券' : '课程券'}}</template>
- </el-table-column>
- <el-table-column
- prop="Price"
- label="券价格">
- </el-table-column>
- <el-table-column
- prop="StartDate"
- label="有效期"
- width="150">
- <template slot-scope="scope">
- <span v-if="scope.row.StartDate.substr(0, 4) !== '0001'" style="width:100%;display:block;text-align:center;white-space: nowrap;">{{toolClass.dateFormat(scope.row.StartDate, 'yyyy-MM-dd')}}</span>
- <span v-if="scope.row.StartDate.substr(0, 4) !== '0001'" style="width:100%;display:block;text-align:center;white-space: nowrap;">至</span>
- <span v-if="scope.row.StartDate.substr(0, 4) !== '0001'" style="width:100%;display:block;text-align:center;white-space: nowrap;">{{toolClass.dateFormat(scope.row.EndDate, 'yyyy-MM-dd')}}</span>
- <span v-else>-</span>
- </template>
- </el-table-column>
- <el-table-column
- prop="SendType"
- label="发放类型">
- <template slot-scope="scope">{{scope.row.SendType === 'channel' ? '渠道' : scope.row.SendType === 'case' ? '案场' : '系统'}}</template>
- </el-table-column>
- <el-table-column
- prop="TotalCount"
- label="总数量">
- </el-table-column>
- <!-- <el-table-column
- prop="SentCount"
- label="已发">
- </el-table-column>
- <el-table-column
- prop="UsedCount"
- label="实际使用">
- </el-table-column> -->
- <el-table-column
- prop="Status"
- label="状态">
- <template slot-scope="scope">
- <span>{{scope.row.Status === 1 ? '正常' : '已过期'}}</span>
- </template>
- </el-table-column>
- <el-table-column label="操作" fixed='right' width="350">
- <template slot-scope="scope">
- <el-button
- size="mini"
- type="warning"
- @click="handleEdit(scope.$index, scope.row)">编辑</el-button>
- <el-button
- size="mini"
- type="danger"
- @click="sendCoupon(scope.$index, scope.row)">赠送客户</el-button>
- <el-button
- size="mini"
- type="success"
- v-if="scope.row.SendType === 'channel'"
- v-clipboard:copy="clientUrl + '/receiveChannelShared/' + scope.row.CouponId + '/coupon/receive'"
- v-clipboard:success="onCopy"
- v-clipboard:error="onError"
- >点击复制链接</el-button>
- </template>
- </el-table-column>
- </el-table>
- </div>
- <el-pagination
- @current-change="handleCurrentChange"
- :current-page.sync="postData.page"
- :page-size="postData.pagesize"
- layout="prev, pager, next, jumper"
- :total="total">
- </el-pagination>
- <el-dialog
- title="选择赠送客户"
- :visible.sync="centerDialogVisible"
- width="800px"
- center>
- <div>
- <ul class="dialogSearchList flex-h" style="margin-bottom:10px;">
- <li class="flex-item">
- <el-input
- placeholder="请输入用户名"
- v-model="dialogPostData.username"
- clearable>
- </el-input>
- </li>
- <li class="flex-item">
- <el-input
- placeholder="请输入手机号"
- v-model="dialogPostData.phone"
- clearable>
- </el-input>
- </li>
- <li class="flex-item">
- <el-input
- placeholder="请输入推荐人"
- v-model="dialogPostData.recommendname"
- clearable>
- </el-input>
- </li>
- <li>
- <el-button type="primary" @click="dialogSearch">搜索</el-button>
- </li>
- </ul>
- <ul class="dialogSearchList flex-h">
- <li class="flex-item">
- <el-date-picker
- v-model="dialogPostData.begindate"
- type="date"
- placeholder="选择起始日期">
- </el-date-picker>
- <el-date-picker
- v-model="dialogPostData.enddate"
- type="date"
- placeholder="选择截止日期">
- </el-date-picker>
- </li>
- </ul>
- </div>
- <div>
- <el-table
- ref="multipleTable"
- :data="customers.list"
- tooltip-effect="dark"
- style="width: 100%"
- @selection-change="handleSelectionChange">
- <el-table-column
- type="selection">
- </el-table-column>
- <el-table-column
- prop="Name"
- label="姓名">
- </el-table-column>
- <el-table-column
- prop="CustomerName"
- label="微信昵称">
- </el-table-column>
- <el-table-column
- prop="Phone"
- label="手机号">
- </el-table-column>
- <el-table-column
- prop="CreateDate"
- label="创建时间">
- <template slot-scope="scope">
- <span>{{toolClass.dateFormat(scope.row.CreateDate, 'yyyy-MM-dd')}}</span>
- </template>
- </el-table-column>
- <el-table-column
- prop="RecommendName"
- label="推荐人">
- </el-table-column>
- </el-table>
- </div>
- <div>
- <el-pagination
- @current-change="handleCurrentChangeDialog"
- :current-page.sync="dialogPostData.page"
- :page-size="dialogPostData.pagesize"
- layout="prev, pager, next, jumper"
- :total="customers.pagenum">
- </el-pagination>
- </div>
- <span slot="footer" class="dialog-footer">
- <el-button @click="centerDialogVisible = false">取 消</el-button>
- <el-button type="primary" @click="ForCustomer">确 定</el-button>
- </span>
- </el-dialog>
- </div>
- </template>
-
- <script>
- import { mapState, createNamespacedHelpers } from 'vuex'
- const { mapState: mapCouponState, mapActions: mapCouponActions } = createNamespacedHelpers('coupon')
- const { mapState: mapCustomerState, mapActions: mapCustomerActions } = createNamespacedHelpers('customer')
-
- export default {
- name: '',
- data () {
- return {
- dialogTotal: 0,
- dialogPostData: {
- username: '',
- phone: '',
- recommendname: '',
- begindate: '',
- enddate: '',
- page: 1, // 当前页码
- pagesize: 6, // 请求数据量
- },
- centerDialogVisible: false,
- total: 0,
- postData: { // 表格搜索条件
- caseid: '', // 案场id
- page: 1, // 当前页码
- pagesize: 10, // 请求数据量
- },
- currentInfo: {},
- selUsers: '',
- }
- },
- mounted () {
- this.$nextTick(function () {
- this.getList()
- })
- },
- computed: {
- ...mapCouponState({
- couponList: x => x.couponList,
- }),
- ...mapCustomerState({
- customers: x => x.customers,
- }),
- ...mapState({
- clientUrl: x => x.app.clientUrl,
- cases: x => x.app.cases.list,
- defaultCaseId: x => x.app.cases.default
- }),
- CaseId: {
- get () {
- return this.postData.caseid || this.defaultCaseId
- },
- set (val) {
- this.postData.caseid = val
- }
- }
- },
- methods: {
- ...mapCouponActions([
- 'GetCouponList',
- 'GiveCoupon',
- ]),
- ...mapCustomerActions([
- 'GetCustomerList',
- 'SetCustomerListNull',
- ]),
- dialogSearch () { // 赠送客户搜索
- this.GetCustomerList(this.dialogPostData)
- // 1
- },
- handleCurrentChangeDialog (val) {
- // 1
- },
- handleSelectionChange (val) {
- this.selUsers = val.map(x => x.CustomerId).join(',')
- // 1
- },
- sendCoupon (index, row) { // 赠送优惠券
- this.currentInfo = row
- this.selUsers = ''
- this.SetCustomerListNull()
- this.centerDialogVisible = true
- },
- search () { // 搜索
- this.postData.page = 1
- if (this.couponList.length) {
- this.couponList = []
- }
- this.getList()
- },
- getList () { // 获取列表
- this.GetCouponList({
- ...this.postData,
- caseid: this.CaseId || this.defaultCaseId
- }).then((res) => {
- this.total = res.pagenum
- // console.log(JSON.stringify(res))
- })
- },
- handleCurrentChange (val) { // 跳转到分页
- this.postData.page = val
- this.getList()
- },
- handleEdit (index, row) { // 编辑
- this.$router.push({ name: 'editCoupon', query: { type: row.CouponType, id: row.CouponId, caseid: row.CaseId } })
- },
- handleDelete (index, row) { // 删除
- let name = '确认删除渠道“' + row.ChannelName + '”?'
- this.$confirm(name, '提示', {
- confirmButtonText: '确定',
- cancelButtonText: '取消',
- type: 'warning'
- }).then(() => {
- this.$ajax(this.$api.channelManager.deleteChannel.url, {
- method: this.$api.channelManager.deleteChannel.method,
- urlData: { channelId: row.ChannelId }
- }).then(res => {
- this.$message({
- type: 'success',
- message: '删除成功!'
- })
- this.search()
- })
- }).catch(() => {
- this.$message({
- type: 'info',
- message: '已取消删除'
- })
- })
- },
- addCoupon (val) {
- this.$router.push({ name: 'editCoupon', query: { type: val } })
- },
- ForCustomer () {
- if (this.selUsers === '') {
- this.$message({
- type: 'error',
- message: '请先选择客户!'
- })
- return false
- }
- if (!this.currentInfo || this.currentInfo.CouponId === '') {
- this.$message({
- type: 'error',
- message: '请先选择需要赠送的优惠券!'
- })
- return false
- }
- this.GiveCoupon({
- id: this.currentInfo.CouponId,
- users: this.selUsers,
- }).then(res => {
- this.$message({
- type: 'success',
- message: '赠送成功!'
- })
- this.centerDialogVisible = false
- this.getList()
- })
- },
- onCopy () {
- this.$message({
- type: 'success',
- message: '复制成功!'
- })
- },
- onError () {
- this.$message({
- type: 'error',
- message: '复制失败!'
- })
- },
- }
- }
- </script>
-
- <!-- Add "scoped" attrib0 0ute to limit CSS to this component only -->
- <style lang="scss" scoped>
- @import "page.scss";
- .dialogSearchList {
- align-items: center;
- > li {
- font-size: 0;
- margin-left: 10px;
- &:first-child {
- margin-left: 0;
- }
- > *:nth-child(2) {
- margin-left: 10px;
- }
- }
- }
- </style>
|