loulijun2021
2022-08-04 1e9fa82cb2fe2c15f46bd1dd73f5c878c74b83b8
src/views/sbgl/sbqd.vue
@@ -39,8 +39,8 @@
                filterable
                style="width: 200px"
                placeholder="请选择"
                @focus="getWorkShopSelect"
              >
                <!--                @focus="getWorkShopSelect"-->
                <el-option
                  v-for="item in WorkShopArr"
                  :key="item.code"
@@ -56,9 +56,10 @@
                style="width: 200px"
                filterable
                placeholder="请选择"
                @focus="getDeviceTypeSelect"
                @change="deviceTypeChange"
              >
                <!--                @focus="getDeviceTypeSelect"-->
                <el-option
                  v-for="item in DeviceTypeArr"
                  :key="item.code"
@@ -96,7 +97,7 @@
        <el-button type="primary" icon="el-icon-circle-plus-outline" @click="add('add')">新增</el-button>
        <el-button type="primary" icon="el-icon-c-scale-to-original" @click="deviceTypeButton">设备类型</el-button>
        <el-button type="primary" icon="el-icon-document-copy" @click="deviceGroupButton">设备组</el-button>
        <el-button type="primary" icon="el-icon-upload2" @click="upload">导入</el-button>
        <!--        <el-button type="primary" icon="el-icon-upload2" @click="upload">导入</el-button>-->
      </div>
      <el-divider />
      <div class="elTableDiv">
@@ -119,25 +120,30 @@
            prop="RowNum"
            width="50"
            label="序号"
            fixed
          />
          <el-table-column
            prop="code"
            label="设备编码"
            min-width="110"
            sortable="custom"
          />
          <el-table-column
            prop="name"
            label="设备名称"
            min-width="110"
            sortable="custom"
          />
          <el-table-column
            prop="eqptype_name"
            label="设备类型"
            min-width="110"
            sortable="custom"
          />
          <el-table-column
            prop="eqpgroup_name"
            label="设备组"
            min-width="110"
            sortable="custom"
          />
          <el-table-column
@@ -165,12 +171,13 @@
            prop="wksp_name"
            label="生产车间"
            sortable="custom"
            min-width="120"
          />
          <el-table-column
            prop="Line_name"
            label="所属产线"
            sortable="custom"
          />
          <!--          <el-table-column-->
          <!--            prop="Line_name"-->
          <!--            label="所属产线"-->
          <!--            sortable="custom"-->
          <!--          />-->
          <el-table-column
            prop="operation_ration"
            label="稼动率"
@@ -189,11 +196,13 @@
          />
          <el-table-column
            prop="lm_date"
            width="160"
            label="创建时间"
            sortable="custom"
          />
          <el-table-column
            label="操作"
            fixed="right"
            width="100"
          >
            <template slot-scope="{row}">
@@ -286,6 +295,8 @@
            placeholder="请选择"
            @change="workshopcodeChange"
          >
            <!--            @focus="getWorkShopSelect"-->
            <el-option
              v-for="item in WorkShopArr"
              :key="item.code"
@@ -294,23 +305,23 @@
            />
          </el-select>
        </el-form-item>
        <el-form-item label="所属产线" prop="linecode">
          <el-select
            v-model="dialogForm.linecode"
            filterable
            :popper-append-to-body="false"
            :disabled="dialogForm.workshopcode===''"
            style="width: 200px"
            placeholder="请选择"
          >
            <el-option
              v-for="item in WorkLineArr"
              :key="item.linecode"
              :label="item.linename"
              :value="item.linecode"
            />
          </el-select>
        </el-form-item>
        <!--        <el-form-item label="所属产线" prop="linecode">-->
        <!--          <el-select-->
        <!--            v-model="dialogForm.linecode"-->
        <!--            filterable-->
        <!--            :popper-append-to-body="false"-->
        <!--            :disabled="dialogForm.workshopcode===''"-->
        <!--            style="width: 200px"-->
        <!--            placeholder="请选择"-->
        <!--          >-->
        <!--            <el-option-->
        <!--              v-for="item in WorkLineArr"-->
        <!--              :key="item.linecode"-->
        <!--              :label="item.linename"-->
        <!--              :value="item.linecode"-->
        <!--            />-->
        <!--          </el-select>-->
        <!--        </el-form-item>-->
        <el-form-item label="使用状态" prop="status">
          <el-select
            v-model="dialogForm.status"
@@ -328,7 +339,7 @@
          </el-select>
        </el-form-item>
        <el-form-item label="稼动率" prop="ratio">
          <el-input v-model="dialogForm.ratio" style="width: 195px" />
          <el-input v-model="dialogForm.ratio" style="width: 175px" />
          <span style="margin-left: 10px">%</span>
        </el-form-item>
