jufubao-admin-library 1.1.211 → 1.1.212

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -24,7 +24,7 @@
24
24
  <xd-dialog
25
25
  :show.sync="showAdjust"
26
26
  title="手动调整售价"
27
- width="600px"
27
+ width="60%"
28
28
  @onConfirm="handleAdjustConfirm"
29
29
  >
30
30
  <xd-base-dynamic-field
@@ -69,6 +69,93 @@
69
69
  <div><el-input class="input50" type="number" v-model="showVipSelectPrice" disabled></el-input></div>
70
70
  </div>
71
71
  </template>
72
+ <template slot="sku_table">
73
+ <div style="margin-top: 20px;">
74
+ <div style="display: flex; justify-content: space-between; align-items: center; margin-bottom: 10px;">
75
+ <h3 style="font-size: 16px; font-weight: 500; margin: 0;">规格调价</h3>
76
+ <el-button
77
+ type="primary"
78
+ size="small"
79
+ @click="handleAddSkuAdjust"
80
+ :disabled="skuAdjustList.length >= 10"
81
+ >新增规格调价(最多10个)</el-button>
82
+ </div>
83
+ <el-table
84
+ :data="skuAdjustList"
85
+ border
86
+ stripe
87
+ style="width: 100%"
88
+ size="small"
89
+ >
90
+ <el-table-column
91
+ prop="sku_name"
92
+ label="规格"
93
+ min-width="120"
94
+ />
95
+ <el-table-column
96
+ prop="base_label"
97
+ label="基于价格"
98
+ min-width="100"
99
+ />
100
+ <el-table-column
101
+ prop="original_price"
102
+ label="调整原始价格"
103
+ min-width="120"
104
+ >
105
+ <template slot-scope="scope">
106
+ {{ scope.row.original_price }}元
107
+ </template>
108
+ </el-table-column>
109
+ <el-table-column
110
+ prop="unit_label"
111
+ label="调价方式"
112
+ min-width="80"
113
+ />
114
+ <el-table-column
115
+ prop="adjust_value"
116
+ label="上调/下调"
117
+ min-width="100"
118
+ >
119
+ <template slot-scope="scope">
120
+ {{ scope.row.adjust_value }}{{ scope.row.unit === 'ratio' ? '%' : '元' }}
121
+ </template>
122
+ </el-table-column>
123
+ <el-table-column
124
+ prop="decimal_label"
125
+ label="小数点保留"
126
+ min-width="100"
127
+ />
128
+ <el-table-column
129
+ prop="adjusted_price"
130
+ label="调整后售价"
131
+ min-width="100"
132
+ >
133
+ <template slot-scope="scope">
134
+ {{ scope.row.adjusted_price }}元
135
+ </template>
136
+ </el-table-column>
137
+ <el-table-column
138
+ label="操作"
139
+ min-width="100"
140
+ align="center"
141
+ >
142
+ <template slot-scope="scope">
143
+ <el-button
144
+ type="text"
145
+ size="small"
146
+ @click="handleEditSkuAdjust(scope.row)"
147
+ >编辑</el-button>
148
+ <el-button
149
+ type="text"
150
+ size="small"
151
+ @click="handleDeleteSkuAdjust(scope.$index)"
152
+ style="color: #ff4d4f;"
153
+ >删除</el-button>
154
+ </template>
155
+ </el-table-column>
156
+ </el-table>
157
+ </div>
158
+ </template>
72
159
  </xd-base-dynamic-field>
73
160
  <xd-dialog
74
161
  v-if="showDesire"
@@ -102,6 +189,41 @@
102
189
  </el-form>
103
190
  </div>
104
191
  </xd-dialog>
192
+ <!-- 新增规格调价弹框 -->
193
+ <xd-dialog
194
+ v-if="showAddSkuAdjust"
195
+ :show.sync="showAddSkuAdjust"
196
+ width="50%"
197
+ @onConfirm="handleAddSkuAdjustConfirm"
198
+ :title="currentEditSku ? '编辑规格调价' : '新增规格调价'"
199
+ >
200
+ <xd-base-dynamic-field
201
+ ref="skuAdjust"
202
+ v-if="skuAdjustStatus && skuAdjustForm.length > 0"
203
+ v-model="skuAdjustValue"
204
+ :list="skuAdjustForm"
205
+ :key="skuAdjustKey"
206
+ label-width="130px"
207
+ >
208
+ <template slot="showSkuOriginalPrice">
209
+ <div class="show-price">
210
+ <div>调整原始价格:</div>
211
+ <div><el-input class="input50" type="number" v-model="showSkuOriginalPrice" disabled></el-input></div>
212
+ </div>
213
+ </template>
214
+ <template slot="skuDesire">
215
+ <el-form-item prop="skuDesire" label="">
216
+ <el-button type="primary" size="small" @click="handleSetSkuDesire">设置期望售价</el-button>
217
+ </el-form-item>
218
+ </template>
219
+ <template slot="showSkuAdjustedPrice">
220
+ <div class="show-price">
221
+ <div>调整后售价:</div>
222
+ <div><el-input class="input50" type="number" v-model="showSkuAdjustedPrice" disabled></el-input></div>
223
+ </div>
224
+ </template>
225
+ </xd-base-dynamic-field>
226
+ </xd-dialog>
105
227
  </xd-dialog>
106
228
  <xd-dialog
107
229
  v-if="showPublicSet"
@@ -147,6 +269,13 @@
147
269
 
148
270
  </el-form>
149
271
  </xd-dialog>
