Newer
Older
smartKitchenFront / src / views / server / operation.vue
<!--服务运营列表-->
<template>
  <div class="product_container">
    <div class="productFun">
      <div class="productInput">
        服务名称
        <div class="inputBox" style="width: 120px">
          <el-input
            v-model="selectInfo.input"
            placeholder="请输入服务名称"
            clearable
            class="product-input"
          />
        </div>
      </div>
      <div class="productBtn">
        <el-button
          type="primary"
          icon="el-icon-search"
          class="btnItem"
          @click="selectData"
        >
          查询
        </el-button>
        <el-button
          type="primary"
          icon="el-icon-refresh-right"
          class="btnItem"
          @click="reset"
        >
          重置
        </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"
      :row-class-name="tableRowClassName"
      :header-cell-style="{
        'text-align': 'center',
        background: '  #2483b3',
        color: 'white',
      }"
      :row-style="{ 'text-align': 'center' }"
      style="width: 100%"
      v-loading="loading"
    >
      <el-table-column type="selection" width="55" />
      <el-table-column prop="date1" label="序号" />
      <el-table-column prop="date" label="服务运营编号" />
      <el-table-column prop="name" label="服务名称" />
      <el-table-column prop="address" label="服务收费(元)" />
      <el-table-column prop="address1" label="服务优惠" />
      <el-table-column prop="address2" label="时间" />

      <el-table-column label="操作">
        <template slot-scope="scope">
          <el-button type="text" size="small" @click="handleClick(scope.row)">
            编辑
          </el-button>
          <el-button type="text" size="small" @click="Bdelete(scope.row)">
            删除
          </el-button>
          <!-- <el-button type="text" size="small">编辑</el-button> -->
        </template>
      </el-table-column>
    </el-table>
    <div class="footer">
      <div>共4条记录 第1/1页</div>
      <div>
        <el-pagination
          background
          layout="  prev, pager, next,sizes, jumper"
          :page-size="10"
          :total="10"
        />
      </div>
      <!-- <div>页码</div> -->
    </div>
    <!-- 新增弹框 -->

    <!-- <brand-add-dialog ></brand-add-dialog> -->
    <operation-add-dialog :is-show-info="isShowAdd" @close="closeAdd" />
  </div>
</template>

<script>
// 组件
// import BrandAddDialog from '../../components/mycomponent/dialog/brandAddDialog.vue';
import OperationAddDialog from "../../components/mycomponent/dialog/server/operationAddDialog.vue";
import { listPage, O_batchDelete, O_delete } from "../../api/server/operation";
// 逻辑
import { tableRowClassName } from "../../utils/myUtils/changeTableTr";

export default {
  components: {
    OperationAddDialog,
  },
  data() {
    return {
      isShowAdd: false, // 显示新增功能
      tableData: [
        {
          date1: "1",
          date: "fwyy001",
          name: "4年免费换新",
          address: "129",
          address1: "限时9折",
          address2: "2022/06/01-2022/06/15",
        },
        {
          date1: "2",
          date: "fwyy002",
          name: "5年免费换新",
          address: "169",
          address1: "限时9折",
          address2: "2022/06/01-2022/06/15",
        },
        {
          date1: "3",
          date: "fwyy003",
          name: "6年全面保修",
          address: "94",
          address1: "限时8折",
          address2: "2022/06/01-2022/06/15",
        },
        {
          date1: "4",
          date: "fwyy004",
          name: "7年免费换新",
          address: "110",
          address1: "限时8折",
          address2: "2022/06/01-2022/06/15",
        },
      ],
      options: [
        {
          value: "选项1",
          label: "黄金糕",
        },
        {
          value: "选项2",
          label: "双皮奶",
        },
        {
          value: "选项3",
          label: "蚵仔煎",
        },
        {
          value: "选项4",
          label: "龙须面",
        },
        {
          value: "选项5",
          label: "北京烤鸭",
        },
      ],
      value: "",
      selectInfo: {
        input: "",
      },
      loading:false
    };
  },
  methods: {
    tableRowClassName: tableRowClassName,
    closeAdd() {
      this.isShowAdd = false;
    },
    addCategory() {
      this.isShowAdd = true;
    },
    reset() {
      this.inpute = "";
    },
    // 获取指定页面
    getListPage(limit, offset) {
      this.loading = true
      listPage(`limit=${limit}&offset=${offset}`, this.queryInfo).then(
        (res) => {
          // 得到相关数据
          res.rows.forEach((item, index) => {
            item.index = index + 1 + (offset - 1) * 10;
          });
          this.tableData = res;
          this.loading = false
        }
      ).catch(err =>{
        this.loading = false
      })
    },
    // 批量删除
    BatchDelete() {
      if (this.$refs.multipleTable.selection.length !== 0) {
        this.$confirm(`确认删除选中的这些服务吗?`, "提示", {
          confirmButtonText: "确定",
          cancelButtonText: "取消",
          type: "warning",
        })
          .then(() => {
            //  得到选中行
            const dle_ary = this.$refs.multipleTable.selection;
            const ids = [];
            dle_ary.forEach((ele) => {
              ids.push(ele.id);
            });
            O_batchDelete({ ids: ids }).then((res) => {
              this.$message({
                message: "删除成功",
                type: "success",
              });
              this.refresh();
            });
          })
          .catch(() => {});
      } else {
        this.$message({
          message: "请先勾选需要删除的服务",
          type: "error",
        });
      }
    },
    // 删除
    Bdelete(row) {
      this.$confirm(`确认删除此服务吗?`, "提示", {
        confirmButtonText: "确定",
        cancelButtonText: "取消",
        type: "warning",
      })
        .then(() => {
          // console.log(row);
          const id = row.id;
          O_delete({ id: id }).then((res) => {
            // console.log(res);
            // 删除成功跟新数据
              this.$message({
                message: "删除成功",
                type: "success",
              });
              this.refresh();
          });
        })
        .catch(() => {});
    },
  },
};
</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: 0px 0px 30px;
    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>