Commit bb27bb95 by 张立顺

feat 功能开发

1 parent 7f6e45cd
import request from "./request" import request from "./request";
const path = 'dj.api.smartcarlife.'
const path = "dj.api.smartcarlife.";
// 获取产品管理 列表数据 // 获取产品管理 列表数据
export function getProductManageList(data) { export function getProductManageList(data) {
data.method = `${path}productManager.page` data.method = `${path}productManager.page`;
return request(data) return request(data);
}
// 获取产品管理列表 SPU 分页(否)
export function getProductManageListPageLimit(data) {
data.method = `${path}productManager.spu.page`;
return request(data);
}
// 获取产品管理列表 pageSku(是)
export function getProductManageListPageSku(data) {
data.method = `${path}productManager.pageSku`;
return request(data);
} }
// 新增产品 // 新增产品
export function addProductManage(data) { export function addProductManage(data) {
data.method = `${path}productManager.add` data.method = `${path}productManager.add`;
return request(data, 'post') return request(data, "post");
} }
// 编辑产品 // 编辑产品
export function UpdateProductManage(data) { export function UpdateProductManage(data) {
data.method = `${path}productManager.update` data.method = `${path}productManager.update`;
return request(data, 'post') return request(data, "post");
} }
// 获取权益/升级类目服务项目 // 获取权益/升级类目服务项目
export function getProductServiceItems(data) { export function getProductServiceItems(data) {
data.method = `${path}vd.item.queryServiceItemsGradeConfig` data.method = `${path}vd.item.queryServiceItemsGradeConfig`;
return request(data, 'post') return request(data, "post");
} }
// 批量导入 // 批量导入
export function productImport(data) { export function productImport(data) {
data.method = `${path}productManager.import` data.method = `${path}productManager.import`;
return request(data, 'post', ["file"]) return request(data, "post", ["file"]);
} }
// 获取延保类服务项目 // 获取延保类服务项目
export function getExtendServiceItems(data) { export function getExtendServiceItems(data) {
data.method = `${path}vd.item.queryExtendServiceItemsConfig` data.method = `${path}vd.item.queryExtendServiceItemsConfig`;
return request(data, 'post') return request(data, "post");
} }
// 获取延保类服务项目部件列表 // 获取延保类服务项目部件列表
export function getExtendServiceItemsParts(data) { export function getExtendServiceItemsParts(data) {
data.method = `${path}vd.item.getExtendUnitList` data.method = `${path}vd.item.getExtendUnitList`;
return request(data, 'post') return request(data, "post");
} }
// 获取适用车系列表 // 获取适用车系列表
export function getCarSeriesList(data) { export function getCarSeriesList(data) {
data.method = `${path}common.car.series.page` data.method = `${path}common.car.series.page`;
return request(data, 'post') return request(data, "post");
} }
// 分页获取上架商品所需的升级商品信息 // 分页获取上架商品所需的升级商品信息
export function getUpgradeProductList(data) { export function getUpgradeProductList(data) {
data.method = `${path}productManager.listUpgradeGoodsWithPage` data.method = `${path}productManager.listUpgradeGoodsWithPage`;
return request(data, 'post') return request(data, "post");
}
// 根据id查询商品详情
export function getBaseGoodsById(data) {
data.method = "dj.api.basegoods.get.byId";
return request(data);
}
// 分页查询 SKU 详情(商品名称/编码搜索)
export function getBaseGoodsSkuPageById(data) {
data.method = "dj.api.basegoods.get.sku.page.byId";
return request(data);
}
// 分页查询基础商品操作日志
export function getBaseGoodsOperationLogPage(data) {
data.method = "dj.api.basegoods.get.goods.operationLog.page";
return request(data);
} }
...@@ -4,7 +4,7 @@ ...@@ -4,7 +4,7 @@
<el-table <el-table
:ref="tableParams.mutiSelectName + 'MutiTable' || 'mutiTable'" :ref="tableParams.mutiSelectName + 'MutiTable' || 'mutiTable'"
:data="getListApi ? data : tableData" :data="getListApi ? data : tableData"
:row-key="tableParams.mutiSelectUniqueKey || ''" :row-key="getRowKey"
v-loading="loading" v-loading="loading"
:border="border" :border="border"
:max-height="maxHeight" :max-height="maxHeight"
...@@ -538,10 +538,10 @@ export default { ...@@ -538,10 +538,10 @@ export default {
type: Function, type: Function,
default: null default: null
}, },
// 列表数据需特殊处理 // 列表数据需特殊处理,传入函数则对列表数据进行转换,函数签名: (listData) => transformedListData
filterListData: { filterListDataFn: {
type: Boolean, type: Function,
default: false default: null
}, },
// 合并单元格方法 // 合并单元格方法
...@@ -584,6 +584,14 @@ export default { ...@@ -584,6 +584,14 @@ export default {
}, },
methods: { methods: {
// 树形表格需 row-key 唯一标识,使用函数确保嵌套行也有有效 key
getRowKey(row) {
const k = this.tableParams.mutiSelectUniqueKey;
const key = (k && row[k]) ?? row.id ?? row.baseGoodsId ?? row.upgradeGoodsId ?? row.commodityCode;
if (key != null && key !== "") return String(key);
this._rowKeyFallback = (this._rowKeyFallback || 0) + 1;
return `row_${this._rowKeyFallback}`;
},
// 表头加图标 // 表头加图标
handleHeaderBatch(currentItem) { handleHeaderBatch(currentItem) {
if (currentItem.headerImgObj.fn) { if (currentItem.headerImgObj.fn) {
...@@ -651,93 +659,15 @@ export default { ...@@ -651,93 +659,15 @@ export default {
// item[this.tableParams.mutiSelectUniqueKey] // item[this.tableParams.mutiSelectUniqueKey]
// })) // }))
// //
res[this.tableParams.listName] && let listData = res[this.tableParams.listName] || []
res[this.tableParams.listName].forEach((val, index) => { listData.forEach((val, index) => {
if (!val.goodsInfo) val.goodsInfo = {} if (!val.goodsInfo) val.goodsInfo = {}
const shopPriceArr = [] val.ownSerialNum = index
val.ownSerialNum = index })
if (this.filterListData) { if (this.filterListDataFn && typeof this.filterListDataFn === "function") {
val.upgradeGoodsList && listData = this.filterListDataFn(listData)
val.upgradeGoodsList.forEach((v) => { }
const { this.data = listData
goodsTypeName,
secondaryGoodsTypeName,
thirdLevelGoodsTypeName
} = val.goodsInfo
const types = [
goodsTypeName,
secondaryGoodsTypeName,
thirdLevelGoodsTypeName
]
v.goodsInfo = {}
shopPriceArr.push(v.upgradePrice)
v.listShowShopPrice = v.upgradePrice
const specificationTypeSequenceArr =
v.specificationTypeSequence?.split(";~;")
const specificationValueSequenceArr =
v?.specificationData?.split(";~;")
const suffixMapping = {
1: "年",
2: "(km/万)",
3: "万"
}
if (specificationTypeSequenceArr?.length) {
specificationValueSequenceArr?.forEach((val, index) => {
const suffix =
suffixMapping[specificationTypeSequenceArr[index]]
if (suffix) {
specificationValueSequenceArr[
index
] = `${val}${suffix}`
}
})
v.listShowSpecificationData =
specificationValueSequenceArr?.join("/")
} else if (v?.specificationData?.includes(";~;")) {
v.listShowSpecificationData =
v?.specificationData?.replace(RegExp(";~;", "g"), "/")
} else {
v.listShowSpecificationData = "-"
}
// v.listShowSpecificationData =
// val.goodsSpecificationNameList?.length > 1
// ? v.specificationData &&
// v.specificationData?.replace(/;~;/g, " ")
// : "-"
v.goodsInfo.goodsName = v.upgradeGoodsName
// v.goodsInfo.goodsTypeName = val.goodsInfo?.goodsTypeName
v.goodsInfo.goodsTypeName = types
.filter((type) => type)
.join("-")
v.goodsInfo.type = v.type || "-"
v.goodsInfo.thumbUrl = val.goodsInfo.thumbUrl
v.goodsSpecificationNameList =
val.goodsSpecificationNameList
v.createdDate = val.createdDate
v.updatedDate = val.updatedDate
v.goodsInfo.brandMerchantName =
val.goodsInfo?.brandMerchantName || "-"
v.goodsInfo.supplierName =
val.goodsInfo?.supplierName || "-"
})
const minPrice = shopPriceArr.length
? Math.min(...shopPriceArr)
: 0
const maxPrice = shopPriceArr.length
? Math.max(...shopPriceArr)
: 0
// 父商品规格数量
val.listShowSpecificationData =
val.goodsSpecificationNameList?.length > 1 &&
val.upgradeGoodsList?.length > 0
? "X" + val.upgradeGoodsList.length
: "-"
val.listShowShopPrice =
minPrice == maxPrice ? maxPrice : minPrice + "~" + maxPrice
val.goodsInfo.type = "-"
}
})
this.data = res[this.tableParams.listName]
if (this.tableParams.needUnique) { if (this.tableParams.needUnique) {
let temp = 1 let temp = 1
this.data.forEach((item) => { this.data.forEach((item) => {
......
...@@ -28,10 +28,10 @@ ...@@ -28,10 +28,10 @@
</div> </div>
</div> </div>
<div class="speci-box" id="specificationDetailList"> <div class="speci-box" id="specificationDetailList">
<singleSpecificationForm ref="singleSpecificationFormRef" v-show="goodsInfoData.specificationType == '1'" <singleSpecificationForm ref="singleSpecificationFormRef" v-if="goodsInfoData.specificationType == '1'"
:product-service-item-list="productServiceItemList" :extend-service-part-list="extendServicePartList"> :product-service-item-list="productServiceItemList" :extend-service-part-list="extendServicePartList">
</singleSpecificationForm> </singleSpecificationForm>
<multipleSpecificationForm ref="multipleSpecificationFormRef" v-show="goodsInfoData.specificationType == '2'" <multipleSpecificationForm ref="multipleSpecificationFormRef" v-if="goodsInfoData.specificationType == '2'"
:product-service-item-list="productServiceItemList" :extend-service-part-list="extendServicePartList"> :product-service-item-list="productServiceItemList" :extend-service-part-list="extendServicePartList">
</multipleSpecificationForm> </multipleSpecificationForm>
</div> </div>
......
/**
* 原生 table 虚拟滚动 mixin
* 使用方需提供: listData, getRowKey, filterRow(可选)
*/
export default {
data() {
return {
virtualScrollTop: 0
}
},
watch: {
virtualScrollDisplayList: {
handler(list) {
const rowHeight = this.virtualScrollRowHeight || 40
if (!list || list.length === 0) {
this.virtualScrollTop = 0
return
}
const maxTop = Math.max(0, (list.length || 0) * rowHeight - (this.virtualScrollContainerHeight || 400))
if (this.virtualScrollTop > maxTop) {
this.virtualScrollTop = maxTop
}
}
}
},
computed: {
virtualScrollDisplayList() {
const list = this.listData || []
const filterRow = this.filterRow || (() => true)
const getRowKey = this.getRowKey || ((item, idx) => 'row-' + idx)
return list
.map((item, idx) => ({
item,
originalIndex: idx,
key: getRowKey.call(this, item, idx)
}))
.filter(({ item }) => filterRow.call(this, item))
},
virtualScrollVisibleRows() {
const list = this.virtualScrollDisplayList
const rowHeight = this.virtualScrollRowHeight || 40
const containerHeight = this.virtualScrollContainerHeight || 400
const buffer = this.virtualScrollBuffer || 5
const start = Math.max(0, Math.floor(this.virtualScrollTop / rowHeight) - buffer)
const visibleCount = Math.ceil(containerHeight / rowHeight)
const end = Math.min(list.length, start + visibleCount + 2 * buffer)
return list.slice(start, end)
},
virtualScrollTotalHeight() {
const list = this.virtualScrollDisplayList
const rowHeight = this.virtualScrollRowHeight || 40
return Math.max(0, (list?.length || 0) * rowHeight)
},
virtualScrollOffsetY() {
const rowHeight = this.virtualScrollRowHeight || 40
const buffer = this.virtualScrollBuffer || 5
const start = Math.max(0, Math.floor(this.virtualScrollTop / rowHeight) - buffer)
return start * rowHeight
}
},
methods: {
virtualScrollOnScroll(e) {
this.virtualScrollTop = e.target.scrollTop
}
}
}
Markdown is supported
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!