<template>
  <div class="app-container">
    <el-form
      :model="queryParams"
      ref="queryForm"
      size="small"
      :inline="true"
      v-show="showSearch"
      label-width="100px"
    >
      <el-form-item label="服务内容" prop="serviceContent">
        <el-input
          v-model="queryParams.serviceContent"
          placeholder="请输入服务内容"
          clearable
          @keyup.enter.native="handleQuery"
        />
      </el-form-item>
      <!-- <el-form-item label="服务方式编码" prop="serviceWayCode">
        <el-input
          v-model="queryParams.serviceWayCode"
          placeholder="请输入服务方式编码"
          clearable
          @keyup.enter.native="handleQuery"
        />
      </el-form-item> -->
      <!-- <el-form-item label="所属服务方式id" prop="serviceWayId">
        <el-input
          v-model="queryParams.serviceWayId"
          placeholder="请输入所属服务方式id"
          clearable
          @keyup.enter.native="handleQuery"
        />
      </el-form-item>
      <el-form-item label="所属服务内容id" prop="serviceContentId">
        <el-input
          v-model="queryParams.serviceContentId"
          placeholder="请输入所属服务内容id"
          clearable
          @keyup.enter.native="handleQuery"
        />
      </el-form-item>
      <el-form-item label="服务频次文本" prop="serviceFrequencyText">
        <el-input
          v-model="queryParams.serviceFrequencyText"
          placeholder="请输入服务频次文本"
          clearable
          @keyup.enter.native="handleQuery"
        />
      </el-form-item>
      <el-form-item label="服务频次数字起始值" prop="serviceFrequencyStart">
        <el-input
          v-model="queryParams.serviceFrequencyStart"
          placeholder="请输入服务频次数字起始值"
          clearable
          @keyup.enter.native="handleQuery"
        />
      </el-form-item>
      <el-form-item label="服务频次数字结束值" prop="serviceFrequencyEnd">
        <el-input
          v-model="queryParams.serviceFrequencyEnd"
          placeholder="请输入服务频次数字结束值"
          clearable
          @keyup.enter.native="handleQuery"
        />
      </el-form-item>
      <el-form-item label="排序" prop="serviceSort">
        <el-input
          v-model="queryParams.serviceSort"
          placeholder="请输入排序"
          clearable
          @keyup.enter.native="handleQuery"
        />
      </el-form-item>
      <el-form-item label="备注" prop="serviceRemark">
        <el-input
          v-model="queryParams.serviceRemark"
          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="['manage:servicewaycontent: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:servicewaycontent: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:servicewaycontent:remove']"
          >删除</el-button
        >
      </el-col> -->
      <!-- <el-col :span="1.5">
        <el-button
          type="warning"
          plain
          icon="el-icon-download"
          size="mini"
          @click="handleExport"
          v-hasPermi="['manage:servicewaycontent:export']"
          >导出</el-button
        >
      </el-col> -->
      <right-toolbar
        :showSearch.sync="showSearch"
        @queryTable="getList"
      ></right-toolbar>
    </el-row>
    <el-row :gutter="20">
      <el-col :span="5">
        <div class="left" ref="box">
          <div class="name">
            服务方式
            <el-button
              plain
              icon="el-icon-circle-plus-outline"
              size="mini"
              @click="handleUpdateserve"
            ></el-button>

            <el-button
              v-if="this.itemname"
              plain
              icon="el-icon-s-tools"
              size="mini"
              @click="handleedit"
            ></el-button>
            <el-button
              v-if="this.itemname"
              plain
              icon="el-icon-delete"
              size="mini"
              @click="handledelete"
            ></el-button>
          </div>
          <div>
            <el-input
              v-model="name"
              placeholder="请输入服务方式"
              clearable
              @keyup.enter.native="handleQuery"
            />
          </div>
          <div class="listitem">
            <div
              :class="itemname == null ? 'allactive' : 'all'"
              @click="itemdata()"
            >
              全部
            </div>
            <span class="count">{{ count }}</span>
          </div>
          <div
            class="listitem"
            v-for="(item, index) in DepartmentoList"
            :key="index"
            @click="itemdata(item)"
          >
            <div :class="itemname == item.id ? 'allactive' : 'all'">
              {{ item.serviceWayName }}
            </div>
            <span class="count">{{ item.serviceContentNum }}</span>
          </div>
        </div>
      </el-col>
      <el-col :span="18">
        <el-table
          v-loading="loading"
          :data="servicewaycontentList"
          @selection-change="handleSelectionChange"
        >
          <el-table-column width="55" align="center" />
          <el-table-column label="序号" align="center" prop="id" type="index" />

          <el-table-column
            label="服务内容"
            align="center"
            prop="serviceContent"
          />
          <el-table-column
            label="服务频次"
            align="center"
            prop="serviceWayFrequencyList"
          >
            <!-- <template slot-scope="scope">

              <el-select
                size="mini"
                @click="getSuppliers()"
                @change="blurInputs(scope.row.valuePlusMax)"
                v-model="scope.row.valuePlusMax"
                clearable
                placeholder="请选择"
              >

                <el-option
                  v-for="item in scope.row.serviceWayFrequencyList"
                  :key="item.id"
                  :label="
                    item.serviceFrequencyType == 'TEXT'
                      ? item.serviceFrequencyText
                      : item.serviceFrequencyType == 'DIGIT'
                      ? JSON.parse(item.serviceFrequencyStart) +
                        '~' +
                        JSON.parse(item.serviceFrequencyEnd)
                      : ''
                  "
                  :value="item.id"
                >
                </el-option>
              </el-select>

            </template> -->

            <!-- </div> -->
            <!-- </template>  -->
            <template slot-scope="scope">
              <!-- {{ scope.row.serviceFrequencyType }} -->
              <!-- <div
                v-for="(item, index) in scope.row"
                :key="index"
              > -->
              <div v-if="scope.row.serviceFrequencyType == 'DIGIT'">
                {{ scope.row.serviceFrequencyStart }}~{{
                  scope.row.serviceFrequencyEnd
                }}
              </div>
              <div v-if="scope.row.serviceFrequencyType == 'TEXT'">
                {{ scope.row.serviceFrequencyText }}
              </div>
              <!-- </div> -->
            </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-edit"
                @click="handleUpdate(scope.row)"
                v-hasPermi="['manage:servicewaycontent:edit']"
                >修改</el-button
              >
              <el-button
                size="mini"
                type="text"
                icon="el-icon-delete"
                @click="handleDelete(scope.row)"
                v-hasPermi="['manage:servicewaycontent: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-col>
    </el-row>

    <!-- 添加或修改服务方式内容对话框 -->
    <el-dialog :title="title" :visible.sync="open" width="700px" append-to-body>
      <el-form ref="form" :model="form" :rules="rules" label-width="110px">
        <!-- <el-form-item label="服务方式名称" prop="serviceWayName">
          <el-input v-model="form.serviceWayName" placeholder="请输入服务方式名称" />
        </el-form-item>
        <el-form-item label="服务方式编码" prop="serviceWayCode">
          <el-input v-model="form.serviceWayCode" placeholder="请输入服务方式编码" />
        </el-form-item> -->
        <el-form-item label="所属服务方式" prop="serviceWayId">
          <el-select
            v-model="form.serviceWayId"
            clearable
            :disabled="disableedit"
            placeholder="请选择服务方式"
            style="width: 250px"
          >
            <el-option
              v-for="item in DepartmentoList"
              :key="item.id"
              :label="item.serviceWayName"
              :value="item.id"
            ></el-option>
          </el-select>
          <!-- <el-input v-model="form.serviceWayId" placeholder="请输入所属服务方式id" /> -->
        </el-form-item>
        <el-form-item label="服务内容" prop="serviceContent" label-width="80">
          <el-input
            type="textarea"
            style="width: 400px"
            placeholder="请输入服务内容"
            v-model="form.serviceContent"
          />
        </el-form-item>
        <el-form-item
          label="服务频次"
          prop="serviceFrequencyType"
          label-width="80px"
        >
          <el-form-item label="" prop="serviceFrequencyType" label-width="">
            <el-checkbox v-model="DIGIT" @change="DIGITlist">数字</el-checkbox>
          </el-form-item>

          <div style="display: flex; margin: -32px 34px 0 66px">
            <el-form-item label="" prop="serviceFrequencyStart" label-width="">
              <el-input
                :disabled="disableda"
                :change="checkPrice()"
                v-model="form.serviceFrequencyStart"
                placeholder="请输入服务频次数字起始值"
              />
            </el-form-item>
            <span>~</span>
            <el-form-item label="" prop="serviceFrequencyEnd" label-width="">
              <el-input
                :disabled="disabledb"
                :change="checkPricemax()"
                oninput="value=value.replace(/[^\d.]/g,'')"
                v-model="form.serviceFrequencyEnd"
                placeholder="请输入服务频次数字结束值"
              />
            </el-form-item>
          </div>
          <div>
            <div style="position: relative; top: 12px">
              <el-form-item label="" prop="serviceFrequencyType" label-width="">
                <el-checkbox v-model="TEXT" @change="textlist"
                  >文本</el-checkbox
                >
              </el-form-item>
            </div>
            <div style="margin: -23px 45px 0px 74px">
              <el-form-item label="" prop="serviceFrequencyText" label-width="">
                <el-input
                  :disabled="disabled"
                  v-model="form.serviceFrequencyText"
                  placeholder="请输入服务频次文本"
                  style="width: 250px"
                />
              </el-form-item>
            </div>
          </div>
        </el-form-item>
        <el-form-item label="排序" prop="serviceSort">
          <el-input-number
            v-model="form.serviceSort"
            controls-position="right"
            :min="0"
            @change="$forceUpdate()"
            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="titles"
      :visible.sync="opens"
      width="500px"
      append-to-body
    >
      <el-form
        ref="form"
        :model="format"
        :rules="rules"
        label-width="120px"
        :inline="true"
      >
        <el-form-item label="服务方式名称" prop="serviceWayName">
          <el-input
            v-model="format.serviceWayName"
            placeholder="请输入服务方式名称"
          />
        </el-form-item>
      </el-form>
      <div slot="footer" class="dialog-footer">
        <el-button type="primary" @click="submitForms">确 定</el-button>
        <el-button @click="cancels">取 消</el-button>
      </div>
    </el-dialog>
  </div>
