oil-station/fuintAdmin/src/views/integral/gift/index.vue

1196 lines
41 KiB
Vue
Raw Normal View History

2023-11-02 18:32:07 +08:00
<template>
<div class="app-container">
<el-card >
2023-11-06 17:52:12 +08:00
<el-form :model="queryParams" ref="queryForm" size="small" :inline="true" v-show="showSearch" label-width="100px">
<el-form-item label="礼品名称" prop="giftName">
2023-11-02 18:32:07 +08:00
<el-input
2023-11-06 17:52:12 +08:00
v-model="queryParams.giftName"
2023-11-02 18:32:07 +08:00
placeholder="请输入供应商名称"
clearable
style="width: 240px;"
@keyup.enter.native="handleQuery"
/>
</el-form-item>
<el-form-item>
<el-select v-model="queryParams.status" style="width: 217px" placeholder="全部" clearable
>
<el-option
v-for="dict in dict.type.zhzt"
:key="dict.label"
:label="dict.label"
:value="dict.label"
/>
</el-select>
</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>
2023-11-06 17:52:12 +08:00
</el-form>
2023-11-02 18:32:07 +08:00
</el-card>
<el-card style="margin-top: 20px" >
<el-row :gutter="10" class="mb8">
<el-col :span="1.5">
<el-button
type="primary"
icon="el-icon-plus"
@click="giftAdd"
>新增礼品</el-button>
</el-col>
<right-toolbar :showSearch.sync="showSearch" @queryTable="getList"></right-toolbar>
</el-row>
<el-table ref="tables"
v-loading="loading"
:data="dataList"
2023-11-03 17:59:55 +08:00
:default-sort="defaultSort">
2023-11-07 18:04:43 +08:00
<el-table-column label="分类" align="center" prop="categoryName" width="50px">
<template slot-scope="scope">
{{ scope.row.categoryName==null? '不分类': scope.row.categoryName}}
</template>
</el-table-column>
2023-11-02 18:32:07 +08:00
<el-table-column label="礼品信息" align="center">
2023-11-03 17:59:55 +08:00
<el-table-column label="名称" align="center" prop="giftName"/>
2023-11-06 17:52:12 +08:00
<el-table-column label="封面图" align="center" prop="coverImage">
<template slot-scope="scope">
<el-image
style="width: 50px; height: 50px"
:src="imagePath+scope.row.coverImage"
:preview-src-list="[imagePath + scope.row.coverImage]"
fit="cover">
</el-image>
</template>
</el-table-column>
2023-11-02 18:32:07 +08:00
</el-table-column>
<el-table-column label="兑换信息" align="center">
2023-11-06 17:52:12 +08:00
<el-table-column label="兑换方式" align="center" prop="exchangeMethod">
<template slot-scope="scope">
<div slot="reference" class="name-wrapper">
<el-tag v-if ="scope.row.exchangeMethod == '积分'" effect="plain" size="medium">积分</el-tag>
<el-tag v-if ="scope.row.exchangeMethod == '金额'" effect="plain" type="success" size="medium">金额</el-tag>
<el-tag v-if ="scope.row.exchangeMethod == '积分+金额'" effect="plain" type="danger" size="medium">积分+金额</el-tag>
<el-tag v-if ="scope.row.exchangeMethod == '积分+加钱购'" effect="plain" type="warning" size="medium">积分+加钱购</el-tag>
</div>
</template>
</el-table-column>
<el-table-column label="兑换方式" align="center" prop="">
<template slot-scope="scope">
<span v-if ="scope.row.exchangeMethod == '积分'" effect="plain" size="medium">{{scope.row.exchangePoints}}积分</span>
<span v-if ="scope.row.exchangeMethod == '金额'" effect="plain" type="success" size="medium">{{scope.row.exchangeAmount}}</span>
<span v-if ="scope.row.exchangeMethod == '积分+金额'" effect="plain" type="danger" size="medium">{{scope.row.exchangePoints}}积分+{{scope.row.exchangeAmount}}</span>
2023-11-13 16:54:15 +08:00
<span v-if ="scope.row.exchangeMethod == '积分+加钱购'" effect="plain" type="warning" size="medium">{{scope.row.exchangePoints}}积分+加钱购比例{{ scope.row.moneyRatio }}</span>
2023-11-06 17:52:12 +08:00
</template>
</el-table-column>
2023-11-02 18:32:07 +08:00
</el-table-column>
<el-table-column label="配送类型" align="center">
2023-11-07 18:04:43 +08:00
<el-table-column label="配送方式" align="center" prop="deliveryMethod">
<template slot-scope="scope">
<span v-for="(row, index) in JSON.parse(scope.row.deliveryMethod)" :key="index">
{{row}}<br>
</span>
</template>
</el-table-column>
2023-11-06 17:52:12 +08:00
<el-table-column label="快递费用" align="center" prop="shippingFeeAmount">
<template slot-scope="scope">
<span v-if ="scope.row.exchangeMethod!= null && !scope.row.exchangeMethod.includes('物流配送')">--</span>
<span v-else effect="plain" type="warning" size="medium">{{scope.row.shippingFeeAmount}}</span>
</template>
</el-table-column>
2023-11-02 18:32:07 +08:00
</el-table-column>
2023-11-03 17:59:55 +08:00
<el-table-column label="礼品类型" align="center" prop="giftType" />
2023-11-02 18:32:07 +08:00
<el-table-column label="礼品库存信息" align="center">
2023-11-06 17:52:12 +08:00
<el-table-column label="总库存" align="center" prop="totalInventory" >
<template slot-scope="scope">
2023-11-07 18:04:43 +08:00
<el-button type="text" @click="clickInventory(scope.row)">{{ scope.row.totalInventory===-1?'无限制': scope.row.totalInventory}}</el-button>
2023-11-06 17:52:12 +08:00
</template>
</el-table-column>
2023-11-07 18:04:43 +08:00
<el-table-column label="已用" align="center" prop="usedInventory">
</el-table-column>
<el-table-column label="可用" align="center" prop="remainingInventory">
2023-11-06 17:52:12 +08:00
<template slot-scope="scope">
2023-11-07 18:04:43 +08:00
<span>{{ scope.row.totalInventory===-1?scope.row.totalInventory-scope.row.usedInventory+1: scope.row.totalInventory-scope.row.usedInventory}}</span>
2023-11-06 17:52:12 +08:00
</template>
</el-table-column>
2023-11-02 18:32:07 +08:00
</el-table-column>
<el-table-column label="排序" align="center" prop="sort" />
<el-table-column label="状态" align="center" prop="status">
<template slot-scope="scope">
<div slot="reference" class="name-wrapper">
<el-tag v-if ="scope.row.status == '启用'" size="medium">启用</el-tag>
<el-tag v-if ="scope.row.status == '禁用'" type="danger" size="medium">禁用</el-tag>
</div>
</template>
</el-table-column>
2023-11-06 17:52:12 +08:00
<el-table-column label="创建时间" align="center" prop="createTime">
</el-table-column>
2023-11-02 18:32:07 +08:00
<el-table-column label="操作" align="center" class-name="small-padding fixed-width">
<template slot-scope="scope">
<el-button
size="mini"
type="text"
icon="el-icon-edit"
@click="handleUpdate(scope.row)"
>修改</el-button>
</template>
</el-table-column>
</el-table>
<pagination
v-show="total>0"
:total="total"
:page.sync="queryParams.page"
:limit.sync="queryParams.pageSize"
@pagination="getList"
/>
</el-card>
2023-11-03 17:59:55 +08:00
<el-dialog :title="title" class="d-dialog" :visible.sync="open" width="1000px" append-to-body :close-on-click-modal="false">
2023-11-02 18:32:07 +08:00
<el-form ref="form" :model="dataForm" :rules="rules" label-width="80px">
<el-row :gutter="24">
<el-col :span="15">
2023-11-03 17:59:55 +08:00
<el-form-item label="礼品名称" prop="giftName">
<el-input v-model="dataForm.giftName" placeholder="请输入礼品名称" maxlength="30"/>
2023-11-02 18:32:07 +08:00
</el-form-item>
</el-col>
<el-col :span="9">
2023-11-03 17:59:55 +08:00
<el-form-item label="分类" prop="categoryId">
2023-11-07 18:04:43 +08:00
<el-select clearable v-model="dataForm.categoryId" placeholder="请选择礼品分类" style="width:100%">
<el-option label="-不分类-" value=""></el-option>
2023-11-03 17:59:55 +08:00
<el-option
v-for="option in giftCategoryList"
:key="option.id"
2023-11-07 18:04:43 +08:00
2023-11-03 17:59:55 +08:00
:label="option.categoryName"
:value="option.id"
></el-option>
</el-select>
2023-11-02 18:32:07 +08:00
</el-form-item>
</el-col>
</el-row>
<el-row :gutter="24">
2023-11-03 17:59:55 +08:00
<el-col :span="6">
2023-11-06 17:52:12 +08:00
<el-form-item label="封面图" prop="coverImage">
2023-11-02 18:32:07 +08:00
<el-upload
:action="uploadAction"
list-type="picture-card"
:class="{hide:hideUpload}"
:file-list="uploadFiles"
:auto-upload="true"
:show-file-list="false"
:headers="uploadHeader"
2023-11-03 17:59:55 +08:00
:on-success="handleUploadSuccessCover">
2023-11-02 18:32:07 +08:00
<img
2023-11-03 17:59:55 +08:00
v-if="this.dataForm.coverImage"
:src="imagePath + this.dataForm.coverImage"
2023-11-02 18:32:07 +08:00
class="list-img"
/>
2023-11-03 17:59:55 +08:00
<i v-if="!this.dataForm.coverImage" class="el-icon-plus"></i>
2023-11-02 18:32:07 +08:00
</el-upload>
</el-form-item>
</el-col>
2023-11-03 17:59:55 +08:00
<el-col :span="18">
2023-11-02 18:32:07 +08:00
<el-form-item label="礼品图片" >
<el-upload
2023-11-03 17:59:55 +08:00
:action="uploadAction"
list-type="picture-card"
2023-11-06 17:52:12 +08:00
:file-list="giftImages"
2023-11-03 17:59:55 +08:00
:headers="uploadHeader"
:auto-upload="true"
:on-preview="handlePictureCardPreview"
:on-success="handleUploadSuccessGift"
style="height: 100px;"
:on-remove="handleRemove">
<i class="el-icon-plus"></i>
</el-upload>
<el-dialog :visible.sync="dialogVisible">
<img width="100%" :src="dialogImageUrl" alt="">
</el-dialog>
<!-- <el-upload
:action="uploadAction"
2023-11-02 18:32:07 +08:00
list-type="picture-card"
:class="{hide:hideUpload}"
:file-list="uploadFiles"
:auto-upload="true"
:show-file-list="false"
:headers="uploadHeader"
2023-11-03 17:59:55 +08:00
:on-success="handleUploadSuccessGift">
2023-11-02 18:32:07 +08:00
<img
2023-11-03 17:59:55 +08:00
v-if="this.dataForm.giftImages"
:src="imagePath + this.dataForm.giftImages"
2023-11-02 18:32:07 +08:00
class="list-img"
/>
2023-11-03 17:59:55 +08:00
<i v-if="!this.dataForm.giftImages" class="el-icon-plus"></i>
</el-upload> -->
2023-11-02 18:32:07 +08:00
</el-form-item>
</el-col>
</el-row>
<el-row>
<el-col>
<el-col :span="20">
2023-11-03 17:59:55 +08:00
<el-form-item label="礼品类型" prop="giftType">
2023-11-06 17:52:12 +08:00
<el-radio-group v-model="dataForm.giftType" @change="changeGiftType($event)">
2023-11-03 17:59:55 +08:00
<el-radio
v-for="dict in dict.type.lplx"
:key="dict.value"
:label="dict.label"
:value="dict.value"
@change="handleIsopenSelect,changeGiftType"
/>
</el-radio-group>
2023-11-02 18:32:07 +08:00
</el-form-item>
</el-col>
</el-col>
</el-row>
<el-row :gutter="24">
2023-11-03 17:59:55 +08:00
<el-col :span="8">
2023-11-06 17:52:12 +08:00
<el-form-item v-if="showList.coupon" label="优惠券" prop="couponId">
2023-11-03 17:59:55 +08:00
<el-select v-model="dataForm.couponId" placeholder="请选择" style="width: 202px;">
<el-option
2023-11-13 16:54:15 +08:00
v-for="option in cardFavorableList"
2023-11-06 17:52:12 +08:00
:key="option.id"
2023-11-13 16:54:15 +08:00
:label="(option.type==0?'油品卷-':option.type==1?'商品卷-':'优惠卷-')+ option.name"
2023-11-06 17:52:12 +08:00
:value="option.id"
2023-11-03 17:59:55 +08:00
></el-option>
</el-select>
</el-form-item>
<el-form-item v-if="showList.voucher" label="兑换券" prop="voucherId">
<el-select v-model="dataForm.voucherId" placeholder="请选择" style="width: 202px;">
<el-option
2023-11-13 16:54:15 +08:00
v-for="option in cardExchangeApiList"
2023-11-06 17:52:12 +08:00
:key="option.id"
2023-11-13 16:54:15 +08:00
:label="(option.type==0?'兑换券-':option.type==1?'洗车券-':'洗车卡-')+ option.name"
2023-11-06 17:52:12 +08:00
:value="option.id"
2023-11-03 17:59:55 +08:00
></el-option>
</el-select>
2023-11-02 18:32:07 +08:00
</el-form-item>
2023-11-06 17:52:12 +08:00
<el-form-item v-if="showList.goods" label="关联商品" prop="goodsId">
<el-input v-model="dataForm.goodsName" placeholder="" maxlength="30" style="width: 202px;" @focus="getCommodity"/>
2023-11-07 18:04:43 +08:00
<!-- </el-select> -->
2023-11-06 17:52:12 +08:00
</el-form-item>
2023-11-02 18:32:07 +08:00
</el-col>
2023-11-03 17:59:55 +08:00
<el-col :span="7">
2023-11-06 17:52:12 +08:00
<el-form-item label="礼品数量" prop="giftQuantity" style="width: 202px;">
2023-11-03 17:59:55 +08:00
<el-input-number v-model="dataForm.giftQuantity" controls-position="right" :min="1" :max="10" label=""></el-input-number>
2023-11-02 18:32:07 +08:00
</el-form-item>
</el-col>
</el-row>
<el-row :gutter="24">
2023-11-03 17:59:55 +08:00
<el-col :span="8">
2023-11-06 17:52:12 +08:00
<el-form-item label="市场价格" prop="market">
<el-input v-model="dataForm.market" placeholder="请输入市场价格" maxlength="30" style="width: 202px;">
2023-11-03 17:59:55 +08:00
<template slot="append"></template></el-input>
2023-11-02 18:32:07 +08:00
</el-form-item>
</el-col>
2023-11-03 17:59:55 +08:00
<el-col :span="7">
<el-form-item label="礼品库存" prop="totalInventory">
2023-11-07 18:04:43 +08:00
<el-input v-model.number="dataForm.totalInventory" placeholder="礼品库存" maxlength="30" style="width: 202px;"/>
2023-11-02 18:32:07 +08:00
</el-form-item>
</el-col>
</el-row>
<el-row>
<el-col>
<el-col :span="20">
2023-11-06 17:52:12 +08:00
<el-form-item label="兑换方式" prop="exchangeMethod">
<el-radio-group v-model="dataForm.exchangeMethod" @change="changeExchange($event)">
2023-11-02 18:32:07 +08:00
<el-radio
2023-11-03 17:59:55 +08:00
v-for="dict in dict.type.redemptionMethod"
2023-11-02 18:32:07 +08:00
:key="dict.value"
:label="dict.label"
@change="handleIsopenSelect"
:value="dict.value"/>
</el-radio-group>
</el-form-item>
</el-col>
</el-col>
</el-row>
2023-11-03 17:59:55 +08:00
<el-row :gutter="24">
2023-11-06 17:52:12 +08:00
<el-col v-if="showList.jf" :span="8">
<el-form-item v-show="showList.jf" label="兑换积分" prop="exchangePoints">
<el-input v-model="dataForm.exchangePoints" placeholder="" maxlength="30" style="width: 202px;">
2023-11-03 17:59:55 +08:00
<template slot="append">积分</template>
</el-input>
</el-form-item>
</el-col>
2023-11-06 17:52:12 +08:00
<el-col v-if="showList.je" :span="8">
<el-form-item label="兑换金额" prop="exchangeAmount">
<el-input v-model="dataForm.exchangeAmount" placeholder="" maxlength="30" style="width: 202px;">
<template slot="append">积分</template>
</el-input>
</el-form-item>
</el-col>
<el-col v-if="showList.jfjq" :span="7">
2023-11-03 17:59:55 +08:00
<el-form-item label="加钱比例" prop="moneyRatio" >
2023-11-06 17:52:12 +08:00
<el-input v-model="dataForm.moneyRatio" placeholder="" maxlength="30" style="width: 202px;">
2023-11-03 17:59:55 +08:00
<template slot="prepend">1积分=</template>
<template slot="append"></template>
</el-input>
</el-form-item>
</el-col>
</el-row>
2023-11-02 18:32:07 +08:00
2023-11-03 17:59:55 +08:00
2023-11-06 17:52:12 +08:00
<el-row :gutter="24" v-if="showList.delivery">
<!-- <el-col :span="8">
<el-form-item label="配送方式" prop="deliveryMethod">
<el-checkbox v-for="item in dict.type.shippingMethod" :key="item.value" v-model="dataForm.deliveryMethod" :label="item.id">{{ item.label }}</el-checkbox>
</el-form-item>
</el-col> -->
2023-11-03 17:59:55 +08:00
<el-col :span="8">
2023-11-06 17:52:12 +08:00
<el-form-item label="配送方式" prop="deliveryMethod">
<el-checkbox v-for="item in dict.type.shippingMethod" :key="item.value" :label="item.label" :checked="dataForm.deliveryMethod != null?dataForm.deliveryMethod.includes(item.label):''" @change="changeExpress(item.label,1)">{{ item.label }}</el-checkbox>
2023-11-03 17:59:55 +08:00
</el-form-item>
</el-col>
2023-11-06 17:52:12 +08:00
<el-col v-if="showList.express" :span="7">
<el-form-item label="快递运费" prop="expressShippingFee">
<el-radio-group v-model="dataForm.expressShippingFee" @change="changeExpress($event,2)">
2023-11-03 17:59:55 +08:00
<el-radio
v-for="dict in dict.type.expressShippingCosts"
:key="dict.value"
:label="dict.label"
@change="handleIsopenSelect"
:value="dict.value"/>
</el-radio-group>
2023-11-02 18:32:07 +08:00
</el-form-item>
</el-col>
2023-11-03 17:59:55 +08:00
2023-11-06 17:52:12 +08:00
<el-col v-if="showList.shippingFee" :span="7">
<el-form-item label="运费金额" prop="shippingFeeAmount">
<el-input v-model="dataForm.shippingFeeAmount" placeholder="" maxlength="30" style="width: 202px;" >
2023-11-03 17:59:55 +08:00
<template slot="append"></template>
</el-input>
2023-11-02 18:32:07 +08:00
</el-form-item>
</el-col>
</el-row>
2023-11-03 17:59:55 +08:00
2023-11-02 18:32:07 +08:00
<el-row :gutter="24">
2023-11-03 17:59:55 +08:00
<el-col :span="8">
<el-form-item label="兑换次数" prop="exchangeTimes">
2023-11-07 18:04:43 +08:00
<el-input v-model.number="dataForm.exchangeTimes" placeholder="" maxlength="30" style="width: 202px;">
2023-11-03 17:59:55 +08:00
<template slot="append"></template>
</el-input>
2023-11-02 18:32:07 +08:00
</el-form-item>
</el-col>
</el-row>
<el-row :gutter="24">
<el-col :span="10">
2023-11-03 17:59:55 +08:00
<el-form-item label="礼品排序" prop="sort" >
<el-input-number v-model="dataForm.sort" :min="1" :max="10" label="" style="width: 202px;"></el-input-number>
2023-11-02 18:32:07 +08:00
</el-form-item>
</el-col>
</el-row>
2023-11-03 17:59:55 +08:00
2023-11-02 18:32:07 +08:00
<el-row>
<el-col>
<el-col :span="20">
<el-form-item label="礼品状态" prop="status">
<el-radio-group v-model="dataForm.status">
<el-radio
v-for="dict in dict.type.zhzt"
:key="dict.value"
:label="dict.label"
@change="handleIsopenSelect"
:value="dict.value"/>
</el-radio-group>
</el-form-item>
</el-col>
</el-col>
</el-row>
2023-11-03 17:59:55 +08:00
<el-row :gutter="24">
2023-11-02 18:32:07 +08:00
<el-col :span="23">
2023-11-03 17:59:55 +08:00
<el-form-item label="图文详情" prop="detailedDescription">
2023-11-06 17:52:12 +08:00
<editor @input="handleChildValue" :value.default="dataForm.detailedDescription" :height.default="150"></editor>
2023-11-02 18:32:07 +08:00
</el-form-item>
</el-col>
2023-11-03 17:59:55 +08:00
</el-row>
2023-11-02 18:32:07 +08:00
</el-form>
<div slot="footer" class="dialog-footer">
2023-11-03 17:59:55 +08:00
<el-button type="primary" @click="submitForm"> </el-button>
2023-11-02 18:32:07 +08:00
<el-button @click="cancel"> </el-button>
</div>
</el-dialog>
2023-11-06 17:52:12 +08:00
<!-- 打开商品界面 -->
<el-dialog title="选择商品" :visible.sync="openCommodity" width="1000px" append-to-body :close-on-click-modal="false">
<el-container>
<el-header style="">
<el-form ref="tankForm" :model="commodityForm" label-width="80px">
<el-row :gutter="24">
<el-col :span="6">
<el-form-item label="商品分类">
<el-select
v-model="commodityForm.cvsGoodId"
placeholder="全部"
clearable
>
<el-option v-for="item in cvsGoodList" :key="item.id" :label="item.name" :value="item.id"/>
</el-select>
</el-form-item>
</el-col>
<el-col :span="6">
<el-form-item label="供应商" prop="supplierId">
<el-select
v-model="commodityForm.supplierId"
placeholder="全部"
clearable
>
<el-option v-for="item in supplierList" :key="item.id" :label="item.name" :value="item.id"/>
</el-select>
</el-form-item>
</el-col>
<el-col :span="8">
<el-form-item label="详细信息">
<el-input v-model="commodityForm.remark" placeholder="商品名称,拼音码,条形码等信息" ></el-input>
</el-form-item>
</el-col>
<el-col :span="4">
<el-button type="primary" @click="inquire()">查询</el-button>
</el-col>
</el-row>
</el-form>
</el-header>
<el-main>
<el-table
ref="tables"
v-loading="loading"
:data="commodityList"
@row-click="handleRowClick"
border
:default-sort="defaultSort"
>
<el-table-column type="index" label="序号"></el-table-column>
<!-- <el-table-column type="selection" width="55"></el-table-column> -->
<el-table-column label="商品名称" align="center" prop="name"/>
<el-table-column label="商品编码" align="center" prop="goodsNo"/>
<el-table-column label="分类名称" prop="cvsGoodId" align="center">
<template slot-scope="scope">
<span>{{ getName(cvsGoodList, scope.row.cvsGoodId) }}</span>
</template>
</el-table-column>
<el-table-column label="供应商" prop="supplierId" align="center">
<template slot-scope="scope">
<span>{{ getName(supplierList, scope.row.supplierId) }}</span>
</template>
</el-table-column>
<el-table-column label="单位" align="center" prop="unit"/>
<el-table-column label="当前库存" align="center" prop="stock"/>
</el-table>
2023-11-02 18:32:07 +08:00
2023-11-06 17:52:12 +08:00
</el-main>
</el-container>
2023-11-13 16:54:15 +08:00
<!-- <div slot="footer" class="dialog-footer">
2023-11-06 17:52:12 +08:00
<el-button type="primary" @click="addCommodity"> </el-button>
<el-button @click="cancel"> </el-button>
2023-11-13 16:54:15 +08:00
</div> -->
2023-11-06 17:52:12 +08:00
</el-dialog>
2023-11-07 18:04:43 +08:00
<el-dialog title="库存变更" :visible.sync="openInventory" width="500px" append-to-body :close-on-click-modal="false">
<el-form ref="form" :model="inventoryForm" :rules="rulesInventory" label-width="100px">
<el-form-item label="当前总库存" prop="totalInventory" >
<el-input disabled v-model="inventoryForm.totalInventory" placeholder="" maxlength="30" style="width: 270px;">
</el-input>
</el-form-item>
<el-form-item label="已用库存" prop="usedInventory" >
<el-input disabled v-model="inventoryForm.usedInventory" placeholder="" maxlength="30" style="width: 270px;">
</el-input>
</el-form-item>
<el-form-item label="可用库存" prop="remainingInventory" >
<el-input disabled v-model="inventoryForm.remainingInventory" placeholder="" maxlength="30" style="width: 270px;">
</el-input>
</el-form-item>
<el-form-item label="变更类型" prop="moneyRatio" >
<el-radio-group :disabled="inventoryForm.flag" v-model="inventoryForm.inventoryFlag">
<el-radio :label="0">增加库存</el-radio>
<el-radio :label="1">减少库存</el-radio>
<el-radio :label="2">不限库存</el-radio>
</el-radio-group>
</el-form-item>
<el-form-item label="库存数量" prop="editInventory" >
<el-input v-if="inventoryForm.inventoryFlag == 0" v-model.number="inventoryForm.editInventory" placeholder="" maxlength="30" style="width: 270px;">
<template slot="prepend">+</template>
</el-input>
<el-input v-else-if="inventoryForm.inventoryFlag == 1" v-model.number="inventoryForm.editInventory" placeholder="" maxlength="30" style="width: 270px;">
<template slot="prepend">-</template>
</el-input>
<el-input v-else="" disabled placeholder="变更为不限制库存" maxlength="30" style="width: 270px;"/>
</el-form-item>
</el-form>
<div slot="footer" class="dialog-footer">
<el-button type="primary" @click="submitInventory"> </el-button>
<el-button @click="cancelInventory"> </el-button>
</div>
2023-11-06 17:52:12 +08:00
</el-dialog>
2023-11-07 18:04:43 +08:00
2023-11-06 17:52:12 +08:00
</div>
</template>
2023-11-02 18:32:07 +08:00
<script>
2023-11-03 17:59:55 +08:00
import {getGiftCategoryApi} from "@/api/integral/category";
2023-11-13 16:54:15 +08:00
import {getGiftApi,insertGiftApi,updateGiftApi ,updateGiftInventoryApi,getCardFavorableApi,getCardExchangeApi} from "@/api/integral/gift";
2023-11-03 17:59:55 +08:00
import { editor } from '@/components/Editor/index'
2023-11-02 18:32:07 +08:00
import { getToken } from '@/utils/auth'
2023-11-06 17:52:12 +08:00
import {listLJGoods} from "@/api/convenienceStore/ljgoods";
2023-11-13 16:54:15 +08:00
import {selectParentById, selectTree} from "@/api/convenienceStore/goods";
2023-11-02 18:32:07 +08:00
export default {
name: "gift",
2023-11-03 17:59:55 +08:00
dicts: ['zhzt','lplx','redemptionMethod','expressShippingCosts','shippingMethod'],
2023-11-02 18:32:07 +08:00
data() {
2023-11-07 18:04:43 +08:00
var valiNumberPass = (rule, value, callback) => {//包含小数的数字
let reg = /^[+-]?(0|([1-9]\d*))(\.\d+)?$/g;
if (value === '') {
callback(new Error('请输入内容'));
} else if (!reg.test(value)) {
callback(new Error('请输入数字'));
} else {
callback();
}
};
2023-11-02 18:32:07 +08:00
return {
dataList: [],
dataForm:{
id: null,
2023-11-03 17:59:55 +08:00
giftName: '', // 礼品名称
categoryId:'', // 分类id
2023-11-06 17:52:12 +08:00
goodsId:'', // 商品Id
goodsName:'', // 商品Id
voucherId:'', // 兑换券id
2023-11-03 17:59:55 +08:00
coverImage:'', // 封面图
giftImages: [], // 礼品图片
2023-11-06 17:52:12 +08:00
giftType:"优惠券", // 礼品类型
2023-11-03 17:59:55 +08:00
couponId:'',// 优惠券
giftQuantity:'', // 礼品数量
totalInventory:'', // 库存
exchangeMethod:'积分', // 兑换方式
exchangePoints:'', // 兑换积分
exchangeTimes:'', // 兑换次数
moneyRatio:'', // 价钱比例
2023-11-06 17:52:12 +08:00
expressShippingFee:'', // 快递运费
shippingFeeAmount:'', // 运费金额
exchangeamount:'', // 兑换金额
deliveryMethod:['门店自提'], // 配送方式
2023-11-03 17:59:55 +08:00
detailedDescription:'', // 图文详情
2023-11-02 18:32:07 +08:00
categoryName: 1,
sort: null,
2023-11-06 17:52:12 +08:00
status: '启用',
market:null
2023-11-02 18:32:07 +08:00
},
2023-11-07 18:04:43 +08:00
inventoryForm: {
inventoryFlag: 0,
remainingInventory: null, // 剩余库存
totalInventory: null, //总库存
usedInventory: null, // 已用库存
editInventory: null,
flag: false,
id:''
},
2023-11-03 17:59:55 +08:00
showList: {
// 优惠类型展示
2023-11-06 17:52:12 +08:00
coupon: true,
voucher: false,
goods: false,
2023-11-03 17:59:55 +08:00
// 兑换方式展示
2023-11-06 17:52:12 +08:00
jf:true,
je:false,
jfje:false,
jfjq:false,
// 配送方式
delivery:false,
express: false,
shippingFee: false
2023-11-03 17:59:55 +08:00
},
2023-11-06 17:52:12 +08:00
getGiftTypeShow: '',
2023-11-13 16:54:15 +08:00
// 兑换卷
cardFavorableList:[],
// 优惠券
cardExchangeApiList:[],
2023-11-02 18:32:07 +08:00
// 弹出框标题
title:'',
// 显示搜索条件
showSearch: true,
disableInput: false, // 默认不禁用
// 是否显示弹出层
// 总条数
2023-11-06 17:52:12 +08:00
open: false,
openCommodity: false,
2023-11-07 18:04:43 +08:00
openInventory: false,
2023-11-02 18:32:07 +08:00
total: 0,
// 查询参数
queryParams: {
2023-11-06 17:52:12 +08:00
giftName: '',
2023-11-02 18:32:07 +08:00
status: '',
page:null,
pageSize:null
},
dateRange:{},
// 遮罩层
loading: false,
// 默认排序
defaultSort: {prop: 'createTime', order: 'descending'},
/**
* 表单
*/
2023-11-03 17:59:55 +08:00
giftCategoryList: [], // 查询分类列表
2023-11-02 18:32:07 +08:00
2023-11-06 17:52:12 +08:00
// 批量图片
giftImages: [],
2023-11-03 17:59:55 +08:00
// 上传地址
uploadAction: process.env.VUE_APP_SERVER_URL + 'backendApi/file/upload',
uploadHeader: { 'Access-Token' : getToken() },
// 隐藏上传
hideUpload: false,
// 上传文件列表
uploadFiles: [
{name:"nihao",
url:'http://localhost:8008/static/uploadImages/20231103/ffbbe7d3ee1441fdaf706802fa0f176a.png'}
],
// 图片根目录
imagePath: process.env.VUE_APP_SERVER_URL,
2023-11-06 17:52:12 +08:00
dialogImageUrl: "",
dialogVisible: false,
2023-11-07 18:04:43 +08:00
rulesInventory: {},
2023-11-06 17:52:12 +08:00
rules: {
giftName: [
{ required: true, message: "礼品名称不能为空", trigger: "blur" },
],
coverImage: [
{ required: true, message: "封面不能为空", trigger: "blur" },
],
giftType: [
{ required: true, message: "礼品类型不能为空", trigger: "change" },
],
couponId: [
{ required: true, message: "请选择优惠券", trigger: "blur" },
],
voucherId: [
{ required: true, message: "请选择兑换券", trigger: "blur" },
],
goodsId: [
2023-11-13 16:54:15 +08:00
{ required: true, message: "请选择关联商品", trigger: "change" },
2023-11-06 17:52:12 +08:00
],
giftQuantity: [
{ required: true, message: "礼品数量不能为空", trigger: "blur" },
],
totalInventory: [
{ required: true, message: "礼品库存不能为空", trigger: "blur" },
],
exchangeMethod: [
{ required: true, message: "兑换方式不能为空", trigger: "blur" },
],
exchangePoints: [
2023-11-07 18:04:43 +08:00
{ required: true, validator:valiNumberPass, trigger: "blur" },
2023-11-06 17:52:12 +08:00
],
exchangeAmount: [
2023-11-07 18:04:43 +08:00
{ required: true, validator:valiNumberPass, trigger: "blur" },
2023-11-06 17:52:12 +08:00
],
moneyRatio: [
2023-11-07 18:04:43 +08:00
{ required: true, validator:valiNumberPass, trigger: "blur" },
2023-11-06 17:52:12 +08:00
],
expressShippingFee: [
{ required: true, message: "快递运费不能为空", trigger: "change" },
],
shippingFeeAmount: [
2023-11-07 18:04:43 +08:00
{ required: true, validator:valiNumberPass, trigger: "blur" },
],
market: [
{ required: true, validator:valiNumberPass, trigger: "blur" },
2023-11-06 17:52:12 +08:00
],
exchangeTimes: [
{ required: true, message: "兑换次数不能为空", trigger: "change" },
],
sort: [
{ required: true, message: "礼品排序不能为空", trigger: "blur" },
],
status: [
{ required: true, message: "请选择礼品状态", trigger: "change" },
]
},
commodityList: [],
2023-11-03 17:59:55 +08:00
2023-11-06 17:52:12 +08:00
commodityForm:{
cvsGoodId: "",
cvsGood: "",
supplierId: "",
supplier: "",
detailed: "",
remark: "",
page: 1,
pageSize: 10,
isRecovery:0,
},
// 商品分类列表
cvsGoodList:[],
// 供应商列表
supplierList:[],
2023-11-03 17:59:55 +08:00
2023-11-06 17:52:12 +08:00
}
},
watch: {
getGiftTypeShow: function(newVal) {
2023-11-02 18:32:07 +08:00
}
},
async created() {
await this.getList();
},
methods: {
getList() {
2023-11-06 17:52:12 +08:00
getGiftApi(this.queryParams).then(res=>{
this.dataList = res.data.records
})
2023-11-02 18:32:07 +08:00
},
submitForm: function() {
2023-11-06 17:52:12 +08:00
let this_ = this
if (Array.isArray(this_.giftImages)) {
this_.dataForm.giftImages = JSON.stringify(this_.giftImages);
}
if (this_.dataForm.deliveryMethod != null && Array.isArray(this_.dataForm.deliveryMethod)) {
2023-11-07 18:04:43 +08:00
this_.dataForm.deliveryMethod = JSON.stringify(this.dataForm.deliveryMethod);
2023-11-06 17:52:12 +08:00
}
this_.dataForm.remainingInventory = this_.dataForm.totalInventory
this_.$refs["form"].validate(valid => {
2023-11-02 18:32:07 +08:00
if (valid) {
2023-11-06 17:52:12 +08:00
if (this_.dataForm.id == null) {
2023-11-02 18:32:07 +08:00
// 判断是否是新增还是修改
2023-11-06 17:52:12 +08:00
insertGiftApi(this_.dataForm).then(res => {
this_.getList(),
this_.open = false
})
2023-11-02 18:32:07 +08:00
} else {
2023-11-06 17:52:12 +08:00
// 判断是否是新增还是修改
updateGiftApi(this_.dataForm).then(res => {
this_.getList()
this_.open = false
})
2023-11-02 18:32:07 +08:00
}
}})
},
2023-11-03 17:59:55 +08:00
2023-11-07 18:04:43 +08:00
submitInventory: function(){
if (this.inventoryForm.inventoryFlag === 1) {
this.inventoryForm.editInventory = - this.inventoryForm.editInventory
} else if(this.inventoryForm.inventoryFlag === 2) {
this.inventoryForm.editInventory = -this.inventoryForm.totalInventory - 1
}
if (this.inventoryForm.totalInventory == '无限制') {
this.inventoryForm.editInventory = this.inventoryForm.editInventory+1
}
updateGiftInventoryApi(this.inventoryForm).then(res=>{
this.getList();
})
this.openInventory = false
this.resInventoryForm()
},
resInventoryForm() {
this.inventoryForm = {
inventoryFlag: 0,
remainingInventory: null, // 剩余库存
totalInventory: null, //总库存
usedInventory: null, // 已用库存
editInventory: null,
flag: false,
id:''
}
},
2023-11-03 17:59:55 +08:00
2023-11-02 18:32:07 +08:00
// 新增
giftAdd() {
2023-11-06 17:52:12 +08:00
this.reset();
2023-11-02 18:32:07 +08:00
this.open = true
2023-11-06 17:52:12 +08:00
this.title = '添加礼品'
2023-11-03 17:59:55 +08:00
this.selectGiftCategory();
2023-11-13 16:54:15 +08:00
this.cardFavorableApi();
this.cardExchangeApi();
2023-11-02 18:32:07 +08:00
},
// 取消按钮
cancel() {
this.open = false;
this.reset();
2023-11-07 18:04:43 +08:00
},
2023-11-13 16:54:15 +08:00
// 取消按钮
2023-11-07 18:04:43 +08:00
cancelInventory() {
this.openInventory = false;
this.resInventoryForm()
2023-11-02 18:32:07 +08:00
},
// 搜索按钮操作
handleQuery() {
this.queryParams.page = 1;
this.getList();
},
// 修改按钮
handleUpdate(data) {
2023-11-08 18:08:54 +08:00
2023-11-13 16:54:15 +08:00
this.cardFavorableApi();
this.cardExchangeApi();
2023-11-06 17:52:12 +08:00
let fileList = JSON.parse(data.giftImages);
this.giftImages = [],
this.giftImages = fileList;
console.log( this.giftImages);
this.giftImages.forEach(image=>{
let sp = image.url.split('//')
image.url = this.imagePath + '/'+sp[2]
})
2023-11-08 18:08:54 +08:00
console.log("data",data.deliveryMethod);
2023-11-06 17:52:12 +08:00
2023-11-13 16:54:15 +08:00
// data.deliveryMethod = JSON.parse(data.deliveryMethod);
// 查询兑换卷和优惠券列表
2023-11-06 17:52:12 +08:00
this.dataForm = data;
this.open = true;
2023-11-02 18:32:07 +08:00
this.getList();
},
2023-11-13 16:54:15 +08:00
cardFavorableApi () {
getCardFavorableApi().then(res=>{
this.cardFavorableList = res.data.records
})
},
cardExchangeApi () {
getCardExchangeApi().then(res=>{
this.cardExchangeApiList =res.data.records
})
},
2023-11-02 18:32:07 +08:00
2023-11-06 17:52:12 +08:00
resetQuery() {
this.queryParams= {
giftName: '',
status: '',
page:null,
pageSize:null
},
this.getList()
2023-11-02 18:32:07 +08:00
},
reset(){
2023-11-06 17:52:12 +08:00
this.dataForm={
id: null,
giftName: '', // 礼品名称
categoryId:'', // 分类id
goodsId:'', // 商品Id
voucherId:'', // 兑换券id
coverImage:'', // 封面图
giftImages: [], // 礼品图片
giftType:"优惠券", // 礼品类型
couponId:'',// 优惠券
giftQuantity:'', // 礼品数量
totalInventory:'', // 库存
exchangeMethod:'积分', // 兑换方式
exchangePoints:'', // 兑换积分
exchangeTimes:'', // 兑换次数
moneyRatio:'', // 价钱比例
expressShippingFee:'', // 快递运费
shippingFeeAmount:'', // 运费金额
exchangeamount:'', // 兑换金额
deliveryMethod:['门店自提'], // 配送方式
detailedDescription:'', // 图文详情
categoryName: 1,
sort: null,
status: '启用',
market:null
}
2023-11-07 18:04:43 +08:00
this.giftImages=[]
2023-11-02 18:32:07 +08:00
},
2023-11-06 17:52:12 +08:00
clickInventory(data) {
2023-11-07 18:04:43 +08:00
this.resInventoryForm()
this.openInventory = true
this.inventoryForm.id = data.id
console.log("data.usedInventory",data.usedInventory)
if (data.usedInventory == null || data.usedInventory == undefined) {
this.inventoryForm.usedInventory = 0
}else {
this.inventoryForm.usedInventory = data.usedInventory
}
if (data.totalInventory == 0) {
this.inventoryForm.totalInventory = 0
this.inventoryForm.remainingInventory = 0
}else if (data.totalInventory === -1) {
this.inventoryForm.flag = true
this.inventoryForm.totalInventory = '无限制'
this.inventoryForm.remainingInventory = '无限制'
} else {
this.inventoryForm.totalInventory = data.totalInventory
this.inventoryForm.remainingInventory = data.totalInventory - data.usedInventory
}
// inventoryForm: {
// inventoryFlag: 0,
// remainingInventory: null, // 剩余库存
// totalInventory: null, //总库存
// usedInventory: null, // 已用库存
// editInventory: null,
// id:''
// },
2023-11-06 17:52:12 +08:00
},
2023-11-02 18:32:07 +08:00
/**
* 表单
*/
2023-11-03 17:59:55 +08:00
// 表单初始化
initializeForm() {
},
// 分类查询
selectGiftCategory() {
let queryParams = {pageSize : 1000}
getGiftCategoryApi(queryParams).then(response => {
this.giftCategoryList = response.data.records;
})
},
// 选择礼品类型
2023-11-06 17:52:12 +08:00
changeGiftType(newVal) {
let this_ = this
if (newVal == '优惠券') {
this_.showList.coupon = true
this_.showList.voucher = false
this_.showList.goods = false
this_.showList.delivery = false
} else if (newVal == '兑换券') {
this_.showList.coupon = false
this_.showList.voucher = true
this_.showList.goods = false
this_.showList.delivery = true
} else if(newVal == '实物商品') {
this_.showList.coupon = false
this_.showList.voucher = false
this_.showList.goods = true
this_.showList.delivery = true
}
},
// 兑换方式
changeExchange(newVal){
let this_ = this
if (newVal == '积分') {
this_.showList.jf = true
this_.showList.je = false
this_.showList.jfjq = false
} else if (newVal == '金额') {
this_.showList.jf = false
this_.showList.je = true
this_.showList.jfjq = false
} else if (newVal == '积分+金额') {
this_.showList.jf = true
this_.showList.je = true
this_.showList.jfjq = false
} else if (newVal == '积分+加钱购') {
this_.showList.jf = true
this_.showList.je = false
this_.showList.jfjq = true
}
},
// 快递
changeExpress(data,flag){
let this_ = this
// express: false,
console.log("data",data)
// shippingFee: false
if(flag === 1) {
if (!this.dataForm.deliveryMethod) {
this.dataForm.deliveryMethod = [];
this.showList.express= false
}
const index = this.dataForm.deliveryMethod.indexOf(data);
if (index === -1) {
this.dataForm.deliveryMethod.push(data);
if(data == '物流配送') {
this.showList.express= true
}
} else {
this.dataForm.deliveryMethod.splice(index, 1);
if(data == '物流配送') {
this.showList.express= false
}
}
console.log("data",this.dataForm.deliveryMethod)
} else {
if (data == '包邮') {
this.showList.shippingFee= false
} else if (data == '统一运费') {
this.showList.shippingFee= true
}
}
2023-11-03 17:59:55 +08:00
},
2023-11-06 17:52:12 +08:00
2023-11-03 17:59:55 +08:00
// 点击按钮处理
handleIsopenSelect() {
// this.$forceUpdate()
2023-11-02 18:32:07 +08:00
},
2023-11-03 17:59:55 +08:00
// 上传封面
handleUploadSuccessCover(file) {
this.dataForm.coverImage = file.data.fileName;
2023-11-02 18:32:07 +08:00
},
2023-11-03 17:59:55 +08:00
// 上传详情图
handleUploadSuccessGift(file) {
let newImage = {
name: file.data.original,
url: process.env.VUE_APP_SERVER_URL + file.data.fileName,
2023-11-07 18:04:43 +08:00
type: file.data.type,
fileName: file.data.fileName
}
2023-11-06 17:52:12 +08:00
if (this.giftImages == undefined) {
this.giftImages = [];
2023-11-03 17:59:55 +08:00
}
2023-11-06 17:52:12 +08:00
this.giftImages.push(newImage);
2023-11-02 18:32:07 +08:00
2023-11-03 17:59:55 +08:00
},
handleRemove(file, fileList) {
2023-11-06 17:52:12 +08:00
this.giftImages.forEach((image, index) => {
2023-11-03 17:59:55 +08:00
if (file.url === image.url) {
2023-11-06 17:52:12 +08:00
this.giftImages.splice(index, 1);
2023-11-03 17:59:55 +08:00
}
});
console.log(file, fileList);
},
handlePictureCardPreview(file) {
console.log(file);
this.dialogImageUrl = file.url;
this.dialogVisible = true;
2023-11-02 18:32:07 +08:00
},
2023-11-06 17:52:12 +08:00
handleChildValue(value) {
this.dataForm.detailedDescription = value
},
// 商品列表
getCommodityList() {
let this_ = this
listLJGoods(this_.commodityForm).then(res=>{
this_.commodityList = res.data.records;
// this_.sumMethod(res.data.records);
// this.total = response.data.total;
})
},
// 查询商品
inquire() {
this.getCommodityList();
},
// 表格选择器
handleSelectionChange(val) {
this.multipleSelection = val;
},
handleRowClick(row) {
this.openCommodity = false
this.$refs.tables.clearSelection(); // 清除当前选中的行
this.$refs.tables.toggleRowSelection(row); // 选中当前点击的行
// 处理选中的行数据
console.log("row",row)
this.dataForm.goodsName = row.name
this.dataForm.goodsId = row.id
},
getCommodity() {
2023-11-13 16:54:15 +08:00
this.getQueryList()
2023-11-06 17:52:12 +08:00
this.openCommodity = true
2023-11-07 18:04:43 +08:00
2023-11-06 17:52:12 +08:00
},
// 查询搜索列表信息
getQueryList(){
selectTree().then(response => {
this.cvsGoodList = response.data.records
});
2023-11-13 16:54:15 +08:00
// listSupplier().then(response => {
// this.supplierList = response.data.records
// })
2023-11-06 17:52:12 +08:00
},
addCommodity () {
}
2023-11-02 18:32:07 +08:00
}
}
</script>
<style scoped>
2023-11-03 17:59:55 +08:00
.d-dialog >>> .el-upload--picture-card {
width: 100px;
height: 100px;
line-height: 100px;
}
.d-dialog >>> .avatar-uploader .el-upload {
width: 100px;
height: 100px;
}
.d-dialog >>> .el-upload-list--picture-card .el-upload-list__item {
width: 100px;
height: 100px;
}
.list-img{
width: 100px;
height: 100px;
2023-11-02 18:32:07 +08:00
}
</style>