产品定义

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")] [Route("mes/md/product")]
public class MdProductDefineController : BaseController public class MdProductDefineController : BaseController
{ {
private readonly IMdProductDefineService mdProduct; private readonly IMdProductDefineService mdProduct;
public MdProductDefineController(IMdProductDefineService mdProduct) { public MdProductDefineController(IMdProductDefineService mdProduct)
this.mdProduct = mdProduct; {
this.mdProduct = mdProduct;
} }
/// <summary> /// <summary>
/// 分页查寻 unti /// 分页查寻 unti
@@ -33,14 +34,23 @@ namespace ZR.Admin.WebApi.Controllers.mes.md
return SUCCESS(unitPageDto); return SUCCESS(unitPageDto);
} }
// /// <summary>
/// 根据单位名称查询单位
/// </summary>
/// <param name="name"></param>
/// <returns></returns>
[HttpGet("getUnit/{name}")] [HttpGet("getUnit/{name}")]
public IActionResult GetUnitlist(string name) public IActionResult GetUnitlist(string name)
{ {
List<MdUnit> units = mdProduct.GetProductDefineList(name); List<MdUnit> units = mdProduct.GetProductDefineList(name);
return SUCCESS(units); return SUCCESS(units);
} }
/// <summary>
/// 获取全部单位
/// </summary>
/// <returns></returns>
[HttpGet("getUnit")] [HttpGet("getUnit")]
public IActionResult GetUnitlist() public IActionResult GetUnitlist()
{ {
@@ -48,17 +58,60 @@ namespace ZR.Admin.WebApi.Controllers.mes.md
return SUCCESS(units); return SUCCESS(units);
} }
//addProductDefine /// <summary>
/// add 产品
/// </summary>
/// <param name="products"></param>
/// <returns></returns>
[HttpPost("addProductDefine")] [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); 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> ///</summary>
[SugarColumn(ColumnName="product_unit" )] [SugarColumn(ColumnName="product_unit" )]
public int? ProductUnit { get; set; } public int? ProductUnit { get; set; }
public string ProductUnitName { get; set; }
[SugarColumn(IsIgnore =true)]
public string ProductUnitName { get; set; }
/// <summary> /// <summary>
/// 工艺路线code /// 工艺路线code
///</summary> ///</summary>
[SugarColumn(ColumnName="processRoute_code" )] [SugarColumn(ColumnName="processRoute_code" )]
public string ProcessrouteCode { get; set; } public string ProcessrouteCode { get; set; }
[SugarColumn(IsIgnore = true)]
public string ProcessrouteCodeName { get; set; }
/// <summary> /// <summary>
/// 工艺路线 /// 工艺路线
///</summary> ///</summary>
[SugarColumn(ColumnName="processRoute_name" )] [SugarColumn(ColumnName="processRoute_name" )]
public string ProcessrouteName { get; set; } public string ProcessrouteName { get; set; }
/// <summary> /// <summary>
/// 预留字段1 /// 预留字段1
///</summary> ///</summary>

View File

