<template>
    <div class="app-container">
    <el-dialog v-dialog-drag :title="title" :visible.sync="openView" width="500px" append-to-body>
        <el-form :model="queryParams" ref="queryForm" size="small" :inline="true" v-show="showSearch" label-width="68px">
        <el-form-item label="服务名称" prop="fwmc">
            <el-input
            v-model="queryParams.fwmc"
            placeholder="请输入服务名称"
            clearable
            @keyup.enter.native="handleQuery"
            />
        </el-form-item>
        <el-form-item>
          <el-button type="primary" icon="el-icon-search" size="mini" @click="handleQuery">搜索</el-button>
          <el-button icon="el-icon-refresh" size="mini" @click="resetQuery">重置</el-button>
        </el-form-item>
      </el-form>
      <el-table v-loading="loading" :data="fwxmList">
        <el-table-column type="selection" width="55" align="center"  />
        <el-table-column label="序号" type="index" align="center"/>
        <el-table-column label="服务名" align="center" prop="fwxmm" />
        <el-table-column label="服务类型" align="center" prop="fwlxmc">
        </el-table-column>
        <el-table-column label="护理等级" align="center" prop="hldj" />
        <el-table-column label="服务价格(元)" align="center" prop="jg" />
      </el-table>
      <pagination
        v-show="total>0"
        :total="total"
        :page.sync="queryParams.pageNum"
        :limit.sync="queryParams.pageSize"
        @pagination="getList"
        />
      <div slot="footer" class="dialog-footer">
        <el-button type="primary" @click="selectView">确 定</el-button>
        <el-button @click="cancel">取 消</el-button>
      </div>
        </el-dialog>
    </div>
</template>

<script>
import { listKhjbxx, getKhjbxx, delKhjbxx, addKhjbxx, updateKhjbxx } from "@/api/organization/khjbxx";

export default {
  name: "Khjbxx",
  props: {
      openView: {
          type: Boolean,
          default: false
      }
  },
  dicts: ['C0009', 'CZ036', 'CZ035', 'C0015', 'sys_user_sex', 'C0003', 'C0025', 'C0024', 'C0010', 'C0032', 'C0031', 'XZ002', 'CH045', 'CH063', 'CH065'],
  data() {
    return {
      // 遮罩层
      loading: true,
      // 选中数组
      ids: [],
      // 显示搜索条件
      showSearch: true,
      // 总条数
      total: 0,
      title: "选择客户",
      // 是否显示dialog
      openView: this.$props.openView,
      selectlist: [],
      // 查询参数
      queryParams: {
        pageNum: 1,
        pageSize: 10,
        fwmc: null,
      },
      // 表单参数
      form: {},
    };
  },
  created() {
    this.getList();
  },
  methods: {
    /** 查询养老机构_客户_基本信息列表 */
    getList() {
      this.loading = true;
      listKhjbxx(this.queryParams).then(response => {
        this.khjbxxList = response.rows;
        this.total = response.total;
        this.loading = false;
      });
    },
    // 取消按钮
    cancel() {
      this.selectlist = [];
      this.$emit("cancel", "");
    },
    selectView() {
        if (this.selectlist) {
            this.$emit("selectRow", this.selectlist[0]);
            this.cancel();
        } else {
            this.$modal.msgError("请选择客户");
        }
    },
    /** 搜索按钮操作 */
    handleQuery() {
      this.queryParams.pageNum = 1;
      this.getList();
    },
    /** 重置按钮操作 */
    resetQuery() {
      this.resetForm("queryForm");
      this.handleQuery();
    },
  }
};
</script>
