<template>
  <div>
    <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">
              <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.idCard }}</div>
                </div>
              </el-col>
              <el-col :span="12">
                <div class="items">
                  <div class="label">组织/部门：</div>
                  <div class="value">{{ detail.orgName }}</div>
                </div>
              </el-col>
              <el-col :span="12">

                <div class="items">
                  <div class="label">职位：</div>
                  <div class="value">
                    <span v-for="(role, index) in detail.szsqRoles" :key="index">
                      {{ role }}<span v-if="index < detail.szsqRoles.length - 1">、</span>
                    </span>
                  </div>
                </div>
              </el-col>
            </template>

            <template v-if="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="wantServiceTime"/>
              <el-table-column v-if="type === 1" label="需求类型" prop="categoryAllName"/>
              <el-table-column v-if="type === 1" label="需求内容" prop="content"/>
              <el-table-column v-if="type === 1" label="满意度" prop="score"/>
              <el-table-column v-if="type === 1" label="状态" prop="statusName"/>

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

              <el-table-column label="操作" prop="op">
                <template slot-scope="scope">
                  <span v-if="type === 1" class="view" @click="handleViewsSeverice(scope.row)">查看</span>
                  <span v-else 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>
    <ServiceDetails ref="ServiceDetails" :currentLevelData="currentLevelData"/>
    <ServiceDetailsLookForSb :id="rowId" :showDialog="showDialog" :type="type" @close="showDialog = false"/>
  </div>
</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";
import ServiceDetails from "@/views/dataBoard/overview/components/ServiceDetails.vue";
import ServiceDetailsLookForSb from "@/views/dataBoard/overview/components/ServiceDetailsLookForSb.vue";

export default {
  name: "MapResourceInfoMore",
  components: {Pagination, Tabs, CallPhone, Title, ServiceDetails, ServiceDetailsLookForSb},
  props: {
    currentLevelData: {
      type: Object,
      default: () => {}
    }
  },
  data() {
    return {
      dialogVisible: false,
      total: 0,
      queryParams: {
        pageSize: 5,
        pageNo: 1,
      },
      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,
        },
      ],
      rowId: '',
      showDialog: false
    }
  },
  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
      this.queryParams.serviceOrgType =
          data.type === 1 ? 'ic_user_volunteer' :
              data.type === 2 ? 'party_unit' :
                  data.type === 3 ? 'community_org' :
                      data.type === 4 ? 'grid_member' :
                          data.type === 5 ? 'publicWelfare' : ''

      this.queryParams.serverId = data.id
      this.queryParams.serviceOrgId = data.id
      this.getList()
    },
    getList() {

      if (this.type === 1) {
        this.getPersonalizedServices();
      }
      if (this.type === 2) {
        this.getServiceFindPeople();
      }
      if (this.type === 3) {
        this.getWarmthAndFindPeople();
      }
      if (this.type === 4) {
        this.getJobAndFindPeople();
      }
      if (this.type === 5) {
        this.getSkillsToFindPeople();
      }
    },
    getPersonalizedServices() {
      this.$http.post('/governance/userdemand/pagelist', {...this.queryParams}).then(({data: {data}}) => {
        this.list = data.list
        this.total = data.total
      })
    },
    getServiceFindPeople() {
      this.$http.post('/governance/icServiceRecordV2/searchList?' + this.$paramsFormat(this.queryParams),this.queryParams).then(({data: {data}}) => {
        this.list = data.list;
        this.total = data.total;
      })
    },
    getWarmthAndFindPeople() {
      this.$http.post('/governance/icServiceWarmRecord/searchList?' + this.$paramsFormat(this.queryParams),this.queryParams).then(({data: {data}}) => {
        this.list = data.list;
        this.total = data.total;
      })
    },
    getJobAndFindPeople() {
      this.$http.post('/governance/icServicePostRecord/searchList?' + this.$paramsFormat(this.queryParams),this.queryParams).then(({data: {data}}) => {
        this.list = data.list;
        this.total = data.total;
      })
    },
    getSkillsToFindPeople() {
      this.$http.post('/governance/icServiceSkillRecord/searchList?' + this.$paramsFormat(this.queryParams),this.queryParams).then(({data: {data}}) => {
        this.list = data.list;
        this.total = data.total;
      })
    },
    typeChange(val) {
      this.type = val
      this.queryParams.pageNo = 1
      this.list = []
      this.getList()
    },
    handleViewsSeverice({demandRecId}) {
      this.$refs.ServiceDetails.open(demandRecId);
    },
    handleViews({serviceRecordId}) {
      this.rowId = serviceRecordId
      this.showDialog = true
    },
    getAgeByDateOfBirth(dateOfBirth) {
      let birthDate = this.$moment(dateOfBirth);
      let age = this.$moment().diff(birthDate, 'years');
      return age;
    },
  }
}
</script>

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

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

.contents {
  padding: 40px 50px 0;

  .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;
  cursor: pointer;
}

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