<template>
  <div class="app-container">
    <!-- 搜索框 -->
    <el-form :model="queryParams" ref="queryForm" size="small" :inline="true" v-show="showSearch" label-width="68px">
      <el-form-item label="姓名" prop="name">
        <el-input v-model="queryParams.name" placeholder="请输入姓名" clearable @keyup.enter.native="handleQuery" />
      </el-form-item>
      <el-form-item label="性别" prop="gender">
        <el-input v-model="queryParams.gender" placeholder="请输入性别" clearable @keyup.enter.native="handleQuery" />
      </el-form-item>
      <el-form-item label="身份证号" prop="sfzid">
        <el-input v-model="queryParams.sfzid" placeholder="请输入身份证号" clearable @keyup.enter.native="handleQuery" />
      </el-form-item>
      <el-form-item label="电话1" prop="telOne">
        <el-input v-model="queryParams.telOne" placeholder="请输入电话1" clearable @keyup.enter.native="handleQuery" />
      </el-form-item>
      <el-form-item label="年龄" prop="age">
        <el-input v-model="queryParams.age" placeholder="请输入年龄" clearable @keyup.enter.native="handleQuery" />
      </el-form-item>
      <el-form-item label="服务机构" prop="serviceid">
        <el-input v-model="queryParams.serviceid" 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-row :gutter="10" class="mb8">
      <el-col :span="1.5">
        <el-button type="primary" plain icon="el-icon-plus" size="mini" @click="handleAdd"
          v-hasPermi="['system:profile:add']">新增</el-button>
      </el-col>
      <el-col :span="1.5">
        <el-button type="success" plain icon="el-icon-edit" size="mini" :disabled="single" @click="handleUpdate"
          v-hasPermi="['system:profile:edit']">修改</el-button>
      </el-col>
      <el-col :span="1.5">
        <el-button type="danger" plain icon="el-icon-delete" size="mini" :disabled="multiple" @click="handleDelete"
          v-hasPermi="['system:profile:remove']">删除</el-button>
      </el-col>
      <el-col :span="1.5">
        <el-button type="success" plain icon="el-icon-download" size="mini" @click="handleExport"
          v-hasPermi="['system:profile:export']">导出</el-button>
      </el-col>
      <el-col :span="1.5">
        <el-button type="warning" plain icon="el-icon-upload2" size="mini" @click="handleUpload"
          v-hasPermi="['system:manage:add']">导入</el-button>
      </el-col>
      <right-toolbar :showSearch.sync="showSearch" @queryTable="getList"></right-toolbar>
    </el-row>
    <!-- 表单 -->
    <el-table v-loading="loading" :data="profileList" @selection-change="handleSelectionChange">
      <el-table-column type="selection" width="55" align="center" />
      <el-table-column label="id" align="center" prop="id" />
      <el-table-column label="姓名" align="center" prop="name" />
      <el-table-column label="性别" align="center" prop="sex">
        <!-- <template slot-scope="scope">
          <dict-tag :options="dict.type.sys_user_sex" :value="scope.row.gender" />
        </template> -->
      </el-table-column>
      <el-table-column label="身份证号" align="center" prop="sfzid" />
      <el-table-column label="电话1" align="center" prop="telOne" />
      <el-table-column label="电话2" align="center" prop="telTwo" />
      <el-table-column label="电话3" align="center" prop="telThree" />
      <el-table-column label="出生年月" align="center" prop="birthday" />
      <el-table-column label="年龄" align="center" prop="age" />
      <el-table-column label="结婚状态" align="center" prop="marrystatus" />
      <el-table-column label="民族" align="center" prop="nation" />
      <el-table-column label="当地户口" align="center" prop="local" />
      <el-table-column label="客户类别" align="center" prop="clienttype" />
      <el-table-column label="居住情况" align="center" prop="livestatus" />
      <el-table-column label="家庭地址" align="center" prop="familyAddress" />
      <el-table-column label="详细地址" align="center" prop="detailAddress" />
      <el-table-column label="户籍地址" align="center" prop="houseAddress" />
      <el-table-column label="户籍详细地址" align="center" prop="houseDetailAddress" />
      <el-table-column label="所属服务机构" align="center" prop="service" />
      <el-table-column label="老人身体特征和状态" align="center" prop="oldmenStatus" />
      <el-table-column label="主要改造内容字段" align="center" prop="changeContent" />
      <el-table-column label="失能月数" align="center" prop="loseMonth" />
      <el-table-column label="治疗月数" align="center" prop="treatMonth" />
      <el-table-column label="是否通过康复治疗" align="center" prop="isTreat" />
      <el-table-column label="服务类型" align="center" prop="servicetype" />
      <el-table-column label="医疗保障" align="center" prop="treatesure" />
      <el-table-column label="经济来源" align="center" prop="moneycome" />
      <el-table-column label="月收入" align="center" prop="moneyMonth" />
      <el-table-column label="社保卡号" align="center" prop="cardCode" />
      <el-table-column label="慢性疾病" align="center" prop="slowillness" />
      <el-table-column label="血型" align="center" prop="bloodtype" />
      <el-table-column label="失能状态" align="center" prop="shistatus" />
      <el-table-column label="残疾情况" align="center" prop="disablitystatus" />
      <el-table-column label="残疾等级" align="center" prop="disablityentry" />
      <el-table-column label="文化程度" align="center" prop="educalevel" />
      <el-table-column label="专业" align="center" prop="special" />
      <el-table-column label="职称" align="center" prop="title" />
      <el-table-column label="原单位" align="center" prop="unity" />
      <el-table-column label="性格心理" align="center" prop="natureHeart" />
      <el-table-column label="饮食特点" align="center" prop="eatPoint" />
      <el-table-column label="特长" align="center" prop="forte" />
      <el-table-column label="爱好" align="center" prop="aihao" />
      <!-- <el-table-column label="照片" align="center" prop="photo" />
      <el-table-column label="其他照片" align="center" prop="otherPhoto" /> -->
      <el-table-column label="备注" align="center" prop="remarks" />
      <el-table-column label="创建时间" align="center" prop="createTime" width="180">
        <template slot-scope="scope">
          <span>{{ parseTime(scope.row.createTime, '{y}-{m}-{d}') }}</span>
        </template>
      </el-table-column>
      <el-table-column label="操作" align="center" class-name="small-padding fixed-width">
        <template slot-scope="scope">
          <el-button size="mini" type="text" icon="el-icon-delete" @click="handleSee(scope.row)">查看</el-button>
          <el-button size="mini" type="text" icon="el-icon-edit" @click="handleUpdate(scope.row)"
            v-hasPermi="['system:profile:edit']">修改</el-button>
          <el-button size="mini" type="text" icon="el-icon-delete" @click="handleDelete(scope.row)"
            v-hasPermi="['system:profile:remove']">删除</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" />

    <!-- 添加或修改用户档案对话框 -->
    <el-dialog :title="title" :visible.sync="open" width="1200px" append-to-body>
      <el-form ref="form" :model="form" :rules="rules" label-width="150px">
        <el-row>
          <el-col :span="12">
            <el-form-item label="姓名" prop="name">
              <el-input v-model="form.name" placeholder="请输入姓名" class="inp" />
            </el-form-item>
          </el-col>
          <el-col :span="12">
            <el-form-item label="性别" prop="gender">
              <el-radio-group v-model="form.gender">
                <el-radio :label="0">男</el-radio>
                <el-radio :label="1">女</el-radio>
              </el-radio-group>
            </el-form-item>
          </el-col>
        </el-row>
        <el-row>
          <el-col :span="12">
            <el-form-item label="身份证号" prop="sfzid">
              <el-input v-model="form.sfzid" type="number" placeholder="请输入身份证号" class="inp" />
            </el-form-item>
          </el-col>
          <el-col :span="12">
            <el-form-item label="电话1" prop="telOne">
              <el-input v-model="form.telOne" type="number" placeholder="请输入电话1" class="inp" />
            </el-form-item>
          </el-col>
        </el-row>
        <el-row>
          <el-col :span="12">
            <el-form-item label="出生年月" prop="birthday">
              <el-date-picker v-model="form.birthday" type="date" placeholder="选择日期"
                style="width: 100%;" value-format="yyyy-MM-dd"></el-date-picker>
            </el-form-item>
          </el-col>
          <el-col :span="12">
            <el-form-item label="电话2" prop="telTwo">
              <el-input v-model="form.telTwo" type="number" placeholder="请输入电话2" class="inp" />
            </el-form-item>
          </el-col>
        </el-row>
        <el-row>
          <el-col :span="12">
            <el-form-item label="年龄" prop="age">
              <el-input v-model="form.age" placeholder="请输入年龄" class="inp" />
            </el-form-item>
          </el-col>
          <el-col :span="12">
            <el-form-item label="电话3" prop="telThree">
              <el-input v-model="form.telThree" type="number" placeholder="请输入电话3" class="inp" />
            </el-form-item>
          </el-col>
        </el-row>
        <el-row>
          <el-col :span="12">
            <el-form-item label="婚姻状况" prop="marrStatus">
              <el-select v-model="form.marrStatus" class="inp">
                <el-option v-for="item in marryStatus" :key="item.dictValue" :label="item.dictLabel"
                  :value="item.dictValue"></el-option>
              </el-select>
            </el-form-item>
          </el-col>
          <el-col :span="12">
            <el-form-item label="民族" prop="national">
              <!-- <el-input v-model="form.national" placeholder="请输入民族" class="inp" /> -->
              <el-select v-model="form.national">
                <el-option v-for="i in nation" :key="i.dictValue" :value="i.dictValue" :label="i.dictLabel"></el-option>
              </el-select>
            </el-form-item>
          </el-col>
        </el-row>
        <el-row>
          <el-col>
            <el-form-item label="本地户口" prop="local">
              <el-radio-group v-model="form.local">
                <el-radio :label="1">是</el-radio>
                <el-radio :label="0">否</el-radio>
              </el-radio-group>
            </el-form-item>
          </el-col>
        </el-row>
        <el-row>
          <el-col>
            <el-form-item label="客户类别" prop="clientType">
              <el-radio-group v-model="form.clientType">
                <el-radio v-for="item in userType" :label="item.dictValue">{{ item.dictLabel }}</el-radio>
              </el-radio-group>
            </el-form-item>
          </el-col>
        </el-row>
        <el-row>
          <el-col>
            <el-form-item label="居住情况" prop="liveStatus">
              <el-radio-group v-model="form.liveStatus">
                <el-radio v-for="item in liveStatus" :label="item.dictValue">{{ item.dictLabel }}</el-radio>
              </el-radio-group>
            </el-form-item>
          </el-col>
        </el-row>
        <el-form-item label="家庭地址" prop="familyAddress">
          <el-input v-model="form.familyAddress" placeholder="请输入家庭地址" />
        </el-form-item>
        <el-form-item label="详细地址" prop="detailAddress">
          <el-input v-model="form.detailAddress" placeholder="请输入详细地址" />
        </el-form-item>
        <el-form-item label="户籍地址" prop="houseAddress">
          <el-input v-model="form.houseAddress" placeholder="请输入户籍地址" />
        </el-form-item>
        <el-form-item label="户籍详细地址" prop="houseDetailAddress">
          <el-input v-model="form.houseDetailAddress" placeholder="请输入户籍详细地址" />
        </el-form-item>
        <el-form-item label="所属服务机构" prop="serviceid">
          <el-select v-model="form.serviceid" style="width: 100%;">
            <el-option v-for="i in manageList" :key="i.id" :label="i.storeName" :value="i.id"></el-option>
          </el-select>
        </el-form-item>
        <el-divider content-position="center">紧急联系人信息</el-divider>
        <el-row :gutter="10" class="mb8">
          <el-col :span="1.5">
            <el-button type="primary" icon="el-icon-plus" size="mini" @click="handleAddTEmergentPeople">添加</el-button>
          </el-col>
          <el-col :span="1.5">
            <el-button type="danger" icon="el-icon-delete" size="mini" @click="handleDeleteTEmergentPeople">删除</el-button>
          </el-col>
        </el-row>
        <el-table :data="tEmergentPeopleList" :row-class-name="rowTEmergentPeopleIndex"
          @selection-change="handleTEmergentPeopleSelectionChange" ref="tEmergentPeople"
          style="width: 100%;margin-bottom: 30px;">
          <el-table-column type="selection" width="130" align="center" />
          <el-table-column label="序号" align="center" prop="index" width="130" />
          <el-table-column label="联系人姓名" prop="name" width="225" header-align="center" align="center">
            <template slot-scope="scope">
              <el-input v-model="scope.row.name" placeholder="请输入联系人姓名" />
            </template>
          </el-table-column>
          <el-table-column label="电话" prop="telno" width="225" header-align="center" align="center">
            <template slot-scope="scope">
              <el-input v-model="scope.row.telno" type="number" placeholder="请输入电话" />
            </template>
          </el-table-column>
          <el-table-column label="关系" prop="relation" width="225" header-align="center" align="center">
            <template slot-scope="scope">
              <el-select v-model="scope.row.relation">
                <el-option v-for="i in relation" :key="i.dictValue" :label="i.dictLabel" :value="i.dictValue"></el-option>
              </el-select>
            </template>
          </el-table-column>
          <el-table-column label="是否接收消息" prop="isConn" width="225" header-align="center" align="center">
            <template slot-scope="scope">
              <el-radio-group v-model="scope.row.isConn">
                <el-radio :label="1">是</el-radio>
                <el-radio :label="0">否</el-radio>
              </el-radio-group>
            </template>
          </el-table-column>
        </el-table>
        <el-form-item label="老人身体特征及身体状态" prop="oldmenStatus">
          <el-input v-model="form.oldmenStatus" placeholder="请输入" />
        </el-form-item>
        <el-form-item label="主要改造内容字段">
          <!-- <editor v-model="form.changeContent" :min-height="192" /> -->
          <el-input v-model="form.changeContent" placeholder="请输入" />
        </el-form-item>
        <el-row>
          <el-col :span="12">
            <el-form-item label="失能月数" prop="loseMonth">
              <el-input v-model="form.loseMonth" placeholder="请输入失能月数" class="inp" />
            </el-form-item>
          </el-col>
          <el-col :span="12">
            <el-form-item label="治疗月数" prop="treatMonth">
              <el-input v-model="form.treatMonth" placeholder="请输入治疗月数" class="inp" />
            </el-form-item>
          </el-col>
        </el-row>
        <el-row>
          <el-col :span="12">
            <el-form-item label="是否通过康复治疗" prop="isTreat">
              <el-radio-group v-model="form.isTreat">
                <el-radio :label="0">是</el-radio>
                <el-radio :label="1">否</el-radio>
              </el-radio-group>
            </el-form-item>
          </el-col>
          <el-col :span="12">
            <el-form-item label="服务类型" prop="serviceType">
              <el-select v-model="form.serviceType" class="inp">
                <el-option v-for="i in serviceType" :key="i.dictValue" :value="i.dictValue"
                  :label="i.dictLabel"></el-option>
              </el-select>
            </el-form-item>
          </el-col>
        </el-row>
        <el-row>
          <el-col :span="12">
            <el-form-item label="医疗保障" prop="treateSure">
              <el-select v-model="form.treateSure" class="inp">
                <el-option v-for="i in treateSure" :key="i.dictValue" :value="i.dictValue"
                  :label="i.dictLabel"></el-option>
              </el-select>
            </el-form-item>
          </el-col>
          <el-col :span="12">
            <el-form-item label="经济来源" prop="moneyCome">
              <el-select v-model="form.moneyCome" class="inp">
                <el-option v-for="i in moneyCome" :key="i.dictValue" :value="i.dictValue"
                  :label="i.dictLabel"></el-option>
              </el-select>
            </el-form-item>
          </el-col>
        </el-row>
        <el-row>
          <el-col :span="12">
            <el-form-item label="月收入" prop="moneyMonth">
              <el-input v-model="form.moneyMonth" placeholder="请输入月收入" class="inp" />
            </el-form-item>
          </el-col>
          <el-col :span="12">
            <el-form-item label="社保卡号" prop="cardCode">
              <el-input v-model="form.cardCode" placeholder="请输入社保卡号" class="inp" />
            </el-form-item>
          </el-col>
        </el-row>
        <el-form-item label="慢性疾病" prop="slowIllness">
          <el-checkbox-group v-model="checked">
            <el-checkbox v-for="i in slowIllness" :key="i.dictValue" :label="i.dictValue">{{ i.dictLabel }}</el-checkbox>
          </el-checkbox-group>
        </el-form-item>
        <el-row>
          <el-col :span="12">
            <el-form-item label="血型" prop="bloodType">
              <el-select v-model="form.bloodType" class="inp">
                <el-option v-for="i in bloodType" :key="i.dictValue" :value="i.dictValue"
                  :label="i.dictLabel"></el-option>
              </el-select>
            </el-form-item>
          </el-col>
          <el-col :span="12">
            <el-form-item label="失能情况" prop="shiStatus">
              <el-select v-model="form.shiStatus" class="inp">
                <el-option v-for="i in shiStatus" :key="i.dictValue" :value="i.dictValue"
                  :label="i.dictLabel"></el-option>
              </el-select>
            </el-form-item>
          </el-col>
        </el-row>
        <el-row>
          <el-col :span="12">
            <el-form-item label="残疾情况" prop="disablityStatus">
              <el-select v-model="form.disablityStatus" class="inp">
                <el-option v-for="i in disablityStatus" :key="i.dictValue" :value="i.dictValue"
                  :label="i.dictLabel"></el-option>
              </el-select>
            </el-form-item>
          </el-col>
          <el-col :span="12">
            <el-form-item label="残疾等级" prop="disablityEntry">
              <el-select v-model="form.disablityEntry" class="inp">
                <el-option v-for="i in disablityEntry" :key="i.dictValue" :value="i.dictValue"
                  :label="i.dictLabel"></el-option>
              </el-select>
            </el-form-item>
          </el-col>
        </el-row>
        <el-row>
          <el-col :span="12">
            <el-form-item label="文化程度" prop="educaLevel">
              <el-select v-model="form.educaLevel" class="inp">
                <el-option v-for="i in educaLevel" :key="i.dictValue" :value="i.dictValue"
                  :label="i.dictLabel"></el-option>
              </el-select>
            </el-form-item>
          </el-col>
          <el-col :span="12">
            <el-form-item label="专业" prop="special">
              <el-input v-model="form.special" placeholder="请输入专业" class="inp" />
            </el-form-item>
          </el-col>
        </el-row>
        <el-row>
          <el-col :span="12">
            <el-form-item label="职称" prop="title">
              <el-input v-model="form.title" placeholder="请输入职称" class="inp" />
            </el-form-item>
          </el-col>
          <el-col :span="12">
            <el-form-item label="原单位" prop="unity">
              <el-input v-model="form.unity" placeholder="请输入原单位" class="inp" />
            </el-form-item>
          </el-col>
        </el-row>
        <el-form-item label="性格心理" prop="natureHeart">
          <el-input v-model="form.natureHeart" placeholder="请输入性格心理" />
        </el-form-item>
        <el-form-item label="饮食特点" prop="eatPoint">
          <el-input v-model="form.eatPoint" placeholder="请输入饮食特点" />
        </el-form-item>
        <el-form-item label="特长" prop="speciality">
          <el-checkbox-group v-model="specialityChecked">
            <el-checkbox v-for="i in speciality" :key="i.dictValue" :label="i.dictValue">{{ i.dictLabel }}</el-checkbox>
          </el-checkbox-group>
        </el-form-item>
        <el-form-item label="爱好" prop="hobby">
          <el-checkbox-group v-model="hobbyChecked">
            <el-checkbox v-for="i in hobby" :key="i.dictValue" :label="i.dictValue">{{ i.dictLabel }}</el-checkbox>
          </el-checkbox-group>
        </el-form-item>
        <el-form-item label="照片" prop="photo">
          <imageUpload :limit="1" url="/system/profile/photoUpload" name="file"></imageUpload>
        </el-form-item>
        <el-form-item label="其他照片" prop="otherPhoto">
          <imageUpload :limit="1" url="/system/profile/otherPhotoUpload" name="file"></imageUpload>
        </el-form-item>
        <el-form-item label="备注" prop="remarks">
          <el-input v-model="form.remarks" type="textarea" placeholder="请输入备注" />
        </el-form-item>
      </el-form>
      <div slot="footer" class="dialog-footer">
        <el-button type="primary" @click="submitForm">确 定</el-button>
        <el-button @click="cancel">取 消</el-button>
      </div>
    </el-dialog>
    <el-dialog :title="title" :visible.sync="toSee" width="1200px" append-to-body>
      <el-form ref="form" :model="form" :rules="rules" label-width="150px" disabled>
        <el-row>
          <el-col :span="12">
            <el-form-item label="姓名" prop="name">
              <el-input v-model="form.name" class="inp" />
            </el-form-item>
          </el-col>
          <el-col :span="12">
            <el-form-item label="性别" prop="gender">
              <div>{{ form.gender == 0 ? '男' : form.gender == 1 ? '女' : '' }}</div>
            </el-form-item>
          </el-col>
        </el-row>
        <el-row>
          <el-col :span="12">
            <el-form-item label="身份证号" prop="sfzid">
              <el-input v-model="form.sfzid" class="inp" />
            </el-form-item>
          </el-col>
          <el-col :span="12">
            <el-form-item label="电话1" prop="telOne">
              <el-input v-model="form.telOne" class="inp" />
            </el-form-item>
          </el-col>
        </el-row>
        <el-row>
          <el-col :span="12">
            <el-form-item label="出生年月" prop="birthday">
              <el-input v-model="form.birthday" class="inp" />
            </el-form-item>
          </el-col>
          <el-col :span="12">
            <el-form-item label="电话2" prop="telTwo">
              <el-input v-model="form.telTwo" class="inp" />
            </el-form-item>
          </el-col>
        </el-row>
        <el-row>
          <el-col :span="12">
            <el-form-item label="年龄" prop="age">
              <el-input v-model="form.age" class="inp" />
            </el-form-item>
          </el-col>
          <el-col :span="12">
            <el-form-item label="电话3" prop="telThree">
              <el-input v-model="form.telThree" class="inp" />
            </el-form-item>
          </el-col>
        </el-row>
        <el-row>
          <el-col :span="12">
            <el-form-item label="婚姻状况" prop="marrStatus">
              <div>{{ marry }}</div>
            </el-form-item>
          </el-col>
          <el-col :span="12">
            <el-form-item label="民族" prop="national">
              <!-- <el-input v-model="form.national" class="inp" /> -->
              <div>{{ minzu }}</div>
            </el-form-item>
          </el-col>
        </el-row>
        <el-row>
          <el-col>
            <el-form-item label="本地户口" prop="local">
              <div>{{ form.local == 0 ? '是' : form.local == 1 ? '否' : '' }}</div>
            </el-form-item>
          </el-col>
        </el-row>
        <el-row>
          <el-col>
            <el-form-item label="客户类别" prop="clientType">
              <div>{{ client }}</div>
            </el-form-item>
          </el-col>
        </el-row>
        <el-row>
          <el-col>
            <el-form-item label="居住情况" prop="liveStatus">
              <div>{{ live }}</div>
            </el-form-item>
          </el-col>
        </el-row>
        <el-form-item label="家庭地址" prop="familyAddress">
          <el-input v-model="form.familyAddress" />
        </el-form-item>
        <el-form-item label="详细地址" prop="detailAddress">
          <el-input v-model="form.detailAddress" />
        </el-form-item>
        <el-form-item label="户籍地址" prop="houseAddress">
          <el-input v-model="form.houseAddress" />
        </el-form-item>
        <el-form-item label="户籍详细地址" prop="houseDetailAddress">
          <el-input v-model="form.houseDetailAddress" />
        </el-form-item>
        <el-form-item label="所属服务机构" prop="serviceid">
          <div>{{ manage }}</div>
        </el-form-item>
        <el-divider content-position="center">紧急联系人信息</el-divider>
        <el-table :data="tEmergentPeopleList" :row-class-name="rowTEmergentPeopleIndex" ref="tEmergentPeople"
          style="width: 100%;margin-bottom: 30px;">
          <el-table-column label="联系人姓名" prop="name" width="275" header-align="center" align="center">
          </el-table-column>
          <el-table-column label="电话" prop="telno" width="275" header-align="center" align="center">
          </el-table-column>
          <el-table-column label="关系" prop="relation" width="275" header-align="center" align="center">
          </el-table-column>
          <el-table-column label="是否接收消息" prop="isConn" width="275" header-align="center" align="center">
          </el-table-column>
        </el-table>
        <el-form-item label="老人身体特征及身体状态" prop="oldmenStatus">
          <el-input v-model="form.oldmenStatus" />
        </el-form-item>
        <el-form-item label="主要改造内容字段">
          <!-- <editor v-model="form.changeContent" :min-height="192" /> -->
          <el-input v-model="form.changeContent" />
        </el-form-item>
        <el-row>
          <el-col :span="12">
            <el-form-item label="失能月数" prop="loseMonth">
              <el-input v-model="form.loseMonth" class="inp" />
            </el-form-item>
          </el-col>
          <el-col :span="12">
            <el-form-item label="治疗月数" prop="treatMonth">
              <el-input v-model="form.treatMonth" class="inp" />
            </el-form-item>
          </el-col>
        </el-row>
        <el-row>
          <el-col :span="12">
            <el-form-item label="是否通过康复治疗" prop="isTreat">
              <div>{{ form.isTreat == 0 ? '是' : form.isTreat == 1 ? '否' : '' }}</div>
            </el-form-item>
          </el-col>
          <el-col :span="12">
            <el-form-item label="服务类型" prop="serviceType">
              <div>{{ service }}</div>
            </el-form-item>
          </el-col>
        </el-row>
        <el-row>
          <el-col :span="12">
            <el-form-item label="医疗保障" prop="treateSure">
              <div>{{ treate }}</div>
            </el-form-item>
          </el-col>
          <el-col :span="12">
            <el-form-item label="经济来源" prop="moneyCome">
              <div>{{ money }}</div>
            </el-form-item>
          </el-col>
        </el-row>
        <el-row>
          <el-col :span="12">
            <el-form-item label="月收入" prop="moneyMonth">
              <el-input v-model="form.moneyMonth" class="inp" />
            </el-form-item>
          </el-col>
          <el-col :span="12">
            <el-form-item label="社保卡号" prop="cardCode">
              <el-input v-model="form.cardCode" class="inp" />
            </el-form-item>
          </el-col>
        </el-row>
        <el-form-item label="慢性疾病" prop="slowIllness">
          <div>{{ illness }}</div>
        </el-form-item>
        <el-row>
          <el-col :span="12">
            <el-form-item label="血型" prop="bloodType">
              <div>{{ blood }}</div>
            </el-form-item>
          </el-col>
          <el-col :span="12">
            <el-form-item label="失能情况" prop="shiStatus">
              <div>{{ shi }}</div>
            </el-form-item>
          </el-col>
        </el-row>
        <el-row>
          <el-col :span="12">
            <el-form-item label="残疾情况" prop="disablityStatus">
              <div>{{ dStatus }}</div>
            </el-form-item>
          </el-col>
          <el-col :span="12">
            <el-form-item label="残疾等级" prop="disablityEntry">
              <div>{{ dEntry }}</div>
            </el-form-item>
          </el-col>
        </el-row>
        <el-row>
          <el-col :span="12">
            <el-form-item label="文化程度" prop="educaLevel">
              <div>{{ educa }}</div>
            </el-form-item>
          </el-col>
          <el-col :span="12">
            <el-form-item label="专业" prop="special">
              <el-input v-model="form.special" class="inp" />
            </el-form-item>
          </el-col>
        </el-row>
        <el-row>
          <el-col :span="12">
            <el-form-item label="职称" prop="title">
              <el-input v-model="form.title" class="inp" />
            </el-form-item>
          </el-col>
          <el-col :span="12">
            <el-form-item label="原单位" prop="unity">
              <el-input v-model="form.unity" class="inp" />
            </el-form-item>
          </el-col>
        </el-row>
        <el-form-item label="性格心理" prop="natureHeart">
          <el-input v-model="form.natureHeart" />
        </el-form-item>
        <el-form-item label="饮食特点" prop="eatPoint">
          <el-input v-model="form.eatPoint" />
        </el-form-item>
        <el-form-item label="特长" prop="speciality">
          <div>{{ forte }}</div>
        </el-form-item>
        <el-form-item label="爱好" prop="hobby">
          <div>{{ aihao }}</div>
        </el-form-item>
        <el-form-item label="照片" prop="photo">
          <el-image style="width: 150px; height: 200px" :src="form.photo"
                :preview-src-list="[form.photo]">
              </el-image>
        </el-form-item>
        <el-form-item label="其他照片" prop="otherPhoto">
          <el-image style="width: 150px; height: 200px" :src="form.otherPhoto"
                :preview-src-list="[form.otherPhoto]">
              </el-image>
        </el-form-item>
        <el-form-item label="备注" prop="remarks">
          <el-input v-model="form.remarks" type="textarea" />
        </el-form-item>
      </el-form>
      <div slot="footer" class="dialog-footer">
        <el-button type="primary" @click="submitForm">确 定</el-button>
        <el-button @click="cancel">取 消</el-button>
      </div>
    </el-dialog>
    <el-dialog :visible.sync="openToUpload" width="630px" append-to-body>
      <el-upload class="upload-demo" drag :action="uploadFileUrl" multiple style="text-align: center;"
        :before-upload="handleBeforeUpload" :headers="headers" :on-success="handleUploadSuccess" ref="fileUpload">
        <i class="el-icon-upload"></i>
        <div class="el-upload__text">将文件拖到此处，或<em>点击上传</em></div>
        <div class="el-upload__tip" slot="tip" style="font-size: 15px;line-height: 15px;">仅允许导入xls、xlsx格式文件
          <el-button type="text" @click="downloadTemplate">下载模板</el-button>
        </div>
      </el-upload>
    </el-dialog>
  </div>
