经济事项信息
新增行
删除行
导入
:data="dataList" @select="selectItemTick" @select-all="selectAllTick" border center="true" max-height="650" style="width: 100%;" > type="selection" header-align="center" width="34" v-if="sendAEData.edit != true" > v-model.trim="scope.row.economic1Code" readonly > v-model.trim="scope.row.economic1Name" @change="oneChange(scope.row,scope.$index)" class="chooseInput" :disabled="scope.row.economic1NameAllow" > v-model.trim="scope.row.economic2Name" @focus='checkTwoConditon(scope.row,scope.$index)' @change="twoChange(scope.row,scope.$index)" class="chooseInput" :disabled="scope.row.economic2NameAllow" > label="三级经济事项编码" prop="economic3Code" min-width="180" show-overflow-tooltip > v-for="(item,index) in scope.row.caliberOption" :label="item.managementCaliberName" :value="item.managementCaliberCode+','+item.managementCaliberName" :key="index" >
title="导入excel文件管理" custom-class="dialogFile" :modal-append-to-body="false" :visible.sync="dialogGetIn" size > :commonUrl="URL" :importUrl="importUrl" :downloadUrl="downloadUrl" @closeImportFile="closeImportFile" @cancelImportFile="cancelImportFile" >
:visible.sync="economicDialogOne" custom-class="commonDialog" title="经济事项一级" :modal-append-to-body="false" >
:visible.sync="economicDialogTwo" custom-class="commonDialog" title="经济事项二级" :modal-append-to-body="false" > :pCode="pCode" @closeEconomic2="closeEconomic2" @saveEconomicData2="saveEconomicData2" >
title="请选择审批链" :visible.sync="showIndicate" size="large" :modal-append-to-body="false" :close-on-press-escape="false" > v-for="(item, index2) in ot.approvalChainPostList" :key="item.id" :title="item.postName || item.roleName" > v-if="item.umAccountList.length == 1 && item.umAccountList[0].umAccLength == 0" slot="description" v-model.trim="item.umAccountList[0].name" @click.native="showApprovalDialog(index2,index)" icon="search" > v-else-if="item.umAccountList.length == 1 && item.isSubmitterUpdate == 0" slot="description" v-model.trim="item.umAccountList[0].name" readonly > v-for="value in item.umAccountList" :label="value.name" :key="value.umNo" :value="value.name" >
:visible.sync="showApplier" title="查询审批人" custom-class="commonDialog850" size="small" :modal="false" > :tabIndex="sendIndex" :index2="sendIndex2" @closedApproval="closedApproval" @getSubApprovalData="getSubApprovalData" >
@import "../../css/common.css";
.titleHeigth {
height: 51px;
}
import Economic1 from "./economic1.vue";
import Economic2 from "./economic2.vue";
import GetInDialog from "../invoiceInfo/GetInDialog.vue";
import BudgetApprovalInput from "../authapply/BudgetApprovalInput.vue";
import { tipMsg, justOne, getToday } from "../../js/common.js";
export default {
props: ["sendAEData"],
name: "addEditEcono",
components: {
Economic1,
Economic2,
BudgetApprovalInput,
GetInDialog
},
watch: {
},
data() {
return {
URL: "", //导入里面的
loadUrl: "",
importUrl: "",
downloadUrl: "",
dataList: [
{
economic1Code: "",
economic1Name: "",
economic2Code: "",
economic2Name: "",
economic1NameAllow: false, //一级是否允许编辑
economic2NameAllow: false, //二级是否允许编辑
economic3NameAllow: false, //三级是否允许编辑
tagAllow: false, //标签是否允许编辑
limitAllow: false, //通用选项是否禁用。默认可用
caliberSwatch: true, //管理口径的禁用状态
commentAllow: false, //三级是否允许编辑
economic3Code: "",
economic3Name: "",
tag: "", //标签 默认通用
tag1: "", //标签 一级标签
tag2: "", //标签 二级标签
status: "",
levelNo: "", //编码等级
completePath: "",
pCode: "",
mgmCaliberCode: [],
comment: "",
caliberOption: [], //管理口径容器
}
],
sendData: {},
checkedList: [], //选择列表
OneEcoList: [],
TwoEcoList: [],
economicDialogOne: false, //1经济事项对话框弹窗
economicDialogTwo: false, //2经济事项对话框弹窗
showCauseOfDeclare: false, //签报事由弹窗
showApplier: false, //审批人弹窗
showIndicate: false, //审批链弹窗
dialogGetIn: false, //导入
stepData: [], //审批步骤
treeCode: "TREE_FAS",
emplId: "",
orgId: "", //审批链入参组织id
sendIndex2: "",
sendIndex: "",
causeOfDeclare: "", //签报事由
LIndex: "0", //行号
TwoLIndex: "", //行号
pCode: "", //父级code,即一级经济事项code
status : 1,
completePath: "",
pCode: "",
sortTotal: 0
};
},
created() {
this.loadUrl = `${this.$root.loadUrl}`;
this.URL = `${this.$root.loadUrl}`;
this.mainpost();
this.findOpenUser();
this.getAllManagementCaliber();
},
mounted() {
this.init();
},
methods: {
init() {
if (this.sendAEData.edit) {
this.dataList[0] = this.sendAEData;
this.dataList[0].tag = this.sendAEData.tag == 1?"通用":"专用";
this.dataList[0].tagAllow = true;
// this.dataList[0].commentAllow = true;
if (this.dataList[0].levelNo == 1) {
this.dataList[0].economic2NameAllow = true;
this.dataList[0].economic3NameAllow = true;
}else if (this.dataList[0].levelNo == 2) {
this.dataList[0].economic1NameAllow = true;
this.dataList[0].economic3NameAllow = true;
} else {
this.dataList[0].economic1NameAllow = true;
this.dataList[0].economic2NameAllow = true;
}
}
},
//对管理口径禁用控制
toggleCaliber(tag,index){
this.LIndex = index;
if (tag == '1'||tag == '通用') {
this.dataList[index].caliberSwatch = true
this.dataList[index].mgmCaliberCode = []
} else {
this.dataList[index].caliberSwatch = false
if (this.dataList[index].economic1Code == ''&&this.dataList[index].economic2Code == ''&&this.dataList[index].economic3Code == '') {
this.getAllManagementCaliber();
}
}
},
//一级经济事项改变
oneChange(row, index) {
if (!this.sendAEData.edit) {
this.dataList[index].economic1Code = ''
this.dataList[index].tag = ''
this.dataList[index].mgmCaliberCode = []
}
this.dataList[index].economic2Code = ''
this.dataList[index].economic2Name = ''
this.dataList[index].economic3Code = ''
this.dataList[index].economic3Name = ''
this.dataList[index].limitAllow = false;
},
//二级经济事项改变
twoChange(row, index) {
if (!this.sendAEData.edit) {
this.dataList[index].economic2Code = ''
this.dataList[index].tag = ''
this.dataList[index].mgmCaliberCode = []
}
this.dataList[index].economic3Code = ''
this.dataList[index].economic3Name = ''
},
//清空释义
clearComment(row, index) {
this.dataList[index].comment = ''
},
//经济事项弹窗
openEconomicDialogOne(row,index) {
if (this.sendAEData.edit == true) {
this.$message({ type: "warning", message: "编辑状态下不可以选择,只可修改。" });
return
}
this.LIndex = index;
this.economicDialogOne = true;
},
//关闭经济事项对话框
closeEconomic1() {
this.economicDialogOne = false;
},
//1经济对话框的保存
saveEconomicData1(data) {
console.log(data);
let indexL = this.LIndex;
this.dataList[indexL].economic1Name = data.name;
this.dataList[indexL].economic1Code = data.code;
this.dataList[indexL].tag = (data.tag == 1 ? "通用" : "专用");
if (data.tag == 0) {
this.dataList[indexL].limitAllow = true;
}else{
this.dataList[indexL].limitAllow = false;
}
//清空联动二级经济事项信息
this.dataList[indexL].economic2Name = "";
this.dataList[indexL].economic2Code = "";
//清空联动三级级经济事项信息
this.dataList[indexL].economic3Name = "";
this.dataList[indexL].economic3Code = "";
this.economicDialogOne = false;
if (data.tag == 1) {
this.getAllManagementCaliber()
}
if (data.tag == 0 && data.code != '') {
this.getManagementCaliber(data.code);
}
},
//2级经济事项弹窗
openEconomicDialogTwo(row, index) {
this.LIndex = index;
// this.S2Index = index;
if (this.sendAEData.edit == true) {
this.$message({ type: "warning", message: "编辑状态下不可以选择,只可修改。" });
return
}
if (this.dataList[index].economic1Code == ''&& this.dataList[index].economic1Name == '') {
this.$message({ type: "warning", message: "请先选择或填写一级经济事项名称!" });
}else if(this.dataList[index].economic1Code == ''&& this.dataList[index].economic1Name != ''){
this.$message({ type: "warning", message: "一级为新增,不可再选择二级经济事项名称。" });
} else {
this.pCode = this.dataList[index].economic1Code;
this.economicDialogTwo = true;
}
},
//关闭经济事项对话框
closeEconomic2() {
this.economicDialogTwo = false;
},
//经济对话框的保存
saveEconomicData2(data) {
console.log(data);
let indexL = this.LIndex;
this.dataList[indexL].economic2Name = data.name;
this.dataList[indexL].economic2Code = data.code;
this.dataList[indexL].tag = (data.tag == 1 ? "通用" : "专用");
if (data.tag == 0) {
this.dataList[indexL].limitAllow = true;
}else{
this.dataList[indexL].limitAllow = false;
}
//清空联动三级级经济事项信息
this.dataList[indexL].economic3Name = "";
this.dataList[indexL].economic3Code = "";
this.economicDialogTwo = false;
if (data.tag == 1) {
this.getAllManagementCaliber()
}
if (data.tag == 0 && data.code != '') {
this.getManagementCaliber(data.code);
}
},
//获取管理口径
getManagementCaliber(code) {
let indexL = this.LIndex;
let params = {
economicCode: code
};
this.$http
.post(
this.URL + "/economicEventsApply/getTargetManagementCaliber",
params
)
.then(res => {
var result = res.body;
if (result.code == "000000") {
this.dataList[indexL].caliberOption = result.data;
}
});
},
//获取全部管理口径
getAllManagementCaliber() {
let indexL = this.LIndex;
this.$http
.get(
this.URL + "/economicEventsApply/getAllManagementCaliber",
{})
.then(res => {
var result = res.body;
if (result.code == "000000") {
this.dataList[indexL].caliberOption = result.data;
if (this.sendAEData.edit == true) {
let alterArr = []
this.sendAEData.applyMgmList.forEach(element => {
alterArr.push(element.managementCaliberCode+','+element.managementCaliberName)
});
this.dataList[0].mgmCaliberCode = alterArr;
this.dataList[0].caliberSwatch = true;
}
}
});
},
//导入
closeImportFile() {
this.dialogGetIn = false;
this.search();
},
//取消导入弹窗
cancelImportFile() {
this.dialogGetIn = false;
},
getIn() {
this.downloadUrl =
"/template/template4EconomicEventsImport/downloadTemplate";
this.importUrl = "/economicEvents/importEconomicEventsList";
this.dialogGetIn = true;
},
//导出
getOut() {
var option = {
url: this.URL + "/economicEvents/exportEconomicEventsList",
data: {
mdmEconomicEventsAttr: {
mname: this.projectQueryDto.mname,
mgmClbId: this.projectQueryDto.nodeId,
code: this.projectQueryDto.code,
name: this.projectQueryDto.name,
pcode: this.projectQueryDto.pcode,
pname: this.projectQueryDto.pname,
status: this.projectQueryDto.status
}
},
method: "post"
};
downLoadFile(option);
},
clearnAction() {
this.$emit("closeAddEditdialog");
},
mainpost() {
this.$Http
.post(this.URL + "/emplRoleDeclare/findMainPostNode", {
treeType: this.treeCode
})
.then(data => {
var result = data.body;
if (result.code == "000000") {
if (result.data == null) {
if (this.treeCode == "TREE_FAS") {
this.$message({
type: "warning",
message:
"您没有所属组织,请去组织树对应组织维护主岗为普通员工岗"
});
}
} else {
this.orgId = result.data.id;
}
}
});
},
findOpenUser() {
this.$Http
.post(this.URL + "/emplRoleDeclare/findOperUsers", {})
.then(data => {
var result = data.body;
if (result.code == "000000") {
this.emplId = result.data.id;
} else {
this.$message({
showClose: true,
message: result.message,
type: "error",
duration: 5000
});
}
});
},
getLength(val) {
let str = new String(val);
let bytesCount = 0;
for (let i = 0 ,n = str.length; i < n; i++) {
let c = str.charCodeAt(i);
if ((c >= 0x0001 && c <= 0x007e) || (0xff60<=c && c<=0xff9f)) {
bytesCount += 1;
} else {
bytesCount += 2;
}
}
return bytesCount;
},
//必填校验
checkMust(){
for(var i=0; i if(this.dataList[i].economic1Name == ''){ tipMsg('一级经济事项名称不可为空', "warning"); return false } if(this.dataList[i].tag == ''){ tipMsg('标签必须选择', "warning"); return false } if (this.sendAEData.edit== false) { if(this.dataList[i].economic1Code != ''&&this.dataList[i].economic2Name == ''){ tipMsg('一级事项是选择,二级事项名称需要新增或选择', "warning"); return false } } if (this.sendAEData.edit== false) { if(this.dataList[i].economic1Code != ''&&this.dataList[i].economic2Name == ''){ tipMsg('一级事项是选择,二级事项名称需要新增或选择', "warning"); return false } } if (this.sendAEData.edit== false) { if(this.dataList[i].economic2Code != ''&&this.dataList[i].economic3Name == ''){ tipMsg('二级事项是选择,三级事项名称需要新增', "warning"); return false } } if(this.getLength(this.dataList[i].economic1Name) >80){ tipMsg('一级经济事项名称长度需在40个字符范围内。', "warning"); return false } if(this.getLength(this.dataList[i].economic2Name)>80){ tipMsg('二级经济事项名称长度需在40个字符范围内。', "warning"); return false } if(this.getLength(this.dataList[i].comment)>500){ tipMsg('释义字节长度需在250字符范围内。', "warning"); return false } } return true; }, openCause() { if (this.checkMust()) { //打开事由弹窗 this.showCauseOfDeclare = true; this.causeOfDeclare ='' //置空事由。 } }, //关闭事由弹窗 colseCause() { this.showCauseOfDeclare = false; }, //事由填写完成,打开审批链弹窗 saveCause() { if(this.causeOfDeclare == ''){ tipMsg('填写申请事由','warning') return; } if(this.causeOfDeclare.length > 200){ tipMsg('提交审批说明需要控制在200个字符内。','warning') return; } this.showIndicate = true; this.getApproval("经济事项新增/修改") //暂时使用 权限新增调试 }, getApproval(str) { let sen = {}; sen.templateName = str; //审批链模板名称 sen.organizationNodeId = this.orgId + ""; //公司组织id sen.emplId = this.emplId + ""; this.$http.post(this.URL + "/approvalChain/findChain", sen).then(res => { if (res.body.code == "200") { this.stepData = res.body.data; this.stepData.forEach(it => { it.approvalChainPostList.forEach(ot => { if (ot.umAccountList.length == 0) { let aobj = { name: "", umNo: "", umAccLength: 0 }; ot.umAccountList.push(aobj); } }); }); } }); }, //关闭审批链弹窗 colseAction() { this.showIndicate = false; }, //提交审批 saveAction(_, enable) { var self = this; //用for循环来中止 forEach不行 for (var i = 0; i < self.stepData.length; i++) { for ( var o = 0; o < self.stepData[i].approvalChainPostList.length; o++ ) { if ( self.stepData[i].approvalChainPostList[o].umAccountList[0].name == "" ) { tipMsg("审批人不能为空!", "error"); enable(); return; } } } //更新审批链数据, 整理sendData, 加入approvalChainInfoRepresentations, 主题TaskName,正文 TaskDesc字段 self.stepData.forEach(item => { //只发送选中的审批人的信息,没选中的审批人去除 item.approvalChainPostList.forEach(ot => { ot.umAccountList.forEach((val, index) => { if (ot.name == val.name) { ot.umAccountList[0] = ot.umAccountList[index]; ot.umAccountList.splice(1, ot.umAccountList.length); } }); }); }); let app = {}; app.approvalChainInfos = this.stepData; app.causeOfDeclare = this.causeOfDeclare; app.orgId = this.orgId; let applyRecords = []; this.dataList.forEach(element => { let levelNo = ""; let koujinRecords = []; if (element.economic3Name != ''&&element.economic3Name != null) { levelNo = 3 } else if(element.economic2Name != ''&&element.economic2Name != null){ levelNo = 2 }else { levelNo = 1 } element.mgmCaliberCode.forEach(item => { koujinRecords.push({ 'managementCaliberCode': item.substr(0, item.indexOf(',')), //截取前半部分 'managementCaliberName': item.substr(item.indexOf(',')+1) }); }); //编辑页面的状态下多三个参数 if (this.sendAEData.edit) { if (element.tag == "通用"||element.tag == 1) { applyRecords.push({ economic1Code: element.economic1Code, economic1Name: element.economic1Name, economic2Code: element.economic2Code, economic2Name: element.economic2Name, economic3Code: element.economic3Code, economic3Name: element.economic3Name, tag: element.tag == "通用"||element.tag == 1 ? 1 : 0, comment: element.comment, levelNo: levelNo, status : element.status, completePath: element.completePath, pCode: element.pCode }); } else { applyRecords.push({ economic1Code: element.economic1Code, economic1Name: element.economic1Name, economic2Code: element.economic2Code, economic2Name: element.economic2Name, economic3Code: element.economic3Code, economic3Name: element.economic3Name, tag: element.tag == "通用"||element.tag == 1 ? 1 : 0, comment: element.comment, levelNo: levelNo, status : element.status, completePath: element.completePath, pCode: element.pCode, applyMgmList: koujinRecords }); } } //新增情况下用这个。 if (!this.sendAEData.edit) { if (element.tag == "通用"||element.tag == 1) { applyRecords.push({ economic1Code: element.economic1Code, economic1Name: element.economic1Name, economic2Code: element.economic2Code, economic2Name: element.economic2Name, economic3Code: element.economic3Code, economic3Name: element.economic3Name, tag: element.tag == "通用"||element.tag == 1 ? 1 : 0, comment: element.comment, levelNo: levelNo }); } else { applyRecords.push({ economic1Code: element.economic1Code, economic1Name: element.economic1Name, economic2Code: element.economic2Code, economic2Name: element.economic2Name, economic3Code: element.economic3Code, economic3Name: element.economic3Name, tag: element.tag == "通用"||element.tag == 1 ? 1 : 0, comment: element.comment, levelNo: levelNo, applyMgmList: koujinRecords }); } } }); app.applyList = applyRecords; console.log(this.stepData); if (!this.sendAEData.edit) { this.$Http .post(this.URL + "/economicEventsApply/insert", app) .then(data => { enable(); var result = data.body; if (result.code == "000000") { tipMsg("新增提交申请成功!", "success"); this.colseAction(); this.closedApproval(); this.colseCause(); this.$emit("closeAddEditdialog"); } else { tipMsg(result.message, "error"); } }) .catch(data => { enable(); }); } else { this.$Http .post(this.URL + "/economicEventsApply/update", app) .then(data => { enable(); var result = data.body; if (result.code == "000000") { tipMsg("编辑提交申请成功!", "success"); this.colseAction(); this.closedApproval(); this.colseCause(); this.$emit("closeAddEditdialog"); } else { tipMsg(result.message, "error"); } }) .catch(data => { enable(); }); } }, //打开选择审批人弹窗 showApprovalDialog(obj2, obj) { this.sendIndex = obj; this.sendIndex2 = obj2; this.showApplier = true; }, //关闭审批人员弹窗 closedApproval() { this.showApplier = false; }, //审批人弹窗选择信息 getSubApprovalData(msg) { console.log(msg); let index1 = msg.index * 1; let index2 = msg.index2 * 1; this.stepData[index1].approvalChainPostList[ index2 ].umAccountList[0].name = msg.name; this.stepData[index1].approvalChainPostList[ index2 ].umAccountList[0].umNo = msg.umNo; this.closedApproval(); }, //选择 selectItemTick(item) { this.checkedList = item; }, //多选 selectAllTick(item) { this.checkedList = item; }, //新增信息行 addList(name) { if (this.dataList.length == 0) { this.dataList.push({ economic1Code: "", economic1Name: "", economic2Code: "", economic2Name: "", economic3Code: "", economic3Name: "", tag: "", //标签 status: "", mgmCaliberCode: [], caliberOption: [], //管理口径容器 caliberSwatch: true, //管理口径的禁用状态 limitAllow: false, //通用选项是否禁用。默认可用 comment: "" //释义 }); } else { let lastObj = this.dataList[this.dataList.length - 1]; let copyobj = {}; copyobj = { economic1Code: "", economic1Name: "", economic2Code: "", economic2Name: "", economic3Code: "", economic3Name: "", caliberSwatch: true, //管理口径的禁用状态 limitAllow: false, //通用选项是否禁用。默认可用 tag: "", //标签 status: "", mgmCaliberCode: [], caliberOption: [], //管理口径容器 comment: "" }; this.dataList.push(JSON.parse(JSON.stringify(copyobj))); } this[name].forEach((item, index) => { item.index = index; }); }, //删除信息行 delList(delArr, name) { //申请信息删除 if (!this.checkedList.length) { tipMsg("请选择一条或多条数据进行删除", "warning"); } else { if ( this.dataList.length == 1 || this.dataList.length == this.checkedList.length ) { tipMsg("至少要保留一条数据", "warning"); } else { this[delArr].map(tempitem => { this[name].forEach((item, index) => { if (tempitem.index === item.index) { this[name].splice(index, 1); tipMsg("删除成功!", "success"); } }); }); } } }, checkTwoConditon(row,index){ if (this.dataList[index].economic1Code == ""&& this.dataList[index].economic1Name == "") { tipMsg("请先选择或填写一级经济事项名称!", "warning"); } // if (this.dataList[index].economic1Code == ""&& this.dataList[index].economic1Name != "") { // tipMsg("一级为新增不能再选择或填二级经济事项", "warning"); // } }, checkThreeConditon(row,index){ if (this.dataList[index].economic2Code == ""&& this.dataList[index].economic2Name == "") { tipMsg("请先选择或填写二级经济事项名称!", "warning"); } // if (this.dataList[index].economic2Code == ""&& this.dataList[index].economic2Name != "") { // tipMsg("二级经济事项为新增,不可再新增三级经济事项!", "warning"); // } } } };