counter.vue 8.21 KB
<template>
  <div class="main">
    <div class="title">全部柜组( 共<span>{{page.total}}</span>个 )</div>
    <div class="searchs">
      <div class="buttons">
        <el-button class="button buttonlight" size="small" @click="addCounter">添加柜组</el-button>
        <el-button class="button buttondark" size="small" v-if="multipleSelection.length>1" @click="handleDelBatch">批量删除</el-button>
      </div>
      <!-- 搜索区 -->
      <el-form
        class="searchzone"
        :inline="true"
        :model="form"
        label-width="auto"
      >
        <el-form-item label="关键词">
          <el-input size="small"  v-model="form.keyWords" style="width:160px"
            placeholder="请输入关键词"  clearable/>
        </el-form-item>
        <el-button class="button buttondark" size="small" style="margin-top:4px;" @click="handleSearch">搜索</el-button>
      </el-form>
    </div>
    <div class="lists">
      <el-table
        stripe
        ref="multipleTable"
        :data="tableData"
        tooltip-effect="dark"
        style="width: 100%;"
        height="calc(100vh - 360px)"
        @selection-change="listPick"
      >
        <el-table-column type="selection" width="60"></el-table-column>
        <el-table-column
          prop="name"
          label="柜组"
          align="center"
        ></el-table-column>
        <el-table-column
          prop="principalName"
          label="柜组负责人"
          align="center"
        ></el-table-column>
        <el-table-column
          prop="num"
          label="柜组编号"
          align="center"
        ></el-table-column>
        <el-table-column
          prop="area"
          label="所在区域"
          align="center"
        ></el-table-column>
         <el-table-column
          prop="adminStallList.length"
          label="门店数量"
          align="center"
          width="120"
        ></el-table-column>
        <el-table-column label="创建时间" width="120" align="center" prop="createDate"/>
        <el-table-column label="操作" align="center" fixed="right" width="200">
          <template slot-scope="scope">
            <el-button type="text" class="btn" @click="handleDetail(scope.row.id)" >详情</el-button>
            <el-button type="text" class="btn" @click="handleEdit(scope.row.id)" >编辑</el-button >
            <el-button type="text" @click="handleDelete(scope.row.id)" class="listButtonRed">删除</el-button>
          </template>
        </el-table-column>
      </el-table>
    </div>
    <div class="pages">
      <el-pagination
      @current-change="handleCurrentChange"
      :current-page="page.currentPage"
      :page-size="page.size"
      layout="total, prev, pager, next, jumper"
      :total="page.total">
    </el-pagination>
    </div>
    <add-counter ref="addCounter"></add-counter>
    <counter-detail ref="counterDetail" :msgId="msgId" v-if="detailDialog" @handleDetailClose="handleDetailClose"></counter-detail>
    <edit-counter ref="editCounter" :msgId="editId" v-if="editDialog" @handleEditClose="handleEditClose"></edit-counter>
  </div>
