浏览代码

新功能

潘超林 3 周之前
父节点
当前提交
02c68cdcc4

+ 94 - 0
src/api/manage/material.js

@@ -0,0 +1,94 @@
+import request from '@/utils/request'
+
+export function getCity(query) {
+    return request({
+        url: '/getCity',
+        method: 'get',
+        params: query
+    })
+}
+export function getCityTree(query) {
+    return request({
+        url: '/getCityTree',
+        method: 'get',
+        params: query
+    })
+}
+
+export function addFreightTemplate(query) {
+    return request({
+        url: '/system/freightTemplate/addFreightTemplate',
+        method: 'post',
+        data: query
+    })
+}
+
+export function getFreightTemplate(query) {
+    return request({
+        url: '/system/freightTemplate/getFreightTemplate',
+        method: 'get',
+        params: query
+    })
+}
+
+
+export function copyFreightTemplate(query) {
+    return request({
+        url: '/system/freightTemplate/copyFreightTemplate',
+        method: 'post',
+        data: query
+    })
+}
+
+
+export function freightTemplateEdit(query) {
+    return request({
+        url: '/system/freightTemplate/edit',
+        method: 'post',
+        data: query
+    })
+}
+
+export function removeDetail(query) {
+    return request({
+        url: '/system/freightTemplate/removeDetail',
+        method: 'post',
+        data: query
+    })
+}
+
+export function freightTemplateRemove(query) {
+    return request({
+        url: '/system/freightTemplate/remove',
+        method: 'post',
+        data: query
+    })
+}
+
+
+
+export function riderDeliveryTemplateget(query) {
+    return request({
+        url: '/system/riderDeliveryTemplate/get',
+        method: 'get',
+        params: query
+    })
+}
+
+export function riderDeliveryTemplateAdd(query) {
+    return request({
+        url: '/system/riderDeliveryTemplate/add',
+        method: 'post',
+        data: query
+    })
+}
+
+
+
+export function riderDeliveryTemplateRemove(query) {
+    return request({
+        url: '/system/riderDeliveryTemplate/delete',
+        method: 'post',
+        data: query
+    })
+}

+ 507 - 0
src/views/material/addMaterial.vue

