|
|
@@ -164,7 +164,6 @@
|
|
|
:rules="{
|
|
|
required: true,
|
|
|
message: '请选择开始计划时间',
|
|
|
-
|
|
|
trigger: 'change'
|
|
|
}"
|
|
|
>
|
|
|
@@ -285,8 +284,10 @@
|
|
|
</el-form>
|
|
|
</div>
|
|
|
<div slot="footer">
|
|
|
- <el-button plain @click="cancel">取消</el-button>
|
|
|
- <el-button type="primary" @click="confirm">确定</el-button>
|
|
|
+ <el-button plain @click="cancel" :loading="loading">取消</el-button>
|
|
|
+ <el-button type="primary" @click="confirm" :loading="loading"
|
|
|
+ >确定</el-button
|
|
|
+ >
|
|
|
</div>
|
|
|
</ele-modal>
|
|
|
</template>
|
|
|
@@ -300,7 +301,6 @@
|
|
|
data() {
|
|
|
return {
|
|
|
visible: false,
|
|
|
-
|
|
|
formData: {},
|
|
|
requestData: {
|
|
|
deviceCode: '',
|
|
|
@@ -308,7 +308,7 @@
|
|
|
deviceId: ''
|
|
|
},
|
|
|
formingNum: 0,
|
|
|
-
|
|
|
+ storageNum: 0,
|
|
|
form: {
|
|
|
surplusUnpack: [],
|
|
|
unpackList: []
|
|
|
@@ -324,7 +324,6 @@
|
|
|
}
|
|
|
}
|
|
|
},
|
|
|
-
|
|
|
pickerOptionsEnd: {
|
|
|
disabledDate: (time) => {
|
|
|
// 根据某个条件动态设置最大日期
|
|
|
@@ -336,9 +335,7 @@
|
|
|
}
|
|
|
}
|
|
|
},
|
|
|
-
|
|
|
rules: {},
|
|
|
-
|
|
|
columns: [
|
|
|
{
|
|
|
prop: 'originalCode',
|
|
|
@@ -368,7 +365,6 @@
|
|
|
minWidth: 200
|
|
|
}
|
|
|
],
|
|
|
-
|
|
|
columns2: [
|
|
|
{
|
|
|
prop: 'originalCode',
|
|
|
@@ -407,20 +403,32 @@
|
|
|
slot: 'action',
|
|
|
showOverflowTooltip: true
|
|
|
}
|
|
|
- ]
|
|
|
+ ],
|
|
|
+ loading: false
|
|
|
};
|
|
|
},
|
|
|
methods: {
|
|
|
open(row) {
|
|
|
this.visible = true;
|
|
|
this.formData = deepClone(row);
|
|
|
- this.formingNum = this.formData.formingNum;
|
|
|
-
|
|
|
+ this.formingNum = this.residualVal();
|
|
|
+ this.storageNum = this.residualVal();
|
|
|
this.form.surplusUnpack = [];
|
|
|
this.form.unpackList = [];
|
|
|
this.setSurplus();
|
|
|
},
|
|
|
|
|
|
+ // 要求生产数量( 剩余值 )
|
|
|
+ residualVal() {
|
|
|
+ if (this.formData.splitResidue) {
|
|
|
+ return this.formData.splitResidue;
|
|
|
+ }
|
|
|
+ if (this.formData.splitResidue === 0) {
|
|
|
+ return 0;
|
|
|
+ }
|
|
|
+ return this.formData.formingNum;
|
|
|
+ },
|
|
|
+
|
|
|
checkEndTimeValid(row) {
|
|
|
const { planStartTime: start, planCompleteTime: end } = row;
|
|
|
if (!start || !end) return; // 开始/结束时间未填,跳过
|
|
|
@@ -445,7 +453,8 @@
|
|
|
setSurplus() {
|
|
|
this.form.surplusUnpack.push({
|
|
|
originalCode: this.formData.code,
|
|
|
- formingNum: this.formData.formingNum,
|
|
|
+ // formingNum: this.formData.formingNum,
|
|
|
+ formingNum: this.residualVal(),
|
|
|
planStartTime: this.formData.planStartTime,
|
|
|
planCompleteTime: this.formData.planCompleteTime,
|
|
|
isCopy: 1
|
|
|
@@ -463,11 +472,11 @@
|
|
|
|
|
|
surplusUnpackFn(index) {
|
|
|
console.log(this.form.unpackList);
|
|
|
- console.log(index, '------------------');
|
|
|
},
|
|
|
|
|
|
changeNum(index) {
|
|
|
- let num = this.formData.formingNum;
|
|
|
+ // let num = this.formData.formingNum;
|
|
|
+ let num = this.storageNum;
|
|
|
this.form.unpackList.forEach((e) => {
|
|
|
if (e.formingNum != null && e.formingNum != undefined) {
|
|
|
num = num - Number(e.formingNum);
|
|
|
@@ -496,17 +505,15 @@
|
|
|
}
|
|
|
});
|
|
|
if (total == 0) {
|
|
|
- this.formingNum = this.formData.formingNum;
|
|
|
+ this.formingNum = this.storageNum;
|
|
|
}
|
|
|
- console.log(this.formData.formingNum, '-----');
|
|
|
- console.log(total, 'total 1234');
|
|
|
});
|
|
|
},
|
|
|
|
|
|
remove(index) {
|
|
|
this.form.unpackList.splice(index, 1);
|
|
|
if (this.form.unpackList.length == 0) {
|
|
|
- this.formingNum = this.formData.formingNum;
|
|
|
+ this.formingNum = this.storageNum;
|
|
|
} else {
|
|
|
this.changeNum(index);
|
|
|
}
|
|
|
@@ -519,37 +526,54 @@
|
|
|
},
|
|
|
|
|
|
confirm() {
|
|
|
+ if (this.form.unpackList.length === 0) {
|
|
|
+ return this.$message.warning('请至少有一条拆单数据');
|
|
|
+ }
|
|
|
this.$refs.form.validate(async (value) => {
|
|
|
if (value) {
|
|
|
- if (
|
|
|
- this.form.unpackList.length == 1 &&
|
|
|
- this.form.unpackList[0].formingNum == this.formData.formingNum
|
|
|
- ) {
|
|
|
- this.$message.info('拆单数要大于1');
|
|
|
- return false;
|
|
|
+ // if (
|
|
|
+ // this.form.unpackList.length == 1 &&
|
|
|
+ // this.form.unpackList[0].formingNum == this.formData.formingNum
|
|
|
+ // ) {
|
|
|
+ // this.$message.info('拆单数要大于1');
|
|
|
+ // return false;
|
|
|
+ // }
|
|
|
+
|
|
|
+ // if (
|
|
|
+ // this.form.surplusUnpack.length == 1 &&
|
|
|
+ // this.form.unpackList.length == 0
|
|
|
+ // ) {
|
|
|
+ // this.$message.info('拆单数要大于1');
|
|
|
+ // return false;
|
|
|
+ // }
|
|
|
+
|
|
|
+ // let params = [];
|
|
|
+ // if (this.formingNum != 0) {
|
|
|
+ // this.form.surplusUnpack[0].formingNum = this.formingNum;
|
|
|
+ // params = [...this.form.unpackList, ...this.form.surplusUnpack];
|
|
|
+ // } else {
|
|
|
+ // params = this.form.unpackList;
|
|
|
+ // }
|
|
|
+ for (let i = 0; i < this.form.unpackList.length; i++) {
|
|
|
+ let item = this.form.unpackList[i];
|
|
|
+ if (item.formingNum == 0) {
|
|
|
+ this.$message.warning(`第${i + 1}条拆单要求生产数据不能为0`);
|
|
|
+ return;
|
|
|
+ }
|
|
|
}
|
|
|
-
|
|
|
- if (
|
|
|
- this.form.surplusUnpack.length == 1 &&
|
|
|
- this.form.unpackList.length == 0
|
|
|
- ) {
|
|
|
- this.$message.info('拆单数要大于1');
|
|
|
- return false;
|
|
|
- }
|
|
|
-
|
|
|
- let params = [];
|
|
|
- if (this.formingNum != 0) {
|
|
|
- this.form.surplusUnpack[0].formingNum = this.formingNum;
|
|
|
- params = [...this.form.unpackList, ...this.form.surplusUnpack];
|
|
|
- } else {
|
|
|
- params = this.form.unpackList;
|
|
|
- }
|
|
|
-
|
|
|
- const res = await splitBatch(params);
|
|
|
- if (res) {
|
|
|
- this.$message.success('拆分成功!');
|
|
|
- this.$emit('success');
|
|
|
- this.cancel();
|
|
|
+ this.form.surplusUnpack[0].formingNum = this.formingNum;
|
|
|
+ let params = [...this.form.unpackList, ...this.form.surplusUnpack];
|
|
|
+ try {
|
|
|
+ this.loading = true;
|
|
|
+ const res = await splitBatch(params);
|
|
|
+ this.loading = false;
|
|
|
+ if (res) {
|
|
|
+ this.$message.success('拆分成功!');
|
|
|
+ this.$emit('success');
|
|
|
+ this.cancel();
|
|
|
+ }
|
|
|
+ } catch (err) {
|
|
|
+ this.loading = false;
|
|
|
}
|
|
|
}
|
|
|
});
|