add
This commit is contained in:
parent
dd5a2e46c9
commit
71b86f2bc5
|
@ -16,14 +16,19 @@
|
||||||
v-model="searchForm.name"
|
v-model="searchForm.name"
|
||||||
></el-input>
|
></el-input>
|
||||||
</el-form-item>
|
</el-form-item>
|
||||||
<el-button type="primary" @click="$refs.oTable.reload();">搜索</el-button>
|
<el-button type="primary" @click="$refs.oTable.reload()"
|
||||||
|
>搜索</el-button
|
||||||
|
>
|
||||||
</el-form>
|
</el-form>
|
||||||
<el-button type="primary" @click="addFareTemplate"
|
<el-button type="primary" @click="addFareTemplate"
|
||||||
>添加运费模板</el-button
|
>添加运费模板</el-button
|
||||||
>
|
>
|
||||||
</div>
|
</div>
|
||||||
</obj-table-plus>
|
</obj-table-plus>
|
||||||
<add-template ref="addTemplate"></add-template>
|
<add-template
|
||||||
|
ref="addTemplate"
|
||||||
|
@refresh="$refs.oTable.refresh()"
|
||||||
|
></add-template>
|
||||||
</div>
|
</div>
|
||||||
</template>
|
</template>
|
||||||
|
|
||||||
|
@ -49,11 +54,14 @@ export default {
|
||||||
})
|
})
|
||||||
.then((res) => {
|
.then((res) => {
|
||||||
console.log(res);
|
console.log(res);
|
||||||
this.$refs.oTable.complete(res.data.data.data,Number(res.data.data.total));
|
this.$refs.oTable.complete(
|
||||||
|
res.data.data.data,
|
||||||
|
Number(res.data.data.total)
|
||||||
|
);
|
||||||
})
|
})
|
||||||
.catch(err=>{
|
.catch((err) => {
|
||||||
this.$refs.oTable.complete(false);
|
this.$refs.oTable.complete(false);
|
||||||
})
|
});
|
||||||
},
|
},
|
||||||
addFareTemplate() {
|
addFareTemplate() {
|
||||||
this.$refs.addTemplate.toggle().add();
|
this.$refs.addTemplate.toggle().add();
|
||||||
|
@ -66,26 +74,59 @@ export default {
|
||||||
type: "jsx",
|
type: "jsx",
|
||||||
render: (row) => {
|
render: (row) => {
|
||||||
console.log(row);
|
console.log(row);
|
||||||
this.$api.mer_admin.getShippingTemplateInfo(row.id)
|
this.$api.mer_admin.getShippingTemplateInfo(row.id).then((res) => {
|
||||||
|
console.log(res);
|
||||||
|
// this.$set(row,tableData,);
|
||||||
|
});
|
||||||
|
const appointMapper = {
|
||||||
|
0: "(全国包邮)",
|
||||||
|
1: "(部分包邮)",
|
||||||
|
2: "(自定义运费)",
|
||||||
|
};
|
||||||
|
|
||||||
|
const edit = () => {
|
||||||
|
this.$api.mer_admin
|
||||||
|
.getShippingTemplateInfo(row.id)
|
||||||
|
.then((res) => {
|
||||||
|
console.log(res);
|
||||||
|
this.$refs.addTemplate.toggle().update(res.data.data);
|
||||||
|
});
|
||||||
|
};
|
||||||
|
const copy = () => {
|
||||||
|
this.$api.mer_admin
|
||||||
|
.getShippingTemplateInfo(row.id)
|
||||||
|
.then((res) => {
|
||||||
|
console.log(res);
|
||||||
|
this.$refs.addTemplate.toggle().copy(res.data.data);
|
||||||
|
});
|
||||||
|
};
|
||||||
|
const remove = () => {
|
||||||
|
this.$api.mer_admin.removeShippingTemplate(row.id)
|
||||||
.then(res=>{
|
.then(res=>{
|
||||||
console.log(res);
|
this.$refs.oTable.refresh();
|
||||||
// this.$set(row,tableData,);
|
|
||||||
})
|
})
|
||||||
const appointMapper={
|
};
|
||||||
0:'(全国包邮)',
|
|
||||||
1:'(部分包邮)',
|
|
||||||
2:'(自定义运费)'
|
|
||||||
}
|
|
||||||
return (
|
return (
|
||||||
<div class="mb-5">
|
<div class="mb-5">
|
||||||
<div class="flex justify-between items-center bg-gray-100 px-4">
|
<div class="flex justify-between items-center bg-gray-100 px-4">
|
||||||
<div>{row.name}{appointMapper[row.appoint]}</div>
|
<div>
|
||||||
|
{row.name}
|
||||||
|
{appointMapper[row.appoint]}
|
||||||
|
</div>
|
||||||
<div class="flex justify-between items-center">
|
<div class="flex justify-between items-center">
|
||||||
<div class="mr-5">最后编辑时间:{row.updateTime}</div>
|
<div class="mr-5">最后编辑时间:{row.updateTime}</div>
|
||||||
<div>
|
<div>
|
||||||
<el-button type="text">复制模板</el-button>
|
<el-button type="text" onClick={copy}>
|
||||||
<el-button type="text">修改</el-button>
|
复制模板
|
||||||
<el-button type="text">删除</el-button>
|
</el-button>
|
||||||
|
<el-button type="text" onClick={edit}>
|
||||||
|
修改
|
||||||
|
</el-button>
|
||||||
|
<el-popconfirm class="ml-2" title="确认删除模板?" onConfirm={remove}>
|
||||||
|
<el-button type="text" slot="reference">
|
||||||
|
删除
|
||||||
|
</el-button>
|
||||||
|
</el-popconfirm>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
|
|
|
@ -65,7 +65,11 @@ export default {
|
||||||
place: "", //场地
|
place: "", //场地
|
||||||
};
|
};
|
||||||
},
|
},
|
||||||
mounted() {},
|
mounted() {
|
||||||
|
window.onbeforeunload = function (e) {
|
||||||
|
return "还有未保存的数据,确定离开此页吗?";
|
||||||
|
};
|
||||||
|
},
|
||||||
methods: {
|
methods: {
|
||||||
computedCityOptions() {
|
computedCityOptions() {
|
||||||
function filterTree(tree, filterArray) {
|
function filterTree(tree, filterArray) {
|
||||||
|
@ -110,25 +114,77 @@ export default {
|
||||||
} else {
|
} else {
|
||||||
this.modalConfig.show = false;
|
this.modalConfig.show = false;
|
||||||
}
|
}
|
||||||
if (e) {
|
//回显数据
|
||||||
console.log(e);
|
const refillData = (e) => {
|
||||||
this.init(cloneDeep(e.row));
|
let _data = cloneDeep(e);
|
||||||
}
|
console.log("_data", _data);
|
||||||
|
|
||||||
|
//默认运费回显
|
||||||
|
_data.shippingTemplatesRegionList =
|
||||||
|
[_data.shippingTemplatesRegionResultList?.[0]] ||
|
||||||
|
BASE_DATA.shippingTemplatesRegionList;
|
||||||
|
//指定城市设置运费
|
||||||
|
_data.shippingTemplatesRegionListAppend =
|
||||||
|
_data.shippingTemplatesRegionResultList
|
||||||
|
?.slice(1, _data.shippingTemplatesRegionResultList.length)
|
||||||
|
?.map((item) => {
|
||||||
|
item.cityCodes = item.cityCodes.split(",");
|
||||||
|
return item;
|
||||||
|
}) || BASE_DATA.shippingTemplatesRegionListAppend;
|
||||||
|
//指定包邮条件
|
||||||
|
_data.shippingTemplatesConditionList =
|
||||||
|
_data.shippingTemplatesConditionResultList?.map((item) => {
|
||||||
|
item.cityCodes = item.cityCodes.split(",");
|
||||||
|
// item.conditionType=
|
||||||
|
if (item.price && item.number) {
|
||||||
|
item.conditionType = "件数+金额";
|
||||||
|
} else if (item.price && !item.number) {
|
||||||
|
item.conditionType = "金额";
|
||||||
|
} else if (!item.price && item.number) {
|
||||||
|
item.conditionType = "件数";
|
||||||
|
}
|
||||||
|
return item;
|
||||||
|
}) || BASE_DATA.shippingTemplatesConditionList;
|
||||||
|
|
||||||
|
//计价方式
|
||||||
|
_data.calculateMethod = {
|
||||||
|
1: "按件数",
|
||||||
|
2: "按重量",
|
||||||
|
3: "按体积",
|
||||||
|
}[_data.groups];
|
||||||
|
|
||||||
|
//运费配置
|
||||||
|
_data.fareConfig = {
|
||||||
|
0: "全国包邮",
|
||||||
|
2: "自定义运费",
|
||||||
|
}[_data.appoint];
|
||||||
|
|
||||||
|
//模板名称
|
||||||
|
_data.templateName = _data.name;
|
||||||
|
|
||||||
|
this.modalData = _data;
|
||||||
|
};
|
||||||
return {
|
return {
|
||||||
add: (item) => {
|
add: () => {
|
||||||
console.log(item);
|
|
||||||
this.$nextTick(() => {
|
this.$nextTick(() => {
|
||||||
this.modalData = JSON.parse(JSON.stringify(BASE_DATA));
|
this.modalData = JSON.parse(JSON.stringify(BASE_DATA));
|
||||||
});
|
});
|
||||||
this.isAdd = true;
|
this.isAdd = true;
|
||||||
|
this.modalConfig.title = "添加运费模板";
|
||||||
},
|
},
|
||||||
update: (row) => {
|
update: (e) => {
|
||||||
this.modalData = row;
|
|
||||||
this.isAdd = false;
|
this.isAdd = false;
|
||||||
|
refillData(e);
|
||||||
|
this.modalConfig.title = "编辑运费模板";
|
||||||
|
},
|
||||||
|
copy: (e) => {
|
||||||
|
this.isAdd = true;
|
||||||
|
refillData(e);
|
||||||
|
this.modalConfig.title = "添加运费模板";
|
||||||
|
this.modalData.templateName += "(复制)";
|
||||||
},
|
},
|
||||||
};
|
};
|
||||||
},
|
},
|
||||||
init(row) {},
|
|
||||||
},
|
},
|
||||||
computed: {
|
computed: {
|
||||||
modalCols() {
|
modalCols() {
|
||||||
|
@ -310,7 +366,7 @@ export default {
|
||||||
<el-input-number
|
<el-input-number
|
||||||
style="width:100%;"
|
style="width:100%;"
|
||||||
min={0}
|
min={0}
|
||||||
max={row.firstPrice}
|
max={Number(row.firstPrice)}
|
||||||
controls={false}
|
controls={false}
|
||||||
precision={2}
|
precision={2}
|
||||||
v-model={row.renewalPrice}
|
v-model={row.renewalPrice}
|
||||||
|
@ -337,6 +393,7 @@ export default {
|
||||||
{
|
{
|
||||||
//默认运费,不限制城市
|
//默认运费,不限制城市
|
||||||
cityCodes: "",
|
cityCodes: "",
|
||||||
|
//城市可选的选项
|
||||||
//首重
|
//首重
|
||||||
first: "",
|
first: "",
|
||||||
//首重价格
|
//首重价格
|
||||||
|
@ -465,6 +522,9 @@ export default {
|
||||||
>
|
>
|
||||||
<el-input-number
|
<el-input-number
|
||||||
min={0}
|
min={0}
|
||||||
|
max={
|
||||||
|
Number(this.modalData.shippingTemplatesRegionList[0].firstPrice)
|
||||||
|
}
|
||||||
controls={false}
|
controls={false}
|
||||||
precision={2}
|
precision={2}
|
||||||
v-model={
|
v-model={
|
||||||
|
@ -479,6 +539,13 @@ export default {
|
||||||
</div>
|
</div>
|
||||||
<div>
|
<div>
|
||||||
<obj-table-plus
|
<obj-table-plus
|
||||||
|
tableProp={{
|
||||||
|
"scroll-y": {
|
||||||
|
enabled: true,
|
||||||
|
gt: 5,
|
||||||
|
},
|
||||||
|
'show-overflow':true
|
||||||
|
}}
|
||||||
style="height:50vh;"
|
style="height:50vh;"
|
||||||
enable-auto-query={false}
|
enable-auto-query={false}
|
||||||
v-model={this.modalData.shippingTemplatesRegionListAppend}
|
v-model={this.modalData.shippingTemplatesRegionListAppend}
|
||||||
|
@ -697,51 +764,121 @@ export default {
|
||||||
handle: debounce(() => {
|
handle: debounce(() => {
|
||||||
console.log(this.modalData);
|
console.log(this.modalData);
|
||||||
if (this.isAdd) {
|
if (this.isAdd) {
|
||||||
this.$api.mer_admin.addShippingTemplate({
|
this.$api.mer_admin
|
||||||
linkId: JSON.parse(sessionStorage.getItem("userInfo")).shopId,
|
.addShippingTemplate({
|
||||||
defaults: 0,//默认值,待确认
|
linkId: JSON.parse(sessionStorage.getItem("userInfo")).shopId,
|
||||||
sort: 0,//默认值,待确认
|
defaults: 0, //默认值,待确认
|
||||||
type:2,//默认值,待确认
|
sort: 0, //默认值,待确认
|
||||||
name: this.modalData.templateName,
|
type: 2, //默认值,待确认
|
||||||
groups: {
|
name: this.modalData.templateName,
|
||||||
按重量: 2,
|
groups: {
|
||||||
按件数: 1,
|
按重量: 2,
|
||||||
按体积: 3,
|
按件数: 1,
|
||||||
}[this.modalData.calculateMethod],
|
按体积: 3,
|
||||||
appoint: {
|
}[this.modalData.calculateMethod],
|
||||||
全国包邮: 0,
|
appoint: {
|
||||||
自定义运费: 2,
|
全国包邮: 0,
|
||||||
}[this.modalData.fareConfig],
|
自定义运费: 2,
|
||||||
shippingTemplatesRegionList:
|
}[this.modalData.fareConfig],
|
||||||
this.modalData.fareConfig == "全国包邮"
|
shippingTemplatesRegionList:
|
||||||
? null
|
this.modalData.fareConfig == "全国包邮"
|
||||||
: [
|
? null
|
||||||
...this.modalData.shippingTemplatesRegionList,
|
: [
|
||||||
...JSON.parse(
|
...this.modalData.shippingTemplatesRegionList,
|
||||||
|
...JSON.parse(
|
||||||
|
JSON.stringify(
|
||||||
|
this.modalData.shippingTemplatesRegionListAppend.map(
|
||||||
|
(item) => {
|
||||||
|
item.cityCodes = item.cityCodes.join(",");
|
||||||
|
return item;
|
||||||
|
}
|
||||||
|
)
|
||||||
|
)
|
||||||
|
),
|
||||||
|
],
|
||||||
|
shippingTemplatesConditionList:
|
||||||
|
this.modalData.fareConfig == "全国包邮"
|
||||||
|
? null
|
||||||
|
: JSON.parse(
|
||||||
JSON.stringify(
|
JSON.stringify(
|
||||||
this.modalData.shippingTemplatesRegionListAppend.map(
|
this.modalData.shippingTemplatesConditionList.map(
|
||||||
(item) => {
|
(item) => {
|
||||||
item.cityCodes = item.cityCodes.join(",");
|
item.cityCodes = item.cityCodes.join(",");
|
||||||
|
//过滤
|
||||||
|
if (item.conditionType == "件数") {
|
||||||
|
item.price = null;
|
||||||
|
} else if (item.conditionType == "金额") {
|
||||||
|
item.number = null;
|
||||||
|
}
|
||||||
return item;
|
return item;
|
||||||
}
|
}
|
||||||
)
|
)
|
||||||
)
|
)
|
||||||
),
|
),
|
||||||
],
|
})
|
||||||
shippingTemplatesConditionList:
|
.then((res) => {
|
||||||
this.modalData.fareConfig == "全国包邮"
|
this.toggle();
|
||||||
? null
|
this.$emit("refresh");
|
||||||
: JSON.parse(
|
});
|
||||||
JSON.stringify(
|
} else {
|
||||||
this.modalData.shippingTemplatesConditionList.map(
|
//编辑
|
||||||
(item) => {
|
this.$api.mer_admin
|
||||||
item.cityCodes = item.cityCodes.join(",");
|
.updateShippingTemplate({
|
||||||
return item;
|
id: this.modalData.id,
|
||||||
}
|
linkId: JSON.parse(sessionStorage.getItem("userInfo")).shopId,
|
||||||
|
defaults: 0, //默认值,待确认
|
||||||
|
sort: 0, //默认值,待确认
|
||||||
|
type: 2, //默认值,待确认
|
||||||
|
name: this.modalData.templateName,
|
||||||
|
groups: {
|
||||||
|
按重量: 2,
|
||||||
|
按件数: 1,
|
||||||
|
按体积: 3,
|
||||||
|
}[this.modalData.calculateMethod],
|
||||||
|
appoint: {
|
||||||
|
全国包邮: 0,
|
||||||
|
自定义运费: 2,
|
||||||
|
}[this.modalData.fareConfig],
|
||||||
|
shippingTemplatesRegionList:
|
||||||
|
this.modalData.fareConfig == "全国包邮"
|
||||||
|
? null
|
||||||
|
: [
|
||||||
|
...this.modalData.shippingTemplatesRegionList,
|
||||||
|
...JSON.parse(
|
||||||
|
JSON.stringify(
|
||||||
|
this.modalData.shippingTemplatesRegionListAppend.map(
|
||||||
|
(item) => {
|
||||||
|
item.cityCodes = item.cityCodes.join(",");
|
||||||
|
return item;
|
||||||
|
}
|
||||||
|
)
|
||||||
|
)
|
||||||
|
),
|
||||||
|
],
|
||||||
|
shippingTemplatesConditionList:
|
||||||
|
this.modalData.fareConfig == "全国包邮"
|
||||||
|
? null
|
||||||
|
: JSON.parse(
|
||||||
|
JSON.stringify(
|
||||||
|
this.modalData.shippingTemplatesConditionList.map(
|
||||||
|
(item) => {
|
||||||
|
item.cityCodes = item.cityCodes.join(",");
|
||||||
|
//过滤
|
||||||
|
if (item.conditionType == "件数") {
|
||||||
|
item.price = null;
|
||||||
|
} else if (item.conditionType == "金额") {
|
||||||
|
item.number = null;
|
||||||
|
}
|
||||||
|
return item;
|
||||||
|
}
|
||||||
|
)
|
||||||
)
|
)
|
||||||
)
|
),
|
||||||
),
|
})
|
||||||
});
|
.then((res) => {
|
||||||
|
this.toggle();
|
||||||
|
this.$emit("refresh");
|
||||||
|
});
|
||||||
}
|
}
|
||||||
}, 300),
|
}, 300),
|
||||||
},
|
},
|
||||||
|
|
Loading…
Reference in New Issue