|
@@ -12,24 +12,31 @@
|
|
|
<p>sitem:{{ status }}</p>
|
|
|
<el-row>
|
|
|
<el-col :span="12">
|
|
|
- <el-form-item label="收货总数量" prop="get_goods_numbers">
|
|
|
+ <el-form-item label="退货总数量" prop="return_num">
|
|
|
<el-input
|
|
|
- :disabled="status != '1' && status != '0'"
|
|
|
- v-model="ruleForm.get_goods_numbers"
|
|
|
- placeholder="收货总数量"
|
|
|
+ disabled
|
|
|
+ v-model="ruleForm.return_num"
|
|
|
+ placeholder="退货总数量"
|
|
|
></el-input>
|
|
|
</el-form-item>
|
|
|
+ <!-- <el-form-item label="收货总数量" prop="receive">
|
|
|
+ <el-input
|
|
|
+ disabled
|
|
|
+ v-model="ruleForm.receive"
|
|
|
+ placeholder="收货总数量"
|
|
|
+ ></el-input>
|
|
|
+ </el-form-item> -->
|
|
|
</el-col>
|
|
|
<el-col :span="12">
|
|
|
- <el-form-item label="可销售数量" prop="can_sell_numbers">
|
|
|
+ <el-form-item label="可销售数量" prop="normal">
|
|
|
<el-input
|
|
|
:disabled="status != '1' && status != '0'"
|
|
|
- v-model="ruleForm.can_sell_numbers"
|
|
|
+ v-model="ruleForm.normal"
|
|
|
placeholder="可销售数量"
|
|
|
></el-input>
|
|
|
</el-form-item>
|
|
|
</el-col>
|
|
|
- <el-col :span="12">
|
|
|
+ <el-col :span="24">
|
|
|
<el-form-item label="其他备注" prop="remark">
|
|
|
<el-input
|
|
|
:disabled="status != '1' && status != '0'"
|
|
@@ -177,15 +184,11 @@
|
|
|
@click="checkRow(scope.$index)"
|
|
|
></i>
|
|
|
</el-tooltip>
|
|
|
- <el-tooltip
|
|
|
- v-if="scope.row.edit"
|
|
|
- effect="dark"
|
|
|
- content="重置"
|
|
|
- placement="top"
|
|
|
- >
|
|
|
+
|
|
|
+ <el-tooltip effect="dark" content="删除" placement="top">
|
|
|
<i
|
|
|
- class="el-icon-refresh-left tb-icon"
|
|
|
- @click="resetRow(scope.$index)"
|
|
|
+ class="el-icon-delete-solid tb-icon"
|
|
|
+ @click="deleteRow(scope.$index)"
|
|
|
></i>
|
|
|
</el-tooltip>
|
|
|
</template>
|
|
@@ -271,19 +274,21 @@ export default {
|
|
|
}
|
|
|
};
|
|
|
return {
|
|
|
+ newArr: [], //存储异常记录列表项
|
|
|
arr: [],
|
|
|
sitemGetNumber: "", //详情总收货量
|
|
|
isShow: false, //用于情况1
|
|
|
returnNO: "", //退货编号
|
|
|
ruleForm: {
|
|
|
- get_goods_numbers: "", //收货总数量
|
|
|
- can_sell_numbers: "", //可销售数量
|
|
|
+ return_num: "", //
|
|
|
+ // receive: "", //收货总数量
|
|
|
+ normal: "", //可销售数量
|
|
|
remark: "", //其他备注
|
|
|
product_go: [], //表格参数
|
|
|
},
|
|
|
- anomalous_numbers: "", //异常数量
|
|
|
- anomalous_reason_code: "", //异常原因
|
|
|
- anomalous_remark: "", //异常备注
|
|
|
+ // anomalous_numbers: "", //异常数量
|
|
|
+ // anomalous_reason_code: "", //异常原因
|
|
|
+ // anomalous_remark: "", //异常备注
|
|
|
// --
|
|
|
btn_code: "",
|
|
|
modelId: "",
|
|
@@ -298,14 +303,22 @@ export default {
|
|
|
rulesThis: this.rules,
|
|
|
// 验证规则
|
|
|
rules: {
|
|
|
- get_goods_numbers: [
|
|
|
+ return_num: [
|
|
|
{
|
|
|
required: true,
|
|
|
trigger: "blur",
|
|
|
validator: validatenumbers,
|
|
|
},
|
|
|
- ],
|
|
|
- can_sell_numbers: [
|
|
|
+ ], //
|
|
|
+
|
|
|
+ // receive: [
|
|
|
+ // {
|
|
|
+ // required: true,
|
|
|
+ // trigger: "blur",
|
|
|
+ // validator: validatenumbers,
|
|
|
+ // },
|
|
|
+ // ],
|
|
|
+ normal: [
|
|
|
{
|
|
|
required: true,
|
|
|
trigger: "blur",
|
|
@@ -360,6 +373,7 @@ export default {
|
|
|
async initForm() {
|
|
|
this.loading = true;
|
|
|
this.rulesThis = this.rules;
|
|
|
+ console.log(this.sitem);
|
|
|
await this.getresultlist();
|
|
|
await this.resetForm();
|
|
|
this.loading = false;
|
|
@@ -373,24 +387,31 @@ export default {
|
|
|
this.$refs.ruleForm.clearValidate();
|
|
|
this.status = "";
|
|
|
this.arr = [];
|
|
|
- console.log(this.sitem);
|
|
|
- let { child, status, received_num, normal_num, remark } = this.sitem;
|
|
|
+ this.newArr = [];
|
|
|
+ // console.log("sitem", this.sitem);
|
|
|
+ let { child, status, received_num, normal_num, remark, return_num } =
|
|
|
+ this.sitem;
|
|
|
this.status = status;
|
|
|
- console.log(child);
|
|
|
+ this.newArr = child;
|
|
|
+ console.log("newArr", this.newArr);
|
|
|
+
|
|
|
child.forEach((ele) => {
|
|
|
let obj = {
|
|
|
+ is_del: "0",
|
|
|
anomalous_numbers: ele.error_num,
|
|
|
anomalous_reason_code: ele.error_code,
|
|
|
anomalous_remark: ele.error_remark,
|
|
|
id: ele.id,
|
|
|
+ edit: false,
|
|
|
};
|
|
|
// console.log("1");
|
|
|
this.arr.push(obj);
|
|
|
});
|
|
|
- console.log(this.arr);
|
|
|
+ console.log("arr", this.arr);
|
|
|
this.ruleForm = {
|
|
|
- get_goods_numbers: received_num, //收货总数量
|
|
|
- can_sell_numbers: normal_num, //可销售数量
|
|
|
+ return_num: return_num,
|
|
|
+ receive: "", //收货总数量
|
|
|
+ normal: normal_num, //可销售数量
|
|
|
remark: remark, //其他备注
|
|
|
product_go: this.arr, //表格参数this.arr
|
|
|
};
|
|
@@ -402,116 +423,82 @@ export default {
|
|
|
await this.$refs.ruleForm.validate(async (valid) => {
|
|
|
if (valid) {
|
|
|
this.loading = true;
|
|
|
- let model = JSON.parse(JSON.stringify(this.ruleForm));
|
|
|
- let thNo = "";
|
|
|
- if (this.sitem) {
|
|
|
- thNo = this.sitem.thNo;
|
|
|
+ const { product_go } = this.ruleForm;
|
|
|
+ let isok = true;
|
|
|
+ product_go.forEach((v) => {
|
|
|
+ if (v.edit) {
|
|
|
+ isok = false;
|
|
|
+ }
|
|
|
+ });
|
|
|
+ if (!isok) {
|
|
|
+ this.$message.warning("请保存异常情况记录表格!");
|
|
|
+ this.loading = false;
|
|
|
+ return;
|
|
|
+ }
|
|
|
+ const { receive, normal } = this.ruleForm;
|
|
|
+ const { return_num } = this.sitem;
|
|
|
+ let a = 0;
|
|
|
+ product_go.forEach((x) => {
|
|
|
+ a += Number(x.anomalous_numbers);
|
|
|
+ });
|
|
|
+
|
|
|
+ if (Number(return_num) !== Number(normal) + a) {
|
|
|
+ this.$message.warning("可销售数量+异常总数量不等于总退回数量!");
|
|
|
+ this.loading = false;
|
|
|
+ return;
|
|
|
}
|
|
|
+ let allList = [];
|
|
|
+ let model = JSON.parse(JSON.stringify(this.ruleForm));
|
|
|
+ delete model["product_go"];
|
|
|
+ model.errorlist = [];
|
|
|
+ model.thNo = this.sitem.thNo;
|
|
|
+
|
|
|
+ let list = JSON.parse(JSON.stringify(this.newArr));
|
|
|
+ product_go.forEach((x) => {
|
|
|
+ let index = this.newArr.findIndex((y) => y.id === x.id);
|
|
|
+ if (index !== -1) {
|
|
|
+ list.splice(index, 1);
|
|
|
+ }
|
|
|
+ });
|
|
|
+ list.forEach((v) => {
|
|
|
+ v.is_del = "1";
|
|
|
+ });
|
|
|
+ console.log(product_go);
|
|
|
+ allList.push(...product_go);
|
|
|
+ allList.push(...list);
|
|
|
+ console.log(allList);
|
|
|
+
|
|
|
let arr = [];
|
|
|
console.log(this.arr);
|
|
|
- this.arr.map((ele) => {
|
|
|
+ allList.map((ele) => {
|
|
|
let obj = {
|
|
|
- error_num: ele.anomalous_numbers,
|
|
|
- error_code: ele.anomalous_reason_code,
|
|
|
- error_remark: ele.anomalous_remark,
|
|
|
+ id: ele.id,
|
|
|
+ is_del: ele.is_del,
|
|
|
+ error_num: ele.anomalous_numbers || "",
|
|
|
+ error_code: ele.anomalous_reason_code || "",
|
|
|
+ error_remark: ele.anomalous_remark || "",
|
|
|
};
|
|
|
- arr.push(obj);
|
|
|
+ model.errorlist.push(obj);
|
|
|
});
|
|
|
- let _model = {
|
|
|
- thNo: thNo, // 退货编号
|
|
|
- receive: model.get_goods_numbers, //收货数量
|
|
|
- normal: model.can_sell_numbers, //正常数量
|
|
|
- remark: model.remark, //
|
|
|
- errorlist: arr, //
|
|
|
- };
|
|
|
- console.log(_model);
|
|
|
+
|
|
|
+ // console.log(model);
|
|
|
+
|
|
|
// return;
|
|
|
- const { get_goods_numbers, can_sell_numbers } = this.ruleForm;
|
|
|
- // 判断收获总数量是否等于可销售数量(情况1:没有异常数量)
|
|
|
- if (Number(get_goods_numbers) === Number(can_sell_numbers)) {
|
|
|
- const res = await asyncRequest.returnCheck({}); //_model
|
|
|
- if (res && res.code === 0) {
|
|
|
- console.log("submit");
|
|
|
- this.$notify.success({
|
|
|
- title: res.message,
|
|
|
- message: "",
|
|
|
- });
|
|
|
- this.$emit("refresh");
|
|
|
- console.log("抛出事件给详情页");
|
|
|
- } else if (res && res.code >= 100 && res.code <= 104) {
|
|
|
- await this.logout();
|
|
|
- } else {
|
|
|
- this.$message.warning(res.message);
|
|
|
- }
|
|
|
- } else if (Number(get_goods_numbers) < Number(can_sell_numbers)) {
|
|
|
- console.log(+get_goods_numbers, +can_sell_numbers);
|
|
|
- this.$message.warning("可销售数量不能大于收货总数量!");
|
|
|
- } else {
|
|
|
- this.ruleForm.product_go.forEach((item) => {
|
|
|
- if (!item.edit) {
|
|
|
- this.edit = true;
|
|
|
- }
|
|
|
- this.totalNumber += Number(item.anomalous_numbers);
|
|
|
+ const res = await asyncRequest.returnCheck(model); //_model
|
|
|
+ this.loading = false;
|
|
|
+ if (res && res.code === 0) {
|
|
|
+ console.log("submit");
|
|
|
+ this.$notify.success({
|
|
|
+ title: res.message,
|
|
|
+ message: "",
|
|
|
});
|
|
|
- if (
|
|
|
- this.edit &&
|
|
|
- Number(this.totalNumber) + Number(can_sell_numbers) ==
|
|
|
- Number(get_goods_numbers)
|
|
|
- ) {
|
|
|
- const res = await asyncRequest.returnCheck(_model);
|
|
|
- if (res && res.code === 0) {
|
|
|
- console.log("submit");
|
|
|
- this.$notify.success({
|
|
|
- title: res.message,
|
|
|
- message: "",
|
|
|
- });
|
|
|
- this.$emit("refresh");
|
|
|
- } else if (res && res.code >= 100 && res.code <= 104) {
|
|
|
- await this.logout();
|
|
|
- } else {
|
|
|
- this.$message.warning(res.message);
|
|
|
- }
|
|
|
- } else {
|
|
|
- this.$message.warning("异常数量不正确或者当前表格在编辑!");
|
|
|
- }
|
|
|
- this.totalNumber = 0;
|
|
|
+ this.$emit("refresh");
|
|
|
+ console.log("抛出事件给详情页");
|
|
|
+ } else if (res && res.code >= 100 && res.code <= 104) {
|
|
|
+ await this.logout();
|
|
|
+ } else {
|
|
|
+ this.$message.warning(res.message);
|
|
|
}
|
|
|
-
|
|
|
- this.totalNumber = 0;
|
|
|
- // if (!this.tableForm.product_go.edit) {
|
|
|
- // console.log(this.$refs.ruleForm);
|
|
|
- // this.$refs.ruleForm.validateField("tableCheck");
|
|
|
- // }
|
|
|
- // let res = {};
|
|
|
- // if (this.id === "add") {
|
|
|
- // delete model["id"];
|
|
|
- // res = await asyncRequest.add(model);
|
|
|
- // } else {
|
|
|
- // res = await asyncRequest.update(model);
|
|
|
- // }
|
|
|
-
|
|
|
- // this.loading = false;
|
|
|
- // if (res && res.code === 0) {
|
|
|
- // const title = this.id === "add" ? "添加成功!" : "修改成功!";
|
|
|
- // this.$notify.success({
|
|
|
- // title,
|
|
|
- // message: "",
|
|
|
- // });
|
|
|
-
|
|
|
- // if (this.id === "add") {
|
|
|
- // this.showModelThis = false;
|
|
|
- // this.$emit("refresh", false);
|
|
|
- // } else {
|
|
|
- // this.initForm();
|
|
|
- // }
|
|
|
- // } else if (res && res.code >= 100 && res.code <= 104) {
|
|
|
- // await this.logout();
|
|
|
- // } else {
|
|
|
- // this.$message.warning(res.message);
|
|
|
- // }
|
|
|
- // } else {
|
|
|
- // console.log("error submit!!");
|
|
|
- // return false;
|
|
|
}
|
|
|
});
|
|
|
},
|
|
@@ -543,21 +530,17 @@ export default {
|
|
|
if (!isnumber(anomalous_numbers)) {
|
|
|
this.$message.warning("异常数量必须为整数!");
|
|
|
return;
|
|
|
- } else if (
|
|
|
- +anomalous_numbers + +this.ruleForm.can_sell_numbers <
|
|
|
- +this.ruleForm.get_goods_numbers
|
|
|
- ) {
|
|
|
- this.$message.warning("当前可销售数量+异常数量小于总收货数量!");
|
|
|
- } else if (
|
|
|
- +anomalous_numbers + +this.ruleForm.can_sell_numbers >
|
|
|
- +this.ruleForm.get_goods_numbers
|
|
|
+ }
|
|
|
+ console.log(this.ruleForm.return_num);
|
|
|
+ console.log(anomalous_numbers, this.ruleForm.normal);
|
|
|
+ if (
|
|
|
+ +anomalous_numbers + +this.ruleForm.normal !==
|
|
|
+ +this.ruleForm.return_num
|
|
|
) {
|
|
|
- this.$message.warning("可销售数量+异常数量不能大于总收货数量!");
|
|
|
+ this.$message.warning("当前可销售数量+异常数量不等于总退货数量!");
|
|
|
return;
|
|
|
}
|
|
|
- if (anomalous_remark.length > 20) {
|
|
|
- this.$message.warning("异常备注字数不能超过250个!");
|
|
|
- }
|
|
|
+
|
|
|
if (anomalous_numbers == 0) {
|
|
|
this.$message.info("异常数量为零,不用选择异常原因!");
|
|
|
this.ruleForm.product_go[rowIndex].edit = false;
|
|
@@ -572,6 +555,8 @@ export default {
|
|
|
},
|
|
|
//编辑某一行
|
|
|
editRow(rowIndex) {
|
|
|
+ console.log(rowIndex);
|
|
|
+ console.log(this.ruleForm.product_go[rowIndex].edit);
|
|
|
let index = this.ruleForm.product_go.findIndex((v) => v.edit);
|
|
|
console.log(index);
|
|
|
if (index !== -1) {
|
|
@@ -582,6 +567,12 @@ export default {
|
|
|
this.ruleForm.product_go[rowIndex].edit = true;
|
|
|
}
|
|
|
},
|
|
|
+ deleteRow(rowIndex) {
|
|
|
+ // console.log(rowIndex);
|
|
|
+ // console.log(this.ruleForm.product_go);
|
|
|
+ this.ruleForm.product_go.shift(rowIndex);
|
|
|
+ // console.log(this.ruleForm.product_go);
|
|
|
+ },
|
|
|
//重置行内参数
|
|
|
resetRow(rowIndex) {
|
|
|
this.ruleForm.product_go[rowIndex].anomalous_numbers = "";
|