272
+ <xd-dialog :show.sync="showSkuDesire" title="设置规格期望售价" width="400px" @onConfirm="handleSkuDesire">
273
+ <el-form ref="skuDesireForm" :model="skuDesireForm" :rules="rules" label-width="120px">
274
+ <el-form-item prop="price" label="期望售价">
275
+ <el-input v-model.number="skuDesireForm.price" type="number" placeholder="请输入期望售价" step="0.01"></el-input>
276
+ </el-form-item>
277
+ </el-form>
278
+ </xd-dialog>
150
279
  <xd-dialog :show.sync="showOpen" title="发票名称设置" width="600px" @onConfirm="handleOpenConfirm">
151
280
  <xd-base-dynamic-field
152
281
  ref="open"
@@ -173,6 +302,7 @@
173
302
  <script>
174
303
  import XdDialog from "@/components/XdDialog"
175
304
  import { getOptions } from "@/utils/options"
305
+ import XdTable from "@/components/XdTable"
176
306
  import XdBaseDynamicField from "@/components/XdBaseDynamicField"
177
307
  import checkPermission from "@/utils/permission"
178
308
  import { mapActions, mapState } from "vuex"
@@ -180,7 +310,8 @@ export default {
180
310
  name: "JfbProductDialog",
181
311
  components: {
182
312
  XdDialog,
183
- XdBaseDynamicField
313
+ XdBaseDynamicField,
314
+ XdTable,
184
315
  },
185
316
  watch: {
186
317
  'adjustListValue.unit' : {
@@ -197,6 +328,91 @@ export default {
197
328
  }
198
329
  }
199
330
  },
331
+ 'skuAdjustValue.unit': {
332
+ handler(n,o){
333
+ if(n&&n!==o){
334
+ // 切换单位时清空另一个单位的值
335
+ if(n === 'ratio') {
336
+ this.skuAdjustValue.moneyValue = '';
337
+ } else {
338
+ this.skuAdjustValue.ratioValue = '';
339
+ }
340
+ this.getSkuAdjustForm(this.skuAdjustValue);
341
+ }
342
+ }
343
+ },
344
+ // 手动调整售价 - 切换基于价格类型时重新计算
345
+ 'adjustListValue.base': {
346
+ handler(n,o){
347
+ if(n && n !== o && this.desireForm.price){
348
+ // 重新计算上调/下调值
349
+ let unit = 'moneyValue';
350
+ if(this.adjustListValue['unit'] === 'ratio') unit = 'ratioValue';
351
+ let price = this.dialogRow['specs'][n];
352
+ if(price){
353
+ let value = this.$xdHelper.divisionFloatNumber(this.$xdHelper.multiplyFloatNumber(this.desireForm.price, 100) - price, price);
354
+ this.adjustListValue[unit] = this.$xdHelper.multiplyFloatNumber(value, 100).toFixed(2);
355
+ this.getAdjustForm(this.adjustListValue);
356
+ this.adjustListKey = Date.now();
357
+ }
358
+ }
359
+ }
360
+ },
361
+ // 规格调价 - 切换基于价格类型时重新计算
362
+ 'skuAdjustValue.base': {
363
+ handler(n,o){
364
+ if(n && n !== o && this.skuDesireForm.price){
365
+ // 重新计算上调/下调值
366
+ let unit = 'moneyValue';
367
+ if(this.skuAdjustValue['unit'] === 'ratio') unit = 'ratioValue';
368
+
369
+ const skuData = this.skuList.find(sku => sku.value === this.skuAdjustValue.product_sku);
370
+ if (skuData && skuData.prices[n]) {
371
+ let price = skuData.prices[n];
372
+ let value = this.$xdHelper.divisionFloatNumber(this.$xdHelper.multiplyFloatNumber(this.skuDesireForm.price, 100) - price, price);
373
+ this.skuAdjustValue[unit] = this.$xdHelper.multiplyFloatNumber(value, 100).toFixed(2);
374
+ this.getSkuAdjustForm(this.skuAdjustValue);
375
+ this.skuAdjustKey = Date.now();
376
+ }
377
+ }
378
+ }
379
+ },
380
+ // VIP价格 - 切换基于价格类型时重新计算
381
+ 'adjustListValue.vip_base': {
382
+ handler(n,o){
383
+ if(n && n !== o && this.vipDesireForm.price){
384
+ // 重新计算上调/下调值
385
+ let unit = 'vipMoneyValue';
386
+ if(this.adjustListValue['vip_unit'] === 'ratio') unit = 'vipRatioValue';
387
+ let price = this.dialogRow['specs'][n];
388
+ if(price){
389
+ let value = this.$xdHelper.divisionFloatNumber(this.$xdHelper.multiplyFloatNumber(this.vipDesireForm.price, 100) - price, price);
390
+ this.adjustListValue[unit] = this.$xdHelper.multiplyFloatNumber(value, 100).toFixed(2);
391
+ this.getAdjustForm(this.adjustListValue);
392
+ this.adjustListKey = Date.now();
393
+ }
394
+ }
395
+ }
396
+ },
397
+ // 规格调价 - 切换商品规格时重新计算
398
+ 'skuAdjustValue.product_sku': {
399
+ handler(n,o){
400
+ if(n && n !== o && this.skuDesireForm.price && this.skuAdjustValue.base){
401
+ // 重新计算上调/下调值
402
+ let unit = 'moneyValue';
403
+ if(this.skuAdjustValue['unit'] === 'ratio') unit = 'ratioValue';
404
+
405
+ const skuData = this.skuList.find(sku => sku.value === n);
406
+ if (skuData && skuData.prices[this.skuAdjustValue.base]) {
407
+ let price = skuData.prices[this.skuAdjustValue.base];
408
+ let value = this.$xdHelper.divisionFloatNumber(this.$xdHelper.multiplyFloatNumber(this.skuDesireForm.price, 100) - price, price);
409
+ this.skuAdjustValue[unit] = this.$xdHelper.multiplyFloatNumber(value, 100).toFixed(2);
410
+ this.getSkuAdjustForm(this.skuAdjustValue);
411
+ this.skuAdjustKey = Date.now();
412
+ }
413
+ }
414
+ }
415
+ },
200
416
  },
