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.

364 lines
33 KiB

3 years ago
<template>
<lay-container fluid="true" class="content-box">
<lay-table id="dataTable" v-if="dataColumn.length > 0" height="320px" :columns="dataColumn" :data-source="dataList"
:cellStyle="cellStyle" :cellClassName="cellClassName">
<template v-slot:toolbar v-if="dataInfoObj.FCanEdit != 2">
<!-- <lay-button size="sm" @click="saveBatch" type="primary" :disabled="editColumn.length === 0">保存
</lay-button> -->
<lay-input :class="this.isShow ? 'isShow' : 'isHidden'" v-model="inputCodeValue" :readonly="true">
<template #prepend>半成品编号</template>
</lay-input>
<lay-input :class="this.isShow ? 'isShow' : 'isHidden'" v-model="inputDescValue" :readonly="true">
<template #prepend>描述</template>
</lay-input>
<lay-button size="sm" type="primary"
3 years ago
@click="_clickFreezingColumnSetting()">固定项
</lay-button>
<lay-button size="sm" style="float:right" type="primary">导出</lay-button>
<lay-button size="sm" style="float:right">刷新</lay-button>
</template>
<template v-for="item in editColumn" v-slot:[item.key]="{ data }">
<lay-select v-if="item.key == 'FTypeID1'" size="sm" v-model="data['FTypeID1']"
@change="_changeType(data, 1)" :showEmpty="false">
<lay-select-option v-for="(tIdv, tIdx) in typeList[0]" :key="tIdx" :value="tIdv.FID"
:label="tIdv.FName"></lay-select-option>
</lay-select>
<lay-select v-else-if="item.key == 'FTypeID2'" size="sm" v-model="data['FTypeID2']"
@change="_changeType(data, 2)" :showEmpty="false">
<lay-select-option v-show="data.FTypeID1 == tIdv.FParentID" v-for="(tIdv, tIdx) in typeList[1]"
:key="tIdx" :value="tIdv.FID" :label="tIdv.FName"></lay-select-option>
</lay-select>
<lay-select v-else-if="item.selectType" size="sm" v-model="data[item.key]" :showEmpty="false">
<lay-select-option v-for="(tIdv, tIdx) in selectDataMap['FType' + item.selectTypeId]" :key="tIdx"
:value="tIdv.FValue" :label="tIdv.FName"></lay-select-option>
</lay-select>
<lay-input v-else-if="!item.dataType" size="sm" v-model="data[item.key]"></lay-input>
</template>
</lay-table>
<OperateLog v-if="dataInfoObj.FTeamID" ref="OperateLog" :dataInfoObj="dataInfoObj"></OperateLog>
</lay-container>
</template>
<style scoped>
.content-box {
margin: 30px 10px;
display: block;
position: relative;
clear: both;
float: none;
min-height: 740px;
}
.row-select td {
overflow: inherit;
}
.layui-select {
width: 100%;
}
.edit {
color: green;
}
:deep(.edit-item .layui-input) {
border-color: #5FB878 !important;
}
:deep(.edit-item .layui-input:hover) {
border-color: #009688 !important;
color: #009688;
}
.isShow {
width: 370px;
height: 30px;
border: none;
}
.isHidden {
display: none;
}
.isBomHidden {
display: none;
}
</style>
<script>
import {
ref
} from 'vue';
import {
getListByTeamId,
updateBatchById2
} from "/src/api/api/view";
import {
getBasicRoleList
} from "/src/api/api/user";
import {
getDataCode,
commonSave
} from "/src/api/api/common";
import {
getInfoData,
changeInfoData
} from "/src/api/api/materialType";
import OperateLog from "./OperateLog.vue";
import FormulaView from "./FormulaView.vue";
import FreezingColumnSetting from './FreezingColumnSetting.vue';
export default {
components: {
OperateLog,
FormulaView,
FreezingColumnSetting
},
setup() {
const dataColumn = ref([]);
const dataList = ref([]);
const editColumn = ref([]);
const selectDataMap = ref(null);
const typeList = ref([
[],
[]
]);
const userPower = ref([
[],
[]
]);
const cellStyle = function (row, column, rowIndex, columnIndex) {
let back = column.table == "TFS_ViewMaterial" ? "background:rgb(246, 246, 246)" : ""
return back;
}
const cellClassName = function (row, column, rowIndex, columnIndex) {
return column.cellClass || "";
}
const inputCodeValue = ref("");
const inputDescValue = ref("");
const visible2 = ref(false)
const changeVisible2 = function () {
visible2.value = !visible2.value
};
const showFreezingColumnSettingBox = ref(false);
const freezingColumnSetting = ref([]);
const originalColumns = ref([]);
const tmpDataColumn = ref([]);
return {
dataColumn,
dataList,
editColumn,
selectDataMap,
typeList,
userPower,
cellStyle,
cellClassName,
inputCodeValue,
inputDescValue,
isShow: false,
isBomShow: false,
visible2,
changeVisible2,
showFreezingColumnSettingBox,
freezingColumnSetting,
originalColumns,
tmpDataColumn
};
},
props: {
dataInfoObj: {
type: Object,
default: () => { },
},
viewDataList: {
type: Object,
default: () => [],
}
},
mounted() {
this.getUserPower();
},
methods: {
async getUserPower() {
if (this.dataInfoObj.FCanEdit != 2) {
this.userPower[0] = (await getBasicRoleList({
FRoleType: 40,
FViewType: this.dataInfoObj.FViewType
}) || []).map(it => parseInt(it.F2))
this.userPower[1] = (await getBasicRoleList({
FRoleType: 44,
FViewType: this.dataInfoObj.FViewType
}) || []).map(it => parseInt(it.F2))
}
this.initPage(layer.load(2));
},
async initPage(idx) {
3 years ago
debugger
3 years ago
this.dataInfoObj["FTeamID"]=224;
this.dataColumn = [{"width":"160px","align":"center","title":"试验号","style":"color:#1E9FFF;background:#ccc !important","key":"F1","rowspan":1},{"width":"160px","align":"center","title":"一级分类","style":"color:#1E9FFF;background:#ccc !important","key":"FTypeName1","rowspan":1},{"width":"160px","align":"center","title":"二级分类","style":"color:#1E9FFF;background:#ccc !important","key":"FTypeName2","rowspan":1},{"width":"160px","align":"center","title":"K3系统代码","style":"color:#1E9FFF;background:#ccc !important","key":"FK3Code","rowspan":1},{"width":"160px","align":"center","title":"K3系统名称","style":"color:#1E9FFF;background:#ccc !important","key":"FK3Name","rowspan":1},{"width":"160px","align":"center","title":"K3系统短代码","style":"color:#1E9FFF;background:#ccc !important","key":"FK3ShortCode","rowspan":1},{"width":"160px","align":"center","title":"产品试验号","style":"color:#1E9FFF;background:#ccc !important","key":"FTestCode","rowspan":1},{"width":"160px","align":"center","title":"SAP系统代码","style":"color:#1E9FFF;background:#ccc !important","key":"FCode","rowspan":1},{"width":"160px","align":"center","title":"SAP系统描述","style":"color:#1E9FFF;background:#ccc !important","key":"FName","rowspan":1},{"width":"160px","align":"center","title":"物料组","style":"color:#1E9FFF;background:#ccc !important","key":"FMaterialGroup","rowspan":1},{"width":"160px","align":"center","title":"物料主分类","style":"color:#1E9FFF;background:#ccc !important","key":"FMaterialType","rowspan":1},{"width":"160px","align":"center","title":"客供料标识","style":"color:#1E9FFF;background:#ccc !important","key":"FCustomerCode","rowspan":1},{"width":"160px","align":"center","title":"总仓地址","style":"color:#1E9FFF;background:#ccc !important","key":"FStoreHouse","rowspan":1},{"width":"160px","align":"center","title":"BOM录入情况","style":"color:#1E9FFF;background:#ccc !important","key":"FBomEntry","rowspan":1},{"width":"160px","align":"center","title":"线边仓地址","style":"color:#1E9FFF;background:#ccc !important","key":"FLineHouse","rowspan":1},{"width":"160px","align":"center","title":"产品说明","style":"color:#1E9FFF;background:#ccc !important","key":"FProductDesc","rowspan":1},{"width":"160px","align":"center","title":"工作中心","style":"color:#1E9FFF;background:#ccc !important","key":"FWorkCenter","rowspan":1},{"width":"160px","align":"center","title":"工艺说明","style":"color:#1E9FFF;background:#ccc !important","key":"FCraftExplain","rowspan":1},{"width":"160px","align":"center","title":"标识符","style":"color:#1E9FFF;background:#ccc !important","key":"FIidentifier","rowspan":1},{"width":"160px","align":"center","title":"保质期","style":"color:#1E9FFF;background:#ccc !important","key":"FGuaranteePeriod","rowspan":1},{"width":"160px","align":"center","title":"存储条件","style":"color:#1E9FFF;background:#ccc !important","key":"FStorageConditions","rowspan":1},{"width":"160px","align":"center","title":"安全库存","style":"color:#1E9FFF;background:#ccc !important","key":"FSafetyStock","rowspan":1},{"width":"160px","align":"center","title":"触发比例","style":"color:#1E9FFF;background:#ccc !important","key":"FTriggerRatio","rowspan":1},{"width":"160px","align":"center","title":"最小量","style":"color:#1E9FFF;background:#ccc !important","key":"FMinAmount","rowspan":1},{"width":"160px","align":"center","title":"最大量","style":"color:#1E9FFF;background:#ccc !important","key":"FMaxAmount","rowspan":1},{"width":"160px","align":"center","title":"得率","style":"color:#1E9FFF;background:#ccc !important","key":"FYield","rowspan":1},{"width":"160px","align":"center","title":"固损","style":"color:#1E9FFF;background:#ccc !important","key":"FFixedLoss","rowspan":1},{"width":"160px","align":"center","title":"理论得率","style":"color:#1E9FFF;background:#ccc !important","key":"FTheoryYield","rowspan":1},{"width":"160px","align":"center","title":"品质检验1","style":"color:#1E9FFF;background:#ccc !important","key":"FQualityTest1","rowspan":
this.dataList=[{"F1":"试验号1","FID":490,"FType":"K1.24.(受托C310)其他自制物料","FDataID":67965,"FMaterialGroup":"","FMaterialType":"","FCustomerCode":"","FStoreHouse":"","FBomEntry":"","FLineHouse":"","FProductDesc":"","FWorkCenter":"","FIidentifier":"","FGuaranteePeriod":"","FStorageConditions":"","FSafetyStock":"","FTriggerRatio":"","FMinAmount":"","FMaxAmount":"","FYield":"","FFixedLoss":"","FTheoryYield":"","FQualityTest1":"","FQualityTest2":"","FAddUser":2,"FAddDate":"2023-04-14T03:11:06.827","FEditUser":0,"FEditDate":"2023-04-14T03:11:06.827","FTypeID1":"","FTypeID2":"","FK3Code":"","FK3Name":"","FK3ShortCode":"","FTestCode":"","FRelationCode":"","FRelationName":"","FOrganizeIndustryField":"M","FOrganizeMaterialType":"ZMAT","FOrganizeFactory":"","FOrganizeInventoryLocation":"","FOrganizeSalesOrganize":"","FOrganizeDistributionChannel":"90","FBaseMaterialCode":"","FBaseTestCode":"","FBaseBasicMeter":"g","FBaseSpecification":"","FBaseMaterialText":"","FBaseIdentifier":"","FBaseVolumeUnit":"M3","FBaseGrossWeight":"","FBaseNetWeight":"","FBaseFameCode":"","FBaseBusinessVolume":"","FPurchaseGroup":"G12","FPurchaseCompany":"","FPurchaseCompanyCount":"","FPurchaseBaseCompanyCount":"","FPurchaseValueCode":"4","FPurchaseFactorySpecificStatus":"","FPurchaseAutoOrder":"X","FPurchaseGoodsSource":"","FTypeCategoryType":"023","FTypeType":"ZBATCLS","FSaleDeliveryFactory":"","FSaleTaxType":"1","FSaleMaterialStatisticsGroup":"1","FSaleSalesCompany":"","FSaleBaseCompanyCount":"","FSaleSalesCompanyCount":"","FSaleAccountSettingGroup":"10","FSaleGeneralProjectCategoryGroup":"","FSaleProjectCategoryGroup":"NORM","FSaleAvailabilityCheck":"02","FSaleOutfitGroup":"0001","FSaleOldMaterialCode":"","FStorageBatchManage":"X","FStorageMaxStoragePeriod":"","FStorageTimeUnit":"","FStorageMinSurplusShelfLife":"1","FStorageTotalShelfLife":"","FStorageSLEDCode":"D","FMRP1Type":"PD","FMRP1ReorderLocation":"","FMRP1RegularBatchSize":"","FMRP1MaxInventorySize":"","FMRP1Controller":"","FMRP1BatchSize":"MB","FMRP1MinBatchSize":"","FMRP1MaxBatchSize":"","FMRP1Group":"0099","FMRP1RoundValue":"","FMRP1ProductType":"","FMRP1CustomerCode":"","FMRP1SizeMaterial":"","FMRP1IgnoreLack":"","FMRP1laminated":"","FMRP1SafeStock":"","FMRP1RequireCount":"","FMRP1SmallMaterialStandard":"","FMRP2PurchaseType":"F","FMRP2PlanMarginalCode":"000","FMRP2SpecialProcurement":"","FMRP2Recoil":"","FMRP2SelfProductTime":"","FMRP2PlannDeliveryTime":"","FMRP2ReceiveProcessTime":"","FMRP2SafeStock":"","FMRP2DeliveryInventoryPlace":"","FMRP2ExternalStoragePlace":"3000","FMRP3PolicyGroup":"40","FMRP3ConsumePattern":"2","FMRP3ForwardConsumePeriod":"365","FMRP3ReverseConsumePeriod":"90","FMRP3BlendMRP":"3","FMRP3AvailabilityCheck":"02","FMRP4AloneOrFocus":"2","FMRP4DiscontinuousIidentifier":"","FMRP4EffectivePeriod":"","FMRP4FollowMaterial":"","FPlanProductPlanParam":"","FPlanUnlimitedOverDelivery":"","FPlanUnderDeliveryTolerance":"","FPlanOverDeliveryTolerance":"","FPlanDeliverCompany":"","FPlanDeliverCompanyCount":"","FPlanBaseCompanyCount":"","FQualityType1":"","FQualityType2":"","FQualityType3":"","FQualityType4":"","FQualityType5":"","FQualityType6":"","FAccountPriceControl":"S","FAccountPriceDetermine":"3","FAccountPriceUnit":"1000","FAccountAccessType":"2000","FAccountSaleOrderInventory":"2010","FAccountStandardPrice":"","FAccountProfitCenter":"PC30","FAccountCostAccountBatch":"1000","FMStorageConditions":"","FTypeID1Type":"0","FTypeID2Type":"0","FK3CodeType":"0","FK3NameType":"0","FK3ShortCodeType":"0","FTestCodeType":"0","FRelationCodeType":"0","FRelationNameType":"0","FSAPCodeType":"0","FSAPDescriptionType":"0","FMaterialGroupType":"0","FMaterialTypeType":"0","FCustomerCodeType":"0","FStoreHouseType":"0","FBomEntryType":"0","FLineHouseType":"0","FProductDescType":"0","FWorkCenterType":"0","FCraftExplainType":"0","FIidentifierType":"0","FGuaranteePeriodType":"0","FStorageConditionsType":"0","FSafetyStockType":"0","FTriggerRatioType":"0","FMinAmountType":"0","FMaxAmountType":"0","FYieldType":"0","FFixedLossType":"0","FTheoryYieldType":"0","FQualityTest1Type":"0"
3 years ago
setTimeout(function () {
layer.close(idx);
}, 500);
},
cancelClick(isRefresh) {
isRefresh = isRefresh == undefined ? false : isRefresh;
this.$emit('cancelClick', isRefresh);
},
async _changeType(data, type) {
if (type == 1) {
data.FTypeID2 = -1;
} else {
if (data.FTypeID2) {
let result = await getInfoData({
"FDataID": data.FTypeID2,
"FType": 1
}) || null;
if (result != null && result.FID) {
let col7 = this.dataColumn.filter(s => s.fieldType == 7) || [];
col7.forEach((item) => {
if (item.table == "TFS_MaterialInfo") {
data[item.key] = result[item.key] || data[item.key] || "";
}
});
this.dataColumn.map(function (item) {
let str = result[item.key + "Type"];
if (typeof (str) != "undefined") {
switch (str) {
case "1":
if (typeof (item.cellClass) == "undefined") {
return item["cellClass"] = "one";
}
return item.cellClass = item.cellClass.split(" ")[0] + " one";
case "2":
if (typeof (item.cellClass) == "undefined") {
return item["cellClass"] = "twe";
}
return item.cellClass = item.cellClass.split(" ")[0] + " twe";
case "3":
if (typeof (item.cellClass) == "undefined") {
return item["cellClass"] = "three";
}
return item.cellClass = item.cellClass.split(" ")[0] + " three";
case "4":
if (typeof (item.cellClass) == "undefined") {
return item["cellClass"] = "four";
}
return item.cellClass = item.cellClass.split(" ")[0] + " four";
}
}
return item["cellClass"]="";
})
}
}
}
},
async saveBatch() {
let idx = layer.load(2);
let updateObj = {
LogList: [],
FTeamID: this.dataInfoObj['FTeamID'],
FViewType: this.dataInfoObj.FViewType
};
let saveId = this.dataInfoObj.FViewType + "_" + this.dataInfoObj.FID;
let cacheDataList = JSON.parse(localStorage.getItem('EditView' + saveId));
this.dataList.forEach((row, index) => {
let cache = cacheDataList[index];
let dataObj = {};
for (let col of this.editColumn) {
let valTemp = row[col.key];
if (valTemp != cache[col.key]) {
if (!dataObj[col.table]) {
dataObj[col.table] = {};
dataObj[col.table].FMaterialID = row["FMaterialID"];
}
dataObj[col.table][col.key] = valTemp;
if (col.key == "FTypeID1" || col.key == "FTypeID2") {
let temps = this.typeList[col.key == "FTypeID1" ? 0 : 1] || [];
let temp = temps.find(s => s.FID == valTemp) || null;
valTemp = temp == null ? "" : temp.FName;
}
updateObj.LogList.push(col.title + "" + (valTemp == "" ? "删除" : valTemp));
}
}
for (let key in dataObj) {
if (!updateObj[key]) updateObj[key] = [];
updateObj[key].push(dataObj[key]);
}
});
let updateLog = updateObj.LogList.join("、");
if (updateLog != "") {
delete updateObj.LogList
// 发送保存请求
let _result = await updateBatchById2(updateObj);
if (_result.Code === 200) {
await commonSave({
teamId: updateObj.FTeamID,
type: this.dataInfoObj['FType'],
desc: updateLog
}, "OperateLog");
let $this = this;
//$this.initPage();
localStorage.setItem('EditView' + saveId, JSON.stringify(this.dataList));
setTimeout(function () {
layer.close(idx);
layer.msg('保存成功');
$this.$emit('cancelClick', true, true);
$this.$refs.OperateLog._getPageList();
}, 500);
}
} else {
layer.close(idx);
layer.msg('您没有做任何更改')
}
},
_clickFreezingColumnSetting() {
this.dataColumn = ref([]);
this.showFreezingColumnSettingBox = true;
},
setFreezingColumns() {
this.tmpDataColumn = this.deepCopy(this.originalColumns);
let freezingColumns = [];
if (this.freezingColumnSetting && this.freezingColumnSetting.length > 0) {
this.freezingColumnSetting.forEach(column => {
let colIndex = this.tmpDataColumn.findIndex(d => d.key === column);
if (colIndex >= 0) {
let fc = this.tmpDataColumn.splice(colIndex, 1)[0];
if (fc) {
fc.fixed = "left";
freezingColumns.push(fc);
}
}
})
this.dataColumn = freezingColumns.concat(this.tmpDataColumn);
} else {
this.dataColumn = this.tmpDataColumn;
}
},
setFreezingColumnsSetting(fcs) {
this.freezingColumnSetting = fcs;
if (fcs && fcs.length > 0) {
} else {
this.dataColumn = this.originalColumns;
}
this.showFreezingColumnSettingBox = false;
},
closeFreezingSetting() {
this.setFreezingColumns();
},
deepCopy(arr) {
return JSON.parse(JSON.stringify(arr))
}
}
}
</script>