| 123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886887888889890891892893894895896897898899900901902903904905906907908909910911912913914915916917918919920921922923924925926927928929930931932933934935936937938939940941942943944945946947948949950951952953954955956957958959960961962963964965966967968969970971972973974975976977978979980981982983984985986987988989990991992993994995996997998999100010011002100310041005100610071008100910101011101210131014101510161017101810191020102110221023102410251026102710281029103010311032103310341035103610371038103910401041104210431044104510461047104810491050105110521053105410551056105710581059106010611062106310641065106610671068106910701071107210731074107510761077107810791080108110821083108410851086108710881089109010911092109310941095109610971098109911001101110211031104110511061107110811091110111111121113111411151116111711181119112011211122112311241125112611271128112911301131113211331134113511361137113811391140114111421143114411451146114711481149115011511152115311541155115611571158115911601161116211631164116511661167116811691170117111721173117411751176117711781179118011811182118311841185118611871188118911901191119211931194119511961197119811991200120112021203120412051206120712081209121012111212121312141215121612171218121912201221122212231224122512261227122812291230123112321233123412351236123712381239124012411242124312441245124612471248124912501251125212531254125512561257125812591260126112621263126412651266126712681269127012711272127312741275127612771278127912801281128212831284128512861287128812891290129112921293129412951296129712981299130013011302130313041305130613071308130913101311131213131314131513161317131813191320132113221323132413251326132713281329133013311332133313341335133613371338133913401341134213431344134513461347134813491350135113521353135413551356135713581359136013611362136313641365136613671368136913701371137213731374137513761377137813791380138113821383138413851386138713881389139013911392139313941395139613971398139914001401140214031404140514061407140814091410141114121413141414151416141714181419142014211422142314241425142614271428142914301431143214331434143514361437143814391440144114421443144414451446144714481449145014511452145314541455145614571458145914601461146214631464146514661467146814691470147114721473147414751476147714781479148014811482148314841485148614871488148914901491149214931494149514961497149814991500150115021503150415051506150715081509151015111512151315141515151615171518151915201521152215231524152515261527152815291530153115321533153415351536153715381539154015411542154315441545154615471548154915501551155215531554155515561557155815591560156115621563156415651566156715681569157015711572157315741575157615771578157915801581158215831584158515861587158815891590159115921593159415951596159715981599160016011602160316041605160616071608160916101611161216131614161516161617161816191620162116221623162416251626162716281629163016311632163316341635163616371638163916401641164216431644164516461647164816491650165116521653165416551656165716581659166016611662166316641665166616671668166916701671167216731674167516761677167816791680168116821683168416851686168716881689169016911692169316941695169616971698169917001701 |
- <template>
- <view>
- <view>
- <view class="col userInp" style="display: flex; align-items: center">
- <text class="label lable150 rx-cc">是否拆包</text>
- <text
- v-if="objData.isUnpack == '1' && objData.singleReport == '1'"
- style="
- color: green;
- font-size: 14px;
- font-weight: 700;
- margin-left: 15px;
- "
- >是</text
- >
- <text
- v-else-if="isNewUnpack == '1' && objData.singleReport == '0'"
- style="
- color: green;
- font-size: 14px;
- font-weight: 700;
- margin-left: 15px;
- "
- >是</text
- >
- <text
- v-else
- style="
- color: green;
- font-size: 14px;
- font-weight: 700;
- margin-left: 15px;
- "
- >否</text
- >
- <u-button
- size="small"
- class="u-reset-button"
- type="primary"
- style="margin-left: 40px; width: 80px"
- @click="checkUnpack"
- v-if="objData.singleReport == '0'"
- >手动拆包</u-button
- >
- </view>
- </view>
- <view
- v-if="
- objData.isUnpack == '1' &&
- (isNewUnpack == 0 || !isNewUnpack) &&
- objData.singleReport == '1'
- "
- >
- <view class="col userInp" style="display: flex; align-items: center">
- <text class="label lable150 rx-cc">规格选择:</text>
- <!-- multiple -->
- <zxz-uni-data-select
- :localdata="localdataList"
- v-model="Usertype"
- @change="changeUserType"
- ></zxz-uni-data-select>
- </view>
- <view class="col userInp" style="display: flex; align-items: center">
- <text class="label lable150 rx-cc">包装选择:</text>
- <!-- multiple -->
- <zxz-uni-data-select
- :localdata="warehouseSpecTypeList"
- v-model="warehouseId"
- @change="changeWarehouseType"
- disabled
- ></zxz-uni-data-select>
- </view>
- <view v-if="warehouseId != 1">
- <view v-for="(item, i) in DispositionList" :key="i">
- <view class="title_box rx-bc">
- <!-- 最小包装单元 -->
- <view class="name">{{ item.titel }}</view>
- <!-- <view class="btn_box rx-bc" @click="handCancelPacking">
- 重置打包
- </view> -->
- </view>
- <view class="material">
- <view class="content_table">
- <view class="item">
- <view class="lable rx-cc">包装总数 </view>
- <view class="content content_num">
- <input
- class="uni-input"
- v-model="formedNumLast"
- type="number"
- disabled
- @input="changeinput"
- />
- <view class="unit">{{ item.packageUnit }}</view>
- </view>
- </view>
- <view class="item rx-sc">
- <view class="rx ww55">
- <view class="lable lable150 rx-cc">{{ item.titel }}单元</view>
- <view class="content content_num">
- <input
- class="uni-input"
- v-model="item.packageCell"
- disabled
- />
- <view style="max-width: 100rpx; font-size: 24rpx">{{
- item.packageUnit
- }}</view>
- </view>
- </view>
- <view class="rx ww45">
- <view class="rx-cc ww80">
- /<view style="max-width: 100rpx; font-size: 24rpx">{{
- item.conversionUnit
- }}</view>
- </view>
- <view class="content rx-sc">
- <!-- <zxz-uni-data-select :localdata="unitList" v-model="unit" dataValue='Key'
- format='{Value}' dataKey="Key" filterable :clear='false'></zxz-uni-data-select> -->
- <!-- <view class="penalize" @click="handleSplit">确认</view> -->
- </view>
- </view>
- </view>
- </view>
- <view class="content_table2" v-if="item.splitList.length">
- <view class="head row rx-sc">
- <view class="item ww10">序号</view>
- <view class="item ww15">数量</view>
- <view class="item ww20">类型</view>
- <view class="item ww20">包装层级</view>
- <!-- <view class="item ww20">计量数</view> -->
- <view class="item ww40">包装编码</view>
- <!-- <view class="item ww10 jsColor" @click="calculation()" v-if="clientEnvironmentId != 3">计算</view>
- <view class="item ww10" v-if="clientEnvironmentId == 3"></view> -->
- </view>
- <view class="table">
- <u-list
- @scrolltolower="scrolltolower"
- class="z_list"
- style="height: 100% !important"
- >
- <view
- class="tr row rx-sc"
- v-for="(it, idx) in item.splitList"
- :key="idx"
- >
- <view class="item ww10 rx-cc">{{ idx + 1 }}</view>
- <view class="item ww15 rx-sc">
- <view> {{ it.feedQuantity }}</view>
- </view>
- <view class="item ww20 rx-sc">
- <view v-if="it.rootCategoryLevelId == 2">在制品</view>
- <view v-else-if="it.rootCategoryLevelId == 23"
- >半成品</view
- >
- <view v-else-if="it.rootCategoryLevelId == 9">产品</view>
- <view v-else-if="it.rootCategoryLevelId == 28">废品</view>
- <view v-else>{{ "" }}</view>
- </view>
- <view class="item ww20 rx-cc">
- <view v-if="it.packingType == 4">外包装</view>
- <view v-else-if="it.packingType == 2">最小包装</view>
- <view v-else-if="it.packingType == 3">内包装</view>
- <view v-else>计量</view>
- </view>
- <view class="item ww40">
- {{ it.packingCode }}
- </view>
- </view>
- </u-list>
- </view>
- </view>
- </view>
- </view>
- </view>
- <SearchPopup mode="center" v-if="show">
- <template v-slot:list>
- <view class="search_list">
- <u-form
- labelPosition="left"
- :model="formData"
- labelWidth="180"
- labelAlign="left"
- class="baseForm"
- >
- <u-form-item
- label="外包装数:"
- class="required-form"
- borderBottom
- prop="assetType"
- >
- <input
- class="uni-input"
- v-model="formData.wPackNum"
- style="width: 280rpx"
- placeholder="外包装数"
- />
- / {{ splitList[0].unit }}
- </u-form-item>
- </u-form>
- </view>
- </template>
- <template v-slot:operate>
- <view class="operate_box rx-bc">
- <u-button
- size="small"
- class="u-reset-button"
- @click="calculationClose()"
- >
- 取消
- </u-button>
- <u-button
- type="success"
- size="small"
- class="u-reset-button"
- @click="calculationReset()"
- >
- 重置
- </u-button>
- <u-button
- type="success"
- size="small"
- class="u-reset-button"
- @click="calculationSave()"
- >
- 确定
- </u-button>
- </view>
- </template>
- </SearchPopup>
- </view>
- <view v-if="isNewUnpack == 1">
- <view class="col userInp" style="display: flex; align-items: center">
- <text class="label lable150 rx-cc">规格选择:</text>
- <!-- multiple -->
- <zxz-uni-data-select
- :localdata="localdataList"
- v-model="Usertype"
- @change="changeUserTypeOne"
- ></zxz-uni-data-select>
- </view>
- <view class="material">
- <view class="content_table">
- <view class="item">
- <view class="lable rx-cc">总数</view>
- <view class="content content_num">
- <input
- class="uni-el-input"
- v-model="formedNumLast"
- type="number"
- @input="changeinput"
- disabled
- style="width: 200px"
- />
- {{ packageUnit }}
- </view>
- </view>
- </view>
- </view>
- <view v-if="warehouseId != 1">
- <view v-for="(item, i) in DispositionList" :key="i">
- <view class="title_box rx-bc">
- <!-- 最小包装单元 -->
- <view class="name">{{ item.titel }}</view>
- </view>
- <view class="material">
- <view class="content_table">
- <view class="item rx-sc">
- <view class="lable rx-cc lable150">包装总数 </view>
- <view class="content content_num">
- <input
- class="uni-input"
- v-model="item.formedNumLast"
- type="number"
- disabled
- @input="changeinput"
- />
- <view class="unit">{{ item.conversionUnit }}</view>
- </view>
- </view>
- <view class="item rx-sc">
- <view class="rx ww55">
- <view class="lable lable150 rx-cc">{{ item.titel }}单元</view>
- <view class="content content_num">
- <input
- class="uni-input"
- v-model="item.packageCell"
- @input="changeInputPack(item, i)"
- :disabled="!item.conversionUnit"
- />
- <view style="max-width: 100rpx; font-size: 24rpx">{{
- item.packageUnit
- }}</view>
- </view>
- </view>
- <view class="rx ww45">
- <view class="rx-cc ww80">
- /<view style="max-width: 100rpx; font-size: 24rpx">{{
- item.conversionUnit
- }}</view>
- </view>
- </view>
- </view>
- </view>
- </view>
- </view>
- <view v-for="item in DispositionList" :key="item.id">
- <view class="content_table2" v-if="item.splitList.length != 0">
- <view class="head row rx-sc">
- <view class="item ww10">序号</view>
- <view class="item ww15">数量</view>
- <view class="item ww20">类型</view>
- <view class="item ww20">包装规格</view>
- <!-- <view class="item ww20">计量数</view> -->
- <view class="item ww40">包装编码</view>
- <!-- <view class="item ww10 jsColor" @click="calculation()" v-if="clientEnvironmentId != 3">计算</view>
- <view class="item ww10" v-if="clientEnvironmentId == 3"></view> -->
- </view>
- <view class="table">
- <u-list
- @scrolltolower="scrolltolower"
- class="z_list"
- style="height: 100% !important"
- >
- <view
- class="tr row rx-sc"
- v-for="(it, idx) in item.splitList"
- :key="idx"
- >
- <view class="item ww10 rx-cc">{{ idx + 1 }}</view>
- <view class="item ww15 rx-sc">
- <view> {{ it.feedQuantity }}</view>
- </view>
- <view class="item ww20 rx-sc">
- <view v-if="it.rootCategoryLevelId == 2">在制品</view>
- <view v-else-if="it.rootCategoryLevelId == 23">半成品</view>
- <view v-else-if="it.rootCategoryLevelId == 9">产品</view>
- <view v-else-if="it.rootCategoryLevelId == 28">废品</view>
- <view v-else>{{ "" }}</view>
- </view>
- <view class="item ww20 rx-cc">
- <view>{{ packageDispositionData }}</view>
- </view>
- <view class="item ww40">
- {{ it.packingCode }}
- </view>
- </view>
- </u-list>
- </view>
- </view>
- </view>
- </view>
- </view>
- <view>
- <uni-popup ref="alertDialog" type="dialog">
- <uni-popup-dialog
- type="warn"
- cancelText="取消"
- confirmText="确定"
- title="提示"
- content="此操作将进行拆包, 是否继续?"
- @confirm="dialogConfirm"
- @close="dialogClose"
- ></uni-popup-dialog>
- </uni-popup>
- </view>
- </view>
- </template>
- <script>
- import { getByCode } from "@/api/pda/common.js";
- import {
- cancelPacking,
- packingReport,
- getPackingReport,
- packingReportRepeat,
- packageDisposition,
- getPackingReportRepeat,
- getPackingList,
- } from "@/api/pda/workOrder.js";
- import SearchPopup from "../../components/searchPopup.vue";
- export default {
- components: {
- SearchPopup,
- },
- props: {
- categoryId: {
- type: String,
- default: "",
- },
- objData: {
- type: Object,
- default: () => {},
- },
- taskId: {
- type: String,
- default: "",
- },
- workOrderId: {
- type: String,
- default: "",
- },
- },
- data() {
- return {
- formedNumLast: 0,
- quantity: "",
- unit: "",
- Usertype: "", // 规格
- unitList: [],
- resObj: {},
- splitList: [],
- localdataList: [],
- newDispositionList: [],
- DispositionListes: [],
- withinQuantity: "", //内包装数量
- withinUnit: "", //内包装单位
- outsideQuantity: "", //外包装数量
- outsideUnit: "", //外包装单位
- timeout: null,
- packUnit: null,
- temporaryNum: 0,
- temporaryCount: 0,
- temporaryList: [],
- packTwoList: [],
- DispositionList: [],
- selectList: [],
- text: "",
- value: "",
- minimumPackage: [], // 最小包装
- withinPackage: [], // 内包装
- minimumUnit: "",
- outsidePackage: [], //外包装
- newCategoryId: "",
- warehouseId: 2,
- warehouseSpecTypeList: [
- {
- text: "按计量",
- value: 1,
- textValue: "按计量",
- },
- {
- text: "最小包装",
- value: 2,
- textValue: "",
- },
- {
- text: "内包装",
- value: 3,
- textValue: "",
- },
- {
- text: "外包装",
- value: 4,
- textValue: "",
- },
- ],
- isNewUnpack: 0,
- packageCell: "",
- packageUnit: "",
- packageOneCell: "",
- packageOneUnit: "",
- packageTwoCell: "",
- packageTwoUnit: "",
- packageDispositionData: "",
- show: false,
- formData: {
- wPackNum: null,
- },
- clientEnvironmentId:
- uni.getStorageSync("userInfo") &&
- uni.getStorageSync("userInfo").clientEnvironmentId,
- };
- },
- watch: {
- categoryId: {
- handler(newVal) {
- this.newCategoryId = newVal;
- },
- deep: true,
- immediate: true,
- },
- objData: {
- handler(newVal) {
- console.log(newVal, "newVal");
- if (newVal.product && newVal.product.length) {
- console.log(44444);
- // this.formedNumLast =
- // newVal.formedNumLast || newVal.product[0].feedQuantity;
- this.newCategoryId = newVal.product[0].categoryId;
- // this.formedNumLast = newVal.product.reduce((acc, pro) => {
- // return pro.extInfo.sourceQuantity
- // ? acc + Number(pro.extInfo.sourceQuantity)
- // : acc;
- // }, 0);
- this.formedNumLast = newVal.product.reduce((acc, pro) => {
- return pro.feedQuantity &&
- (!pro.extInfo.isQualified ||
- pro.extInfo.isQualified == 1 ||
- pro.extInfo.isQualified == 3) &&
- !pro.extInfo.isLoss
- ? this.add(acc, Number(pro.feedQuantity))
- : acc;
- }, 0);
- } else if (newVal.semiProductList && newVal.semiProductList.length) {
- this.newCategoryId = newVal.semiProductList[0].categoryId;
- // this.formedNumLast = newVal.semiProductList.reduce((acc, pro) => {
- // return pro.feedQuantity ? acc + Number(pro.feedQuantity) : acc;
- // }, 0);
- this.formedNumLast = newVal.semiProductList.reduce((acc, pro) => {
- return pro.feedQuantity &&
- (!pro.extInfo.isQualified ||
- pro.extInfo.isQualified == 1 ||
- pro.extInfo.isQualified == 3) &&
- !pro.extInfo.isLoss
- ? this.add(acc, Number(pro.feedQuantity))
- : acc;
- }, 0);
- } else {
- this.formedNumLast = 0;
- }
- if (newVal.isUnpack == "1" && this.objData.singleReport == "1") {
- this.packageDispositionFn();
- }
- if (newVal.isNewUnpack == 1) {
- this.getPackingData();
- }
- // this.packageDispositionFn();
- //
- },
- deep: true,
- immediate: true,
- },
- },
- created() {
- // this.formedNumLast = this.objData.product[0].feedQuantity;
- console.log(this.objData, "我是阿打啥啊电话");
- this.byCode();
- // this.getPackingDetails()
- // this.getPackingDetailsTwo()
- },
- methods: {
- // 输入数量变化
- changeinput(e) {
- clearTimeout(this.timeout);
- // 设置新的定时器
- this.timeout = setTimeout(() => {
- this.formedNumLast = e.detail.value;
- this.initFn(this.selectList);
- }, 500); // 500毫秒后触发
- },
- changeUserType(e) {
- console.log(e);
- this.text = e.text;
- this.value = e.value;
- this.selectList = e.arr;
- this.initFn(e.arr);
- },
- changeUserTypeOne(e) {
- this.text = e.text;
- this.value = e.value;
- this.selectList = e.arr;
- this.initFn1(e.arr);
- },
- groupBy(arr, key) {
- return arr.reduce((acc, obj) => {
- const groupKey = obj[key];
- if (!acc[groupKey]) {
- acc[groupKey] = [];
- }
- console.log();
- acc[groupKey].push(obj);
- return acc;
- }, {});
- },
- async packageDispositionFn() {
- console.log(this.newCategoryId, "555555555555");
- let that = this;
- const res = await packageDisposition(this.newCategoryId);
- if (res.length) {
- res.shift();
- let data = JSON.parse(JSON.stringify(res));
- let list = this.groupBy(data, "code");
- this.localdataList = [];
- Object.entries(list).forEach(([key, value]) => {
- let obj = {
- text: value[0].name,
- arr: value,
- value: key,
- };
- this.localdataList.push(obj);
- });
- this.Usertype = this.localdataList[0].value;
- this.text = this.localdataList[0].text;
- this.value = this.localdataList[0].value;
- res.map((v) => {
- v.splitList = [];
- });
- // this.newDispositionList = res;
- if (this.warehouseId == 2) {
- this.newDispositionList = [res[0]];
- } else if (this.warehouseId == 3) {
- this.newDispositionList = [res[1]];
- } else if (this.warehouseId == 4) {
- this.newDispositionList = [res[2]];
- }
- this.selectList = res;
- this.warehouseSpecTypeList.forEach((item) => {
- if (item.value == 2) {
- item.textValue = item.text + `(${this.selectPackInfo(res[0])})`;
- }
- if (item.value == 3) {
- item.textValue = item.text + `(${this.selectPackInfo(res[1])})`;
- }
- if (item.value == 4) {
- item.textValue = item.text + `(${this.selectPackInfo(res[2])})`;
- }
- });
- this.initFn(this.localdataList[0].arr);
- // this.listFn(this.localdataList[0].arr);
- }
- },
- selectPackInfo(data) {
- const num = data.packageCell ? data.packageCell : "";
- const packageUnit = data.packageUnit ? data.packageUnit : "";
- const conversionUnit = data.conversionUnit ? data.conversionUnit : "";
- let packInfo = "";
- if (num) {
- packInfo = num + "/" + packageUnit + "/" + conversionUnit;
- }
- return packInfo;
- },
- initFn(v) {
- if (v.length) {
- this.withinQuantity = v[1].packageCell; //内包装数量
- this.withinUnit = v[1].conversionUnit; //内包装单位
- this.outsideQuantity = v[2].packageCell; //外包装数量
- this.outsideUnit = v[2].conversionUnit; //外包装单位
- this.minimumUnit = v[0].conversionUnit;
- }
- this.handleSplit(v[0]);
- },
- async listFn(res) {
- let {
- minimumPackage,
- withinQuantity,
- outsidePackage,
- outsideQuantity,
- withinPackage,
- } = res;
- // let textList = ["最小包装", "内包装", "外包装"];
- // let arr = [
- // { list: minimumPackage },
- // { list: withinPackage, num: withinQuantity },
- // { list: outsidePackage, num: outsideQuantity },
- // ];
- let textList = [];
- let arr = [];
- if (this.warehouseId == 2) {
- textList.push("最小包装");
- arr.push({ list: minimumPackage });
- } else if (this.warehouseId == 3) {
- textList.push("内包装");
- arr.push({ list: withinPackage, num: withinQuantity });
- } else if (this.warehouseId == 4) {
- textList.push("外包装");
- arr.push({ list: outsidePackage, num: outsideQuantity });
- }
- this.minimumPackage = minimumPackage; // 最小包装
- this.withinPackage = withinPackage; // 内包装
- this.outsidePackage = outsidePackage; //外包装
- // this.newDispositionList.map((v, i) => {
- // v.splitList = arr[i].list;
- // v.titel = textList[i];
- // if (i == 0) {
- // v.formedNumLast = this.formedNumLast;
- // } else {
- // v.formedNumLast = arr[i].num;
- // }
- // });
- this.newDispositionList.map((v, i) => {
- v.splitList = arr[0].list;
- v.titel = textList[0];
- if (i == 0) {
- v.formedNumLast = this.formedNumLast;
- } else {
- v.formedNumLast = arr.num;
- }
- });
- this.$nextTick(() => {
- console.log(this.DispositionList, "我是啥来着");
- this.$set(this, "DispositionList", this.newDispositionList);
- });
- },
- sunNum(v, i) {
- let _this = this;
- this.$nextTick(() => {
- switch (i) {
- case 0:
- console.log(_this.formedNumLast);
- return _this.formedNumLast;
- case 1:
- return v.splitList.length || 0;
- case 2:
- return v.splitList.length || 0;
- }
- });
- },
- byCode() {
- getByCode("packing_unit").then((res) => {
- this.unitList = [];
- res.forEach((obj, index) => {
- for (let key in obj) {
- if (obj.hasOwnProperty(key)) {
- // 确保key是对象自身的属性
- this.unitList.push({
- Key: `${key}`,
- Value: ` ${obj[key]}`,
- });
- }
- }
- });
- });
- },
- getPackingDetails() {
- let param = {
- workOrderId: this.workOrderId,
- taskId: this.taskId,
- tier: 1,
- };
- getPackingReport(param).then((res) => {
- this.splitList = res.detailList;
- this.formedNumLast = res.totalQuantity;
- this.quantity = res.quantity;
- this.unit = res.unit;
- });
- },
- handCancelPacking() {
- uni.showModal({
- title: `是否清空包装?`,
- content: "",
- confirmText: "确认",
- success: () => {
- let param = {
- workOrderId: this.workOrderId,
- taskId: this.taskId,
- };
- cancelPacking(param).then((res) => {
- this.getPackingDetails();
- this.getPackingDetailsTwo();
- });
- },
- });
- },
- // 第一次调用
- handleSplit(v) {
- if (this.splitList.length) {
- uni.showToast({
- title: "产品已分包",
- icon: "none",
- });
- return false;
- }
- // if (!this.formedNumLast) {
- // uni.showToast({
- // title: '包装总数数量不能为空',
- // icon: 'none'
- // })
- // return false
- // }
- if (!v.packageCell) {
- uni.showToast({
- title: "内包装单元数量不能为空",
- icon: "none",
- });
- return false;
- }
- if (!v.packageUnit) {
- uni.showToast({
- title: "请选择包装单位",
- icon: "none",
- });
- return false;
- }
- let param = {
- workOrderId: this.workOrderId, //工单id
- taskId: this.taskId,
- tier: this.warehouseId,
- totalQuantity: this.formedNumLast, //总数量
- quantity: v.packageCell, //数量
- unit: v.packageUnit, //单位
- minimumUnit: this.minimumUnit, //最小包装单位
- withinQuantity: this.withinQuantity, //内包装数量
- withinUnit: this.withinUnit, //内包装单位
- outsideQuantity: this.outsideQuantity, //外包装数量
- outsideUnit: this.outsideUnit, //外包装单位
- packageUnit: v.conversionUnit,
- };
- // packingReport(param).then((res) => {
- // this.listFn(res);
- // });
- if (this.warehouseId != 1) {
- getPackingList(param).then((res) => {
- this.listFn(res);
- });
- }
- // getPackingList(param).then((res) => {
- // this.listFn(res);
- // });
- },
- handleCheck(idx, it) {
- if (it.quantity <= 0) {
- uni.showToast({
- icon: "none",
- title: "数量为空不能勾选",
- });
- return false;
- }
- this.$set(this.splitList[idx], "check", it.check ? 0 : 1);
- this.temporaryList = [];
- this.temporaryList = this.splitList.filter((e) => {
- return e.check == 1;
- });
- this.temporaryNum = 0;
- this.temporaryCount = 0;
- if (this.temporaryList.length > 0) {
- this.temporaryList.forEach((e) => {
- this.temporaryNum = this.temporaryNum + 1;
- this.temporaryCount = this.temporaryCount + Number(e.quantity);
- });
- }
- },
- handclose(it) {
- this.splitList.forEach((f) => {
- if (f.computeSize == it.computeSize) {
- f.check = 0;
- }
- });
- this.temporaryList = [];
- this.temporaryList = this.splitList.filter((e) => {
- return e.check == 1;
- });
- },
- getPackingDetailsTwo(v) {
- console.log(v);
- let param = {
- totalQuantity: v.formedNumLast,
- quantity: v.packageCell,
- unit: v.conversionUnit,
- workOrderId: this.workOrderId,
- taskId: this.taskId,
- tier: 2,
- };
- getPackingReportRepeat(param).then((res) => {
- resolve(res.detailList);
- });
- },
- handlePack(v, s) {
- let _arr = [];
- _arr = s.map((m) => {
- return {
- ...m,
- isChecked: 1,
- };
- });
- console.log(_arr, "123");
- let param = {
- detailList: _arr,
- quantity: v.temporaryCount,
- totalQuantity: v.formedNumLast,
- unit: v.packageUnit,
- taskId: this.taskId,
- workOrderId: this.workOrderId,
- tier: 2,
- };
- return new Promise((resolve, reject) => {
- packingReportRepeat(param).then((res) => {
- console.log(res);
- // this.temporaryList = []
- this.getPackingDetails();
- // this.getPackingDetailsTwo()
- });
- });
- },
- scrolltolower() {},
- getData() {
- let _packingReportMarginList = [];
- _packingReportMarginList = this.splitList.filter((e) => {
- return !e.parentId;
- });
- let packInfo = {};
- if (this.isNewUnpack == 1) {
- if (this.DispositionList && this.DispositionList.length != 0) {
- packInfo = {
- // this.DispositionList[0]
- specText: this.text,
- specValue: this.value,
- minimumPackage: this.minimumPackage, // 最小包装
- withinPackage: this.withinPackage,
- outsidePackage: this.outsidePackage,
- tier: this.warehouseId,
- isUnpack: this.objData.isUnpack,
- packageUnit: this.packageUnit,
- formedNumLast: this.formedNumLast,
- minimumPackageCell: this.DispositionList[0].packageCell, // 最小包装
- minimumPackageUnit: this.DispositionList[0].packageUnit, // 最小包装单位
- minimumConversionUnit: this.DispositionList[0].conversionUnit, // 最小包装单位
- minimumFormedNumLast: this.DispositionList[0].formedNumLast, // 总包装数量
- withinPackageCell: this.DispositionList[1].packageCell, // 最小包装名称
- withinPackageUnit: this.DispositionList[1].packageUnit, // 最小包装单位
- withinConversionUnit: this.DispositionList[1].conversionUnit, // 最小包装单位
- withinFormedNumLast: this.DispositionList[1].formedNumLast, // 总包装数量
- outsidePackageCell: this.DispositionList[2].packageCell, // 最小包装名称
- outsidePackageUnit: this.DispositionList[2].packageUnit, // 最小包装单位
- outsideConversionUnit: this.DispositionList[2].conversionUnit, // 最小包装单位
- outsideFormedNumLast: this.DispositionList[2].formedNumLast,
- isNewUnpack: this.isNewUnpack,
- };
- } else {
- packInfo = {
- isUnpack: this.objData.isUnpack,
- };
- }
- } else {
- if (this.warehouseId == 2) {
- if (this.DispositionList && this.DispositionList.length != 0) {
- packInfo = {
- // this.DispositionList[0]
- specText: this.text,
- specValue: this.value,
- minimumPackage: this.minimumPackage, // 最小包装
- tier: this.warehouseId,
- isUnpack: this.objData.isUnpack,
- packUnitInfo: this.warehouseSpecTypeList[1].textValue,
- minimumPackageCell: this.DispositionList[0].packageCell, // 最小包装
- minimumPackageUnit: this.DispositionList[0].packageUnit, // 最小包装单位
- minimumConversionUnit: this.DispositionList[0].conversionUnit, // 最小包装单位
- minimumFormedNumLast: this.DispositionList[0].formedNumLast, // 总包装数量
- isNewUnpack: this.isNewUnpack,
- };
- } else {
- packInfo = {
- tier: 1,
- isUnpack: this.objData.isUnpack,
- };
- }
- } else if (this.warehouseId == 3) {
- if (this.DispositionList && this.DispositionList.length != 0) {
- packInfo = {
- specText: this.text,
- specValue: this.value,
- withinPackage: this.withinPackage, // 内包装
- tier: this.warehouseId,
- isUnpack: this.objData.isUnpack,
- packUnitInfo: this.warehouseSpecTypeList[2].textValue,
- withinPackageCell: this.DispositionList[1].packageCell, // 最小包装名称
- withinPackageUnit: this.DispositionList[1].packageUnit, // 最小包装单位
- withinConversionUnit: this.DispositionList[1].conversionUnit, // 最小包装单位
- withinFormedNumLast: this.DispositionList[1].formedNumLast,
- isNewUnpack: this.isNewUnpack,
- }; // 总包装数量
- } else {
- packInfo = {
- tier: 3,
- isUnpack: this.objData.isUnpack,
- };
- }
- } else if (this.warehouseId == 4) {
- if (this.DispositionList && this.DispositionList.length != 0) {
- packInfo = {
- specText: this.text,
- specValue: this.value,
- outsidePackage: this.outsidePackage, //外包装
- tier: this.warehouseId,
- isUnpack: this.objData.isUnpack,
- packUnitInfo: this.warehouseSpecTypeList[3].textValue,
- outsidePackageCell: this.DispositionList[2].packageCell, // 最小包装名称
- outsidePackageUnit: this.DispositionList[2].packageUnit, // 最小包装单位
- outsideConversionUnit: this.DispositionList[2].conversionUnit, // 最小包装单位
- outsideFormedNumLast: this.DispositionList[2].formedNumLast,
- isNewUnpack: this.isNewUnpack,
- }; // 总包装数量
- } else {
- packInfo = {
- tier: 4,
- isUnpack: this.objData.isUnpack,
- };
- }
- }
- }
- return packInfo;
- },
- calculation() {
- this.show = true;
- },
- calculationSave() {
- let count = this.splitList.filter((item) => item.isChecked != 1).length;
- if (this.formData.wPackNum <= count && count != 0) {
- for (let i = 0; i < this.formData.wPackNum; i++) {
- this.splitList[i].check = 1;
- }
- this.handleCheck(0, 0);
- this.calculationClose();
- } else {
- if (count != 0) {
- for (let i = 0; i < count; i++) {
- this.splitList[i].check = 1;
- }
- this.handleCheck(0, 0);
- this.calculationClose();
- }
- uni.showToast({
- icon: "none",
- title: "外包装数超出内包装条数",
- });
- }
- },
- calculationClose() {
- this.show = false;
- },
- calculationReset() {
- this.formData.wPackNum = null;
- this.splitList.forEach((f) => {
- f.check = null;
- });
- this.temporaryList = [];
- this.show = false;
- },
- changeWarehouseType() {
- this.packageDispositionFn();
- },
- checkUnpack() {
- this.$refs.alertDialog.open();
- },
- dialogConfirm() {
- this.isNewUnpack = 1;
- this.getPackingData();
- },
- async getPackingData() {
- console.log(this.newCategoryId, "555555555555");
- let that = this;
- const res = await packageDisposition(this.newCategoryId);
- if (res.length) {
- res.shift();
- let data = JSON.parse(JSON.stringify(res));
- let list = this.groupBy(data, "code");
- this.localdataList = [];
- Object.entries(list).forEach(([key, value]) => {
- let obj = {
- text: value[0].name,
- arr: value,
- value: key,
- };
- this.localdataList.push(obj);
- });
- this.Usertype = this.localdataList[0].value;
- this.text = this.localdataList[0].text;
- this.value = this.localdataList[0].value;
- res.map((v) => {
- v.splitList = [];
- });
- // this.newDispositionList = res;
- this.DispositionListes = res;
- this.selectList = res;
- this.initFn1(this.localdataList[0].arr);
- }
- },
- initFn1(v) {
- if (v.length) {
- this.withinQuantity = v[1].packageCell; //内包装数量
- this.withinUnit = v[1].conversionUnit; //内包装单位
- this.outsideQuantity = v[2].packageCell; //外包装数量
- this.outsideUnit = v[2].conversionUnit; //外包装单位
- this.minimumUnit = v[0].conversionUnit;
- }
- this.handleSplit1(v[0]);
- },
- handleSplit1(v) {
- if (this.splitList.length) {
- uni.showToast({
- title: "产品已分包",
- icon: "none",
- });
- return false;
- }
- if (!v.packageCell) {
- uni.showToast({
- title: "内包装单元数量不能为空",
- icon: "none",
- });
- return false;
- }
- if (!v.packageUnit) {
- uni.showToast({
- title: "请选择包装单位",
- icon: "none",
- });
- return false;
- }
- this.packageCell = this.formedNumLast;
- this.packageUnit = v.packageUnit;
- let param = {
- workOrderId: this.workOrderId, //工单id
- taskId: this.taskId,
- tier: this.warehouseId,
- totalQuantity: this.formedNumLast, //总数量
- quantity: v.packageCell, //数量
- unit: v.packageUnit, //单位
- minimumUnit: this.minimumUnit, //最小包装单位
- withinQuantity: this.withinQuantity, //内包装数量
- withinUnit: this.withinUnit, //内包装单位
- outsideQuantity: this.outsideQuantity, //外包装数量
- outsideUnit: this.outsideUnit, //外包装单位
- packageUnit: v.conversionUnit,
- isNewUnpack: this.isNewUnpack,
- };
- if (this.warehouseId != 1) {
- getPackingList(param).then((res) => {
- this.listFn1(res);
- });
- }
- },
- toInteger(num) {
- const len = this.getDecimalLength(num);
- return {
- int: Math.round(num * Math.pow(10, len)),
- factor: Math.pow(10, len),
- };
- },
- add(a, b) {
- const { int: aInt, factor: aFactor } = this.toInteger(a);
- const { int: bInt, factor: bFactor } = this.toInteger(b);
- const maxFactor = Math.max(aFactor, bFactor);
- return (
- (aInt * (maxFactor / aFactor) + bInt * (maxFactor / bFactor)) /
- maxFactor
- );
- },
- sub(a, b) {
- const { int: aInt, factor: aFactor } = this.toInteger(a);
- const { int: bInt, factor: bFactor } = this.toInteger(b);
- const maxFactor = Math.max(aFactor, bFactor);
- return (
- (aInt * (maxFactor / aFactor) - bInt * (maxFactor / bFactor)) /
- maxFactor
- );
- },
- getDecimalLength(num) {
- return (num.toString().split(".")[1] || "").length;
- },
- async listFn1(res) {
- let {
- minimumPackage,
- withinQuantity,
- outsidePackage,
- outsideQuantity,
- withinPackage,
- minimumQuantity,
- } = res;
- let textList = ["最小包装", "内包装", "外包装"];
- let arr = [
- { list: minimumPackage, num: minimumQuantity },
- { list: withinPackage, num: withinQuantity },
- { list: outsidePackage, num: outsideQuantity },
- ];
- this.minimumPackage = minimumPackage; // 最小包装
- this.withinPackage = withinPackage; // 内包装
- this.outsidePackage = outsidePackage; //外包装
- this.newDispositionList = this.DispositionListes.filter(
- (it) => it.code == this.Usertype && it.sort != "0"
- );
- this.newDispositionList.map((v, i) => {
- v.splitList = arr[i].list;
- v.titel = textList[i];
- // if (i == 0) {
- // v.formedNumLast = this.formedNumLast;
- // } else {
- v.formedNumLast = arr[i].num;
- // }
- });
- this.$nextTick(() => {
- this.newDispositionList.forEach((item, index) => {
- if (index == 0) {
- this.packageCell = item.formedNumLast ? item.formedNumLast : "";
- this.packageUnit = item.packageUnit ? item.packageUnit : "";
- this.conversionUnit = item.conversionUnit
- ? item.conversionUnit
- : "";
- } else if (index == 1) {
- this.packageOneCell = item.formedNumLast ? item.formedNumLast : "";
- this.packageOneUnit = item.packageUnit ? item.packageUnit : "";
- this.conversionOneUnit = item.conversionUnit
- ? item.conversionUnit
- : "";
- } else if (index == 2) {
- this.packageTwoCell = item.formedNumLast ? item.formedNumLast : "";
- this.packageTwoUnit = item.packageUnit ? item.packageUnit : "";
- this.conversionTwoUnit = item.conversionUnit
- ? item.conversionUnit
- : "";
- }
- });
- this.packageDispositionData = `${this.formedNumLast}${this.packageUnit}/${this.packageCell}${this.conversionUnit}/${this.packageOneCell}${this.conversionOneUnit}/${this.packageTwoCell}${this.conversionTwoUnit}`;
- this.newDispositionList.forEach((item, index) => {
- if (item.splitList.length != 0) {
- item.splitList[0].extInfo.packageDisposition =
- this.packageDispositionData;
- if (index == 0) {
- this.warehouseId = 2;
- } else if (index == 1) {
- this.warehouseId = 3;
- } else if (index == 2) {
- this.warehouseId = 4;
- }
- }
- });
- this.$set(this, "DispositionList", this.newDispositionList);
- this.$forceUpdate();
- });
- },
- changeInputPack(item, index) {
- setTimeout(() => {
- if (this.DispositionList[index]) {
- if (!this.DispositionList[index].packageCell) {
- if (index <= this.DispositionList.length - 1) {
- this.DispositionList[index].formedNumLast = "";
- if (index + 1 <= this.DispositionList.length - 1) {
- this.DispositionList[index + 1].formedNumLast = "";
- }
- if (index + 2 <= this.DispositionList.length - 1) {
- this.DispositionList[index + 2].formedNumLast = "";
- }
- }
- this.newDispositionList.forEach((item, index) => {
- if (index == 0) {
- this.packageCell = item.formedNumLast ? item.formedNumLast : "";
- this.packageUnit = item.packageUnit ? item.packageUnit : "";
- this.conversionUnit = item.conversionUnit
- ? item.conversionUnit
- : "";
- } else if (index == 1) {
- this.packageOneCell = item.formedNumLast
- ? item.formedNumLast
- : "";
- this.packageOneUnit = item.packageUnit ? item.packageUnit : "";
- this.conversionOneUnit = item.conversionUnit
- ? item.conversionUnit
- : "";
- } else if (index == 2) {
- this.packageTwoCell = item.formedNumLast
- ? item.formedNumLast
- : "";
- this.packageTwoUnit = item.packageUnit ? item.packageUnit : "";
- this.conversionTwoUnit = item.conversionUnit
- ? item.conversionUnit
- : "";
- }
- });
- this.packageDispositionData = `${this.formedNumLast}${this.packageUnit}/${this.packageCell}${this.conversionUnit}/${this.packageOneCell}${this.conversionOneUnit}/${this.packageTwoCell}${this.conversionTwoUnit}`;
- this.DispositionList.forEach((item, index) => {
- if (item.splitList.length != 0) {
- this.DispositionList[
- index
- ].splitList[0].extInfo.packageDisposition =
- this.packageDispositionData;
- }
- });
- this.$forceUpdate();
- return;
- }
- }
- if (this.DispositionList[index]) {
- if (this.DispositionList[index].titel == "最小包装") {
- if (
- this.DispositionList[index].formedNumLast &&
- Number(this.DispositionList[index].packageCell) >
- Number(this.formedNumLast)
- ) {
- this.DispositionList[index].packageCell = Number(
- this.formedNumLast
- );
- }
- } else if (this.DispositionList[index].titel == "内包装") {
- if (
- this.DispositionList[index - 1].formedNumLast &&
- Number(this.DispositionList[index].packageCell) >
- Number(this.DispositionList[index - 1].formedNumLast)
- ) {
- this.DispositionList[index].packageCell = Number(
- this.DispositionList[index - 1].formedNumLast
- );
- }
- } else if (this.DispositionList[index].titel == "外包装") {
- if (
- this.DispositionList[index - 1].formedNumLast &&
- Number(this.DispositionList[index].packageCell) >
- Number(this.DispositionList[index - 1].formedNumLast)
- ) {
- this.DispositionList[index].packageCell = Number(
- this.DispositionList[index - 1].formedNumLast
- );
- }
- }
- }
- console.log(this.DispositionList, "返回的数据");
- this.initFn1(this.DispositionList);
- }, 500);
- },
- dialogClose() {
- console.log("窗口关闭了");
- },
- deepCopy(obj, hash = new WeakMap()) {
- if (obj === null) return null;
- if (obj instanceof Date) return new Date(obj);
- if (obj instanceof RegExp) return new RegExp(obj);
- if (typeof obj !== "object" && typeof obj !== "function") return obj;
- if (hash.has(obj)) return hash.get(obj); // 处理循环引用
- const result = Array.isArray(obj) ? [] : {};
- hash.set(obj, result); // 存储原始对象和其副本的映射关系
- return Object.keys(obj).reduce((acc, key) => {
- acc[key] = this.deepCopy(obj[key], hash);
- return acc;
- }, result);
- },
- },
- };
- </script>
- <style lang="scss" scoped>
- .title_box {
- margin-top: 20rpx;
- .ww20 {
- width: 20%;
- }
- .name {
- font-size: 28rpx;
- font-style: normal;
- font-weight: 400;
- color: $theme-color;
- padding-left: 20rpx;
- position: relative;
- &:before {
- position: absolute;
- content: "";
- left: 0rpx;
- top: 0rpx;
- bottom: 0rpx;
- width: 4rpx;
- height: 28rpx;
- background: $theme-color;
- margin: auto;
- }
- }
- .btn_box {
- color: $theme-color;
- }
- }
- .material {
- margin-top: 10rpx;
- .content_table {
- width: 100%;
- border: 2rpx solid $border-color;
- .item {
- display: flex;
- border-bottom: 2rpx solid $border-color;
- .lable {
- width: 132rpx;
- text-align: center;
- background-color: #f7f9fa;
- font-size: 26rpx;
- border-right: 2rpx solid $border-color;
- flex-shrink: 0;
- }
- .lable220 {
- width: 220rpx !important;
- font-size: 24rpx;
- }
- .lable150 {
- width: 156rpx !important;
- font-size: 24rpx;
- }
- .ww80 {
- width: 80rpx;
- }
- .content {
- width: 518rpx;
- min-height: 64rpx;
- font-size: 28rpx;
- line-height: 28rpx;
- font-style: normal;
- font-weight: 400;
- // padding: 18rpx 8rpx;
- box-sizing: border-box;
- word-wrap: break-word;
- flex-grow: 1 !important;
- .unit {
- padding: 0 4rpx;
- font-size: 24rpx;
- color: #404446;
- }
- }
- &:last-child {
- border-bottom: none;
- }
- }
- .ww55 {
- width: 55%;
- }
- .ww45 {
- width: 45%;
- }
- }
- }
- .content_table2 {
- width: 100%;
- margin-top: 16rpx;
- .row {
- width: 100%;
- .item {
- color: #404446;
- font-size: 28rpx;
- padding-left: 12rpx;
- }
- .color157 {
- color: $theme-color;
- }
- .ww30 {
- width: 30%;
- }
- .ww50 {
- width: 50%;
- }
- .ww90 {
- width: 90%;
- }
- .ww15 {
- width: 15%;
- }
- .ww10 {
- width: 10%;
- }
- .ww30 {
- width: 30%;
- }
- .ww20 {
- width: 20%;
- }
- .ww40 {
- width: 40%;
- }
- .jsColor {
- color: $theme-color;
- font-size: 20rpx;
- }
- }
- .head {
- height: 64rpx;
- background: #f7f9fa;
- border-top: 2rpx solid #e3e5e5;
- border-left: 2rpx solid #e3e5e5;
- .item {
- height: 64rpx;
- line-height: 64rpx;
- border-right: 2rpx solid #e3e5e5;
- box-sizing: border-box;
- }
- }
- .tr {
- border-top: 2rpx solid #e3e5e5;
- border-left: 2rpx solid #e3e5e5;
- .item {
- font-size: 24rpx;
- min-height: 64rpx;
- display: flex;
- align-items: center;
- border-right: 2rpx solid #e3e5e5;
- box-sizing: border-box;
- white-space: normal;
- word-break: break-all;
- }
- &:last-child {
- border-bottom: 2rpx solid #e3e5e5;
- }
- }
- }
- .label {
- display: flex;
- height: 70rpx;
- width: 86px !important;
- font-size: 13px;
- align-items: center;
- justify-content: center;
- background-color: #f7f9fa;
- }
- .content_num {
- display: flex;
- align-items: center;
- padding: 0 4rpx;
- /deep/ .uni-input-input {
- border: 2rpx solid #f0f8f2;
- background: #f0f8f2;
- color: $theme-color;
- }
- }
- .penalize {
- width: 86rpx;
- line-height: 60rpx;
- background: $theme-color;
- font-size: 24rpx;
- text-align: center;
- color: #fff;
- }
- .check {
- width: 30rpx;
- height: 30rpx;
- }
- .z_list {
- max-height: 500rpx;
- }
- .search_list {
- min-height: 100rpx;
- width: 80vw;
- /deep/ .baseForm {
- padding: 0 20rpx;
- }
- }
- .operate_box {
- padding: 10rpx 32rpx;
- /deep/ .u-button {
- width: 30%;
- }
- }
- </style>
|