Browse Source

用户桥梁分配权限

luyanan 6 years ago
parent
commit
455410caee

+ 57 - 69
src/views/peoplesManage/infoManage/editUserPermissions.vue

2
  <el-dialog title="用户数据权限修改" :visible.sync="dialogTableVisible" width="860px" @close='closed'>
2
  <el-dialog title="用户数据权限修改" :visible.sync="dialogTableVisible" width="860px" @close='closed'>
3
    <el-form class="form-main" :model="ruleForm2"  ref="ruleForm2">
3
    <el-form class="form-main" :model="ruleForm2"  ref="ruleForm2">
4
      <el-row :gutter="16">
4
      <el-row :gutter="16">
5
        <el-col :xs="12" :sm="12" :lg="12">
5
        <el-col :xs="24" :sm="24" :lg="24">
6
          <div class="list-item">
6
          <div class="list-item">
7
            <el-row>
7
            <el-row>
8
              <el-col :span="12">
8
              <el-col :span="8">
9
                <el-form-item label="账号">{{ruleForm2.account}}</el-form-item>
9
                <el-form-item label="账号">{{ruleForm2.account}}</el-form-item>
10
              </el-col>
10
              </el-col>
11
              <el-col :span="12">
11
              <el-col :span="8">
12
                <el-form-item label="用户姓名">{{ruleForm2.name}}</el-form-item>
12
                <el-form-item label="用户姓名">{{ruleForm2.name}}</el-form-item>
13
              </el-col>
13
              </el-col>
14
              <el-col :span="12"  style='margin-top:30px'>
14
              <el-col :span="8">
15
                <el-form-item label="用户类型">{{(ruleForm2.type) ? '管理员' : '普通用户'}}</el-form-item>
15
                <el-form-item label="用户类型">{{(ruleForm2.type) ? '管理员' : '普通用户'}}</el-form-item>
16
              </el-col>
16
              </el-col>
17
              <el-col :span="12" style='margin-top:30px'>
17
              <el-col :span="8">
18
                <el-form-item label="职位">{{ruleForm2.job}}</el-form-item>
18
                <el-form-item label="职位">{{ruleForm2.job}}</el-form-item>
19
              </el-col>
19
              </el-col>
20
              <el-col :span="24" style='margin-top:30px'>
20
              <el-col :span="16">
21
                <el-form-item label="所属机构">{{ruleForm2.comp}}</el-form-item>
21
                <el-form-item label="所属机构">{{ruleForm2.comp}}</el-form-item>
22
              </el-col>
22
              </el-col>
23
            </el-row>
23
            </el-row>
24
          </div>
24
          </div>
25
        </el-col>
25
        </el-col>
26
        <el-col :xs="12" :sm="12" :lg="12">
26
<!--         <el-col :xs="12" :sm="12" :lg="12">
27
          <div class="list-item">
27
          <div class="list-item">
28
            <el-row>
28
            <el-row>
29
              <el-col :span="24">
29
              <el-col :span="24">
60
              </el-col>
60
              </el-col>
61
            </el-row>
61
            </el-row>
62
          </div>
62
          </div>
63
        </el-col> -->
64
        <el-col :xs="24" :sm="24" :lg="24">
65
          <el-transfer class="check-transfer"
66
            filterable
67
            v-model="valueBridge"
68
            :titles="['所有桥梁', '负责桥梁']"
69
            :button-texts="['删除', '添加']"
70
            :props="{
71
              key: 'id',
72
              label: 'value'
73
            }"
74
            :left-default-checked="bridgeListsChecked"
75
            :data="bridgeLists">
76
          </el-transfer>
63
        </el-col>
77
        </el-col>
64
      </el-row>
65
      <el-row>
66
        <el-col :span="24" class="el-btn-col">
78
        <el-col :span="24" class="el-btn-col">
67
            <div class="el-btn-col-box">
68
              <el-button type="primary" @click="submit">确认</el-button>
69
              <el-button type="info"  @click="closed">返回</el-button>
70
            </div>
71
          </el-col>
79
          <div class="el-btn-col-box">
80
            <el-button type="primary" @click="submit">确认</el-button>
81
            <el-button type="info"  @click="closed">返回</el-button>
82
          </div>
83
        </el-col>
72
      </el-row>
84
      </el-row>
73
    </el-form>
85
    </el-form>
74
  </el-dialog>
86
  </el-dialog>
80
  props: ['dialog', 'id'],
92
  props: ['dialog', 'id'],
81
  data() {
93
  data() {
82
    return {
94
    return {
83
      arr: [],
95
      bridgeLists: [],
96
      bridgeListsChecked: [],
97
      valueBridge: [],
84
      shouHead: false,
98
      shouHead: false,
85
      state4: '',
99
      state4: '',
86
      ruleForm2: {
100
      ruleForm2: {
90
        job: '',
104
        job: '',
91
        type: 0
105
        type: 0
92
      },
106
      },
93
      tableData3: [],
94
      timeout: null,
95
      dialogTableVisible: false
107
      dialogTableVisible: false
96
    }
108
    }
97
  },
109
  },
110
  created() {
111
    this.getAllBridges()
112
  },
