xyc
2024-03-06 532ffadcae3ea0ebdde66f038d351a01f2fb503a
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
<template>
  <el-card shadow="never" class="aui-card--fill">
    <div class="mod-modules-workflowConfigUser}">
      <el-row :gutter="24">
        <el-col :span="23" style="margin-top: -22px">
          <zt-table-wraper ref="tableObj" query-url="/workflowConfig/getUserByWorkflowSteps" delete-url="/workflowConfig" :lazy="true" v-slot="{ table }" :paging="true" >
            <el-form :inline="true" :model="dataForm" @keyup.enter.native="table.query()">
              <el-form-item class="toolbar">
                <el-button type="text" class="form-title">流程步骤审核用户 </el-button>
              </el-form-item>
                <el-form-item style="margin-left: 10px">
                <zt-button type="primary" v-show="selectedWorkflowConfigFlag"  @click="addUser(dataForm.id)">添加用户</zt-button>
                </el-form-item>
                <el-form-item>
                <zt-button type="delete" v-show="selectedWorkflowConfigFlag" @click="deleteHandle()"/>
                </el-form-item>
 
            </el-form>
            <el-table ref="table" v-loading="table.dataLoading" :data="table.dataList"
                      @selection-change="table.selectionChangeHandle"
                      border highlight-current-row
                      row-key="id" width="120%">
              <el-table-column type="selection" width="60" align="center"/>
              <el-table-column prop="userName" label="用户名" align="center" width="140px"/>
              <el-table-column prop="realName" label="姓名" align="center" width="140px"/>
              <el-table-column prop="deptName" label="部门名称" align="center"/>
              <el-table-column prop="companyName" label="公司名称" align="center" width="240px"/>
            </el-table>
            <!-- 弹窗, 新增 / 修改 -->
            <workflow-config-user-add @refreshDataList="table.query" ref="workflowConfigUserAdd"/>
          </zt-table-wraper>
        </el-col>
      </el-row>
    </div>
  </el-card>
</template>
 
<script>
  import workflowConfigUserAdd from './workflow-config-user-add'
  import qs from 'qs'
  import Cookies from 'js-cookie'
  export default {
    data() {
      return {
        dataForm: {
          id: '',
          userId: '',
        },
        defList: [],
        selectedWorkflowConfigFlag: false,
      }
    },
    components: {
      workflowConfigUserAdd
    },
    methods: {
      initTable(id) {
        if (id) {
          this.dataForm.id = id
          this.$refs.tableObj.query()
          this.selectedWorkflowConfigFlag = true
        } else {
          this.selectedWorkflowConfigFlag = false
          this.$refs.tableObj.dataList = []
        }
      },
      addUser(id) {
        this.$refs.workflowConfigUserAdd.$refs.dialog.init(id)
      },
      async deleteHandle() {
        let dataIds = []
        for (let val of this.$refs.tableObj.dataSelectedList) {
          dataIds.push(val.stepId)
        }
        let userIds = []
        for (let val of this.$refs.tableObj.dataSelectedList) {
          userIds.push(val.userId)
        }
        console.log(userIds.length)
        if (dataIds.length <= 0) {
          this.$tip.alert('请勾选要删除的数据')
        }else {
          if (await this.$tip.confirm(dataIds.length > 0 ? '是否删除【勾选】的数据?' : '是否删除所有【满足条件】的数据', '提示')) {
            let ids = ''
            for (let val of this.$refs.tableObj.dataSelectedList) {
              ids = val.stepId
            }
            for (let val of this.$refs.tableObj.dataSelectedList) {
              this.dataForm.userId = this.dataForm.userId + val.userId + ','
            }
            let params = qs.stringify({
              'token': Cookies.get('token'),
              'stepId': ids,
              'userId': this.dataForm.userId,
            })
            let res = await this.$http.get(`/workflowConfig/deleteWorkflowStepsUser?${params}`)
            if (res.success) {
              await this.$tip.success()
              this.$refs.tableObj.query()
            }
          }
        }
      },
    }
  }
</script>