| 123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886887888889890891892893894895896897898899900901902903904905906907908909910911912913914915916917918919920921922923924925926927928929930931932933934935936937938939940941942943944945946947948949950951952953954955956957958959960961962963964965966967968969970971972973974975976977978979980981982983984985986987988989990991992993994995996997998999100010011002100310041005100610071008100910101011101210131014101510161017101810191020102110221023102410251026102710281029103010311032103310341035103610371038103910401041104210431044104510461047104810491050105110521053105410551056105710581059106010611062106310641065106610671068106910701071107210731074107510761077107810791080108110821083108410851086108710881089109010911092109310941095109610971098109911001101110211031104110511061107110811091110111111121113111411151116111711181119112011211122112311241125112611271128112911301131113211331134113511361137113811391140114111421143114411451146114711481149115011511152115311541155115611571158115911601161116211631164116511661167116811691170117111721173117411751176117711781179118011811182118311841185118611871188118911901191119211931194119511961197 |
- <!-- 质检内容 -->
- <template>
- <el-row>
- <!-- 选择质检方案 -->
- <inspectionTemplateDialog
- ref="inspectionTemplateRef"
- @choose="inspectionTemplateSuccess"
- ></inspectionTemplateDialog>
- <header-title title="质检内容">
- <el-button
- type="primary"
- :loading="loading"
- v-if="type != 'detail'"
- @click="$emit('batch-quality')"
- >批量质检</el-button
- >
- <!-- <el-button
- type="primary"
- :loading="loading"
- v-if="type != 'detail'"
- @click="$emit('batch-dispose')"
- >批量处置</el-button
- > -->
- </header-title>
- <el-tabs v-model="activeNameKK" @tab-click="handleClick">
- <!-- -->
- <el-tab-pane label="来源清单" name="1">
- <ele-pro-table
- ref="sourceTable"
- :columns="tableColumns1"
- :datasource="datasource"
- @selection-change="handleSelectionChange"
- :initLoad="false"
- :needPage="false"
- height="500px"
- >
- <!-- :pagination="true" -->
- <template
- v-slot:toolbar
- v-if="form.qualityMode == 2 && type != 'detail'"
- >
- <el-dropdown trigger="click" @command="handleSampleNumber">
- <el-link type="primary" icon="el-icon-plus">取样</el-link>
- <el-dropdown-menu slot="dropdown">
- <el-dropdown-item command="1">取整样</el-dropdown-item>
- <el-dropdown-item command="2">取小样</el-dropdown-item>
- </el-dropdown-menu>
- </el-dropdown>
- </template>
- <template v-slot:toolkit v-if="form.qualityMode == 2">
- <el-row>
- <el-form
- ref="ruleForm"
- :model="formData"
- label-width="60px"
- size="mini"
- :rules="rules"
- class="flex"
- :show-message="false"
- >
- <el-col :span="6" v-if="conditionType == 2">
- <el-form-item
- prop="number"
- label-width="0"
- style="margin-bottom: 0"
- >
- <el-input
- v-model="formData.number"
- placeholder="请输入"
- size="mini"
- ></el-input>
- </el-form-item>
- </el-col>
- <el-col :span="6" v-if="conditionType == 2">
- <el-form-item
- prop="sampleUnit"
- label-width="0"
- style="margin: 0"
- >
- <DictSelection
- dictName="计量单位"
- clearable
- v-model="formData.sampleUnit"
- size="mini"
- @change="changeSamUnit"
- >
- </DictSelection>
- </el-form-item>
- </el-col>
- <el-col :span="8" v-if="conditionType == 2">
- <el-form-item prop="portion" label="数量" style="margin: 0">
- <el-input
- v-model="formData.portion"
- placeholder="请输入"
- size="mini"
- ></el-input>
- </el-form-item>
- </el-col>
- <el-col :span="10" v-if="conditionType == 1">
- <el-form-item prop="portion" label="数量" style="margin: 0">
- <el-input
- v-model="formData.portion"
- placeholder="请输入"
- size="mini"
- ></el-input>
- </el-form-item>
- </el-col>
- <el-col :span="10" v-if="conditionType == 1">
- <el-form-item
- prop="packingUnit"
- label="单位"
- style="margin: 0"
- >
- <el-select
- v-model="formData.packingUnit"
- placeholder="请选择"
- >
- <el-option
- v-for="item in packingSpecificationOption"
- :key="item.id"
- :label="item.conversionUnit"
- :value="item.id"
- >
- </el-option>
- </el-select>
- </el-form-item>
- </el-col>
- <el-col
- :span="4"
- style="text-align: right"
- v-if="conditionType == 2"
- >
- <el-button
- type="primary"
- size="mini"
- @click="handleSampleSubmit"
- style="margin-right: 12px"
- >确认</el-button
- >
- </el-col>
- <el-col
- :span="4"
- style="text-align: right"
- v-if="conditionType == 1"
- >
- <el-button
- type="primary"
- size="mini"
- @click="handleSampleSubmit"
- style="margin-right: 12px"
- >确认</el-button
- >
- </el-col>
- </el-form>
- </el-row>
- </template>
- <template v-slot:materielDesignation="{ row }">
- <el-input
- v-model="row.materielDesignation"
- placeholder="请输入"
- ></el-input>
- </template>
- <template v-slot:clientCode="{ row }">
- <el-input v-model="row.clientCode" placeholder="请输入"></el-input>
- </template>
- <template v-slot:engrave="{ row }">
- <el-input v-model="row.engrave" placeholder="请输入"></el-input>
- </template>
- <template v-slot:weight="{ row }">
- <el-input v-model="row.weight" placeholder="请输入"></el-input>
- </template>
- </ele-pro-table>
- </el-tab-pane>
- <!-- -->
- <el-tab-pane label="样品清单" name="2">
- <el-table
- v-if="sampleList.length > 0"
- ref="showSampleListTable"
- :data="paginatedSampleList"
- tooltip-effect="dark"
- height="500"
- border
- row-key="id"
- >
- <el-table-column
- label="序号"
- type="index"
- width="50"
- align="center"
- fixed="left"
- ></el-table-column>
- <template v-for="(column, index) in tableColumns">
- <el-table-column
- :key="index"
- :label="column.label"
- :prop="column.prop"
- :fixed="column.fixed"
- :show-overflow-tooltip="true"
- :width="column.width"
- :align="column.align"
- >
- <template slot-scope="scope">
- <template v-if="column.prop === 'categoryCode'">
- <el-link
- type="primary"
- :underline="false"
- @click="handleDetail(scope.$index, scope.row, 'detail')"
- >
- {{ scope.row.categoryCode }}
- </el-link>
- </template>
- <template v-else-if="column.prop === 'materielDesignation'">
- <el-input
- :disabled="status"
- v-model="scope.row.materielDesignation"
- size="mini"
- v-direction="{ x: 0, y: scope.$index }"
- ></el-input>
- </template>
- <template v-else-if="column.prop === 'clientCode'">
- <el-input
- :disabled="status"
- v-model="scope.row.clientCode"
- size="mini"
- v-direction="{ x: 1, y: scope.$index }"
- ></el-input>
- </template>
- <template v-else-if="column.prop === 'engrave'">
- <el-input
- :disabled="status"
- v-model="scope.row.engrave"
- size="mini"
- v-direction="{ x: 2, y: scope.$index }"
- ></el-input>
- </template>
- <template v-else-if="column.prop === 'weight'">
- <el-input
- v-model="scope.row.weight"
- :disabled="status"
- oninput="value = value.replace(/[^\d.]/g, '')"
- :min="0"
- @input="inputWeight(scope.row, scope.$index)"
- size="mini"
- v-direction="{ x: 3, y: scope.$index }"
- ></el-input>
- </template>
- <template v-else>
- {{ scope.row[column.prop] }}
- </template>
- </template>
- </el-table-column>
- </template>
- <!-- *** fixed="right" -->
- <el-table-column
- label="处置状态"
- prop="disposeType"
- align="center"
- :show-overflow-tooltip="true"
- >
- <template slot-scope="scope">
- <span>{{ disposeTypeList[scope.row.disposeType] }}</span>
- </template>
- </el-table-column>
- <!-- *** fixed="right" -->
- <el-table-column
- label="处置时间"
- prop="disposeTime"
- align="center"
- :show-overflow-tooltip="true"
- >
- </el-table-column>
- <!-- *** fixed="right" -->
- <el-table-column
- label="质检状态"
- prop="qualityStatus"
- align="center"
- fixed="right"
- :show-overflow-tooltip="true"
- >
- <template slot-scope="scope">
- <span v-if="scope.row.qualityStatus == 0">未检</span>
- <span v-if="scope.row.qualityStatus == 1">已检</span>
- <span v-if="scope.row.qualityStatus == 2">待检</span>
- </template>
- </el-table-column>
- <el-table-column
- label="质检结果"
- prop="qualityResults"
- align="center"
- width="180"
- fixed="right"
- :show-overflow-tooltip="true"
- >
- <template slot-scope="scope">
- <el-select
- @change="selectQualityResultsChange"
- v-model="scope.row.qualityResults"
- placeholder="请选择"
- style="width: 100%"
- :disabled="type == 'detail'"
- size="mini"
- >
- <el-option
- v-for="item in qualityResultsList"
- :key="item.value"
- :label="item.label"
- :value="item.value"
- >
- </el-option>
- </el-select>
- </template>
- </el-table-column>
- <el-table-column
- label="操作"
- align="center"
- width="120"
- fixed="right"
- v-if="type != 'detail'"
- >
- <template slot-scope="scope">
- <el-link
- :type="scope.row.isValid ? 'primary' : 'danger'"
- :underline="false"
- @click="handleDetail(scope.$index, scope.row, 'report')"
- >
- 质检
- </el-link>
- <!-- <el-link
- type="primary"
- :underline="false"
- @click="handleDispose(scope.$index, scope.row, 'dispose')"
- >处置
- </el-link> -->
- </template>
- </el-table-column>
- </el-table>
- <!-- <el-pagination
- @size-change="handleSampleSizeChange"
- @current-change="handleSampleCurrentChange"
- :current-page="samplePagination.currentPage"
- :page-sizes="[10, 20, 50, 100]"
- :page-size="samplePagination.pageSize"
- layout="total, sizes, prev, pager, next, jumper"
- :total="sampleList.length"
- /> -->
- </el-tab-pane>
- <!-- -->
- <el-tab-pane label="质检方案" name="3">
- <el-button
- v-if="type !== 'detail'"
- @click="addInspectionTemplate"
- type="primary"
- style="margin-top: 5px"
- >选择质检方案</el-button
- >
- <el-table
- :data="paginatedSchemeList"
- tooltip-effect="dark"
- height="500"
- border
- row-key="id"
- >
- <el-table-column
- label="序号"
- type="index"
- width="50"
- align="center"
- ></el-table-column>
- <el-table-column
- label="质检方案编码"
- prop="qualitySchemeTemplateCode"
- align="center"
- >
- </el-table-column>
- <el-table-column
- label="质检方案名称"
- prop="qualitySchemeTemplateName"
- align="center"
- ></el-table-column>
- <el-table-column
- label="质检类型"
- prop="categoryLevelClassName"
- align="center"
- ></el-table-column>
- <el-table-column
- label="质检项编码"
- prop="inspectionCode"
- align="center"
- ></el-table-column>
- <el-table-column
- label="质检项名称"
- prop="inspectionName"
- align="center"
- ></el-table-column>
- <el-table-column
- label="工艺参数"
- show-overflow-tooltip
- prop="defaultValue"
- align="center"
- >
- <template slot-scope="scope">
- <div style="display: flex; justify-content: center">
- <span>{{ scope.row.symbol }}</span>
- <span v-if="scope.row.textType == 3">
- {{ scope.row.minValue }}-{{ scope.row.maxValue }}
- </span>
- <span v-else>
- <span>{{ scope.row.defaultValue }}</span>
- </span>
- {{ scope.row.unitName }}
- </div>
- </template>
- </el-table-column>
- <el-table-column
- fixed="right"
- label="操作"
- width="80"
- v-if="type !== 'detail'"
- >
- <template slot-scope="scope">
- <el-popconfirm
- class="ele-action"
- title="确定要删除当前方案吗?"
- @confirm="handDel(scope.$index)"
- >
- <template v-slot:reference>
- <el-link
- type="danger"
- :underline="false"
- icon="el-icon-delete"
- >
- 删除
- </el-link>
- </template>
- </el-popconfirm>
- </template>
- </el-table-column>
- </el-table>
- <!-- <el-pagination
- @size-change="handleSchemeSizeChange"
- @current-change="handleSchemeCurrentChange"
- :current-page="schemePagination.currentPage"
- :page-sizes="[10, 20, 50, 100]"
- :page-size="schemePagination.pageSize"
- layout="total, sizes, prev, pager, next, jumper"
- :total="schemeList.length"
- /> -->
- </el-tab-pane>
- </el-tabs>
- </el-row>
- </template>
- <script>
- import inspectionTemplateDialog from '@/views/inspectionTemplate/components/inspectionTemplateDialog.vue';
- import {
- getDetails,
- getCategoryPackageDisposition
- } from '@/api/classifyManage/itemInformation';
- import {
- save,
- update,
- getById,
- exeReportWork,
- queryQualitySamplContent,
- queryQualityTempleContent,
- queryQualityInventory
- } from '@/api/inspectionWork';
- import { getQualityTemplateByIds } from '@/api/inspectionTemplate';
- export default {
- components: {
- inspectionTemplateDialog
- },
- watch: {
- schemeList: {
- handler(newVal, oldVal) {
- this.templateList = newVal;
- // console.log(newVal, 'schemeList');
- },
- deep: true,
- immediate: true
- },
- activeName: {
- handler(newVal) {
- this.activeNameKK = newVal;
- // console.log(newVal);
- }
- }
- },
- props: {
- type: String,
- packingList: Array,
- sampleList: Array,
- schemeList: Array,
- loading: Boolean,
- form: Object,
- ids: String,
- activeName: String,
- status: Boolean,
- productId: {
- type: String,
- default: ''
- }
- },
- data() {
- return {
- disposeTypeList: {
- 1: '返工',
- 2: '返修',
- 3: '报废',
- 4: '降级使用',
- 5: '让步接收',
- 6: '留样',
- 7: '消耗',
- 8: '回用/归批',
- 9: '转试销',
- 10: '退货'
- },
- templateList: [],
- planTemplateList: [],
- activeNameKK: '',
- samplePagination: { currentPage: 1, pageSize: 10 },
- schemePagination: { currentPage: 1, pageSize: 10 },
- qualityResultsList: [
- {
- value: 1,
- label: '合格'
- },
- {
- value: 2,
- label: '不合格'
- },
- {
- value: 3,
- label: '让步接收'
- }
- ],
- tableColumns: [
- {
- label: '样品编码',
- prop: 'sampleCode',
- width: '200',
- align: 'center',
- fixed: 'left'
- },
- {
- label: '编码',
- prop: 'categoryCode',
- align: 'center',
- fixed: 'left'
- },
- {
- label: '名称',
- prop: 'categoryName',
- align: 'center'
- },
- { label: '批次号', prop: 'batchNo', align: 'center' },
- { label: '发货条码', prop: 'barcodes', align: 'center' },
- { label: '包装编码', prop: 'packageNo', align: 'center' },
- { label: '包装数量', prop: 'packingQuantity', align: 'center' },
- { label: '包装单位', prop: 'packingUnit', align: 'center' },
- { label: '计量数量', prop: 'measureQuantity', align: 'center' },
- { label: '计量单位', prop: 'measureUnit', align: 'center' },
- {
- label: '供应商名称',
- prop: 'supplierName',
- align: 'center',
- width: '120'
- },
- {
- label: '供应商代号',
- prop: 'supplierCode',
- align: 'center',
- width: '120'
- },
- {
- label: '物料代号',
- prop: 'materielDesignation',
- align: 'center',
- slot: 'materielDesignation',
- width: '120'
- },
- {
- label: '客户代号',
- prop: 'clientCode',
- align: 'center',
- slot: 'clientCode',
- width: '120'
- },
- {
- label: '刻码',
- prop: 'engrave',
- align: 'center',
- slot: 'engrave',
- width: '120'
- },
- {
- label: '机型',
- prop: 'modelKey',
- align: 'center',
- showOverflowTooltip: true
- },
- {
- label: '颜色',
- prop: 'colorKey',
- align: 'center',
- showOverflowTooltip: true
- },
- {
- label: '重量',
- prop: 'weight',
- align: 'center',
- slot: 'weight',
- width: '120'
- },
- {
- label: '重量单位',
- prop: 'weightUnit',
- align: 'center',
- width: 100
- },
- { label: '仓库', prop: 'warehouseName', align: 'center', width: 100 },
- { label: '货区', prop: 'areaName', align: 'center' },
- { label: '货架', prop: 'goodsShelfName', align: 'center' },
- { label: '货位', prop: 'goodsAllocationName', align: 'center' },
- { label: '生产日期', prop: 'productionDate', align: 'center' },
- { label: '采购日期', prop: 'purchaseDate', align: 'center' }
- ],
- conditionType: null,
- formData: {
- number: 1,
- sampleUnit: '',
- portion: null,
- packingUnit: ''
- },
- rules: {
- number: [
- {
- required: true,
- message: '请输入',
- trigger: 'blur'
- }
- ],
- sampleUnit: [
- {
- required: true,
- message: '请选择样品单位',
- trigger: 'change'
- }
- ],
- portion: [
- {
- required: true,
- message: '请输入',
- trigger: 'blur'
- }
- ],
- packingUnit: [
- {
- required: true,
- message: '请选择',
- trigger: 'change'
- }
- ]
- },
- packingSpecificationOption: [] // 包装规格下拉
- };
- },
- computed: {
- showBtn() {
- return this.$route.query.qualityType == 2;
- },
- tableColumns1() {
- let arr = [
- // (this.btnType !== 'issued' || this.baseForm.qualityMode === 2)
- // ? {
- // columnKey: 'selection',
- // type: 'selection',
- // width: 45,
- // align: 'center'
- // }
- // : null,
- {
- columnKey: 'selection',
- type: 'selection',
- width: 45,
- align: 'center'
- },
- {
- columnKey: 'index',
- label: '序号',
- type: 'index',
- width: 55,
- align: 'center',
- fixed: 'left'
- },
- {
- label: '编码',
- prop: 'categoryCode',
- width: 150,
- align: 'center',
- showOverflowTooltip: true
- },
- {
- label: '名称',
- prop: 'categoryName',
- width: '150',
- align: 'center',
- width: 120,
- showOverflowTooltip: true
- },
- {
- label: '批次号',
- prop: 'batchNo',
- align: 'center',
- width: 120,
- showOverflowTooltip: true
- },
- {
- label: '发货条码',
- prop: 'barcodes',
- align: 'center',
- showOverflowTooltip: true
- },
- {
- label: '包装编码',
- prop: 'packageNo',
- align: 'center',
- width: 120,
- showOverflowTooltip: true
- },
- { label: '包装数量', prop: 'packingQuantity', align: 'center' },
- { label: '包装单位', prop: 'packingUnit', align: 'center' },
- // {
- // label: '包装规格',
- // prop: 'packingSpecification',
- // align: 'center',
- // width: 180
- // },
- { label: '计量数量', prop: 'measureQuantity', align: 'center' },
- { label: '计量单位', prop: 'measureUnit', align: 'center' },
- { label: '物料代号', prop: 'materielDesignation', align: 'center' },
- { label: '客户代号', prop: 'clientCode', align: 'center' },
- {
- label: '供应商名称',
- prop: 'supplierName',
- align: 'center',
- width: 120,
- showOverflowTooltip: true
- },
- {
- label: '供应商代号',
- prop: 'supplierCode',
- align: 'center',
- width: '120',
- showOverflowTooltip: true
- },
- { label: '刻码', prop: 'engrave', align: 'center' },
- {
- label: '机型',
- prop: 'modelKey',
- align: 'center',
- showOverflowTooltip: true
- },
- {
- label: '颜色',
- prop: 'colorKey',
- align: 'center',
- showOverflowTooltip: true
- },
- { label: '重量', prop: 'weight', align: 'center' },
- { label: '重量单位', prop: 'weightUnit', align: 'center' },
- {
- label: '仓库',
- prop: 'warehouseName',
- align: 'center',
- width: 120,
- showOverflowTooltip: true
- },
- { label: '货区', prop: 'areaName', align: 'center' },
- { label: '货架', prop: 'goodsShelfName', align: 'center' },
- { label: '货位', prop: 'goodsAllocationName', align: 'center' },
- {
- label: '生产日期',
- prop: 'productionDate',
- align: 'center',
- width: 120,
- showOverflowTooltip: true
- },
- {
- label: '采购日期',
- prop: 'purchaseDate',
- align: 'center',
- width: 120,
- showOverflowTooltip: true
- }
- ];
- return arr;
- },
- // 分页后的样品列表
- paginatedSampleList() {
- // const { currentPage, pageSize } = this.samplePagination;
- // const start = (currentPage - 1) * pageSize;
- // const end = start + pageSize;
- // return this.sampleList?.slice(start, end);
- return this.sampleList;
- },
- // 分页后的质检方案列表
- paginatedSchemeList() {
- // const { currentPage, pageSize } = this.schemePagination;
- // const start = (currentPage - 1) * pageSize;
- // const end = start + pageSize;
- // console.log(this.templateList,'全部数据')
- // return this.templateList?.slice(start, end);
- return this.templateList;
- }
- },
- created() {
- this.activeNameKK = this.activeName;
- this.reload({ qualityWorkerId: this.ids });
- let direction = this.$getDirection();
- direction.on('keyup', function (e, val) {
- if (e.keyCode == 39) {
- direction.next();
- }
- if (e.keyCode == 37) {
- direction.previous();
- }
- if (e.keyCode == 38) {
- direction.previousLine();
- }
- if (e.keyCode == 40) {
- direction.nextLine();
- }
- });
- },
- methods: {
- //合格数量变化设置样品清单 全减并且不拆包才执行
- setSampleList(val, total) {
- this.$set(this.sampleList[0], 'measureQuantity', val);
- let weight = this.form.totalWeight / total;
- let arr = [];
- for (let i = 0; i < total - val; i++) {
- let data = JSON.parse(JSON.stringify(this.sampleList[0]));
- data['measureQuantity'] = 1;
- data['qualityResults'] = 2;
- data['qualityStatus'] = 1;
-
- data['id'] = '';
- data['weight'] = parseFloat(weight).toFixed(2);
- arr.push(data);
- }
- this.$set(this.sampleList[0], 'weight',parseFloat(val*weight).toFixed(2));
- this.sampleList = [this.sampleList[0], ...arr];
- this.$emit('sampleListChange', this.sampleList);
- },
- async datasource({ page, limit, where }) {
- console.log('执行33');
- const res = await queryQualityInventory({
- ...where,
- pageNum: page,
- // size: limit
- size: -1
- });
- if (res.list.length == 0) {
- return res;
- }
- // 包装数量的字段
- // if (!this.productId) {
- // return res;
- // }
- // const result = await getCategoryPackageDisposition({
- // categoryIds: [this.productId]
- // });
- // let str = '';
- // if (result.length) {
- let o = res.list[0];
- let listArr = [];
- if (o.measureUnit) {
- listArr.push({
- packageCellTotal: 1,
- conversionUnit: o.measureUnit,
- id: '111'
- });
- }
- if (o.packingUnit) {
- listArr.push({
- packageCellTotal: o.measureQuantity - 0,
- conversionUnit: o.packingUnit,
- id: '222'
- });
- }
- // result.map((el, index) => {
- // // let Unit = el.conversionUnit.trim();
- // // if (Unit == o.packingUnit.trim() || Unit == o.measureUnit.trim()) {
- // // listArr.push(el);
- // // }
- // if (index == 0) {
- // // el.packageCellTotal = el.packageCell - 0;
- // return;
- // }
- // if (index === result.length - 1) {
- // str = `${str}${el.packageCell}${el.packageUnit}/${el.conversionUnit}`;
- // } else {
- // str = `${str}${el.packageCell}${el.packageUnit}/${el.conversionUnit},`;
- // }
- // // if (index == 1) {
- // // el.packageCellTotal = el.packageCell - 0;
- // // return;
- // // }
- // // 计算乘法的规则
- // // el.packageCellTotal =
- // // el.packageCell * result[index - 1].packageCellTotal;
- // });
- res.list.map((el) => {
- el.weightProportion = el.weight
- ? (el.weight / el.measureQuantity).toFixed(4)
- : 0;
- el.weightProportion = el.weightProportion - 0;
- });
- this.packingSpecificationOption = listArr;
- return res;
- },
- reload(where) {
- this.$nextTick(() => {
- if (this.$refs.sourceTable && this.$refs.sourceTable.reload)
- this.$refs.sourceTable.reload({ page: 1, where: where });
- });
- },
- tableSelClear() {
- this.$refs.sourceTable.clearSelection();
- },
- handleSelectionChange(selection) {
- if (this.form.conditionType == 2) {
- if (this.form.isUnpack == 2) {
- this.$set(this.form, 'sampleNumber', this.formData.portion);
- } else {
- this.formData.portion = selection.length;
- this.$set(this.form, 'sampleNumber', selection.length);
- }
- this.formData.sampleUnit = selection[0]?.measureUnit;
- this.$set(this.form, 'sampleMeasureUnit', selection[0]?.measureUnit);
- } else if (this.form.conditionType == 1) {
- this.$set(this.form, 'sampleNumber', this.formData.portion);
- }
- // this.formData.portion = selection.length;
- // this.formData.sampleUnit = selection[0]?.measureUnit;
- //
- // this.$set(this.form, 'sampleNumber', selection.length);
- // this.$set(this.form, 'sampleMeasureUnit', selection[0]?.measureUnit);
- this.$emit('handleSelectionChange', selection);
- },
- handleSampleNumber(val) {
- this.conditionType = val;
- this.form.sampleUnit = '';
- this.$emit('getConditionType', val);
- //取整样
- // let data = this.$refs.sourceTable.getData()
- // this.$emit('getSelectedList')
- // if (this.selectedList.length == 0) {
- // this.$message.warning('请先选择样品!');
- // }
- // if (val == 1) {
- // // this.activeName = '2'
- // this.$emit('handleSample1', val, data)
- // } else if (val == 2) {
- // this.tableSelClear();
- // this.$emit('handleSample1', val, data)
- // }
- },
- handleInputNumber(val) {
- let packingList = this.$refs.sourceTable.getData();
- const maxValue =
- packingList.length > 1
- ? packingList.length
- : packingList[0].measureQuantity;
- if (val > maxValue) {
- this.$message.warning('数量不能大于计量数量!');
- this.formData.number = maxValue;
- return;
- }
- },
- handleInput(val) {
- if (val == 0 || val == '' || val == null) {
- this.$refs.sourceTable.clearSelection();
- return;
- }
- let packingList = this.$refs.sourceTable.getData();
- if (!packingList || packingList.length === 0) {
- return;
- }
- // 计算 packingList 中 measureQuantity 字段的总和
- const measureQuantitySum = packingList.reduce((sum, item) => {
- const quantity = Number(item.measureQuantity) || 0;
- return sum + quantity;
- }, 0);
- const portion = Number(this.formData.portion);
- // 清空当前选中
- this.$refs.sourceTable.clearSelection();
- if (this.form.conditionType == 2) {
- // 确保 portion 不超过数据列表长度
- const safePortion = Math.min(portion, packingList.length);
- if (this.form.isUnpack == 2) {
- const maxQuantity = Number(packingList[0].measureQuantity);
- if (portion > maxQuantity) {
- this.$message.warning('取样数量不能大于计量数量!');
- this.formData.portion = maxQuantity;
- }
- } else if (this.form.isUnpack == 1) {
- if (portion > packingList.length) {
- this.$message.warning('取样数量不能大于来源清单数量!');
- this.formData.portion = packingList.length;
- }
- }
- packingList.slice(0, safePortion).forEach((row) => {
- this.$refs.sourceTable.toggleRowSelection(row);
- });
- } else if (this.form.conditionType == 1) {
- // 确保 portion 不超过数据列表长度
- const safePortion = Math.min(portion, measureQuantitySum);
- if (portion > measureQuantitySum) {
- this.$message.warning('取样数量不能大于计量数量!');
- this.formData.portion = measureQuantitySum;
- }
- // 选中前 safePortion 行
- packingList.slice(0, safePortion).forEach((row) => {
- this.$refs.sourceTable.toggleRowSelection(row, true);
- });
- }
- // if (packingList.length > 1) {
- // if (portion > packingList.length) {
- // this.$message.warning('取样数量不能大于来源清单数量!');
- // this.formData.portion = packingList.length;
- // return;
- // }
- // packingList.slice(0, this.formData.portion).forEach(row => {
- // this.$refs.table12.toggleRowSelection(row);
- // });
- // } else {
- // const maxQuantity = Number(packingList[0].measureQuantity);
- // if (portion > maxQuantity) {
- // this.$message.warning('取样数量不能大于计量数量!');
- // this.formData.portion = maxQuantity;
- // return;
- // }
- // }
- },
- changeSamUnit(val) {
- this.$emit('changeSamUnit', val);
- },
- handleSampleSubmit() {
- this.$refs.ruleForm.validate((valid) => {
- if (valid) {
- //取小样 赋值右上角单位
- this.changeSamUnit(this.formData.sampleUnit);
- let params = {
- conditionType: this.conditionType,
- measureQ: this.formData.number,
- sampleUnit: this.formData.sampleUnit,
- portion: this.formData.portion
- };
- let specifications = this.packingSpecificationOption.find(
- (el) => el.id == this.formData.packingUnit
- );
- console.log('执行这里没', params, '---');
- this.$emit('handleSampleSubmit', params, specifications);
- }
- });
- },
- handleClick(tab) {
- this.activeNameKK = tab.name;
- },
- tabsChange(val) {
- this.activeNameKK = val;
- },
- tabsConditionType(val) {
- this.conditionType = val;
- },
- checkSelectable(row, index) {
- // 只有当质检方式为抽检(qualityMode=2)时 类型不是生产检验 才可选
- return this.form.qualityType != 2 && this.form.qualityMode === 2;
- },
- handleDetail(index, row, type) {
- this.$emit('handleDetail', index, row, type);
- },
- inputWeight(row, index) {
- this.$emit('inputWeight', row, index);
- },
- handleDispose(index, row, type) {
- this.$emit('handleDispose', { row, index });
- },
- handleSampleSizeChange(val) {
- this.samplePagination.pageSize = val;
- this.samplePagination.currentPage = 1;
- },
- handleSampleCurrentChange(val) {
- this.samplePagination.currentPage = val;
- },
- handleSchemeSizeChange(val) {
- this.schemePagination.pageSize = val;
- this.schemePagination.currentPage = 1;
- },
- handleSchemeCurrentChange(val) {
- this.schemePagination.currentPage = val;
- },
- selectQualityResultsChange() {
- this.$emit('countQualityResults');
- },
- addInspectionTemplate() {
- let type = this.form.qualityType || 1;
- this.$refs.inspectionTemplateRef.open(type);
- },
- async inspectionTemplateSuccess(select) {
- let data = await getQualityTemplateByIds({
- templateIds: select.map((item) => item.id)
- });
- data.forEach((item) => {
- item.id = null;
- });
- // 这里是选择方案后,数据新加,要改为覆盖
- // this.templateList.push(...data);
- // const strings = this.templateList.map((item) => JSON.stringify(item));
- // const removeDupList = [...new Set(strings)];
- // const result = removeDupList.map((item) => JSON.parse(item));
- this.templateList = [];
- this.templateList.push(...data);
- this.templateList.forEach((item) => {
- item['qualityResults'] = 1;
- });
- // this.templateList = result.map((item) => {
- // item['qualityResults'] = 1;
- // return item;
- // });
- this.sampleList.forEach((item, index) => {
- this.$set(
- this.sampleList[index],
- 'qualitySampleTemplateList',
- this.templateList
- );
- });
- this.$set(this.form, 'templateList', this.templateList);
- this.$emit('setSchemeList', this.templateList);
- // this.schemeList = this.templateList;
- this.schemePagination.total = this.templateList.length;
- },
- handDel(index) {
- this.templateList.splice(index, 1);
- this.sampleList.forEach((item, index) => {
- this.$set(
- this.sampleList[index],
- 'qualitySampleTemplateList',
- this.templateList.map((item) => {
- item['qualityResults'] = 1;
- return item;
- })
- );
- });
- }
- }
- };
- </script>
|