<!-- 收银台订单-->
<template>
  <div style="padding-top: 15px; padding-right: 40px; background: #f6f8f9;">
    <el-card class="box-card" shadow="never">
      <el-form :model="queryParams" ref="queryForm" size="small" :inline="true" label-width="120px">

        <el-form-item label="" prop="deptId" style="width: 180px">
          <el-input
            v-model="queryParams.realName"
            placeholder="请选择设备类型"
            clearable
            @keyup.enter.native="handleQuery"
          />
        </el-form-item>
        <el-form-item label="" prop="deptId" style="width: 180px">
          <el-select
            v-model="queryParams.deptId"
            clearable
            placeholder="请输入设备名称"
          >
            <el-option v-for="item in deptList" :key="item.id" :label="item.deptName" :value="item.deptId">
            </el-option>
          </el-select>
        </el-form-item>
        <el-form-item label="" prop="status" style="width: 180px">
          <el-select
            v-model="queryParams.status"
            clearable
            placeholder="请选择设备状态"
          >
            <el-option
              v-for="dict in dict.type.zhzt"
              :key="dict.value"
              :label="dict.label"
              :value="dict.value"
            />
          </el-select>
        </el-form-item>
        <el-form-item style="float: right">
          <el-button type="primary" icon="el-icon-search" @click="handleQuery">搜索</el-button>
          <el-button icon="el-icon-refresh" @click="resetQuery">重置</el-button>
          <el-button type="primary" @click="handleAdd">新增设备</el-button>
        </el-form-item>

      </el-form>


      <!--    </el-card>-->
      <!--    <el-card class="box-card" style="min-height: 500px;" shadow="never">-->
      <div class="table-box">
        <el-table
          :data="orderList"
          style="width: 100%">
          <el-table-column type="index" width="50" align="center" label="序号"/>
          <el-table-column prop="storeName" align="center" label="设备类型"></el-table-column>
          <el-table-column prop="storeName" align="center" label="设备名称"></el-table-column>
          <el-table-column prop="payMoney" align="center" label="设备ID"></el-table-column>
          <el-table-column prop="count" align="center" label="创建人"></el-table-column>
          <el-table-column prop="refMoney" align="center" label="创建时间"></el-table-column>
          <el-table-column align="center" label="操作">
            <template slot-scope="scope">
              <el-button
                size="mini"
                type="text"
                icon="el-icon-edit"
                @click="handleUpdate(scope.row)"
              >修改</el-button>
              <el-button
                size="mini"
                type="text"
                icon="el-icon-delete"
                @click="handleDelete(scope.row)"
              >删除</el-button>
            </template>
          </el-table-column>
        </el-table>
      </div>
      <pagination
        v-show="total>0"
        :total="total"
        :page.sync="queryParams.page"
        :limit.sync="queryParams.pageSize"
        @pagination="getList"
      />
    </el-card>

    <!-- 添加或修改对话框 -->
    <el-dialog center :close-on-click-modal="false" :title="title" :visible.sync="open" width="30%" append-to-body>
      <el-form ref="form" :model="form" :rules="rules" label-width="120px">

        <el-form-item label="设备名称" prop="realName">
          <el-input v-model="form.realName" placeholder="请输入设备名称" maxlength="30" style="width: 270px"/>
        </el-form-item>

        <el-form-item label="品牌" prop="pinpai">
          <el-input v-model="form.pinpai" placeholder="请输入品牌名称" maxlength="30" style="width: 270px"/>
        </el-form-item>

        <el-form-item label="设备功能" prop="gongneng">
<!--          <el-checkbox-group v-model="form.gongneng">-->
            <el-checkbox v-model="form.gongneng" label="打印小票"></el-checkbox>
            <el-checkbox v-model="form.gongneng" label="语音播报"></el-checkbox>
<!--          </el-checkbox-group>-->
        </el-form-item>

        <el-form-item label="设备终端号" prop="zhongduan">
          <el-input v-model="form.zhongduan" placeholder="请输入设备终端号" />
        </el-form-item>
        <el-form-item label="密钥" prop="miyao">
          <el-input v-model="form.miyao" placeholder="请输入密钥" />
        </el-form-item>
        <el-form-item label="关联员工" prop="staffId">
          <el-input v-model="form.staffId" placeholder="请输入关联员工" />
        </el-form-item>


        <el-form-item label="用户状态" prop="status">
          <el-switch
            v-model="form.status"
            active-value="qy"
            inactive-value="jy"
            active-color="#13ce66"
            inactive-color="#ff4949">
          </el-switch>
        </el-form-item>

        <el-form-item label="备注" >
          <el-input v-model="form.desc" placeholder="请输入备注" type="textarea"/>
        </el-form-item>

      </el-form>
      <div slot="footer" class="dialog-footer">
        <el-button type="primary" @click="submitForm">确 定</el-button>
        <el-button @click="cancel">取 消</el-button>
      </div>
    </el-dialog>
  </div>
