产品定义

This commit is contained in:
DESKTOP-H2PAFLR\Administrator
2023-08-10 10:27:53 +08:00
parent 915c83bd2e
commit c3010d75e4
6 changed files with 191 additions and 64 deletions

View File

@@ -14,9 +14,10 @@ namespace ZR.Admin.WebApi.Controllers.mes.md
[Route("mes/md/product")]
public class MdProductDefineController : BaseController
{
private readonly IMdProductDefineService mdProduct;
public MdProductDefineController(IMdProductDefineService mdProduct) {
this.mdProduct = mdProduct;
private readonly IMdProductDefineService mdProduct;
public MdProductDefineController(IMdProductDefineService mdProduct)
{
this.mdProduct = mdProduct;
}
/// <summary>
/// 分页查寻 unti
@@ -33,14 +34,23 @@ namespace ZR.Admin.WebApi.Controllers.mes.md
return SUCCESS(unitPageDto);
}
//
/// <summary>
/// 根据单位名称查询单位
/// </summary>
/// <param name="name"></param>
/// <returns></returns>
[HttpGet("getUnit/{name}")]
public IActionResult GetUnitlist(string name)
{
List<MdUnit> units = mdProduct.GetProductDefineList(name);
List<MdUnit> units = mdProduct.GetProductDefineList(name);
return SUCCESS(units);
}
/// <summary>
/// 获取全部单位
/// </summary>
/// <returns></returns>
[HttpGet("getUnit")]
public IActionResult GetUnitlist()
{
@@ -48,17 +58,60 @@ namespace ZR.Admin.WebApi.Controllers.mes.md
return SUCCESS(units);
}
//addProductDefine
/// <summary>
/// add 产品
/// </summary>
/// <param name="products"></param>
/// <returns></returns>
[HttpPost("addProductDefine")]
public int addProductDefine([FromBody] MdProductDefine products)
public IActionResult addProductDefine([FromBody] MdProductDefine products)
{
if (products != null)
{
products.ToCreate(HttpContext);
}
int result = mdProduct.InsertProductDefine(products);
return result;
return SUCCESS(result);
}
/// <summary>
/// 根据主键查询product
/// </summary>
/// <param name="id"></param>
/// <returns></returns>
[HttpGet("getProductBypk/{id}")]
public IActionResult GetProductBypk(int id)
{
MdProductDefine mdProductDefine = mdProduct.GetProductDefinebyPK(id);
return SUCCESS(mdProductDefine);
}
/// <summary>
/// 修改产品
/// </summary>
/// <param name="products"></param>
/// <returns></returns>
[HttpPost("updateProductDefine")]
public IActionResult UpdateProductDefine([FromBody] MdProductDefine products)
{
int result= mdProduct.UpdateProductDefine(products);
return SUCCESS(result);
}
[HttpDelete("delproduct/{id}")]
public IActionResult DelUnit(string id)
{
int[] ids = Tools.SpitIntArrary(id);
int result = mdProduct.deleteProductDefine(ids);
return ToResponse(result);
}
}
}

View File

@@ -30,18 +30,22 @@ namespace ZR.Model.mes.md
///</summary>
[SugarColumn(ColumnName="product_unit" )]
public int? ProductUnit { get; set; }
public string ProductUnitName { get; set; }
[SugarColumn(IsIgnore =true)]
public string ProductUnitName { get; set; }
/// <summary>
/// 工艺路线code
///</summary>
[SugarColumn(ColumnName="processRoute_code" )]
public string ProcessrouteCode { get; set; }
[SugarColumn(IsIgnore = true)]
public string ProcessrouteCodeName { get; set; }
/// <summary>
/// 工艺路线
///</summary>
[SugarColumn(ColumnName="processRoute_name" )]
public string ProcessrouteName { get; set; }
[SugarColumn(ColumnName="processRoute_name" )]
public string ProcessrouteName { get; set; }
/// <summary>
/// 预留字段1
///</summary>

View File

