原料管理接口对接

This commit is contained in:
zzyuan 2025-05-28 10:28:52 +08:00
parent e098b0c988
commit 0dad103565
4 changed files with 138 additions and 357 deletions

View File

@ -3,7 +3,7 @@ import request from '@/utils/request'
// 原料类别树
export function systemMaterialTreeApi(data) {
return request({
url: '/smart-canteen/menu_material_category/getTree',
url: '/smart-canteen/cook_material_type/getTree',
method: 'post',
headers: {
"merchant-id":"378915229716713472",
@ -14,7 +14,7 @@ export function systemMaterialTreeApi(data) {
// 新增原料类别
export function addMaterialTypeApi(data) {
return request({
url: '/smart-canteen/menu_material_category/add',
url: '/smart-canteen/cook_material_type/add',
method: 'post',
headers: {
"merchant-id":"378915229716713472",
@ -25,7 +25,7 @@ export function addMaterialTypeApi(data) {
//修改原料类别
export function updateMaterialTypeApi(data) {
return request({
url: '/smart-canteen/menu_material_category/edit',
url: '/smart-canteen/cook_material_type/edit',
method: 'post',
headers: {
"merchant-id":"378915229716713472",
@ -36,19 +36,18 @@ export function updateMaterialTypeApi(data) {
//删除原料类别
export function removeMaterialTypeApi(data) {
return request({
url: '/smart-canteen/menu_material_category/del',
url: '/smart-canteen/cook_material_type/del/'+data.id,
method: 'post',
headers: {
"merchant-id":"378915229716713472",
},
data: data
}
})
}
// 查询原料列表
export function getMaterialListApi(data) {
return request({
url: '/smart-canteen/menu_material/list',
url: '/smart-canteen/cook_material/list',
method: 'get',
headers: {
"merchant-id":"378915229716713472",
@ -60,7 +59,7 @@ export function getMaterialListApi(data) {
// 新增原料
export function addMaterialApi(data) {
return request({
url: '/smart-canteen/menu_material/addMessage',
url: '/smart-canteen/cook_material/add',
method: 'post',
headers: {
"merchant-id":"378915229716713472",
@ -72,7 +71,7 @@ export function addMaterialApi(data) {
// 编辑原料
export function updateMaterialApi(data) {
return request({
url: '/smart-canteen/menu_material/edit',
url: '/smart-canteen/cook_material/edit',
method: 'post',
headers: {
"merchant-id":"378915229716713472",
@ -84,14 +83,18 @@ export function updateMaterialApi(data) {
// 删除原料
export function removeMaterialApi(data) {
return request({
url: '/smart-canteen/menu_material/del',
url: '/smart-canteen/cook_material/del/'+data.materialId,
method: 'post',
headers: {
"merchant-id":"378915229716713472",
},
data: data
}
})
}
// 批量删除原料
export function batchRemoveMaterialApi(data) {
return request({
@ -118,12 +121,12 @@ export function batchUpdateMaterialApi(data) {
//{current: 1, size: -1, ifListUse: 1, areaId: '421488254718578688'}
export function getDrpUnitListApi(data) {
return request({
url: '/smart-canteen/menu_material/getDrpUnit',
method: 'post',
url: '/smart-canteen/supply_product_unit/list',
method: 'get',
headers: {
"merchant-id":"378915229716713472",
},
data: data
params: data
})
}

View File

@ -70,7 +70,6 @@ export function delNutrition(data) {
})
}
// 查询详细数据
export function getNutritionInfo(data) {
return request({
@ -79,23 +78,6 @@ export function getNutritionInfo(data) {
})
}
// 获取所有营养信息
export function nutritionAllListApi(data) {
return request({

View File

@ -13,6 +13,16 @@
<el-tab-pane label="基础信息" name="basic">
<el-form ref="form" :model="form" :rules="rules" label-width="120px">
<el-row>
<el-col :span="12">
<el-form-item label="原料编号" prop="materialCode">
<el-input
v-model="form.materialCode"
placeholder="请输入原料编号"
maxlength="40"
show-word-limit
/>
</el-form-item>
</el-col>
<el-col :span="12">
<el-form-item label="原料名称" prop="materialName">
<el-input
@ -24,8 +34,8 @@
</el-form-item>
</el-col>
<el-col :span="12">
<el-form-item label="原料类别" prop="categoryId">
<el-cascader v-model="form.categoryId"
<el-form-item label="原料类别" prop="materialTypeId">
<el-cascader v-model="form.materialTypeId"
:options="treeTypeOptions" :filterable="true" style="width: 100%;" :show-all-levels="false"
:props="{
emitPath: false,// falseid
@ -47,14 +57,14 @@
</el-cascader>
</el-form-item>
</el-col>
<!-- <el-col :span="12">
<el-col :span="12">
<el-form-item label="计量类型" prop="salesMode" >
<el-select v-model="form.salesMode" placeholder="请选择计量类型" style="width: 100%" @change="getDrpUnitList">
<el-option label="按份" value="1" />
<el-option label="称重" value="2" />
</el-select>
</el-form-item>
</el-col> -->
</el-col>
<el-col :span="12">
<el-form-item label="原料单位" prop="unitId">
<el-select v-model="form.unitId" placeholder="请选择原料单位" style="width: 100%">
@ -89,14 +99,14 @@
</el-form-item>
</el-col> -->
<el-col :span="12">
<el-form-item label="营养信息类别" prop="nutritionType">
<el-form-item label="营养信息类别" prop="nutritionTypeId">
<el-cascader
v-model="form.nutritionType"
v-model="form.nutritionTypeId"
:options="cascaderOptions"
:props="{
emitPath: false,// falseid
checkStrictly: false,//
value:'value',label:'label'
value:'id',label:'label'
}"
placeholder="请选择营养信息类别"
clearable style="width: 100%;"
@ -105,61 +115,16 @@
</el-form-item>
</el-col>
<el-col :span="12">
<el-form-item label="营养信息" prop="categoryId">
<el-select v-model="form.categoryId" placeholder="请选择营养信息" style="width: 100%" clearable @change="chosenNutrition">
<el-form-item label="营养信息" prop="nutritionId">
<el-select v-model="form.nutritionId" placeholder="请选择营养信息" style="width: 100%" clearable @change="chosenNutrition">
<el-option v-for="item in this.nutritionOptions"
:key="item.categoryId"
:label="item.categoryName"
:value="item.categoryId"
:key="item.nutritionId"
:label="item.nutritionName"
:value="item.nutritionId"
></el-option>
</el-select>
</el-form-item>
</el-col>
<!-- <el-col :span="12">
<el-form-item label="保质期">
<el-select v-model="form.shelfLifeType" style="width: 80px; margin-left: 10px">
<el-option label="按年" value="1" />
<el-option label="按月" value="2" />
<el-option label="按日" value="3" />
</el-select>
<el-input v-model="form.shelfLifeDays" placeholder="请输入" style="width: 120px;margin-right: 10px;" @input="(v)=>(form.shelfLifeDays=v.replace(/[^\d]/g,''))"/>
<span v-if="form.shelfLifeType==1"></span>
<span v-if="form.shelfLifeType==2"></span>
<span v-if="form.shelfLifeType==3"></span>
</el-form-item>
</el-col>
<el-col :span="12">
<el-form-item label="采购上限价格" prop="purPriceCeiling">
<el-input
v-model="form.purPriceCeiling"
placeholder="请输入采购上限价格"
@input="handleNumericInput('purPriceCeiling', $event)"
@blur="formatNumericValue('purPriceCeiling')"
>
<template slot="append"></template>
</el-input>
</el-form-item>
</el-col>
<el-col :span="12">
<el-form-item label="原料规格" prop="size">
<el-input v-model="form.size" placeholder="请输入原料规格" maxlength="20">
</el-input>
</el-form-item>
</el-col>
<el-col :span="12">
<el-form-item label="原料税率" prop="taxRate">
<el-select v-model="form.taxRate" placeholder="请选择原料税率" style="width: 100%">
<el-option label="0%" :value="0" />
<el-option label="1%" :value="1" />
<el-option label="2%" :value="2" />
<el-option label="3%" :value="3" />
<el-option label="5%" :value="5" />
<el-option label="6%" :value="6" />
<el-option label="9%" :value="9" />
<el-option label="13%" :value="13"/>
</el-select>
</el-form-item>
</el-col> -->
<el-col :span="24">
<h3>营养信息</h3>
<el-row class="nutrition-info">
@ -202,27 +167,11 @@
<el-table-column label="硒(μg/100g)" prop="selenium" align="center" width="140"></el-table-column>
</el-table>
</el-col>
<!-- <el-col :span="12" v-for="(item, index) in nutritionFields" :key="index">
<el-form-item :label="item.label" :prop="'menuMaterialNutritionDTO.' + item.prop">
<el-input
v-model="form.menuMaterialNutritionDTO[item.prop]"
:placeholder="'请输入' + item.label" disabled
@input="handleNumericInput('menuMaterialNutritionDTO.' + item.prop, $event)"
@blur="formatNumericValue('menuMaterialNutritionDTO.' + item.prop)"
>
<template slot="append">{{item.unit}}</template>
</el-input>
</el-form-item>
</el-col> -->
</el-row>
</el-col>
</el-row>
</el-form>
</el-tab-pane>
<!-- <el-tab-pane label="原料识别注册图" name="image">
这里添加图片上传组件
</el-tab-pane> -->
</el-tabs>
</div>
<div slot="footer" class="dialog-footer">
@ -254,12 +203,9 @@ export default {
treeAreaOptions:[],//
treeTypeOptions:[],//
unitOptions:[],//
nutritionTypeTreeData:[],//
cascaderOptions: [], //
nutritionOptions:[],
bigType:"",
littleType:"",
menuMaterialNutritionDTO:{
processingTime: '0',//min
edible: '0',//(g/100g)
@ -292,29 +238,16 @@ export default {
iodine: '0'
},
form: {
materialCode: '',//
materialName: '',//
areaId: null,//
categoryId: null,//
materialType: 1,
salesMode: '2',//
materialTypeId: null,//
salesMode: '1',//
unitId: '',//
unitPrice: '',//()
barCode: '',//
nutritionType:null,//
categoryId:null,//
shelfLifeType:"1",//
shelfLifeDays:"",//
purPriceCeiling:'',//
size:'',//
taxRate:'',//
// safeConfigDTO:{
// ifNeedDetect: '2',//12
// detectInstitution:'1',//(1,2,3,4)
// detectItem:"1",//
// },
// qualificationCert: '',
// firstProcessList: [''],
// cutProcessList: [''],
nutritionTypeId:null,//
nutritionId:null,//
//
menuMaterialNutritionDTO: {}
},
@ -354,7 +287,7 @@ export default {
rules: {
materialName: [{ required: true, message: '请输入原料名称', trigger: 'blur' }],
areaId: [{ required: true, message: '请选择所属区域', trigger: 'change' }],
categoryId: [{ required: true, message: '请选择原料类别', trigger: 'change' }],
materialTypeId: [{ required: true, message: '请选择原料类别', trigger: 'change' }],
salesMode: [{ required: true, message: '请选择计量类型', trigger: 'change' }],
// unitId: [{ required: true, message: '', trigger: 'change' }]
},
@ -399,29 +332,25 @@ export default {
this.getAreaTreeData();//
this.getTypeTreeData();//
this.getDrpUnitList();//
this.getNutritionType()//
this.getNutritionTypeList()//
},
methods: {
//
getAreaTreeData() {
systemAreaTreeApi({}).then((response) => {
this.treeAreaOptions = response.data;
console.log(this.treeAreaOptions)
});
},
//-
handleAreaChange(val){
console.log(this.form)
this.form.categoryId=null
this.getTypeTreeData()
this.getDrpUnitList()
// this.form.categoryId=null
// this.getTypeTreeData()
// this.getDrpUnitList()
},
//
getTypeTreeData() {
let param = {
categoryType:1,
ifAdd: 1,
areaId:this.form.areaId
// areaId:this.form.areaId
}
systemMaterialTreeApi(param).then((response) => {
this.treeTypeOptions = response.data;
@ -430,90 +359,62 @@ export default {
//
getDrpUnitList() {
let param = {
weighType:this.form.salesMode,
// areaId: this.form.areaId||""
// ifListUse: 1,
// current: 1,
// size: -1
"weighType":this.form.salesMode,
"pageNum": 1,
"pageSize": 100
}
this.form.unitId=null
getDrpUnitListApi(param).then((response) => {
this.unitOptions = response.data;
// if(response.data.records.length>0){
// response.data.records.forEach(item => {
// if(item.weighType==this.form.salesMode){
// this.unitOptions.push(item)
// }
// });
// }
this.unitOptions = response.rows;
});
},
//
getNutritionType() {
//
getNutritionTypeList() {
nutritionTypeListApi().then(response => {
this.nutritionTypeTreeData = response.data;
this.typeTreeData = response.data;
this.cascaderOptions = this.cascaderOptionsMethod();
console.log(this.cascaderOptions)
// this.updateCascaderOptions(); //
}).catch(error => {
console.error("Failed to fetch food types:", error);
});
},
//
cascaderOptionsMethod() {
if (this.nutritionTypeTreeData.length==0) {
if (this.typeTreeData.length==0) {
return [];
}
return this.nutritionTypeTreeData.map(item => ({
value: item.id,
label: item.bigType,
return this.typeTreeData.map(item => ({
id: item.id,
label: item.name,
parentId:0,
level:1,
level:0,
children: item.littleTypeList.map(subItem => ({
value: subItem.id,//value#
label: subItem.bigType,
bigType: item.bigType,
id: subItem.id,//value#
label: subItem.name,
bigType: item.name,
parentId:item.id,
level:2
level:1
}))
}));
},
//
getParentCategoryName(Id) {
const findNode = (nodes) => {
for (let node of nodes) {
if (node.value == Id) {
return node;
}
if (node.children) {
const result = findNode(node.children);
if (result) return result;
}
}
return "";
};
return findNode(this.cascaderOptions);
},
//
handleNutritionChange(value) {
console.log("选中营养信息类别",value)
// this.nutritionAllList()
this.nutritionAllList(value)
},
//
nutritionAllList(){
nutritionAllList(value){
let param = {
categoryId:value
}
nutritionAllListApi(param).then((response) => {
this.$set(this.form,"categoryId",null)
this.$set(this.form,"nutritionId",null)
this.nutritionOptions = response.data;
});
},
//
chosenNutrition(){
console.log("选中营养信息",this.form.categoryId)
getNutritionInfo({categoryId: this.form.categoryId}).then((response) => {
console.log("选中营养信息",this.form.nutritionId)
getNutritionInfo({nutritionId: this.form.nutritionId}).then((response) => {
if(response.data){
this.form.menuMaterialNutritionDTO = response.data
this.formTable = [this.form.menuMaterialNutritionDTO]
@ -523,9 +424,6 @@ export default {
}
});
},
handleNumericInput(field, event) {
// const value = event.target.value;
const value = event;
@ -551,7 +449,6 @@ export default {
this.form[field] = newValue;
}
},
formatNumericValue(field) {
let value;
if (field.includes('.')) {
@ -593,50 +490,27 @@ export default {
setFormData(row){
console.log(row)
// this.getTypeTreeData()
// this.getDrpUnitList()
this.$set(this.form,"areaId",row.areaId)
this.getTypeTreeData()
this.getDrpUnitList()
this.$set(this.form,"id",row.id)
this.$set(this.form,"areaName",row.areaName)
this.$set(this.form,"categoryId",row.categoryId)
this.$set(this.form,"categoryName",row.categoryName)
this.$set(this.form,"materialTypeId",row.materialTypeId)
this.$set(this.form,"materialTypeName",row.materialTypeName)
this.$set(this.form,"materialCode",row.materialCode)
this.$set(this.form,"materialId",row.materialId)
this.$set(this.form,"materialName",row.materialName)
this.$set(this.form,"materialType",row.materialType)
this.$set(this.form,"salesMode",row.salesMode+'')
this.getDrpUnitList()
this.$set(this.form,"unitId",row.unitId)
this.$set(this.form,"unitPrice",Number((row.unitPrice/100).toFixed(2)))
this.$set(this.form,"barCode",row.barCode)
if(row.shelfLifeType){
this.$set(this.form,"shelfLifeType",row.shelfLifeType+"")
}else{
this.$set(this.form,"shelfLifeType","1")
}
this.$set(this.form,"shelfLifeDays",row.shelfLifeDays)
this.$set(this.form,"purPriceCeiling",Number((row.purPriceCeiling/100).toFixed(2)))
this.$set(this.form,"size",row.size)
this.$set(this.form,"taxRate",row.taxRate)
// this.$set(this.form.safeConfigDTO,"ifNeedDetect",row.safeConfigDTO.ifNeedDetect+'')
// this.$set(this.form.safeConfigDTO,"detectInstitution",row.safeConfigDTO.detectInstitution+'')
// this.$set(this.form.safeConfigDTO,"detectItem",row.safeConfigDTO.detectItem+'')
// this.$set(this.form,"qualificationCert","")
// this.$set(this.form,"firstProcessList",row.firstProcessList)
// this.$set(this.form,"cutProcessList",row.cutProcessList)
if(row.nutritionType){
this.$set(this.form,"nutritionType",Number(row.nutritionType))
let obj = this.getParentCategoryName(row.nutritionType)
this.bigType = obj.bigType
this.littleType = obj.label
this.nutritionAllList()
if(row.nutritionTypeId){
this.$set(this.form,"nutritionTypeId",Number(row.nutritionTypeId))
this.nutritionAllList(this.form.nutritionTypeId)
setTimeout(()=>{
this.$set(this.form,"categoryId",row.categoryId)
if(this.form.categoryId){
getNutritionInfo({categoryId: this.form.categoryId}).then((response) => {
this.$set(this.form,"nutritionId",row.nutritionId)
if(this.form.nutritionId){
getNutritionInfo({nutritionId: this.form.nutritionId}).then((response) => {
if(response.data){
this.form.menuMaterialNutritionDTO = response.data
this.formTable = [this.form.menuMaterialNutritionDTO]
@ -649,63 +523,44 @@ export default {
this.form.menuMaterialNutritionDTO = this.menuMaterialNutritionDTO
this.formTable = [this.menuMaterialNutritionDTO]
}
},800)
},600)
}else{
this.$set(this.form,"nutritionType",null)
this.form.menuMaterialNutritionDTO = this.menuMaterialNutritionDTO
this.formTable = [this.menuMaterialNutritionDTO]
}
},
submitForm() {
this.$refs.form.validate(valid => {
if (valid) {
this.form.unitPrice = Number(this.form.unitPrice)*100
this.form.purPriceCeiling = Number(this.form.purPriceCeiling)*100
this.$emit('submit', this.form);
}
});
},
handleClose() {
this.$emit('update:visible', false);
this.$nextTick(() => {
this.reset();
});
},
cancel() {
this.$emit('update:visible', false);
this.$nextTick(() => {
this.reset();
});
},
reset() {
this.form = {
materialName: '',//
areaId: null,//
categoryId: null,//
materialType: 1,
salesMode: '2',//
materialTypeId: null,//
salesMode: '1',//
unitId: '',//
unitPrice: '',//()
barCode: '',//
nutritionType:null,//
categoryId:null,//
shelfLifeType:"1",//
shelfLifeDays:"",//
purPriceCeiling:'',//
size:'',//
taxRate:'',//
// safeConfigDTO:{
// ifNeedDetect: '2',//12
// detectInstitution:'1',//(1,2,3,4)
// detectItem:"1",//
// },
// qualificationCert: '',
// firstProcessList: [''],
// cutProcessList: [''],
nutritionId:null,//
//
menuMaterialNutritionDTO: this.menuMaterialNutritionDTO
};

View File

@ -42,7 +42,7 @@
<el-button
type="text"
size="mini"
icon="el-icon-plus" v-if="data.level<2"
icon="el-icon-plus" v-if="data.level<1"
@click.stop="() => appendTreeNode(data)"
>
</el-button>
@ -60,7 +60,7 @@
size="mini"
icon="el-icon-delete"
style="color: #f56c6c"
v-if="data.parentId != '-1'"
v-if="data.parentId != '0'"
@click.stop="() => removeTreeNode(data)"
>
</el-button>
@ -98,15 +98,6 @@
@keyup.enter.native="handleQuery"
/>
</el-form-item>
<!-- <el-form-item label="条码" prop="barCode">
<el-input
v-model="queryParams.barCode"
placeholder="请输入条码"
clearable maxlength="30"
style="width: 240px"
@keyup.enter.native="handleQuery"
/>
</el-form-item> -->
<el-form-item label="原料编码" prop="materialCode">
<el-input
v-model="queryParams.materialCode"
@ -141,7 +132,7 @@
@click="handleAdd"
>新增</el-button>
</el-col>
<el-col :span="1.5">
<!-- <el-col :span="1.5">
<el-button
type="danger"
plain
@ -149,7 +140,7 @@
:disabled="multiple"
@click="handleBatchDel"
>批量删除</el-button>
</el-col>
</el-col> -->
<!-- <el-col :span="1.5">
<el-button
type="primary"
@ -198,7 +189,7 @@
</el-table-column>
<el-table-column label="原料编码" align="center" key="materialCode" prop="materialCode" :show-overflow-tooltip="true" />
<el-table-column label="原料名称" align="center" key="materialName" prop="materialName" :show-overflow-tooltip="true" />
<el-table-column label="原料类别" align="center" key="categoryName" prop="categoryName" :show-overflow-tooltip="true" />
<el-table-column label="原料类别" align="center" key="materialTypeName" prop="materialTypeName" :show-overflow-tooltip="true" />
<el-table-column label="计量单位" align="center" key="unitName" prop="unitName" :show-overflow-tooltip="true" width="120"/>
<el-table-column label="所属区域" align="center" key="areaName" prop="areaName" :show-overflow-tooltip="true" />
<!-- <el-table-column label="原料规格" align="center" key="size" prop="size" :show-overflow-tooltip="true" width="100"/>
@ -266,44 +257,17 @@
}" clearable>
</el-cascader>
</el-form-item>
<el-row>
<el-col :span="24">
<el-form-item label="原料类别" prop="categoryName">
<el-form-item label="原料类别" prop="materialTypeName">
<el-input
v-model="form.categoryName"
v-model="form.materialTypeName"
placeholder="请输入原料类别"
maxlength="30"
/>
</el-form-item>
</el-col>
</el-row>
<!-- <el-row v-if="isEditType">
<el-col :span="24">
<el-form-item label="原类别父节点" prop="superAreaName">
<el-input
v-model="form.superAreaName"
disabled
placeholder="原类别父节点"
/>
</el-form-item>
</el-col>
</el-row>
<el-row v-if="isEditType">
<el-col :span="24">
<el-form-item label="新类别父节点" prop="newParentId">
<el-cascader v-model="form.newParentId"
:options="treeOptions" :filterable="true" style="width: 100%;" :show-all-levels="false"
:props="{
emitPath: false,// falseid
checkStrictly: true,//
value:'id',label:'categoryName'
}" clearable >
</el-cascader>
</el-form-item>
</el-col>
</el-row> -->
</el-form>
<div slot="footer" class="dialog-footer">
<el-button type="primary" @click="handleSubmit"> </el-button>
@ -311,18 +275,19 @@
</div>
</el-dialog>
<!-- 批量修改原料类别对话框 -->
<el-dialog title="批量修改原料类别" :visible.sync="openEdit"
width="500px" append-to-body :close-on-click-modal="false">
<el-form ref="editForm" :model="editForm" :rules="editRules" label-width="120px">
<el-row>
<el-col :span="24">
<el-form-item label="原料名称" prop="categoryNames">
<el-input v-model="editForm.categoryNames" placeholder="请输入原料名称" :readonly="true" />
<el-form-item label="原料名称" prop="materialTypeName">
<el-input v-model="editForm.materialTypeName" placeholder="请输入原料名称" :readonly="true" />
</el-form-item>
</el-col>
</el-row>
<el-row>
<!-- <el-row>
<el-col :span="24">
<el-form-item label="新类别" prop="categroyId">
<el-cascader v-model="editForm.categroyId"
@ -335,7 +300,7 @@
</el-cascader>
</el-form-item>
</el-col>
</el-row>
</el-row> -->
</el-form>
<div slot="footer" class="dialog-footer">
<el-button type="primary" @click="handleSubmitEdit"> </el-button>
@ -391,9 +356,7 @@ export default {
pageSize: 10,
areaId:null,
materialName:"",
barCode:"",
materialCode:"",
materialType:1, //(12)
categoryIdList:[]
},
//
@ -407,14 +370,13 @@ export default {
title: "",
//
form: {
categoryName: "",
materialTypeName: "",
parentId: "",
categoryType: "",
superAreaName: "",
goodsType: "",
},
//
rules: {
categoryName: [
materialTypeName: [
{
required: true,
message: "类别名称不能为空",
@ -427,8 +389,8 @@ export default {
batchIds:[],
openEdit:false,
editForm:{
categoryNames:"",
categroyId:null
materialTypeName:"",
materialTypeId:null
},
editRules: {
categroyId: [
@ -472,7 +434,6 @@ export default {
this.treeOptions = response.data;
this.addLevel(this.treeOptions)
console.log("this.treeOptions",this.treeOptions)
this.queryParams.materialType=this.treeOptions[0].categoryType;
if(this.treeOptions && this.treeOptions.length > 0){
this.getList();
} else {
@ -502,7 +463,7 @@ export default {
this.form={}
this.resetForm("form");
this.$set(this.form,"parentId",data.id)
this.$set(this.form,"categoryType",data.categoryType)
this.$set(this.form,"goodsType",data.categoryType)
this.open = true;
this.title = "新增";
},
@ -513,37 +474,20 @@ export default {
this.resetForm("form");
this.form = {
...data,
// categoryId:data.id,
// superAreaName: data.parentId === "-1" ? "" : this.getParentCategoryName(data.parentId)
};
console.log(this.form)
console.log(this.treeOptions)
this.$set(this.form,"materialTypeId",data.id)
this.$set(this.form,"materialTypeName",data.categoryName)
this.$set(this.form,"goodsType",data.categoryType)
this.open = true;
this.title = "修改";
},
//
getParentCategoryName(parentId) {
const findNode = (nodes) => {
for (let node of nodes) {
if (node.id === parentId) {
return node.categoryName;
}
if (node.children) {
const result = findNode(node.children);
if (result) return result;
}
}
return "";
};
return findNode(this.treeOptions);
},
/* 树节点删除 */
removeTreeNode(data) {
console.log(data, "删除时的数据源--");
this.$modal
.confirm("是否确认删除数据项?")
.then(function () {
return removeMaterialTypeApi({"ids":[data.id]});
return removeMaterialTypeApi({"id":data.id});
})
.then(() => {
this.$modal.msgSuccess("删除成功");
@ -562,14 +506,13 @@ export default {
handleSubmit() {
this.$refs.form.validate(valid => {
if (valid) {
if (this.form.id != undefined) {
if (this.form.materialTypeId != undefined) {
updateMaterialTypeApi(this.form).then(response => {
this.$modal.msgSuccess("修改成功");
this.open = false;
this.getTreeData();
});
} else {
console.log(this.form)
addMaterialTypeApi(this.form).then(response => {
this.$modal.msgSuccess("新增成功");
this.open = false;
@ -602,10 +545,8 @@ export default {
"pageNum": this.queryParams.pageNum,
"areaId": this.queryParams.areaId,
"materialName": this.queryParams.materialName,
"barCode": this.queryParams.barCode,
"materialCode": this.queryParams.materialCode,
"materialType": this.queryParams.materialType,//(12)
"categoryIdList": this.$refs.typeTree.getCheckedKeys(),
"materialTypeIds": this.$refs.typeTree.getCheckedKeys(),
}
getMaterialListApi(params).then((response) => {
this.tableList = response.rows;
@ -658,7 +599,7 @@ export default {
this.$modal
.confirm("是否确认删除数据项?")
.then(function () {
return removeMaterialApi({"ids":[row.id]});
return removeMaterialApi({"materialId":row.materialId});
})
.then(() => {
this.$modal.msgSuccess("删除成功");