loulijun2021
2022-10-29 e713b378b01d189f972cfb5b9eae749ee95a8b51
src/views/sbgl/sbqd.vue
@@ -2,10 +2,13 @@
  <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-c-scale-to-original" @click="deviceTypeButton">设备类型</el-button>
        <el-button icon="el-icon-document-copy" @click="deviceGroupButton">设备组</el-button>
        <div style="display: flex">
          <el-button icon="el-icon-c-scale-to-original" @click="deviceTypeButton">设备类型</el-button>
          <el-button icon="el-icon-document-copy" @click="deviceGroupButton">设备组</el-button>
        </div>
        <!--        <el-button type="primary" icon="el-icon-upload2" @click="upload">导入</el-button>-->
      </div>
@@ -13,12 +16,12 @@
        <el-form
          ref="form"
          :model="form"
          label-width="80px"
          label-width="100px"
          inline
          style="display: flex;justify-content: space-between"
        >
          <div class="elForm">
            <el-form-item label="设备编码" style=" display: flex;">
          <div class="elForm" style="justify-content: flex-start">
            <el-form-item label-width="70px" label="设备编码" style=" display: flex;">
              <el-input v-model="form.DeviceCode" placeholder="请输入" style="width: 200px" />
            </el-form-item>
            <el-form-item label="设备名称" style=" display: flex;">
@@ -57,14 +60,13 @@
                />
              </el-select>
            </el-form-item>
            <el-form-item filterable label="设备类型" style="display: flex;">
            <el-form-item v-show="isExpandForm" label-width="70px" filterable label="设备类型" style="display: flex;">
              <el-select
                v-model="form.DeviceType"
                :popper-append-to-body="false"
                style="width: 200px"
                filterable
                placeholder="请选择"
                @change="deviceTypeChange"
              >
                <!--                @focus="getDeviceTypeSelect"-->
@@ -76,7 +78,7 @@
                />
              </el-select>
            </el-form-item>
            <el-form-item label="设备组" style=" display: flex;">
            <el-form-item v-show="isExpandForm" label="设备组" style=" display: flex;">
              <el-select
                v-model="form.DeviceGroup"
                filterable
@@ -94,21 +96,40 @@
              </el-select>
            </el-form-item>
          </div>
          <div style="display: flex;align-items: start;margin-top: 5px;">
          <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>
        </el-form>
        <div
          class="bodyTopFormExpand"
        >
          <svg-icon
            v-show="mouseHoverType==='mouseout'"
            style="cursor: pointer"
            :icon-class="!isExpandForm?'doubleDown3':'doubleUp3'"
            @mouseenter="mouseHoverType=$event.type"
          />
          <svg-icon
            v-show="mouseHoverType==='mouseenter'"
            style="cursor: pointer"
            :icon-class="!isExpandForm?'doubleDown':'doubleUp'"
            @click="isExpandForm=!isExpandForm"
            @mouseout="mouseHoverType=$event.type"
          />
        </div>
      </div>
      <div class="elTableDiv">
      <div class="elTableDiv" style="margin-top: 0;">
        <el-table
          ref="tableDataRef"
          :data="tableData"
          border
          :height="tableHeight+'px'"
          class="tableFixed"
          :height="isExpandForm?tableHeight:(tableHeight+40)+'px'"
          highlight-current-row
          :row-class-name="tableRowClassName"
          :style="{width: 100+'%',height:(tableHeight-50)+'px'}"
          :style="{width: 100+'%',height:isExpandForm?tableHeight:(tableHeight+40)+'px',}"
          :header-cell-style="this.$headerCellStyle"
          :cell-style="this.$cellStyle"
          @sort-change="sortChange"
@@ -144,6 +165,7 @@
          <el-table-column
            prop="eqpgroup_name"
            label="设备组"
            show-tooltip-when-overflow
            min-width="110"
            sortable="custom"
          />
@@ -186,7 +208,8 @@
            width="100"
          >
            <template slot-scope="{row}">
              <div>{{ row.operation_ration }}%</div>
              <div v-if=" parseFloat(row.operation_ration)===0">/</div>
              <div v-else>{{ row.operation_ration }}%</div>
            </template>
          </el-table-column>
          <el-table-column
@@ -221,7 +244,6 @@
      </div>
      <!--分页-->
      <pagination
        v-show="total>0"
        :total="total"
        :page.sync="form.page"
        :limit.sync="form.rows"
@@ -352,7 +374,12 @@
      <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
            type="primary"
            :loading="$store.state.app.buttonIsDisabled"
            :disabled="$store.state.app.buttonIsDisabled"
            @click="dialogVisibleConfirm"
          >确 定</el-button>
        </div>
      </span>
    </el-dialog>
@@ -386,6 +413,7 @@
          width="50"
          label="序号"
          prop="RowNum"
          fixed
        />
        <el-table-column
          prop="code"
@@ -393,7 +421,7 @@
          sortable="custom"
        >
          <template slot-scope="{row}">
            <el-input v-if="row.isVisible===1" v-model="row.code" placeholder="请输入" />
            <el-input v-if="row.isVisible===1" v-model="row.code" oninput="value=value.replace(/[^0-9a-zA-Z]/g,'')" placeholder="请输入" />
            <div v-else> {{ row.code }}</div>
          </template>
        </el-table-column>
@@ -429,7 +457,6 @@
      </el-table>
      <!--分页-->
      <pagination
        v-show="DeviceTypeTotal>0"
        :total="DeviceTypeTotal"
        :page.sync="formDeviceType.page"
        :limit.sync="formDeviceType.rows"
