Blame view

src/components/contract/selectStaff.vue 4.56 KB
b25b036d   wuxw   v1.9 优化日期
1
  <template>
bc37d685   wuxw   开发完成合同功能
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
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
    <el-dialog
      :title="$t('selectStaff.title')"
      :visible.sync="dialogVisible"
      width="80%"
    >
      <el-row>
        <el-col :span="12" class="border-right">
          <div class="text-center">
            <h4>{{ $t('selectStaff.orgInfo') }}</h4>
          </div>
          <div class="tree-container">
            <org-tree-show
              ref="orgTreeShow"
              :call-back-listener="callBackListener"
            />
          </div>
        </el-col>
        
        <el-col :span="12">
          <div class="text-center">
            <h4>{{ $t('selectStaff.staffInfo') }}</h4>
          </div>
          <div class="staff-list">
            <div
              v-for="(item, index) in selectStaffInfo.staffs"
              :key="index"
              class="staff-item"
              :class="{ 'selected': selectStaffInfo.curStaffId === item.staffId }"
              @click="changeStaff(item)"
            >
              <div>
                <i class="el-icon-user"></i>
                {{ item.name }}
              </div>
              <div>{{ item.tel }}</div>
            </div>
          </div>
        </el-col>
      </el-row>
      
      <div
        v-if="selectStaffInfo.staff.from === 'bpmn' || 
              selectStaffInfo.staff.from === 'purchase' || 
              selectStaffInfo.staff.from === 'contract'"
        slot="footer"
        class="dialog-footer"
      >
        <el-button @click="firstUser">
          {{ $t('selectStaff.submitter') }}
        </el-button>
        <el-button type="primary" @click="customUser">
          {{ $t('selectStaff.dynamicAssign') }}
        </el-button>
      </div>
    </el-dialog>
  </template>
  
  <script>
  import { queryStaffInfos } from '@/api/contract/contractChangeDetailApi'
  import OrgTreeShow from '@/components/contract/OrgTreeShow'
  
  export default {
    name: 'SelectStaff',
    components: {
      OrgTreeShow
    },
    data() {
      return {
        dialogVisible: false,
        selectStaffInfo: {
          staffs: [],
          curStaffId: '',
          curStaffName: '',
          staff: {}
        },
        callBackListener: 'selectStaff'
      }
    },
    methods: {
      open(staff) {
        this.selectStaffInfo.staff = staff
        this.dialogVisible = true
        this.$refs.orgTreeShow.loadOrgsShow()
      },
      changeStaff(item) {
        this.selectStaffInfo.curStaffId = item.staffId
        this.selectStaffInfo.curStaffName = item.name
        
        if (this.selectStaffInfo.staff) {
          this.selectStaffInfo.staff.staffId = item.userId
          this.selectStaffInfo.staff.staffName = item.userName
          this.selectStaffInfo.staff.staffTel = item.tel
          
          if (this.selectStaffInfo.staff.call) {
            this.selectStaffInfo.staff.call(this.selectStaffInfo.staff)
          }
        }
        
        this.dialogVisible = false
      },
      loadStaff(org) {
        const param = {
          page: 1,
          rows: 50,
          orgId: org.orgId
        }
  
        queryStaffInfos(param)
          .then(response => {
            const staffInfo = response.data
            this.selectStaffInfo.staffs = staffInfo.staffs
            if (staffInfo.staffs.length > 0) {
              this.selectStaffInfo.curStaffId = staffInfo.staffs[0].orgId
            }
          })
          .catch(error => {
            console.error('请求失败:', error)
          })
      },
      firstUser() {
        if (this.selectStaffInfo.staff) {
          this.selectStaffInfo.staff.staffId = '${startUserId}'
          this.selectStaffInfo.staff.staffName = this.$t('selectStaff.submitter')
          
          if (this.selectStaffInfo.staff.call) {
            this.selectStaffInfo.staff.call(this.selectStaffInfo.staff)
          }
        }
        this.dialogVisible = false
      },
      customUser() {
        if (this.selectStaffInfo.staff) {
          this.selectStaffInfo.staff.staffId = '${nextUserId}'
          this.selectStaffInfo.staff.staffName = this.$t('selectStaff.dynamicAssign')
          
          if (this.selectStaffInfo.staff.call) {
            this.selectStaffInfo.staff.call(this.selectStaffInfo.staff)
          }
        }
        this.dialogVisible = false
      }
    },
    created() {
      this.$on('switchOrg', param => {
        this.loadStaff(param)
      })
    }
  }
  </script>
  
  <style scoped>
  .border-right {
    border-right: 1px solid #eee;
    padding-right: 20px;
  }
  
  .tree-container {
    height: 400px;
    overflow-y: auto;
  }
  
  .staff-list {
    height: 400px;
    overflow-y: auto;
    padding-left: 20px;
  }
  
  .staff-item {
    padding: 10px;
    margin-bottom: 5px;
    cursor: pointer;
    border-radius: 4px;
  }
  
  .staff-item:hover {
    background-color: #f5f7fa;
  }
  
  .staff-item.selected {
    background-color: #ecf5ff;
    color: #409eff;
  }
  
  .text-center {
    text-align: center;
    margin-bottom: 15px;
  }
  
  .dialog-footer {
    text-align: right;
  }
  </style>