提交 a597f7b2 authored 作者: 吴德鹏's avatar 吴德鹏

魔方

上级 033c860a
package com.platform.controller;
import com.platform.entity.TbCfCubeEntity;
import com.platform.service.TbCfCubeService;
import com.platform.utils.PageUtils;
import com.platform.utils.Query;
import com.platform.utils.R;
import org.apache.shiro.authz.annotation.RequiresPermissions;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.ResponseBody;
import java.util.List;
import java.util.Map;
/**
* 魔方Controller
*
* @author lipengjun
* @date 2020-06-01 14:34:09
*/
@Controller
@RequestMapping("tbcfcube")
public class TbCfCubeController {
@Autowired
private TbCfCubeService tbCfCubeService;
/**
* 查看列表
*/
@RequestMapping("/list")
@RequiresPermissions("tbcfcube:list")
@ResponseBody
public R list(@RequestParam Map<String, Object> params) {
//查询列表数据
Query query = new Query(params);
List<TbCfCubeEntity> tbCfCubeList = tbCfCubeService.queryList(query);
int total = tbCfCubeService.queryTotal(query);
PageUtils pageUtil = new PageUtils(tbCfCubeList, total, query.getLimit(), query.getPage());
return R.ok().put("page", pageUtil);
}
/**
* 查看信息
*/
@RequestMapping("/info/{id}")
@RequiresPermissions("tbcfcube:info")
@ResponseBody
public R info(@PathVariable("id") String id) {
TbCfCubeEntity tbCfCube = tbCfCubeService.queryObject(id);
return R.ok().put("tbCfCube", tbCfCube);
}
/**
* 保存
*/
@RequestMapping("/save")
@RequiresPermissions("tbcfcube:save")
@ResponseBody
public R save(@RequestBody TbCfCubeEntity tbCfCube) {
tbCfCubeService.save(tbCfCube);
return R.ok();
}
/**
* 修改
*/
@RequestMapping("/update")
@RequiresPermissions("tbcfcube:update")
@ResponseBody
public R update(@RequestBody TbCfCubeEntity tbCfCube) {
tbCfCubeService.update(tbCfCube);
return R.ok();
}
/**
* 删除
*/
@RequestMapping("/delete")
@RequiresPermissions("tbcfcube:delete")
@ResponseBody
public R delete(@RequestBody String[] ids) {
tbCfCubeService.deleteBatch(ids);
return R.ok();
}
/**
* 查看所有列表
*/
@RequestMapping("/queryAll")
@ResponseBody
public R queryAll(@RequestParam Map<String, Object> params) {
List<TbCfCubeEntity> list = tbCfCubeService.queryList(params);
return R.ok().put("list", list);
}
}
package com.platform.dao;
import com.platform.entity.TbCfCubeEntity;
/**
* 魔方Dao
*
* @author lipengjun
* @date 2020-06-01 14:34:09
*/
public interface TbCfCubeDao extends BaseDao<TbCfCubeEntity> {
}
package com.platform.entity;
import java.io.Serializable;
import java.util.Date;
/**
* 魔方实体
* 表名 tb_cf_cube
*
* @author lipengjun
* @date 2020-06-01 14:43:29
*/
public class TbCfCubeEntity implements Serializable {
private static final long serialVersionUID = 1L;
/**
* 魔方ID
*/
private String id;
/**
* 魔方标题
*/
private String cubeTitle;
/**
* 标题图片
*/
private String headerImage;
/**
* 商品ID集合
*/
private String itemIds;
/**
* 排序
*/
private Integer sort;
/**
* 是否可用 0:不可用 1:可用
*/
private Integer isEnabled;
/**
* 创建时间
*/
private Date createTime;
/**
* 更新时间
*/
private Date updateTime;
/**
* 设置:魔方ID
*/
public void setId(String id) {
this.id = id;
}
/**
* 获取:魔方ID
*/
public String getId() {
return id;
}
/**
* 设置:魔方标题
*/
public void setCubeTitle(String cubeTitle) {
this.cubeTitle = cubeTitle;
}
/**
* 获取:魔方标题
*/
public String getCubeTitle() {
return cubeTitle;
}
/**
* 设置:标题图片
*/
public void setHeaderImage(String headerImage) {
this.headerImage = headerImage;
}
/**
* 获取:标题图片
*/
public String getHeaderImage() {
return headerImage;
}
/**
* 设置:商品ID集合
*/
public void setItemIds(String itemIds) {
this.itemIds = itemIds;
}
/**
* 获取:商品ID集合
*/
public String getItemIds() {
return itemIds;
}
/**
* 设置:排序
*/
public void setSort(Integer sort) {
this.sort = sort;
}
/**
* 获取:排序
*/
public Integer getSort() {
return sort;
}
/**
* 设置:是否可用 0:不可用 1:可用
*/
public void setIsEnabled(Integer isEnabled) {
this.isEnabled = isEnabled;
}
/**
* 获取:是否可用 0:不可用 1:可用
*/
public Integer getIsEnabled() {
return isEnabled;
}
/**
* 设置:创建时间
*/
public void setCreateTime(Date createTime) {
this.createTime = createTime;
}
/**
* 获取:创建时间
*/
public Date getCreateTime() {
return createTime;
}
/**
* 设置:更新时间
*/
public void setUpdateTime(Date updateTime) {
this.updateTime = updateTime;
}
/**
* 获取:更新时间
*/
public Date getUpdateTime() {
return updateTime;
}
}
package com.platform.service;
import com.platform.entity.TbCfCubeEntity;
import java.util.List;
import java.util.Map;
/**
* 魔方Service接口
*
* @author lipengjun
* @date 2020-06-01 14:34:09
*/
public interface TbCfCubeService {
/**
* 根据主键查询实体
*
* @param id 主键
* @return 实体
*/
TbCfCubeEntity queryObject(String id);
/**
* 分页查询
*
* @param map 参数
* @return list
*/
List<TbCfCubeEntity> queryList(Map<String, Object> map);
/**
* 分页统计总数
*
* @param map 参数
* @return 总数
*/
int queryTotal(Map<String, Object> map);
/**
* 保存实体
*
* @param tbCfCube 实体
* @return 保存条数
*/
int save(TbCfCubeEntity tbCfCube);
/**
* 根据主键更新实体
*
* @param tbCfCube 实体
* @return 更新条数
*/
int update(TbCfCubeEntity tbCfCube);
/**
* 根据主键删除
*
* @param id
* @return 删除条数
*/
int delete(String id);
/**
* 根据主键批量删除
*
* @param ids
* @return 删除条数
*/
int deleteBatch(String[] ids);
}
package com.platform.service.impl;
import com.platform.dao.TbCfCubeDao;
import com.platform.entity.TbCfCubeEntity;
import com.platform.service.TbCfCubeService;
import com.platform.utils.IdUtil;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import java.util.Date;
import java.util.List;
import java.util.Map;
/**
* 魔方Service实现类
*
* @author lipengjun
* @date 2020-06-01 14:34:09
*/
@Service("tbCfCubeService")
public class TbCfCubeServiceImpl implements TbCfCubeService {
@Autowired
private TbCfCubeDao tbCfCubeDao;
@Override
public TbCfCubeEntity queryObject(String id) {
return tbCfCubeDao.queryObject(id);
}
@Override
public List<TbCfCubeEntity> queryList(Map<String, Object> map) {
return tbCfCubeDao.queryList(map);
}
@Override
public int queryTotal(Map<String, Object> map) {
return tbCfCubeDao.queryTotal(map);
}
@Override
public int save(TbCfCubeEntity tbCfCube) {
tbCfCube.setId(IdUtil.createIdbyUUID());
tbCfCube.setCreateTime(new Date());
tbCfCube.setUpdateTime(new Date());
return tbCfCubeDao.save(tbCfCube);
}
@Override
public int update(TbCfCubeEntity tbCfCube) {
tbCfCube.setUpdateTime(new Date());
return tbCfCubeDao.update(tbCfCube);
}
@Override
public int delete(String id) {
return tbCfCubeDao.delete(id);
}
@Override
public int deleteBatch(String[] ids) {
return tbCfCubeDao.deleteBatch(ids);
}
}
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE mapper PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" "http://mybatis.org/dtd/mybatis-3-mapper.dtd">
<mapper namespace="com.platform.dao.TbCfCubeDao">
<resultMap type="com.platform.entity.TbCfCubeEntity" id="tbCfCubeMap">
<result property="id" column="id"/>
<result property="cubeTitle" column="cube_title"/>
<result property="headerImage" column="header_image"/>
<result property="itemIds" column="item_ids"/>
<result property="sort" column="sort"/>
<result property="isEnabled" column="is_enabled"/>
<result property="createTime" column="create_time"/>
<result property="updateTime" column="update_time"/>
</resultMap>
<select id="queryObject" resultType="com.platform.entity.TbCfCubeEntity">
select
`id`,
`cube_title`,
`header_image`,
`item_ids`,
`sort`,
`is_enabled`,
`create_time`,
`update_time`
from tb_cf_cube
where id = #{id}
</select>
<select id="queryList" resultType="com.platform.entity.TbCfCubeEntity">
select
`id`,
`cube_title`,
`header_image`,
`item_ids`,
`sort`,
`is_enabled`,
`create_time`,
`update_time`
from tb_cf_cube
WHERE 1=1
<if test="name != null and name.trim() != ''">
AND name LIKE concat('%',#{name},'%')
</if>
<choose>
<when test="sidx != null and sidx.trim() != ''">
order by ${sidx} ${order}
</when>
<otherwise>
order by id desc
</otherwise>
</choose>
<if test="offset != null and limit != null">
limit #{offset}, #{limit}
</if>
</select>
<select id="queryTotal" resultType="int">
select count(*) from tb_cf_cube
WHERE 1=1
<if test="name != null and name.trim() != ''">
AND name LIKE concat('%',#{name},'%')
</if>
</select>
<insert id="save" parameterType="com.platform.entity.TbCfCubeEntity">
insert into tb_cf_cube(
`id`,
`cube_title`,
`header_image`,
`item_ids`,
`sort`,
`is_enabled`,
`create_time`,
`update_time`)
values(
#{id},
#{cubeTitle},
#{headerImage},
#{itemIds},
#{sort},
#{isEnabled},
#{createTime},
#{updateTime})
</insert>
<update id="update" parameterType="com.platform.entity.TbCfCubeEntity">
update tb_cf_cube
<set>
<if test="cubeTitle != null">`cube_title` = #{cubeTitle}, </if>
<if test="headerImage != null">`header_image` = #{headerImage}, </if>
<if test="itemIds != null">`item_ids` = #{itemIds}, </if>
<if test="sort != null">`sort` = #{sort}, </if>
<if test="isEnabled != null">`is_enabled` = #{isEnabled}, </if>
<if test="createTime != null">`create_time` = #{createTime}, </if>
<if test="updateTime != null">`update_time` = #{updateTime}</if>
</set>
where id = #{id}
</update>
<delete id="delete">
delete from tb_cf_cube where id = #{value}
</delete>
<delete id="deleteBatch">
delete from tb_cf_cube where id in
<foreach item="id" collection="array" open="(" separator="," close=")">
#{id}
</foreach>
</delete>
</mapper>
\ No newline at end of file
...@@ -2,13 +2,13 @@ ...@@ -2,13 +2,13 @@
#jdbc.username=root #jdbc.username=root
#jdbc.password=root #jdbc.password=root
#jdbc.url=jdbc:mysql://47.106.242.175:3306/chinafrica?allowMultiQueries=true&useSSL=false&useUnicode=true&characterEncoding=UTF-8 jdbc.url=jdbc:mysql://47.106.242.175:3306/chinafrica?allowMultiQueries=true&useSSL=false&useUnicode=true&characterEncoding=UTF-8
#jdbc.username=root jdbc.username=root
#jdbc.password=diaoyun666 jdbc.password=diaoyun666
jdbc.url: jdbc:mysql://159.138.48.71:3306/chinafrica?useUnicode=true&characterEncoding=UTF-8&rewriteBatchedStatements=true&autoReconnect=true&failOverReadOnly=false&zeroDateTimeBehavior=convertToNull&useSSL=false #jdbc.url: jdbc:mysql://159.138.48.71:3306/chinafrica?useUnicode=true&characterEncoding=UTF-8&rewriteBatchedStatements=true&autoReconnect=true&failOverReadOnly=false&zeroDateTimeBehavior=convertToNull&useSSL=false
jdbc.username: root #jdbc.username: root
jdbc.password: Diaoyunnuli.8 #jdbc.password: Diaoyunnuli.8
jdbc.initialSize=5 jdbc.initialSize=5
jdbc.maxActive=30 jdbc.maxActive=30
......
...@@ -2,13 +2,13 @@ ...@@ -2,13 +2,13 @@
#jdbc.username=root #jdbc.username=root
#jdbc.password=root #jdbc.password=root
#jdbc.url=jdbc:mysql://47.106.242.175:3306/chinafrica?allowMultiQueries=true&useSSL=false&useUnicode=true&characterEncoding=UTF-8 jdbc.url=jdbc:mysql://47.106.242.175:3306/chinafrica?allowMultiQueries=true&useSSL=false&useUnicode=true&characterEncoding=UTF-8
#jdbc.username=root jdbc.username=root
#jdbc.password=diaoyun666 jdbc.password=diaoyun666
jdbc.url: jdbc:mysql://159.138.48.71:3306/chinafrica?useUnicode=true&characterEncoding=UTF-8&rewriteBatchedStatements=true&autoReconnect=true&failOverReadOnly=false&zeroDateTimeBehavior=convertToNull&useSSL=false #jdbc.url: jdbc:mysql://159.138.48.71:3306/chinafrica?useUnicode=true&characterEncoding=UTF-8&rewriteBatchedStatements=true&autoReconnect=true&failOverReadOnly=false&zeroDateTimeBehavior=convertToNull&useSSL=false
jdbc.username: root #jdbc.username: root
jdbc.password: Diaoyunnuli.8 #jdbc.password: Diaoyunnuli.8
jdbc.initialSize=5 jdbc.initialSize=5
jdbc.maxActive=30 jdbc.maxActive=30
......
<!DOCTYPE html>
<html xmlns:v-bind="http://www.w3.org/1999/xhtml">
<head>
<title>魔方</title>
#parse("sys/header.html")
<style>
body {
background: #f9f9f9;
}
ul li {
list-style: none;
}
.category-container {
min-height: 100%;
padding-bottom: 80px;
}
.edit-container {
position: relative;
height: 500px;
}
.btn-container {
position: absolute;
bottom: 0;
right: 0;
}
.productList {
padding-bottom: 10px;
}
.productList, .search {
display: flex;
justify-content: start;
}
.productList-style-start {
display: flex;
justify-content: start;
}
.vRadio {
display: inline-block;
width: 20px;
height: 20px;
background: #eeeeee;
border-radius: 4px;
transition: all 0.4s;
}
.vradio-wrapper {
cursor: pointer;
}
.vRadio-active {
background: #000;
opacity: 0.6;
}
.vradio-wrapper > i {
vertical-align: top;
}
#searchjqGrid {
width: 100%;
margin-top: 10px;
}
#showItems {
margin-top: 20px;
}
.app-mask {
width: 50%;
height: 50%;
position: absolute;
left: 0;
top: 0;
z-index: -1;
background: #000;
opacity: 0.5;
}
#app {
width: 100vw;
height: 100vh;
position: fixed;
top: 0px;
left: 0px;
z-index: 100;
}
</style>
</head>
<body>
<div id="rrapp" v-cloak style="height: calc(100% - 15px);">
<div v-show="showList" style="height: 100%;">
<Row :gutter="16">
<div class="search-group">
<i-col span="4">
<i-input v-model="q.name" @on-enter="query" placeholder="名称"/>
</i-col>
<i-button @click="query">查询</i-button>
<i-button @click="reloadSearch">重置</i-button>
</div>
<div class="buttons-group">
#if($shiro.hasPermission("tbcfcube:save"))
<i-button type="info" @click="add"><i class="fa fa-plus"></i>&nbsp;新增</i-button>
#end
#if($shiro.hasPermission("tbcfcube:update"))
<i-button type="warning" @click="update"><i class="fa fa-pencil-square-o"></i>&nbsp;修改</i-button>
#end
#if($shiro.hasPermission("tbcfcube:delete"))
<i-button type="error" @click="del"><i class="fa fa-trash-o"></i>&nbsp;删除</i-button>
#end
</div>
</Row>
<table id="jqGrid"></table>
</div>
<Card v-show="!showList">
<p slot="title">{{title}}</p>
<i-form ref="formValidate" :model="tbCfCube" :rules="ruleValidate" :label-width="80">
<Form-item label="魔方标题" prop="cubeTitle">
<i-input v-model="tbCfCube.cubeTitle" placeholder="魔方标题" style="width:500px"/>
</Form-item>
<Form-item label="标题图片" prop="headerImage">
<!-- <i-input v-model="tbCfCube.headerImage" placeholder="标题图片" style="width:500px"/>-->
<img v-bind:src="tbCfCube.headerImage" v-show="!!tbCfCube.headerImage"/>
<input type="file" placeholder="栏目图片" @change="tirggerFile($event)"/>
</Form-item>
<div class="choose">
<h5 style="margin-left: 20px;float: left">商品选择</h5>
<transition-group tag="ul" name="slide">
<li v-for="(el,i) in chooseItems" :key="i">
<div class="app-item">
<i-button class="prev-del" type="error" size="small"
@click="delParamster(i)" style="float: right;margin-right: 980px">删除
</i-button>
<i-button class="prev-choose" type="primary" size="small"
@click="selectItems" style="float: right;margin-right: 10px">选择
</i-button>
<Form-item>
<i-input v-model="el.item" placeholder="商品选择"
style="width:500px;float: left"/>
</Form-item>
</div>
</li>
</transition-group>
</div>
<Form-item>
<i-button type="primary" @click="addItem">新增商品</i-button>
</Form-item>
<div id="app" v-show="showItems">
<div class="app-mask"></div>
<Card class="category-container">
<i-button class="prev-del" type="info"
@click="back(itemId)">返回
</i-button>
<p slot="title">
<span
v-for="(element,index) in items" :key='index'
@click='vHandleChange(element,index)'
style="margin-left:20px;"
class="vradio-wrapper"
>
<span class="vRadio" :class="[element.isChecked?'vRadio-active':null]"></span>
<i>{{element.name}}</i>
</span>
</p>
<section class="edit-container">
<!-- 链接 -->
<div v-if='typeActive==0'>
<i-Input v-model="link" placeholder="请输入目标链接"/>
</div>
<!-- 分类子页面 -->
<!-- <div v-else-if='typeActive==1'>-->
<!-- <span>一级分类</span>-->
<!-- <i-Select v-model="subcategoryListsActive" style="width:200px" @on-change="changeSubCateType">-->
<!-- <i-Option v-for="item in subCategoryLists" :value="item.value" :key="item.value">{{ item.label }}</i-Option>-->
<!-- </i-Select>-->
<!-- <span style="margin-left:20px;">二级分类</span>-->
<!-- <i-Select v-model="subsubCategoryListsActive" style="width:200px">-->
<!-- <i-Option v-for="item in subsubCategoryLists" :value="item.value" :key="item.value">{{ item.label }}</i-Option>-->
<!-- </i-Select>-->
<!-- </div>-->
<!-- 商品列表页 -->
<div v-else-if='typeActive==1'>
<div class="productList-style-start">
<div>
<span>一级分类</span>
<i-Select v-model.sync="categoryListsActive1" style="width:100px"
@on-change="changeSubCateType">
<i-Option v-for="item in CategoryLists1" :value="item.value" :key="item.value">
{{ item.label }}
</i-Option>
</i-Select>
</div>
<div>
<span style="margin-left:20px;">二级分类</span>
<i-Select v-model.sync="categoryListsActive2" @on-change="queryMiniCatagory(2)"
style="width:100px">
<i-Option v-for="item in CategoryLists2" :value="item.value" :key="item.value">
{{ item.label }}
</i-Option>
</i-Select>
</div>
<div>
<span style="margin-left:20px;">三级分类</span>
<i-Select v-model.sync="categoryListsActive3" style="width:100px">
<i-Option v-for="item in CategoryLists3" :value="item.value" :key="item.value">
{{ item.label }}
</i-Option>
</i-Select>
</div>
</div>
<i-Button type="warning" style="float: right;margin-top:30px;width:100px;"
@click='resetSelectedCategory'>重置
</i-Button>
</div>
<!-- 商品 -->
<div v-else-if="typeActive==2">
<div class="productList-style-start">
<div>
<span>一级分类</span>
<i-Select v-model="commoditycategoryListsActive1" style="width:100px"
@on-change="changeSubCateType">
<i-Option v-for="item in commodityCategoryLists1" :value="item.value"
:key="item.value">{{ item.label }}
</i-Option>
</i-Select>
</div>
<div>
<span style="margin-left:20px;">二级分类</span>
<i-Select v-model="commoditycategoryListsActive2" @on-change="queryMiniCatagory(3)"
style="width:100px">
<i-Option v-for="item in commodityCategoryLists2" :value="item.value"
:key="item.value">{{ item.label }}
</i-Option>
</i-Select>
</div>
<div>
<span style="margin-left:20px;">三级分类</span>
<i-Select v-model="commoditycategoryListsActive3" style="width:100px">
<i-Option v-for="item in commodityCategoryLists3" :value="item.value"
:key="item.value">{{ item.label }}
</i-Option>
</i-Select>
</div>
</div>
<div class="search" style="margin-top:20px;">
<div>
<i-Input v-model="search"
placeholder="请输入搜索内容(可选)"
style="width:500px;"/>
</div>
<i-Button
type="primary"
style="width:100px;"
@click='handleSearch()'
>搜索
</i-Button>
<i-Button style="width:100px;" @click="resetSelectedCategory('commodity')">重置</i-Button>
</div>
<section id="showItems">
<table id="searchjqGrid"></table>
</section>
</div>
<div v-else-if="typeActive==3">
<div>
<span style="margin-left:20px;">商品标签</span>
<i-Select v-model="tagListsActive" style="width:100px">
<i-Option v-for="item in tagLists" :value="item.value" :key="item.value">{{
item.label }}
</i-Option>
</i-Select>
</div>
</div>
</section>
</Card>
</div>
<Form-item label="排序" prop="sort">
<i-input v-model="tbCfCube.sort" placeholder="排序" style="width:500px"/>
</Form-item>
<Form-item label="是否启用" prop="isEnabled">
<i-select placeholder="请选择" v-model="tbCfCube.isEnabled" style="width:500px">
<i-option v-for=" e in chooseOptions"
:value="e.value">{{e.label}}
</i-option>
</i-select>
</Form-item>
<Form-item>
<i-button type="primary" @click="handleSubmit('formValidate')">提交</i-button>
<i-button type="warning" @click="reload" style="margin-left: 8px"/>
返回</i-button>
<i-button type="ghost" @click="handleReset('formValidate')" style="margin-left: 8px">重置</i-button>
</Form-item>
</i-form>
</Card>
</div>
<script src="${rc.contextPath}/js/sys/tbcfcube.js?_${date.systemTime}"></script>
</body>
</html>
\ No newline at end of file
...@@ -298,10 +298,10 @@ ...@@ -298,10 +298,10 @@
<!-- </Form-item>--> <!-- </Form-item>-->
<Form-item label="是否展示" prop="enableFlag"> <Form-item label="是否展示" prop="enableFlag">
<i-select placeholder="请选择" v-model="tbCfHomePage.enableFlag"> <i-select placeholder="请选择" v-model="tbCfHomePage.enableFlag">
<i-option v-for="(el,i) in chooseOptions" :key='i' <i-option v-for="(el,i) in chooseOptions" :key='i'
:value="el.value">{{el.label}} :value="el.value">{{el.label}}
</i-option> </i-option>
</i-select> </i-select>
</Form-item> </Form-item>
<Form-item> <Form-item>
<i-button type="primary" @click="handleSubmit('formValidate')">提交</i-button> <i-button type="primary" @click="handleSubmit('formValidate')">提交</i-button>
......
$(function () {
$("#jqGrid").Grid({
url: '../tbcfcube/list',
colModel: [
{label: 'id', name: 'id', index: 'id', key: true, hidden: true},
{label: '魔方标题', name: 'cubeTitle', index: 'cube_title', width: 80},
{label: '标题图片', name: 'headerImage', index: 'header_image', width: 80},
{label: '排序', name: 'sort', index: 'sort', width: 80},
{label: '是否启用', name: 'isEnabled', index: 'is_enabled', width: 80},
{label: '创建时间', name: 'createTime', index: 'create_time', width: 80}]
});
});
let vm = new Vue({
el: '#rrapp',
data: {
typeActive: 2, //显示索引
items: [],
/*
--链接方式
*/
link: null,//链接
/*
--分类子页面
*/
// 一级分类
subCategoryLists: [
{
value: 'New',
label: 'New'
}
],
subcategoryListsActive: null,
// 二级分类
subsubCategoryLists: [
{
value: 'York',
label: 'York'
}
],
subsubCategoryListsActive: null,
/*
--商品列表页
*/
//一级
CategoryLists1: [
{
value: '一级',
label: '一级'
}
],
categoryListsActive1: null,
//二级
CategoryLists2: [
{
value: '二级',
label: '二级'
}
],
categoryListsActive2: null,
//三级
CategoryLists3: [
{
value: '三级',
label: '三级'
}
],
categoryListsActive3: null,
// 独立
tagLists: [
{
value: '独立',
label: '独立'
}
],
tagListsActive: null,
/*
--商品
*/
commodityCategoryLists1: [
{
value: '商品一级',
label: '商品一级'
}
],
commoditycategoryListsActive1: null,
//二级
commodityCategoryLists2: [
{
value: '商品二级',
label: '商品二级'
}
],
commoditycategoryListsActive2: null,
//三级
commodityCategoryLists3: [
{
value: '商品三级',
label: '商品三级'
}
],
commoditycategoryListsActive3: null,
// 搜索
search: null,
showList: true,
title: null,
tbCfPosters: {},
ruleValidate: {
name: [
{required: true, message: '名称不能为空', trigger: 'blur'}
]
},
showItems: false,
radio: 1,
showList: true,
title: null,
chooseItems: [{item: null}],
tbCfCube: {},
chooseOptions: [{
value: 0,
label: '不启用'
}, {
value: 1,
label: '启用'
}],
ruleValidate: {
name: [
{required: true, message: '名称不能为空', trigger: 'blur'}
]
},
q: {
name: ''
}
},
methods: {
tirggerFile: function (event) {
var file = event.target.files[0];
var formData = new FormData();
formData.append("file", file);
$.ajax({
url: "../api/upload/image/",
type: "POST",
data: formData,
cache: false, //不设置缓存
processData: false, // 不处理数据
contentType: false,// 不设置内容类型
success: function (result) {
result = JSON.parse(result);
//console.log(result)
if (result.errno == 0) {//成功
vm.tbCfCube.headerImage = result.data;
vm.$forceUpdate();
} else {
iview.Message.error(result.errmsg);
}
}
});
},
back(id) {
this.showItems = false;
console.log(111,id)
},
handleSubmit: function (name) {
let redirectUrl = null;
let postersType = this.typeActive; //海报类型
switch (this.typeActive) {
case 0:
redirectUrl = this.link;
redirectUrl ? vm.saveOrUpdate(redirectUrl) : this.$Message.info('请输入链接')
break;
case 1:
this.categoryListsActive1 ? (() => {
redirectUrl = `${this.categoryListsActive1},${this.categoryListsActive2},${this.categoryListsActive3}`;
vm.saveOrUpdate(redirectUrl)
})() : this.$Message.info('至少选择一种分类')
break;
case 2:
redirectUrl = getSelectedRows("#searchjqGrid")[0];
if (redirectUrl) {
vm.saveOrUpdate(redirectUrl)
}
break;
case 3:
redirectUrl = this.tagListsActive;
if (redirectUrl) {
vm.saveOrUpdate(redirectUrl)
}
break;
default :
vm.saveOrUpdate('')
break;
}
// handleSubmitValidate(this, name, function () {
// vm.saveOrUpdate()
// });
},
handleReset: function (name) {
handleResetForm(this, name);
},
$(name) {
return document.querySelectorAll(name);
},
//切换海报导航定向方式
vHandleChange(element, _index) {
this.items.forEach((item, index) => {
item.isChecked = false
})
this.typeActive = _index;
this.items[_index].isChecked = true;
},
/* 重置选中的类别 */
resetSelectedCategory(e) {
if (e === 'commodity') {
this.search = this.commoditycategoryListsActive1 = this.commoditycategoryListsActive2 = this.commoditycategoryListsActive3 = null;
} else {
this.categoryListsActive = this.categoryListsActive3 = this.categoryListsActive2 = this.categoryListsActive1 = null;
}
},
/* 搜索 */
handleSearch(e) {
1 == 1 ? (() => {
$('#showItems').children().remove();
$('#showItems').append(`<table id="searchjqGrid"></table>`);
function beforeSelectRow() {
$("#searchjqGrid").jqGrid('resetSelection');
return (true);
}
let _this = this;
$(function () {
$("#searchjqGrid").Grid({
url: `../tbcfstationitem/list?itemCategory=${_this.commoditycategoryListsActive1 || ''}&typeTwo=${_this.commoditycategoryListsActive2 || ''}&typeThree=${_this.commoditycategoryListsActive3 || ''}&name=${vm.search || e || ''}`,
colModel: [
{label: 'itemId', name: 'itemId', index: 'item_id', key: true, hidden: true},
{label: '商品图片', name: 'itemImg', index: 'item_img', width: 50, formatter: imageFormat},
{label: '商品编号', name: 'itemCode', index: 'item_code', width: 160},
{label: '商品名称', name: 'itemName', index: 'item_name', width: 160},
/* {label: '商品标题', name: 'itemBrief', index: 'item_brief', width: 120},*/
/*{label: '商品链接', name: 'itemUrl', index: 'item_url', width: 80,formatter:linkFormat},*/
{label: '商品原价', name: 'itemPrice', index: 'item_price', width: 65},
{label: '商品现价', name: 'discountPrice', index: 'discount_price', width: 55},
{label: '库存', name: 'itemCount', index: 'item_count', width: 55},
{label: '点击量', name: 'itemNum', index: 'item_num', width: 55},
/*{label: '所属平台', name: 'platformCode', index: 'platform_code', width: 80},
{label: '平台名', name: 'platformName', index: 'platform_name', width: 80},*/
{label: '供应商', name: 'supplier', index: 'supplier', width: 80},
{label: '商品一级分类', name: 'goodtype', index: 'goodtype', width: 80},
{label: '商品二级分类', name: 'title', index: 'title', width: 80},
{label: '商品品名', name: 'dname', index: 'itemDescritionId', width: 120},
{
label: '状态',
name: 'enableFlag',
index: 'enable_flag',
width: 120,
formatter: itemStatusFormat
},
{label: '创建日期', name: 'createTime', index: 'create_time', width: 160}
],
multiselect: true,
multiboxonly: true,
beforeSelectRow: beforeSelectRow,
});
});
})() : alert('未输入搜索内容~');
},
//获取分类子页面二级分类数据
changeSubCateType(callback = null) {
let ID = null;
if (this.typeActive === 1000) {
ID = this.subcategoryListsActive
} else if (this.typeActive === 1) {
ID = this.categoryListsActive1
} else {
ID = this.commoditycategoryListsActive1
}
this.subsubCategoryLists = [];
this.CategoryLists2 = [];
this.commodityCategoryLists2 = [];
$.get('../tbcfstationitem/queryByItemType?typeId=' + ID, res => {
let _res = JSON.parse(res);
_res.code === 0 ? (() => {
if (this.typeActive === 1000) {
_res.list.forEach((item) => {
this.subsubCategoryLists.push({
label: item.goodstwotypeTitle,
value: item.goodstwotypeId
})
})
} else if (this.typeActive === 1) {
_res.list.forEach((item) => {
this.CategoryLists2.push({
label: item.goodstwotypeTitle,
value: item.goodstwotypeId
})
})
} else {
_res.list.forEach((item) => {
this.commodityCategoryLists2.push({
label: item.goodstwotypeTitle,
value: item.goodstwotypeId
})
})
}
callback ? callback() : null;
})() : null
})
},
//查询三级分类
queryMiniCatagory(status, callback = null) {
let ID = null
status === 2 ? ID = this.categoryListsActive2 : ID = this.commoditycategoryListsActive2
$.get('../tbcfstationitem/queryByItemTypeTwo?typeTwoId=' + ID, res => {
this.CategoryLists3 = [];
this.commodityCategoryLists3 = [];
let _res = JSON.parse(res);
_res.code === 0 ? (() => {
_res.descripiton.forEach((item) => {
this.CategoryLists3.push({
label: item.descripitionName,
value: item.descripitionId
})
this.commodityCategoryLists3.push({
label: item.descripitionName,
value: item.descripitionId
})
})
callback ? callback() : null;
})() : null
})
},
selectItems() {
this.showItems = true;
},
delParamster(i) {
if (this.chooseItems.length <= 1) {
this.$Message.info('必须保留一个商品');
} else {
let arr = new Array();
this.chooseItems.map((item, index) => {
if (i !== index) {
arr.push(item)
}
})
this.chooseItems = arr;
}
},
addItem() {
if (this.chooseItems.length > 5) {
this.$Message.info('最多添加6个商品');
} else {
this.chooseItems.push({
item: null
})
}
},
query: function () {
vm.reload();
},
add: function () {
vm.showList = false;
vm.title = "新增";
vm.tbCfCube = {};
},
update: function (event) {
let id = getSelectedRow("#jqGrid");
if (id == null) {
return;
}
vm.showList = false;
vm.title = "修改";
vm.getInfo(id);
},
saveOrUpdate: function (event) {
let url = vm.tbCfCube.id == null ? "../tbcfcube/save" : "../tbcfcube/update";
Ajax.request({
url: url,
params: JSON.stringify(vm.tbCfCube),
type: "POST",
contentType: "application/json",
successCallback: function (r) {
alert('操作成功', function (index) {
vm.reload();
});
}
});
},
del: function (event) {
let ids = getSelectedRows("#jqGrid");
if (ids == null) {
return;
}
confirm('确定要删除选中的记录?', function () {
Ajax.request({
url: "../tbcfcube/delete",
params: JSON.stringify(ids),
type: "POST",
contentType: "application/json",
successCallback: function () {
alert('操作成功', function (index) {
vm.reload();
});
}
});
});
},
getInfo: function (id) {
Ajax.request({
url: "../tbcfcube/info/" + id,
async: true,
successCallback: function (r) {
vm.tbCfCube = r.tbCfCube;
}
});
},
reload: function (event) {
vm.showList = true;
let page = $("#jqGrid").jqGrid('getGridParam', 'page');
$("#jqGrid").jqGrid('setGridParam', {
postData: {'name': vm.q.name},
page: page
}).trigger("reloadGrid");
vm.handleReset('formValidate');
},
reloadSearch: function () {
vm.q = {
name: ''
};
vm.reload();
},
handleSubmit: function (name) {
handleSubmitValidate(this, name, function () {
vm.saveOrUpdate()
});
},
handleReset: function (name) {
handleResetForm(this, name);
}
}
,
created() {
document.onkeydown=(e)=>{
if(this.search&&e.keyCode===13){
this.handleSearch()
}
}
//获取分类子页面一级分类数据
$.get('../tbcfgoodstype/queryAll', res => {
res.code === 0 ? (() => {
this.subCategoryLists = [];
this.commodityCategoryLists1 = [];
this.CategoryLists1 = [];
res.list.forEach((item) => {
this.subCategoryLists.push({
label: item.goodstypeTitle,
value: item.goodstypeId
});
this.commodityCategoryLists1.push({
label: item.goodstypeTitle,
value: item.goodstypeId
});
this.CategoryLists1.push({
label: item.goodstypeTitle,
value: item.goodstypeId
})
})
})() : null
})
//获取标签
$.get('../tbcflabel/queryAll?timestamp=' + new Date().getTime(), res => {
this.tagLists=[];
let OBJ_res = JSON.parse(res);
OBJ_res.list.forEach((item) => {
console.log('labelName',item.labelName)
this.tagLists.push({
label: item.labelName,
value: item.id
});
})
})
},
mounted() {
}
});
\ No newline at end of file
Markdown 格式
0%
您添加了 0 到此讨论。请谨慎行事。
请先完成此评论的编辑!
注册 或者 后发表评论