loulijun2021
2022-09-07 ef9633e0d1689fd8869170f3aa0af6c90c2e5e7f
src/views/scgl/gdplgb.vue
@@ -1,9 +1,12 @@
<template>
  <div>
    <div class="body" :style="{height:mainHeight+'px'}">
      <div class="bodyTopButtonGroup">
        <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 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 icon="el-icon-switch-button" @click="handleClose('close')">批量关单</el-button>
        <el-button icon="el-icon-switch-button" @click="handleClose('noClose')">批量反关单</el-button>
      </div>
      <div class="bodyTopFormGroup">
@@ -15,24 +18,39 @@
          style="display: flex;justify-content: space-between"
        >
          <div class="elForm">
            <el-form-item label="组织编码" style=" display: flex;">
              <el-input v-model="form.OrgCode" placeholder="请输入" style="width: 200px" />
            <el-form-item label="工单状态" style=" display: flex;">
              <el-input v-model="form.mesorderstus" placeholder="请输入" style="width: 200px" />
            </el-form-item>
            <el-form-item label="组织名称" style=" display: flex;">
              <el-input v-model="form.OrgName" placeholder="请输入" style="width: 200px" />
            <el-form-item label="工单编号" style=" display: flex;">
              <el-input v-model="form.mesordercode" placeholder="请输入" style="width: 200px" />
            </el-form-item>
            <el-form-item label="组织类型" style=" display: flex;">
              <el-select v-model="form.OrgType" style="width: 200px" placeholder="请选择">
            <el-form-item label="源单单号" style=" display: flex;">
              <el-input v-model="form.sourceorder" placeholder="请输入" style="width: 200px" />
            </el-form-item>
            <el-form-item label="单据类型" style=" display: flex;">
              <el-select v-model="form.ordertype" style="width: 200px" placeholder="请选择">
                <el-option
                  v-for="item in OrgTypeArr"
                  v-for="item in ordertypeArr"
                  :key="item.code"
                  :label="item.name"
                  :value="item.code"
                />
              </el-select>
            </el-form-item>
            <el-form-item label="产品编码" style=" display: flex;">
              <el-input v-model="form.partcode" style="width: 200px" placeholder="请输入" />
            </el-form-item>
            <el-form-item label="产品名称" style=" display: flex;">
              <el-input v-model="form.partname" style="width: 200px" placeholder="请输入" />
            </el-form-item>
            <el-form-item label="产品规格" style=" display: flex;">
              <el-input v-model="form.partspec" style="width: 200px" placeholder="请输入" />
            </el-form-item>
            <el-form-item label="创建人员" style=" display: flex;">
              <el-input v-model="form.UserName" style="width: 200px" placeholder="请输入" />
              <el-input v-model="form.creatuser" style="width: 200px" placeholder="请输入" />
            </el-form-item>
            <el-form-item label="创建时间" style=" display: flex;">
              <el-input v-model="form.createdate" style="width: 200px" placeholder="请输入" />
            </el-form-item>
          </div>
          <div style="display: flex;align-items: start;margin-top: 5px;z-index: 2">
@@ -44,6 +62,7 @@
      <div class="elTableDiv">
        <el-table
          ref="multipleTable"
          :data="tableData"
          :height="tableHeight+'px'"
          border
