<template>
    <div class="app-container">
        <el-form :model="queryParams" ref="queryForm" size="small" :inline="true" label-width="80px">
            <el-form-item label="患者姓名" prop="patientName">
                <el-input v-model="queryParams.patientName" placeholder="请输入患者姓名" clearable
                    @keyup.enter.native="handleQuery" style="width:200px" />
            </el-form-item>
            <el-form-item label="患者电话" prop="patientPhone">
                <el-input v-model="queryParams.patientPhone" placeholder="请输入患者电话" clearable
                    @keyup.enter.native="handleQuery" style="width:200px" />
            </el-form-item>
            <el-form-item label="身份证号" prop="cardNo">
                <el-input v-model="queryParams.cardNo" placeholder="请输入身份证号" clearable @keyup.enter.native="handleQuery"
                    style="width:200px" />
            </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-table v-loading="loading" :data="patientInfoList">
            <el-table-column label="序号" type="index" width="55" align="center" />
            <el-table-column label="患者姓名" align="center" prop="patientName" />
            <el-table-column label="患者电话" align="center" prop="patientPhone" width='120' />
            <el-table-column label="出生日期" align="center" prop="birthDate" width='130' />
            <el-table-column label="身份证号" align="center" prop="cardNo" width='130' />
            <el-table-column label="性别" align="center" prop="sex">
                <template slot-scope="scope">
                    {{ scope.row.sex == 'MALE' ? '男' : '' }}
                    {{ scope.row.sex == 'FEMALE' ? '女' : '' }}
                </template>
            </el-table-column>
            <el-table-column label="年龄" align="center" prop="age" />
            <el-table-column label="患者类型" align="center" prop="visitDate" width='130'>
                <template slot-scope="scope">
                    <dict-tag :options="dict.type.patient_type" :value="scope.row.patientType" />
                </template>
            </el-table-column>
            <el-table-column label="签约状态" align="center" prop="signStatus" width='130'>
                <template slot-scope="scope">
                    <!-- <dict-tag :options="dict.type.sign_status" :value="scope.row.signStatus" /> -->
                    {{ scope.row.signStatus == 'UN_SIGN' ? '未签约' : '' }}
                    {{ scope.row.signStatus == 'IN_SIGN' ? '在签' : '' }}
                    {{ scope.row.signStatus == 'SEPARATE_SIGN' ? '解约' : '' }}
                </template>
            </el-table-column>
            <el-table-column label="服务状态" align="center" prop="serviceStatus" width='130'>
                <template slot-scope="scope">
                    {{ scope.row.serviceStatus == 'INTENTIONAL_SIGNING' ? '意向签约' : '' }}
                    {{ scope.row.serviceStatus == 'SERVICE_CENTER' ? '服务中' : '' }}
                    {{ scope.row.serviceStatus == 'SERVICE_END' ? '服务结束' : '' }}
                </template>
            </el-table-column>
            <el-table-column label="就诊方式" align="center" prop="visitMethod">
                <template slot-scope="scope">
                    <dict-tag :options="dict.type.visit_method" :value="scope.row.visitMethod" />
                </template>
            </el-table-column>
            <el-table-column label="医院" align="center" prop="hospitalAgencyName" width='130' />
            <el-table-column label="科室名称" align="center" prop="departmentName" width='130' />
            <!-- <el-table-column label="患者健康状况" align="center" prop="patientHealthState">
                <template slot-scope="scope">
                    {{ scope.row.patientHealthState == 'ABNORMAL' ? '异常' : '' }}
                    {{ scope.row.patientHealthState == 'GOOD' ? '良好' : '' }}
                    {{ scope.row.patientHealthState == 'BLACKLIST' ? '黑名单' : '' }}
                </template>
            </el-table-column> -->
            <el-table-column label="操作" align="center" class-name="small-padding fixed-width" fixed="right" width="200">
                <template slot-scope="scope">
                    <el-button size="mini" type="text" @click="goQuestionnaireDetails(scope.row)">满意度问卷详情</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" />
    </div>
</template>
<script>
import { satisfactionSurvey } from "@/api/system/satisfactionSurvey";
import { getAge } from "@/utils/age";
export default {
    name: "satisfactionSurvey",
    dicts: ['visit_method', 'patient_source', 'patient_type', 'sign_status'],
    data() {
        return {
            // 遮罩层
            loading: true,
            // 总条数
            total: 0,
            // 患者信息表格数据
            patientInfoList: [],
            // 查询参数
            queryParams: {
                pageNum: 1,
                pageSize: 10,
                patientName: null,
                patientPhone: null,
                cardNo: null,
            },
        };
    },
    created() {
        this.getList();
    },
    methods: {
        /** 查询信息列表 */
        getList() {
            this.loading = true;
            this.queryParams.params = {};
            satisfactionSurvey(this.queryParams).then(response => {
                response.rows.forEach(e => {
                    e.birthDate ? e.age = getAge(e.birthDate) : ''
                })
                this.patientInfoList = response.rows;
                this.total = response.total;
                this.loading = false;
            });
        },
        //跳转详情
        goQuestionnaireDetails(row) {
            this.$store.dispatch('tagsView/delView', this.$route).then(({ visitedViews }) => {
                this.$router.push({
                    path: "/satisfactionSurvey/SatisfactionQuestionnaireDetails",
                    query: {
                        patientQuestionSubmitResultId: row.patientQuestionSubmitResultId,
                        taskContent: row.taskContent,
                        taskType: row.taskType,
                        templateId: row.templateId,
                        cardNo: row.cardNo,
                        patientName: row.patientName,
                        patientPhone: row.patientPhone,
                        sex: row.sex,
                        routeHandleRemark: row.routeHandleRemark,
                        textRemindContent: row.textRemindContent,
                        birthDate: row.birthDate,
                        address: row.address,
                        patientSource: row.patientSource,
                        createTime: row.createTime,
                        age: row.birthDate ? getAge(row.birthDate) : "",
                    },
                });
            })
        },
        /** 搜索按钮操作 */
        handleQuery() {
            this.queryParams.pageNum = 1;
            this.getList();
        },
        /** 重置按钮操作 */
        resetQuery() {
            this.resetForm("queryForm");
            this.handleQuery();
        },
    }
};
</script>