| 123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300 |
- <template>
- <ele-modal
- :visible.sync="visible"
- :title="title"
- v-if="visible"
- width="65vw"
- append-to-body
- :maxable="true"
- >
- <el-button
- size="small"
- type="primary"
- icon="el-icon-plus"
- class="ele-btn-icon"
- @click="addGoods"
- style="margin-bottom: 10px"
- v-if="type != 'detail' && type != 'receipt'"
- >
- 新增在制品
- </el-button>
- <ele-pro-table
- ref="entrustCreateTable"
- :columns="columns"
- :datasource="goodsList"
- :selection.sync="selection"
- :current.sync="current"
- highlight-current-row
- row-key="id"
- height="40vh"
- >
- <template v-slot:quantity="{ row }">
- <span>{{ row.quantity }}{{ row.measuringUnit }}</span>
- </template>
- <template v-slot:weight="{ row }">
- <span>{{ row.weight }}{{ row.weightUnit }}</span>
- </template>
- <template v-slot:receiveQuantity="{ row }">
- <el-input
- placeholder=""
- v-model="row.receiveQuantity"
- :disabled="type == 'receipt' && itemData.sendStatus == 4"
- >
- <template slot="append">{{ row.measuringUnit }}</template>
- </el-input>
- </template>
- <template v-slot:rootCategoryLevelId="{ row }">
- <el-tag>{{ typeName[Number(row.rootCategoryLevelId)] }}</el-tag>
- </template>
- </ele-pro-table>
- <template v-slot:footer v-if="type != 'detail' && itemData.sendStatus != 4">
- <el-button @click="cancel">取消</el-button>
- <el-button type="primary" @click="save"> 确定 </el-button>
- </template>
- <add-invoice ref="addInvoiceRef" @chooseData="chooseData"></add-invoice>
- </ele-modal>
- </template>
- <script>
- import {
- pleaseEntrustGoodsDetail,
- pleaseEntrustSaveDetail,
- pleaseTReceiveGoods
- } from '@/api/entrust';
- import { typeName } from '@/views/produce/components/common.js';
- import addInvoice from './addInvoice.vue';
- export default {
- components: {
- addInvoice
- },
- data() {
- return {
- visible: false,
- goodsList: [],
- selection: [],
- current: null,
- typeName,
- id: '',
- title: '',
- type: '',
- itemData: {},
- loading: null
- };
- },
- computed: {
- columns() {
- return [
- {
- columnKey: 'index',
- label: '序号',
- type: 'index',
- width: 55,
- align: 'center',
- showOverflowTooltip: true,
- fixed: 'left'
- },
- {
- prop: 'categoryName',
- label: '名称',
- align: 'center',
- minWidth: 110,
- showOverflowTooltip: true
- },
- {
- prop: 'brandNum',
- label: '牌号',
- align: 'center',
- minWidth: 110,
- showOverflowTooltip: true
- },
- {
- prop: 'batchNo',
- label: '批次号',
- align: 'center',
- minWidth: 110,
- showOverflowTooltip: true
- },
- {
- prop: 'quantity',
- slot: 'quantity',
- label: '数量',
- align: 'center',
- minWidth: 140,
- showOverflowTooltip: true
- },
- {
- prop: 'workOrderCode',
- label: '生产工单号',
- align: 'center',
- minWidth: 110,
- showOverflowTooltip: true
- },
- {
- prop: 'receiveQuantity',
- slot: 'receiveQuantity',
- label: '接收数量',
- align: 'center',
- minWidth: 150,
- showOverflowTooltip: true,
- show: this.type == 'receipt' ? true : false
- },
- {
- prop: 'specification',
- label: '规格',
- align: 'center',
- minWidth: 110,
- showOverflowTooltip: true
- },
- {
- prop: 'modelType',
- label: '型号',
- align: 'center',
- minWidth: 110,
- showOverflowTooltip: true
- },
- // {
- // prop: 'taskName',
- // label: '工序',
- // align: 'center',
- // minWidth: 150,
- // showOverflowTooltip: true
- // },
- {
- prop: 'categoryCode',
- label: '编码',
- align: 'center',
- showOverflowTooltip: true
- },
- {
- prop: 'weight',
- slot: 'weight',
- label: '重量',
- align: 'center',
- showOverflowTooltip: true
- },
- {
- prop: 'rootCategoryLevelId',
- slot: 'rootCategoryLevelId',
- label: '类型',
- align: 'center',
- showOverflowTooltip: true
- }
- ];
- }
- },
- methods: {
- open(item, type) {
- this.visible = true;
- this.type = type;
- this.title = this.type != 'receipt' ? '发货单' : '收货单';
- this.itemData = item;
- this.id = item.id;
- this.getDetail(item.id);
- },
- async getDetail(id) {
- const detailType = this.type == 'receipt' ? 2 : 1;
- await pleaseEntrustGoodsDetail({
- id,
- detailType
- }).then((res) => {
- this.goodsList = [];
- res.data.forEach((item) => {
- if (this.type == 'receipt' && this.itemData.sendStatus != 4) {
- item.receiveQuantity = item.quantity;
- }
- this.goodsList.push(this.deepCopy(item));
- });
- });
- },
- save() {
- if (this.type != 'receipt') {
- if (this.goodsList.length == 0) {
- return this.$message.warning('请先新增一条在制品数据!');
- }
- this.loading = this.$loading({
- lock: true,
- text: '加载中',
- background: 'rgba(0, 0, 0, 0.7)'
- });
- pleaseEntrustSaveDetail(this.goodsList)
- .then((res) => {
- this.loading.close();
- this.$message.success('发货成功');
- this.$emit('done');
- this.visible = false;
- })
- .catch(() => {
- this.loading.close();
- });
- } else if (this.type == 'receipt') {
- this.loading = this.$loading({
- lock: true,
- text: '加载中',
- background: 'rgba(0, 0, 0, 0.7)'
- });
- pleaseTReceiveGoods(this.goodsList)
- .then((res) => {
- this.loading.close();
- this.$message.success('收货成功');
- this.$emit('done');
- this.visible = false;
- })
- .catch(() => {
- this.loading.close();
- });
- }
- },
- cancel() {
- this.visible = false;
- },
- chooseData(dataList) {
- this.goodsList = [];
- dataList.forEach((item) => {
- this.goodsList.push(this.deepCopy(item));
- });
- },
- 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);
- },
- addGoods() {
- this.$refs.addInvoiceRef.open(this.id, this.goodsList);
- }
- }
- };
- </script>
- <style></style>
|