spring
2025-03-17 2bfe437d8b30fb7d80a38875b00ebf2b222ea05f
src/views/structural/capabilityAndLaboratory/capability/index.vue
@@ -9,11 +9,9 @@
          </el-radio-group>
        </el-col>
        <el-col :span="12" style="text-align: right;">
          <el-upload v-if="radio === 0" ref='upload1'
                     style="display: inline;margin-right: 8px"
                     :action="uploadAction1"
                     :before-upload="beforeUpload1" :headers="token" :on-error="onError1"
                     :on-success="handleSuccessUp1" :show-file-list="false" accept='.doc,.docx,.xls,.xlsx'>
          <el-upload v-if="radio === 0" ref='upload1' style="display: inline;margin-right: 8px" :action="uploadAction1"
            :before-upload="beforeUpload1" :headers="token" :on-error="onError1" :on-success="handleSuccessUp1"
            :show-file-list="false" accept='.doc,.docx,.xls,.xlsx'>
            <el-button size="small" type="primary">导入</el-button>
          </el-upload>
          <el-button size="small" type="primary" v-if="radio === 1" @click="uploadDia = true">导入</el-button>
@@ -24,18 +22,18 @@
    <div>
      <el-form :model="itemParameterForm" ref="itemParameterForm" size="small" :inline="true">
        <el-form-item label="检验项" prop="inspectionItem" v-if="radio===0">
          <el-input size="small" placeholder="请输入" clearable
                    v-model="itemParameterForm.inspectionItem" @keyup.enter.native="refreshTable()">
          <el-input size="small" placeholder="请输入" clearable v-model="itemParameterForm.inspectionItem"
            @keyup.enter.native="refreshTable()">
          </el-input>
        </el-form-item>
        <el-form-item label="检验子项" prop="inspectionItemSubclass" v-if="radio===0">
          <el-input size="small" placeholder="请输入" clearable
                    v-model="itemParameterForm.inspectionItemSubclass" @keyup.enter.native="refreshTable()">
          <el-input size="small" placeholder="请输入" clearable v-model="itemParameterForm.inspectionItemSubclass"
            @keyup.enter.native="refreshTable()">
          </el-input>
        </el-form-item>
        <el-form-item label="检验对象" prop="sample">
          <el-input size="small" placeholder="请输入" clearable
                    v-model="itemParameterForm.sample" @keyup.enter.native="refreshTable()">
          <el-input size="small" placeholder="请输入" clearable v-model="itemParameterForm.sample"
            @keyup.enter.native="refreshTable()">
          </el-input>
        </el-form-item>
        <el-form-item>
@@ -45,21 +43,19 @@
      </el-form>
<!--      检验项目参数表格-->
      <div class="table" v-if="radio===0">
        <lims-table :tableData="tableData" :column="column" key="tableData"
                    @pagination="pagination" :height="'calc(100vh - 290px)'"
                    :page="page" :tableLoading="tableLoading"></lims-table>
        <lims-table :tableData="tableData" :column="column" key="tableData" @pagination="pagination"
          :height="'calc(100vh - 290px)'" :page="page" :tableLoading="tableLoading"></lims-table>
      </div>
<!--      检验对象表格-->
      <div class="table" v-if="radio===1">
        <lims-table :tableData="testObjectTableData" :column="testObjectColumn" key="testObjectTableData"
                    @pagination="pagination" :height="'calc(100vh - 290px)'"
                    :page="testObjectPage" :tableLoading="tableLoading"></lims-table>
          @pagination="pagination" :height="'calc(100vh - 290px)'" :page="testObjectPage"
          :tableLoading="tableLoading"></lims-table>
      </div>
    </div>
    <!--产品维护弹框-->
    <el-dialog title="产品维护" :visible.sync="diaProduct" width="900px">
      <lims-table :tableData="productData" :column="productColumn" height="460"
                  @pagination="productPagination"
      <lims-table :tableData="productData" :column="productColumn" height="460" @pagination="productPagination"
                  :page="productPage" :tableLoading="productableLoading"></lims-table>
      <span slot="footer" class="dialog-footer">
        <el-button @click="diaProduct = false">取 消</el-button>
