<template>
    <div class="page">
      <LayoutTable notAdd notDel :data="tableData" :config="tableConfig">

        <el-button
            slot="table-head-left2"
            style="margin-left: 10px"
            icon="el-icon-tickets"
            size="mini"
            type="danger"
            @click="monitorWarn"
        >监测预警</el-button
        >

        <drawer-show ref="dataDrawerShow"  />

        <track-dialog-show ref="trackdialogform" @ok="getData" />

        <dialog-show ref="dialogform" @ok="getData" />

      </LayoutTable>

    </div>
</template>

<script>
    /** 表单弹出框模式需引入 */
    import dialogShow from "./dialogshow";
    import trackdialogShow from "./trackdialogshow";
    import drawerShow from "./dataDrawerShow";
    import table from "@/assets/mixins/table";
    export default {
        name: "CareRecordsList",
        components: {
            dialogShow,drawerShow,trackdialogShow},
        mixins: [table],
        created() {
        },
        methods: {
            /** 重写新增方法 */
            toAdd(row) {
                this.$refs.dialogform.add(row);
            },
            /** 重写编辑方法 */
            toEdit(row) {
                this.$refs.dialogform.edit(row);
            },
            /** 重写查看方法 */
            toView(row) {
                this.$refs.dialogform.view(row);
            },
          /** 监测预警 */
          monitorWarn(row) {
            this.$refs.dataDrawerShow.view(row);
          },

          toNotice(row){
            let _this=this
            this.$confirm(
                '负责人姓名：刘琳琳           联系电话：15244845448',
                "通知负责人",
                {
                  confirmButtonText: "确定",
                  cancelButtonText: "取消",
                  type: "warning",
                }
            ).then(function () {
              _this.$post("/care/records/notice", { id: [row.id] })
                  .then((res) => {
                    if (res && res.code && res.code == 1) {
                      _this.getList();
                      _this.$message.success("通知成功");
                    }
                  })
                  .catch((error) => {
                    _this.$message.error(error.message);
                  });
            });
          },


          /** 打开跟踪反馈 */
          toTrack(row) {
            this.$refs.trackdialogform.view(row);
          },

        },
        data() {
            return {
                config: {
                    search: [
                      {
                        name: "detectTimeStart",
                        type: "datetime",
                        label: "开始时间",
                      },

                      {
                        name: "detectTimeEnd",
                        type: "datetime",
                        label: "结束时间",
                      },

                      {
                        name: "name",
                        type: "text",
                        label: "姓名",
                        fuzzy: true,
                      },
                    ],
                    columns: [
                        {type: "index",label: "序号",width: 50},

                        {label: "姓名", prop: "name"},

                        {label: "联系方式", prop: "contact"},

                        {label: "身份证号码", prop: "idCard"},

                        {label: "办理业务", prop: "service"},

                        {label: "排队编号", prop: "queueNo"},

                        {label: "监测时间", prop: "monitorTime", formatter: this.formatterDate},

                        {label: "监测设备", prop: "monitorDevice"},

                        {label: "最终等待时长", prop: "waitTime", formatter: this.formatter},

                        {label: "办理状态", prop: "processStatus"},
                        {
                            label: "操作",
                            width: 240,
                            formatter: row => {
                                return (
                                    <div>
                                      {row.processStatus === '排队中' ? (<div>
                                          <el-button
                                              size="mini"
                                              type="text"
                                              icon="el-icon-open"
                                              onClick={() => {
                                                this.reCare(row);
                                              }}
                                          >
                                            再次关怀
                                          </el-button>
                                          <span> </span>
                                            <el-button
                                                size="mini"
                                                type="text"
                                                icon="el-icon-open"
                                                onClick={() => {
                                                  this.notice(row);
                                                }}
                                            >
                                              通知负责人
                                            </el-button>
                                          </div>

                                      ) : (
                                          ""
                                      )}
                                      <span> </span>
                                      <el-button
                                          size="mini"
                                          type="text"
                                          icon="el-icon-open"
                                          onClick={() => {
                                            this.toTrack(row);
                                          }}
                                      >
                                        跟踪反馈
                                      </el-button>

                                    </div>

                            );
                            }
                        }
                    ]
                }
            };
        }
    };
</script>
