You cannot select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
udiwms-vue/src/views/thrsys/thrOrderNew.vue

945 lines
36 KiB
Vue

This file contains ambiguous Unicode characters!

This file contains ambiguous Unicode characters that may be confused with others in your current locale. If your use case is intentional and legitimate, you can safely ignore this warning. Use the Escape button to highlight these characters.

<template>
<div>
<el-form :model="formData" :rules="formRules" ref="dataForm">
<el-row type="flex" justify="end">
<el-button-group style="display: flex;margin-bottom: 15px; margin-right: 50px">
<el-button
type="primary"
@click.native="saveOrder('1')"
:loading="loading"
>草稿保存
</el-button
>
<el-button
type="primary"
@click.native="saveOrder('2')"
:loading="loading"
>提交单据
</el-button
>
</el-button-group>
</el-row>
<el-card style="margin-top: -5px;">
<el-row :gutter="20" style="margin-top: 10px;">
<el-col :span="3">
<div class="ao-text">
<span>单据号</span>
</div>
</el-col>
<el-col :span="7">
<el-form-item prop="billNo">
<el-input v-model="formData.billNo" auto-complete="off" :disabled="true"></el-input>
</el-form-item>
</el-col>
<el-col :span="3">
<div class="ao-text">
<span>单据日期:</span>
</div>
</el-col>
<el-col :span="7">
<el-form-item prop="billdate">
<el-date-picker
v-model="formData.billdate"
type="datetime"
placeholder="选择日期"
style="width: 100%"
:clearable="false"
value-format="yyyy-MM-dd HH:mm:ss"
>
</el-date-picker>
</el-form-item>
</el-col>
</el-row>
<el-row :gutter="20" style="margin-top: -10px">
<el-col :span="3">
<div class="ao-text">
<span>当前仓库:</span>
</div>
</el-col>
<el-col :span="7">
<el-form-item >
<el-select v-model="formData.invWarehouseCode" filterable @change="subStorageChange" placeholder="当前仓库信息" clearable
style="width: 100%;" >
<el-option
v-for="item in subInvList"
:key="item.name"
:label="item.name"
:value="item.code">
<span style="float: left">{{ item.name }}</span>
<span style="float: right; color: #8492a6; font-size: 13px">{{ item.warehouseName }}</span>
</el-option>
</el-select>
</el-form-item>
</el-col>
<el-col :span="3">
<div class="ao-text">
<span>往来信息:</span>
</div>
</el-col>
<el-col :span="7">
<el-form-item>
<el-select v-model="formData.fromSubInvCode" @change="getFromSubStorageCode" filterable placeholder="请选择仓库" clearable="true"
style="width: 100%"
>
<el-option
v-for="item in fromSubStorageOptions"
:key="item.code"
:label="item.name"
:value="item.code">
<span style="float: left">{{ item.name }}</span>
<span style="float: right; color: #8492a6; font-size: 13px">{{ item.warehouseName }}</span>
</el-option>
</el-select>
</el-form-item>
</el-col>
</el-row>
<el-row :gutter="20" style="margin-top: -10px">
<el-col :span="3">
<div class="ao-text">
<span>领用类型:</span>
</div>
</el-col>
<el-col :span="7">
<el-form-item prop="billType">
<el-select v-model="formData.billType" placeholder="请选择领用类型" style="width: 100%"
clearable>
<el-option
v-for="item in busTypes"
:key="item.originAction"
:label="item.originName"
:value="item.originAction">
<span style="float: left">{{ item.originName }}</span>
</el-option>
</el-select>
</el-form-item>
</el-col>
<el-col :span="3">
<div class="ao-text">
<span>备注:</span>
</div>
</el-col>
<el-col :span="7">
<el-form-item prop="remark">
<el-input v-model="formData.remark" auto-complete="off"></el-input>
</el-form-item>
</el-col>
</el-row>
</el-card>
<el-card>
<el-button-group style="display: flex">
<el-button
type="primary"
size="small"
@click.native.stop="selectProductFunction()"
style="margin: 0px 60px 10px auto; height: 35px"
:loading="loading"
>产品录入
</el-button
>
</el-button-group>
<el-table v-loading="loading" :data="codeArray" style="width: 100%;"
:row-class-name="tableRowClassName"
max-height="300" height="300" ref="multipleTable">
<el-table-column label="序号" type="index" width="50"></el-table-column>
<el-table-column width="150"
label="产品通用名"
prop="productName"
show-overflow-tooltip
></el-table-column>
<el-table-column width="150"
label="规格型号"
prop="spec"
show-overflow-tooltip
></el-table-column>
<el-table-column width="150" label="批次号">
<template slot-scope="scope">
<el-input size="small" v-model="scope.row.batchNo"
:disabled="scope.row.index !== selectedIndex"
@input="scope.row.batchNo =scope.row.batchNo.replace(/[\W]/g, '')"
ref='inputBatchNoRef'
placeholder="请输入批次号" style="width: 80%"></el-input>
</template>
</el-table-column>
<el-table-column width="180" label="生产日期(yyMMdd)">
<template slot-scope="scope">
<el-input v-model="scope.row.productDate" auto-complete="off"
oninput="if(value.length>6)value=value.slice(0,6)"
:disabled="scope.row.index !== selectedIndex"
type="number"
></el-input>
</template>
</el-table-column>
<el-table-column width="180" label="失效日期(yyMMdd)">
<template slot-scope="scope">
<el-input v-model="scope.row.expireDate" auto-complete="off"
oninput="if(value.length>6)value=value.slice(0,6)"
:disabled="scope.row.index !== selectedIndex"
type="number"
></el-input>
</template>
</el-table-column>
<el-table-column width="150" label="单据数量">
<template slot-scope="scope">
<el-input size="small" v-model="scope.row.count"
placeholder="请输入数量" style="width: 80%"
type='number'
@change="tableCountChange(scope.row)"
:disabled="scope.row.index !== selectedIndex"
oninput="value=value.replace(/[^\d]/g,'')"></el-input>
</template>
</el-table-column>
<el-table-column width="150" label="价格">
<template slot-scope="scope">
<el-input size="small" v-model="scope.row.price"
type='number'
:disabled="scope.row.index !== selectedIndex"
placeholder="请输入价格" style="width: 80%"
></el-input>
</template>
</el-table-column>
<el-table-column width="150"
label="注册/备案凭证号"
prop="zczbhhzbapzbh"
show-overflow-tooltip
></el-table-column>
<el-table-column width="150"
label="生产厂家"
prop="ylqxzcrbarmc"
show-overflow-tooltip
></el-table-column>
<el-table-column label="操作" fixed="right" width="150">
<template slot-scope="scope">
<el-button
type="text"
size="small"
:disabled="scope.row.index === selectedIndex"
@click.stop="true"
@click.native="rowChange(scope.row)"
>编辑
</el-button
>
<el-button
type="text"
size="small"
@click.stop="true"
@click.native="copyDetail(scope.row)"
>复制
</el-button
>
<el-button
type="text"
size="small"
@click.stop="true"
@click.native="deleteCodeArray(scope.$index, scope.row)"
>删除
</el-button
>
</template>
</el-table-column>
</el-table>
</el-card>
</el-form>
<el-dialog
title="库存产品录入"
:visible.sync="selectInvProductVisible"
:close-on-click-modal="false"
:close-on-press-escape="false"
width="85%"
v-if="selectInvProductVisible"
:append-to-body='true'
>
<dialogInvProduct
:closeDialog="closeDialogC2"
:data="thisData"
:invQueryData="invQueryData"
:type="1"
></dialogInvProduct>
</el-dialog>
</div>
</template>
<script>
import {
stockOrderDetail,
submitStockOrder,
stockOrderGenerateBillNo,
getStockOrderDetailInstrument,
insertStockOrderWeb,
deleteStockOrderDetailById,
addStockOrderDetailFromCode,
uploadStockOrderDetail,
} from "../../api/inout/stockOrder";
import draggable from "vuedraggable";
import {saveAs} from "file-saver";
import {parseTime} from "../../filtres";
import store from "../../store";
import stockOrderNewSelectProduct from "../business/stockOrderNewSelectProduct";
import {getBasicUnitMaintains} from "../../api/basic/basicUnitMaintain";
import {filterAllByLoc, filterAllByUser} from "@/api/basic/invWarehouse";
import dialogInvProduct from "../inventory/DialogInvProduct"
import {getBusChange} from "@/api/basic/busTypeChange";
import {inserThrOrderWeb, updateReceive} from "@/api/thrsys/thrOrderReceive";
import {getThrOrderDetails, delThrOrders, delOrderDetail} from "@/api/thrsys/thrOrder";
import {filterSubByInv} from "@/api/basic/invSubWarehouse";
import {isBlank} from "@/utils/strUtil";
export default {
name: "idQuery",
props: {
closeDialog: {
type: Function,
required: true,
},
idQuery: {
type: Object,
required: true,
},
closeConfirmFunction: {
type: Function,
required: true,
},
editType: {
type: Object,
required: true,
},
},
data() {
return {
code: "",
query: {
orderIdFk: "",
page: 1,
limit: 10,
},
formData: {
noInvOut: false,
locStorageCode: null,
invWarehouseCode: null,
fromSubInvCode: null,
billNo: null,
billdate: "",
billType: "",
type: null,
corpName: "",
corpId: "",
},
formRules: {
corpName: [
{required: true, message: "请输入供应商", trigger: "blur"}
],
billdate: [
{required: true, message: "请输入单据日期", trigger: "blur"}
],
billType: [
{required: true, message: "请选择业务类型", trigger: "blur"}
],
locStorageCode: [
{required: true, message: "请选择当前仓库", trigger: "blur"}
],
invWarehouseCode: [
{required: true, message: "请选择当前分库", trigger: "blur"}
],
// type: [
// {required: true, message: "请选择采购类型", trigger: "blur"}
// ],
},
codeArray: [],
subInvList: [],
fromOptions: [],
fromStorageOptions: [],
fromSubStorageOptions: [],
total: 0,
loading: false,
index: null,
formLoading: false,
formVisible: false,
deleteLoading: false,
orderNo: null,
statusMap: {
101: "未处理",
102: "已处理",
201: "未配货",
202: "已配货",
301: "已打印",
401: "异常",
501: "未提交",
502: "已提交",
},
typeMap: {
1: "预入库",
2: "普通采购",
},
orderEditor: true,
iCount: 0,
sOptions: [],
sValue: [],
sList: [],
sLoading: false,
busTypes: [],
currentRow: {},
selectedIndex: "",
selectInvProductVisible: false,
thisData: {},
storageList: [],
invQueryData: {},
type: 1,
};
},
components: {
draggable,
stockOrderNewSelectProduct,
dialogInvProduct,
},
methods: {
saveOrder(status) {
this.code = "";
this.$refs.multipleTable.setCurrentRow();
this.currentRow = {};
this.selectedIndex = "";
this.iCount = 0;
this.$refs["dataForm"].validate(valid => {
if (valid) {
if (this.codeArray.length < 1) {
this.$message.warning('未添加产品');
return;
}
for (let i = 0; i < this.codeArray.length; i++) {
if (!this.$isBlank(this.codeArray[i].productDate) && this.codeArray[i].productDate.length != 6) {
return this.$message.error('生产日期格式错误');
}
if (!this.$isBlank(this.codeArray[i].expireDate) && this.codeArray[i].expireDate.length != 6) {
return this.$message.error('失效日期格式错误');
}
}
if (status === '2') {
for (let i = 0; i < this.codeArray.length; i++) {
if (this.$isBlank(this.codeArray[i].count) || this.codeArray[i].count == "0") {
return this.$message.error('单据数量不能为0');
}
}
}
if (status === '0') {
for (let i = 0; i < this.codeArray.length; i++) {
if (this.$isBlank(this.codeArray[i].count) || this.codeArray[i].count == "0") {
return this.$message.error('单据数量不能为0');
}
}
}
if (status == "1") {
this.submitFunction(status);
} else {
let tip = "是否确定提交订单?";
this.$confirm(tip, "提示", {
confirmButtonText: "确定",
cancelButtonText: "取消",
type: "warning",
}).then(() => {
this.submitFunction(status);
}).catch(() => {
this.loading = false;
});
}
}
});
},
storageChange(row) {
console.log(row);
this.formData.corpId = row.code;
this.formData.corpName = row.name;
this.findSubStorageMethod();
},
subStorageChange(item) {
// this.formData.fromSubInvCode = null;
this.formData.locStorageCode= this.subInvList.find(item => item.code == this.formData.invWarehouseCode).parentId
this.formData.corpId=this.subInvList.find(item => item.code == this.formData.invWarehouseCode).code
this.formData.corpName=this.subInvList.find(item => item.code == this.formData.invWarehouseCode).warehouseName
this.findSubStorageMethod();
this.getBusType();
},
//当前分库
findSubInvs() {
this.subInvList = [];
let query = {
filter: 3,
};
filterSubByInv(query)
.then((response) => {
this.subInvList = response.data || [];
if (this.subInvList != null && this.subInvList.length == 1) {
this.formData.invWarehouseCode = this.subInvList[0].code;
}
})
.catch(() => {
});
},
getActionName(action) {
for (let i = 0; i < this.busTypes.length; i++) {
if (this.busTypes[i].action === action) {
return this.busTypes[i].advanceType;
}
}
},
//往来分库
findSubStorageMethod() {
let cQuery = {
code: this.formData.invWarehouseCode,
filter: 2,
};
filterSubByInv(cQuery)
.then((response) => {
this.fromSubStorageOptions = response.data || [];
})
.catch(() => {
});
},
submitFunction(status) {
let tMessage = status === '501' ? '保存' : '提交';
this.loading = true;
let tQuery = this.formData;
tQuery.editStatus = status;
tQuery.subErpOrders = this.codeArray;
tQuery.thirdPartyDate = 2;
if (this.editType === "add") {
inserThrOrderWeb(tQuery)
.then(response => {
this.loading = false;
if (response.code === 20000) {
this.$message.success(tMessage + "成功");
this.closeDialog(true);
} else {
this.$message.error(response.message);
}
})
.catch(() => {
this.loading = false;
})
} else if (this.editType === "update") {
updateReceive(tQuery)
.then(response => {
this.loading = false;
if (response.code === 20000) {
this.$message.success(tMessage + "成功");
this.closeDialog(true);
} else {
this.$message.error(response.message);
}
})
.catch(() => {
this.loading = false;
})
}
},
selectProductFunction(event) {
if (event == null) {
// this.$refs.inputRef.focus();
} else {
event.target.select();
}
if (this.$isBlank(event)) {
if (this.$isBlank(this.formData.corpName) || this.$isBlank(this.formData.billType)) {
this.$message.error("往来信息和单据类型不能为空!")
return;
}
this.code = "";
this.$refs.multipleTable.setCurrentRow();
this.currentRow = {};
this.selectedIndex = "";
this.iCount = 0;
this.thisData.code = "";
this.thisData.orderEditor = this.orderEditor;
this.thisData.orderId = "";
if (this.orderEditor) {
this.thisData.orderId = this.formData.id
}
this.thisData.stockOrderLists = this.codeArray;
this.thisData.formData = this.formData;
this.invQueryData = {
locStorageCode: this.formData.locStorageCode,
invWarehouseCode: this.formData.invWarehouseCode
};
this.selectInvProductVisible = true;
return;
}
},
closeDialogC2(rData) {
this.selectInvProductVisible = false;
this.thisData = {};
if (this.$isNotBlank(rData)) {
this.codeArray = [];
rData.forEach((obj, index) => {
this.codeArray.unshift(obj);
});
console.log(this.codeArray);
this.$refs.multipleTable.setCurrentRow(this.codeArray[0]);
this.currentRow = this.codeArray[0];
this.selectedIndex = 0;
this.focusNext('iCount');
this.closeConfirmFunction(true);
}
},
rowChange(val) {
this.currentRow = val;
this.selectedIndex = val.index;
this.iCount = val.count;
this.focusNext('iCount');
},
getFromSubStorageCode(){
// this.formData.locStorageCode= this.fromSubStorageOptions.find(item => item.code == this.formData.fromSubInvCode).parentId
},
iCountEnterFunction() {
if (this.$isNotBlank(this.currentRow)) {
this.currentRow.count = this.iCount;
// this.currentRow.reCount = this.iCount;
}
this.focusNext('inputRef');
},
tableCountChange(row) {
if (this.$isNotBlank(row)) {
// row.count = row.reCount;
}
},
tableRowClassName({row, rowIndex}) {
row.index = rowIndex;
},
focusNext(nextRef) {
this.$refs[nextRef].focus()
},
focusNextToTable(nextRef) {
this.$refs[nextRef][0].focus()
},
// 刷新表单
resetForm() {
if (this.$refs["dataForm"]) {
// 清空验证信息表单
this.$refs["dataForm"].clearValidate();
// 刷新表单
this.$refs["dataForm"].resetFields();
this.getList();
}
},
addCode() {
this.code = this.code.trim();
if (this.$isBlank(this.code)) {
this.$message.warning('请输入条码');
return;
}
if (this.iCount <= 0) {
this.$message.warning('请输入数量');
return;
}
this.loading = true;
let tQuery = {
orderId: this.formData.id,
count: this.iCount,
code: this.code,
};
if (this.orderEditor) {
addStockOrderDetailFromCode(tQuery).then((response) => {
this.loading = false;
if (response.code === 20000) {
this.getStockOrderDetailList();
} else {
this.$alert(response.message, '提示', {
confirmButtonText: '确定',
type: 'warning',
closeOnClickModal: true,
callback: action => {
this.$refs.inputRef.focus();
}
});
}
});
} else {
getStockOrderDetailInstrument(tQuery).then((response) => {
this.loading = false;
if (response.code === 20000) {
for (let i = 0; i < this.codeArray.length; i++) {
if (this.codeArray[i].productId === response.data.productId) {
this.$alert("已添加", '提示', {
confirmButtonText: '确定',
type: 'warning',
closeOnClickModal: true,
callback: action => {
this.$refs.inputRef.focus();
}
});
break;
}
if (i + 1 === this.codeArray.length) {
this.codeArray.push(response.data);
}
}
if (this.codeArray.length === 0) {
this.codeArray.push(response.data);
}
} else {
this.$alert(response.message, '提示', {
confirmButtonText: '确定',
type: 'warning',
closeOnClickModal: true,
callback: action => {
this.$refs.inputRef.focus();
}
});
}
});
}
},
saveCodeArray(index, row) {
if (this.$isBlank(row.batchNo)) {
return this.$message.error('批次号不能为空');
}
this.$refs.multipleTable.setCurrentRow();
this.currentRow = {};
this.selectedIndex = "";
this.iCount = 0;
this.detailLoading = true;
// row.count = row.reCount;
let tQuery = row;
uploadStockOrderDetail(tQuery).then((response) => {
this.detailLoading = false;
if (response.code === 20000) {
this.$message.success("修改完成");
this.getStockOrderDetailList();
this.$refs.inputRef.focus();
} else {
this.$message.error(response.message);
}
});
},
deleteCodeArray(index, row) {
this.$confirm("此操作将永久删除该数据, 是否继续?", "提示", {
confirmButtonText: "确定",
cancelButtonText: "取消",
type: "warning",
}).then(() => {
this.$refs.multipleTable.setCurrentRow();
this.currentRow = {};
this.selectedIndex = "";
this.iCount = 0;
if (this.orderEditor) {
this.detailLoading = true;
if (this.$isNotBlank(row.id)) {
delOrderDetail({id: row.id})
.then(response => {
this.detailLoading = false;
if (response.code === 20000) {
this.$message.success(response.data);
// this.getStockOrderDetailList();
this.codeArray.splice(index, 1);
} else {
this.$message.error(response.message);
}
})
.catch(() => {
this.detailLoading = false;
})
} else {
this.$message.success('删除成功');
this.codeArray.splice(index, 1);
}
} else {
this.$message.success('删除成功');
this.codeArray.splice(index, 1);
}
}).catch(() => {
});
},
copyDetail(row) {
this.$confirm("是否复制该记录?", "提示", {
confirmButtonText: "确定",
cancelButtonText: "取消",
type: "warning",
}).then(() => {
let rData = JSON.parse(JSON.stringify(row));
rData.id = null;
if (this.codeArray.length === 0) {
this.codeArray.push(rData);
this.$refs.multipleTable.setCurrentRow(this.codeArray[0]);
this.currentRow = this.codeArray[0];
this.selectedIndex = 0;
} else {
this.codeArray.unshift(rData);
this.$refs.multipleTable.setCurrentRow(this.codeArray[0]);
this.currentRow = this.codeArray[0];
this.selectedIndex = 0;
}
this.$message.success("复制成功");
this.iCount = this.currentRow.count;
this.focusNext('iCount');
}).catch(() => {
});
},
getInputFocus(event) {
event.currentTarget.select();
},
tableSelection() {
this.$refs.multipleTable.clearSelection();
this.$refs.multipleTable.toggleAllSelection();
},
handleSizeChange(val) {
this.query.limit = val;
this.getStockOrderDetailList();
},
handleCurrentChange(val) {
this.query.page = val;
this.getStockOrderDetailList();
},
getStockOrderDetailList() {
this.loading = true;
getThrOrderDetails(this.query) //查找该单号下的所有条码
.then((response) => {
console.log(response)
this.codeArray = response.data.list || [];
this.total = response.data.total || 0;
this.loading = false;
})
.catch(() => {
this.loading = false;
this.list = [];
this.total = 0;
});
},
intentBack() {
this.$router.go(-1);
},
getBusType() {
let query = {
type: 1,
enable: false,
};
getBusChange(query)
.then((response) => {
this.busTypes = response.data.list || [];
})
.catch(() => {
});
},
selectOne(event) {
this.formData.corpName = event.name;
this.formData.corpId = event.erpId;
this.formData.unitIdFk = event.erpId;
},
getActionItem(action) {
for (let i = 0; i < this.busTypes.length; i++) {
if (this.busTypes[i].thirdAction === action) {
return this.busTypes[i];
}
}
},
},
filters: {},
mounted() {
document.body.ondrop = function (event) {
event.preventDefault();
event.stopPropagation();
};
},
created() {
if (this.$isNotBlank(this.idQuery.id)) {
this.query.limit = 100;
this.query.orderIdFk = this.idQuery.id;
this.formData = this.idQuery.formData;
this.orderEditor = true;
this.sValue = this.formData.corpName;
this.getStockOrderDetailList();
} else {
this.formData = {
billNo: null,
billdate: "",
customerId: store.getters.customerId,
billType: "",
type: "2",
corpName: "",
corpId: "",
noInvOut: "",
locStorageCode: "",
invWarehouseCode: "",
};
this.iCount = 0;
this.orderEditor = false;
// this.generateBillNo();
}
this.getBusType();
this.findSubInvs();
if (!isBlank(this.formData.invWarehouseCode)) {
this.findSubStorageMethod();
}
// this.findSubInvByInv();
this.codeArray = [];
this.closeConfirmFunction(false);
},
};
</script>
<style>
.ao-text {
width: 100%;
font-size: 13px;
font-family: "Microsoft YaHei";
float: right;
text-align: right;
margin-top: 10px;
}
</style>