You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
 
 
 
 
 

1538 lines
52 KiB

<template>
<div class="mod-config">
<!-- 收藏 -->
<div>
<span @click="favoriteFunction()">
<icon-svg :name="favorite?'xiangqufill':'xiangqu'" class="sl-svg"></icon-svg>
</span>
</div>
<!-- 条件查询 -->
<el-form :inline="true" label-position="top" :model="searchData" @keyup.enter.native="getDataList()">
<el-form-item :label="'物料编码'">
<el-input v-model="searchData.partNo" clearable style="width: 120px"></el-input>
</el-form-item>
<el-form-item :label="'物料名称'">
<el-input v-model="searchData.partDesc" clearable style="width: 120px"></el-input>
</el-form-item>
<el-form-item :label="'类别名称'">
<el-input v-model="searchData.familyName" clearable style="width: 120px"></el-input>
</el-form-item>
<el-form-item :label="' '">
<el-button type="primary" @click="getDataList()">查询</el-button>
<el-button type="primary" @click="addModal()">新增</el-button>
</el-form-item>
<el-form-item :label="' '">
<el-button type="primary" icon="el-icon-upload" @click="qcUpload()">导入</el-button>
<download-excel
:fields="fields()"
:data="exportData"
type="xls"
:name="exportName"
:header="exportHeader"
:footer="exportFooter"
:fetch="createExportData"
:before-generate="startDownload"
:before-finish="finishDownload"
worksheet="导出信息"
class="el-button el-button--primary el-button--medium">
{{ "导出" }}
</download-excel>
</el-form-item>
</el-form>
<!-- 展示列表 -->
<el-table
:height="height"
:data="dataList"
border
v-loading="dataListLoading"
style="width: 100%;">
<!-- <el-table-column-->
<!-- prop="partNo"-->
<!-- header-align="center"-->
<!-- align="center"-->
<!-- label="物料编码"-->
<!-- width="100">-->
<!-- </el-table-column>-->
<!-- <el-table-column-->
<!-- prop="partDesc"-->
<!-- header-align="center"-->
<!-- align="left"-->
<!-- label="物料名称"-->
<!-- :width="flexColumnWidth('物料名称','partDesc')">-->
<!-- </el-table-column>-->
<el-table-column
v-for="(item,index) in columnList" :key="index"
:sortable="item.columnSortable"
:prop="item.columnProp"
:header-align="item.headerAlign"
:show-overflow-tooltip="item.showOverflowTooltip"
:align="item.align"
:fixed="item.fixed === ''?false:item.fixed"
:width="item.columnWidth"
:label="item.columnLabel">
<template slot-scope="scope">
<span v-if="!item.columnHidden">{{scope.row[item.columnProp]}}</span>
<span v-if="item.columnImage"><img :src="scope.row[item.columnProp]" style="width: 100px; height: 80px"/></span>
</template>
</el-table-column>
<el-table-column
fixed="right"
header-align="center"
align="center"
width="160"
label="操作">
<template slot-scope="scope">
<a type="text" size="small" @click="detailModal(scope.row)">检验模板</a>
<a type="text" size="small" @click="deletePropertiesModel(scope.row)">删除</a>
</template>
</el-table-column>
</el-table>
<!-- 分页栏 -->
<el-pagination
@size-change="sizeChangeHandle"
@current-change="currentChangeHandle"
:current-page="pageIndex"
:page-sizes="[20, 50, 100, 200, 500]"
:page-size="pageSize"
:total="totalPage"
layout="total, sizes, prev, pager, next, jumper">
</el-pagination>
<!-- 物料属性新增/修改 -->
<el-dialog title="物料属性设置" :close-on-click-modal="false" v-drag :visible.sync="modalFlag" width="430px">
<el-form :inline="true" label-position="top" :model="modalData" :rules="rules" style="margin-left: 7px;margin-top: -5px;">
<el-form-item prop="partNo" :rules="rules.partNoType">
<span slot="label" @click="getBaseList(1043)"><a herf="#">物料编码:</a></span>
<el-input v-model="modalData.partNo" style="width: 120px"></el-input>
</el-form-item>
<el-form-item label="物料名称:" prop="partDesc" :rules="rules.partDescType">
<el-input v-model="modalData.partDesc" disabled style="width: 240px"></el-input>
</el-form-item>
</el-form>
<el-form :inline="true" label-position="top" style="margin-left: 7px;margin-top: -5px;">
<el-form-item label="备注:">
<el-input v-model="modalData.attributeRemark" style="width: 315px"></el-input>
</el-form-item>
<el-form-item label="是否免检">
<input type="checkbox" value="Y" name="isExemptInspection" v-model="modalData.exemptInspection"/>
</el-form-item>
</el-form>
<el-footer style="height:40px;margin-top: 10px;text-align:center">
<el-button type="primary" @click="saveData()">保存</el-button>
<el-button type="primary" @click="modalFlag = false">关闭</el-button>
</el-footer>
</el-dialog>
<!-- 检验模板 -->
<el-dialog title="检验模板清单" :close-on-click-modal="false" v-drag :visible.sync="detailModelFlag" width="1400px">
<el-form :inline="true" label-position="top" @keyup.enter.native="getDataList()">
<el-form-item :label="'物料编码'">
<el-input v-model="detailData.partNo" readonly style="width: 120px"></el-input>
</el-form-item>
<el-form-item :label="'物料名称'">
<el-input v-model="detailData.partDesc" readonly style="width: 300px"></el-input>
</el-form-item>
<el-form-item :label="' '">
<el-button type="primary" @click="addFastModal()">新增</el-button>
</el-form-item>
</el-form>
<!-- 检验项目展示列表 -->
<div class="rq ">
<el-table
:height="300"
:data="detailList"
border
v-loading="dataListLoading"
style="width: 100%;">
<el-table-column
prop="templateId"
header-align="center"
align="center"
label="模板编码">
</el-table-column>
<el-table-column
prop="templateName"
header-align="center"
align="left"
label="模板名称"
:width="flexColumnWidth2('模板名称','templateName')">
</el-table-column>
<el-table-column
v-for="(item,index) in columnDetailList" :key="index"
:sortable="item.columnSortable"
:prop="item.columnProp"
:header-align="item.headerAlign"
:show-overflow-tooltip="item.showOverflowTooltip"
:align="item.align"
:fixed="item.fixed===''?false:item.fixed"
:min-width="item.columnWidth"
:label="item.columnLabel">
<template slot-scope="scope">
<span v-if="!item.columnHidden">{{scope.row[item.columnProp]}}</span>
<span v-if="item.columnImage"><img :src="scope.row[item.columnProp]" style="width: 100px; height: 80px"/></span>
</template>
</el-table-column>
<el-table-column
prop="operation"
header-align="center"
align="center"
label="工序">
</el-table-column>
<el-table-column
prop="resourceID"
header-align="center"
align="center"
label="机台">
</el-table-column>
<el-table-column
prop="manufacturerName"
header-align="center"
align="center"
label="供应商">
</el-table-column>
<el-table-column
prop=""
header-align="center"
align="center"
min-width="170"
label="检验水平">
<template slot-scope="scope">
<el-button type="primary" @click="chooseLevel(scope.row)" style="width:18%;padding: 3px 7px">·&nbsp;·&nbsp;·</el-button>
<el-input v-model="scope.row.samplingLevelDesc" readonly style="width:77%"></el-input>
</template>
</el-table-column>
<el-table-column
prop=""
header-align="center"
align="center"
min-width="60"
label="检验周期(h)">
<template slot-scope="scope">
<el-input v-model="scope.row.inspectionCycle" type="number" style="height: 11px;padding: 0px " allow-create>;width:98%"</el-input>
</template>
</el-table-column>
<el-table-column
prop=""
header-align="center"
align="center"
min-width="170"
label="抽样方案">
<template slot-scope="scope">
<el-button type="primary" @click="chooseProgrammeRow(scope.row)" style="width:18%;padding: 3px 7px" >·&nbsp;·&nbsp;·</el-button>
<el-input v-model="scope.row.samplingProgrammeDesc" readonly style="width:77%"></el-input>
</template>
</el-table-column>
<el-table-column
prop=""
header-align="center"
align="center"
min-width="60"
label="AQL">
<template slot-scope="scope">
<el-input v-model="scope.row.aql" type="number" style="height: 11px;padding: 0px " allow-create>;width:98%"</el-input>
</template>
</el-table-column>
<el-table-column
prop=""
header-align="center"
align="center"
min-width="60"
label="AC">
<template slot-scope="scope">
<el-input v-model="scope.row.ac" type="number" style="height: 11px;padding: 0px " allow-create>;width:98%"</el-input>
</template>
</el-table-column>
<el-table-column
prop=""
header-align="center"
align="center"
min-width="60"
label="RE">
<template slot-scope="scope">
<el-input v-model="scope.row.re" type="number" style="height: 11px;padding: 0px " allow-create>;width:98%"</el-input>
</template>
</el-table-column>
<el-table-column
prop="templateRemark"
header-align="center"
align="center"
label="备注">
</el-table-column>
<el-table-column
fixed="right"
header-align="center"
align="center"
width="80"
label="操作">
<template slot-scope="scope">
<a type="text" size="small" @click="deletePartAttributeDetails(scope.row)">删除模板</a>
</template>
</el-table-column>
</el-table>
</div>
<el-footer style="height:40px;margin-top: 20px;text-align:center">
<el-button type="primary" @click="saveDetail()">保存</el-button>
<el-button type="primary" @click="detailModelFlag = false">关闭</el-button>
</el-footer>
</el-dialog>
<!-- 检验模板->快速新增 -->
<el-dialog title="新增" @close="refreshDetailList" :close-on-click-modal="false" v-drag :visible.sync="fastAddFlag" width="1100px">
<div style="font-size: 12px">
<el-form :inline="true" label-position="top" :model="detailData">
<el-form-item :label="'模板编码'">
<el-input v-model="detailData.templateId" clearable style="width: 120px"></el-input>
</el-form-item>
<el-form-item :label="'模板名称'">
<el-input v-model="detailData.templateName" clearable style="width: 120px"></el-input>
</el-form-item>
<el-form-item label="检验类型">
<el-select v-model="detailData.inspectionTypeNo" @change="checkInspectionType()" placeholder="请选择">
<el-option
v-for = "i in options"
:key = "i.inspectionTypeNo"
:label = "i.inspectionTypeName"
:value = "i.inspectionTypeNo">
</el-option>
</el-select>
</el-form-item>
<el-form-item :label="' '">
<el-button type="primary" @click="checkInspectionType()">查询</el-button>
</el-form-item>
<el-form-item style="margin-left: 117px" :label="' '">
<el-button type="primary" @click="getOperationList()" style="width: 63px" v-if="this.detailData.inspectionTypeNo === '101' || this.detailData.inspectionTypeNo === '102' || this.detailData.inspectionTypeNo === '103' || this.detailData.inspectionTypeNo === '104' || this.detailData.inspectionTypeNo === '106' || this.detailData.inspectionTypeNo === '107'">工序</el-button>
<el-button type="primary" @click="getManufacturerList()" v-if="this.detailData.inspectionTypeNo === '105'" style="width: 63px">供应商</el-button>
</el-form-item>
<el-form-item :label="' '">
<el-button type="primary" @click="getAllResourceList()" style="width: 63px" v-if="this.detailData.inspectionTypeNo === '101' || this.detailData.inspectionTypeNo === '102' || this.detailData.inspectionTypeNo === '103' || this.detailData.inspectionTypeNo === '104' || this.detailData.inspectionTypeNo === '106' || this.detailData.inspectionTypeNo === '107'">机台</el-button>
</el-form-item>
</el-form>
</div>
<el-container style="margin-top: 0px;">
<el-main style="width: 470px;padding: 1px">
<span style="font-size: 12px" >可选模板:</span>
<el-table
height="400px"
:data="itemList1"
border
ref="itemTable1"
@row-click="itemClickRow1"
@selection-change="selectionItem1"
highlight-current-row
v-loading="dataListLoading"
style="width: 100%">
<el-table-column
type="selection"
header-align="center"
align="center"
:selectable="selectFlag"
width="50">
</el-table-column>
<el-table-column
prop="templateId"
header-align="center"
align="center"
min-width="80"
label="模板编码">
</el-table-column>
<el-table-column
prop="templateName"
header-align="center"
align="center"
min-width="170"
label="模板名称">
</el-table-column>
<el-table-column
prop="inspectionTypeName"
header-align="center"
align="center"
min-width="80"
label="检验类型">
</el-table-column>
</el-table>
</el-main>
<el-main style="width: 100px;padding: 1px">
<div style="margin-top: 180px;margin-left: 18px">
<el-button type="primary" @click="addItem()">添加>></el-button>
</div>
<div style="margin-top: 15px;margin-left: 18px">
<el-button type="primary" @click="deleteItem()">删除<<</el-button>
</div>
</el-main>
<el-main style="width: 470px;padding: 1px">
<span style="font-size: 12px">已有模板:</span>
<el-table
height="400px"
:data="itemList2"
border
ref="itemTable2"
@row-click="itemClickRow2"
@selection-change="selectionItem2"
highlight-current-row
v-loading="dataListLoading"
style="width: 100%">
<el-table-column
type="selection"
header-align="center"
align="center"
:selectable="selectFlag"
width="50">
</el-table-column>
<el-table-column
prop="templateId"
header-align="center"
align="center"
label="模板编码">
</el-table-column>
<el-table-column
prop="templateName"
header-align="center"
align="center"
label="模板名称">
</el-table-column>
<el-table-column
prop="operation"
header-align="center"
align="center"
label="工序">
</el-table-column>
<el-table-column
prop="resourceID"
header-align="center"
align="center"
label="机台">
</el-table-column>
<el-table-column
prop="manufacturerName"
header-align="center"
align="center"
label="供应商">
</el-table-column>
<el-table-column
prop="inspectionTypeName"
header-align="center"
align="center"
label="检验类型">
</el-table-column>
</el-table>
</el-main>
</el-container>
<el-footer style="height:40px;margin-top: 20px;text-align:center">
<el-button type="primary" @click="fastAddFlag = false">关闭</el-button>
</el-footer>
</el-dialog>
<!-- 工序 -->
<el-dialog title="工序清单" :close-on-click-modal="false" v-drag :visible.sync="operationModelFlag" width="420px">
<div class="rq">
<el-form :inline="true" label-position="top" :model="operationData">
<el-form-item :label="'工序:'">
<el-input v-model="operationData.operationDesc" clearable style="width: 120px"></el-input>
</el-form-item>
<el-form-item :label="' '">
<el-button type="primary" @click="getOperationList2()">查询</el-button>
</el-form-item>
</el-form>
<el-table
:height="300"
:data="operationList"
ref="operationTable"
@row-click="operationClickRow"
@selection-change="selectionOperationChangeHandle"
border
v-loading="dataListLoading"
:row-class-name="operationRowClassName"
style="width: 100%;">
<el-table-column type="index" width="50" align="center">
<template slot-scope="scope">
<el-radio v-model="operationCurrent" :label="scope.row.index">{{''}}</el-radio>
</template>
</el-table-column>
<el-table-column
prop="operationDesc"
header-align="center"
align="center"
label="工序">
</el-table-column>
</el-table>
</div>
<el-footer style="height:40px;margin-top: 20px;text-align:center">
<el-button type="primary" @click="confirmOperation()">确认</el-button>
</el-footer>
</el-dialog>
<!-- 机台 -->
<el-dialog title="机台清单" :close-on-click-modal="false" v-drag :visible.sync="resourceModelFlag" width="420px">
<div class="rq">
<el-form :inline="true" label-position="top" :model="resourceData">
<el-form-item :label="'机台编码'">
<el-input v-model="resourceData.resourceId" clearable style="width: 120px"></el-input>
</el-form-item>
<el-form-item :label="'机台名称'">
<el-input v-model="resourceData.resourceDesc" clearable style="width: 120px"></el-input>
</el-form-item>
<el-form-item :label="' '">
<el-button type="primary" @click="getAllResourceList2()">查询</el-button>
</el-form-item>
</el-form>
<el-table
:height="300"
:data="resourceList"
ref="resourceTable"
@row-click="resourceClickRow"
@selection-change="selectionResourceChangeHandle"
border
v-loading="dataListLoading"
:row-class-name="resourceRowClassName"
style="width: 100%;">
<el-table-column type="index" width="50" align="center">
<template slot-scope="scope">
<el-radio v-model="resourceCurrent" :label="scope.row.index">{{''}}</el-radio>
</template>
</el-table-column>
<el-table-column
prop="resourceId"
header-align="center"
align="center"
label="机台编码">
</el-table-column>
<el-table-column
prop="resourceDesc"
header-align="center"
align="center"
label="机台名称">
</el-table-column>
</el-table>
</div>
<el-footer style="height:40px;margin-top: 20px;text-align:center">
<el-button type="primary" @click="confirmResource()">确认</el-button>
</el-footer>
</el-dialog>
<!-- 供应商 -->
<el-dialog title="供应商清单" :close-on-click-modal="false" v-drag :visible.sync="manufacturerModelFlag" width="520px">
<div class="rq">
<el-form :inline="true" label-position="top" :model="manufacturerData">
<el-form-item :label="'供应商编码:'">
<el-input v-model="manufacturerData.manufacturerID" clearable style="width: 120px"></el-input>
</el-form-item>
<el-form-item :label="'供应商名称:'">
<el-input v-model="manufacturerData.manufacturerName" clearable style="width: 120px"></el-input>
</el-form-item>
<el-form-item :label="' '">
<el-button type="primary" @click="getManufacturerList()">查询</el-button>
</el-form-item>
</el-form>
<el-table
:height="300"
:data="manufacturerList"
ref="manufacturerTable"
@row-click="manufacturerClickRow"
@selection-change="selectionManufacturerChangeHandle"
border
v-loading="dataListLoading"
style="width: 100%;">
<el-table-column
type="selection"
header-align="center"
align="center"
:selectable="selectFlag"
width="50">
</el-table-column>
<el-table-column
prop="manufacturerID"
header-align="center"
align="center"
label="供应商编码">
</el-table-column>
<el-table-column
prop="manufacturerName"
header-align="center"
align="center"
label="供应商名称">
</el-table-column>
</el-table>
</div>
<el-footer style="height:40px;margin-top: 20px;text-align:center">
<el-button type="primary" @click="confirmManufacturer()">确认</el-button>
<el-button type="primary" @click="manufacturerModelFlag = false">关闭</el-button>
</el-footer>
</el-dialog>
<Chooselist ref="baseList" @getBaseData="getBaseData"></Chooselist>
<!-- 导入 -->
<qcUpload ref="qcUpload" @refreshPageTables="getDataList()" v-drag></qcUpload>
</div>
</template>
<script>
import {
qcPartAttributeSearch, // 查询物料属性
qcPartAttributeSave, // 新增物料属性
qcPartAttributeDelete, // 删除物料属性
searchPartAttributeDetails, // 查询物料属性模板
savePartAttributeDetails, // 新增物料属性模板
deletePartAttributeDetails, // 删除物料属性模板
saveAttributeDetailed, // 新增物料属性模板详情
//getItemLists, // 获取项目列表
getPartTemplateLists, // 获取模板列表
InspectionTypeSearch, // 搜索所有检验类型
getOperationDescList, // 查询工序列表
getManufacturerList, // 查询供应商列表
getAllResourceList // 查询机台列表
} from "@/api/qc/qc.js"
import Chooselist from '@/views/modules/common/Chooselist_eam'
import {userFavoriteList, saveUserFavorite, removeUserFavorite} from '@/api/userFavorite.js'
import qcUpload from "./qc_upload";
export default {
components: {
Chooselist,
qcUpload
},
data () {
return {
// 是否收藏
favorite: false,
// 导出 start
exportData: [],
exportName: "根据物料设置检验模板" + this.dayjs().format('YYYYMMDDHHmmss'),
exportHeader: ["根据物料设置检验模板"],
exportFooter: [],
exportList:[],
// 导出 end
tagNo: '',
searchData: {
site: this.$store.state.user.site,
partNo: '',
partDesc: '',
familyID: '',
familyName: '',
attributeType: 'A',
page: 1,
limit: 10,
},
height: 200,
pageIndex: 1,
pageSize: 50,
totalPage: 0,
modalFlag: false,
modalDisableFlag: false,
modalData:{
flag: '',
partNo: '',
partDesc: '',
familyID: '',
familyName: '',
umid: '',
supplierNo: '',
supplierDesc: '',
attributeRemark: '',
createTime: '',
createBy: this.$store.state.user.name,
attributeType: 'A',
exemptInspection: ''
},
detailData:{
site: this.$store.state.user.site,
partNo: '',
attributeNo: '',
partDesc: '',
attributeType: 'A',
inspectionTypeNo: '',
templateId: '',
templateName: '',
createBy: this.$store.state.user.name
},
columnList: [
{
columnProp: 'partNo',
headerAlign: "center",
align: "center",
columnLabel: '物料编码',
columnHidden: false,
columnImage: false,
columnSortable: false,
sortLv: 0,
status: true,
fixed: '',
},
{
columnProp: 'partDesc',
headerAlign: "center",
align: "left",
columnLabel: '物料名称',
columnHidden: false,
columnImage: false,
columnSortable: false,
sortLv: 0,
status: true,
fixed: '',
},
{
columnProp: 'familyName',
headerAlign: "center",
align: "center",
columnLabel: '物料类别',
columnHidden: false,
columnImage: false,
columnSortable: false,
sortLv: 0,
status: true,
fixed: '',
},
{
columnProp: 'umid',
headerAlign: "center",
align: "center",
columnLabel: '规格型号',
columnHidden: false,
columnImage: false,
columnSortable: false,
sortLv: 0,
status: true,
fixed: '',
},
{
columnProp: 'supplierDesc',
headerAlign: "center",
align: "center",
columnLabel: '供应商',
columnHidden: false,
columnImage: false,
columnSortable: false,
sortLv: 0,
status: true,
fixed: '',
},
{
columnProp: 'exemptInspection',
headerAlign: "center",
align: "center",
columnLabel: '是否免检',
columnHidden: false,
columnImage: false,
columnSortable: false,
sortLv: 0,
status: true,
fixed: '',
},
{
columnProp: 'attributeRemark',
headerAlign: "center",
align: "center",
columnLabel: '备注',
columnHidden: false,
columnImage: false,
columnSortable: false,
sortLv: 0,
status: true,
fixed: '',
},
{
columnProp: 'createTime',
headerAlign: "center",
align: "center",
columnLabel: '创建时间',
columnHidden: false,
columnImage: false,
columnSortable: false,
sortLv: 0,
status: true,
fixed: '',
},
{
columnProp: 'createBy',
headerAlign: "center",
align: "center",
columnLabel: '创建人',
columnHidden: false,
columnImage: false,
columnSortable: false,
sortLv: 0,
status: true,
fixed: '',
},
{
columnProp: 'updateDate',
headerAlign: "center",
align: "center",
columnLabel: '更新时间',
columnHidden: false,
columnImage: false,
columnSortable: false,
sortLv: 0,
status: true,
fixed: '',
},
{
columnProp: 'updateBy',
headerAlign: "center",
align: "center",
columnLabel: '更新人',
columnHidden: false,
columnImage: false,
columnSortable: false,
sortLv: 0,
status: true,
fixed: '',
},
],
detailModelFlag:false,
detailList: [],
dataListLoading: false,
dataList:[],
// 展示列集
columnDetailList: [
{
columnProp: 'inspectionTypeName',
headerAlign: "center",
align: "center",
columnLabel: '检验类型',
columnHidden: false,
columnImage: false,
columnSortable: false,
sortLv: 0,
status: true,
fixed: '',
},
{
columnProp: 'templateVersion',
headerAlign: "center",
align: "center",
columnLabel: '版本号',
columnHidden: false,
columnImage: false,
columnSortable: false,
sortLv: 0,
status: true,
fixed: '',
},
{
columnProp: 'defaultSamplingQuantity',
headerAlign: "center",
align: "right",
columnLabel: '默认检验数量',
columnHidden: false,
columnImage: false,
columnSortable: false,
sortLv: 0,
status: true,
fixed: '',
},
{
columnProp: 'defaultSamplingProportion',
headerAlign: "center",
align: "right",
columnLabel: '默认检验比例',
columnHidden: false,
columnImage: false,
columnSortable: false,
sortLv: 0,
status: true,
fixed: '',
},
],
// 快速添加
fastAddFlag:false,
itemList1:[],
itemList2:[],
itemListRow1:{},
itemListRow2:{},
tempLevelRow:'',
tempProgrammeRow:'',
options: [],
itemSelections1: [],
itemSelections2: [],
rules:{
partNoType:[
{
required: true,
message: ' ',
trigger: 'change'
}
],
partDescType:[
{
required: true,
message: ' ',
trigger: 'change'
}
]
},
// 工序
operationList: [],
resourceList: [],
operationModelFlag: false,
resourceModelFlag: false,
dataListOperationSelections: [],
operationData:{
operationDesc: ''
},
resourceData: {
site: this.$store.state.user.site,
resourceId: '',
resourceDesc: ''
},
operation: '',
resourceId: '',
selectionManufacturer: [],
// 供应商
manufacturerList: [],
manufacturerModelFlag: false,
dataListManufacturerSelections: [],
manufacturerData:{
site: this.$store.state.user.site,
manufacturerID: '',
manufacturerName: ''
},
// 单选框绑定的值
operationCurrent: -1,
resourceCurrent: -1
}
},
mounted () {
this.$nextTick(() => {
this.height = window.innerHeight - 210
})
},
created () {
this.getDataList();
this.favoriteIsOk();
this.InspectionTypeSearch();
},
methods: {
/**
* 自适应
* @param label
* @param prop
* @returns {string}
*/
flexColumnWidth (label, prop) {
// 1.获取该列的所有数据
const arr = this.dataList.map(x => x[prop])
arr.push(label) // 把每列的表头也加进去算
// 2.计算每列内容最大的宽度 + 表格的内间距(依据实际情况而定)
return (this.getMaxLength(arr) + 25) + 'px'
},
flexColumnWidth2 (label, prop) {
// 1.获取该列的所有数据
const arr = this.detailList.map(x => x[prop])
arr.push(label) // 把每列的表头也加进去算
// 2.计算每列内容最大的宽度 + 表格的内间距(依据实际情况而定)
return (this.getMaxLength(arr) + 25) + 'px'
},
getTextWidth (str) {
let width = 0
const html = document.createElement('span')
html.innerText = str
html.className = 'getTextWidth'
document.querySelector('body').appendChild(html)
width = document.querySelector('.getTextWidth').offsetWidth
document.querySelector('.getTextWidth').remove()
return width
},
getMaxLength (arr) {
return arr.reduce((acc, item) => {
if (item) {
const calcLen = this.getTextWidth(item)
if (acc < calcLen) {
acc = calcLen
}
}
return acc
}, 0)
},
// 查询检验类型
InspectionTypeSearch(){
InspectionTypeSearch().then(({data}) => {
if (data.code === 0) {
this.options = data.rows
}
})
},
chooseLevel(row){
this.tempLevelRow = row;
this.getBaseList(1048);
},
chooseProgrammeRow(row){
this.tempProgrammeRow = row;
this.getBaseList(1051);
},
// 获取基础数据列表S
getBaseList (val,type) {
this.tagNo = val
this.$nextTick(() => {
let strVal = ''
if (val === 1043) {
strVal = this.modalData.partNo
this.$refs.baseList.init(val, strVal)
}
if (val === 1048) {
strVal = this.tempLevelRow.samplingLevelNo
this.$refs.baseList.init(val, strVal)
}
if (val === 1051) {
strVal = this.tempProgrammeRow.samplingProgrammeNo
this.$refs.baseList.init(val, strVal)
}
if (val === 1056) {
strVal = this.modalData.supplierNo
this.$refs.baseList.init(val, strVal)
}
})
},
/* 列表方法的回调 */
getBaseData (val) {
if (this.tagNo === 1043) {
this.modalData.partNo = val.part_no
this.modalData.partDesc = val.part_desc
}
if (this.tagNo === 1048) {
this.tempLevelRow.samplingLevelNo = val.sampling_level_no
this.tempLevelRow.samplingLevelDesc = val.sampling_level_desc
}
if (this.tagNo === 1051) {
this.tempProgrammeRow.samplingProgrammeNo = val.sampling_programme_no
this.tempProgrammeRow.samplingProgrammeDesc = val.sampling_programme_desc
}
if (this.tagNo === 1056) {
this.modalData.supplierNo = val.supplier_id
this.modalData.supplierDesc = val.supplier_name
}
},
// 获取数据列表
getDataList () {
this.searchData.limit = this.pageSize
this.searchData.page = this.pageIndex
qcPartAttributeSearch(this.searchData).then(({data}) => {
if (data.code === 0) {
this.dataList = data.page.list
this.pageIndex = data.page.currPage
this.pageSize = data.page.pageSize
this.totalPage = data.page.totalCount
}
this.dataListLoading = false
})
},
// 每页数
sizeChangeHandle (val) {
this.pageSize = val
this.pageIndex = 1
this.getDataList()
},
// 当前页
currentChangeHandle (val) {
this.pageIndex = val
this.getDataList()
},
addModal(){
this.modalData = {
site: this.$store.state.user.site,
flag: '1',
partNo: '',
partDesc: '',
familyID: '',
familyName: '',
umid: '',
supplierNo: '',
supplierDesc: '',
attributeRemark: '',
createTime: '',
updateBy: this.$store.state.user.name,
createBy: this.$store.state.user.name,
attributeType: 'A',
exemptInspection: ''
};
this.modalDisableFlag = false;
this.modalFlag = true;
},
// 删除
deletePropertiesModel (row) {
this.$confirm(`是否删除这个检验模板?`, '提示', {
confirmButtonText: '确定',
cancelButtonText: '取消',
type: 'warning'
}).then(() => {
qcPartAttributeDelete(row).then(({data}) => {
if (data && data.code === 0) {
this.getDataList()
this.$message({
message: '操作成功',
type: 'success',
duration: 1500,
onClose: () => {
}
})
} else {
this.$alert(data.msg, '错误', {
confirmButtonText: '确定'
})
}
})
}).catch(() => {
})
},
saveData(){
if (this.modalData.partNo === '' || this.modalData.partNo == null) {
this.$message.warning('请选择物料编码!')
return
}
if (this.modalData.partDesc === '' || this.modalData.partDesc == null) {
this.$message.warning('请选择物料名称!')
return
}
let obj = document.getElementsByName('isExemptInspection')
let s = ''
for (let i = 0; i < obj.length; i++) {
if (obj[i].checked) {
s += obj[i].value + ','
}
}
s = s.substring(0, s.length - 1)
this.modalData.exemptInspection = s
if(this.modalData.flag === '1'){
qcPartAttributeSave(this.modalData).then(({data}) => {
if (data && data.code === 0) {
this.getDataList()
this.modalFlag = false
this.$message({
message: '操作成功',
type: 'success',
duration: 1500,
onClose: () => {
}
})
} else {
this.$alert(data.msg, '错误', {
confirmButtonText: '确定'
})
}
})
}
},
// 保存属性模板
saveDetail(){
for (let i = 0; i < this.detailList.length; i++) {
this.detailList[i].updateBy = this.$store.state.user.name
saveAttributeDetailed(this.detailList[i]).then(({data}) => {
if (data && data.code === 0) {
this.getDataList()
this.detailModelFlag = false
this.$message({
message: '操作成功',
type: 'success',
duration: 1500,
onClose: () => {
}
})
} else {
this.$alert(data.msg, '错误', {
confirmButtonText: '确定'
}).then(() => {
return false
})
}
})
}
},
//打开物料模板清单
detailModal (row) {
this.detailData.partNo = row.partNo
this.detailData.attributeNo = row.partNo
this.detailData.partDesc = row.partDesc
searchPartAttributeDetails(this.detailData).then(({data}) => {
this.detailList = data.rows
})
this.detailModelFlag = true;
},
checkInspectionType(){
getPartTemplateLists(this.detailData).then(({data}) => {
this.operation = ''
this.resourceId = ''
this.itemList1 = data.row1;
this.itemList2 = data.row2;
})
},
// 快速新增
addFastModal(){
this.itemSelections1 = null
this.itemSelections2 = null
getPartTemplateLists(this.detailData).then(({data}) => {
this.itemList1 = data.row1
this.itemList2 = data.row2
})
this.detailData.inspectionTypeNo = this.options[0].inspectionTypeNo
this.checkInspectionType()
this.dataListOperationSelections = []
this.operation = ''
this.resourceId = ''
this.operationData.operationDesc = ''
this.resourceData.resourceId = ''
this.resourceData.resourceDesc = ''
this.operationCurrent = -1
this.resourceCurrent = -1
this.selectionManufacturer = []
this.dataListManufacturerSelections = []
this.fastAddFlag = true
},
// 可选项目
itemClickRow1(row){
this.$refs.itemTable1.toggleRowSelection(row);
},
// 已有项目
itemClickRow2(row){
this.$refs.itemTable2.toggleRowSelection(row);
},
selectFlag(){
return true;
},
selectionItem1(val){
this.itemSelections1 = val
},
selectionItem2(val){
this.itemSelections2 = val
},
// 添加模板
addItem(){
if(this.itemSelections1 == null || this.itemSelections1.length === 0){
this.$message.warning('请选择可选模板!')
return
}
if((this.detailData.inspectionTypeNo === '101' || this.detailData.inspectionTypeNo === '102' || this.detailData.inspectionTypeNo === '103' || this.detailData.inspectionTypeNo === '104' || this.detailData.inspectionTypeNo === '106' || this.detailData.inspectionTypeNo === '107') && (this.operation == null || this.operation === '')){
this.$message.warning('请选择工序!')
return
}
if((this.detailData.inspectionTypeNo === '101' || this.detailData.inspectionTypeNo === '102' || this.detailData.inspectionTypeNo === '103' || this.detailData.inspectionTypeNo === '104' || this.detailData.inspectionTypeNo === '106' || this.detailData.inspectionTypeNo === '107') && (this.resourceId == null || this.resourceId === '')){
this.$message.warning('请选择机台!')
return
}
if((this.detailData.inspectionTypeNo === '105') && (this.selectionManufacturer == null || this.selectionManufacturer.length === 0)){
this.$message.warning('请选择供应商!')
return
}
let inData = {
site: this.$store.state.user.site,
attributeNo: this.detailData.partNo,
itemList: this.itemSelections1,
operation: this.operation,
resourceID: this.resourceId,
manufacturerList: this.selectionManufacturer,
attributeType: this.detailData.attributeType,
inspectionTypeNo: this.detailData.inspectionTypeNo
}
savePartAttributeDetails(inData).then(({data}) => {
if (data && data.code === 0) {
getPartTemplateLists(this.detailData).then(({data}) => {
this.itemList1 = data.row1;
this.itemList2 = data.row2;
})
this.itemSelections1 = []
this.operation = ''
this.resourceId = ''
this.selectionManufacturer = []
} else {
this.$alert(data.msg, '错误', {
confirmButtonText: '确定'
})
}
})
},
// 删除模板
deleteItem(){
if(this.itemSelections2 == null || this.itemSelections2.length === 0){
this.$message.warning('请选择已有模板!')
return
}
let inData = {
attributeNo:this.detailData.partNo,
itemList: this.itemSelections2,
attributeType: this.detailData.attributeType,
site:this.$store.state.user.site
}
deletePartAttributeDetails(inData).then(({data}) => {
if (data && data.code === 0) {
getPartTemplateLists(this.detailData).then(({data}) => {
this.itemList1 = data.row1;
this.itemList2 = data.row2;
})
this.itemSelections2 = []
} else {
this.$alert(data.msg, '错误', {
confirmButtonText: '确定'
})
}
})
},
// 关闭后刷新列表
refreshDetailList(){
searchPartAttributeDetails(this.detailData).then(({data}) => {
this.detailList = data.rows
})
},
// 删除物料属性中的模板
deletePartAttributeDetails(row){
this.$confirm(`是否删除这个检验模板?`, '提示', {
confirmButtonText: '确定',
cancelButtonText: '取消',
type: 'warning'
}).then(() => {
deletePartAttributeDetails(row).then(({data}) => {
if (data && data.code === 0) {
searchPartAttributeDetails(this.detailData).then(({data}) => {
this.detailList = data.rows
})
this.$message({
message: '操作成功',
type: 'success',
duration: 1500,
onClose: () => {
}
})
} else {
this.$alert(data.msg, '错误', {
confirmButtonText: '确定'
})
}
})
}).catch(() => {
})
},
// 校验用户是否收藏
favoriteIsOk() {
let userFavorite = {
userId: this.$store.state.user.id,
languageCode: this.$i18n.locale
}
userFavoriteList(userFavorite).then(({data}) => {
for (let i = 0; i < data.list.length; i++) {
if(this.$route.meta.menuId==data.list[i].menuId){
this.favorite = true
}
}
})
},
// 收藏 OR 取消收藏
favoriteFunction() {
let userFavorite = {
userId: this.$store.state.user.id,
functionId: this.$route.meta.menuId,
}
if (this.favorite) {
removeUserFavorite(userFavorite).then(({data}) => {
this.$message.success(data.msg)
this.favorite = false
})
} else {
// 收藏
saveUserFavorite(userFavorite).then(({data}) => {
this.$message.success(data.msg)
this.favorite = true
})
}
},
//导出excel
async createExportData() {
this.searchData.limit = -1
this.searchData.page = 1
await qcPartAttributeSearch(this.searchData).then(({data}) => {
this.exportList= data.page.list;
})
return this.exportList;
},
startDownload() {
},
finishDownload() {
},
fields() {
let json = "{"
this.columnList.forEach((item, index) => {
if (index == this.columnList.length - 1) {
json += "\"" + item.columnLabel + "\"" + ":" + "\"" + item.columnProp + "\""
} else {
json += "\"" + item.columnLabel + "\"" + ":" + "\"" + item.columnProp + "\"" + ","
}
})
json += "}"
let s = eval("(" + json + ")")
return s
},
// 导出 end
// 导入
qcUpload(){
let currentData = {
flag: 'partAttribute',
createBy: this.$store.state.user.name,
site: this.$store.state.user.site,
};
//打开组件 去做新增业务
this.$nextTick(() => {
this.$refs.qcUpload.init(currentData);
})
},
// 获取工序列表
getOperationList(){
getOperationDescList(this.operationData).then(({data}) => {
if (data && data.code === 0) {
this.operationList = data.rows;
// // 回显数据
// // 先清空缓存选中
// this.$nextTick(() => this.$refs.operationTable.clearSelection())
// // 拿到选中的工序
// let tempDataList = this.operationDesc
// this.operationList.forEach(val => {
// // 回显选中的工序
// if (tempDataList === val.operationDesc) {
// this.$nextTick(() => this.$refs.operationTable.toggleRowSelection(val, true))
// }
// })
this.operationModelFlag = true;
} else {
this.$alert(data.msg, '错误', {
confirmButtonText: '确定'
})
}
})
},
// 获取机台列表
getAllResourceList () {
getAllResourceList(this.resourceData).then(({data}) => {
if (data && data.code === 0) {
this.resourceList = data.rows
this.resourceModelFlag = true;
} else {
this.$alert(data.msg, '错误', {
confirmButtonText: '确定'
})
}
})
},
// 条件查询获取工序列表
getOperationList2(){
getOperationDescList(this.operationData).then(({data}) => {
if (data && data.code === 0) {
this.operationList = data.rows
this.operationCurrent = -1
} else {
this.$alert(data.msg, '错误', {
confirmButtonText: '确定'
})
}
})
},
// 条件查询获取机台列表
getAllResourceList2 () {
getAllResourceList(this.resourceData).then(({data}) => {
if (data && data.code === 0) {
this.resourceList = data.rows
this.resourceCurrent = -1
} else {
this.$alert(data.msg, '错误', {
confirmButtonText: '确定'
})
}
})
},
// 点击行选中工序复选框
operationClickRow (row) {
this.$refs.operationTable.toggleRowSelection(row);
},
// 点击行选中机台复选框
resourceClickRow (row) {
this.$refs.resourceTable.toggleRowSelection(row);
},
// 多选工序
selectionOperationChangeHandle (val) {
this.operation = val[0].operationDesc
if (val) {
this.operationCurrent = val.index;
}
},
// 多选机台
selectionResourceChangeHandle (val) {
this.resourceId = val[0].resourceId
if (val) {
this.resourceCurrent = val.index;
}
},
operationRowClassName ({row, rowIndex}) {
row.index = rowIndex; // 在原有的数据上加一个index
},
resourceRowClassName ({row, rowIndex}) {
row.index = rowIndex; // 在原有的数据上加一个index
},
// // 单选
// clickChange (row) {
// this.radioOperation = row.operationDesc
// },
// 确认选择工序
confirmOperation () {
//this.operationDesc = ''
// this.operationDesc = this.radioOperation
// this.radioOperation = ''
// for (let i = 0; i < this.dataListOperationSelections.length; i++) {
// this.selectionOperation.push(this.dataListOperationSelections[i].operationDesc)
// }
this.operationModelFlag = false
},
// 确认选择工序
confirmResource () {
this.resourceModelFlag = false
},
// 获取供应商列表
getManufacturerList(){
getManufacturerList(this.manufacturerData).then(({data}) => {
if (data && data.code === 0) {
this.manufacturerList = data.rows;
// 回显数据
// 先清空缓存选中
this.$nextTick(() => this.$refs.manufacturerTable.clearSelection())
// 拿到选中的供应商
let tempDataList = this.selectionManufacturer
this.manufacturerList.forEach(val => {
// 回显选中的供应商
if (tempDataList.includes(val.manufacturerID)) {
this.$nextTick(() => this.$refs.manufacturerTable.toggleRowSelection(val, true))
}
})
this.manufacturerModelFlag = true;
} else {
this.$alert(data.msg, '错误', {
confirmButtonText: '确定'
})
}
})
},
// 点击行选中复选框
manufacturerClickRow(row){
this.$refs.manufacturerTable.toggleRowSelection(row);
},
// 多选
selectionManufacturerChangeHandle (val) {
this.dataListManufacturerSelections = val
},
// 确认多选供应商
confirmManufacturer(){
this.selectionManufacturer = []
for (let i = 0; i < this.dataListManufacturerSelections.length; i++) {
this.selectionManufacturer.push(this.dataListManufacturerSelections[i].manufacturerID)
}
this.manufacturerModelFlag = false
}
}
}
</script>