loulijun2021
2023-03-20 ed4da27a04e5c00dc2a457d9bdc92eacd38398a8
src/views/sbgl/djbz.vue
@@ -2,8 +2,8 @@
  <div>
    <div class="body" :style="{height:mainHeight+'px'}">
      <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>
        <el-button v-waves type="primary" icon="el-icon-circle-plus-outline" @click="add('add')">新增</el-button>
        <el-button v-waves icon="el-icon-download" @click="upload">导入</el-button>
      </div>
      <div class="bodyTopFormGroup">
@@ -12,10 +12,10 @@
          :model="form"
          label-width="100px"
          inline
          style="display: flex;justify-content: space-between"
          style="display: flex;"
        >
          <div class="elForm">
            <el-form-item label-width="70px" label="标准编码" style=" display: flex;">
            <el-form-item label="标准编码" style=" display: flex;">
              <el-input v-model="form.checkstandcode" placeholder="请输入" style="width: 200px" />
            </el-form-item>
            <el-form-item label="标准名称" style=" display: flex;">
@@ -32,9 +32,12 @@
              </el-select>
            </el-form-item>
          </div>
          <div class="bodySearchReset" :style="{marginLeft:$store.state.app.sidebar.opened?'5%':'10%'}">
            <el-button type="primary" icon="el-icon-search" @click="search">查询</el-button>
            <el-button type="info" icon="el-icon-refresh" @click="reset">重置</el-button>
          <div
            class="bodySearchReset"
            :style="{marginLeft:$store.state.app.sidebar.opened? $store.state.settings.menuIsHorizontal?'15%':'3%':'10%'}"
          >
            <el-button v-waves type="primary" icon="el-icon-search" @click="search">查询</el-button>
            <el-button v-waves type="info" icon="el-icon-refresh" @click="reset">重置</el-button>
          </div>
        </el-form>
@@ -70,11 +73,13 @@
          <el-table-column
            prop="code"
            label="标准编码"
            show-tooltip-when-overflow
            sortable="custom"
          />
          <el-table-column
            prop="name"
            label="标准名称"
            show-tooltip-when-overflow
            sortable="custom"
          />
@@ -93,14 +98,15 @@
            prop="iscontr"
            label="点检管控"
            sortable="custom"
            show-tooltip-when-overflow
          >
            <template slot-scope="{row}">
              <div v-if="row.iscontr==='Y'">
                <svg-icon icon-class="circleYes" style="margin-right: 2px" />
                <i class="el-icon-success" :style="{color:$store.state.settings.theme}" style="margin-right: 2px" />
                是
              </div>
              <div v-if="row.iscontr==='N'">
                <svg-icon icon-class="circleNo" style="margin-right: 2px" />
                <i class="el-icon-info" style="margin-right: 2px" />
                否
              </div>
            </template>
@@ -108,10 +114,16 @@
          <el-table-column
            prop="is_checkeqp"
            label="关联设备"
            show-tooltip-when-overflow
            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==='Y'"
                :style="{color:$store.state.settings.theme}"
                class="el-icon-share"
                @click="checkeqpClick(row)"
              />
              <i
                v-if="row.is_checkeqp==='N'"
                class="el-icon-share"
@@ -124,12 +136,14 @@
            prop="lm_user"
            label="创建人员"
            sortable="custom"
            show-tooltip-when-overflow
          />
          <el-table-column
            prop="lm_date"
            label="创建时间"
            width="160"
            sortable="custom"
            show-tooltip-when-overflow
          />
          <el-table-column
            label="操作"
@@ -139,10 +153,14 @@
            <template slot-scope="{row}">
              <div class="operationClass">
                <el-tooltip class="item" effect="dark" content="编辑" placement="top">
                  <i class="el-icon-edit-outline" @click="edit('edit',row)" />
                  <i
                    :style="{color:$store.state.settings.theme}"
                    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)" />
                  <i :style="{color:$store.state.settings.theme}" class="el-icon-delete" @click="del(row)" />
                </el-tooltip>
              </div>
            </template>
@@ -162,6 +180,7 @@
    </div>
    <el-dialog
      v-el-drag-dialog
      :title="operation==='add'?'新增':'编辑'"
      :visible.sync="dialogVisible"
      width="800px"
@@ -171,7 +190,7 @@
    >
      <!--      @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:$store.state.settings.theme}" style="margin: -20px 10px 20px 0" />设备点检标准信息:
      </div>
      <div style="margin: 0 30px;">
        <el-form ref="dialogForm" inline :rules="dialogFormRules" :model="dialogForm" label-width="80px">
@@ -202,10 +221,10 @@
        </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:$store.state.settings.theme}" style="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>
        <el-button v-waves type="primary" icon="el-icon-circle-plus-outline" @click="addRow">新增</el-button>
      </div>
      <div class="elTableDiv">
        <el-table
@@ -227,6 +246,7 @@
          <el-table-column
            prop="checkitem_code"
            label="点检部位编码"
            show-tooltip-when-overflow
          >
            <template slot-scope="{row}">
              <div v-if="row.isVisible===0">{{ row.checkitem_code }}</div>
