<template>
  <el-dialog
      :before-close="handleClose"
      :modal="true"
      :modal-append-to-body="false"
      :visible.sync="dialogVisible"
      class="dissatisfied-detail"
      title=""
      width="1118px"
  >
    <div class="content">
      <div class="main-title main-title2">
        <Title text="查看更多"/>
      </div>

      <div class="contents">
        <el-row>
          <el-col :span="12">
            <div class="items">
              <div class="label">资源类型：</div>
              <div class="value">{{ typesList[types] }}</div>
            </div>
          </el-col>
          <template v-if="types === 2 || types === 3">
            <el-col :span="12">

              <div class="items">
                <div class="label">单位名称：</div>
                <div class="value">{{ detail.unitName }}</div>
              </div>
            </el-col>
            <el-col :span="12">
              <div class="items">
                <div class="label">分类：</div>
                <div class="value">{{ detail.typeName }}</div>
              </div>
            </el-col>
            <el-col :span="12">
              <div class="items">
                <div class="label">服务事项：</div>
                <div class="value">{{
                    detail.serviceMatterNameList ? detail.serviceMatterNameList.join('、') : ''
                  }}
                </div>
              </div>
            </el-col>
            <el-col :span="12">
              <div class="items">
                <div class="label">联系人：</div>
                <div class="value">{{ detail.contact }}</div>
              </div>
            </el-col>
            <el-col :span="12">
              <div class="items">
                <div class="label">联系电话：</div>
                <div class="value">{{ detail.contactMobile }}</div>
                <CallPhone icon="el-icon-phone"/>
              </div>
            </el-col>
            <el-col :span="12">
              <div class="items">
                <div class="label">地理位置：</div>
                <div class="value">{{ detail.address }}</div>
              </div>
            </el-col>
          </template>
          <template v-if="types === 3">
            <el-col :span="12">
              <div class="items">
                <div class="label">组织名称：</div>
                <div class="value">{{ detail.organizationName }}</div>
              </div>
            </el-col>
            <el-col :span="12">
              <div class="items">
                <div class="label">分类：</div>
                <div class="value">{{ detail.categoryName }}</div>
              </div>
            </el-col>
            <el-col :span="12">
              <div class="items">
                <div class="label">服务事项：</div>
                <div class="value">{{ detail.serviceItem }}</div>
              </div>
            </el-col>
            <el-col :span="12">
              <div class="items">
                <div class="label">联系人：</div>
                <div class="value">{{ detail.principalName }}</div>
              </div>
            </el-col>
            <el-col :span="12">
              <div class="items">
                <div class="label">联系电话：</div>
                <div class="value">{{ detail.principalPhone }}</div>
                <CallPhone icon="el-icon-phone"/>
              </div>
            </el-col>
            <el-col :span="12">
              <div class="items">
                <div class="label">地理位置：</div>
                <div class="value">{{ detail.address }}</div>
              </div>
            </el-col>
          </template>

          <template v-if="types === 4 || types === 5 || types === 1">
            <el-col :span="12">
              <div class="items">
                <div class="label">姓名：</div>
                <div class="value">{{ detail.name }}</div>
              </div>
            </el-col>
            <el-col :span="12">
              <div class="items">
                <div class="label">联系电话：</div>
                <div class="value">{{ detail.mobile }}</div>
                <CallPhone icon="el-icon-phone"/>
              </div>
            </el-col>
            <el-col :span="12">
              <div class="items">
                <div class="label">年龄：</div>
                <div class="value">{{ detail.birthday ? getAgeByDateOfBirth(detail.birthday) : '未知' }}</div>
              </div>
            </el-col>
            <el-col :span="12">
              <div class="items">
                <div class="label">学历：</div>
                <div class="value">{{ education ? education.cultureLevelName : '' }}</div>
              </div>
            </el-col>
            <el-col :span="12">
              <!--            <div class="items">
                            <div class="label">状态：</div>
                            <div class="value">巡查中</div>
                          </div>-->

              <div class="items">
                <div class="label">所在位置：</div>
                <div class="value">{{ detail.houseInfo.homeName }}</div>
              </div>
            </el-col>
            <el-col :span="12">
              <div class="items">
                <div class="label">兴趣爱好：</div>
                <div class="value">{{ hobby ? hobby.hobbyRemark : '' }}</div>
              </div>
            </el-col>
          </template>
        </el-row>
        <Tabs v-model="type" :list="typeList" @changeVal="typeChange"/>
        <div class="table">
          <el-table v-loading="loading" :data="list" element-loading-background="rgba(0, 0, 0, 0.3)"
                    height="250px">
            <el-table-column label="序号" type="index"/>

            <el-table-column v-if="type === 1" label="服务时间" prop="key"/>
            <el-table-column v-if="type === 1" label="需求类型" prop="key"/>
            <el-table-column v-if="type === 1" label="需求内容" prop="key"/>
            <el-table-column v-if="type === 1" label="满意度" prop="key"/>
            <el-table-column v-if="type === 1" label="状态" prop="key"/>

            <el-table-column v-if="type !== 1" label="服务类型" prop="key"/>
            <el-table-column v-if="type !== 1" label="服务事项" prop="key"/>
            <el-table-column v-if="type !== 1" label="来自" prop="key"/>
            <el-table-column v-if="type !== 1" label="服务时间" prop="key"/>
            <el-table-column v-if="type !== 1" label="服务人数" prop="key"/>

            <el-table-column label="操作" prop="op">
              <template slot-scope="scope">
                <span class="view" @click="handleViews(scope.row)">查看</span>
              </template>
            </el-table-column>
          </el-table>
          <Pagination
              v-show="total > 0"
              :limit.sync="queryParams.pageSize"
              :page.sync="queryParams.pageNo"
              :total="total"
              @pagination="getList"
          />
        </div>
      </div>
    </div>
  </el-dialog>
