loulijun2021
2022-12-20 b58dc818feacbfc6bf01453b0db8ad3306c8d6dd
src/views/zzmx/gxdy.vue
@@ -11,12 +11,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;">
            <el-form-item label-width="70px" label="工序编码" style=" display: flex;">
              <el-input v-model="form.stepcode" placeholder="请输入" style="width: 200px" />
            </el-form-item>
            <el-form-item label="工序名称" style=" display: flex;">
@@ -54,24 +54,43 @@
                />
              </el-select>
            </el-form-item>
            <el-form-item label="创建人员" style=" display: flex;">
            <el-form-item v-show="isExpandForm" label-width="70px" label="创建人员" style=" display: flex;">
              <el-input v-model="form.createuser" style="width: 200px" placeholder="请输入" />
            </el-form-item>
          </div>
          <div style="display: flex;align-items: start;margin-top: 5px;z-index: 2">
          <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">
        <el-table
          ref="tableDataRef"
          class="tableFixed"
          :data="tableData"
          :height="tableHeight"
          :height="isExpandForm?tableHeight:(tableHeight+40)+'px'"
          border
          :row-class-name="tableRowClassName"
          :style="{width: 100+'%',height:tableHeight+'px'}"
          :style="{width: 100+'%',height:isExpandForm?tableHeight:(tableHeight+40)+'px',}"
          highlight-current-row
          :header-cell-style="this.$headerCellStyle"
          :cell-style="this.$cellStyle"
@@ -89,6 +108,7 @@
          />
          <el-table-column
            prop="stepcode"
            show-tooltip-when-overflow
            label="工序编码"
            min-width="150"
            sortable="custom"
@@ -96,12 +116,14 @@
          <el-table-column
            prop="stepname"
            min-width="150"
            show-tooltip-when-overflow
            label="工序名称"
            sortable="custom"
          />
          <el-table-column
            prop="flwtype"
            min-width="150"
            show-tooltip-when-overflow
            label="工序类型"
            sortable="custom"
          >
@@ -113,36 +135,52 @@
          </el-table-column>
          <el-table-column
            prop="descr"
            show-tooltip-when-overflow
            label="工序描述"
            min-width="180"
            sortable="custom"
          />
          >
            <template slot-scope="{row}">
              <div v-if="row.descr">{{ row.descr }}</div>
              <div v-else>/</div>
            </template>
          </el-table-column>
          <el-table-column
            prop="enable"
            label="启用状态"
            show-tooltip-when-overflow
            sortable="custom"
            width="110"
          >
            <template slot-scope="{row}">
              <div v-if="row.enable==='Y'">是</div>
              <div v-if="row.enable==='N'">否</div>
              <div v-if="row.enable==='Y'">
                <svg-icon icon-class="circleYes" style="margin-right: 2px" />
                是
              </div>
              <div v-if="row.enable==='N'">
                <svg-icon icon-class="circleNo" style="margin-right: 2px" />
                否
              </div>
            </template>
          </el-table-column>
          <el-table-column
            prop="lm_user"
            label="创建人员"
            show-tooltip-when-overflow
            width="110"
            sortable="custom"
          />
          <el-table-column
            prop="lm_date"
            label="创建时间"
            show-tooltip-when-overflow
            width="160"
            sortable="custom"
          />
          <el-table-column
            label="关联工作站"
            prop="is_eqp"
            show-tooltip-when-overflow
            width="110"
          >
            <template slot-scope="{row}">
@@ -160,6 +198,7 @@
          <el-table-column
            label="关联缺陷"
            prop="is_defect"
            show-tooltip-when-overflow
            width="110"
          >
            <template slot-scope="{row}">
@@ -194,7 +233,6 @@
      </div>
      <!--分页-->
      <pagination
        v-show="total>0"
        :total="total"
        :page.sync="form.page"
        :limit.sync="form.rows"
@@ -273,7 +311,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>
@@ -341,7 +384,12 @@
      <span slot="footer" class="dialog-footer">
        <div class="footerButton">
          <el-button @click="workDialogVisibleCancel">取 消</el-button>
          <el-button type="primary" @click="workDialogVisibleConfirm">确 定</el-button>
          <el-button
            type="primary"
            :loading="$store.state.app.buttonIsDisabled"
            :disabled="$store.state.app.buttonIsDisabled"
            @click="workDialogVisibleConfirm"
          >确 定</el-button>
        </div>
      </span>
    </el-dialog>
@@ -383,7 +431,12 @@
      <span slot="footer" class="dialog-footer">
        <div class="footerButton">
          <el-button @click="defectDialogVisibleCancel">取 消</el-button>
          <el-button type="primary" @click="defectDialogVisibleConfirm">确 定</el-button>
          <el-button
            type="primary"
            :loading="$store.state.app.buttonIsDisabled"
            :disabled="$store.state.app.buttonIsDisabled"
            @click="defectDialogVisibleConfirm"
          >确 定</el-button>
        </div>
      </span>
    </el-dialog>
