loulijun2021
2022-09-14 5eeb8864bebb1dc4f97f2feef32b742d8a9a10d5
src/views/sbgl/djbz.vue
@@ -1,7 +1,7 @@
<template>
  <div>
    <div class="body" :style="{height:mainHeight+'px'}">
      <div class="bodyTopButtonGroup">
      <div class="bodyTopButtonGroup" style="justify-content: space-between">
        <el-button type="primary" icon="el-icon-circle-plus-outline" @click="add('add')">新增</el-button>
        <el-button icon="el-icon-download" @click="upload">导入</el-button>
      </div>
@@ -58,34 +58,62 @@
          <el-table-column
            prop="RowNum"
            width="50"
            fixed
            label="序号"
          />
          <el-table-column
            prop="org_code"
            prop="code"
            label="标准编码"
            sortable="custom"
          />
          <el-table-column
            prop="org_name"
            prop="name"
            label="标准名称"
            sortable="custom"
          />
          <el-table-column
            prop="parentorg_name"
            prop="description"
            label="标准描述"
            sortable="custom"
          />
            show-tooltip-when-overflow
          >
            <template slot-scope="{row}">
              <div v-if="row.description">{{ row.description }}</div>
              <div v-else>/</div>
            </template>
          </el-table-column>
          <el-table-column
            prop="parentorg_name"
            prop="iscontr"
            label="点检管控"
            sortable="custom"
          />
          >
            <template slot-scope="{row}">
              <div v-if="row.iscontr==='Y'">
                <svg-icon icon-class="circleYes" style="margin-right: 2px" />
                是
              </div>
              <div v-if="row.iscontr==='N'">
                <svg-icon icon-class="circleNo" style="margin-right: 2px" />
                否
              </div>
            </template>
          </el-table-column>
          <el-table-column
            prop="parentorg_name"
            prop="is_checkeqp"
            label="关联设备"
            sortable="custom"
          />
          >
            <template slot-scope="{row}">
              <i v-if="row.is_checkeqp==='Y'" class="el-icon-share" @click="checkeqpClick(row)" />
              <i
                v-if="row.is_checkeqp==='N'"
                class="el-icon-share"
                style="color: rgb(180 ,181, 185)"
                @click="checkeqpClick(row)"
              />
            </template>
          </el-table-column>
          <el-table-column
            prop="lm_user"
            label="创建人员"
@@ -99,11 +127,17 @@
          />
          <el-table-column
            label="操作"
            fixed="right"
            width="120"
          >
            <template slot-scope="{row}">
              <div class="operationClass">
                <el-button type="text" @click="edit('edit',row)">编辑</el-button>
                <el-button type="text" @click="del(row)">删除</el-button>
                <el-tooltip class="item" effect="dark" content="编辑" placement="top">
                  <i class="el-icon-edit-outline" @click="edit('edit',row)" />
                </el-tooltip>
                <el-tooltip v-del-tab-index class="item" effect="dark" content="删除" placement="top">
                  <i class="el-icon-delete" @click="del(row)" />
                </el-tooltip>
              </div>
            </template>
          </el-table-column>
@@ -115,7 +149,7 @@
        :page.sync="form.page"
        :limit.sync="form.rows"
        align="right"
        layout="prev, pager, next,sizes"
        layout="total,prev, pager, next,sizes"
        popper-class="select_bottom"
        @pagination="getDeviceCheckStandArdSearch"
      />
@@ -128,10 +162,10 @@
      :close-on-click-modal="false"
      top="8vh"
      @closed="handleClose"
      @close="handleClose"
    >
      <!--      @close="handleClose"-->
      <div>
        <i class="el-icon-s-operation" style="color:#42b983;margin: -20px 10px 20px 0" />设备点检标准信息
        <i class="el-icon-s-operation" style="color:#42b983;margin: -20px 10px 20px 0" />设备点检标准信息:
      </div>
      <div style="margin: 0 30px;">
        <el-form ref="dialogForm" inline :rules="dialogFormRules" :model="dialogForm" label-width="80px">
