绩效考核PC端
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.
 
 
 

756 lines
36 KiB

<!--
@ 作者: 秦东
@ 时间: 2023-03-22 10:18:00
@ 备注: 条件设置
-->
<template>
<el-drawer :append-to-body="true" title="条件设置" :visible.sync="conditionDrawer" direction="rtl" class="condition_copyer" size="550px" :before-close="saveCondition">
<select v-model="conditionConfig.priorityLevel" class="priority_level">
<option v-for="item in conditionsConfig.conditionNodes.length" :value="item" :key="item">优先级{{item}}</option>
</select>
<div class="demo-drawer__content">
<div class="condition_content drawer_content">
<p class="tip">当审批单同时满足以下条件时进入此流程</p>
<ul>
<li v-for="(item,index) in conditionConfig.conditionList" :key="index">
<el-row>
<el-col :span="5"><span class="ellipsis">{{item.type==1?'发起人':item.showName}}:</span></el-col>
<el-col :span="17">
<div v-if="item.type==1">
<p :class="conditionConfig.nodeUserList.length > 0?'selected_list':''" @click.self="addConditionRole" style="cursor:text">
<span v-for="(item1,index1) in conditionConfig.nodeUserList" :key="index1">
{{item1.name}}<img src="@/assets/images/add-close1.png" @click="$func.removeEle(conditionConfig.nodeUserList,item1,'targetId')">
</span>
<input type="text" placeholder="请选择具体人员/角色/部门" v-if="conditionConfig.nodeUserList.length == 0" @click="addConditionRole">
</p>
</div>
<div v-else-if="item.columnType == 'String' && item.showType == 'checkBox'">
<p class="check_box">
<a :class="$func.toggleStrClass(item,item1.key)&&'active'" @click="toStrChecked(item,item1.key)"
v-for="(item1,index1) in JSON.parse(item.fixedDownBoxValue)" :key="index1">{{item1.value}}</a>
</p>
</div>
<div v-else-if="item.type==4" >
<el-row v-for="(item69,index69) in item.condition" :key="index69" :gutter="2">
<el-col :span="24" class="bottor_piayi">
<el-row>
<el-col :span="6">
<el-input v-model="item69.wordfield" placeholder="判断关键字"></el-input>
</el-col>
<el-col :span="item69.optType != 6?7:16">
<select v-model="item69.optType" style="width:100%" @change="myoptChhange($event,item69)">
<option value="1">小于</option>
<option value="2">大于</option>
<option value="3">小于等于</option>
<option value="4">等于</option>
<option value="5">大于等于</option>
<option value="6">介于两个数之间</option>
<option value="7">包含</option>
<option value="8">不包含</option>
</select>
</el-col>
<el-col v-if="item69.optType != 6" :span="9">
<el-input v-model="item69.factor.leftval" placeholder="请输入值"></el-input>
</el-col>
<el-col :span="2">
<el-button type="danger" icon="el-icon-delete" size="mini" circle style="margin-bottom:0px" @click="delmyCondition(index69,item.condition)"></el-button>
</el-col>
</el-row>
</el-col>
<el-col v-if="item69.optType == 6" :span="24" class="bottor_piayi">
<el-row>
<el-col :span="5">
<input type="text" style="width:75px;" class="mr_10" v-model="item69.factor.leftval" placeholder="请输入">
</el-col>
<el-col :span="5">
<select style="width:60px;" v-model="item69.factor.leftoptType">
<option value="1">&lt;</option>
<option value="3">≤</option>
</select>
</el-col>
<el-col :span="4">
<span class="ellipsis" style="display:inline-block;width:60px;vertical-align: text-bottom;">{{item69.wordfield}}</span>
</el-col>
<el-col :span="5">
<select style="width:60px;" class="ml_10" v-model="item69.factor.rightoptType">
<option value="1">&lt;</option>
<option value="3">≤</option>
</select>
</el-col>
<el-col :span="5">
<input type="text" style="width:75px;" class="mr_10" v-model="item69.factor.rightval" placeholder="请输入">
</el-col>
</el-row>
</el-col>
</el-row>
<el-button type="primary" size="mini" plain @click="addConditionEs(item.condition)">添加条件</el-button>
</div>
<div v-else-if="item.type==3">
<el-button v-for="(item1,index1) in JSON.parse(item.fixedDownBoxValue)" :key="index1" type="text" style="padding: 6px 5px;" @click="openDataTable(item1,item)">{{item1.name}}</el-button>
</div>
</el-col>
<el-col :span="2" style="text-align: right;">
<!-- <a v-if="item.type==1" @click="conditionConfig.nodeUserList= [];$func.removeEle(conditionConfig.conditionList,item,'columnId')">删除</a>
<a v-if="item.type==2" @click="$func.removeEle(conditionConfig.conditionList,item,'columnId')">删除</a>
<a v-if="item.type==3" @click="conditionWordList=[];$func.removeEle(conditionConfig.conditionList,item,'columnId')">删除</a> -->
<el-button v-if="item.type==1" type="danger" icon="el-icon-delete" size="mini" circle @click="conditionConfig.nodeUserList= [];$func.removeEle(conditionConfig.conditionList,item,'columnId')"></el-button>
<el-button v-if="item.type==2" type="danger" icon="el-icon-delete" size="mini" circle @click="$func.removeEle(conditionConfig.conditionList,item,'columnId')"></el-button>
<el-button v-if="item.type==3" type="danger" icon="el-icon-delete" size="mini" circle @click="conditionWordList=[];$func.removeEle(conditionConfig.conditionList,item,'columnId')"></el-button>
</el-col>
</el-row>
<div v-if="item.type==3" style="width:100%">
<el-row v-for="item4 in conditionWordList" :key="item4.tablekey" style="width:99%">
<el-col :span="4" style="word-wrap:break-word; word-break:break-all;">
数据表<br>{{ item4.tablekey }}
</el-col>
<el-col :span="20">
<el-row class="wordbody" v-for="item3 in item4.wordlist" :key="item3.tablekey" :gutter="5">
<el-col :span="6" style="word-wrap:break-word; word-break:break-all;">字段:{{ item3.key }}</el-col>
<el-col :span="6">
<select v-model="item3.notation" style="width:100%" @change="equationChanage($event,item3)">
<option v-if="item3.type=='int'" value="1">小于</option>
<option v-if="item3.type=='int'" value="2">大于</option>
<option v-if="item3.type=='int'" value="3">小于等于</option>
<option v-if="item3.type=='int'" value="4">等于</option>
<option v-if="item3.type=='int'" value="5">大于等于</option>
<option v-if="item3.type=='int'" value="6">介于两个数之间</option>
<option v-if="item3.type=='string'" value="in">包含</option>
<option v-if="item3.type=='string'" value="notin">不包含</option>
</select>
</el-col>
<el-col :span="10">
<input v-if="item3.notation != 6" v-model="item3.equation.letfval" type="text" placeholder="请输入" style="width:100%">
</el-col>
<el-col :span="2">
<el-button type="danger" icon="el-icon-delete" size="mini" circle @click="$func.removeEle(item4.wordlist,item3,'key')"></el-button>
</el-col>
<el-col v-if="item3.notation == 6" :span="24" class="wordbody" >
<input type="text" style="width:75px;" class="mr_10" v-model="item3.equation.letfval">
<select style="width:60px;" v-model="item3.equation.leftnotation">
<option value="1">&lt;</option>
<option value="3">≤</option>
</select>
<span class="ellipsis" style="display:inline-block;width:60px;vertical-align: text-bottom;">{{item3.key}}</span>
<select style="width:60px;" class="ml_10" v-model="item3.equation.rightnotation">
<option value="1">&lt;</option>
<option value="3">≤</option>
</select>
<input type="text" style="width:75px;" v-model="item3.equation.rightval">
</el-col>
<el-col :span="24" class="wordbody" >
描述:{{ item3.comment }}
</el-col>
</el-row>
</el-col>
</el-row>
</div>
</li>
</ul>
<el-button type="primary" @click="addCondition">添加条件</el-button>
<el-dialog title="选择条件" :visible.sync="conditionVisible" width="480px" append-to-body class="condition_list">
<p>请选择用来区分审批流程的条件字段</p>
<p class="check_box">
<a :class="$func.toggleClass(conditionList,{columnId:0},'columnId')&&'active'" @click="$func.toChecked(conditionList,{columnId:0},'columnId')">发起人</a>
<a v-for="(item,index) in conditions" :key="index" :class="$func.toggleClass(conditionList,item,'columnId')&&'active'"
@click="$func.toChecked(conditionList,item,'columnId')">{{item.showName}}</a>
</p>
<span slot="footer" class="dialog-footer">
<el-button @click="conditionVisible = false">取 消</el-button>
<el-button type="primary" @click="sureCondition">确 定</el-button>
</span>
</el-dialog>
<!--选择数据表-->
<el-dialog title="选择表及条件字段" :visible.sync="tabelDialog" width="480px" append-to-body class="condition_list">
<template>
<el-select v-model="dataBaseTable" placeholder="请选择数据表!" style="width:100%" @change="tableChange">
<el-option
v-for="item in dataBaseTableList"
:key="item.key"
:label="item.name"
:value="item.key">
</el-option>
</el-select>
</template>
<template>
<el-table
:data="tableDataBaseWord"
border
ref="multipleTable"
tooltip-effect="dark"
@selection-change="handleSelectionChange"
style="width: 100%" height="500">
<el-table-column
type="selection"
width="55">
</el-table-column>
<el-table-column
prop="field"
label="表名"
>
</el-table-column>
<el-table-column
prop="type"
label="类型"
>
</el-table-column>
<el-table-column
prop="comment"
label="描述">
</el-table-column>
</el-table>
</template>
<span slot="footer" class="dialog-footer">
<el-button @click="tabelDialog = false">取 消</el-button>
<el-button type="primary" @click="sureTabelWords">确 定</el-button>
</span>
</el-dialog>
</div>
<employeesRoleDialog
:visible.sync="conditionRoleVisible"
:data.sync="checkedList"
@change="sureConditionRole"
:isDepartment="true"
/>
<div class="demo-drawer__footer clear">
<el-button type="primary" @click="saveCondition">确 定</el-button>
<el-button @click="setCondition(false)">取 消</el-button>
</div>
</div>
</el-drawer>
</template>
<script>
import { mapState, mapMutations } from 'vuex'
import employeesRoleDialog from '@/customworkflow/dialog/employeesRoleDialog'
import { getConditions,getDataBaseTable,getDataBaseTableCont } from "@/api/workflowapi/workflowaip"
export default {
components: {
employeesRoleDialog
},
data() {
return {
conditionsConfig: {
conditionNodes: [],
}, //条件数据
PriorityLevel: "", //优先等级
conditionConfig: {},
conditionRoleVisible: false, //选择成员或角色弹窗
checkedList: [], //选择成员或角色弹窗内容
conditionList:[], //添加条件
conditionVisible: false, //条件弹窗
conditions: [], //获取API值
databaseradio:"", //数据库
tabelDialog:false, //选择表及字段弹窗
dataBaseTable:"", //数据表
dataBaseTableList:[], //数据表数组
tableDataBaseWord:[], //数据表字段列表
sureTableWords:[], //被选中得字段
conditionWordList:[], //数据表条件列表
}
},
created(){
},
computed: {
...mapState(['tableId', 'conditionsConfig1', 'conditionDrawer']),
},
watch: {
conditionsConfig1(val) {
this.conditionsConfig = val.value;
this.PriorityLevel = val.priorityLevel
this.conditionConfig = val.priorityLevel
? this.conditionsConfig.conditionNodes[val.priorityLevel - 1]
: { nodeUserList: [], conditionList: [] }
},
},
methods:{
...mapMutations(['setCondition', 'setConditionsConfig']),
//保存条件
saveCondition(){
console.log("保存条件--->",this.conditionWordList)
console.log("保存条件--1->",this.conditionsConfig)
this.conditionConfig.databasecondition = this.conditionWordList
var a = this.conditionsConfig.conditionNodes.splice(this.PriorityLevel - 1, 1)//截取旧下标
this.conditionsConfig.conditionNodes.splice(this.conditionConfig.priorityLevel - 1, 0, a[0])//填充新下标
this.conditionsConfig.conditionNodes.map((item, index) => {
item.priorityLevel = index + 1
});
let isOk = true
for (var i = 0; i < this.conditionsConfig.conditionNodes.length; i++) {
this.conditionsConfig.conditionNodes[i].error = this.$func.conditionStr(this.conditionsConfig, i) == "请设置条件" && i != this.conditionsConfig.conditionNodes.length - 1
if(this.conditionsConfig.conditionNodes[i].conditionList.length > 0){
this.conditionsConfig.conditionNodes[i].conditionList.forEach(itan =>{
if(itan.columnType == "custom"){
if(itan.condition.length > 0){
itan.condition.forEach(itansun => {
if(itansun.wordfield=="" || itansun.wordfield==null){
isOk = false
}
})
}
}
})
}
}
if(!isOk){
this.$alert('自定义判断条件有未填写的内容!', '温馨提示', {
dangerouslyUseHTMLString: true
});
return false;
}
this.setConditionsConfig({
value: this.conditionsConfig,
flag: true,
id: this.conditionsConfig1.id
})
// this.setCondition(false)
this.setCondition(false); //关闭弹窗
},
//选择成员或角色弹窗值变化时操作
sureConditionRole(data) {
this.conditionConfig.nodeUserList = data;
this.conditionRoleVisible = false;
},
//添加条件
async addCondition() {
this.conditionList = [];
this.conditionVisible = true;
let { data } = await getConditions({ tableId: this.tableId })
this.conditions = data;
console.log("添加条件--->",this.conditionConfig.conditionList,this.conditions)
if (this.conditionConfig.conditionList) {
for (var i = 0; i < this.conditionConfig.conditionList.length; i++) {
var { columnId } = this.conditionConfig.conditionList[i]
if (columnId.toString() == "0") {
this.conditionList.push({ columnId: 0 })
} else {
// console.log("添加条件-1-->",this.conditionList)
// this.conditions.filter(item=>{
// console.log("添加条件-222-->",columnId,item.columnId)
// if(item.columnId == columnId.toString()){
// console.log("添加条件-2-->",columnId,item)
// this.conditionList.push(columnId)
// }
// })
// console.log("添加条件-1-->",this.conditionList)
this.conditionList.push(this.conditions.filter(item => item.columnId == columnId)[0])
// console.log("添加条件-3-->",this.conditionList)
}
}
}
},
//确定条件类型
sureCondition() {
//1.弹窗有,外面无+
//2.弹窗有,外面有不变
for (var i = 0; i < this.conditionList.length; i++) {
var { columnId, showName, columnName, showType, columnType, fixedDownBoxValue } = this.conditionList[i];
if (this.$func.toggleClass(this.conditionConfig.conditionList, this.conditionList[i], "columnId")) {
continue;
}
if (columnId == 0) {
this.conditionConfig.nodeUserList == [];
this.conditionConfig.conditionList.push({
"type": 1,
columnId,
"showName": '发起人'
});
} else {
if (columnType == "Double") {
this.conditionConfig.conditionList.push({
showType,
columnId,
"type": 2,
showName,
"optType": "1",
"zdy1": "2",
"opt1": "<",
"zdy2": "",
"opt2": "<",
"columnDbname": columnName,
columnType,
})
} else if (columnType == "String" && showType == "checkBox") {
this.conditionConfig.conditionList.push({
showType,
columnId,
"type": 2,
showName,
"zdy1": "",
"columnDbname": columnName,
columnType,
fixedDownBoxValue
})
} else if (showType == "datatable") {
this.conditionConfig.conditionList.push({
showType,
columnId,
"type": 3,
showName,
"columnDbname": columnName,
columnType,
fixedDownBoxValue,
databasecondition:[] //判断条件字段
})
}else if(columnType == "custom"){
this.conditionConfig.conditionList.push({
showType,
"type": 4,
columnId,
showName,
columnType,
condition:[
{
wordfield:"",
optType:"1",
factor:{
leftoptType:"1",
leftval:"",
rightoptType:"1",
rightval:""
}
}
]
});
}else{
this.conditionConfig.conditionList.push({
showType,
columnId,
"type": 5,
showName,
"zdy1": "",
"columnDbname": columnName,
columnType,
fixedDownBoxValue
})
}
}
}
//3.弹窗无,外面有-
for (let i = this.conditionConfig.conditionList.length - 1; i >= 0; i--) {
if (!this.$func.toggleClass(this.conditionList, this.conditionConfig.conditionList[i], "columnId")) {
this.conditionConfig.conditionList.splice(i, 1);
}
}
this.conditionConfig.conditionList.sort(function (a, b) { return a.columnId - b.columnId; });
this.conditionVisible = false;
this.conditionWordList=[]
},
//条件类型一
addConditionRole() {
this.conditionRoleVisible = true;
this.checkedList = this.conditionConfig.nodeUserList
},
//选择选项
toStrChecked(item, key) {
let a = item.zdy1 ? item.zdy1.split(",") : []
var isIncludes = this.$func.toggleStrClass(item, key);
if (!isIncludes) {
a.push(key)
item.zdy1 = a.toString()
} else {
this.removeStrEle(item, key);
}
},
//单选项目
async toCheckRadio(){
let { data } = await getDataBaseTable({ name: this.databaseradio })
this.dataBaseTableList = data
if(this.dataBaseTableList.length > 0){
this.dataBaseTable= this.dataBaseTableList[0].key
}
console.log("单选项目---->",this.databaseradio,data)
this.getDataBaseTableWord();
this.tabelDialog = true
},
//打开数据库选择数据表弹窗
async openDataTable(val){
this.databaseradio = val.key
let { data } = await getDataBaseTable({ name: val.key })
this.dataBaseTableList = data
if(this.dataBaseTableList.length > 0){
this.dataBaseTable= this.dataBaseTableList[0].key
console.log("单选项目---1->",this.dataBaseTableList[0].key)
}
console.log("单选项目---->",val,this.dataBaseTable)
this.getDataBaseTableWord();
this.tabelDialog = true
},
//获取表字段
async getDataBaseTableWord(){
console.log("获取表字段---->",this.databaseradio,this.dataBaseTable)
var sendCont = {
databasename:this.databaseradio,
tablesname:this.dataBaseTable
}
console.log("获取表字段---->",sendCont)
let { data } = await getDataBaseTableCont(sendCont)
this.tableDataBaseWord = data
console.log("获取表字段---->",this.databaseradio,data)
},
//选中的字段
handleSelectionChange(val) {
console.log("选中的字段---->",val)
this.sureTableWords = val
},
//改变选择表格
tableChange(){
this.getDataBaseTableWord();
},
//确定选中得字段
sureTabelWords(){
console.log("确定选中得字段---->",this.sureTableWords)
// this.conditionWordList = []
let wordList = new Array
this.sureTableWords.forEach(item=>{
let equation = "4"
if(item.type != "int"){
equation = "in"
}
let wordCont = {
key:item.field,
type:item.type,
comment:item.comment,
notation:equation,
equation:{
leftnotation:equation,
letfval:"",
rightnotation:"1",
rightval:""
}
}
wordList.push(wordCont)
})
console.log("确定选中得字段--1->",wordList)
if(this.conditionWordList.length > 0 && this.judjeInAry(this.conditionWordList)){
this.conditionWordList.forEach(item1=>{
if(this.dataBaseTable == item1.tablekey && this.databaseradio == item1.databasename){
console.log("确定选中得字段--3->",wordList)
if(item1.wordlist.length > 0){
wordList.forEach(itmCont=>{
item1.wordlist.push(itmCont)
})
}else{
item1.wordlist = wordList
}
}
})
}else{
console.log("确定选中得字段--2->",wordList)
this.conditionWordList.push({
databasename:this.databaseradio,
tablekey: this.dataBaseTable,
wordlist: wordList
});
}
this.closeSureTableWords();
},
//关闭选择数据库弹窗
closeSureTableWords(){
this.tabelDialog = false;
},
//判断是否再数组中存在
judjeInAry(ary = new Array){
let isTrue = false;
console.log("判断是否再数组中存在--2->",ary)
ary.forEach(item1=>{
console.log("判断是否再数组中存在-1-->",item1.tablekey,item1.databasename,this.dataBaseTable,this.databaseradio)
if(this.dataBaseTable == item1.tablekey && this.databaseradio == item1.databasename){
isTrue = true;
}
})
console.log("判断是否再数组中存在--->",isTrue)
return isTrue
},
//等式取值
equationChanage(val,subent){
console.log("等式取值--->",val.target.value,subent)
if(val.target.value == "6"){
subent.equation.leftnotation = "1"
subent.equation.letfval = ""
subent.equation.rightnotation = "1"
subent.equation.rightval = ""
}
},
//删除选中得表单字段
delwordkey(val,contList){
console.log("删除选中得表单字段--->",val,contList)
let guoDu = new Array
if(contList.length > 0){
contList.forEach(item=>{
if(item.key != val.key){
guoDu.push(item)
}
})
}
contList = guoDu
console.log("删除选中得表单字段--->",val,contList)
},
//添加条件
addConditionEs(val){
val.push({
wordfield:"",
optType:"1",
factor:{
leftoptType:"1",
leftval:"",
rightoptType:"1",
rightval:""
}
});
},
//自定义条件选择
myoptChhange(val,objCont){
if(val.target.value != 6){
objCont.factor.leftoptType = val.target.value
}
},
//删除条件
delmyCondition(includesIndex,condAry){
condAry.splice(includesIndex, 1);
},
}
}
</script>
<style lang="less">
.condition_copyer {
.el-drawer__body {
.priority_level {
position: absolute;
top: 11px;
right: 30px;
width: 100px;
height: 32px;
background: rgba(255, 255, 255, 1);
border-radius: 4px;
border: 1px solid rgba(217, 217, 217, 1);
}
}
.condition_content {
padding: 20px 20px 0;
p.tip {
margin: 20px 0;
width: 510px;
text-indent: 17px;
line-height: 45px;
background: rgba(241, 249, 255, 1);
border: 1px solid rgba(64, 163, 247, 1);
color: #46a6fe;
font-size: 14px;
}
ul {
max-height: 500px;
overflow-y: scroll;
margin-bottom: 20px;
li {
&>span {
float: left;
margin-right: 8px;
width: 100px;
line-height: 32px;
text-align: right;
}
&>div {
display: inline-block;
width: 100%;
&>p:not(:last-child) {
margin-bottom: 10px;
}
}
&:not(:last-child)>div>p {
margin-bottom: 20px;
}
&>a {
float: right;
margin-right: 10px;
margin-top: 7px;
}
.condition_content {
padding: 5px 0;
}
select,
input {
width: 100%;
height: 32px;
background: rgba(255, 255, 255, 1);
border-radius: 4px;
border: 1px solid rgba(217, 217, 217, 1);
padding: 0;
}
select+input {
width: 260px;
}
select {
margin-right: 10px;
width: 100px;
}
p.selected_list {
padding-left: 10px;
border-radius: 4px;
min-height: 32px;
border: 1px solid rgba(217, 217, 217, 1);
word-break: break-word;
}
p.check_box {
line-height: 32px;
}
}
}
.el-button {
margin-bottom: 20px;
}
}
}
.condition_list {
.el-dialog__body {
padding: 16px 26px;
}
p {
color: #666666;
margin-bottom: 10px;
&>.check_box {
margin-bottom: 0;
line-height: 36px;
}
}
}
.wordbody{
padding: 5px 0;
}
.bottor_piayi{
margin-bottom: 10px;
}
</style>