Browse Source

更新

master
gengby 2 years ago
parent
commit
aaf10a6edb
  1. 8
      acs/nladmin-system/src/main/java/org/nl/acs/device/service/StorageCellService.java
  2. 13
      acs/nladmin-system/src/main/java/org/nl/acs/device/service/impl/StorageCellServiceImpl.java
  3. 14
      acs/nladmin-system/src/main/java/org/nl/acs/device_driver/basedriver/agv/ndcone/AgvNdcOneDeviceDriver.java
  4. 26
      acs/nladmin-system/src/main/java/org/nl/acs/ext/wms/service/impl/WmsToAcsServiceImpl.java
  5. 4
      acs/nladmin-system/src/main/java/org/nl/modules/system/repository/DictDetailRepository.java
  6. 10
      acs/nladmin-system/src/main/java/org/nl/modules/system/rest/DictController.java
  7. 4
      acs/nladmin-system/src/main/java/org/nl/modules/system/service/DictDetailService.java
  8. 9
      acs/nladmin-system/src/main/java/org/nl/modules/system/service/DictService.java
  9. 10
      acs/nladmin-system/src/main/java/org/nl/modules/system/service/impl/DictDetailServiceImpl.java
  10. 74
      acs/nladmin-system/src/main/java/org/nl/modules/system/service/impl/DictServiceImpl.java
  11. 9
      acs/nladmin-ui/src/api/system/dict.js
  12. 116
      acs/nladmin-ui/src/views/system/dict/UploadDialog.vue
  13. 26
      acs/nladmin-ui/src/views/system/dict/index.vue

8
acs/nladmin-system/src/main/java/org/nl/acs/device/service/StorageCellService.java