</template>
<script>
import CounterDetail from "./components/counterDetail"
import AddCounter from "./components/addCounter"
import EditCounter from "./components/editCounter"
import { getList,stallDel } from "@/api/in/counter"
export default {
  components: {
    CounterDetail,
    AddCounter,
    EditCounter
  },
  data() {
    return {
      tableData: [],
      list: {
        search: {
          bar: [
            {
              id: "1",
              name: "全部"
            },
            {
              id: "2",
              name: "测试"
            }
          ],
          taskType: [
            {
              id: "1",
              name: "全部"
            },
            {
              id: "2",
              name: "测试"
            }
          ]
        }
      },
      detailDialog: false,
      counterDialog: false,
      editDialog: false,
      tableHeight: window.innerHeight * 0.5 ,
      page:{
          currentPage:1,
          size:10,
          total:0
      },
      form:{
        keyWords:''
      },
      msgId: "",
      editId: "",
      multipleSelection:[]
    };
  },
  mounted() {
    this.getListData()
  },
  methods: {
    getListData() {
      let param = {}
      let _this = this
      param.keyWords = this.form.keyWords? this.form.keyWords : 0
      param.pageNum = this.page.currentPage
      getList(param).then(res => {
        if(res.result == 'fail'){
          _this.$message.error(res.errorMsg)
          _this.tableData = []
        }
        if(res.result == 'success'){
          let data = res.data.pageInfo.list
          _this.tableData  =  data.map((v,i)=>{
            let obj = {}
            for(let key in v.adminShop){
              obj[key] = v.adminShop[key]
              obj.principalName = v.principal
            }
            return obj
          })
          _this.page.total = Number(res.data.pageInfo.total)
        }
      })
    },
    listPick(val) {
      this.multipleSelection = val;
    },
    handleEdit(id) {
      this.editId = id
      this.editDialog = true
      this.$refs.editCounter.counterDialog = true
    },
    //删除
    handleDelete(id) {
      let _this = this
      this.$confirm('确定删除该柜组吗?', {
        }).then(() => {
        stallDel({shopIds:id}).then(res=>{
          if(res.result == 'fail'){
            _this.$message.error(res.errorMsg)
          }
          if(res.result == 'success'){
            _this.getListData()
          }
        })
        }).catch(() => {
          this.$message.info("取消删除")
        });
    },
    //批量删除
    handleDelBatch(){
      let _this = this
      let delIds = this.multipleSelection.map(v=>{
        return v.id
      }).join(',')
      this.$confirm('确定批量删除柜组吗?', {
      }).then(() => {
        stallDel({shopIds:delIds}).then(res=>{
          if(res.result == 'fail'){
            _this.$message.error(res.errorMsg)
          }
          if(res.result == 'success'){
            _this.getListData()
          }
        })
      }).catch(() => {
        this.$message.info("取消删除")
      });
    },
    handleEditClose() {
      this.editDialog = false
    },
    pagesSizeChange() {},
    pagesNowPageChange() {},
    handleDetail(id) {
      this.msgId = id
      this.detailDialog = true
      this.$refs.counterDetail.detailDialog = true
    },
    handleDetailClose() {
      this.detailDialog = false
    },
    addCounter() {
      this.$refs.addCounter.counterDialog= true
    },
    addCounterFinish() {
      this.counterDialog = false
    },
    handleCurrentChange(val) {
      this.page.currentPage = val
      this.getListData()
    },
    //搜索 根据搜索条件查询
    handleSearch(){
      this.getListData()
    },
  },
 /*  mounted() {
     this.$nextTick(() => {
         this.tableHeight = window.innerHeight - 120;
     })
  } */
}
</script>
<style lang="scss" scoped>
.main {
  position: relative;
  background-color: #fff;
  box-sizing: border-box;
  height: 100%;
  padding: 0px 16px 16px;
  display: flex;
  flex-direction: column;
  justify-content: flex-start;
  width: 100%;
  box-shadow: 0px 2px 4px 0px #ddd;
}
.searchs {
  height: 40px;
  width: 100%;
  display: flex;
  flex-direction: row;
  justify-content: space-between;
  align-items: center;
}
.buttons {
  width: 266px;
  display: flex;
  flex-direction: row;
  justify-content: flex-start;
}
.buttonlight {
  background-color: #e8e9fe;
  color: #4e59c7;
  border: 1px solid #4e59c7;
  box-sizing: border-box;
}

.btn {
  font-size:14px;
  // font-weight:bold;
  color:rgba(102,102,102,1);
}
.buttondark {
  width: 88px;
  height: 32px;
  background-color: #4e59c7;
  color: #ffffff;
  border: 1px solid #4e59c7;
  box-sizing: border-box;
}

.searchzone {
  height: 40px;
  width: auto;
  min-width: 654px;
  text-align: right;
}
.lists {
  height: auto;
  min-height: 70%;
  width: 100%;
  margin-top: 20px;
}
.listButtonRed {
  color: #D0021B;
  // font-weight: bold;
}
.pages {
  height: 40px;
  width: 100%;
  display: flex;
  flex-direction: row;
  justify-content: flex-end;
  align-items: center;
}
.title {
  height: 48px;
  line-height: 48px;
  color:rgba(56,56,56,1);
  border-bottom: 1px solid #f8f8f8;
  margin-bottom: 16px;
}
</style>