<template>
  <div>
    <div class="search-wrapper">
      <el-form
        :inline="true"
        :model="searchForm"
        class="search_form"
        style="text-align: left"
      >
        <el-form-item label="用户名称">
          <el-input
            v-model="searchForm.name"
            placeholder="请输入用户名称"
            @keyup.enter.native="onSubmit"
          ></el-input>
        </el-form-item>
        <el-form-item label="需求类型">
          <el-select
            v-model="searchForm.typeId"
            placeholder="请选择需求类型"
            @change="onSubmit"
            size="medium"
          >
            <el-option
              v-for="item in TypeList"
              :key="item.id"
              :label="item.name"
              :value="item.id"
            >
            </el-option>
          </el-select>
        </el-form-item>
      </el-form>
    </div>
    <div class="table-wrapper">
      <table-template
        :tableData="tableData"
        :tableColumns="tableColumns"
        :loading="loading"
        :pagination="pagination"
        @Jump="jumpPage"
      >
        <el-table-column slot="icon" label="服务图标" align="center">
          <template slot-scope="scope">
            <el-image
              style="width: 30px; height: 30px"
              :src="scope.row.icon"
              :preview-src-list="[scope.row.icon]"
            >
            </el-image>
          </template>
        </el-table-column>
        <el-table-column fixed="right" label="操作" width="350" align="center">
          <template slot-scope="scope">
            <el-button type="primary" size="mini" round @click="view(scope.row)"
              >查看</el-button
            >
            <el-button
              type="success"
              size="mini"
              class="btn"
              round
              @click="edit(scope.row)"
              >编辑</el-button
            >
            <el-popconfirm title="确定删除此数据吗？" @confirm="del(scope.row)">
              <el-button type="warning" size="mini" round slot="reference"
                >删除</el-button
              >
            </el-popconfirm>
          </template>
        </el-table-column>
      </table-template>
    </div>

    <el-dialog title="编辑" :visible.sync="dialogVisible" width="30%">
      <el-form
        :model="dataForm"
        :rules="rules"
        ref="ruleForm"
        label-width="100px"
        class="demo-ruleForm"
      >
        <el-form-item label="服务名称" prop="name">
          <el-input v-model="dataForm.name"></el-input>
        </el-form-item>
      </el-form>

      <span slot="footer" class="dialog-footer">
        <el-button @click="dialogVisible = false">取 消</el-button>
        <el-button type="primary" @click="dialogVisible = false"
          >确 定</el-button
        >
      </span>
    </el-dialog>
  </div>
</template>

<script>
import TableTemplate from "@/components/Table";

export default {
  components: { TableTemplate },

  data() {
    return {
      searchForm: {},
      TypeList: [],
      loading: false,
      tableData: [
        {
          name: "服务名称",
          type: "所属类型",
          icon: require("@/assets/1.png"),
          wx: "1",
        },
      ],
      tableColumns: [
        {
          key: "name",
          label: "用户名称",
        },
        {
          key: "type",
          label: "需求类型",
        },
        {
          key: "desc",
          label: "需求描述",
        },
        {
          key: "address",
          label: "详细地址",
        },
        {
          key: "icon",
          label: "照片",
          type: "slot",
        },
        {
          key: "phone",
          label: "联系电话",
        },
        {
          key: "wx",
          label: "微信号",
        },
      ],
      pagination: {
        total: 0,
        pageSize: 10,
        currentPage: 1,
      },
      rules: {
        name: [{ required: true, message: "请输入活动名称", trigger: "blur" }],
      },
      dataForm: {},
      dialogVisible: false,
    };
  },
  watch: {
    dialogVisible(val) {
      if (!val) {
        this.$refs.ruleForm.resetFields();
      }
    },
  },
  created() {
    this.init();
  },
  methods: {
    init() {},
    onSubmit() {},
    jumpPage() {
      this.init();
    },
    view() {
      this.dialogVisible = true;
    },
    edit() {
      this.dialogVisible = true;
    },
    del() {},
  },
};
</script>

<style lang="stylus" scoped>
@import '~@/stylus/common';
.btn{
    margin-right 10px
}
</style>