@ -49,6 +49,14 @@ public interface StorageCellService {
*/ */
StorageCellDto findByCode(String code); StorageCellDto findByCode(String code);
/**
* 根据编码查询
*
* @param parent_storage_code parent_storage_code
* @return StorageCell
*/
StorageCellDto findByParentCode(String parent_storage_code);
/** /**
* 根据地址查询 * 根据地址查询
* *

13
acs/nladmin-system/src/main/java/org/nl/acs/device/service/impl/StorageCellServiceImpl.java

@ -83,7 +83,18 @@ public class StorageCellServiceImpl implements StorageCellService {
@Override @Override
public StorageCellDto findByCode(String code) { public StorageCellDto findByCode(String code) {
WQLObject wo = WQLObject.getWQLObject("acs_storage_cell"); WQLObject wo = WQLObject.getWQLObject("acs_storage_cell");
JSONObject json = wo.query("code ='" + code + "'").uniqueResult(0); JSONObject json = wo.query("storage_code ='" + code + "'").uniqueResult(0);
if (ObjectUtil.isNotEmpty(json)){
final StorageCellDto obj = json.toJavaObject(StorageCellDto.class);
return obj;
}
return null;
}
@Override
public StorageCellDto findByParentCode(String parent_storage_code) {
WQLObject wo = WQLObject.getWQLObject("acs_storage_cell");
JSONObject json = wo.query("parent_storage_code ='" + parent_storage_code + "'").uniqueResult(0);
if (ObjectUtil.isNotEmpty(json)){ if (ObjectUtil.isNotEmpty(json)){
final StorageCellDto obj = json.toJavaObject(StorageCellDto.class); final StorageCellDto obj = json.toJavaObject(StorageCellDto.class);
return obj; return obj;

14
acs/nladmin-system/src/main/java/org/nl/acs/device_driver/basedriver/agv/ndcone/AgvNdcOneDeviceDriver.java

@ -11,6 +11,8 @@ import lombok.extern.slf4j.Slf4j;
import org.nl.acs.agv.server.NDCAgvService; import org.nl.acs.agv.server.NDCAgvService;
import org.nl.acs.auto.run.OneNDCSocketConnectionAutoRun; import org.nl.acs.auto.run.OneNDCSocketConnectionAutoRun;
import org.nl.acs.device.service.DeviceService; import org.nl.acs.device.service.DeviceService;
import org.nl.acs.device.service.StorageCellService;
import org.nl.acs.device.service.impl.StorageCellServiceImpl;
import org.nl.acs.device_driver.DeviceDriver; import org.nl.acs.device_driver.DeviceDriver;
import org.nl.acs.device_driver.basedriver.siemens_conveyor.SiemensConveyorDeviceDriver; import org.nl.acs.device_driver.basedriver.siemens_conveyor.SiemensConveyorDeviceDriver;
import org.nl.acs.device_driver.basedriver.standard_ordinary_site.StandardOrdinarySiteDeviceDriver; import org.nl.acs.device_driver.basedriver.standard_ordinary_site.StandardOrdinarySiteDeviceDriver;
@ -28,7 +30,9 @@ import org.nl.acs.opc.Device;
import org.nl.acs.opc.DeviceAppService; import org.nl.acs.opc.DeviceAppService;
import org.nl.acs.task.service.TaskService; import org.nl.acs.task.service.TaskService;
import org.nl.acs.task.service.impl.TaskServiceImpl; import org.nl.acs.task.service.impl.TaskServiceImpl;
import org.nl.modules.system.service.DictDetailService;
import org.nl.modules.system.service.ParamService; import org.nl.modules.system.service.ParamService;
import org.nl.modules.system.service.impl.DictDetailServiceImpl;
import org.nl.modules.system.service.impl.ParamServiceImpl; import org.nl.modules.system.service.impl.ParamServiceImpl;
import org.nl.modules.wql.util.SpringContextHolder; import org.nl.modules.wql.util.SpringContextHolder;
@ -46,6 +50,7 @@ import java.util.Map;
public class AgvNdcOneDeviceDriver extends AbstractDeviceDriver implements DeviceDriver { public class AgvNdcOneDeviceDriver extends AbstractDeviceDriver implements DeviceDriver {
ParamService paramService = SpringContextHolder.getBean(ParamServiceImpl.class); ParamService paramService = SpringContextHolder.getBean(ParamServiceImpl.class);
DictDetailService dictDetailService = SpringContextHolder.getBean(DictDetailServiceImpl.class);
InstructionService instructionService = SpringContextHolder.getBean(InstructionServiceImpl.class); InstructionService instructionService = SpringContextHolder.getBean(InstructionServiceImpl.class);
AcsToWmsService acsToWmsService = SpringContextHolder.getBean(AcsToWmsServiceImpl.class); AcsToWmsService acsToWmsService = SpringContextHolder.getBean(AcsToWmsServiceImpl.class);
TaskService taskService = SpringContextHolder.getBean(TaskServiceImpl.class); TaskService taskService = SpringContextHolder.getBean(TaskServiceImpl.class);
@ -53,6 +58,7 @@ public class AgvNdcOneDeviceDriver extends AbstractDeviceDriver implements Devic
DeviceExecuteLogService logServer = SpringContextHolder.getBean(DeviceExecuteLogService.class); DeviceExecuteLogService logServer = SpringContextHolder.getBean(DeviceExecuteLogService.class);
DeviceAppService deviceAppService = SpringContextHolder.getBean(DeviceAppService.class); DeviceAppService deviceAppService = SpringContextHolder.getBean(DeviceAppService.class);
DeviceService deviceService = SpringContextHolder.getBean(DeviceService.class); DeviceService deviceService = SpringContextHolder.getBean(DeviceService.class);
StorageCellService storageCellService = SpringContextHolder.getBean(StorageCellServiceImpl.class);
int agvaddr = 0; int agvaddr = 0;
int agvaddr_copy = 0; int agvaddr_copy = 0;
int weight = 0; int weight = 0;
@ -175,7 +181,7 @@ public class AgvNdcOneDeviceDriver extends AbstractDeviceDriver implements Devic
JSONObject map = new JSONObject(); JSONObject map = new JSONObject();
map.put("Vehiclecode", inst.getVehicle_code()); map.put("Vehiclecode", inst.getVehicle_code());
map.put("Status", "1"); map.put("Status", "1");
map.put("Devicecode", inst.getStart_point_code()); map.put("Devicecode", storageCellService.findByCode(inst.getStart_point_code()).getParent_storage_code());
map.put("Taskcode", inst.getTask_code()); map.put("Taskcode", inst.getTask_code());
req.add(map); req.add(map);
HttpResponse httpResponse = acsToWmsService.feedAgvTaskStatus(req); HttpResponse httpResponse = acsToWmsService.feedAgvTaskStatus(req);
@ -233,7 +239,7 @@ public class AgvNdcOneDeviceDriver extends AbstractDeviceDriver implements Devic
JSONObject map = new JSONObject(); JSONObject map = new JSONObject();
map.put("Vehiclecode", inst.getVehicle_code()); map.put("Vehiclecode", inst.getVehicle_code());
map.put("Status", "2"); map.put("Status", "2");
map.put("Devicecode", inst.getStart_point_code()); map.put("Devicecode", storageCellService.findByCode(inst.getStart_point_code()).getParent_storage_code());
map.put("Taskcode", inst.getTask_code()); map.put("Taskcode", inst.getTask_code());
req.add(map); req.add(map);
HttpResponse httpResponse = acsToWmsService.feedAgvTaskStatus(req); HttpResponse httpResponse = acsToWmsService.feedAgvTaskStatus(req);
@ -287,7 +293,7 @@ public class AgvNdcOneDeviceDriver extends AbstractDeviceDriver implements Devic
JSONObject map = new JSONObject(); JSONObject map = new JSONObject();
map.put("Vehiclecode", inst.getVehicle_code()); map.put("Vehiclecode", inst.getVehicle_code());
map.put("Status", "3"); map.put("Status", "3");
map.put("Devicecode", inst.getNext_point_code()); map.put("Devicecode", storageCellService.findByCode(inst.getNext_point_code()).getParent_storage_code());
map.put("Taskcode", inst.getTask_code()); map.put("Taskcode", inst.getTask_code());
req.add(map); req.add(map);
HttpResponse httpResponse = acsToWmsService.feedAgvTaskStatus(req); HttpResponse httpResponse = acsToWmsService.feedAgvTaskStatus(req);
@ -341,7 +347,7 @@ public class AgvNdcOneDeviceDriver extends AbstractDeviceDriver implements Devic
JSONObject map = new JSONObject(); JSONObject map = new JSONObject();
map.put("Vehiclecode", inst.getVehicle_code()); map.put("Vehiclecode", inst.getVehicle_code());
map.put("Status", "4"); map.put("Status", "4");
map.put("Devicecode", inst.getNext_point_code()); map.put("Devicecode", storageCellService.findByCode(inst.getNext_point_code()).getParent_storage_code());
map.put("Taskcode", inst.getTask_code()); map.put("Taskcode", inst.getTask_code());
req.add(map); req.add(map);
HttpResponse httpResponse = acsToWmsService.feedAgvTaskStatus(req); HttpResponse httpResponse = acsToWmsService.feedAgvTaskStatus(req);

26
acs/nladmin-system/src/main/java/org/nl/acs/ext/wms/service/impl/WmsToAcsServiceImpl.java

@ -12,6 +12,8 @@ import lombok.extern.slf4j.Slf4j;
import org.nl.acs.AcsConfig; import org.nl.acs.AcsConfig;
import org.nl.acs.common.IDriverService; import org.nl.acs.common.IDriverService;
import org.nl.acs.device.service.DeviceService; import org.nl.acs.device.service.DeviceService;
import org.nl.acs.device.service.StorageCellService;
import org.nl.acs.device.service.dto.StorageCellDto;
import org.nl.acs.device_driver.basedriver.cargo_lift_conveyor.CargoLiftConveyorDeviceDriver; import org.nl.acs.device_driver.basedriver.cargo_lift_conveyor.CargoLiftConveyorDeviceDriver;
import org.nl.acs.device_driver.basedriver.empty_vehicle_stacking_position.EmptyVehicleStackingPositionDeviceDriver; import org.nl.acs.device_driver.basedriver.empty_vehicle_stacking_position.EmptyVehicleStackingPositionDeviceDriver;
import org.nl.acs.device_driver.basedriver.hongxiang_conveyor.HongXiangStationDeviceDriver; import org.nl.acs.device_driver.basedriver.hongxiang_conveyor.HongXiangStationDeviceDriver;
@ -31,6 +33,8 @@ import org.nl.acs.route.service.RouteLineService;
import org.nl.acs.task.service.TaskService; import org.nl.acs.task.service.TaskService;
import org.nl.acs.task.service.dto.TaskDto; import org.nl.acs.task.service.dto.TaskDto;
import org.nl.modules.common.exception.BadRequestException; import org.nl.modules.common.exception.BadRequestException;
import org.nl.modules.system.domain.DictDetail;
import org.nl.modules.system.service.DictDetailService;
import org.nl.modules.system.service.ParamService; import org.nl.modules.system.service.ParamService;
import org.nl.modules.wql.core.bean.WQLObject; import org.nl.modules.wql.core.bean.WQLObject;
import org.nl.modules.wql.exception.WDKException; import org.nl.modules.wql.exception.WDKException;
@ -58,7 +62,8 @@ public class WmsToAcsServiceImpl implements WmsToAcsService {
private final DeviceAppService deviceAppService; private final DeviceAppService deviceAppService;
private final RouteLineService routeLineService; private final RouteLineService routeLineService;
private final AcsToLiKuService acsToLiKuService; private final AcsToLiKuService acsToLiKuService;
private final DictDetailService dictDetailService;
private final StorageCellService storageCellService;
private String log_file_type = "log_file_type"; private String log_file_type = "log_file_type";
private String log_type = "LMS请求ACS"; private String log_type = "LMS请求ACS";
@ -493,6 +498,25 @@ public class WmsToAcsServiceImpl implements WmsToAcsService {
errArr.add(json); errArr.add(json);
continue; continue;
} }
StorageCellDto startParentCode = storageCellService.findByParentCode(start_device_code);
StorageCellDto nextParentCode = storageCellService.findByParentCode(next_device_code);
if (ObjectUtil.isEmpty(startParentCode)){
JSONObject json = new JSONObject();
json.put("task_code", task_code);
json.put("message", "ACS未查询到该设备!设备号:" + start_device_code);
errArr.add(json);
continue;
}
if (ObjectUtil.isEmpty(nextParentCode)){
JSONObject json = new JSONObject();
json.put("task_code", task_code);
json.put("message", "ACS未查询到该设备!设备号:" + next_device_code);
errArr.add(json);
continue;
}
//start_device_code = startParentCode.getStorage_code();
//next_device_code = nextParentCode.getStorage_code();
JSONObject start_device_json = WQLObject.getWQLObject("acs_storage_cell").query("parent_storage_code ='" + start_device_code + "'").uniqueResult(0); JSONObject start_device_json = WQLObject.getWQLObject("acs_storage_cell").query("parent_storage_code ='" + start_device_code + "'").uniqueResult(0);
if (!ObjectUtil.isEmpty(start_device_json)) { if (!ObjectUtil.isEmpty(start_device_json)) {
start_point_code = (String) start_device_json.get("parent_storage_code") == null ? start_device_code : (String) start_device_json.get("storage_code"); start_point_code = (String) start_device_json.get("parent_storage_code") == null ? start_device_code : (String) start_device_json.get("storage_code");

4
acs/nladmin-system/src/main/java/org/nl/modules/system/repository/DictDetailRepository.java

@ -33,4 +33,8 @@ public interface DictDetailRepository extends JpaRepository<DictDetail, Long>, J
* @return / * @return /
*/ */
List<DictDetail> findByDictName(String name); List<DictDetail> findByDictName(String name);
DictDetail findDictDetailByLabelAndName(String label,String name);
DictDetail findDictDetailByValueAndName(String value,String name);
} }

