| 123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684 |
- <template>
- <ele-modal
- title="领料单"
- :visible.sync="visible"
- :before-close="handleClose"
- :close-on-click-modal="false"
- :maxable="true"
- :close-on-press-escape="false"
- append-to-body
- width="80%"
- @update:fullscreen="fullscreen"
- :fullscreen="isFullscreen"
- :height="dialogDynamicHeight"
- >
- <el-form>
- <el-row :gutter="24">
- <el-col :span="6">
- <el-form-item label="领料单编号" prop="pickCode" label-width="90px">
- <el-input v-model="pickCode" disabled=""></el-input>
- </el-form-item>
- </el-col>
- <el-col :span="6">
- <el-form-item label="领料单名称" prop="pickName" label-width="90px">
- <el-input v-model="pickName" style="width: 260px"></el-input>
- </el-form-item>
- </el-col>
- </el-row>
- </el-form>
- <div v-for="(item, idx) in workList" :key="idx">
- <el-form
- :ref="`formRef${idx}`"
- :model="{ pickList: item }"
- :rules="tableRules"
- size="mini"
- label-position="left"
- >
- <div class="tableZ_box">
- <div class="row">
- <div class="col">
- <div class="name">生产工单号</div>
- <div class="content">{{ item.code }}</div>
- </div>
- <div class="col">
- <div class="name">产品编码</div>
- <div class="content">{{ item.productCode }}</div>
- </div>
- <div class="col">
- <div class="name">产品名称</div>
- <div class="content">{{ item.productName }}</div>
- </div>
- <div class="col">
- <div class="name">批次号</div>
- <div class="content">{{ item.batchNo }}</div>
- </div>
- <div class="col pd6" v-if="clientEnvironmentId != 21">
- <el-button type="primary" size="mini" @click="openPicking()"
- >获取委外单</el-button
- >
- </div>
- </div>
- </div>
- <div>
- <el-table
- :ref="`tableRef${idx}`"
- class="table_content"
- :max-height="300"
- :data="item.pickList"
- tooltip-effect="dark"
- style="width: 100%"
- stripe
- border
- >
- <el-table-column label="序号" type="index" width="60">
- <template slot-scope="{ row, $index }">
- {{ $index + 1 }}
- </template>
- </el-table-column>
- <el-table-column label="类型" prop="rootCategoryLevelId" width="80">
- <template slot-scope="{ row, $index }">
- <el-tag size="mini">{{
- typeName[Number(row.rootCategoryLevelId)]
- }}</el-tag>
- </template>
- </el-table-column>
- <el-table-column
- label="编码"
- prop="assetCode"
- show-overflow-tooltip
- >
- <template slot-scope="{ row, $index }">
- <span
- v-if="
- Object.prototype.hasOwnProperty.call(row, 'isBom') &&
- row.isBom == 1
- "
- style="color: #faad14"
- >
- {{ row.categoryCode }}
- </span>
- <span>
- {{
- row.rootCategoryLevelId == 4 ? row.codeNumber : row.code
- }}</span
- >
- </template>
- </el-table-column>
- <el-table-column label="名称" prop="name" show-overflow-tooltip>
- <template slot-scope="{ row, $index }">
- <span
- v-if="
- Object.prototype.hasOwnProperty.call(row, 'isBom') &&
- row.isBom == 1
- "
- >
- {{ row.categoryName }}
- </span>
- <span> {{ row.name }}</span>
- <span v-if="row.isOut" style="color: #faad14"> (委外) </span>
- </template>
- </el-table-column>
- <el-table-column
- label="型号"
- prop="modelType"
- show-overflow-tooltip
- >
- </el-table-column>
- <el-table-column
- label="规格"
- prop="specification"
- show-overflow-tooltip
- >
- </el-table-column>
- <el-table-column label="批次号" prop="batchNo"> </el-table-column>
- <el-table-column label="数量" prop="demandQuantity">
- <template slot-scope="{ row, $index }">
- <el-form-item>
- <el-input
- v-model="row.demandQuantity"
- @input="
- row.demandQuantity > row.availableCountBase
- ? (row.demandQuantity = row.availableCountBase)
- : row.demandQuantity
- "
- size="mini"
- style="width: 120px"
- >
- <template slot="append">{{ row.unit }}</template>
- </el-input>
- </el-form-item>
- </template>
- </el-table-column>
- <el-table-column label="计量库存数量" prop="availableCountBase">
- <template slot-scope="{ row, $index }">
- {{ row.availableCountBase }} {{ row.unit }}
- </template>
- </el-table-column>
- <el-table-column label="领料仓库" prop="warehouseId">
- <template slot-scope="{ row, $index }">
- <div
- v-if="
- Object.prototype.hasOwnProperty.call(row, 'isBom') &&
- row.isBom == 1
- "
- >
- <el-select
- v-model="row.warehouseId"
- placeholder="请选择"
- filterable
- >
- <el-option
- v-for="item in row.warehouseList"
- :label="item.name"
- :value="item.id"
- :key="item.id"
- >
- </el-option>
- </el-select>
- </div>
- <div v-else-if="clientEnvironmentId == 21">
- <el-select
- v-model="row.warehouseId"
- placeholder="请选择"
- filterable
- >
- <el-option
- v-for="item in row.warehouseList"
- :label="item.name"
- :value="item.id"
- :key="item.id"
- >
- </el-option>
- </el-select>
- </div>
- <div v-else-if="row.warehouseName">
- <span>{{ row.warehouseName }}</span>
- </div>
- <div v-else>
- <el-select
- v-model="row.warehouseId"
- placeholder="请选择"
- filterable
- >
- <el-option
- v-for="item in row.warehouseLists"
- :label="item.warehouse_name"
- :value="item.warehouse_id"
- :key="item.warehouse_id"
- >
- </el-option>
- </el-select>
- </div>
- </template>
- </el-table-column>
- <el-table-column label="操作" fixed="right" width="100px">
- <template slot-scope="{ $index, row }">
- <el-link type="danger" @click="removeItem(idx, $index)"
- >删除</el-link
- >
- </template>
- </el-table-column>
- </el-table>
- </div>
- </el-form>
- </div>
- <template slot="footer">
- <el-button size="mini" @click="handleClose">取 消</el-button>
- <el-button
- size="mini"
- type="primary"
- :loading="loadingBtn"
- @click="save()"
- >确 定</el-button
- >
- </template>
- <!-- <pickingList
- isType="pick"
- ref="pickingListRef"
- @allSelection="allSelection"
- ></pickingList> -->
- <outsourcingPickingList
- v-if="outsourcingPickingShow"
- ref="outsourcingPickingListRef"
- :workTaskId="workListIds[0]"
- :taskId="taskObj.id"
- @closeOutsourcingPicking="closeOutsourcingPicking"
- @outsourceEmit="outsourceEmit"
- ></outsourcingPickingList>
- </ele-modal>
- </template>
- <script>
- import pickingList from './pickingList.vue';
- import {
- workorderList,
- getCode,
- getInventoryTotal,
- znworkorderList
- } from '@/api/produce/workOrder';
- import { typeName } from '../common.js';
- import {
- batchSave,
- znfindVoucherList,
- listOutsourceInWarehouse
- } from '@/api/produce/picking';
- import outsourcingPickingList from './outsourcingPickingList.vue';
- export default {
- components: {
- pickingList,
- outsourcingPickingList
- },
- props: {
- workListIds: {
- type: Array,
- default() {
- return [];
- }
- }
- },
- data() {
- return {
- visible: true,
- workList: [],
- rules: {},
- pickCode: null,
- pickName: null,
- typeName,
- tableRules: {},
- loadingBtn: false,
- outsourcingPickingShow: false,
- isFullscreen: false
- };
- },
- computed: {
- taskObj() {
- return this.$store.state.user.taskObj;
- },
- clientEnvironmentId() {
- return this.$store.state.user.info.clientEnvironmentId;
- },
- dialogDynamicHeight() {
- if (this.isFullscreen) {
- // 全屏时,高度为窗口高度
- console.log(window.innerHeight + 'px', '全屏高度');
- this.tabalHeight = window.innerHeight - 200;
- return window.innerHeight + 'px';
- } else {
- this.tabalHeight = 300;
- return '500px';
- }
- }
- },
- watch: {},
- methods: {
- getList() {
- let param = {
- ids: this.workListIds,
- taskId: this.taskObj.id
- };
- console.log('1111122222', this.clientEnvironmentId);
- if (this.clientEnvironmentId == 21) {
- znworkorderList(param).then((res) => {
- let arr = res.map((e) => {
- e.bomDetailDTOS.map((d) => {
- e.warehouseId =
- d.warehouseList.length > 0 ? d.warehouseList[0].id : '';
- });
- // e.pickList = [...e.bomDetailDTOS];
- e.pickList = [];
- e.bomDetailDTOS = [];
- return e;
- });
- this.pickName = res[0].productName + '领料';
- // arr.bomDetailDTOS.map(v=>{
- // this.getInventoryTotalFn(v.id)
- // })
- // getInventoryTotal
- // this.workList = arr;
- this.$set(this, 'workList', arr);
- this.getOrderCode();
- this.$forceUpdate();
- });
- } else {
- workorderList(param).then((res) => {
- let arr = res.map((e) => {
- e.bomDetailDTOS.map((d) => {
- e.warehouseId =
- d.warehouseList.length > 0 ? d.warehouseList[0].id : '';
- // this.getInventoryTotalFn([d.categoryCode])
- });
- // e.pickList = [...e.bomDetailDTOS];
- e.pickList = [];
- e.bomDetailDTOS = [];
- return e;
- });
- this.pickName = res[0].productName + '领料';
- // arr.bomDetailDTOS.map(v=>{
- // this.getInventoryTotalFn(v.id)
- // })
- // getInventoryTotal
- // this.workList = arr;
- this.$set(this, 'workList', arr);
- this.getOrderCode();
- this.getInventoryTotalFn();
- this.$forceUpdate();
- });
- }
- },
- async getInventoryTotalFn(id) {
- let ids = [];
- this.workList.map((item) => {
- item.pickList.map((pitem) => {
- ids.push(pitem.code);
- });
- });
- if (ids.length == 0) {
- return;
- }
- const res = await getInventoryTotal(ids);
- res.map((ritem) => {
- this.workList.map((item) => {
- item.pickList.map((pitem, index) => {
- if (pitem.warehouseName == ritem.warehouseName) {
- // pitem.availableCountBase = ritem.availableCountBase;
- this.$set(
- this.workList[0].pickList[index],
- 'availableCountBase',
- ritem.availableCountBase
- );
- }
- });
- });
- });
- console.log(this.workList, 'this.workList');
- // console.log('cashasisasa', res);
- },
- async getOrderCode() {
- console.log(this.workListIds, '555555');
- this.pickCode = await getCode('pick_order_code');
- },
- removeItem(idx, index) {
- this.workList[idx].pickList.splice(index, 1);
- },
- handleClose() {
- this.loadingBtn = false;
- this.$emit('close', false);
- },
- outsourceEmit(list) {
- if (list) {
- let param = {
- outsourceOrder: list || [],
- workOrderId: this.workListIds[0],
- taskId: this.taskObj.id,
- isPC: 1
- };
- listOutsourceInWarehouse(param).then((res) => {
- let indexList = [];
- res.list.forEach((item) => {
- item.isOut = 1;
- this.workList[0].pickList.forEach((i, index) => {
- if (i.categoryId == item.categoryId) {
- indexList.push(index);
- }
- });
- });
- if (indexList.length > 0) {
- indexList.forEach((i) => {
- this.workList[0].pickList.splice(i, 1);
- });
- }
- let _arr = [...this.workList[0].pickList, ...res.list];
- this.$set(this.workList[0], 'pickList', _arr);
- this.$forceUpdate();
- console.log(this.workList[0], 'this.workList[0]');
- // this.getInventoryTotalFn(this.workList[0])
- // let ids = [];
- // console.log(list, 'list111');
- // this.workList[0].pickList.forEach((item) => {
- // ids.push(item.code);
- // });
- // console.log(ids, 'ids');
- // if (ids.length != 0) {
- this.getInventoryTotalFn();
- // }
- });
- }
- this.closeOutsourcingPicking();
- },
- openPicking(id, item) {
- this.outsourcingPickingShow = true;
- // this.$refs.pickingListRef.open(id, item, '选择列表');
- },
- allSelection(id, list) {
- this.workList.forEach((e) => {
- if (e.id == id) {
- e.pickList = list;
- this.$forceUpdate();
- }
- });
- },
- save() {
- console.log(this.workList, 'cvassasasag');
- if (this.workList.length > 0) {
- let bol;
- let _i;
- bol = this.workList.every((e, i) => {
- _i = i;
- return (
- Object.prototype.hasOwnProperty.call(e, 'pickList') &&
- e.pickList.length > 0
- );
- });
- if (!bol) {
- this.$message.warning(
- `生成工单${this.workList[_i].code}领料不能为空`
- );
- return false;
- }
- }
- if (this.workList.length > 0) {
- let name;
- let bol2;
- let _i;
- this.workList.forEach((e, i) => {
- _i = i;
- console.log(e.pickList);
- bol2 = e.pickList.every((y) => {
- name = y.name;
- return (
- Object.prototype.hasOwnProperty.call(y, 'demandQuantity') &&
- Number(y.demandQuantity) > 0
- );
- });
- });
- if (!bol2) {
- this.$message.warning(
- `${this.workList[_i].code}的${name}数量不能为空`
- );
- return false;
- }
- }
- let _arr = [];
- _arr = this.workList.map((m) => {
- m.instanceList = [];
- m.bomDetailDTOSList = [];
- m.pickList.forEach((e) => {
- if (
- Object.prototype.hasOwnProperty.call(e, 'isBom') &&
- e.isBom == 1
- ) {
- m.bomDetailDTOSList.push(e);
- } else {
- m.instanceList.push(e);
- }
- });
- m.workOrderId = m.id;
- delete m.id;
- return {
- ...m
- };
- });
- this.loadingBtn = true;
- if (_arr.length != 0) {
- _arr.forEach((it) => {
- it.isOutsource = 1;
- });
- }
- // if (this.clientEnvironmentId == 21) {
- // let param = {
- // workOrderId: this.workListIds[0],
- // pickingCode: this.pickCode
- // };
- // znfindVoucherList(param).then((res) => {
- // this.loadingBtn = false;
- // this.$message.success('领料成功');
- // });
- // }
- let param = {
- allPickList: _arr,
- pickName: this.pickName,
- pickCode: this.pickCode
- };
- batchSave(param)
- .then((res) => {
- this.loadingBtn = false;
- this.$message.success('领料成功');
- this.$emit('close', true);
- })
- .catch((err) => {
- this.loadingBtn = false;
- });
- },
- closeOutsourcingPicking() {
- this.outsourcingPickingShow = false;
- },
- fullscreen() {
- this.isFullscreen = !this.isFullscreen;
- }
- },
- created() {
- this.getList();
- },
- mounted() {
- this.$nextTick(() => {
- // this.outsourcingPickingShow = true;
- setTimeout(() => {
- // this.outsourcingPickingShow = true;
- }, 5000);
- });
- }
- };
- </script>
- <style lang="scss" scoped>
- .table_content {
- margin-bottom: 10px;
- }
- .tableZ_box {
- border: 1px solid #e3e5e5;
- margin: 6px 0;
- &:last-child {
- border-bottom: none;
- }
- .row {
- width: 100%;
- display: flex;
- }
- .col {
- width: calc(100% / 5);
- display: flex;
- align-items: center;
- min-width: 200px;
- min-height: 32px;
- border-bottom: 1px solid #e3e5e5;
- border-right: 1px solid #e3e5e5;
- &:last-child {
- border-right: none;
- }
- .name {
- display: flex;
- align-items: center;
- padding: 4px;
- width: 80px;
- height: 100%;
- background-color: #d0e4d5;
- color: #000;
- }
- .content {
- padding: 4px 6px;
- color: #000;
- }
- }
- .pd6 {
- padding: 0 6px;
- }
- }
- </style>
- <style>
- :v-deep .el-form-item__error {
- bottom: -6px !important;
- }
- </style>
|