leo 3 years ago
commit b86dcbbc06

@ -26,4 +26,11 @@ export async function updateBatchById2(params) {
});
return result;
}
//获取物理视图
export async function GetMaterialInfoListByTeamId(params) {
let result = {};
await http.post('/api/View/GetMaterialInfoListByTeamId', params).then((data) => {
result = data;
});
return result;
}

@ -75,6 +75,12 @@
<lay-layer :area="modelArea[9]" v-model="showEditBox[9]" :title="objInfoObj.FName">
<EditType v-if="showEditBox[9]" :dataInfoObj="objInfoObj" @cancelClick="cancelClick"></EditType>
</lay-layer>
<lay-layer :area="modelArea[10]" v-model="showEditBox[10]" :title="objInfoObj.FName">
<EditFSuccedaneum v-if="showEditBox[10]" @getData="getData" :dataInfoObj="objInfoObj" @cancelClick="cancelClick"></EditFSuccedaneum>
</lay-layer>
<lay-layer :area="modelArea[11]" v-model="showEditBox[11]" :title="objInfoObj.FName">
<EditMaterial v-if="showEditBox[11]" @getData="getData" @showEditMaterial="showEditMaterial" :MaterialModel="MaterialModel" :dataInfoObj="objInfoObj" @cancelClick="cancelClick"></EditMaterial>
</lay-layer>
</lay-container>
</template>
<script>
@ -95,6 +101,8 @@
import EditGroup from "./components/EditGroup.vue";
import SureTeam from "./components/SureTeam.vue";
import SupplyPackage from "./components/SupplyPackage.vue";
import EditFSuccedaneum from "./components/EditFSuccedaneum.vue";
import EditMaterial from "./components/EditMaterial.vue";
import '@layui/layui-vue/es/checkbox/index.css';
import '@layui/layui-vue/es/radio/index.css';
@ -108,7 +116,9 @@
SureView,
EditGroup,
SureTeam,
SupplyPackage
SupplyPackage,
EditFSuccedaneum,
EditMaterial
},
setup() {
let dataColumn = [{
@ -191,9 +201,9 @@
const typeList = ref([]);
const searchObj = ref({});
const postData = ref({});
const MaterialModel= ref({});
const showEditBox = ref([false, false, false, false, false, false, false, false, false, false, false, false]);
const modelArea = ref(["70%", "70%", "70%", "86%", "70%", "70%", "70%", "70%", "700px", "70%", "70%"]);
const modelArea = ref(["70%", "70%", "70%", "86%", "70%", "70%", "70%", "70%", "700px", "70%", "70%","70%"]);
const objInfoObj = ref({});
const editType = ref(1);
const stateList = ref([{
@ -204,7 +214,7 @@
name: "已完成"
}]);
const hasLoaded = ref(false);
const dataItem=ref([]);
return {
selectedKeys,
checkbox,
@ -220,7 +230,9 @@
objInfoObj,
editType,
stateList,
hasLoaded
hasLoaded,
MaterialModel,
dataItem
};
},
props: {
@ -228,6 +240,7 @@
type: Object,
default: () => {},
},
pageTypeObj: {
type: Number,
default: () => 1,
@ -298,7 +311,22 @@
dateFormat(dataStr) {
return dataStr.replace('T', ' ').split('.')[0];
},
getData(data){
this.MaterialModel = data;
debugger
for (let i = 0; i < this.showEditBox.length; i++) {
this.showEditBox[i] = false;
}
this.showEditBox[11] = true;
this.editType = 1;
},
showEditMaterial(){
this._clickSetInfo(this.dataItem,1);
},
_clickSetInfo(data, type) {
debugger
for (let i = 0; i < this.showEditBox.length; i++) {
this.showEditBox[i] = false;
}
@ -320,7 +348,10 @@
data.FBoxType = 8; //
} else if (data.FType == 15) {
data.FBoxType = 9; //
} else {
}else if(data.FType==16){
this.dataItem=data;
data.FBoxType = 10; //
}else {
return layer.msg("未知事项类型");
}
this.objInfoObj = data;

@ -0,0 +1,353 @@
<template>
<lay-container fluid="true" class="content-box">
<lay-table class="row-select" 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" type="primary" :class="this.isBomShow ? 'isBomShow' : 'isBomHidden'" @click="changeVisible2">BOM</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>
</template>
<template v-if="dataList == undefined || !dataList.FID" v-slot:operator="{ data }">
<lay-button size="xs" type="primary" @click="openConfirm2(data)"></lay-button>
</template>
</lay-table>
<OperateLog v-if="dataInfoObj.FTeamID" ref="OperateLog" :dataInfoObj="dataInfoObj"></OperateLog>
</lay-container>
<template>
<lay-button type="primary" @click="openConfirm2"></lay-button>
</template>
</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;
}
.isBomShow {}
.isBomHidden {
display: none;
}
</style>
<script>
import {
ref
} from 'vue';
import {
GetMaterialInfoListByTeamId
} 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 { EditTypeList } from "/src/api/api/teamwork";
import OperateLog from "./OperateLog.vue";
export default {
components: {
OperateLog
},
setup() {
let dataColumn = [{
title: "ID",
key: "FID",
width: "160px",
align: 'center',
hide: false
},
{
title: "试验号",
key: "FTestCode",
width: "160px",
align: 'center',
hide: false
},
{
title: "物料编号",
key: "FCode",
width: "400px",
align: 'center'
},
{
title: "物料描述",
key: "FDesc",
width: "360px",
align: 'center'
},
{
title: "替代料编号",
key: "FSuccedaneumID",
width: "178px",
align: 'center'
},
{
title: "替代品描述",
key: "FSuccedaneumInfo",
width: "360px",
align: 'center'
},
{
title: "负责人",
key: "FUserName",
width: "160px",
align: 'center'
},
{
title: "操作",
key: "operator",
width: "100px",
fixed: "right",
customSlot: 'operator',
align: 'center'
}
];
//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) !important;" : ""
return back;
}
const cellClassName = function (row, column, rowIndex, columnIndex) {
return column.cellClass || "";
}
const inputCodeValue = ref("");
const inputDescValue = ref("");
const visible2 = ref(false);
const openConfirm2 = function(data) {
layer.confirm("是否选择替代料", {btn: [{text:'选择'},{text:'不选择'}]})
}
return {
dataColumn,
dataList,
editColumn,
selectDataMap,
typeList,
userPower,
cellStyle,
cellClassName,
inputCodeValue,
inputDescValue,
isShow: false,
isBomShow: false,
visible2,
openConfirm2
};
},
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) {
let _data = await GetMaterialInfoListByTeamId({
tempId: this.dataInfoObj.FTeamID
});
this.dataList = _data.Data;
setTimeout(function () {
layer.close(idx);
}, 500);
},
changeVisible2(data) {
this.$emit('cancelClick', true, false);
this.$emit("getData", data);
},
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] || "";
}
});
}
}
}
},
async saveBatch() {
var arr = new Array();
for (let i = 0; i < this.dataList.length; i++) {
if (this.dataList[i].FTypeID1 == null || this.dataList[i].FTypeID1 == "") {
layer.msg("请选择一级分类", { icon: 2, time: 1000 });
return;
}
if (this.dataList[i].FTypeID2 == null || this.dataList[i].FTypeID2 == "") {
layer.msg("请选择二级分类", { icon: 2, time: 1000 });
return;
}
arr.push({ FMaterialID: this.dataList[i].FMaterialID, FTypeID1: this.dataList[i].FTypeID1, FTypeID2: this.dataList[i].FTypeID2 })
}
let arr2 = {
taskId: this.dataInfoObj.FID,
tempId: this.dataInfoObj.FTeamID,
list: arr
}
let result = await EditTypeList(arr2);
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('EditType' + 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
//
if (result.Code === 200) {
await commonSave({
teamId: updateObj.FTeamID,
type: this.dataInfoObj['FType'],
desc: updateLog
}, "OperateLog");
let $this = this;
//$this.initPage();
localStorage.setItem('EditType' + 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('您没有做任何更改')
}
}
}
}
</script>