10
acs/nladmin-system/src/main/java/org/nl/modules/system/rest/DictController.java

@ -29,7 +29,9 @@ import org.springframework.http.HttpStatus;
import org.springframework.http.ResponseEntity; import org.springframework.http.ResponseEntity;
import org.springframework.validation.annotation.Validated; import org.springframework.validation.annotation.Validated;
import org.springframework.web.bind.annotation.*; import org.springframework.web.bind.annotation.*;
import org.springframework.web.multipart.MultipartFile;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse; import javax.servlet.http.HttpServletResponse;
import java.io.IOException; import java.io.IOException;
import java.util.Set; import java.util.Set;
@ -97,4 +99,12 @@ public class DictController {
dictService.delete(ids); dictService.delete(ids);
return new ResponseEntity<>(HttpStatus.OK); return new ResponseEntity<>(HttpStatus.OK);
} }
@PostMapping("/excelImport")
@Log("excel导入")
@ApiOperation("excel导入")
public ResponseEntity<Object> excelImport(@RequestParam("file") MultipartFile file, HttpServletRequest request) {
dictService.excelImport(file, request);
return new ResponseEntity<>(HttpStatus.OK);
}
} }

4
acs/nladmin-system/src/main/java/org/nl/modules/system/service/DictDetailService.java