@@ -248,6 +268,7 @@
          <el-table-column
            prop="checkitem_name"
            label="点检部位名称"
            show-tooltip-when-overflow
          >
            <template slot-scope="{row}">
              <div v-if="row.isVisible===0">{{ row.checkitem_name }}</div>
@@ -280,6 +301,7 @@
          <el-table-column
            prop="isscan"
            label="选择扫码"
            show-tooltip-when-overflow
          >
            <template slot-scope="{row}">
              <div v-if="row.isVisible===0">{{ row.isscan === 'Y' ? '是' : '否' }}</div>
@@ -300,6 +322,7 @@
          <el-table-column
            prop="cycle"
            label="点检周期"
            show-tooltip-when-overflow
          >
            <template slot-scope="{row}">
              <div v-if="row.isVisible===0">{{ row.cycle === 'D' ? '日' : '' }}</div>
@@ -324,11 +347,11 @@
          >
            <template slot-scope="{row}">
              <div class="operationClass">
                <el-button v-if="row.isVisible===0" type="text" @click="editRow(row)">编辑</el-button>
                <el-button v-if="row.isVisible===0" type="text" @click="delRow(row)">删除</el-button>
                <el-button v-if="row.isVisible===0" v-waves type="text" @click="editRow(row)">编辑</el-button>
                <el-button v-if="row.isVisible===0" v-waves type="text" @click="delRow(row)">删除</el-button>
                <el-button v-if="row.isVisible===1" type="text" @click="saveRow(row)">确认</el-button>
                <el-button v-if="row.isVisible===1" type="text" @click="cancelRow(row)">取消</el-button>
                <el-button v-if="row.isVisible===1" v-waves type="text" @click="saveRow(row)">确认</el-button>
                <el-button v-if="row.isVisible===1" v-waves type="text" @click="cancelRow(row)">取消</el-button>
              </div>
            </template>
          </el-table-column>
@@ -336,14 +359,21 @@
      </div>
      <span slot="footer" class="dialog-footer">
        <div class="footerButton">
          <el-button @click="dialogVisibleCancel">取 消</el-button>
          <el-button type="primary" @click="dialogVisibleConfirm">确 定</el-button>
          <el-button v-waves @click="dialogVisibleCancel">取 消</el-button>
          <el-button
            v-waves
            type="primary"
            :loading="$store.state.app.buttonIsDisabled"
            :disabled="$store.state.app.buttonIsDisabled"
            @click="dialogVisibleConfirm"
          >确 定</el-button>
        </div>
      </span>
    </el-dialog>
    <!--    关联设备-->
    <el-dialog
      v-el-drag-dialog
      title="关联设备"
      :visible.sync="dialogVisibleEqp"
      width="800px"
@@ -356,39 +386,52 @@
      <!--      @opened="handleOpenedRoles"-->
      <div>
        <i class="el-icon-s-comment" style="color:#42b983;" /> 标准名称:{{ dialogFormEqp.name }}
        <i class="el-icon-s-comment" :style="{color:$store.state.settings.theme}" /> 标准名称:{{ dialogFormEqp.name }}
      </div>
      <el-divider />
      <div>
        <div style="margin-bottom:20px">
          <i class="el-icon-s-operation" style="color:#42b983;" /> 设备所属车间集合:
          <i class="el-icon-s-operation" :style="{color:$store.state.settings.theme}" /> 设备所属车间集合:
        </div>
        <div class="myCheckboxGroup">
          <div
            v-for="item in dialogFormEqp.eqpArr"
            :key="item.code"
            :style="{border:item.isSelected1?'1px solid #42b983':'1px solid #eee'}"
            :style="{border:item.isSelected1?'1px solid '+$store.state.settings.theme:'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 }}
            <!--            <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"-->
            <el-checkbox
              :key="item.code"
              v-model="item.isSelected2"
              class="myCheckboxInput"
              :value="item.code"
              :name="item.name"
              :checked="item.isSelected2"
              :label="item.name"
              @change="myCheckboxInputClick(item)"
            />
            <div class="myCheckboxInputLabel">{{ item.name }}</div>
          </div>
        </div>
      </div>
      <el-divider />
      <div>
        <div style="margin-bottom:20px">
          <i class="el-icon-s-operation" style="color:#42b983;" /> 设备信息:
          <i class="el-icon-s-operation" :style="{color:$store.state.settings.theme}" /> 设备信息:
        </div>
        <el-tree
          ref="epqTree"
@@ -396,7 +439,7 @@
          show-checkbox
          node-key="code"
          default-expand-all
          style="height: 300px"
          style="height: 320px;overflow: auto"
          :props="defaultPropsOfEqpTree"
          @check="checkBoxClick"
        />
