|
@@ -1,10 +1,12 @@
|
|
|
<template>
|
|
|
<div>
|
|
|
<el-dialog
|
|
|
- title="提示"
|
|
|
+ custom-class="myFields"
|
|
|
+ title="显示栏位管理"
|
|
|
:visible.sync="dialogVisible"
|
|
|
- width="50%"
|
|
|
+ width="300px"
|
|
|
:before-close="handleClose"
|
|
|
+ :close-on-click-modal="false"
|
|
|
>
|
|
|
<div>
|
|
|
<el-checkbox
|
|
@@ -13,19 +15,27 @@
|
|
|
@change="handleCheckAllChange"
|
|
|
>全选</el-checkbox
|
|
|
>
|
|
|
- <div style="margin: 15px 0"></div>
|
|
|
+ <p></p>
|
|
|
<el-checkbox-group v-model="checked" @change="handleCheckedChange">
|
|
|
- <el-checkbox
|
|
|
- v-for="field in filedList"
|
|
|
- :label="field.value"
|
|
|
- :key="field.value"
|
|
|
- >{{ field.name }}</el-checkbox
|
|
|
- >
|
|
|
+ <template>
|
|
|
+ <div v-for="(field,index) in filedList" :key="field.value" style="padding:5px 0;">
|
|
|
+ <el-checkbox :label="field.value">
|
|
|
+ <div>
|
|
|
+ <div>{{ field.name }}</div>
|
|
|
+ <div>
|
|
|
+ <i class="el-icon-sort-down down" :disabled="index == filedList.length-1" @click.stop.prevent="down(index,field)"></i>
|
|
|
+ <i class="el-icon-sort-up up" :disabled="index == 0" @click.stop.prevent="up(index,field)"></i>
|
|
|
+ </div>
|
|
|
+ </div>
|
|
|
+ </el-checkbox>
|
|
|
+ </div>
|
|
|
+ </template>
|
|
|
+
|
|
|
</el-checkbox-group>
|
|
|
</div>
|
|
|
<span slot="footer" class="dialog-footer">
|
|
|
<el-button @click="handleClose">取 消</el-button>
|
|
|
- <el-button type="primary" @click="submit">确 定</el-button>
|
|
|
+ <el-button type="primary" :loading="loading" @click="submit">确 定</el-button>
|
|
|
</span>
|
|
|
</el-dialog>
|
|
|
</div>
|
|
@@ -35,12 +45,6 @@
|
|
|
export default {
|
|
|
components: {},
|
|
|
props: {
|
|
|
- filedList: {
|
|
|
- type: Array,
|
|
|
- default: () => {
|
|
|
- return [];
|
|
|
- },
|
|
|
- },
|
|
|
type:{
|
|
|
type:String,
|
|
|
default:''
|
|
@@ -56,43 +60,66 @@ export default {
|
|
|
checkAll: false,
|
|
|
//选择
|
|
|
checked: [],
|
|
|
+ //显示栏位
|
|
|
+ filedList:[],
|
|
|
+ //按钮加载
|
|
|
+ loading:false
|
|
|
};
|
|
|
},
|
|
|
watch: {},
|
|
|
computed: {},
|
|
|
created() {},
|
|
|
mounted() {
|
|
|
- //获取显示栏位
|
|
|
- this.getCustomField(this.type);
|
|
|
},
|
|
|
methods: {
|
|
|
- getCustomField(type) {
|
|
|
- if(!this.type) return;
|
|
|
- var params = {
|
|
|
- tableName: type,
|
|
|
- };
|
|
|
- this.$api.getCustomField(params).then((response) => {
|
|
|
- if (response.code == 200) {
|
|
|
- this.filedList.push(...response.data.data)
|
|
|
- this.$emit('getFieldList',this.filedList)
|
|
|
- }
|
|
|
- }).catch(error=>{
|
|
|
- this.filedList.splice(0)
|
|
|
- this.$emit('getFieldList',this.filedList)
|
|
|
- });
|
|
|
- },
|
|
|
+
|
|
|
//打开栏位
|
|
|
open(data) {
|
|
|
+ this.filedList = JSON.parse(JSON.stringify(data))
|
|
|
+ this.checked = data.filter(item=>{
|
|
|
+ return item.ifHidden == false
|
|
|
+ }).map(item=>{
|
|
|
+ return item.value
|
|
|
+ })
|
|
|
+ this.handleCheckedChange(this.checked)
|
|
|
this.dialogVisible = true;
|
|
|
},
|
|
|
+ //下移
|
|
|
+ down(index,file){
|
|
|
+ var arr = this.filedList
|
|
|
+ this.filedList.splice(index, 2, arr[index + 1], arr[index])
|
|
|
+ },
|
|
|
+ //上移
|
|
|
+ up(index,file){
|
|
|
+ var arr = this.filedList
|
|
|
+ this.filedList.splice(index - 1, 2, arr[index], arr[index - 1])
|
|
|
+ },
|
|
|
//关闭弹窗
|
|
|
handleClose() {
|
|
|
this.dialogVisible = false;
|
|
|
},
|
|
|
//提交更改
|
|
|
submit() {
|
|
|
- this.$api.setCustomField().then(()=>{
|
|
|
-
|
|
|
+ for(var i = 0; i < this.filedList.length; i++ ){
|
|
|
+ if(this.checked.includes(this.filedList[i].value)){
|
|
|
+ this.filedList[i].ifHidden = false
|
|
|
+ }else{
|
|
|
+ this.filedList[i].ifHidden = true
|
|
|
+ }
|
|
|
+ }
|
|
|
+ var params = {
|
|
|
+ tableName : this.type,
|
|
|
+ value:this.filedList
|
|
|
+ }
|
|
|
+ this.loading = true
|
|
|
+ this.$api.setCustomField(params).then((response)=>{
|
|
|
+ if(response.code == 200){
|
|
|
+ this.loading = false
|
|
|
+ this.handleClose()
|
|
|
+ this.$emit('getFieldList',this.filedList)
|
|
|
+ }
|
|
|
+ }).catch(error=>{
|
|
|
+ this.loading = false
|
|
|
})
|
|
|
},
|
|
|
//全选
|
|
@@ -105,10 +132,29 @@ export default {
|
|
|
let checkedCount = value.length;
|
|
|
this.checkAll = checkedCount === this.filedList.length;
|
|
|
this.isIndeterminate =
|
|
|
- checkedCount > 0 && checkedCount < this.cities.length;
|
|
|
+ checkedCount > 0 && checkedCount < this.filedList.length;
|
|
|
},
|
|
|
},
|
|
|
};
|
|
|
</script>
|
|
|
-<style lang="scss" scoped>
|
|
|
+<style lang="scss">
|
|
|
+.myFields{
|
|
|
+ .el-checkbox{
|
|
|
+ width: 100%;
|
|
|
+ .el-checkbox__label{
|
|
|
+ width:calc(100% - 10px);
|
|
|
+ div{
|
|
|
+ display: flex;
|
|
|
+ justify-content: space-between;
|
|
|
+ align-items: center;
|
|
|
+ i{
|
|
|
+ color: #999;
|
|
|
+ }
|
|
|
+ i:hover{
|
|
|
+ color: #409EFF;
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
+}
|
|
|
</style>
|