@ -61,4 +61,8 @@ public interface DictDetailService {
* @return / * @return /
*/ */
List<DictDetailDto> getDictByName(String name); List<DictDetailDto> getDictByName(String name);
DictDetail findDictDetailByLabelAndName(String label,String name);
DictDetail findDictDetailByValueAndName(String value,String name);
} }

9
acs/nladmin-system/src/main/java/org/nl/modules/system/service/DictService.java

@ -19,7 +19,9 @@ import org.nl.modules.system.domain.Dict;
import org.nl.modules.system.service.dto.DictDto; import org.nl.modules.system.service.dto.DictDto;
import org.nl.modules.system.service.dto.DictQueryCriteria; import org.nl.modules.system.service.dto.DictQueryCriteria;
import org.springframework.data.domain.Pageable; import org.springframework.data.domain.Pageable;
import org.springframework.web.multipart.MultipartFile;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse; import javax.servlet.http.HttpServletResponse;
import java.io.IOException; import java.io.IOException;
import java.util.List; import java.util.List;
@ -73,4 +75,11 @@ public interface DictService {
* @throws IOException / * @throws IOException /
*/ */
void download(List<DictDto> queryAll, HttpServletResponse response) throws IOException; void download(List<DictDto> queryAll, HttpServletResponse response) throws IOException;
/**
* excel导入
* @param file
* @param request
*/
void excelImport(MultipartFile file, HttpServletRequest request);
} }

