| 123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561 |
- <?php
- /**
- * @link:http://www.goodmall.com/
- * @copyright: Copyright (c) 2022
- * 名片
- * Author: zcx
- * Date: 2022-09-14
- * Time: 11:37
- */
- use common\helpers\ComponentHelper;
- ComponentHelper::loadComponentView('com-dialog-select');
- ?>
- <div id="app" v-cloak>
- <el-card shadow="never" style="border:0;min-width: 1200px;" body-style="background-color: #f3f3f3;padding: 10px 0 0;">
- <div slot="header">
- <span>商品列表</span>
- </div>
- <div class="table-body">
- <el-form size="small" :inline="true" flex="dir:left cross:center">
- <div class="flex-bew">
- <div flex>
- <el-button size="small" type="primary" style="padding: 9px 15px !important;height:32px" @click="delGoods">
-
- 批量删除
- </el-button>
- <com-dialog-select ref="goodsSelect" v-model="cForm.goods_id" :multiple="true" url="blind-box/default/goods-list"
- @selected="selectGoodsWarehouse">
- <el-button size="medium" type="primary" style="padding: 9px 15px !important;">选择商品</el-button>
- </com-dialog-select>
- </div>
- <div flex>
- <div class="item-box" flex="dir:left cross:center">
- <div class="label">关键字:</div>
- <el-input size="small" style="width: 200px" v-model="search.name" placeholder="请输入关键字"></el-input>
- </div>
- <div class="item-box" flex="dir:left cross:center">
- <div class="label">状态:</div>
- <el-select v-model="search.status" placeholder="请选择" clearable>
- <el-option
- label="上架"
- value="1">
- </el-option>
- <el-option
- label="下架"
- value="0">
- </el-option>
- </el-select>
- </div>
- <div class="item-box" flex="dir:left cross:center">
- <div class="label">选择时间:</div>
- <el-date-picker style="margin-top: 1px;" size="small" @change="changeTime" v-model="time" type="datetimerange" value-format="yyyy-MM-dd HH:mm:ss" range-separator="至" start-placeholder="开始日期" clearable end-placeholder="结束日期" :default-time="['00:00:00', '23:59:59']"></el-date-picker>
- </div>
- <div class="item-box" flex="dir:left cross:center">
- <el-button size="small" type="primary" style="padding: 9px 15px !important;" @click="searchs">
- <i class="el-icon-search"></i>
- 搜索
- </el-button>
- </div>
- </div>
- </div>
- </el-form>
- <el-tabs v-model="activeName" @tab-click="handleClick">
- <el-table :data="list" stripe v-loading="loading" size="small" style="margin-bottom: 15px;"
- @selection-change="handleSelectionChange">
- <el-table-column type="selection"></el-table-column>
- <el-table-column prop="id" label="ID"></el-table-column>
- <el-table-column label="商品名称" prop="goods_name" align="center" width="250" class-name="goods-name"></el-table-column>
- <el-table-column label="分类" prop="cate_name" min-width="160" align="center"></el-table-column>
- <el-table-column label="贡献值" prop="contribution" min-width="160" align="center"></el-table-column>
- <el-table-column label="利润值" prop="profit" min-width="160" align="center"></el-table-column>
- <el-table-column label="状态" prop="status" align="center">
- <template slot-scope="scope">
- <div>{{scope.row.status == 1 ? '上架':'下架'}}</div>
- </template>
- </el-table-column>
- <el-table-column label="类型" prop="goods_type" align="center">
- <template slot-scope="scope">
- <div>{{scope.row.goods_type == 1 ? '实物商品':(scope.row.goods_type == 2 ? '虚拟商品' : '预约商品')}}</div>
- </template>
- </el-table-column>
- <el-table-column label="添加时间" prop="created_at" min-width="160" align="center">
- <template slot-scope="scope">
- <div>{{scope.row.created_at|dateTimeFormat('Y-m-d H:i:s')}}</div>
- </template>
- </el-table-column>
- <el-table-column
- fixed="right"
- label="操作"
- align="center"
- width="300">
- <template slot-scope="scope">
- <el-button type="text" @click="editGoods('edit',scope.row)">编辑</el-button>
- <el-button type="text" @click="handleSelectionChange(scope.row,'row')">删除</el-button>
- </template>
- </el-table-column>
- </el-table>
- </el-tabs>
- <!-- 分页器 -->
- <div flex="box:last cross:center">
- <div></div>
- <div>
- <el-pagination v-if="pagination" :page-size="pagination.defaultPageSize"
- style="display: inline-block;float: right;" background @current-change="pageChange"
- layout="prev, pager, next" :total="pagination.totalCount">
- </el-pagination>
- </div>
- </div>
- </div>
- </el-card>
- <el-dialog title="商品设置" :visible.sync="editGoodsDialog" width="500px">
- <div>
- <el-form :model="setting" size="small" label-width="150px">
-
- <el-form-item label="贡献值">
- <el-radio-group v-model="setting.contribution_percent">
- <el-radio :label="1">
- 百分比
- </el-radio>
- <el-radio :label="0">
- 固定值
- </el-radio>
- </el-radio-group>
- <el-input maxlength="20" v-model="setting.contribution" placeholder="请输入"></el-input>
- </el-form-item>
- <el-form-item label="利润值">
- <el-radio-group v-model="setting.profit_percent">
- <el-radio :label="1">
- 百分比
- </el-radio>
- <el-radio :label="0">
- 固定值
- </el-radio>
- </el-radio-group>
- <el-input maxlength="20" v-model="setting.profit" placeholder="请输入"></el-input>
- </el-form-item>
- <el-form-item label="分类">
- <el-select v-model="setting.cate_id" placeholder="请选择" clearable>
- <el-option
- v-for="(item,index) in cateList"
- :key="item.id"
- :label="item.name"
- :value="item.id">
- </el-option>
- </el-select>
- </el-form-item>
- </el-form>
- </div>
- <span slot="footer" class="dialog-footer">
- <el-button @click="editGoodsDialog = false" type="default" size="small" >取消</el-button>
- <el-button type="primary" :loading="loading" style="margin-bottom: 10px;" size="small" @click="editGoodsComfirm">确定</el-button>
- </span>
- </el-dialog>
- </div>
- <script>
- const app = new Vue({
- el: '#app',
- data: {
- addType:'',
- cForm:{
- goods_id:[]
- },
- cateList:[],//分类列表
- page:1,
- limit:50,
- time:[], //本地存时间,请求时不发送
- search: {
- name : '',
- status:null,
- start:'',
- end:''
- },
- time:'',
- loading: false,
- activeName: '-1',
- list: [], //列表数据
- pagination: null,
- choose_list:[],
- cateForm:{
- id:0,
- name:'',
- status:0
- },
- setting:{
- id:0,
- contribution:0,
- contribution_percent:0,
- profit_percent:0,
- profit:0,
- cate_id:null
- },
- editGoodsDialog:false
- },
- mounted() {
- // 获取列表首页数据
- this.loadData(this.page,this.search); //获取列表数据
- this.getCateList()
- },
- methods: {
- selectGoodsWarehouse(val){
- //添加商品
- console.log('goods-id',val)
- //弹出选择框
- this.editGoodsDialog = true
- this.cForm = val
- // val.forEach(item =>{
- // console.log(5555555555,item.id)
- // this.cForm.goods_id.push(item.id)
- // })
- console.log('this.cForm',this.cForm.goods_id)
- this.addType = 'add'
- },
- chooseAll(){
- this.$refs.goodsSelect.chooseAll()
- },
- clearGoods(){
- this.$refs.goodsSelect.clear()
- },
- changeTime(e){
- if(e == null){
- this.search.start = ''
- this.search.end = ''
- }else{
- this.search.start = e[0]
- this.search.end = e[1]
- }
- console.log('选择时间',e)
-
- },
- getCateList(){
- this.loading = true;
- request({
- method: 'get',
- params: {
- r: 'blind-box/cate/index',
- page: this.page,
- limit:this.limit,
- status:1
- },
- }).then(e => {
- this.loading = false;
- if (e.data.code === 0) {
- this.cateList = e.data.data.list;
- } else {
- this.$message.error(e.data.msg);
- }
- }).catch(e => {
- });
- },
- loadData(page,others) {
- this.loading = true;
- console.log(666,this.search);
- request({
- method: 'get',
- params: {
- r: 'blind-box/goods/index',
- page: page,
- limit:this.limit,
- ...others, //其他搜索字段
- },
- }).then(e => {
- this.loading = false;
- if (e.data.code === 0) {
- this.list = e.data.data.list;
- console.log('this.list',this.list)
- this.pagination = e.data.data.pagination;
- } else {
- this.$message.error(e.data.msg);
- }
- }).catch(e => {
- });
- },
- pageChange(page) {
- this.page = page;
- this.loadData(this.page,this.search);
- },
- handleClick(tab, event) {
- this.page = 1;
- this.search.status = this.activeName;
- this.loadData(this.page,this.search)
- },
- handleSelectionChange(val,type) {
- console.log('val',val,type)
- let self = this;
- if(type == 'row'){
- self.choose_list.push(val.id)
- self.delGoods()
- }else{
- self.choose_list = [];
- val.forEach(function (item) {
- self.choose_list.push(item.id);
- })
- }
- },
- searchs() {
- this.page = 1;
- this.loadData(this.page,this.search);
- },
- editGoods(type,row){
- this.setting.contribution = row.contribution
- this.setting.contribution_percent = row.contribution_percent
- this.setting.profit_percent = row.profit_percent
- this.setting.profit = row.profit
- if(row.cate_id == 0){
- row.cate_id = null
- }
- this.setting.cate_id = row.cate_id
- this.setting.id = row.id
- this.editGoodsDialog = true
- },
- addGoods(){
- console.log('添加商品的id',this.cForm.goods_id)
- let goods_id = []
- this.cForm.forEach((item)=>{
- goods_id.push(item.id)
- })
- this.loading = true
- request({
- method: 'post',
- params: {
- r: 'blind-box/goods/add',
- },
- data: {
- goods_id:goods_id,
- ...this.setting
- }
- }).then(e => {
- this.loading = false;
- if (e.data.code === 0) {
- this.$message.success(e.data.msg);
- this.page = 1;
- this.loadData();
- this.editGoodsDialog = false
- } else {
- this.$message.error(e.data.msg);
- }
- }).catch(e => {
- });
- },
- editGoodsComfirm(row){
- console.log('addType',this.addType)
- if(this.addType == 'add'){
- this.addGoods()
- }else{
- this.loading = true
- request({
- method: 'post',
- params: {
- r: 'blind-box/goods/edit',
- },
- data: {
- id:row.id,
- ...this.setting
- }
- }).then(e => {
- this.loading = false;
- if (e.data.code === 0) {
- this.loading = false
- this.$message.success(e.data.msg);
- this.page = 1;
- this.loadData();
- this.editGoodsDialog = false
- } else {
- this.$message.error(e.data.msg);
- }
- }).catch(e => {
- });
- }
-
- },
- delGoods(){ //批量删除
- console.log(this.choose_list)
- if(this.choose_list.length == 0){
- this.$message.error('请选择商品')
- }else{
- this.$confirm('是否确定删除商品?', '提示', {
- confirmButtonText: '确定',
- cancelButtonText: '取消',
- type: 'warning'
- }).then(() => {
- this.loading = true;
- request({
- params: {
- r: 'blind-box/goods/del',
- },
- method: 'post',
- data: {
- id: this.choose_list,
- }
- }).then(e => {
- let res = e.data;
- this.loading = false;
- if (res.code === 0) {
- this.$message.success(res.msg);
- this.loadData();
- } else {
- this.$message.error(res.msg);
- }
- }).catch(e => {});
- }).catch(() => {
- this.$message({
- type: 'info',
- message: '系统错误'
- });
- });
- }
- }
- }
- });
- </script>
- <style>
- .el-tabs__header {
- font-size: 16px;
- }
- .table-body {
- padding: 20px;
- background-color: #fff;
- }
- .table-body .el-button {
- padding: 0 !important;
- border: 0;
- margin: 0 5px;
- }
- .input-item {
- width: 250px;
- margin: 0 0 20px;
- display: inline-block;
- }
- .input-item .el-input__inner {
- border-right: 0;
- }
- .input-item .el-input__inner:hover {
- border: 1px solid #dcdfe6;
- border-right: 0;
- outline: 0;
- }
- .input-item .el-input__inner:focus {
- border: 1px solid #dcdfe6;
- border-right: 0;
- outline: 0;
- }
- .input-item .el-input-group__append {
- background-color: #fff;
- border-left: 0;
- width: 10%;
- padding: 0;
- }
- .input-item .el-input-group__append .el-button {
- padding: 0;
- }
- .input-item .el-input-group__append .el-button {
- margin: 0;
- }
- .batch {
- margin: 0 0 20px;
- display: inline-block;
- }
- .batch .el-button {
- padding: 9px 15px !important;
- }
- .item-box{
- margin-right: 20px;
- }
- .item-box .label{
- margin-right: 8px;
- }
- .form-nickname{
- width: 180px;
- white-space:nowrap;
- overflow:hidden;
- text-overflow:ellipsis;
- }
- .index-video-url{
- width: 300px;
- }
- .index-video-url video{
- width: 100%;
- }
- .index-related-info{
- width: 500px;
- }
- .video-top{
- width: 100%;
- display: flex;
- align-items: flex-start;
- box-sizing: border-box;
- padding: 20px;
- /* opacity: .5; */
- background-color: #FFFFFF;
- }
- .video-top .top-right{
- line-height: 26px;
- }
- .video-top .top-right .top-title{
- font-size: 18px;
- white-space:nowrap;
- overflow:hidden;
- text-overflow:ellipsis;
- width: 360px;
- }
- .video-top .top-right .wrapper{
- display: flex;
- /* align-items: flex-start; */
- }
- .video-top .top-right .wrapper .to-copy{
- /* color: #03C5FF; */
- margin-left: 20px;
- }
- .video-top .top-right .detail-price{
- color: #BC0100;
- font-size: 18px;
- font-family: Microsoft YaHei;
- font-weight: bold;
- }
- /* .atooltip {
- background: #FFFFFF !important;
- border: none !important;
- } */
- .el-table th>.cell{
- color: #333;
- font-weight: bold;
- font-size: 14px;
- }
- .el-table__footer-wrapper, .el-table__header-wrapper{
- border-bottom: 1.4px solid #D6D6D6;
- }
- .award-money{
- color: #BC0100;
- }
- .flex-bew{
- display:flex;
- justify-content: space-between;
- width:100%;
- }
- .goods-name .cell{
- width: 250px;
- word-break: break-all;
- text-overflow: ellipsis;
- display: -webkit-box;
- -webkit-box-orient: vertical;
- -webkit-line-clamp: 2; /* 这里是超出几行省略 */
- overflow: hidden;
- }
- </style>
|