201
417
 
202
418
  data () {
@@ -259,6 +475,11 @@ export default {
259
475
  { required: true, message: '请输入期望售价', trigger: 'change' }
260
476
  ],
261
477
  },
478
+ // 规格期望售价
479
+ showSkuDesire: false,
480
+ skuDesireForm: {
481
+ price: ''
482
+ },
262
483
  setRules:{
263
484
  public: [
264
485
  { required: true, message: '请选择是否公开', trigger: 'change' }
@@ -267,6 +488,16 @@ export default {
267
488
  { required: true, message: '请选择标签', trigger: 'change' }
268
489
  ],
269
490
  },
491
+ //规格调价相关
492
+ skuAdjustList: [],
493
+ showAddSkuAdjust: false,
494
+ skuAdjustForm: [],
495
+ skuAdjustValue: {},
496
+ skuAdjustKey: 'skuAdjustKey',
497
+ skuAdjustStatus: false,
498
+ skuList: [],
499
+ currentEditSku: null,
500
+ sku_count: 0,
270
501
  }
271
502
  },
272
503
  computed: {
@@ -347,6 +578,45 @@ export default {
347
578
  let price = this.dialogRow['specs'][this.adjustListValue.vip_base];
348
579
  return this.$xdHelper.divisionFloatNumber(price, 100)
349
580
  },
581
+ showSkuOriginalPrice(){
582
+ if(!this.skuAdjustValue.product_sku || !this.skuAdjustValue.base) return '';
583
+ let skuData = this.skuList.find(sku => sku.value === this.skuAdjustValue.product_sku);
584
+ if(!skuData || !skuData.prices[this.skuAdjustValue.base]) return '';
585
+ let price = skuData.prices[this.skuAdjustValue.base];
586
+ return this.$xdHelper.divisionFloatNumber(price, 100);
587
+ },
588
+ showSkuAdjustedPrice(){
589
+ if(!this.skuAdjustValue.product_sku || !this.skuAdjustValue.base || !this.skuAdjustValue.unit) return '';
590
+ let skuData = this.skuList.find(sku => sku.value === this.skuAdjustValue.product_sku);
591
+ if(!skuData || !skuData.prices[this.skuAdjustValue.base]) return '';
592
+
593
+ const handle = (price, value, type) => {
594
+ let toFixed = 0;
595
+ if(this.skuAdjustValue.decimal > 0) toFixed = this.skuAdjustValue.decimal;
596
+ let temp = 0;
597
+ if(type) {
598
+ value = this.$xdHelper.multiplyFloatNumber(value, 100);
599
+ temp = this.$xdHelper.addFloatNumber(value, price)
600
+ } else {
601
+ value = this.$xdHelper.addFloatNumber(this.$xdHelper.divisionFloatNumber(value, 100), 1);
602
+ temp = this.$xdHelper.multiplyFloatNumber(value, price)
603
+ }
604
+ let priceNew = this.$xdHelper.divisionFloatNumber(temp, 100);
605
+ return this.$xdHelper.divisionFloatNumber(priceNew * Math.pow(10, toFixed), Math.pow(10, toFixed), toFixed).toFixed(this.skuAdjustValue.decimal)
606
+ };
607
+
608
+ let price = skuData.prices[this.skuAdjustValue.base];
609
+ let value = null;
610
+ if(this.skuAdjustValue.unit === 'money') {
611
+ if(this.skuAdjustValue.moneyValue !== '') value = Number(this.skuAdjustValue.moneyValue);
612
+ }
613
+ if(this.skuAdjustValue.unit === 'ratio') {
614
+ if(this.skuAdjustValue.ratioValue !== '') value = Number(this.skuAdjustValue.ratioValue);
615
+ }
616
+ if(value === null) return '';
617
+
618
+ return handle(price, value, this.skuAdjustValue.unit === 'money');
619
+ },
350
620
  isShowVipSet(){
351
621
  return this.channelParams.group_key&&this.channelParams.group_key==='vip'
352
622
  }
@@ -372,8 +642,9 @@ export default {
372
642
 
373
643
  //手动调整售价
374
644
  if (this.dialogType === 'showAdjust') {
375
- let { id, product_id, product_name } = this.dialogRow;
645
+ let { id, product_id, product_name,sku_count } = this.dialogRow;
376
646
  product_id = product_id || id;
647
+ this.sku_count = sku_count||0;
377
648
  let info = await this.getOnePriceInfo({ product_id });
378
649
  this.priceTypeList = info.data['price_options'];
379
650
  let params = info.data['formula']['price'];
@@ -739,6 +1010,10 @@ export default {
739
1010
  ele: 'slot',
740
1011
  slot:'showVipPrice'
741
1012
  },
1013
+ this.sku_count>1&&{
1014
+ ele:'slot',
1015
+ slot:'sku_table'
1016
+ }
742
1017
  ].filter(i => i)
743
1018
  this.adjustListKey = Date.now()
744
1019
  },
@@ -786,7 +1061,7 @@ export default {
786
1061
  if(this.adjustListValue['vip_unit'] === 'ratio') unit = 'vipRatioValue';
787
1062
  let price = this.dialogRow['specs'][this.adjustListValue['vip_base']];
788
1063
  let value = this.$xdHelper.divisionFloatNumber( this.$xdHelper.multiplyFloatNumber(this.desireVipForm.price, 100) - price, price);
789
- this.adjustListValue[vip_unit] = this.$xdHelper.multiplyFloatNumber(value, 100).toFixed(2);
1064
+ this.adjustListValue[unit] = this.$xdHelper.multiplyFloatNumber(value, 100).toFixed(2);
790
1065
  this.getAdjustForm(this.adjustListValue);
791
1066
  this.adjustListKey = Date.now()
792
1067
  this.showVipDesire = false
@@ -796,6 +1071,38 @@ export default {
796
1071
  });
797
1072
  // this.desireForm.price:''
798
1073
  },