@ -0,0 +1,295 @@
<template>
<lay-container class="content-box" :style="'padding-top:'+(editType!=1?0:35)+'px'">
<view class="edit-box">
<lay-form :model="searchObj" class="search-box edit-info">
<lay-row class="color666">
<lay-form-item label="物料号" prop="FCode">
<lay-input v-model="searchObj.FCode"></lay-input>
</lay-form-item>
<lay-form-item label="试验号" prop="FTestCode">
<lay-input v-model="searchObj.FTestCode"></lay-input>
</lay-form-item>
<lay-form-item label="物料描述" prop="FName">
<lay-input v-model="searchObj.FName"></lay-input>
</lay-form-item>
<lay-form-item label="产品分类" prop="FType">
<lay-select v-model="searchObj.FType">
<lay-select-option v-for="(tIdv,tIdx) in typeListObj" :key="tIdx" :value="tIdv.FValue"
:label="tIdv.FName"></lay-select-option>
</lay-select>
</lay-form-item>
<lay-form-item v-if="editType != 1"></lay-form-item>
</lay-row>
<lay-form-item class="search-btn">
<lay-button size="sm" type="primary" @click="_clickSearch"></lay-button>
<lay-button size="sm" @click="_clickReset"></lay-button>
</lay-form-item>
</lay-form>
<lay-form :model="objInfo" class="search-box edit-info color999">
<lay-form-item label="主物料号" prop="FCode">
<lay-input :disabled="isDisabled" v-model="objInfo.FCode"></lay-input>
</lay-form-item>
<lay-form-item label="主物料描述" prop="FName">
<lay-input :disabled="isDisabled" v-model="objInfo.FName" type="FName"></lay-input>
</lay-form-item>
<lay-form-item :label=" editType == 1 ? '替代料物料号' : '副产物物料号' ">
<lay-input :disabled="isDisabled" v-model="objInfo.choseData.FCode"></lay-input>
</lay-form-item>
<lay-form-item :label=" editType == 1 ? '替代料描述' : '副产物描述' ">
<lay-input :disabled="isDisabled" v-model="objInfo.choseData.FName"></lay-input>
</lay-form-item>
<lay-form-item v-if="editType != 1" label="副产物数量">
<lay-input v-model="objInfo.choseData.FCount"></lay-input>
</lay-form-item>
<lay-form-item v-if="editType != 1" label="副产物单位">
<lay-input v-model="objInfo.choseData.FUnit"></lay-input>
</lay-form-item>
<lay-form-item class="search-btn">
<lay-button size="sm" type="danger" @click="submitClick"></lay-button>
<lay-button size="sm" @click="cancelClick"></lay-button>
</lay-form-item>
</lay-form>
</view>
<view class="edit-box">
<lay-table :class=" 'empty-small' + editType " :columns="dataColumn" id="id" :dataSource="dataList"
v-model:selected-key="selectedKey" :page="dataList.length>0?pageInfo:null" @change="changePage">
</lay-table>
</view>
</lay-container>
</template>
<style scoped>
.content-box {
height: 744px;
display: block;
position: relative;
clear: both;
float: none;
}
.edit-box {
display: block;
width: 99%;
text-align: center;
margin: 0 auto;
clear: both;
float: none;
}
.edit-info {
margin: 20px 0 10px;
width: 47%;
padding-left: 1%;
padding-right: 1%;
display: inline-block;
margin-right: 0.75%;
}
.edit-info+.edit-info {
margin-left: 0.75%;
margin-right: 0;
}
.layui-form-item {
margin-bottom: 16px;
}
</style>
<script>
import {
ref,
watch
} from 'vue';
import {
updateDataInfo,
getPageList
} from "/src/api/api/common";
export default {
setup() {
const objInfo = ref({
choseData: {
FName: "",
FType: "",
FCode: ""
}
});
const postData = ref({});
const pageInfo = ref({
total: 0,
limit: 5,
current: 1
});
let dataColumn = [{
type: "radio"
},
{
title: "物料号",
key: "FCode",
width: "200px"
},
{
title: "试验号",
key: "FTestCode",
width: "200px"
},
{
title: "物料描述",
key: "FName",
minWidth: "300px"
},
{
title: "产品分类",
key: "FTypeName",
width: "110px"
}
];
dataColumn.forEach((item) => {
item.align = "center";
});
const dataList = ref([]);
const selectedKey = ref("");
const isDisabled = ref(true);
const searchObj = ref({});
watch(selectedKey, function() {
const choseObj = dataList.value.find(s => s.id == selectedKey.value) || null;
if (choseObj != null) {
objInfo.value.choseData.FID = choseObj.FID;
objInfo.value.choseData.FName = choseObj.FName;
objInfo.value.choseData.FType = choseObj.FType;
objInfo.value.choseData.FCode = choseObj.FCode;
}
});
return {
objInfo,
postData,
pageInfo,
dataColumn,
dataList,
selectedKey,
isDisabled,
searchObj
}
},
props: {
dataInfoObj: {
type: Object,
default: () => {},
},
MaterialModel:{
type: Object,
default: () => {},
},
typeListObj: {
type: Array,
default: () => [],
},
editType: {
type: Number,
default: () => 1,
},
},
mounted() {
debugger
this.objInfoObj=this.MaterialModel;
let objInfo = JSON.parse(JSON.stringify(this.objInfoObj));
objInfo.choseData = {
FID: this.editType == 1 ? objInfo.FSuccedaneumID : objInfo.FFuProductsID,
FName: this.editType == 1 ? objInfo.FSuccedaneumInfo : objInfo.FFuProductsInfo,
FType: this.editType == 1 ? objInfo.FSuccedaneumType : objInfo.FFuProductsType,
FCode: this.editType == 1 ? objInfo.FSuccedaneumCode : objInfo.FFuProductsCode,
FCount: objInfo.FFuProductsCount || "",
FUnit: objInfo.FFuProductsUnit || ""
};
if (this.editType == 1) this.pageInfo.limit = 6;
this.objInfo = objInfo;
this._getPageList();
},
methods: {
//-
changePage(obj) {
this.pageInfo.current = obj.current;
this._getPageList();
},
//-
_clickSearch() {
this.postData = {};
for (let key in this.searchObj) {
let val = this.searchObj[key];
if (val != null && val != "") this.postData[key] = val;
}
this._getPageList(true);
},
//-
_clickReset() {
this.searchObj = {};
this._clickSearch();
},
//-
async _getPageList(isFirst) {
debugger
this.pageInfo.total = 0;
if (isFirst) {
this.pageInfo.current = 1;
this.pageInfo.total = 0;
}
this.postData.FPageIndex = this.pageInfo.current;
this.postData.FPageSize = this.pageInfo.limit;
let result = await getPageList(this.postData, "Material");
result.Data.List = result.Data.List || [];
let cD = this.objInfo.choseData;
result.Data.List.forEach((item) => {
let type = this.typeListObj.find(s => s.FValue == item.FType);
item.FTypeName = type == null ? "" : type.FName;
item.id = item.FID;
if (item.FCode == cD.FCode && item.FName == cD.FName && item.FType == cD.FType &&
this.selectedKey != item.id) {
this.selectedKey = item.id
}
});
this.pageInfo.total = result.Data.Total || 0;
this.dataList = result.Data.List;
},
//
async submitClick() {
let updateInfo = {
FID: this.objInfo.FID
};
if (this.editType == 1) {
updateInfo.FSuccedaneumID = this.objInfo.choseData.FID || -1;
updateInfo.FSuccedaneumInfo = this.objInfo.choseData.FName || "";
updateInfo.FSuccedaneumType = this.objInfo.choseData.FType || "";
updateInfo.FSuccedaneumCode = this.objInfo.choseData.FCode || "";
} else {
updateInfo.FFuProductsID = this.objInfo.choseData.FID || -1;
updateInfo.FFuProductsInfo = this.objInfo.choseData.FName || "";
updateInfo.FFuProductsType = this.objInfo.choseData.FType || "";
updateInfo.FFuProductsCode = this.objInfo.choseData.FCode || "";
updateInfo.FFuProductsCount = this.objInfo.choseData.FCount || "";
updateInfo.FFuProductsUnit = this.objInfo.choseData.FUnit || "";
}
let result = await updateDataInfo(updateInfo, "Material") || 0;
if (result > 0) {
layer.msg("操作成功", {
time: 1500,
icon: 1
});
setTimeout(() => {
this.cancelClick(true);
this.$emit("showEditMaterial");
}, 150)
} else {
layer.msg("操作失败", {
time: 1000,
icon: 2
})
}
},
//
cancelClick(isRefresh) {
this.$emit('cancelClick', isRefresh == undefined ? false : isRefresh);
}
}
}
</script>

