提交 b79693bd authored 作者: zgy's avatar zgy

一、二级分类新增图片

上级 d1b10389
......@@ -4,11 +4,11 @@ import java.io.Serializable;
import java.util.Date;
/**
* 实体
* 商品二级分类表实体
* 表名 tb_cf_goodstwotype
*
* @author lipengjun
* @date 2019-10-15 15:06:31
* @date 2020-03-05 13:29:28
*/
public class TbCfGoodstwotypeEntity implements Serializable {
private static final long serialVersionUID = 1L;
......@@ -25,6 +25,10 @@ public class TbCfGoodstwotypeEntity implements Serializable {
* 商品一级分类id
*/
private String goodstypeId;
/**
* 二级分类图片
*/
private String goodstwotypeUrl;
/**
* 设置:商品二级分类Id
......@@ -65,4 +69,17 @@ public class TbCfGoodstwotypeEntity implements Serializable {
public String getGoodstypeId() {
return goodstypeId;
}
/**
* 设置:二级分类图片
*/
public void setGoodstwotypeUrl(String goodstwotypeUrl) {
this.goodstwotypeUrl = goodstwotypeUrl;
}
/**
* 获取:二级分类图片
*/
public String getGoodstwotypeUrl() {
return goodstwotypeUrl;
}
}
......@@ -23,6 +23,16 @@ public class GoodsTypeToGoodsTwo implements Serializable {
private String goodstypeTitle;
private String goodstwotypeUrl;
public String getGoodstwotypeUrl() {
return goodstwotypeUrl;
}
public void setGoodstwotypeUrl(String goodstwotypeUrl) {
this.goodstwotypeUrl = goodstwotypeUrl;
}
/**
* 设置:商品二级分类Id
*/
......
......@@ -7,6 +7,7 @@
<result property="goodstwotypeId" column="goodstwotype_id"/>
<result property="goodstwotypeTitle" column="goodstwotype_title"/>
<result property="goodstypeId" column="goodstype_id"/>
<result property="goodstwotypeUrl" column="goodstwotype_url"/>
</resultMap>
<resultMap type="com.platform.entity.merge.GoodsTypeToGoodsTwo" id="GoodsToTwo">
......@@ -14,12 +15,14 @@
<result property="goodstwotypeTitle" column="goodstwotype_title"/>
<result property="goodstypeId" column="goodstype_id"/>
<result property="goodstypeTitle" column="goodstype_title"/>
<result property="goodstwotypeUrl" column="goodstwotype_url"/>
</resultMap>
<select id="queryGoodsTypeId" resultMap="GoodsToTwo">
SELECT
tw.`goodstwotype_id`,
tw.`goodstwotype_title`,
tw.`goodstwotype_url`,
ds.`goodstype_id`,
ds.`goodstype_title`
FROM tb_cf_goodstwotype tw
......@@ -30,6 +33,7 @@
select
`goodstwotype_id`,
`goodstwotype_title`,
`goodstwotype_url`,
`goodstype_id`
from tb_cf_goodstwotype
WHERE goodstype_id= #{id}
......@@ -38,7 +42,8 @@
select
`goodstwotype_id`,
`goodstwotype_title`,
`goodstype_id`
`goodstype_id`,
`goodstwotype_url`
from tb_cf_goodstwotype
where goodstwotype_id = #{id}
</select>
......@@ -47,6 +52,7 @@
SELECT
tw.`goodstwotype_id`,
tw.`goodstwotype_title`,
tw.`goodstwotype_url`,
ds.`goodstype_id`,
ds.`goodstype_title`
FROM tb_cf_goodstwotype tw
......@@ -80,18 +86,21 @@
insert into tb_cf_goodstwotype(
`goodstwotype_id`,
`goodstwotype_title`,
`goodstype_id`)
`goodstype_id`,
`goodstwotype_url`)
values(
#{goodstwotypeId},
#{goodstwotypeTitle},
#{goodstypeId})
#{goodstypeId},
#{goodstwotypeUrl})
</insert>
<update id="update" parameterType="com.platform.entity.TbCfGoodstwotypeEntity">
update tb_cf_goodstwotype
<set>
<if test="goodstwotypeTitle != null">`goodstwotype_title` = #{goodstwotypeTitle},</if>
<if test="goodstypeId != null">`goodstype_id` = #{goodstypeId}</if>
<if test="goodstwotypeTitle != null">`goodstwotype_title` = #{goodstwotypeTitle}, </if>
<if test="goodstypeId != null">`goodstype_id` = #{goodstypeId}, </if>
<if test="goodstwotypeUrl != null">`goodstwotype_url` = #{goodstwotypeUrl}</if>
</set>
where goodstwotype_id = #{goodstwotypeId}
</update>
......
......@@ -69,8 +69,7 @@
update tb_cf_goodstype
<set>
<if test="goodstypeTitle != null">`goodstype_title` = #{goodstypeTitle},</if>
<if test="goodstypeSort != null">`goodstype_sort` = #{goodstypeSort}</if>
<if test="goodstypeSort != null">`goodstype_sort` = #{goodstypeSort}</if>
<if test="goodstypeSort != null">`goodstype_sort` = #{goodstypeSort},</if>
<if test="goodstypeUrl != null">`goodstype_url` = #{goodstypeUrl}</if>
</set>
where goodstype_id = #{goodstypeId}
......
<!DOCTYPE html>
<html>
<html xmlns:v-bind="http://www.w3.org/1999/xhtml">
<head>
<title></title>
#parse("sys/header.html")
......@@ -52,6 +52,11 @@
:value="el.goodstypeId">{{el.goodstypeTitle}}</i-option>
</i-select>
</Form-item>
<Form-item label="二级分类图片" prop="goodstwotypeUrl">
<img v-bind:src="tbCfGoodstwotype.goodstwotypeUrl" v-show="!!tbCfGoodstwotype.goodstwotypeUrl"/>
<input type="file" placeholder="二级分类图片" @change="tirggerFile($event)"/>
</Form-item>
<Form-item label="商品二级分类标题" prop="goodstwotypeTitle">
<i-input v-model="tbCfGoodstwotype.goodstwotypeTitle" placeholder="商品二级分类标题"/>
</Form-item>
......
<!DOCTYPE html>
<html>
<html xmlns:v-bind="http://www.w3.org/1999/xhtml">
<head>
<title></title>
#parse("sys/header.html")
......@@ -48,6 +48,12 @@
<Form-item label="商品分类标题" prop="goodstypeTitle">
<i-input v-model="tbCfGoodstype.goodstypeTitle" placeholder="商品分类标题"/>
</Form-item>
<Form-item label="一级分类图片" prop="goodstypeUrl">
<img v-bind:src="tbCfGoodstype.goodstypeUrl" v-show="!!tbCfGoodstype.goodstypeUrl"/>
<input type="file" placeholder="一级分类图片" @change="tirggerFile($event)"/>
</Form-item>
<Form-item label="排序编号" prop="goodstypeSort">
<i-input v-model="tbCfGoodstype.goodstypeSort" placeholder="排序编号"/>
</Form-item>
......
......@@ -2,112 +2,140 @@ $(function () {
$("#jqGrid").Grid({
url: '../tbcfgoodstwotype/list',
colModel: [
{label: 'ID', name: 'goodstwotypeId', index: 'goodstwotype_id', key: true},
{label: '商品一级分类', name: 'goodstypeTitle', index: 'goodstype_title', width: 80},
{label: '商品二级分类', name: 'goodstwotypeTitle', index: 'goodstwotype_title', width: 80}],
shrinkToFit: true,
datatype : "json",
rowNum:15,
rowList:[15,30,45],
mtype: "POST",
rownumbers: true,
rownumWidth: 40,
gridview: true,
pager: '#speedp',
sortname: 'goodstwotype_id',
viewrecords: true,
sortorder: "asc"
{label: 'ID', name: 'goodstwotypeId', index: 'goodstwotype_id', key: true},
{label: '商品一级分类', name: 'goodstypeTitle', index: 'goodstype_title', width: 80},
{label: '商品二级分类', name: 'goodstwotypeTitle', index: 'goodstwotype_title', width: 80},
{label: '二级分类图片', name: 'goodstwotypeUrl', index: 'goodstwotype_url', width: 80, formatter: imageFormat}],
shrinkToFit: true,
datatype: "json",
rowNum: 15,
rowList: [15, 30, 45],
mtype: "POST",
rownumbers: true,
rownumWidth: 40,
gridview: true,
pager: '#speedp',
sortname: 'goodstwotype_id',
viewrecords: true,
sortorder: "asc"
});
});
let vm = new Vue({
el: '#rrapp',
data: {
el: '#rrapp',
data: {
showList: true,
title: null,
tbCfGoodstwotype: {},
Goodstype:null,
ruleValidate: {
name: [
{required: true, message: '名称不能为空', trigger: 'blur'}
]
},
q: {
name: ''
}
},
methods: {
query: function () {
vm.reload();
},
add: function () {
vm.showList = false;
vm.title = "新增";
vm.tbCfGoodstwotype = {};
},
update: function (event) {
tbCfGoodstwotype: {},
Goodstype: null,
ruleValidate: {
name: [
{required: true, message: '名称不能为空', trigger: 'blur'}
]
},
q: {
name: ''
}
},
methods: {
query: function () {
vm.reload();
},
add: function () {
vm.showList = false;
vm.title = "新增";
vm.tbCfGoodstwotype = {};
},
update: function (event) {
let goodstwotypeId = getSelectedRow("#jqGrid");
if (goodstwotypeId == null) {
return;
}
vm.showList = false;
if (goodstwotypeId == null) {
return;
}
vm.showList = false;
vm.title = "修改";
vm.getInfo(goodstwotypeId);
},
saveOrUpdate: function (event) {
},
saveOrUpdate: function (event) {
let url = vm.tbCfGoodstwotype.goodstwotypeId == null ? "../tbcfgoodstwotype/save" : "../tbcfgoodstwotype/update";
Ajax.request({
url: url,
url: url,
params: JSON.stringify(vm.tbCfGoodstwotype),
type: "POST",
contentType: "application/json",
contentType: "application/json",
successCallback: function (r) {
alert('操作成功', function (index) {
vm.reload();
});
}
});
},
del: function (event) {
});
},
del: function (event) {
let goodstwotypeIds = getSelectedRows("#jqGrid");
if (goodstwotypeIds == null){
return;
}
if (goodstwotypeIds == null) {
return;
}
confirm('确定要删除选中的记录?', function () {
confirm('确定要删除选中的记录?', function () {
Ajax.request({
url: "../tbcfgoodstwotype/delete",
url: "../tbcfgoodstwotype/delete",
params: JSON.stringify(goodstwotypeIds),
type: "POST",
contentType: "application/json",
contentType: "application/json",
successCallback: function () {
alert('操作成功', function (index) {
vm.reload();
});
}
});
});
},
getInfo: function(goodstwotypeId){
}
});
});
},
getInfo: function (goodstwotypeId) {
Ajax.request({
url: "../tbcfgoodstwotype/info/"+goodstwotypeId,
url: "../tbcfgoodstwotype/info/" + goodstwotypeId,
async: true,
successCallback: function (r) {
vm.tbCfGoodstwotype = r.tbCfGoodstwotype;
}
});
},
reload: function (event) {
vm.showList = true;
},
reload: function (event) {
vm.showList = true;
let page = $("#jqGrid").jqGrid('getGridParam', 'page');
$("#jqGrid").jqGrid('setGridParam', {
$("#jqGrid").jqGrid('setGridParam', {
postData: {'name': vm.q.name},
page: page
}).trigger("reloadGrid");
vm.handleReset('formValidate');
},
reloadSearch: function() {
}
,
handleReset: function (name) {
handleResetForm(this, name);
},
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.tbCfGoodstwotype.goodstwotypeUrl = result.data;
vm.$forceUpdate();
} else {
iview.Message.error(result.errmsg);
}
}
});
},
reloadSearch: function () {
vm.q = {
name: ''
};
......@@ -121,14 +149,14 @@ let vm = new Vue({
handleReset: function (name) {
handleResetForm(this, name);
}
},
created(){
var that = this
$.get('../tbcfgoodstype/queryAll',function (res) {
debugger
// console.log(that,"this");
that.Goodstype = res.list;
// console.log(that.Goodstype);
})
}
},
created() {
var that = this
$.get('../tbcfgoodstype/queryAll', function (res) {
debugger
// console.log(that,"this");
that.Goodstype = res.list;
// console.log(that.Goodstype);
})
}
});
\ No newline at end of file
......@@ -2,10 +2,10 @@ $(function () {
$("#jqGrid").Grid({
url: '../tbcfgoodstype/list',
colModel: [
{label: 'ID', name: 'goodstypeId', index: 'goodstype_id', key: true},
{label: 'ID', name: 'goodstypeId', index: 'goodstype_id', key: true,hidden: true},
{label: '商品一级分类', name: 'goodstypeTitle', index: 'goodstype_title', width: 80},
{label: '排序编号', name: 'goodstypeSort', index: 'goodstype_sort', width: 80}
/*{label: '商品分类跳转链接', name: 'goodstypeUrl', index: 'goodstype_url', width: 80}*/],
{label: '排序编号', name: 'goodstypeSort', index: 'goodstype_sort', width: 80},
{label: '一级分类图片', name: 'goodstwotypeUrl', index: 'goodstype_url', width: 80, formatter: imageFormat}],
shrinkToFit: true,
datatype : "json",
rowNum:15,
......@@ -120,6 +120,29 @@ let vm = new Vue({
},
handleReset: function (name) {
handleResetForm(this, name);
}
},
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.tbCfGoodstype.goodstypeUrl = result.data;
vm.$forceUpdate();
} else {
iview.Message.error(result.errmsg);
}
}
});
}
}
});
\ No newline at end of file
Markdown 格式
0%
您添加了 0 到此讨论。请谨慎行事。
请先完成此评论的编辑!
注册 或者 后发表评论