| 123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886887888889890891892893894895896897898899900901902903904905906907908909910911912913914915916917918919920921922923924925926927928929930931932933934935936937938939940941942943944945946947948949950951952953954955956957958959960961962963964965966967968969970971972973974975976977978979980981982983984985986987988989990991992993994995996997998999100010011002100310041005100610071008100910101011101210131014101510161017101810191020102110221023102410251026102710281029103010311032103310341035103610371038103910401041104210431044104510461047104810491050105110521053105410551056105710581059106010611062106310641065106610671068106910701071107210731074107510761077107810791080108110821083108410851086108710881089109010911092109310941095109610971098109911001101110211031104110511061107110811091110111111121113111411151116111711181119112011211122112311241125112611271128112911301131113211331134113511361137113811391140114111421143114411451146114711481149115011511152115311541155115611571158115911601161116211631164116511661167116811691170117111721173117411751176117711781179118011811182118311841185118611871188118911901191119211931194119511961197119811991200120112021203120412051206120712081209121012111212121312141215121612171218121912201221122212231224122512261227122812291230123112321233123412351236123712381239124012411242124312441245124612471248124912501251125212531254125512561257125812591260126112621263126412651266126712681269127012711272127312741275127612771278127912801281128212831284128512861287128812891290129112921293129412951296129712981299130013011302130313041305130613071308130913101311131213131314131513161317131813191320132113221323132413251326132713281329133013311332133313341335133613371338133913401341134213431344134513461347134813491350135113521353135413551356135713581359136013611362136313641365136613671368136913701371137213731374137513761377137813791380138113821383138413851386138713881389139013911392139313941395139613971398139914001401140214031404140514061407140814091410141114121413141414151416141714181419142014211422142314241425142614271428142914301431143214331434143514361437143814391440144114421443144414451446144714481449145014511452145314541455145614571458145914601461146214631464146514661467146814691470147114721473147414751476147714781479148014811482148314841485148614871488148914901491149214931494149514961497149814991500150115021503150415051506150715081509151015111512151315141515151615171518151915201521152215231524152515261527152815291530153115321533153415351536153715381539154015411542154315441545154615471548154915501551155215531554155515561557155815591560156115621563156415651566156715681569157015711572157315741575157615771578157915801581158215831584158515861587158815891590159115921593159415951596159715981599160016011602160316041605160616071608160916101611161216131614161516161617161816191620162116221623162416251626162716281629163016311632163316341635163616371638163916401641164216431644164516461647164816491650165116521653165416551656165716581659166016611662166316641665166616671668166916701671167216731674167516761677167816791680168116821683168416851686168716881689169016911692169316941695169616971698169917001701170217031704170517061707170817091710171117121713171417151716171717181719172017211722172317241725172617271728172917301731173217331734173517361737173817391740174117421743174417451746174717481749175017511752175317541755175617571758175917601761176217631764176517661767176817691770177117721773177417751776177717781779178017811782178317841785178617871788178917901791179217931794179517961797179817991800180118021803180418051806180718081809181018111812181318141815181618171818181918201821182218231824182518261827182818291830183118321833183418351836183718381839184018411842184318441845184618471848184918501851185218531854185518561857185818591860186118621863186418651866186718681869187018711872187318741875187618771878187918801881188218831884188518861887188818891890189118921893189418951896189718981899190019011902190319041905190619071908190919101911191219131914191519161917191819191920192119221923192419251926192719281929193019311932193319341935193619371938193919401941194219431944194519461947194819491950195119521953195419551956195719581959196019611962196319641965196619671968196919701971197219731974197519761977197819791980198119821983198419851986198719881989199019911992199319941995199619971998199920002001200220032004200520062007200820092010201120122013201420152016201720182019202020212022202320242025202620272028202920302031203220332034203520362037203820392040204120422043204420452046204720482049205020512052205320542055205620572058205920602061206220632064206520662067206820692070207120722073207420752076207720782079208020812082208320842085208620872088208920902091209220932094209520962097209820992100210121022103210421052106210721082109211021112112211321142115211621172118211921202121212221232124212521262127212821292130213121322133213421352136213721382139214021412142214321442145214621472148214921502151215221532154215521562157215821592160216121622163216421652166216721682169217021712172217321742175217621772178217921802181218221832184218521862187218821892190219121922193219421952196219721982199220022012202220322042205220622072208220922102211221222132214221522162217221822192220222122222223222422252226222722282229223022312232223322342235223622372238223922402241224222432244224522462247224822492250225122522253225422552256225722582259226022612262226322642265226622672268226922702271227222732274227522762277227822792280228122822283228422852286228722882289229022912292229322942295229622972298229923002301230223032304230523062307230823092310231123122313231423152316231723182319232023212322232323242325232623272328232923302331233223332334233523362337233823392340234123422343234423452346234723482349235023512352235323542355235623572358235923602361236223632364236523662367236823692370237123722373237423752376237723782379238023812382238323842385238623872388238923902391239223932394239523962397239823992400240124022403240424052406240724082409241024112412241324142415241624172418241924202421242224232424242524262427242824292430243124322433243424352436243724382439244024412442244324442445244624472448244924502451245224532454245524562457245824592460246124622463246424652466246724682469 |
- <template>
- <div class="ele-body" v-loading="loading">
- <div class="switch" v-if="this.qualityType == 2">
- <div class="switch_left">
- <ul>
- <li
- v-for="item in tabOptions"
- :key="item.key"
- :class="{ active: activeComp == item.key }"
- @click="activeComp = item.key"
- >
- {{ item.name }}
- </li>
- </ul>
- </div>
- </div>
- <el-card shadow="never" v-show="activeComp == 'main'">
- <header-title title="基本信息">
- <el-button @click="cancel">返回</el-button>
- <el-button
- type="primary"
- @click="save"
- :loading="loading"
- v-if="type != 'detail'"
- >保存</el-button
- >
- <el-button
- type="primary"
- @click="handleReporting"
- :loading="loading"
- v-if="type != 'detail'"
- >报工完成</el-button
- >
- </header-title>
- <base-info
- ref="baseInfoRefs"
- v-if="form"
- :form="form"
- :btnType="type"
- :qualityType1="qualityType"
- @changeModel="changeModel"
- @changeNumber="changeNumber"
- @quantityAssignment="quantityAssignment"
- @changeInspectionStandardsModel="changeInspectionStandardsModel"
- @quantityCalculation="quantityCalculation"
- ></base-info>
- <header-title title="样品信息"></header-title>
- <el-form label-width="130px">
- <el-row>
- <el-col :span="6">
- <el-form-item label="样品合格数:" prop="sampleQualifiedNumber">
- <el-input
- type="number"
- :min="0"
- disabled
- v-model="form.sampleQualifiedNumber"
- placeholder=""
- >
- <template slot="append">{{
- sampleList[0]?.measureUnit
- }}</template>
- </el-input>
- </el-form-item>
- </el-col>
- <el-col :span="6">
- <el-form-item label="样品不合格数:" prop="sampleNoQualifiedNumber">
- <el-input
- type="number"
- :min="0"
- disabled
- v-model="form.sampleNoQualifiedNumber"
- placeholder=""
- >
- <template slot="append">{{
- sampleList[0]?.measureUnit
- }}</template></el-input
- >
- </el-form-item>
- </el-col>
- <el-col :span="6">
- <el-form-item label="样品合格率:" prop="sampleQualificationRate">
- <el-input
- v-model="form.sampleQualificationRate"
- disabled
- type="text"
- >
- </el-input>
- </el-form-item>
- </el-col>
- <el-col :span="6">
- <el-form-item
- label="样品不合格率:"
- prop="sampleNoQualificationRate"
- >
- <el-input
- v-model="form.sampleNoQualificationRate"
- disabled
- type="text"
- >
- </el-input>
- </el-form-item>
- </el-col>
- </el-row>
- <el-row>
- <el-col :span="6">
- <el-form-item label="样品类型:" prop="samplesType">
- <el-input disabled :value="sampletypeVal(form.conditionType)" />
- </el-form-item>
- </el-col>
- <el-col :span="6">
- <el-form-item label="记录方法:" prop="recordingMethod">
- <el-select
- style="width: 100%"
- v-model="form.recordingMethod"
- placeholder="请选择"
- :disabled="isDisabled"
- @change="recordingMethodChange"
- >
- <el-option
- v-for="item in recordingMethodList"
- :label="item.label"
- :value="item.value"
- :key="item.value"
- ></el-option>
- </el-select>
- <!-- <el-input
- disabled
- :value="
- recordingMethodList.find(
- (item) => item.value == form.recordingMethod
- )?.label
- "
- /> -->
- </el-form-item>
- </el-col>
- <el-col :span="6">
- <el-form-item label="样品数量:" prop="sampleQuantity">
- <el-input type="number" disabled v-model="form.sampleQuantity">
- <template slot="append">{{
- sampleList[0]?.measureUnit
- }}</template></el-input
- >
- </el-form-item>
- </el-col>
- <el-col :span="6">
- <el-form-item label="样品重量:" prop="sampleWeight">
- <el-input type="number" disabled v-model="form.sampleWeight" />
- </el-form-item>
- </el-col>
- </el-row>
- <el-row>
- <el-col :span="6">
- <el-form-item label="留样数(合格品):" prop="retainedSampleQuantity">
- <el-input
- v-model="form.retainedSampleQuantity"
- :disabled="
- default_disposal_type == 1 || form.recordingMethod == 1
- "
- @input="
- inputValue('retainedSampleQuantity', 'sampleQualifiedNumber')
- "
- ><template slot="append">{{
- sampleList[0]?.measureUnit
- }}</template></el-input
- >
- </el-form-item>
- </el-col>
- <el-col :span="6">
- <el-form-item
- label="留样数(不合格品):"
- prop="retainedSampleUnqualified"
- >
- <el-input
- v-model="form.retainedSampleUnqualified"
- :disabled="
- default_disposal_type == 1 || form.recordingMethod == 1
- "
- @input="
- inputValue(
- 'retainedSampleUnqualified',
- 'sampleNoQualifiedNumber'
- )
- "
- ><template slot="append">{{
- sampleList[0]?.measureUnit
- }}</template></el-input
- >
- </el-form-item>
- </el-col>
- <el-col :span="6">
- <el-form-item label="损耗数(合格品):" prop="lossNumber">
- <el-input
- v-model="form.lossNumber"
- :disabled="
- default_disposal_type == 1 || form.recordingMethod == 1
- "
- @input="inputValue('lossNumber', 'sampleQualifiedNumber')"
- ><template slot="append">{{
- sampleList[0]?.measureUnit
- }}</template></el-input
- >
- </el-form-item>
- </el-col>
- <el-col :span="6">
- <el-form-item
- label="损耗数(不合格品):"
- prop="lossNumberUnqualified"
- >
- <el-input
- v-model="form.lossNumberUnqualified"
- :disabled="
- default_disposal_type == 1 || form.recordingMethod == 1
- "
- @input="
- inputValue('lossNumberUnqualified', 'sampleNoQualifiedNumber')
- "
- ><template slot="append">{{
- sampleList[0]?.measureUnit
- }}</template></el-input
- >
- </el-form-item>
- </el-col>
- </el-row>
- </el-form>
- <quality-content-tabs
- v-if="form.id"
- ref="tabsRef"
- :type="type"
- :ids="this.$route.query.id"
- :sample-list="sampleList"
- :activeName="activeName"
- :scheme-list="schemeList"
- :loading="loading"
- :form="form"
- :productId="productId"
- :status="statusType"
- :fileParam="form.fileParam"
- @handleSelectionChange="handleSelectionChange1"
- @batch-quality="batchQuality"
- @batch-dispose="batchDispose"
- @handleDetail="handleDetail"
- @inputWeight="inputWeight"
- @handleDispose="handleDispose"
- @changeSamUnit="changeSamUnit"
- @handleSample1="handleSample1"
- @handleSampleSubmit="handleSampleSubmit"
- @getConditionType="getConditionType"
- @countQualityResults="countQualityResults"
- @getSampleQuantity="getSampleQuantity"
- @setSchemeList="setSchemeList"
- @sampleListChange="sampleListChange"
- @inspectionProjectReport="inspectionProjectReport"
- @setSchemeListChange="setSchemeListChange"
- />
- </el-card>
- <pickOrderList
- :list="form.orderInfoList"
- v-show="activeComp == 'pickOrderListShow'"
- ></pickOrderList>
- <sampleListDialog
- ref="detailRef"
- @handleConfirm="handleConfirm"
- @handleDispose="handleDispose"
- ></sampleListDialog>
- <sampleDisposeDialog
- v-if="sampleDisposeVisble"
- :sampleDisposeVisble.sync="sampleDisposeVisble"
- ref="disposeRef"
- @handleDisposeConfirm="handleDisposeConfirm"
- :rowData="rowData"
- @close="closeDispose"
- @handleDispose="handleDispose"
- ></sampleDisposeDialog>
- <inspectionProjectReport
- ref="inspectionProjectReportRef"
- @success="inspectionProjectReportSuccess"
- ></inspectionProjectReport>
- </div>
- </template>
- <script>
- import baseInfo from './components/baseInfo.vue';
- // import QualityContentTabs from './components/QualityContentTabs.vue';
- import QualityContentTabs from './components/newQualityContentTabs.vue';
- import pickOrderList from './components/pickOrderList/index.vue'; //领料记录
- import { recordingMethodList } from '@/utils/util.js';
- import { parameterGetByCode } from '@/api/main/index';
- import { getCode, getCodeList } from '@/api/login';
- import {
- save,
- update,
- getById,
- exeReportWork,
- queryQualitySamplContent,
- queryQualityTempleContent,
- queryQualityInventory
- } from '@/api/inspectionWork';
- import dictMixins from '@/mixins/dictMixins';
- // import term from './term';
- import sampleListDialog from './components/sampleListDialog.vue';
- import sampleDisposeDialog from './components/sampleDisposeDialog.vue';
- import inspectionProjectReport from './components/inspectionProjectReport.vue';
- import { finishPageTab } from '@/utils/page-tab-util';
- export default {
- components: {
- baseInfo,
- QualityContentTabs,
- sampleListDialog,
- sampleDisposeDialog,
- pickOrderList,
- inspectionProjectReport
- },
- mixins: [dictMixins],
- computed: {
- isDisabled() {
- if (
- this.form.taskMonadList?.length ||
- this.form.requestEntrustList?.length ||
- this.form.isUpdate == 1
- ) {
- return true;
- }
- return false;
- },
- sampletypeVal() {
- return (row) => {
- if (row == 1) {
- return '整样';
- }
- return '小样';
- };
- },
- //按样品
- getSampleQuantityYp() {
- return (key) => {
- let num = 0;
- this.form.taskMonadList?.forEach((item) => {
- num += Number(item[key]) || 0;
- });
- this.form.requestEntrustList?.forEach((item) => {
- num += Number(item[key]) || 0;
- });
- return num;
- };
- }
- },
- beforeRouteLeave(to, from, next) {
- this.$refs.inspectionProjectReportRef.handleClose();
- this.$nextTick(() => {
- next();
- });
- },
- data() {
- const defaultForm = function () {
- return {
- code: '',
- qualityType: null,
- qualityModeproduceRoutingId: '',
- produceRoutingName: '',
- produceTaskId: '',
- produceTaskName: '',
- productName: '',
- productCode: '',
- batchNo: '',
- specification: '',
- modelType: '',
- brandNo: '',
- total: '',
- qualifiedNumber: '',
- noQualifiedNumber: '',
- groupId: '',
- groupName: '',
- qualityId: '',
- qualityName: '',
- qualityTime: '',
- hours: '',
- qualificationRate: '',
- noQualificationRate: '',
- totalWeight: '',
- sampleNumber: '',
- imgUrl: [],
- qualityTimeStart: '',
- qualityTimeEnd: '',
- templateList: [],
- qualityIdList: [],
- sampleMeasureUnit: '',
- conditionType: null,
- taskMonadInfo: {
- lossNumber: 0,
- lossNumberUnqualified: 0,
- retainedSampleQuantity: 0,
- retainedSampleUnqualified: 0,
- sampleNoQualifiedNumber: 0,
- sampleQualifiedNumber: 0,
- sampleQuantity: 0,
- type: 2,
- qualityWorkOrderId: ''
- }
- };
- };
- return {
- default_disposal_type: 2,
- recordingMethodList,
- activeComp: 'main',
- tabOptions: [
- { key: 'main', name: '报工' },
- { key: 'pickOrderListShow', name: '领料记录' }
- ],
- rowData: null,
- defaultForm,
- sampleDisposeVisble: false,
- // 表单数据
- form: { ...defaultForm() },
- voList: [],
- // 表单验证规则
- categoryParamList: [],
- type: '',
- title: '',
- loading: false,
- tabTaskId: null,
- // activeName: '2',
- packingList: [],
- // 样品清单,处置,批量处置,批量检测,检测的操作
- sampleList: [],
- schemeList: [],
- inventoryList: [],
- activeName: '1',
- isValid: true,
- isStatus: true,
- SampleListbyReportList: [],
- qualityTimeStart: '',
- isReportProcessProduce: false,
- addStatus: [],
- statusType: false
- };
- },
- watch: {
- '$route.query.id': {
- handler(id) {
- if (id) {
- this.getDetail();
- } else {
- this.form = { ...defaultForm() };
- }
- }
- },
- // 样品清单
- sampleList: {
- handler(newVal) {
- if (!newVal || newVal.length == 0) {
- return;
- }
- console.log(newVal, 'newVal 12');
- // 默认赋值检测结果
- this.setInspectionResults(newVal);
- },
- deep: true,
- immediate: true
- },
- form: {
- handler(newVal) {
- console.log(newVal, 'newVal 新的form');
- },
- deep: true,
- immediate: true
- },
- 'form.sampleQualifiedNumber': {
- handler(newVal) {
- if (this.form.recordingMethod == 2) {
- if (this.default_disposal_type == 1) {
- this.form.lossNumber = newVal;
- this.form.lossNumberUnqualified =
- this.form.sampleNoQualifiedNumber;
- } else {
- [
- 'retainedSampleQuantity',
- 'lossNumber',
- 'retainedSampleUnqualified',
- 'lossNumberUnqualified'
- ].forEach((item) => {
- this.form[item] = 0;
- });
- }
- }
- },
- deep: true,
- immediate: true
- },
- 'form.qualityResults': {
- handler(newVal, oldVal) {
- if (!newVal && oldVal) {
- this.form.qualityResults = oldVal;
- }
- }
- }
- },
- created() {
- //样品默认处置类型:1、自动消耗 2、不自动消耗
- parameterGetByCode({
- code: 'default_disposal_type'
- }).then((res) => {
- this.default_disposal_type = res.value;
- });
- this.open();
- if (this.$route.query.id) {
- this.getDetail();
- }
- },
- methods: {
- recordingMethodChange() {
- this.$nextTick(() => {
- if (this.form.recordingMethod != 1) {
- this.$refs.tabsRef.$refs.showSampleListTable.doLayout();
- this.countQualityResults();
- }
- });
- },
- //按质检项同步质检请托单数据
- getSampleQuantity() {
- let sampleQuantity = this.form.sampleQuantity; //剩余样品数
- //样品不合格:获取质检请托、质检任务、质检工单、最大不合格数,样品合格:样品数-样品不合格
- //损耗不合格:获取质检请托、质检任务、质检工单、最大损耗不合格数
- //损耗合格:获取质检请托、质检任务、质检工单、最大损耗合格数 损耗合格+损耗不合格>样品数 损耗合格=样品数-损耗不合格 损耗合格>样品合格 损耗合格=样品合格
- //留样不合格:获取质检请托、质检任务、质检工单、最大留样不合格数 损耗合格+损耗不合格+留样不合格>样品数 留样不合格=样品数-损耗不合格-损耗合格 留样不合格>样品不合格 留样不合格=样品不合格
- //留样合格:获取质检请托、质检任务、质检工单、最大留样合格数 损耗合格+损耗不合格+留样不合格+留样合格>样品数 留样不合格=样品数-损耗不合格-损耗合格-留样不合格 留样合格>样品合格 留样合格=样品合格
- [
- 'sampleNoQualifiedNumber',
- 'sampleQualifiedNumber',
- 'lossNumberUnqualified',
- 'lossNumber',
- 'retainedSampleUnqualified',
- 'retainedSampleQuantity'
- ].forEach((key) => {
- let arr = [Number(this.form.taskMonadInfo?.[key]) || 0];
- [...this.form.taskMonadList, ...this.form.requestEntrustList].forEach(
- (item) => {
- if (item) {
- arr.push(Number(item[key]) || 0);
- }
- }
- );
- this.form[key] = Math.max(...arr);
- if (sampleQuantity < 0) {
- return;
- }
- if (key == 'sampleQualifiedNumber') {
- this.form.sampleQualifiedNumber =
- this.form.sampleQuantity - this.form.sampleNoQualifiedNumber;
- }
- if (key == 'lossNumber') {
- if (this.form.lossNumber > sampleQuantity) {
- this.form.lossNumber = sampleQuantity;
- }
- if (this.form.lossNumber > this.form.sampleQualifiedNumber) {
- this.form.lossNumber = this.form.sampleQualifiedNumber;
- }
- }
- if (key == 'retainedSampleUnqualified') {
- if (this.form.retainedSampleUnqualified > sampleQuantity) {
- this.form.lossNumber = sampleQuantity;
- }
- if (
- Number(this.form.retainedSampleUnqualified || 0) +
- Number(this.form.lossNumberUnqualified || 0) >
- this.form.sampleNoQualifiedNumber
- ) {
- this.form.retainedSampleUnqualified =
- this.form.sampleNoQualifiedNumber -
- this.form.lossNumberUnqualified;
- }
- }
- if (key == 'retainedSampleQuantity') {
- if (this.form.retainedSampleQuantity > sampleQuantity) {
- this.form.retainedSampleQuantity = sampleQuantity;
- }
- if (
- Number(this.form.retainedSampleQuantity || 0) +
- Number(this.form.lossNumber || 0) >
- this.form.sampleQualifiedNumber
- ) {
- this.form.retainedSampleQuantity =
- this.form.sampleQualifiedNumber - this.form.lossNumber;
- }
- }
- if (
- !['sampleQualifiedNumber', 'sampleNoQualifiedNumber'].includes(key)
- ) {
- sampleQuantity = sampleQuantity - this.form[key];
- }
- });
- this.form.sampleNoQualificationRate =
- (
- (this.form.sampleNoQualifiedNumber / this.form.sampleQuantity) *
- 100
- ).toFixed(2) + '%';
- this.form.sampleQualificationRate =
- (
- (this.form.sampleQualifiedNumber / this.form.sampleQuantity) *
- 100
- ).toFixed(2) + '%';
- this.quantityAssignment();
- },
- //合格与不合格数变化处理逻辑
- quantityCalculation(val) {
- this.$refs.tabsRef.setSampleList(val, this.form.total);
- },
- setInspectionResults(list) {
- this.$nextTick(() => {
- let qualityResults = this.form.qualityResults;
- let showArrange = this.$refs.baseInfoRefs.showArrange;
- if (
- showArrange == '1' ||
- (showArrange == '2' && this.form.qualityMode != '2')
- ) {
- return;
- }
- if (qualityResults == null || qualityResults == undefined) {
- for (let i = 0; i < list.length; i++) {
- let el = list[i];
- if (el.qualityResults == 2) {
- this.$set(this.form, 'qualityResults', 2);
- return;
- }
- }
- this.$set(this.form, 'qualityResults', 1);
- // this.$set(this.form, 'status', 1);
- console.log(list, 'list');
- console.log(this.form.qualityResults, '检测结果');
- }
- });
- },
- inputValue(key, totalKey) {
- if (totalKey == 'sampleQualifiedNumber') {
- if (
- Number(this.form.retainedSampleQuantity || 0) +
- Number(this.form.lossNumber || 0) >
- this.form.sampleQualifiedNumber
- ) {
- this.$message.error('留样合格数与损耗合格数之和不能大于样品合格数');
- this.form[key] = 0;
- }
- } else {
- if (
- Number(this.form.retainedSampleUnqualified) +
- Number(this.form.lossNumberUnqualified) >
- this.form.sampleNoQualifiedNumber
- ) {
- this.$message.error(
- '留样不合格数与损耗不合格数之和不能大于样品不合格数'
- );
- this.form[key] = 0;
- }
- }
- if (this.form[key] < this.getSampleQuantityYp(key)) {
- this.form[key] = this.getSampleQuantityYp(key) || 0;
- }
- },
- //
- calculate(list) {
- if (list.length == 0) {
- this.form.sampleQuantity = 0;
- this.form.sampleWeight = 0;
- }
- let sampleQuantity = 0; // 样品数量
- let sampleWeight = 0; // 样品重量
- let sampleQualifiedNumber = 0; // 样品合格数
- let sampleNoQualifiedNumber = 0; // 样品不合格数
- list.forEach((el) => {
- sampleQuantity += el.measureQuantity - 0;
- sampleWeight += el.weight - 0;
- if (el.qualityResults != 2) {
- sampleQualifiedNumber += el.measureQuantity - 0;
- } else {
- sampleNoQualifiedNumber += el.measureQuantity - 0;
- }
- });
- // 计算合格率和不合格率(百分比形式)
- let sampleQualificationRate = '';
- let sampleNoQualificationRate = '';
- if (
- (sampleQualifiedNumber || sampleQualifiedNumber == 0) &&
- sampleQuantity !== 0
- ) {
- sampleQualificationRate =
- ((sampleQualifiedNumber / sampleQuantity) * 100).toFixed(2) || '';
- sampleNoQualificationRate =
- ((sampleNoQualifiedNumber / sampleQuantity) * 100).toFixed(2) || '';
- }
- if (sampleQualificationRate || sampleQualificationRate == '0.00') {
- if (isNaN(sampleQualificationRate)) {
- sampleQualificationRate = '0%';
- } else {
- sampleQualificationRate = sampleQualificationRate + '%';
- }
- }
- if (sampleNoQualificationRate || sampleNoQualificationRate == '0.00') {
- if (isNaN(sampleNoQualificationRate)) {
- sampleNoQualificationRate = '0%';
- } else {
- sampleNoQualificationRate = sampleNoQualificationRate + '%';
- }
- }
- // let resultsTotal = this.form.total - sampleQuantity;
- // if (sampleQuantity == sampleQualifiedNumber) {
- // // this.$set(this.form, 'qualifiedNumber', resultsTotal);
- // // this.$set(this.form, 'noQualifiedNumber', 0);
- // this.$set(this.form, 'qualificationRate', '100%');
- // this.$set(this.form, 'noQualificationRate', '0');
- // this.$set(this.form, 'qualityResults', 1);
- // } else {
- // // this.$set(this.form, 'noQualifiedNumber', resultsTotal);
- // // this.$set(this.form, 'qualifiedNumber', 0);
- // this.$set(this.form, 'qualificationRate', '0');
- // this.$set(this.form, 'noQualificationRate', '100%');
- // this.$set(this.form, 'qualityResults', 2);
- // }
- // this.$nextTick(() => {
- let showArrange = this.$refs.baseInfoRefs?.showArrange;
- if (
- showArrange != '1' ||
- (showArrange == '2' && this.form.qualityMode == '2')
- ) {
- if (sampleQuantity == sampleQualifiedNumber) {
- this.$set(this.form, 'qualificationRate', '100%');
- this.$set(this.form, 'noQualificationRate', '0');
- this.$set(this.form, 'qualityResults', 1);
- //样品数量和样品合格数相等 默认合格率100% 不合格率0% 检测结果合格
- this.$set(this.form, 'qualifiedNumber', this.form.total);
- this.$set(this.form, 'noQualifiedNumber', 0);
- } else {
- this.$set(this.form, 'qualificationRate', '0');
- this.$set(this.form, 'noQualificationRate', '100%');
- this.$set(this.form, 'qualityResults', 2);
- }
- }
- // });
- // this.$set(this.form, 'resultsTotal', resultsTotal);
- console.log(sampleQualificationRate, 'sampleQualificationRate');
- this.$set(
- this.form,
- 'sampleQualificationRate',
- sampleQualificationRate
- );
- this.$set(
- this.form,
- 'sampleNoQualificationRate',
- sampleNoQualificationRate
- );
- this.$set(this.form, 'sampleQuantity', sampleQuantity);
- this.$set(this.form, 'sampleWeight', sampleWeight);
- this.$set(this.form, 'sampleQualifiedNumber', sampleQualifiedNumber);
- this.$set(
- this.form,
- 'sampleNoQualifiedNumber',
- sampleNoQualifiedNumber
- );
- // 数量赋值
- console.log(this.form, 'this.form');
- this.quantityAssignment();
- },
- // 计算合格数不合格数
- quantityAssignment() {
- let showArrange = this.$refs.baseInfoRefs?.showArrange;
- let noQualifiedNumber = 0;
- let qualifiedNumber = 0;
- let data = this.form;
- let total = data.total - 0;
- if (this.form.qualityResults == 2) {
- noQualifiedNumber = total - (data.sampleQualifiedNumber - 0);
- qualifiedNumber = total - noQualifiedNumber;
- } else {
- qualifiedNumber = total - (data.sampleNoQualifiedNumber - 0);
- noQualifiedNumber = total - qualifiedNumber;
- }
- this.$set(this.form, 'qualifiedNumber', qualifiedNumber);
- this.$set(this.form, 'noQualifiedNumber', noQualifiedNumber);
- if (
- showArrange != '1' ||
- (showArrange == '2' && this.form.qualityMode == '2')
- ) {
- return;
- }
- this.$set(
- this.form,
- 'qualificationRate',
- ((qualifiedNumber / total) * 100).toFixed(2) + '%'
- );
- this.$set(
- this.form,
- 'noQualificationRate',
- ((noQualifiedNumber / total) * 100).toFixed(2) + '%'
- );
- },
- //切换检验方式
- changeModel(val, flag) {
- this.$refs.tabsRef.tableSelClear();
- this.sampleList = [];
- this.$refs.tabsRef.tabsChange('1');
- this.$refs.tabsRef.tabsConditionType(null);
- this.form.qualityMode = val;
- //检验方式 全检
- if (this.form.qualityMode == 1) {
- this.activeName = '2';
- this.form.sampleNumber = '';
- this.changeGetSampleList(this.inventoryList);
- } else {
- this.activeName = '1';
- if (!flag) {
- this.sampleList = [];
- }
- }
- this.calculate([]);
- },
- //根据类型判断样品清单现实列表数据
- async getProSamList(list) {
- //生产检验
- if (this.qualityType == 2) {
- if (this.form.qualityMode != null) {
- const ProductSampleList = [];
- for (const oldItem of list) {
- const count = oldItem.measureQuantity;
- const newMeasureQuantity = oldItem.measureQuantity / count;
- const newWeight = parseFloat((oldItem.weight / count).toFixed(2));
- // 遍历新数组设置 qualityResults 默认值
- this.schemeList.forEach((item) => {
- if (typeof item === 'object' && item !== null) {
- item.qualityResults = 1; // 设置默认值
- }
- delete item.id;
- });
- delete oldItem.id;
- if (
- oldItem.qualitySampleTemplateList == undefined ||
- oldItem.qualitySampleTemplateList == null ||
- oldItem.qualitySampleTemplateList.length == 0
- ) {
- oldItem.qualitySampleTemplateList = JSON.parse(
- JSON.stringify(this.schemeList)
- );
- for (let i = 0; i < count; i++) {
- ProductSampleList.push({
- ...oldItem,
- measureQuantity: newMeasureQuantity,
- weight: newWeight,
- sampleCode: await this.getSampleCode(),
- qualitySampleTemplateList: JSON.parse(
- JSON.stringify(this.schemeList)
- )
- });
- }
- this.sampleList = ProductSampleList;
- this.calculate(this.sampleList);
- const pNum = ProductSampleList.reduce((sum, item) => {
- return sum + Number(item.weight || 0);
- }, 0);
- this.form.totalWeight = parseFloat(pNum.toFixed(2));
- } else {
- for (let i = 0; i < count; i++) {
- ProductSampleList.push({
- ...oldItem,
- measureQuantity: newMeasureQuantity,
- weight: newWeight,
- sampleCode: await this.getSampleCode(),
- qualitySampleTemplateList: JSON.parse(
- JSON.stringify(oldItem.qualitySampleTemplateList)
- )
- });
- }
- this.sampleList = ProductSampleList;
- this.calculate(this.sampleList);
- const pNum = ProductSampleList.reduce((sum, item) => {
- return sum + Number(item.weight || 0);
- }, 0);
- this.form.totalWeight = parseFloat(pNum.toFixed(2));
- }
- }
- }
- } else {
- // this.sampleList = list;
- this.sampleList = this.addStatus;
- }
- },
- // 创建计量数量为1的样品清单函数,用于计数类型的
- async createSampleList(list) {
- if (this.form.qualityMode != null) {
- this.$message.closeAll();
- this.$message('正在生成样品清单');
- const ProductSampleList = [];
- for (const oldItem of list) {
- const count = oldItem.measureQuantity ? oldItem.measureQuantity : 1;
- const newMeasureQuantity = oldItem.measureQuantity / count;
- const newWeight = parseFloat((oldItem.weight / count).toFixed(2));
- // 遍历新数组设置 qualityResults 默认值
- this.schemeList.forEach((item) => {
- if (typeof item === 'object' && item !== null) {
- item.qualityResults = 1; // 设置默认值
- }
- delete item.id;
- });
- delete oldItem.id;
- if (
- oldItem.qualitySampleTemplateList == undefined ||
- oldItem.qualitySampleTemplateList == null ||
- oldItem.qualitySampleTemplateList.length == 0
- ) {
- oldItem.qualitySampleTemplateList = JSON.parse(
- JSON.stringify(this.schemeList)
- );
- for (let i = 0; i < count; i++) {
- ProductSampleList.push({
- ...oldItem,
- measureQuantity: newMeasureQuantity,
- weight: newWeight,
- sampleCode: await this.getSampleCode(),
- qualitySampleTemplateList: JSON.parse(
- JSON.stringify(this.schemeList)
- )
- });
- }
- this.sampleList = ProductSampleList;
- this.calculate(this.sampleList);
- const pNum = ProductSampleList.reduce((sum, item) => {
- return sum + Number(item.weight || 0);
- }, 0);
- this.form.totalWeight = parseFloat(pNum.toFixed(2));
- } else {
- for (let i = 0; i < count; i++) {
- ProductSampleList.push({
- ...oldItem,
- measureQuantity: newMeasureQuantity,
- weight: newWeight,
- sampleCode: await this.getSampleCode(),
- qualitySampleTemplateList: JSON.parse(
- JSON.stringify(oldItem.qualitySampleTemplateList)
- )
- });
- }
- this.sampleList = ProductSampleList;
- this.calculate(this.sampleList);
- const pNum = ProductSampleList.reduce((sum, item) => {
- return sum + Number(item.weight || 0);
- }, 0);
- this.form.totalWeight = parseFloat(pNum.toFixed(2));
- }
- }
- }
- },
- // 全检计量计重的样品清单函数
- async updatePackingList(list, sampleCount) {
- // for (let i = 0; i < list.length; i++) {
- // list[i].sampleCode = await this.getSampleCode();
- // }
- const dataList = [];
- let currentNum = sampleCount - list.length;
- let currentNum1 = sampleCount;
- // console.log(this.selectedList);
- let count = list ? list.length : 0;
- const codeList = await this.batchCodes(count);
- for (const [index, item] of list.entries()) {
- const qualitySampleTemplateList = item.qualitySampleTemplateList
- ?.length
- ? JSON.parse(JSON.stringify(item.qualitySampleTemplateList))
- : JSON.parse(
- JSON.stringify(
- this.schemeList.map((item) => {
- item['qualityResults'] = 1;
- return item;
- })
- )
- );
- if (sampleCount >= list.length) {
- dataList.push({
- ...item,
- measureQuantity: item.measureQuantity, //作为计量数量
- // sampleCode: await this.getSampleCode(),
- sampleCode: codeList[index],
- qualitySampleTemplateList
- });
- }
- }
- this.sampleList = dataList;
- this.calculate(this.sampleList);
- this.sampleNumber = this.sampleList.length;
- },
- //检测项报工
- inspectionProjectReport({ index, list }) {
- this.$nextTick(() => {
- // if (this.form.taskMonadInfo) {
- // delete this.form.taskMonadInfo.remainingSampleCount;
- // }
- this.$refs.inspectionProjectReportRef.open(
- {
- workData: {
- qualityWorkOrderCode: this.form.code,
- qualityWorkOrderName: this.form.name,
- qualityWorkOrderId: this.form.id,
- sourceCode: this.form.sourceCode,
- qualityType: this.form.qualityType,
- qualityMode: this.form.qualityMode,
- productCode: this.form.productCode,
- productName: this.form.productName,
- batchNo: this.form.batchNo,
- specification: this.form.specification,
- brandNo: this.form.brandNo,
- produceTaskName: this.form.produceTaskName,
- total: this.form.total,
- hours: this.form.hours,
- accessory: this.form.accessory,
- qualityNames: this.form.qualityNames,
- qualityTimeEnd: this.form.qualityTimeEnd,
- workSampleCount: this.form.sampleQuantity,
- // remainingSampleCount: this.form.remainingSampleCount,
- measureUnit: this.sampleList[0]?.measureUnit
- },
- row: this.form.taskMonadInfo || {},
- list
- },
- 'report'
- );
- });
- },
- //检测项报工回调
- inspectionProjectReportSuccess({ data, tableData }) {
- this.schemeList = [
- ...tableData,
- ...this.schemeList.filter((item) => item.correlationId)
- ];
- data.type = 2;
- // this.form.remainingSampleCount =
- // data.remainingSampleCount - data.sampleQuantity;
- this.form.taskMonadInfo = data;
- this.form.hours = data.hours;
- this.getSampleQuantity();
- console.log(this.schemeList, 'this.schemeList');
- },
- // 切换检验方式为全检后生成样品
- changeGetSampleList(list) {
- this.$message.closeAll();
- this.$message('正在生成样品清单');
- // // 计量类型1是数量,2是重量
- // if (this.form.inspectionStandards == 1) {
- // this.createSampleList(list);
- // }
- // if (this.form.inspectionStandards == 2) {
- // this.updatePackingList(list, this.form.total);
- // // this.handleWeightFullSample(this.form.total);
- // }
- this.updatePackingList(list, this.form.total);
- },
- //输入取样数量
- changeNumber(val) {
- if (this.form.qualityMode !== 2) {
- return;
- }
- if (val <= 0) {
- this.$refs.showPackingListTable.clearSelection();
- return;
- }
- if (this.qualityType == 2) {
- //生产检验的抽检逻辑
- if (val > this.packingList[0].measureQuantity) {
- this.$message.warning('取样数量不能大于来源清单的计量数量!');
- return;
- }
- const ProductSampleList = [];
- this.packingList.forEach((oldItem) => {
- const count = oldItem.measureQuantity;
- const newMeasureQuantity = oldItem.measureQuantity / count;
- const newWeight = parseFloat((oldItem.weight / count).toFixed(2));
- delete oldItem.id;
- // 遍历新数组设置 qualityResults 默认值
- this.schemeList.forEach((item) => {
- if (typeof item === 'object' && item !== null) {
- item.qualityResults = 1; // 设置默认值
- }
- delete item.id;
- });
- for (let i = 0; i < val; i++) {
- ProductSampleList.push({
- ...oldItem,
- measureQuantity: newMeasureQuantity,
- weight: newWeight,
- qualitySampleTemplateList: JSON.parse(
- JSON.stringify(this.schemeList)
- )
- });
- }
- });
- this.sampleList = ProductSampleList;
- this.calculate(this.sampleList);
- const pNum = ProductSampleList.reduce((sum, item) => {
- return sum + Number(item.weight || 0);
- }, 0);
- this.form.totalWeight = parseFloat(pNum.toFixed(2));
- } else {
- if (val > this.packingList.length) {
- this.$message.warning('取样数量不能大于物料明细总数!');
- return;
- }
- const rows = this.packingList.slice(0, val);
- rows.forEach((row) => {
- this.$refs.showPackingListTable.toggleRowSelection(row);
- });
- }
- },
- getNowDate() {
- let date = new Date(),
- obj = {
- year: date.getFullYear(), //获取当前月份(0-11,0代表1月)
- month: date.getMonth() + 1, //获取当前月份(0-11,0代表1月)
- strDate: date.getDate(), // 获取当前日(1-31)
- hour: date.getHours(), //获取当前小时(0 ~ 23)
- minute: date.getMinutes(), //获取当前分钟(0 ~ 59)
- second: date.getSeconds() //获取当前秒数(0 ~ 59)
- };
- Object.keys(obj).forEach((key) => {
- if (obj[key] < 10) obj[key] = `0${obj[key]}`;
- });
- return obj;
- },
- //来源清单勾选事件
- handleSelectionChange1(selection) {
- if (this.form.qualityMode === 2) {
- this.selectedList = selection;
- this.activeName = '1';
- if (this.schemeList.length == 0) {
- for (let i = 0; i < selection.length; i++) {
- this.$set(selection[i], 'qualityStatus', 2);
- // 遍历新数组设置 qualityResults 默认值
- this.schemeList.forEach((item) => {
- if (typeof item === 'object' && item !== null) {
- item.qualityResults = 1; // 设置默认值
- }
- delete item.id;
- });
- this.$set(
- selection[i],
- 'qualitySampleTemplateList',
- JSON.parse(JSON.stringify(this.schemeList))
- );
- }
- }
- // this.sampleList = selection;
- //赋值取样数量
- this.form.sampleNumber = selection.length;
- }
- },
- async open() {
- this.type = this.$route.query.type;
- this.qualityType = this.$route.query.qualityType;
- this.title =
- this.type == 'add' ? '新增' : this.type == 'edit' ? '报工' : '详情';
- if (this.type == 'add') {
- const code = await getCode('quality_work_order_code');
- this.form.code = code;
- } else {
- if (
- this.$route.query.qualityTimeStart != '' ||
- this.$route.query.qualityTimeStart != null ||
- this.$route.query.qualityTimeStart != undefined
- ) {
- this.qualityTimeStart = this.getNowTime();
- }
- }
- },
- getNowTime() {
- const nowDate = this.getNowDate();
- return (
- nowDate.year +
- '-' +
- nowDate.month +
- '-' +
- nowDate.strDate +
- ' ' +
- nowDate.hour +
- ':' +
- nowDate.minute +
- ':' +
- nowDate.second
- );
- },
- getNowTimes() {
- const nowDate = this.getNowDate();
- return nowDate.year + '-' + nowDate.month + '-' + nowDate.strDate;
- },
- async getDetail() {
- await getById(this.$route.query.id).then((res) => {
- if (res.data.jobList?.length == 1) {
- res.data.executeJobId = res.data.jobList[0].id;
- res.data.executeJobName = res.data.jobList[0].name;
- }
- this.form = res.data;
- console.log(this.form, 'this.form');
- this.form.executeUserIdList = this.form.executeUserId
- ? this.form.executeUserId.split(',')
- : [];
- this.form.qualityIdList = this.form.qualityId
- ? this.form.qualityId.split(',')
- : [];
- this.productId = res.data.productId || '';
- this.statusType = this.form.status == 1 ? true : false;
- this.isReportProcessProduce =
- this.form.isReportProcessProduce == 1 ? true : false;
- this.tabTaskId =
- this.categoryParamList[0] && this.categoryParamList[0].id;
- if (this.form.assignType == 1) {
- this.form.executeUserIdList = [this.$store.state.user.info.userId];
- this.form.executeUserName = this.$store.state.user.info.name;
- }
- //宇信
- if (this.$store.state.user.info.clientEnvironmentId == 10) {
- //客户:5#和6#默认是重油公司7#默认是红山 2008389016775864321==7#
- if (this.form.productLineId == '2008389016775864321') {
- this.form.contactId =
- this.form.contactId || '2008562263580520449';
- this.form.contactName =
- this.form.contactName || '克拉玛依红山油田有限责任公司';
- } else {
- this.form.contactId =
- this.form.contactId || '2008383566202318850';
- this.form.contactName =
- this.form.contactName || '中国石油新疆油田分公司(重油公司)';
- }
- }
- if (this.form.groupId) {
- this.$nextTick(() => {
- this.$refs.baseInfoRefs?.getUserList({
- groupId: this.form.groupId
- });
- });
- }
- if (this.form.produceRoutingId) {
- this.$nextTick(() => {
- this.$refs.baseInfoRefs?.getTaskList();
- });
- }
- });
- // await this.queryQualityInventory()
- // 检测方案
- await this.queryQualityTempleContent();
- // 样品清单
- await this.queryQualitySamplContent();
- // 来源清单
- await this.getQueryQualityInventory();
- console.log(this.form.recordingMethod, 'this.form.recordingMethod');
- if (this.form.recordingMethod != 1) {
- [
- 'retainedSampleQuantity',
- 'retainedSampleUnqualified',
- 'lossNumber',
- 'lossNumberUnqualified'
- ].forEach((key) => {
- this.form[key] =
- this.form[key] || this.getSampleQuantityYp(key) || 0;
- });
- } else {
- this.getSampleQuantity();
- }
- // this.getSampleQuantityYp()
- },
- // getNewData(val) {
- // console.log(val, '清单列表')
- // this.packingList = val
- // },
- // async queryQualityInventory() {
- // let res = await queryQualityInventory({ qualityWorkerId: this.$route.query.id });
- // console.log(res, '清单列表');
- // this.packingList = res;
- // },
- changeSamUnit(val) {
- this.$set(this.form, 'sampleMeasureUnit', val);
- },
- async handleSample1(val, data) {
- this.sampleList = [];
- if (this.selectedList == undefined || this.selectedList.length == 0) {
- this.activeName = '1';
- this.$message.warning('请先选择样品!');
- return;
- }
- if (val == 1) {
- this.activeName = '2';
- if (this.form.isUnpack == 1) {
- for (let i = 0; i < this.selectedList.length; i++) {
- for (let j = 0; j < this.selectedList[i].measureQuantity; j++) {
- // 不拆计算每个重量
- let newWeight = parseFloat(
- (
- this.selectedList[i].weight /
- this.selectedList[i].measureQuantity
- ).toFixed(4)
- );
- if (
- this.selectedList[i].qualitySampleTemplateList == undefined ||
- this.selectedList[i].qualitySampleTemplateList == null ||
- this.selectedList[i].qualitySampleTemplateList.length == 0
- ) {
- this.sampleList.push({
- ...this.selectedList[i],
- sampleCode: await this.getSampleCode(),
- measureQuantity: 1,
- qualitySampleTemplateList: JSON.parse(
- JSON.stringify(this.schemeList)
- ),
- weight: newWeight || 0
- });
- } else {
- this.sampleList.push({
- ...this.selectedList[i],
- sampleCode: await this.getSampleCode(),
- measureQuantity: 1,
- qualitySampleTemplateList: JSON.parse(
- JSON.stringify(
- this.selectedList[i].qualitySampleTemplateList
- )
- ),
- weight: newWeight || 0
- });
- }
- }
- }
- } else if (this.form.isUnpack == 2) {
- // 不拆计算每个重量
- let newWeight = parseFloat(
- (
- this.selectedList[0].weight /
- this.selectedList[0].measureQuantity
- ).toFixed(4)
- );
- for (let i = 0; i < this.selectedList[0].measureQuantity; i++) {
- if (
- this.selectedList[0].qualitySampleTemplateList == undefined ||
- this.selectedList[0].qualitySampleTemplateList == null ||
- this.selectedList[0].qualitySampleTemplateList.length == 0
- ) {
- this.sampleList.push({
- ...this.selectedList[0],
- sampleCode: await this.getSampleCode(),
- measureQuantity: 1,
- qualitySampleTemplateList: JSON.parse(
- JSON.stringify(this.schemeList)
- ),
- weight: newWeight || 0
- });
- } else {
- this.sampleList.push({
- ...this.selectedList[0],
- sampleCode: await this.getSampleCode(),
- measureQuantity: 1,
- qualitySampleTemplateList: JSON.parse(
- JSON.stringify(
- this.selectedList[0].qualitySampleTemplateList
- )
- ),
- weight: newWeight || 0
- });
- }
- }
- }
- //取整样=勾选数据
- // this.sampleList = this.selectedList;
- this.$message.success('取样成功!');
- } else if (val == 2) {
- console.log(data, 'datadatadatadataxiaoyang');
- }
- this.calculate(this.sampleList);
- },
- async handleSampleSubmit(data, specifications) {
- this.sampleList = [];
- if (!this.selectedList || this.selectedList.length == 0) {
- this.$message.warning('请先选择样品!');
- return;
- }
- const measureQ = data.measureQ || 1;
- const unit = data.sampleUnit;
- const sampleCount = Number(data.portion);
- try {
- if (this.isStandard1OrWeightSample()) {
- // 新增校验 数量 取整样 ***
- if (this.form.conditionType == 1) {
- let isFlag = this.validateSampleQuantity(
- sampleCount,
- specifications
- );
- if (!isFlag) return;
- }
- // ***
- //抽检计量整样小样或者抽检计重小样
- if (!this.validateMeasureQuantity(measureQ, unit, sampleCount))
- return; //取样数量验证
- if (unit === 'KG' && !this.validateWeight(measureQ, sampleCount))
- return; // 若计量单位为重量,还需验证总重量是否足够
- await this.getNewFullSampleList(
- Math.ceil(sampleCount),
- // sampleCount,
- measureQ,
- unit,
- specifications
- );
- // 这里是取整样 非数量
- } else if (this.isWeightStandardFullSample()) {
- console.log('这里是取整样 吗');
- //抽检取计重取整样
- if (!this.validateSampleCount(sampleCount, specifications)) return;
- await this.handleWeightFullSample(sampleCount, specifications);
- }
- this.activeName = '2';
- this.$refs.tabsRef.tabsChange('2');
- } catch (error) {
- console.error('取样处理失败:', error);
- this.$message.error('取样处理失败');
- }
- this.calculate(this.sampleList);
- },
- // 当计量类型 是数量的时候 取整样 校验
- validateSampleQuantity(sampleCount, specifications) {
- let packingUnit = this.selectedList[0].packingUnit?.trim() || '';
- let totalS = 0;
- let labelKey =
- packingUnit == specifications.conversionUnit.trim()
- ? 'packingQuantity'
- : 'measureQuantity';
- let labelName = labelKey == 'packingQuantity' ? '包装数量' : '计量数量';
- totalS = this.selectedList.reduce(
- (total, el) => total + el[labelKey],
- 0
- );
- if (sampleCount > totalS) {
- this.$message.info(
- `所填的条目数量不能超过所选${labelName}总和${totalS}`
- );
- return false;
- }
- return true;
- },
- //获取样品编码
- async getSampleCode() {
- return await getCode('sample_code');
- },
- async getNewSampleList(measureQ, unit, nums) {
- this.sampleList = [];
- if (!this.selectedList || this.selectedList.length == 0) {
- this.$message.warning('请先选择来源清单!');
- return;
- }
- this.activeName = '2';
- this.$refs.tabsRef.tabsChange('2');
- if (this.form.isUnpack == 1) {
- // 1 拆包 2 不拆
- let measureQuantity = 1;
- if (this.form.conditionType == 2) {
- measureQuantity = measureQ;
- }
- for (let i = 0; i < this.selectedList.length; i++) {
- if (
- this.selectedList[i].qualitySampleTemplateList == undefined ||
- this.selectedList[i].qualitySampleTemplateList == null ||
- this.selectedList[i].qualitySampleTemplateList.length == 0
- ) {
- this.sampleList.push({
- ...this.selectedList[i],
- sampleCode: await this.getSampleCode(),
- measureQuantity: measureQuantity,
- qualitySampleTemplateList: JSON.parse(
- JSON.stringify(this.schemeList)
- ),
- measureUnit: unit
- });
- } else {
- this.sampleList.push({
- ...this.selectedList[i],
- sampleCode: await this.getSampleCode(),
- measureQuantity: measureQuantity,
- qualitySampleTemplateList: JSON.parse(
- JSON.stringify(this.selectedList[i].qualitySampleTemplateList)
- ),
- measureUnit: unit
- });
- }
- }
- } else if (this.form.isUnpack == 2) {
- if (this.form.conditionType == 1) {
- measureQ = 1;
- }
- // 不拆计算每个重量
- let newWeight = parseFloat(
- (
- this.selectedList[0].weight / this.selectedList[0].measureQuantity
- ).toFixed(4)
- );
- for (let i = 0; i < nums; i++) {
- if (
- this.selectedList[0].qualitySampleTemplateList == undefined ||
- this.selectedList[0].qualitySampleTemplateList == null ||
- this.selectedList[0].qualitySampleTemplateList.length == 0
- ) {
- this.sampleList.push({
- ...this.selectedList[0],
- sampleCode: await this.getSampleCode(),
- measureQuantity: measureQ,
- qualitySampleTemplateList: JSON.parse(
- JSON.stringify(this.schemeList)
- ),
- measureUnit: unit,
- weight: newWeight || 0
- });
- } else {
- this.sampleList.push({
- ...this.selectedList[0],
- sampleCode: await this.getSampleCode(),
- measureQuantity: measureQ,
- qualitySampleTemplateList: JSON.parse(
- JSON.stringify(this.selectedList[0].qualitySampleTemplateList)
- ),
- measureUnit: unit,
- weight: newWeight || 0
- });
- // this.sampleList.push({
- // ...this.selectedList[0],
- // sampleCode: await this.getSampleCode(),
- // measureQuantity: measureQ,
- // measureUnit: unit,
- // weight: newWeight || 0,
- // });
- }
- }
- }
- // this.sampleList = this.selectedList.map(oldItem => {
- // const newItem = JSON.parse(JSON.stringify(oldItem));
- // newItem.measureQuantity = measureQ;
- // newItem.measureUnit = unit;
- // return newItem;
- // });
- this.calculate(this.sampleList);
- this.$refs.tabsRef.tabsChange('2');
- },
- async getQueryQualityInventory() {
- const res = await queryQualityInventory({
- qualityWorkerId: this.$route.query.id,
- size: -1
- });
- if (res.list.length > 0) {
- this.inventoryList = res.list;
- }
- },
- async queryQualitySamplContent() {
- const res = await queryQualitySamplContent({
- qualityWorkerId: this.$route.query.id,
- size: 1000
- });
- let addStatus = res.list.map((item) => {
- item.isValid = true;
- item.status = item.status || 1;
- item.qualityStatus = 1;
- // item.disposeTime = item.disposeTime
- // ? item.disposeTime.split(' ')[0]
- // : null;
- item.sampleDate = item.sampleDate
- ? item.sampleDate.split(' ')[0]
- : null;
- return {
- ...item
- };
- });
- if (addStatus.length > 0) {
- this.sampleList = addStatus;
- // this.calculate(this.sampleList);
- this.addStatus = addStatus;
- } else {
- this.getProSamList(this.packingList);
- }
- if (this.form.recordingMethod != 1) {
- this.$nextTick(() => {
- this.countQualityResults();
- });
- }
- },
- async queryQualityTempleContent() {
- const res = await queryQualityTempleContent({
- qualityWorkerId: this.$route.query.id,
- page: 1,
- size: 10000
- });
- this.schemeList = res.list;
- },
- // 取样
- getConditionType(val) {
- this.form.conditionType = val;
- },
- /* 保存编辑 */
- save() {
- // *** 新增判断
- // let flag = this.$refs.baseInfoRefs.quantityCalculation();
- // if (!flag) return;
- // ***
- if (this.form.qualityIdList.length == 0) {
- this.$message.error('请选择检测人');
- return;
- }
- this.$refs.baseInfoRefs.$refs.form1.validate((valid) => {
- if (!valid) {
- return false;
- }
- // this.loading = true;
- let URL =
- this.type == 'add' ? save : this.type == 'edit' ? update : '';
- this.form.qualityTimeStart = this.qualityTimeStart;
- this.form.qualityId = this.form.qualityIdList.toString();
- delete this.form['qualityTimeEnd'];
- this.form.executeUserId = this.form.executeUserIdList.toString();
- this.form.isUpdate = 1;
- this.schemeList.forEach((item) => {
- if (item.executionMethod != 2 || this.form.recordingMethod != 1) {
- item.experiment = null;
- }
- });
- let params = {
- ...this.form,
- sampleList: this.sampleList,
- planTemplateList: this.schemeList,
- templateList: this.schemeList,
- // qualityInventoryList: this.$refs.tabsRef.$refs.sourceTable.getData()
- qualityInventoryList: this.inventoryList
- };
- console.log(params, 'params');
- URL(params)
- .then((msg) => {
- this.loading = false;
- this.$message.success(msg);
- this.cancel();
- this.$emit('done');
- })
- .catch((e) => {
- this.loading = false;
- });
- });
- },
- update() {
- this.loading = true;
- this.form['status'] = 1;
- update({ ...this.form })
- .then((msg) => {
- this.loading = false;
- this.$message.success(msg);
- this.$emit('done');
- })
- .catch((e) => {
- this.loading = false;
- });
- },
- setSchemeListChange() {
- this.form.qualityTimeStart = this.qualityTimeStart;
- this.form.qualityId = this.form.qualityIdList.join(',');
- delete this.form['qualityTimeEnd'];
- let params = {
- ...this.form,
- sampleList: this.sampleList,
- planTemplateList: this.schemeList,
- templateList: this.schemeList,
- // qualityInventoryList: this.$refs.tabsRef.$refs.sourceTable.getData()
- qualityInventoryList: this.inventoryList
- };
- this.loading = true;
- update(params)
- .then((msg) => {
- this.loading = false;
- this.getDetail();
- })
- .catch((e) => {
- this.loading = false;
- });
- },
- restForm() {
- this.form = { ...this.defaultForm() };
- this.$nextTick(() => {
- this.$refs.baseInfoRefs.$refs.form1.clearValidate();
- });
- },
- cancel() {
- finishPageTab();
- this.$router.go(-1);
- },
- setSchemeList(list) {
- this.schemeList = list;
- },
- handleDetail(index, row, type) {
- if (!this.sampleList[index] || !this.schemeList) {
- return;
- }
- const selectedData = [];
- selectedData.push(this.sampleList[index]);
- if (this.schemeList.length != 0) {
- this.sampleList.forEach((item) => {
- if (item.qualitySampleTemplateList.length == 0) {
- item.qualitySampleTemplateList.push(...this.schemeList);
- }
- });
- }
- console.log(selectedData, 'selectedData');
- this.$refs.detailRef.openDia(
- index,
- row,
- type,
- selectedData,
- null,
- this.schemeList.toolList
- );
- },
- sampleListChange(sampleList) {
- this.$set(this, 'sampleList', sampleList);
- // this.sampleList = sampleList;
- },
- inputWeight(row, index) {
- // 计算所有样本的总重量
- console.log(this.sampleList);
- const pNum = this.sampleList.reduce((sum, item) => {
- return sum + Number(item.weight || 0);
- }, 0);
- this.form.totalWeight = parseFloat(pNum.toFixed(2));
- },
- handleDispose(data) {
- // return
- this.rowData = data;
- this.sampleDisposeVisble = true;
- // if (!this.sampleList[index]) {
- // return;
- // }
- // this.sampleList[index].sampleDate = this.getNowTimes();
- // this.sampleList[index].disposeTime = this.getNowTimes();
- // console.log(index, row, type, this.qualityType);
- // this.$refs.disposeRef.openDispose(index, row, type, this.qualityType);
- },
- // 报工
- handleReporting(index, row) {
- if (this.form.qualityIdList.length == 0) {
- this.$message.error('请选择检测人');
- return;
- }
- if (this.form.qualityMode == 2 && !this.form.qualityResults) {
- this.$refs.baseInfoRefs.toggleExpand2();
- this.$message.error('请选择检测结果');
- return;
- }
- this.$refs.baseInfoRefs.$refs.form1.validate((valid) => {
- if (!valid) return false;
- //单样全部
- console.log(this.form.recordingMethod, 'this.form.recordingMethod');
- if (this.form.recordingMethod == 2) {
- if (this.qualityType == 2 && this.isReportProcessProduce) {
- for (let i = 0; i < this.sampleList.length; i++) {
- const disposalStatus = this.sampleList[i].disposalStatus;
- if (disposalStatus == null) {
- this.loading = false;
- this.$refs.tabsRef.tabsChange('2');
- this.$message.error('请完成以下样品处置!');
- return;
- }
- }
- }
- for (let i = 0; i < this.sampleList.length; i++) {
- const status = this.sampleList[i].status;
- if (status != '1') {
- this.loading = false;
- this.$refs.tabsRef.tabsChange('2');
- this.$message.error('请完成以下样品检测!');
- return;
- }
- }
- } else {
- let is = false;
- this.schemeList.forEach((item) => {
- if (item.status != 1) {
- is = true;
- }
- });
- if (is) {
- this.$message.error('有未完成检测项检测,请检查!');
- return;
- }
- if (!this.schemeList.length) {
- this.$message.error('检测方案不能为空,请检查!');
- return;
- }
- }
- this.form.qualityTimeEnd = this.getNowTime();
- this.form.qualityTimeStart = this.qualityTimeStart;
- this.form.qualityId = this.form.qualityIdList.toString();
- this.form.executeUserIdList = this.form.executeUserIdList || [];
- if (
- !this.form.executeUserIdList.find(
- (item) => item == this.$store.state.user.info.userId
- )
- ) {
- this.form.executeUserIdList.push(
- this.$store.state.user.info.userId
- );
- this.form.executeUserName =
- this.form.executeUserIdList.length > 1
- ? this.form.executeUserName +
- ',' +
- this.$store.state.user.info.name
- : this.$store.state.user.info.name;
- }
- this.form.executeUserId = this.form.executeUserIdList.toString();
- // this.form.qualityIdList = [];
- this.schemeList.forEach((item) => {
- if (item.executionMethod != 2 || this.form.recordingMethod != 1) {
- item.experiment = null;
- }
- });
- let params = {
- ...this.form,
- sampleList: this.sampleList,
- planTemplateList: this.schemeList,
- // qualityInventoryList: this.$refs.tabsRef.$refs.sourceTable.getData()
- qualityInventoryList: this.inventoryList
- };
- this.loading = true;
- exeReportWork(params)
- .then((msg) => {
- this.loading = false;
- this.$message.success(msg);
- this.cancel();
- this.$emit('done');
- })
- .catch((e) => {
- this.loading = false;
- });
- });
- },
- // 处理确认事件
- handleDisposeConfirm(data, index) {
- if (index == undefined) {
- this.sampleList.forEach((obj) => {
- obj.disposeType = data.disposeType;
- obj.sampleDate = data.sampleDate;
- obj.sampleCondition = data.sampleCondition;
- obj.producerManufacturer = data.producerManufacturer;
- obj.samplePlace = data.samplePlace;
- obj.sampleRemark = data.sampleRemark;
- obj.depotId = data.depotId;
- obj.depotName = data.depotName;
- });
- } else {
- this.$set(this.sampleList, index, data);
- }
- },
- //确认检测
- handleConfirm(list, index) {
- let qualityResults = '';
- list.forEach((item) => {
- if (item.correlationId) {
- return;
- }
- if (item.qualitySampleTemplateList.length == 1) {
- if (
- item.qualitySampleTemplateList.some(
- (child) => child.qualityResults === 3
- )
- ) {
- // 如果检测项只有一条而且结果为让步接收那么整个就是让步接收
- item.isValid = false;
- item.qualityResults = 3;
- } else if (
- item.qualitySampleTemplateList.some(
- (child) => child.qualityResults === 2
- )
- ) {
- item.isValid = false;
- item.qualityResults = 2;
- } else {
- item.isValid = true;
- item.qualityResults = 1;
- }
- } else {
- if (
- item.qualitySampleTemplateList.some(
- (child) => child.qualityResults === 2
- )
- ) {
- item.isValid = false;
- item.qualityResults = 2;
- } else {
- item.isValid = true;
- item.qualityResults = 1;
- }
- }
- item.qualityStatus = 1;
- qualityResults = item.qualityResults;
- });
- if (index != null) {
- this.$set(this.sampleList, index, list[0]);
- // this.$set(this.sampleList, index, list[0]);
- // if (this.form.qualityMode == 1 && this.form.isUnpack == 2) {
- // this.activeName = '2';
- // this.countQualityResults();
- // return;
- // }
- this.countQualityResults();
- } else {
- this.$set(this, 'sampleList', list);
- // console.log(this.sampleList, 'this.sampleList');
- // return
- // this.sampleList = list;
- this.calculate(this.sampleList);
- console.log(this.sampleList, 'this.sampleList');
- }
- this.activeName = '2';
- if (this.$store.state.user.info.clientEnvironmentId == 10) {
- this.$refs.baseInfoRefs.setQualityResults(qualityResults);
- }
- // *** 选完批量检测调用
- // this.countQualityResults();
- // this.$refs.baseInfoRefs.quantityCalculation(
- // 'noQualifiedNumber',
- // 'noSetSampleList'
- // );
- console.log('检测没有 2');
- },
- // 批量检测
- batchQuality(index, row, type) {
- if (this.sampleList.length == 0) {
- this.$message.error('样品清单不能为空');
- return;
- }
- if (this.form.recordingMethod == 1) {
- this.inspectionProjectReport({
- index: -1,
- list: this.schemeList.filter((item) => !item.correlationId)
- });
- return;
- }
- if (this.schemeList.length != 0) {
- this.sampleList.forEach((item, index) => {
- if (item.qualitySampleTemplateList.length == 0) {
- let arr = JSON.parse(JSON.stringify(this.schemeList));
- arr.forEach((el) => {
- el.qualityResults = item.qualityResults;
- });
- this.$set(
- this.sampleList[index],
- 'qualitySampleTemplateList',
- arr
- );
- }
- });
- }
- console.log(this.sampleList, 'dsds');
- this.$refs.detailRef.openDia(
- null,
- null,
- 'report',
- this.sampleList,
- null,
- this.schemeList.toolList
- );
- },
- // 批量处置
- batchDispose() {
- if (this.sampleList && this.sampleList.length) {
- this.sampleDisposeVisble = true;
- return;
- }
- this.$message('当前没有样品清单可以处置');
- // this.$refs.disposeRef.openDispose(
- // null,
- // null,
- // 'dispose',
- // this.qualityType
- // );
- },
- //全检,检验标准改变时,重新获取样品列表
- async changeInspectionStandardsModel(val) {
- const sData = this.$refs.tabsRef.$refs.sourceTable.getData();
- if (sData.length > 0) {
- for (let i = 0; i < sData.length; i++) {
- this.$set(sData[i], 'qualityStatus', 2);
- }
- }
- this.form.inspectionStandards = val;
- this.form.sampleNumber = '';
- this.$refs.tabsRef.tableSelClear();
- this.sampleList = [];
- this.$refs.tabsRef.tabsChange('1');
- //检验标准 2计重 1计量
- if (
- [2, 3, 4, 5].includes(this.form.inspectionStandards) &&
- this.form.qualityMode == 1
- ) {
- for (let i = 0; i < sData.length; i++) {
- let qualitySampleTemplateList = [];
- if (
- sData[i].qualitySampleTemplateList == undefined ||
- sData[i].qualitySampleTemplateList == null ||
- sData[i].qualitySampleTemplateList.length == 0
- ) {
- qualitySampleTemplateList = JSON.parse(
- JSON.stringify(this.schemeList)
- );
- } else {
- qualitySampleTemplateList = sData[i].qualitySampleTemplateList;
- }
- this.sampleList.push({
- ...sData[i],
- sampleCode: await this.getSampleCode(),
- qualitySampleTemplateList
- });
- }
- } else if (
- this.form.inspectionStandards == 1 &&
- this.form.qualityMode == 1
- ) {
- this.getProSamList(sData);
- }
- this.calculate(this.sampleList);
- },
- //从来源数组取样到目标数组
- async getNewFullSampleList(
- sampleCount,
- sampleQuantity,
- sampleUnit,
- specifications
- ) {
- const sourceArray = this.selectedList;
- // 检查单位是否匹配
- const isUnitMismatch =
- sourceArray.length > 0 && sourceArray[0].measureUnit !== sampleUnit;
- // 创建副本并计算初始可取样数量
- const items = sourceArray.map((item) => ({
- ...item,
- remainingQuantity: isUnitMismatch
- ? Infinity
- : item['measureQuantity'], // 剩余可取样数量
- maxPossible: item['measureQuantity'] / sampleQuantity // 最大取样次数
- }));
- const result = [];
- let remainingCount = sampleCount;
- let count = Math.ceil(remainingCount);
- const codeList = await this.batchCodes(count);
- let codeIdx = 0;
- // 尽可能均匀地从各条目取样
- while (remainingCount > 0) {
- // 按剩余可取样比例排序
- items.sort(
- (a, b) =>
- b.remainingQuantity / b['measureQuantity'] -
- a.remainingQuantity / a['measureQuantity']
- );
- let distributed = false;
- for (const item of items) {
- // let values = remainingCount > 1 ? 1 : remainingCount;
- if (
- !isUnitMismatch ||
- (item.remainingQuantity >= sampleQuantity && remainingCount > 0)
- ) {
- let qualitySampleTemplateList = [];
- if (
- item.qualitySampleTemplateList == undefined ||
- item.qualitySampleTemplateList == null ||
- item.qualitySampleTemplateList.length == 0
- ) {
- qualitySampleTemplateList = JSON.parse(
- JSON.stringify(this.schemeList)
- );
- } else {
- qualitySampleTemplateList = item.qualitySampleTemplateList;
- }
- // 添加到结果数组
- // let sampleCode = await this.getSampleCode();
- let sampleCode = codeList[codeIdx];
- if (
- this.form.conditionType == 1 &&
- this.form.inspectionStandards == 1
- ) {
- result.push({
- ...item,
- // measureQuantity: values,
- measureQuantity: 1,
- sampleCode,
- qualitySampleTemplateList
- });
- } else if (this.form.conditionType == 2) {
- let weight = (item.weight / item.maxPossible).toFixed(2);
- result.push({
- ...item,
- measureQuantity: sampleQuantity,
- measureUnit: sampleUnit,
- sampleCode,
- weight,
- qualitySampleTemplateList
- });
- }
- // 更新剩余数量
- if (!isUnitMismatch) {
- item.remainingQuantity -= sampleQuantity;
- }
- remainingCount = (remainingCount - 1).toFixed(2);
- codeIdx++;
- distributed = true;
- }
- }
- // 如果没有分配任何取样
- if (!distributed) {
- break;
- }
- }
- // 判断是不是取整样
- if (
- this.form.conditionType == 1 &&
- specifications &&
- specifications.id
- ) {
- result.map((el) => {
- el.measureQuantity =
- el.measureQuantity * specifications.packageCellTotal;
- el.weight = this.formatNumber(
- el.measureQuantity,
- el.weightProportion
- );
- });
- }
- this.sampleList = result;
- if (this.sampleList.length > sampleCount) {
- this.sampleList = this.sampleList.splice(0, sampleCount);
- }
- this.form.sampleNumber = this.sampleList.length;
- this.calculate(this.sampleList);
- },
- // 小数点数据判断
- formatNumber(a, b, maxDecimals = 4) {
- if (a == 0 || b == 0 || !a || !b) {
- return 0;
- }
- // 计算乘积
- const product = a * b;
- // 转换为固定小数位数,然后转换为数字以去除末尾零
- const rounded = Number(product.toFixed(maxDecimals));
- // 转换为字符串检查是否需要显示小数部分
- const str = rounded.toString();
- // 如果包含小数点
- if (str.indexOf('.') !== -1) {
- // 移除末尾的零和小数点(如果后面没有数字了)
- return str.replace(/\.?0+$/, '');
- }
- return str;
- },
- validateWeight(measureQ, sampleCount) {
- let totalMaxPossible = 0;
- this.selectedList.forEach((item) => {
- totalMaxPossible += item.measureQuantity / measureQ;
- });
- if (totalMaxPossible < sampleCount) {
- // this.formData.portion = totalMaxPossible;
- this.$message.info(`最大取样条数为${totalMaxPossible}`);
- return false;
- }
- let totalWeight = this.selectedList.reduce(
- (sum, item) => sum + item.weight,
- 0
- );
- const weightUnit = this.selectedList[0].weightUnit;
- if (weightUnit === 'G') totalWeight /= 1000;
- if (measureQ * sampleCount > totalWeight) {
- this.$message.info('取样计量重量不能大于总计量重量');
- return false;
- }
- const invalidItem = this.selectedList.find((item) => {
- const weight =
- item.weightUnit === 'G' ? item.weight / 1000 : item.weight;
- return weight < measureQ;
- });
- if (invalidItem) {
- this.$message.info('勾选条目重量小于取样重量');
- return false;
- }
- return true;
- },
- isStandard1OrWeightSample() {
- return (
- this.form.inspectionStandards === 1 ||
- ([2, 3, 4, 5].includes(this.form.inspectionStandards) &&
- this.form.conditionType == 2)
- );
- },
- validateMeasureQuantity(measureQ, unit, sampleCount) {
- if (this.form.conditionType == 2 && measureQ <= 0) {
- this.$message.info('取样计量数量必须大于0');
- return false;
- }
- const totalQuantity = this.selectedList.reduce(
- (sum, item) => sum + item.measureQuantity,
- 0
- );
- if (
- (this.selectedList[0].measureUnit === unit ||
- this.form.conditionType == 1) &&
- measureQ * sampleCount > totalQuantity
- ) {
- this.$message.info('取样计量数量不能大于总计量数量');
- return false;
- }
- const invalidItem = this.selectedList.find(
- (item) => item.measureQuantity < measureQ
- );
- if (invalidItem) {
- this.$message.info('条目计量数量小于取样计量数量');
- return false;
- }
- return true;
- },
- isWeightStandardFullSample() {
- return (
- [2, 3, 4, 5].includes(this.form.inspectionStandards) &&
- this.form.conditionType == 1
- );
- },
- // 抽检取整样 校验
- validateSampleCount(sampleCount, specifications) {
- // 新增校验 ***
- let isFlag = this.validateSampleQuantity(sampleCount, specifications);
- if (!isFlag) {
- return false;
- }
- // ***
- const chooseNumber = this.selectedList.reduce((acc, pro) => {
- return pro.measureQuantity ? acc + Number(pro.measureQuantity) : acc;
- }, 0);
- const invalidItem = chooseNumber < sampleCount;
- // console.log(this.selectedList, 'this.selectedList');
- // const invalidItem = this.selectedList.find(
- // (item) => item.measureQuantity < sampleCount
- // );
- if (invalidItem) {
- this.$message.info('所选的条目计量数量小于取样计量数量');
- return false;
- }
- // ***
- return true;
- },
- async handleWeightFullSample(sampleCount, specifications) {
- const dataList = [];
- let currentNum = sampleCount - this.selectedList.length;
- let currentNum1 = sampleCount;
- for (const item of this.selectedList) {
- const qualitySampleTemplateList = item.qualitySampleTemplateList
- ?.length
- ? JSON.parse(JSON.stringify(item.qualitySampleTemplateList))
- : JSON.parse(
- JSON.stringify(
- this.schemeList.map((item) => {
- item['qualityResults'] = 1;
- return item;
- })
- )
- );
- if (sampleCount >= this.selectedList.length) {
- dataList.push({
- ...item,
- measureQuantity: 1, //作为计量数量
- sampleCode: await this.getSampleCode(),
- qualitySampleTemplateList
- });
- } else {
- if (dataList.length < sampleCount) {
- dataList.push({
- ...item,
- measureQuantity: currentNum1 > 1 ? 1 : currentNum1, //作为计量数量
- sampleCode: await this.getSampleCode(),
- qualitySampleTemplateList
- });
- currentNum1 -= 1;
- }
- }
- }
- if (sampleCount > this.selectedList.length) {
- dataList.forEach((item) => {
- if (currentNum > 0) {
- let data = this.selectedList.find((val) => val.id == item.id);
- item['measureQuantity'] =
- data.measureQuantity - 1 - currentNum > 0
- ? currentNum + 1
- : data.measureQuantity;
- currentNum = currentNum - (data.measureQuantity - 1);
- }
- });
- }
- // 更改 从新计算 样品清单 取整样 数据
- if (specifications && specifications.id) {
- // let proportion = (obj.weight / obj.measureQuantity).toFixed(2);
- dataList.map((el) => {
- el.measureQuantity =
- el.measureQuantity * specifications.packageCellTotal;
- el.weight = this.formatNumber(
- el.measureQuantity,
- el.weightProportion
- );
- });
- }
- // 更改
- this.sampleList = dataList;
- this.calculate(this.sampleList);
- this.sampleNumber = this.sampleList.length;
- },
- // 批量生成编码 4444444 getCodeList
- async batchCodes(count) {
- if (count <= 0) return;
- let params = { count };
- const res = await getCodeList('sample_code', params);
- return res;
- },
- //计算合格率
- countQualityResults() {
- console.log(321);
- let sampleList = this.sampleList; //样品清单
- let sampleNumber = this.form.total; //样品总数
- // let qualifiedNumber = sampleList.filter(item => item.qualityResults == 1 || item.qualityResults == 3).length;
- // let noQualifiedNumber = sampleList.filter(
- // (item) => item.qualityResults == 2
- // ).length;
- let noQualifiedNumber = sampleList.reduce((acc, pro) => {
- // console.log(acc, pro);
- // if (pro.qualityResults == 2) {
- // return acc + Number(pro.measureQuantity);
- // }
- return pro.qualityResults == 2
- ? acc + Number(pro.measureQuantity)
- : acc;
- }, 0);
- let qualifiedNumber = sampleNumber - noQualifiedNumber; //不合格数
- let qualificationRate = (
- (qualifiedNumber / sampleNumber) *
- 100
- ).toFixed(2); //合格率
- let noQualificationRate = (
- (noQualifiedNumber / sampleNumber) *
- 100
- ).toFixed(2); //不合格率
- this.$refs.baseInfoRefs.updateQualificationRate(
- qualifiedNumber,
- noQualifiedNumber,
- qualificationRate,
- noQualificationRate
- );
- this.calculate(this.sampleList);
- },
- closeDispose() {
- this.rowData = null;
- this.sampleDisposeVisble = false;
- // this.rowData = null;
- }
- }
- };
- </script>
- <style lang="scss" scoped></style>
|