1074
+ /**设置规格期望售价**/
1075
+ handleSetSkuDesire(){
1076
+ if(!this.skuAdjustValue.product_sku || !this.skuAdjustValue.base){
1077
+ this.$message.error('请选择商品规格和基于类型');
1078
+ return;
1079
+ }
1080
+ this.showSkuDesire = true;
1081
+ },
1082
+ /**设置规格期望售价确定**/
1083
+ handleSkuDesire(){
1084
+ this.$refs['skuDesireForm'].validate((valid) => {
1085
+ if (valid) {
1086
+ if(!this.skuAdjustValue.product_sku || !this.skuAdjustValue.base || !this.skuDesireForm.price) return false;
1087
+
1088
+ let unit = 'moneyValue';
1089
+ if(this.skuAdjustValue['unit'] === 'ratio') unit = 'ratioValue';
1090
+
1091
+ const skuData = this.skuList.find(sku => sku.value === this.skuAdjustValue.product_sku);
1092
+ if (!skuData || !skuData.prices[this.skuAdjustValue.base]) return false;
1093
+
1094
+ let price = skuData.prices[this.skuAdjustValue.base];
1095
+ let value = this.$xdHelper.divisionFloatNumber(this.$xdHelper.multiplyFloatNumber(this.skuDesireForm.price, 100) - price, price);
1096
+ this.skuAdjustValue[unit] = this.$xdHelper.multiplyFloatNumber(value, 100).toFixed(2);
1097
+
1098
+ this.getSkuAdjustForm(this.skuAdjustValue);
1099
+ this.skuAdjustKey = Date.now();
1100
+ this.showSkuDesire = false;
1101
+ } else {
1102
+ return false;
1103
+ }
1104
+ });
1105
+ },
799
1106
  getAdjustParams () {
800
1107
  const { product_id, unit, base,decimal,ratioValue, moneyValue,vip_unit, vip_base,vip_decimal,vipRatioValue, vipMoneyValue} = this.adjustListValue;
801
1108
  let value = 0;
@@ -804,38 +1111,68 @@ export default {
804
1111
  let vip_value = 0;
805
1112
  if(vip_unit === 'ratio') vip_value = Number(vipRatioValue);
806
1113
  if(vip_unit === 'money') vip_value = Number(vipMoneyValue);
1114
+
1115
+ const formula = {
1116
+ sale_price: {
1117
+ unit,
1118
+ base,
1119
+ value: this.$xdHelper.multiplyFloatNumber(Number(value), 100),
1120
+ decimal
1121
+ }
1122
+ };
1123
+
807
1124
  if(this.isShowVipSet){
808
- return {
809
- product_id,
810
- formula: {
1125
+ formula.vip_price = {
1126
+ unit:vip_unit,
1127
+ base:vip_base,
1128
+ value: this.$xdHelper.multiplyFloatNumber(Number(vip_value), 100),
1129
+ decimal:vip_decimal
1130
+ };
1131
+ }
1132
+
1133
+ const params = {
1134
+ product_id,
1135
+ formula
1136
+ };
1137
+
1138
+ // 添加规格调价信息到skus数组
1139
+ if(this.skuAdjustList && this.skuAdjustList.length > 0){
1140
+ params.skus = this.skuAdjustList.map(item => {
1141
+ let sku_value = 0;
1142
+ if(item.unit === 'ratio') sku_value = Number(item.adjust_value);
1143
+ if(item.unit === 'money') sku_value = Number(item.adjust_value);
1144
+
1145
+ const skuFormula = {
811
1146
  sale_price: {
812
- unit,
813
- base,
814
- value: this.$xdHelper.multiplyFloatNumber(Number(value), 100),
815
- decimal
816
- },
817
- vip_price:{
818
- unit:vip_unit,
819
- base:vip_base,
820
- value: this.$xdHelper.multiplyFloatNumber(Number(vip_value), 100),
821
- decimal:vip_decimal
1147
+ unit: item.unit,
1148
+ base: item.base,
1149
+ value: this.$xdHelper.multiplyFloatNumber(Number(sku_value), 100),
1150
+ decimal: item.decimal
822
1151
  }
1152
+ };
1153
+
1154
+ // 如果支持VIP价格,添加vip_price到规格的formula中
1155
+ if(this.isShowVipSet && item.vip_unit && item.vip_base){
1156
+ let vip_sku_value = 0;
1157
+ if(item.vip_unit === 'ratio') vip_sku_value = Number(item.vip_adjust_value);
1158
+ if(item.vip_unit === 'money') vip_sku_value = Number(item.vip_adjust_value);
1159
+
1160
+ skuFormula.vip_price = {
1161
+ unit: item.vip_unit,
1162
+ base: item.vip_base,
1163
+ value: this.$xdHelper.multiplyFloatNumber(Number(vip_sku_value), 100),
1164
+ decimal: item.vip_decimal
1165
+ };
823
1166
  }
824
- }
825
- }else{
826
- return {
827
- product_id,
828
- formula: {
829
- sale_price: {
830
- unit,
831
- base,
832
- value: this.$xdHelper.multiplyFloatNumber(Number(value), 100),
833
- decimal
834
- },
835
- }
836
- }
1167
+
1168
+ return {
1169
+ product_sku: item.product_sku,
1170
+ formula: skuFormula
1171
+ };
1172
+ });
837
1173
  }
838
1174
 
1175
+ return params;
839
1176
  },
840
1177
 
841
1178
  handleAdjustConfirm () {
@@ -997,6 +1334,271 @@ export default {
997
1334
  })
998
1335
  },
999
1336
 
1337
+ //==规格调价相关方法==============================
1338
+ async handleAddSkuAdjust() {
1339
+ if (!this.skuList || this.skuList.length === 0) {
1340
+ await this.getSkuList();
1341
+ }
1342
+ this.currentEditSku = null;
1343
+ this.skuAdjustValue = {
1344
+ product_sku: '',
1345
+ base: '',
1346
+ unit: 'money',
1347
+ decimal: 2,
1348
+ moneyValue: '',
1349
+ ratioValue: ''
1350
+ };
1351
+ this.getSkuAdjustForm(this.skuAdjustValue);
1352
+ this.skuAdjustStatus = true;
1353
+ this.showAddSkuAdjust = true;
1354
+ },
1355
+
1356
+ handleEditSkuAdjust(row) {
1357
+ this.currentEditSku = row;
1358
+ this.skuAdjustValue = {
1359
+ product_sku: row.product_sku,
1360
+ base: row.base,
1361
+ unit: row.unit,
1362
+ decimal: row.decimal,
1363
+ moneyValue: row.unit === 'money' ? row.adjust_value : '',
1364
+ ratioValue: row.unit === 'ratio' ? row.adjust_value : ''
1365
+ };
1366
+ // 如果是按比例,回显期望售价为调整后售价
1367
+ if (row.unit === 'ratio') {
1368
+ this.skuDesireForm.price = row.adjusted_price;
1369
+ }
1370
+ this.getSkuAdjustForm(this.skuAdjustValue);
1371
+ this.skuAdjustStatus = true;
1372
+ this.showAddSkuAdjust = true;
1373
+ },
1374
+
1375
+ handleDeleteSkuAdjust(index) {
1376
+ this.$confirm('确定要删除该规格调价吗?', '提示', {
1377
+ confirmButtonText: '确定',
1378
+ cancelButtonText: '取消',
1379
+ type: 'warning'
1380
+ }).then(() => {
1381
+ this.skuAdjustList.splice(index, 1);
1382
+ this.$message({
1383
+ type: 'success',
1384
+ message: '删除成功!'
1385
+ });
1386
+ }).catch(() => {
1387
+ // 用户取消删除
1388
+ });
1389
+ },
1390
+
1391
+ handleAddSkuAdjustConfirm() {
1392
+ this.$refs['skuAdjust'].submitAll()
1393
+ .then(res => {
1394
+ const { product_sku, base, unit, decimal, moneyValue, ratioValue } = this.skuAdjustValue;
1395
+ const skuData = this.skuList.find(sku => sku.value === product_sku);
1396
+ if (!skuData) return;
1397
+
1398
+ // 检查是否已存在该sku的调价记录(编辑时除外)
1399
+ if (!this.currentEditSku) {
1400
+ const existingSku = this.skuAdjustList.find(item => item.product_sku === product_sku);
1401
+ if (existingSku) {
1402
+ this.$message.error('该规格已存在调价记录,不能重复添加');
1403
+ return;
1404
+ }
1405
+ }
1406
+
1407
+ const originalPrice = this.$xdHelper.divisionFloatNumber(skuData.prices[base], 100);
1408
+ const adjustValue = unit === 'money' ? moneyValue : ratioValue;
1409
+ const adjustedPrice = this.showSkuAdjustedPrice;
1410
+
1411
+ const adjustItem = {
1412
+ product_sku,
1413
+ sku_name: skuData.label,
1414
+ base,
1415
+ base_label: this.priceTypeList.find(item => item.value === base)?.label || base,
1416
+ unit,
1417
+ unit_label: unit === 'money' ? '按金额' : '按比例',
1418
+ decimal,
1419
+ decimal_label: decimal === -1 ? '零位' : decimal === 1 ? '一位' : '两位',
1420
+ adjust_value: adjustValue,
1421
+ original_price: originalPrice,
1422
+ adjusted_price: adjustedPrice
1423
+ };
1424
+
1425
+ if (this.currentEditSku) {
1426
+ const index = this.skuAdjustList.findIndex(item => item.product_sku === this.currentEditSku.product_sku);
1427
+ if (index !== -1) {
1428
+ this.$set(this.skuAdjustList, index, adjustItem);
1429
+ }
1430
+ } else {
1431
+ this.skuAdjustList.push(adjustItem);
1432
+ }
1433
+
1434
+ this.showAddSkuAdjust = false;
1435
+ this.skuAdjustStatus = false;
1436
+ this.currentEditSku = null;
1437
+ this.skuDesireForm.price = '';
1438
+ this.$message({
1439
+ message: '操作成功',
1440
+ type: 'success'
1441
+ });
1442
+ })
1443
+ .catch(err => {
1444
+ console.log(err, 'err');
1445
+ });
1446
+ },
1447
+
1448
+ async getSkuList() {
1449
+ if (!this.dialogRow.product_id) return;
1450
+ try {
1451
+ let res = await getOptions({
1452
+ server: 'product-partner',
1453
+ fn: 'selected-products-skus',
1454
+ path: 'p3',
1455
+ params:{
1456
+ product_id:this.dialogRow.product_id
1457
+ }
1458
+ })
1459
+ console.log(res,'aaaaaa')
1460
+ this.skuList = res.data.list
1461
+ } catch (error) {
1462
+ console.error('获取商品规格失败:', error);
1463
+ }
1464
+ },
1465
+
1466
+ getSkuAdjustForm(params) {
1467
+ // 确保当切换单位时,清空另一个单位的值
1468
+ if (params.unit === 'ratio' && params.moneyValue !== '') {
1469
+ this.skuAdjustValue.moneyValue = '';
1470
+ }
1471
+ if (params.unit === 'money' && params.ratioValue !== '') {
1472
+ this.skuAdjustValue.ratioValue = '';
1473
+ }
1474
+
1475
+ this.skuAdjustForm = [
1476
+ {
1477
+ label: '商品规格:',
1478
+ ele: 'xd-select-list',
1479
+ valueKey: 'product_sku',
1480
+ value: params.product_sku || '',
1481
+ placeholder: '请选择商品规格',
1482
+ multiple: false,
1483
+ list: this.skuList,
1484
+ rules: [{
1485
+ required: true,
1486
+ message: '请选择商品规格',
1487
+ trigger: 'change'
1488
+ }],
1489
+ className: 'input70',
1490
+ inline: true
1491
+ },
1492
+ {
1493
+ label: '基于:',
1494
+ ele: 'xd-select-list',
1495
+ valueKey: 'base',
1496
+ value: params.base || '',
1497
+ placeholder: '请选择调价基准类型',
1498
+ multiple: false,
1499
+ list: this.priceTypeList,
1500
+ disabled: this.priceTypeList.length === 1,
1501
+ className: 'input70',
1502
+ rules: [{
1503
+ required: true,
1504
+ message: '请选择调价基准类型',
1505
+ trigger: 'change'
1506
+ }],
1507
+ notice: '<span style="color:#000; font-size: 14px;">调整</span><span style="color:#f00; font-size: 14px;">售价</span>',
1508
+ inline: true
1509
+ },
1510
+ {
1511
+ keys: Date.now(),
1512
+ label: "",
1513
+ ele: 'slot',
1514
+ slot: 'showSkuOriginalPrice'
1515
+ },
1516
+ {
1517
+ label: "",
1518
+ ele: "xd-radio",
1519
+ valueKey: "unit",
1520
+ value: params.unit || 'money',
1521
+ list: [
1522
+ { "label": "按金额", "value": "money" },
1523
+ { "label": "按比例", "value": "ratio" },
1524
+ ],
1525
+ },
1526
+ this.skuAdjustValue.unit==='ratio' && {
1527
+ keys: Date.now(),
1528
+ label: "",
1529
+ ele: 'slot',
1530
+ slot: 'skuDesire'
1531
+ },
1532
+ params.unit === 'ratio' && {
1533
+ label: '上调/下调:',
1534
+ ele: 'xd-input-unit',
1535
+ valueKey: 'ratioValue',
1536
+ keys: Date.now(),
1537
+ value: params['ratioValue'],
1538
+ className: 'input50',
1539
+ setting: {
1540
+ unit: '%',
1541
+ pos: 'append',
1542
+ type: 'number'
1543
+ },
1544
+ placeholder: {
1545
+ unitPlaceholder: '请输入比例',
1546
+ },
1547
+ rules: [
1548
+ { required: true, message: '请输入比例', trigger: 'blur' },
1549
+ ],
1550
+ notice: '可设置正负值,负值时为下调',
1551
+ inline: false
1552
+ },
1553
+ params.unit === 'money' && {
1554
+ label: '上调/下调:',
1555
+ ele: 'xd-input-unit',
1556
+ valueKey: 'moneyValue',
1557
+ keys: Date.now(),
1558
+ value: params['moneyValue'],
1559
+ setting: {
1560
+ unit: '元',
1561
+ pos: 'append',
1562
+ type: 'number'
1563
+ },
1564
+ placeholder: {
1565
+ unitPlaceholder: '请输入金额',
1566
+ },
1567
+ rules: [
1568
+ { required: true, message: '请输入金额', trigger: 'blur' },
1569
+ ],
1570
+ notice: '可设置正负值,负值时为下调',
1571
+ inline: false
1572
+ },
1573
+ {
1574
+ label: '小数点保留位数:',
1575
+ ele: 'xd-select-list',
1576
+ valueKey: 'decimal',
1577
+ className: 'input50',
1578
+ value: params.decimal || 2,
1579
+ placeholder: '请选择小数点保留位数',
1580
+ multiple: false,
1581
+ list: [
1582
+ { "label": "零位", "value": -1 },
1583
+ { "label": "一位", "value": 1 },
1584
+ { "label": "两位", "value": 2 },
1585
+ ],
1586
+ rules: [{
1587
+ required: true,
1588
+ message: '请选择小数点保留位数',
1589
+ trigger: 'change'
1590
+ }],
1591
+ },
1592
+ {
1593
+ label: "调整后售价",
1594
+ ele: 'slot',
1595
+ slot: 'showSkuAdjustedPrice'
1596
+ }
1597
+ ].filter(i => i);
1598
+ this.skuAdjustKey = Date.now();
1599
+ },
1600
+ //==规格调价相关方法==============================
1601
+
1000
1602
  }
