shish 2 lat temu
rodzic
commit
eca6f7b010

+ 19 - 114
ghsApp/src/admin/cp/addCp.vue

@@ -49,8 +49,7 @@
 
       <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>
+        <button class="admin-button-com big blue" formType="submit">添加</button>
       </view>
 
     </form>
@@ -72,7 +71,7 @@
   const form = require("@/utils/formValidation.js");
   import { getAllItemClass } from "@/api/item-class";
   import { getAllUnit } from "@/api/unit";
-  import { getAllCpClass,addCpFn,updateCpFn } from "@/api/cp"
+  import { getAllCpClass,addCpFn,updateCpFn,getPtCpInfo } from "@/api/cp"
   import { addProduct,updateProduct,getProductDetail } from "@/api/product";
   import { getPtItemDetail } from "@/api/pt-item";
   import { mapGetters } from "vuex"
@@ -86,25 +85,17 @@
     },
     data() {
       return {
-        status: 1,
-        pcClassList:[],
         currentImgData: [],
         cpClassList:[],
         form: {
-          id:0,
           name:"",
           classId:0,
           className:'',
           cover:[],
-          inTurn:100
+          inTurn:100,
+          ptCpId:0
         },
-        itemClassSelectedData:{},
-        itemClassData:[],
-        unitData:[],
-        smallUnitSelectedData:{},
-        bigUnitSelectedData:{},
         hasRequest:0,
-        productData:{id:0},
         headers:{token:''}
       };
     },
@@ -112,9 +103,6 @@
         ...mapGetters(["getLoginInfo","getDictionariesInfo"])
     },
     onLoad(option) {
-      if(option.id){
-        this.form.id = this.option.id
-      }
       const token = uni.getStorageSync('token')
       this.headers.token = token
     },
@@ -128,69 +116,13 @@
         this.$refs.classRef.close()
         this.form.classId = info.id ? info.id : 0
         this.form.className = info.name ? info.name : ''
-        console.log(this.form)
         this.$forceUpdate()
       },
       notModify(){
         this.$msg('不可修改')
       },
-      goStockDetail(item){
-        this.$util.pageTo({url: "/pagesStorehouse/stockWarn/detailed?id="+item.id+'&name='+item.name})
-      },
-      statusChange(e){
-        this.form.status = e.detail.value ? 1 : 2;
-      },
-      changeStock(event){
-        let num = Number(event.target.value)
-        if(num > 0){
-          this.form.status = 1
-        }else{
-          this.form.status = 2
-        }
-      },
       goBack(){
-        uni.navigateBack({ delta: 1 })
-      },
-      getPtItemInfo(ptItemId){
-        getPtItemDetail({id:ptItemId}).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.form.classId = ''
-          this.form.id = 0
-        })
-      },
-      getDetail() {
-        return getProductDetail({ 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.form.price = res.data.prePrice
-  
-          this.itemClassSelectedData = this.itemClassData.filter(
-            e => this.form.classId == e.id
-          )[0];
-          this.smallUnitSelectedData = this.unitData.filter(
-            e => this.form.smallUnitId == e.id
-          )[0];
-         this.bigUnitSelectedData = this.unitData.filter(
-            e => this.form.bigUnitId == e.id
-          )[0];
-          this.productData = res.data
-        });
+        uni.navigateBack()
       },
       imgUploadSuccess(res) {
         var _res = JSON.parse(res.data)
@@ -205,62 +137,35 @@
       },
       init() {
         let that = this
-        if(!this.$util.isEmpty(this.option.ptItemId)){
-          uni.setNavigationBarTitle({title: "确认产品信息"})
-        }
         if(this.hasRequest == 1){
           return
         }
-        this._getAllUnit().then(res=>{
-          this._getAllItemClass().then(res => {
-            if(this.form.id == 0){
-              this.smallUnitSelectedData = this.unitData.filter(e => 2 == e.id)[0];
-              this.bigUnitSelectedData = this.unitData.filter(e => 1 == e.id)[0];
-              if(!this.$util.isEmpty(this.option.ptItemId)){
-                this.getPtItemInfo(this.option.ptItemId)
-              }
-            }else{
-              this.getDetail();
-            }
-          });
-        })
         this.hasRequest = 1
-
+        //从平台导入花材
+        if(this.option.ptCpId){
+          let ptCpId = this.option.ptCpId
+          getPtCpInfo({id:ptCpId}).then(res=>{
+            if(res.code == 1){
+              that.form.name = res.data.info.name
+              that.form.inTurn = res.data.info.inTurn
+              that.form.ptCpId = res.data.info.id
+              that.currentImgData.push(res.data.info.cover)
+              that.form.cover.push(res.data.info.shortCover)
+            }
+          })
+        }
         getAllCpClass().then(res => {
           that.cpClassList = res.data.list ? res.data.list : []
         })
-
-      },
-      async _getAllUnit() {
-        await getAllUnit().then(res => {
-          if (this.$util.isEmpty(res.data)){
-            return false;
-          }
-          this.unitData = res.data.list;
-        });
-      },
-      async _getAllItemClass() {
-        await getAllItemClass().then(res => {
-          if (this.$util.isEmpty(res.data)){
-            return false;
-          }
-          this.itemClassData = res.data;
-        });
       },
       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 => {
+        addCpFn({...form,cover:this.form.cover[0]}).then(res => {
           uni.hideLoading()
           if(res.code == 1){
             this.$msg(res.msg)

+ 3 - 3
ghsApp/src/admin/cp/ptCpList.vue

@@ -6,7 +6,7 @@
                     <app-search-module v-model="py" placeholder="这里搜索产品" @input="searchFnContrapose"/>
                 </view>
                 <view style="padding:0 0upx 0 20upx;" >
-                    <button class="admin-button-com middle blue" @click="pageTo({ url: '/admin/cp/addCp',type:2 })">创建产品</button>
+                    <button class="admin-button-com middle blue" @click="pageTo({ url: '/admin/cp/addCp',type:2 })">创建产品</button>
                 </view>
             </view>
             <view style="position:fixed;z-index:99999;text-align:center;top:100upx;background-color:white;width:100%;height:60upx;font-size:26upx;">
@@ -120,12 +120,12 @@ export default {
             }else{
                 if(item.select == 2){
                     this.$util.confirmModal({content:'确认查看?'},() => {
-                        this.$util.pageTo({ url: '/admin/item/detail?id='+item.ghs_item_id})
+                        this.$util.pageTo({ url: '/admin/cp/updateCp?id='+item.cpId})
                     })
                     return
                 }
                 this.$util.confirmModal({content:'确认采用?'},() => {
-                    this.$util.pageTo({ url: '/admin/item/detail',type:2,query:{ptItemId:item.id}})
+                    this.$util.pageTo({ url: '/admin/cp/addCp?ptCpId='+item.id,type:2})
                 })
             }
         }

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

@@ -8,6 +8,10 @@ export const updateCpFn = data => {
 	return https.post('/cp/update-cp', data)
 }
 
+export const getPtCpInfo = data => {
+	return https.get('/pt-cp/detail', data)
+}
+
 export const getPtCpList = data => {
 	return https.get('/pt-cp/list', data)
 }