增加品牌管理,品牌动态选择

This commit is contained in:
19173159168
2025-08-12 21:25:07 +08:00
parent 676e156702
commit 6fadd0aed9
29 changed files with 1419 additions and 34 deletions

View File

@ -119,7 +119,12 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
<include refid="selectCompanyStoreVo"/>
where id = #{id}
</select>
<select id="checkStoreNoUnique" parameterType="String" resultMap="CompanyStoreResult">
<include refid="selectCompanyStoreVo"/>
where store_number = #{storeNumber} and del_flag = '0' limit 1
</select>
<insert id="insertCompanyStore" parameterType="CompanyStore" useGeneratedKeys="true" keyProperty="id">
insert into zc_company_store
<trim prefix="(" suffix=")" suffixOverrides=",">

View File

@ -0,0 +1,151 @@
<?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.ruoyi.operation.mapper.ZcCarBrandMapper">
<resultMap type="ZcCarBrand" id="ZcCarBrandResult">
<result property="id" column="id" />
<result property="brandName" column="brand_name" />
<result property="brandIntro" column="brand_intro" />
<result property="status" column="status" />
<result property="delFlag" column="del_flag" />
<result property="createBy" column="create_by" />
<result property="createTime" column="create_time" />
<result property="updateBy" column="update_by" />
<result property="updateTime" column="update_time" />
<result property="remark" column="remark" />
<result property="extend1" column="extend1" />
<result property="extend2" column="extend2" />
<result property="extend3" column="extend3" />
</resultMap>
<resultMap id="ZcCarBrandZcCarModelResult" type="ZcCarBrand" extends="ZcCarBrandResult">
<collection property="zcCarModelList" notNullColumn="sub_id" javaType="java.util.List" resultMap="ZcCarModelResult" />
</resultMap>
<resultMap type="ZcCarModel" id="ZcCarModelResult">
<result property="id" column="sub_id" />
<result property="modelName" column="sub_model_name" />
<result property="brandId" column="sub_brand_id" />
<result property="brandName" column="sub_brand_name" />
<result property="batteryType" column="sub_battery_type" />
<result property="maxSpeed" column="sub_max_speed" />
<result property="weight" column="sub_weight" />
<result property="status" column="sub_status" />
<result property="delFlag" column="sub_del_flag" />
<result property="createBy" column="sub_create_by" />
<result property="createTime" column="sub_create_time" />
<result property="updateBy" column="sub_update_by" />
<result property="updateTime" column="sub_update_time" />
<result property="remark" column="sub_remark" />
<result property="extend1" column="sub_extend1" />
<result property="extend2" column="sub_extend2" />
<result property="extend3" column="sub_extend3" />
</resultMap>
<sql id="selectZcCarBrandVo">
select id, brand_name, brand_intro, status, del_flag, create_by, create_time, update_by, update_time, remark, extend1, extend2, extend3 from zc_car_brand
</sql>
<select id="selectZcCarBrandList" parameterType="ZcCarBrand" resultMap="ZcCarBrandResult">
<include refid="selectZcCarBrandVo"/>
<where>
del_flag = '0'
<if test="brandName != null and brandName != ''"> and brand_name like concat('%', #{brandName}, '%')</if>
<if test="status != null and status != ''"> and status = #{status}</if>
<if test="extend1 != null and extend1 != ''"> and extend1 = #{extend1}</if>
<if test="extend2 != null and extend2 != ''"> and extend2 = #{extend2}</if>
<if test="extend3 != null and extend3 != ''"> and extend3 = #{extend3}</if>
</where>
</select>
<select id="selectZcCarBrandById" parameterType="Long" resultMap="ZcCarBrandZcCarModelResult">
select a.id, a.brand_name, a.brand_intro, a.status, a.del_flag, a.create_by, a.create_time, a.update_by, a.update_time, a.remark, a.extend1, a.extend2, a.extend3,
b.id as sub_id, b.model_name as sub_model_name, b.brand_id as sub_brand_id, b.brand_name as sub_brand_name, b.battery_type as sub_battery_type, b.max_speed as sub_max_speed, b.weight as sub_weight, b.status as sub_status, b.del_flag as sub_del_flag, b.create_by as sub_create_by, b.create_time as sub_create_time, b.update_by as sub_update_by, b.update_time as sub_update_time, b.remark as sub_remark, b.extend1 as sub_extend1, b.extend2 as sub_extend2, b.extend3 as sub_extend3
from zc_car_brand a
left join zc_car_model b on b.brand_id = a.id
where a.id = #{id}
</select>
<insert id="insertZcCarBrand" parameterType="ZcCarBrand" useGeneratedKeys="true" keyProperty="id">
insert into zc_car_brand
<trim prefix="(" suffix=")" suffixOverrides=",">
<if test="brandName != null and brandName != ''">brand_name,</if>
<if test="brandIntro != null">brand_intro,</if>
<if test="status != null">status,</if>
<if test="delFlag != null">del_flag,</if>
<if test="createBy != null">create_by,</if>
<if test="createTime != null">create_time,</if>
<if test="updateBy != null">update_by,</if>
<if test="updateTime != null">update_time,</if>
<if test="remark != null">remark,</if>
<if test="extend1 != null">extend1,</if>
<if test="extend2 != null">extend2,</if>
<if test="extend3 != null">extend3,</if>
</trim>
<trim prefix="values (" suffix=")" suffixOverrides=",">
<if test="brandName != null and brandName != ''">#{brandName},</if>
<if test="brandIntro != null">#{brandIntro},</if>
<if test="status != null">#{status},</if>
<if test="delFlag != null">#{delFlag},</if>
<if test="createBy != null">#{createBy},</if>
<if test="createTime != null">#{createTime},</if>
<if test="updateBy != null">#{updateBy},</if>
<if test="updateTime != null">#{updateTime},</if>
<if test="remark != null">#{remark},</if>
<if test="extend1 != null">#{extend1},</if>
<if test="extend2 != null">#{extend2},</if>
<if test="extend3 != null">#{extend3},</if>
</trim>
</insert>
<update id="updateZcCarBrand" parameterType="ZcCarBrand">
update zc_car_brand
<trim prefix="SET" suffixOverrides=",">
<if test="brandName != null and brandName != ''">brand_name = #{brandName},</if>
<if test="brandIntro != null">brand_intro = #{brandIntro},</if>
<if test="status != null">status = #{status},</if>
<if test="delFlag != null">del_flag = #{delFlag},</if>
<if test="createBy != null">create_by = #{createBy},</if>
<if test="createTime != null">create_time = #{createTime},</if>
<if test="updateBy != null">update_by = #{updateBy},</if>
<if test="updateTime != null">update_time = #{updateTime},</if>
<if test="remark != null">remark = #{remark},</if>
<if test="extend1 != null">extend1 = #{extend1},</if>
<if test="extend2 != null">extend2 = #{extend2},</if>
<if test="extend3 != null">extend3 = #{extend3},</if>
</trim>
where id = #{id}
</update>
<delete id="deleteZcCarBrandById" parameterType="Long">
delete from zc_car_brand where id = #{id}
</delete>
<delete id="deleteZcCarBrandByIds" parameterType="String">
delete from zc_car_brand where id in
<foreach item="id" collection="array" open="(" separator="," close=")">
#{id}
</foreach>
</delete>
<delete id="deleteZcCarModelByBrandIds" parameterType="String">
delete from zc_car_model where brand_id in
<foreach item="brandId" collection="array" open="(" separator="," close=")">
#{brandId}
</foreach>
</delete>
<delete id="deleteZcCarModelByBrandId" parameterType="Long">
delete from zc_car_model where brand_id = #{brandId}
</delete>
<insert id="batchZcCarModel">
insert into zc_car_model( id, model_name, brand_id, brand_name, battery_type, max_speed, weight, status, del_flag, create_by, create_time, update_by, update_time, remark, extend1, extend2, extend3) values
<foreach item="item" index="index" collection="list" separator=",">
( #{item.id}, #{item.modelName}, #{item.brandId}, #{item.brandName}, #{item.batteryType}, #{item.maxSpeed}, #{item.weight}, #{item.status}, #{item.delFlag}, #{item.createBy}, #{item.createTime}, #{item.updateBy}, #{item.updateTime}, #{item.remark}, #{item.extend1}, #{item.extend2}, #{item.extend3})
</foreach>
</insert>
</mapper>

View File

@ -49,6 +49,7 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
<include refid="selectZcCarModelVo"/>
<where>
<if test="modelName != null and modelName != ''"> and model_name like concat('%', #{modelName}, '%')</if>
<if test="brandId != null"> and brand_id = #{brandId}</if>
<if test="brandName != null and brandName != ''"> and brand_name like concat('%', #{brandName}, '%')</if>
<if test="status != null and status != ''"> and status = #{status}</if>
</where>
@ -124,7 +125,9 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
</trim>
where id = #{id}
</update>
<update id="updateZcCarModelBrand" parameterType="ZcCarModel">
update zc_car_model set brand_name = #{brandName} where brand_id = #{brandId}
</update>
<delete id="deleteZcCarModelById" parameterType="Long">
delete from zc_car_model where id = #{id}
</delete>
@ -141,6 +144,9 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
</select>
<select id="selectModelsByBrand" resultMap="ZcCarModelResult">
SELECT id,model_name FROM zc_car_model WHERE del_flag = 0 and brand_name = #{brandName} ORDER BY model_name ASC
SELECT id,model_name FROM zc_car_model WHERE del_flag = 0 and brand_id = #{brandId} ORDER BY model_name ASC
</select>
<select id="checkModelNameUnique" resultType="com.ruoyi.operation.domain.ZcCarModel">
SELECT * FROM zc_car_model WHERE del_flag = 0 and brand_id = #{brandId} and model_name = #{modelName}
</select>
</mapper>

View File

@ -22,7 +22,8 @@
<div class="form-group">
<label class="col-sm-3 control-label is-required">车辆品牌:</label>
<div class="col-sm-8">
<select name="brandName" id="brand-select" class="form-control m-b" required>
<input type="hidden" id="brandName" name="brandName">
<select name="brandId" id="brand-select" class="form-control m-b" required>
<option value="">请选择品牌</option>
</select>
</div>
@ -126,23 +127,25 @@
$(function () {
// 加载品牌列表
$.ajax({
url: ctx + 'operation/carModel/brands',
url: ctx + 'operation/carBrand/brands',
type: 'GET',
success: function (brands) {
var brandSelect = $('#brand-select');
brands.forEach(function (brand) {
brandSelect.append('<option value="' + brand + '">' + brand + '</option>');
brandSelect.append('<option value="' + brand.id + '">' + brand.brandName + '</option>');
});
}
});
// 品牌选择变化时加载对应车型
$('#brand-select').on('change', function () {
var brandName = $(this).val();
var brandId = $(this).val();
var brandName = $(this).find("option:selected").text();
$('#brandName').val(brandName);
var modelSelect = $('#model-select');
modelSelect.empty().append('<option value="">加载中...</option>').prop('disabled', true);
if (!brandName) {
if (!brandId) {
modelSelect.empty().append('<option value="">请先选择品牌</option>').prop('disabled', true);
return;
}
@ -150,7 +153,7 @@
$.ajax({
url: ctx + 'operation/carModel/getModels',
type: 'POST',
data: { brandName: brandName },
data: { brandId: brandId },
success: function (models) {
modelSelect.empty();
if (models.length === 0) {
@ -160,6 +163,9 @@
modelSelect.append('<option value="' + model.id + '">' + model.modelName + '</option>');
});
modelSelect.prop('disabled', false);
var modelName = $('#model-select option:selected').text();
// 将门店名称赋值给隐藏输入框
$("#modelName").val(modelName);
}
}
});

View File

@ -23,7 +23,8 @@
<div class="form-group">
<label class="col-sm-3 control-label is-required">车辆品牌:</label>
<div class="col-sm-8">
<select name="brandName" id="brand-select" class="form-control m-b" required>
<input type="hidden" id="brandName" name="brandName" th:field="*{brandName}">
<select name="brandId" id="brand-select" class="form-control m-b" required>
<option value="">请选择品牌</option>
</select>
</div>
@ -118,19 +119,20 @@
var modelSelect = $('#model-select');
// 保存当前车辆的品牌与车型值
var savedBrand = [[${zcCar.brandName}]];
var savedBrand = [[${zcCar.brandId}]];
var savedBrandName = [[${zcCar.brandName}]];
var modelId = [[${zcCar.modelId}]];
var modelName = [[${zcCar.modelName}]];
// 加载品牌列表
$.ajax({
url: ctx + 'operation/carModel/brands',
url: ctx + 'operation/carBrand/brands',
type: 'GET',
success: function (brands) {
var brandSelect = $('#brand-select');
brands.forEach(function (brand) {
var option = $('<option>').val(brand).text(brand);
if (brand === savedBrand) {
var option = $('<option>').val(brand.id).text(brand.brandName);
if (brand.id === savedBrand) {
option.attr('selected', 'selected');
}
brandSelect.append(option);
@ -150,6 +152,8 @@
// =================== 品牌选择变化事件 ===================
brandSelect.on('change', function () {
var selectedBrand = $(this).val();
var brandName = $(this).find("option:selected").text();
$('#brandName').val(brandName);
if (!selectedBrand) {
modelSelect.empty().append('<option value="">请先选择品牌</option>').prop('disabled', true);
return;
@ -159,11 +163,11 @@
});
// =================== 加载车型方法封装 ===================
function loadModels(brandName, modelName = null) {
function loadModels(brandId, modelName = null) {
$.ajax({
url: ctx + 'operation/carModel/getModels',
type: 'POST',
data: { brandName: brandName },
data: { brandId: brandId },
success: function (models) {
modelSelect.empty();
@ -181,6 +185,9 @@
// 设置隐藏域
var selectedModelName = modelSelect.find('option:selected').text();
$('#modelName').val(selectedModelName);
}else{
// 将门店名称赋值给隐藏输入框
$("#modelName").val($('#model-select option:selected').text());
}
}
}

View File

@ -0,0 +1,245 @@
<!DOCTYPE html>
<html lang="zh" xmlns:th="http://www.thymeleaf.org" >
<head>
<th:block th:include="include :: header('新增品牌管理')" />
</head>
<body class="white-bg">
<div class="wrapper wrapper-content animated fadeInRight ibox-content">
<form class="form-horizontal m" id="form-carBrand-add">
<!-- <h4 class="form-header h4">品牌管理信息</h4>-->
<div class="form-group">
<label class="col-sm-3 control-label is-required">品牌名称:</label>
<div class="col-sm-8">
<input name="brandName" class="form-control" type="text" required>
</div>
</div>
<div class="form-group">
<label class="col-sm-3 control-label">品牌介绍:</label>
<div class="col-sm-8">
<textarea name="brandIntro" class="form-control"></textarea>
</div>
</div>
<div class="form-group">
<label class="col-sm-3 control-label">备注:</label>
<div class="col-sm-8">
<textarea name="remark" class="form-control"></textarea>
</div>
</div>
<!-- <h4 class="form-header h4">品牌车型</h4>-->
<!-- <div class="row">-->
<!-- <div class="col-sm-12">-->
<!-- <button type="button" class="btn btn-white btn-sm" onclick="addRow()"><i class="fa fa-plus"> 增加</i></button>-->
<!-- <button type="button" class="btn btn-white btn-sm" onclick="sub.delRow()"><i class="fa fa-minus"> 删除</i></button>-->
<!-- <div class="col-sm-12 select-table table-striped">-->
<!-- <table id="bootstrap-table"></table>-->
<!-- </div>-->
<!-- </div>-->
<!-- </div>-->
</form>
</div>
<th:block th:include="include :: footer" />
<script th:inline="javascript">
var prefix = ctx + "operation/carBrand"
var statusDatas = [[${@dict.getType('key_company_status')}]];
$("#form-carBrand-add").validate({
focusCleanup: true
});
function submitHandler() {
if ($.validate.form()) {
$.operate.save(prefix + "/add", $('#form-carBrand-add').serialize());
}
}
$(function() {
var options = {
pagination: false,
showSearch: false,
showRefresh: false,
showToggle: false,
showColumns: false,
sidePagination: "client",
columns: [{
checkbox: true
},
{
field: 'index',
align: 'center',
title: "序号",
formatter: function (value, row, index) {
var columnIndex = $.common.sprintf("<input type='hidden' name='index' value='%s'>", $.table.serialNumber(index));
return columnIndex + $.table.serialNumber(index);
}
},
{
field: 'modelName',
align: 'center',
title: '车型名称',
formatter: function(value, row, index) {
var html = $.common.sprintf("<input class='form-control' type='text' name='zcCarModelList[%s].modelName' value='%s'>", index, value);
return html;
}
},
{
field: 'brandName',
align: 'center',
title: '品牌名称',
formatter: function(value, row, index) {
var html = $.common.sprintf("<input class='form-control' type='text' name='zcCarModelList[%s].brandName' value='%s'>", index, value);
return html;
}
},
{
field: 'batteryType',
align: 'center',
title: '电池类型',
formatter: function(value, row, index) {
var html = $.common.sprintf("<input class='form-control' type='text' name='zcCarModelList[%s].batteryType' value='%s'>", index, value);
return html;
}
},
{
field: 'maxSpeed',
align: 'center',
title: '最高时速(km/h)',
formatter: function(value, row, index) {
var html = $.common.sprintf("<input class='form-control' type='text' name='zcCarModelList[%s].maxSpeed' value='%s'>", index, value);
return html;
}
},
{
field: 'weight',
align: 'center',
title: '整车重量(kg)',
formatter: function(value, row, index) {
var html = $.common.sprintf("<input class='form-control' type='text' name='zcCarModelList[%s].weight' value='%s'>", index, value);
return html;
}
},
{
field: 'status',
align: 'center',
title: '状态',
formatter: function(value, row, index) {
var name = $.common.sprintf("zcCarModelList[%s].status", index);
return $.common.dictToSelect(statusDatas, value, name);
}
},
{
field: 'delFlag',
align: 'center',
title: '删除标志',
formatter: function(value, row, index) {
var html = $.common.sprintf("<input class='form-control' type='text' name='zcCarModelList[%s].delFlag' value='%s'>", index, value);
return html;
}
},
{
field: 'createBy',
align: 'center',
title: '创建者',
formatter: function(value, row, index) {
var html = $.common.sprintf("<input class='form-control' type='text' name='zcCarModelList[%s].createBy' value='%s'>", index, value);
return html;
}
},
{
field: 'createTime',
align: 'center',
title: '创建时间',
formatter: function(value, row, index) {
var html = $.common.sprintf("<input class='form-control' type='text' name='zcCarModelList[%s].createTime' value='%s'>", index, value);
return html;
}
},
{
field: 'updateBy',
align: 'center',
title: '更新者',
formatter: function(value, row, index) {
var html = $.common.sprintf("<input class='form-control' type='text' name='zcCarModelList[%s].updateBy' value='%s'>", index, value);
return html;
}
},
{
field: 'updateTime',
align: 'center',
title: '更新时间',
formatter: function(value, row, index) {
var html = $.common.sprintf("<input class='form-control' type='text' name='zcCarModelList[%s].updateTime' value='%s'>", index, value);
return html;
}
},
{
field: 'remark',
align: 'center',
title: '备注',
formatter: function(value, row, index) {
var html = $.common.sprintf("<input class='form-control' type='text' name='zcCarModelList[%s].remark' value='%s'>", index, value);
return html;
}
},
{
field: 'extend1',
align: 'center',
title: '扩展字段1',
formatter: function(value, row, index) {
var html = $.common.sprintf("<input class='form-control' type='text' name='zcCarModelList[%s].extend1' value='%s'>", index, value);
return html;
}
},
{
field: 'extend2',
align: 'center',
title: '扩展字段2',
formatter: function(value, row, index) {
var html = $.common.sprintf("<input class='form-control' type='text' name='zcCarModelList[%s].extend2' value='%s'>", index, value);
return html;
}
},
{
field: 'extend3',
align: 'center',
title: '扩展字段3',
formatter: function(value, row, index) {
var html = $.common.sprintf("<input class='form-control' type='text' name='zcCarModelList[%s].extend3' value='%s'>", index, value);
return html;
}
},
{
title: '操作',
align: 'center',
formatter: function(value, row, index) {
var value = $.common.isNotEmpty(row.index) ? row.index : $.table.serialNumber(index);
return '<a class="btn btn-danger btn-xs" href="javascript:void(0)" onclick="sub.delRowByIndex(\'' + value + '\')"><i class="fa fa-remove"></i>删除</a>';
}
}]
};
$.table.init(options);
});
function addRow() {
var count = $("#" + table.options.id).bootstrapTable('getData').length;
var row = {
index: $.table.serialNumber(count),
modelName: "",
brandName: "",
batteryType: "",
maxSpeed: "",
weight: "",
status: "",
delFlag: "",
createBy: "",
createTime: "",
updateBy: "",
updateTime: "",
remark: "",
extend1: "",
extend2: "",
extend3: "",
}
sub.addRow(row);
}
</script>
</body>
</html>

View File

@ -0,0 +1,92 @@
<!DOCTYPE html>
<html lang="zh" xmlns:th="http://www.thymeleaf.org" xmlns:shiro="http://www.pollix.at/thymeleaf/shiro">
<head>
<th:block th:include="include :: header('品牌管理列表')" />
</head>
<body class="gray-bg">
<div class="container-div">
<div class="row">
<div class="col-sm-12 search-collapse">
<form id="formId">
<div class="select-list">
<ul>
<li>
<label>品牌名称:</label>
<input type="text" name="brandName"/>
</li>
<li>
<a class="btn btn-primary btn-rounded btn-sm" onclick="$.table.search()"><i class="fa fa-search"></i>&nbsp;搜索</a>
<a class="btn btn-warning btn-rounded btn-sm" onclick="$.form.reset()"><i class="fa fa-refresh"></i>&nbsp;重置</a>
</li>
</ul>
</div>
</form>
</div>
<div class="btn-group-sm" id="toolbar" role="group">
<a class="btn btn-success" onclick="$.operate.add()" shiro:hasPermission="operation:carBrand:add">
<i class="fa fa-plus"></i> 添加
</a>
<a class="btn btn-primary single disabled" onclick="$.operate.edit()" shiro:hasPermission="operation:carBrand:edit">
<i class="fa fa-edit"></i> 修改
</a>
</div>
<div class="col-sm-12 select-table table-striped">
<table id="bootstrap-table"></table>
</div>
</div>
</div>
<th:block th:include="include :: footer" />
<script th:inline="javascript">
var editFlag = [[${@permission.hasPermi('operation:carBrand:edit')}]];
var removeFlag = [[${@permission.hasPermi('operation:carBrand:remove')}]];
var prefix = ctx + "operation/carBrand";
$(function() {
var options = {
url: prefix + "/list",
createUrl: prefix + "/add",
updateUrl: prefix + "/edit/{id}",
removeUrl: prefix + "/remove",
exportUrl: prefix + "/export",
modalName: "品牌",
columns: [{
checkbox: true
},
{
field: 'id',
title: '车型ID',
visible: false
},
{
field: 'brandName',
title: '品牌名称'
},
{
field: 'brandIntro',
title: '品牌介绍',
width: '800'
},
{
field: 'createTime',
title: '创建时间',
width: '200'
},
{
title: '操作',
align: 'center',
width: '200',
formatter: function(value, row, index) {
var actions = [];
actions.push('<a class="btn btn-success btn-xs ' + editFlag + ' btnOption" href="javascript:void(0)" onclick="$.operate.editCustomize(\'' + row.id + '\',1300,700)"><i class="fa fa-edit"></i>修改</a> ');
actions.push('<a class="btn btn-danger btn-xs ' + removeFlag + ' btnOption" href="javascript:void(0)" onclick="$.operate.remove(\'' + row.id + '\')"><i class="fa fa-remove"></i>删除</a>');
return actions.join('');
}
}]
};
$.table.init(options);
});
</script>
</body>
</html>

View File

@ -0,0 +1,146 @@
<!DOCTYPE html>
<html lang="zh" xmlns:th="http://www.thymeleaf.org" >
<head>
<th:block th:include="include :: header('修改品牌管理')" />
</head>
<body class="white-bg">
<div class="wrapper wrapper-content animated fadeInRight ibox-content">
<form class="form-horizontal m" id="form-carBrand-edit" th:object="${zcCarBrand}">
<h4 class="form-header h4">品牌信息</h4>
<input name="id" th:field="*{id}" type="hidden">
<div class="form-group">
<label class="col-sm-3 control-label is-required">品牌名称:</label>
<div class="col-sm-8">
<input name="brandName" th:field="*{brandName}" class="form-control" type="text" required>
</div>
</div>
<div class="form-group">
<label class="col-sm-3 control-label">品牌介绍:</label>
<div class="col-sm-8">
<textarea name="brandIntro" class="form-control">[[*{brandIntro}]]</textarea>
</div>
</div>
<div class="form-group">
<label class="col-sm-3 control-label">备注:</label>
<div class="col-sm-8">
<textarea name="remark" class="form-control">[[*{remark}]]</textarea>
</div>
</div>
<h4 class="form-header h4">品牌车型信息</h4>
<div class="row">
<div class="col-sm-12">
<!-- <button type="button" class="btn btn-white btn-sm" onclick="addRow()"><i class="fa fa-plus"> 增加</i></button>-->
<!-- <button type="button" class="btn btn-white btn-sm" onclick="sub.delRow()"><i class="fa fa-minus"> 删除</i></button>-->
<div class="col-sm-12 select-table table-striped">
<table id="bootstrap-table"></table>
</div>
</div>
</div>
</form>
</div>
<th:block th:include="include :: footer" />
<script th:inline="javascript">
var prefix = ctx + "operation/carBrand";
var statusDatas = [[${@dict.getType('key_company_status')}]];
$("#form-carBrand-edit").validate({
focusCleanup: true
});
function submitHandler() {
if ($.validate.form()) {
$.operate.save(prefix + "/edit", $('#form-carBrand-edit').serialize());
}
}
$(function() {
var options = {
data: [[${zcCarBrand.zcCarModelList}]],
pagination: false,
showSearch: false,
showRefresh: false,
showToggle: false,
showColumns: false,
sidePagination: "client",
columns: [
{
field: 'index',
align: 'center',
title: "序号",
formatter: function (value, row, index) {
var columnIndex = $.common.sprintf("<input type='hidden' name='index' value='%s'>", $.table.serialNumber(index));
return columnIndex + $.table.serialNumber(index);
}
},
{
field: 'modelName',
align: 'center',
title: '车型名称'
},
{
field: 'brandName',
align: 'center',
title: '品牌名称'
},
{
field: 'batteryType',
align: 'center',
title: '电池类型'
},
{
field: 'maxSpeed',
align: 'center',
title: '最高时速(km/h)'
},
{
field: 'weight',
align: 'center',
title: '整车重量(kg)'
},
{
field: 'status',
align: 'center',
title: '状态',
formatter: function(value, row, index) {
return $.table.selectDictLabel(statusDatas, value);
}
},
{
field: 'createTime',
align: 'center',
title: '创建时间'
}]
};
$.table.init(options);
});
function addRow() {
var count = $("#" + table.options.id).bootstrapTable('getData').length;
var row = {
index: $.table.serialNumber(count),
modelName: "",
brandName: "",
batteryType: "",
maxSpeed: "",
weight: "",
status: "",
delFlag: "",
createBy: "",
createTime: "",
updateBy: "",
updateTime: "",
remark: "",
extend1: "",
extend2: "",
extend3: "",
}
sub.addRow(row);
}
</script>
</body>
</html>

View File

@ -13,10 +13,14 @@
<form class="form-horizontal m" id="form-carModel-add">
<input type="hidden" id="rentCarRuleIds" name="rentCarRuleIds">
<input type="hidden" id="brandName" name="brandName">
<div class="form-group">
<label class="col-sm-2 control-label is-required">品牌名称:</label>
<div class="col-sm-9">
<input name="brandName" class="form-control" type="text" maxlength="20" required>
<select name="brandId" id="brandId" class="form-control m-b" required>
<option value="">请选择品牌</option>
<option th:each="brand : ${carBrandList}" th:value="${brand.id}" th:text="${brand.brandName}"></option>
</select>
</div>
</div>
<div class="form-group">
@ -127,8 +131,19 @@
).on("filecleared", function (event, data, msg) {
$("input[name='" + event.currentTarget.id + "']").val('')
});
// 品牌选择变化时
$('#brandId').on('change', function () {
var brandName = $(this).find("option:selected").text();
$('#brandName').val(brandName);
});
});
$(function() {
var options = {
data: rentCarRuleList,

View File

@ -13,7 +13,10 @@
<li>
<label>品牌名称:</label>
<input type="text" name="brandName"/>
<select name="brandId" id="brandId" class="form-control m-b" required>
<option value="">全部</option>
<option th:each="brand : ${carBrandList}" th:value="${brand.id}" th:text="${brand.brandName}"></option>
</select>
</li>
<li>
<label>车型名称:</label>
@ -84,7 +87,7 @@
{
field: 'modelName',
title: '车型名称',
width: '400'
width: '200'
},
{
field: 'batteryType',

View File

@ -13,10 +13,17 @@
<form class="form-horizontal m" id="form-carModel-edit" th:object="${zcCarModel}">
<input name="id" th:field="*{id}" type="hidden">
<input type="hidden" id="rentCarRuleIds" name="rentCarRuleIds">
<input type="hidden" id="brandName" name="brandName" th:field="*{brandName}">
<div class="form-group">
<label class="col-sm-2 control-label is-required">品牌名称:</label>
<div class="col-sm-9">
<input name="brandName" th:field="*{brandName}" class="form-control" type="text" required>
<select name="brandId" id="brandId" class="form-control m-b" required>
<option value="">请选择品牌</option>
<option th:each="brand : ${carBrandList}"
th:value="${brand.id}"
th:text="${brand.brandName}"
th:selected="${brand.id == zcCarModel.brandId}"></option>
</select>
</div>
</div>
<div class="form-group">
@ -96,6 +103,11 @@
var selectedValues = [[${zcCarModel.batteryType}]].split(',');
$('.select2-multiple').val(selectedValues).trigger('change');
// 品牌选择变化时
$('#brandId').on('change', function () {
var brandName = $(this).find("option:selected").text();
$('#brandName').val(brandName);
});
var options = {
data: rentCarRuleList,

View File

@ -147,9 +147,9 @@
align: "left",
formatter: function(value, row, index) {
var actions = [];
actions.push('<a class="btn btn-success btn-xs ' + editFlag + '" href="javascript:void(0)" onclick="$.operate.edit(\'' + row.menuId + '\')"><i class="fa fa-edit"></i>编辑</a> ');
actions.push('<a class="btn btn-info btn-xs ' + addFlag + '" href="javascript:void(0)" onclick="$.operate.add(\'' + row.menuId + '\')"><i class="fa fa-plus"></i>新增</a> ');
actions.push('<a class="btn btn-danger btn-xs ' + removeFlag + '" href="javascript:void(0)" onclick="$.operate.remove(\'' + row.menuId + '\')"><i class="fa fa-trash"></i>删除</a>');
actions.push('<a class="btn btn-success btn-xs ' + editFlag + ' btnOption" href="javascript:void(0)" onclick="$.operate.edit(\'' + row.menuId + '\')"><i class="fa fa-edit"></i>编辑</a> ');
actions.push('<a class="btn btn-info btn-xs ' + addFlag + ' btnOption" href="javascript:void(0)" onclick="$.operate.add(\'' + row.menuId + '\')"><i class="fa fa-plus"></i>新增</a> ');
actions.push('<a class="btn btn-danger btn-xs ' + removeFlag + ' btnOption" href="javascript:void(0)" onclick="$.operate.remove(\'' + row.menuId + '\')"><i class="fa fa-trash"></i>删除</a>');
return actions.join('');
}
}]