@@ -52,38 +71,192 @@
          highlight-current-row
          :header-cell-style="this.$headerCellStyle"
          :cell-style="this.$cellStyle"
          @selection-change="handleSelectionChange"
          @sort-change="sortChange"
        >
          <el-table-column
            type="selection"
            fixed
            width="50"
          />
          <!--          <el-table-column-->
          <!--            width="50"-->
          <!--            fixed-->
          <!--          >-->
          <!--            <template slot-scope="{row}">-->
          <!--              <el-radio-->
          <!--                v-model="radioSelected"-->
          <!--                :label="row.wo_code"-->
          <!--                style="color: transparent;padding-left: 10px;"-->
          <!--                @change.native="getCurrentRow(row.wo_code)"-->
          <!--              />-->
          <!--            </template>-->
          <!--          </el-table-column>-->
          <el-table-column
            prop="RowNum"
            width="50"
            fixed
            label="序号"
            fixed
          />
          <el-table-column
            prop="org_code"
            label="组织编码"
            prop="status"
            label="订单状态"
            sortable="custom"
            width="110"
          >
            <template slot-scope="{row}">
              <div v-if="row.status==='NEW'">新工单</div>
              <!--              <div v-if="row.status==='CREATING'">执行中</div>-->
              <!--              <div v-if="row.status==='CREATED'">已关闭</div>-->
              <div v-if="row.status==='ALLO'">已派发</div>
              <div v-if="row.status==='START'">开工</div>
              <div v-if="row.status==='CLOSED'">完工</div>
            </template>
          </el-table-column>
          <el-table-column
            prop="wo_code"
            label="工单编号"
            sortable="custom"
            min-width="160"
          />
          <el-table-column
            prop="m_po"
            label="源单单号"
            sortable="custom"
            min-width="160"
          />
          <el-table-column
            prop="wotype"
            label="单据类型"
            sortable="custom"
            min-width="120"
          >
            <template slot-scope="{row}">
              <div v-if="row.wotype==='PO'">标准工单</div>
              <div v-else-if="row.wotype==='FO'">报废补单</div>
              <div v-else>/</div>
            </template>
          </el-table-column>
          <el-table-column
            prop="partcode"
            label="产品编码"
            sortable="custom"
            min-width="120"
          />
          <el-table-column
            prop="partname"
            min-width="150"
            label="产品名称"
            sortable="custom"
          />
          <el-table-column
            prop="org_name"
            label="组织名称"
            prop="partspec"
            label="产品规格"
            sortable="custom"
            width="110"
          >
            <template slot-scope="{row}">
              <div v-if="row.partspec">{{ row.partspec }}</div>
              <div v-else>/</div>
            </template>
          </el-table-column>
          <el-table-column
            prop="plan_qty"
            label="任务数量"
            sortable="custom"
            width="110"
          />
          <el-table-column
            prop="description"
            label="组织类型"
            prop="good_qty"
            label="合格数量"
            sortable="custom"
            width="110"
          />
          <el-table-column
            prop="parentorg_name"
            label="上级单位"
            prop="ng_qty"
            label="不良数量"
            sortable="custom"
            width="110"
          />
          <el-table-column
            prop="bad_qty"
            label="报废数量"
            sortable="custom"
            width="110"
          />
          <el-table-column
            prop="wkshp_name"
            label="生产车间"
            sortable="custom"
            width="120"
          >
            <template slot-scope="{row}">
              <div v-if="row.wkshp_name">{{ row.wkshp_name }}</div>
              <div v-else>/</div>
            </template>
          </el-table-column>
          <el-table-column
            prop="route_name"
            label="工艺路线"
            show-tooltip-when-overflow
            sortable="custom"
            width="180"
          >
            <template slot-scope="{row}">
              <div v-if="row.route_name">{{ row.route_name }}</div>
              <div v-else>/</div>
            </template>
          </el-table-column>
          <!--          <el-table-column-->
          <!--            prop="route_name"-->
          <!--            label="关联工艺路线"-->
          <!--            min-width="110"-->
          <!--          >-->
          <!--            <template slot-scope="{row}">-->
          <!--              <i v-if="row.route_name" class="el-icon-share" @click="routeClick(row)" />-->
          <!--              <i v-else style="color:rgb(180 ,181, 185)" class="el-icon-share" @click="routeClick(row)" />-->
          <!--            </template>-->
          <!--          </el-table-column>-->
          <el-table-column
            prop="plan_startdate"
            label="计划开始时间"
            sortable="custom"
            width="160"
          >
            <template slot-scope="{row}">
              <div v-if="row.plan_startdate">{{ row.plan_startdate }}</div>
              <div v-else>/</div>
            </template>
          </el-table-column>
          <el-table-column
            prop="plan_enddate"
            label="计划结束时间"
            sortable="custom"
            width="160"
          >
            <template slot-scope="{row}">
              <div v-if="row.plan_enddate">{{ row.plan_enddate }}</div>
              <div v-else>/</div>
            </template>
          </el-table-column>
          <el-table-column
            prop="piroque"
            label="工单等级"
            sortable="custom"
            width="120"
          >
            <template slot-scope="{row}">
              <div v-if="row.piroque==='1'">特级</div>
              <div v-if="row.piroque==='2'">紧急</div>
              <div v-if="row.piroque==='3'">正常</div>
              <div v-else>/</div>
            </template>
          </el-table-column>
          <el-table-column
            prop="lm_user"
            label="创建人员"
            sortable="custom"
            width="120"
          />
          <el-table-column
            prop="lm_date"