@@ -0,0 +1,507 @@
+<template>
+  <div class="app-container">
+    <h4>新增运费模版</h4>
+    <el-row :gutter="20">
+      <!--用户数据-->
+      <el-col :span="24" :xs="24">
+        <el-form
+          :model="form"
+          ref="queryForm"
+          size="small"
+          :inline="true"
+          :rules="rules"
+          label-width="100px"
+        >
+          <el-form-item prop="templateName">
+            <span slot="label">模板名称</span>
+            <el-input
+              v-model="form.templateName"
+              placeholder="请输入模板名称"
+              clearable
+              style="width: 260px"
+              maxlength="20"
+              show-word-limit
+            />
+          </el-form-item>
+          <br />
+          <el-form-item label="发货地" prop="cityInfo">
+            <el-select
+              v-model="form.provinceInfo"
+              @change="provinceChange"
+              placeholder="请选择省"
+            >
+              <el-option
+                v-for="item in province"
+                :key="item.cityId"
+                :label="item.name"
+                :value="{ value: item.cityId, label: item.name }"
+              >
+              </el-option>
+            </el-select>
+
+            <el-select
+              v-model="form.cityInfo"
+              placeholder="请选择市"
+              @change="cityChange"
+            >
+              <el-option
+                v-for="item in city"
+                :key="item.cityId"
+                :label="item.name"
+                :value="{ value: item.cityId, label: item.name }"
+              >
+              </el-option>
+            </el-select>
+
+            <el-select
+              v-model="form.areaInfo"
+              placeholder="请选择区"
+              @change="areaChange"
+            >
+              <el-option
+                v-for="item in area"
+                :key="item.cityId"
+                :label="item.name"
+                :value="{ value: item.cityId, label: item.name }"
+              >
+              </el-option>
+            </el-select>
+          </el-form-item>
+          <br />
+          <el-form-item label="是否包邮" prop="freeShipping">
+            <el-radio-group v-model="form.freeShipping">
+              <el-radio :label="0" :value="0">自定义运费</el-radio>
+              <el-radio :label="1" :value="1">包邮</el-radio>
+            </el-radio-group>
+          </el-form-item>
+          <br />
+          <el-form-item
+            label="计件方式"
+            prop="claType"
+            v-if="form.freeShipping == 0"
+          >
+            <el-radio-group v-model="form.claType">
+              <el-radio :label="0" :value="0">按重量</el-radio>
+              <el-radio :label="1" :value="1">按件数</el-radio>
+            </el-radio-group>
+          </el-form-item>
+        </el-form>
+        <el-table
+          v-if="form.freeShipping == 0"
+          :data="tableData"
+          style="width: 100%"
+          :header-cell-style="{ 'text-align': 'center', background: '#eef1f6' }"
+          border
+        >
+          <el-table-column prop="receiveCityJson" label="送达地区" width="800">
+            <template slot-scope="scope">
+              <span v-if="scope.row.isDefault == 0">
+                {{ scope.row.receiveCityJson }}
+              </span>
+              <span
+                v-else
+                v-for="(item, index) in scope.row.receiveCityJson
+                  ? JSON.parse(scope.row.receiveCityJson)
+                  : []"
+                :key="index"
+              >
+                <div>
+                  {{ item.provinceName }}
+                  (<span v-for="(item, index) in item.cityList" :key="index">
+                    {{ item.cityName }}
+                  </span>
+                  )
+                </div>
+              </span>
+            </template>
+          </el-table-column>
+          <el-table-column
+            align="center"
+            width="180"
+            :label="form.claType == 1 ? '首重件数' : '首重重量(kg)'"
+          >
+            <template slot-scope="scope">
+              <el-input
+                v-model="scope.row.firstWeight"
+                :placeholder="
+                  form.claType == 1 ? '请输入首重件数' : '请输入首重重量'
+                "
+              ></el-input>
+            </template>
+          </el-table-column>
+          <el-table-column
+            align="center"
+            width="180"
+            :label="form.claType == 1 ? '首件价格(元)' : '首重价格(元)'"
+          >
+            <template slot-scope="scope">
+              <el-input
+                v-model="scope.row.firstWeightPrice"
+                :placeholder="
+                  form.claType == 1 ? '请输入首件价格' : '请输入首重价格'
+                "
+              ></el-input>
+            </template>
+          </el-table-column>
+          <el-table-column
+            align="center"
+            :label="form.claType == 1 ? '续件件数' : '续重重量(kg)'"
+          >
+            <template slot-scope="scope">
+              <el-input
+                v-model="scope.row.lastWeight"
+                :placeholder="
+                  form.claType == 1 ? '请输入续件件数' : '请输入续重重量'
+                "
+              ></el-input>
+            </template>
+          </el-table-column>
+          <el-table-column
+            align="center"
+            :label="form.claType == 1 ? '续件价格' : '续重价格(元)'"
+          >
+            <template slot-scope="scope">
+              <el-input
+                v-model="scope.row.lastWeightPrice"
+                :placeholder="
+                  form.claType == 1 ? '请输入续件价格' : '请输入续重价格'
+                "
+              ></el-input>
+            </template>
+          </el-table-column>
+          <el-table-column align="center" label="操作">
+            <template slot-scope="scope">
+              <el-button
+                type="text"
+                v-if="scope.$index != 0"
+                style="color: red"
+                @click="remove(scope.$index)"
+                >删除</el-button
+              >
+            </template>
+          </el-table-column>
+        </el-table>
+
+        <el-button type="text" @click="appoint">为指定城市设置运费</el-button>
+        <!-- <span>为指定城市设置运费</span> -->
+      </el-col>
+      <div style="text-align: center">
+        <el-button type="primary" @click="submitTemplate">确 定</el-button>
+        <el-button @click="cancal">取 消</el-button>
+      </div>
+    </el-row>
+
+    <el-dialog title="设置重量" :visible.sync="open" width="600px">
+      <el-form ref="form" :model="form" label-width="80px">
+        <el-row>
+          <el-col :span="24">
+            <el-form-item label="重量区间">
+              <el-input
+                v-model="form.secondStartWeight"
+                placeholder="请输入续重开始"
+                style="width: 160px"
+              >
+                <template slot="suffix"> /Kg </template> </el-input
+              >--
+              <el-input
+                v-model="form.secondEndWeight"
+                placeholder="请输入续重结束"
+                style="width: 160px"
+              >
+                <template slot="suffix"> /Kg </template></el-input
+              >
+            </el-form-item>
+          </el-col>
+        </el-row>
+      </el-form>
+      <div slot="footer" class="dialog-footer">
+        <el-button type="primary" @click="submitForm">确 定</el-button>
+        <el-button @click="open = false">取 消</el-button>
+      </div>
+    </el-dialog>
+    <el-dialog title="设置首重" :visible.sync="szopen" width="600px">
+      <el-form ref="form" :model="form" label-width="80px">
+        <el-row>
+          <el-col :span="24">
+            <el-form-item label="首重">
+              <el-input
+                v-model="form.firstWeight"
+                placeholder="请输入首重"
+                style="width: 160px"
+              >
+                <template slot="suffix"> /Kg </template>
+              </el-input>
+            </el-form-item>
+          </el-col>
+        </el-row>
+      </el-form>
+      <div slot="footer" class="dialog-footer">
+        <el-button type="primary" @click="submitFormsz">确 定</el-button>
+        <el-button @click="szopen = false">取 消</el-button>
+      </div>
+    </el-dialog>
+
+    <!-- 添加或修改用户配置对话框 -->
+    <el-dialog
+      title="选择区域"
+      :visible.sync="areaOpen"
+      width="900px"
+      :destroy-on-close="true"
+    >
+      <el-form ref="form" :model="form" label-width="80px">
+        <el-row>
+          <!-- <el-col :span="8" v-for="(item, index) in areaList" :key="index"> -->
+          <el-tree
+            @check="handleNodeClick"
+            ref="tree"
+            :data="areaList"
+            show-checkbox
+            node-key="cityId"
+            :props="{ children: 'cityList', label: 'name' }"
+          >
+          </el-tree>
+          <!-- </el-col> -->
+        </el-row>
+      </el-form>
+      <div slot="footer" class="dialog-footer">
+        <el-button type="primary" @click="areaSubmit">确 定</el-button>
+        <el-button @click="areaOpen = false">取 消</el-button>
+      </div>
+    </el-dialog>
+  </div>
+</template>
+
+<script>
+import {
+  getCity,
+  getCityTree,
+  addFreightTemplate,
+} from "@/api/manage/material";
+export default {
+  data() {
+    return {
+      form: {
+        unit: "kg",
+        expressType: 0,
+        firstWeight: "",
+      },
+      open: false,
+      areaOpen: false,
+      szopen: false,
+      tableData: [
+        {
+          firstWeight: "1",
+          firstWeightPrice: "",
+          isDefault: "0",
+          lastWeight: "",
+          lastWeightPrice: "",
+          receiveCityJson: "默认运费(未添加地区运费根据默认运费计算)",
+          secondEndWeight: "",
+          secondStartWeight: "",
+          secondWeightPrice: "",
+          unit: "kg",
+        },
+      ],
+      province: [],
+      city: [],
+      areaList: [],
+      areaSelectList: [],
+      areaCheckList: [],
+      area: [],
+      rules: {
+        templateName: [
+          { required: true, message: "模板名称不能为空", trigger: "blur" },
+        ],
+        provinceInfo: [
+          { required: true, message: "发货地不能为空", trigger: "blur" },
+        ],
+        cityInfo: [
+          { required: true, message: "发货地不能为空", trigger: "blur" },
+        ],
+        claType: [
+          { required: true, message: "计费类型不能为空", trigger: "blur" },
+        ],
+        freeShipping: [
+          { required: true, message: "请选择是否包邮", trigger: "blur" },
+        ],
+      },
+    };
+  },
+  created() {
+    this.getProvince();
+  },
+  methods: {
+    submitTemplate() {
+      this.$refs.queryForm.validate((valid) => {
+        if (valid) {
+          let titleBoolean = false;
+          this.form.detailList = this.tableData;
+          let title = "";
+          if (titleBoolean) {
+            title =
+              "部分城市还未设置运费,如不设置,这部分运费将根据默认运费计算,是否确认保存?";
+          } else {
+            title = "是否确认保存该模版?";
+          }
+          this.$confirm(title, "提示", {
+            confirmButtonText: "确定",
+            cancelButtonText: "取消",
+            type: "warning",
+          }).then(() => {
+            addFreightTemplate(this.form).then((res) => {
+              if (res.code == 200) {
+                this.$message.success("添加成功");
+                this.$store.dispatch("tagsView/delView", this.$route); //关闭当前页
+                this.$router.replace({ path: "/product/material/index" });
+              }
+            });
+          });
+        } else {
+          return false;
+        }
+      });
+    },
+    remove(index) {
+      this.tableData.splice(index, 1);
+    },
+    cancal() {
+      this.$confirm("是否取消,取消后所填写信息不会保存", "提示", {
+        confirmButtonText: "确定",
+        cancelButtonText: "取消",
+        type: "warning",
+      }).then(() => {
+        this.$store.dispatch("tagsView/delView", this.$route); //关闭当前页
+        this.$router.replace({ path: "/product/material/index" });
+      });
+    },
+    handleNodeClick(node, item) {
+      console.log(item);
+      this.areaCheckList = [];
+      item.checkedNodes.forEach((e) => {
+        if (e.cityList) {
+          this.areaCheckList.push(e);
+        } else {
+          for (let i = 0; i < item.halfCheckedNodes.length; i++) {
+            let city = item.halfCheckedNodes[i].cityList;
+            let list = [];
+            for (let c = 0; c < city.length; c++) {
+              for (let n = 0; n < item.checkedNodes.length; n++) {
+                if (city[c].code == item.checkedNodes[n].code) {
+                  list.push(item.checkedNodes[n]);
+                }
+              }
+            }
+            let params = {
+              name: item.halfCheckedNodes[i].name,
+              code: item.halfCheckedNodes[i].code,
+              cityList: list,
+            };
+            this.areaCheckList.push(params);
+          }
+        }
+      });
+      this.areaCheckList = this.unique(this.areaCheckList);
+    },
+
+    areaSubmit() {
+      let aalist = [];
+      this.areaCheckList.forEach((e) => {
+        let children = e.cityList.map((item) => ({
+          cityCode: item.code,
+          cityName: item.name,
+        }));
+        aalist.push({
+          provinceCode: e.code,
+          provinceName: e.name,
+          cityList: children,
+        });
+      });
+      // aalist.forEach((e) => {
+      this.tableData.push({
+        firstWeight: "",
+        firstWeightPrice: "",
+        isDefault: "1",
+        lastWeight: "",
+        lastWeightPrice: "",
+        receiveCityJson: JSON.stringify(aalist),
+        unit: "kg",
+      });
+      // });
+      this.areaOpen = false;
+    },
+
+    unique(arr) {
+      const res = new Map();
+      return arr.filter((item) => !res.has(item.code) && res.set(item.code, 1));
+    },
+    appoint() {
+      this.areaOpen = true;
+    },
+    submitFormsz() {
+      this.form.secondStartWeight = this.form.firstWeight;
+      this.szopen = false;
+    },
+    submitForm() {
+      this.form.lastWeight = this.form.secondEndWeight;
+      this.open = false;
+    },
+    continueSz() {
+      this.szopen = true;
+    },
+    continueCk() {
+      this.open = true;
+    },
+
+    areaChange(val) {
+      this.form.sendAreaName = val.label;
+      this.form.sendAreaCode = val.value;
+    },
+    cityChange(val) {
+      this.form.sendCityName = val.label;
+      this.form.sendCityCode = val.value;
+      getCity({ parentCityId: val.value }).then((res) => {
+        if (res.code == 200) {
+          console.log(res);
+          this.area = res.data;
+        }
+      });
+    },
+    provinceChange(val) {
+      console.log(val);
+      this.form.sendProvinceName = val.label;
+      this.form.sendProvinceCode = val.value;
+      getCity({ parentCityId: val.value }).then((res) => {
+        if (res.code == 200) {
+          this.city = res.data;
+        }
+      });
+    },
+    getProvince(val) {
+      getCity().then((res) => {
+        if (res.code == 200) {
+          this.province = res.data;
+          getCityTree().then((res) => {
+            if (res.code == 200) {
+              this.areaList = res.data;
+            }
+          });
+        }
+      });
+    },
+  },
+};
+</script>
+
+<style>
+.el-tree {
+  display: flex;
+  flex-direction: row;
+  flex-wrap: wrap;
+  justify-content: flex-start;
+}
+.el-tree-node {
+  white-space: nowrap;
+  outline: none;
+  width: 150px;
+}
+</style>

