涂强
1 year ago
9 changed files with 967 additions and 0 deletions
@ -0,0 +1,87 @@ |
|||
package org.nl.acs.order.rest; |
|||
|
|||
import io.swagger.annotations.Api; |
|||
import io.swagger.annotations.ApiOperation; |
|||
import lombok.RequiredArgsConstructor; |
|||
import lombok.extern.slf4j.Slf4j; |
|||
import org.nl.acs.order.service.OrderDetailService; |
|||
import org.nl.acs.order.service.dto.OrderDetailDto; |
|||
import org.nl.annotation.Log; |
|||
import org.springframework.data.domain.Pageable; |
|||
import org.springframework.http.HttpStatus; |
|||
import org.springframework.http.ResponseEntity; |
|||
import org.springframework.validation.annotation.Validated; |
|||
import org.springframework.web.bind.annotation.*; |
|||
import org.springframework.web.multipart.MultipartFile; |
|||
|
|||
import javax.servlet.http.HttpServletRequest; |
|||
import javax.servlet.http.HttpServletResponse; |
|||
import java.io.IOException; |
|||
import java.text.ParseException; |
|||
import java.util.Map; |
|||
|
|||
/** |
|||
* @author tuq |
|||
* @date 2023-10-24 |
|||
**/ |
|||
@RestController |
|||
@RequiredArgsConstructor |
|||
@Api(tags = "订单详细") |
|||
@RequestMapping("/api/orderdetail") |
|||
@Slf4j |
|||
public class OrderDetailController { |
|||
private final OrderDetailService orderDetailService; |
|||
|
|||
@GetMapping |
|||
@Log("查询订单") |
|||
@ApiOperation("查询订单") |
|||
//@PreAuthorize("@el.check('orderDetail:list')")
|
|||
public ResponseEntity<Object> query(@RequestParam Map whereJson, Pageable page){ |
|||
return new ResponseEntity<>(orderDetailService.queryAll(whereJson,page), HttpStatus.OK); |
|||
} |
|||
|
|||
@PostMapping |
|||
@Log("新增order") |
|||
@ApiOperation("新增order") |
|||
//@PreAuthorize("@el.check('orderDetail:add')")
|
|||
public ResponseEntity<Object> create(@Validated @RequestBody OrderDetailDto dto){ |
|||
orderDetailService.create(dto); |
|||
return new ResponseEntity<>(HttpStatus.CREATED); |
|||
} |
|||
|
|||
@PutMapping |
|||
@Log("修改order") |
|||
@ApiOperation("修改order") |
|||
//@PreAuthorize("@el.check('orderDetail:edit')")
|
|||
public ResponseEntity<Object> update(@Validated @RequestBody OrderDetailDto dto){ |
|||
orderDetailService.update(dto); |
|||
return new ResponseEntity<>(HttpStatus.NO_CONTENT); |
|||
} |
|||
|
|||
@Log("删除order") |
|||
@ApiOperation("删除order") |
|||
//@PreAuthorize("@el.check('orderDetail:del')")
|
|||
@DeleteMapping |
|||
public ResponseEntity<Object> delete(@RequestBody String[] ids) { |
|||
orderDetailService.deleteAll(ids); |
|||
return new ResponseEntity<>(HttpStatus.OK); |
|||
} |
|||
|
|||
@Log("导出order") |
|||
@ApiOperation("导出order") |
|||
@GetMapping(value = "/download") |
|||
//@PreAuthorize("@el.check('orderDetail:list')")
|
|||
public void download(HttpServletResponse response, @RequestParam Map whereJson) throws IOException { |
|||
orderDetailService.download(orderDetailService.queryAll(whereJson), response); |
|||
} |
|||
|
|||
@PostMapping("/excelImport") |
|||
@Log("excel导入") |
|||
@ApiOperation("excel导入") |
|||
public ResponseEntity<Object> excelImport(@RequestParam("file") MultipartFile file, HttpServletRequest request) throws IOException, ParseException { |
|||
orderDetailService.excelImport(file, request); |
|||
return new ResponseEntity<>(HttpStatus.OK); |
|||
} |
|||
|
|||
|
|||
} |
@ -0,0 +1,85 @@ |
|||
package org.nl.acs.order.service; |
|||
|
|||
import org.nl.acs.order.service.dto.OrderDetailDto; |
|||
import org.springframework.data.domain.Pageable; |
|||
import org.springframework.web.multipart.MultipartFile; |
|||
|
|||
import javax.servlet.http.HttpServletRequest; |
|||
import javax.servlet.http.HttpServletResponse; |
|||
import java.io.IOException; |
|||
import java.text.ParseException; |
|||
import java.util.List; |
|||
import java.util.Map; |
|||
|
|||
/** |
|||
* @description 服务接口 |
|||
* @author tuq |
|||
* @date 2023-10-24 |
|||
**/ |
|||
public interface OrderDetailService { |
|||
/** |
|||
* 查询数据分页 |
|||
* @param whereJson 条件 |
|||
* @param page 分页参数 |
|||
* @return Map<String,Object> |
|||
*/ |
|||
Map<String,Object> queryAll(Map whereJson, Pageable page); |
|||
|
|||
/** |
|||
* 查询所有数据不分页 |
|||
* @param whereJson 条件参数 |
|||
* @return List<OrderDetailDto> |
|||
*/ |
|||
List<OrderDetailDto> queryAll(Map whereJson); |
|||
|
|||
List<OrderDetailDto> queryAll(); |
|||
|
|||
/** |
|||
* 根据ID查询 |
|||
* @param order_id ID |
|||
* @return OrderDetail |
|||
*/ |
|||
OrderDetailDto findById(String order_id); |
|||
|
|||
/** |
|||
* 根据编码查询 |
|||
* @param code code |
|||
* @return OrderDetail |
|||
*/ |
|||
OrderDetailDto findByCode(String code); |
|||
|
|||
|
|||
/** |
|||
* 创建 |
|||
* @param dto / |
|||
*/ |
|||
void create(OrderDetailDto dto); |
|||
|
|||
/** |
|||
* 编辑 |
|||
* @param dto / |
|||
*/ |
|||
void update(OrderDetailDto dto); |
|||
|
|||
/** |
|||
* 多选删除 |
|||
* @param ids / |
|||
*/ |
|||
void deleteAll(String[] ids); |
|||
|
|||
/** |
|||
* 导出数据 |
|||
* @param dtos 待导出的数据 |
|||
* @param response / |
|||
* @throws IOException / |
|||
*/ |
|||
void download(List<OrderDetailDto> dtos, HttpServletResponse response) throws IOException; |
|||
|
|||
|
|||
/** |
|||
* excel导入 |
|||
* @param file |
|||
* @param request |
|||
*/ |
|||
void excelImport(MultipartFile file, HttpServletRequest request) throws ParseException, IOException; |
|||
} |
@ -0,0 +1,48 @@ |
|||
package org.nl.acs.order.service.dto; |
|||
|
|||
import lombok.Data; |
|||
|
|||
import java.io.Serializable; |
|||
import java.math.BigDecimal; |
|||
|
|||
/** |
|||
* @description / |
|||
* @author tuq |
|||
* @date 2023-10-24 |
|||
**/ |
|||
@Data |
|||
public class OrderDetailDto implements Serializable { |
|||
|
|||
/** 订单标识 */ |
|||
private String order_id; |
|||
|
|||
/** 订单号 */ |
|||
private String order_no; |
|||
|
|||
/** 管长 */ |
|||
private BigDecimal tube_len; |
|||
|
|||
/** 管径 */ |
|||
private BigDecimal tube_width; |
|||
|
|||
/** 起始时间 */ |
|||
private String start_time; |
|||
|
|||
/** 结束时间 */ |
|||
private String end_time; |
|||
|
|||
/** 间隔时间*/ |
|||
private String interval_time; |
|||
|
|||
/** 平均时间 */ |
|||
private String avg_time; |
|||
|
|||
/** 修改者 */ |
|||
private String update_by; |
|||
|
|||
/** 修改时间 */ |
|||
private String update_time; |
|||
|
|||
/** 数量 */ |
|||
private String qty; |
|||
} |
@ -0,0 +1,268 @@ |
|||
package org.nl.acs.order.service.impl; |
|||
|
|||
import cn.hutool.core.date.DateUtil; |
|||
import cn.hutool.core.text.csv.*; |
|||
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 cn.hutool.poi.excel.WorkbookUtil; |
|||
import com.alibaba.fastjson.JSONArray; |
|||
import com.alibaba.fastjson.JSONObject; |
|||
import lombok.RequiredArgsConstructor; |
|||
import lombok.extern.slf4j.Slf4j; |
|||
import org.nl.acs.order.service.OrderDetailService; |
|||
import org.nl.acs.order.service.dto.OrderDetailDto; |
|||
import org.nl.exception.BadRequestException; |
|||
import org.nl.utils.FileUtil; |
|||
import org.nl.utils.SecurityUtils; |
|||
import org.nl.wql.core.bean.ResultBean; |
|||
import org.nl.wql.core.bean.WQLObject; |
|||
import org.nl.wql.util.WqlUtil; |
|||
import org.springframework.data.domain.Pageable; |
|||
import org.springframework.stereotype.Service; |
|||
import org.springframework.transaction.annotation.Transactional; |
|||
import org.springframework.web.multipart.MultipartFile; |
|||
|
|||
import javax.servlet.http.HttpServletRequest; |
|||
import javax.servlet.http.HttpServletResponse; |
|||
import java.io.File; |
|||
import java.io.IOException; |
|||
import java.io.InputStream; |
|||
import java.nio.charset.Charset; |
|||
import java.text.ParseException; |
|||
import java.text.SimpleDateFormat; |
|||
import java.util.*; |
|||
|
|||
/** |
|||
* @author tuq |
|||
* @description 服务实现 |
|||
* @date 2023-10-24 |
|||
**/ |
|||
@Service |
|||
@RequiredArgsConstructor |
|||
@Slf4j |
|||
public class OrderDetailServiceImpl implements OrderDetailService { |
|||
|
|||
@Override |
|||
public Map<String, Object> queryAll(Map whereJson, Pageable page) { |
|||
WQLObject wo = WQLObject.getWQLObject("order_detail"); |
|||
ResultBean rb = wo.pagequery(WqlUtil.getHttpContext(page), "", "update_time desc"); |
|||
final JSONObject json = rb.pageResult(); |
|||
return json; |
|||
} |
|||
|
|||
@Override |
|||
public List<OrderDetailDto> queryAll(Map whereJson) { |
|||
WQLObject wo = WQLObject.getWQLObject("order_detail"); |
|||
JSONArray arr = wo.query().getResultJSONArray(0); |
|||
List<OrderDetailDto> list = arr.toJavaList(OrderDetailDto.class); |
|||
return list; |
|||
} |
|||
|
|||
@Override |
|||
public List<OrderDetailDto> queryAll() { |
|||
WQLObject wo = WQLObject.getWQLObject("order_detail"); |
|||
JSONArray arr = wo.query().getResultJSONArray(0); |
|||
List<OrderDetailDto> list = arr.toJavaList(OrderDetailDto.class); |
|||
return list; |
|||
} |
|||
|
|||
@Override |
|||
public OrderDetailDto findById(String order_id) { |
|||
WQLObject wo = WQLObject.getWQLObject("order_detail"); |
|||
JSONObject json = wo.query("order_id ='" + order_id + "'").uniqueResult(0); |
|||
final OrderDetailDto obj = (OrderDetailDto) JSONObject.toJavaObject(json, OrderDetailDto.class); |
|||
return obj; |
|||
} |
|||
|
|||
@Override |
|||
public OrderDetailDto findByCode(String code) { |
|||
WQLObject wo = WQLObject.getWQLObject("order_detail"); |
|||
JSONObject json = wo.query("code ='" + code + "'").uniqueResult(0); |
|||
final OrderDetailDto obj = (OrderDetailDto) JSONObject.toJavaObject(json, OrderDetailDto.class); |
|||
return obj; |
|||
} |
|||
|
|||
@Override |
|||
@Transactional(rollbackFor = Exception.class) |
|||
public void create(OrderDetailDto dto) { |
|||
String currentUsername = SecurityUtils.getCurrentUsername(); |
|||
dto.setOrder_id(IdUtil.simpleUUID()); |
|||
dto.setUpdate_time(DateUtil.now()); |
|||
dto.setUpdate_by(currentUsername); |
|||
|
|||
WQLObject wo = WQLObject.getWQLObject("order_detail"); |
|||
JSONObject json = (JSONObject) JSONObject.toJSON(dto); |
|||
wo.insert(json); |
|||
} |
|||
|
|||
@Override |
|||
@Transactional(rollbackFor = Exception.class) |
|||
public void update(OrderDetailDto dto) { |
|||
OrderDetailDto entity = this.findById(dto.getOrder_id()); |
|||
if (entity == null) throw new BadRequestException("被删除或无权限,操作失败!"); |
|||
|
|||
String currentUsername = SecurityUtils.getCurrentUsername(); |
|||
String now = DateUtil.now(); |
|||
dto.setUpdate_time(now); |
|||
dto.setUpdate_by(currentUsername); |
|||
|
|||
WQLObject wo = WQLObject.getWQLObject("order_detail"); |
|||
JSONObject json = (JSONObject) JSONObject.toJSON(dto); |
|||
wo.update(json); |
|||
} |
|||
|
|||
@Override |
|||
public void deleteAll(String[] ids) { |
|||
WQLObject wo = WQLObject.getWQLObject("order_detail"); |
|||
for (String order_id : ids) { |
|||
wo.delete("order_id = '" + order_id + "'"); |
|||
} |
|||
} |
|||
|
|||
@Override |
|||
public void download(List<OrderDetailDto> dtos, HttpServletResponse response) throws IOException { |
|||
List<Map<String, Object>> list = new ArrayList<>(); |
|||
for (OrderDetailDto orderDetailDto : dtos) { |
|||
Map<String, Object> map = new LinkedHashMap<>(); |
|||
map.put("订单号", orderDetailDto.getOrder_no()); |
|||
map.put("管长", orderDetailDto.getTube_len()); |
|||
map.put("管径", orderDetailDto.getTube_width()); |
|||
map.put("起始时间", orderDetailDto.getStart_time()); |
|||
map.put("结束时间", orderDetailDto.getEnd_time()); |
|||
map.put("间隔时间", orderDetailDto.getInterval_time()); |
|||
map.put("平均时间", orderDetailDto.getAvg_time()); |
|||
map.put("修改者", orderDetailDto.getUpdate_by()); |
|||
map.put("修改时间", orderDetailDto.getUpdate_time()); |
|||
list.add(map); |
|||
} |
|||
FileUtil.downloadExcel(list, response); |
|||
} |
|||
|
|||
@Override |
|||
@Transactional(rollbackFor = Exception.class) |
|||
public void excelImport(MultipartFile file, HttpServletRequest request) throws ParseException, IOException { |
|||
if (file.isEmpty()) { |
|||
throw new BadRequestException("文件为空,请添加数据后重新导入"); |
|||
} |
|||
Long currentUserId = SecurityUtils.getCurrentUserId(); |
|||
String nickName = SecurityUtils.getCurrentUser().getUsername(); |
|||
String now = DateUtil.now(); |
|||
// 1.获取上传文件输入流
|
|||
InputStream inputStream = null; |
|||
try { |
|||
inputStream = file.getInputStream(); |
|||
} catch (Exception e) { |
|||
e.printStackTrace(); |
|||
} |
|||
WQLObject wo = WQLObject.getWQLObject("order_detail"); |
|||
|
|||
// 调用用 hutool 方法读取数据 默认调用第一个sheet
|
|||
ExcelReader excelReader = ExcelUtil.getReader(inputStream); |
|||
// 从第二行开始获取数据 excelReader.read的结果是一个2纬的list,外层是行,内层是行对应的所有列
|
|||
List<List<Object>> read = excelReader.read(1, excelReader.getPhysicalRowCount()); |
|||
List<Object> readline = new ArrayList<>(); |
|||
// 循环获取每一行的数据
|
|||
for (int i = 0; i < read.size(); i++) { |
|||
readline.add(read.get(i)); |
|||
} |
|||
ArrayList<Object> list = new ArrayList<>(); |
|||
// 循环获取每一行的订单号数据
|
|||
for (int j = 0; j < readline.size(); j++) { |
|||
Object o = read.get(j).get(2); |
|||
list.add(o); |
|||
} |
|||
|
|||
for (int i = 0; i < read.size(); i++) { |
|||
List list1 = read.get(i); |
|||
JSONObject param = new JSONObject(); |
|||
int i1 = list.indexOf(list1.get(2));//订单号第一次出现的位置
|
|||
int i2 = list.lastIndexOf(list1.get(2));//订单号最后一次出现的位置
|
|||
if (read.get(i2).equals(list1)) { |
|||
//得到相同订单的第一条数据
|
|||
List list2 = getFirstOrder(i1, read); |
|||
//得到相同订单的最后一条数据
|
|||
List list3 = getLastOrder(i2, read); |
|||
|
|||
|
|||
//相同订单的第一条数据的时间
|
|||
String time1 = list2.get(0).toString(); |
|||
String substring1 = time1.substring(11); |
|||
String date1 = list2.get(1).toString(); |
|||
String[] split1 = date1.split("/"); |
|||
String year = split1[2]; |
|||
String month = split1[0]; |
|||
String day = split1[1]; |
|||
String start_time = year + "-" + month + "-" + day + " " + substring1; |
|||
|
|||
//相同订单的最后一条数据的时间
|
|||
String time2 = list3.get(0).toString(); |
|||
String substring2 = time2.substring(11); |
|||
String date2 = list3.get(1).toString(); |
|||
String[] split2 = date2.split("/"); |
|||
String year1 = split2[2]; |
|||
String month1 = split2[0]; |
|||
String day1 = split2[1]; |
|||
String end_time = year1 + "-" + month1 + "-" + day1 + " " + substring2; |
|||
|
|||
String order_no = list2.get(2).toString();//订单号
|
|||
String tube_len = list2.get(3).toString();//管长
|
|||
String tube_width = list2.get(4).toString();//管径
|
|||
|
|||
SimpleDateFormat format = new SimpleDateFormat("yyyy-MM-dd hh:mm:ss"); |
|||
Date d1 = format.parse(start_time); |
|||
Date d2 = format.parse(end_time); |
|||
long l = (d2.getTime() - d1.getTime())/ 1000; //秒
|
|||
String interval_time = Long.toString(l);//间隔时间
|
|||
|
|||
long l1 = l / (i2 - i1 + 1);//平均时间
|
|||
String avg_time = Long.toString(l1); |
|||
|
|||
String qty = Integer.toString(i2 - i1 + 1);//数量
|
|||
|
|||
//按照列获取
|
|||
param.put("order_id", IdUtil.getSnowflake(1, 1).nextId()); |
|||
param.put("order_no", order_no); |
|||
param.put("tube_len", tube_len); |
|||
param.put("tube_width", tube_width); |
|||
param.put("start_time", start_time); |
|||
param.put("end_time", end_time); |
|||
param.put("interval_time", interval_time); |
|||
param.put("avg_time", avg_time); |
|||
param.put("update_by", nickName); |
|||
param.put("update_time", now); |
|||
param.put("qty", qty); |
|||
|
|||
wo.insert(param); |
|||
} |
|||
continue; |
|||
} |
|||
} |
|||
|
|||
private List getLastOrder(int i2, List<List<Object>> read) { |
|||
List list = new ArrayList(); |
|||
for (int i = 0; i < read.size(); i++) { |
|||
if (!read.get(i2).equals(read.get(i))) { |
|||
continue; |
|||
}else { |
|||
list = read.get(i); |
|||
} |
|||
} |
|||
return list; |
|||
} |
|||
|
|||
private List getFirstOrder(int i1, List<List<Object>> read) { |
|||
List list = new ArrayList(); |
|||
for (int i = 0; i < read.size(); i++) { |
|||
if (!read.get(i1).equals(read.get(i))) { |
|||
continue; |
|||
}else { |
|||
list = read.get(i); |
|||
} |
|||
} |
|||
return list; |
|||
} |
|||
} |
|||
|
Binary file not shown.
@ -0,0 +1,43 @@ |
|||
import request from '@/utils/request' |
|||
|
|||
export function add(data) { |
|||
return request({ |
|||
url: 'api/orderdetail', |
|||
method: 'post', |
|||
data |
|||
}) |
|||
} |
|||
|
|||
export function del(ids) { |
|||
return request({ |
|||
url: 'api/orderdetail/', |
|||
method: 'delete', |
|||
data: ids |
|||
}) |
|||
} |
|||
|
|||
export function edit(data) { |
|||
return request({ |
|||
url: 'api/orderdetail', |
|||
method: 'put', |
|||
data |
|||
}) |
|||
} |
|||
|
|||
export function queryOrderdetail(data) { |
|||
return request({ |
|||
url: 'api/orderdetail', |
|||
method: 'get', |
|||
data |
|||
}) |
|||
} |
|||
|
|||
export function excelImport(data) { |
|||
return request({ |
|||
url: 'api/orderdetail/excelImport', |
|||
method: 'post', |
|||
data |
|||
}) |
|||
} |
|||
|
|||
export default { add, edit, del, queryOrderdetail, excelImport } |
@ -0,0 +1,182 @@ |
|||
<template> |
|||
<el-dialog |
|||
title="订单选择" |
|||
append-to-body |
|||
:visible.sync="dialogVisible" |
|||
destroy-on-close |
|||
width="1000px" |
|||
@close="close" |
|||
@open="open" |
|||
> |
|||
<el-form |
|||
:inline="true" |
|||
class="demo-form-inline" |
|||
label-position="right" |
|||
label-width="80px" |
|||
label-suffix=":" |
|||
> |
|||
<el-form-item label="模糊搜索"> |
|||
<el-input |
|||
v-model="query.search" |
|||
clearable |
|||
size="mini" |
|||
placeholder="编码、名称" |
|||
@keyup.enter.native="crud.toQuery" |
|||
/> |
|||
</el-form-item> |
|||
<rrOperation /> |
|||
</el-form> |
|||
|
|||
<!--表格渲染--> |
|||
<el-table |
|||
ref="table" |
|||
v-loading="crud.loading" |
|||
:data="crud.data" |
|||
style="width: 100%;" |
|||
size="mini" |
|||
border |
|||
:header-cell-style="{background:'#f5f7fa',color:'#606266'}" |
|||
@select="handleSelectionChange" |
|||
@select-all="onSelectAll" |
|||
@current-change="clickChange" |
|||
> |
|||
<el-table-column v-if="!isSingle" type="selection" width="55" /> |
|||
<el-table-column v-if="isSingle" label="选择" width="55"> |
|||
<template slot-scope="scope"> |
|||
<el-radio v-model="tableRadio" :label="scope.row"><i /></el-radio> |
|||
</template> |
|||
</el-table-column> |
|||
|
|||
<el-table-column v-if="false" prop="order_id" label="订单标识" /> |
|||
<el-table-column prop="order_no" label="订单号" /> |
|||
<el-table-column prop="tube_len" label="管长 " /> |
|||
<el-table-column prop="tube_width" label="管径" /> |
|||
<el-table-column prop="start_time" label="起始时间" /> |
|||
<el-table-column prop="end_time" label="结束时间" /> |
|||
<el-table-column prop="interval_time" label="间隔时间" /> |
|||
<el-table-column prop="avg_time" label="平均时间" /> |
|||
<el-table-column prop="update_by" label="修改者" /> |
|||
<el-table-column prop="update_time" label="修改时间" /> |
|||
<el-table-column prop="qty" label="数量" /> |
|||
</el-table> |
|||
<!--分页组件--> |
|||
<pagination /> |
|||
<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 crudOrderDetail from '@/api/acs/order/orderDetail' |
|||
import CRUD, { header, presenter } from '@crud/crud' |
|||
import rrOperation from '@crud/RR.operation' |
|||
import pagination from '@crud/Pagination' |
|||
import '@riophae/vue-treeselect/dist/vue-treeselect.css' |
|||
|
|||
export default { |
|||
name: 'MaterDtl', |
|||
components: { rrOperation, pagination }, |
|||
cruds() { |
|||
return CRUD({ title: '物料', url: 'api/orderDetail', crudMethod: { ...crudOrderDetail }, optShow: {}}) |
|||
}, |
|||
mixins: [presenter(), header()], |
|||
dicts: ['product_series'], |
|||
props: { |
|||
dialogShow: { |
|||
type: Boolean, |
|||
default: false |
|||
}, |
|||
isSingle: { |
|||
type: Boolean, |
|||
default: true |
|||
}, |
|||
materOptCode: { |
|||
type: String, |
|||
default: '00' |
|||
} |
|||
}, |
|||
data() { |
|||
return { |
|||
dialogVisible: false, |
|||
classes: [], |
|||
tableRadio: null, |
|||
class_idStr: null, |
|||
checkrow: null, |
|||
data: [] |
|||
} |
|||
}, |
|||
watch: { |
|||
dialogShow: { |
|||
handler(newValue) { |
|||
this.dialogVisible = newValue |
|||
} |
|||
} |
|||
}, |
|||
methods: { |
|||
clickChange(item) { |
|||
this.tableRadio = item |
|||
}, |
|||
seriesFormat(row) { |
|||
return this.dict.label.product_series[row.product_series] |
|||
}, |
|||
open() { |
|||
this.crud.toQuery() |
|||
}, |
|||
handleSelectionChange(val, row) { |
|||
if (val.length > 1) { |
|||
this.$refs.table.clearSelection() |
|||
this.$refs.table.toggleRowSelection(val.pop()) |
|||
} else { |
|||
this.checkrow = row |
|||
} |
|||
}, |
|||
onSelectAll() { |
|||
this.$refs.table.clearSelection() |
|||
}, |
|||
close() { |
|||
this.crud.resetQuery(false) |
|||
this.$emit('update:dialogShow', false) |
|||
}, |
|||
submit() { |
|||
// 处理单选 |
|||
if (this.isSingle && this.tableRadio) { |
|||
this.$emit('update:dialogShow', false) |
|||
this.$emit('tableChanged2', this.tableRadio) |
|||
return |
|||
} |
|||
this.rows = this.$refs.table.selection |
|||
if (this.rows.length <= 0) { |
|||
this.$message('请先勾选物料') |
|||
return |
|||
} |
|||
this.crud.resetQuery(false) |
|||
this.$emit('update:dialogShow', false) |
|||
this.$emit('tableChanged2', this.data) |
|||
}, |
|||
loadClass({ action, parentNode, callback }) { |
|||
// if (action === LOAD_CHILDREN_OPTIONS) { |
|||
// crudClassstandard.getClass({ pid: parentNode.id }).then(res => { |
|||
// parentNode.children = res.content.map(function(obj) { |
|||
// if (obj.hasChildren) { |
|||
// obj.children = null |
|||
// } |
|||
// return obj |
|||
// }) |
|||
// setTimeout(() => { |
|||
// callback() |
|||
// }, 100) |
|||
// }) |
|||
// } |
|||
} |
|||
} |
|||
} |
|||
</script> |
|||
<style rel="stylesheet/scss" lang="scss" scoped> |
|||
::v-deep .el-dialog__body { |
|||
padding-top: 0px; |
|||
} |
|||
</style> |
|||
|
@ -0,0 +1,117 @@ |
|||
<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 crudOrderDetail from '@/api/acs/order/orderDetail' |
|||
|
|||
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 data = new FormData() |
|||
data.append('file', this.file1.raw) |
|||
// excelImport:请求接口 formdata:传递参数 |
|||
crudOrderDetail.excelImport(data).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> |
|||
|
@ -0,0 +1,137 @@ |
|||
<template> |
|||
<div class="app-container"> |
|||
<!--工具栏--> |
|||
<div class="head-container"> |
|||
<!--如果想在工具栏加入更多按钮,可以使用插槽方式, slot = 'left' or 'right'--> |
|||
<crudOperation :permission="permission"> |
|||
<el-button |
|||
slot="right" |
|||
class="filter-item" |
|||
size="mini" |
|||
type="primary" |
|||
icon="el-icon-refresh" |
|||
@click="reload" |
|||
> |
|||
导入 |
|||
</el-button> |
|||
</crudOperation> |
|||
<!--表单组件--> |
|||
<el-dialog :close-on-click-modal="false" :before-close="crud.cancelCU" :visible.sync="crud.status.cu > 0" :title="crud.status.title" width="500px"> |
|||
<el-form ref="form" :model="form" :rules="rules" size="small" label-width="80px"> |
|||
<el-form-item label="订单号" prop="order_no"> |
|||
<el-input v-model="form.order_no" style="width: 370px;" /> |
|||
</el-form-item> |
|||
<el-form-item label="管长 " prop="tube_len"> |
|||
<el-input v-model="form.tube_len" style="width: 370px;" /> |
|||
</el-form-item> |
|||
<el-form-item label="管径"> |
|||
<el-input v-model="form.tube_width" style="width: 370px;" /> |
|||
</el-form-item> |
|||
<el-form-item label="起始时间"> |
|||
<el-input v-model="form.start_time" style="width: 370px;" /> |
|||
</el-form-item> |
|||
<el-form-item label="结束时间"> |
|||
<el-input v-model="form.end_time" style="width: 370px;" /> |
|||
</el-form-item> |
|||
<el-form-item label="间隔时间(s)"> |
|||
<el-input v-model="form.interval_time" style="width: 370px;" /> |
|||
</el-form-item> |
|||
<el-form-item label="平均时间(s)"> |
|||
<el-input v-model="form.avg_time" style="width: 370px;" /> |
|||
</el-form-item> |
|||
<el-form-item label="修改者"> |
|||
<el-input v-model="form.update_by" style="width: 370px;" /> |
|||
</el-form-item> |
|||
<el-form-item label="修改时间"> |
|||
<el-input v-model="form.update_time" style="width: 370px;" /> |
|||
</el-form-item> |
|||
<el-form-item label="数量"> |
|||
<el-input v-model="form.qty" style="width: 370px;" /> |
|||
</el-form-item> |
|||
</el-form> |
|||
<div slot="footer" class="dialog-footer"> |
|||
<el-button type="text" @click="crud.cancelCU">取消</el-button> |
|||
<el-button :loading="crud.cu === 2" type="primary" @click="crud.submitCU">确认</el-button> |
|||
</div> |
|||
</el-dialog> |
|||
<!--表格渲染--> |
|||
<el-table ref="table" v-loading="crud.loading" :data="crud.data" size="small" style="width: 100%;" @selection-change="crud.selectionChangeHandler"> |
|||
<el-table-column type="selection" width="55" /> |
|||
<el-table-column v-if="false" prop="order_id" label="订单标识" /> |
|||
<el-table-column prop="order_no" label="订单号" /> |
|||
<el-table-column prop="tube_len" label="管长 " /> |
|||
<el-table-column prop="tube_width" label="管径" /> |
|||
<el-table-column prop="start_time" label="起始时间" /> |
|||
<el-table-column prop="end_time" label="结束时间" /> |
|||
<el-table-column prop="interval_time" label="间隔时间(s)" /> |
|||
<el-table-column prop="avg_time" label="平均时间(s)" /> |
|||
<el-table-column prop="update_by" label="修改者" /> |
|||
<el-table-column prop="update_time" label="修改时间" /> |
|||
<el-table-column prop="qty" label="数量" /> |
|||
<el-table-column v-permission="['admin','orderDetail:edit','orderDetail:del']" label="操作" width="150px" align="center"> |
|||
<template slot-scope="scope"> |
|||
<udOperation |
|||
:data="scope.row" |
|||
:permission="permission" |
|||
/> |
|||
</template> |
|||
</el-table-column> |
|||
</el-table> |
|||
<!--分页组件--> |
|||
<pagination /> |
|||
</div> |
|||
<UploadDialog :dialog-show.sync="uploadShow" @tableChanged3="tableChanged3" /> |
|||
</div> |
|||
</template> |
|||
|
|||
<script> |
|||
import CRUD, { crud, form, header, presenter } from '@crud/crud' |
|||
import crudOperation from '@crud/CRUD.operation' |
|||
import udOperation from '@crud/UD.operation' |
|||
import pagination from '@crud/Pagination' |
|||
import UploadDialog from '@/views/acs/order/UploadDialog' |
|||
import crudOrderDetail from '@/api/acs/order/orderDetail' |
|||
|
|||
const defaultForm = { order_id: null, order_no: null, tube_len: null, tube_width: null, start_time: null, end_time: null, interval_time: null, avg_time: null, update_by: null, update_time: null, qty: null } |
|||
export default { |
|||
name: 'OrderDetail', |
|||
components: { pagination, crudOperation, udOperation, UploadDialog }, |
|||
mixins: [presenter(), header(), form(defaultForm), crud()], |
|||
cruds() { |
|||
return CRUD({ title: 'orderDetail', url: 'api/orderdetail', idField: 'order_id', sort: 'order_id,desc', crudMethod: { ...crudOrderDetail }}) |
|||
}, |
|||
data() { |
|||
return { |
|||
uploadShow: false, |
|||
permission: { |
|||
add: ['admin', 'orderDetail:add'], |
|||
edit: ['admin', 'orderDetail:edit'], |
|||
del: ['admin', 'orderDetail:del'] |
|||
}, |
|||
rules: { |
|||
order_no: [ |
|||
{ required: true, message: '订单号不能为空', trigger: 'blur' } |
|||
], |
|||
tube_len: [ |
|||
{ required: true, message: '管长 不能为空', trigger: 'blur' } |
|||
], |
|||
tube_width: [ |
|||
{ required: true, message: '管径不能为空', trigger: 'blur' } |
|||
] |
|||
}} |
|||
}, |
|||
methods: { |
|||
// 钩子:在获取表格数据之前执行,false 则代表不获取数据 |
|||
[CRUD.HOOK.beforeRefresh]() { |
|||
return true |
|||
}, |
|||
reload() { |
|||
this.uploadShow = true |
|||
} |
|||
} |
|||
} |
|||
</script> |
|||
|
|||
<style scoped> |
|||
|
|||
</style> |
Loading…
Reference in new issue