车辆导入导出

This commit is contained in:
19173159168
2025-07-16 23:17:01 +08:00
parent b2151b00d6
commit d71b9eae03
10 changed files with 360 additions and 26 deletions

View File

@ -163,6 +163,23 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
<if test="extend5 != null">#{extend5},</if>
</trim>
</insert>
<insert id="batchInsert">
INSERT INTO zc_car (vin, license_plate, brand_name,
model_name, lot_number, purchase_date,
purchase_price, belong_type, iot_code,
operator_id, operator_name,
store_id, store_name,
create_by, create_time, update_time, remark)
VALUES
<foreach collection="list" item="item" separator=",">
(#{item.vin}, #{item.licensePlate}, #{item.brandName}
#{item.modelName}, #{item.lotNumber}, #{item.purchaseDate}
#{item.purchasePrice}, #{item.belongType}, #{item.iotCode}
#{item.operatorId}, #{item.operatorName},
#{item.storeId}, #{item.storeName},
#{item.createBy}, #{item.createTime}, #{item.updateTime},#{item.remark})
</foreach>
</insert>
<update id="updateZcCar" parameterType="ZcCar">
update zc_car
@ -186,7 +203,6 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
<if test="iotCode != null">iot_code = #{iotCode},</if>
<if test="operatorId != null">operator_id = #{operatorId},</if>
<if test="operatorName != null">operator_name = #{operatorName},</if>
<if test="storeId != null">store_id = #{storeId},</if>
<if test="storeName != null">store_name = #{storeName},</if>
<if test="packageId != null">package_id = #{packageId},</if>
<if test="packageName != null">package_name = #{packageName},</if>
@ -202,6 +218,7 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
<if test="extend3 != null">extend3 = #{extend3},</if>
<if test="extend4 != null">extend4 = #{extend4},</if>
<if test="extend5 != null">extend5 = #{extend5},</if>
store_id = #{storeId}
</trim>
where id = #{id}
</update>

View File

@ -27,11 +27,14 @@
</li>
<li>
<label>所属运营商名称</label>
<input type="text" name="operatorName"/>
<label>所属运营商:</label>
<select name="operatingId" id="operatingId" >
<option value="">请选择所属运营商</option>
<option th:each="company : ${companyList}" th:value="${company.id}" th:text="${company.companyName}"></option>
</select>
</li>
<li>
<label>所属门店名称</label>
<label>所属门店:</label>
<input type="text" name="storeName"/>
</li>
<li>
@ -68,6 +71,7 @@
<th:block th:include="include :: footer" />
<script th:inline="javascript">
var editFlag = [[${@permission.hasPermi('operation:car:edit')}]];
var distributeFlag = [[${@permission.hasPermi('operation:car:distribute')}]];
var removeFlag = [[${@permission.hasPermi('operation:car:remove')}]];
var statusDatas = [[${@dict.getType('key_car_status')}]];
var batteryTypeDatas = [[${@dict.getType('key_car_battery_type')}]];
@ -160,7 +164,7 @@
formatter: function(value, row, index) {
var actions = [];
actions.push('<a class="btn btn-success btn-xs ' + editFlag + ' btnOption" href="javascript:void(0)" onclick="$.operate.edit(\'' + row.id + '\')"><i class="fa fa-edit"></i>编辑</a> ');
actions.push('<a class="btn btn-success btn-xs ' + editFlag + ' btnOption" href="javascript:void(0)" onclick="$.operate.edit(\'' + row.id + '\')"><i class="fa fa-edit"></i>分配</a> ');
actions.push('<a class="btn btn-success btn-xs ' + distributeFlag + ' btnOption" href="javascript:void(0)" onclick="distribute(\'' + row.id + '\')"><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>');
if (row.status == 1) {
actions.push('<a class="btn btn-success btn-xs ' + editFlag + ' btnOption" href="javascript:void(0)" onclick="enable(\'' + row.id + '\')"><i class="fa fa-edit"></i>上架</a> ');
@ -174,6 +178,9 @@
$.table.init(options);
});
function distribute(id){
$.modal.open("车辆分配", prefix + "/distribute/" + id);
}
/* 下架 */
function disable(id) {
$.modal.confirm("确认是否下架此车辆?<span style='color: red'>下架后此车辆将在不会显示在用户小程序中</span>", function() {

View File

@ -0,0 +1,163 @@
<!DOCTYPE html>
<html lang="zh" xmlns:th="http://www.thymeleaf.org" >
<head>
<th:block th:include="include :: header('分配车辆')" />
<th:block th:include="include :: datetimepicker-css" />
</head>
<body class="white-bg">
<div class="wrapper wrapper-content animated fadeInRight ibox-content">
<form class="form-horizontal m" id="form-car-edit" th:object="${zcCar}">
<input name="id" th:field="*{id}" type="hidden">
<div class="form-group">
<label class="col-sm-3 control-label">车架号(VIN)</label>
<div class="col-sm-8">
<input readonly name="vin" th:field="*{vin}" class="form-control" type="text">
</div>
</div>
<div class="form-group">
<label class="col-sm-3 control-label">车牌号码:</label>
<div class="col-sm-8">
<input readonly name="licensePlate" th:field="*{licensePlate}" class="form-control" type="text">
</div>
</div>
<div class="form-group">
<label class="col-sm-3 control-label">车辆归属:</label>
<div class="col-sm-8">
<select readonly name="belongType" class="form-control m-b" th:with="type=${@dict.getType('key_car_belong_type')}">
<option th:each="dict : ${type}" th:text="${dict.dictLabel}" th:value="${dict.dictValue}" th:field="*{belongType}"></option>
</select>
</div>
</div>
<div class="form-group">
<label class="col-sm-3 control-label is-required">所属运营商:</label>
<div class="col-sm-8">
<input name="operatorName" id="operatorName" class="form-control" type="hidden" >
<select name="operatorId" id="operator-select" class="form-control m-b" required>
<option value="">请选择运营商</option>
</select>
</div>
</div>
<div class="form-group">
<label class="col-sm-3 control-label">所属门店:</label>
<div class="col-sm-8">
<input name="storeName" id="storeName" class="form-control" type="hidden" >
<select name="storeId" id="store-select" class="form-control m-b" disabled>
<option value="">请先选择运营商</option>
</select>
</div>
</div>
</form>
</div>
<th:block th:include="include :: footer" />
<th:block th:include="include :: datetimepicker-js" />
<script th:inline="javascript">
var prefix = ctx + "operation/car";
$("#form-car-edit").validate({
focusCleanup: true
});
$(function () {
// 获取运营商与门店下拉框
var operatorSelect = $('#operator-select');
var storeSelect = $('#store-select');
// 保存当前车辆的运营商与门店值
var savedOperatorId = [[${zcCar.operatorId}]];
var savedStoreId = [[${zcCar.storeId}]];
// =================== 加载运营商列表 ===================
$.ajax({
url: ctx + 'operation/company/companyAll',
type: 'GET',
success: function (companies) {
companies.forEach(function (company) {
var option = $('<option>').val(company.id).text(company.companyName);
if (company.id == savedOperatorId) {
option.attr('selected', 'selected');
}
operatorSelect.append(option);
});
// 如果有已选运营商,则触发加载门店
if (savedOperatorId) {
storeSelect.prop('disabled', false).empty().append('<option value="">加载中...</option>');
loadStores(savedOperatorId, savedStoreId);
}
}
});
// =================== 运营商选择变化事件 ===================
operatorSelect.on('change', function () {
var selectedOperatorId = $(this).val();
if (!selectedOperatorId) {
storeSelect.empty().append('<option value="">请先选择运营商</option>').prop('disabled', true);
return;
}
// 设置隐藏域 operatorName
var selectedOperatorName = operatorSelect.find('option:selected').text();
$('#operatorName').val(selectedOperatorName);
loadStores(selectedOperatorId);
});
// =================== 加载门店方法封装 ===================
function loadStores(operatorId, savedStoreId = null) {
$.ajax({
url: ctx + 'operation/store/storesByCompanyId',
type: 'POST',
data: { companyId: operatorId },
success: function (stores) {
storeSelect.empty();
$('#storeName').val('');
if (stores.length === 0) {
storeSelect.append('<option value="">暂无门店</option>').prop('disabled', true);
} else {
storeSelect.append($('<option>').val('').text('请选择门店'));
stores.forEach(function (store) {
storeSelect.append($('<option>').val(store.id).text(store.name));
});
storeSelect.prop('disabled', false);
// 回显门店
if (savedStoreId) {
storeSelect.val(savedStoreId);
// 设置隐藏域 storeName
var selectedStoreName = storeSelect.find('option:selected').text();
$('#storeName').val(selectedStoreName);
}
}
}
});
}
// =================== 门店选择变化事件 ===================
storeSelect.on('change', function () {
var selectedStoreId = $(this).val();
var selectedStoreName = $(this).find('option:selected').text();
if(selectedStoreId != ''){
$('#storeName').val(selectedStoreName);
}
});
});
function submitHandler() {
if ($.validate.form()) {
$.operate.save(prefix + "/edit", $('#form-car-edit').serialize());
}
}
$("input[name='purchaseDate']").datetimepicker({
format: "yyyy-mm-dd",
minView: "month",
autoclose: true
});
</script>
</body>
</html>

View File

@ -234,10 +234,11 @@
data: { companyId: operatorId },
success: function (stores) {
storeSelect.empty();
$('#storeName').val('');
if (stores.length === 0) {
storeSelect.append('<option value="">暂无门店</option>').prop('disabled', true);
} else {
storeSelect.append($('<option>').val('').text('请选择门店'));
stores.forEach(function (store) {
storeSelect.append($('<option>').val(store.id).text(store.name));
});
@ -259,7 +260,9 @@
storeSelect.on('change', function () {
var selectedStoreId = $(this).val();
var selectedStoreName = $(this).find('option:selected').text();
$('#storeName').val(selectedStoreName);
if(selectedStoreId != ''){
$('#storeName').val(selectedStoreName);
}
});
});