zouyu
5 天以前 12c8999bab7206bc652fd69ac4f364d84c9e7153
src/views/business/unpass/index-manage.vue
@@ -4,39 +4,85 @@
      <div>
        <el-form :model="entity" ref="entity" size="small" :inline="true">
          <el-form-item label="IFS域" prop="contract">
            <el-select @keyup.enter.native="refreshTable" v-model="entity.contract" clearable placeholder="请选择" size="small">
              <el-option label="ZTNS" value="ZTNS"/>
              <el-option label="KJNS" value="KJNS"/>
            <el-select
              @keyup.enter.native="refreshTable"
              v-model="entity.contract"
              clearable
              placeholder="请选择"
              size="small"
            >
              <el-option label="ZTNS" value="ZTNS" />
              <el-option label="KJNS" value="KJNS" />
            </el-select>
          </el-form-item>
          <el-form-item label="批号" prop="updateBatchNo">
            <el-input v-model="entity.updateBatchNo" clearable placeholder="请输入" size="small"
                      @keyup.enter.native="refreshTable()">
            <el-input
              v-model="entity.updateBatchNo"
              clearable
              placeholder="请输入"
              size="small"
              @keyup.enter.native="refreshTable()"
            >
            </el-input>
          </el-form-item>
          <el-form-item label="订单编号" prop="no">
            <el-input size="small" placeholder="请输入" clearable v-model="entity.no"
                      @keyup.enter.native="refreshTable()"></el-input>
            <el-input
              size="small"
              placeholder="请输入"
              clearable
              v-model="entity.no"
              @keyup.enter.native="refreshTable()"
            ></el-input>
          </el-form-item>
          <el-form-item label="规格型号" prop="specsModels">
            <el-input size="small" placeholder="请输入" clearable v-model="entity.specsModels"
                      @keyup.enter.native="refreshTable()"></el-input>
            <el-input
              size="small"
              placeholder="请输入"
              clearable
              v-model="entity.specsModels"
              @keyup.enter.native="refreshTable()"
            ></el-input>
          </el-form-item>
          <el-form-item label="样品名称" prop="sample">
            <el-input size="small" placeholder="请输入" clearable v-model="entity.sample"
                      @keyup.enter.native="refreshTable()"></el-input>
            <el-input
              size="small"
              placeholder="请输入"
              clearable
              v-model="entity.sample"
              @keyup.enter.native="refreshTable()"
            ></el-input>
          </el-form-item>
          <el-form-item label="物料属性" prop="materialProp">
            <el-select clearable size="small" v-model="entity.materialProp" style="width: 100%" @change="refreshTable()">
              <el-option v-for="dict in dict.type.material_prop_type" :key="dict.value" :label="dict.label"
                         :value="dict.value">
            <el-select
              clearable
              size="small"
              v-model="entity.materialProp"
              style="width: 100%"
              @change="refreshTable()"
            >
              <el-option
                v-for="dict in dict.type.material_prop_type"
                :key="dict.value"
                :label="dict.label"
                :value="dict.value"
              >
              </el-option>
            </el-select>
          </el-form-item>
          <el-form-item label="OA审核状态" prop="operation">
            <el-select clearable size="small" v-model="entity.operation" style="width: 100%" @change="refreshTable()">
              <el-option v-for="dict in dict.type.oa_workflow_state" :key="dict.value" :label="dict.label"
                         :value="dict.value">
            <el-select
              clearable
              size="small"
              v-model="entity.operation"
              style="width: 100%"
              @change="refreshTable()"
            >
              <el-option
                v-for="dict in dict.type.oa_workflow_state"
                :key="dict.value"
                :label="dict.label"
                :value="dict.value"
              >
              </el-option>
            </el-select>
          </el-form-item>
@@ -49,26 +95,47 @@
              clearable
              value-format="yyyy-MM-dd"
              v-model="entity.feedbackDateTime"
              @keyup.enter.native="refreshTable()">
              @keyup.enter.native="refreshTable()"
            >
            </el-date-picker>
          </el-form-item>
          <el-form-item label="供应商名称" prop="supplierName">
            <el-input size="small" placeholder="请输入" clearable v-model="entity.supplierName"
                      @keyup.enter.native="refreshTable()"></el-input>
            <el-input
              size="small"
              placeholder="请输入"
              clearable
              v-model="entity.supplierName"
              @keyup.enter.native="refreshTable()"
            ></el-input>
          </el-form-item>
          <el-form-item>
            <el-button type="primary" size="mini" @click="refreshTable">查询</el-button>
            <el-button type="primary" size="mini" @click="refreshTable"
              >查询</el-button
            >
            <el-button size="mini" @click="refresh">重置</el-button>
            <el-button :loading="exportLoading" type="success" size="mini" @click="exportUnqualifiedHandler">导出</el-button>
            <el-button type="primary" size="mini" @click="openInsOrderDialog">新增不合格处理</el-button>
            <el-button
              :loading="exportLoading"
              type="success"
              size="mini"
              @click="exportUnqualifiedHandler"
              >导出</el-button
            >
            <el-button type="primary" size="mini" @click="openInsOrderDialog"
              >新增不合格处理</el-button
            >
          </el-form-item>
        </el-form>
      </div>
    </div>
    <div>
      <lims-table :tableData="tableData" :column="column"
                  :more="true" @pagination="pagination"
                  :page="page" :tableLoading="tableLoading"></lims-table>
      <lims-table
        :tableData="tableData"
        :column="column"
        :more="true"
        @pagination="pagination"
        :page="page"
        :tableLoading="tableLoading"
      ></lims-table>
    </div>
    <el-dialog
      title="提交"