@@ -20,9 +20,10 @@ namespace ZR.Service.mes.md
{
public int deleteProductDefine(int[] ids)
{
throw new NotImplementedException();
return Delete(ids);
}
public MdProductDefineDTO GetList(string name, string code, int pageNum, int pageSize)
{
int totalNum = 0;
@@ -48,14 +49,13 @@ namespace ZR.Service.mes.md
}
public List<MdUnit> GetList(SearchOptionDTO searchOption)
{
throw new NotImplementedException();
}
public MdUnit GetProductDefinebyPK(int measure)
public MdProductDefine GetProductDefinebyPK(int measure)
{
throw new NotImplementedException();
MdProductDefine product=GetId(measure);
MdUnit unit= Context.Queryable<MdUnit>().Where(it=>it.MeasureId == product.ProductUnit).First();
product.ProductUnitName= unit.MeasureName;
return product;
}
public List<MdUnit> GetProductDefineList(string name)
@@ -68,14 +68,27 @@ namespace ZR.Service.mes.md
return Context.Queryable<MdUnit>().ToList();
}
public int InsertProductDefine(MdUnit jo)
public int InsertProductDefine(MdProductDefine jo)
{
throw new NotImplementedException();
return Insert(jo);
}
public int UpdateProductDefine(MdUnit paramss)
{
throw new NotImplementedException();
}
public int UpdateProductDefine(MdProductDefine paramss)
{
return Update(paramss,true);
}
List<MdProductDefine> IMdProductDefineService.GetList(SearchOptionDTO searchOption)
{
throw new NotImplementedException();
}
}
}

View File

