You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

429 lines
10 KiB

3 years ago
<template>
<lay-form :model="dataInfo" class="dataInfo">
3 years ago
<lay-form-item label="原配方" label-width="120" prop="formula1Name" required :initValidate="false">
<lay-input v-model="formula1Name" style="width:calc(100% - 76px);margin-right:10px" disabled="true"></lay-input>
3 years ago
<lay-button type="normal" @click="selectMaterial(1)">
3 years ago
</lay-button>
3 years ago
<p class="note">配方号+版本号+描述</p>
</lay-form-item>
3 years ago
<lay-form-item label="变更后的配方" label-width="120" prop="formula2Name" required :initValidate="false">
<lay-input v-model="formula2Name" style="width:calc(100% - 76px);margin-right:10px" disabled="true"></lay-input>
3 years ago
<lay-button type="normal" @click="selectMaterial(2)">
3 years ago
</lay-button>
3 years ago
<p class="note">配方号+版本号+描述</p>
</lay-form-item>
3 years ago
<lay-form-item label="模式" prop="factoryID" required label-width="120" style="margin-bottom:30px;">
<lay-select v-model="factoryID" placeholder="请选择">
<lay-select-option v-for="(fIdv, fIdx) in factoryLists" key="fIdx" :value="fIdv.FID"
:label="fIdv.FName"></lay-select-option>
3 years ago
</lay-select>
</lay-form-item>
3 years ago
<lay-form-item>
<p class="note3">配方变更影响的旧物料</p>
3 years ago
<lay-table :columns="dataColumn" v-model:selected-key="selectedKey" id="FID" :dataSource="dataList">
3 years ago
</lay-table>
</lay-form-item>
<lay-form-item class="remark">
3 years ago
<p>备注配方变更需要重新下载BOM配方配方变更后一下内容需要重新更新到SAP</p>
<p>1如果实验号变更那么实验号对应的受影响的物料会自动更新实验号</p>
<p>2配方变更会重新下载BOM配方</p>
<p>3新BOM配方对应的配方视图重新生成同时用户需要更新到SAP</p>
<p>4新BOM配方中的新的物料需要用户维护视图并更新到SAP</p>
</lay-form-item>
</lay-form>
<div v-if="showButton" style="text-align: center;">
<lay-form-item>
<lay-button type="normal" @click="submitClick(true)"></lay-button>
<lay-button @click="cancelClick"></lay-button>
</lay-form-item>
</div>
3 years ago
<lay-layer :area="['70%', '80%']" v-model="showEditBox" title="选择包材">
<MaterialSelect @_getSeachData="_getSeachData" :dataType1="dataType" @cancelClick="showEditBox = false">
</MaterialSelect>
</lay-layer>
3 years ago
</template>
<style scoped>
.dataInfo {
max-width: 90%;
height: 600px;
margin: 30px auto;
padding-right: 30px;
overflow-y: auto;
}
.search-btn2 {
position: absolute;
right: 0;
top: 0;
}
.note2 {
display: inline-block;
margin-left: 16px;
}
.note3 {
display: inline-flex;
line-height: 38px;
}
.note2,
.note {
color: #999;
font-size: 12px;
}
.note {
margin-top: 4px;
position: absolute;
left: 0;
}
.note .layui-form-radio,
.note .layui-form-radio i {
margin: 0 1px 0 0;
padding: 0;
font-size: 14px;
margin-top: -2px;
line-height: 0;
}
.FSearchName {
color: var(--global-primary-color)
}
3 years ago
.remark {
line-height: 2;
font-size: 18px;
}
3 years ago
</style>
<script>
import {
ref,
watch
} from 'vue';
import {
getDataCode,
getPageList,
getBasicList,
insertDataInfo,
updateDataInfo,
getDataModel
} from "/src/api/api/common";
3 years ago
import MaterialSelect from "./MaterialSelect.vue";
3 years ago
import {
getFactoryList
} from "/src/api/api/factory";
3 years ago
import {
3 years ago
getFormulaList
3 years ago
} from '/src/api/api/formula';
3 years ago
import {
3 years ago
InsertDataModel
3 years ago
} from '/src/api/api/halfmaterialteamwork'
3 years ago
export default {
3 years ago
components: {
MaterialSelect
},
3 years ago
setup() {
const dataInfo = ref({
FMaterialType: "ZMAT",
FWeightUnit: "KG"
});
const formulaList = ref([]);
const seletList = ref([
[],
[]
]);
const typeList = ref([]);
3 years ago
let dataColumn = [{
3 years ago
title: "物料号",
3 years ago
key: "FCode",
width: "160px"
3 years ago
},
{
title: "试验号",
3 years ago
key: "FTestCode",
width: "160px"
3 years ago
},
{
title: "物料描述",
3 years ago
key: "FDesc",
width: "110px",
width: "260px"
3 years ago
},
{
title: "产品分类",
3 years ago
key: "FTypeName",
width: "160px"
3 years ago
}
];
dataColumn.forEach((item) => {
item.align = "center";
});
3 years ago
const dataType = ref("");
3 years ago
const pageInfo = ref({
total: 0,
limit: 5,
current: 1
});
const dataList = ref([]);
const selectedKey = ref("");
watch(selectedKey, function () {
const chose = dataList.value.find(s => s.FID == selectedKey.value) || null;
if (chose != null) {
dataInfo.value.FFormulaName = chose.FName + "+" + chose.FTestCode + "+" + chose.FVersionCode;
dataInfo.value.FFormulaID = chose.FID;
dataInfo.value.FVersionCode = chose.FVersionCode;
dataInfo.value.FFormulaTestCode = chose.FTestCode;
}
});
const showEditBox = ref(false);
const showButton = ref(true);
const saleList = ref([]);
const factoryLists = ref([]);
3 years ago
const factoryValue = ref(null);
const formula1 = ref(-1);
3 years ago
const formula1Name = ref("");
3 years ago
const formula2 = ref(-1);
const formula2Name = ref("");
3 years ago
const factoryID = ref("");
3 years ago
const fVersion1Code=ref("");
const fVersion2Code=ref("");
const FDesc=ref("");
const FNewDesc=ref("");
3 years ago
return {
dataInfo,
formulaList,
seletList,
typeList,
dataColumn,
dataList,
pageInfo,
selectedKey,
showEditBox,
showButton,
saleList,
factoryLists,
3 years ago
factoryValue,
formula1,
3 years ago
formula2,
formula1Name,
formula2Name,
3 years ago
fVersion1Code,
fVersion2Code,
3 years ago
dataType,
3 years ago
factoryID,
FDesc,
FNewDesc
3 years ago
}
},
props: {
dataInfoObj: {
type: Object,
default: () => { },
3 years ago
},
3 years ago
},
mounted() {
//其他地方过来获取数据
if (this.dataInfoObj && this.dataInfoObj.FTeamID) {
this._getTeamData(this.dataInfoObj.FTeamID);
this.showButton = this.dataInfoObj.FCanEdit != 2
}
this._getSelectList();
this._getFactoryList();
3 years ago
this._getFormulaList();
3 years ago
},
methods: {
cancelClick(isFirst) {
this.$emit('cancelClick', isFirst ? isFirst : false);
},
async _getFactoryList() {
this.factoryLists = await getFactoryList() || [];
},
async _getTeamData(dataId) {
let result = await getDataModel({
FID: dataId,
FKey: "FID,FTestCode,FWeightUnit,FSaleCode,FMaterialType,FMaterialGroup,FFormulaTestCode,FFormulaName,FFormulaID,FPackCode,FCreateFactoryID"
}, "Teamwork");
this.dataInfo = result || this.dataInfo;
},
3 years ago
async _getFormulaList() {
this.formulaList = await getFormulaList();
},
async _getMateriaList() {
this._getPageList(true);
3 years ago
},
3 years ago
async _getSelectList() {
let result = await getDataCode({
FType: '1,2'
});
this.seletList[0] = result.FType1 || [];
this.seletList[1] = result.FType2 || [];
this.typeList = await getBasicList(37) || [];
this._getPageList();
},
async _inputSaleCode(val) {
let pData = {
FPageIndex: 1,
FPageSize: 10,
FName: val || ""
};
this.saleList = [];
if (pData.FName != "") {
let result = await getPageList(pData, "Material");
this.saleList = result.Data.List || [];
}
},
//配方检索
_searchPageList(value) {
this._getPageList(true);
},
//配方翻页
changePage(obj) {
this.pageInfo.current = obj.current;
this.pageInfo.limit = obj.limit;
this._getPageList();
},
3 years ago
selectMaterial(str) {
3 years ago
this.dataType = str;
3 years ago
this.showEditBox = true;
},
3 years ago
_getSeachData(data) {
3 years ago
debugger
3 years ago
if (this.dataType == 1) {
this.formula1 = data.FTestCode;
this.formula1Name = data.FName;
3 years ago
this.fVersion1Code=data.FVersionCode;
this.FDesc=data.FDesc;
3 years ago
this._getPageList(true);
3 years ago
} else {
this.formula2 = data.FTestCode;
this.formula2Name = data.FName;
3 years ago
this.fVersion2Code=data.FVersionCode;
this.FNewDesc=data.FDesc;
3 years ago
}
3 years ago
this.showEditBox = false;
3 years ago
},
3 years ago
//配方接口
async _getPageList(isFirst) {
if (isFirst) {
this.pageInfo.current = 1;
this.pageInfo.total = 0;
}
let postData = {
FPageIndex: this.pageInfo.current,
3 years ago
FPageSize: this.pageInfo.limit,
FTestCode: this.formula1
3 years ago
}
let search = this.dataInfo.FSearchName;
if (search && search != "") {
postData.Or_FPlmCode = postData.Or_FTestCode = postData.Or_FName = postData.Or_FVersionCode =
search;
}
3 years ago
if (this.formula1Name != "") {
let result = await getPageList(postData, "Material");
result.Data.List = result.Data.List || [];
result.Data.List.forEach((item) => {
let type = this.typeList.find(s => s.FValue == item.FType);
item.FTypeName = type == null ? item.FType : type.FName;
if (this.dataInfo.FFormulaID == item.FID) this.selectedKey = item.FID
});
this.pageInfo.total = result.Data.Total || 0;
this.dataList = result.Data.List;
}
3 years ago
},
//数据-验证
async submitClick(isCreate) {
3 years ago
let postData = {
"FTestCode": this.formula1,
"FNewTestCode": this.formula2,
"FVersionCode":this.fVersion1Code,
"FNewVersionCode":this.fVersion2Code,
"FCreateFactoryID": this.factoryID,
"FDesc":this.FDesc,
"FNewDesc":this.FNewDesc
};
3 years ago
if (this.formula1Name.trim() == "") {
layer.msg('请选择试验号');
return false;
}
if (this.formula2Name.trim() == "") {
layer.msg('请选择替换试验号');
return false;
}
if (this.factoryID == "") {
layer.msg('请选择模式');
return false;
}
3 years ago
3 years ago
let ids = layer.load(0)
3 years ago
debugger
3 years ago
3 years ago
let result = await InsertDataModel(postData);
3 years ago
if (result.Code == 200) {
3 years ago
layer.msg('创建成功');
this.cancelClick(true);
} else {
3 years ago
//layer.msg('创建失败');
3 years ago
}
layer.close(ids);
// if(result.Code==200){
// setTimeout(() => {
// layer.close(ids);
// }, 3000);
// }
3 years ago
},
//数据-确认
sureTextCode(postData) {
let $this = this;
layer.confirm("选择的配方和订单试验号不一致,请确认使用选择的配方嘛?", {
title: "提示",
btn: [{
text: '暂时保存',
callback: function (id) {
layer.close(id);
postData["FState"] = 0;
$this._postTermData(postData);
}
},
{
text: '确认提交',
callback: function (id) {
layer.close(id);
postData["FState"] = 1;
$this._postTermData(postData);
}
}
]
});
},
//数据-提交
async _postTermData(postData) {
delete postData["FSearchName"];
let result = 0;
let idx = layer.load(2);
if (postData.FID && postData.FID > 0) {
3 years ago
result = await updateDataInfo(postData, "HalfMaterialTeamwork") || 0;
3 years ago
} else {
3 years ago
result = await insertDataInfo(postData, "HalfMaterialTeamwork") || 0;
3 years ago
}
if (result > 0) {
this.cancelClick(true);
}
layer.close(idx);
}
}
}
</script>