10
acs/nladmin-system/src/main/java/org/nl/modules/system/service/impl/DictDetailServiceImpl.java

@ -83,6 +83,16 @@ public class DictDetailServiceImpl implements DictDetailService {
return dictDetailMapper.toDto(dictDetailRepository.findByDictName(name)); return dictDetailMapper.toDto(dictDetailRepository.findByDictName(name));
} }
@Override
public DictDetail findDictDetailByLabelAndName(String label, String name) {
return dictDetailRepository.findDictDetailByLabelAndName(label, name);
}
@Override
public DictDetail findDictDetailByValueAndName(String value, String name) {
return dictDetailRepository.findDictDetailByValueAndName(value, name);
}
@Override @Override
@Transactional(rollbackFor = Exception.class) @Transactional(rollbackFor = Exception.class)
public void delete(Long id) { public void delete(Long id) {

74
acs/nladmin-system/src/main/java/org/nl/modules/system/service/impl/DictServiceImpl.java

@ -16,23 +16,38 @@
package org.nl.modules.system.service.impl; package org.nl.modules.system.service.impl;
import cn.hutool.core.collection.CollectionUtil; import cn.hutool.core.collection.CollectionUtil;
import cn.hutool.core.date.DateUtil;
import cn.hutool.core.util.IdUtil;
import cn.hutool.core.util.ObjectUtil;
import cn.hutool.core.util.StrUtil;
import cn.hutool.poi.excel.ExcelReader;
import cn.hutool.poi.excel.ExcelUtil;
import com.alibaba.fastjson.JSONObject;
import lombok.RequiredArgsConstructor; import lombok.RequiredArgsConstructor;
import org.nl.acs.device.service.dto.DeviceDto;
import org.nl.modules.common.exception.BadRequestException;
import org.nl.modules.common.utils.*; import org.nl.modules.common.utils.*;
import org.nl.modules.system.domain.Dict; import org.nl.modules.system.domain.Dict;
import org.nl.modules.system.domain.DictDetail;
import org.nl.modules.system.repository.DictRepository; import org.nl.modules.system.repository.DictRepository;
import org.nl.modules.system.service.DictDetailService;
import org.nl.modules.system.service.DictService; import org.nl.modules.system.service.DictService;
import org.nl.modules.system.service.dto.DictDetailDto; import org.nl.modules.system.service.dto.DictDetailDto;
import org.nl.modules.system.service.dto.DictDto; import org.nl.modules.system.service.dto.DictDto;
import org.nl.modules.system.service.dto.DictQueryCriteria; import org.nl.modules.system.service.dto.DictQueryCriteria;
import org.nl.modules.system.service.mapstruct.DictMapper; import org.nl.modules.system.service.mapstruct.DictMapper;
import org.nl.modules.wql.core.bean.WQLObject;
import org.springframework.cache.annotation.CacheConfig; import org.springframework.cache.annotation.CacheConfig;
import org.springframework.data.domain.Page; import org.springframework.data.domain.Page;
import org.springframework.data.domain.Pageable; import org.springframework.data.domain.Pageable;
import org.springframework.stereotype.Service; import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional; import org.springframework.transaction.annotation.Transactional;
import org.springframework.web.multipart.MultipartFile;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse; import javax.servlet.http.HttpServletResponse;
import java.io.IOException; import java.io.IOException;
import java.io.InputStream;
import java.util.*; import java.util.*;
/** /**
@ -47,6 +62,7 @@ public class DictServiceImpl implements DictService {
private final DictRepository dictRepository; private final DictRepository dictRepository;
private final DictMapper dictMapper; private final DictMapper dictMapper;
private final RedisUtils redisUtils; private final RedisUtils redisUtils;
private final DictDetailService dictDetailService;
@Override @Override
public Map<String, Object> queryAll(DictQueryCriteria dict, Pageable pageable){ public Map<String, Object> queryAll(DictQueryCriteria dict, Pageable pageable){
@ -116,6 +132,64 @@ public class DictServiceImpl implements DictService {
FileUtil.downloadExcel(list, response); FileUtil.downloadExcel(list, response);
} }
public List<Dict> queryAll(DictQueryCriteria dict,String a) {
List<Dict> list = dictRepository.findAll((root, query, cb) -> QueryHelp.getPredicate(root, dict, cb));
return list;
}
@Override
@Transactional
public void excelImport(MultipartFile file, HttpServletRequest request) {
if (file.isEmpty()) {
throw new BadRequestException("文件为空,请添加数据后重新导入");
}
Long currentUserId = SecurityUtils.getCurrentUserId();
String nickName = SecurityUtils.getCurrentNickName();
String now = DateUtil.now();
// 1.获取上传文件输入流
InputStream inputStream = null;
try {
inputStream = file.getInputStream();
} catch (Exception e) {
e.printStackTrace();
}
// 调用用 hutool 方法读取数据 默认调用第一个sheet
ExcelReader excelReader = ExcelUtil.getReader(inputStream);
// 从第二行开始获取数据 excelReader.read的结果是一个2纬的list,外层是行,内层是行对应的所有列
List<List<Object>> read = excelReader.read(1, excelReader.getRowCount());
// 循环获取的数据
for (int i = 0; i < read.size(); i++) {
List list = read.get(i);
JSONObject param = new JSONObject();
String label = list.get(0).toString();
String value = list.get(1).toString();
if (StrUtil.isEmpty(label)) {
throw new BadRequestException("wms编号不能为空!");
}
if (StrUtil.isEmpty(value)) {
throw new BadRequestException("acs编号不能为空!");
}
DictDetail detail = dictDetailService.findDictDetailByLabelAndName(label, "location_comparison");
if (ObjectUtil.isNotEmpty(detail)){
continue;
}
DictQueryCriteria dict = new DictQueryCriteria();
dict.setBlurry("location_comparison");
List<Dict> dictDtos = queryAll(dict,"");
Dict dictDto = dictDtos.get(0);
DictDetail dictDetail = new DictDetail();
dictDetail.setId(IdUtil.getSnowflake().nextId());
dictDetail.setDictSort(i + 1);
dictDetail.setLabel(label);
dictDetail.setValue(value);
dictDetail.setDict(dictDto);
dictDetail.setCreateBy(SecurityUtils.getCurrentUsername());
dictDetail.setName("location_comparison");
dictDetailService.create(dictDetail);
}
}
public void delCaches(Dict dict){ public void delCaches(Dict dict){
redisUtils.del("dict::name:" + dict.getName()); redisUtils.del("dict::name:" + dict.getName());
} }

9
acs/nladmin-ui/src/api/system/dict.js

@ -30,5 +30,12 @@ export function edit(data) {
data data
}) })
} }
export function excelImport(data) {
return request({
url: 'api/dict/excelImport',
method: 'post',
data
})
}
export default { add, edit, del } export default { add, edit, del, excelImport }

116
acs/nladmin-ui/src/views/system/dict/UploadDialog.vue

@ -0,0 +1,116 @@
<template>
<el-dialog
title="导入Excel文件"
append-to-body
:visible.sync="dialogVisible"
destroy-on-close
width="400px"
:show-close="true"
@close="close"
@open="open"
>
<el-upload
ref="upload"
class="upload-demo"
action=""
drag
:on-exceed="is_one"
:limit="1"
:auto-upload="false"
:multiple="false"
:show-file-list="true"
:on-change="uploadByJsqd"
:file-list="fileList"
accept=".xlsx,.xls"
>
<i class="el-icon-upload" />
<div class="el-upload__text">
将文件拖到此处
<em>点击上传</em>
</div>
<div slot="tip" class="el-upload__tip">只能上传Excel文件且不超过10MB</div>
</el-upload>
<span slot="footer" class="dialog-footer">
<el-button @click="dialogVisible = false"> </el-button>
<el-button type="primary" @click="submit"> </el-button>
</span>
</el-dialog>
</template>
<script>
import crudDict from '@/api/system/dict'
import CRUD, { crud } from '@crud/crud'
export default {
name: 'UploadDialog',
mixins: [crud()],
components: {},
props: {
dialogShow: {
type: Boolean,
default: false
},
openParam: {
type: String
}
},
data() {
return {
dialogVisible: false,
fileList: [],
file1: ''
}
},
watch: {
dialogShow: {
handler(newValue, oldValue) {
this.dialogVisible = newValue
}
},
openParam: {
handler(newValue, oldValue) {
this.opendtlParam = newValue
}
}
},
methods: {
open() {
},
close() {
this.$emit('update:dialogShow', false)
},
is_one() {
this.crud.notify('只能上传一个excel文件!', CRUD.NOTIFICATION_TYPE.WARNING)
},
//
beforeAvatarUpload(file) {
// 2Mb
if (file.size > 10 * 1024 * 1024) {
return false
}
return true
},
//
uploadByJsqd(file) {
this.file1 = file
},
submit() {
if (this.beforeAvatarUpload(this.file1)) {
this.fileList.name = this.file1.name
this.fileList.url = ''
var formdata = new FormData()
formdata.append('file', this.file1.raw)
// excelImport formdata
crudDict.excelImport(formdata).then((res) => {
this.crud.notify('导入成功', CRUD.NOTIFICATION_TYPE.SUCCESS)
this.$emit('tableChanged3', '')
this.$emit('update:dialogShow', false)
})
} else {
this.crud.notify('文件过大,请上传小于10MB的文件〜', CRUD.NOTIFICATION_TYPE.WARNING)
}
}
}
}
</script>

26
acs/nladmin-ui/src/views/system/dict/index.vue

@ -60,11 +60,24 @@
icon="el-icon-plus" icon="el-icon-plus"
@click="$refs.dictDetail && $refs.dictDetail.crud.toAdd()" @click="$refs.dictDetail && $refs.dictDetail.crud.toAdd()"
>新增</el-button> >新增</el-button>
<el-button
v-if="dictNames === 'location_comparison'"
slot="right"
class="filter-item"
style="float: right;padding: 4px 10px"
type="warning"
icon="el-icon-upload2"
size="mini"
@click="uploadShow = true"
>
导入
</el-button>
</div> </div>
<dictDetail ref="dictDetail" :permission="permission" /> <dictDetail ref="dictDetail" :permission="permission" />
</el-card> </el-card>
</el-col> </el-col>
</el-row> </el-row>
<UploadDialog :dialog-show.sync="uploadShow" @tableChanged3="tableChanged3" />
</div> </div>
</template> </template>
@ -78,12 +91,12 @@ import crudOperation from '@crud/CRUD.operation'
import pagination from '@crud/Pagination' import pagination from '@crud/Pagination'
import rrOperation from '@crud/RR.operation' import rrOperation from '@crud/RR.operation'
import udOperation from '@crud/UD.operation' import udOperation from '@crud/UD.operation'
import UploadDialog from '@/views/system/dict/UploadDialog'
const defaultForm = { id: null, name: null, description: null, dictDetails: [] } const defaultForm = { id: null, name: null, description: null, dictDetails: [] }
export default { export default {
name: 'Dict', name: 'Dict',
components: { crudOperation, pagination, rrOperation, udOperation, dictDetail }, components: { crudOperation, pagination, rrOperation, udOperation, dictDetail, UploadDialog },
cruds() { cruds() {
return [ return [
CRUD({ title: '字典', url: 'api/dict', crudMethod: { ...crudDict }}) CRUD({ title: '字典', url: 'api/dict', crudMethod: { ...crudDict }})
@ -105,7 +118,9 @@ export default {
add: ['admin', 'dict:add'], add: ['admin', 'dict:add'],
edit: ['admin', 'dict:edit'], edit: ['admin', 'dict:edit'],
del: ['admin', 'dict:del'] del: ['admin', 'dict:del']
} },
uploadShow: false,
dictNames: ''
} }
}, },
methods: { methods: {
@ -117,9 +132,14 @@ export default {
} }
return true return true
}, },
tableChanged3() {
this.$refs.dictDetail.crud.toQuery()
},
// //
handleCurrentChange(val) { handleCurrentChange(val) {
if (val) { if (val) {
console.log(val)
this.dictNames = val.name
this.$refs.dictDetail.query.dictName = val.name this.$refs.dictDetail.query.dictName = val.name
this.$refs.dictDetail.dictId = val.id this.$refs.dictDetail.dictId = val.id
this.$refs.dictDetail.crud.toQuery() this.$refs.dictDetail.crud.toQuery()

Loading…
Cancel
Save