@@ -28,11 +28,39 @@ export function listproductEfinition(query) {
})
}
export function addUnitmeasure(data) {
export function addProductDefine(data) {
return request({
url: '/mes/md/unit/addUnit',
url: '/mes/md/product/addProductDefine',
method: 'post',
data: data,
contextType:"application/json"
})
}
export function updateProductDefine(data) {
return request({
url: '/mes/md/product/updateProductDefine',
method: 'post',
data: data,
contextType:"application/json"
})
}
export function getProductBypk(query) {
return request({
url: '/mes/md/product/getProductBypk/'+query,
method: 'get',
})
}
export function delproduct(id) {
return request({
url: '/mes/md/product/delproduct/'+id,
method: 'delete',
})
}

View File

@@ -35,6 +35,12 @@
<el-table-column label="产品名称" align="center" prop="productName" />
<el-table-column label="单位" align="center" prop="productUnitName" />
<el-table-column label="工艺路线" align="center" prop="processrouteName" />
<el-table-column label="操作" align="center" class-name="small-padding fixed-width">
<template slot-scope="scope">
<el-button size="mini" type="text" icon="el-icon-edit" @click="handleUpdate(scope.row)">修改</el-button>
<el-button size="mini" type="text" icon="el-icon-delete" @click="handleDelete(scope.row)" class="delred">删除</el-button>
</template>
</el-table-column>
</el-table>
<pagination :v-show="true" :total="total" :page.sync="queryParams.pageNum" :limit.sync="queryParams.pageSize" @pagination="getList" />
@@ -49,7 +55,7 @@
</el-form-item>
<el-form-item label="单位" prop="measureName">
<el-autocomplete
v-model="dmlform.measureName"
v-model="dmlform.productUnitName"
:fetch-suggestions="querymeasureNameAsync"
placeholder="请输入单位名称"
@select="handlemeasureNamSelect"
@@ -57,7 +63,7 @@
</el-form-item>
<el-form-item label="工艺路线" prop="processrouteName">
<el-autocomplete
v-model="dmlform.processrouteName"
v-model="dmlform.processrouteCodeName"
:fetch-suggestions="queryprocessrouteNameAsync"
placeholder="请输入工艺路线"
@select="handleProcessrouteNameSelect"
@@ -96,12 +102,11 @@
<script>
import {
listproductEfinition,
listPrimaryUnitmeasure,
addProductDefine,
getUnitmeasure,
delUnitmeasure,
addUnitmeasure,
updateUnitmeasure,
exportUnit,
updateProductDefine,
getProductBypk,
delproduct
} from '@/api/basisManagement/productEfinition.js'
import { debounce } from '@/utils'
@@ -131,17 +136,18 @@ export default {
open: false,
exportopen: false,
dmlform: {
measureCode: '',
productCode: '',
productName: '',
measureName: '',
processrouteName: '',
measureId: '',
ProcessrouteId:""
measureId: '', //unit表
productUnit: '', //product表
productUnitName: '', //product表
processrouteCodeName: '',
ProcessrouteId: '',
},
rules: {
measureCode: [{ required: true, message: '单位编码不能为空', trigger: 'blur' }],
measureName: [{ required: true, message: '单位名称不能为空', trigger: 'blur' }],
enableFlag: [{ required: true, message: '是否启用不能为空', trigger: 'blur' }],
productCode: [{ required: true, message: '产品编码不能为空', trigger: 'blur' }],
productName: [{ required: true, message: '产品名称不能为空', trigger: 'blur' }],
productUnitName: [{ required: true, message: '单位名称不能为空', trigger: 'blur' }],
},
ids: [],
idsName: [],
@@ -206,21 +212,25 @@ export default {
this.open = true
},
handleUpdate(row) {
debugger
this.dmlform.productUnitName = '22222222222222222'
this.reset()
this.open = true
this.title = '修改'
const measureId = row.measureId || this.ids
getUnitmeasure(measureId).then((response) => {
const id = row.id || this.ids
getProductBypk(id).then((response) => {
this.dmlform = response.data
})
//ProductUnitName
},
handleDelete(row) {
const measureIds = row.measureId || this.ids
const idsName = row.measureName || this.idsName
const id = row.id || this.ids
const idsName = row.productName || this.idsName
this.$modal
.confirm('是否确认删除单位编号为"' + idsName + '"的数据项?')
.then(function () {
return delUnitmeasure(measureIds)
return delproduct(id)
})
.then((response) => {
this.getList()
@@ -241,8 +251,8 @@ export default {
// 多选框选中数据
handleSelectionChange(selection) {
this.ids = selection.map((item) => item.measureId)
this.idsName = selection.map((item) => item.measureName)
this.ids = selection.map((item) => item.id)
this.idsName = selection.map((item) => item.productName)
this.single = selection.length !== 1
this.multiple = !selection.length
},
@@ -250,20 +260,32 @@ export default {
submitForm() {
this.$refs['dmlform'].validate((valid) => {
if (valid) {
if (this.dmlform.measureId != null || this.dmlform.measureId == '') {
updateUnitmeasure(this.dmlform).then((response) => {
if (this.dmlform.id != null || this.dmlform.id == '') {
updateProductDefine(this.dmlform).then((response) => {
if (response.data == 1) {
this.$modal.msgSuccess('修改成功')
this.open = false
this.getList()
this.reset()
}
})
} else {
addUnitmeasure(this.dmlform).then((response) => {
let data = new Object()
data.productCode = this.dmlform.productCode
data.productName = this.dmlform.productName
data.productUnit = this.dmlform.productUnit
data.productUnitName = this.dmlform.productUnitName
data.productUnitName = this.dmlform.productUnitName
data.processrouteCodeName = this.dmlform.processrouteCodeName
data.ProcessrouteId = this.dmlform.ProcessrouteId
addProductDefine(data).then((response) => {
if (response.data == 1) {
this.$modal.msgSuccess('新增成功')
this.open = false
this.getList()
} else {
this.$notify.error('新增失败')
}
})
}
@@ -278,14 +300,16 @@ export default {
// 表单重置
reset() {
this.form = {
measureId: null,
measureCode: null,
measureName: null,
enableFlag: 'Y',
remark: null,
}
this.resetForm('dmlform')
;(this.dmlform = {
productCode: '',
productName: '',
measureId: '', //unit表
productUnit: '', //product表
productUnitName: '', //product表
processrouteCodeName: '',
ProcessrouteId: '',
}),
this.resetForm('dmlform')
},
//excel导出
@@ -302,11 +326,14 @@ export default {
// 远程搜索单位
querymeasureNameAsync(queryString, cb) {
if (queryString == undefined) {
queryString = ''
}
getUnitmeasure(queryString).then((res) => {
const data = []
for (let i of res.data) {
data.push({
unitid: i.measureId,
measureId: i.measureId,
value: i.measureName,
})
}
@@ -316,15 +343,18 @@ export default {
},
//处理单位选择
handlemeasureNamSelect(row) {
this.dmlform.measureId = row.unitid
this.dmlform.productUnit = row.measureId
},
//搜索远程工艺路线
queryprocessrouteNameAsync(queryString, cb) {
if (queryString == undefined) {
queryString = ''
}
getUnitmeasure(queryString).then((res) => {
const data = []
for (let i of res.data) {
data.push({
unitid: i.measureId,
measureId: i.measureId,
value: i.measureName,
})
}
@@ -333,10 +363,9 @@ export default {
})
},
handleProcessrouteNameSelect(row){
this.dmlform.Processroute = row.unitid
}
handleProcessrouteNameSelect(row) {
this.dmlform.Processroute = row.measureId
},
},
}
</script>

View File

@@ -288,7 +288,7 @@ export default {
},
// 表单重置
reset() {
this.form = {
this.dmlform = {
measureId: null,
measureCode: null,
measureName: null,