|
|
<template> <div class="mod-config"> <el-dialog width="40%" :title="value === 'save' ? '新增-项目' :value === 'update'?'修改-项目':'新增-子项目'" :close-on-click-modal="false" :visible.sync="visible" @close="closeSaveDialog"> <el-form ref="saveForm" :model="dataForm" label-position="top" label-width="100px" :rules="projectRole"> <el-row :gutter="25"> <el-col :span="6"> <el-form-item :label="(value !=='save' && value !== 'update')?'上级项目号':'项目号'"> <el-input v-model="dataForm.projectId" disabled ></el-input> </el-form-item> </el-col> <el-col :span="12"> <el-form-item label="项目名称" prop="projectName"> <el-input v-model="dataForm.projectName" :disabled="isProjectFieldDisabled('projectName')" ></el-input> </el-form-item> </el-col> <el-col :span="6"> <el-form-item prop="projectTypeDb" label="项目类型"> <dict-data-select dict-type="project_info_type_db" v-if="visible" v-model="dataForm.projectTypeDb" :disabled="isProjectFieldDisabled('projectTypeDb')"></dict-data-select> </el-form-item> </el-col> <el-col :span="6"> <el-form-item prop="industry" label="行业"> <dict-data-select dict-type="project_info_industry" v-if="visible" v-model="dataForm.industry" :disabled="isProjectFieldDisabled('industry')"></dict-data-select> </el-form-item> </el-col> <el-col :span="6"> <el-form-item prop="priority" label="优先级"> <dict-data-select dict-type="project_info_priority" v-if="visible" v-model="dataForm.priority" :disabled="isProjectFieldDisabled('priority')"></dict-data-select> </el-form-item> </el-col> <el-col :span="6"> <el-form-item prop="projectManagerName"> <span v-if="isProjectTeamFieldDisabled('projectManagerList')" slot="label">项目经理</span> <span v-else slot="label" @click="managerChooseModal()"><a herf="#">项目经理</a></span> <el-input v-model="dataForm.projectManagerName" readonly ></el-input> </el-form-item> </el-col> <el-col :span="6"> <el-form-item prop="projectOwnerName" :rules="projectRole.projectOwnerName"> <span v-if="isProjectTeamFieldDisabled('projectOwnerList')" slot="label">项目审批人</span> <span v-else slot="label" @click="ownerChooseModal()"><a herf="#">项目审批人</a></span> <el-input v-model="dataForm.projectOwnerName" readonly></el-input> </el-form-item> </el-col> <el-col :span="6"> <el-form-item prop="customerId"> <span slot="label" style="" @click="!isProjectFieldDisabled('customerId') && getBaseList(102,1)"><a herf="#">客户</a></span> <el-input v-model="dataForm.customerId" @blur="getCustomerName(1)" :disabled="isProjectFieldDisabled('customerId')"></el-input> </el-form-item> </el-col> <el-col :span="12"> <el-form-item prop="customerName" label="客户名称"> <el-input v-model="dataForm.customerName" disabled></el-input> </el-form-item> </el-col> <el-col :span="6"><!-- <el-form-item label="终端客户">--><!--<!– <span slot="label" style="" @click="getBaseList(102,2)"><a herf="#">终端客户</a></span>–>--><!--<!– <el-input v-model="dataForm.finalCustomerId" @blur="getCustomerName(2)"></el-input>–>--><!-- <dict-data-select v-model="dataForm.finalCustomerId" clearable filterable dict-type="finalCustomer" :use-default-value="true"></dict-data-select>--><!-- </el-form-item>--> </el-col><!-- <el-col :span="12">--><!-- <el-form-item label="终端客户名称:">--><!-- <el-input v-model="dataForm.finalCustomerName" disabled ></el-input>--><!-- </el-form-item>--><!-- </el-col>--> <el-col :span="6"> <el-form-item label="客户项目号"> <el-input v-model="dataForm.customerProjectNo" :disabled="isProjectFieldDisabled('customerProjectNo')" ></el-input> </el-form-item> </el-col> <el-col :span="6"> <el-form-item class="project-amount-form-item"> <span slot="label" class="project-amount-label">项目年销售额CNY(K)</span> <el-input v-model="dataForm.projectAmount" :disabled="isProjectFieldDisabled('projectAmount')" @input="dataForm.projectAmount = dataForm.projectAmount.replace(/[^\d.]/g, '').replace(/\.{2,}/g, '.').replace(/^(\d+\.\d{1,6}).*$/, '$1')"></el-input> </el-form-item> </el-col> <el-col :span="8"> <el-form-item label="直接客户"> <el-input v-model="dataForm.finalCustomerId" :disabled="isProjectFieldDisabled('finalCustomerId')"></el-input> </el-form-item> </el-col> </el-row> <el-form-item label="项目描述" style="height: 70px"> <el-input type="textarea" resize="none" :autosize="{minRows: 2, maxRows: 2}" v-model="dataForm.projectDesc" :disabled="isProjectFieldDisabled('projectDesc')" ></el-input> </el-form-item> <el-form-item label="客户应用/要求" style="height: 70px"> <el-input type="textarea" resize="none" :autosize="{minRows: 2, maxRows: 2}" v-model="dataForm.customerRemark" :disabled="isProjectFieldDisabled('customerRemark')" ></el-input> </el-form-item> <el-form-item label="其他要求" style="height: 70px"> <el-input type="textarea" resize="none" :autosize="{minRows: 2, maxRows: 2}" v-model="dataForm.remark" :disabled="isProjectFieldDisabled('remark')" ></el-input> </el-form-item> <el-form-item prop="userRoleName" :rules="projectRole.userRoleName"> <span slot="label" style="" @click="!isProjectFieldDisabled('userRoleName') && userRollModal()"><a herf="#">项目权限</a></span> <el-input v-model="dataForm.userRoleName" :disabled="isProjectFieldDisabled('userRoleName')" ></el-input> </el-form-item> </el-form> <span slot="footer" class="dialog-footer"> <el-button type="primary" v-if="canSaveAction()" @click="dataFormSubmit()">{{'保存'}}</el-button> <el-button type="primary" @click="visible = false">{{'关闭'}}</el-button> <el-button type="primary" v-if="canAgreeAction()" :loading="submitLoading" @click="agreeSubmit">同意</el-button> <el-button type="primary" v-if="canRejectAction()" :loading="submitLoading" @click="openRejectModal">驳回</el-button> </span> </el-dialog>
<el-dialog title="驳回" top="30vh" :close-on-click-modal="false" :visible.sync="submitModalFlag" width="500px"> <el-form label-position="top"> <el-form-item label="驳回意见"> <el-input type="textarea" v-model="rejectOpinion" :rows="3" resize="none"></el-input> </el-form-item> </el-form> <span slot="footer" class="dialog-footer"> <el-button type="primary" :loading="submitLoading" @click="rejectSubmit">确定</el-button> <el-button type="primary" @click="submitModalFlag = false">取消</el-button> </span> </el-dialog>
<el-dialog width="530px" title="项目经理" :close-on-click-modal="false" :visible.sync="managerFlag"> <el-transfer class="rq" filterable v-model="projectManagerList" :props="{ key: 'operatorId', label: 'operatorName' }" :data="operatorList" :titles="['未选择', '已选择']"></el-transfer> <span slot="footer" class="dialog-footer"> <div style="margin-top: 5px"> <el-button type="primary" @click="saveManagerList()">确定</el-button> <el-button @click="managerFlag = false" type="primary">取消</el-button> </div> </span> </el-dialog>
<el-dialog width="530px" title="项目审批人" :close-on-click-modal="false" :visible.sync="ownerFlag"> <el-transfer class="rq" filterable v-model="projectOwnerList" :props="{ key: 'operatorId', label: 'operatorName' }" :data="operatorList" :titles="['未选择', '已选择']"></el-transfer> <span slot="footer" class="dialog-footer"> <el-button type="primary" @click="saveOwnerList()">确定</el-button> <el-button @click="ownerFlag = false" type="primary">取消</el-button> </span> </el-dialog>
<el-dialog width="530px" title="权限" :close-on-click-modal="false" :visible.sync="userRoleFlag"> <el-form :inline="true" :model="userRoleForm" label-position="top"> <el-form-item label="账号"> <el-input v-model="userRoleForm.username" placeholder=" "></el-input> </el-form-item> <el-form-item label="姓名"> <el-input v-model="userRoleForm.userDisplay" placeholder=" "></el-input> </el-form-item> <el-form-item label=" "><!-- <el-button type="primary" @click="searchUserRoll()">查询</el-button>--> <el-button type="primary" @click="loadView">查询</el-button> </el-form-item> </el-form> <el-table ref="table" :data="copyUserRoleList" border :height="300" v-loading="queryUserRoleListLoading" style="width: 100%;"> <el-table-column prop="username" header-align="center" align="center" min-width="35" label="账号"> </el-table-column> <el-table-column prop="userDisplay" header-align="center" align="center" min-width="35" label="姓名"> </el-table-column> <el-table-column prop="" header-align="center" align="center" min-width="30" label=""> <template slot="header" slot-scope="scope"> <el-checkbox :indeterminate="saveCheckAllIndeterminate" v-model="saveCheckAll" true-label="Y" false-label="N" @change="changeSaveCheckAll"></el-checkbox> </template> <template slot-scope="scope"> <!-- 如果数据为Y,显示勾选框,否则不勾选 --> <el-checkbox :indeterminate="userRoleIndeterminateList[scope.$index]" v-model="scope.row.checkAll" @change="changeAll(scope.row)"></el-checkbox> </template> </el-table-column> <el-table-column prop="" header-align="center" align="center" min-width="30" label="查询"> <template slot-scope="scope"> <!-- 如果数据为Y,显示勾选框,否则不勾选 --> <el-checkbox v-model="scope.row.searchCheck" @change="changeCheck(scope.row,1)"></el-checkbox> </template> </el-table-column> <el-table-column prop="" header-align="center" align="center" min-width="30" label="修改"> <template slot-scope="scope"> <!-- 如果数据为Y,显示勾选框,否则不勾选 --> <el-checkbox v-model="scope.row.updateCheck" @change="changeCheck(scope.row,2)"></el-checkbox> </template> </el-table-column> <el-table-column prop="" header-align="center" align="center" min-width="30" label="下载"> <template slot-scope="scope"> <!-- 如果数据为Y,显示勾选框,否则不勾选 --> <el-checkbox v-model="scope.row.downCheck" @change="changeCheck(scope.row,3)"></el-checkbox> </template> </el-table-column> <el-table-column prop="" header-align="center" align="center" min-width="30" label="删除"> <template slot-scope="scope"> <!-- 如果数据为Y,显示勾选框,否则不勾选 --> <el-checkbox v-model="scope.row.deleteCheck" @change="changeCheck(scope.row,4)"></el-checkbox> </template> </el-table-column> </el-table>
<span slot="footer" class="dialog-footer"> <div style="margin-top: 5px"> <el-button type="primary" @click="saveUserList()">确定</el-button> <el-button @click="userRoleFlag = false" type="primary">取消</el-button> </div> </span> </el-dialog> <Chooselist ref="baseList" @getBaseData="getBaseData"></Chooselist> </div></template>
<script> import { projectInfoSearch, searchOperatorWithSite, searchProjectTeamStr, searchUserRoll, searchSelectionUserRole, saveProjectInfo, submitProjectInfo, } from "@/api/project/project.js" import Chooselist from '@/views/modules/common/Chooselist' import DictDataSelect from "../../sys/dict-data-select.vue"; import {queryCustomer } from "@/api/customer/customerInformation"; import item from "../../code/item.vue"; import {queryUsernameByRoleSuperFlag} from "../../../../api/project/project"; import {getNodeAuthority, checkSuperAdmin} from "@/api/changeManagement/changeManagement" import {isAuth} from "../../../../utils";
export default { model:{ prop:'value', event:'change', }, props:{ value:{ required:true, type:String, } }, components: { DictDataSelect, Chooselist }, data () { return { tagNo:'', tagNo1:'', visible: false, treeVisible: false, managerFlag:false, userRoleFlag:false, ownerFlag:false, submitModalFlag:false, submitLoading:false, rejectOpinion:'', nodeAuthorityLoaded: true, plmProjectAuthorityArr: [], plmProjectTeamAuthorityArr: [], menuId: '101002001', authSubmit: false, authReject: false, superAdmin: false, createBy2: this.$store.state.user.name, operatorList:[], dataForm: { id: 0, site:this.$store.state.user.site, projectLevel:1, customerProjectNo:'', projectId:'', projectTypeDb:'', projectType:'', customerName:'', finalCustomerName:'', customerId:'', finalCustomerId:'', projectName:'', projectDesc:'', needDate:'', priority:'', projectSource:'', industry:'', priorityDesc:'', projectSourceDesc:'', industryDesc:'', projectManagerName:'', projectOwnerName:'', customerRemark:'', remark:'', userRoleName:'', projectManagerList:[], projectOwnerList:[], userRoleList:[], productSet:'', projectAmount:'', status:'草稿', stepId: 10, rejectFlag: 'N', createBy2: '', isReject: 'N' }, userRoleForm:{ username:'', userDisplay:'', }, projectManagerList:[], projectOwnerList:[], userRoleList:[], projectRole: { projectLevel: [ { required: true, message: ' ', trigger: ['change','blur'] } ], customerName: [ { required: true, message: ' ', trigger: ['change','blur'] } ], projectName: [ { required: true, message: ' ', trigger: ['change','blur'] } ], customerId: [ { required: true, message: ' ', trigger: ['change','blur'] } ], projectOwnerName: [ { required: true, message: ' ', trigger: 'change' } ], userRoleName: [ { required: true, message: ' ', trigger: 'change' } ], }, saveCheckAll:'N',
queryUserRoleListLoading:false, filterParams:{
}, } }, created () { this.menuId = (this.$route.meta && this.$route.meta.menuId) || this.menuId this.authSubmit = isAuth(this.menuId + ':submit') this.authReject = isAuth(this.menuId + ':reject') checkSuperAdmin().then(({data}) => { this.superAdmin = !!(data && data.superAdmin) }) }, watch:{ userRoleFlag(newVal,oldVal){ if (newVal === false){ this.userRoleForm.username = '' this.userRoleForm.userDisplay = '' // this.saveCheckAll='N'
} }, queryUserRoleListLoading(newVal,oldVal){ if (newVal){ setTimeout(()=>{ this.queryUserRoleListLoading = false },5000) } }, }, computed:{ saveCheckAllIndeterminate(){ if (this.userRoleList.every(item => item.checkAll === true)){ this.saveCheckAll = 'Y' return false }else if (this.userRoleList.every(item => item.checkAll === false)){ this.saveCheckAll = 'N' return false }else { this.saveCheckAll = 'N' return true } }, userRoleIndeterminateList(){ return this.userRoleList.map(item=>{ if (item.checkAll === true){ return false }else { return !(item.searchCheck === false && item.updateCheck === false && item.downCheck === false && item.deleteCheck === false); } }) }, copyUserRoleList: { get() { return this.userRoleList.filter(item => { const usernameMatch = this.filterParams.username ? item.username.toLowerCase().includes(this.filterParams.username.toLowerCase()) : true; const userDisplayMatch = this.filterParams.userDisplay ? item.userDisplay.toLowerCase().includes(this.filterParams.userDisplay.toLowerCase()) : true; return usernameMatch && userDisplayMatch; }); } } }, methods: { loadView(){ this.filterParams = { ...this.userRoleForm } },
// 获取基础数据列表S
getBaseList (val, type) { this.tagNo = val this.tagNo1 = type this.$nextTick(() => { let strVal = '' let conSql = '' if (val === 1010) { if(type==1) { strVal = this.dataForm.projectTypeDb } } if (val === 106) { if(type==1) { strVal = this.dataForm.buNo } } if (val === 102) { if(type==1) { strVal = this.dataForm.customerId conSql = " order by Customer_no " } if(type==2) { strVal = this.dataForm.finalCustomerId } } if (val === 1011) { if(type==1) { strVal = this.dataForm.projectSource } } if (val === 1012) { if(type==1) { strVal = this.dataForm.priority } } this.$refs.baseList.init(val, strVal, conSql) }) },
/* 列表方法的回调 */ getBaseData (val) { if (this.tagNo === 1010) { if(this.tagNo1==1) { this.dataForm.projectTypeDb = val.Base_id this.dataForm.projectType = val.Base_desc } } if (this.tagNo === 102) { if(this.tagNo1==1) { this.dataForm.customerId = val.Customer_no this.dataForm.customerName = val.Customer_desc } if(this.tagNo1==2) { this.dataForm.finalCustomerId = val.Customer_no this.dataForm.finalCustomerName = val.Customer_desc } } if (this.tagNo === 1011) { if(this.tagNo1==1) { this.dataForm.projectSource = val.Base_id this.dataForm.projectSourceDesc = val.Base_desc } } if (this.tagNo === 1012) { if(this.tagNo1==1) { this.dataForm.priority = val.Base_id this.dataForm.priorityDesc = val.Base_desc } } if (this.tagNo === 106) { if(this.tagNo1==1) { this.dataForm.buNo = val.Bu_no this.dataForm.buDesc = val.Bu_desc } } }, init (id) { this.dataForm.id = id || 0 let requestCustomer = null; if (this.dataForm.customerId){ requestCustomer = JSON.parse(JSON.stringify(this.dataForm)) } if(this.dataForm.id!==0){ let inData={ page: 1, limit: 10, id:id, menuId: this.menuId, userId: this.$store.state.user.name } projectInfoSearch(inData).then(({data}) => { if(data.page.list.length>0){ this.dataForm= data.page.list[0]; const isReject = String(this.dataForm.isReject || this.dataForm.reject || '').trim().toUpperCase() === 'Y' ? 'Y' : 'N' this.$set(this.dataForm, 'isReject', isReject) let inData={ site:this.dataForm.site, projectId:this.dataForm.projectId, type:'manager', } searchProjectTeamStr(inData).then(({data}) => { this.dataForm.projectManagerList=data.rows }) let inData2={ site:this.dataForm.site, projectId:this.dataForm.projectId, type:'owner', } searchProjectTeamStr(inData2).then(({data}) => { this.dataForm.projectOwnerList=data.rows }) this.searchUserRollAll(); this.loadNodeAuthority(this.dataForm.site, this.dataForm.stepId || 10) } }) } else { // 项目新增
this.dataForm = { id: 0, site: this.$store.state.user.site, projectLevel: 1, customerProjectNo: '', projectId: '', projectTypeDb: '', projectType: '', customerName: '', finalCustomerName: '', customerId: '', finalCustomerId: '', projectName: '', projectDesc: '', needDate: '', priority: '', projectSource: '', industry: '', priorityDesc: '', projectSourceDesc: '', industryDesc: '', projectManagerName: '', projectOwnerName: '', customerRemark: '', remark: '', userRoleName: '', projectManagerList: [], projectOwnerList: [], userRoleList: [], productSet: '', projectAmount: '', status: '草稿', stepId: 10, rejectFlag: 'N', createBy2: '', isReject: 'N' } this.plmProjectAuthorityArr = [] this.plmProjectTeamAuthorityArr = [] this.nodeAuthorityLoaded = true // 默认插入当前用户
this.addRollForUsername(this.$store.state.user.name,this.$store.state.user.userDisplay) // this.searchUserRollAll();
// 添加超级管理员角色
let params = { site: this.$store.state.user.site } queryUsernameByRoleSuperFlag(params).then(({data})=>{ if (data && data.code === 0){ let rows = [] rows = data.rows; rows.forEach(item => { this.addRollForUsername(item.username,item.userDisplay) }) } }) } if (requestCustomer) { this.initCustomer(requestCustomer) } this.visible = true },
searchUserRoll(){ let inData3={ site:this.dataForm.site, projectId:this.dataForm.projectId, username:this.userRoleForm.username, userDisplay:this.userRoleForm.userDisplay, checkList:this.dataForm.userRoleList, } this.queryUserRoleListLoading = true this.userRoleList = [] searchUserRoll(inData3).then(({data}) => { if (data && data.code === 0){ this.userRoleList = data.rows; }else { this.$message.warning(data.msg) } this.queryUserRoleListLoading = false }).catch((error)=>{ this.$message.error(error) this.queryUserRoleListLoading = false }) }, searchUserRollAll(){ let inData3={ site:this.dataForm.site, projectId:this.dataForm.projectId, } // searchUserRoll(inData3).then(({data}) => {
// this.dataForm.userRoleList=data.rows;
// // this.userRollModal();
// })
searchSelectionUserRole(inData3).then(({data})=>{ if (data && data.code === 0){ this.dataForm.userRoleList = data.rows; } }) }, managerChooseModal(){ let inData={ site:this.dataForm.site, projectId:this.dataForm.projectId, roleNo:'R001', } this.operatorList = []; searchOperatorWithSite(inData).then(({data}) => { this.operatorList=data.rows }) this.projectManagerList = JSON.parse(JSON.stringify(this.dataForm.projectManagerList)); this.managerFlag=true }, saveManagerList(){ let projectManagerName=''; let selectionManagerList = this.operatorList.filter((item) => { return this.projectManagerList.includes(item.operatorId); }) projectManagerName=selectionManagerList.map(item => item.operatorName).join(';'); for (let i = 0; i < selectionManagerList.length; i++) { let row = selectionManagerList[i] this.addRollForUsername(row.operatorId,row.operatorName) } this.dataForm.projectManagerName=projectManagerName this.dataForm.projectManagerList=JSON.parse(JSON.stringify(this.projectManagerList)); this.managerFlag=false }, ownerChooseModal(){ let inData={ site:this.dataForm.site, projectId:this.dataForm.projectId, roleNo:'R016', } this.operatorList = []; searchOperatorWithSite(inData).then(({data}) => { this.operatorList=data.rows }) this.projectOwnerList = JSON.parse(JSON.stringify(this.dataForm.projectOwnerList)); this.ownerFlag=true }, saveOwnerList(){ let projectOwnerName=''; let selectionOwnerList = this.operatorList.filter((item) => { return this.projectOwnerList.includes(item.operatorId); })
projectOwnerName=selectionOwnerList.map(item => item.operatorName).join(';');
for (let i = 0; i < selectionOwnerList.length; i++) { let row = selectionOwnerList[i] this.addRollForUsername(row.operatorId,row.operatorName) }
this.dataForm.projectOwnerName = projectOwnerName this.dataForm.projectOwnerList=JSON.parse(JSON.stringify(this.projectOwnerList)); this.ownerFlag=false }, addRollForUsername(username,userDisplay){ if(this.dataForm.userRoleList.length>0) { let checkList = this.dataForm.userRoleList.filter(item => item.username === username) if (checkList.length === 0) { this.dataForm.userRoleList.push({ checkAll: true, deleteCheck: true, deleteFlag: 'Y', downCheck: true, downFlag: 'Y', searchCheck: true, searchFlag: 'Y', updateCheck: true, updateFlag: 'Y', userDisplay: userDisplay, username: username, }) } }else { this.dataForm.userRoleList=[{ checkAll: true, deleteCheck: true, deleteFlag: 'Y', downCheck: true, downFlag: 'Y', searchCheck: true, searchFlag: 'Y', updateCheck: true, updateFlag: 'Y', userDisplay: userDisplay, username: username, }] } let selectionUserList = this.dataForm.userRoleList.filter(item => item.searchCheck || item.updateCheck || item.downCheck || item.deleteCheck) this.dataForm.userRoleName = selectionUserList.map(item => item.userDisplay).join(';'); }, userRollModal(){ this.searchUserRoll() this.userRoleFlag=true }, saveUserList(){ let name = ""; let selectionUserList = this.userRoleList.filter(item => item.searchCheck || item.updateCheck || item.downCheck || item.deleteCheck)
this.dataForm.userRoleList = [...selectionUserList] name = selectionUserList.map(item => item.userDisplay).join(";") // for (let i = 0; i <this.userRoleList.length ; i++) {
// if(this.userRoleList[i].username===this.$store.state.user.name){
// this.userRoleList[i].searchCheck=true;
// this.userRoleList[i].updateCheck=true;
// this.userRoleList[i].downCheck=true;
// this.userRoleList[i].deleteCheck=true;
// this.userRoleList[i].searchFlag='Y'
// this.userRoleList[i].updateFlag='Y'
// this.userRoleList[i].downFlag='Y'
// this.userRoleList[i].deleteFlag='Y'
// }
// }
// let name = '';
// for (let i = 0; i < this.userRoleList.length; i++) {
// this.dataForm.userRoleList=this.dataForm.userRoleList.filter(item => item.username !== this.userRoleList[i].username)
// if(this.userRoleList[i].searchCheck||this.userRoleList[i].updateCheck||this.userRoleList[i].downCheck||this.userRoleList[i].deleteCheck){
// this.dataForm.userRoleList.push(this.userRoleList[i])
// }
// }
// for (let i = 0; i < this.dataForm.userRoleList.length; i++) {
// if(this.dataForm.userRoleList[i].searchCheck||this.dataForm.userRoleList[i].updateCheck
// ||this.dataForm.userRoleList[i].downCheck||this.dataForm.userRoleList[i].deleteCheck){
// name+=this.dataForm.userRoleList[i].userDisplay+';'
// }
// }
this.dataForm.userRoleName = name // this.dataForm.userRoleList=JSON.parse(JSON.stringify(this.userRoleList));
this.userRoleFlag=false
}, changeAll(row){ if(row.checkAll){ row.searchCheck=true; row.updateCheck=true; row.downCheck=true; row.deleteCheck=true; row.searchFlag='Y' row.updateFlag='Y' row.downFlag='Y' row.deleteFlag='Y' }else { row.searchCheck=false; row.updateCheck=false; row.downCheck=false; row.deleteCheck=false; row.searchFlag='N' row.updateFlag='N' row.downFlag='N' row.deleteFlag='N' } }, changeCheck(row,type){ if(type==1){ if(row.searchCheck){ row.searchFlag='Y' }else { row.searchFlag='N' } } if(type==2){ if(row.updateCheck){ row.updateFlag='Y' }else { row.updateFlag='N' } } if(type==3){ if(row.downCheck){ row.downFlag='Y' }else { row.downFlag='N' } } if(type==4){ if(row.deleteCheck){ row.deleteFlag='Y' }else { row.deleteFlag='N' } } if(row.searchCheck && row.updateCheck && row.downCheck && row.deleteCheck){ row.checkAll=true }else{ row.checkAll=false } this.$forceUpdate(); },
// 表单提交
dataFormSubmit () { this.$refs.saveForm.validate((validate) => { if (validate) { this.dataForm.updateBy = this.$store.state.user.name saveProjectInfo(this.dataForm).then(({data}) => { if (data && data.code === 0) { this.$message.success( '操作成功') this.visible = false this.$emit('refreshDataList', data.projectId) } else { this.$message.error(data.msg) } }) } else { // if(!this.dataForm.projectTypeDb){
// this.$alert('请选择项目类型!', '错误', {
// confirmButtonText: '确定'
// })
// return false;
// }
if(!this.dataForm.customerId){ this.$alert('请选择直接客户!', '错误', { confirmButtonText: '确定' }) return false; } if(!this.dataForm.projectName){ this.$alert('请输入项目名称!', '错误', { confirmButtonText: '确定' }) return false; } // if(!this.dataForm.projectSource){
// this.$alert('请选择项目来源!', '错误', {
// confirmButtonText: '确定'
// })
// return false;
// }
// if(!this.dataForm.buDesc){
// this.$alert('请选择BU!', '错误', {
// confirmButtonText: '确定'
// })
// return false;
// }
// if(!this.dataForm.priority){
// this.$alert('请选择优先级!', '错误', {
// confirmButtonText: '确定'
// })
// return false;
// }
if(!this.dataForm.projectOwnerName){ this.$alert('请选择项目审批人!', '错误', { confirmButtonText: '确定' }) return false; } if(!this.dataForm.userRoleName){ this.$alert('请选择权限!', '错误', { confirmButtonText: '确定' }) return false; } } }) },
closeSaveDialog () { this.$refs.saveForm.resetFields(); },
isCurrentApprover () { return this.superAdmin || (this.dataForm.createBy2 && String(this.dataForm.createBy2).split(';').includes(this.createBy2)) }, canSaveAction () { if (this.dataForm.status === '已完成') { return false } if (!this.dataForm.status || this.dataForm.status === '草稿') { return true } return this.dataForm.status === '审批中' && this.isCurrentApprover() }, canAgreeAction () { return this.authSubmit && this.isCurrentApprover() && this.dataForm.status === '审批中' }, canRejectAction () { return this.authReject && this.isCurrentApprover() && this.dataForm.status === '审批中' && this.dataForm.isReject === 'Y' }, projectFieldFlag (fieldId) { if (!this.plmProjectAuthorityArr || this.plmProjectAuthorityArr.length === 0) { return this.dataForm.id ? 'N' : 'Y' } let target = this.plmProjectAuthorityArr.find(item => item.fieldId === fieldId) return target ? target.updateFlag : 'N' }, isProjectFieldDisabled (fieldId) { if (this.dataForm.status === '已完成') { return true } if (!this.dataForm.id) { return false } return this.projectFieldFlag(fieldId) === 'N' }, plmProjectTeamArrFlag (fieldId) { if (!this.plmProjectTeamAuthorityArr) { return 'N' } let arr = this.plmProjectTeamAuthorityArr.filter(a => a.fieldId === fieldId) if (arr.length > 0) { return arr[0].updateFlag } return 'N' }, isProjectTeamFieldDisabled (fieldId) { if (this.dataForm.status === '已完成') { return true } if (!this.dataForm.id || this.dataForm.status === '草稿') { return false } return this.plmProjectTeamArrFlag(fieldId) === 'N' }, loadNodeAuthority (site, stepId) { if (!site || stepId === null || stepId === undefined || !this.menuId) { this.plmProjectAuthorityArr = [] this.plmProjectTeamAuthorityArr = [] this.nodeAuthorityLoaded = true return Promise.resolve() } this.nodeAuthorityLoaded = false return getNodeAuthority({ site: site, stepId: stepId, menuId: this.menuId }).then(({data}) => { if (data && data.code === 0 && data.rows) { this.plmProjectAuthorityArr = data.rows.plm_project_info || [] this.plmProjectTeamAuthorityArr = data.rows.plm_project_team || [] } else { this.plmProjectAuthorityArr = [] this.plmProjectTeamAuthorityArr = [] } this.nodeAuthorityLoaded = true }).catch(() => { this.plmProjectAuthorityArr = [] this.plmProjectTeamAuthorityArr = [] this.nodeAuthorityLoaded = true }) }, validateSubmitRequiredFields () { if (this.plmProjectAuthorityArr) { for (let i = 0; i < this.plmProjectAuthorityArr.length; i++) { const fieldConfig = this.plmProjectAuthorityArr[i] if (fieldConfig.required !== 'Y') { continue } const value = this.dataForm[fieldConfig.fieldId] if (value === null || value === undefined || String(value).trim() === '') { this.$message.warning((fieldConfig.fieldName || fieldConfig.fieldId) + '不能为空!') return false } } } if (this.plmProjectTeamAuthorityArr) { for (let i = 0; i < this.plmProjectTeamAuthorityArr.length; i++) { const fieldConfig = this.plmProjectTeamAuthorityArr[i] if (fieldConfig.required !== 'Y') { continue } const value = this.dataForm[fieldConfig.fieldId] if (!value || value.length === 0) { this.$message.warning((fieldConfig.fieldName || fieldConfig.fieldId) + '不能为空!') return false } } } return true }, hasProjectManager () { if (this.dataForm.projectManagerList && this.dataForm.projectManagerList.length > 0) { return true } return !!(this.dataForm.projectManagerName && String(this.dataForm.projectManagerName).trim()) }, validateManagerRequiredFields () { if (!this.hasProjectManager()) { return true } const missing = [] if (this.dataForm.projectAmount === null || this.dataForm.projectAmount === undefined || String(this.dataForm.projectAmount).trim() === '') { missing.push('项目年销售额CNY(K)') } if (!this.dataForm.finalCustomerId || String(this.dataForm.finalCustomerId).trim() === '') { missing.push('直接客户') } if (!this.dataForm.customerRemark || String(this.dataForm.customerRemark).trim() === '') { missing.push('客户应用/要求') } if (missing.length) { this.$message.warning('项目经理不为空时,' + missing.join('、') + '不能为空') return false } return true }, agreeSubmit () { if (!this.canAgreeAction()) { this.$message.warning('当前状态不允许同意') return } this.$confirm('确认同意该项目?', '提示', { confirmButtonText: '确定', cancelButtonText: '取消', type: 'warning' }).then(() => { this.submitProject('Y') }) }, openRejectModal () { if (!this.canRejectAction()) { this.$message.warning('当前状态不允许驳回') return } if (!this.validateManagerRequiredFields()) { return } this.rejectOpinion = '' this.submitModalFlag = true }, rejectSubmit () { if (!this.rejectOpinion || !this.rejectOpinion.trim()) { this.$message.warning('请填写驳回意见') return } this.submitProject('N') }, submitProject (nodeConclusion) { if (!this.nodeAuthorityLoaded) { this.$message.warning('节点权限加载中,请稍后重试') return } if (!this.validateManagerRequiredFields()) { return } if (nodeConclusion === 'Y' && !this.validateSubmitRequiredFields()) { return } this.submitLoading = true submitProjectInfo({ ...this.dataForm, nodeConclusion: nodeConclusion, rejectOpinion: this.rejectOpinion, menuId: this.menuId }).then(({data}) => { this.submitLoading = false if (data && data.code === 0) { this.$message.success(nodeConclusion === 'Y' ? '同意成功' : '驳回成功') this.submitModalFlag = false this.visible = false this.$emit('refreshDataList', this.dataForm.projectId) } else { this.$message.error((data && data.msg) || '提交失败') } }).catch(err => { this.submitLoading = false this.$message.error((err && err.message) || '提交失败') }) },
updateDataForm (val) { this.dataForm.projectId = val; },
initCustomer (row) { this.dataForm.customerId = row.customerId; this.dataForm.customerName = row.customerName; },
changeSaveCheckAll (val) { for (let i = 0; i < this.userRoleList.length; i++) { let row = this.userRoleList[i] row.checkAll = (val === 'Y') this.changeAll(row) } },
getCustomerName(type){ if(type===1){ let params = { site:this.$store.state.user.site, customerNo:this.dataForm.customerId } queryCustomer(params).then(({data})=>{ if (data && data.code === 0 ) { if (data.rows && data.rows.length === 1){ this.dataForm.customerName = data.rows[0].customerDesc }else { this.dataForm.customerName = '' } }else { this.$message.warning(data.msg) } }).catch((error)=>{ this.$message.error(error) }) } if(type===2){ let params = { site:this.$store.state.user.site, customerNo:this.dataForm.finalCustomerId } queryCustomer(params).then(({data})=>{ if (data && data.code === 0 ) { if (data.rows && data.rows.length === 1){ this.dataForm.finalCustomerName = data.rows[0].customerDesc }else { this.dataForm.finalCustomerName = '' } }else { this.$message.warning(data.msg) } }).catch((error)=>{ this.$message.error(error) }) } }, }, }</script>
<style > .el-transfer-panel { border: 2px solid #17b3a3; border-radius: 4px; overflow: hidden; background: #fff; display: inline-block; vertical-align: middle; width: 200px; max-height: 100%; -webkit-box-sizing: border-box; box-sizing: border-box; position: relative; }
.el-transfer-panel .el-transfer-panel__header { height: 40px; line-height: 40px; background: #17b3a3; margin: 0; padding-left: 15px; border-bottom: 1px solid #17b3a3; -webkit-box-sizing: border-box; box-sizing: border-box; color: #000; }
.el-transfer-panel .el-transfer-panel__header .el-checkbox .el-checkbox__label { font-size: 14px; color: #303133; font-weight: 400; }
.el-textarea .el-textarea__inner { padding: 0px 5px; height: auto; }
.project-amount-form-item .el-form-item__label { overflow: visible; }
.project-amount-label { display: inline-block; width: 160px; white-space: nowrap; }
</style>
|