</template>

<script>

import {delStaff} from "@/api/staff/staff";

export default {
  dicts: ['zhzt'],
  data() {
    return {
      loading: false,
      open:false,
      title:'',
      // 日期范围
      dateRange: [],
      beginTime: "",
      endTime: "",
      // 收银台订单列表
      orderList: [],
      deptList: [],
      form:{},
      // 查询参数
      queryParams: {
        page: 1,
        pageSize: 10,
      },
      total: 0,
      // 表单校验
      rules: {
        realName: [
          {required: true, message: "设备名称不能为空", trigger: "blur"},
        ],
        pinpai: [
          {required: true, message: "品牌不能为空", trigger: "blur"},
        ],
        gongneng: [
          {required: true, message: "设备功能不能为空", trigger: "blur"}
        ],
        zhongduan: [
          {required: true, message: "设备终端号不能为空", trigger: "blur"}
        ],
        miyao: [
          {required: true, message: "密钥不能为空", trigger: "blur"}
        ],
        staffId: [
          {required: true, message: "关联员工不能为空", trigger: "blur"}
        ],
        status: [
          {required: true, message: "状态不能为空", trigger: "blur"}
        ]
      }
    }
  },
  created() {
    this.getList();

  },
  methods: {
    getDeptList() {
      // getRunningWaterByTissueApi(this.addDateRange(this.queryParams)).then(response => {
      //   this.deptList = response.data.records;
      // })
    },
    // 获取列表信息
    getList() {

    },
    // 取消按钮
    cancel() {
      this.open = false;
      this.reset();
    },
    // 提交按钮
    submitForm: function () {
      this.$refs["form"].validate(valid => {
        if (valid) {
          if (!this.form.id) {

          } else {

          }
        }
      });
    },
    // 新增按钮操作
    handleAdd() {
      this.reset();
      this.open = true;
      this.title = "新增员工";
    },
    // 搜索按钮操作
    handleQuery() {
      this.queryParams.page = 1;
      this.getList();
    },
    // 重置按钮操作
    resetQuery() {
      this.dateRange = [];
      this.queryParams = {
        page: 1,
        pageSize: 10,
      }
      this.handleQuery();
    },
    // 修改按钮操作
    handleUpdate(row) {
      this.reset();
      this.open = true;
    },
    // 表单重置
    reset() {
      this.resetForm("form");
    },
    // 删除按钮操作
    handleDelete(row) {
      const name = row.realName || this.id;
      this.$modal.confirm('是否确认删除"' + name + '"的员工信息？').then(function() {
        return delStaff(row.id);
      }).then(() => {
        this.queryParams.page = 1
        this.getList();
        this.$modal.msgSuccess("删除成功");
      }).catch(() => {});
    }
  }
}
</script>

<style scoped>
.box-card {
  width: 100%;
  margin: 0px 20px 20px 20px;
  border: none;
  box-shadow: none;
}

.el-form--inline .el-form-item {
  margin-right: 20px;
}

.table-box {
  width: 100%;
  height: 46vh;
  overflow: auto;
}

.wrap-boxs {
  width: 100%;
  display: flex;
  align-items: center;
  margin-bottom: 15px;
}

.k_ {
  width: 250px;
  height: 75px;
  margin-right: 20px;
  box-sizing: border-box;
  padding: 15px 10px;
  padding-top: 5px;
  color: #333333;
}

.size_ {
  font-weight: 400;
  font-size: 14px;
  color: #333333;
  margin-bottom: 20px;
}

.title_ {
  font-weight: 600;
  font-size: 24px;
  color: #333333;
}

.d-s {
  display: flex;
  align-items: center;
}

.anniu-h {
  width: 80px;
  height: 26px;
  background: #FAFAFA;
  border-radius: 4px 4px 4px 4px;
  border: 1px solid #DDDDDD;
  display: flex;
  align-items: center;
  justify-content: center;
  color: #777777;
  margin-right: 20px;
}

.anniu-act {
  background: #FF9655 !important;
  border: 1px solid #FF9655 !important;
  color: #fff;

}

</style>