@@ -91,22 +264,26 @@
            width="160"
            sortable="custom"
          />
          <el-table-column
            label="操作"
            width="120"
            fixed="right"
          >
            <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)" />
                </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>
          <!--          <el-table-column-->
          <!--            label="操作"-->
          <!--            width="120"-->
          <!--            fixed="right"-->
          <!--          >-->
          <!--            <template slot-scope="{row}">-->
          <!--              <div class="operationClass">-->
          <!--                <el-tooltip class="item" effect="dark" content="工序任务" placement="top">-->
          <!--                  <i-->
          <!--                    class="el-icon-tickets"-->
          <!--                    style="cursor: pointer;color: #42b983;margin-right: 15px"-->
          <!--                    @click="check(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>-->
        </el-table>
      </div>
      <!--分页-->
@@ -115,54 +292,21 @@
        :page.sync="form.page"
        :limit.sync="form.rows"
        align="right"
        layout="prev, pager, next,sizes"
        layout="total,prev, pager, next,sizes"
        popper-class="select_bottom"
        @pagination="getOrganizationSearch"
        @pagination="getMesOrderBitchClosedSearch"
      />
    </div>
    <el-dialog
      :title="operation==='add'?'新增':'编辑'"
      :visible.sync="dialogVisible"
      width="800px"
      :close-on-click-modal="false"
      top="15vh"
      @closed="handleClose"
      @close="handleClose"
    >
      <el-form ref="dialogForm" inline :rules="dialogFormRules" :model="dialogForm" label-width="80px">
        <el-form-item label="组织编码" prop="OrgCode">
          <el-input v-model="dialogForm.OrgCode" :disabled="operation!=='add'" style="width: 200px" />
        </el-form-item>
        <el-form-item label="组织名称" prop="OrgName">
          <el-input v-model="dialogForm.OrgName" style="width: 200px" />
        </el-form-item>
        <el-form-item prop="SupUnit" label="上级单位">
          <el-select
            v-model="dialogForm.SupUnit"
            style="width: 200px"
            placeholder="请选择"
            :popper-append-to-body="false"
          >
            <el-option
              v-for="item in SupUnitArr"
              :key="item.code"
              :label="item.name"
              :value="item.code"
            />
          </el-select>
        </el-form-item>
      </el-form>
      <span slot="footer" class="dialog-footer">
        <div class="footerButton">
          <el-button @click="dialogVisibleCancel">取 消</el-button>
          <el-button type="primary" @click="dialogVisibleConfirm">确 定</el-button>
        </div>
      </span>
    </el-dialog>
    <!--导入组件-->
    <import-picker ref="importPickerFunc" class="importPickerClass" :shows.sync="shows" :title="title_value" :colos="colos" :code="code" />
    <import-picker
      ref="importPickerFunc"
      class="importPickerClass"
      :shows.sync="shows"
      :title="title_value"
      :colos="colos"
      :code="code"
    />
  </div>
