| 123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268 |
- <template>
- <view class="price-edit-modal">
- <!-- 遮罩层 -->
- <view class="mask" @tap="close"></view>
- <!-- 弹窗内容 -->
- <view class="modal-content">
- <view class="modal-header">修改销售价</view>
- <template v-for="(listItem, isd) in upList">
- <view class="wparnkd-centent" :key="'sdfgdxf' + isd">
- <!-- 商品类型选择 -->
- <view class="goods-type" :key="'sdfgdf' + isd">
- <text class="label">商品类型:</text>
- <radio-group @change="handleTypeChange">
- <view
- v-for="(item, index) in goodsTypesData"
- :key="item.value + '_index' + index"
- class="radio-item"
- >
- <label>
- <radio
- :value="String(item.value)"
- :checked="currentType === item.value"
- color="#007AFF"
- />
- {{ item.label }}
- </label>
- </view>
- </radio-group>
- </view>
- <view v-if="uplength != 1 && uplength != 0" :key="'sdfgdttf' + isd">
- <view style="padding-bottom: 10rpx">规格:</view>
- <view style="color: #007aff">{{ listItem.detail.规格 }}</view>
- </view>
- <!-- 价格输入区域 -->
- <view class="price-input" :key="'sdfotktmgdf' + isd">
- <text class="tip"
- >最低销售价格不能小于:{{ listItem.min_market_price }}</text
- >
- <view class="input-row">
- <text>销售价:</text>
- <input
- type="number"
- v-model="fuzupList[isd].price"
- placeholder="请输入销售价"
- @input="calculateProfit"
- />
- </view>
- </view>
- <!-- 计算结果显示 -->
- <view class="profit-display" :key="'sdkkf' + isd">
- <view>销售价:{{ listItem.price || "0.00" }}</view>
- <view>养老金:{{ listItem.gong_pension || "0.00" }}</view>
- <view>创客利润:{{ listItem.plate_mer_profit || "0.00" }}</view>
- </view>
- </view>
- </template>
- <button class="confirm-btn" @tap="handleConfirm">确定</button>
- </view>
- </view>
- </template>
- <script>
- import { editSupplyChainPrice } from "@/commit/product.js";
- export default {
- props: {
- productData: {
- type: Object,
- default: () => {},
- },
- merInfo: {
- type: Object,
- default: () => {},
- },
- },
- data() {
- return {
- currentPrice: "",
- currentType: "",
- goodsTypes: "", // 商品类型
- productStyles: [
- { value: "", label: "全部" },
- { value: "0", label: "单规格" },
- { value: "1", label: "多规格" },
- ],
- upList: [], //attrValue
- uplength: 0, //attrValue.length
- pnjen: "", //product_id
- fuzupList: [], //attrValue
- };
- },
- watch: {
- productData: {
- handler(val) {
- this.getProductData(val);
- },
- deep: true,
- },
- },
- mounted() {
- this.getProductData(this.productData);
- },
- methods: {
- handleTypeChange(e) {
- this.currentType = e.detail.value;
- // 这里可以添加不同类型的价格计算逻辑
- },
- calculateProfit() {
- // 示例计算逻辑,实际根据业务需求修改
- this.pensionFund = this.currentPrice * 0.05;
- this.makerProfit = this.currentPrice * 0.15;
- },
- getProductData(val) {
- const _this = this;
- const ev = (val && val.attrValue) || [];
- const en = val && val.product_id;
- const etype = val && val.type;
- _this.goodsTypes = etype;
- _this.upList = JSON.parse(JSON.stringify([...ev]));
- _this.fuzupList = JSON.parse(JSON.stringify([...ev]));
- _this.pnjen = en;
- _this.uplength = ev.length;
- },
- handleConfirm() {
- var reg =
- /(^[1-9]([0-9]+)?(.[0-9]{1,2})?$)|(^(0){1}$)|(^[0-9].[0-9]([0-9])?$)/;
- //单拿数据 组成新的数组
- const skuArr = this.fuzupList.map((project) => ({
- sku_id: project.gong_sku_id,
- edit_price: project.price,
- }));
- let _this = this;
- const isEmtyPrice = skuArr.some(
- (item) =>
- item.edit_price == "" ||
- item.edit_price == null ||
- item.edit_price == undefined
- );
- const isZQPrice = skuArr.some(
- (item) => !reg.test(item.edit_price) || item.edit_price == 0
- );
- if (isEmtyPrice) {
- uni.showToast({ title: "请输入金额", icon: "none" });
- return;
- }
- if (isZQPrice) {
- uni.showToast({ title: "请输入正确金额", icon: "none" });
- return;
- }
- editSupplyChainPrice(this.pnjen, {
- skuArr: skuArr,
- type: this.goodsTypes,
- }).then(
- (res) => {
- if (res.data.status == 200) {
- uni.showToast({ title: res.data.message, icon: "none" });
- _this.$emit("confirm");
- } else {
- uni.showToast({ title: res.data.message, icon: "none" });
- }
- },
- (fail) => {
- uni.showToast({ title: res.data.message, icon: "none" });
- }
- );
- },
- close() {
- this.$emit("close");
- },
- },
- computed: {
- goodsTypesData() {
- if (this.merInfo && this.merInfo.mer_id == 324) {
- return [
- { label: "普通商品", value: 1 },
- { label: "会员商品", value: 8 },
- { label: "高级会员商品", value: 10 },
- { label: "合伙人商品", value: 14 },
- { label: "股权商品", value: 15 },
- { label: "合伙人+股权商品", value: 16 },
- ];
- } else {
- return [{ label: "普通商品", value: 1 }];
- }
- },
- },
- };
- </script>
- <style scoped>
- /* 弹窗公共样式 */
- .mask {
- position: fixed;
- top: 0;
- left: 0;
- right: 0;
- bottom: 0;
- background: rgba(0, 0, 0, 0.5);
- z-index: 999;
- }
- .modal-content {
- position: fixed;
- top: 50%;
- left: 50%;
- transform: translate(-50%, -50%);
- width: 85%;
- max-width: 600rpx;
- background: #fff;
- border-radius: 12rpx;
- padding: 30rpx;
- z-index: 1000;
- }
- .wparnkd-centent{
- max-height: 70vh;
- overflow-y: auto;
- }
- .modal-header {
- font-size: 18px;
- font-weight: bold;
- margin-bottom: 20rpx;
- text-align: center;
- }
- /* 商品类型选择样式 */
- .goods-type {
- margin-bottom: 30rpx;
- }
- .radio-item {
- margin: 15rpx 0;
- display: flex;
- align-items: center;
- }
- /* 输入区域样式 */
- .price-input {
- margin: 20rpx 0;
- }
- .input-row {
- display: flex;
- align-items: center;
- margin: 15rpx 0;
- }
- input {
- border: 1rpx solid #ddd;
- padding: 10rpx;
- border-radius: 8rpx;
- flex: 1;
- margin-left: 15rpx;
- }
- /* 按钮样式 */
- .confirm-btn {
- background: #007aff;
- color: white;
- margin-top: 30rpx;
- border-radius: 8rpx;
- }
- .profit-display {
- padding: 15rpx 0;
- border-top: 1rpx solid #eee;
- margin-top: 20rpx;
- }
- </style>
|