<template>
|
<div class="quotationEdit height overflow">
|
<div class="width overflow height92">
|
<div class="quotationEdit-height">
|
<div class="flex justify-between">
|
<div class="width55 flex align-center">
|
<label class="width40 textalign">生产计划单号:</label>
|
<el-input size="mini"
|
disabled
|
v-model="iqnuer.inOrderCode"
|
class="width60"> </el-input>
|
</div>
|
<div class="width40 flex align-center">
|
<label class="width40 textalign">生产类型:</label>
|
<el-select class="width60"
|
size="mini"
|
clearable
|
:disabled="isReadOnly"
|
v-model="iqnuer.orderType"
|
placeholder="请选择"
|
required="true">
|
<el-option v-for="item in orderTypelist"
|
:key="item.value"
|
:label="item.label"
|
:value="item.value">
|
</el-option>
|
</el-select>
|
</div>
|
</div>
|
<div class="flex justify-between margintopbot">
|
<div class="width55 flex align-center">
|
<label class="width40 textalign">备注:</label>
|
<el-input class="width60"
|
type="textarea"
|
clearable
|
:disabled="isReadOnly"
|
size="mini"
|
resize="none"
|
:autosize="{ minRows: 1, maxRows: 1 }"
|
placeholder="请输入内容"
|
v-model="iqnuer.textarea1">
|
</el-input>
|
</div>
|
<div class="width40 flex align-center">
|
<label class="width40 textalign">计划数量:</label>
|
<el-input clearable
|
size="mini"
|
disabled
|
v-model="iqnuer.totalNum"
|
class="width60"> </el-input>
|
</div>
|
</div>
|
<el-button-group>
|
<el-button type="primary"
|
size="mini"
|
:disabled="isReadOnly"
|
icon="el-icon-plus"
|
@click="$emit('partclick')">新建</el-button>
|
<el-button type="primary"
|
size="mini"
|
:disabled="isReadOnly"
|
icon="el-icon-delete"
|
@click="delclick">删除</el-button>
|
</el-button-group>
|
</div>
|
<div class="width quotationEdit-tebleheight overflow">
|
<table-container ref="tablecontainer"
|
height="91%"
|
:tableHead="tableHead"
|
:tableData="tableData"
|
:operation="true"
|
:editShow="true"
|
:setshow="false"
|
:naxnumShow="true"
|
:selectionShow="true"
|
:roweditshow="roweditshow"
|
:currentPage="page"
|
:pageSize="pageSize"
|
:totle="totle"
|
:inputshow="true"
|
@edit="edit"
|
@handleSelectionChange="handleSelectionChange"
|
@itemchange="itemchange"
|
@CurrentChange="CurrentChange" />
|
</div>
|
</div>
|
<div class="quotationEdit-button text-right margin-right15 margin-top2">
|
<el-button type="primary"
|
size="mini"
|
class="form-buttom"
|
:loading="savloading"
|
:disabled="isReadOnly"
|
@click="submitForm">保存</el-button>
|
<el-button type="primary"
|
size="mini"
|
class="form-buttom"
|
@click="$emit('cancel')">取消</el-button>
|
</div>
|
</div>
|
</template>
|
|
<script>
|
import { TableContainer, Modal } from '@/components/index';
|
import { getCache, setCache, removeToken } from '@/utils/sessionStorage';
|
const { quotationedit } = require('@/components/tableContainer/tableHead');
|
import { InOrderGetCode } from '@/api/quotation';
|
import { getDate, GetTimeStr } from '@/utils/date';
|
import { itemSearch } from '@/api/enterchoose';
|
import { InOrderAddOrUpdate } from '@/api/quotation';
|
export default {
|
data () {
|
return {
|
iqnuer: {
|
inOrderCode: '', //计划单号
|
orderType: '', //计划类型
|
totalNum: '', //零件总数
|
doneNum: '', //已下线数 新增传0,编辑,原数据返回
|
userName: getCache('userInfo').userName, //创建人编号 当前登陆人状态
|
productionLineCode: '', //(预留)传空
|
doTime: '', //执行时间
|
itemName: '', //零件编号传,其它零件信息可不传
|
productionLineName: '' //暂时传空
|
},
|
orderTypelist: [
|
{
|
label: '即墨入库',
|
value: '即墨入库'
|
},
|
{
|
label: '李沧入库',
|
value: '李沧入库'
|
}
|
],
|
tableData: [],
|
savloading: false,
|
totle: 0,
|
page: 1,
|
pageSize: 20,
|
roweditshow: false
|
};
|
},
|
props: {
|
//是否只读
|
isReadOnly: {
|
type: Boolean,
|
default: false
|
},
|
rowitem: {
|
type: Object,
|
default: () => { }
|
},
|
chooselist: {
|
type: Array,
|
default: () => []
|
}
|
},
|
components: { TableContainer },
|
computed: {
|
tableHead () {
|
return quotationedit;
|
}
|
},
|
mounted () {
|
if (JSON.stringify(this.rowitem) != '{}') {
|
this.iqnuer = this.rowitem;
|
this.itemSearch();
|
} else {
|
this.iqnuer.doneNum = 0;
|
this.InOrderGetCode();
|
}
|
},
|
methods: {
|
//自动生成单号
|
InOrderGetCode () {
|
InOrderGetCode().then(res => {
|
this.iqnuer.inOrderCode = res;
|
});
|
},
|
//编辑时获取零件列表数据
|
itemSearch () {
|
itemSearch(this.page, { itemName: this.rowitem.itemName }).then(res => {
|
if (res.code == 0) {
|
let data = res.data;
|
data.forEach(item => {
|
item.image = process.env.IMAGE_URL + item.image;
|
});
|
this.storgage(data);
|
this.totle = res.num;
|
}
|
});
|
},
|
//编辑
|
edit (row) { },
|
CurrentChange (e) {
|
this.page = e;
|
this.itemSearch();
|
},
|
submitForm () {
|
if (this.roweditshow) {
|
this.$message({
|
type: 'warning',
|
message: '请先保存'
|
});
|
} else {
|
if (this.iqnuer.orderType == '') {
|
this.$message({
|
type: 'warning',
|
message: '请选择生产类型'
|
});
|
} else {
|
this.savloading = true;
|
this.iqnuer.creatorId = getCache('userInfo').id;
|
InOrderAddOrUpdate(this.iqnuer).then(res => {
|
if (res.code == 0) {
|
this.$message({
|
type: 'success',
|
message: '添加成功'
|
});
|
this.$emit('cancel');
|
} else {
|
this.$message({
|
type: 'warning',
|
message: res.msg
|
});
|
}
|
this.savloading = false;
|
});
|
}
|
}
|
},
|
//过滤存储
|
storgage (lists) {
|
let list = [...lists];
|
// list.forEach(element => {
|
// this.storagelist.push(element);
|
this.storagelist = lists;
|
// });
|
this.filtration();
|
},
|
filtration (lists) {
|
let list = [...this.storagelist];
|
let getWeight = '';
|
list.forEach(element => {
|
element.edit = false;
|
if (JSON.stringify(this.rowitem) != '{}') {
|
element.doTime = this.rowitem.doTime;
|
element.maxNum = this.rowitem.totalNum;
|
} else {
|
element.doTime = getDate() + ' ' + GetTimeStr(0);
|
if (element.maxNum) {
|
// this.iqnuer.totalNum += parseInt(element.maxNum);
|
this.iqnuer.totalNum = element.maxNum;
|
} else {
|
this.iqnuer.totalNum = 0;
|
}
|
}
|
|
// element.itemNum = element.maxNum;
|
});
|
const { doTime, itemName } = list[0];
|
this.iqnuer.doTime = doTime;
|
this.iqnuer.itemName = itemName;
|
this.tableData = list;
|
},
|
//数量
|
itemchange (e) {
|
console.log(e);
|
this.roweditshow = !this.roweditshow;
|
const { maxNum, doTime } = e[0];
|
this.iqnuer.totalNum = maxNum;
|
this.iqnuer.doTime = doTime;
|
// this.storgage(e);
|
// this.iqnuer.itemNum = 0;
|
// e.forEach(element => {
|
// element.edit = false;
|
// if (element.weight) {
|
// weight = element.weight;
|
// }
|
// if (element.maxNum) {
|
// this.iqnuer.itemNum += parseInt(element.maxNum);
|
// }
|
// element.itemNum = element.maxNum;
|
// });
|
},
|
//勾选table
|
handleSelectionChange (e) {
|
console.log(e);
|
this.Selection = e;
|
},
|
//删除
|
delclick () {
|
this.Selection.forEach(element => {
|
let index = this.tableData.findIndex(item => item.itemName == element.itemName);
|
let storgindex = this.storagelist.findIndex(item => item.itemName == element.itemName);
|
this.tableData.splice(index, 1);
|
this.storagelist.splice(storgindex, 1);
|
});
|
this.iqnuer.totalNum = 0;
|
}
|
},
|
watch: {
|
chooselist: {
|
handler (nvl, ovl) {
|
this.storgage(nvl);
|
},
|
deep: true
|
}
|
}
|
};
|
</script>
|
|
<style lang="scss" scoped>
|
.quotationEdit {
|
width: 98%;
|
padding: 1%;
|
.quotationEdit-height {
|
height: 120px;
|
}
|
.quotationEdit-tebleheight {
|
height: calc(100% - 125px);
|
}
|
.show-pwd {
|
position: absolute;
|
right: 10px;
|
top: 3px;
|
font-size: 16px;
|
color: #889aa4;
|
cursor: pointer;
|
user-select: none;
|
}
|
.centent-form {
|
height: 92%;
|
width: 100%;
|
margin: auto;
|
}
|
.quotationEdit-button {
|
}
|
::v-deep .el-form-item__content {
|
width: 60%;
|
}
|
::v-deep .el-select {
|
// width: 100%;
|
}
|
}
|
</style>
|