1001
1603
  }
1002
1604
  </script>
@@ -570,6 +570,19 @@ module.exports = {
570
570
  disabled: true,
571
571
  role: 'ROLE_MARKET_STORE_PRODUCT_RULE_LOG_DETAIL',
572
572
  },
573
+ {
574
+ title: "加盟商后台 复制选店规则条件",
575
+ mapFn: "selectShopRuleCopy",
576
+ isPublic: true,
577
+ path: '/supplier-partner/v1/:xsiteid/:xnamespace/select-shop-rule/copy-rule-id',
578
+ isRule: false,
579
+ data: {
580
+ xsiteid: ['站点Id', 'String', '必填'],
581
+ xnamespace: ['命名空间', 'String', '必填'],
582
+ rule_id: ['rule_id', 'String', '必填'],
583
+ },
584
+ disabled: true,
585
+ },
573
586
  ],
574
587
  }
575
588
 
@@ -36,6 +36,22 @@
36
36
  ></xd-pagination>
37
37
  </div>
38
38
  </el-card>
39
+ <xd-dialog
40
+ v-if="createMethodShow"
41
+ :show.sync="createMethodShow"
42
+ @onConfirm="handleCreateMethodConfirm()"
43
+ @onCancel="handleCreateMethodCancel()"
44
+ title=""
45
+ width="500px"
46
+ >
47
+ <xd-base-dynamic-field
48
+ ref="createMethod"
49
+ v-if="createMethodForm.length > 0"
50
+ v-model="createMethodValue"
51
+ :key="createMethodKey"
52
+ :list="createMethodForm"
53
+ ></xd-base-dynamic-field>
54
+ </xd-dialog>
39
55
  </div>