@@ -141,7 +175,7 @@
          <el-form-item label="标准名称" prop="name">
            <el-input v-model="dialogForm.name" style="width: 200px" />
          </el-form-item>
          <el-form-item prop="SupUnit" label="点检管控">
          <el-form-item required label="点检管控">
            <el-select
              v-model="dialogForm.enable"
              style="width: 200px"
@@ -162,13 +196,14 @@
        </el-form>
      </div>
      <div>
        <i class="el-icon-s-operation" style="color:#42b983;margin: -20px 10px 20px 0" />设备点检点检信息
        <i class="el-icon-s-operation" style="color:#42b983;margin: -20px 10px 20px 0" />设备关联点检项信息:
      </div>
      <div style="margin-bottom:10px">
        <el-button type="primary" icon="el-icon-circle-plus-outline" @click="addRow">新增</el-button>
      </div>
      <div class="elTableDiv">
        <el-table
          ref="tableDataDialogRef"
          :data="tableDataDialog"
          :height="(tableHeight-300)+'px'"
          border
@@ -227,12 +262,13 @@
          </el-table-column>
          <el-table-column
            prop="chkdesc"
            prop="checkitem_descr"
            label="点检要求"
            show-tooltip-when-overflow
          >
            <template slot-scope="{row}">
              <div v-if="row.isVisible===0">{{ row.chkdesc }}</div>
              <el-input v-else v-model="row.chkdesc" />
              <div v-if="row.isVisible===0">{{ row.checkitem_descr }}</div>
              <el-input v-else v-model="row.checkitem_descr" />
            </template>
          </el-table-column>
          <el-table-column
@@ -240,7 +276,7 @@
            label="选择扫码"
          >
            <template slot-scope="{row}">
              <div v-if="row.isVisible===0">{{ row.isscan==='Y'?'是':'否' }}</div>
              <div v-if="row.isVisible===0">{{ row.isscan === 'Y' ? '是' : '否' }}</div>
              <el-select
                v-if="row.isVisible===1"
                v-model="row.isscan"
@@ -260,7 +296,7 @@
            label="点检周期"
          >
            <template slot-scope="{row}">
              <div v-if="row.isVisible===0">{{ row.cycle==='D'?'日':'' }}</div>
              <div v-if="row.isVisible===0">{{ row.cycle === 'D' ? '日' : '' }}</div>
              <el-select
                v-if="row.isVisible===1"
                v-model="row.cycle"
@@ -300,6 +336,75 @@
      </span>
    </el-dialog>
    <!--    关联设备-->
    <el-dialog
      title="关联设备"
      :visible.sync="dialogVisibleEqp"
      width="800px"
      top="10vh"
      :close-on-click-modal="false"
      class="dialogVisibleEqp"
      @closed="handleCloseEqp"
      @close="handleCloseEqp"
    >
      <!--      @opened="handleOpenedRoles"-->
      <div>
        <i class="el-icon-s-comment" style="color:#42b983;" /> 标准名称:{{ dialogFormEqp.name }}
      </div>
      <el-divider />
      <div>
        <div style="margin-bottom:20px">
          <i class="el-icon-s-operation" style="color:#42b983;" /> 设备所属车间集合:
        </div>
        <div class="myCheckboxGroup">
          <div
            v-for="item in dialogFormEqp.eqpArr"
            :key="item.code"
            :style="{border:item.isSelected1?'1px solid #42b983':'1px solid #eee'}"
            class="myCheckbox"
            @click="myCheckboxClick(item)"
          >
            <input
              class="myCheckboxInput"
              type="checkbox"
              :value="item.code"
              :name="item.name"
              :style="{color:item.isSelected2?'#42b983':'#fff'}"
              @click="myCheckboxInputClick(item)"
            >{{ item.name }}
            <!--            父子点击事件不影响-->
            <!--            onClick="event.cancelBubble = true"-->
          </div>
        </div>
      </div>
      <el-divider />
      <div>
        <div style="margin-bottom:20px">
          <i class="el-icon-s-operation" style="color:#42b983;" /> 设备信息:
        </div>
        <el-tree
          ref="epqTree"
          :data="dialogFormEqp.eqpTree"
          show-checkbox
          node-key="code"
          default-expand-all
          style="height: 300px"
          :props="defaultPropsOfEqpTree"
          @check="checkBoxClick"
        />
        <!--        @check-change="checkChange"-->
      </div>
      <span slot="footer" class="dialog-footer">
        <div class="footerButton">
          <el-button @click="eqpDialogVisibleCancel">取 消</el-button>
          <el-button type="primary" @click="eqpDialogVisibleConfirm">确 定</el-button>
        </div>
      </span>
    </el-dialog>
    <!--导入组件-->
    <import-picker
      ref="importPickerFunc"
