Newer
Older
smartKitchenFront / src / views / system / certification.vue
liyaguang on 6 Dec 2022 8 KB fix: 修改资质管理相关功能
<!--资质管理列表-->
<template>
  <div class="product_container">
    <div class="productFun">
      <div class="productInput">
        编号
        <div class="inputBox" style="width: 120px">
          <el-input
            v-model="selectInfo.qualifyCode"
            placeholder="请输入编号"
            clearable
            class="product-input"
          />
        </div>
        名称
        <div class="inputBox" style="width: 144px">
          <el-input
            v-model="selectInfo.qualifyName"
            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>
        <el-button
          type="primary"
          icon="el-icon-folder-opened"
          class="btnItem"
          @click="exportToExcel"
        >
          导出
        </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 prop="index" label="序号" width="50" />
      <el-table-column prop="qualifyCode" label="资质编号" />
      <!-- <el-table-column prop="id" label="序号"> </el-table-column> -->
      <el-table-column prop="qualifyName" label="资质要求名称" />
      <el-table-column prop="qualifyDesc" label="资质要求描述" />
      <el-table-column prop="proveMaterialDesc" label="资质要求证明材料要求" />
      <el-table-column prop="remark" label="备注" />
      <el-table-column label="操作">
        <template slot-scope="scope">
          <el-button type="text" size="small" @click="showInfo(scope.row)">
            详情
          </el-button>
          <el-button type="text" size="small" @click="compile(scope.row)">
            编辑
          </el-button>
          <el-button type="text" size="small" @click="Cdelete(scope.row)">
            删除
          </el-button>
          <!-- <el-button type="text" size="small">编辑</el-button> -->
        </template>
      </el-table-column>
    </el-table>
    <!-- 分页组件 -->
    <group-page
      v-model="isFristPage"
      :limit="limit"
      :total="total"
      :offset="offset"
      :count="tableData.total"
      @setOffset="setOffset"
      @setLimit="setLimit"
    />
    <!-- 新增弹框 -->
    <!-- <category-add-dialog
      :title="title"
      :isShowInfo="isShowAdd"
      :dataInfo="dataInfo"
      @close="closeAdd"
      @refresh="refresh"
    ></category-add-dialog> -->
    <certification-add-dlalog
      :title="title"
      :is-show-info="isShowAdd"
      :data-info="dataInfo"
      @close="closeAdd"
    />
    <!-- 详情 -->

    <CertificationInfoDlalog
      :is-show-info="isshowDetail"
      :data-info="rowInfo"
      :Detailclose="closeDetail"
    />
  </div>
</template>

<script>
// 组件

import GroupPage from "../../components/mycomponent/groupPage.vue";

// 逻辑
import { tableRowClassName } from "../../utils/myUtils/changeTableTr";
import { listPage, batchDelete, Cdelete } from "../../api/system/certification";
import { listMixin, elDataDialog } from "../../utils/myUtils/mixins/listPage";
import { outToExcel } from "../../utils/myUtils/exportToExcel";
import CertificationAddDlalog from "../../components/mycomponent/dialog/certification/certificationAddDlalog.vue";
import CertificationInfoDlalog from "../../components/mycomponent/dialog/certification/certificationInfoDlalog.vue";
export default {
  // 加入分页逻辑
  components: {
    GroupPage,
    CertificationAddDlalog,
    CertificationInfoDlalog,
  },
  mixins: [listMixin, elDataDialog],
  data() {
    return {
      title: "", // 弹框标题
      dataInfo: {}, // 编辑 , 新增数据
      isShowAdd: false, // 显示新增, 编辑
      isShowdetail: false, //详情 显示
      rowInfo:{},
      selectInfo: {
        // 搜索框中的数据的数据
        qualifyCode: "",
        qualifyName: "",
      },
    };
  },
  mounted() {
    // 获取品类列表
  },
  methods: {
    tableRowClassName: tableRowClassName,
    closeAdd() {
      this.isShowAdd = false;
      this.refresh();
    },

    addCategory() {
      this.isShowAdd = true;
      this.dataInfo = "";
      this.title = "新增资质要求";
    },
    reset() {
      this.selectInfo = {
        qualifyCode: "",
        qualifyName: "",
      };
      // this.queryInfo = { ...this.selectInfo}
      listPage(`limit=${10}&offset=${1}`, {}).then((res) => {
        // 得到相关数据
        res.rows.forEach((item, index) => {
          item.index = index + 1 + (1 - 1) * 10;
        });
        this.tableData = res;
      });
    },
    // 获取指定页面
    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;
        }
      );
    },
    // 删除
    Cdelete(row) {
      this.$confirm("确认删除此项数据?", "提示", {
        confirmButtonText: "确定",
        cancelButtonText: "取消",
        type: "warning",
      }).then((res) => {
        const id = row.id;
        Cdelete({ id: id }).then((res) => {
          //  删除成功 跟新列表
          this.$message({
            message: "删除成功",
            type: "success",
          });
          this.refresh();
        });
      });
    },
    //  批量删除
    BatchDelete() {
      if (this.$refs.multipleTable.selection.length) {
        this.$confirm("确认删除选中的这些数据?", "提示", {
          confirmButtonText: "确定",
          cancelButtonText: "取消",
          type: "warning",
        }).then((res) => {
          //  得到选中行
          const dle_ary = this.$refs.multipleTable.selection;
          const ids = [];
          dle_ary.forEach((ele) => {
            ids.push(ele.id);
          });
          batchDelete({ ids: ids }).then((res) => {
            this.$message({
              message: "删除成功",
              type: "success",
            });
            this.refresh();
          });
        });
      } else {
        this.$message.warning("请先选择需要删除的数据");
      }
    },
    //  编辑
    compile(row) {
      this.isShowAdd = true;
      this.title = "编辑";
      this.dataInfo = row;
    },
    //  详情
    showInfo(row) {
      this.rowInfo = row
      this.isshowDetail = true
      this.title = "详情";
      console.log(this.isshowDetail)
    },
    closeDetail(row) {
      console.log(456)
      this.isshowDetail = false
    },
    exportToExcel() {
      listPage("limit=1000000000&offset=1", {}).then((res) => {
        res.rows = res.rows.map((item, index) => {
          return {
            序号: index + 1,
            资质编号: item.qualifyCode,
            资质要求名称: item.qualifyName,
            资质要求描述: item.qualifyDesc,
            证明材料: item.proveMaterialDesc,
            备注: item.remark,
          };
        });
        outToExcel(res.rows, "资质管理");
      });
    },
  },
};
</script>

<style lang="scss" scoped>
.el-form-item__label {
  width: 115px;
  text-align: inherit;
  line-height: 21px !important;
}
.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>