zhanghua
2023-02-09 bf9a412b20afe9f22e99448eb002ff9e92fd30cb
src/views/operate/message/mycontrol/index.vue
@@ -4,18 +4,30 @@
            <div class="mainContent">
                <div class="main-nav">
                    <span>数据列表</span>
                    <el-button class="button-addition" type="primary" icon="el-icon-plus" @click="dialogCreate = true">添加</el-button>
          <el-button
            class="button-addition"
            type="primary"
            icon="el-icon-plus"
            @click="dialogCreate = true"
            >添加</el-button
          >
                </div>
                <!-- 数据展示 -->
                <el-table
                    border
                    stripe
                    ref="multipleTable"
                    :header-cell-style="{ 'background':'#F5F5F5','font-weight':'650','line-height':'45px'}"
                    :data="tableData" style="width: 100%" :row-class-name="tableRowClassName"
                    @selection-change="tableChange">
                    <el-table-column type="selection" min-width="5">
                    </el-table-column>
          :header-cell-style="{
            background: '#F5F5F5',
            'font-weight': '650',
            'line-height': '45px',
          }"
          :data="tableData"
          style="width: 100%"
          :row-class-name="tableRowClassName"
          @selection-change="tableChange"
        >
          <el-table-column type="selection" min-width="5"> </el-table-column>
                    <el-table-column prop="columnName" label="栏目名称" min-width="10">
                    </el-table-column>
                    <el-table-column prop="updateTime" label="修改时间" min-width="10">
@@ -27,29 +39,56 @@
                    </el-table-column>
                    <el-table-column prop="isShow" label="显示" min-width="5">
                        <template slot-scope="scope">
                            <el-switch class="switchStyle" v-model="scope.row.isShow" active-text="开" inactive-text="关"
                                active-color="#3fef9a" inactive-color="#000212" @change="handleChangeStatus(scope.row)">
              <el-switch
                class="switchStyle"
                v-model="scope.row.isShow"
                active-text="开"
                inactive-text="关"
                active-color="#3fef9a"
                inactive-color="#000212"
                @change="handleChangeStatus(scope.row)"
              >
                            </el-switch>
                        </template>
                    </el-table-column>
                    <el-table-column prop="operation" label="操作" min-width="15">
                        <template slot-scope="scope">
                            <div class="operation">
                                <el-link icon="el-icon-edit" :underline="false" @click="handleEdit(scope.row)">编辑</el-link>
                                <el-link class="leftPx" icon="el-icon-delete-solid" :underline="false"
                                    @click="handleDelete([scope.row.id])">删除</el-link>
                <el-link
                  icon="el-icon-edit"
                  :underline="false"
                  @click="handleEdit(scope.row)"
                  >编辑</el-link
                >
                <el-link
                  class="leftPx"
                  icon="el-icon-delete-solid"
                  :underline="false"
                  @click="handleDelete([scope.row.id])"
                  >删除</el-link
                >
                            </div>
                        </template>
                    </el-table-column>
                </el-table>
                <!-- 创建页面 -->
                <el-dialog title="添加栏目" :visible.sync="dialogCreate" v-if="dialogCreate" width="45%"
                    :before-close="handleClose">
        <el-dialog
          title="添加栏目"
          :visible.sync="dialogCreate"
          v-if="dialogCreate"
          width="45%"
          :before-close="handleClose"
        >
                    <MyCreate @closeDialog="closeDialog"></MyCreate>
                </el-dialog>
                <!-- 编辑页面 -->
                <el-dialog title="修改栏目" :visible.sync="dialogEdit" v-if="dialogEdit" width="45%"
                    :before-close="handleClose">
        <el-dialog
          title="修改栏目"
          :visible.sync="dialogEdit"
          v-if="dialogEdit"
          width="45%"
          :before-close="handleClose"
        >
                    <MyEdit  @closeDialog="closeDialog" :info="info"></MyEdit>
                </el-dialog>
            </div>
