selectProduct.data.js
7.87 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
import { get } from "lodash-es";
import { BaseData } from "@/common/constants";
import { isZeroOrNumber } from "@/libs/number";
import store from "@/store";
import { convertYuanToWan, filterSpecsStr } from "@/views/goods/filterOption";
import { isExtendedWarranty, isMembraneType, isOfficialRightsService, isThirdPart } from "@/views/goods/shelfProduct/utils/businessCheck";
let positionOption = [];
function getUpgradeGoods(product, path = "detailList.0.upgradeGoods") {
return get(product, path) || { goodsInfo: {} };
}
// 商品嵌套的UpgradeGoods
export async function getUpgradeGoodsDescriptionSchema() {
if (!positionOption || !positionOption.length) {
positionOption = await store.dispatch("d2admin/base/get", BaseData.positionTypeList);
}
return [
{ name: "detailList.0.upgradeGoods.upgradeGoodsName", label: "产品名称", col: 8 },
{
name: "detailList.0.upgradeGoods.specificationData",
label: "规格",
col: 8,
render(h, { data }) {
return h(
"span",
filterSpecsStr(data.detailList[0].upgradeGoods),
);
},
},
{
name: "detailList.0.upgradeGoods.type",
label: "产品编码",
col: 8,
render(h, { data, schemaItem }) {
const value = get(data, schemaItem.name);
return h(
"span",
value || "-",
);
},
},
{
name: "detailList.0.upgradeGoods.thirdPartyCode",
label: "供应商编码",
col: 8,
render(h, { data, schemaItem }) {
const value = get(data, schemaItem.name);
return h(
"span",
value || "-",
);
},
},
// {
// name: "detailList.0.upgradeGoods.purchasePrice",
// label: "采购价/卷",
// col: 8,
// render(h, { data, schemaItem }) {
// const value = isZeroOrNumber(get(data, schemaItem.name));
// return h(
// "span",
// value === "-" ? value : `${value}元`,
// );
// },
// },
{
name: "detailList.0.upgradeGoods.upgradePrice",
label: "参考售价/件",
col: 8,
render(h, { data, schemaItem }) {
const value = isZeroOrNumber(get(data, schemaItem.name));
return h(
"span",
value === "-" ? value : `${value}元`,
);
},
},
{
name: "detailList.0.upgradeGoods.carTypeConfigList",
label: "适用车型",
col: 8,
tooltip: true,
tooltipProps: {
effect: "dark",
placement: "right",
style: { "display": "inline-block", "width": "auto", "max-width": "100%" },
render(h, { data, schemaItem }) {
const list = get(data, schemaItem.name);
const seriesNameList = list?.map(item => item.seriesName);
const names = seriesNameList?.join("/") || "-";
return h(
"span",
names,
);
},
},
render(h, { data, schemaItem }) {
const list = get(data, schemaItem.name);
const seriesNameList = list?.map(item => item.seriesName);
const names = seriesNameList?.join("/") || "-";
return h(
"span",
{
class: "text-hide",
},
names,
);
},
},
{
name: "detailList.0.upgradeGoods.goodsInfo.goodsName",
label: "所属系列",
col: 8,
render(h, { data, schemaItem }) {
return h(
"span",
get(data, schemaItem.name) ?? "-",
);
},
},
{
name: "detailList.0.upgradeGoods.goodsInfo",
label: "所属分类",
col: 8,
render(h, { data, schemaItem }) {
const goodsInfo = get(data, schemaItem.name);
if (!goodsInfo) {
return h("span", "-");
}
const types = [goodsInfo?.goodsTypeName];
if (goodsInfo?.secondaryGoodsTypeName) {
types.push(goodsInfo?.secondaryGoodsTypeName);
}
if (goodsInfo?.thirdLevelGoodsTypeName) {
types.push(goodsInfo?.thirdLevelGoodsTypeName);
}
return h(
"span",
types ? types.join("/") : "-",
);
},
},
{ name: "detailList.0.upgradeGoods.commodityCode", label: "产品ID", col: 8 },
{
name: "detailList.0.upgradeGoods.djCost",
label: "嘀加成本/件",
col: 8,
render(h, { data, schemaItem }) {
const value = isZeroOrNumber(get(data, schemaItem.name));
return h(
"span",
value === "-" ? value : `${value}元`,
);
},
isHide: ({ formModel }) => {
const upgradeGoods = getUpgradeGoods(formModel);
const goodsType = upgradeGoods?.goodsInfo?.goodsType;
const supplierCode = upgradeGoods?.goodsInfo?.supplierCode;
//
return !((isOfficialRightsService(goodsType) || isExtendedWarranty(goodsType)) && !isThirdPart(supplierCode));
},
},
// {
// name: "detailList.0.upgradeGoods.position",
// label: "部位",
// col: 8,
// render(h, { data, schemaItem }) {
// function result(value) {
// return h("span", value);
// }
// const value = get(data, schemaItem.name);
// if (!value) {
// return result("-");
// }
// const val = String(value).split(",");
// const positions = positionOption.filter(item => val.includes(String(item.position))) || [];
// if (!positions.length) {
// return result("-");
// }
// const names = positions.map(item => item.confName);
// return result(names?.join("/"));
// },
// isHide: ({ formModel }) => {
// return formModel?.detailList?.[0]?.goodsType !== 1;
// },
// },
{
name: "detailList.0.upgradeGoods.upgradeGoodsServiceItemsList",
label: "服务项目",
col: 8,
tooltip: true,
tooltipProps: {
effect: "dark",
placement: "bottom",
style: { "display": "inline-block", "width": "auto", "max-width": "100%" },
render(h, { data, schemaItem }) {
const list = get(data, schemaItem.name);
const upgradeGoodsServiceItemsList = list?.map((item) => {
return `${item.serviceName}-${item.serviceGrade}/${item.servicePeriod}${(item.serviceItemId) ? `/${convertYuanToWan(item.minPrice)}-${convertYuanToWan(item.maxPrice)}万` : ""}`;
});
const value = upgradeGoodsServiceItemsList?.join(",") || "-";
return h(
"span",
value,
);
},
},
render(h, { data, schemaItem }) {
const list = get(data, schemaItem.name);
const upgradeGoodsServiceItemsList = list?.map((item) => {
return `${item.serviceName}-${item.serviceGrade}/${item.servicePeriod}${(item.serviceItemId) ? `/${convertYuanToWan(item.minPrice)}-${convertYuanToWan(item.maxPrice)}万` : ""}`;
});
const value = upgradeGoodsServiceItemsList?.join(",") || "-";
return h(
"span",
{
class: "text-hide",
},
value,
);
},
isHide: ({ formModel }) => {
// 产品分类 权益类(供应方为非第三方)
const upgradeGoods = getUpgradeGoods(formModel);
const goodsType = upgradeGoods?.goodsInfo?.goodsType;
const supplierCode = upgradeGoods?.goodsInfo?.supplierCode;
return !(isOfficialRightsService(goodsType) && !isThirdPart(supplierCode));
},
},
{
name: "detailList.0.upgradeGoods.entityCardFlag",
label: "实体卡",
col: 8,
render(h, { data, schemaItem }) {
const value = get(data, schemaItem.name);
return h(
"span",
value === "Y" ? "是" : "否",
);
},
// 权益升级显示
isHide: ({ formModel }) => {
const upgradeGoods = getUpgradeGoods(formModel);
const goodsType = upgradeGoods?.goodsInfo?.goodsType;
return !isOfficialRightsService(goodsType);
},
},
{
name: "detailList.0.upgradeGoods.warrantyPeriod",
label: "质保年限/年",
col: 8,
render(h, { data, schemaItem }) {
const value = isZeroOrNumber(get(data, schemaItem.name));
return h(
"span",
value === "-" ? value : `${value}年`,
);
},
// 膜类展示
isHide: ({ formModel }) => {
const upgradeGoods = getUpgradeGoods(formModel);
const goodsType = upgradeGoods?.goodsInfo?.goodsType;
return !isMembraneType(goodsType);
},
},
{
name: "detailList.0.upgradeGoods.operationCost",
label: "运营成本/元",
col: 8,
render(h, { data, schemaItem }) {
const value = isZeroOrNumber(get(data, schemaItem.name));
return h(
"span",
value === "-" ? value : `${value}元`,
);
},
},
];
}