Skip to content

Commit

Permalink
前端页面
Browse files Browse the repository at this point in the history
  • Loading branch information
yakeJiang committed Nov 5, 2023
1 parent e87a5f7 commit 87d5827
Show file tree
Hide file tree
Showing 175 changed files with 123,980 additions and 18 deletions.
Binary file modified demo.sqlite
Binary file not shown.
Original file line number Diff line number Diff line change
Expand Up @@ -5,12 +5,11 @@
import com.aiassistant.utils.ResultModel;
import com.aiassistant.utils.ResultPageModel;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import org.springframework.web.bind.annotation.*;

@RestController
@RequestMapping("/supplierProduct")
@CrossOrigin(origins = {"*"})
public class SupplierProductController {
private final SupplierProductService supplierProductService;

Expand All @@ -20,12 +19,17 @@ public SupplierProductController(SupplierProductService supplierProductService)
}

@PostMapping("/add")
public ResultModel addSupplierProduct(SupplierProduct supplierProduct) {
public ResultModel addSupplierProduct(@RequestBody SupplierProduct supplierProduct) {
return supplierProductService.addSupplierProduct(supplierProduct);
}

@PostMapping("/list")
public ResultPageModel<SupplierProduct> getSupplierProductList() {
return supplierProductService.getSupplierProductList();
@PostMapping("/save")
public ResultModel saveSupplierProduct(SupplierProduct supplierProduct) {
return supplierProductService.addSupplierProduct(supplierProduct);
}

@GetMapping("/list")
public ResultPageModel<SupplierProduct> getSupplierProductList(@RequestParam(name = "productCode", required = false) String productCode) {
return supplierProductService.getSupplierProductList(productCode);
}
}
14 changes: 9 additions & 5 deletions src/main/java/com/aiassistant/mapper/SupplierProductMapper.java
Original file line number Diff line number Diff line change
Expand Up @@ -9,13 +9,17 @@

@Mapper
public interface SupplierProductMapper {
@Insert("insert into supplier_product(product_model,delivery_time,product_price,deliverable_quantity,trading_counterparty,advance_payment_ratio) "+
@Insert("insert into supplier_product(product_model,delivery_time,product_price,deliverable_quantity,trading_counterparty,advance_payment_ratio) " +
"values(#{productModel},#{deliveryTime},#{productPrice},#{deliverableQuantity},#{tradingCounterparty},#{advancePaymentRatio})")
void insertSupplierProduct(SupplierProduct supplierProduct);
@Select("select * from supplier_product")

@Select("select * from supplier_product")
List<SupplierProduct> getSupplierProductList();

@Select("select * from supplier_product where product_model = #{productModel}")

@Select("select * from supplier_product where product_model like '%' || #{productModel} || '%'")
List<SupplierProduct> getSupplierProductListByModel(String productModel);


@Select("select * from supplier_product where product_model = #{productModel} limit 1")
SupplierProduct selectByProductModel(String productModel);
}
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,6 @@

public interface SupplierProductService {
ResultModel addSupplierProduct(SupplierProduct supplierProduct);
ResultPageModel<SupplierProduct> getSupplierProductList();
ResultPageModel<SupplierProduct> getSupplierProductList(String productCode);
SupplierProduct getSupplierProductByProductModel(String productModel);
}
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@
import com.aiassistant.service.SupplierProductService;
import com.aiassistant.utils.ResultModel;
import com.aiassistant.utils.ResultPageModel;
import org.apache.commons.lang3.StringUtils;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

Expand All @@ -25,12 +26,16 @@ public ResultModel addSupplierProduct(SupplierProduct supplierProduct) {
}

@Override
public ResultPageModel<SupplierProduct> getSupplierProductList() {
ResultPageModel<SupplierProduct> resultPageModel =
ResultPageModel.of(supplierProductMapper.getSupplierProductList());
return resultPageModel;
public ResultPageModel<SupplierProduct> getSupplierProductList(String productCode) {
if (StringUtils.isNotBlank(productCode)) {
return ResultPageModel.of(supplierProductMapper.getSupplierProductListByModel(productCode));
} else {
ResultPageModel<SupplierProduct> resultPageModel =
ResultPageModel.of(supplierProductMapper.getSupplierProductList());
return resultPageModel;
}
}


@Override
public SupplierProduct getSupplierProductByProductModel(String productModel) {
Expand Down
163 changes: 163 additions & 0 deletions src/main/resources/static/index.html
Original file line number Diff line number Diff line change
@@ -0,0 +1,163 @@
<!DOCTYPE html>
<html>
<head>
<meta charset="UTF-8">
<link rel="stylesheet" type="text/css" href="semantic/semantic.min.css">
<script src="jquery-3.6.0.min.js"></script>
<script src="semantic/semantic.min.js"></script>
</head>
<body>
<div class="center center-content">
<div class="ui segment">

<!-- 查询输入框 -->
<div class="ui labeled input">
<label class="ui label" for="productCode">产品型号:</label>
<input type="text" placeholder="产品编码" id="productCode">
</div>


<button class="ui primary button" id="searchButton">查询</button>


<button class="ui primary button" id="addButton">添加</button>


<h3>Data List</h3>
<table class="ui celled table">
<thead>
<tr>
<th>产品型号</th>
<th>交付时间</th>
<th>产品价格</th>
<th>可交付数量</th>
<th>交易对手方</th>
<th>预付款比例</th>
</tr>
</thead>
<tbody id="data-table-body">
<!-- Data will be dynamically populated here -->
</tbody>
</table>


</div>

<div class="ui modal" id="myModal">
<i class="close icon"></i>
<div class="header">
新增
</div>
<div class="content">
<!-- 使用表单 -->
<form id="feedbackForm">
<div class="ui form">
<div class="field">
<label>产品型号</label>
<input type="text" name="productModel" placeholder="输入产品型号">
</div>
<div class="field">
<label>交付时间</label>
<input type="text" name="deliveryTime" placeholder="输入交付时间">
</div>
<div class="field">
<label>产品价格</label>
<input type="text" name="productPrice" placeholder="输入产品价格">
</div>
<div class="field">
<label>可交付数量</label>
<input type="text" name="deliverableQuantity" placeholder="输入可交付数量">
</div>
<div class="field">
<label>交易对手方</label>
<input type="text" name="tradingCounterparty" placeholder="输入交易对手方">
</div>
<div class="field">
<label>预付款比例</label>
<input type="text" name="advancePaymentRatio" placeholder="输入预付款比例">
</div>
</div>
</form>
</div>
<div class="actions">
<div class="ui button" id="cancelButton">取消</div>
<button type="button" class="ui primary button" id="saveButton">保存</button>
</div>
</div>

</div>

<script>
$(document).ready(function () {
search('',0)
});

$('#searchButton').click(function () {
var productCode = $('#productCode').val();
search(productCode, 1)
})

function search(product_code, flag) {
$("#data-table-body").empty();

$.get("/supplierProduct/list?productCode=" + product_code, function (data) {

const tableBody = document.getElementById('data-table-body');

// Iterate through the data and create list items
$.each(data.list, function (index, item) {
const row = document.createElement('tr');
row.innerHTML = `
<td>${item.productModel}</td>
<td>${item.deliveryTime}</td>
<td>${item.productPrice}</td>
<td>${item.deliverableQuantity}</td>
<td>${item.tradingCounterparty}</td>
<td>${item.advancePaymentRatio}</td>
`;
tableBody.appendChild(row);



//$("#data-list").append("<li class='item'>" + item.name + "</li>");
});

});

}

$('#addButton').click(function () {
$('#myModal').modal('show'); // 显示模态框
});

$('#cancelButton').click(function () {
$('#myModal').modal('hide'); // 隐藏模态框
});

$('#saveButton').click(function() {
// 获取表单数据
var formData = new FormData(document.getElementById('feedbackForm'));

// 手动触发AJAX请求
$.ajax({
url: '/supplierProduct/save',
type: 'POST',
data: formData,
processData: false,
contentType: false,
success: function(response) {
// 处理保存成功的响应
location.reload();
},
error: function(error) {
// 处理保存失败的情况
}
});
});



</script>

</body>
</html>
2 changes: 2 additions & 0 deletions src/main/resources/static/jquery-3.6.0.min.js

Large diffs are not rendered by default.

4 changes: 4 additions & 0 deletions src/main/resources/static/semantic/.versions
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
jquery@1.11.3_2
meteor@1.1.6
semantic:ui-css@2.0.7
underscore@1.0.3
22 changes: 22 additions & 0 deletions src/main/resources/static/semantic/LICENSE
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
The MIT License (MIT)

Copyright (c) 2015 Semantic Org

Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
in the Software without restriction, including without limitation the rights
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
copies of the Software, and to permit persons to whom the Software is
furnished to do so, subject to the following conditions:

The above copyright notice and this permission notice shall be included in all
copies or substantial portions of the Software.

THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
SOFTWARE.

7 changes: 7 additions & 0 deletions src/main/resources/static/semantic/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
# CSS Distribution

This repository is automatically synced with the main [Semantic UI](https://github.com/Semantic-Org/Semantic-UI) repository to provide lightweight CSS only version of Semantic UI.

This package **does not support theming** and includes generated CSS files of the default theme only.

You can view more on Semantic UI at [LearnSemantic.com](http://www.learnsemantic.com) and [Semantic-UI.com](http://www.semantic-ui.com)
Loading

0 comments on commit 87d5827

Please sign in to comment.