|
@@ -0,0 +1,788 @@
|
|
|
+<template>
|
|
|
+ <el-form
|
|
|
+ :model="ruleForm"
|
|
|
+ status-icon
|
|
|
+ :rules="rulesThis"
|
|
|
+ ref="ruleForm"
|
|
|
+ :size="'mini'"
|
|
|
+ label-width="100px"
|
|
|
+ class="demo-ruleForm"
|
|
|
+ >
|
|
|
+ <el-row>
|
|
|
+ <el-col :span="1" class="dtitle">
|
|
|
+ <ul style="padding:40px 0 0 0">
|
|
|
+ <li>固</li>
|
|
|
+ <li>定</li>
|
|
|
+ <li>成</li>
|
|
|
+ <li>本</li>
|
|
|
+ </ul></el-col
|
|
|
+ >
|
|
|
+ <el-col :span="23" class="dmain">
|
|
|
+ <el-row>
|
|
|
+ <el-col :span="8">
|
|
|
+ <el-form-item label="证书费" prop="a1">
|
|
|
+ <el-input
|
|
|
+ placeholder="证书费"
|
|
|
+ v-model="ruleForm.a1"
|
|
|
+ type="number"
|
|
|
+ :min="0"
|
|
|
+ :max="9999999999.99"
|
|
|
+ :step="2"
|
|
|
+ >
|
|
|
+ <template slot="append">元</template>
|
|
|
+ </el-input>
|
|
|
+ </el-form-item>
|
|
|
+ </el-col>
|
|
|
+ <el-col :span="8">
|
|
|
+ <el-form-item label="包装费" prop="a2">
|
|
|
+ <el-input
|
|
|
+ placeholder="包装费"
|
|
|
+ v-model="ruleForm.a2"
|
|
|
+ type="number"
|
|
|
+ :min="0"
|
|
|
+ :max="9999999999.99"
|
|
|
+ :step="2"
|
|
|
+ >
|
|
|
+ <template slot="append">元</template>
|
|
|
+ </el-input>
|
|
|
+ </el-form-item>
|
|
|
+ </el-col>
|
|
|
+ <el-col :span="8">
|
|
|
+ <el-form-item label="成本工艺费" prop="a3">
|
|
|
+ <el-input
|
|
|
+ placeholder="成本工艺费"
|
|
|
+ v-model="ruleForm.a3"
|
|
|
+ type="number"
|
|
|
+ :min="0"
|
|
|
+ :max="9999999999.99"
|
|
|
+ :step="2"
|
|
|
+ >
|
|
|
+ <template slot="append">元</template>
|
|
|
+ </el-input>
|
|
|
+ </el-form-item>
|
|
|
+ </el-col>
|
|
|
+ <el-col :span="8">
|
|
|
+ <el-form-item label="加标费" prop="a4">
|
|
|
+ <el-input
|
|
|
+ placeholder="加标费"
|
|
|
+ v-model="ruleForm.a4"
|
|
|
+ type="number"
|
|
|
+ :min="0"
|
|
|
+ :max="9999999999.99"
|
|
|
+ :step="2"
|
|
|
+ >
|
|
|
+ <template slot="append">元</template>
|
|
|
+ </el-input>
|
|
|
+ </el-form-item>
|
|
|
+ </el-col>
|
|
|
+ <el-col :span="8">
|
|
|
+ <el-form-item label="打样费" prop="a5">
|
|
|
+ <el-input
|
|
|
+ placeholder="打样费"
|
|
|
+ v-model="ruleForm.a5"
|
|
|
+ type="number"
|
|
|
+ :min="0"
|
|
|
+ :max="9999999999.99"
|
|
|
+ :step="2"
|
|
|
+ >
|
|
|
+ <template slot="append">元</template>
|
|
|
+ </el-input>
|
|
|
+ </el-form-item>
|
|
|
+ </el-col>
|
|
|
+ <el-col :span="8">
|
|
|
+ <el-form-item label="开模费" prop="a6">
|
|
|
+ <el-input
|
|
|
+ placeholder="开模费"
|
|
|
+ v-model="ruleForm.a6"
|
|
|
+ type="number"
|
|
|
+ :min="0"
|
|
|
+ :max="9999999999.99"
|
|
|
+ :step="2"
|
|
|
+ >
|
|
|
+ <template slot="append">元</template>
|
|
|
+ </el-input>
|
|
|
+ </el-form-item>
|
|
|
+ </el-col>
|
|
|
+ <el-col :span="8">
|
|
|
+ <el-form-item label="调样费" prop="a7">
|
|
|
+ <el-input
|
|
|
+ placeholder="调样费"
|
|
|
+ v-model="ruleForm.a7"
|
|
|
+ type="number"
|
|
|
+ :min="0"
|
|
|
+ :max="9999999999.99"
|
|
|
+ :step="2"
|
|
|
+ >
|
|
|
+ <template slot="append">元</template>
|
|
|
+ </el-input>
|
|
|
+ </el-form-item>
|
|
|
+ </el-col>
|
|
|
+ <el-col :span="8">
|
|
|
+ <el-form-item label="市场价" prop="a8">
|
|
|
+ <el-input
|
|
|
+ placeholder="市场价"
|
|
|
+ v-model="ruleForm.a8"
|
|
|
+ type="number"
|
|
|
+ :min="0"
|
|
|
+ :max="9999999999.99"
|
|
|
+ :step="2"
|
|
|
+ >
|
|
|
+ <template slot="append">元</template>
|
|
|
+ </el-input>
|
|
|
+ </el-form-item>
|
|
|
+ </el-col>
|
|
|
+ <el-col :span="8">
|
|
|
+ <el-form-item label="含税成本裸价" prop="a9">
|
|
|
+ <el-input
|
|
|
+ placeholder="含税成本裸价"
|
|
|
+ v-model="ruleForm.a9"
|
|
|
+ type="number"
|
|
|
+ :min="0"
|
|
|
+ :max="9999999999.99"
|
|
|
+ :step="2"
|
|
|
+ >
|
|
|
+ <template slot="append">元</template>
|
|
|
+ </el-input>
|
|
|
+ </el-form-item>
|
|
|
+ </el-col>
|
|
|
+ </el-row>
|
|
|
+ </el-col>
|
|
|
+ </el-row>
|
|
|
+ <el-row class="ddiv">
|
|
|
+ <el-col :span="1" class="dtitle">
|
|
|
+ <ul>
|
|
|
+ <li>阶</li>
|
|
|
+ <li>梯</li>
|
|
|
+ <li>成</li>
|
|
|
+ <li>本</li>
|
|
|
+ </ul></el-col
|
|
|
+ >
|
|
|
+ <el-col :span="23" class="dmain" style="padding-left:18px">
|
|
|
+ <el-table
|
|
|
+ :data="tableData"
|
|
|
+ :size="'mini'"
|
|
|
+ border
|
|
|
+ stripe
|
|
|
+ style="width: 100%"
|
|
|
+ >
|
|
|
+ <el-table-column prop="num" label="起订量(>=)" />
|
|
|
+ <el-table-column prop="name" label="成本裸价" />
|
|
|
+ <el-table-column prop="address" label="成本合计" />
|
|
|
+ <el-table-column prop="address" label="其中运费" />
|
|
|
+ <el-table-column fixed="right">
|
|
|
+ <template slot="header" slot-scope="scope">
|
|
|
+ <span>操作</span>
|
|
|
+ <el-tooltip effect="dark" content="添加阶梯" placement="top">
|
|
|
+ <i
|
|
|
+ class="el-icon-circle-plus-outline tb-icon fr"
|
|
|
+ @click="openModal('')"
|
|
|
+ ></i>
|
|
|
+ </el-tooltip>
|
|
|
+ </template>
|
|
|
+ <template slot-scope="scope">
|
|
|
+ <el-tooltip effect="dark" content="修改" placement="top">
|
|
|
+ <i class="el-icon-edit tb-icon" @click="openModal('')"></i>
|
|
|
+ </el-tooltip>
|
|
|
+ <el-tooltip effect="dark" content="禁/启用" placement="top">
|
|
|
+ <i class="el-icon-video-pause tb-icon" @click="openModal('')"></i>
|
|
|
+ <!-- el-icon-video-play -->
|
|
|
+ </el-tooltip>
|
|
|
+ </template>
|
|
|
+ </el-table-column>
|
|
|
+ </el-table> </el-col
|
|
|
+ ></el-row>
|
|
|
+ </el-form>
|
|
|
+</template>
|
|
|
+ <script>
|
|
|
+import asyncRequest from "@/apis/service/goodStore/goodsCost";
|
|
|
+import resToken from "@/mixins/resToken";
|
|
|
+import { mapGetters } from "vuex";
|
|
|
+import { options1, options2, options3, options4, options5 } from "../columns";
|
|
|
+export default {
|
|
|
+ name: "goodsCostAdd",
|
|
|
+ mixins: [resToken],
|
|
|
+ computed: {
|
|
|
+ ...mapGetters(["tablebtnSize", "searchSize", "size"]),
|
|
|
+ powers() {
|
|
|
+ let tran =
|
|
|
+ this.$store.getters.btnList.find(
|
|
|
+ (item) => item.menu_route == "goodsCostAdd"
|
|
|
+ ) || {};
|
|
|
+ if (tran && tran.action && tran.action.length > 0) {
|
|
|
+ return tran.action;
|
|
|
+ } else {
|
|
|
+ return [];
|
|
|
+ }
|
|
|
+ },
|
|
|
+ },
|
|
|
+ data() {
|
|
|
+ return {
|
|
|
+ size: "small",
|
|
|
+ rulesThis: this.rules,
|
|
|
+ activeName: "1",
|
|
|
+ loading: false,
|
|
|
+ tableData: [{ num: 1 }],
|
|
|
+ options1: options1,
|
|
|
+ options2: options2,
|
|
|
+ options3: options3,
|
|
|
+ options4: options4,
|
|
|
+ options5: options5,
|
|
|
+ supplierOptions4: [
|
|
|
+ { id: "0", name: "0%" },
|
|
|
+ { id: "1", name: "1%" },
|
|
|
+ { id: "3", name: "3%" },
|
|
|
+ { id: "6", name: "6%" },
|
|
|
+ { id: "9", name: "9%" },
|
|
|
+ { id: "13", name: "13%" },
|
|
|
+ ],
|
|
|
+ supplierOptions6: [
|
|
|
+ { id: "0", name: "供应商1" },
|
|
|
+ { id: "1", name: "供应商1" },
|
|
|
+ ],
|
|
|
+
|
|
|
+ ruleForm: {
|
|
|
+ id: this.id,
|
|
|
+ catid: [],
|
|
|
+ good_name: "",
|
|
|
+ unit: "",
|
|
|
+ supplier: "",
|
|
|
+ brandid: "",
|
|
|
+ image: [],
|
|
|
+ spec: "",
|
|
|
+ table: "",
|
|
|
+ },
|
|
|
+
|
|
|
+ rules: {
|
|
|
+ supplier: [
|
|
|
+ {
|
|
|
+ required: true,
|
|
|
+ message: "供应商联系人",
|
|
|
+ trigger: "change",
|
|
|
+ },
|
|
|
+ ],
|
|
|
+ image: [
|
|
|
+ {
|
|
|
+ required: true,
|
|
|
+ message: "商品主图",
|
|
|
+ trigger: "change",
|
|
|
+ },
|
|
|
+ ],
|
|
|
+ catid: [
|
|
|
+ {
|
|
|
+ required: true,
|
|
|
+ message: "商品分类",
|
|
|
+ trigger: "change",
|
|
|
+ },
|
|
|
+ ],
|
|
|
+ brandid: [
|
|
|
+ {
|
|
|
+ required: true,
|
|
|
+ message: "商品品牌",
|
|
|
+ trigger: "change",
|
|
|
+ },
|
|
|
+ ],
|
|
|
+ good_name: [
|
|
|
+ {
|
|
|
+ required: true,
|
|
|
+ message: "请输入商品名称",
|
|
|
+ trigger: "blur",
|
|
|
+ },
|
|
|
+ {
|
|
|
+ min: 2,
|
|
|
+ max: 50,
|
|
|
+ message: "长度在 2 到 50 个字符",
|
|
|
+ trigger: "blur",
|
|
|
+ },
|
|
|
+ ],
|
|
|
+ unit: [
|
|
|
+ {
|
|
|
+ required: true,
|
|
|
+ message: "请输入商品单位",
|
|
|
+ trigger: "blur",
|
|
|
+ },
|
|
|
+ {
|
|
|
+ min: 1,
|
|
|
+ max: 10,
|
|
|
+ message: "长度在 1 到 10 个字符",
|
|
|
+ trigger: "blur",
|
|
|
+ },
|
|
|
+ ],
|
|
|
+ },
|
|
|
+ ruleForm: {},
|
|
|
+ };
|
|
|
+ },
|
|
|
+ mounted() {
|
|
|
+ this.initForm();
|
|
|
+ },
|
|
|
+ methods: {
|
|
|
+ async initForm() {
|
|
|
+ this.loading = true;
|
|
|
+ this.rulesThis = this.rules;
|
|
|
+ await this.resetForm();
|
|
|
+ this.loading = false;
|
|
|
+ },
|
|
|
+ handleClick(row) {
|
|
|
+ console.log(row);
|
|
|
+ },
|
|
|
+ async initData() {
|
|
|
+ this.loading = true;
|
|
|
+ let res = await asyncRequest.detail({ id: this.id });
|
|
|
+ this.loading = false;
|
|
|
+ if (res.code === 0) {
|
|
|
+ await this.resetForm(res.data);
|
|
|
+ }
|
|
|
+ },
|
|
|
+ async resetForm() {
|
|
|
+ // 重置
|
|
|
+ await this.$nextTick(async () => {
|
|
|
+ if (this.$refs.ruleForm) {
|
|
|
+ this.$refs.ruleForm.resetFields();
|
|
|
+ this.$refs.ruleForm.clearValidate();
|
|
|
+ // if (data) {
|
|
|
+ // this.ruleForm = {
|
|
|
+ // id: this.id,
|
|
|
+ // catid: data.good_cat.split(","),
|
|
|
+ // good_name: data.good_name,
|
|
|
+ // unit: data.good_unit,
|
|
|
+ // supplier: data.supplier,
|
|
|
+ // brandid: data.brand_id,
|
|
|
+ // image: data.galley.split(","),
|
|
|
+ // };
|
|
|
+ // this.oldcatid = this.ruleForm.catid;
|
|
|
+ // // await this.specByCat(false);
|
|
|
+ // } else {
|
|
|
+ this.ruleForm = {
|
|
|
+ id: this.id,
|
|
|
+ catid: ["1", "2", "3"],
|
|
|
+ good_name:
|
|
|
+ "2018春秋新款V领修身丝绒西装女 双排扣复古极简中长款工装外套",
|
|
|
+ unit: "件",
|
|
|
+ supplier: "8",
|
|
|
+ brandid: "3",
|
|
|
+ supplier3: "0",
|
|
|
+ image: [
|
|
|
+ "http://cum.sit.wanyuhengtong.com/20210425/1edfa0da4eee9b24d1f35d52b6a0ec0a.jpg",
|
|
|
+ "http://cum.sit.wanyuhengtong.com/20210425/cc70a4c06c83d9d8ac27ae35b118a23f.jpg",
|
|
|
+ "http://cum.sit.wanyuhengtong.com/20210425/a5e05dc1c5c75030bcc95f1da1d2d9cb.jpg",
|
|
|
+ "http://cum.sit.wanyuhengtong.com/20210425/9d505e7632891459a29f2fafe28d6705.jpg",
|
|
|
+ "http://cum.sit.wanyuhengtong.com/20210425/714914d7545184e99e240b3affeada07.jpg",
|
|
|
+ ],
|
|
|
+ // };
|
|
|
+ };
|
|
|
+
|
|
|
+ // this.ruleForm = {
|
|
|
+ // spec: "",
|
|
|
+ // table: "",
|
|
|
+ // };
|
|
|
+ }
|
|
|
+ });
|
|
|
+ },
|
|
|
+
|
|
|
+ async submitForm() {
|
|
|
+ await this.$refs.ruleForm.validate(async (valid) => {
|
|
|
+ if (valid) {
|
|
|
+ let change = false;
|
|
|
+ this.mock.forEach((v1) => {
|
|
|
+ if (v1.change && v1.change.length > 0) {
|
|
|
+ change = true;
|
|
|
+ }
|
|
|
+ });
|
|
|
+ if (!change) {
|
|
|
+ this.ruleForm.spec = "规格!";
|
|
|
+ return;
|
|
|
+ } else {
|
|
|
+ this.ruleForm.spec = "";
|
|
|
+ let table = false;
|
|
|
+ let hasnot = false;
|
|
|
+ let stock = [];
|
|
|
+ this.right.specList.forEach((v1) => {
|
|
|
+ if (v1) {
|
|
|
+ v1.forEach((v2) => {
|
|
|
+ if (v2 && v2.limit && v2.limit.length > 0) {
|
|
|
+ let list = [];
|
|
|
+ v2.limit.forEach((v3) => {
|
|
|
+ if (v3.num != 0 && v3.price != 0) {
|
|
|
+ table = true;
|
|
|
+ list.push(v3);
|
|
|
+ }
|
|
|
+ if (
|
|
|
+ (v3.num != 0 && v3.price == 0) ||
|
|
|
+ (v3.num == 0 && v3.price !== 0)
|
|
|
+ ) {
|
|
|
+ hasnot = true;
|
|
|
+ }
|
|
|
+ });
|
|
|
+ if (list.length > 0) {
|
|
|
+ let model = Object.assign({}, v2);
|
|
|
+ model.limit = list;
|
|
|
+ stock.push(model);
|
|
|
+ }
|
|
|
+ }
|
|
|
+ });
|
|
|
+ }
|
|
|
+ });
|
|
|
+
|
|
|
+ if (hasnot) {
|
|
|
+ this.ruleForm.table =
|
|
|
+ "起订量与成本价需成对填写,未成对请设为零!";
|
|
|
+ } else {
|
|
|
+ if (!table) {
|
|
|
+ this.ruleForm.table = "至少填写一堆起订量与成本价!";
|
|
|
+ } else {
|
|
|
+ this.ruleForm.table = "";
|
|
|
+ this.loading = true;
|
|
|
+ let obj = JSON.parse(JSON.stringify(this.ruleForm));
|
|
|
+ obj.stock = stock;
|
|
|
+ obj.catid = obj.catid[obj.catid.length - 1];
|
|
|
+ obj.image = obj.image.join();
|
|
|
+ //split(",");
|
|
|
+ console.log(obj);
|
|
|
+ let res = {};
|
|
|
+ if (this.id === "add") {
|
|
|
+ delete obj["id"];
|
|
|
+ res = await asyncRequest.add(obj);
|
|
|
+ } else {
|
|
|
+ res = await asyncRequest.update(obj);
|
|
|
+ }
|
|
|
+ this.loading = false;
|
|
|
+ if (res.code === 0) {
|
|
|
+ let title = this.id === "add" ? "添加成功" : "修改成功";
|
|
|
+ this.$notify.success({
|
|
|
+ title,
|
|
|
+ message: "",
|
|
|
+ });
|
|
|
+ // 刷新
|
|
|
+ this.$emit("refresh");
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
+ } else {
|
|
|
+ console.log("error submit!!");
|
|
|
+ return false;
|
|
|
+ }
|
|
|
+ });
|
|
|
+ },
|
|
|
+ // groupChange($event, index, item) {
|
|
|
+ // this.$set(this.mock, index, item);
|
|
|
+ // this.actionSpecList();
|
|
|
+ // },
|
|
|
+ // actionSpecList() {
|
|
|
+ // // this.leftS = "0px";
|
|
|
+ // this.left.header = [];
|
|
|
+ // this.left.middle = [];
|
|
|
+ // this.left.specList = [];
|
|
|
+ // console.log(this.mock);
|
|
|
+ // console.log(this.right.specList);
|
|
|
+ // this.mock.forEach((v1) => {
|
|
|
+ // if (
|
|
|
+ // v1.change &&
|
|
|
+ // v1.change.length > 0 &&
|
|
|
+ // v1.child &&
|
|
|
+ // v1.child.length > 0
|
|
|
+ // ) {
|
|
|
+ // this.left.header.push({
|
|
|
+ // spec_id: v1.spec_id,
|
|
|
+ // spec_name: v1.spec_name,
|
|
|
+ // });
|
|
|
+ // let arr = [];
|
|
|
+ // let changeList = v1.change;
|
|
|
+ // changeList.forEach((v2) => {
|
|
|
+ // let index = v1.child.findIndex((v3) => v2 === v3.id);
|
|
|
+ // if (index !== -1) {
|
|
|
+ // let x = {
|
|
|
+ // spec_id: v1.spec_id,
|
|
|
+ // spec_name: v1.spec_name,
|
|
|
+ // id: v1.child[index].id,
|
|
|
+ // spec_value: v1.child[index].spec_value,
|
|
|
+ // };
|
|
|
+ // arr.push(x);
|
|
|
+ // }
|
|
|
+ // });
|
|
|
+ // this.left.middle.push(arr);
|
|
|
+ // }
|
|
|
+ // });
|
|
|
+ // let lang = this.left.header.length;
|
|
|
+ // this.leftS = lang * 70 + "px";
|
|
|
+ // if (this.left.middle.length > 1) {
|
|
|
+ // this.left.specList = this.doExchange(this.left.middle);
|
|
|
+ // } else if (this.left.middle.length === 0) {
|
|
|
+ // this.left.specList = [];
|
|
|
+ // } else {
|
|
|
+ // let list1 = [];
|
|
|
+ // this.left.middle.forEach((v1) => {
|
|
|
+ // if (v1) {
|
|
|
+ // v1.forEach((v2) => {
|
|
|
+ // let list2 = [];
|
|
|
+ // list2.push(v2);
|
|
|
+ // list1.push(list2);
|
|
|
+ // });
|
|
|
+ // }
|
|
|
+ // });
|
|
|
+ // this.left.specList = list1;
|
|
|
+ // }
|
|
|
+ // this.right.header = [];
|
|
|
+ // for (let i = 0; i < this.ladderNum; i++) {
|
|
|
+ // this.right.header.push(this.headLadder);
|
|
|
+ // }
|
|
|
+ // this.right.specList = [];
|
|
|
+ // this.left.specList.forEach((v1) => {
|
|
|
+ // let arr = [];
|
|
|
+ // let model = {
|
|
|
+ // specid: [],
|
|
|
+ // limit: [],
|
|
|
+ // };
|
|
|
+ // v1.forEach((v2) => {
|
|
|
+ // model.specid.push(v2.id);
|
|
|
+ // });
|
|
|
+ // for (let i = 0; i < this.ladderNum; i++) {
|
|
|
+ // let bodyLadder = {
|
|
|
+ // num: 0,
|
|
|
+ // price: 0,
|
|
|
+ // };
|
|
|
+ // model.limit.push(bodyLadder);
|
|
|
+ // }
|
|
|
+ // arr.push(model);
|
|
|
+ // this.right.specList.push(arr);
|
|
|
+ // });
|
|
|
+ // console.log(this.right.specList);
|
|
|
+ // },
|
|
|
+
|
|
|
+ // closeLadder(index) {
|
|
|
+ // console.log(index);
|
|
|
+ // },
|
|
|
+ // async handleChange(type) {
|
|
|
+ // if (this.ruleForm.catid !== this.oldcatid && this.oldcatid.length === 0) {
|
|
|
+ // await this.specByCat();
|
|
|
+
|
|
|
+ // if (this.step === 0 && !type) {
|
|
|
+ // this.step = 1;
|
|
|
+ // }
|
|
|
+ // } else if (
|
|
|
+ // this.ruleForm.catid !== this.oldcatid &&
|
|
|
+ // this.oldcatid.length > 0
|
|
|
+ // ) {
|
|
|
+ // await this.$confirm(
|
|
|
+ // "分类修改会影响该商品规格与价格!",
|
|
|
+ // "确定要修改?",
|
|
|
+ // {
|
|
|
+ // confirmButtonText: "确定",
|
|
|
+ // cancelButtonText: "取消",
|
|
|
+ // type: "warning",
|
|
|
+ // }
|
|
|
+ // )
|
|
|
+ // .then(async () => {
|
|
|
+ // await this.specByCat();
|
|
|
+ // if (this.step === 0) {
|
|
|
+ // this.step = 1;
|
|
|
+ // }
|
|
|
+ // })
|
|
|
+ // .catch(() => {
|
|
|
+ // this.ruleForm.catid = this.oldcatid;
|
|
|
+ // });
|
|
|
+ // } else {
|
|
|
+ // if (this.step === 0 && !type) {
|
|
|
+ // this.step = 1;
|
|
|
+ // }
|
|
|
+ // }
|
|
|
+ // },
|
|
|
+ // // 商品种类ID换取规格值
|
|
|
+ // async specByCat(type) {
|
|
|
+ // console.log("准备拉取!");
|
|
|
+ // this.mock = [];
|
|
|
+ // this.$set(this.mock);
|
|
|
+ // let list = this.ruleForm.catid;
|
|
|
+ // let res = await asyncRequest.specByCat({ catid: list[list.length - 1] });
|
|
|
+ // if (res.code === 0) {
|
|
|
+ // this.dealWitHInitMock(res.data, type);
|
|
|
+ // this.oldcatid = list;
|
|
|
+ // } else if (res.code !== 101 && res.code !== 102) {
|
|
|
+ // this.ruleForm.catid = this.oldcatid;
|
|
|
+ // }
|
|
|
+ // },
|
|
|
+ // // 规格属性值新建
|
|
|
+ // async specinfoadd(id, value) {
|
|
|
+ // console.log(id, value);
|
|
|
+ // let list = this.ruleForm.catid;
|
|
|
+ // let model = {
|
|
|
+ // catid: list[list.length - 1],
|
|
|
+ // specid: id,
|
|
|
+ // spec_value: value,
|
|
|
+ // };
|
|
|
+ // let res = await asyncRequest.specinfoadd(model);
|
|
|
+ // if (res.code === 0) {
|
|
|
+ // await this.specByCat(true);
|
|
|
+ // }
|
|
|
+ // },
|
|
|
+ // dealWitHInitMock(list, type) {
|
|
|
+ // console.log(list, type);
|
|
|
+ // if (!type) {
|
|
|
+ // this.mock = [];
|
|
|
+ // console.log("12345678");
|
|
|
+ // console.log(this.mock);
|
|
|
+
|
|
|
+ // this.left.header = [];
|
|
|
+ // this.left.specList = [];
|
|
|
+ // this.right.header = [];
|
|
|
+ // this.right.specList = [];
|
|
|
+ // list.map((v1) => {
|
|
|
+ // v1.value = "";
|
|
|
+ // v1.change = [];
|
|
|
+ // return v1;
|
|
|
+ // });
|
|
|
+ // this.mock = list;
|
|
|
+ // console.log(this.mock);
|
|
|
+ // this.mock.forEach((v3, i) => {
|
|
|
+ // this.$set(this.mock, i, v3);
|
|
|
+ // });
|
|
|
+ // } else {
|
|
|
+ // let arr = JSON.parse(JSON.stringify(this.mock));
|
|
|
+ // list.map((v1) => {
|
|
|
+ // v1.value = "";
|
|
|
+ // let index = arr.findIndex((v2) => v2.spec_id === v1.spec_id);
|
|
|
+ // if (index !== -1) {
|
|
|
+ // v1.change = arr[index].change;
|
|
|
+ // }
|
|
|
+ // return v1;
|
|
|
+ // });
|
|
|
+ // this.mock = list;
|
|
|
+ // this.mock.forEach((v3, i) => {
|
|
|
+ // this.$set(this.mock, i, v3);
|
|
|
+ // });
|
|
|
+ // }
|
|
|
+ // },
|
|
|
+ // async getAllbrandid() {
|
|
|
+ // const res = await asyncRequest.brandAll({});
|
|
|
+ // if (res.code === 0 && res.data) {
|
|
|
+ // this.brandidOptions = res.data;
|
|
|
+ // }
|
|
|
+ // },
|
|
|
+ // async getAllCat() {
|
|
|
+ // const res = await asyncRequest.catAll({});
|
|
|
+ // if (res.code === 0 && res.data) {
|
|
|
+ // let list = res.data;
|
|
|
+ // list.map((v1) => {
|
|
|
+ // v1.value = v1.id;
|
|
|
+ // v1.label = v1.cat_name;
|
|
|
+ // if (v1.child && v1.child.length > 0) {
|
|
|
+ // v1.child.map((v2) => {
|
|
|
+ // v2.value = v2.id;
|
|
|
+ // v2.label = v2.cat_name;
|
|
|
+ // if (v2.child && v2.child.length > 0) {
|
|
|
+ // v2.child.map((v3) => {
|
|
|
+ // v3.value = v3.id;
|
|
|
+ // v3.label = v3.cat_name;
|
|
|
+ // return v3;
|
|
|
+ // });
|
|
|
+ // v2.children = v2.child;
|
|
|
+ // }
|
|
|
+ // return v2;
|
|
|
+ // });
|
|
|
+ // v1.children = v1.child;
|
|
|
+ // }
|
|
|
+
|
|
|
+ // return v1;
|
|
|
+ // });
|
|
|
+ // this.catOptions = list;
|
|
|
+ // }
|
|
|
+ // },
|
|
|
+ // async getAllSupplier() {
|
|
|
+ // const res = await asyncRequest.supplierAll({});
|
|
|
+ // if (res.code === 0 && res.data) {
|
|
|
+ // let list = res.data;
|
|
|
+ // this.supplierOptions = list;
|
|
|
+ // }
|
|
|
+ // },
|
|
|
+ //图片上传失败
|
|
|
+ UploadErrorEvent() {
|
|
|
+ this.$message.error("图片上传失败!");
|
|
|
+ this.$refs.ruleForm.validateField("image");
|
|
|
+ },
|
|
|
+ closeImg(index) {
|
|
|
+ this.ruleForm.image.splice(index, 1);
|
|
|
+ this.$refs.ruleForm.validateField("image");
|
|
|
+ },
|
|
|
+ //图片上传成功
|
|
|
+ UploadSuccessEvent(data) {
|
|
|
+ console.log(data);
|
|
|
+ this.ruleForm.image.push(data.url);
|
|
|
+ this.$message.success("图片上传成功!");
|
|
|
+ this.$refs.ruleForm.validateField("image");
|
|
|
+ },
|
|
|
+ //判断图片规格
|
|
|
+ beforeAvatarUpload(file) {
|
|
|
+ console.log(file);
|
|
|
+ let isJPG = false;
|
|
|
+ if (
|
|
|
+ file.type === "image/jpg" ||
|
|
|
+ file.type === "image/png" ||
|
|
|
+ file.type === "image/bmp" ||
|
|
|
+ file.type === "image/jpeg" ||
|
|
|
+ file.type === "image/gif"
|
|
|
+ ) {
|
|
|
+ isJPG = true;
|
|
|
+ }
|
|
|
+ const isLt2M = file.size / 1024 / 1024 < 1;
|
|
|
+ if (!isJPG) {
|
|
|
+ this.$message.error("图片格式不正确!");
|
|
|
+ }
|
|
|
+ if (!isLt2M) {
|
|
|
+ this.$message.error("图片大小不能超过 1MB!");
|
|
|
+ }
|
|
|
+ return isJPG && isLt2M;
|
|
|
+ },
|
|
|
+ doExchange(arr) {
|
|
|
+ let len = arr.length;
|
|
|
+ // 当数组大于等于2个的时候
|
|
|
+ if (len >= 2) {
|
|
|
+ // 第一个数组的长度
|
|
|
+ let len1 = arr[0].length;
|
|
|
+ // 第二个数组的长度
|
|
|
+ let len2 = arr[1].length;
|
|
|
+ // 2个数组产生的组合数
|
|
|
+ let lenBoth = len1 * len2;
|
|
|
+ // 申明一个新数组
|
|
|
+ let items = new Array(lenBoth);
|
|
|
+ // 申明新数组的索引
|
|
|
+ let index = 0;
|
|
|
+ for (let i = 0; i < len1; i++) {
|
|
|
+ for (let j = 0; j < len2; j++) {
|
|
|
+ if (arr[0][i] instanceof Array) {
|
|
|
+ items[index] = arr[0][i].concat(arr[1][j]);
|
|
|
+ } else {
|
|
|
+ items[index] = [arr[0][i]].concat(arr[1][j]);
|
|
|
+ }
|
|
|
+ index++;
|
|
|
+ }
|
|
|
+ }
|
|
|
+ let newArr = new Array(len - 1);
|
|
|
+ for (let i = 2; i < arr.length; i++) {
|
|
|
+ newArr[i - 1] = arr[i];
|
|
|
+ }
|
|
|
+ newArr[0] = items;
|
|
|
+ return this.doExchange(newArr);
|
|
|
+ } else {
|
|
|
+ return arr[0];
|
|
|
+ }
|
|
|
+ },
|
|
|
+ },
|
|
|
+ watch: {},
|
|
|
+};
|
|
|
+</script>
|
|
|
+ <style lang="scss" scoped>
|
|
|
+.goodsCostAdd {
|
|
|
+ .goodsCostAdd-title {
|
|
|
+ border-top: 1px solid #ebeef5;
|
|
|
+ span {
|
|
|
+ height: 50px;
|
|
|
+ line-height: 50px;
|
|
|
+ font-family: "微软雅黑", sans-serif;
|
|
|
+ font-weight: 400;
|
|
|
+ font-style: normal;
|
|
|
+ font-size: 16fpx;
|
|
|
+ text-align: left;
|
|
|
+ }
|
|
|
+ }
|
|
|
+}
|
|
|
+</style>
|
|
|
+
|