Newer
Older
smartKitchenFront / src / views / server / Management.vue
liuyangyingjie on 26 Oct 2022 6 KB first commit
<template>
  <div class="product_container">
    <div class="productFun">
      <div class="productInput">
        服务名称
        <div class="inputBox" style="width: 120px">
          <el-input
            placeholder="请输入服务名称"
            v-model="selectInfo.serviceName"
            clearable
            class="product-input"
          >
          </el-input>
        </div>
           服务类型
        <div class="inputBox" >
         <el-select v-model="selectInfo.typeCode" class="inquiry-select" filterable placeholder="请选择服务类型" style="width: 200px">
        <el-option v-for="item in options" :key="item.id" :label="item.typeName" :value="item.typeCode">
        </el-option>
      </el-select>
        </div>
      </div>
      <div class="productBtn">
        <el-button type="primary" icon="el-icon-search" class="btnItem"
        @click="selectData" >查询</el-button
        >
        
        <el-button
          type="success"
          icon="el-icon-circle-plus-outline"
          class="btnItem bggreen"
          @click="addCategory"
          >新增</el-button
        >
        <el-button type="danger" icon="el-icon-delete-solid" class="btnItem bgred"
          @click=" BatchDelete" >删除</el-button
        >
        
      </div>
    </div>
    <el-table
    ref="multipleTable"
      :data="tableData.rows"
      :row-class-name="tableRowClassName"
      :header-cell-style="{
        'text-align': 'center',
        background: '  #2483b3',
        color: 'white',
      }"
      :row-style="{ 'text-align': 'center' }"
      style="width: 100%"
    >
      <el-table-column type="selection" width="55"> </el-table-column>
      <el-table-column prop="index" label="序号"> </el-table-column>
      <el-table-column prop="serviceCode" label="服务编号"> </el-table-column>
      <el-table-column prop="serviceName" label="服务名称"> </el-table-column>
      <el-table-column prop="typeCode" label="服务类型"> </el-table-column>
      <el-table-column prop="description" label="服务描述"> </el-table-column>
      <el-table-column prop="serviceTime" label="服务时间"> </el-table-column>
      <el-table-column prop="remark" label="备注"> </el-table-column>
      <el-table-column label="操作">
        <template slot-scope="scope">
    
          <el-button @click="handleClick(scope.row)" type="text" size="small"
            >编辑</el-button
          >
          <el-button @click="Bdelete(scope.row)" type="text" size="small"
            >删除</el-button
          >
          <!-- <el-button type="text" size="small">编辑</el-button> -->
        </template>
      </el-table-column>
    </el-table>
   <!-- 分页组件 -->
   <group-page :limit ="limit" :total="total" :offset="offset" :count="tableData.total" @setOffset="setOffset"  @setLimit ="setLimit"  v-model="isFristPage"/>
    <!-- 新增弹框 -->
   
    <!-- <brand-add-dialog ></brand-add-dialog> -->
    <management-add-dialog :isShowInfo="isShowAdd"
      @close="closeAdd" :title="title" :dataInfo ="rowInfo"> </management-add-dialog>
  </div>
</template>
  
  <script>
//组件
import ManagementAddDialog from '../../components/mycomponent/dialog/server/managementAddDialog.vue';
import GroupPage from '../../components/mycomponent/groupPage.vue';
//逻辑
import { tableRowClassName } from "../../utils/myUtils/changeTableTr";
import { listMixin,elDataDialog } from '../../utils/myUtils/mixins/listPage'
import { listPage,M_batchDelete,M_delete} from '../../api/server/Management'
import { TM_list } from '../../api/server/TypeManagement'
export default {
  mixins:[listMixin,elDataDialog],
  components: {
    ManagementAddDialog,
    GroupPage
  },
  data() {
    return {
      isShowAdd: false, //显示新增功能
      selectInfo:{
        serviceName:'',
        typeCode:''
      },
      options:[],
      title:''
    };
  },
  mounted(){
    TM_list().then(res=>{
      console.log(res);
      this.options= res
    })
  },
  methods: {
    tableRowClassName: tableRowClassName,
    closeAdd() {
      this.isShowAdd = false;
      this.refresh()
    },
    addCategory() {
      this.title ="服务新增"
      this.isShowAdd = true;
      this.rowInfo= ''
    },
    handleClick(row){
      this.title ="服务编辑"
      this.isShowAdd = true;
      console.log(row);
      this.rowInfo =row
    },
      // 获取指定页面
      getListPage(limit,offset){
        listPage(`limit=${limit}&offset=${offset}`,this.queryInfo).then(res => {
      // 得到相关数据
      res.rows.forEach((item,index)=>{
        item.index =(index+1)+((offset-1)*10)
      })
      this.tableData = res 
     })
    },
      // 批量删除
      BatchDelete(){
      //  得到选中行
      const dle_ary =this.$refs.multipleTable.selection
      const ids = []
      dle_ary.forEach(ele => {
        ids.push(ele.id)
      })
      M_batchDelete({ids:ids}).then(res=>{
      if(res!=''){
          this.$message({
          message: '删除成功',
          type: 'success'
        });
        this.refresh()
        }
    })
    },
      // 删除
      Bdelete(row){
      // console.log(row);
      const id  = row.id
      M_delete({id:id}).then(res => {
        // console.log(res);
        // 删除成功跟新数据
        if(res!=''){
          this.$message({
          message: '删除成功',
          type: 'success'
        });
        this.refresh()
        }
      })
    },
  },
};
</script>
  
  <style lang="scss" scoped>
.product_container {
  position: relative;
  width: 100%;
  min-height: 700px;
  overflow: auto;
  .productData {
    width: 100%;
    display: flex;
    justify-content: center;
    .middle {
      margin: 0 30px;
    }
  }
  .productFun {
    margin: 30px 0;
    display: flex;
    justify-content: space-between;
    .productInput {
      display: flex;
      align-items: center;
      .inputBox {
        margin: 0 50px 0 10px;
      }
    }
    .productBtn {
      .btnItem {
        margin-right: 10px;
        border-radius: 5px;
        // height: 32px;
        // width: 84px;
        font-size: 16px;
      }
      
    }
  }
  .footer {
    display: flex;
    justify-content: space-between;
    color: #6666;
    margin: 30px 10px;
  }
}
</style>