@ -0,0 +1,390 @@
<template>
<lay-container fluid="true" class="content-box">
<lay-table class="row-select" 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-button size="sm" type="primary" :class="this.isBomShow ? 'isBomShow' : 'isBomHidden'" @click="changeVisible2">BOM</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>
</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-layer title="标题" :move="false" v-model="visible2">-->
<!-- 内容-->
<!-- </lay-layer>-->
</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;
}
.isBomShow{
}
.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{EditTypeList} from "/src/api/api/teamwork";
import OperateLog from "./OperateLog.vue";
export default {
components: {
OperateLog
},
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) !important;" : ""
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
}
return {
dataColumn,
dataList,
editColumn,
selectDataMap,
typeList,
userPower,
cellStyle,
cellClassName,
inputCodeValue,
inputDescValue,
isShow: false,
isBomShow :false,
visible2,
changeVisible2
};
},
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) {
let _data = await getListByTeamId({
teamId: this.dataInfoObj.FTeamID,
viewType: ""
});
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;
// });
let editColumn = dataColumn.map(function(item){
if(item.title=="一级分类"||item.title=="二级分类")
{
item.customSlot=item.key;
item.cellClass="edit-item";
}
return item;
});
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 col7 = dataColumn.filter(s => s.fieldType == 7) || [];
_data.rows.forEach((item) => {
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('EditType' + saveId, JSON.stringify(_data.rows));
this.editColumn = editColumn;
this.dataList = _data.rows;
this.dataColumn = dataColumn;
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] || "";
}
});
}
}
}
},
async saveBatch() {
var arr=new Array();
for(let i=0;i<this.dataList.length;i++)
{
if(this.dataList[i].FTypeID1==null||this.dataList[i].FTypeID1=="")
{
layer.msg("请选择一级分类", { icon : 2, time: 1000});
return;
}
if(this.dataList[i].FTypeID2==null||this.dataList[i].FTypeID2=="")
{
layer.msg("请选择二级分类", { icon : 2, time: 1000});
return;
}
arr.push({FMaterialID:this.dataList[i].FMaterialID,FTypeID1:this.dataList[i].FTypeID1,FTypeID2:this.dataList[i].FTypeID2})
}
let arr2={
taskId:this.dataInfoObj.FID,
tempId:this.dataInfoObj.FTeamID,
list:arr
}
let result= await EditTypeList(arr2);
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('EditType' + 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
//
if (result.Code === 200) {
await commonSave({
teamId: updateObj.FTeamID,
type: this.dataInfoObj['FType'],
desc: updateLog
}, "OperateLog");
//$this.initPage();
localStorage.setItem('EditType' + 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('您没有做任何更改')
}
}
}
}
</script>
Loading…
Cancel
Save