loulijun2021
2022-08-27 3cbb9eb9e6f594721239bde5754db6df924472a6
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>
@@ -61,31 +61,52 @@
            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"
          />
          <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 +120,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>
@@ -128,8 +155,8 @@
      :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" />设备点检标准信息
      </div>
@@ -241,7 +268,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"
@@ -261,7 +288,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"
@@ -301,6 +328,74 @@
      </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="roleTree"
          :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"
@@ -319,7 +414,12 @@
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,
  ViewDeviceCheckStanedSearch
} from '@/api/sbgl'
const SER_HZ = /^[\u4e00-\u9fa5]+$/
export default {
@@ -388,8 +488,21 @@
        ]
      },
      tableDataDialog: [], // 表格数据
      tableDataDialogSelected: [], // 已选code
      // tableDataDialogSelected: [], // 已选code
      checkItemSelectArr: [],
      checkItemIsCancel: true,
      dialogVisibleEqp: false,
      dialogFormEqp: {
        name: '',
        eqpArr: [],
        eqpTree: []
      },
      defaultPropsOfEqpTree: {
        value: 'code',
        label: 'name',
        children: 'children'
      },
      title_value: '数据导入 / 点检部位',
      code: '4',
@@ -410,6 +523,8 @@
  mounted() {
    window.addEventListener('resize', this.getHeight)
    this.getHeight()
    this.getDeviceCheckItemSelect()
  },
  methods: {
    async getDeviceCheckStandArdSearch() {
@@ -445,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()
    },
@@ -461,24 +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.$refs.tableDataDialogRef.doLayout()
      })
      this.$nextTick(() => {
        this.dialogForm.OrgCode = row.org_code
        this.dialogForm.OrgName = row.org_name
        this.dialogForm.SupUnit = row.parent_id
      // 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) {
@@ -487,7 +623,7 @@
        cancelButtonText: '取消',
        type: 'warning'
      }).then(() => {
        DeleteOrganization({ orgid: row.code }).then(res => {
        DeleteDeviceCheckStaned({ checkstand_code: row.code }).then(res => {
          if (res.code === '200') {
            this.$message.success('删除成功!')
            this.getDeviceCheckStandArdSearch()
@@ -497,6 +633,7 @@
        this.$message.info('已取消删除')
      })
    },
    // 对话框关闭事件
    handleClose() {
      this.dialogForm.code = ''
@@ -504,6 +641,7 @@
      this.dialogForm.enable = 'Y'
      this.dialogForm.description = ''
      this.tableDataDialog = []
      this.getDeviceCheckItemSelect()
      this.$refs.dialogForm.clearValidate()
    },
    // 对话框取消
@@ -514,6 +652,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) => {
@@ -545,16 +691,12 @@
    },
    selectChange(val, row) {
      row.checkitem_descr = 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() {
@@ -576,12 +718,25 @@
        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) => {
@@ -598,31 +753,45 @@
      })
    },
    delRow(row) {
      console.log(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)
        }
@@ -637,6 +806,30 @@
    },
    tableRowClassName({ row, rowIndex }) {
      return 'custom-row'
    },
    // 关联设备
    checkeqpClick(row) {
      this.dialogVisibleEqp = true
    },
    handleCloseEqp() {
    },
    // 大盒子点击
    myCheckboxClick() {
    },
    // 小盒子点击
    myCheckboxInputClick() {
    },
    checkBoxClick() {
    },
    eqpDialogVisibleCancel() {
      this.dialogVisibleEqp = false
    },
    eqpDialogVisibleConfirm() {
      this.dialogVisibleEqp = false
    }
  }
}
@@ -645,6 +838,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;
@@ -740,7 +994,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;