</template>

<script>
import {
  listServicewaycontent,
  getServicewaycontent,
  delServicewaycontent,
  addServicewaycontent,
  editServiceWay,
  updateServicewaycontent,
  addServiceWay,
  serviceWayList,
  removeServiceWay,
  serviceWay,
} from "@/api/manage/servicewaycontent";

export default {
  name: "Servicewaycontent",
  data() {
    return {
      list: [],
      disableedit: false,
      serviceFrequencyStart: "",
      serviceFrequencyEnd: "",
      serviceFrequencyType: "",
      // disabled: "",
      disabledcontent: false,
      titles: "",
      DIGIT: true,
      TEXT: false,
      DepartmentoList: [], //左侧数组
      format: {
        serviceWayName: "",
        id: "",
      },
      // 遮罩层
      loading: true,
      opens: false,
      // 选中数组
      ids: [],
      // 非单个禁用
      single: true,
      // 非多个禁用
      multiple: true,
      // 显示搜索条件
      showSearch: true,
      // 总条数
      total: 0,
      // 服务方式内容表格数据
      servicewaycontentList: [],
      // 弹出层标题
      title: "",
      // 是否显示弹出层
      open: false,
      name: "",

      // 查询参数
      queryParams: {
        pageNum: 1,
        pageSize: 10,
        serviceWayName: null,
        serviceWayCode: null,
        serviceType: null,
        serviceWayId: null,
        serviceContent: null,
        serviceContentId: null,
        serviceFrequencyType: null,
        serviceFrequencyText: null,
        serviceFrequencyStart: null,
        serviceFrequencyEnd: null,
        serviceSort: null,
        serviceRemark: null,
      },
      count: "", //全部
      id: "",
      // 表单参数
      form: {},
      // 表单校验
      rules: {
        serviceFrequencyType: [{ required: true }],

        serviceWayId: [
          { required: true, message: "请选中所属服务方式", trigger: "blur" },
        ],
        serviceContent: [
          { required: true, message: "请输入服务内容", trigger: "blur" },
        ],
        serviceSort: [
          { required: true, message: "请输入排序", trigger: "blur" },
        ],
        // serviceFrequencyStart:[
        // { required: true, message: "请输入结束值", trigger: "blur" },
        // ],
        // serviceFrequencyText:[
        // { required: true, message: "请输入结束值", trigger: "blur" },
        // ],
      },
      itemname: null,
      serviceWayName: null,
      querydepartmen: {
        serviceWayName: "",
      },
      disabled: true,
      disabledb: false,
      disableda: false,
      valuePlus: "",
      serviceFrequencyText: "",
      keyTable: "",
      // list:[],
    };
  },
  watch: {
    name(val) {
      this.querydepartmen.serviceWayName = val;
      this.mentlist();
    },
  },
  created() {
    this.getList();
    this.mentlist();
  },
  methods: {
    /**只能输入数字且有小数点最多保留两位*/
    checkPrice() {
      let checkPlan = "" + this.form.serviceFrequencyStart;
      checkPlan = checkPlan
        .replace(/[^\d.]/g, "") // 清除“数字”和“.”以外的字符
        .replace(/\.{2,}/g, ".") // 只保留第一个. 清除多余的
        .replace(/^\./g, "") // 保证第一个为数字而不是.
        .replace(".", "$#$")
        .replace(/\./g, "")
        .replace("$#$", ".");
      if (checkPlan.indexOf(".") < 0 && checkPlan !== "") {
        // 以上已经过滤，此处控制的是如果没有小数点，首位不能为类似于 01、02的金额
        checkPlan = parseFloat(checkPlan) + "";
      } else if (checkPlan.indexOf(".") >= 0) {
        checkPlan = checkPlan.replace(/^()*(\d+)\.(\d\d).*$/, "$1$2.$3"); // 只能输入两个小数
      }
      this.form.serviceFrequencyStart = checkPlan;
    },
    checkPricemax() {
      let checkPlan = "" + this.form.serviceFrequencyEnd;
      checkPlan = checkPlan
        .replace(/[^\d.]/g, "") // 清除“数字”和“.”以外的字符
        .replace(/\.{2,}/g, ".") // 只保留第一个. 清除多余的
        .replace(/^\./g, "") // 保证第一个为数字而不是.
        .replace(".", "$#$")
        .replace(/\./g, "")
        .replace("$#$", ".");
      if (checkPlan.indexOf(".") < 0 && checkPlan !== "") {
        // 以上已经过滤，此处控制的是如果没有小数点，首位不能为类似于 01、02的金额
        checkPlan = parseFloat(checkPlan) + "";
      } else if (checkPlan.indexOf(".") >= 0) {
        checkPlan = checkPlan.replace(/^()*(\d+)\.(\d\d).*$/, "$1$2.$3"); // 只能输入两个小数
      }
      this.form.serviceFrequencyEnd = checkPlan;
    },
    // getSuppliers(e) {
    //   console.log(e);
    // },
    // blurInput(val) {
    //   // this.servicewaycontentList.serviceFrequencyText=val
    // },
    // blurInputs() {
    //   this.keyTable = Math.random();
    // },
    // 选择文本
    textlist(e) {
      if (e == true) {
        this.form.serviceFrequencyStart = null;
        this.form.serviceFrequencyEnd = null;

        this.disableda = true;
        this.disabledb = true;
        this.disabled = false;

        this.form.serviceFrequencyType = "TEXT";
      }
      this.DIGIT = false;
    },
    // 选择数字
    DIGITlist(e) {
      console.log(e, "5");
      if (e == true) {
        this.form.serviceFrequencyText = null;
        this.disableda = false;
        this.disabledb = false;
        this.disabled = true;
        this.form.serviceFrequencyType = "DIGIT";
      }
      this.TEXT = false;

      // else {
      //   this.form.serviceFrequencyType = "TEXT";
      // }
    },
    // 左侧服务方式提交
    submitForms() {
      // this.form.serviceFrequencyType=this.DIGIT
      // console.log(this.format,'5252')
      this.$refs["form"].validate((valid) => {
        if (valid) {
          // console.log(this.format);
          if (this.format.id) {
            editServiceWay(this.format).then((response) => {
              this.$modal.msgSuccess("修改成功");
              this.opens = false;
              this.mentlist();
            });
          } else {
            addServiceWay(this.format).then((response) => {
              this.$modal.msgSuccess("新增成功");
              this.opens = false;
              this.mentlist();
            });
          }
        }
      });
    },
    cancels() {
      this.opens = false;
    },
    // 左侧服务方式列表
    mentlist() {
      this.loading = true;
      serviceWayList(this.querydepartmen).then((response) => {
        this.DepartmentoList = response.data;
        let sum = 0;
        this.DepartmentoList.forEach((item) => {
          if (item.serviceContentNum) {
            console.log(item.countNum);
            sum += item.serviceContentNum;
          }
          this.count = sum;
        });
        this.loading = false;
      });
    },
    // 左侧科室
    itemdata(item) {
      if (item) {
        console.log(item, "9999");
        this.form.serviceWayId = item.id;
        this.form.serviceWayName = item.serviceWayName;
        // if(item.id==5){
        //   this.disabled=false
        // }else{
        //   this.disabled=true
        // }
        this.itemname = item.id;
        // this.serviceWayName = item.serviceWayName;
        this.form.serviceWayId = item.id;

        // this.departmentName = item.serviceWayName;
        this.loading = true;
        this.queryParams.serviceWayId = item.id;
        this.getList();
      } else {
        this.queryParams.serviceWayId = "";
        this.itemname = null;
        this.getList();
      }
    },
    /** 查询服务方式内容列表 */
    getList() {
      this.loading = true;
      this.servicewaycontentList = [];
      listServicewaycontent(this.queryParams).then((response) => {
        // this.servicewaycontentList = response.rows;
        response.rows.forEach((e) => {
          e.serviceWayFrequencyList.forEach((el) => {
            el.serviceContent = e.serviceContent;
            this.servicewaycontentList.push(el);
            console.log(
              this.servicewaycontentList,
              "this.servicewaycontentList"
            );
          });
        });
        this.total = response.total;
        this.loading = false;
      });
    },
    // 取消按钮
    cancel() {
      this.open = false;
      this.reset();
    },
    // 表单重置
    reset() {
      this.form = {
        id: null,
        serviceWayName: null,
        serviceWayCode: null,
        serviceType: null,
        serviceWayId: null,
        serviceContent: null,
        serviceContentId: null,
        serviceFrequencyType: null,
        serviceFrequencyText: null,
        serviceFrequencyStart: null,
        serviceFrequencyEnd: null,
        serviceSort: undefined,
        serviceRemark: null,
        createBy: null,
        createTime: null,
        updateBy: null,
        updateTime: null,
      };
      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.disableedit = false;
      this.disabledcontent = false;
      this.DIGIT = true;
      this.TEXT = false;
      this.disableda = false;
      this.disabledb = false;
      this.disabled = true; //文本
      this.form.serviceFrequencyType = "DIGIT";
      console.log(this.itemname, "itemname");
      if (this.itemname) {
        this.form.serviceWayName = this.serviceWayName;
        this.form.serviceWayId = this.itemname;
        console.log(this.form, " this.form");
      }
      this.open = true;
      this.title = "添加服务方式内容";
    },
    /** 修改按钮操作 */
    handleUpdate(row) {
      this.disableedit = true;
      this.disabledcontent = true;
      console.log(row, "99999");

      this.reset();
      getServicewaycontent(row.id).then((response) => {
        this.form = response.data;
        if (response.data.serviceFrequencySort) {
        this.form.serviceSort = response.data.serviceFrequencySort;
        }
        else {
          this.form.serviceSort = undefined;
        }
        this.form.id = response.data.serviceFrequencyId;
        if (response.data.serviceWayId) {
          this.form.serviceWayId = response.data.serviceWayId;
        }
        //  ----------

        if (response.data.serviceFrequencyType == "DIGIT") {
          this.DIGIT = true;
          this.TEXT = false;
          this.disableda = false;
          this.disabledb = false;
          this.disabled = true;
        } else {
          this.TEXT = true;
          this.DIGIT = false;
          this.disableda = true;
          this.disabledb = true;
          this.disabled = false;
        }

        // ---------------
        this.open = true;
        this.title = "修改服务方式内容";
      });
      // -----------
    },
    changeDIGIT(item) {
      console.log(item, "changeTEXT");
    },
    changeTEXT(item) {},
    /** 提交按钮 */
    submitForm() {
      console.log(this.form);
      this.$refs["form"].validate((valid) => {
        if (valid) {
          if (
            (this.form.serviceFrequencyType == "DIGIT" &&
              this.form.serviceFrequencyStart == null &&
              this.form.serviceFrequencyEnd == null) ||
            (this.form.serviceFrequencyType == "DIGIT" &&
              this.form.serviceFrequencyEnd == "" &&
              this.form.serviceFrequencyStart == "")
          ) {
            this.$message.error("请输入服务频次起始值和结束值");
          } else if (
            (this.form.serviceFrequencyType == "DIGIT" &&
              this.form.serviceFrequencyStart == null) ||
            (this.form.serviceFrequencyStart == "" &&
              this.form.serviceFrequencyType == "DIGIT")
          ) {
            this.$message.error("请输入服务频次起始值");
          } else if (
            (this.form.serviceFrequencyType == "DIGIT" &&
              this.form.serviceFrequencyEnd == null) ||
            (this.form.serviceFrequencyEnd == "" &&
              this.form.serviceFrequencyType == "DIGIT")
          ) {
            this.$message.error("请输入服务频次结束值");
          } else if (
            (this.form.serviceFrequencyType == "TEXT" &&
              this.form.serviceFrequencyText == null) ||
            (this.form.serviceFrequencyText == "" &&
              this.form.serviceFrequencyType == "TEXT")
          ) {
            this.$message.error("请输入服务频次文本");
          } else if (
            this.form.serviceFrequencyType != "TEXT" &&
            this.form.serviceFrequencyType != "DIGIT"
          ) {
            this.$message.error("请选择数字还是文本");
          } else if (
            this.form.serviceFrequencyStart &&
            this.form.serviceFrequencyEnd &&
            Number(this.form.serviceFrequencyStart) >=
              this.form.serviceFrequencyEnd
          ) {
            this.$message.error("结束值必须大于开始值");
            // }
          } else {
            if (this.form.serviceContentId != null) {
              updateServicewaycontent(this.form).then((response) => {
                this.$modal.msgSuccess("修改成功");
                this.open = false;
                this.getList();
                this.mentlist();
              });
            } else {
              addServicewaycontent(this.form).then((response) => {
                this.$modal.msgSuccess("新增成功");
                this.open = false;
                this.getList();
                this.mentlist();
              });
            }
          }

          // }
        }
      });
    },
    // 修改服务方式
    handleedit() {
      console.log(this.itemname);
      this.format.id = this.itemname;
      if (this.itemname) {
        serviceWay(this.itemname).then((res) => {
          this.format.serviceWayName = res.msg;
          this.opens = true;
          this.title = "修改服务方式内容";
        });
      }
      // else {
      //   this.$message.error("请先选择一种服务方式");
      // }
      this.format.serviceWayName = "";
      this.titles = "修改服务方式";
    },
    handledelete() {
      const id = this.itemname;
      console.log(id, "111111111");
      this.$modal
        .confirm("是否确认删除此服务方式？")
        .then(function () {
          return removeServiceWay(id);
        })
        .then(() => {
          this.mentlist();
          this.$modal.msgSuccess("删除成功");
        })
        .catch(() => {});
    },
    // },
    handleUpdateserve() {
      this.titles = "新增服务方式";
      this.format.serviceWayName = "";
      this.format.id = "";
      this.opens = true;
    },
    /** 删除按钮操作 */
    handleDelete(row) {
      console.log(row);
      // row.serviceWayFrequencyList.forEach((e) => {
      //   this.id = e.id;
      // });
      const id = row.id;

      this.$modal
        .confirm("是否确认删除此该数据项？")
        .then(function () {
          return delServicewaycontent(id);
        })
        .then(() => {
          this.getList();
          this.$modal.msgSuccess("删除成功");
        })
        .catch(() => {});
    },
    /** 导出按钮操作 */
    handleExport() {
      this.download(
        "manage/servicewaycontent/export",
        {
          ...this.queryParams,
        },
        `servicewaycontent_${new Date().getTime()}.xlsx`
      );
    },
  },
};
</script>
<style lang="scss">
.el-form-item__error {
  color: #ff4949;
  font-size: 12px;
  line-height: 1;
  padding-top: 4px;
  padding-left: 80px;
  position: absolute;
  top: 100%;
  left: 0;
}
.left {
  height: 530px;
  overflow: scroll;
  .name {
    font-weight: 700;
    margin-bottom: 10px;
  }
  .listitem {
    width: 100%;
    height: 50px;
    border-bottom: 1px solid #dcdfe6;
    .count {
      display: inline-block;
      position: relative;
      // right: -172px;
      left: 216px;
      color: #a4a6aa;
      top: -35px;
      font-size: 13px;
    }
    .all {
      height: 50px;
      line-height: 50px;
      padding-left: 13px;
    }
    .allactive {
      background: #e8f4ff;
      height: 50px;
      line-height: 50px;
      padding-left: 13px;
      border-left: 3px solid #4d9de7;
    }
  }
}
.changeTEXT :hover {
  color: red;
  border-bottom: solid 1px red;
}
.button {
  display: inline-block;
  position: relative;
  left: 20px;
  top: -11px;
}
.dotClass {
  width: 10px;
  height: 10px;
  border-radius: 50%;
  display: block;
  // margin-left: 10px;  //这个用于圆点居中
  position: relative;
  top: 16px;
  left: 12px;
}
.el-button--success.is-plain {
  font-size: 10px;
}
</style>
