<template>
  <div class="app-container" ref="layout">
    <el-row :gutter="20">
      <el-col :span="5" :xs="24">
        <div class="left" ref="box">
          <!-- <div :class="itemid=='' ? 'all' : 'all'" @click="allclick"> -->
          <div class="all" @click="allclick">

            全部
          </div>
          <el-collapse
            v-model="activeNames"
            @change="handleChange"
            v-for="(item, index) in list"
            :key="index"
          >
            <el-collapse-item :name="item.taskTypeId">
              <template slot="title">
                {{ item.taskTypeName }}
                <!-- {{item}} -->
              </template>
              <el-table
                :data="item.taskPartitionDictList"
                style="width: 100%"
                :show-header="false"
                :row-style="{ height: '35px' }" :cell-style="{ padding: '0px' }"
              >
                <el-table-column prop="" label="">
                  <template slot-scope="scope">
         
                    <div
                      @click="clickitem(scope.row)"
                      :class="itemid == scope.row.id ? 'allactive' : 'collitem'"
                    >
                      {{ scope.row.taskPartitionName }}
                    <span class="count" v-if="scope.row.taskPartitionRemark">{{scope.row.taskPartitionRemark}}</span>

                    </div>
                    <!-- </div> -->
                  </template>
                </el-table-column>
                <!-- <template slot="title">
                  {{ item.name }}
                </template>
                <div v-for="(aitem, aindex) in item.items" :key="aindex">
                  <div class="collitem">{{ aitem.keyname }}</div>
                </div> -->
              </el-table>
            </el-collapse-item>
          </el-collapse>
        </div>
      </el-col>
      <el-col :span="19" :xs="24">
        <div ref="topform" class="form">
          <el-form
            :model="queryParams"
            ref="queryForm"
            size="small"
            :inline="true"
            v-show="showSearch"
            label-width="68px"
          >
            <el-form-item label="字段名称" prop="fieldName">
              <el-input
                v-model="queryParams.fieldName"
                placeholder="请输入字段名称"
                clearable
                @keyup.enter.native="handleQuery"
              />
            </el-form-item>
            <el-form-item label="字段类型" label-width="100px" prop="fieldType">
              <el-select
                v-model="queryParams.fieldType"
                placeholder="请选择字段类型"
                clearable
              >
                <el-option
                  v-for="item in options"
                  :key="item.dictValue"
                  :label="item.dictLabel"
                  :value="item.dictValue"
                >
                </el-option>
              </el-select>
            </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>
        </div>
        <div ref="mb8" class="mb8">
          <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="['manage:labelfieldinfo: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="['manage:labelfieldinfo: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="['manage:labelfieldinfo:remove']"
                >删除</el-button
              >
            </el-col>
            <right-toolbar
              :showSearch.sync="showSearch"
              @queryTable="getList"
            ></right-toolbar>
          </el-row>
        </div>
        <div ref="table">
          <el-table
            :max-height="maxTableHeight"
            v-loading="loading"
            :data="labelfieldinfodata"
            @selection-change="handleSelectionChange"
          >
            <el-table-column type="selection" width="55" align="center" />
            <el-table-column label="字段名称" align="center" prop="fieldName" />
            <el-table-column label="字段编码" align="center" prop="fieldCode" />
            <el-table-column
              label="任务细分"
              align="center"
              prop="taskPartitionDictName"
              :show-overflow-tooltip="true"
            />
           
            <el-table-column label="字段类型" align="center" prop="fieldType">
              <template slot-scope="scope">
                {{ scope.row.fieldType == "STRING" ? "默认字符串" : "" }}
                {{ scope.row.fieldType == "INT" ? "整型" : "" }}
                {{ scope.row.fieldType == "DECIMAL" ? "数值" : "" }}
                {{ scope.row.fieldType == "ENUM" ? "枚举" : "" }}
              </template>
            </el-table-column>
            <el-table-column label="字段排序" align="center" prop="fieldSort" />
            <!-- <el-table-column
              label="字段备注信息"
              align="center"
              prop="fieldRemark"
              :show-overflow-tooltip="true"
            /> -->

           
            <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="['manage:labelfieldinfo:edit']"
                  >修改</el-button
                >
                <el-button
                  size="mini"
                  type="text"
                  icon="el-icon-delete"
                  @click="handleDelete(scope.row)"
                  v-hasPermi="['manage:labelfieldinfo:remove']"
                  >删除</el-button
                >
              </template>
            </el-table-column>
          </el-table>
        </div>
        <!-- <pagination v-show="total > 0" :total="total" :page.sync="queryParams.pageNum"
          :limit.sync="queryParams.pageSize" @pagination="getList" /> -->
        <myPagination
          v-show="total > 0"
          :total="total"
          :pageSize="queryParams.pageSize"
          :indexFromWrap="queryParams.pageNum"
          @updateCPage="updateCPage"
        ></myPagination>
      </el-col>
    </el-row>

    <!-- 添加标签字段信息对话框 -->
    <el-dialog :title="title" :visible.sync="open" width="750px" append-to-body>
      <el-form
        ref="form"
        :model="form"
        :rules="rules"
        label-width="100px"
        :inline="true"
      >
        <div v-for="(aitem, index) in form.labelFieldInfoList" :key="index">
          <el-form-item
            label="字段名称"
            :rules="rules.labelFieldInfoList.fieldName"
            :prop="`labelFieldInfoList.${index}.fieldName`"
          >
            <el-input
              v-model="aitem.fieldName"
              placeholder="请输入字段名称"
              style="width: 210px"
            />
          </el-form-item>
          <el-form-item
            label="字段类型"
            :rules="rules.labelFieldInfoList.fieldType"
            :prop="`labelFieldInfoList.${index}.fieldType`"
          >
            <el-select
              v-model="aitem.fieldType"
              placeholder="请选择字段类型"
              clearable
              style="width: 210px"
            >
              <el-option
                v-for="item in options"
                :key="item.dictValue"
                :label="item.dictLabel"
                :value="item.dictValue"
              >
              </el-option>
            </el-select>
          </el-form-item>

          <el-form-item label="任务类型" prop="taskTypeId">
            <el-button
              type=""
              v-if="aitem.taskTypeName == '请选择任务类型'"
              @click="clicktype(aitem, index)"
              style="
                width: 210px;
                text-align: left;
                height: 36px;
                color: #c0c4cc;
                overflow: hidden;
              "
              >{{ aitem.taskTypeName }}</el-button
            >
            <el-button
              @click="clicktype(aitem, index)"
              type=""
              v-else
              style="
                width: 210px;
                text-align: left;
                height: 36px;
                padding-left: -10px;
                overflow: hidden;
              "
              >{{ aitem.taskTypeName }}</el-button
            >
          </el-form-item>
          <el-form-item label="任务细分" prop="taskPartitionDictId">
            <el-button
              type=""
              v-if="aitem.taskPartitionDictName == '请选择任务细分'"
              @click="clickinnerVisible(aitem, index)"
              style="
                width: 210px;
                text-align: left;
                height: 36px;
                color: #c0c4cc;
                overflow: hidden;
              "
              >{{ aitem.taskPartitionDictName }}</el-button
            >
            <el-button
              @click="clickinnerVisible(aitem, index)"
              type=""
              v-else
              style="
                width: 210px;
                text-align: left;
                height: 36px;
                padding-left: -10px;
                overflow: hidden;
              "
              >{{ aitem.taskPartitionDictName }}</el-button
            >
          </el-form-item>
          <el-form-item
            label="字段排序"
            :rules="rules.labelFieldInfoList.fieldSort"
            :prop="`labelFieldInfoList.${index}.fieldSort`"
          >
            <el-input-number
              v-model="aitem.fieldSort"
              controls-position="right"
              :min="0"
              placeholder="请输入字段排序"
              style="width: 210px"
            />
            <!-- <el-input v-model="aitem.fieldSort" placeholder="请输入字段排序" oninput="value=value.replace(/[^\d]/g,'')"
              maxlength="5"/> -->
          </el-form-item>
          <el-form-item
            label="字段编码"
            :rules="rules.labelFieldInfoList.fieldCode"
            :prop="`labelFieldInfoList.${index}.fieldCode`"
          >
            <el-input
              onkeyup="this.value=this.value.replace(/[^A-Z]/g,'')"
              maxlength="50"
              v-model="aitem.fieldCode"
              placeholder="请输入字段编码"
              style="width: 210px"
            />
          </el-form-item>
          <el-form-item label="字段备注信息" prop="fieldRemark">
            <el-input
              style="width: 530px"
              v-model="aitem.fieldRemark"
              placeholder="请输入字段备注信息"
              type="textarea"
            />
          </el-form-item>

          <el-button
            type="primary"
            plain
            icon="el-icon-circle-plus-outline"
            style="margin-left: 6px; margin-top: 9px"
            v-if="index == 0"
            @click="addnurseClassifyitem"
          ></el-button>
          <el-button
            type="danger"
            icon="el-icon-delete"
            plain
            style="margin-left: 6px; margin-top: 9px"
            v-if="index != 0"
            @click="delnurseClassifyitem(index)"
          ></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="titleup"
      :visible.sync="openup"
      width="750px"
      append-to-body
    >
      <el-form
        ref="form"
        :model="form"
        :rules="rulesup"
        label-width="100px"
        :inline="true"
      >
        <el-form-item label="字段名称" prop="fieldName">
          <el-input
            v-model="form.fieldName"
            placeholder="请输入字段名称"
            style="width: 210px"
          />
        </el-form-item>
        <el-form-item label="字段类型" prop="fieldType">
          <el-select
            v-model="form.fieldType"
            placeholder="请选择字段类型"
            clearable
            style="width: 210px"
          >
            <el-option
              v-for="item in options"
              :key="item.dictValue"
              :label="item.dictLabel"
              :value="item.dictValue"
            >
            </el-option>
          </el-select>
        </el-form-item>
        <el-form-item label="任务类型" prop="taskTypeId">
          <el-button
            type=""
            v-if="form.taskTypeName == '请选择任务类型'"
            @click="clicktypexg()"
            style="
              width: 210px;
              text-align: left;
              height: 36px;
              color: #c0c4cc;
              overflow: hidden;
            "
            >{{ form.taskTypeName }}</el-button
          >
          <el-button
            @click="clicktypexg()"
            type=""
            v-else
            style="
              width: 210px;
              text-align: left;
              height: 36px;
              padding-left: -10px;
              overflow: hidden;
            "
            >{{ form.taskTypeName }}</el-button
          >
        </el-form-item>
        <el-form-item label="任务细分" prop="taskPartitionDictId">
          <el-button
            type=""
            v-if="form.taskPartitionDictName == '请选择任务细分'"
            @click="clickinnerVisiblexg()"
            style="
              width: 210px;
              text-align: left;
              height: 36px;
              color: #c0c4cc;
              overflow: hidden;
            "
            >{{ form.taskPartitionDictName }}</el-button
          >
          <el-button
            @click="clickinnerVisiblexg()"
            type=""
            v-else
            style="
              width: 210px;
              text-align: left;
              height: 36px;
              padding-left: -10px;
              overflow: hidden;
            "
            >{{ form.taskPartitionDictName }}</el-button
          >
        </el-form-item>
        <el-form-item label="字段排序" prop="fieldSort">
          <el-input-number
            v-model="form.fieldSort"
            controls-position="right"
            :min="0"
            placeholder="请输入字段排序"
            style="width: 210px"
          />
        </el-form-item>
        <el-form-item label="字段编码" prop="fieldCode">
          <el-input
            maxlength="50"
            onkeyup="this.value=this.value.replace(/[^A-Z]/g,'')"
            v-model="form.fieldCode"
            placeholder="请输入字段编码"
            style="width: 210px"
          />
        </el-form-item>
        <el-form-item label="字段备注信息" prop="fieldRemark">
          <el-input
            style="width: 530px"
            v-model="form.fieldRemark"
            placeholder="请输入字段备注信息"
            type="textarea"
          />
        </el-form-item>
      </el-form>
      <div slot="footer" class="dialog-footer">
        <el-button type="primary" @click="submitForm">确 定</el-button>
        <el-button @click="cancelup">取 消</el-button>
      </div>
    </el-dialog>
    <!-- 任务细分弹框 -->
    <el-dialog
      title="选择任务细分"
      :visible.sync="innerVisible"
      width="1000px"
      append-to-body
      :before-close="innerVisiblecancel"
    >
      <el-form
        :model="queryParamstask"
        ref="queryForm"
        size="small"
        :inline="true"
        v-show="showSearch"
        label-width="100px"
      >
        <el-form-item label="任务细分名称" prop="taskPartitionName">
          <el-input
            v-model="queryParamstask.taskPartitionName"
            placeholder="请输入任务细分名称"
            clearable
          />
        </el-form-item>
        <el-form-item label="任务细分编码" prop="taskPartitionCode">
          <el-input
            v-model="queryParamstask.taskPartitionCode"
            placeholder="请输入任务细分编码"
            clearable
          />
        </el-form-item>
        <el-form-item>
          <el-button
            type="primary"
            icon="el-icon-search"
            size="mini"
            @click="handleQuerytask"
            >搜索</el-button
          >
          <el-button icon="el-icon-refresh" size="mini" @click="resetQuerytask"
            >重置</el-button
          >
        </el-form-item>
      </el-form>
      <el-table
        :max-height="maxTableHeight"
        v-loading="loading"
        :data="partitionList"
        @cell-dblclick="nurseclickzx"
        @selection-change="handleSelectionChange"
      >
        <el-table-column label="请选择" width="100" align="center">
          <template slot-scope="scope">
            <el-button
              type="primary"
              style="width: 15px; height: 15px"
              v-if="taskPartitionDictId == scope.row.id"
              circle
              @click="nurseclickzx(scope.row)"
            ></el-button>
            <el-button
              v-else
              style="width: 15px; height: 15px"
              circle
              @click="nurseclickzx(scope.row)"
            ></el-button>
          </template>
        </el-table-column>
        <el-table-column
          label="任务类型名称"
          align="center"
          prop="taskTypeName"
        />
        <el-table-column
          label="任务细分名称"
          align="center"
          prop="taskPartitionName"
        />
        <el-table-column
          label="任务细分编码"
          align="center"
          prop="taskPartitionCode"
        />
        <el-table-column
          label="二级分类描述"
          align="center"
          prop="secondClassifyDescribe"
          :show-overflow-tooltip="true"
        />
        <el-table-column
          label="执行时间"
          align="center"
          prop="executionTime"
          width="180"
        >
        </el-table-column>
        <el-table-column
          label="任务细分排序"
          align="center"
          prop="taskPartitionSort"
        />
        <el-table-column
          label="任务细分备注"
          align="center"
          prop="taskPartitionRemark"
          :show-overflow-tooltip="true"
        />
      </el-table>
      <!-- <pagination class="pag" v-show="totaltask > 0" :total="totaltask" :page.sync="queryParamstask.pageNum"
        :limit.sync="queryParamstask.pageSize" @pagination="getListpartit" />
       -->
      <myPagination
        v-show="totaltask > 0"
        :total="totaltask"
        :pageSize="queryParamstask.pageSize"
        :indexFromWrap="queryParamstask.pageNum"
        @updateCPage="updateCPagetwo"
      ></myPagination>
    </el-dialog>
    <!-- 任务类型 -->
    <el-dialog
      title="选择任务类型"
      :visible.sync="innertype"
      width="1000px"
      append-to-body
      :before-close="typeecancel"
    >
      <el-form
        :model="queryType"
        ref="queryForm"
        size="small"
        :inline="true"
        v-show="showSearch"
        label-width="100px"
      >
        <el-form-item label="任务类型名称" prop="taskTypeName">
          <el-input
            v-model="queryType.taskTypeName"
            placeholder="请输入任务类型名称"
            clearable
            @keyup.enter.native="handleQuery"
          />
        </el-form-item>
        <el-form-item>
          <el-button
            type="primary"
            icon="el-icon-search"
            size="mini"
            @click="handleQuerytype"
            >搜索</el-button
          >
          <el-button icon="el-icon-refresh" size="mini" @click="resetQuerytype"
            >重置</el-button
          >
        </el-form-item>
      </el-form>
      <el-table
        :max-height="maxTableHeight"
        v-loading="loading"
        :data="taskTypeList"
        @cell-dblclick="nurseclicktype"
        @selection-change="handleSelectionChange"
      >
        <el-table-column label="请选择" width="100" align="center">
          <template slot-scope="scope">
            <el-button
              type="primary"
              style="width: 15px; height: 15px"
              v-if="taskTypeId == scope.row.id"
              circle
              @click="nurseclicktype(scope.row)"
            ></el-button>
            <el-button
              v-else
              style="width: 15px; height: 15px"
              circle
              @click="nurseclicktype(scope.row)"
            ></el-button>
          </template>
        </el-table-column>
        <el-table-column
          label="任务类型名称"
          align="center"
          prop="taskTypeName"
        />
        <el-table-column
          label="任务类型编码"
          align="center"
          prop="taskTypeCode"
        />
        <el-table-column
          label="任务类型排序"
          align="center"
          prop="taskTypeSort"
        />
        <el-table-column
          label="任务类型备注"
          align="center"
          prop="taskTypeRemark"
          :show-overflow-tooltip="true"
        />
      </el-table>
      <myPagination
        v-show="totaltype > 0"
        :total="totaltype"
        :pageSize="queryType.pageSize"
        :indexFromWrap="queryType.pageNum"
        @updateCPage="updateCPagetype"
      ></myPagination>
    </el-dialog>
  </div>
</template>

<script>
import { listLabelfieldinfo, getLabelfieldinfo, delLabelfieldinfo, addLabelfieldinfo, updateLabelfieldinfo, taskTypeGrouping } from "@/api/manage/labelfieldinfo";
import { listPartition } from "@/api/system/partition";
import { getAgencytype } from "@/api/system/agency";
import { listTaskType } from "@/api/system/taskType";


export default {
  name: "Labelfieldinfo",
  data() {
    return {
      itemid: null,

      list: [],
      // listdata: {
      //   list: [
      //     {
      //       name: '一致性 Consistency',
      //       id: '1',
      //       items: [{
      //         lable: '1',
      //         keyname: '与现实生活一致'
      //       },
      //       {
      //         lable: '2',
      //         keyname: '在界面中一致'
      //       }
      //       ]
      //     },
      //     {
      //       name: '一致性',
      //       id: '2',

      //       items: [{
      //         lable: '3',
      //         keyname: '与现实生活一致'
      //       },
      //       {
      //         lable: '4',
      //         keyname: '在界面中一致'
      //       }, {
      //         lable: '5',
      //         keyname: '在界面中一致'
      //       }
      //       ]
      //     },
      //     {
      //       name: '一致性',
      //       id: '3',

      //       items: [{
      //         lable: '6',
      //         keyname: '与现实生活一致'
      //       },
      //       {
      //         lable: '7',
      //         keyname: '在界面中一致'
      //       }, {
      //         lable: '8',
      //         keyname: '在界面中一致'
      //       }
      //       ]
      //     },
      //     {
      //       name: '一致性',
      //       id: '4',

      //       items: [{
      //         lable: '6',
      //         keyname: '与现实生活一致'
      //       },
      //       {
      //         lable: '7',
      //         keyname: '在界面中一致'
      //       }, {
      //         lable: '8',
      //         keyname: '在界面中一致'
      //       }
      //       ]
      //     },

      //   ]

      // },
      activeNames: [],
      innerVisible: false,//任务细分
      // 任务细分字典表格数据
      partitionList: [],
      // 查询参数
      queryParamstask: {
        pageNum: 1,
        pageSize: 10,

        taskTypeId: null,
        taskTypeName: null,
        taskPartitionName: null,
        taskPartitionCode: null,
        secondClassifyDescribe: null,
        executionTime: null,
        taskPartitionSort: null,
        taskPartitionRemark: null,
      },
      nnerVisibleindex: '',
      taskPartitionDictId: '',
      taskTypeId: '',
      maxTableHeight: undefined,
      totaltask: 0,
      // 任务类型
      innertype: false,
      totaltype: 0,
      taskTypeList: [],

      queryType: {
        pageNum: 1,
        pageSize: 10,
        taskTypeName: null,
        taskTypeCode: null,
        taskTypeSort: null,
        taskTypeRemark: null,
      },
      // 遮罩层
      loading: true,
      // 选中数组
      ids: [],
      // 非单个禁用
      single: true,
      // 非多个禁用
      multiple: true,
      // 显示搜索条件
      showSearch: true,
      // 总条数
      total: 0,
      // 标签字段信息表格数据
      labelfieldinfodata: [],
      // 弹出层标题
      title: "",
      titleup: "",
      // 是否显示弹出层
      open: false,
      openup: false,//修改
      // 查询参数
      queryParams: {
        pageNum: 1,
        pageSize: 10,
        fieldName: null,
        fieldType: null,
        fieldType: null,
        fieldSort: null,
        fieldRemark: null,
      },
      options: [],
      // 表单参数
      form: {},
      // 表单校验
      rules: {
        labelFieldInfoList: {
          fieldType: [
            {
              required: true,
              message: "请选择字段类型",
              trigger: "blur",
            },
          ],
          fieldName: [
            {
              required: true,
              message: "请输入字段名称",
              trigger: "blur",
            },
          ],
          fieldSort: [
            {
              required: true,
              message: "请输入字段排序",
              trigger: "blur",
            },
          ],
          fieldCode: [
            {
              required: true,
              message: "请输入字段编码",
              trigger: "blur",
            },
          ],
          fieldRemark: [
            {
              required: true,
              message: "请输入字段备注信息",
              trigger: "blur",
            },
          ],

        },
      },
      rulesup: {
        fieldType: [
          {
            required: true,
            message: "请选择字段类型",
            trigger: "blur",
          },
        ],
        fieldName: [
          {
            required: true,
            message: "请输入字段名称",
            trigger: "blur",
          },
        ],
        fieldCode: [
          {
            required: true,
            message: "请输入字段编码",
            trigger: "blur",
          },
        ],
        fieldSort: [
          {
            required: true,
            message: "请输入字段排序",
            trigger: "blur",
          },
        ],
        // fieldRemark: [
        //   {
        //     required: true,
        //     message: "请输入字段备注信息",
        //     trigger: "blur",
        //   },
        // ],

      },
      currentRow: null,
    };
  },
  created() {
    this.getList();
    this.infolistword();
    this.getListleft();

  },
  mounted() {
    this.getMaxTableHeight()
    // this.screenChange()

  },
  methods: {
    // 全部点击事件
    allclick() {
      this.itemid = ''
      this.queryParams.taskPartitionDictId=null
      this.getList();
    },
    // 左侧点击事件
    clickitem(row) {
      console.log(row, 'row');
      this.queryParams.taskPartitionDictId = row.id
      this.itemid = this.queryParams.taskPartitionDictId;
      this.getList();



    },
    handleChange(val) {
      console.log(val);
    },
    updateCPage(index, size) {
      this.queryParams.pageNum = index
      this.queryParams.pageSize = size
      this.getList();
    },
    updateCPagetwo(index, size) {
      this.queryParamstask.pageNum = index
      this.queryParamstask.pageSize = size
      this.getListpartit();
    },
    updateCPagetype(index, size) {
      this.queryType.pageNum = index
      this.queryType.pageSize = size
      this.getListType();
    },

    infolistword() {
      var dictType = "field_type";
      getAgencytype(dictType).then((res) => {
        this.options = res.data;
      });
    },
    // 左侧查询
    getListleft() {
      this.loading = true;
      taskTypeGrouping().then(response => {
        console.log(response, 'response')
        this.list = response.data;
        this.list.forEach(e => {
          this.activeNames.push(e.taskTypeId);
          console.log(this.activeNames, 'this.activeNames')

        })
      });
    },

    /** 查询任务类型字典列表 */
    getListType() {
      this.loading = true;
      listTaskType(this.queryType).then(response => {
        this.taskTypeList = response.rows;
        this.totaltype = response.total;
        this.loading = false;
      });
    },
    // 任务细分列表
    getListpartit() {
      this.loading = true;
      listPartition(this.queryParamstask).then(response => {
        this.partitionList = response.rows;
        this.totaltask = response.total;
        this.loading = false;
      });
    },
    // 任务类型弹框
    clicktype(aitem, index) {
      this.getListType();
      this.taskTypeId = aitem.taskTypeId ? aitem.taskTypeId : '';
      this.nnerVisibleindex = index;
      this.innertype = true


    },
    // 任务细分弹框
    clickinnerVisible(aitem, index) {
      if (this.taskTypeId == '' || !aitem.taskTypeId) {
        this.$modal.msgError("请先选择任务类型");
      } else {
        this.nnerVisibleindex = index;
        this.taskPartitionDictId = aitem.taskPartitionDictId ? aitem.taskPartitionDictId : '';
        this.innerVisible = true;
      }
      if (aitem.taskTypeId) {
        this.queryParamstask.taskTypeId = aitem.taskTypeId
      }
      this.getListpartit();

    },
    // 修改任务类型
    clicktypexg() {
      if (this.form.taskTypeId) {
        this.taskTypeId = this.form.taskTypeId
      }
      this.getListType();
      this.innertype = true;

    },
    // 修改任务细分弹框
    clickinnerVisiblexg() {
      if (this.form.taskPartitionDictId) {
        this.taskPartitionDictId = this.form.taskPartitionDictId
      }
      if (this.form.taskTypeId) {
        this.taskTypeId = this.form.taskTypeId
      }

      this.getListpartit();
      this.innerVisible = true;
    },

    // 关闭
    innerVisiblecancel() {
      this.innerVisible = false;
    },
    typeecancel() {
      this.innertype = false;
    },
    nurseclickzx(row) {
      this.taskPartitionDictId = row.id
      if (this.title == '添加标签字段信息') {
        this.form.labelFieldInfoList[this.nnerVisibleindex].taskPartitionDictName =
          row.taskPartitionName;
        this.form.labelFieldInfoList[this.nnerVisibleindex].taskPartitionDictId =
          row.id;
      } else if (this.titleup == '修改标签字段信息') {
        this.form.taskPartitionDictName = row.taskPartitionName;
        this.form.taskPartitionDictId =
          row.id;

      }
      this.innerVisible = false;
    },
    // 任务类型
    nurseclicktype(row) {
      console.log(row, 'row')
      this.queryParamstask.taskTypeId = row.id
      this.taskTypeId = this.queryParamstask.taskTypeId
      // this.getListpartit()
      if (this.title == '添加标签字段信息') {
        this.form.labelFieldInfoList[this.nnerVisibleindex].taskTypeName =
          row.taskTypeName;
        this.form.labelFieldInfoList[this.nnerVisibleindex].taskTypeId =
          row.id;
        this.form.labelFieldInfoList[this.nnerVisibleindex].taskPartitionDictName = '请选择任务细分',
          this.form.labelFieldInfoList[this.nnerVisibleindex].taskPartitionDictId = '';
        // this.form.taskPartitionDictName = '请选择任务细分',
        this.taskPartitionDictId = '';

      } else if (this.titleup == '修改标签字段信息') {
        this.form.taskTypeName = row.taskTypeName;
        this.form.taskTypeId = row.id;
        this.form.taskPartitionDictName = "请选择任务细分";
        this.form.taskPartitionDictId = '';
      }
      this.innertype = false;
    },

    /** 查询标签字段信息列表 */
    getList() {
      this.loading = true;
      listLabelfieldinfo(this.queryParams).then(response => {
        this.labelfieldinfodata = response.rows;
        this.total = response.total;
        this.loading = false;
      });
    },
    //添加时新增item
    addnurseClassifyitem() {
      var obj = {
        fieldType: null,
        fieldName: null,
        fieldRemark: null,
        fieldSort: undefined,
        taskPartitionDictName: '请选择任务细分',
        taskPartitionDictId: '',
        taskTypeName: '请选择任务类型',
        taskTypeId: '',
        fieldCode: null,

      };
      this.taskTypeId = ''
      if (this.form.labelFieldInfoList.length == 5) {
        this.$message.error("最多批量添加5条");
      } else {
        this.form.labelFieldInfoList.push(obj);
        console.log(this.form)
      }
    },
    //添加时删除item
    delnurseClassifyitem(index) {
      this.form.labelFieldInfoList.splice(index, 1);
    },
    // 取消按钮
    cancel() {
      this.open = false;
      this.reset();
    },
    // 修改取消
    cancelup() {
      this.openup = false,
        this.reset();

    },
    // 表单重置
    reset() {
      this.form = {
        id: null,
        fieldName: null,
        fieldType: null,
        fieldType: null,
        fieldSort: undefined,
        fieldRemark: null,
        createBy: null,
        createTime: null,
        updateBy: null,
        updateTime: null,
        taskPartitionDictName: null,
        taskPartitionDictId: null,
        taskTypeId: null,
        taskTypeName: null,


      };
      this.resetForm("form");
    },
    /** 搜索按钮操作 */
    handleQuery() {
      this.queryParams.pageNum = 1;
      this.queryParams.taskPartitionDictId = null;
      this.getList();
      // this.getListleft()
    },
    /** 重置按钮操作 */
    resetQuery() {
      this.itemid = null;

      this.resetForm("queryForm");
      this.handleQuery();
    },
    // 细分
    handleQuerytask() {
      this.queryParamstask.pageNum = 1;
      this.getListpartit();

    },
    resetQuerytask() {
      this.resetForm("queryForm");
      this.handleQuerytask();
    },
    // 类型
    handleQuerytype() {
      this.queryType.pageNum = 1;
      this.getListType();

    },
    resetQuerytype() {
      this.resetForm("queryForm");
      this.handleQuerytype();
    },

    // 多选框选中数据
    handleSelectionChange(selection) {
      this.ids = selection.map(item => item.id)
      this.single = selection.length !== 1
      this.multiple = !selection.length
    },
    /** 新增按钮操作 */
    handleAdd() {
      this.reset();
      this.taskTypeId = '',
        this.taskPartitionDictId = '',
        this.form = {
          labelFieldInfoList: [
            {
              fieldType: null,
              fieldName: null,
              fieldRemark: null,
              fieldSort: undefined,
              taskPartitionDictName: '请选择任务细分',
              taskPartitionDictId: '',
              taskTypeName: '请选择任务类型',
              taskTypeId: '',


            },
          ],
        };
      this.open = true;
      this.title = "添加标签字段信息";
    },
    /** 修改按钮操作 */
    handleUpdate(row) {
      this.reset();
      this.infolistword();
      const id = row.id || this.ids
      getLabelfieldinfo(id).then(response => {
        this.form = response.data;
        if (!this.form.taskPartitionDictName || this.form.taskPartitionDictName == "") {
          this.form.taskPartitionDictName = '请选择任务细分'
        }
        if (!this.form.taskTypeName || this.form.taskTypeName == "") {
          this.form.taskTypeName = '请选择任务类型'
        }
        if (this.form.taskTypeId) {
          this.queryParamstask.taskTypeId = this.form.taskTypeId
          this.getListpartit();
        }
        this.openup = true;
        this.titleup = "修改标签字段信息";
      });
    },
    /** 提交按钮 */
    submitForm() {
      // return
      this.$refs["form"].validate(valid => {
        var obj = JSON.parse(JSON.stringify(this.form))
        if (valid) {
          if (this.form.id != null) {
            if (obj.taskPartitionDictName == '请选择任务细分') {
              obj.taskPartitionDictName = ""
            }
            if (obj.taskTypeName == '请选择任务类型') {
              obj.taskTypeName = ""
            }

            updateLabelfieldinfo(obj).then(response => {
              this.$modal.msgSuccess("修改成功");
              this.openup = false;
              this.getList();
            });
          } else {

            obj.labelFieldInfoList.forEach(e => {
              if (e.taskPartitionDictName == '请选择任务细分') {
                e.taskPartitionDictName = ""
              }
              if (e.taskTypeName == '请选择任务类型') {
                e.taskTypeName = ""
              }

            });
            // return
            addLabelfieldinfo(obj).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 delLabelfieldinfo(ids);
      }).then(() => {
        this.getList();
        this.$modal.msgSuccess("删除成功");
      }).catch(() => { });
    },
    /** 导出按钮操作 */
    handleExport() {
      this.download('manage/labelfieldinfo/export', {
        ...this.queryParams
      }, `labelfieldinfo_${new Date().getTime()}.xlsx`)
    },
    // 获取表格最高高度
    getMaxTableHeight() {
      const windowInnerHeight = window.innerHeight // 屏幕可视高度
      const layoutDiv = this.$refs.layout
      const formDiv = this.$refs.topform
      const mb8Div = this.$refs.mb8
      this.maxTableHeight =
        windowInnerHeight - 134 -
        this.getBoxPadding(layoutDiv) -
        this.getBoxHeight(mb8Div) -
        this.getBoxHeight(formDiv)
    },
    // 屏幕resize监听
    screenChange() {
      // 屏幕resize监听事件：一旦屏幕宽高发生变化，就会执行resize
      window.addEventListener('resize', this.getMaxTableHeight, true)
      // 将屏幕监听事件移除
      // 这步是必须的。离开页面时不移除，再返回，或者进入到别的有相同元素的页面会报错
      // 或者将这里的方法直接写在beforeDestroy函数中也可以
      this.$once('hook:beforeDestroy', () => {
        window.removeEventListener('resize', this.getMaxTableHeight, true)
      })
    },
  }
};
</script>
<style lang="scss" scoped>
/* 设置被点击行的背景颜色 */

// ::v-deep .el-table__body tr.current-row>td{
//     background-color: #92cbf1!important;
//      color: #fff;
//   }
::v-deep .el-collapse-item__header {
  font-size: 15px;
  // font-weight: 600;
}
::v-deep .el-collapse-item__wrap {
  border-bottom: none;
}


::v-deep .el-table::before {
  height: 0px !important;
}
.left {
  height: calc(100vh - 119px);
  overflow-y: auto;
  overflow-x: hidden;
  ::v-deep .el-collapse-item__content{
    padding-bottom: 0px;

  }
  .count {
          float: right;
          margin-right: 50px;
          color: #a4a6aa;
          font-size: 13px;
        }
  ::v-deep table td.el-table__cell:last-child {
  // border-bottom: 1px solid #dfe6ec;
  // border-bottom: none;
}
  .clickall {
    width: 167px;
    height: 48px;
    line-height: 48px;
    background: #e8f4ff;
    font-size: 15px;
    // font-weight: 600;
  }
  .all {
    height: 48px;
    line-height: 48px;
    font-size: 15px;
    // font-weight: 600;
  }
  .collitem {
    width: 110%;
    height: 35px;
    line-height: 35px;
    padding-left: 10px;
    margin-left: -10px;
  }
  .allactive {
    width: 110%;
    height: 35px;
    line-height: 35px;
    padding-left: 10px;
    margin-left: -10px;
    background: #e8f4ff;
  }
}
::v-deep .el-dialog__body {
  padding-bottom: 60px !important;
}

::v-deep .el-input-number .el-input__inner {
  text-align: left;
}
</style>
