<template>
  <div class="app-container">
      <el-form :model="queryParams" ref="queryForm" :inline="true" v-show="showSearch" label-width="68px">
        <el-form-item prop="phonenumber">
          <el-input
            v-model="queryParams.povertyAreaName"
            placeholder="请输入类别名称"
            clearable
            size="small"
            style="width: 240px"
            @keyup.enter.native="handleQuery"
          />
        </el-form-item>
        <el-form-item>
          <el-button type="cyan" 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-row :gutter="10" class="mb8">
        <el-col :span="1.5">
          <el-button
            type="primary"
            icon="el-icon-plus"
            size="mini"
            @click="handleAdd"
          >新增</el-button>
        </el-col>
        <right-toolbar :showSearch.sync="showSearch" @queryTable="getList"></right-toolbar>
      </el-row>
      <el-table v-loading="loading" :data="list">
        <el-table-column label="序号" type="index" width="50" align="center" />
        <el-table-column label="区域名称" align="center" prop="povertyAreaName" />
        <el-table-column label="区域地址" align="center" prop="areaAddress" :show-overflow-tooltip="true" />
        <el-table-column label="区域描述" align="center" prop="areaDesc" :show-overflow-tooltip="true" />
        <el-table-column
          label="操作"
          align="center"
          width="280"
          class-name="small-padding fixed-width"
        >
          <template slot-scope="scope">
            <el-button
              size="mini"
              type="primary"
              icon="el-icon-view"
              @click="handleView(scope.row)"
            >查看</el-button>
            <el-button
              size="mini"
              type="success"
              icon="el-icon-edit"
              @click="handleEdit(scope.row)"
            >编辑</el-button>
            <el-button
              size="mini"
              type="danger"
              @click="handleDelete"
              icon="el-icon-delete"
            >删除</el-button>
          </template>
        </el-table-column>
      </el-table>
      <pagination
        v-show="total>0"
        :total="total"
        :page.sync="queryParams.pageNum"
        :limit.sync="queryParams.pageSize"
        @pagination="getList"
      />
      <add-mobiel
      			v-if="modal.visibleModal"
      			:title="modal.title"
      			:action="modal.action"
      			:visible="modal.visibleModal"
      			:selectRow="modal.selectRow"
      			@closeModal="closeModal">
      		</add-mobiel>
  </div>
</template>
56757
<script>
import { listArea } from "@/api/belongToSubject/area";
import addMobiel from './modal/addMobiel'
export default {
  name: "area",
  components: {
    addMobiel
  },
  data() {
    return {
      // 遮罩层
      loading: true,
      // 显示搜索条件
      showSearch: true,
      // 总条数
      total: 0,
      // 表格数据
      list: null,
      // 状态数据字典
      statusOptions: [],
      // 表单参数
      form: {},
      //弹出层
      modal:{
        action:'',
        title:'',
        visibleModal:false,
        selectRow:null
      },
      // 查询参数
      queryParams: {
        pageNum: 1,
        pageSize: 10
      }
    };
  },
  created() {
    this.getList();
  },
  methods: {
    /** 查询产婆类别列表 */
    getList() {
      this.loading = false;
      this.list = [
        {
          id:"1",
          typeName:'test1',
          typeVal:'n019284423',
          methodology:'花菜',
          typeDesc:'备注描述',
          createTime:'2015.10.11',
          productTypeExpansionForms:[
            {
                expansionItem:'白菜'
            },
            {
                expansionItem:'花菜'
            }
          ]
        },
        {
          id:"2",
          typeName:'test1',
          typeVal:'n019284423',
          methodology:'花菜',
          typeDesc:'备注描述',
          createTime:'2015.10.11',
          productTypeExpansionForms:[
            {
                expansionItem:'白菜'
            },
            {
                expansionItem:'花菜'
            }
          ]
        },
        {
          id:"3",
          typeName:'test1',
          typeVal:'n019284423',
          methodology:'花菜',
          typeDesc:'备注描述',
          createTime:'2015.10.11',
          productTypeExpansionForms:[
            {
                expansionItem:'白菜'
            },
            {
                expansionItem:'花菜'
            }
          ]
        },
        {
          id:"3",
          typeName:'test1',
          typeVal:'n019284423',
          methodology:'花菜',
          typeDesc:'备注描述',
          createTime:'2015.10.11',
          productTypeExpansionForms:[
            {
                expansionItem:'白菜'
            },
            {
                expansionItem:'花菜'
            }
          ]
        }
      ]
      listArea(this.queryParams).then(res => {
          if(res.retHead.errCode == 0){
            this.list = res.retBody
            this.total = res.retHead.total
          }
        }
      );
    },
    /** 搜索按钮操作 */
    handleQuery() {
      this.queryParams.page = 1;
      this.getList();
    },
    /** 重置按钮操作 */
    resetQuery() {
      this.resetForm("queryForm");
      this.handleQuery();
    },
    /** 新增按钮操作 */
    handleAdd() {
        this.modal.visibleModal = true
        this.modal.title = '新增产品类别'
        this.modal.action = 'add'
    },
    /** 查看按钮操作 */
    handleView(item){
        this.modal.visibleModal = true
        this.modal.title = '产品类别详情'
        this.modal.action = 'view'
        this.modal.selectRow = item
    },
    /** 查看按钮操作 */
    handleEdit(item){
        this.modal.visibleModal = true
        this.modal.title = '编辑产品类别'
        this.modal.action = 'edit'
        this.modal.selectRow = item
    },
    /** 删除按钮操作 */
    handleDelete(row) {
      // const userIds = row.userId || this.ids;
      this.$confirm('是否确认删除该数据项?', "警告", {
          confirmButtonText: "确定",
          cancelButtonText: "取消",
          type: "warning"
        }).then(function() {
          // return delUser(userIds);
        }).then(() => {
          this.getList();
          this.msgSuccess("删除成功");
        }).catch(function() {});
    },
    //窗口关闭
    closeModal(flag = false){
      this.modal.visibleModal = false
      flag && this.getList()
    }
  }
};
</script>