@@ -20,9 +20,10 @@ namespace ZR.Service.mes.md
{ {
public int deleteProductDefine(int[] ids) public int deleteProductDefine(int[] ids)
{ {
throw new NotImplementedException(); return Delete(ids);
} }
public MdProductDefineDTO GetList(string name, string code, int pageNum, int pageSize) public MdProductDefineDTO GetList(string name, string code, int pageNum, int pageSize)
{ {
int totalNum = 0; 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) public List<MdUnit> GetProductDefineList(string name)
@@ -68,14 +68,27 @@ namespace ZR.Service.mes.md
return Context.Queryable<MdUnit>().ToList(); 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) public int UpdateProductDefine(MdUnit paramss)
{ {
throw new NotImplementedException(); 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({ return request({
url: '/mes/md/unit/addUnit', url: '/mes/md/product/addProductDefine',
method: 'post', method: 'post',
data: data, data: data,
contextType:"application/json" 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="productName" />
<el-table-column label="单位" align="center" prop="productUnitName" /> <el-table-column label="单位" align="center" prop="productUnitName" />
<el-table-column label="工艺路线" align="center" prop="processrouteName" /> <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> </el-table>
<pagination :v-show="true" :total="total" :page.sync="queryParams.pageNum" :limit.sync="queryParams.pageSize" @pagination="getList" /> <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>
<el-form-item label="单位" prop="measureName"> <el-form-item label="单位" prop="measureName">
<el-autocomplete <el-autocomplete
v-model="dmlform.measureName" v-model="dmlform.productUnitName"
:fetch-suggestions="querymeasureNameAsync" :fetch-suggestions="querymeasureNameAsync"
placeholder="请输入单位名称" placeholder="请输入单位名称"
@select="handlemeasureNamSelect" @select="handlemeasureNamSelect"
@@ -57,7 +63,7 @@
</el-form-item> </el-form-item>
<el-form-item label="工艺路线" prop="processrouteName"> <el-form-item label="工艺路线" prop="processrouteName">
<el-autocomplete <el-autocomplete
v-model="dmlform.processrouteName" v-model="dmlform.processrouteCodeName"
:fetch-suggestions="queryprocessrouteNameAsync" :fetch-suggestions="queryprocessrouteNameAsync"
placeholder="请输入工艺路线" placeholder="请输入工艺路线"
@select="handleProcessrouteNameSelect" @select="handleProcessrouteNameSelect"
@@ -96,12 +102,11 @@
<script> <script>
import { import {
listproductEfinition, listproductEfinition,
listPrimaryUnitmeasure, addProductDefine,
getUnitmeasure, getUnitmeasure,
delUnitmeasure, updateProductDefine,
addUnitmeasure, getProductBypk,
updateUnitmeasure, delproduct
exportUnit,
} from '@/api/basisManagement/productEfinition.js' } from '@/api/basisManagement/productEfinition.js'
import { debounce } from '@/utils' import { debounce } from '@/utils'
@@ -131,17 +136,18 @@ export default {
open: false, open: false,
exportopen: false, exportopen: false,
dmlform: { dmlform: {
measureCode: '', productCode: '',
productName: '', productName: '',
measureName: '', measureId: '', //unit表
processrouteName: '', productUnit: '', //product表
measureId: '', productUnitName: '', //product表
ProcessrouteId:"" processrouteCodeName: '',
ProcessrouteId: '',
}, },
rules: { rules: {
measureCode: [{ required: true, message: '单位编码不能为空', trigger: 'blur' }], productCode: [{ required: true, message: '产品编码不能为空', trigger: 'blur' }],
measureName: [{ required: true, message: '单位名称不能为空', trigger: 'blur' }], productName: [{ required: true, message: '产品名称不能为空', trigger: 'blur' }],
enableFlag: [{ required: true, message: '是否启用不能为空', trigger: 'blur' }], productUnitName: [{ required: true, message: '单位名称不能为空', trigger: 'blur' }],
}, },
ids: [], ids: [],
idsName: [], idsName: [],
@@ -206,21 +212,25 @@ export default {
this.open = true this.open = true
}, },
handleUpdate(row) { handleUpdate(row) {
debugger
this.dmlform.productUnitName = '22222222222222222'
this.reset() this.reset()
this.open = true this.open = true
this.title = '修改' this.title = '修改'
const measureId = row.measureId || this.ids const id = row.id || this.ids
getUnitmeasure(measureId).then((response) => {
getProductBypk(id).then((response) => {
this.dmlform = response.data this.dmlform = response.data
}) })
//ProductUnitName
}, },
handleDelete(row) { handleDelete(row) {
const measureIds = row.measureId || this.ids const id = row.id || this.ids
const idsName = row.measureName || this.idsName const idsName = row.productName || this.idsName
this.$modal this.$modal
.confirm('是否确认删除单位编号为"' + idsName + '"的数据项?') .confirm('是否确认删除单位编号为"' + idsName + '"的数据项?')
.then(function () { .then(function () {
return delUnitmeasure(measureIds) return delproduct(id)
}) })
.then((response) => { .then((response) => {
this.getList() this.getList()
@@ -241,8 +251,8 @@ export default {
// 多选框选中数据 // 多选框选中数据
handleSelectionChange(selection) { handleSelectionChange(selection) {
this.ids = selection.map((item) => item.measureId) this.ids = selection.map((item) => item.id)
this.idsName = selection.map((item) => item.measureName) this.idsName = selection.map((item) => item.productName)
this.single = selection.length !== 1 this.single = selection.length !== 1
this.multiple = !selection.length this.multiple = !selection.length
}, },
@@ -250,20 +260,32 @@ export default {
submitForm() { submitForm() {
this.$refs['dmlform'].validate((valid) => { this.$refs['dmlform'].validate((valid) => {
if (valid) { if (valid) {
if (this.dmlform.measureId != null || this.dmlform.measureId == '') { if (this.dmlform.id != null || this.dmlform.id == '') {
updateUnitmeasure(this.dmlform).then((response) => { updateProductDefine(this.dmlform).then((response) => {
if (response.data == 1) { if (response.data == 1) {
this.$modal.msgSuccess('修改成功') this.$modal.msgSuccess('修改成功')
this.open = false this.open = false
this.getList() this.getList()
this.reset()
} }
}) })
} else { } 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) { if (response.data == 1) {
this.$modal.msgSuccess('新增成功') this.$modal.msgSuccess('新增成功')
this.open = false this.open = false
this.getList() this.getList()
} else {
this.$notify.error('新增失败')
} }
}) })
} }
@@ -278,14 +300,16 @@ export default {
// 表单重置 // 表单重置
reset() { reset() {
this.form = { ;(this.dmlform = {
measureId: null, productCode: '',
measureCode: null, productName: '',
measureName: null, measureId: '', //unit表
enableFlag: 'Y', productUnit: '', //product表
remark: null, productUnitName: '', //product表
} processrouteCodeName: '',
this.resetForm('dmlform') ProcessrouteId: '',
}),
this.resetForm('dmlform')
}, },
//excel导出 //excel导出
@@ -302,11 +326,14 @@ export default {
// 远程搜索单位 // 远程搜索单位
querymeasureNameAsync(queryString, cb) { querymeasureNameAsync(queryString, cb) {
if (queryString == undefined) {
queryString = ''
}
getUnitmeasure(queryString).then((res) => { getUnitmeasure(queryString).then((res) => {
const data = [] const data = []
for (let i of res.data) { for (let i of res.data) {
data.push({ data.push({
unitid: i.measureId, measureId: i.measureId,
value: i.measureName, value: i.measureName,
}) })
} }
@@ -316,15 +343,18 @@ export default {
}, },
//处理单位选择 //处理单位选择
handlemeasureNamSelect(row) { handlemeasureNamSelect(row) {
this.dmlform.measureId = row.unitid this.dmlform.productUnit = row.measureId
}, },
//搜索远程工艺路线 //搜索远程工艺路线
queryprocessrouteNameAsync(queryString, cb) { queryprocessrouteNameAsync(queryString, cb) {
if (queryString == undefined) {
queryString = ''
}
getUnitmeasure(queryString).then((res) => { getUnitmeasure(queryString).then((res) => {
const data = [] const data = []
for (let i of res.data) { for (let i of res.data) {
data.push({ data.push({
unitid: i.measureId, measureId: i.measureId,
value: i.measureName, value: i.measureName,
}) })
} }
@@ -333,10 +363,9 @@ export default {
}) })
}, },
handleProcessrouteNameSelect(row){ handleProcessrouteNameSelect(row) {
this.dmlform.Processroute = row.unitid this.dmlform.Processroute = row.measureId
},
}
}, },
} }
</script> </script>

View File

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