shish 2 лет назад
Родитель
Сommit
fa473209ca

+ 4 - 1
ghsApp/src/admin/cp/components/cpItem.vue

@@ -30,7 +30,7 @@
 			</view>
 		</view>
 	</view>
-	<text class="bottom-button">花材列表</text>
+	<text class="bottom-button" @click.stop="editCp(info)">编辑</text>
 </view>
 </template>
 <script>
@@ -58,6 +58,9 @@ export default {
 		}
 	},
 	methods: {
+		editCp(info){
+			this.$emit('editCp',info)
+		},
 		doIt(info){
 			this.$emit("doIt",info)
 		},

+ 4 - 1
ghsApp/src/admin/cp/list.vue

@@ -28,7 +28,7 @@
                             <view v-if="!$util.isEmpty(globalCpList)">
                                 <template v-for="(productItem, productIndex) in globalCpList">
                                     <view style="height:255upx" :key="productIndex">
-                                        <cpStock :info="productItem" @moreAction="moreAction" @doIt="doIt"
+                                        <cpStock :info="productItem" @moreAction="moreAction" @doIt="doIt" @editCp="editCp"
                                         @doPrintLabel="doPrintLabel" @cancelDiscountFn="cancelDiscountFn" @cancelFullOff="cancelFullOff"
                                         :ref="`productRef${productItem.id}`" @hideChangeFn="hideChangeFn" 
                                         @cancelPreSellFn="cancelPreSellFn" @breakSingleItem="breakSingleItem">
@@ -181,6 +181,9 @@
         selectFlowerNumFn(){
             this.$msg('开发中')
         },
+        editCp(info){
+            this.$util.pageTo({url: '/admin/cp/updateCp?id='+info.id})
+        },
         doIt(info){
             if(this.skip == 0){
                 this.$util.pageTo({url: '/admin/cp/item?cpId='+info.id})

+ 268 - 0
ghsApp/src/admin/cp/updateCp.vue

@@ -0,0 +1,268 @@
+<template>
+  <view class="app-content">
+    <form @submit="formSubmit">
+      <div class="module-com input-line-wrap">
+
+        <tui-list-cell class="line-cell" :hover="false">
+          <div class="tui-title">名称</div>
+          <input v-model="form.name" placeholder-class="phcolor" class="tui-input" name="name" placeholder="产品名称" maxlength="50" type="text" />
+        </tui-list-cell>
+
+        <tui-list-cell class="line-cell" :hover="false">
+          <div class="tui-title">初始名称</div>
+          <view style="color:#CCCCCC;width:450upx;height:45upx;" @click.stop="notModify">
+            {{form.name}}
+          </view>
+        </tui-list-cell>
+
+        <tui-list-cell class="line-cell" :hover="false" :arrow="true">
+          <div class="tui-title">分类</div>
+          <input v-model="form.classId" name="classId" type="text" hidden />
+          <view style="color:#CCCCCC;width:450upx;height:45upx;" @click.stop="changeClass()" v-if="form.classId == 0">
+            请选择分类
+          </view>
+          <view @click.stop="changeClass()" style="width:450upx;height:45upx;" v-else>
+            {{form.className}}
+          </view>
+        </tui-list-cell>
+
+      </div>
+
+      <div class="module-com input-line-wrap goods-wrap">
+        <div class="module-tit">
+          <span>产品图片</span>
+          <span class="app-color-3"></span>
+        </div>
+        <view class="module-det">
+          <htz-image-upload :max="1" :compress="true" v-model="currentImgData" :headers="headers"
+            @uploadSuccess="imgUploadSuccess" @imgDelete="imgDeleteFn" :action="getLoginInfo.imgUploadApi">
+          </htz-image-upload>
+        </view>
+      </div>
+
+      <view class="module-com input-line-wrap">
+        <tui-list-cell class="line-cell" :hover="false">
+          <view class="tui-title">顺序值</view>
+          <input v-model="form.inTurn" placeholder-class="phcolor" class="tui-input" name="inTurn" @focus="form.inTurn=''" placeholder="请填写数字" type="number" />
+        </tui-list-cell> 
+      </view>
+
+      <view class="app-footer">
+        <button class="admin-button-com big default" @click="goBack()">取消</button>
+        <button v-if="option.ptItemId" class="admin-button-com big blue" formType="submit" @click="status = 1">添加</button>
+        <button v-else class="admin-button-com big blue" formType="submit" @click="status = 1">确认</button>
+      </view>
+
+    </form>
+
+    <uni-popup ref="classRef" background-color="#fff" type="center" :animation="false" class="class-popup-style">
+      <view style="margin-left:30upx;margin-top:15upx;font-size:26upx;font-weight:bold;">请选择分类:</view>
+        <view style="display:flex;padding:20upx;height:auto;justify-content: space-between;align-items:center;flex-wrap:wrap;max-height:100vh;overflow:auto;">
+          <view v-for="(item, index) in cpClassList" :key="index" @tap.stop="setThisClass(item)" style="margin-bottom:20upx;margin-left:3upx;">
+          <image :src="item.cover" style="width:120upx;height:120upx;border-radius:10upx;"></image>
+          <view style="margin-top:5upx;overflow: hidden;white-space: nowrap;width:120upx;text-align:center;">{{item.name}}</view>
+        </view>
+      </view>
+    </uni-popup>
+
+  </view>
+</template>
+<script>
+  import TuiListCell from "@/components/plugin/list-cell";
+  const form = require("@/utils/formValidation.js");
+  import { getAllItemClass } from "@/api/item-class";
+  import { getAllUnit } from "@/api/unit";
+  import { getAllCpClass,addCpFn,updateCpFn,getCpDetail } from "@/api/cp"
+  import { addProduct,updateProduct,getProductDetail } from "@/api/product";
+  import { getPtItemDetail } from "@/api/pt-item";
+  import { mapGetters } from "vuex"
+  //图片上传插件来源:https://ext.dcloud.net.cn/plugin?id=2922 已改造,不能再升级 shish 20211228
+  import htzImageUpload from '@/components/htz-image-upload/htz-image-upload.vue'
+  export default {
+    name: "addCp",
+    components: {
+      TuiListCell,
+      htzImageUpload
+    },
+    data() {
+      return {
+        status: 1,
+        pcClassList:[],
+        currentImgData: [],
+        cpClassList:[],
+        form: {
+          id:0,
+          name:"",
+          classId:0,
+          className:'',
+          cover:[],
+          inTurn:100
+        },
+        itemClassSelectedData:{},
+        itemClassData:[],
+        unitData:[],
+        smallUnitSelectedData:{},
+        bigUnitSelectedData:{},
+        hasRequest:0,
+        cpData:{id:0},
+        headers:{token:''}
+      };
+    },
+    computed:{
+        ...mapGetters(["getLoginInfo","getDictionariesInfo"])
+    },
+    onLoad(option) {
+      if(option.id){
+        this.form.id = this.option.id
+      }
+      const token = uni.getStorageSync('token')
+      this.headers.token = token
+    },
+    watch:{
+    },
+    methods: {
+      changeClass(item){
+        this.$refs.classRef.open('center')
+      },
+      setThisClass(info){
+        this.$refs.classRef.close()
+        this.form.classId = info.id ? info.id : 0
+        this.form.className = info.name ? info.name : ''
+        this.$forceUpdate()
+      },
+      notModify(){
+        this.$msg('不可修改')
+      },
+      goStockDetail(item){
+        this.$util.pageTo({url: "/pagesStorehouse/stockWarn/detailed?id="+item.id+'&name='+item.name})
+      },
+      goBack(){
+        uni.navigateBack({ delta: 1 })
+      },
+      getDetail() {
+        return getCpDetail({ id: this.option.id }).then(res => {
+          if (this.$util.isEmpty(res.data)) {
+            return;
+          }
+          Object.keys(this.form).forEach((i, index) => {
+            this.form[i] = res.data[i];
+          });
+          this.currentImgData.push(res.data.cover)
+          this.form.cover = [res.data.shortCover]
+          this.cpData = res.data
+        });
+      },
+      imgUploadSuccess(res) {
+        var _res = JSON.parse(res.data)
+        if(_res.code == 1){
+          this.currentImgData.push(_res.data.smallUrl)
+          this.form.cover.push(_res.data.shortUrl)
+        }
+      },
+      imgDeleteFn(res){
+        const index = res.index
+        this.form.cover.splice(index,1)
+      },
+      init() {
+        let that = this
+        if(this.hasRequest == 1){
+          return
+        }
+        this.getDetail();
+        this.hasRequest = 1
+        getAllCpClass().then(res => {
+          that.cpClassList = res.data.list ? res.data.list : []
+        })
+      },
+      confirmFn() {
+        if (this.$util.isEmpty(this.form.cover)) {
+          this.$msg("请上传图片")
+          return false
+        }
+        let requestHost = addCpFn
+        if(this.form.id && this.form.id != 0){
+          requestHost = updateCpFn;
+        }else{
+
+        }
+        let form = JSON.parse(JSON.stringify(this.form))
+        uni.showLoading({mask:true})
+        requestHost({...form,cover:this.form.cover[0]}).then(res => {
+          uni.hideLoading()
+          if(res.code == 1){
+            this.$msg(res.msg)
+            uni.navigateBack({})
+          }
+        });
+      },
+      formSubmit(e) {
+        let rules = [
+          {
+            name: "name",
+            rule: ["required"],
+            msg: ["请填写名称"]
+          },
+          {
+            name: "classId",
+            rule: ["required"],
+            msg: ["请选择分类"]
+          }
+        ];
+        let formData = e.detail.value;
+        let checkRes = form.validation(formData, rules);
+        if (!checkRes) {
+            this.confirmFn()
+        } else {
+          this.$msg(checkRes);
+        }
+      }
+    }
+  };
+  </script>
+  <style lang="scss" scoped>
+  .app-content {
+    min-height: calc(100vh - 100upx);
+    padding-bottom: 150upx;
+  }
+  .module-com {
+    margin-bottom: 20upx;
+    background-color: #fff;
+    color: $fontColor2;
+    .module-tit {
+      padding: 20upx 30upx;
+      font-size: 28upx;
+    }
+    .module-det {
+      padding: 0 30upx;
+    }
+  }
+  .category-wrap {
+    align-items: flex-start;
+    padding-bottom: 0 !important;
+    .tui-input {
+      @include disFlex(center, flex-start);
+      flex-wrap: wrap;
+      .admin-button-com {
+        margin-right: 20upx;
+        margin-bottom: 20upx;
+        position: relative;
+        z-index: 9999;
+      }
+    }
+  }
+  .summary-wrap {
+    .goods-summary {
+      height: 400upx;
+    }
+  }
+  .app-footer {
+    justify-content: space-evenly;
+    z-index: 95;
+    .admin-button-com {
+      width: 46%;
+    }
+  }
+  .class-popup-style{
+		z-index:9999;
+	}
+  </style>

+ 4 - 0
ghsApp/src/api/cp/index.js

@@ -50,4 +50,8 @@ export const addCpItem = data => {
 
 export const getCpList = data => {
 	return https.get('/cp/list', data)
+}
+
+export const getCpDetail = data => {
+	return https.get('/cp/detail', data)
 }

+ 1 - 0
ghsApp/src/pages.json

@@ -418,6 +418,7 @@
 				{"path": "item","style": {"navigationBarTitleText": "花材"}},
 				{"path": "ptCpList","style": {"navigationBarTitleText": "从平台找产品"}},
 				{"path": "addCp","style": {"navigationBarTitleText": "创建产品"}},
+				{"path": "updateCp","style": {"navigationBarTitleText": "修改产品"}},
 				{"path": "cpDetail","style": {"navigationBarTitleText": "详情"}}
 			]
 		},