+ 565 - 0
src/views/material/editMaterial.vue

@@ -0,0 +1,565 @@
+<template>
+  <div class="app-container">
+    <h4>新增运费模版</h4>
+    <el-row :gutter="20">
+      <!--用户数据-->
+      <el-col :span="24" :xs="24">
+        <el-form
+          :model="form"
+          ref="queryForm"
+          size="small"
+          :inline="true"
+          :rules="rules"
+          label-width="100px"
+        >
+          <el-form-item prop="templateName">
+            <span slot="label">模板名称</span>
+            <el-input
+              v-model="form.templateName"
+              placeholder="请输入模板名称"
+              clearable
+              style="width: 260px"
+              maxlength="20"
+              show-word-limit
+            />
+          </el-form-item>
+          <br />
+          <el-form-item label="发货地" prop="cityInfo">
+            <el-select
+              v-model="form.provinceInfo"
+              @change="provinceChange"
+              :placeholder="p ? p : '请选择省'"
+            >
+              <el-option
+                v-for="item in province"
+                :key="item.cityId"
+                :label="item.name"
+                :value="{ value: item.cityId, label: item.name }"
+              >
+              </el-option>
+            </el-select>
+
+            <el-select
+              v-model="form.cityInfo"
+              :placeholder="s ? s : '请选择市'"
+              @change="cityChange"
+            >
+              <el-option
+                v-for="item in city"
+                :key="item.cityId"
+                :label="item.name"
+                :value="{ value: item.cityId, label: item.name }"
+              >
+              </el-option>
+            </el-select>
+
+            <el-select
+              v-model="form.areaInfo"
+              :placeholder="q ? q : '请选择区'"
+              @change="areaChange"
+            >
+              <el-option
+                v-for="item in area"
+                :key="item.cityId"
+                :label="item.name"
+                :value="{ value: item.cityId, label: item.name }"
+              >
+              </el-option>
+            </el-select>
+          </el-form-item>
+          <br />
+          <el-form-item label="是否包邮" prop="freeShipping">
+            <el-radio-group v-model="form.freeShipping">
+              <el-radio :label="0" :value="0">自定义运费</el-radio>
+              <el-radio :label="1" :value="1">包邮</el-radio>
+            </el-radio-group>
+          </el-form-item>
+          <br />
+          <el-form-item
+            label="计件方式"
+            prop="claType"
+            v-if="form.freeShipping == 0"
+          >
+            <el-radio-group v-model="form.claType">
+              <el-radio :label="0" :value="0">按重量</el-radio>
+              <el-radio :label="1" :value="1">按件数</el-radio>
+            </el-radio-group>
+          </el-form-item>
+        </el-form>
+        <el-table
+          v-if="form.freeShipping == 0"
+          :data="tableData"
+          style="width: 100%"
+          :header-cell-style="{ 'text-align': 'center', background: '#eef1f6' }"
+          border
+        >
+          <el-table-column prop="receiveCityJson" label="送达地区" width="800">
+            <template slot-scope="scope">
+              <span v-if="scope.row.isDefault == 0">
+                {{ scope.row.receiveCityJson }}
+              </span>
+              <span
+                v-else
+                v-for="(item, index) in scope.row.receiveCityJson
+                  ? JSON.parse(scope.row.receiveCityJson)
+                  : []"
+                :key="index"
+              >
+                <div>
+                  {{ item.provinceName }}
+                  (<span v-for="(item, index) in item.cityList" :key="index">
+                    {{ item.cityName }}
+                  </span>
+                  )
+                </div>
+              </span>
+            </template>
+          </el-table-column>
+          <el-table-column
+            align="center"
+            width="180"
+            :label="form.claType == 1 ? '首重件数' : '首重重量(kg)'"
+          >
+            <template slot-scope="scope">
+              <el-input
+                v-model="scope.row.firstWeight"
+                :placeholder="
+                  form.claType == 1 ? '请输入首重件数' : '请输入首重重量'
+                "
+              ></el-input>
+            </template>
+          </el-table-column>
+          <el-table-column
+            align="center"
+            width="180"
+            :label="form.claType == 1 ? '首件价格(元)' : '首重价格(元)'"
+          >
+            <template slot-scope="scope">
+              <el-input
+                v-model="scope.row.firstWeightPrice"
+                :placeholder="
+                  form.claType == 1 ? '请输入首件价格' : '请输入首重价格'
+                "
+              ></el-input>
+            </template>
+          </el-table-column>
+          <el-table-column
+            align="center"
+            :label="form.claType == 1 ? '续件件数' : '续重重量(kg)'"
+          >
+            <template slot-scope="scope">
+              <el-input
+                v-model="scope.row.lastWeight"
+                :placeholder="
+                  form.claType == 1 ? '请输入续件件数' : '请输入续重重量'
+                "
+              ></el-input>
+            </template>
+          </el-table-column>
+          <el-table-column
+            align="center"
+            :label="form.claType == 1 ? '续件价格' : '续重价格(元)'"
+          >
+            <template slot-scope="scope">
+              <el-input
+                v-model="scope.row.lastWeightPrice"
+                :placeholder="
+                  form.claType == 1 ? '请输入续件价格' : '请输入续重价格'
+                "
+              ></el-input>
+            </template>
+          </el-table-column>
+          <el-table-column align="center" label="操作">
+            <template slot-scope="scope">
+              <el-button
+                type="text"
+                v-if="scope.$index != 0"
+                style="color: red"
+                @click="remove(scope.row, scope.$index)"
+                >删除</el-button
+              >
+            </template>
+          </el-table-column>
+        </el-table>
+
+        <el-button type="text" @click="appoint">为指定城市设置运费</el-button>
+        <!-- <span>为指定城市设置运费</span> -->
+      </el-col>
+      <div style="text-align: center">
+        <el-button type="primary" @click="submitTemplate">确 定</el-button>
+        <el-button @click="cancal">取 消</el-button>
+      </div>
+    </el-row>
+
+    <el-dialog title="设置重量" :visible.sync="open" width="600px">
+      <el-form ref="form" :model="form" label-width="80px">
+        <el-row>
+          <el-col :span="24">
+            <el-form-item label="重量区间">
+              <el-input
+                v-model="form.secondStartWeight"
+                placeholder="请输入续重开始"
+                style="width: 160px"
+              >
+                <template slot="suffix"> /Kg </template> </el-input
+              >--
+              <el-input
+                v-model="form.secondEndWeight"
+                placeholder="请输入续重结束"
+                style="width: 160px"
+              >
+                <template slot="suffix"> /Kg </template></el-input
+              >
+            </el-form-item>
+          </el-col>
+        </el-row>
+      </el-form>
+      <div slot="footer" class="dialog-footer">
+        <el-button type="primary" @click="submitForm">确 定</el-button>
+        <el-button @click="open = false">取 消</el-button>
+      </div>
+    </el-dialog>
+    <el-dialog title="设置首重" :visible.sync="szopen" width="600px">
+      <el-form ref="form" :model="form" label-width="80px">
+        <el-row>
+          <el-col :span="24">
+            <el-form-item label="首重">
+              <el-input
+                v-model="form.firstWeight"
+                placeholder="请输入首重"
+                style="width: 160px"
+              >
+                <template slot="suffix"> /Kg </template>
+              </el-input>
+            </el-form-item>
+          </el-col>
+        </el-row>
+      </el-form>
+      <div slot="footer" class="dialog-footer">
+        <el-button type="primary" @click="submitFormsz">确 定</el-button>
+        <el-button @click="szopen = false">取 消</el-button>
+      </div>
+    </el-dialog>
+
+    <!-- 添加或修改用户配置对话框 -->
+    <el-dialog
+      title="选择区域"
+      :visible.sync="areaOpen"
+      width="900px"
+      :destroy-on-close="true"
+    >
+      <el-form ref="form" :model="form" label-width="80px">
+        <el-row>
+          <!-- <el-col :span="8" v-for="(item, index) in areaList" :key="index"> -->
+          <el-tree
+            @check="handleNodeClick"
+            ref="tree"
+            :data="areaList"
+            show-checkbox
+            node-key="cityId"
+            :props="{ children: 'cityList', label: 'name' }"
+          >
+          </el-tree>
+          <!-- </el-col> -->
+        </el-row>
+      </el-form>
+      <div slot="footer" class="dialog-footer">
+        <el-button type="primary" @click="areaSubmit">确 定</el-button>
+        <el-button @click="areaOpen = false">取 消</el-button>
+      </div>
+    </el-dialog>
+  </div>
+</template>
+
+<script>
+import {
+  getCity,
+  getCityTree,
+  freightTemplateEdit,
+  removeDetail,
+} from "@/api/manage/material";
+export default {
+  data() {
+    return {
+      szopen: false,
+      form: {
+        unit: "kg",
+        expressType: 0,
+        firstWeight: "",
+      },
+      open: false,
+      areaOpen: false,
+      tableData: [
+        {
+          firstWeight: "1",
+          firstWeightPrice: "",
+          isDefault: "0",
+          lastWeight: "",
+          lastWeightPrice: "",
+          receiveCityJson: "默认运费(未添加地区运费根据默认运费计算)",
+          secondEndWeight: "",
+          secondStartWeight: "",
+          secondWeightPrice: "",
+          unit: "kg",
+        },
+      ],
+      province: [],
+      city: [],
+      provinceInfo: "",
+      cityInfo: "",
+      areaList: [],
+      area: [],
+      areaSelectList: [],
+      areaCheckList: [],
+      p: "",
+      s: "",
+      q: "",
+      rules: {
+        templateName: [
+          { required: true, message: "模板名称不能为空", trigger: "blur" },
+        ],
+        provinceInfo: [
+          { required: true, message: "发货地不能为空", trigger: "blur" },
+        ],
+        cityInfo: [
+          { required: true, message: "发货地不能为空", trigger: "blur" },
+        ],
+        claType: [
+          { required: true, message: "计费类型不能为空", trigger: "blur" },
+        ],
+        freeShipping: [
+          { required: true, message: "请选择是否包邮", trigger: "blur" },
+        ],
+      },
+    };
+  },
+  created() {},
+  mounted() {
+    this.form = this.$route.query;
+    this.GetprovinceChange(
+      this.form.sendProvinceCode,
+      this.form.sendCityCode,
+      this.form.sendAreaCode
+    );
+    this.form.freeShipping = parseInt(this.form.freeShipping);
+    this.form.claType = parseInt(this.form.claType);
+    this.tableData = this.$route.query.detailList;
+  },
+  methods: {
+    GetprovinceChange(p, s, q) {
+      getCityTree().then((res) => {
+        if (res.code == 200) {
+          this.areaList = res.data;
+        }
+      });
+      getCity().then((res) => {
+        if (res.code == 200) {
+          this.province = res.data;
+          getCity({ parentCityId: p }).then((res) => {
+            if (res.code == 200) {
+              this.city = res.data;
+              getCity({ parentCityId: s }).then((res) => {
+                if (res.code == 200) {
+                  this.area = res.data;
+                  this.$set(this.form, "provinceInfo", {
+                    label: this.form.sendProvinceName,
+                    value: this.form.sendProvinceCode,
+                  });
+                  this.$set(this.form, "cityInfo", {
+                    label: this.form.sendCityName,
+                    value: this.form.sendCityCode,
+                  });
+                  this.$set(this.form, "areaInfo", {
+                    label: this.form.sendAreaName,
+                    value: this.form.sendAreaCode,
+                  });
+                }
+              });
+            }
+          });
+        }
+      });
+
+      console.log("city", this.city);
+      console.log("arae", this.area);
+    },
+
+    submitFormsz() {
+      this.szopen = false;
+    },
+    submitTemplate() {
+      this.$refs.queryForm.validate((valid) => {
+        if (valid) {
+          this.form.detailList = this.tableData;
+          console.log(this.tableData);
+          let titleBoolean = false;
+          this.tableData.forEach((e) => {
+            e.firstWeight = this.form.firstWeight;
+            e.secondEndWeight = this.form.secondEndWeight;
+            e.secondStartWeight = this.form.secondStartWeight;
+            for (const key in e) {
+              if (e[key] == "") {
+                titleBoolean = true;
+              }
+            }
+          });
+          let title = "";
+          if (titleBoolean) {
+            title = "是否确认编辑保存?";
+          } else {
+            title = "是否确认保存该模版?";
+          }
+          this.$confirm(title, "提示", {
+            confirmButtonText: "确定",
+            cancelButtonText: "取消",
+            type: "warning",
+          }).then(() => {
+            freightTemplateEdit(this.form).then((res) => {
+              if (res.code == 200) {
+                this.$message.success("修改成功!");
+                this.$store.dispatch("tagsView/delView", this.$route); //关闭当前页
+                this.$router.replace({ path: "/product/material/index" });
+              }
+            });
+          });
+        }
+      });
+    },
+    remove(record, index) {
+      if (record.id) {
+        removeDetail({ id: record.id }).then((res) => {
+          if (res.code == 200) {
+            this.$message.success("删除成功");
+            this.tableData.splice(index, 1);
+          }
+        });
+      } else {
+        this.tableData.splice(index, 1);
+      }
+    },
+    cancal() {
+      this.$confirm("是否取消,取消后所填写信息不会保存", "提示", {
+        confirmButtonText: "确定",
+        cancelButtonText: "取消",
+        type: "warning",
+      }).then(() => {
+        this.$store.dispatch("tagsView/delView", this.$route); //关闭当前页
+        this.$router.replace({ path: "/product/material/index" });
+      });
+    },
+    handleNodeClick(node, item) {
+      console.log(item);
+      this.areaCheckList = [];
+      item.checkedNodes.forEach((e) => {
+        if (e.cityList) {
+          this.areaCheckList.push(e);
+        } else {
+          for (let i = 0; i < item.halfCheckedNodes.length; i++) {
+            let city = item.halfCheckedNodes[i].cityList;
+            let list = [];
+            for (let c = 0; c < city.length; c++) {
+              for (let n = 0; n < item.checkedNodes.length; n++) {
+                if (city[c].code == item.checkedNodes[n].code) {
+                  list.push(item.checkedNodes[n]);
+                }
+              }
+            }
+            let params = {
+              name: item.halfCheckedNodes[i].name,
+              code: item.halfCheckedNodes[i].code,
+              cityList: list,
+            };
+            this.areaCheckList.push(params);
+          }
+        }
+      });
+      this.areaCheckList = this.unique(this.areaCheckList);
+    },
+    continueSz() {
+      this.szopen = true;
+    },
+    areaSubmit() {
+      let aalist = [];
+      this.areaCheckList.forEach((e) => {
+        let children = e.cityList.map((item) => ({
+          cityCode: item.code,
+          cityName: item.name,
+        }));
+        aalist.push({
+          provinceCode: e.code,
+          provinceName: e.name,
+          cityList: children,
+        });
+      });
+      // aalist.forEach((e) => {
+      this.tableData.push({
+        firstWeight: "",
+        firstWeightPrice: "",
+        isDefault: "1",
+        lastWeight: "",
+        lastWeightPrice: "",
+        receiveCityJson: JSON.stringify(aalist),
+        unit: "kg",
+      });
+      // });
+      this.areaOpen = false;
+    },
+
+    unique(arr) {
+      const res = new Map();
+      return arr.filter((item) => !res.has(item.code) && res.set(item.code, 1));
+    },
+    appoint() {
+      this.areaOpen = true;
+    },
+    submitForm() {
+      this.form.lastWeight = this.form.secondEndWeight;
+      this.open = false;
+    },
+    continueCk() {
+      this.open = true;
+    },
+    areaChange(val) {
+      this.form.sendAreaName = val.label;
+      this.form.sendAreaCode = val.value;
+    },
+    cityChange(val) {
+      this.form.sendCityName = val.label;
+      this.form.sendCityCode = val.value;
+      getCity({ parentCityId: val.value }).then((res) => {
+        if (res.code == 200) {
+          console.log(res);
+          this.area = res.data;
+        }
+      });
+    },
+    provinceChange(val) {
+      console.log(val);
+      this.form.sendProvinceName = val.label;
+      this.form.sendProvinceCode = val.value;
+      getCity({ parentCityId: val.value }).then((res) => {
+        if (res.code == 200) {
+          this.city = res.data;
+        }
+      });
+    },
+  },
+};
+</script>
+
+<style>
+::v-deep .el-input__placeholder {
+  color: #000 !important; /* 自定义颜色 */
+}
+.el-tree {
+  display: flex;
+  flex-direction: row;
+  flex-wrap: wrap;
+  justify-content: flex-start;
+}
+.el-tree-node {
+  white-space: nowrap;
+  outline: none;
+  width: 150px;
+}
+</style>

