Browse Source

用户桥梁分配权限

luyanan 6 years ago
parent
commit
455410caee

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

@ -2,28 +2,28 @@
2 2
  <el-dialog title="用户数据权限修改" :visible.sync="dialogTableVisible" width="860px" @close='closed'>
3 3
    <el-form class="form-main" :model="ruleForm2"  ref="ruleForm2">
4 4
      <el-row :gutter="16">
5
        <el-col :xs="12" :sm="12" :lg="12">
5
        <el-col :xs="24" :sm="24" :lg="24">
6 6
          <div class="list-item">
7 7
            <el-row>
8
              <el-col :span="12">
8
              <el-col :span="8">
9 9
                <el-form-item label="账号">{{ruleForm2.account}}</el-form-item>
10 10
              </el-col>
11
              <el-col :span="12">
11
              <el-col :span="8">
12 12
                <el-form-item label="用户姓名">{{ruleForm2.name}}</el-form-item>
13 13
              </el-col>
14
              <el-col :span="12"  style='margin-top:30px'>
14
              <el-col :span="8">
15 15
                <el-form-item label="用户类型">{{(ruleForm2.type) ? '管理员' : '普通用户'}}</el-form-item>
16 16
              </el-col>
17
              <el-col :span="12" style='margin-top:30px'>
17
              <el-col :span="8">
18 18
                <el-form-item label="职位">{{ruleForm2.job}}</el-form-item>
19 19
              </el-col>
20
              <el-col :span="24" style='margin-top:30px'>
20
              <el-col :span="16">
21 21
                <el-form-item label="所属机构">{{ruleForm2.comp}}</el-form-item>
22 22
              </el-col>
23 23
            </el-row>
24 24
          </div>
25 25
        </el-col>
26
        <el-col :xs="12" :sm="12" :lg="12">
26
<!--         <el-col :xs="12" :sm="12" :lg="12">
27 27
          <div class="list-item">
28 28
            <el-row>
29 29
              <el-col :span="24">
@ -60,15 +60,27 @@
60 60
              </el-col>
61 61
            </el-row>
62 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 77
        </el-col>
64
      </el-row>
65
      <el-row>
66 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 84
      </el-row>
73 85
    </el-form>
74 86
  </el-dialog>
@ -80,7 +92,9 @@ export default {
80 92
  props: ['dialog', 'id'],
81 93
  data() {
82 94
    return {
83
      arr: [],
95
      bridgeLists: [],
96
      bridgeListsChecked: [],
97
      valueBridge: [],
84 98
      shouHead: false,
85 99
      state4: '',
86 100
      ruleForm2: {
@ -90,14 +104,14 @@ export default {
90 104
        job: '',
91 105
        type: 0
92 106
      },
93
      tableData3: [],
94
      timeout: null,
95 107
      dialogTableVisible: false
96 108
    }
97 109
  },
110
  created() {
111
    this.getAllBridges()
112
  },
98 113
  watch: {
99 114
    dialog() {
100
      this.dialogTableVisible = true
101 115
      queryRegister({ id: this.id }).then(response => {
102 116
        if (response.success) {
103 117
          const $data = response.data
@ -110,56 +124,29 @@ export default {
110 124
          }
111 125
        }
112 126
      })
113
      queryResponsibleBridge({ uid: this.id }).then(response => {
127
      queryResponsibleBridge({ uid: this.id, active: 1 }).then(response => {
114 128
        if (response.success) {
115 129
          const $info = response.data
116 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 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 151
    pop($par) {
165 152
      this.$confirm($par, '提示', {
@ -175,22 +162,17 @@ export default {
175 162
      })
176 163
    },
177 164
    closed() {
178
      this.tableData3 = []
179
      this.arr = []
165
      this.valueBridge = []
180 166
      this.dialogTableVisible = false
181 167
    },
182 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 170
        this.$message.error('请至少选择一个桥梁')
188 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 174
        if (response.success) {
192
          this.tableData3 = []
193
          this.arr = []
175
          this.valueBridge = []
194 176
          this.$emit('chilF')
195 177
          const that = this
196 178
          setTimeout(function() {
@ -206,17 +188,23 @@ export default {
206 188
207 189
<style rel="stylesheet/scss" lang="scss" scoped>
208 190
  .el-form-item{
209
    margin: 0;
191
    margin-bottom: 10px;
210 192
  }
211 193
  .textarea-div{
212 194
    line-height: 26px;
213 195
    margin-bottom: 10px;
214 196
  }
215 197
  .list-item{
216
    margin-bottom: 20px;
217 198
    padding: 10px 15px;
218 199
  }
219 200
  .el-autocomplete {
220 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 210
</style>

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

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