40
56
  </template>
41
57
 
@@ -49,6 +65,8 @@ import XdPagination from "@/components/XdPagination.vue"
49
65
  import XdTable from "@/components/XdTable"
50
66
  import checkPermission from "@/utils/permission"
51
67
  import permissions from "@/constant/permissions"
68
+ import XdDialog from "@/components/XdDialog"
69
+ import XdBaseDynamicField from "@/components/XdBaseDynamicField"
52
70
 
53
71
  export default {
54
72
  name: "StoreRuleList",
@@ -56,7 +74,9 @@ export default {
56
74
  XdPagination,
57
75
  XdSearch,
58
76
  XdTableStatus,
59
- XdTable
77
+ XdTable,
78
+ XdDialog,
79
+ XdBaseDynamicField
60
80
  },
61
81
 
62
82
  data () {
@@ -69,6 +89,10 @@ export default {
69
89
  searchParams: null, // 搜索参数
70
90
  tables: [],
71
91
  total: 0,
92
+ createMethodKey: 'createMethodKey',
93
+ createMethodShow: false,
94
+ createMethodValue: {},
95
+ createMethodForm: [],
72
96
  }
73
97
  },
74
98
  computed:{
@@ -115,6 +139,16 @@ export default {
115
139
  }
116
140
  ]
117
141
  }