@@ -544,7 +555,6 @@
<script>
import Pagination from '@/components/Pagination'
import { getCookie } from '@/utils/auth'
import {
  AddUpdateDeviceGroup, AddUpdateDeviceManger,
  AddUpdateDeviceType, DeleteDeviceManger, DeleteDeviceType,
@@ -606,10 +616,10 @@
        devicename: '',
        devicetypecode: '',
        devicegroupcode: '',
        importdate: '',
        importdate: handleDatetime(new Date()),
        workshopcode: '',
        linecode: '',
        status: '',
        status: 'Y',
        ratio: ''
      },
      DeviceGroupDialogArr: [], // 设备组数组
@@ -634,9 +644,9 @@
        workshopcode: [
          { required: true, message: '请选择所属车间', trigger: ['blur', 'change'] }
        ],
        linecode: [
          { required: true, message: '请选择所属产线', trigger: ['blur', 'change'] }
        ],
        // linecode: [
        //   { required: true, message: '请选择所属产线', trigger: ['blur', 'change'] }
        // ],
        status: [
          { required: true, message: '请选择使用状态', trigger: ['blur', 'change'] }
        ]
@@ -662,23 +672,30 @@
    }
  },
  created() {
    // 获取设备清单列表
    this.getDeviceMangerSearch()
    // 获取设备类型下拉
    // this.getDeviceTypeSelect()
    // 获取所属车间下拉
    // this.getWorkShopSelect()
    this.handleRequest()
  },
  mounted() {
    window.addEventListener('resize', this.getHeight)
    this.getHeight()
  },
  methods: {
    handleRequest() {
      // 获取设备清单列表
      this.getDeviceMangerSearch().then(res => {
        if (res.code === '200') {
          // 获取设备类型下拉
          this.getDeviceTypeSelect()
          // 获取所属车间下拉
          this.getWorkShopSelect()
        }
      })
    },
    // 获取设备清单列表
    async getDeviceMangerSearch() {
      const res = await DeviceMangerSearch(this.form)
      this.tableData = res.data
      this.total = res.count
      return { code: res.code }
    },
    // 获取所属车间下拉
    async getWorkShopSelect() {
@@ -749,7 +766,7 @@
        this.dialogForm.devicegroupcode = row.eqpgroup_code
        this.dialogForm.importdate = row.input_date
        this.dialogForm.workshopcode = row.wksp_code
        this.dialogForm.linecode = row.Line_code
        // this.dialogForm.linecode = row.Line_code
        this.dialogForm.status = row.enable
        this.dialogForm.ratio = row.operation_ration
      })
@@ -778,10 +795,10 @@
      this.dialogForm.devicename = ''
      this.dialogForm.devicetypecode = ''
      this.dialogForm.devicegroupcode = ''
      this.dialogForm.importdate = ''
      this.dialogForm.importdate = handleDatetime(new Date())
      this.dialogForm.workshopcode = ''
      this.dialogForm.linecode = ''
      this.dialogForm.status = ''
      // this.dialogForm.linecode = ''
      this.dialogForm.status = 'Y'
      this.dialogForm.ratio = ''
      this.$refs.dialogForm.clearValidate()
    },
@@ -789,7 +806,7 @@
    async workshopcodeChange(val) {
      const { data: res } = await WorkShopSelectLine({ workshopcode: val })
      this.WorkLineArr = res
      this.dialogForm.linecode = ''
      // this.dialogForm.linecode = ''
    },
    // 对话框设备类型下拉选择改变时
    async devicetypecodeChange(val) {
@@ -813,7 +830,8 @@
            devicegroupcode: this.dialogForm.devicegroupcode,
            importdate: handleDatetime(this.dialogForm.importdate),
            workshopcode: this.dialogForm.workshopcode,
            linecode: this.dialogForm.linecode,
            // linecode: this.dialogForm.linecode,
            linecode: '',
            status: this.dialogForm.status,
            ratio: this.dialogForm.ratio,
            OperType: this.operation === 'add' ? 'Add' : 'Update'
@@ -908,9 +926,9 @@
      if (row.name.trim().length < 1) {
        return this.$message.info('类型名称不能为空!')
      }
      if (row.remark.trim().length < 1) {
        return this.$message.info('类型描述不能为空!')
      }
      // if (row.remark.trim().length < 1) {
      //   return this.$message.info('类型描述不能为空!')
      // }
      const data = {
        'code': row.code,
        'name': row.name,
@@ -1022,9 +1040,9 @@
      if (row.eqptype_code.trim().length < 1) {
        return this.$message.info('所属设备类型不能为空!')
      }
      if (row.remark.trim().length < 1) {
        return this.$message.info('分组描述不能为空!')
      }
      // if (row.remark.trim().length < 1) {
      //   return this.$message.info('分组描述不能为空!')
      // }
      const data = {
        'code': row.code,
        'name': row.name,