Commit a50a15e9 authored by 覃振观's avatar 覃振观 👶

产品接口

parent a0cab296
/**
* 监听页面动作,维护数据映射及数据集
* 当前主要使用遍历实现。
* 后期优化项目, window.dataSet.newData.backColors.compares 需要向外抛出、并且单独维护。
* @createDate 2019-04-12
*/
......@@ -177,7 +178,7 @@ function checkArrayMapper(str) {
}
/**
* Grid 编辑前触发。 这里记录当前编辑框 对应的 Grid 行索引 GridRowIndex
* Grid 编辑前触发。 这里记录当前编辑框 对应的 Grid 行 rowIndex 和列 property
* @param options
* @private
*/
......@@ -200,7 +201,7 @@ function onBeforeEdit_(options) {
console.error("dataMapping 中,无法找到该 DOMId 的映射。请检查!");
} else {
//mapperEntry[currentMapper.beanName]['rowId'] = parentDomId;
mapperEntry[currentMapper.beanName][rowId]['rowIndex'] = editParm.rowindex;
mapperEntry[currentMapper.beanName][rowId] = colName;
}
}
originalOnBeforeEdit.call(this, editParm, '11');
......@@ -221,18 +222,42 @@ function listeningSearchbox(elId, options) {
if(eleName.split('_').length > 1) {
property = eleName.split('_')[1];
} else {
let beanName = mapper[0];
property = mapper[1];
if(typeof property== 'string') {
window.dataSet.newData[beanName][property] = data[property];
fillInValue = data[property];
} else if(property instanceof Object) {
let entry = Object.entries(property);
let rowIndex = entry[0];
let propertyName = entry[1];
window.dataSet.newData[beanName].compares[rowIndex]
}
}
let beanName = mapper[0];
window.dataSet.newData[beanName][property] = data[property];
fillInValue = data[property];
})
originalOnChange.call(this, value, data, fillInValue);
}
$(elId).searchbox(options);
}
function listeningGridSearchbox(propertyName, options) {
if(!window.gridSearchboxOptions) {
window.gridSearchboxOptions = {};
}
window.gridSearchboxOptions[propertyName] = options;
}
function DropdownTrigger(node) {
let nodeId = node.id;
let tempId = nodeId.slice(0, nodeId.lastIndexOf('_'));
listeningSearchbox('#'+nodeId, window.gridSearchboxOptions[tempId]);
}
/**
* 若需要监听 Grid 数据,必须在此调用组件初始化,此处获取元素 ID
* @param elId
......@@ -280,8 +305,8 @@ function listeningGrid(elId, options) {
// ------------- 设置 mapper -------------
settingGridMapper(currentMapper.property.columns, mapper, rowId, beanName, data);
data[idProperty] = rowId;
data['rowIndex'] =rowId
// data[idProperty] = rowId;
data['rowIndex'] = rowId
// ------------- 设置 compares -------------
if(!window.dataSet.newData[beanName]) {
window.dataSet.newData[beanName] = {};
......@@ -296,7 +321,7 @@ function listeningGrid(elId, options) {
}
window.dataSet.newData[beanName].ids.push(rowId);
UICtrl.addGridRow(gridManager, data);
originalOnClick.call(this, data);
originalOnClick.call(this, data, gridManager);
}
}
if(but.id === "menuDelete") {
......@@ -316,7 +341,7 @@ function listeningGrid(elId, options) {
});
gridManager.deleteSelectedRow();
debugger;
originalOnClick.call(this, selectRow);
originalOnClick.call(this, selectRow, gridManager);
}
}
})
......@@ -361,7 +386,6 @@ function listenerContent(event) {
debugger;
tryForEach(Object.entries(beanMapping), mapperEntry => {
let mapperKey = mapperEntry[0], mapperVal = mapperEntry[1];
Object.entries(mapperEntry[1]).forEach(rowEntry => {
let rowId = rowEntry[0];
if(rowEntry[1].rowIndex != undefined) {
......@@ -424,7 +448,8 @@ const observer = new MutationObserver((mutations) => {
let childNodes = addNodes[0].childNodes;
if(childNodes.length === 1 && childNodes[0].nodeName === 'INPUT') {
let node = childNodes[0];
node.addEventListener('input', gridEditor)
node.addEventListener('input', gridEditor);
DropdownTrigger(node);
}
}
let removeNodes = mutation.removedNodes;
......@@ -469,6 +494,7 @@ function checkUpdata() {
let rawIds = raw.ids, nowIds = now.ids;
dataSet.upData[beanName] = {};
dataSet.upData[beanName].del = [];
debugger;
let delIds = rawIds.filter(x => !nowIds.includes(x));
tryForEach(delIds, id => {
dataSet.upData[beanName].del.push(rawCompares[id]);
......
......@@ -4,6 +4,7 @@ $(document).ready(function() {
initializeToobarContainer();
initializeTab();
initializateSelectC();
initGridSearchbox();
// runObserver();
});
......@@ -51,11 +52,21 @@ function initializateSelectC() {
$('#submitForm').formSet(showData);
processedGrid('#processedGrid', window.dataSet.rawData.processed);
});
// $('#selectedTechnology').val(data.productTechnologyName)
}
});
}
function initGridSearchbox() {
listeningGridSearchbox('fronColorsGrid_colorId', {
type: "product",
name: "color",
onChange: function (value, data, fillInValue) {
console.log('fillInValue : '+ fillInValue);
debugger;
// $('#selectedTechnology').val(data.productTechnologyName)
}
})
}
function initializeUI() {
......@@ -168,11 +179,11 @@ var dataMapping = {
},
fronColors: {
id: "productFaceColorId",
columns: [ "productFaceColorId", "coverageRate" ]
columns: [ "productFaceColorId", "coverageRate", "productFaceId", "colorId" ]
},
backColors: {
id: "productFaceColorId",
columns: [ "productFaceColorId", "coverageRate" ]
columns: [ "productFaceColorId", "coverageRate", "productFaceId", "colorId" ]
},
processed: {
id: "productTechnologyId",
......@@ -186,21 +197,27 @@ var dataMapping = {
function faceGrid(elId, data) {
var toolbarOptions = UICtrl.getDefaultToolbarOptions({
addHandler: function(rawData){
debugger;
},
updateHandler: function(){
updateHandler();
addHandler: function(rawData, gridManager){
let isBack = true;
if(gridManager.id.indexOf('fronColors') >= 0) { isBack = false; }
window.dataSet.newData.frontFaces.raw.forEach(item=> {
if(isBack === item.back) {
if(isBack) {
window.dataSet.newData.backColors.compares[rawData.rowIndex].productFaceId = item.productFaceId;
} else {
window.dataSet.newData.fronColors.compares[rawData.rowIndex].productFaceId = item.productFaceId;
}
}
})
},
deleteHandler: (rowData) => {
deleteHandler: (rowData, gridManager) => {
console.log(rowData.rowIndex);
},
});
var gridManager = listeningGrid(elId, {
columns: [
{ display: "颜色名称", name: "productFaceColorId", width: 140, minWidth: 60, type: "string", align: "left", editor: {
type: 'text',
required: true
{ display: "颜色名称", name: "colorId", width: 140, minWidth: 60, type: "string", align: "left", editor: {
type: 'select'
}},
{ display: "油墨覆盖率(%)", name: "coverageRate", width: 120, minWidth: 60, type: "string", align: "left", editor: { type: 'text', required: true } }
],
......@@ -211,7 +228,7 @@ function faceGrid(elId, data) {
checkbox: true,
usePager: false,
width: "98%",
height: "98%",
height: "90%",
onBeforeEdit : function(editParm, gg) {
console.log('original run onBeforeEdit()');
},
......
......@@ -42,4 +42,6 @@ public interface ProductApplication {
* @createDate 2023/12/8 17:19
*/
HashMap<String, Object> saveOrUpdataOnAllDetail(HashMap<String, Object> newData);
HashMap<String, Object> queryProductList();
}
......@@ -6,6 +6,7 @@ import com.huigou.topsun.product.application.ProductApplication;
import com.huigou.topsun.product.domain.*;
import com.huigou.topsun.product.repository.*;
import com.huigou.topsun.util.Snowflake;
import com.huigou.uasp.bmp.common.application.BaseApplication;
import lombok.RequiredArgsConstructor;
import org.apache.commons.beanutils.BeanUtils;
import org.springframework.stereotype.Service;
......@@ -29,7 +30,7 @@ import java.util.stream.Stream;
*/
@Service
@RequiredArgsConstructor
public class ProductApplicationImpl implements ProductApplication {
public class ProductApplicationImpl extends BaseApplication implements ProductApplication {
@PersistenceContext(unitName = "system")
private EntityManager entityManager;
......@@ -107,9 +108,10 @@ public class ProductApplicationImpl implements ProductApplication {
if(productDetail != null) {
ArrayList<ProductFace> frontFaces = new ArrayList<>();
if(productDetail.getBackProductFaceId() != null) {
ProductFace frontFace = faceRepository.findByProductFaceId(productDetail.getBackProductFaceId());
ProductFace frontFace = faceRepository.findByProductFaceId(productDetail.getRightProductFaceId());
frontFace.setBack(false);
ArrayList <ProductFaceColor> fronColors =
(ArrayList<ProductFaceColor>) faceColorRepository.findByProductFaceId(productDetail.getBackProductFaceId());
(ArrayList<ProductFaceColor>) faceColorRepository.findByProductFaceId(productDetail.getRightProductFaceId());
frontFaces.add(frontFace);
assemble.put("fronColors", fronColors == null ? new ArrayList<>() : fronColors);
} else {
......@@ -122,6 +124,7 @@ public class ProductApplicationImpl implements ProductApplication {
}
if(productDetail.getBackProductFaceId() != null) {
ProductFace backFace = faceRepository.findByProductFaceId(productDetail.getBackProductFaceId());
backFace.setBack(true);
ArrayList <ProductFaceColor> backColors =
(ArrayList<ProductFaceColor>) faceColorRepository.findByProductFaceId(productDetail.getBackProductFaceId());
frontFaces.add(backFace);
......@@ -221,6 +224,27 @@ public class ProductApplicationImpl implements ProductApplication {
return map;
}
@Override
public HashMap<String, Object> queryProductList() {
String sql = "SELECT\n" +
"\tt.product_id,\n" +
"\tt.product_category_id,\n" +
"\tt.product_unit,\n" +
"\tt.is_only_code,\n" +
"\tt.brand_name,\n" +
"\tpc.dispatch_multiple,\n" +
"\tpc.row_num,\n" +
"\tpt.product_technology_name\n" +
"FROM\n" +
"\tproduct t\n" +
"\tLEFT JOIN product_published_conf pc ON t.product_id = pc.product_id\n" +
"\tLEFT JOIN product_technology pt ON t.product_id = pt.product_id";
ArrayList<Map<String, Object>> list = (ArrayList<Map<String, Object>>) this.sqlExecutorDao.queryToListMap(sql);
HashMap<String, Object> map = new HashMap<>(3);
map.put("productList", list);
return map;
}
@SuppressWarnings("unchecked")
public static <T> T uncheckedCast(Object obj) {
if(obj != null) {
......
......@@ -11,6 +11,7 @@ import com.huigou.topsun.product.application.ProductProcessApplication;
import com.huigou.topsun.product.domain.Product;
import com.huigou.topsun.product.domain.ProductProcess;
import com.huigou.uasp.annotation.ControllerMapping;
import com.huigou.uasp.annotation.SkipAuth;
import com.huigou.uasp.client.CommonController;
import com.huigou.util.SDO;
import org.springframework.beans.factory.annotation.Autowired;
......@@ -118,4 +119,16 @@ public class ProductController extends CommonController {
return success(list);
}
@SkipAuth
public String queryProductList() {
HashMap<String, Object> aa = productService.queryProductList();
String json = "";
try {
json = objectMapper.writeValueAsString(aa);
} catch (JsonProcessingException e) {
throw new RuntimeException(e);
}
return success(aa);
}
}
\ No newline at end of file
package com.huigou.topsun.product.repository;
import java.math.BigDecimal;
/**
* A Projection for the {@link com.huigou.topsun.product.domain.ProductDetail} entity
*/
public interface ProductDetailInfo {
String getFactoryName();
BigDecimal getBackProductFaceId();
}
\ No newline at end of file
package com.huigou.topsun.product.repository;
import java.math.BigDecimal;
/**
* A Projection for the {@link com.huigou.topsun.product.domain.Product} entity
*/
public interface ProductInfo {
BigDecimal getProductId();
String getProductName();
}
\ No newline at end of file
......@@ -4,6 +4,8 @@ import com.huigou.topsun.product.domain.Product;
import org.springframework.data.jpa.repository.JpaRepository;
import org.springframework.stereotype.Repository;
import java.util.List;
/**
* @author: xin.lu
* @Date: 2023/11/22/10:40
......@@ -12,4 +14,6 @@ import org.springframework.stereotype.Repository;
@Repository
public interface ProductRepository extends JpaRepository<Product,String> {
@Override
List<Product> findAll();
}
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment