|
@@ -253,11 +253,26 @@
|
|
|
</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
|
|
|
+ v-model="form.merchantClassifyIds"
|
|
|
+ ref="formCascader"
|
|
|
+ :placeholder="
|
|
|
+ form.merchantClassifyName ? form.merchantClassifyName : '请选择分类'
|
|
|
+ "
|
|
|
+ :props="categoryprops"
|
|
|
+ @change="cascaderChange"
|
|
|
+ />
|
|
|
+ </el-form-item>
|
|
|
+ </el-col>
|
|
|
</el-row>
|
|
|
</el-form>
|
|
|
</template>
|
|
|
|
|
|
<script>
|
|
|
+import { getMerchantClassifyList } from "@/api/sort/index.js";
|
|
|
import { getStoreInfo } from "@/api/common/index";
|
|
|
import { getDict } from "@/api/common/index.js";
|
|
|
export default {
|
|
@@ -283,6 +298,9 @@ export default {
|
|
|
skuList: [],
|
|
|
packing: "",
|
|
|
shippingTimeDesc: "",
|
|
|
+ merchantClassifyId: "",
|
|
|
+ merchantClassifyIds: [],
|
|
|
+ merchantClassifyName: "",
|
|
|
},
|
|
|
addr: "",
|
|
|
measure: [],
|
|
@@ -299,6 +317,9 @@ export default {
|
|
|
"shippingAddrBean.addrDetail": [
|
|
|
{ required: true, message: "详细地址不能为空", trigger: "blur" },
|
|
|
],
|
|
|
+ merchantClassifyIds: [
|
|
|
+ { required: true, message: "店铺所属分类不能为空", trigger: "blur" },
|
|
|
+ ],
|
|
|
},
|
|
|
shopInfo: {},
|
|
|
saleType: undefined,
|
|
@@ -306,13 +327,19 @@ export default {
|
|
|
showCom: true,
|
|
|
skuIds: [],
|
|
|
saleModel: 1,
|
|
|
+ categoryprops: {
|
|
|
+ checkStrictly: true,
|
|
|
+ lazy: true,
|
|
|
+ lazyLoad: this.categoryLazyLoad,
|
|
|
+ label: "label",
|
|
|
+ value: "value",
|
|
|
+ },
|
|
|
};
|
|
|
},
|
|
|
|
|
|
watch: {
|
|
|
//监听文件url改变时重新赋值
|
|
|
saleModels(newVal, oldVal) {
|
|
|
- console.log("azxczx", newVal);
|
|
|
this.saleModel = newVal;
|
|
|
this.$forceUpdate();
|
|
|
},
|
|
@@ -322,43 +349,104 @@ export default {
|
|
|
this.getdictImpl();
|
|
|
},
|
|
|
methods: {
|
|
|
+ cascaderChange(val) {
|
|
|
+ const dom = document.getElementsByClassName("el-radio is-checked");
|
|
|
+ //这里我把dom打出来看了 最后一个选项才是我选中的节点 即[length-1] 有的博主写的是 第一个元素 即[0] 大家自行尝试
|
|
|
+ let radioDom = dom[dom.length - 1];
|
|
|
+ const brother = radioDom.nextElementSibling;
|
|
|
+ brother.click();
|
|
|
+ let nodes = this.$refs.formCascader.getCheckedNodes();
|
|
|
+ this.form.merchantClassifyName = nodes[0].label;
|
|
|
+ this.form.merchantClassifyIds = val;
|
|
|
+ this.form.merchantClassifyId = val;
|
|
|
+ this.form.merchantClassifyId = `["${this.form.merchantClassifyId.join('", "')}"]`;
|
|
|
+ this.passValue();
|
|
|
+ },
|
|
|
+
|
|
|
+ categoryLazyLoad(node, resolve) {
|
|
|
+ let level = node.level;
|
|
|
+ if (!node.data) {
|
|
|
+ getMerchantClassifyList({ classifyType: 0 }).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: 0 }).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({});
|
|
|
+ }
|
|
|
+ },
|
|
|
+
|
|
|
getFormInfo(record) {
|
|
|
- this.saleModel = record.saleModel;
|
|
|
- this.addr = record.shippingAddr;
|
|
|
- this.form.expressType = record.expressType;
|
|
|
+ const {
|
|
|
+ saleModel,
|
|
|
+ shippingAddr,
|
|
|
+ expressType,
|
|
|
+ merchantClassifyId,
|
|
|
+ merchantClassifyName,
|
|
|
+ shippingAddrBean,
|
|
|
+ props,
|
|
|
+ lookSalesVolume,
|
|
|
+ unit,
|
|
|
+ packing,
|
|
|
+ shippingTimeDesc,
|
|
|
+ freeShipping,
|
|
|
+ skuList,
|
|
|
+ } = record;
|
|
|
+
|
|
|
+ this.saleModel = saleModel;
|
|
|
+ this.addr = shippingAddr;
|
|
|
+
|
|
|
+ // 批量赋值一些表单属性
|
|
|
+ Object.assign(this.form, {
|
|
|
+ expressType,
|
|
|
+ merchantClassifyId,
|
|
|
+ merchantClassifyIds: JSON.parse(merchantClassifyId),
|
|
|
+ merchantClassifyName,
|
|
|
+ lookSalesVolume,
|
|
|
+ unit,
|
|
|
+ shippingAddr,
|
|
|
+ packing,
|
|
|
+ shippingTimeDesc,
|
|
|
+ skuList,
|
|
|
+ });
|
|
|
+ // 处理 shippingAddrBean
|
|
|
this.form.shippingAddrBean = {
|
|
|
- addr: record.shippingAddr,
|
|
|
- addrDetail: record.shippingAddrBean
|
|
|
- ? record.shippingAddrBean.addrDetail
|
|
|
- : undefined,
|
|
|
- cityCode: record.cityCode,
|
|
|
- countyCode: record.countyCode,
|
|
|
- latitude: record.latitude,
|
|
|
- longitude: record.longitude,
|
|
|
- provinceCode: record.provinceCode,
|
|
|
+ addr: shippingAddr,
|
|
|
+ addrDetail: shippingAddrBean?.addrDetail,
|
|
|
+ cityCode: shippingAddrBean?.cityCode,
|
|
|
+ countyCode: shippingAddrBean?.countyCode,
|
|
|
+ latitude: shippingAddrBean?.latitude,
|
|
|
+ longitude: shippingAddrBean?.longitude,
|
|
|
+ provinceCode: shippingAddrBean?.provinceCode,
|
|
|
};
|
|
|
- if (record.props && record.props?.length < 1) {
|
|
|
- this.form.props = [];
|
|
|
- } else if (!record.props) {
|
|
|
- this.form.props = [];
|
|
|
- } else {
|
|
|
- this.form.props = record.props;
|
|
|
- }
|
|
|
- this.form.lookSalesVolume = record.lookSalesVolume;
|
|
|
- this.form.unit = record.unit;
|
|
|
- this.form.shippingAddr = record.shippingAddr;
|
|
|
- this.form.packing = record.packing;
|
|
|
- this.form.shippingTimeDesc = record.shippingTimeDesc;
|
|
|
+ // 处理 props
|
|
|
+ this.form.props = Array.isArray(props) ? props : [];
|
|
|
+ // 处理 freeShipping
|
|
|
if (this.form.freeShipping) {
|
|
|
- this.form.freeShipping = record.freeShipping;
|
|
|
+ this.form.freeShipping = freeShipping;
|
|
|
}
|
|
|
- this.form.skuList = record.skuList;
|
|
|
},
|
|
|
-
|
|
|
setShowCom(val) {
|
|
|
this.showCom = val;
|
|
|
},
|
|
|
-
|
|
|
formvalidate() {
|
|
|
let that = this;
|
|
|
return new Promise((resolve) => {
|
|
@@ -384,23 +472,24 @@ export default {
|
|
|
}
|
|
|
});
|
|
|
},
|
|
|
- getdictImpl() {
|
|
|
- getDict("stockUnit").then((res) => {
|
|
|
- if (res.code == 200) {
|
|
|
- this.measure = res.data;
|
|
|
+ async getdictImpl() {
|
|
|
+ try {
|
|
|
+ const [stockUnitRes, packTypeRes] = await Promise.all([
|
|
|
+ getDict("stockUnit"),
|
|
|
+ getDict("packType"),
|
|
|
+ ]);
|
|
|
+ if (stockUnitRes.code === 200) {
|
|
|
+ this.measure = stockUnitRes.data;
|
|
|
}
|
|
|
- });
|
|
|
- getDict("packType").then((res) => {
|
|
|
- if (res.code == 200) {
|
|
|
- this.package = res.data;
|
|
|
+ if (packTypeRes.code === 200) {
|
|
|
+ this.package = packTypeRes.data;
|
|
|
}
|
|
|
- });
|
|
|
+ } catch (error) {
|
|
|
+ console.error("获取字典数据失败:", error);
|
|
|
+ }
|
|
|
},
|
|
|
|
|
|
passValue() {
|
|
|
- console.log(this.form);
|
|
|
- console.log("model", this.saleModel);
|
|
|
-
|
|
|
if (this.saleModel == 1) {
|
|
|
this.form.skuList.forEach((e) => {
|
|
|
e.skuPriceList[0].price = e.skuPriceList[0].originalPrice;
|
|
@@ -409,24 +498,6 @@ export default {
|
|
|
|
|
|
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({
|
|
@@ -448,12 +519,14 @@ export default {
|
|
|
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,
|