Blame view

src/components/staff/SelectStaff.vue 3.34 KB
b25b036d   wuxw   v1.9 优化日期
1
  <template>
4927ce37   wuxw   开发完成报修功能
2
    <el-dialog :visible="visible" :title="$t('selectStaff.title')" width="80%" @close="handleClose">
2e0fd29c   wuxw   开发报修
3
4
5
6
7
8
9
10
11
12
13
14
15
16
      <el-row :gutter="20">
        <el-col :span="12" class="border-right">
          <div class="text-center">
            <h4>{{ $t('selectStaff.orgInfo') }}</h4>
          </div>
          <div class="staff padding">
            <OrgTreeShow ref="orgTree" @org-selected="handleOrgSelected" />
          </div>
        </el-col>
        <el-col :span="12">
          <div class="text-center">
            <h4>{{ $t('selectStaff.staffInfo') }}</h4>
          </div>
          <div class="padding-left staff padding padding-top-xs">
4927ce37   wuxw   开发完成报修功能
17
18
            <div v-for="(item, index) in staffs" :key="index" class="staff-item" 
            :class="{'selected': curStaffId == item.userId }" @click="selectStaff(item)">
2e0fd29c   wuxw   开发报修
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
              <div>
                <i class="el-icon-user margin-right-xs"></i>
                {{ item.name }}
              </div>
              <div>{{ item.tel }}</div>
            </div>
          </div>
        </el-col>
      </el-row>
      <div slot="footer" class="dialog-footer">
        <el-button @click="handleClose">{{ $t('common.cancel') }}</el-button>
        <el-button type="primary" @click="handleSubmit">{{ $t('common.confirm') }}</el-button>
      </div>
    </el-dialog>
  </template>
  
  <script>
4927ce37   wuxw   开发完成报修功能
36
  import OrgTreeShow from '@/components/org/OrgTreeShow'
2e0fd29c   wuxw   开发报修
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
  import { getStaffInfos } from '@/api/work/repairTypeUserApi'
  
  export default {
    name: 'SelectStaff',
    components: {
      OrgTreeShow
    },
    data() {
      return {
        visible: false,
        staffs: [],
        curStaffId: '',
        selectedStaff: null,
        staffConfig: {},
        currentOrgId: ''
      }
    },
    methods: {
4927ce37   wuxw   开发完成报修功能
55
      open() {
2e0fd29c   wuxw   开发报修
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
        this.visible = true
        this.$nextTick(() => {
          this.$refs.orgTree.refreshTree()
        })
      },
      handleClose() {
        this.visible = false
        this.staffs = []
        this.curStaffId = ''
        this.selectedStaff = null
      },
      handleOrgSelected(org) {
        this.currentOrgId = org.orgId
        this.loadStaff(org.orgId)
      },
      async loadStaff(orgId) {
        try {
          const params = {
            orgId: orgId,
4927ce37   wuxw   开发完成报修功能
75
76
            row: 50,
            page: 1
2e0fd29c   wuxw   开发报修
77
          }
4927ce37   wuxw   开发完成报修功能
78
79
80
          const {staffs} = await getStaffInfos(params)
  
            this.staffs = staffs
2e0fd29c   wuxw   开发报修
81
            if (this.staffs.length > 0) {
4927ce37   wuxw   开发完成报修功能
82
              this.curStaffId = this.staffs[0].userId
72de60dc   wuxw   优化报修完成
83
              this.selectedStaff = this.staffs[0]
2e0fd29c   wuxw   开发报修
84
            }
2e0fd29c   wuxw   开发报修
85
86
87
88
89
90
        } catch (error) {
          console.error('Error loading staff:', error)
          this.$message.error(this.$t('common.requestFailed'))
        }
      },
      selectStaff(staff) {
4927ce37   wuxw   开发完成报修功能
91
        this.curStaffId = staff.userId
2e0fd29c   wuxw   开发报修
92
93
94
95
        this.selectedStaff = staff
      },
      handleSubmit() {
        if (this.selectedStaff) {
4927ce37   wuxw   开发完成报修功能
96
97
98
          this.selectedStaff.staffId = this.selectedStaff.userId
          this.selectedStaff.staffName = this.selectedStaff.userName
          this.$emit('selectStaff', this.selectedStaff)
2e0fd29c   wuxw   开发报修
99
100
101
102
103
104
105
106
107
108
109
110
111
          this.handleClose()
        } else {
          this.$message.warning(this.$t('selectStaff.selectStaffFirst'))
        }
      }
    }
  }
  </script>
  
  <style scoped>
  .border-right {
    border-right: 1px solid #ebeef5;
  }
4927ce37   wuxw   开发完成报修功能
112
  
2e0fd29c   wuxw   开发报修
113
114
115
  .padding {
    padding: 15px;
  }
4927ce37   wuxw   开发完成报修功能
116
  
2e0fd29c   wuxw   开发报修
117
118
119
  .staff-item {
    padding: 10px;
    margin-bottom: 10px;
4927ce37   wuxw   开发完成报修功能
120
    
2e0fd29c   wuxw   开发报修
121
122
123
    border-radius: 4px;
    cursor: pointer;
  }
4927ce37   wuxw   开发完成报修功能
124
  
2e0fd29c   wuxw   开发报修
125
126
127
  .staff-item:hover {
    background-color: #f5f7fa;
  }
4927ce37   wuxw   开发完成报修功能
128
129
  
  .selected {
2e0fd29c   wuxw   开发报修
130
    background-color: #ecf5ff;
4927ce37   wuxw   开发完成报修功能
131
    border: 1px solid #409eff;
2e0fd29c   wuxw   开发报修
132
  }
4927ce37   wuxw   开发完成报修功能
133
  
2e0fd29c   wuxw   开发报修
134
135
136
137
138
  .text-center {
    text-align: center;
    margin-bottom: 15px;
  }
  </style>