98
  watch: {
113
  watch: {
99
    dialog() {
114
    dialog() {
100
      this.dialogTableVisible = true
101
      queryRegister({ id: this.id }).then(response => {
115
      queryRegister({ id: this.id }).then(response => {
102
        if (response.success) {
116
        if (response.success) {
103
          const $data = response.data
117
          const $data = response.data
110
          }
124
          }
111
        }
125
        }
112
      })
126
      })
113
      queryResponsibleBridge({ uid: this.id }).then(response => {
127
      queryResponsibleBridge({ uid: this.id, active: 1 }).then(response => {
114
        if (response.success) {
128
        if (response.success) {
115
          const $info = response.data
129
          const $info = response.data
116
          for (let j = 0; j < $info.length; j++) {
130
          for (let j = 0; j < $info.length; j++) {
117
            this.tableData3.push({ name: $info[j].shortName, address: $info[j].id })
131
            this.valueBridge.push($info[j].id)
118
          }
132
          }
119
        }
133
        }
120
      })
134
      })
135
      this.dialogTableVisible = true
121
    }
136
    }
122
  },
137
  },
123
  methods: {
138
  methods: {
124
    querySearchAsync(queryString, cb) {
125
      clearTimeout(this.timeout)
126
      this.timeout = setTimeout(() => {
127
        DeviceOfservice({ key: this.state4, active: 1 }).then(response => {
128
          const $info = response.data
129
          if ($info.length) {
130
            const $data = $info.map(item => {
131
              return { 'value': item.shortName, 'id': item.id }
132
            })
133
            cb($data)
134
          } else {
135
            cb([{ 'value': '暂无数据', 'id': '' }])
136
            setTimeout(function() {
137
              cb([])
138
            }, 300)
139
          }
140
        })
141
      }, 3000 * Math.random())
142
    },
143
    handleSelect(item) {
144
      this.state4 = ''
145
      if (item.value === '暂无数据' && item.id === '') {
146
        return
147
      }
148
      let flag = false
149
      for (let i = 0; i < this.tableData3.length; i++) {
150
        if (item.id === this.tableData3[i].address) {
151
          flag = true
152
          break
139
    getAllBridges() {
140
      DeviceOfservice({ key: this.state4, active: 1 }).then(response => {
141
        const $info = response.data
142
        if ($info.length) {
143
          this.bridgeListsChecked.push($info[0].id)
144
          const $data = $info.map(item => {
145
            return { 'value': item.shortName, 'id': item.id }
146
          })
147
          this.bridgeLists = $data
153
        }
148
        }
154
      }
155
      if (!flag) {
156
        const $data = { name: item.value, address: item.id }
157
        this.tableData3.push($data)
158
      }
159
    },
160
    handleModifyStatus(value) {
161
      const index = this.tableData3.indexOf(value)
162
      this.tableData3.splice(index, 1)
149
      })
163
    },
150
    },
164
    pop($par) {
151
    pop($par) {
165
      this.$confirm($par, '提示', {
152
      this.$confirm($par, '提示', {
175
      })
162
      })
176
    },
163
    },
177
    closed() {
164
    closed() {
178
      this.tableData3 = []
179
      this.arr = []
165
      this.valueBridge = []
180
      this.dialogTableVisible = false
166
      this.dialogTableVisible = false
181
    },
167
    },
182
    submit() {
168
    submit() {
183
      this.tableData3.map(item => {
184
        this.arr.push(item.address)
185
      })
186
      if (!this.arr.length) {
169
      if (!this.valueBridge.length) {
187
        this.$message.error('请至少选择一个桥梁')
170
        this.$message.error('请至少选择一个桥梁')
188
        return
171
        return
189
      }
172
      }
190
      updatePermission({ id: this.id, bridges: this.arr }).then(response => {
173
      updatePermission({ id: this.id, bridges: this.valueBridge }).then(response => {
191
        if (response.success) {
174
        if (response.success) {
192
          this.tableData3 = []
193
          this.arr = []
175
          this.valueBridge = []
194
          this.$emit('chilF')
176
          this.$emit('chilF')
195
          const that = this
177
          const that = this
196
          setTimeout(function() {
178
          setTimeout(function() {
206
188
207
<style rel="stylesheet/scss" lang="scss" scoped>
189
<style rel="stylesheet/scss" lang="scss" scoped>
208
  .el-form-item{
190
  .el-form-item{
209
    margin: 0;
191
    margin-bottom: 10px;
210
  }
192
  }
211
  .textarea-div{
193
  .textarea-div{
212
    line-height: 26px;
194
    line-height: 26px;
213
    margin-bottom: 10px;
195
    margin-bottom: 10px;
214
  }
196
  }
215
  .list-item{
197
  .list-item{
216
    margin-bottom: 20px;
217
    padding: 10px 15px;
198
    padding: 10px 15px;
218
  }
199
  }
219
  .el-autocomplete {
200
  .el-autocomplete {
220
    width: 100%
201
    width: 100%
221
  }
202
  }
203
  .check-transfer.el-transfer{
204
    padding-left: 15px;
205
    margin-bottom: 15px;
206
  }
207
  .check-transfer .el-transfer-panel{
208
    width: 240px;
209
  }
222
</style>
210
</style>

+ 1 - 1
src/views/peoplesManage/infoManage/index.vue

128
        const $data = response.data.data
128
        const $data = response.data.data
129
        for (let i = 0; i < $data.length; i++) {
129
        for (let i = 0; i < $data.length; i++) {
130
          $data[i].bridgeName = ''
130
          $data[i].bridgeName = ''
131
          queryResponsibleBridge({ uid: $data[i].id }).then(response => {
131
          queryResponsibleBridge({ uid: $data[i].id, active: 1 }).then(response => {
132
            if (response.success) {
132
            if (response.success) {
133
              const arr = []
133
              const arr = []
134
              const $info = response.data
134
              const $info = response.data