123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418 |
- <template>
- <div class="app-container">
- <el-form :model="queryParams" ref="queryForm" :inline="true" v-show="showSearch" label-width="90px">
- <el-form-item label-width="120px" prop="orgIndex" v-if="userInfoVO.userType == '00'">
- <el-select v-model="queryParams.orgIndex" placeholder="请选择门店" clearable>
- <el-option-group label="工厂">
- <template>
- <el-option v-for="factory in factoryList" :key="factory.id + factory.sourceType" :label="factory.name" :value="factory.id + ',' + factory.sourceType"> </el-option>
- </template>
- </el-option-group>
- <el-option-group label="门店">
- <template>
- <el-option v-for="store in storeList" :key="store.id + store.sourceType" :label="store.name" :value="store.id + ',' + store.sourceType"> </el-option>
- </template>
- </el-option-group>
- </el-select>
- </el-form-item>
- <el-form-item prop="discountWay">
- <el-select v-model="queryParams.discountWay" placeholder="请选择优惠券类型" clearable>
- <el-option v-for="dict in dict.type.coupon_type" :key="dict.value" :label="dict.label" :value="dict.value" />
- </el-select>
- </el-form-item>
- <el-form-item prop="isUsed" v-if="isUsed != 'Y'">
- <el-select v-model="queryParams.isUsed" placeholder="请选择是否核销" clearable>
- <el-option v-for="dict in dict.type.sys_yes_no" :key="dict.value" :label="dict.label" :value="dict.value" />
- </el-select>
- </el-form-item>
- <el-form-item>
- <el-date-picker v-model="queryParams.duringDate" style="width: 240px" value-format="yyyy-MM-dd" type="daterange" range-separator="-" start-placeholder="开始日期" end-placeholder="结束日期"></el-date-picker>
- </el-form-item>
- <el-form-item prop="appUserPhoneNumber">
- <el-input v-model="queryParams.appUserPhoneNumber" placeholder="请输入客户手机号" clearable @keyup.enter.native="handleQuery" />
- </el-form-item>
- <el-form-item>
- <el-button type="primary" icon="el-icon-search" @click="handleQuery">搜索</el-button>
- <el-button icon="el-icon-refresh" @click="resetQuery">重置</el-button>
- </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" @click="handleAdd" v-hasPermi="['app:couponItem:add']">手动发送优惠券</el-button>
- </el-col>
- <el-col :span="1.5">
- <el-button type="warning" plain icon="el-icon-download" @click="handleExport" v-hasPermi="['app:couponItem:export']">导出</el-button>
- </el-col>
- <right-toolbar :showSearch.sync="showSearch" @queryTable="getList"></right-toolbar>
- </el-row>
- <Page uri="/mapi/app/couponItem/list" :request-params="queryParams" ref="pagination">
- <!-- <el-table-column type="selection" width="55" align="center" fixed="left"/>-->
- <el-table-column label="编号" align="center" prop="id" fixed="left" />
- <!-- <el-table-column label="订单编码" align="center" prop="orderNo" />-->
- <el-table-column label="优惠券名称" align="center" prop="couponTypeTitle" width="120" :show-overflow-tooltip="true" />
- <el-table-column label="优惠券类型" align="center" prop="discountWay" width="120" :show-overflow-tooltip="true">
- <template slot-scope="scope">
- <dict-tag :options="dict.type.coupon_type" :value="scope.row.discountWay" />
- </template>
- </el-table-column>
- <el-table-column label="活动名称" align="center" prop="activityTitle" width="120" :show-overflow-tooltip="true" />
- <!-- <el-table-column label="活动ID" align="center" prop="activityInfoId" />-->
- <el-table-column label="发放门店/工厂" align="center" prop="orgName" width="120" :show-overflow-tooltip="true" />
- <el-table-column label="客户姓名" align="center" prop="appUserName" width="100" />
- <el-table-column label="客户手机号" align="center" prop="appUserPhone" width="120" />
- <el-table-column label="是否核销" align="center" prop="isUsed" width="80">
- <template slot-scope="scope">
- <dict-tag :options="dict.type.sys_yes_no" :value="scope.row.isUsed" />
- </template>
- </el-table-column>
- <el-table-column label="核销门店/工厂" align="center" prop="usedOrgName" width="120" :show-overflow-tooltip="true" />
- <el-table-column label="核销时间" align="center" prop="usedTime" width="180"> </el-table-column>
- <el-table-column label="有效期开始时间" align="center" prop="startDate" width="180"> </el-table-column>
- <el-table-column label="有效期结束时间" align="center" prop="endDate" width="180"> </el-table-column>
- <el-table-column label="是否单件抵扣券" align="center" prop="isUnique" width="180">
- <template slot-scope="scope">
- <dict-tag :options="dict.type.sys_yes_no" :value="scope.row.isUnique" />
- </template>
- </el-table-column>
- <el-table-column label="是否手动发券" align="center" prop="canManual" width="180">
- <template slot-scope="scope">
- <dict-tag :options="dict.type.sys_yes_no" :value="scope.row.canManual" />
- </template>
- </el-table-column>
- <el-table-column label="抵用金额(元)" align="center" prop="deductAmount" width="120" />
- <el-table-column label="核销订单编码" align="center" prop="deductOrderNo" width="150" />
- <el-table-column label="操作" align="center" class-name="small-padding fixed-width" fixed="right" width="150" v-if="isUsed != 'Y'">
- <template slot-scope="scope">
- <el-button type="text" icon="el-icon-edit" @click="handleUpdate(scope.row)" v-hasPermi="['app:couponItem:edit']">修改有效期</el-button>
- <!-- <el-button-->
- <!-- -->
- <!-- type="text"-->
- <!-- icon="el-icon-delete"-->
- <!-- @click="handleDelete(scope.row)"-->
- <!-- v-hasPermi="['app:couponItem:remove']"-->
- <!-- >删除</el-button>-->
- </template>
- </el-table-column>
- </Page>
- <pagination v-show="total > 0" :total="total" :page.sync="queryParams.pageNum" :limit.sync="queryParams.pageSize" @pagination="getList" />
- <!-- 发送优惠券对话框 -->
- <el-dialog :title="sendCouponTitle" :visible.sync="sendCouponOpen" size="30%" append-to-body>
- <el-row :gutter="15">
- <el-form ref="form" :model="sendCouponForm" :rules="rules" label-width="140px">
- <el-col :span="24">
- <el-form-item label="门店" prop="orgId">
- <el-select v-model="sendCouponForm.orgId" style="width: 200px" @input="getAllValidList(sendCouponForm.orgId)" placeholder="请选择门店" clearable>
- <el-option v-for="item in storeList" :key="item.id" :label="item.name" :value="item.id" />
- </el-select>
- </el-form-item>
- </el-col>
- <el-col :span="24">
- <el-form-item label="优惠劵" prop="couponTypeId" v-if="sendCouponForm.orgId != null">
- <el-select v-model="sendCouponForm.couponTypeId" style="width: 200px" placeholder="请选择优惠劵" clearable>
- <el-option v-for="item in couponList" :key="item.id" :label="item.title" :value="item.id" />
- </el-select>
- </el-form-item>
- </el-col>
- <el-col :span="24">
- <el-form-item label="用户手机号" prop="appUserPhoneNumber">
- <el-input style="width: 200px" v-model.number="sendCouponForm.appUserPhoneNumber" placeholder="请输入手机号" clearable maxlength="11" />
- </el-form-item>
- </el-col>
- <el-col :span="24">
- <el-form-item label="一次性发送数量" prop="sendNum">
- <el-input-number v-model.number="sendCouponForm.sendNum" placeholder="请输入发送数量" :controls="false" min="1" />
- </el-form-item>
- </el-col>
- </el-form>
- </el-row>
- <div slot="footer" class="dialog-footer">
- <el-button type="primary" @click="submitSendCouponForm" style="margin-left: 5%">提交</el-button>
- <el-button @click="sendCouponCancel">取 消</el-button>
- </div>
- </el-dialog>
- <!-- 添加或修改优惠券对话框 -->
- <el-dialog :title="title" :visible.sync="open" size="30%" append-to-body>
- <el-row :gutter="15">
- <el-form ref="form" :model="form" :rules="rules" label-width="100px">
- <el-col :span="24">
- <el-form-item label="有效期" prop="duringDate">
- <el-date-picker v-model="form.duringDate" style="width: 240px" value-format="yyyy-MM-dd" type="daterange" range-separator="-" start-placeholder="开始日期" end-placeholder="结束日期"></el-date-picker>
- </el-form-item>
- </el-col>
- </el-form>
- </el-row>
- <div slot="footer" class="dialog-footer">
- <el-button type="primary" @click="submitForm" style="margin-left: 5%">提交</el-button>
- <el-button @click="cancel">取 消</el-button>
- </div>
- </el-dialog>
- </div>
- </template>
- <script>
- import { listCouponItem, getCouponItem, delCouponItem, sendCoupon, updateCouponItem, updateCouponItemStatus } from '@/api/coupon/item'
- import { allOrg } from '@/api/system/store'
- import { allValidList } from '@/api/coupon/type'
- export default {
- name: 'CouponItem',
- dicts: ['sys_source_type', 'sys_yes_no', 'coupon_type'],
- data() {
- return {
- // 遮罩层
- loading: true,
- // 选中数组
- ids: [],
- // 非单个禁用
- single: true,
- // 非多个禁用
- multiple: true,
- // 显示搜索条件
- showSearch: true,
- // 总条数
- total: 0,
- // 优惠券表格数据
- couponItemList: [],
- // 弹出层标题
- title: '',
- sendCouponTitle: '',
- // 是否显示弹出层
- open: false,
- sendCouponOpen: false,
- // 查询参数
- queryParams: {
- orgIndex: null,
- dateRange: []
- },
- // 表单参数
- form: {},
- // 表单参数
- sendCouponForm: {},
- // 表单校验
- rules: {
- duringDate: [{ required: true, message: '有效期不能为空', trigger: 'blur' }],
- orgId: [{ required: true, message: '门店不能为空', trigger: 'blur' }],
- couponTypeId: [{ required: true, message: '优惠券不能为空', trigger: 'blur' }],
- appUserPhoneNumber: [{ required: true, message: '用户手机号不能为空', trigger: 'blur' }],
- sendNum: [{ required: true, message: '发放数量不能为空', trigger: 'blur' }]
- },
- orgList: [],
- isUsed: null,
- storeList: [],
- factoryList: [],
- couponList: [],
- dateRange: []
- }
- },
- created() {
- this.handleUser()
- this.isUsed = this.getUrlParam('isUsed')
- if (this.isUsed == 'Y') {
- this.queryParams.isUsed = this.isUsed
- }
- this.getList()
- allOrg().then((res) => {
- this.orgList = res.data
- this.orgList.forEach((org) => {
- if (org.sourceType == '01') {
- this.factoryList.push(org)
- } else {
- this.storeList.push(org)
- }
- })
- })
- },
- methods: {
- handleUser() {
- this.userInfoVO = this.getUserInfo()
- },
- /** 查询优惠券列表 */
- getList() {
- if (this.queryParams.orgIndex != null) {
- this.queryParams.orgId = this.queryParams.orgIndex.split(',')[0]
- this.queryParams.sourceType = this.queryParams.orgIndex.split(',')[1]
- } else {
- delete this.queryParams.orgId
- delete this.queryParams.sourceType
- }
- if (null != this.queryParams.duringDate && this.queryParams.duringDate.length > 0) {
- this.queryParams.startDate = this.queryParams.duringDate[0]
- this.queryParams.endDate = this.queryParams.duringDate[1]
- } else {
- delete this.queryParams.startDate
- delete this.queryParams.endDate
- }
- this.$nextTick(() => {
- this.$refs.pagination.handleSearch(true)
- })
- },
- getAllValidList(id) {
- this.sendCouponForm.couponTypeId = null
- allValidList(id).then((res) => {
- this.couponList = res.data
- })
- },
- // 取消按钮
- cancel() {
- this.open = false
- this.reset()
- },
- // 取消按钮
- sendCouponCancel() {
- this.sendCouponOpen = false
- this.reset()
- },
- // 表单重置
- reset() {
- this.form = {
- id: null,
- orderNo: null,
- couponTypeId: null,
- activityInfoId: null,
- orgId: null,
- sourceType: null,
- appUserId: null,
- isUsed: null,
- usedOrgId: null,
- usedSourceType: null,
- usedTime: null,
- startDate: null,
- endDate: null,
- isUnique: null,
- canManual: null,
- deductAmount: null,
- deductOrderNo: null,
- createById: null,
- createBy: null,
- createTime: null,
- updateById: null,
- updateBy: null,
- updateTime: null,
- remark: null
- }
- this.sendCouponForm = {
- couponTypeId: null,
- activityInfoId: null,
- orgId: null,
- sourceType: null,
- appUserPhoneNumber: null,
- sendNum: null
- }
- this.resetForm('form')
- },
- /** 搜索按钮操作 */
- handleQuery() {
- this.getList()
- },
- /** 重置按钮操作 */
- resetQuery() {
- this.resetForm('queryForm')
- this.handleQuery()
- },
- // 多选框选中数据
- handleSelectionChange(selection) {
- this.ids = selection.map((item) => item.id)
- this.single = selection.length !== 1
- this.multiple = !selection.length
- },
- /** 发送优惠券按钮操作 */
- handleAdd() {
- this.reset()
- this.sendCouponOpen = true
- this.sendCouponTitle = '发送优惠券'
- },
- /** 修改按钮操作 */
- handleUpdate(row) {
- this.reset()
- const id = row.id || this.ids
- getCouponItem(id).then((response) => {
- var duringDate = []
- duringDate.push(response.data.startDate)
- duringDate.push(response.data.endDate)
- response.data.duringDate = duringDate
- this.form = response.data
- this.open = true
- this.title = '修改优惠券'
- })
- },
- /** 提交按钮 */
- submitForm() {
- var params = {}
- if (null != this.form.duringDate && this.form.duringDate.length > 0) {
- params['startDate'] = this.form.duringDate[0]
- params['endDate'] = this.form.duringDate[1]
- }
- params.id = this.form.id
- this.$refs['form'].validate((valid) => {
- if (valid) {
- // if (this.form.id != null) {
- updateCouponItem(params).then((response) => {
- this.$modal.msgSuccess('修改成功')
- this.open = false
- this.getList()
- })
- // } else {
- // addCouponItem(this.form).then(response => {
- // this.$modal.msgSuccess("新增成功");
- // this.open = false;
- // this.getList();
- // });
- // }
- }
- })
- },
- /** 提交发送优惠券 */
- submitSendCouponForm() {
- this.$refs['form'].validate((valid) => {
- if (valid) {
- this.sendCouponForm.sourceType = '02'
- sendCoupon(this.sendCouponForm).then((response) => {
- this.$modal.msgSuccess('提交成功')
- this.sendCouponOpen = false
- this.getList()
- })
- }
- })
- },
- /** 删除按钮操作 */
- handleDelete(row) {
- const ids = row.id || this.ids
- this.$modal
- .confirm('是否确认删除优惠券编号为"' + ids + '"的数据项?')
- .then(function () {
- return delCouponItem(ids)
- })
- .then(() => {
- this.getList()
- this.$modal.msgSuccess('删除成功')
- })
- .catch(() => {})
- },
- /** 导出按钮操作 */
- handleExport() {
- this.download(
- 'mapi/app/couponItem/export',
- {
- ...this.queryParams
- },
- `couponItem_${new Date().getTime()}.xlsx`
- )
- },
- checkClose(done) {
- this.$confirm('是否关闭表单,关闭后数据将丢失?')
- .then(function () {
- done()
- })
- .then(() => {})
- .catch(() => {})
- }
- }
- }
- </script>
|