AddSelGoods.vue 21 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723
  1. <template>
  2. <view class="detail-view">
  3. <u-form label-width="150" :model="add_form" ref="uForm">
  4. <view class="form-model-view">
  5. <u-form-item required label="选择店铺" prop="shopName">
  6. <u-input @click="goPage('/pagesT/shop/selShop')" class="dis-input" disabled v-model="add_form.shopName" placeholder="请选择" />
  7. <u-icon name="arrow-right" size="24" color="#6c6c6c"></u-icon>
  8. </u-form-item>
  9. <u-form-item required label="选择商品" prop="goodsName">
  10. <u-input @click="selGoods" class="dis-input" disabled v-model="add_form.goodsName" placeholder="请选择" />
  11. <u-icon name="arrow-right" size="24" color="#6c6c6c"></u-icon>
  12. </u-form-item>
  13. <u-form-item label="上下架">
  14. <view class="form-value">
  15. <u-switch
  16. style="transform: translateY(14rpx);"
  17. @change="enableStatusChange"
  18. v-model="enableStatus"
  19. :active-value="5"
  20. :inactive-value="4"
  21. size="40"
  22. ></u-switch>
  23. </view>
  24. </u-form-item>
  25. <u-form-item label="负库存销售">
  26. <view class="form-value">
  27. <u-switch
  28. style="transform: translateY(14rpx);"
  29. @change="isDistributionChange"
  30. v-model="isDistribution"
  31. :active-value="5"
  32. :inactive-value="4"
  33. size="40"
  34. ></u-switch>
  35. </view>
  36. </u-form-item>
  37. </view>
  38. <view class="form-model-view">
  39. <u-form-item label="快递运费">
  40. <u-input @click="openSel('expressType_show')" class="dis-input" disabled v-model="expressType_name" placeholder="请选择" />
  41. <u-icon name="arrow-right" size="24" color="#6c6c6c"></u-icon>
  42. </u-form-item>
  43. <u-form-item label="商品服务" label-position="top">
  44. <u-checkbox-group>
  45. <u-checkbox v-model="item.checked" v-for="(item, index) in serve_list" :key="index" :name="item.id">{{ item.servicesName }}</u-checkbox>
  46. </u-checkbox-group>
  47. </u-form-item>
  48. <u-form-item label="运费模版" v-if="add_form.expressType === 2">
  49. <u-input @click="openSel('template_show')" class="dis-input" disabled v-model="template_name" placeholder="请选择" />
  50. <u-icon name="arrow-right" size="24" color="#6c6c6c"></u-icon>
  51. </u-form-item>
  52. <u-form-item label="统一运费" v-if="add_form.expressType === 3"><u-input v-model="add_form.expressFee" placeholder="请输入" /></u-form-item>
  53. </view>
  54. <view class="form-model-view" v-if="spec_multiple.length">
  55. <u-form-item label-position="top" label="价格明细">
  56. <view class="price-ul">
  57. <view class="price-li clearfix">
  58. <view class="price-li-in">规格明细</view>
  59. <view class="price-li-in">共{{ spec_multiple.length }}种规格</view>
  60. <view class="price-li-in" @click="openSel('price_show')" v-if="add_form.specType === 2">
  61. 批量设置
  62. <u-icon name="arrow-right" size="24" color="#6c6c6c"></u-icon>
  63. </view>
  64. </view>
  65. <view class="price-li thead ">
  66. <view class="price-li-in">规格名称</view>
  67. <view class="price-li-in" style="color: #333333;">订货价</view>
  68. </view>
  69. <view class="price-li clearfix" v-for="(item, index) in spec_multiple" :key="index">
  70. <view class="price-li-in">
  71. {{ item.unitName }};
  72. <text v-for="(sku, skuI) in item.specGroup" :key="skuI">{{ sku.specValueName }}</text>
  73. </view>
  74. <view class="price-li-in" @click="openSel('price_show', item, index)">
  75. {{ (item.enabledLadder !== 1 && item.salePrice > 0) || item.enabledLadder === 1 ? '已设置' : '未设置' }}
  76. <u-icon name="arrow-right" size="24" color="#999999"></u-icon>
  77. </view>
  78. </view>
  79. </view>
  80. </u-form-item>
  81. </view>
  82. </u-form>
  83. <view class="submit-btn"><view class="btn-min" @click="submit">提交发布</view></view>
  84. <u-select v-model="expressType_show" @confirm="expressTypeConfirm" :list="expressType_list"></u-select>
  85. <!-- 运费模版 -->
  86. <u-select v-model="template_show" @confirm="templateConfirm" label-name="title" value-name="id" :list="express_list"></u-select>
  87. <u-popup v-model="price_show" mode="bottom" :mask-close-able="false">
  88. <view class="pop-ul">
  89. <view class="sku-name" v-if="!pop_price.unitName">批量设置</view>
  90. <view class="sku-name" v-else>
  91. {{ pop_price.unitName }};
  92. <text v-for="(sku, skuI) in pop_price.specGroup" :key="skuI">{{ sku.specValueName }}</text>
  93. <text v-if="pop_price.isMaster === 4" style="font-weight: 400;font-size: 24rpx;">
  94. (1{{ pop_price.unitName }}={{ Number(pop_price.conversion) }}{{ primary_unit }})
  95. </text>
  96. </view>
  97. <view class="pop-li clearfix">
  98. <view class="float_left">阶梯价</view>
  99. <view class="float_right">
  100. <u-switch
  101. :disabled="isEq === 5 && pop_price.isMaster === 4"
  102. style="transform: translateY(14rpx);"
  103. @change="ladderChange"
  104. v-model="pop_enabled_ladder"
  105. :active-value="1"
  106. :inactive-value="0"
  107. size="40"
  108. ></u-switch>
  109. </view>
  110. </view>
  111. <view class="pop-li clearfix" v-if="pop_price.enabledLadder !== 1">
  112. <view class="float_left">销售价/元</view>
  113. <view class="float_right">
  114. <input
  115. @blur="salePriceBlur"
  116. :disabled="isEq === 5 && pop_price.isMaster === 4"
  117. input-align="right"
  118. placeholder="请输入"
  119. v-model="pop_price.salePrice"
  120. height="90"
  121. type="digit"
  122. />
  123. </view>
  124. </view>
  125. <view class="pop-li ladder-price clearfix" v-if="pop_price.enabledLadder === 1">
  126. <view class="clearfix" style="padding: 10rpx 0;">
  127. <view class="float_left">销售价/元</view>
  128. <view class="float_right" v-if="pop_price.ladderPrice.length < 3"><u-button @click="addLadderprice" size="mini" type="primary">新增</u-button></view>
  129. </view>
  130. <view style="padding-bottom: 10rpx;" v-for="(ladder, ladderI) in pop_price.ladderPrice" :key="ladderI">
  131. <view class="input-view">
  132. <input disabled type="digit" v-model="ladder.from" />
  133. <u-tag :text="pop_price.unitName || '件'" mode="light" />
  134. </view>
  135. -
  136. <view class="input-view">
  137. <input
  138. :disabled="isEq === 5 && pop_price.isMaster === 4"
  139. @blur="ladderBlur($event, ladderI)"
  140. type="digit"
  141. v-if="ladderI !== pop_price.ladderPrice.length - 1"
  142. v-model="ladder.to"
  143. />
  144. <input v-else disabled value="∞" />
  145. <u-tag :text="pop_price.unitName || '件'" mode="light" />
  146. </view>
  147. =
  148. <view class="input-view">
  149. <input :disabled="isEq === 5 && pop_price.isMaster === 4" type="digit" @blur="salePriceLadderBlur(ladderI)" v-model="ladder.price" />
  150. <u-icon
  151. name="shanchu"
  152. v-if="pop_price.ladderPrice.length > 2 && ladderI !== pop_price.ladderPrice.length - 1"
  153. color="#ff4501"
  154. custom-prefix="custom-icon"
  155. @click="delLadderPrice(ladderI)"
  156. ></u-icon>
  157. </view>
  158. </view>
  159. </view>
  160. <view class="pop-li clearfix">
  161. <view class="float_left">会员价/元</view>
  162. <view class="float_right">
  163. <input
  164. :disabled="isEq === 5 && pop_price.isMaster === 4"
  165. input-align="right"
  166. placeholder="请输入"
  167. v-model="pop_price.memberPrice"
  168. height="90"
  169. type="digit"
  170. />
  171. </view>
  172. </view>
  173. <view class="pop-li clearfix">
  174. <view class="float_left">市场价/元</view>
  175. <view class="float_right"><input input-align="right" placeholder="请输入" v-model="pop_price.marketPrice" height="90" type="digit" /></view>
  176. </view>
  177. <view class="pop-li clearfix">
  178. <view class="float_left">起订数量</view>
  179. <view class="float_right"><u-input input-align="right" placeholder="请输入" v-model="pop_price.setNum" height="90" type="number" /></view>
  180. </view>
  181. <view class="pop-li clearfix">
  182. <view class="float_left">是否销售</view>
  183. <view class="float_right">
  184. <u-switch style="transform: translateY(14rpx);" v-model="pop_price.isSale" :active-value="5" :inactive-value="4" size="40"></u-switch>
  185. </view>
  186. </view>
  187. <view class="btn" @click="popconfirm">确定</view>
  188. </view>
  189. </u-popup>
  190. </view>
  191. </template>
  192. <script>
  193. export default {
  194. data() {
  195. return {
  196. template_show: false,
  197. template_name: '',
  198. pop_enabled_ladder: false,
  199. pop_price: {},
  200. sku_price_index: 0,
  201. price_show: false,
  202. expressType_show: false,
  203. expressType_list: [
  204. {
  205. value: 1,
  206. label: '包邮'
  207. },
  208. {
  209. value: 2,
  210. label: '运费模版'
  211. },
  212. {
  213. value: 3,
  214. label: '统一运费'
  215. }
  216. ],
  217. shopData: '',
  218. goodsSel: '',
  219. enableStatus: true,
  220. isDistribution: false,
  221. expressType_name: '包邮',
  222. spec_multiple: [],
  223. add_form: {
  224. createUserName: '',
  225. goodsName: '',
  226. enableStatus: 5,
  227. isDistribution: 4, //负库存销售
  228. specType: '',
  229. goodsBasicId: 0, // 商品基础资料
  230. shopId: '', // 店铺
  231. shopName: '', // 店铺
  232. images: [], // 相册
  233. salesArea: [], // 销售区域
  234. serviceInfo: 1,
  235. price: [], // 区域价
  236. specification: [], // // 规格
  237. content: '', // 商品描述
  238. isRecommend: 5, // 5推荐 4不推荐
  239. sort: '1', // 排序
  240. deliverySupIds: '1,2', // 物流支持 固定值 1 快递 2 自提 传参格式:1,2
  241. expressType: 1, // 快递运费 1 包邮 2 运费模版 3 固定费用
  242. expressFee: '', // 固定费用
  243. showExpress: 5, // 是否展示快递 5展示 4不展示
  244. ruleId: '', // 运费模版id
  245. isShield: 4, // 经营屏蔽 4关闭 5开启
  246. notArea: [], //经营屏蔽地区
  247. notCustomerType: '', //经营屏蔽 客户类型屏蔽
  248. notCustomer: '', //经营屏蔽 客户屏蔽
  249. support: ''
  250. },
  251. express_list: [],
  252. goods_id: '',
  253. primary_unit: '',
  254. primary_unit_num: '',
  255. serve_list: [],
  256. support_list: [], // 预存商品服务数据
  257. isEq: 4 //是否是抄码商品
  258. };
  259. },
  260. computed: {
  261. userName() {
  262. return this.$store.state.userInfo.name;
  263. }
  264. },
  265. watch: {
  266. shopData(val) {
  267. if (val) {
  268. this.add_form.shopId = val.id;
  269. this.add_form.shopName = val.name;
  270. }
  271. },
  272. goodsSel(val) {
  273. if (val) {
  274. this.getGoodsBasicInfoById(val.id);
  275. }
  276. }
  277. },
  278. async onLoad(options) {
  279. if (options.id) {
  280. this.goods_id = options.id;
  281. uni.setNavigationBarTitle({
  282. title: '编辑商品'
  283. });
  284. await this.getGoodsInfo();
  285. }
  286. await this.getAllExpressRule();
  287. await this.getAllGoodsSupport();
  288. },
  289. methods: {
  290. // 商品详情
  291. async getGoodsInfo() {
  292. await this.$u.api.getGoodsInfo(this.goods_id).then(({ data }) => {
  293. // this.goods_detail = res.data;
  294. this.isEq = data.isEq;
  295. this.enableStatus = data.enableStatus === 5;
  296. this.isDistribution = data.isDistribution === 5;
  297. this.spec_multiple = data.specMultiple;
  298. this.support_list = data.support.map(item => Number(item));
  299. this.add_form = {
  300. createUserName: data.createUserName,
  301. goodsName: data.title,
  302. enableStatus: data.enableStatus,
  303. isDistribution: data.isDistribution, //负库存销售
  304. specType: data.specType,
  305. goodsBasicId: data.basicGoodsId, // 商品基础资料
  306. shopId: data.shopId, // 店铺
  307. shopName: data.shopName, // 店铺
  308. images: data.images, // 相册
  309. salesArea: data.salesArea, // 销售区域
  310. serviceInfo: data.serviceInfo,
  311. price: data.price, // 区域价
  312. specification: data.specification, // // 规格
  313. content: data.content, // 商品描述
  314. isRecommend: data.isRecommend, // 5推荐 4不推荐
  315. sort: data.sort, // 排序
  316. deliverySupIds: data.deliverySupIds, // 物流支持 固定值 1 快递 2 自提 传参格式:1,2
  317. expressType: data.expressType, // 快递运费 1 包邮 2 运费模版 3 固定费用
  318. expressFee: data.goodsName, // 固定费用
  319. showExpress: data.showExpress, // 是否展示快递 5展示 4不展示
  320. ruleId: data.ruleId, // 运费模版id
  321. isShield: data.isShield, // 经营屏蔽 4关闭 5开启
  322. notArea: data.notArea, //经营屏蔽地区
  323. notCustomerType: data.notCustomerType, //经营屏蔽 客户类型屏蔽
  324. notCustomer: data.notCustomer //经营屏蔽 客户屏蔽
  325. };
  326. });
  327. },
  328. expressTypeConfirm(arr) {
  329. this.expressType_name = arr[0].label;
  330. this.add_form.expressType = arr[0].value;
  331. },
  332. templateConfirm(arr) {
  333. this.template_name = arr[0].label;
  334. this.add_form.ruleId = arr[0].value;
  335. },
  336. openSel(key, row, index) {
  337. this[key] = true;
  338. if (key === 'price_show') {
  339. if (!row) {
  340. this.pop_enabled_ladder = false;
  341. this.sku_price_index = '';
  342. this.pop_price = {
  343. ladderPrice: [],
  344. marketPrice: '',
  345. memberPrice: '',
  346. salePrice: '',
  347. setNum: 1,
  348. isSale: true,
  349. enabledLadder: 0
  350. };
  351. } else {
  352. this.pop_enabled_ladder = row.enabledLadder === 1;
  353. this.sku_price_index = index;
  354. this.pop_price = {
  355. ...row,
  356. isSale: row.isSale !== 4
  357. };
  358. }
  359. }
  360. },
  361. selGoods() {
  362. if (!this.add_form.shopId) {
  363. this.$u.toast('请选择店铺');
  364. return;
  365. }
  366. this.goPage(`/pagesT/goods/selBaseGoods?check=-1&shopId=${this.add_form.shopId}`);
  367. },
  368. //运费模版
  369. getAllExpressRule() {
  370. this.$u.api.getAllExpressRule().then(res => {
  371. this.express_list = res.data;
  372. });
  373. },
  374. getGoodsBasicInfoById(id) {
  375. this.$u.api
  376. .getGoodsBasicInfoById(id, {
  377. isAddGoods: 5
  378. })
  379. .then(({ data }) => {
  380. let arr = '';
  381. data.unitData.forEach(item => {
  382. if (item.isMaster === 5) {
  383. arr = item.unitName;
  384. }
  385. });
  386. this.primary_unit = arr;
  387. this.add_form.goodsName = data.title;
  388. this.add_form.images = data.images;
  389. this.add_form.specType = data.specType;
  390. this.add_form.content = data.description;
  391. this.add_form.goodsBasicId = data.id;
  392. if (data.specType === 1) {
  393. this.add_form.specification = (data.branchUnit || []).concat(data.masterUnit);
  394. } else if (data.specType === 2) {
  395. this.add_form.specification = data.specMultiple;
  396. }
  397. this.spec_multiple = data.specMultiple.map(item => {
  398. return {
  399. ...item,
  400. ladderPrice: [],
  401. marketPrice: '',
  402. memberPrice: '',
  403. salePrice: '',
  404. salePriceAreaType: 1,
  405. setNum: 1,
  406. isSale: 5,
  407. enabledLadder: 0
  408. };
  409. });
  410. });
  411. },
  412. submit() {
  413. this.add_form.createUserName = this.userName;
  414. if (!this.add_form.shopName) {
  415. this.$u.toast('请选择发布商铺');
  416. return;
  417. }
  418. if (!this.add_form.goodsName) {
  419. this.$u.toast('请选择发布商品');
  420. return;
  421. }
  422. // 判断价格是否为0
  423. const isFSale = this.spec_multiple.every(item => item.isSale === 4);
  424. if (isFSale) {
  425. this.$u.toast('至少保留一条规格的销售状态为【启用】');
  426. return;
  427. }
  428. let isPrice = false;
  429. for (let i in this.spec_multiple.length) {
  430. let item = this.spec_multiple[i];
  431. if (item.enabledLadder === 1) {
  432. isPrice = item.ladderPrice.some(item => item.price <= 0);
  433. } else {
  434. isPrice = item.salePrice <= 0;
  435. }
  436. let skuName = '';
  437. if (item.specGroup && item.specGroup.length) {
  438. skuName = item.specGroup.map(item => item.specValueName).join(';');
  439. }
  440. if (isPrice) {
  441. this.$u.toast(`规格【${item.unitName};${skuName}】的价格不能为0`);
  442. break;
  443. }
  444. }
  445. if (isPrice) {
  446. return;
  447. }
  448. this.add_form.support = this.serve_list.filter(item => item.checked).map(item => item.id);
  449. this.add_form.price = this.spec_multiple;
  450. if (this.goods_id) {
  451. this.$u.api.editGoods(this.goods_id, this.add_form).then(res => {
  452. this.$u.toast('修改成功');
  453. setTimeout(() => {
  454. uni.navigateBack();
  455. }, 2000);
  456. });
  457. } else {
  458. this.$u.api.addGoods(this.add_form).then(res => {
  459. this.$u.toast('新增成功');
  460. setTimeout(() => {
  461. uni.navigateBack();
  462. }, 2000);
  463. });
  464. }
  465. },
  466. isDistributionChange(val) {
  467. this.add_form.isDistribution = val;
  468. },
  469. enableStatusChange(val) {
  470. this.add_form.enableStatus = val;
  471. },
  472. addLadderprice() {
  473. const target = this.$u.deepClone(this.pop_price);
  474. if (!target.ladderPrice.length) {
  475. target.ladderPrice.push({
  476. from: 1,
  477. price: '',
  478. to: 2
  479. });
  480. } else {
  481. const upL = target.ladderPrice[0];
  482. target.ladderPrice.splice(1, '', {
  483. from: upL.to + 1,
  484. price: '',
  485. to: upL.to + 2
  486. });
  487. if (target.ladderPrice.length === 3) {
  488. target.ladderPrice[target.ladderPrice.length - 1].from = upL.to + 3;
  489. }
  490. }
  491. this.pop_price = target;
  492. },
  493. ladderChange(val) {
  494. this.pop_price.enabledLadder = val;
  495. if (val === 1) {
  496. this.pop_price.ladderPrice = [
  497. {
  498. from: 1,
  499. price: 0,
  500. to: 2
  501. },
  502. {
  503. from: 3,
  504. price: 0,
  505. to: 4
  506. },
  507. {
  508. from: 5,
  509. price: 0,
  510. to: 999999999
  511. }
  512. ];
  513. } else {
  514. this.pop_price.ladderPrice = [];
  515. }
  516. },
  517. // 价格设置
  518. popconfirm() {
  519. if (this.pop_price.enabledLadder === 1) {
  520. const isPrice = this.pop_price.ladderPrice.some(item => item.price <= 0);
  521. if (isPrice) {
  522. this.$u.toast('销售价不能为0');
  523. return;
  524. }
  525. } else {
  526. if (this.pop_price.salePrice <= 0) {
  527. this.$u.toast('销售价不能为0');
  528. return;
  529. }
  530. }
  531. let target = this.$u.deepClone(this.spec_multiple);
  532. if (!this.pop_price.unitName) {
  533. // 批量设置
  534. this.spec_multiple = target.map(item => {
  535. item = {
  536. ...item,
  537. ...this.pop_price,
  538. isSale: this.pop_price.isSale ? 5 : 4
  539. };
  540. // 根据换算关系 批量设置
  541. if (Number(item.conversion)) {
  542. item.salePrice = this.$NP.times(Number(item.conversion), this.pop_price.salePrice);
  543. item.marketPrice = this.$NP.times(Number(item.conversion), this.pop_price.marketPrice);
  544. item.memberPrice = this.$NP.times(Number(item.conversion), this.pop_price.memberPrice);
  545. if (this.pop_price.enabledLadder === 1) {
  546. item.ladderPrice = this.pop_price.ladderPrice.map(ladder => {
  547. return {
  548. ...ladder,
  549. price: this.$NP.times(Number(item.conversion), ladder.price)
  550. };
  551. });
  552. }
  553. }
  554. // const salePrice = Number(item.)
  555. return item;
  556. });
  557. } else {
  558. // 抄码商品根据比例自动换算
  559. if (this.add_form.specType === 1 && this.pop_price.isMaster === 5) {
  560. target.forEach(item => {
  561. if (item.conversion && item.isMaster === 4) {
  562. item.marketPrice = this.$NP.times(this.pop_price.marketPrice, item.conversion);
  563. item.salePrice = this.$NP.times(this.pop_price.salePrice, item.conversion);
  564. item.memberPrice = this.$NP.times(this.pop_price.memberPrice, item.conversion);
  565. if (this.isEq === 5) {
  566. item.enabledLadder = this.pop_price.enabledLadder;
  567. item.ladderPrice = this.pop_price.ladderPrice.map(ladder => {
  568. return {
  569. ...ladder,
  570. price: this.$NP.times(ladder.price, item.conversion)
  571. };
  572. });
  573. }
  574. }
  575. });
  576. }
  577. target[this.sku_price_index] = {
  578. ...this.pop_price,
  579. isSale: this.pop_price.isSale ? 5 : 4
  580. };
  581. this.spec_multiple = target;
  582. }
  583. this.price_show = false;
  584. },
  585. ladderBlur(e, index) {
  586. let val = Number(e.detail.value);
  587. const target = this.$u.deepClone(this.pop_price);
  588. if (val <= target.ladderPrice[index].from) {
  589. val = target.ladderPrice[index].from + 1;
  590. target.ladderPrice[index].to = val;
  591. }
  592. target.ladderPrice[index + 1].from = val + 1;
  593. if (index === 0) {
  594. target.ladderPrice[index + 1].to = val + 2;
  595. if (target.ladderPrice[index + 2]) {
  596. target.ladderPrice[index + 2].from = val + 3;
  597. }
  598. }
  599. this.pop_price = target;
  600. },
  601. delLadderPrice(index) {
  602. const target = this.$u.deepClone(this.pop_price);
  603. target.ladderPrice.splice(index, 1);
  604. target.ladderPrice[0].from = 1;
  605. target.ladderPrice[target.ladderPrice.length - 1].from = target.ladderPrice[0].to + 1;
  606. this.pop_price = target;
  607. },
  608. // 销售价失去焦点
  609. salePriceBlur(val) {
  610. this.pop_price.marketPrice = this.$NP.times(this.pop_price.salePrice, 1.5);
  611. },
  612. // 阶梯价第一级失去焦点
  613. salePriceLadderBlur(index) {
  614. if (index === 0) {
  615. this.pop_price.marketPrice = this.$NP.times(this.pop_price.ladderPrice[0].price, 1.5);
  616. }
  617. },
  618. async getAllGoodsSupport() {
  619. await this.$u.api
  620. .getAllGoodsSupport({
  621. page: 1,
  622. pageSize: 99
  623. })
  624. .then(res => {
  625. this.serve_list = res.data.map(item => {
  626. return {
  627. ...item,
  628. checked: this.support_list.indexOf(item.id) > -1
  629. };
  630. });
  631. });
  632. }
  633. }
  634. };
  635. </script>
  636. <style lang="scss" scoped>
  637. .price-ul {
  638. .price-li {
  639. width: 700rpx;
  640. line-height: 90rpx;
  641. display: flex;
  642. border-top: 1px solid #eeeeee;
  643. .price-li-in {
  644. flex: 2;
  645. text-align: center;
  646. color: #999999;
  647. &:first-child {
  648. text-align: left;
  649. color: #333333;
  650. }
  651. &:last-child {
  652. text-align: right;
  653. }
  654. }
  655. }
  656. .thead {
  657. padding-top: 30rpx;
  658. line-height: 60rpx;
  659. font-size: 24rpx;
  660. font-weight: bold;
  661. }
  662. }
  663. .pop-ul {
  664. line-height: 90rpx;
  665. .sku-name {
  666. font-weight: bold;
  667. padding: 0 24rpx;
  668. }
  669. .pop-li {
  670. padding: 0 24rpx;
  671. border-top: 1px solid #eeeeee;
  672. line-height: 90rpx;
  673. input {
  674. text-align: right;
  675. line-height: 90rpx;
  676. height: 90rpx;
  677. display: inline-block;
  678. vertical-align: middle;
  679. }
  680. }
  681. .ladder-price {
  682. line-height: 60rpx;
  683. .input-view {
  684. line-height: 60rpx;
  685. display: inline-block;
  686. width: 210rpx;
  687. margin: 0 6rpx;
  688. input {
  689. padding: 0 8rpx;
  690. display: inline-block;
  691. vertical-align: middle;
  692. width: 100rpx;
  693. border: 1px solid #eeeeee;
  694. border-radius: 10rpx;
  695. line-height: 60rpx;
  696. height: 60rpx;
  697. margin-right: 8rpx;
  698. }
  699. }
  700. }
  701. .btn {
  702. text-align: center;
  703. color: #ffffff;
  704. line-height: 90rpx;
  705. background-color: $uni-color-primary;
  706. }
  707. }
  708. </style>