</template>
@@ -172,77 +316,41 @@
import { AddUpdateOrganization, DeleteOrganization, OrganizationSearch, PrentOrganization } from '@/api/jcsz'
import { getCookie } from '@/utils/auth'
import ImportPicker from '@/components/ImportPicker'
import { validateCode } from '@/utils/global'
import { MesOrderBitchAntiClosedSeave, MesOrderBitchClosedSearch, MesOrderBitchClosedSeave } from '@/api/scgl'
const SER_HZ = /^[\u4e00-\u9fa5]+$/
export default {
  name: 'Zzjg',
  components: {
    Pagination, ImportPicker
  },
  data() {
    const validateName = (rule, value, callback) => {
      if (!value) {
        return callback(new Error('请输入编码'))
      } else {
        if (SER_HZ.test(value)) {
          return callback(new Error('编码不能为中文'))
        } else {
          callback()
        }
      }
    }
    const validateTypeCode = (rule, value, callback) => {
      if (!value) {
        return callback(new Error('请选择上级'))
      } else {
        callback()
      }
    }
    return {
      mainHeight: 0,
      tableHeight: 0,
      form: {
        OrgCode: '', // 组织架构代码
        OrgName: '', // 组织架构名称
        OrgType: '', // 组织类型
        UserName: '', // 创建人员
        mesorderstus: '', // 工单状态
        mesordercode: '', // 工单编号
        sourceorder: '', // 源单单号
        ordertype: '', // 单据类型
        partcode: '', // 产品编码
        partname: '', // 产品名称
        partspec: '', // 产品规格
        creatuser: '', // 创建人员
        createdate: '', // 创建时间
        prop: 'lm_date', // 排序字段
        order: 'desc', // 排序字段
        page: 1, // 第几页
        rows: 20 // 每页多少条
      },
      OrgTypeArr: [
        { label: '工厂', value: 'F' },
        { label: '部门', value: 'D' },
        { label: '车间', value: 'W' },
        { label: '科室', value: 'K' },
        { label: '生产线', value: 'L' }
      ordertypeArr: [// 工单类型
        { code: 'PO', name: '标准工单' },
        { code: 'FO', name: '报废补单' }
      ],
      total: 10,
      tableData: [],
      dialogVisible: false,
      dialogForm: {
        OrgType: '',
        OrgCode: '',
        OrgName: '',
        SupUnit: ''// 上级单位
      },
      operation: '',
      dialogFormRules: {
        OrgType: [
          { required: true, message: '请输入选择类型', trigger: ['blur', 'change'] }
        ],
        OrgCode: [
          { required: true, validator: validateName, trigger: ['blur', 'change'] }
        ],
        OrgName: [
          { required: true, message: '请输入名称', trigger: ['blur', 'change'] }
        ],
        SupUnit: [
          { required: true, validator: validateTypeCode, trigger: ['blur', 'change'] }
        ]
      },
      multipleSelection: [],
      title_value: '数据导入 / 点检部位',
      code: '4',
@@ -253,20 +361,20 @@
  watch: {
    shows() {
      if (!this.shows) {
        this.getOrganizationSearch()
        this.getMesOrderBitchClosedSearch()
      }
    }
  },
  created() {
    this.getOrganizationSearch()
    this.getMesOrderBitchClosedSearch()
  },
  mounted() {
    window.addEventListener('resize', this.getHeight)
    this.getHeight()
  },
  methods: {
    async getOrganizationSearch() {
      const res = await OrganizationSearch(this.form)
    async getMesOrderBitchClosedSearch() {
      const res = await MesOrderBitchClosedSearch(this.form)
      this.tableData = res.data
      this.total = res.count
    },
@@ -281,11 +389,11 @@
      }
      this.form.order = order
      this.form.prop = prop
      this.getOrganizationSearch()
      this.getMesOrderBitchClosedSearch()
    },
    // 查询
    search() {
      this.getOrganizationSearch()
      this.getMesOrderBitchClosedSearch()
    },
    // 导入按钮
    upload() {
@@ -297,88 +405,71 @@
    },
    // 重置
    reset() {
      this.form.OrgCode = ''
      this.form.OrgName = ''
      this.form.OrgType = ''
      this.form.UserName = ''
      this.getOrganizationSearch()
      this.form.mesorderstus = ''
      this.form.mesordercode = ''
      this.form.sourceorder = ''
      this.form.ordertype = ''
      this.form.partcode = ''
      this.form.partname = ''
      this.form.partspec = ''
      this.form.creatuser = ''
      this.form.createdate = ''
      this.getMesOrderBitchClosedSearch()
    },
    // 新增按钮
    add(operation) {
      this.operation = operation
      this.dialogVisible = true
    handleSelectionChange(val) {
      this.multipleSelection = val
    },
    // 修改按钮
    edit(operation, row) {
      this.operation = operation
      this.dialogVisible = true
      this.$nextTick(() => {
        this.dialogForm.OrgCode = row.org_code
        this.dialogForm.OrgName = row.org_name
        this.dialogForm.SupUnit = row.parent_id
      })
    },
    // 删除按钮
    async del(row) {
      this.$confirm('是否确认删除?', '提示', {
        confirmButtonText: '确定',
        cancelButtonText: '取消',
        type: 'warning'
      }).then(() => {
        DeleteOrganization({ orgid: row.code }).then(res => {
          if (res.code === '200') {
            this.$message.success('删除成功!')
            if (this.form.page > 1 && this.tableData.length === 1) {
              this.form.page--
            }
            this.getOrganizationSearch()
    handleClose(val) {
      const data = []
      if (val === 'close') {
        // 判断逻辑:合格+不良>=任务数量时 且状态不为CLOSED
        this.multipleSelection.forEach(item => {
          if (item.status !== 'CLOSED' && parseFloat(item.good_qty) + parseFloat(item.ng_qty) + parseFloat(item.bad_qty) >= parseFloat(item.plan_qty)) {
            data.push({ wo_code: item.wo_code })
          }
        })
      }).catch(() => {
        this.$message.info('已取消删除')
      })
    },
    // 对话框关闭事件
    handleClose() {
      this.dialogForm.OrgType = ''
      this.dialogForm.OrgCode = ''
      this.dialogForm.OrgName = ''
      this.dialogForm.SupUnit = ''
      this.$refs.dialogForm.clearValidate()
    },
    // 对话框取消
    dialogVisibleCancel() {
      this.dialogVisible = false
    },
    // 对话框确认
    dialogVisibleConfirm() {
      this.$refs.dialogForm.validate(valid => {
        if (valid) {
          const data = {
            OrganCode: this.dialogForm.OrgCode,
            OrganName: this.dialogForm.OrgName,
            OperType: this.operation === 'add' ? 'Add' : 'Update',
            Operator: getCookie('admin')
          }
          AddUpdateOrganization(data).then(res => {
        this.$confirm('是否确认批量关单?', '提示', {
          confirmButtonText: '确定',
          cancelButtonText: '取消',
          type: 'warning'
        }).then(() => {
          MesOrderBitchClosedSeave({ dt: data }).then(res => {
            if (res.code === '200') {
              this.$message.success(this.operation === 'add' ? '添加成功!' : '修改成功!')
              this.dialogVisible = false
              this.getOrganizationSearch()
            } else {
              this.$message.error(this.operation === 'add' ? '添加失败!' : '修改失败!')
              this.$message.success('批量关单成功!')
              this.$refs.multipleTable.clearSelection()
            }
          })
        }
      })
        }).catch(() => {
          this.$message.info('已取消批量关单!')
        })
      } else if (val === 'noClose') {
        this.multipleSelection.forEach(item => {
          if (item.status === 'CLOSED') {
            data.push({ wo_code: item.wo_code })
          }
        })
        this.$confirm('是否确认批量反关单?', '提示', {
          confirmButtonText: '确定',
          cancelButtonText: '取消',
          type: 'warning'
        }).then(() => {
          MesOrderBitchAntiClosedSeave({ dt: data }).then(res => {
            if (res.code === '200') {
              this.$message.success('批量反关单成功!')
              this.$refs.multipleTable.clearSelection()
            }
          })
        }).catch(() => {
          this.$message.info('已取消批量反关单!')
        })
      }
    },
    // 获取页面高度
    getHeight() {
      this.$nextTick(() => {
        this.mainHeight = window.innerHeight - 85
        this.tableHeight = this.mainHeight - 200
        this.tableHeight = this.mainHeight - 240
      })
    },
    tableRowClassName({ row, rowIndex }) {
@@ -391,15 +482,17 @@
<!--公共页面样式-->
<style lang="scss" scoped>
$main_color: #42b983;
::v-deep .el-button--text{
  font-size: 14px ;
  cursor: pointer ;
::v-deep .el-button--text {
  font-size: 14px;
  cursor: pointer;
}
.el-icon-share ,.el-icon-delete,.el-icon-edit-outline{
.el-icon-share, .el-icon-delete, .el-icon-edit-outline {
  color: $main_color;
  cursor: pointer;
}
.el-icon-edit-outline{
.el-icon-edit-outline {
  margin-right: 15px;
}
@@ -460,8 +553,8 @@
  background-color: #f8f8fa;
}
::v-deep .el-table__body .el-table__row.hover-row td{
  background-color: #eaecef ;
::v-deep .el-table__body .el-table__row.hover-row td {
  background-color: #eaecef;
}
::v-deep .el-form--inline .el-form-item__label {
@@ -482,7 +575,7 @@
  margin-bottom: 0;
}
::v-deep .el-select__caret{
::v-deep .el-select__caret {
  display: flex;
  align-items: center;
  justify-content: center;