+ 284 - 0
src/views/material/index.vue

@@ -0,0 +1,284 @@
+<template>
+  <div class="app-container">
+    <el-row :gutter="20">
+      <!--用户数据-->
+      <el-col :span="24" :xs="24">
+        <el-form
+          :model="queryParams"
+          ref="queryForm"
+          size="small"
+          :inline="true"
+          label-width="100px"
+        >
+          <el-form-item label="模板名称搜索" prop="key">
+            <el-input
+              v-model="queryParams.key"
+              placeholder="请输入模板名称"
+            ></el-input>
+          </el-form-item>
+          <el-form-item>
+            <el-button
+              type="primary"
+              icon="el-icon-search"
+              size="mini"
+              @click="handleQuery"
+              >搜索</el-button
+            >
+            <el-button icon="el-icon-refresh" size="mini" @click="resetQuery"
+              >重置</el-button
+            >
+          </el-form-item>
+        </el-form>
+        <el-button
+          type="primary"
+          size="mini"
+          @click="addTemplate"
+          style="margin-bottom: 10px"
+          >新增模版</el-button
+        >
+
+        <el-row>
+          <el-col
+            :span="24"
+            v-for="(item, index) in tableData"
+            :key="index"
+            style="margin-bottom: 20px"
+          >
+            <div
+              style="
+                padding: 5px 10px;
+                background: #0ea0df2e;
+                display: flex;
+                flex-direction: row;
+                justify-content: space-between;
+                align-items: center;
+              "
+            >
+              <div>
+                <div>
+                  发货地:{{ item.sendProvinceName }}{{ item.sendCityName
+                  }}{{ item.sendAreaName }}
+                </div>
+                <br />
+                <div>模板名称:{{ item.templateName }}</div>
+              </div>
+
+              <div>
+                <el-button type="text" @click="copyTemplate(item)"
+                  >复制模版</el-button
+                >
+                <el-button type="text" @click="editTemplate(item)"
+                  >编辑</el-button
+                >
+                <el-button
+                  type="text"
+                  style="color: red"
+                  @click="removeTemplate(item)"
+                  >删除</el-button
+                >
+              </div>
+            </div>
+            <el-table :data="item.detailList" style="width: 100%" border>
+              <el-table-column
+                prop="receiveCityJson"
+                label="送达地区"
+                width="800"
+              >
+                <template slot-scope="scope">
+                  <span v-if="scope.row.isDefault == 0">
+                    {{ scope.row.receiveCityJson }}
+                  </span>
+                  <span
+                    v-else
+                    v-for="(item, index) in scope.row.receiveCityJson
+                      ? JSON.parse(scope.row.receiveCityJson)
+                      : []"
+                    :key="index"
+                  >
+                    <div>
+                      {{ item.provinceName }}
+                      (<span
+                        v-for="(item, index) in item.cityList"
+                        :key="index"
+                      >
+                        {{ item.cityName }}
+                      </span>
+                      )
+                    </div>
+                  </span>
+                </template>
+              </el-table-column>
+              <el-table-column align="center" label="首重重量(kg)">
+                <template slot-scope="scope">
+                  {{ scope.row.firstWeight }}
+                </template>
+              </el-table-column>
+              <el-table-column align="center" label="首重价格(元)">
+                <template slot-scope="scope">
+                  {{ scope.row.firstWeightPrice }}
+                </template>
+              </el-table-column>
+              <el-table-column align="center" label="首重价格(元)">
+                <template slot-scope="scope">
+                  {{ scope.row.firstWeightPrice }}
+                </template>
+              </el-table-column>
+              <el-table-column align="center" label="续重重量(kg)">
+                <template slot-scope="scope">
+                  {{ scope.row.lastWeight }}
+                </template>
+              </el-table-column>
+              <el-table-column align="center" width="180" label="续重价格(元)">
+                <template slot-scope="scope">
+                  {{ scope.row.lastWeightPrice }}
+                </template>
+              </el-table-column>
+            </el-table>
+          </el-col>
+
+          <el-col :span="24" v-if="tableData.length < 1">
+            <el-result
+              icon="info"
+              title="暂无数据"
+              subTitle="暂无模版,请新增模版!"
+            >
+            </el-result>
+          </el-col>
+        </el-row>
+
+        <pagination
+          v-show="total > 0"
+          :total="total"
+          :page.sync="queryParams.pageNo"
+          :limit.sync="queryParams.pageSize"
+          @pagination="getList"
+        />
+      </el-col>
+    </el-row>
+  </div>
+</template>
+
+<script>
+import {
+  getFreightTemplate,
+  copyFreightTemplate,
+  freightTemplateRemove,
+} from "@/api/manage/material";
+import { getToken } from "@/utils/auth";
+import "@riophae/vue-treeselect/dist/vue-treeselect.css";
+export default {
+  name: "User",
+  data() {
+    return {
+      // 遮罩层
+      loading: true,
+      total: 0,
+      queryParams: {
+        pageNo: 1,
+        pageSize: 10,
+        key: "",
+      },
+      tableData: [],
+    };
+  },
+
+  mounted() {
+    this.getList();
+  },
+  methods: {
+    copyTemplate(record) {
+      copyFreightTemplate({
+        id: record.id,
+        expressType: record.expressType,
+      }).then((res) => {
+        if (res.code == 200) {
+          this.$message.success("复制成功!");
+          this.getList();
+        }
+      });
+    },
+    /** 搜索按钮操作 */
+    handleQuery() {
+      this.getList();
+    },
+    getList() {
+      this.tableData = [];
+      getFreightTemplate(this.queryParams).then((res) => {
+        if (res.code == 200) {
+          if (res.data.records) {
+            res.data.records.forEach((e) => {
+              e.detailList.forEach((a, index) => {
+                e.firstWeight = a.firstWeight;
+                e.secondStartWeight = a.secondStartWeight;
+                e.secondEndWeight = a.secondEndWeight;
+              });
+            });
+          }
+          console.log("res.data.records", res.data.records);
+
+          this.tableData = res.data.records;
+          this.total = res.data.total;
+          console.log(this.tableData);
+        }
+      });
+    },
+    removeTemplate(record) {
+      this.$confirm("是否确认删除该模板,删除后无法恢复!", "提示", {
+        confirmButtonText: "确定",
+        cancelButtonText: "取消",
+        type: "warning",
+      }).then(() => {
+        freightTemplateRemove({ id: record.id }).then((res) => {
+          if (res.code == 200) {
+            this.$message.success("删除成功!");
+            this.getList();
+          }
+        });
+      });
+    },
+    editTemplate(record) {
+      this.$router.push({
+        path: "/product/material/editMaterial",
+        query: record,
+      });
+    },
+    /** 重置按钮操作 */
+    resetQuery() {
+      this.queryParams.pageNo = 1;
+      this.queryParams.key = "";
+      this.handleQuery();
+    },
+
+    addTemplate() {
+      this.$router.push({
+        path: "/product/material/addMaterial",
+      });
+    },
+  },
+};
+</script>
+
+<style>
+.my-label {
+  width: 100px;
+}
+</style>
+<style lang="scss" scoped>
+.detail_Header {
+  margin-bottom: 35px;
+  display: flex;
+  flex-direction: row;
+  justify-content: space-around;
+  align-items: center;
+  .item {
+    display: flex;
+    flex-direction: column;
+    justify-content: center;
+    align-items: center;
+    .count {
+      font-weight: bold;
+      font-size: 18px;
+    }
+  }
+}
+</style>

