<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="nurseStationId">
        <el-button type="" class="stationbtn" @click="ParamsStation(true)">{{
          queryParams.nurseStationName
        }}</el-button>
      </el-form-item>
      <el-form-item label="科室编码" prop="departmentCode">
        <el-input
          v-model="queryParams.departmentCode"
          placeholder="请输入科室编码"
          clearable
          @keyup.enter.native="handleQuery"
        />
      </el-form-item>
      <el-form-item label="科室名称" prop="departmentName">
        <el-input
          v-model="queryParams.departmentName"
          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:StationDepartment: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:StationDepartment: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:StationDepartment:remove']"
          >删除</el-button
        >
      </el-col>
      <right-toolbar
        :showSearch.sync="showSearch"
        @queryTable="getList"
      ></right-toolbar>
    </el-row>

    <el-table
      v-loading="loading"
      :data="StationDepartmentList"
      @selection-change="handleSelectionChange"
    >
      <el-table-column type="selection" width="55" align="center" />
      <el-table-column
        label="护理站名称"
        align="center"
        prop="nurseStationName"
      />
      <el-table-column label="科室编码" align="center" prop="departmentCode" />
      <el-table-column label="科室名称" align="center" prop="departmentName" />
      <el-table-column label="联系电话" align="center" prop="phone" />
      <el-table-column label="创建时间" align="center" prop="createTime" />
      <el-table-column label="创建人" align="center" prop="createBy" />
      <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-edit"
            @click="handleUpdate(scope.row)"
            v-hasPermi="['system:StationDepartment:edit']"
            >修改</el-button
          >
          <el-button
            size="mini"
            type="text"
            icon="el-icon-delete"
            @click="handleDelete(scope.row)"
            v-hasPermi="['system:StationDepartment: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="addopen"
      width="800px"
      append-to-body
      :before-close="cancel"
    >
      <el-form
        ref="form"
        :model="form"
        :rules="rules"
        label-width="100px"
        :inline="true"
      >
        <div
          v-for="(item, index) in form.nurseStationDepartmentList"
          :key="index"
          style="margin-top: 20px; border-bottom: 1px solid #f3f3f3"
        >
          <el-form-item
            label="所属护理站"
            :rules="rules.nurseStationDepartmentList.nurseStationId"
            :prop="`nurseStationDepartmentList.${index}.nurseStationId`"
          >
            <el-button
              type=""
              v-if="item.nurseStationName == '请选择所属护理站'"
              @click="clickinnerVisible(item, index)"
              style="
                width: 250px;
                text-align: left;
                height: 36px;
                color: #c0c4cc;
                overflow: hidden;
              "
              >{{ item.nurseStationName }}</el-button
            >
            <el-button
              @click="clickinnerVisible(item, index)"
              type=""
              v-else
              style="
                width: 250px;
                text-align: left;
                height: 36px;
                padding-left: -10px;
                overflow: hidden;
              "
              >{{ item.nurseStationName }}</el-button
            >
          </el-form-item>
          <el-form-item
            label="科室名称"
            :rules="rules.nurseStationDepartmentList.departmentName"
            :prop="`nurseStationDepartmentList.${index}.departmentName`"
          >
            <el-input
              v-model="item.departmentName"
              placeholder="请输入科室名称"
              style="width: 250px"
              maxlength="15"
            />
          </el-form-item>
          <el-form-item
            label="科室负责人"
            :rules="rules.nurseStationDepartmentList.departmentPerson"
            :prop="`nurseStationDepartmentList.${index}.departmentPerson`"
          >
            <el-input
              v-model="item.departmentPerson"
              placeholder="请输入科室负责人"
              style="width: 250px"
              maxlength="15"
            />
          </el-form-item>
          <el-form-item
            label="联系电话"
            :rules="rules.nurseStationDepartmentList.phone"
            :prop="`nurseStationDepartmentList.${index}.phone`"
          >
            <el-input
              v-model="item.phone"
              placeholder="请输入联系电话"
              maxlength="11"
              style="width: 250px"
            />
          </el-form-item>
          <el-button
            type="primary"
            circle
            plain
            icon="el-icon-circle-plus-outline"
            @click="adddisease"
            v-if="index == 0"
          ></el-button>
          <el-button
            type="danger"
            icon="el-icon-delete"
            circle
            plain
            @click="deldisease(index)"
            v-if="index != 0"
          ></el-button>
        </div>
      </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="open" width="500px" append-to-body>
      <el-form ref="form" :model="form" :rules="rules" label-width="100px">
        <el-form-item label="所属护理站" prop="nurseStationId">
          <el-input
            v-model="form.nurseStationName"
            placeholder="请选择所属护理站"
            style="width: 250px"
            disabled
          />
        </el-form-item>
        <el-form-item label="科室名称" prop="departmentName">
          <el-input
            v-model="form.departmentName"
            placeholder="请输入科室名称"
            style="width: 250px"
            maxlength="15"
          />
        </el-form-item>
        <el-form-item label="科室负责人" prop="departmentPerson">
          <el-input
            v-model="form.departmentPerson"
            placeholder="请输入科室负责人"
            style="width: 250px"
          />
        </el-form-item>
        <el-form-item label="联系电话" prop="phone">
          <el-input
            v-model="form.phone"
            placeholder="请输入联系电话"
            maxlength="11"
            style="width: 250px"
          />
        </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="选择护理站"
      :visible.sync="innerVisible"
      width="1000px"
      append-to-body
      :before-close="innerVisiblecancel"
    >
      <el-form
        ref="queryForm"
        :model="nurseStationqueryParams"
        :rules="rules"
        label-width="80px"
        :inline="true"
      >
        <el-form-item
          label="护理站编码"
          prop="nurseStationCode"
          label-width="120"
        >
          <el-input
            v-model="nurseStationqueryParams.nurseStationCode"
            placeholder="请输入护理站编码"
            clearable
            @keyup.enter.native="info"
          />
        </el-form-item>
        <el-form-item
          label="护理站名称"
          prop="nurseStationName"
          label-width="120"
        >
          <el-input
            v-model="nurseStationqueryParams.nurseStationName"
            placeholder="请输入护理站名称"
            clearable
            @keyup.enter.native="info"
          />
        </el-form-item>
        <el-form-item>
          <el-button
            type="primary"
            icon="el-icon-search"
            size="mini"
            @click="info"
            >搜索</el-button
          >
          <el-button icon="el-icon-refresh" size="mini" @click="addresetQuery"
            >重置</el-button
          >
        </el-form-item>
      </el-form>

      <el-table
        :data="nurseStationlist"
        @cell-dblclick="nurseclick"
        v-loading="loading"
      >
        <el-table-column label="请选择" width="100" align="center">
          <template slot-scope="scope">
            <el-button
              type="primary"
              style="width: 15px; height: 15px"
              v-if="stationid == scope.row.id"
              circle
              @click="nurseclick(scope.row)"
            ></el-button>
            <el-button
              v-else
              style="width: 15px; height: 15px"
              circle
              @click="nurseclick(scope.row)"
            ></el-button>
          </template>
        </el-table-column>
        <el-table-column
          property="nurseStationCode"
          label="护理站编码"
          align="center"
        >
        </el-table-column>
        <el-table-column
          property="nurseStationName"
          label="护理站名称"
          align="center"
          :show-overflow-tooltip="true"
        >
        </el-table-column>
        <el-table-column property="phone" label="联系电话" align="center">
        </el-table-column>
        <el-table-column
          property="address"
          label="护理站地址"
          align="center"
          :show-overflow-tooltip="true"
        >
        </el-table-column>
      </el-table>
      <pagination
        v-show="total2 > 0"
        :total="total2"
        :page.sync="nurseStationqueryParams.pageNum"
        :limit.sync="nurseStationqueryParams.pageSize"
        @pagination="info"
      />
    </el-dialog>
  </div>
</template>
<script>
import indexjs from "./indexjs.js";
export default indexjs;
</script>
<style scoped lang="scss">
.stationbtn {
  width: 208px;
  text-align: left;
  height: 32px;
  overflow: hidden;
  font-size: 14px;
}
</style>