@@ -68,7 +64,8 @@
    </el-dialog>
    <!--产品维护编辑-->
    <el-dialog title="操作产品维护" :visible.sync="productEditDia" width="400px">
      <el-form :model="productEditForm" ref="productEditForm" :rules="productRules" label-position="right" label-width="100px">
      <el-form :model="productEditForm" ref="productEditForm" :rules="productRules" label-position="right"
        label-width="100px">
        <el-form-item label="产品名称" prop="name">
          <el-input size="small" placeholder="请输入" clearable v-model="productEditForm.name"></el-input>
        </el-form-item>
@@ -84,10 +81,8 @@
    </el-dialog>
    <el-dialog :visible.sync="uploadDia" title="数据导入" width="500px">
      <div style="margin: 0 auto;">
        <el-upload ref="upload" :action="uploadAction"
                   :auto-upload="false" :file-list="fileList"
                   :headers="token" :limit="1"
                   :on-change="beforeUpload" :on-error="onError" :on-success="onSuccess" accept=".xlsx" drag
        <el-upload ref="upload" :action="uploadAction" :auto-upload="false" :file-list="fileList" :headers="token"
          :limit="1" :on-change="beforeUpload" :on-error="onError" :on-success="onSuccess" accept=".xlsx" drag
                   name="file">
          <i class="el-icon-upload"></i>
          <div class="el-upload__text">将文件拖到此处,或<em>点击上传</em></div>
@@ -101,14 +96,26 @@
    <!--检验项目参数-编辑弹框-->
    <EditForm ref="editForm" @refreshList="refreshList1"></EditForm>
    <testObjectEditForm ref="testObjectEditForm" @refreshList="refreshList"></testObjectEditForm>
    <BindPartDialog v-if="bindPartDialog" :bindPartDialog="bindPartDialog"
                    :currentRow="currentRow"
                    :type="type"
    <BindPartDialog v-if="bindPartDialog" :bindPartDialog="bindPartDialog" :currentRow="currentRow" :type="type"
                    @closeBindPartDialog="closeBindPartDialog"></BindPartDialog>
    <BindSupplierDensityDialog v-if="bindSupplierDensityDialog"
                               :bindSupplierDensityDialog="bindSupplierDensityDialog"
                               :currentRow="currentSupplierDensityRow"
                               @closeBindPartDialog="closeBindSupplierDensityDialog"></BindSupplierDensityDialog>
    <BindSupplierDensityDialog v-if="bindSupplierDensityDialog" :bindSupplierDensityDialog="bindSupplierDensityDialog"
      :currentRow="currentSupplierDensityRow" @closeBindPartDialog="closeBindSupplierDensityDialog">
    </BindSupplierDensityDialog>
    <el-dialog title="车间绑定" :visible.sync="workshopVisible" width="400px">
      <el-form :model="workshopForm" ref="workshopForm" :rules="workshopRules" label-position="right"
        label-width="100px">
        <el-form-item label="车间名称" prop="workShopId">
          <el-select v-model="workshopForm.workShopId" placeholder="请选择" size="small">
            <el-option v-for="item in workshopList" :key="item.id" :label="item.name" :value="item.id">
            </el-option>
          </el-select>
        </el-form-item>
      </el-form>
      <span slot="footer" class="dialog-footer">
        <el-button @click="workshopVisible = false">取 消</el-button>
        <el-button :loading="uploading" type="primary" @click="submitWorkshop">确 认</el-button>
      </span>
    </el-dialog>
  </div>
</template>
@@ -118,14 +125,14 @@
import {
  addProduct,
  delItemParameter, delProduct, delTestObject, selectItemParameterList, selectProductListByObjectId,
  selectTestObjectList, upProduct,
  selectTestObjectList, upProduct, updateWorkShop
} from "@/api/structural/capability";
import limsTable from "@/components/Table/lims-table.vue";
import EditForm from "@/views/structural/capabilityAndLaboratory/capabilityComponents/EditForm.vue";
import testObjectEditForm from "@/views/structural/capabilityAndLaboratory/capabilityComponents/testObjectEditForm.vue";
import {getToken} from "@/utils/auth";
import { obtainItemParameterList } from '@/api/structural/laboratoryScope'
import { selectWorkShop } from "@/api/structural/workshop.js"
export default {
  name: 'Capability',
  components: {limsTable, EditForm, testObjectEditForm, BindPartDialog, BindSupplierDensityDialog},
@@ -226,26 +233,16 @@
        {label: '检验对象EN', prop: 'specimenNameEn'},
        {label: '产品', prop: 'product'},
        {label: '对象代号', prop: 'code'},
        {label: '对象类型', prop: 'objectType',
        {
          label: '对象类型', prop: 'objectType',
          dataType: 'tag',
          formatData: (params) => {
            if (params == 1) {
              return '原材料'
            } else if (params == 2) {
              return '成品'
            } else {
              return '辅材'
            let obj = this.productClassification.find(m => params == m.value)
            if (obj) {
              return obj.label
            }
          },
          formatType: (params) => {
            if (params == 1) {
              return 'success'
            } else if (params == 2) {
              return 'info'
            } else {
              return 'warning'
            }
          }},
        },
        {label: '创建人', prop: 'createUserName'},
        {label: '更新人', prop: 'updateUserName'},
        {label: '创建时间', prop: 'createTime'},
@@ -277,13 +274,13 @@
                this.upProduct(row);
              },
            },
            {
              name: '零件绑定',
              type: 'text',
              clickFun: (row) => {
                this.bindPartFirst(row);
              },
            },
            // {
            //   name: '零件绑定',
            //   type: 'text',
            //   clickFun: (row) => {
            //     this.bindPartFirst(row);
            //   },
            // },
          ]
        }
      ],
