This commit is contained in:
zhutianqi
2021-07-08 17:31:21 +08:00
parent cf357076ea
commit edf0a1ad03
5 changed files with 681 additions and 193 deletions
@@ -6,23 +6,19 @@
<el-transfer
:data="data"
v-model="value"
:titles="['可选模块','个人模块']"
:titles="['可选模块','个人展示模块']"
@change="handleChange"
@left-check-change="selectedChange"
@right-check-change="selectedChange"
filterable>
</el-transfer>
<div class="btn-group">
<!-- <div class="button-wrapper">-->
<!-- <el-button type="primary" size="small" class="searchAngNewBtn" @click="reloadMockData(1)">{{$t('m.moveUp')}}</el-button>-->
<!-- <el-button type="primary" size="small" class="searchAngNewBtn" @click="reloadMockData(2)" style="margin-left: 0.5rem;">{{$t('m.moveDown')}}</el-button>-->
<!-- </div>-->
</div>
</div>
</div>
<el-divider></el-divider>
<div class="footer">
<el-button type="primary" size="small" class="searchAngNewBtn" v-btn-permission="'NQDDVW8JW3EUVAEXZH3F'" @click="savePersonal">保存修改</el-button>
<el-button type="primary" size="small" class="searchAngNewBtn" @click="savePersonal">保存修改</el-button>
</div>
</div>
</template>
@@ -47,46 +43,36 @@ export default {
listStyle: {
width: '5rem',
height: '8rem'
}
},
oldData: []
}
},
methods: {
// 右侧列表元素变化时触发
handleChange (newTargetKeys, direction, moveKeys) {
this.targetKeys = newTargetKeys
this.numData = []
if (direction === 'left') {
this.oldData.forEach( item => {
moveKeys.forEach( items => {
if (items === item.id) {
item.state = 1
}
})
})
} else if (direction === 'right'){
this.oldData.forEach( item => {
moveKeys.forEach( items => {
if (items === item.id) {
item.state = 0
}
})
})
}
this.targetKeys = newTargetKeys
this.numData = []
},
selectedChange (sourceSelectedKeys, targetSelectedKeys) {
this.numData = sourceSelectedKeys
this.sourceSelectedKeys = targetSelectedKeys
},
renderPersonal (item) {
return item.label
},
// 上移,下移
reloadMockData (flag) {
if (this.numData.length > 1 || this.numData.length === 0) {
this.$message({
message: '选择个人板块一条板块进行上移下移操作',
type: 'warning'
})
} else {
// numData : 选中的值
let num = this.targetKeys.indexOf(this.numData[0])
if (flag === 1) {
// 1表示上移
if (num > 0) {
this.value.splice(num, 1)
this.value.splice(num - 1, 0, this.numData[0])
}
} else {
// 2表示下移
this.targetKeys.splice(num, 1)
this.targetKeys.splice(num + 1, 0, this.numData[0])
// targetKeys 变了
// this.data = JSON.stringify(this.targetKeys)
}
}
this.numData = sourceSelectedKeys
this.sourceSelectedKeys = targetSelectedKeys
},
savePersonal () {
if (this.targetKeys.length === 0) {
@@ -96,9 +82,10 @@ export default {
})
return
}
this.$http.post('person/personModuleUser/insertModule',
this.$http.postData('sarPersonalCenter/sar-user-personal-menu/update',
{
moduleIds: this.targetKeys
sarUserPersonalMenus: this.oldData,
userId: this.$store.getters.userInfo.userId
}, {
_this: this
}, res => {
@@ -113,16 +100,14 @@ export default {
},
// 获取模块
selectPersonConf () {
this.$http.get('person/personModule/queryByList',
this.$http.get('/sarPersonalCenter/sar-user-personal-menu/getList',
{
userId: this.$store.getters.userInfo.userId
}, {_this: this}, res => {
res.data.map((item) => {
if (item.moduleName === '首页') {
res.data.records.map((item) => {
if (item.menuName === '首页') {
this.selected.push(item)
} else if (item.moduleName === '待办任务') {
this.selected.push(item)
} else if (item.flag === '0') {
} else if (item.state == 0) {
this.selected.push(item)
}
})
@@ -132,16 +117,17 @@ export default {
}
// 左侧数据会筛选出右侧数据进行显示
var j
for (j = 0; j < res.data.length; j++) {
for (j = 0; j < res.data.records.length; j++) {
let moduleLabel = {}
moduleLabel = res.data[j].moduleName
moduleLabel = res.data.records[j].menuName
let moduleid = {}
moduleid = res.data[j].id
moduleid = res.data.records[j].id
this.data.push({
label: moduleLabel,
key: moduleid,
disabled: moduleLabel === '首页' || moduleLabel === '待办任务'
disabled: moduleLabel === '首页'
})
this.oldData = JSON.parse(JSON.stringify(res.data.records))
}
this.value = this.targetKeys
}, e => {