@@ -76,24 +143,14 @@
      :close-on-press-escape="false"
      :close-on-click-modal="false"
      :visible.sync="dialogVisible"
      width="30%">
      width="30%"
    >
      <span>是否确认提交OA?</span>
      <span slot="footer" class="dialog-footer">
        <el-button @click="dialogVisible = false">取 消</el-button>
        <el-button type="primary" @click="submitOA" :loading="submitOALoading">确 定</el-button>
      </span>
    </el-dialog>
    <el-dialog
      title="删除"
      :show-close="false"
      :close-on-press-escape="false"
      :close-on-click-modal="false"
      :visible.sync="deleteVisible"
      width="30%">
      <span>是否确认<span style="color: #FF4902">删除</span>OA?</span>
      <span slot="footer" class="dialog-footer">
        <el-button @click="deleteVisible = false">取 消</el-button>
        <el-button type="primary" @click="cancelOA" :loading="cancelOALoading">确 定</el-button>
        <el-button type="primary" @click="submitOA" :loading="submitOALoading"
          >确 定</el-button
        >
      </span>
    </el-dialog>
    <el-dialog
@@ -102,408 +159,437 @@
      :close-on-click-modal="false"
      :visible.sync="insOrderVisible"
      @closed="resetInsOrderForm"
      width="50%">
      <el-row :gutter="20" style="margin-bottom:10px">
      @open="getListData"
      width="50%"
    >
      <el-row :gutter="20" style="margin-bottom: 10px">
        <el-col :span="12">
          <el-input clearable size="small" v-model="lotBatchNo" placeholder="请输入批次号"></el-input>
          <el-input
            clearable
            size="small"
            v-model="lotBatchNo"
            placeholder="请输入批次号"
          ></el-input>
        </el-col>
        <el-col :span="12">
          <el-button size="small" type="primary" @click="searchInsOrderList">搜索</el-button>
          <el-button size="small" type="primary" @click="searchInsOrderList"
            >搜索</el-button
          >
        </el-col>
      </el-row>
      <el-tabs v-model="activeName" @tab-click="searchInsOrderList">
        <el-tab-pane label="原材料下单" name="raw">
          <lims-table ref="rawInsOrderTable"
                      v-if="activeName==='raw'"
                      :tableData="insOrderDataList"
                      :column="insOrderTableDataColumn"
                      :isSelection="true"
                      :selectionSelectable="insOrderSelectable"
                      :handleSelectionChange="selectRawMethod"
                      :rowClassName="insOrderRowClassName"
                      @pagination="insOrderPageination"
                      :height="500"
                      :page="insOrderPage"
                      :tableLoading="insOrderTableLoading">
          <lims-table
            ref="rawInsOrderTable"
            v-if="activeName === 'raw'"
            :tableData="insOrderDataList"
            :column="insOrderTableDataColumn"
            :isSelection="true"
            :selectionSelectable="insOrderSelectable"
            :handleSelectionChange="handlerSelection"
            :rowClassName="insOrderRowClassName"
            @pagination="insOrderPageination"
            :height="500"
            :page="insOrderPage"
            :tableLoading="insOrderTableLoading"
          >
          </lims-table>
        </el-tab-pane>
        <el-tab-pane label="外购下单" name="wg">
          <lims-table ref="wgInsOrderTable"
                      v-if="activeName==='wg'"
                      :tableData="wgInsOrderDataList"
                      :column="wgInsOrderTableDataColumn"
                      :isSelection="true"
                      :selectionSelectable="insOrderSelectable"
                      :handleSelectionChange="selectWgMethod"
                      :rowClassName="insOrderRowClassName"
                      @pagination="wgInsOrderPageination"
                      :height="500"
                      :page="wgInsOrderPage"
                      :tableLoading="insOrderTableLoading">
          <lims-table
            ref="wgInsOrderTable"
            v-if="activeName === 'wg'"
            :tableData="wgInsOrderDataList"
            :column="wgInsOrderTableDataColumn"
            :isSelection="true"
            :selectionSelectable="insOrderSelectable"
            :handleSelectionChange="handlerSelection"
            :rowClassName="insOrderRowClassName"
            @pagination="wgInsOrderPageination"
            :height="500"
            :page="wgInsOrderPage"
            :tableLoading="insOrderTableLoading"
          >
          </lims-table>
        </el-tab-pane>
      </el-tabs>
      <span slot="footer" class="dialog-footer">
        <el-button @click="resetInsOrderForm">取 消</el-button>
        <el-button type="primary" @click="openAddUnqualifiedHandlerView">确 定</el-button>
        <el-button type="primary" @click="openAddUnqualifiedHandlerView"
          >确 定</el-button
        >
      </span>
    </el-dialog>
    <UnPassDialog ref="unPassDialog" v-if="unPassDialog"
                  :orderId="orderId"
                  @resetForm="resetForm1"
                  :unPassDialog="unPassDialog"></UnPassDialog>
    <OAProcess ref="OAProcess"
               :OAProcess="OAProcess"
               :isOldData="isOldData"
               @closeOAProcess="closeOAProcess"
               v-if="OAProcess"></OAProcess>
    <UnPassDialog
      ref="unPassDialog"
      v-if="unPassDialog"
      :selectOrderIds="selectOrderIds"
      @resetForm="resetForm1"
      :unPassDialog="unPassDialog"
    ></UnPassDialog>
    <OAProcess
      ref="OAProcess"
      :OAProcess="OAProcess"
      :isOldData="isOldData"
      @closeOAProcess="closeOAProcess"
      v-if="OAProcess"
    ></OAProcess>
  </div>
