| 123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463 |
- <template>
- <ele-modal
- :visible.sync="visible"
- :title="title"
- v-if="visible"
- width="65vw"
- append-to-body
- :maxable="true"
- >
- <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:receiveQuantity="{ row }">
- <el-input
- placeholder=""
- v-model="row.receiveQuantity"
- :disabled="type == 'detail' || type == 'send'"
- >
- <template slot="append">{{ row.measuringUnit }}</template>
- </el-input>
- </template> -->
- <template v-slot:receiveQuantity="{ row }">
- <el-input placeholder="" v-model="row.receiveQuantity" disabled>
- <template slot="append">{{ row.measuringUnit }}</template>
- </el-input>
- </template>
- <template v-slot:weight="{ row }">
- <span>{{ row.weight }}{{ row.weightUnit }}</span>
- </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' && type != 'send'">
- <el-button @click="cancel">取消</el-button>
- <el-button type="primary" @click="rejectReason"> 驳回 </el-button>
- <el-button type="primary" @click="save"> 确认收货 </el-button>
- </template>
- <!-- 驳回原因弹窗 -->
- <el-dialog
- :visible.sync="rejectDialogVisible"
- v-if="rejectDialogVisible"
- title="请输入驳回原因"
- width="30vw"
- append-to-body
- :close-on-click-modal="false"
- :before-close="
- () => {
- rejectDialogVisible = false;
- }
- "
- >
- <el-form
- ref="rejectForm"
- :model="rejectForm"
- :rules="rejectRules"
- label-width="80px"
- >
- <el-form-item label="原因" prop="reason">
- <el-input
- type="textarea"
- v-model="rejectForm.reason"
- placeholder="请输入驳回原因"
- rows="4"
- ></el-input>
- </el-form-item>
- </el-form>
- <span slot="footer" class="dialog-footer">
- <el-button @click="rejectDialogVisible = false">取消</el-button>
- <el-button type="primary" @click="confirmReject">确定</el-button>
- </span>
- </el-dialog>
- </ele-modal>
- </template>
- <script>
- import { pleaseEntrustGoodsDetail } from '@/api/entrust';
- import { confirmReceipt, rejectGoods } from '@/api/beEntrusted';
- import { typeName } from '@/views/produce/components/common.js';
- export default {
- data() {
- return {
- visible: false,
- goodsList: [],
- selection: [],
- current: null,
- typeName,
- id: '',
- type: '',
- title: '',
- loading: null,
- // 驳回弹窗
- rejectDialogVisible: false,
- rejectForm: { reason: '' },
- rejectRules: {
- reason: [
- { required: true, message: '请输入驳回原因', trigger: 'blur' }
- ]
- },
- itemData: {}
- };
- },
- computed: {
- columns() {
- return [
- {
- width: 45,
- type: 'selection',
- columnKey: 'selection',
- align: 'center',
- reserveSelection: true
- },
- {
- 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: 110,
- // showOverflowTooltip: true
- // },
- {
- prop: 'receiveQuantity',
- slot: 'receiveQuantity',
- label: '接收数量',
- align: 'center',
- minWidth: 150,
- showOverflowTooltip: true,
- show: this.type != 'send' ? true : false
- },
- {
- prop: 'workOrderCode',
- label: '生产工单号',
- align: 'center',
- minWidth: 110,
- showOverflowTooltip: true
- },
- {
- 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.id = item.id;
- this.itemData = item;
- this.type = type;
- this.title = this.type != 'send' ? '收货单' : '发货单';
- this.getDetail(item.id);
- },
- async getDetail(id) {
- const detailType = this.type != 'send' ? 1 : 2;
- await pleaseEntrustGoodsDetail({
- id,
- detailType
- }).then((res) => {
- this.goodsList = [];
- res.data.forEach((item) => {
- if (this.type != 'detail') {
- item.receiveQuantity = item.quantity;
- }
- item.sendStatus = 2;
- this.goodsList.push(this.deepCopy(item));
- });
- });
- },
- // save() {
- // if (this.selection.length == 0) {
- // return this.$message.warning('请先选择一条收货数据!');
- // }
- // const selectionIds = new Set(this.selection.map((it) => it.id));
- // for (let item of this.goodsList) {
- // if (!selectionIds.has(item.id)) {
- // item.receiveQuantity = 0;
- // }
- // }
- // if (
- // Number(this.itemData.sendOutQuantity) <
- // Number(this.itemData.formingNum)
- // ) {
- // this.$confirm('收货数量小于请托数量是否继续收货?', '提示', {
- // type: 'warning'
- // })
- // .then(() => {
- // this.loading = this.$loading({
- // lock: true,
- // text: '加载中',
- // background: 'rgba(0, 0, 0, 0.7)'
- // });
- // confirmReceipt(this.goodsList)
- // .then((res) => {
- // this.loading.close();
- // this.$message.success('收货成功');
- // this.$emit('done');
- // this.visible = false;
- // })
- // .catch(() => {
- // this.loading.close();
- // });
- // })
- // .catch(() => {});
- // } else if (
- // Number(this.itemData.sendOutQuantity) ==
- // Number(this.itemData.formingNum)
- // ) {
- // this.loading = this.$loading({
- // lock: true,
- // text: '加载中',
- // background: 'rgba(0, 0, 0, 0.7)'
- // });
- // confirmReceipt(this.goodsList)
- // .then((res) => {
- // this.loading.close();
- // this.$message.success('收货成功');
- // this.$emit('done');
- // this.visible = false;
- // })
- // .catch(() => {
- // this.loading.close();
- // });
- // } else if (
- // Number(this.itemData.sendOutQuantity) >
- // Number(this.itemData.formingNum)
- // ) {
- // this.$confirm('收货数量大于请托数量是否继续收货?', '提示', {
- // type: 'warning'
- // })
- // .then(() => {
- // this.loading = this.$loading({
- // lock: true,
- // text: '加载中',
- // background: 'rgba(0, 0, 0, 0.7)'
- // });
- // confirmReceipt(this.goodsList)
- // .then((res) => {
- // this.loading.close();
- // this.$message.success('收货成功');
- // this.$emit('done');
- // this.visible = false;
- // })
- // .catch(() => {
- // this.loading.close();
- // });
- // })
- // .catch(() => {});
- // }
- // },
- save() {
- if (this.selection.length === 0) {
- return this.$message.warning('请先选择一条收货数据!');
- }
- const selectionIds = new Set(this.selection.map((it) => it.id));
- this.goodsList.forEach((item) => {
- if (!selectionIds.has(item.id)) {
- item.receiveQuantity = 0;
- }
- });
- const totalNum = this.selection.reduce(
- (total, pro) => total + Number(pro.receiveQuantity || 0),
- 0
- );
- const formingNum = Number(this.itemData.sendOutQuantity);
- let confirmMessage = '';
- console.log(totalNum, formingNum, '8888');
- if (totalNum < formingNum) {
- confirmMessage = '收货数量小于请托数量,是否继续收货?';
- } else if (totalNum > formingNum) {
- confirmMessage = '收货数量大于请托数量,是否继续收货?';
- }
- const doConfirmReceipt = () => {
- this.loading = this.$loading({
- lock: true,
- text: '加载中',
- background: 'rgba(0, 0, 0, 0.7)'
- });
- confirmReceipt(this.goodsList)
- .then(() => {
- this.loading.close();
- this.$message.success('收货成功');
- this.$emit('done');
- this.visible = false;
- })
- .catch(() => {
- this.loading.close();
- });
- };
- if (confirmMessage) {
- this.$confirm(confirmMessage, '提示', { type: 'warning' })
- .then(() => doConfirmReceipt())
- .catch(() => {});
- } else {
- doConfirmReceipt();
- }
- },
- cancel() {
- this.visible = false;
- },
- rejectReason() {
- this.rejectDialogVisible = true;
- },
- confirmReject() {
- this.$refs.rejectForm.validate((valid) => {
- if (!valid) return;
- this.$confirm('确认要驳回该收货单吗?', '提示', { type: 'warning' })
- .then(() => {
- const ids = this.goodsList.map((it) => {
- return it.id;
- });
- console.log('7777');
- rejectGoods({
- ids,
- applyId: this.id,
- beReason: this.rejectForm.reason
- }).then(() => {
- this.$message.success('驳回成功');
- this.rejectDialogVisible = false;
- this.visible = false;
- this.$emit('done');
- });
- })
- .catch(() => {});
- });
- },
- 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);
- }
- }
- };
- </script>
- <style></style>
|