@@ -475,6 +502,7 @@
        <el-table-column
          width="50"
          label="序号"
          fixed
          prop="RowNum"
        />
        <el-table-column
@@ -483,7 +511,7 @@
          sortable="custom"
        >
          <template slot-scope="{row}">
            <el-input v-if="row.isVisible===1" v-model="row.code" placeholder="请输入" />
            <el-input v-if="row.isVisible===1"v-model="row.code" oninput="value=value.replace(/[^0-9a-zA-Z]/g,'')" placeholder="请输入" />
            <div v-else> {{ row.code }}</div>
          </template>
        </el-table-column>
@@ -542,7 +570,6 @@
      </el-table>
      <!--分页-->
      <pagination
        v-show="DeviceGroupTotal>0"
        :total="DeviceGroupTotal"
        :page.sync="formDeviceGroup.page"
        :limit.sync="formDeviceGroup.rows"
@@ -569,7 +596,7 @@
import Pagination from '@/components/Pagination'
import {
  AddUpdateDeviceGroup, AddUpdateDeviceManger,
  AddUpdateDeviceType, DeleteDeviceManger, DeleteDeviceType,
  AddUpdateDeviceType, DeleteDeviceGroup, DeleteDeviceManger, DeleteDeviceType,
  DeviceGroupSearch,
  DeviceMangerSearch,
  DeviceTypeSearch,
@@ -577,27 +604,17 @@
  DeviceTypeSelectGroup,
  WorkShopSelect, WorkShopSelectLine
} from '@/api/sbgl'
import { handleDatetime } from '@/utils/global'
import { handleDatetime, validateCode } from '@/utils/global'
const SER_HZ = /^[\u4e00-\u9fa5]+$/
export default {
  name: 'SBQD',
  components: {
    Pagination
  },
  data() {
    const validateName = (rule, value, callback) => {
      if (!value) {
        return callback(new Error('请输入编码'))
      } else {
        if (SER_HZ.test(value)) {
          return callback(new Error('编码不能为中文'))
        } else {
          callback()
        }
      }
    }
    return {
      mouseHoverType: 'mouseout',
      isExpandForm: false,
      mainHeight: 0,
      tableHeight: 0,
      form: {
@@ -639,7 +656,7 @@
      operation: '',
      dialogFormRules: {
        devicecode: [
          { required: true, validator: validateName, trigger: ['blur', 'change'] }
          { required: true, validator: validateCode, trigger: ['blur', 'change'] }
        ],
        devicename: [
          { required: true, message: '请输入名称', trigger: ['blur', 'change'] }
@@ -793,6 +810,9 @@
        DeleteDeviceManger({ devicecode: row.code }).then(res => {
          if (res.code === '200') {
            this.$message.success('删除成功!')
            if (this.form.page > 1 && this.tableData.length === 1) {
              this.form.page--
            }
            this.getDeviceMangerSearch()
          }
        })
@@ -834,6 +854,7 @@
    dialogVisibleConfirm() {
      this.$refs.dialogForm.validate(valid => {
        if (valid) {
          this.$store.state.app.buttonIsDisabled = true
          const data = {
            id: this.dialogForm.id,
            devicecode: this.dialogForm.devicecode,
@@ -850,9 +871,10 @@
          }
          AddUpdateDeviceManger(data).then(res => {
            if (res.code === '200') {
              this.$message.success(this.operation === 'add' ? '添加成功!' : '修改成功!')
              this.dialogVisible = false
              this.$message.success(this.operation === 'add' ? '添加成功!' : '修改成功!')
              this.getDeviceMangerSearch()
              this.$store.state.app.buttonIsDisabled = false
            } else {
              this.$message.error(this.operation === 'add' ? '添加失败!' : '修改失败!')
            }
@@ -864,7 +886,8 @@
    getHeight() {
      this.$nextTick(() => {
        this.mainHeight = window.innerHeight - 85
        this.tableHeight = this.mainHeight - 240
        this.tableHeight = this.mainHeight - 245
        this.$refs.tableDataRef.doLayout()
        // if (window.innerHeight < 769) {
        //   this.tableHeight = this.tableHeight - 50
        // }
@@ -926,6 +949,9 @@
        DeleteDeviceType({ devicetypecode: row.code }).then(res => {
          if (res.code === '200') {
            this.$message.success('删除成功!')
            if (this.formDeviceType.page > 1 && this.DeviceTypeArray.length === 1) {
              this.formDeviceType.page--
            }
            this.getDeviceTypeSearchDialog()
          }
        })
@@ -1040,6 +1066,9 @@
        DeleteDeviceGroup({ devicegroupcode: row.code }).then(res => {
          if (res.code === '200') {
            this.$message.success('删除成功!')
            if (this.formDeviceGroup.page > 1 && this.DeviceGroupArray.length === 1) {
              this.formDeviceGroup.page--
            }
            this.getDeviceGroupSearchDialog()
          }
        })
@@ -1096,6 +1125,10 @@
<!--公共页面样式-->
<style lang="scss" scoped>
$main_color: #42b983;
::v-deep .el-button--text{
  font-size: 14px ;
  cursor: pointer ;
}
.el-icon-share ,.el-icon-delete,.el-icon-edit-outline{
  color: $main_color;
  cursor: pointer;
@@ -1181,7 +1214,20 @@
.userDialogVisible ::v-deep .el-form-item {
  margin-bottom: 0;
}
::v-deep .el-select__caret{
  display: flex;
  justify-content: center;
  align-items: center;
}
.tableFixed{
  ::v-deep .el-table__fixed-right{
    height: 100% !important;
  }
  ::v-deep .el-table__fixed{
    height: 100% !important;
  }
}
</style>
<style>