@@ -402,26 +455,17 @@
  StepSearch
} from '@/api/zzmx'
import $ from 'jquery'
import { validateCode } from '@/utils/global'
const SER_HZ = /^[\u4e00-\u9fa5]+$/
export default {
  name: 'GXDY',
  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,
      isIpad: false,
      mainHeight: 0,
      tableHeight: 0,
@@ -460,7 +504,7 @@
      operation: '',
      dialogFormRules: {
        stepcode: [
          { required: true, validator: validateName, trigger: ['blur', 'change'] }
          { required: true, validator: validateCode, trigger: ['blur', 'change'] }
        ],
        stepname: [
          { required: true, message: '请输入名称', trigger: ['blur', 'change'] }
@@ -569,6 +613,9 @@
        DeleteStep({ stepcode: row.stepcode }).then(res => {
          if (res.code === '200') {
            this.$message.success('删除成功!')
            if (this.form.page > 1 && this.tableData.length === 1) {
              this.form.page--
            }
            this.getStepSearch()
          }
        })
@@ -593,6 +640,7 @@
    dialogVisibleConfirm() {
      this.$refs.dialogForm.validate(valid => {
        if (valid) {
          this.$store.state.app.buttonIsDisabled = true
          const data = {
            id: this.dialogForm.id,
            stepcode: this.dialogForm.stepcode,
@@ -604,9 +652,10 @@
          }
          AddUpdateStep(data).then(res => {
            if (res.code === '200') {
              this.$message.success(this.operation === 'add' ? '添加成功!' : '修改成功!')
              this.dialogVisible = false
              this.$message.success(this.operation === 'add' ? '添加成功!' : '修改成功!')
              this.getStepSearch()
              this.$store.state.app.buttonIsDisabled = false
            } else {
              this.$message.error(this.operation === 'add' ? '添加失败!' : '修改失败!')
            }
@@ -619,64 +668,81 @@
      this.$nextTick(() => {
        // this.mainHeight = window.innerHeight - 250
        this.mainHeight = window.innerHeight - 85
        this.tableHeight = this.mainHeight - 200
        this.tableHeight = this.mainHeight - 255
        if (window.innerHeight < 769) {
          this.tableHeight = this.tableHeight - 40
        }
        this.isIpad = window.innerHeight < 769 && window.innerWidth < 1367
        this.$refs.tableDataRef.doLayout()
      })
    },
    /* 关联工作站模块*/
    // 关联工作站点击
    async workClick(row) {
      this.workDialogVisible = true
    workClick(row) {
      const loading = this.$loading({
        lock: true,
        text: '正在加载数据,请稍等...',
        spinner: 'el-icon-loading',
        customClass: 'osloading',
        background: 'rgba(0, 0, 0, 0.7)'
      })
      this.workDialogForm.stepcode = row.stepcode
      this.workDialogForm.stepname = row.stepname
      const { data: res } = await StepAssociationEqp({ stepcode: this.workDialogForm.stepcode })
      this.workDialogForm.workArr = res
      let workGatherArr = []
      if (row.flwtype === 'W') { // 外协情况下
        workGatherArr = this.workDialogForm.workArr.filter(item => item.type === 'W')
      } else if (row.flwtype === 'Z') { // 自制情况下
        workGatherArr = this.workDialogForm.workArr.filter(item => item.type === 'E')
      } else { // 自制+外协
        workGatherArr = this.workDialogForm.workArr
      }
      // this.workDialogForm.workArr[1].children = []
      const nodeKey = []// 需要树形数显的值
      workGatherArr.forEach((item, index) => {
        this.workDialogForm.workGatherArr.push({
          isSelected1: index === 0,
          isSelected2: item.flag === 'Y',
          code: item.code,
          name: item.name,
          type: item.type,
          flag: item.flag
        })
        if (item.flag === 'Y' && item.children && item.children.length > 0) {
          this.$nextTick(() => {
            $("input[name='gather']").eq(index).prop('checked', true)// 自定义单选框回显
          })
          item.children.forEach(it => {
            if (it.flag === 'Y') {
              nodeKey.push(it.code)
            }
          })
        }
        if (index === 0) {
          if (item.children && item.children.length > 0) {
            this.workDialogForm.workTreeArr = this.workDialogForm.workArr.filter(it => it.code === item.code)
            this.workDialogForm.workTreeArr[0].name = '全部'
          }
        }
        // item.flag === 'Y'&&item
      })
      console.log(nodeKey, 1)
      this.$refs.workTree.setCheckedKeys(nodeKey)
      this.workDialogForm.workTreeSelectedArr = nodeKey
      StepAssociationEqp({ stepcode: this.workDialogForm.stepcode }).then(res => {
        if (res.code === '200') {
          setTimeout(() => {
            loading.close()
            this.workDialogVisible = true
      console.log(this.workDialogForm.workGatherArr, 6)
      console.log(this.workDialogForm.workTreeArr, 7)
            this.workDialogForm.workArr = res.data.filter(item => item.children.length !== 0)
            let workGatherArr = []
            if (row.flwtype === 'W') { // 外协情况下
              workGatherArr = this.workDialogForm.workArr.filter(item => item.type === 'W')
            } else if (row.flwtype === 'Z') { // 自制情况下
              workGatherArr = this.workDialogForm.workArr.filter(item => item.type === 'E')
            } else { // 自制+外协
              workGatherArr = this.workDialogForm.workArr
            }
            const nodeKey = []// 需要树形数显的值
            workGatherArr.forEach((item, index) => {
              this.workDialogForm.workGatherArr.push({
                isSelected1: index === 0,
                isSelected2: item.flag === 'Y',
                code: item.code,
                name: item.name,
                type: item.type,
                flag: item.flag
              })
              if (item.flag === 'Y' && item.children && item.children.length > 0) {
                this.$nextTick(() => {
                  $("input[name='gather']").eq(index).prop('checked', true)// 自定义单选框回显
                })
                item.children.forEach(it => {
                  if (it.flag === 'Y') {
                    nodeKey.push(it.code)
                  }
                })
              }
              if (index === 0) {
                if (item.children && item.children.length > 0) {
                  this.workDialogForm.workTreeArr = this.workDialogForm.workArr.filter(it => it.code === item.code)
                  this.workDialogForm.workTreeArr[0].name = '全部'
                }
              }
              // item.flag === 'Y'&&item
            })
            this.$nextTick(() => {
              this.$refs.workTree.setCheckedKeys(nodeKey)
            })
            this.workDialogForm.workTreeSelectedArr = nodeKey
          }, 1000)
        } else {
          loading.close()
        }
      })
    },
    // 大盒子点击事件
    myCheckboxClick(val) {
@@ -895,8 +961,7 @@
    // 确认
    async workDialogVisibleConfirm() {
      this.workDialogForm.workTreeSelectedArr = [...new Set(this.workDialogForm.workTreeSelectedArr)]
      console.log(this.workDialogForm.workTreeSelectedArr, 18)
      console.log(this.workDialogForm.workArr, 20)
      const data = []
      this.workDialogForm.workArr.forEach(item => {
        if (item.flag === 'Y' && item.children && item.children.length > 0) {
@@ -907,34 +972,51 @@
          })
        }
      })
      console.log(data)
      this.$store.state.app.buttonIsDisabled = true
      const res = await SaveStepAssociationEqp(this.workDialogForm.stepcode, data)
      if (res.code === '200') {
        this.workDialogVisible = false
        this.$message.success('保存成功!')
        await this.getStepSearch()
        this.workDialogVisible = false
        this.$store.state.app.buttonIsDisabled = false
      }
    },
    /* 关联缺陷*/
    //  关联缺陷点击
    async defectClick(row) {
    defectClick(row) {
      const loading = this.$loading({
        lock: true,
        text: '正在加载数据,请稍等...',
        spinner: 'el-icon-loading',
        customClass: 'osloading',
        background: 'rgba(0, 0, 0, 0.7)'
      })
      this.defectTreeCode = row.stepcode
      this.defectTreeName = row.stepname
      this.defectDialogVisible = true
      const { data: res } = await StepAssociationDefect({ stepcode: row.stepcode })
      // this.defectTree = res
      this.defectTree.push({ code: 'QB', name: '全部', children: res, flag: 'N' })
      console.log(this.defectTree, 6)
      const nokeKey = []
      this.defectTree[0].children.forEach(item => {
        if (item.flag === 'Y') {
          nokeKey.push(item.code)
      StepAssociationDefect({ stepcode: row.stepcode }).then(res => {
        if (res.code === '200') {
          setTimeout(() => {
            loading.close()
            this.defectDialogVisible = true
            this.defectTree.push({ code: 'QB', name: '全部', children: res.data, flag: 'N' })
            const nokeKey = []
            this.defectTree[0].children.forEach(item => {
              if (item.flag === 'Y') {
                nokeKey.push(item.code)
              }
            })
            this.$nextTick(() => {
              this.$refs.defectTree.setCheckedKeys(nokeKey)
            })
          }, 1000)
        } else {
          loading.close()
        }
      })
      console.log(nokeKey, 2)
      this.$nextTick(() => {
        this.$refs.defectTree.setCheckedKeys(nokeKey)
      })
    },
    // 关闭
@@ -955,11 +1037,13 @@
          data.push({ code: item.code, name: item.name })
        }
      })
      this.$store.state.app.buttonIsDisabled = true
      const res = await SaveStepAssociationDefect(this.defectTreeCode, data)
      if (res.code === '200') {
        this.defectDialogVisible = false
        this.$message.success('保存成功!')
        await this.getStepSearch()
        this.defectDialogVisible = false
        this.$store.state.app.buttonIsDisabled = false
      }
    }
  }
@@ -1118,9 +1202,24 @@
  margin-bottom: 0;
}
.tableFixed {
  ::v-deep .el-table__fixed-right {
    height: 100% !important;
  }
  ::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;
}