</template>

<script>
import Pagination from "@/views/dataBoard/satisfactionEval/components/Pagination";
import Tabs from "@/views/dataBoard/satisfactionEval/components/Tabs/index.vue";
import CallPhone from "@/views/dataBoard/cpts/CallPhone";
import Title from "@/views/dataBoard/satisfactionEval/components/Title";

export default {
  name: "MapResourceInfoMore",
  components: {Pagination, Tabs, CallPhone, Title},
  data() {
    return {
      dialogVisible: false,
      total: 10,
      queryParams: {},
      type: "1",
      list: [],
      loading: false,
      typesList: {
        1: '志愿者',
        2: '联建单位',
        3: '社区自组织',
        4: '网格员',
        5: '公益岗'
      },
      detail: {},
      types: '',
      education: {},
      hobby: {},
      typeList: [
        {
          label: "个性服务",
          value: 1,
        },
        {
          label: "服务找人",
          value: 2,
        },
        {
          label: "温暖找人",
          value: 3,
        },
        {
          label: "岗位找人",
          value: 4,
        },
        {
          label: "技能找人",
          value: 5,
        },
      ],
    }
  },
  mounted() {

  },
  methods: {
    handleClose(done) {
      this.dialogVisible = false;
    },
    open(data) {
      this.detail = data.detail;
      this.types = data.type;
      this.education = data.education;
      this.hobby = data.hobby;
      this.dialogVisible = true;
    },
    getList() {
      if (this.type === 1) {
        this.getPersonalizedNeeds();
      }
      if (this.type === 1) {
        this.getPersonalizedServices();
      }
      if (this.type === 1) {
        this.getServiceFindPeople();
      }
      if (this.type === 1) {
        this.getWarmthAndFindPeople();
      }
      if (this.type === 1) {
        this.getJobAndFindPeople();
      }
      if (this.type === 1) {
        this.getSkillsToFindPeople();
      }
    },
    getPersonalizedServices() {
      this.$http.post('/api/governance/userdemand/pagelist', {...this.queryParams}).then(({data: {data}}) => {
        this.list = data.list
        this.total = data.total
      })
    },
    getPersonalizedNeeds() {
      this.$http.get('icServiceRecordV2/searchList', {...this.queryParams}).then(({data: {data}}) => {
        this.list = data.list
        this.total = data.total
      })
    },
    getServiceFindPeople() {
      this.$htpp.get('', {...this.queryParams}).then(({data: {data}}) => {
        this.list = data.list;
        this.total = data.total;
      })
    },
    getWarmthAndFindPeople() {
      this.$htpp.get('', {...this.queryParams}).then(({data: {data}}) => {
        this.list = data.list;
        this.total = data.total;
      })
    },
    getJobAndFindPeople() {
      this.$htpp.get('', {...this.queryParams}).then(({data: {data}}) => {
        this.list = data.list;
        this.total = data.total;
      })
    },
    getSkillsToFindPeople() {
      this.$htpp.get('', {...this.queryParams}).then(({data: {data}}) => {
        this.list = data.list;
        this.total = data.total;
      })
    },
    typeChange() {

    }
  }
}
</script>

<style lang="scss" scoped>
@import "@/assets/scss/dataBoard/table2.scss";

@import "~@/assets/scss/dataBoard/dialog.scss";

.contents {
  padding: 40px 50px;

  .items {
    font-size: 14px;
    position: relative;
    display: flex;
    align-items: center;
    margin-bottom: 17px;

    .label {
      color: #9CB4D3;
    }

    .value {
      color: #FFFFFF;
    }
  }
}

.table {
  margin-top: 20px;
}

.handle {
  font-size: 14px;
  margin-left: 10px;
  color: #9A69EC;
}

.view {
  font-size: 14px;
  margin-left: 10px;
  color: #007FF1;
}
</style>