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.

901 lines
99 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" :disabled="editColumn.length === 0"
@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) {
this.dataInfoObj["FTeamID"]=224;
let _data = {"columns":[{"id":227,"key":"FTypeID1","table":"TFS_Material","title":"一级分类","category":"基础信息","width":"220px","align":"center","dataType":"","fieldType":7},{"id":228,"key":"FTypeID2","table":"TFS_Material","title":"二级分类","category":"基础信息","width":"300px","align":"center","dataType":"","fieldType":7},{"id":229,"key":"FK3Code","table":"TFS_Material","title":"K3系统代码","category":"基础信息","width":"170px","align":"center","dataType":"","fieldType":7},{"id":230,"key":"FK3Name","table":"TFS_Material","title":"K3系统名称","category":"基础信息","width":"260px","align":"center","dataType":"","fieldType":7},{"id":231,"key":"FK3ShortCode","table":"TFS_Material","title":"K3系统短代码","category":"基础信息","width":"140px","align":"center","dataType":"","fieldType":7},{"id":232,"key":"FTestCode","table":"TFS_Material","title":"产品试验号","category":"基础信息","width":"140px","align":"center","dataType":"","fieldType":7},{"id":233,"key":"FRelationCode","table":"TFS_Material","title":"关联物料代码","category":"基础信息","width":"140px","align":"center","dataType":"","fieldType":7},{"id":234,"key":"FRelationName","table":"TFS_Material","title":"关联物料名称","category":"基础信息","width":"140px","align":"center","dataType":"","fieldType":7},{"id":235,"key":"FSAPCode","table":"TFS_Material","title":"SAP系统代码","category":"基础信息","width":"140px","align":"center","dataType":"","fieldType":7},{"id":236,"key":"FSAPDescription","table":"TFS_Material","title":"SAP系统描述","category":"基础信息","width":"140px","align":"center","dataType":"","fieldType":7},{"id":205,"key":"FMaterialGroup","table":"TFS_MaterialInfo","title":"物料组","category":"基础信息","width":"160px","align":"center","dataType":"","fieldType":7},{"id":207,"key":"FMaterialType","table":"TFS_MaterialInfo","title":"物料主分类","category":"基础信息","width":"160px","align":"center","dataType":"","fieldType":7},{"id":208,"key":"FCustomerCode","table":"TFS_MaterialInfo","title":"客供料标识","category":"基础信息","width":"160px","align":"center","dataType":"","fieldType":7},{"id":209,"key":"FStoreHouse","table":"TFS_MaterialInfo","title":"总仓地址","category":"基础信息","width":"160px","align":"center","dataType":"","fieldType":7},{"id":210,"key":"FBomEntry","table":"TFS_MaterialInfo","title":"BOM录入情况","category":"基础信息","width":"160px","align":"center","dataType":"","fieldType":7},{"id":211,"key":"FLineHouse","table":"TFS_MaterialInfo","title":"线边仓地址","category":"基础信息","width":"160px","align":"center","dataType":"","fieldType":7},{"id":212,"key":"FProductDesc","table":"TFS_MaterialInfo","title":"产品说明","category":"基础信息","width":"160px","align":"center","dataType":"","fieldType":7},{"id":213,"key":"FWorkCenter","table":"TFS_MaterialInfo","title":"工作中心","category":"基础信息","width":"160px","align":"center","dataType":"","fieldType":7},{"id":214,"key":"FCraftExplain","table":"TFS_MaterialInfo","title":"工艺说明","category":"基础信息","width":"160px","align":"center","dataType":"","fieldType":7},{"id":215,"key":"FIidentifier","table":"TFS_MaterialInfo","title":"标识符","category":"基础信息","width":"160px","align":"center","dataType":"","fieldType":7},{"id":216,"key":"FGuaranteePeriod","table":"TFS_MaterialInfo","title":"保质期","category":"基础信息","width":"160px","align":"center","dataType":"","fieldType":7},{"id":217,"key":"FBStorageConditions","table":"TFS_MaterialInfo","title":"存储条件","category":"基础信息","width":"160px","align":"center","dataType":"","fieldType":7},{"id":218,"key":"FSafetyStock","table":"TFS_MaterialInfo","title":"安全库存","category":"基础信息","width":"160px","align":"center","dataType":"","fieldType":7},{"id":219,"key":"FTriggerRatio","table":"TFS_MaterialInfo","title":"触发比例","category":"基础信息","width":"160px","align":"center","dataType":"","fieldType":7},{"id":220,"key":"FMinAmount",
if (this.dataInfoObj.FViewType == 1) {
this.inputCodeValue = _data.rows[0].HalfCode;
this.inputDescValue = _data.rows[0].HalfDesc;
this.isShow = true;
} else if (this.dataInfoObj.FViewType == 2 || this.dataInfoObj.FViewType == 3 || this.dataInfoObj.FViewType == 4) {
this.isBomShow = true;
}
this.typeList[0] = _data.types.filter(s => s.FDepth == 1) || [];
this.typeList[1] = _data.types.filter(s => s.FDepth != 1) || [];
let dataColumn = _data.columns || [];
let editColumn = dataColumn.filter(it => {
let b = false;
if (this.dataInfoObj.FCanEdit != 2) {
if (it.fieldType == 7) b = this.userPower[1].indexOf(it.id) >= 0;
else b = this.userPower[0].indexOf(it.id) >= 0;
if (b) {
it.customSlot = it.key;
it.cellClass = "edit-item"
}
}
return b;
});
if (editColumn.length > 0) {
if (this.selectDataMap == null) {
let dataTypeIds = editColumn.filter(it => {
it.selectType = it.dataType.startsWith('select:');
if (it.selectType) {
it.selectTypeId = it.dataType.substring(7)
}
return it.selectType;
}).map(it => it.selectTypeId);
if (dataTypeIds.length > 0) {
this.selectDataMap = await getDataCode({
FType: dataTypeIds.join(",")
});
}
}
// //修改项移到前面
// if (this.dataInfoObj.FCanEdit != 2) {
// let tempColumn1 = dataColumn.filter(s => s.customSlot) || [];
// let tempColumn2 = dataColumn.filter(s => s.customSlot == undefined) || [];
// dataColumn = [...tempColumn1, ...tempColumn2];
// }
}
let columnsList = [];
let col7 = dataColumn.filter(s => s.fieldType == 7) || [];
_data.rows.forEach((item, i) => {
columnsList = _data.columns.map(function (items) {
let str = _data.infos[i][items.key + "Type"];
if (typeof (str) != "undefined") {
switch (str) {
case "1":
return items.cellClass = items.cellClass + " one";
case "2":
return items.cellClass = items.cellClass + " twe";
case "3":
return items.cellClass = items.cellClass + " three";
case "4":
return items.cellClass = items.cellClass + " four";
}
}
return items["cellClass"]="";
})
let k3Code = item.FBaseMaterialDesc;
if (k3Code.indexOf("@") > 0) {
item.FK3Code = k3Code.substr(0, k3Code.indexOf("@"));
item.FK3Name = k3Code.substr(k3Code.indexOf("@") + 1);
} else {
item.FK3Code = "";
item.FK3Name = "";
}
if (k3Code.lastIndexOf(".") > 0) {
item.FK3ShortCode = item.FK3Code.substr(item.FK3Code.lastIndexOf(".") + 1);
} else {
item.FK3ShortCode = "";
}
let info = _data.infos.find(s => s.FDataID == item.FMaterialID) || null;
if (info != null) {
col7.forEach((col) => {
item[col.key] = info[col.key] || item[col.key] || "";
});
}
item.FTypeID1 = (item.FTypeID1 == 0 || item.FTypeID1 == -1) ? "" : item.FTypeID1;
item.FTypeID2 = (item.FTypeID2 == 0 || item.FTypeID2 == -1) ? "" : item.FTypeID2;
});
let saveId = this.dataInfoObj.FViewType + "_" + this.dataInfoObj.FID;
localStorage.setItem('EditView' + saveId, JSON.stringify(_data.rows));
this.editColumn = editColumn;
this.dataList = [
{
"FID": 124417,
"FMaterialID": 67945,
"FTeamID": 214,
"FFactoryCode": "C310",
"FFactoryID": 1,
"FViewType": 1,
"FGroupCode": "",
"FLevel": 1,
"FDeleted": 0,
"FAddDate": "2023-04-12T18:22:14.47",
"FEditUser": 2,
"FEditDate": null,
"FOrganizeIndustryField": "M",
"FOrganizeMaterialType": "ZMAT",
"FOrganizeFactory": "C310",
"FOrganizeInventoryLocation": "",
"FOrganizeSalesOrganize": "C310",
"FOrganizeDistributionChannel": "99",
"FBaseMaterialCode": "1681323734",
"FBaseTestCode": "444",
"FBaseBasicMeter": "KG",
"FBaseMaterialDesc": "C444",
"FBaseMaterialGroup": "1301",
"FBaseSpecification": "",
"FBaseMaterialText": "",
"FBaseIdentifier": "",
"FBaseVolumeUnit": "M3",
"FBaseGrossWeight": "",
"FBaseNetWeight": "",
"FBaseWeightUnit": "kg",
"FBaseBusinessVolume": "",
"FBaseFameCode": "",
"FPurchaseGroup": "G02",
"FPurchaseCompany": "",
"FPurchaseCompanyCount": "",
"FPurchaseBaseCompanyCount": "",
"FPurchaseValueCode": "4",
"FPurchaseFactorySpecificStatus": "",
"FPurchaseAutoOrder": "X",
"FPurchaseGoodsSource": "",
"FTypeCategoryType": "023",
"FTypeType": "ZBATCLS",
"FSaleDeliveryFactory": "C310",
"FSaleTaxType": "1",
"FSaleMaterialStatisticsGroup": "1",
"FSaleSalesCompany": "",
"FSaleBaseCompanyCount": "",
"FSaleSalesCompanyCount": "",
"FSaleAccountSettingGroup": "10",
"FSaleGeneralProjectCategoryGroup": "",
"FSaleProjectCategoryGroup": "NORM",
"FSaleAvailabilityCheck": "02",
"FSaleOutfitGroup": "0001",
"FSaleOldMaterialCode": "",
"FStorageConditions": "",
"FStorageBatchManage": "X",
"FStorageMaxStoragePeriod": "",
"FStorageTimeUnit": "",
"FStorageMinSurplusShelfLife": "1",
"FStorageTotalShelfLife": "",
"FStorageSLEDCode": "D",
"FMRP1Type": "ND",
"FMRP1Controller": "101",
"FMRP1BatchSize": "WB",
"FMRP1MinBatchSize": "",
"FMRP1MaxBatchSize": "",
"FMRP1Group": "0099",
"FMRP1RoundValue": "",
"FMRP1ProductType": "10",
"FMRP1CustomerCode": "",
"FMRP1SizeMaterial": "",
"FMRP1SmallMaterialStandard": "",
"FMRP2PurchaseType": "F",
"FMRP2PlanMarginalCode": "000",
"FMRP2SpecialProcurement": "30",
"FMRP2Recoil": "",
"FMRP2SelfProductTime": "",
"FMRP2PlannDeliveryTime": "",
"FMRP2ReceiveProcessTime": "",
"FMRP2SafeStock": "",
"FMRP2DeliveryInventoryPlace": "",
"FMRP2ExternalStoragePlace": "3000",
"FMRP3PolicyGroup": "40",
"FMRP3ConsumePattern": "2",
"FMRP3ForwardConsumePeriod": "365",
"FMRP3ReverseConsumePeriod": "90",
"FMRP3BlendMRP": "3",
"FMRP3AvailabilityCheck": "02",
"FMRP4AloneOrFocus": "2",
"FPlanProductPlanParam": "",
"FPlanUnlimitedOverDelivery": "",
"FPlanUnderDeliveryTolerance": "",
"FPlanOverDeliveryTolerance": "",
"FPlanDeliverCompany": "",
"FPlanDeliverCompanyCount": "",
"FPlanBaseCompanyCount": "",
"FQualityType1": "",
"FQualityType2": "",
"FQualityType3": "",
"FQualityType4": "",
"FQualityType5": "",
"FQualityType6": "",
"FAccountPriceControl": "S",
"FAccountPriceDetermine": "3",
"FAccountPriceUnit": "1",
"FAccountAccessType": "3000",
"FAccountSaleOrderInventory": "3010",
"FAccountStandardPrice": "",
"FAccountProfitCenter": "PC30",
"FAccountCostAccountBatch": "1",
"FExtraQuantity": "",
"FMRP1ReorderLocation": "",
"FMRP1RegularBatchSize": "",
"FMRP1MaxInventorySize": "",
"FMRP1IgnoreLack": "",
"FMRP1laminated": "",
"FMRP1SafeStock": "",
"FMRP1RequireCount": "",
"FMRP4DiscontinuousIidentifier": "",
"FMRP4EffectivePeriod": "",
"FMRP4FollowMaterial": "",
"FTypeID1": 25,
"FTypeID2": 27,
"FK3Code": "",
"FK3Name": "",
"FK3ShortCode": "",
"FTestCode": "",
"FRelationCode": "",
"FRelationName": "",
"FSAPCode": "",
"FSAPDescription": "",
"FMaterialGroup": "",
"FMaterialType": "",
"FCustomerCode": "",
"FStoreHouse": "",
"FBomEntry": "",
"FLineHouse": "",
"FProductDesc": "",
"FWorkCenter": "",
"FCraftExplain": "",
"FIidentifier": "",
"FGuaranteePeriod": "",
"FBStorageConditions": "",
"FSafetyStock": "",
"FTriggerRatio": "",
"FMinAmount": "",
"FMaxAmount": "",
"FYield": "",
"FFixedLoss": "",
"FTheoryYield": "",
"FQualityTest1": "",
"FQualityTest2": ""
},
{
"FID": 124418,
"FMaterialID": 67946,
"FTeamID": 214,
"FFactoryCode": "C320",
"FFactoryID": 3,
"FViewType": 1,
"FGroupCode": "",
"FLevel": 1,
"FDeleted": 0,
"FAddDate": "2023-04-12T18:22:14.593",
"FEditUser": 2,
"FEditDate": null,
"FOrganizeIndustryField": "M",
"FOrganizeMaterialType": "ZMAT",
"FOrganizeFactory": "C320",
"FOrganizeInventoryLocation": "",
"FOrganizeSalesOrganize": "C320",
"FOrganizeDistributionChannel": "99",
"FBaseMaterialCode": "1681323734",
"FBaseTestCode": "444",
"FBaseBasicMeter": "KG",
"FBaseMaterialDesc": "C444",
"FBaseMaterialGroup": "1301",
"FBaseSpecification": "",
"FBaseMaterialText": "",
"FBaseIdentifier": "",
"FBaseVolumeUnit": "M3",
"FBaseGrossWeight": "",
"FBaseNetWeight": "",
"FBaseWeightUnit": "kg",
"FBaseBusinessVolume": "",
"FBaseFameCode": "",
"FPurchaseGroup": "G12",
"FPurchaseCompany": "",
"FPurchaseCompanyCount": "",
"FPurchaseBaseCompanyCount": "",
"FPurchaseValueCode": "4",
"FPurchaseFactorySpecificStatus": "",
"FPurchaseAutoOrder": "X",
"FPurchaseGoodsSource": "",
"FTypeCategoryType": "023",
"FTypeType": "ZBATCLS",
"FSaleDeliveryFactory": "C320",
"FSaleTaxType": "1",
"FSaleMaterialStatisticsGroup": "1",
"FSaleSalesCompany": "",
"FSaleBaseCompanyCount": "",
"FSaleSalesCompanyCount": "",
"FSaleAccountSettingGroup": "10",
"FSaleGeneralProjectCategoryGroup": "",
"FSaleProjectCategoryGroup": "NORM",
"FSaleAvailabilityCheck": "02",
"FSaleOutfitGroup": "0001",
"FSaleOldMaterialCode": "",
"FStorageConditions": "",
"FStorageBatchManage": "X",
"FStorageMaxStoragePeriod": "",
"FStorageTimeUnit": "",
"FStorageMinSurplusShelfLife": "1",
"FStorageTotalShelfLife": "",
"FStorageSLEDCode": "D",
"FMRP1Type": "PD",
"FMRP1Controller": "101",
"FMRP1BatchSize": "MB",
"FMRP1MinBatchSize": "",
"FMRP1MaxBatchSize": "",
"FMRP1Group": "0099",
"FMRP1RoundValue": "",
"FMRP1ProductType": "10",
"FMRP1CustomerCode": "C310",
"FMRP1SizeMaterial": "",
"FMRP1SmallMaterialStandard": "",
"FMRP2PurchaseType": "E",
"FMRP2PlanMarginalCode": "000",
"FMRP2SpecialProcurement": "",
"FMRP2Recoil": "",
"FMRP2SelfProductTime": "",
"FMRP2PlannDeliveryTime": "",
"FMRP2ReceiveProcessTime": "",
"FMRP2SafeStock": "",
"FMRP2DeliveryInventoryPlace": "",
"FMRP2ExternalStoragePlace": "3000",
"FMRP3PolicyGroup": "52",
"FMRP3ConsumePattern": "2",
"FMRP3ForwardConsumePeriod": "365",
"FMRP3ReverseConsumePeriod": "90",
"FMRP3BlendMRP": "3",
"FMRP3AvailabilityCheck": "02",
"FMRP4AloneOrFocus": "2",
"FPlanProductPlanParam": "000001",
"FPlanUnlimitedOverDelivery": "X",
"FPlanUnderDeliveryTolerance": "",
"FPlanOverDeliveryTolerance": "",
"FPlanDeliverCompany": "",
"FPlanDeliverCompanyCount": "",
"FPlanBaseCompanyCount": "",
"FQualityType1": "",
"FQualityType2": "",
"FQualityType3": "",
"FQualityType4": "",
"FQualityType5": "",
"FQualityType6": "",
"FAccountPriceControl": "S",
"FAccountPriceDetermine": "3",
"FAccountPriceUnit": "1",
"FAccountAccessType": "3000",
"FAccountSaleOrderInventory": "3010",
"FAccountStandardPrice": "",
"FAccountProfitCenter": "PC30",
"FAccountCostAccountBatch": "1",
"FExtraQuantity": "",
"FMRP1ReorderLocation": "",
"FMRP1RegularBatchSize": "",
"FMRP1MaxInventorySize": "",
"FMRP1IgnoreLack": "",
"FMRP1laminated": "",
"FMRP1SafeStock": "",
"FMRP1RequireCount": "",
"FMRP4DiscontinuousIidentifier": "",
"FMRP4EffectivePeriod": "",
"FMRP4FollowMaterial": "",
"FTypeID1": 1,
"FTypeID2": 3,
"FK3Code": "",
"FK3Name": "",
"FK3ShortCode": "",
"FTestCode": "",
"FRelationCode": "",
"FRelationName": "",
"FSAPCode": "",
"FSAPDescription": "",
"FMaterialGroup": "",
"FMaterialType": "",
"FCustomerCode": "",
"FStoreHouse": "",
"FBomEntry": "",
"FLineHouse": "",
"FProductDesc": "",
"FWorkCenter": "",
"FCraftExplain": "",
"FIidentifier": "",
"FGuaranteePeriod": "",
"FBStorageConditions": "",
"FSafetyStock": "",
"FTriggerRatio": "",
"FMinAmount": "",
"FMaxAmount": "",
"FYield": "",
"FFixedLoss": "",
"FTheoryYield": "",
"FQualityTest1": "",
"FQualityTest2": ""
}
];
this.dataColumn = [
{
"id": 227,
"key": "FK3Code",
"table": "TFS_Material",
"title": "实验号",
"category": "基础信息",
"width": "220px",
"align": "center",
"dataType": "",
"fieldType": 7,
"customSlot": "FK3Code",
"cellClass": "",
"selectType": false
},
{
"id": 227,
"key": "FTypeID1",
"table": "TFS_Material",
"title": "一级分类",
"category": "基础信息",
"width": "220px",
"align": "center",
"dataType": "",
"fieldType": 7,
"customSlot": "FTypeID1",
"cellClass": "",
"selectType": false
},
{
"id": 228,
"key": "FTypeID2",
"table": "TFS_Material",
"title": "二级分类",
"category": "基础信息",
"width": "300px",
"align": "center",
"dataType": "",
"fieldType": 7,
"customSlot": "FTypeID2",
"cellClass": "",
"selectType": false
},
{
"id": 229,
"key": "FK3Code",
"table": "TFS_Material",
"title": "视图模板",
"category": "基础信息",
"width": "170px",
"align": "center",
"dataType": "",
"fieldType": 7,
"customSlot": "FK3Code",
"cellClass": "",
"selectType": false
},
{
"id": 230,
"key": "FK3Name",
"table": "TFS_Material",
"title": "物料号",
"category": "基础信息",
"width": "260px",
"align": "center",
"dataType": "",
"fieldType": 7,
"customSlot": "FK3Name",
"cellClass": "",
"selectType": false
},
{
"id": 231,
"key": "FK3ShortCode",
"table": "TFS_Material",
"title": "物料描述",
"category": "基础信息",
"width": "140px",
"align": "center",
"dataType": "",
"fieldType": 7,
"cellClass": ""
},
{
"id": 232,
"key": "FTestCode",
"table": "TFS_Material",
"title": "存储条件",
"category": "基础信息",
"width": "140px",
"align": "center",
"dataType": "",
"fieldType": 7,
"cellClass": ""
},
{
"id": 233,
"key": "FRelationCode",
"table": "TFS_Material",
"title": "基础信息",
"category": "基础信息",
"width": "140px",
"align": "center",
"dataType": "",
"fieldType": 7,
"cellClass": ""
},
{
"id": 234,
"key": "FRelationName",
"table": "TFS_Material",
"title": "物料视图",
"category": "基础信息",
"width": "140px",
"align": "center",
"dataType": "",
"fieldType": 7,
"cellClass": ""
},
{
"id": 235,
"key": "FSAPCode",
"table": "TFS_Material",
"title": "操作",
"category": "基础信息",
"width": "140px",
"align": "center",
"dataType": "",
"fieldType": 7,
"cellClass": ""
}
];
this.originalColumns = this.deepCopy(dataColumn);
debugger
this._changeType(_data.rows[0],2);
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>