142
+ },
143
+ watch:{
144
+ 'createMethodValue.create_method':{
145
+ handler(newVal,oldVal){
146
+ if(newVal&&newVal!==oldVal){
147
+ this.initCreateMethodForm(this.createMethodValue)
148
+ this.createMethodKey = Date.now()
149
+ }
150
+ }
151
+ }
118
152
  },
119
153
  created () {
120
154
  this.getList()
@@ -125,7 +159,8 @@ export default {
125
159
  ...mapActions('store_selection', [
126
160
  'selectShopRuleList',
127
161
  'selectShopRuleExecTask',
128
- 'selectShopRuleDelete'
162
+ 'selectShopRuleDelete',
163
+ 'selectShopRuleCopy'
129
164
  ]),
130
165
 
131
166
  onJfbTagForReload () {
@@ -240,7 +275,67 @@ export default {
240
275
  },
241
276
  //创建
242
277
  handleCreate(){
243
- this.$router.push('/store/store_rule_create')
278
+ this.initCreateMethodForm({})
279
+ },
280
+ initCreateMethodForm(params){
281
+ this.createMethodForm = [
282
+ {
283
+ label: "创建方式:",
284
+ ele: "xd-radio",
285
+ valueKey: "create_method",
286
+ value: params.create_method || "custom",
287
+ rules: [
288
+ { required: true, message: "请选择", trigger: ["blur", "change"] },
289
+ ],
290
+ list: [
291
+ { label: "自定义", value: "custom" },
292
+ { label: "按规则ID", value: "by_rule_id" },
293
+ ],
294
+ },
295
+ params.create_method==='by_rule_id' && {
296
+ label: " ",
297
+ ele: "el-input",
298
+ type: "text",
299
+ valueKey: "rule_id",
300
+ value: params.rule_id || "",
301
+ placeholder: "请输入规则ID",
302
+ className: "input40",
303
+ rules: [
304
+ {
305
+ required: true,
306
+ message: "请输入规则ID",
307
+ trigger: "blur",
308
+ },
309
+ ],
310
+ },
311
+ ].filter(i=>i);
312
+ this.createMethodKey = Date.now();
313
+ this.createMethodShow = true;
314
+ },
315
+ handleCreateMethodConfirm(){
316
+ this.$refs["createMethod"].submit().then(() => {
317
+ if(this.createMethodValue.create_method==='by_rule_id'){
318
+ if(!this.createMethodValue.rule_id){
319
+ this.$message.error("请输入规则ID")
320
+ return
321
+ }
322
+ // 请求接口
323
+ this.selectShopRuleCopy({rule_id:this.createMethodValue.rule_id}).then(res=>{
324
+ this.$message.success("操作成功")
325
+ this.getList()
326
+ this.createMethodShow = false
327
+ })
328
+ }else if(this.createMethodValue.create_method==='custom'){
329
+ this.createMethodShow = false
330
+ this.$router.push('/store/store_rule_create')
331
+ }
332
+ }).catch(() => {
333
+ this.$message.error("操作失败")
334
+ })
335
+ },
336
+ handleCreateMethodCancel(){
337
+ this.createMethodValue = {}
338
+ this.createMethodShow = false
244
339
  },
245
340
  }
246
341
  }
@@ -91,6 +91,7 @@ import {mapActions,} from 'vuex'
91
91
  import XdBaseDynamicField from "@/components/XdBaseDynamicField.vue";
92
92
  import XdDialog from "@/components/XdDialog.vue";
93
93
  import mCompany from '@/constant/modules/mCompany'
94
+ import { getSiteRouter } from "@/utils/xd.base";
94
95
 
95
96
  export default {
96
97
  name: "ModuleCompanyList",
@@ -125,8 +126,17 @@ export default {
125
126
  }
126
127
  },
127
128
  watch:{
128
- 'listValue.site_id'(){
129
- this.initForm(this.listValue);
129
+ 'listValue.site_id':{
130
+ handler(newVal,oldVal){
131
+ console.log(newVal,oldVal,'newVal,oldVal')
132
+ if(newVal&&newVal!==oldVal){
133
+ let params = this.$xdHelper.cloneDeep(this.listValue);
134
+ if(this.default_entry_page){
135
+ params.default_entry_page = this.default_entry_page
136
+ }
137
+ this.initForm(params);
138
+ }
139
+ }
130
140
  },
131
141
  },
132
142
  data () {
@@ -155,6 +165,7 @@ export default {
155
165
  //是否为编辑
156
166
  isEdit: false,
157
167
  isPc: false,
168
+ default_entry_page: null,
158
169
  }
159
170
  },
160
171
 
@@ -167,7 +178,8 @@ export default {
167
178
  'getSaasCompanyList',
168
179
  'getSaasSiteList',
169
180
  'updateSaasCompany',
170
- 'xAppSync'
181
+ 'xAppSync',
182
+ 'getEditxSiteLists',
171
183
  ]),
172
184
  ...mapActions({
173
185
  getAllPlatformCatelogs: 'mCompany/getAllMPlatformCatelogs',
@@ -190,8 +202,14 @@ export default {
190
202
  this.$refs['form'].submit()
191
203
  .then(res=>{
192
204
  let form = this.$xdHelper.cloneDeep(this.$refs['form'].getAllFormData());
205
+ let copyForm = this.$xdHelper.cloneDeep(form);
206
+ if(form.default_entry_page){
207
+ copyForm['default_entry_page'] = JSON.stringify(form.default_entry_page)
208
+ }else{
209
+ delete copyForm['default_entry_page']
210
+ }
193
211
  let loading = Loading.service({});
194
- this.updateSaasCompany({id:this.id,item:form})
212
+ this.updateSaasCompany({id:this.id,item:copyForm})
195
213
  .then(res=>{
196
214
  loading.close();
197
215
  this.clearDialog();
@@ -207,6 +225,7 @@ export default {
207
225
  },
208
226
 
209
227
  initForm (params = {}) {
228
+ console.log(params,'ppppp')
210
229
  this.listForm = [
211
230
  params.company_id && {
212
231
  label: "客户ID",
@@ -281,6 +300,49 @@ export default {
281
300
  { required: true, message: "请选择默认进入应用",trigger: ['change']}
282
301
  ]
283
302
  },
303
+ params.site_id && {
304
+ label: "默认进入页面:",
305
+ ele: "xd-select-site-path",
306
+ className: "input100",
307
+ valueKey: "default_entry_page",
308
+ value: params.default_entry_page || null,
309
+ placeholder: "请选择默认进入页面",
310
+ setting:{
311
+ site_id:params.site_id,
312
+ hiddenSite:true
313
+ },
314
+ handleCustom: ({ action, data }) => {
315
+ if (action === "siteList") {
316
+ this.getEditxSiteLists()
317
+ .then((res) => {
318
+ data.cb(
319
+ res.data.list.map((item) => {
320
+ return {
321
+ ...item,
322
+ label: item["site_name"],
323
+ value: item["site_id"],
324
+ };
325
+ })
326
+ );
327
+ })
328
+ .catch((res) => {
329
+ console.error(res);
330
+ data.cb([]);
331
+ });
332
+ }
333
+ //获取应用列表
334
+ if (action === 'appList') {
335
+ if (data.params && data.params.value) {
336
+ getSiteRouter(this, data.cb, {site_id: data.params.value,isLimit: true});
337
+ } else {
338
+ data.cb([])
339
+ }
340
+ }
341
+ },
342
+ rules: [
343
+ { required: false, message: "请选择网站地址", trigger: "change" },
344
+ ],
345
+ },
284
346
  {
285
347
  label: '客户状态:',
286
348
  ele: 'xd-radio-status',
@@ -336,6 +398,12 @@ export default {
336
398
  company_status: row.company_status,
337
399
  index_path:row.index_path
338
400
  };
401
+ if(row.default_entry_page){
402
+ info.default_entry_page = JSON.parse(row.default_entry_page)
403
+ this.default_entry_page = info.default_entry_page
404
+ }else{
405
+ this.default_entry_page = null
406
+ }
339
407
  this.isEdit = !!row.site_id;
340
408
  this.initForm(info);
341
409
  this.dialog = true;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "jufubao-admin-library",
3
- "version": "1.1.211",
3
+ "version": "1.1.212",
4
4
  "description": "聚福宝福利后台管理系统公共模块",
5
5
  "author": "goashiyong <gaoshiyong1272@vip.163.com>",
6
6
  "scripts": {