</template>
<script>
import {getIfsByAll} from "@/api/business/rawMaterialOrder";
import {  getIfsByAll as getIfsByWgAll } from "@/api/business/outsourcingFinishProductInspection";
import { getIfsByAll } from "@/api/business/rawMaterialOrder";
import { getIfsByAll as getIfsByWgAll } from "@/api/business/outsourcingFinishProductInspection";
import UnPassDialog from "./components/unPassDialog.vue";
import OAProcess from "./components/OAProcess.vue";
import limsTable from "@/components/Table/lims-table.vue";
import {deleteUnqualifiedHandler, page, pushOA,exportUnqualifiedHandler} from "@/api/business/unqualifiedHandler";
import {transformExcel} from '@/utils/file'
import {
  deleteUnqualifiedHandler,
  page,
  pushOA,
  exportUnqualifiedHandler,
  getList
} from "@/api/business/unqualifiedHandler";
import { transformExcel } from "@/utils/file";
export default {
  components: {
    limsTable,
    OAProcess,
    UnPassDialog,
  },
  dicts: ['material_prop_type','oa_workflow_state','categories_no_conformities','attribution_no_conformities'],
  dicts: [
    "material_prop_type",
    "oa_workflow_state",
    "categories_no_conformities",
    "attribution_no_conformities",
  ],
  data() {
    return {
      activeName: 'raw',
      lotBatchNo:null,
      insOrderVisible:false,
      insOrderTableLoading:false,
      insOrderDataList:[],
      insOrderTableDataColumn:[
      activeName: "raw",
      lotBatchNo: null,
      insOrderVisible: false,
      insOrderTableLoading: false,
      insOrderDataList: [],
      insOrderTableDataColumn: [
        {
          label: 'IFS域',
          prop: 'contract',
          width: '120px',
          dataType: 'tag',
          label: "IFS域",
          prop: "contract",
          width: "120px",
          dataType: "tag",
          formatData: (params) => {
            return params
            return params;
          },
          formatType: (params) => {
            if (params === 'ZTNS') {
              return ''
            } else if (params === 'KJNS') {
              return 'success'
            }else {
              return null
            if (params === "ZTNS") {
              return "";
            } else if (params === "KJNS") {
              return "success";
            } else {
              return null;
            }
          }
          },
        },
        { label: '委托编号', prop: 'entrustCode', width: "160px", },
        { label: "委托编号", prop: "entrustCode", width: "160px" },
        {
          dataType: 'tag',
          label: '检验状态',
          prop: 'inspectStatus',
          dataType: "tag",
          label: "检验状态",
          prop: "inspectStatus",
          formatData: (params) => {
            if (params == 0) {
              return '检验中'
              return "检验中";
            } else if (params == 1) {
              return '合格'
              return "合格";
            } else if (params == 2) {
              return '不合格'
              return "不合格";
            } else if (params == 3) {
              return '未下单'
              return "未下单";
            } else if (params == 4) {
              return '让步放行'
              return "让步放行";
            } else {
              return null
              return null;
            }
          },
          formatType: (params) => {
            if (params == 0) {
              return 'warning'
              return "warning";
            } else if (params == 1) {
              return 'success'
              return "success";
            } else if (params == 2) {
              return 'danger'
              return "danger";
            } else if (params == 3) {
              return 'info'
              return "info";
            } else if (params == 4) {
              return ''
              return "";
            } else {
              return null
              return null;
            }
          }
          },
        },
        { label: '订单号', prop: 'orderNo' },
        { label: '抵达的采购数量', prop: 'purQtyInStore' ,width:'160' },
        { label: '下发时间', prop: 'sendTime',width:'160' },
        { label: '批号', prop: 'updateBatchNo',width:'160' },
        { label: '零件号', prop: 'partNo',width:'140' },
        { label: '零件描述', prop: 'partDesc' },
        { label: '供应商编码', prop: 'supplierId',width:'140' },
        { label: '供应商名称', prop: 'supplierName',width:'140' },
        { label: "订单号", prop: "orderNo" },
        { label: "抵达的采购数量", prop: "purQtyInStore", width: "160" },
        { label: "下发时间", prop: "sendTime", width: "160" },
        { label: "批号", prop: "updateBatchNo", width: "160" },
        { label: "零件号", prop: "partNo", width: "140" },
        { label: "零件描述", prop: "partDesc" },
        { label: "供应商编码", prop: "supplierId", width: "140" },
        { label: "供应商名称", prop: "supplierName", width: "140" },
        {
          dataType: 'tag',
          label: '免检',
          prop: 'isExemption',
          dataType: "tag",
          label: "免检",
          prop: "isExemption",
          formatData: (params) => {
            if (params == 1) {
              return '免检'
              return "免检";
            } else {
              return null
              return null;
            }
          },
          formatType: (params) => {
            if (params == 1) {
              return 'success'
              return "success";
            } else {
              return null
            }
          }
        },
        {
          label: '样品名称',
          prop: 'sampleName',
          width: "160px"
        },
        { label: '样品型号', prop: 'sampleModel' },
        { label: '检验人', prop: 'userName' },
        {
          label: '物料属性',
          prop: 'materialProp',
          formatData: (params) => {
            if (!params) return null
            for (let i = 0; i < this.dict.type.material_prop_type.length; i++) {
              const item = this.dict.type.material_prop_type[i]
              if (item.value == params) {
                return item.label
              }
            }
            return null
          }
        },
        {
          dataType: 'tag',
          label: '物料类型',
          prop: 'isExpire',
          formatData: (params) => {
            if (params == 1) {
              return '过期物料'
            } else {
              return null
              return null;
            }
          },
          formatType: (params) => {
            if (params == 1) {
              return 'info'
            } else {
              return null
            }
          }
        },
        { label: '单位', prop: 'buyUnitMeas' },
        { label: '接收时间', prop: 'receiverDate',width:'160' },
        { label: '报检时间', prop: 'declareDate',width:'160' },
      ],
      insOrderPage:{
        total: 0,
        size: 20,
        current: 1
      },
      wgInsOrderTableDataColumn:[
        {
          label: 'IFS域',
          prop: 'contract',
          width: '120px',
          dataType: 'tag',
          formatData: (params) => {
            return params
          },
          formatType: (params) => {
            if (params === 'ZTNS') {
              return ''
            } else if (params === 'KJNS') {
              return 'success'
            }else {
              return null
            }
          }
        },
        { label: '委托编号', prop: 'entrustCode', width: "160px", },
        {
          dataType: 'tag',
          label: '检验状态',
          prop: 'inspectStatus',
          formatData: (params) => {
            if (params == 0) {
              return '检验中'
            } else if (params == 1) {
              return '合格'
            } else if (params == 2) {
              return '不合格'
            } else if (params == 3) {
              return '未下单'
            } else if (params == 4) {
              return '让步放行'
            } else {
              return null
            }
          },
          formatType: (params) => {
            if (params == 0) {
              return 'warning'
            } else if (params == 1) {
              return 'success'
            } else if (params == 2) {
              return 'danger'
            } else if (params == 3) {
              return 'info'
            } else if (params == 4) {
              return ''
            } else {
              return null
            }
          }
        },
        { label: '订单号', prop: 'orderNo' },
        { label: '抵达的采购数量', prop: 'purQtyInStore', width: '130px' },
        { label: '下发时间', prop: 'sendTime', width: '130px' },
        { label: '批号', prop: 'updateBatchNo', width: '130px' },
        { label: '零件号', prop: 'partNo', width: '140px' },
        { label: '零件描述', prop: 'partDesc' },
        { label: '供应商名称', prop: 'supplierName' },
        {
          dataType: 'tag',
          label: '免检',
          prop: 'isExemption',
          formatData: (params) => {
            if (params == 1) {
              return '免检'
            } else {
              return null
            }
          },
          formatType: (params) => {
            if (params == 1) {
              return 'success'
            } else {
              return null
            }
          }
        },
        {
          label: '样品名称',
          prop: 'sampleName',
          label: "样品名称",
          prop: "sampleName",
          width: "160px",
        },
        { label: '样品型号', prop: 'sampleModel' },
        { label: '检验人', prop: 'userName' },
        { label: "样品型号", prop: "sampleModel" },
        { label: "检验人", prop: "userName" },
        {
          label: '物料属性',
          prop: 'materialProp',
          label: "物料属性",
          prop: "materialProp",
          formatData: (params) => {
            if (!params) return null
            if (!params) return null;
            for (let i = 0; i < this.dict.type.material_prop_type.length; i++) {
              const item = this.dict.type.material_prop_type[i]
              const item = this.dict.type.material_prop_type[i];
              if (item.value == params) {
                return item.label
                return item.label;
              }
            }
            return null
          }
            return null;
          },
        },
        {
          dataType: 'tag',
          label: '物料类型',
          prop: 'isExpire',
          dataType: "tag",
          label: "物料类型",
          prop: "isExpire",
          formatData: (params) => {
            if (params == 1) {
              return '过期物料'
              return "过期物料";
            } else {
              return null
              return null;
            }
          },
          formatType: (params) => {
            if (params == 1) {
              return 'info'
              return "info";
            } else {
              return null
              return null;
            }
          }
          },
        },
        { label: '单位', prop: 'buyUnitMeas' },
        { label: '接收时间', prop: 'receiverDate' },
        { label: '报检时间', prop: 'declareDate' },
        { label: "单位", prop: "buyUnitMeas" },
        { label: "接收时间", prop: "receiverDate", width: "160" },
        { label: "报检时间", prop: "declareDate", width: "160" },
      ],
      wgInsOrderPage:{
      insOrderPage: {
        total: 0,
        size: 20,
        current: 1
        current: 1,
      },
      wgInsOrderTableLoading:false,
      wgInsOrderDataList:[],
      wgInsOrderTableDataColumn: [
        {
          label: "IFS域",
          prop: "contract",
          width: "120px",
          dataType: "tag",
          formatData: (params) => {
            return params;
          },
          formatType: (params) => {
            if (params === "ZTNS") {
              return "";
            } else if (params === "KJNS") {
              return "success";
            } else {
              return null;
            }
          },
        },
        { label: "委托编号", prop: "entrustCode", width: "160px" },
        {
          dataType: "tag",
          label: "检验状态",
          prop: "inspectStatus",
          formatData: (params) => {
            if (params == 0) {
              return "检验中";
            } else if (params == 1) {
              return "合格";
            } else if (params == 2) {
              return "不合格";
            } else if (params == 3) {
              return "未下单";
            } else if (params == 4) {
              return "让步放行";
            } else {
              return null;
            }
          },
          formatType: (params) => {
            if (params == 0) {
              return "warning";
            } else if (params == 1) {
              return "success";
            } else if (params == 2) {
              return "danger";
            } else if (params == 3) {
              return "info";
            } else if (params == 4) {
              return "";
            } else {
              return null;
            }
          },
        },
        { label: "订单号", prop: "orderNo" },
        { label: "抵达的采购数量", prop: "purQtyInStore", width: "130px" },
        { label: "下发时间", prop: "sendTime", width: "130px" },
        { label: "批号", prop: "updateBatchNo", width: "130px" },
        { label: "零件号", prop: "partNo", width: "140px" },
        { label: "零件描述", prop: "partDesc" },
        { label: "供应商名称", prop: "supplierName" },
        {
          dataType: "tag",
          label: "免检",
          prop: "isExemption",
          formatData: (params) => {
            if (params == 1) {
              return "免检";
            } else {
              return null;
            }
          },
          formatType: (params) => {
            if (params == 1) {
              return "success";
            } else {
              return null;
            }
          },
        },
        {
          label: "样品名称",
          prop: "sampleName",
          width: "160px",
        },
        { label: "样品型号", prop: "sampleModel" },
        { label: "检验人", prop: "userName" },
        {
          label: "物料属性",
          prop: "materialProp",
          formatData: (params) => {
            if (!params) return null;
            for (let i = 0; i < this.dict.type.material_prop_type.length; i++) {
              const item = this.dict.type.material_prop_type[i];
              if (item.value == params) {
                return item.label;
              }
            }
            return null;
          },
        },
        {
          dataType: "tag",
          label: "物料类型",
          prop: "isExpire",
          formatData: (params) => {
            if (params == 1) {
              return "过期物料";
            } else {
              return null;
            }
          },
          formatType: (params) => {
            if (params == 1) {
              return "info";
            } else {
              return null;
            }
          },
        },
        { label: "单位", prop: "buyUnitMeas" },
        { label: "接收时间", prop: "receiverDate" },
        { label: "报检时间", prop: "declareDate" },
      ],
      wgInsOrderPage: {
        total: 0,
        size: 20,
        current: 1,
      },
      wgInsOrderTableLoading: false,
      wgInsOrderDataList: [],
      handlerId: null,
      contract:null,
      contract: null,
      groupId: null,
      entity: {
        contract: null,
        sample: null,
        specsModels: null,
        supplierName: null,
        feedbackDateTime:[],
        feedbackDateTime: [],
        materialProp: null,
        operation:null
        operation: null,
      },
      tableData: [],
      tableLoading: false,
      column: [
        {
          label: 'IFS域',
          prop: 'contract',
          width: '80px',
          dataType: 'tag',
          label: "IFS域",
          prop: "contract",
          width: "80px",
          dataType: "tag",
          formatData: (params) => {
            return params
            return params;
          },
          formatType: (params) => {
            if (params === 'ZTNS') {
              return ''
            } else if (params === 'KJNS') {
              return 'success'
            }else {
              return null
            if (params === "ZTNS") {
              return "";
            } else if (params === "KJNS") {
              return "success";
            } else {
              return null;
            }
          }
          },
        },
        { label: '编号', prop: 'no', width: "160px", },
        { label: "编号", prop: "no", width: "160px" },
        {
          label: "OA审核状态",
          prop: "operation",
          width: "100px",
          dataType: "tag",
          formatData: (params) => {
            return params
            return params;
          },
          formatType: (params) => {
            if(params){
              this.dict.type.oa_workflow_state.forEach(item => {
                if(item.value === params){
                  params = item.raw.listClass
            if (params) {
              this.dict.type.oa_workflow_state.forEach((item) => {
                if (item.value === params) {
                  params = item.raw.listClass;
                }
              });
            }
            return params
            return params;
          },
        },
        { label: '订单号', prop: 'orderNo' },
        { label: "订单号", prop: "orderNo" },
        {
          label: "零件号",
          prop: "partNo",
@@ -511,388 +597,390 @@
          dataType: "link",
          linkMethod: "openUnPassDialog",
        },
        { label: '零件描述', prop: 'partDesc',width: "160px" },
        { label: "零件描述", prop: "partDesc", width: "160px" },
        {
          label: '物料属性',
          prop: 'materialProp',
          label: "物料属性",
          prop: "materialProp",
          formatData: (params) => {
            if (!params) return null
            if (!params) return null;
            for (let i = 0; i < this.dict.type.material_prop_type.length; i++) {
              const item = this.dict.type.material_prop_type[i]
              const item = this.dict.type.material_prop_type[i];
              if (item.value == params) {
                return item.label
                return item.label;
              }
            }
            return null
          }
            return null;
          },
        },
        { label: '物料名称', prop: 'materialName',width: "160px" },
        { label: '生产批次', prop: 'productionBatch',width: "160px" },
        { label: '到货数量', prop: 'cargoQuantity' },
        { label: '规格型号', prop: 'specsModels',width:'140' },
        { label: '报检日期', prop: 'inspectTime',width:'120' },
        { label: '状态', prop: 'statusDB' },
        { label: '反馈人', prop: 'feedbackUser' },
        { label: '要检验的采购数量', prop: 'qtyToInspect',width: "140px" },
        { label: '反馈日期', prop: 'feedbackTime',width: "100px" },
        { label: "物料名称", prop: "materialName", width: "160px" },
        { label: "生产批次", prop: "productionBatch", width: "160px" },
        { label: "到货数量",prop: "cargoQuantity"},
        { label: "采购单位",prop: "buyUnitMeas"},
        { label: "规格型号", prop: "specsModels", width: "140" },
        { label: "报检日期", prop: "inspectTime", width: "120" },
        { label: "状态", prop: "statusDB" },
        { label: "反馈人", prop: "feedbackUser" },
        { label: "要检验的采购数量", prop: "qtyToInspect", width: "140px" },
        { label: "反馈日期", prop: "feedbackTime", width: "100px" },
        {
          label: "分类",
          prop: "classification",
          width: "100px",
          dataType: "tag",
          formatData: (params) => {
            let label = null
            this.dict.type.categories_no_conformities.forEach(item=>{
              if(item.raw.dictValue==params){
                label = item.raw.dictLabel
            let label = null;
            this.dict.type.categories_no_conformities.forEach((item) => {
              if (item.raw.dictValue == params) {
                label = item.raw.dictLabel;
              }
            })
            return label
            });
            return label;
          },
          formatType: (params) => {
            let type = null
            this.dict.type.categories_no_conformities.forEach(item=>{
              if(item.raw.dictValue==params){
                type =  item.raw.listClass
            let type = null;
            this.dict.type.categories_no_conformities.forEach((item) => {
              if (item.raw.dictValue == params) {
                type = item.raw.listClass;
              }
            })
            return type
            });
            return type;
          },
        },
        { label: '供应商编码', prop: 'supplierId',width:'140' },
        { label: '供应商名称', prop: 'supplierName',width:'140' },
        { label: "供应商编码", prop: "supplierId", width: "140" },
        { label: "供应商名称", prop: "supplierName", width: "140" },
        {
          label: "不合格归属",
          prop: "offGradeAscription",
          width: "120px",
          dataType: "tag",
          formatData: (params) => {
            let label = params
            this.dict.type.attribution_no_conformities.forEach(item=>{
              if(item.raw.dictValue==params){
                label = item.raw.dictLabel
            let label = params;
            this.dict.type.attribution_no_conformities.forEach((item) => {
              if (item.raw.dictValue == params) {
                label = item.raw.dictLabel;
              }
            })
            return label
            });
            return label;
          },
          formatType: (params) => {
            let type = null
            this.dict.type.attribution_no_conformities.forEach(item=>{
              if(item.raw.dictValue==params){
                type = item.raw.listClass
            let type = null;
            this.dict.type.attribution_no_conformities.forEach((item) => {
              if (item.raw.dictValue == params) {
                type = item.raw.listClass;
              }
            })
            return type
            });
            return type;
          },
        },
        { label: '不合格描述', prop: 'unqualifiedDesc',width: "160px" },
        { label: "不合格描述", prop: "unqualifiedDesc", width: "160px" },
        {
          dataType: 'action',
          fixed: 'right',
          label: '操作',
          width: '220px',
          dataType: "action",
          fixed: "right",
          label: "操作",
          prop:'groupId',
          mergeCol:true,
          width: "220px",
          operation: [
            {
              name: (row)=>{
                return row.requestId !== null && row.operation==='退回' ? '重新提交' : '提交OA'
              name: (row) => {
                return row.requestId !== null && row.operation === "退回"
                  ? "重新提交"
                  : "提交OA";
              },
              type: 'text',
              type: "text",
              clickFun: (row) => {
                this.openOA(row);
              },
              disabled: (row, index) => {
                return row.requestId !== null && row.operation!=='退回'  // 有requestId说明已经提交过OA,不可再次提交
              }
                return row.requestId !== null && row.operation !== "退回"; // 有requestId说明已经提交过OA,不可再次提交
              },
            },
            {
              name: '查看OA流程',
              type: 'text',
              name: "查看OA流程",
              type: "text",
              clickFun: (row) => {
                this.OAView(row);
              },
            },
            {
              name: '删除',
              type: 'text',
              name: "删除",
              type: "text",
              clickFun: (row) => {
                this.deleteOA(row);
              },
              disabled: (row, index) => {
                return row.requestId !== null && row.operation!=='退回'  // 有requestId说明已经提交过OA,不可再次提交
              }
                return row.requestId !== null && row.operation !== "退回"; // 有requestId说明已经提交过OA,不可再次提交
              },
            },
          ]
        }
          ],
        },
      ],
      page: {
        total: 0,
        size: 20,
        current: 1
        current: 1,
      },
      statusList: [],
      dialogVisible: false, // 确认提交OA弹框
      unPassDialog: false, // 不合格处理弹框
      orderId: '',
      selectOrderIds: [],
      multipleSelection: [],
      OAProcess: false, // OA流程弹框
      submitOALoading: false, // OA流程弹框提交按钮loading
      deleteVisible: false, // OA流程删除弹框
      cancelOALoading: false, // OA流程删除弹框提交按钮loading
      exportLoading:false,
      isOldData: true,//是否是旧数据
      exportLoading: false,
      isOldData: true, //是否是旧数据
      insOrderIds: [],
      rowColSplitNodes: [],
    };
  },
  mounted() {
    this.refreshTable()
    this.refreshTable();
  },
  methods: {
    getInsOrderRowId(row) {
      if (!row) {
        return ''
      }
      const currentId = row.enterOrderId || row.insOrderId || row.orderId || row.id
      return currentId ? String(currentId) : ''
    },
    getExistingInsOrderIds() {
      const ids = new Set()
      this.tableData.forEach(row => {
        ['insOrderId'].forEach(key => {
          if (row[key] !== undefined && row[key] !== null && row[key] !== '') {
            ids.add(String(row[key]))
          }
        })
    getListData(){
      getList().then(res => {
        this.insOrderIds = [];
        if(res.code === 200){
          this.insOrderIds = res.data;
        }
      }).catch(err => {
        console.error(err)
      })
      return ids
    },
    isDisabledInsOrderRow(row) {
      const currentId = this.getInsOrderRowId(row)
      if (!currentId) {
        return false
      }
      return this.getExistingInsOrderIds().has(currentId)
    },
    insOrderSelectable(row) {
      return !this.isDisabledInsOrderRow(row)
      const existsInMain = this.insOrderIds.some(
        (id) => id === row.enterOrderId
      );
      return !existsInMain;
    },
    insOrderRowClassName({ row }) {
      return this.isDisabledInsOrderRow(row) ? 'disabled-selection-row' : ''
      const existsInMain = this.insOrderIds.some(
        (id) => id === row.enterOrderId
      );
      return existsInMain ? "disabled-selection-row" : "";
    },
    resetInsOrderForm(){
      this.activeName = 'raw'
      this.insOrderDataList = []
      this.wgInsOrderDataList = []
      this.lotBatchNo = null
      this.orderId = ''
    resetInsOrderForm() {
      this.activeName = "raw";
      this.insOrderDataList = [];
      this.wgInsOrderDataList = [];
      this.lotBatchNo = null;
      this.multipleSelection = [];
      this.insOrderPage = {
        total: 0,
        size: 20,
        current: 1,
      }
      };
      this.wgInsOrderPage = {
        total: 0,
        size: 20,
        current: 1,
      }
      this.$nextTick(()=>{
        this.insOrderVisible = false
      })
      };
      this.$nextTick(() => {
        this.insOrderVisible = false;
      });
    },
    openInsOrderDialog(){
      this.insOrderVisible = true
    openInsOrderDialog() {
      this.insOrderVisible = true;
    },
    searchInsOrderList(){
      this.insOrderTableLoading = true
    searchInsOrderList() {
      this.multipleSelection = [];
      this.insOrderTableLoading = true;
      const params = {
        updateBatchNo: this.lotBatchNo,
        isInspect: 1,
      }
      if(this.activeName==='raw'){
        getIfsByAll({...params,...this.insOrderPage}).then(res => {
          this.insOrderTableLoading = false
          if (res.code === 200) {
            this.insOrderDataList = res.data.records
            this.insOrderPage.total = res.data.total
          }
        }).catch(err => {
          this.insOrderTableLoading = false
        })
      }else if(this.activeName==='wg'){
        getIfsByWgAll({...params,...this.wgInsOrderPage}).then(res => {
          this.insOrderTableLoading = false
          if (res.code === 200) {
            this.wgInsOrderDataList = res.data.records
            this.wgInsOrderPage.total = res.data.total
          }
        }).catch(err => {
          this.insOrderTableLoading = false
        })
      };
      if (this.activeName === "raw") {
        getIfsByAll({ ...params, ...this.insOrderPage })
          .then((res) => {
            this.insOrderTableLoading = false;
            if (res.code === 200) {
              this.insOrderDataList = res.data.records;
              this.insOrderPage.total = res.data.total;
            }
          })
          .catch((err) => {
            this.insOrderTableLoading = false;
          });
      } else if (this.activeName === "wg") {
        getIfsByWgAll({ ...params, ...this.wgInsOrderPage })
          .then((res) => {
            this.insOrderTableLoading = false;
            if (res.code === 200) {
              this.wgInsOrderDataList = res.data.records;
              this.wgInsOrderPage.total = res.data.total;
            }
          })
          .catch((err) => {
            this.insOrderTableLoading = false;
          });
      }
    },
    insOrderPageination(page){
      this.insOrderPage.size = page.limit
      this.searchInsOrderList()
    insOrderPageination(page) {
      this.insOrderPage.size = page.limit;
      this.searchInsOrderList();
    },
    wgInsOrderPageination(page){
      this.wgInsOrderPage.size = page.limit
      this.searchInsOrderList()
    wgInsOrderPageination(page) {
      this.wgInsOrderPage.size = page.limit;
      this.searchInsOrderList();
    },
    selectRawMethod(val){
    handlerSelection(val) {
      if (!val || val.length === 0) {
        this.orderId = ''
        return
      }
      const currentRow = val[val.length - 1]
      this.orderId = this.getInsOrderRowId(currentRow)
      if (val.length > 1 && this.$refs.rawInsOrderTable && this.$refs.rawInsOrderTable.$refs.multipleTable) {
        this.$refs.rawInsOrderTable.$refs.multipleTable.clearSelection()
        this.$refs.rawInsOrderTable.$refs.multipleTable.toggleRowSelection(currentRow, true)
      }
    },
    selectWgMethod(val){
      if (!val || val.length === 0) {
        this.orderId = ''
        return
      }
      const currentRow = val[val.length - 1]
      this.orderId = this.getInsOrderRowId(currentRow)
      if (val.length > 1 && this.$refs.wgInsOrderTable && this.$refs.wgInsOrderTable.$refs.multipleTable) {
        this.$refs.wgInsOrderTable.$refs.multipleTable.clearSelection()
        this.$refs.wgInsOrderTable.$refs.multipleTable.toggleRowSelection(currentRow, true)
      }
    },
    //打开新增不合格处理弹框
    openAddUnqualifiedHandlerView(){
      if(!this.orderId){
        this.$message.warning("请选择一条订单记录")
        this.multipleSelection = [];
        return;
      }
      this.multipleSelection = val
    },
    //打开新增不合格处理弹框
    openAddUnqualifiedHandlerView() {
      if (!this.multipleSelection || this.multipleSelection.length === 0) {
        this.$message.warning("请至少选择一条订单记录");
        return;
      }
      const contracts = [...new Set(this.multipleSelection.map(item=>{return item.contract}))]
      if(contracts && contracts.length>1){
        this.$message.warning("请选择相同IFS域的订单");
        return;
      }
      const partNos = [...new Set(this.multipleSelection.map(item=>{return item.partNo}))]
      if(partNos && partNos.length>1){
        this.$message.warning("请选择相同零件的订单");
        return;
      }
      this.selectOrderIds = this.multipleSelection.map(item=>{return item.enterOrderId})
      this.insOrderVisible = false
      this.unPassDialog = true;
      this.$nextTick(() => {
        this.$refs.unPassDialog.getInsOrder('add');
        this.$refs.unPassDialog.getInsOrder("add");
      });
    },
    exportUnqualifiedHandler(){
      this.exportLoading = true
      const newEntity = { ...this.entity }
    exportUnqualifiedHandler() {
      this.exportLoading = true;
      const newEntity = { ...this.entity };
      if (newEntity.feedbackDateTime && newEntity.feedbackDateTime.length > 0) {
        newEntity.feedbackStartTime = newEntity.feedbackDateTime[0]
        newEntity.feedbackEndTime = newEntity.feedbackDateTime[1]
        newEntity.feedbackStartTime = newEntity.feedbackDateTime[0];
        newEntity.feedbackEndTime = newEntity.feedbackDateTime[1];
      }
      exportUnqualifiedHandler({...newEntity}).then(res=>{
        transformExcel(res,'不合格处理记录.xlsx')
        this.exportLoading = false
      }).catch(error=>{
        console.error(error)
      })
      exportUnqualifiedHandler({ ...newEntity })
        .then((res) => {
          transformExcel(res, "不合格处理记录.xlsx");
          this.exportLoading = false;
        })
        .catch((error) => {
          console.error(error);
        });
    },
    refreshTable() {
      this.tableLoading = true
      const newEntity = { ...this.entity }
      this.tableLoading = true;
      const newEntity = { ...this.entity };
      if (newEntity.feedbackDateTime && newEntity.feedbackDateTime.length > 0) {
        newEntity.feedbackStartTime = newEntity.feedbackDateTime[0]
        newEntity.feedbackEndTime = newEntity.feedbackDateTime[1]
        newEntity.feedbackStartTime = newEntity.feedbackDateTime[0];
        newEntity.feedbackEndTime = newEntity.feedbackDateTime[1];
      }
      page({ ...this.page, ...newEntity }).then(res => {
        this.tableLoading = false
        this.tableData = res.data.records
        this.page.total = res.data.total
      }).catch(err => {
        this.tableLoading = false
      })
      page({ ...this.page, ...newEntity })
        .then((res) => {
          this.tableLoading = false;
          this.tableData = res.data.records;
          this.page.total = res.data.total;
        })
        .catch((err) => {
          this.tableLoading = false;
        });
    },
    // 重置
    refresh() {
      this.resetForm('entity')
      this.refreshTable()
      this.resetForm("entity");
      this.refreshTable();
    },
    // 分页切换
    pagination(page) {
      this.page.size = page.limit
      this.refreshTable()
      this.page.size = page.limit;
      this.refreshTable();
    },
    // 打开不合格处理弹框
    openUnPassDialog (row) {
      this.unPassDialog = true
    openUnPassDialog(row) {
      this.unPassDialog = true;
      this.$nextTick(() => {
        this.$refs.unPassDialog.getInsOrder('view', row)
      })
    },
    // 关闭不合格处理弹框
    resetForm1 () {
      this.$refs.unPassDialog.$refs['unPassForm'].resetFields();
      this.unPassDialog = false
      this.$nextTick(()=>{
        this.refreshTable('page')
      })
    },
    // 打开删除OA确认弹框
    deleteOA (row) {
      this.handlerId = row.handlerId
      this.deleteVisible = true
    },
    // 提交删除申请
    cancelOA () {
      this.de = true
      deleteUnqualifiedHandler({id: this.handlerId,}).then(res => {
        this.cancelOALoading = false
        if (res.code === 200) {
          this.deleteVisible = false
          this.$message.success('删除成功')
          this.refreshTable('page')
        }
      }).catch(error => {
        this.cancelOALoading = false
        console.error(error);
        this.$refs.unPassDialog.getInsOrder("view", row);
      });
    },
    // 关闭不合格处理弹框
    resetForm1() {
      this.$refs.unPassDialog.$refs["unPassForm"].resetFields();
      this.unPassDialog = false;
      this.$nextTick(() => {
        this.refreshTable("page");
      });
    },
    // 删除OA确认弹框
    deleteOA(row) {
      this.$confirm('是否确认删除当前OA流程?', '提示', {
        confirmButtonText: '确定',
        cancelButtonText: '取消',
        type: 'warning'
      }).then(() => {
        deleteUnqualifiedHandler({ groupId: row.groupId })
          .then((res) => {
            if (res.code === 200) {
              this.$message.success("删除成功");
              this.refreshTable("page");
            }
          })
          .catch((error) => {
            console.error(error);
          });
      }).catch(() => { });
    },
    // 查看提交OA的数据
    openOA (row) {
      this.handlerId = row.handlerId
      this.contract = row.contract
      if(row && row.requestId !== null  ){
    openOA(row) {
      this.handlerId = row.handlerId;
      this.contract = row.contract;
      this.groupId = row.groupId;
      if (row && row.requestId !== null) {
        // 重新提交OA,打开编辑弹框
        this.unPassDialog = true
        this.unPassDialog = true;
        this.$nextTick(() => {
          this.$refs.unPassDialog.getInsOrder('resubmit', row)
        })
      }else{
        this.dialogVisible = true
          this.$refs.unPassDialog.getInsOrder("resubmit", row);
        });
      } else {
        this.dialogVisible = true;
      }
    },
    // 查看OA流程
    OAView (row) {
      this.OAProcess = true
      this.isOldData = row.isOldData
    OAView(row) {
      this.OAProcess = true;
      this.isOldData = row.isOldData;
      this.$nextTick(() => {
        this.$refs.OAProcess.getInfo(row.handlerId,row?row.unqualifiedDesc:"")
      })
        this.$refs.OAProcess.getInfo(
          row.handlerId,
          row ? row.unqualifiedDesc : "",
          row.classification
        );
      });
    },
    // 关闭查看OA流程的弹框
    closeOAProcess () {
      this.OAProcess = false
    closeOAProcess() {
      this.OAProcess = false;
    },
    //提交OA
    submitOA(row) {
      // 提交OA
      this.submitOALoading = true
      pushOA({handlerId: this.handlerId,contract:this.contract}).then(res => {
        this.submitOALoading = false
        if (res.code === 200) {
          this.dialogVisible = false
          this.$message.success('提交成功')
          this.refreshTable('page')
        }
      }).catch(error => {
        this.submitOALoading = false
        console.error(error);
      });
    }
  }
      this.submitOALoading = true;
      pushOA({ handlerId: this.handlerId, contract: this.contract,groupId: this.groupId })
        .then((res) => {
          this.submitOALoading = false;
          if (res.code === 200) {
            this.dialogVisible = false;
            this.$message.success("提交成功");
            this.refreshTable("page");
          }
        })
        .catch((error) => {
          this.submitOALoading = false;
          console.error(error);
        });
    },
  },
};
</script>