@@ -405,8 +448,14 @@
      </div>
      <span slot="footer" class="dialog-footer">
        <div class="footerButton">
          <el-button @click="eqpDialogVisibleCancel">取 消</el-button>
          <el-button type="primary" @click="eqpDialogVisibleConfirm">确 定</el-button>
          <el-button v-waves @click="eqpDialogVisibleCancel">取 消</el-button>
          <el-button
            v-waves
            type="primary"
            :loading="$store.state.app.buttonIsDisabled"
            :disabled="$store.state.app.buttonIsDisabled"
            @click="eqpDialogVisibleConfirm"
          >确 定</el-button>
        </div>
      </span>
    </el-dialog>
@@ -437,12 +486,15 @@
} from '@/api/sbgl'
import $ from 'jquery'
import { validateCode } from '@/utils/global'
import elDragDialog from '@/directive/el-drag-dialog'
import waves from '@/directive/waves'
export default {
  name: 'Zzjg',
  components: {
    Pagination, ImportPicker
  },
  directives: { elDragDialog, waves },
  data() {
    return {
      mainHeight: 0,
@@ -506,7 +558,7 @@
      },
      title_value: '数据导入 / 点检部位',
      code: '4',
      code: '22',
      shows: false
    }
@@ -659,8 +711,13 @@
    },
    // 对话框确认
    dialogVisibleConfirm() {
      if (this.tableDataDialog.length === 0) {
        return this.$message.info('设备关联点检项信息不能为空!')
      }
      this.$refs.dialogForm.validate(valid => {
        if (valid) {
          this.$store.state.app.buttonIsDisabled = true
          // this.tableDataDialog.forEach((item, index) => { // 去掉正在编辑且是空checkitem_code
          //   if (item.isVisible === 1 && item.checkitem_code === '') {
          //     this.tableDataDialog.splice(index, 1)
@@ -688,9 +745,10 @@
          AddUpdateDeviceCheckStandArd(data, this.operation === 'add' ? 'Add' : 'Update').then(res => {
            if (res.code === '200') {
              this.$message.success(this.operation === 'add' ? '添加成功!' : '修改成功!')
              this.dialogVisible = false
              this.$message.success(this.operation === 'add' ? '添加成功!' : '修改成功!')
              this.getDeviceCheckStandArdSearch()
              this.$store.state.app.buttonIsDisabled = false
            } else {
              this.$message.error(this.operation === 'add' ? '添加失败!' : '修改失败!')
            }
@@ -817,43 +875,58 @@
      return 'custom-row'
    },
    // 关联设备
    async checkeqpClick(row) {
    checkeqpClick(row) {
      const loading = this.$loading({
        lock: true,
        text: '正在加载数据,请稍等...',
        spinner: 'el-icon-loading',
        customClass: 'osloading',
        background: 'rgba(0, 0, 0, 0.7)'
      })
      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)
      DeviceCheckStanedAssociationEqp({ checkstand_code: row.code }).then(res => {
        if (res.code === '200') {
          setTimeout(() => {
            loading.close()
            this.dialogFormEqp.eqpAll = res.data.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 (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)
            })
          }
          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)
          }, 1000)
        } else {
          loading.close()
        }
      })
    },
    // 关联设备对话框关闭
@@ -882,7 +955,7 @@
    // 小盒子点击
    myCheckboxInputClick(val) {
      console.log(val)
      val.isSelected2 = !val.isSelected2
      val.isSelected2 = !!val.isSelected2
      if (val.isSelected2) { // 从没选中到选中
        console.log('从没选中到选中')
        this.dialogFormEqp.eqpAll.forEach((item, index) => {
@@ -1013,6 +1086,7 @@
    eqpDialogVisibleConfirm() {
      // console.log(this.dialogFormEqp.eqpCodeSelectedArr, 888)
      // this.dialogVisibleEqp = false
      this.$store.state.app.buttonIsDisabled = true
      const data = []
      this.dialogFormEqp.eqpAll.forEach((item, index) => {
        if (item.children && item.children.length > 0) {
@@ -1029,9 +1103,10 @@
      SaveDeviceCheckStanedAssociationEqp(data, this.dialogFormEqp.code).then(res => {
        if (res.code === '200') {
          this.dialogVisibleEqp = false
          this.$message.success('关联成功!')
          this.getDeviceCheckStandArdSearch()
          this.dialogVisibleEqp = false
          this.$store.state.app.buttonIsDisabled = false
        }
      })
    }
@@ -1057,10 +1132,20 @@
      margin: 10px 30px 0 0;
      border-radius: 5px;
      cursor: default;
      position: relative;
      .myCheckboxInput {
        margin: 1px 5px 0 0;
        cursor: pointer;
      }
      .myCheckboxInputLabel {
        position: absolute;
        left: 29px;
        padding: 5px;
        top: 6px;
        color: transparent;
      }
    }
@@ -1205,16 +1290,24 @@
  justify-content: center;
}
.tableFixed{
  ::v-deep .el-table__fixed-right{
.tableFixed {
  ::v-deep .el-table__fixed-right {
    height: 100% !important;
  }
  ::v-deep .el-table__fixed{
  ::v-deep .el-table__fixed {
    height: 100% !important;
  }
}
</style>
<style>
.osloading {
  font-size: 26px !important;
}
.el-loading-text {
  font-size: 26px !important;
}
.el-table .custom-row {
  background: #f8f8fa;