|
@@ -60,9 +60,9 @@
|
|
|
<el-form-item label="项目总预算" prop="budget_total">
|
|
|
<digital-input
|
|
|
:values="ruleForm.budget_total"
|
|
|
- :placeholder="'起订量'"
|
|
|
+ :placeholder="'项目总预算'"
|
|
|
:min="0"
|
|
|
- :max="10000000000"
|
|
|
+ :max="100000000000"
|
|
|
:position="'right'"
|
|
|
:precision="2"
|
|
|
:size="'mini'"
|
|
@@ -99,16 +99,22 @@
|
|
|
<el-col :span="24">
|
|
|
<el-form-item label="商品要求" prop="ladder">
|
|
|
<el-table
|
|
|
- :data="tableData"
|
|
|
+ :data="ruleForm.ladder"
|
|
|
:size="'mini'"
|
|
|
border
|
|
|
stripe
|
|
|
- style="width: 100%; margin: 0 0 20px 0"
|
|
|
+ style="width: 100%"
|
|
|
>
|
|
|
- <el-table-column label="商品阶梯">
|
|
|
- <template slot-scope="scope"> {{ scope.$index }}</template>
|
|
|
+ <el-table-column label="商品阶梯" width="70px">
|
|
|
+ <template slot-scope="scope">
|
|
|
+ {{ scope.$index + 1 }}</template
|
|
|
+ >
|
|
|
+ </el-table-column>
|
|
|
+ <el-table-column prop="good_type" label="商品类型" width="80px">
|
|
|
+ <template slot-scope="scope">
|
|
|
+ {{ scope.$index + 1 }}</template
|
|
|
+ >
|
|
|
</el-table-column>
|
|
|
- <el-table-column prop="good_type" label="商品类型" />
|
|
|
<el-table-column prop="good_name" label="商品名称" />
|
|
|
<el-table-column prop="good_img" label="商品图片" />
|
|
|
<el-table-column prop="cat_id" label="商品分类" />
|
|
@@ -193,12 +199,30 @@ export default {
|
|
|
// },
|
|
|
},
|
|
|
data() {
|
|
|
+ const validate_sale_price = (rule, value, callback) => {
|
|
|
+ if (value === "") {
|
|
|
+ callback(new Error("项目总预算不能为空!"));
|
|
|
+ } else if (
|
|
|
+ value === "0" ||
|
|
|
+ value === "0." ||
|
|
|
+ value === "0.0" ||
|
|
|
+ value === "0.00"
|
|
|
+ ) {
|
|
|
+ callback(new Error("项目总预算不能为零!"));
|
|
|
+ } else {
|
|
|
+ callback();
|
|
|
+ }
|
|
|
+ };
|
|
|
return {
|
|
|
loading: false,
|
|
|
tableData: [],
|
|
|
costshowModel: false,
|
|
|
costmodelIndex: "",
|
|
|
costsitem: {},
|
|
|
+ options: [
|
|
|
+ { value: "1", label: "竞品" },
|
|
|
+ { value: "2", label: "竞聘" },
|
|
|
+ ],
|
|
|
pickerOptions: {
|
|
|
disabledDate(time) {
|
|
|
return time.getTime() <= Date.now();
|
|
@@ -210,7 +234,7 @@ export default {
|
|
|
companyNo: "",
|
|
|
khNo: [],
|
|
|
customer_name: "",
|
|
|
- budget_total: "",
|
|
|
+ budget_total: "0",
|
|
|
arrtime: "",
|
|
|
use_desc: "",
|
|
|
ladder: [],
|
|
@@ -251,7 +275,7 @@ export default {
|
|
|
budget_total: [
|
|
|
{
|
|
|
required: true,
|
|
|
- message: "项目总预算",
|
|
|
+ validator: validate_sale_price,
|
|
|
trigger: "blur",
|
|
|
},
|
|
|
],
|
|
@@ -286,11 +310,48 @@ export default {
|
|
|
this.initForm();
|
|
|
},
|
|
|
methods: {
|
|
|
+ //商品要求阶梯修改
|
|
|
+ costrefreshEdit(e) {
|
|
|
+ let item = JSON.parse(JSON.stringify(e));
|
|
|
+ const {
|
|
|
+ index,
|
|
|
+ id,
|
|
|
+ budget_price,
|
|
|
+ num,
|
|
|
+ cat_name,
|
|
|
+ good_img,
|
|
|
+ good_name,
|
|
|
+ good_type,
|
|
|
+ cat_id,
|
|
|
+ } = item;
|
|
|
+ if (index + "" === "-1") {
|
|
|
+ this.ruleForm.ladder.push(item);
|
|
|
+ } else {
|
|
|
+ this.ruleForm.ladder.forEach((i, findex) => {
|
|
|
+ if (i.id === id && findex === parseInt(i.index)) {
|
|
|
+ this.ruleForm.ladder[findex].id = id;
|
|
|
+ this.ruleForm.ladder[findex].budget_price = budget_price;
|
|
|
+ this.ruleForm.ladder[findex].num = num;
|
|
|
+ this.ruleForm.ladder[findex].good_type = good_type;
|
|
|
+ this.ruleForm.ladder[findex].cat_id = JSON.parse(
|
|
|
+ JSON.stringify(cat_id)
|
|
|
+ );
|
|
|
+ this.ruleForm.ladder[findex].cat_name = JSON.parse(
|
|
|
+ JSON.stringify(cat_name)
|
|
|
+ );
|
|
|
+ this.ruleForm.ladder[findex].good_name = good_name;
|
|
|
+ this.ruleForm.ladder[findex].good_img = good_img;
|
|
|
+ }
|
|
|
+ });
|
|
|
+ }
|
|
|
+ this.showModel = false;
|
|
|
+ this.$refs.ruleForm.validateField("ladder");
|
|
|
+ },
|
|
|
//平台选择
|
|
|
platform_codesearchChange(e) {
|
|
|
if (e) {
|
|
|
const { id, code, label } = e;
|
|
|
- this.parmValue.platform = id ? [id] : [];
|
|
|
+ this.ruleForm.platform = id ? [id] : [];
|
|
|
this.$refs.ruleForm.validateField("platform");
|
|
|
}
|
|
|
},
|
|
@@ -316,53 +377,31 @@ export default {
|
|
|
|
|
|
this.$refs.ruleForm.validateField("khNo");
|
|
|
},
|
|
|
+ //项目总预算编辑
|
|
|
budget_total_change(e) {
|
|
|
this.ruleForm.budget_total = e + "";
|
|
|
this.$refs.ruleForm.validateField("budget_total");
|
|
|
},
|
|
|
+ //商品要求阶梯弹窗打开
|
|
|
openCostEdit(index, sitem) {
|
|
|
this.costmodelIndex = index;
|
|
|
this.costsitem = sitem;
|
|
|
this.costshowModel = true;
|
|
|
},
|
|
|
-
|
|
|
+ //删除某一商品要求
|
|
|
openCostEditDelete(index) {
|
|
|
- this.tableData.splice(index, 1);
|
|
|
- },
|
|
|
- showAddrAddEditModalRefresh(e) {
|
|
|
- const { index, item } = e;
|
|
|
-
|
|
|
- if (index === -1) {
|
|
|
- this.addrForm.addrlist.push(JSON.parse(JSON.stringify(item)));
|
|
|
- } else {
|
|
|
- const {
|
|
|
- arrive_time,
|
|
|
- receipt_quantity,
|
|
|
- contactor,
|
|
|
- mobile,
|
|
|
- addr_code,
|
|
|
- addr_code_name,
|
|
|
- addr,
|
|
|
- id,
|
|
|
- } = JSON.parse(JSON.stringify(item));
|
|
|
- this.addrForm.addrlist[index].receipt_quantity = receipt_quantity;
|
|
|
- this.addrForm.addrlist[index].arrive_time = arrive_time;
|
|
|
- this.addrForm.addrlist[index].contactor = contactor;
|
|
|
- this.addrForm.addrlist[index].mobile = mobile;
|
|
|
- this.addrForm.addrlist[index].addr_code = addr_code;
|
|
|
- this.addrForm.addrlist[index].addr_code_name = addr_code_name;
|
|
|
- this.addrForm.addrlist[index].addr = addr;
|
|
|
- this.addrForm.addrlist[index].id = id;
|
|
|
- }
|
|
|
- this.$refs.addrForm.validateField("addrlist");
|
|
|
+ this.ruleForm.ladder.splice(index, 1);
|
|
|
+ this.$refs.ruleForm.validateField("ladder");
|
|
|
},
|
|
|
+ //初始化整个组件
|
|
|
async initForm() {
|
|
|
this.loading = true;
|
|
|
+ this.ruleForm.ladder = [];
|
|
|
this.rulesThis = this.rules;
|
|
|
await this.resetForm();
|
|
|
this.loading = false;
|
|
|
},
|
|
|
-
|
|
|
+ //初始化整个表单
|
|
|
async resetForm() {
|
|
|
// 重置
|
|
|
await this.$nextTick(() => {
|
|
@@ -372,124 +411,61 @@ export default {
|
|
|
// const { zxNo, class_cat, khname, khNo, cpName, budget_total } =
|
|
|
// this.sitem;
|
|
|
this.ruleForm = {
|
|
|
- name: "",
|
|
|
+ name: "新项目",
|
|
|
platform: [],
|
|
|
companyNo: "",
|
|
|
khNo: [],
|
|
|
- budget_total: "",
|
|
|
- arrtime: "",
|
|
|
- use_desc: "",
|
|
|
+ budget_total: "100",
|
|
|
+ arrtime: "2022-03-01",
|
|
|
+ use_desc: "111",
|
|
|
ladder: [],
|
|
|
};
|
|
|
}
|
|
|
});
|
|
|
},
|
|
|
- addrRefresh(e) {
|
|
|
- const { list } = e;
|
|
|
- this.addrForm.addrlist.push(...list);
|
|
|
- },
|
|
|
- openHouseModal(index) {
|
|
|
- this.AddrAddEditModalIndex = index;
|
|
|
|
|
|
- if (index === -1) {
|
|
|
- this.AddrAddEditModalSitem = {};
|
|
|
- } else {
|
|
|
- this.AddrAddEditModalSitem = JSON.parse(
|
|
|
- JSON.stringify(this.addrForm.addrlist[index])
|
|
|
- );
|
|
|
- }
|
|
|
- this.showAddrAddEditModal = true;
|
|
|
-
|
|
|
- // let findex = this.addrForm.addrlist.findIndex((v) => v.edit === true);
|
|
|
- // if (findex !== -1) {
|
|
|
- // this.$message.warning("当前已有地址在编辑,请保存后再试!");
|
|
|
- // return;
|
|
|
- // } else {
|
|
|
- // if (index === -1) {
|
|
|
- // this.addrForm.addrlist.push({
|
|
|
- // edit: true,
|
|
|
- // arrive_time: "",
|
|
|
- // receipt_quantity: "",
|
|
|
- // contactor: "",
|
|
|
- // mobile: "",
|
|
|
- // addr_code: [],
|
|
|
- // addr: "",
|
|
|
- // });
|
|
|
- // } else {
|
|
|
- // this.addrForm.addrlist[index].edit = true;
|
|
|
- // }
|
|
|
- // }
|
|
|
- },
|
|
|
- //省市区选择
|
|
|
- select_area_change(e, index) {
|
|
|
- this.addrForm.addrlist[index].addr_code = e;
|
|
|
- },
|
|
|
- //省市区保存某一行
|
|
|
- checkRow(rowIndex) {
|
|
|
- this.$refs.addrForm.validate((valid) => {
|
|
|
- if (valid) {
|
|
|
- this.addrForm.addrlist[rowIndex].edit = false;
|
|
|
- } else {
|
|
|
- console.log("error submit!!");
|
|
|
- return false;
|
|
|
- }
|
|
|
- });
|
|
|
- },
|
|
|
- // 省市区删除行操作
|
|
|
- deleteRow(index, rows) {
|
|
|
- rows.splice(index, 1);
|
|
|
- },
|
|
|
async submitForm() {
|
|
|
await this.$refs.ruleForm.validate(async (valid) => {
|
|
|
if (valid) {
|
|
|
this.loading = true;
|
|
|
- const { zxNo, khNo, good_num, sendtype, companyNo, goodtype } =
|
|
|
- JSON.parse(JSON.stringify(this.ruleForm));
|
|
|
- const { addrlist } = JSON.parse(JSON.stringify(this.addrForm));
|
|
|
- if (sendtype === "1") {
|
|
|
- let isok = true,
|
|
|
- addrT = 0;
|
|
|
- addrlist.forEach((v) => {
|
|
|
- addrT += parseInt(v.receipt_quantity);
|
|
|
- if (v.edit) {
|
|
|
- isok = false;
|
|
|
- }
|
|
|
- });
|
|
|
- if (!isok) {
|
|
|
- this.$message.warning("请保存地址信息!");
|
|
|
- this.loading = false;
|
|
|
- return;
|
|
|
- }
|
|
|
- if (parseInt(good_num) !== addrT) {
|
|
|
- this.$message.warning(
|
|
|
- "下单数量,与收货地址信息中的总数量不一致!"
|
|
|
- );
|
|
|
- this.loading = false;
|
|
|
- return;
|
|
|
- }
|
|
|
+ let model = JSON.parse(JSON.stringify(this.ruleForm));
|
|
|
+ console.log(model);
|
|
|
+ const { budget_total, ladder } = model;
|
|
|
+ let ztotal = Math.floor(budget_total * 100) / 100;
|
|
|
+ model.platform = model.platform.toString();
|
|
|
+ model.khNo = model.khNo.toString();
|
|
|
+ delete model["customer_name"];
|
|
|
+ if (ladder && ladder.length < 2) {
|
|
|
+ this.$message.warning("至少添加两个商品要求!");
|
|
|
+ this.loading = false;
|
|
|
+ return;
|
|
|
}
|
|
|
- const model = {
|
|
|
- zxNo: zxNo || "",
|
|
|
- khNo: khNo.length === 1 ? khNo[0] : "",
|
|
|
- good_num: good_num || "",
|
|
|
- companyNo: companyNo.length > 0 ? companyNo[0] : "",
|
|
|
- sendtype: sendtype | "",
|
|
|
- goodtype: goodtype || "",
|
|
|
- addrlist: [],
|
|
|
- };
|
|
|
+ let total = 0;
|
|
|
let list = [];
|
|
|
- addrlist.forEach((v) => {
|
|
|
- let xitem = {
|
|
|
- contactor: v.contactor,
|
|
|
- mobile: v.mobile,
|
|
|
- addr: v.addr,
|
|
|
- addr_code: v.addr_code,
|
|
|
- receipt_quantity: v.receipt_quantity,
|
|
|
- arrive_time: v.arrive_time,
|
|
|
- };
|
|
|
- list.push(xitem);
|
|
|
+ ladder.forEach((e) => {
|
|
|
+ let item = JSON.parse(JSON.stringify(e));
|
|
|
+ delete item["id"];
|
|
|
+ delete item["index"];
|
|
|
+ delete item["is_del"];
|
|
|
+ delete item["cat_name"];
|
|
|
+ item.cat_id =
|
|
|
+ item.cat_id && item.cat_id.length > 0
|
|
|
+ ? item.cat_id[item.cat_id.length - 1]
|
|
|
+ : "";
|
|
|
+ list.push(item);
|
|
|
+ let a1 = Math.floor(e.budget_price * 100);
|
|
|
+ let a2 = parseInt(e.num);
|
|
|
+ let a3 = (a1 * a2) / 100;
|
|
|
+ total = Math.floor((a3 + total) * 100) / 100;
|
|
|
});
|
|
|
- model.addrlist = sendtype === "1" ? list : [];
|
|
|
+ console.log(`项目总预算为${ztotal}---商品要求预算总和为${total}`);
|
|
|
+ if (ztotal < total) {
|
|
|
+ this.$message.warning("项目总预算不能低于所以商品要求预算总和!");
|
|
|
+ this.loading = false;
|
|
|
+ return;
|
|
|
+ }
|
|
|
+ model.ladder = JSON.parse(JSON.stringify(list));
|
|
|
+
|
|
|
let res = await asyncRequest.add(model);
|
|
|
this.loading = false;
|
|
|
if (res && res.code === 0) {
|
|
@@ -499,7 +475,7 @@ export default {
|
|
|
});
|
|
|
this.showModelThis = false;
|
|
|
// 刷新
|
|
|
- this.$emit("refresh");
|
|
|
+ this.$emit("refresh",res.data);
|
|
|
} else if (res && res.code >= 100 && res.code <= 104) {
|
|
|
await this.logout();
|
|
|
} else {
|