@@ -58,14 +97,15 @@
</template>
<script>
// 引入创建栏目组件
import MyCreate from './createUser'
import MyCreate from "./createUser";
// 引入编辑组件
import MyEdit from './update'
import MyEdit from "./update";
// 引入日期js
import helper from '@/utils/mydate'
import helper from "@/utils/mydate";
export default {
    components: {
        MyCreate,MyEdit
    MyCreate,
    MyEdit,
    },
    data() {
        return {
@@ -78,28 +118,28 @@
            unsame: false,
            myIdx: 0,
            preMyIdx: 0,
            info:'',
      info: "",
            options: [
                {
                    value: 0,
                    label: '批量操作',
          label: "批量操作",
                    disabled: true,
                },
                {
                    value: 1,
                    label: '批量启用',
          label: "批量启用",
                },
                {
                    value: 2,
                    label: '批量禁用',
          label: "批量禁用",
                },
                {
                    value: 3,
                    label: '批量删除',
                }
          label: "批量删除",
        },
            ],
            tempList: []
        }
      tempList: [],
    };
    },
    created() {
        this.setTableData();
@@ -112,53 +152,49 @@
        },
        // 删除数据
        handleDelete(idArr) {
            this.$confirm('是否确定确定删除栏目?')
                .then(_ => {
      this.$confirm("是否确定确定删除栏目?")
        .then((_) => {
                    this.$axios({
                        method: 'post',
                        url: 'sccg/message_column/delete' + '?ids=' + idArr,
                    })
                        .then(res => {
            method: "post",
            url: "sccg/message_column/delete" + "?ids=" + idArr,
          }).then((res) => {
                            if (res.code === 200) {
                                this.$message({
                                    type: 'success',
                                    message: '删除成功',
                type: "success",
                message: "删除成功",
                                });
                                this.setTableData();
                            }
          });
                        })
                })
                .catch(err=>{
                })
        .catch((err) => {});
        },
        // 修改栏目状态
        handleChangeStatus({ id, isShow }) {
            this.$axios({
                method: 'post',
        method: "post",
                url: `sccg/message_column/update/${id}`,
                data: {
                    isShow: Number(isShow),
                }
            })
                .then(res => {
        },
      }).then((res) => {
                    if (res.code === 200) {
                        this.setTableData();
                    }
                })
      });
        },
        // 获取全部栏目
        async getColumnList() {
            let arr = [];
            await this.$axios({
                method: 'get',
                url: 'sccg/message_column/getAllColumn',
            })
                .then(res => {
                    res.data.forEach(item => {
                        item.isShow === 1 ? item.isShow = true : item.isShow = false;
                    })
                    arr = res.data
                })
        method: "get",
        url: "sccg/message_column/getAllColumn",
      }).then((res) => {
        res.data.forEach((item) => {
          item.isShow === 1 ? (item.isShow = true) : (item.isShow = false);
        });
        arr = res.data;
      });
            return arr;
        },
        // 设置表格数据
@@ -180,46 +216,49 @@
            } else {
                this.myIdx = this.preMyIdx;
                this.$message({
                    type: 'warning',
                    message: '您还没选中任何数据',
                })
          type: "warning",
          message: "您还没选中任何数据",
        });
            }
        },
        // 批量操作
        mulUpdateStatus(idArr, flag) {
            this.$confirm(flag === 1 ? "您确定要进行批量启用角色吗?" : '您确定要进行批量禁用角色吗?')
                .then(_ => {
      this.$confirm(
        flag === 1
          ? "您确定要进行批量启用角色吗?"
          : "您确定要进行批量禁用角色吗?"
      )
        .then((_) => {
                    this.$axios({
                        method: 'post',
                        url: 'sccg/role/updateStatusBatch?ids=' + idArr + '&status=' + flag,
                    })
                        .then(res => {
            method: "post",
            url: "sccg/role/updateStatusBatch?ids=" + idArr + "&status=" + flag,
          }).then((res) => {
                            if (res.code === 200) {
                                this.$message({
                                    type: 'success',
                                    message: '更改用户状态成功',
                                })
                type: "success",
                message: "更改用户状态成功",
              });
                                this.getUserList();
                            } else {
                                this.$message({
                                    type: 'error',
                                    message: res.message
                                })
                type: "error",
                message: res.message,
              });
                            }
          });
                        })
                })
                .catch(err => {  })
        .catch((err) => {});
        },
        // 表格状态监听
        tableChange(list) {
            this.tempList = [];
            list.forEach(item => {
      list.forEach((item) => {
                this.tempList.push(item.id);
            })
      });
            if (list.length === this.tableData.length) {
                this.all = true;
            } else {
                this.all = false
        this.all = false;
            }
        },
        // 改变日期格式
@@ -232,18 +271,18 @@
        },
        // 反选
        disSame(list) {
            list.forEach(row => {
                this.$refs.multipleTable.toggleRowSelection(row)
            })
      list.forEach((row) => {
        this.$refs.multipleTable.toggleRowSelection(row);
      });
        },
        // 设置表格斑马纹
        tableRowClassName({ row, rowIndex }) {
            if ((rowIndex + 1) % 2 == 0) {
                return 'warning-row';
        return "warning-row";
            } else {
                return 'success-row';
        return "success-row";
            }
            return '';
      return "";
        },
        // 当前页改变触发事件
        changeCurrentPage(page) {
@@ -262,12 +301,11 @@
        },
        // 关闭弹窗
        handleClose(done) {
            this.$confirm('确定关闭?')
                .then(_ => {
      this.$confirm("确定关闭?")
        .then((_) => {
                    done();
                })
                .catch(err => {
                })
        .catch((err) => {});
        },
        // 自定义关闭弹窗
        closeDialog({ flag, index }) {
@@ -276,9 +314,9 @@
            if (index === 1) {
                this.setTableData();
            }
        }
    }
}
    },
  },
};
</script>
<style lang="scss" scoped>
.userList {
@@ -343,7 +381,6 @@
                        color: #4b9bb7;
                    }
                }
            }
            .pagination {
@@ -387,7 +424,7 @@
                .el-link {
                    color: #4b9bb7;
                }
        color: var(--operation-color);
                .leftPx {
                    margin-left: 10px;
                }