@@ -306,6 +303,7 @@
      productColumn: [
        {label: '产品名称', prop: 'name'},
        {label: '产品名称EN', prop: 'nameEn'},
        { label: '车间名称', prop: 'workShopName' },
        {
          dataType: 'action',
          label: '操作',
@@ -330,6 +328,20 @@
              clickFun: (row) => {
                this.bindPartSecond(row);
              },
            },
            {
              name: '车间绑定',
              type: 'text',
              clickFun: (row) => {
                this.bindWokshop(row);
              },
              showHide: (row) => {
                if (this.currentObj.objectType != '原材料') {
                  return false
                } else {
                  return true
                }
              }
            },
            {
              name: '厂家密度绑定',
@@ -371,12 +383,25 @@
      bindSupplierDensityDialog: false,
      bindPartDialog: false,
      type: null,  // 零件绑定的类型--0:检验对象,1:产品维护,
      laboratoryList:[]
      laboratoryList: [],
      productClassification: [],//产品类型
      currentObj: {},//当前对象
      currentProduct: {},//当前产品
      workshopVisible: false,
      workshopForm: {},
      workshopRules: {
        workShopId: [{ required: true, message: '请选择车间', trigger: 'change' }]
      },
      workshopList: [],//车间列表
    }
  },
  created() {
    this.getItemParameterList()
    this.refreshTable()
    this.getDicts("product_classification").then((response) => {
      this.productClassification = this.dictToValue(response.data);
    });
    this.selectWorkShop()
  },
  computed: {
    title() {
@@ -384,6 +409,11 @@
    }
  },
  methods: {
    selectWorkShop() {
      selectWorkShop({ size: -1, current: -1 }).then(res => {
        this.workshopList = res.data.records
      })
    },
    submitUpload() {
      if (this.$refs.upload.uploadFiles.length === 0) {
        this.$message.error('未选择文件')
@@ -538,6 +568,16 @@
    },
    // 产品维护
    upProduct(row) {
      this.currentObj = row;
      if (this.currentObj.objectType == '原材料') {
        if (this.productColumn.length < 4) {
          this.productColumn.splice(2, 0, { label: '车间名称', prop: 'workShopName' })
        }
      } else {
        if (this.productColumn.length == 4) {
          this.productColumn.splice(2, 1)
        }
      }
      this.diaProduct = true
      this.objectId = row.id
      this.productPage.current = 1
@@ -633,6 +673,10 @@
    bindPartSecond (row) {
      this.bindPart(row, 1)
    },
    bindWokshop(row) {
      this.currentProduct = row;
      this.workshopVisible = true
    },
    // 厂家密度绑定
    bindSupplierDensitySecond (row) {
      this.bindSupplierDensity(row)
@@ -665,6 +709,28 @@
        })
        this.laboratoryList = data
      })
    },
    // 绑定车间
    submitWorkshop() {
      this.$refs['workshopForm'].validate((valid) => {
        if (valid) {
          this.uploading = true
          updateWorkShop({
            id: this.currentProduct.id,
            workShopId: this.workshopForm.workShopId,
            name: this.workshopList.find(m => m.id == this.workshopForm.workShopId).name
          }).then(res => {
            this.uploading = false
            if (res.code === 200) {
              this.$message.success('新增成功')
              this.getProductList();
              this.workshopVisible = false
            }
          }).catch(err => {
            this.uploading = false
          })
        }
      })
    }
  }
}