+ 4 - 4
src/views/member/createProduct.vue

@@ -352,10 +352,10 @@ export default {
         this.$message.error(`商品规格不能为空`);
         return;
       }
-      if (!this.form.shippingAddrBean.provinceCode) {
-        this.$message.error(`请点击选择地址,选择发货地址的省市区!`);
-        return;
-      }
+      // if (!this.form.shippingAddrBean.provinceCode) {
+      //   this.$message.error(`请点击选择地址,选择发货地址的省市区!`);
+      //   return;
+      // }
       if (this.form.categoryId?.length > 0) {
         this.form.categoryId = this.form.categoryId[this.form.categoryId.length - 1];
       }

+ 1 - 1
src/views/member/module/sales-info.vue

@@ -451,7 +451,7 @@ export default {
 
       this.form = {
         ...this.form,
-        shippingAddrId,
+        shippingAddrId: JSON.stringify(shippingAddrId),
         merchantClassifyName,
         expressType,
         shareRate,

+ 3 - 1
src/views/product/module/sales-info.vue

@@ -586,7 +586,7 @@ export default {
 
       this.form = {
         ...this.form,
-        shippingAddrId,
+        shippingAddrId:JSON.stringify(shippingAddrId),
         merchantClassifyName,
         expressType,
         shareRate,
@@ -614,6 +614,8 @@ export default {
         },
       };
 
+      console.log(this.form);
+
       this.saleModel = saleModel;
       this.addr = shippingAddr;
     },

+ 1 - 1
src/views/productNationwide/module/sales-info.vue

@@ -578,7 +578,7 @@ export default {
       // 更新表单数据
       this.form = {
         ...this.form, // 保留原有属性
-        shippingAddrId,
+        shippingAddrId: JSON.stringify(shippingAddrId),
         merchantClassifyName,
         expressType,
         shareRate,

+ 1 - 1
src/views/shipping/createProduct.vue

@@ -249,7 +249,7 @@ import {
 } from "@/api/manage/product";
 import basicInfo from "./module/basic-info.vue";
 import productInfo from "@/views/product/module/product-info.vue";
-import salesInfo from "@/views/product/module/sales-info.vue";
+import salesInfo from "./module/sales-info.vue";
 import phoneView from "@/components/phoneView/index.vue";
 import Amap from "@/components/Map/map.vue";
 import moment from "moment";

+ 814 - 0
src/views/shipping/module/sales-info.vue

@@ -0,0 +1,814 @@
+<template>
+  <el-form
+    :model="form"
+    ref="queryForm"
+    size="small"
+    :inline="true"
+    label-width="120px"
+    :rules="rules"
+  >
+    <el-row>
+      <el-col :span="24">
+        <el-form-item prop="lookSalesVolume">
+          <span slot="label">展示销量</span>
+          <el-input
+            v-model="form.lookSalesVolume"
+            placeholder="请输入展示销量"
+            clearable
+            @input="passValue"
+          />
+        </el-form-item>
+      </el-col>
+      <el-col :span="24">
+        <el-form-item prop="giftDesc" label="快递类型">
+          <el-radio
+            v-model="form.expressType"
+            :label="0"
+            :value="0"
+            @change="passValue"
+            >水果特惠</el-radio
+          >
+          <el-radio
+            v-model="form.expressType"
+            :label="1"
+            :value="1"
+            @change="passValue"
+            >生鲜特快</el-radio
+          >
+          <el-radio
+            v-model="form.expressType"
+            :label="2"
+            :value="2"
+            @change="passValue"
+            >京东标快</el-radio
+          >
+        </el-form-item>
+      </el-col>
+      <el-col :span="24">
+        <el-form-item prop="unit">
+          <span slot="label">计量单位</span>
+          <el-select
+            v-model="form.unit"
+            placeholder="请选择"
+            @change="passValue"
+          >
+            <el-option
+              v-for="item in measure"
+              :key="item.dictLabel"
+              :label="item.dictLabel"
+              :value="item.dictLabel"
+            >
+            </el-option>
+          </el-select>
+        </el-form-item>
+      </el-col>
+      <el-col :span="24">
+        <el-form-item>
+          <span slot="label"><span class="required">*</span> 商品规格</span>
+          <el-button @click="addSpecification" type="primary"
+            >添加规格</el-button
+          >
+          <el-table :data="form.skuList" style="width: 100%; margin-top: 20px">
+            <el-table-column prop="name" label="规格名称" width="160">
+              <template slot-scope="scope">
+                <el-input
+                  v-model="scope.row.skuSpecsList[0].specsName"
+                  placeholder="请输入规格名称"
+                  clearable
+                  maxlength="8"
+                  @input="passValue"
+                  show-word-limit
+                />
+              </template>
+            </el-table-column>
+            <el-table-column prop="address" label="规格内容" width="160">
+              <template slot-scope="scope">
+                <el-input
+                  v-model="scope.row.skuSpecsList[0].specsValue"
+                  placeholder="规格内容"
+                  clearable
+                  maxlength="8"
+                  @input="passValue"
+                  show-word-limit
+                />
+              </template>
+            </el-table-column>
+
+            <el-table-column prop="name" label="预计库存" width="160">
+              <template slot-scope="scope">
+                <el-input-number
+                  :controls="false"
+                  v-model="scope.row.predictStocks"
+                  placeholder="预计库存"
+                  clearable
+                  @input="passValue"
+                >
+                  <template slot="suffix"> {{ form.unit }} </template>
+                </el-input-number>
+              </template>
+            </el-table-column>
+            <el-table-column prop="name" label="实际库存" width="160">
+              <template slot-scope="scope">
+                <el-input-number
+                  :controls="false"
+                  v-model="scope.row.stock"
+                  placeholder="实际库存"
+                  clearable
+                  @input="passValue"
+                >
+                  <template slot="suffix"> {{ form.unit }} </template>
+                </el-input-number>
+              </template>
+            </el-table-column>
+            <el-table-column label="起批量" width="160">
+              <template slot-scope="scope">
+                <el-input-number
+                  :controls="false"
+                  v-model="scope.row.skuPriceList[0].minPurchase"
+                  placeholder="起批量"
+                  clearable
+                  @input="passValue"
+                >
+                  <template slot="suffix">
+                    {{ form.unit }}
+                  </template>
+                </el-input-number>
+              </template>
+            </el-table-column>
+
+            <el-table-column label="原价" width="160" v-if="saleType == 4">
+              <template slot-scope="scope">
+                <el-input-number
+                  :controls="false"
+                  v-model="scope.row.skuPriceList[0].originalPrice"
+                  placeholder="原价"
+                  clearable
+                  @input="passValue"
+                >
+                  <template slot="suffix"> {{ form.unit }}/元 </template>
+                </el-input-number>
+              </template>
+            </el-table-column>
+            <el-table-column label="现价" width="160" v-if="saleType == 4">
+              <template slot-scope="scope">
+                <el-input-number
+                  :controls="false"
+                  v-model="scope.row.skuPriceList[0].price"
+                  placeholder="现价"
+                  clearable
+                  @input="passValue"
+                >
+                  <template slot="suffix"> {{ form.unit }}/元 </template>
+                </el-input-number>
+              </template>
+            </el-table-column>
+            <el-table-column
+              v-if="saleType != 4"
+              width="160"
+              :label="
+                saleModel == 5
+                  ? '福利价'
+                  : saleModel == 3
+                  ? '秒杀价'
+                  : saleModel == 4
+                  ? '清库价'
+                  : saleModel == 2
+                  ? '预售价'
+                  : '原价'
+              "
+            >
+              <template slot-scope="scope">
+                <el-input-number
+                  :controls="false"
+                  v-model="scope.row.skuPriceList[0].price"
+                  :placeholder="
+                    saleModel == 5
+                      ? '福利价'
+                      : saleModel == 3
+                      ? '秒杀价'
+                      : saleModel == 4
+                      ? '清库价'
+                      : saleModel == 2
+                      ? '预售价'
+                      : '原价'
+                  "
+                  clearable
+                  @input="passValue"
+                >
+                  <template slot="suffix"> {{ form.unit }}/元 </template>
+                </el-input-number>
+              </template>
+            </el-table-column>
+
+            <el-table-column
+              label="批发价"
+              width="160"
+              v-if="saleType != 4 && saleModel != 1"
+            >
+              <template slot-scope="scope">
+                <el-input-number
+                  :controls="false"
+                  v-model="scope.row.skuPriceList[0].originalPrice"
+                  placeholder="批发价"
+                  clearable
+                  @input="passValue"
+                >
+                  <template slot="suffix"> {{ form.unit }}/元 </template>
+                </el-input-number>
+              </template>
+            </el-table-column>
+            <el-table-column
+              prop="address"
+              label="商品单价"
+              width="120"
+              v-if="saleType == 4"
+            >
+              <template slot-scope="scope">
+                {{ compilatePrice(scope.row.skuPriceList[0]) }}
+                元/{{ form.unit }}
+              </template>
+            </el-table-column>
+
+            <el-table-column prop="address" label="商品单价" width="120" v-else>
+              <template slot-scope="scope">
+                {{
+                  scope.row.skuPriceList[0].price
+                    ? scope.row.skuPriceList[0].price.toFixed(2)
+                    : 0
+                }}
+                元/{{ form.unit }}
+              </template>
+            </el-table-column>
+
+            <el-table-column label="净重量(kg )" width="160">
+              <template slot-scope="scope">
+                <el-input-number
+                  :controls="false"
+                  v-model="scope.row.weight"
+                  placeholder="请输入净重量"
+                  clearable
+                  @input="passValue"
+                >
+                  <template slot="suffix"> /Kg </template>
+                </el-input-number>
+              </template>
+            </el-table-column>
+            <el-table-column prop="address" label="操作" width="160">
+              <template slot-scope="scope">
+                <el-button
+                  type="text"
+                  style="color: red"
+                  @click="removeSpecification(scope.row, scope.$index)"
+                  >删除</el-button
+                >
+              </template>
+            </el-table-column>
+          </el-table>
+        </el-form-item>
+      </el-col>
+      <el-col :span="24" style="margin-top: 20px">
+        <el-form-item>
+          <span slot="label"><span class="required">*</span> 商品属性</span>
+          <div class="main">
+            <div style="padding-top: 20px">
+              <el-form-item label="包装方式" prop="packing">
+                <el-select
+                  v-model="form.packing"
+                  placeholder="请选择包装方式"
+                  @change="passValue"
+                >
+                  <el-option
+                    v-for="item in package"
+                    :key="item.dictLabel"
+                    :label="item.dictLabel"
+                    :value="item.dictLabel"
+                  >
+                  </el-option>
+                </el-select>
+              </el-form-item>
+              <el-form-item prop="shippingTimeDesc">
+                <span slot="label">发货时间</span>
+                <el-select
+                  v-model="form.shippingTimeDesc"
+                  placeholder="请选择发货时间"
+                  @change="passValue"
+                >
+                  <el-option label="付款24小时之内" value="付款24小时之内" />
+                  <el-option label="付款36小时之内" value="付款36小时之内" />
+                  <el-option label="付款48小时之内" value="付款48小时之内" />
+                  <el-option label="付款72小时之内" value="付款72小时之内" />
+                </el-select>
+              </el-form-item>
+            </div>
+
+            <el-form-item
+              label="自定义属性"
+              v-if="form.props && form.props.length > 0"
+            >
+              <div
+                style="
+                  width: 100%;
+                  display: flex;
+                  flex-direction: row;
+                  flex-flow: wrap;
+                  justify-content: center;
+                "
+              >
+                <div
+                  class="item"
+                  v-for="(item, index) in form.props ? form.props : []"
+                  :key="index"
+                >
+                  <el-input
+                    v-model="item.name"
+                    placeholder="请输入属性名称"
+                    clearable
+                    maxlength="8"
+                    show-word-limit
+                    style="width: 200px"
+                  />
+                  <el-input
+                    v-model="item.value"
+                    placeholder="请输入属性值"
+                    clearable
+                    maxlength="8"
+                    show-word-limit
+                    @input="passValue"
+                    style="width: 200px"
+                  />
+                  <i
+                    class="el-icon-delete"
+                    size="22"
+                    style="color: red"
+                    @click="removeAttribute(item, index)"
+                  ></i>
+                </div>
+              </div>
+            </el-form-item>
+          </div>
+          <div class="item1" style="width: 180px">
+            <span @click="addattribute" style="cursor: pointer">
+              <i class="el-icon-plus" size="22"></i>自定义添加商品属性</span
+            >
+          </div>
+        </el-form-item>
+      </el-col>
+      <el-col :span="24" v-if="saleModel == 1">
+        <el-form-item prop="merchantClassifyIds">
+          <span slot="label">店铺内所属分类</span>
+          <el-cascader
+            :filterable="true"
+            v-model="form.merchantClassifyIds"
+            ref="formCascader"
+            :placeholder="
+              form.merchantClassifyName
+                ? form.merchantClassifyName
+                : '请选择分类'
+            "
+            :props="categoryprops"
+            @change="cascaderChange"
+          />
+        </el-form-item>
+      </el-col>
+      <el-form-item label="电商运费模板" prop="logisticsTemplateId">
+        <el-select
+          v-model="form.logisticsTemplateId"
+          placeholder="请选择电商运费模板"
+          @change="passValue"
+        >
+          <el-option
+            v-for="item in templateList"
+            :key="item.id"
+            :label="item.templateName"
+            :value="item.id"
+          >
+          </el-option>
+        </el-select>
+      </el-form-item>
+      <el-col :span="24">
+        <el-form-item prop="shareRate">
+          <span slot="label">分享比例</span>
+          <el-input-number
+            v-model="form.shareRate"
+            :min="0"
+            :max="100"
+            placeholder="请输入分享比例"
+            :controls="false"
+            @change="passValue"
+          >
+          </el-input-number
+          >%
+        </el-form-item>
+      </el-col>
+    </el-row>
+    <Amap ref="mapOpen" @address="Mapaddress"></Amap>
+  </el-form>
+</template>
+
+<script>
+import { getFreightTemplate } from "@/api/manage/material";
+import { getMerchantClassifyList } from "@/api/sort/index.js";
+import { getStoreInfo } from "@/api/common/index";
+import Amap from "@/components/Map/map.vue";
+import { getDict } from "@/api/common/index.js";
+import { dxAddressList } from "@/api/manage/address";
+export default {
+  props: ["data", "saleType", "saleModels"],
+  components: { Amap },
+  data() {
+    return {
+      form: {
+        expressType: 0,
+        unit: "斤",
+        props: [],
+        freeShipping: 0,
+        lookSalesVolume: "",
+        shippingAddrBean: {
+          addr: "",
+          addrDetail: "",
+          cityCode: "",
+          countyCode: "",
+          latitude: "",
+          longitude: "",
+          provinceCode: "",
+        },
+        shippingAddr: "",
+        skuList: [],
+        packing: "",
+        shippingTimeDesc: "",
+        merchantClassifyId: "",
+        merchantClassifyIds: [],
+        merchantClassifyName: "",
+      },
+      addr: "",
+      measure: [],
+      package: [],
+      rules: {
+        logisticsTemplateId: [
+          { required: true, message: "请选择电商运费模板", trigger: "blur" },
+        ],
+        freeShipping: [
+          { required: true, message: "请选择运费方式", trigger: "blur" },
+        ],
+        props: [
+          { required: true, message: "商品属性不能为空", trigger: "blur" },
+        ],
+        unit: [
+          { required: true, message: "计量单位不能为空", trigger: "blur" },
+        ],
+        shippingTimeDesc: [
+          { required: true, message: "发货时间不能为空", trigger: "blur" },
+        ],
+        skuList: [{ required: true, message: "规格不能为空", trigger: "blur" }],
+        packing: [
+          { required: true, message: "包装方式不能为空", trigger: "blur" },
+        ],
+
+        merchantClassifyIds: [
+          { required: true, message: "店铺所属分类不能为空", trigger: "blur" },
+        ],
+      },
+
+      shopInfo: {},
+      saleType: undefined,
+      sj: true,
+      skuIds: [],
+      saleModel: 1,
+      options: [],
+      categoryprops: {
+        checkStrictly: true,
+        lazy: true,
+        lazyLoad: this.categoryLazyLoad,
+        label: "label",
+        value: "value",
+      },
+      templateList: [],
+    };
+  },
+  watch: {
+    //监听文件url改变时重新赋值
+    saleModels(newVal, oldVal) {
+      this.saleModel = newVal;
+      this.$forceUpdate();
+    },
+  },
+  mounted() {
+    this.getInfo();
+    this.getdictImpl();
+    this.getAreaList();
+    this.getList();
+  },
+
+  methods: {
+    getList() {
+      this.tableData = [];
+      getFreightTemplate({
+        pageNo: "1",
+        pageSize: "9999",
+      }).then((res) => {
+        if (res.code == 200) {
+          console.log(res.data);
+          this.templateList = res.data.records;
+        }
+      });
+    },
+    getAreaList() {
+      dxAddressList().then((res) => {
+        if (res.code == 200) {
+          this.options = res.data;
+          let defaults = this.options.filter((item) => {
+            // 根据搜索文本过滤,不区分大小写
+            return item.defaultTag == 1;
+          });
+          this.form.shippingAddrId = defaults[0].id;
+        }
+      });
+    },
+    areaAdd() {
+      this.$router.push({ path: "/manage/manage/address/index" });
+    },
+    categoryLazyLoad(node, resolve) {
+      let level = node.level;
+      if (!node.data) {
+        getMerchantClassifyList({ classifyType: 1, isDefault: 1 }).then(
+          (res) => {
+            //接口
+            const nodes = Array.from(res.data).map((item, index) => ({
+              value: item.id,
+              label: `${item.classifyName}`,
+              leaf: level >= 2,
+            }));
+            // 通过调用resolve将子节点数据返回,通知组件数据加载完成
+            resolve(nodes);
+          }
+        );
+      } else if (level == 1) {
+        getMerchantClassifyList({
+          parentId: node.data.value,
+          classifyType: 1,
+        }).then((res) => {
+          const nodes = Array.from(res.data).map((item) => ({
+            value: item.id,
+            label: `${item.classifyName}`,
+            leaf: level >= 2,
+            // level: 2,
+          }));
+          // 通过调用resolve将子节点数据返回,通知组件数据加载完成
+          resolve(nodes);
+        });
+      } else {
+        resolve({});
+      }
+    },
+    cascaderChange(val) {
+      const dom = document.getElementsByClassName("el-radio is-checked");
+      //这里我把dom打出来看了 最后一个选项才是我选中的节点 即[length-1] 有的博主写的是 第一个元素 即[0] 大家自行尝试
+      let radioDom = dom[dom.length - 1];
+      const brother = radioDom.nextElementSibling;
+      let nodes = this.$refs.formCascader.getCheckedNodes();
+      this.form.merchantClassifyName = nodes[0].label;
+      this.form.merchantClassifyIds = val;
+      this.form.merchantClassifyId = JSON.stringify(val);
+      brother.click();
+      // this.form.merchantClassifyId = `["${this.form.merchantClassifyId.join('')}"]`;
+      this.passValue();
+    },
+    getFormInfo(record) {
+      const {
+        merchantClassifyName,
+        saleModel,
+        shippingAddr,
+        expressType,
+        shareRate,
+        merchantClassifyId,
+        lookSalesVolume,
+        unit,
+        packing,
+        shippingTimeDesc,
+        freeShipping,
+        skuList,
+        props = [],
+        shippingAddrId,
+        logisticsTemplateId,
+      } = record || {};
+
+      this.form = {
+        ...this.form,
+        logisticsTemplateId,
+        shippingAddrId: JSON.stringify(shippingAddrId),
+        merchantClassifyName,
+        expressType,
+        shareRate,
+        merchantClassifyIds: merchantClassifyId,
+        merchantClassifyId,
+        lookSalesVolume,
+        unit,
+        shippingAddr,
+        packing,
+        shippingTimeDesc,
+        freeShipping:
+          this.form.freeShipping !== undefined
+            ? freeShipping
+            : this.form.freeShipping,
+        skuList,
+        props,
+        shippingAddrBean: {
+          addr: shippingAddr,
+          addrDetail: record?.shippingAddrBean?.addrDetail,
+          cityCode: record.cityCode,
+          countyCode: record.countyCode,
+          latitude: record.latitude,
+          longitude: record.longitude,
+          provinceCode: record.provinceCode,
+        },
+      };
+
+      console.log(this.form);
+
+      this.saleModel = saleModel;
+      this.addr = shippingAddr;
+    },
+
+    compilatePrice(data) {
+      if (data.price) {
+        return data.price.toFixed(2);
+      } else if (data.originalPrice) {
+        return data.originalPrice.toFixed(2);
+      } else if (data.originalPrice && data.price) {
+        return data.price.toFixed(2);
+      }
+    },
+    formvalidate() {
+      let that = this;
+      return new Promise((resolve) => {
+        that.$refs.queryForm.validate((valid, row) => {
+          if (valid) {
+            resolve(valid);
+          } else {
+            for (const key in row) {
+              for (let index = 0; index < row[key].length; index++) {
+                this.$message.error(row[key][index].message);
+                return;
+              }
+            }
+            resolve(valid);
+          }
+        });
+      });
+    },
+    getInfo() {
+      getStoreInfo().then((res) => {
+        if (res.code == 200) {
+          this.shopInfo = res.data;
+        }
+      });
+    },
+    getdictImpl() {
+      getDict("stockUnit").then((res) => {
+        if (res.code == 200) {
+          this.measure = res.data;
+        }
+      });
+      getDict("packType").then((res) => {
+        if (res.code == 200) {
+          this.package = res.data;
+        }
+      });
+    },
+    passValue() {
+      if (this.saleType == 4) {
+        this.form?.skuList.forEach((e) => {
+          e.skuPriceList.forEach((a) => {
+            a.price = a.originalPrice;
+          });
+        });
+      }
+      this.$emit("updateValue", this.form);
+    },
+
+    Mapaddress(data) {
+      this.form.shippingAddr = data.pname + data.cityname + data.adname;
+      this.form.shippingAddrBean.addr = data.address;
+      // this.form.shippingAddrBean.addrDetail = data.name ? data.name : undefined;
+      this.form.shippingAddrBean.cityCode = data.cityCode;
+      this.form.shippingAddrBean.countyCode = data.adcode;
+      if (data.location) {
+        this.form.shippingAddrBean.latitude = data.location.lat;
+        this.form.shippingAddrBean.longitude = data.location.lng;
+      }
+      this.form.shippingAddrBean.provinceCode = data.pcode;
+      this.addr = data.address;
+      this.$refs.mapOpen.closeMap();
+      // this.passValue();
+    },
+    selectAddr() {
+      this.$refs.mapOpen.loadMap();
+    },
+    addattribute() {
+      if (this.form.prop?.length > 0) {
+        this.form.props.push({
+          name: "",
+          id: "",
+          value: "",
+        });
+      } else {
+        this.form.prop = [];
+        this.form.props.push({
+          name: "",
+          id: "",
+          value: "",
+        });
+      }
+    },
+    removeAttribute(record, index) {
+      this.form.props.splice(index, 1);
+      this.passValue();
+    },
+    removeSpecification(record, index) {
+      console.log("record", record.id);
+      this.skuIds.push(record.id);
+      this.form.skuList.splice(index, 1);
+      this.$emit("skuRemove", this.skuIds);
+    },
+    addSpecification() {
+      if (!this.form.skuList) {
+        this.form.skuList = [];
+      }
+      this.form.skuList.push({
+        stock: undefined,
+        weight: undefined,
+        sj: true,
+        skuCost: {
+          purchaseFee: undefined,
+          laborFee: undefined,
+          agencyFee: undefined,
+          materialFee: undefined,
+        },
+        skuSpecsList: [
+          {
+            specsId: "0",
+            specsName: "",
+            specsValue: "",
+          },
+        ],
+        skuPriceList: [
+          {
+            minPurchase: undefined,
+            maxPurchase: undefined,
+            price: undefined,
+            originalPrice: undefined,
+            lowestPrice: 1,
+          },
+        ],
+      });
+    },
+  },
+};
+</script>
+<style>
+.el-upload-list__item {
+  transition: none !important;
+  -webkit-transition: nonne !important;
+}
+.el-upload-list__item-name {
+  transition: none !important;
+  -webkit-transition: nonne !important;
+}
+</style>
+<style scoped>
+/deep/ .el-radio-group {
+  display: flex;
+  flex-direction: column;
+  justify-content: space-around;
+  height: 50px;
+}
+.item {
+  display: flex;
+  flex-direction: row;
+  align-items: center;
+  margin-bottom: 20px;
+  margin-right: 10px;
+}
+.main1 {
+  background: #f1f1f1;
+  min-height: 80px;
+  display: flex;
+  flex-direction: row;
+  flex-wrap: wrap;
+  align-items: center;
+  padding: 0px 20px;
+}
+.main {
+  width: 58vw;
+  background: #f1f1f1;
+  min-height: 80px;
+  display: flex;
+  flex-direction: column;
+  align-items: flex-start;
+  /* display: flex;
+  flex-direction: row;
+  flex-wrap: wrap;
+  align-items: center;
+  padding: 20px 20px 0px 20px; */
+}
+</style>

+ 1 - 1
src/views/shipping/updateProduct.vue

@@ -254,7 +254,7 @@ import {
 } from "@/api/manage/product";
 import basicInfo from "./module/basic-info.vue";
 import productInfo from "@/views/product/module/product-info.vue";
-import salesInfo from "@/views/product/module/sales-info.vue";
+import salesInfo from "./module/sales-info.vue";
 import phoneView from "@/components/phoneView/index.vue";
 import Amap from "@/components/Map/map.vue";
 import moment from "moment";