@@ -318,33 +423,21 @@
import { AddUpdateOrganization, DeleteOrganization, OrganizationSearch, PrentOrganization } from '@/api/jcsz'
import { getCookie } from '@/utils/auth'
import ImportPicker from '@/components/ImportPicker'
import { AddUpdateDeviceCheckStandArd, DeviceCheckItemSelect, DeviceCheckStandArdSearch } from '@/api/sbgl'
import {
  AddUpdateDeviceCheckStandArd, DeleteDeviceCheckStaned,
  DeviceCheckItemSelect,
  DeviceCheckStandArdSearch, DeviceCheckStanedAssociationEqp, SaveDeviceCheckStanedAssociationEqp,
  ViewDeviceCheckStanedSearch
} from '@/api/sbgl'
import $ from 'jquery'
import { validateCode } from '@/utils/global'
const SER_HZ = /^[\u4e00-\u9fa5]+$/
export default {
  name: 'Zzjg',
  components: {
    Pagination, ImportPicker
  },
  data() {
    const validateName = (rule, value, callback) => {
      if (!value) {
        return callback(new Error('请输入编码'))
      } else {
        if (SER_HZ.test(value)) {
          return callback(new Error('编码不能为中文'))
        } else {
          callback()
        }
      }
    }
    const validateTypeCode = (rule, value, callback) => {
      if (!value) {
        return callback(new Error('请选择上级'))
      } else {
        callback()
      }
    }
    return {
      mainHeight: 0,
      tableHeight: 0,
@@ -371,13 +464,13 @@
        code: '',
        name: '',
        enable: 'Y',
        description: ''// 上级单位
        description: ''
      },
      operation: '',
      dialogFormRules: {
        code: [
          { required: true, validator: validateName, trigger: ['blur', 'change'] }
          { required: true, validator: validateCode, trigger: ['blur', 'change'] }
        ],
        name: [
          { required: true, message: '请输入标准名称', trigger: ['blur', 'change'] }
@@ -387,8 +480,24 @@
        ]
      },
      tableDataDialog: [], // 表格数据
      tableDataDialogSelected: [], // 已选code
      // tableDataDialogSelected: [], // 已选code
      checkItemSelectArr: [],
      checkItemIsCancel: true,
      dialogVisibleEqp: false,
      dialogFormEqp: {
        name: '',
        code: '',
        eqpAll: [], // 车间及设备所有
        eqpArr: [], // 车间集合所有
        eqpTree: [], // 设备树形所有
        eqpCodeSelectedArr: []// 设备树形选中
      },
      defaultPropsOfEqpTree: {
        value: 'code',
        label: 'name',
        children: 'children'
      },
      title_value: '数据导入 / 点检部位',
      code: '4',
@@ -404,18 +513,25 @@
    }
  },
  created() {
    this.getDeviceCheckStandArdSearch()
    this.handleRequest()
  },
  mounted() {
    window.addEventListener('resize', this.getHeight)
    this.getHeight()
  },
  methods: {
    handleRequest() {
      this.getDeviceCheckStandArdSearch().then(res => {
        if (res.code === '200') {
          this.getDeviceCheckItemSelect()
        }
      })
    },
    async getDeviceCheckStandArdSearch() {
      console.log(this.form, 11)
      const res = await DeviceCheckStandArdSearch(this.form)
      this.tableData = res.data
      this.total = res.count
      return { code: res.code }
    },
    // 排序改变时
    sortChange({ column, prop, order }) {
@@ -444,10 +560,9 @@
    },
    // 重置
    reset() {
      this.form.OrgCode = ''
      this.form.OrgName = ''
      this.form.OrgType = ''
      this.form.UserName = ''
      this.form.checkstandcode = ''
      this.form.checkstandname = ''
      this.form.checkcontr = ''
      this.getDeviceCheckStandArdSearch()
    },
@@ -460,19 +575,46 @@
    add(operation) {
      this.operation = operation
      this.dialogVisible = true
      this.getDeviceCheckItemSelect()
      // this.getDeviceCheckItemSelect()
      this.$nextTick(() => {
        this.$refs.tableDataDialogRef.doLayout()
      })
    },
    // 修改按钮
    edit(operation, row) {
      // this.getDeviceCheckItemSelect()
      this.operation = operation
      this.getViewDeviceCheckStanedSearch(row.code)
      this.dialogVisible = true
      this.getDeviceCheckItemSelect()
      this.$nextTick(() => {
        this.dialogForm.OrgCode = row.org_code
        this.dialogForm.OrgName = row.org_name
        this.dialogForm.SupUnit = row.parent_id
        this.$refs.tableDataDialogRef.doLayout()
      })
      // this.$nextTick(() => {
      //   this.dialogForm.code = row.code
      //   this.dialogForm.name = row.name
      //   this.dialogForm.enable = row.enable
      //   this.dialogForm.description = row.description
      // })
    },
    // 修改前请求接口
    async getViewDeviceCheckStanedSearch(checkstand_code) {
      const { data: res } = await ViewDeviceCheckStanedSearch({ checkstand_code })
      this.tableDataDialog = res.Data
      this.dialogForm.code = res.code
      this.dialogForm.name = res.name
      this.dialogForm.enable = res.enable
      this.dialogForm.description = res.description
      this.tableDataDialog.forEach(item => {
        item.isVisible = 0
        item.checkitem_code = item.code
        item.checkitem_name = item.name
        item.checkitem_descr = item.chkdesc
      })
      this.checkItemSelectArr = [...this.checkItemSelectArr].filter(x => [...this.tableDataDialog].every(y => y.checkitem_code !== x.code))
    },
    // 删除按钮
    async del(row) {
@@ -481,9 +623,12 @@
        cancelButtonText: '取消',
        type: 'warning'
      }).then(() => {
        DeleteOrganization({ orgid: row.code }).then(res => {
        DeleteDeviceCheckStaned({ checkstand_code: row.code }).then(res => {
          if (res.code === '200') {
            this.$message.success('删除成功!')
            if (this.form.page > 1 && this.tableData.length === 1) {
              this.form.page--
            }
            this.getDeviceCheckStandArdSearch()
          }
        })
@@ -491,6 +636,7 @@
        this.$message.info('已取消删除')
      })
    },
    // 对话框关闭事件
    handleClose() {
      this.dialogForm.code = ''
@@ -498,6 +644,7 @@
      this.dialogForm.enable = 'Y'
      this.dialogForm.description = ''
      this.tableDataDialog = []
      this.getDeviceCheckItemSelect()
      this.$refs.dialogForm.clearValidate()
    },
    // 对话框取消
@@ -508,6 +655,14 @@
    dialogVisibleConfirm() {
      this.$refs.dialogForm.validate(valid => {
        if (valid) {
          // this.tableDataDialog.forEach((item, index) => { // 去掉正在编辑且是空checkitem_code
          //   if (item.isVisible === 1 && item.checkitem_code === '') {
          //     this.tableDataDialog.splice(index, 1)
          //   }
          // })
          this.tableDataDialog.filter(item => item.checkitem_code !== '')
          let Data = []
          // 数组中对象相同的去重
          Data = this.tableDataDialog.filter((currentValue, currentIndex, selfArr) => {
@@ -516,7 +671,7 @@
          Data.forEach((item, index) => {
            item.checkitem_seq = index + 1
          })
          console.log(Data, 999)
          const data = {
            'code': this.dialogForm.code,
            'name': this.dialogForm.name,
@@ -524,7 +679,7 @@
            'description': this.dialogForm.description,
            'Data': Data
          }
          console.log(data, 111)
          AddUpdateDeviceCheckStandArd(data, this.operation === 'add' ? 'Add' : 'Update').then(res => {
            if (res.code === '200') {
              this.$message.success(this.operation === 'add' ? '添加成功!' : '修改成功!')
@@ -539,16 +694,12 @@
    },
    selectChange(val, row) {
      row.chkdesc = this.checkItemSelectArr.find(item => {
      const res = this.checkItemSelectArr.find(item => {
        return item.code === val || item.name === val
      }).description
      row.checkitem_code = this.checkItemSelectArr.find(item => {
        return item.code === val || item.name === val
      }).code
      row.checkitem_name = this.checkItemSelectArr.find(item => {
        return item.code === val || item.name === val
      }).name
      })
      row.checkitem_descr = res.description
      row.checkitem_code = res.code
      row.checkitem_name = res.name
    },
    // 新增行
    addRow() {
@@ -565,17 +716,30 @@
      this.tableDataDialog.push({
        checkitem_code: '',
        checkitem_name: '',
        chkdesc: '',
        checkitem_descr: '',
        isscan: 'Y',
        cycle: 'D',
        isVisible: 1
      })
      this.checkItemIsCancel = false
    },
    editRow(row) {
      this.tableDataDialogSelected.forEach((item, index) => {
        if (item === row.checkitem_code) {
          this.tableDataDialogSelected.splice(index, 1)
      let flag = false
      this.tableDataDialog.forEach((item, index) => {
        if (item.isVisible === 1) {
          flag = true
        }
      })
      if (flag) {
        return this.$message.info('请先确认或取消其它行!')
      }
      this.checkItemIsCancel = false
      this.checkItemSelectArr.splice(0, 0, {
        code: row.checkitem_code,
        name: row.checkitem_name,
        description: row.checkitem_descr
      })
      this.tableDataDialog.forEach((item, index) => {
@@ -583,7 +747,7 @@
          this.tableDataDialog.splice(index, 1, {
            checkitem_code: row.checkitem_code,
            checkitem_name: row.checkitem_name,
            chkdesc: row.chkdesc,
            checkitem_descr: row.checkitem_descr,
            isscan: row.isscan,
            cycle: row.cycle,
            isVisible: 1
@@ -592,31 +756,44 @@
      })
    },
    delRow(row) {
      this.checkItemSelectArr.splice(0, 0, {
        code: row.checkitem_code,
        name: row.checkitem_name,
        description: row.checkitem_descr
      })
      this.tableDataDialog.forEach((item, index) => {
        if (item.checkitem_code === row.checkitem_code) {
          this.tableDataDialog.splice(index, 1)
        }
      })
      this.tableDataDialogSelected.forEach((item, index) => {
        if (item === row.checkitem_code) {
          this.tableDataDialogSelected.splice(index, 1)
    },
    saveRow(row) {
      if (row.checkitem_code === '' && row.checkitem_name === '') {
        return this.$message.info('点检部位不能为空!')
      }
      row.isVisible = 0
      this.checkItemSelectArr.forEach((item, index) => {
        if (item.code === row.checkitem_code) {
          this.checkItemSelectArr.splice(index, 1)
        }
      })
    },
    saveRow(row) {
      if (this.tableDataDialogSelected.includes(row.checkitem_code)) {
        return this.$message.info('点检部位不能选择相同!')
      }
      this.tableDataDialogSelected.push(row.checkitem_code)
      row.isVisible = 0
      console.log(this.tableDataDialog)
    },
    cancelRow(row) {
      console.log(row, 111)
      // this.checkItemSelectArr.forEach((item, index) => {
      //   if (item.code === row.checkitem_code) {
      if (this.checkItemIsCancel) {
        this.checkItemSelectArr.splice(0, 0, {
          code: row.checkitem_code,
          name: row.checkitem_name,
          description: row.checkitem_descr
        })
      }
      this.JYIsCancel = true
      // }
      // })
      this.tableDataDialog.forEach((item, index) => {
        if (item.checkitem_code === row.checkitem_code && item.isVisible === 1) {
          console.log(item)
          row.isVisible = 0
          this.tableDataDialog.splice(index, 1)
        }
@@ -631,6 +808,225 @@
    },
    tableRowClassName({ row, rowIndex }) {
      return 'custom-row'
    },
    // 关联设备
    async checkeqpClick(row) {
      this.dialogFormEqp.name = row.name
      this.dialogFormEqp.code = row.code
      const { data: res } = await DeviceCheckStanedAssociationEqp({ checkstand_code: row.code })
      this.dialogFormEqp.eqpAll = res.filter(item => item.children.length > 0)
      if (this.dialogFormEqp.eqpAll.length > 0) {
        this.dialogFormEqp.eqpAll.forEach((item, index) => {
          this.dialogFormEqp.eqpArr.push({
            code: item.code,
            name: item.name,
            type: item.type,
            isSelected1: index === 0,
            isSelected2: item.flag === 'Y'
          })
          if (item.flag === 'Y') {
            this.$nextTick(() => {
              $('input:checkbox').eq(index).prop('checked', true)// 自定义单选框回显
            })
          }
          if (item.children && item.children.length > 0) {
            item.children.forEach(it => {
              if (it.flag === 'Y') {
                this.dialogFormEqp.eqpCodeSelectedArr.push(it.code)
              }
            })
          }
        })
        this.dialogFormEqp.eqpAll[0].name = '全部'
        this.dialogFormEqp.eqpTree = [this.dialogFormEqp.eqpAll[0]]
      }
      this.dialogVisibleEqp = true
      this.$nextTick(() => { // 树形回显
        this.$refs.epqTree.setCheckedKeys(this.dialogFormEqp.eqpCodeSelectedArr)
      })
    },
    // 关联设备对话框关闭
    handleCloseEqp() {
      this.$refs.epqTree.setCheckedKeys([])
      this.dialogFormEqp.code = ''
      this.dialogFormEqp.name = ''
      this.dialogFormEqp.eqpAll = []
      this.dialogFormEqp.eqpArr = []
      this.dialogFormEqp.eqpTree = []
      this.dialogFormEqp.eqpCodeSelectedArr = []
    },
    // 大盒子点击
    myCheckboxClick(val) {
      this.dialogFormEqp.eqpArr.forEach((item, index) => {
        item.isSelected1 = item.code === val.code
        if (item.code === val.code) {
          this.dialogFormEqp.eqpAll[index].name = '全部'
          this.dialogFormEqp.eqpTree = [this.dialogFormEqp.eqpAll[index]]
        }
      })
      this.$nextTick(() => { // 树形回显
        this.$refs.epqTree.setCheckedKeys(this.dialogFormEqp.eqpCodeSelectedArr)
      })
    },
    // 小盒子点击
    myCheckboxInputClick(val) {
      console.log(val)
      val.isSelected2 = !val.isSelected2
      if (val.isSelected2) { // 从没选中到选中
        console.log('从没选中到选中')
        this.dialogFormEqp.eqpAll.forEach((item, index) => {
          if (item.code === val.code) {
            if (item.children && item.children.length > 0) {
              item.children.forEach(it => {
                this.dialogFormEqp.eqpCodeSelectedArr.push(it.code)
              })
            }
          }
        })
        console.log(this.dialogFormEqp.eqpCodeSelectedArr, 1)
        this.$nextTick(() => { // 树形回显
          this.$refs.epqTree.setCheckedKeys(this.dialogFormEqp.eqpCodeSelectedArr)
        })
      } else { // 从选中到没选中
        console.log('从选中到没选中')
        const temp = []
        this.dialogFormEqp.eqpAll.forEach((item, index) => {
          if (item.code === val.code) {
            if (item.children && item.children.length > 0) {
              item.children.forEach(it => {
                temp.push(it.code)
              })
            }
          }
        })
        this.dialogFormEqp.eqpCodeSelectedArr = [...this.dialogFormEqp.eqpCodeSelectedArr].filter(x => [...temp].every(y => y !== x))
        this.$nextTick(() => { // 树形回显
          this.$refs.epqTree.setCheckedKeys(this.dialogFormEqp.eqpCodeSelectedArr)
        })
      }
      console.log(this.dialogFormEqp.eqpCodeSelectedArr, 999)
    },
    // 树形复选框点击事件
    checkBoxClick(obj, { checkedNodes, checkedKeys, halfCheckedNodes, halfCheckedKeys }) {
      let checkedFatherCode = '' // 找到 checkedFatherCode  父code值
      console.log(obj, { checkedNodes, checkedKeys, halfCheckedNodes, halfCheckedKeys })
      this.dialogFormEqp.eqpAll.forEach((item, index) => {
        if (item.code === obj.code) {
          checkedFatherCode = item.code
        }
        if (item.children && item.children.length > 0) {
          item.children.forEach((it, ind) => {
            if (it.code === obj.code) {
              checkedFatherCode = item.code
            }
          })
        }
      })
      console.log(checkedFatherCode, 1)
      // 1.第一种情况当树形   半叶 不为零   全叶 不为零
      if (halfCheckedKeys.length !== 0 && checkedKeys.length !== 0) {
        console.log('// 1.第一种情况当树形   半叶 不为零   全叶 不为零')
        this.dialogFormEqp.eqpArr.forEach((item, index) => {
          if (item.code === checkedFatherCode) {
            console.log(item.code, 777)
            this.dialogFormEqp.eqpArr[index].isSelected2 = true
            this.$nextTick(() => {
              $('input:checkbox').eq(index).prop('checked', true)// 自定义单选框回显
            })
          }
        })
        this.dialogFormEqp.eqpCodeSelectedArr.forEach((item, index) => {
          if (item === obj.code) {
            this.dialogFormEqp.eqpCodeSelectedArr.splice(index, 1)
          }
        })
        checkedKeys.forEach(item => {
          this.dialogFormEqp.eqpCodeSelectedArr.push(item)
        })
        this.dialogFormEqp.eqpCodeSelectedArr = [...new Set(this.dialogFormEqp.eqpCodeSelectedArr)]
      }
      console.log(this.dialogFormEqp.eqpCodeSelectedArr, 666)
      // 2.第二种情况当树形   半叶 为零   全叶 为零
      if (halfCheckedKeys.length === 0 && checkedKeys.length === 0) {
        console.log('// 2.第二种情况当树形   半叶 为零   全叶 为零')
        const temp = []
        this.dialogFormEqp.eqpArr.forEach((item, index) => {
          if (item.code === checkedFatherCode) {
            this.dialogFormEqp.eqpArr[index].isSelected2 = false
            this.$nextTick(() => {
              $('input:checkbox').eq(index).prop('checked', false)// 自定义单选框回显
            })
          }
        })
        this.dialogFormEqp.eqpAll.forEach((item, index) => {
          if (item.code === checkedFatherCode) {
            if (item.children && item.children.length > 0) {
              item.children.forEach(it => {
                temp.push(it.code)
              })
            }
          }
        })
        this.dialogFormEqp.eqpCodeSelectedArr = [...this.dialogFormEqp.eqpCodeSelectedArr].filter(x => [...temp].every(y => y !== x))
      }
      // 3.第三种种情况当树形   半叶 为零   全叶 不为零
      if (halfCheckedKeys.length === 0 && checkedKeys.length !== 0) {
        console.log('// 3.第三种种情况当树形   半叶 为零   全叶 不为零')
        this.dialogFormEqp.eqpArr.forEach((item, index) => {
          if (item.code === checkedFatherCode) {
            this.dialogFormEqp.eqpArr[index].isSelected2 = true
            this.$nextTick(() => {
              $('input:checkbox').eq(index).prop('checked', true)// 自定义单选框回显
            })
          }
        })
        this.dialogFormEqp.eqpAll.forEach((item, index) => {
          if (item.code === checkedFatherCode) {
            if (item.children && item.children.length > 0) {
              item.children.forEach(it => {
                this.dialogFormEqp.eqpCodeSelectedArr.push(it.code)
              })
            }
          }
        })
      }
    },
    // 取消事件
    eqpDialogVisibleCancel() {
      this.dialogVisibleEqp = false
    },
    // 确认事件
    eqpDialogVisibleConfirm() {
      // console.log(this.dialogFormEqp.eqpCodeSelectedArr, 888)
      // this.dialogVisibleEqp = false
      const data = []
      this.dialogFormEqp.eqpAll.forEach((item, index) => {
        if (item.children && item.children.length > 0) {
          item.children.forEach(it => {
            if (this.dialogFormEqp.eqpCodeSelectedArr.includes(it.code)) {
              data.push({
                name: it.name,
                code: it.code
              })
            }
          })
        }
      })
      SaveDeviceCheckStanedAssociationEqp(data, this.dialogFormEqp.code).then(res => {
        if (res.code === '200') {
          this.$message.success('关联成功!')
          this.getDeviceCheckStandArdSearch()
          this.dialogVisibleEqp = false
        }
      })
    }
  }
}
@@ -639,6 +1035,67 @@
<!--公共页面样式-->
<style lang="scss" scoped>
$main_color: #42b983;
.dialogVisibleEqp {
  .myCheckboxGroup {
    display: flex;
    flex-wrap: wrap;
    .myCheckbox {
      //border: 1px solid $main_color;
      border: 1px solid #eee;
      display: flex;
      min-width: 100px;
      padding: 10px;
      margin: 10px 30px 0 0;
      border-radius: 5px;
      cursor: default;
      .myCheckboxInput {
        margin: 1px 5px 0 0;
        cursor: pointer;
      }
    }
    //.myCheckbox{
    //  border: 1px solid $main_color;
    //}
    input[type=checkbox] {
      cursor: pointer;
      position: relative;
      width: 14px;
      height: 14px;
      font-size: 14px;
    }
    input[type=checkbox]::after {
      position: absolute;
      top: 0;
      //color: rgb(130, 35, 35);
      color: $main_color;
      width: 14px;
      height: 14px;
      display: inline-block;
      visibility: visible;
      padding-left: 0px;
      text-align: center;
      content: ' ';
      border-radius: 3px
    }
    input[type=checkbox]:checked::after {
      //content: "✓";
      content: "√";
      color: #fff;
      font-size: 12px;
      font-weight: bold;
      background-color: $main_color;
    }
  }
}
::v-deep .el-button--text {
  font-size: 14px;
  cursor: pointer;
@@ -734,7 +1191,8 @@
.userDialogVisible ::v-deep .el-form-item {
  margin-bottom: 0;
}
::v-deep .el-select__caret{
::v-deep .el-select__caret {
  display: flex;
  align-items: center;
  justify-content: center;