|
@@ -2,9 +2,13 @@
|
|
|
<div :class="ui" class="hc-tasks-user">
|
|
|
<div class="tasks-user-box">
|
|
|
<div class="tag-user-list" @click="showModalClick">
|
|
|
- <template v-for="(item, index) in UserDataList" :key="index">
|
|
|
+ <!-- <template v-for="(item, index) in UserDataList" :key="index">
|
|
|
<el-tag>{{ setCheckboxUserName(item) }}</el-tag>
|
|
|
<HcIcon v-if="(UserDataList.length - 1) > index" name="arrow-right" ui="arrow-icon-tag" />
|
|
|
+ </template> -->
|
|
|
+ <template v-for="(item, index) in fixedBranchList" :key="index">
|
|
|
+ <el-tag>{{ item.name }}</el-tag>
|
|
|
+ <HcIcon v-if="(UserDataList.length - 1) > index" name="arrow-right" ui="arrow-icon-tag" />
|
|
|
</template>
|
|
|
<div v-if="UserDataList.length <= 0" class="tasks-placeholder">点击这里选择任务人</div>
|
|
|
</div>
|
|
@@ -20,13 +24,13 @@
|
|
|
<el-button type="primary" size="default" @click="addTaskName">添加</el-button>
|
|
|
</div>
|
|
|
<div class="task-list-box">
|
|
|
- <div v-for="(item, index) in taskNameList" class="task-list-box-item">
|
|
|
+ <div v-for="(item, index) in fixedBranchList" class="task-list-box-item">
|
|
|
<el-tooltip :content="item.type === 2 ? '流程审批' : '平行审批'" placement="right">
|
|
|
- <el-button size="default">
|
|
|
- {{ item.title }}
|
|
|
+ <el-button size="default" :color="curItem?.name === item.name ? 'orange' : ''" @click="chekckTask(item)">
|
|
|
+ {{ item.name }}
|
|
|
<HcIcon v-if="item.type === 1" name="links" class="ml-2" @click="item.type = 2" />
|
|
|
<HcIcon v-if="item.type === 2" name="exchange-2" class="ml-2" @click="item.type = 1" />
|
|
|
- <HcIcon name="close" class="ml-2" @click="delTask(index)" />
|
|
|
+ <HcIcon name="close" class="ml-2" @click="delTask(item, index)" />
|
|
|
</el-button>
|
|
|
</el-tooltip>
|
|
|
</div>
|
|
@@ -124,8 +128,9 @@
|
|
|
<script setup>
|
|
|
import { onMounted, ref, watch } from 'vue'
|
|
|
import tasksFlowApi from '~api/tasks/flow'
|
|
|
-import { deepClone, getArrValue } from 'js-fast-way'
|
|
|
+import { arrToKey, deepClone, getArrValue } from 'js-fast-way'
|
|
|
import Draggable from 'vuedraggable'
|
|
|
+import { delMessage } from '~uti/tools'
|
|
|
|
|
|
//参数
|
|
|
const props = defineProps({
|
|
@@ -150,6 +155,15 @@ const props = defineProps({
|
|
|
type:Boolean,
|
|
|
default:false,
|
|
|
},
|
|
|
+ id:{
|
|
|
+ type: [String, Number],
|
|
|
+ default: '', //预设流程ID
|
|
|
+ },
|
|
|
+ fixedBranchList:{
|
|
|
+ type:Array,
|
|
|
+ default: () => ([]),
|
|
|
+ },
|
|
|
+
|
|
|
})
|
|
|
//事件
|
|
|
const emit = defineEmits(['change'])
|
|
@@ -161,6 +175,8 @@ const checkboxUserList = ref([])
|
|
|
const UserDataList = ref([])
|
|
|
const projectId = ref(props.projectId)
|
|
|
const contractId = ref(props.contractId)
|
|
|
+const id = ref(props.id)
|
|
|
+const fixedBranchList = ref(props.fixedBranchList)
|
|
|
|
|
|
//树数据
|
|
|
const ElTreeProps = { children: 'childRoleList', label: 'roleName' }
|
|
@@ -177,21 +193,79 @@ watch(() => [
|
|
|
props.projectId,
|
|
|
props.contractId,
|
|
|
props.isShowTaskName,
|
|
|
-], ([users, pid, cid, ishow]) => {
|
|
|
+ props.id,
|
|
|
+ props.fixedBranchList,
|
|
|
+], ([users, pid, cid, ishow, Id, list]) => {
|
|
|
projectId.value = pid
|
|
|
contractId.value = cid
|
|
|
setUserDataList(users)
|
|
|
isShowTaskName.value = ishow
|
|
|
+ id.value = Id
|
|
|
+ fixedBranchList.value = list
|
|
|
+ fixedBranchList.value.forEach((ele)=>{
|
|
|
+ let userList = getArrValue(ele.userList)
|
|
|
+ let userIds = arrToKey(userList, 'userId', ',') // '1,2,3'
|
|
|
+ ele.userIds = userIds
|
|
|
+ let users = ''
|
|
|
+ for (let index = 0; index < userList.length; index++) {
|
|
|
+ const element = userList[index]
|
|
|
+ if (users) {
|
|
|
+ users += `,${element['userName']}-${element['userId']}`
|
|
|
+ } else {
|
|
|
+ users = `${element['userName']}-${element['userId']}`
|
|
|
+ }
|
|
|
+ }
|
|
|
+ ele.users = users
|
|
|
+ delete ele.userList
|
|
|
+ })
|
|
|
+ console.log(fixedBranchList.value, 'fixedBranchList.value')
|
|
|
+ if ( fixedBranchList.value.length > 0) {
|
|
|
+ curItem.value = fixedBranchList.value[0]
|
|
|
+ }
|
|
|
+})
|
|
|
+//监听
|
|
|
+watch(() => [
|
|
|
+ checkboxUserList.value,
|
|
|
+], ([list]) => {
|
|
|
+
|
|
|
+ console.log(list, 'list')
|
|
|
+ let newUser = [], newUserId = [], users = ''
|
|
|
+ const dataList = deepClone(checkboxUserList.value)
|
|
|
+ UserDataList.value = dataList
|
|
|
+ if (dataList.length > 0) {
|
|
|
+
|
|
|
+ //封装数据
|
|
|
+ dataList.forEach(item => {
|
|
|
+ const itemArr = item.split('-')
|
|
|
+ if (itemArr.length > 0 && itemArr[0]) {
|
|
|
+ users = users ? `${users},${item}` : item
|
|
|
+ newUser.push({
|
|
|
+ userId: itemArr[1],
|
|
|
+ userName: itemArr[0],
|
|
|
+ })
|
|
|
+ newUserId.push(itemArr[1])
|
|
|
+ }
|
|
|
+ })
|
|
|
+ console.log(users, 'users')
|
|
|
+ if ( curItem.value) {
|
|
|
+ curItem.value.userIds = newUserId.join(',')
|
|
|
+ curItem.value.users = users
|
|
|
+ }
|
|
|
+
|
|
|
+
|
|
|
+ }
|
|
|
})
|
|
|
|
|
|
//渲染完成
|
|
|
onMounted(() => {
|
|
|
setUserDataList(props.users)
|
|
|
queryAllRoleList()
|
|
|
+
|
|
|
})
|
|
|
|
|
|
//处理用户数据
|
|
|
const setUserDataList = (users) => {
|
|
|
+ console.log(users, 'users')
|
|
|
if (users) {
|
|
|
const usersArr = users.split(',')
|
|
|
UserDataList.value = usersArr
|
|
@@ -282,10 +356,19 @@ const upSortClick = (index) => {
|
|
|
//确认选择
|
|
|
const sureSignUserLoading = ref(false)
|
|
|
const sureSignUserClick = () => {
|
|
|
- let newUser = [], newUserId = [], users = ''
|
|
|
+ console.log(fixedBranchList.value, 'fixedBranchList.value3333333')
|
|
|
+ let isEmptyuserIds = fixedBranchList.value.some(obj => obj.userIds === '')
|
|
|
+ if (isEmptyuserIds) {
|
|
|
+ window.$message.warning('请选择对应的任务人员')
|
|
|
+ return
|
|
|
+ } else if (fixedBranchList.value.length === 0) {
|
|
|
+ window.$message.warning('请选择对应的任务人员和任务名称')
|
|
|
+ return
|
|
|
+ } else {
|
|
|
+ let newUser = [], newUserId = [], users = ''
|
|
|
const dataList = deepClone(checkboxUserList.value)
|
|
|
UserDataList.value = dataList
|
|
|
- if (dataList.length > 0) {
|
|
|
+
|
|
|
sureSignUserLoading.value = true
|
|
|
//封装数据
|
|
|
dataList.forEach(item => {
|
|
@@ -301,38 +384,48 @@ const sureSignUserClick = () => {
|
|
|
})
|
|
|
showModal.value = false
|
|
|
sureSignUserLoading.value = false
|
|
|
- emit('change', newUser, newUserId, users)
|
|
|
- } else {
|
|
|
- window.$message?.warning('请先选择任务人员,或点击取消')
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+ console.log(fixedBranchList.value, fixedBranchList.value)
|
|
|
+ emit('change', fixedBranchList.value)
|
|
|
+
|
|
|
}
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
}
|
|
|
const taskNameinput = ref('')
|
|
|
-const taskNameList = ref([
|
|
|
- {
|
|
|
- title:'任务1',
|
|
|
- type:1,
|
|
|
- },
|
|
|
- {
|
|
|
- title:'任务2',
|
|
|
- type:2,
|
|
|
- },
|
|
|
-])
|
|
|
+
|
|
|
const addTaskName = ()=>{
|
|
|
if (taskNameinput.value) {
|
|
|
- taskNameList.value.push({
|
|
|
- title:taskNameinput.value,
|
|
|
+ fixedBranchList.value.push({
|
|
|
+ name:taskNameinput.value,
|
|
|
type:1,
|
|
|
+ userIds:'',
|
|
|
})
|
|
|
taskNameinput.value = ''
|
|
|
+
|
|
|
} else {
|
|
|
window.$message.warning('请输入任务名称')
|
|
|
}
|
|
|
-
|
|
|
+ checkboxUserList.value = []
|
|
|
+ curItem.value = null
|
|
|
}
|
|
|
|
|
|
-const delTask = (index)=>{
|
|
|
+const delTask = async (item, index)=>{
|
|
|
console.log(index, 'index')
|
|
|
- taskNameList.value.splice(index, 1)
|
|
|
+
|
|
|
+ fixedBranchList.value.splice(index, 1)
|
|
|
+}
|
|
|
+const curItem = ref(null)
|
|
|
+const chekckTask = (item)=>{
|
|
|
+ console.log(item)
|
|
|
+ curItem.value = item
|
|
|
+ setUserDataList(item.users)
|
|
|
+ console.log(checkboxUserList.value, 'checkboxUserList.value')
|
|
|
}
|
|
|
</script>
|
|
|
|