</template>

<script>
import { listProfile, getProfile, delProfile, addProfile, updateProfile } from "@/api/system/profile";
import { listManage } from "@/api/system/manage";
import imageUpload from '@/components/ImageUpload'
import { getToken } from "@/utils/auth";
export default {
  name: "Profile",
  data() {
    return {
      openToUpload: false,
      headers: {
        Authorization: "Bearer " + getToken(),
      },
      fileType: ["xlsx", "xls"],
      uploadFileUrl: process.env.VUE_APP_BASE_API + "/system/profile/importData",
      // 遮罩层
      loading: true,
      // 选中数组
      ids: [],
      // 子表选中数据
      checkedTEmergentPeople: [],
      // 非单个禁用
      single: true,
      // 非多个禁用
      multiple: true,
      // 显示搜索条件
      showSearch: true,
      // 总条数
      total: 0,
      // 用户档案表格数据
      profileList: [],
      // 紧急联系人表格数据
      tEmergentPeopleList: [],
      // 弹出层标题
      title: "",
      // 是否显示弹出层
      open: false,
      // 查询参数
      queryParams: {
        pageNum: 1,
        pageSize: 10,
        name: null,
        gender: null,
        sfzid: null,
        telOne: null,
        telTwo: null,
        telThree: null,
        birthday: null,
        age: null,
        marrStatus: null,
        national: null,
        local: null,
        clientType: null,
        liveStatus: null,
        familyAddress: null,
        detailAddress: null,
        houseAddress: null,
        houseDetailAddress: null,
        serviceid: null,
        oldmenStatus: null,
        changeContent: null,
        loseMonth: null,
        treatMonth: null,
        isTreat: null,
        serviceType: null,
        treateSure: null,
        moneyCome: null,
        moneyMonth: null,
        cardCode: null,
        slowIllness: null,
        bloodType: null,
        shiStatus: null,
        disablityStatus: null,
        disablityEntry: null,
        educaLevel: null,
        special: null,
        title: null,
        unity: null,
        natureHeart: null,
        eatPoint: null,
        speciality: null,
        hobby: null,
        photo: null,
        otherPhoto: null,
        remarks: null,
        createTime: null
      },
      // 表单参数
      form: {},
      // 表单校验
      rules: {
      },
      marryStatus: [],
      userType: [],
      liveStatus: [],
      manageList: [],
      relation: [],
      serviceType: [],
      treateSure: [],
      moneyCome: [],
      slowIllness: [],
      checked: [],
      bloodType: [],
      shiStatus: [],
      disablityStatus: [],
      disablityEntry: [],
      educaLevel: [],
      speciality: [],
      specialityChecked: [],
      hobby: [],
      hobbyChecked: [],
      toSee: false,
      marry: null,
      client: null,
      live: null,
      manage: null,
      service: null,
      treate: null,
      money: null,
      illness: null,
      blood: null,
      shi: null,
      dStatus: null,
      dEntry: null,
      educa: null,
      forte: null,
      aihao: null,
      nation: [],
      minzu: null
    };
  },
  created() {
    this.getList();
    this.getDicts('sys_marry_status').then(res => {
      this.marryStatus = res.data
    })
    this.getDicts('sys_hobby').then(res => {
      this.hobby = res.data
    })
    this.getDicts('sys_national').then(res => {
      this.nation = res.data
    })
    this.getDicts('sys_speciality').then(res => {
      this.speciality = res.data
    })
    this.getDicts('sys_educa_level').then(res => {
      this.educaLevel = res.data
    })
    this.getDicts('sys_disablity_status').then(res => {
      this.disablityStatus = res.data
    })
    this.getDicts('sys_disablity_entry').then(res => {
      this.disablityEntry = res.data
    })
    this.getDicts('sys_user_type').then(res => {
      this.userType = res.data
    })
    this.getDicts('sys_live_status').then(res => {
      this.liveStatus = res.data
    })
    this.getDicts('sys_relation').then(res => {
      this.relation = res.data
    })
    this.getDicts('sys_service_type').then(res => {
      this.serviceType = res.data
    })
    this.getDicts('sys_money_come').then(res => {
      this.moneyCome = res.data
    })
    this.getDicts('sys_treate_sure').then(res => {
      this.treateSure = res.data
    })
    this.getDicts('sys_slow_illness').then(res => {
      this.slowIllness = res.data
    })
    this.getDicts('sys_blood_type').then(res => {
      this.bloodType = res.data
    })
    this.getDicts('sys_shi_status').then(res => {
      this.shiStatus = res.data
    })
    this.getManage()
  },
  watch: {
    'form.national': {
      handler(val) {
        if (val) {
          this.minzu = this.nation[val].dictLabel
        }
      }
    },
    'form.hobby': {
      handler(val) {
        if (val) {
          let arr = JSON.parse(val)
          this.aihao = []
          arr.map(item => {
            this.aihao.push(this.hobby[item].dictLabel)
          })
          this.aihao = this.aihao.join('、')
        }
      }
    },
    'form.speciality': {
      handler(val) {
        if (val) {
          let arr = JSON.parse(val)
          this.forte = []
          arr.map(item => {
            this.forte.push(this.speciality[item].dictLabel)
          })
          this.forte = this.forte.join('、')
        }
      }
    },
    checked(val) {
      this.form.slowIllness = JSON.stringify(val)
    },
    specialityChecked(val) {
      this.form.speciality = JSON.stringify(val)
    },
    hobbyChecked(val) {
      this.form.hobby = JSON.stringify(val)
    },
    'form.marrStatus': {
      handler(val) {
        if (val) {
          this.marry = this.marryStatus[val].dictLabel
        }
      }
    },
    'form.clientType': {
      handler(val) {
        if (val) {
          this.client = this.userType[val].dictLabel
        }
      }
    },
    'form.liveStatus': {
      handler(val) {
        if (val) {
          this.live = this.liveStatus[val].dictLabel
        }
      }
    },
    'form.serviceid': {
      handler(val) {
        if (val) {
          this.manageList.map(item => {
            if (item.id == val) {
              this.manage = item.storeName
            }
          })
        }
      }
    },
    'form.serviceType': {
      handler(val) {
        if (val) {
          this.service = this.serviceType[val].dictLabel
        }
      }
    },
    'form.treateSure': {
      handler(val) {
        if (val) {
          this.treate = this.treateSure[val].dictLabel
        }
      }
    },
    'form.moneyCome': {
      handler(val) {
        if (val) {
          this.money = this.moneyCome[val].dictLabel
        }
      }
    },
    'form.slowIllness': {
      handler(val) {
        if (val) {
          let arr = JSON.parse(val)
          this.illness = []
          arr.map(item => {
            this.illness.push(this.slowIllness[item].dictLabel)
          })
          this.illness = this.illness.join('、')
        }
      }
    },
    'form.bloodType': {
      handler(val) {
        if (val) {
          this.blood = this.bloodType[val].dictLabel
        }
      }
    },
    'form.shiStatus': {
      handler(val) {
        if (val) {
          this.shi = this.shiStatus[val].dictLabel
        }
      }
    },
    'form.disablityStatus': {
      handler(val) {
        if (val) {
          this.dStatus = this.disablityStatus[val].dictLabel
        }
      }
    },
    'form.disablityEntry': {
      handler(val) {
        if (val) {
          this.dEntry = this.disablityEntry[val].dictLabel
        }
      }
    },
    'form.educaLevel': {
      handler(val) {
        if (val) {
          this.educa = this.educaLevel[val].dictLabel
        }
      }
    },
  },
  methods: {
    downloadTemplate() {
      this.download('system/profile/importTemplate', {
      }, `user_template_${new Date().getTime()}.xlsx`)
    },
    handleUploadSuccess(res, file) {
      if (res.code != 200) {
        this.$modal.msgError(`上传模板不正确，请重新上传`);
        this.$modal.closeLoading()
        this.$refs.fileUpload.handleRemove(file);
      } else {
        this.modal.msgSuccess("导入成功");
        this.openToUpload = false
        this.resetQuery()
      }
    },
    handleBeforeUpload(file) {
      // 校检文件类型
      if (this.fileType) {
        const fileName = file.name.split('.');
        const fileExt = fileName[fileName.length - 1];
        const isTypeOk = this.fileType.indexOf(fileExt) >= 0;
        if (!isTypeOk) {
          this.$modal.msgError(`文件格式不正确, 请上传${this.fileType.join("/")}格式文件!`);
          return false;
        }
      }
      this.$modal.loading("正在上传文件，请稍候...");
      return true;
    },
    getManage() {
      listManage({
        page: 1,
        size: 999,
        storeName: null
      }).then(res => {
        this.manageList = res.rows
      })
    },
    /** 查询用户档案列表 */
    getList() {
      this.loading = true;
      listProfile(this.queryParams).then(response => {
        this.profileList = response.rows;
        this.profileList.map(item => {
          item.sex = item.gender == 0 ? '男' : item.gender == 1 ? '女' : ''
          item.local = item.local == 1 ? '是' : item.local == 0 ? '否' : ''
          item.isTreat = item.isTreat == 1 ? '是' : item.isTreat == 0 ? '否' : ''
          if (item.marrStatus != null) {
            item.marrystatus = this.marryStatus[item.marrStatus].dictLabel
          }
          if (item.national != null) {
            item.nation = this.nation[item.national].dictLabel
          }
          if (item.clientType != null) {
            item.clienttype = this.userType[item.clientType].dictLabel
          }
          if (item.liveStatus != null) {
            item.livestatus = this.liveStatus[item.liveStatus].dictLabel
          }
          if (item.serviceType != null) {
            item.servicetype = this.serviceType[item.serviceType].dictLabel
          }
          if (item.treateSure != null) {
            item.treatesure = this.treateSure[item.treateSure].dictLabel
          }
          if (item.moneyCome != null) {
            item.moneycome = this.moneyCome[item.moneyCome].dictLabel
          }
          if (item.bloodType != null) {
            item.bloodtype = this.bloodType[item.bloodType].dictLabel
          }
          if (item.disablityStatus != null) {
            item.disablitystatus = this.disablityStatus[item.disablityStatus].dictLabel
          }
          if (item.disablityEntry != null) {
            item.disablityentry = this.disablityEntry[item.disablityEntry].dictLabel
          }
          if (item.educaLevel != null) {
            item.educalevel = this.educaLevel[item.educaLevel].dictLabel
          }
          if (item.shiStatus != null) {
            item.shistatus = this.shiStatus[item.shiStatus].dictLabel
          }
          if (item.slowIllness != null && item.slowIllness != '') {
            let arr = JSON.parse(item.slowIllness)
            item.slowillness = []
            arr.map(i => {
              item.slowillness.push(this.slowIllness[i].dictLabel)
            })
            item.slowillness = item.slowillness.join('、')
          }
          if (item.speciality != null && item.speciality != '') {
            let arr = JSON.parse(item.speciality)
            item.forte = []
            arr.map(i => {
              item.forte.push(this.speciality[i].dictLabel)
            })
            item.forte = item.forte.join('、')
          }
          if (item.hobby != null && item.hobby != '') {
            let arr = JSON.parse(item.hobby)
            item.aihao = []
            arr.map(i => {
              item.aihao.push(this.hobby[i].dictLabel)
            })
            item.aihao = item.aihao.join('、')
          }
          if (item.serviceid != null) {
            this.manageList.map(i => {
              if (i.id == item.serviceid) {
                item.service = i.storeName
              }
            })
          }
        })
        this.total = response.total;
        this.loading = false;
      });
    },
    // 取消按钮
    cancel() {
      this.open = false;
      this.reset();
    },
    // 表单重置
    reset() {
      this.form = {
        id: null,
        name: null,
        gender: null,
        sfzid: null,
        telOne: null,
        telTwo: null,
        telThree: null,
        birthday: null,
        age: null,
        marrStatus: null,
        national: null,
        local: null,
        clientType: null,
        liveStatus: null,
        familyAddress: null,
        detailAddress: null,
        houseAddress: null,
        houseDetailAddress: null,
        serviceid: null,
        oldmenStatus: null,
        changeContent: null,
        loseMonth: null,
        treatMonth: null,
        isTreat: null,
        serviceType: null,
        treateSure: null,
        moneyCome: null,
        moneyMonth: null,
        cardCode: null,
        slowIllness: null,
        bloodType: null,
        shiStatus: null,
        disablityStatus: null,
        disablityEntry: null,
        educaLevel: null,
        special: null,
        title: null,
        unity: null,
        natureHeart: null,
        eatPoint: null,
        speciality: null,
        hobby: null,
        photo: null,
        otherPhoto: null,
        remarks: null,
        createTime: null
      };
      this.tEmergentPeopleList = [];
      this.resetForm("form");
    },
    /** 搜索按钮操作 */
    handleQuery() {
      this.queryParams.pageNum = 1;
      this.getList();
    },
    /** 重置按钮操作 */
    resetQuery() {
      this.resetForm("queryForm");
      this.handleQuery();
    },
    // 多选框选中数据
    handleSelectionChange(selection) {
      this.ids = selection.map(item => item.id)
      this.single = selection.length !== 1
      this.multiple = !selection.length
    },
    /** 新增按钮操作 */
    handleAdd() {
      this.reset();
      this.open = true;
      this.title = "添加用户档案";
    },
    /** 修改按钮操作 */
    handleUpdate(row) {
      this.reset();
      const id = row.id || this.ids
      getProfile(id).then(response => {
        this.form = response.data;
        this.tEmergentPeopleList = response.data.temergentPeopleList;
        this.open = true;
        this.title = "修改用户档案";
      });
    },
    handleSee(row) {
      this.reset();
      const id = row.id
      getProfile(id).then(response => {
        this.form = response.data;
        this.tEmergentPeopleList = response.data.temergentPeopleList;
        if (this.tEmergentPeopleList.length) {
          this.tEmergentPeopleList.map(item => {
            item.relation = this.relation[item.relation].dictLabel
            item.isConn = item.isConn == 1 ? '是' : item.isConn == 0 ? '否' : ''
          })
        }
        this.toSee = true
        this.title = "查看用户档案";
      });
    },
    /** 提交按钮 */
    submitForm() {
      this.$refs["form"].validate(valid => {
        this.form.temergentPeopleList = this.tEmergentPeopleList;
        if (valid) {
          if (this.form.id != null) {
            updateProfile(this.form).then(response => {
              this.$modal.msgSuccess("修改成功");
              this.open = false;
              this.getList();
            });
          } else {
            addProfile(this.form).then(response => {
              this.$modal.msgSuccess("新增成功");
              this.open = false;
              this.getList();
            });
          }
        }
      });
    },
    /** 删除按钮操作 */
    handleDelete(row) {
      const ids = row.id || this.ids;
      this.$modal.confirm('是否确认删除用户档案编号为"' + ids + '"的数据项？').then(function () {
        return delProfile(ids);
      }).then(() => {
        this.getList();
        this.$modal.msgSuccess("删除成功");
      }).catch(() => { });
    },
    /** 紧急联系人序号 */
    rowTEmergentPeopleIndex({ row, rowIndex }) {
      row.index = rowIndex + 1;
    },
    /** 紧急联系人添加按钮操作 */
    handleAddTEmergentPeople() {
      if (this.tEmergentPeopleList.length >= 2) {
        this.$modal.msgError("最多可添加两个");
        return
      }
      let obj = {};
      obj.name = "";
      obj.telno = "";
      obj.relation = "";
      obj.isConn = "";
      this.tEmergentPeopleList.push(obj);
    },
    /** 紧急联系人删除按钮操作 */
    handleDeleteTEmergentPeople() {
      if (this.checkedTEmergentPeople.length == 0) {
        this.$modal.msgError("请先选择要删除的紧急联系人数据");
      } else {
        const tEmergentPeopleList = this.tEmergentPeopleList;
        const checkedTEmergentPeople = this.checkedTEmergentPeople;
        this.tEmergentPeopleList = tEmergentPeopleList.filter(function (item) {
          return checkedTEmergentPeople.indexOf(item.index) == -1
        });
      }
    },
    /** 复选框选中数据 */
    handleTEmergentPeopleSelectionChange(selection) {
      this.checkedTEmergentPeople = selection.map(item => item.index)
    },
    /** 导出按钮操作 */
    handleExport() {
      this.download('system/profile/export', {
        ...this.queryParams
      }, `profile_${new Date().getTime()}.xlsx`)
    },
    handleUpload() {
      this.openToUpload = true
    },
  }
};
</script>
<style scoped>
.inp /deep/ .el-input__inner {
  color: #000 !important;
  /* cursor: pointer; */
}</style>