shish 2 лет назад
Родитель
Сommit
7893d313ed
3 измененных файлов с 36 добавлено и 14 удалено
  1. 1 1
      ghsApp/src/admin/cp/list.vue
  2. 27 13
      ghsApp/src/admin/item/detail.vue
  3. 8 0
      ghsApp/src/api/cp/index.js

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

@@ -171,7 +171,7 @@
                 let pages = getCurrentPages();
                 let pages = getCurrentPages();
                 let prevPage = pages[ pages.length - 2 ];
                 let prevPage = pages[ pages.length - 2 ];
                 //修改上一页data里面的xjData
                 //修改上一页data里面的xjData
-                prevPage.$vm.returnCpInfo = {cpId:info.id,cpName:info.name,needUpdate:1}
+                prevPage.$vm.backCpInfo = {cpId:info.id,cpName:info.name,needUpdate:1}
                 uni.navigateBack()
                 uni.navigateBack()
             }
             }
         },
         },

+ 27 - 13
ghsApp/src/admin/item/detail.vue

@@ -96,14 +96,13 @@
           </view>
           </view>
         </tui-list-cell>
         </tui-list-cell>
 
 
-        <tui-list-cell class="line-cell" :arrow="true">
+        <tui-list-cell class="line-cell" :hover="false">
           <view class="tui-title">所属产品</view>
           <view class="tui-title">所属产品</view>
-          <input v-model="form.cpId" name="cpId" type="text" hidden />
-          <view style="color:#CCCCCC;width:450upx;height:45upx;" @click.stop="changeCp()" v-if="form.cpId == 0">
-            请选择产品
-          </view>
-          <view @click.stop="changeCp()" style="width:450upx;height:45upx;" v-else>
-            {{form.cpName}}
+          <view>
+            <block v-if="productData.cpInfo && !$util.isEmpty(productData.cpInfo)">
+              <button v-for="(cpItem, cpIndex) in productData.cpInfo" class="admin-button-com blue mini-btn" style="margin-right:8upx;" @click.stop="delOneCp(cpItem)">{{cpItem.cpName}} ×</button>
+            </block>
+            <button class="admin-button-com default mini-btn" @click.stop="changeCp()">添加产品</button>
           </view>
           </view>
         </tui-list-cell>
         </tui-list-cell>
 
 
@@ -283,6 +282,7 @@ import TuiListCell from "@/components/plugin/list-cell";
 const form = require("@/utils/formValidation.js");
 const form = require("@/utils/formValidation.js");
 import { getAllItemClass } from "@/api/item-class";
 import { getAllItemClass } from "@/api/item-class";
 import { applyAuth } from '@/api/item';
 import { applyAuth } from '@/api/item';
+import { delCpItem,addCpItem } from '@/api/cp'
 import { getAllUnit } from "@/api/unit";
 import { getAllUnit } from "@/api/unit";
 import { addProduct,updateProduct,getProductDetail,py,print,modifyOnStockFn,delStatusUpdate } from "@/api/product";
 import { addProduct,updateProduct,getProductDetail,py,print,modifyOnStockFn,delStatusUpdate } from "@/api/product";
 import { getPtItemDetail } from "@/api/pt-item";
 import { getPtItemDetail } from "@/api/pt-item";
@@ -314,8 +314,6 @@ export default {
         smallUnitId:2,
         smallUnitId:2,
         classId:'',
         classId:'',
         className:'',
         className:'',
-        cpId:'',
-        cpName:'',
         price:'',
         price:'',
         skPrice:'',
         skPrice:'',
         hjPrice:'',
         hjPrice:'',
@@ -373,6 +371,7 @@ export default {
 
 
   },
   },
   onShow(){
   onShow(){
+    let that = this
     //重复花材,删除花材之后,返回上一页花材,需要刷新
     //重复花材,删除花材之后,返回上一页花材,需要刷新
     if(this.onShowRefresh == 1){
     if(this.onShowRefresh == 1){
       if(this.hasRequest == 0){
       if(this.hasRequest == 0){
@@ -381,13 +380,28 @@ export default {
       }
       }
     }
     }
     if(this.backCpInfo.needUpdate == 1){
     if(this.backCpInfo.needUpdate == 1){
-      this.backCpInfo.needUpdate = 0
-      this.form.cpId = this.backCpInfo.cpId
-      this.form.cpName = this.backCpInfo.cpName
-      this.$forceUpdate()
+      addCpItem({cpId:that.backCpInfo.cpId,productId:that.productData.id}).then(res=>{
+        if(res.code == 1){
+          that.$msg(res.msg)
+          that.hasRequest = 0
+          that.init()
+        }
+      })
     }
     }
   },
   },
   methods: {
   methods: {
+    delOneCp(cp){
+      let that = this
+      that.$util.confirmModal({content:'确认删除'+cp.cpName+'?'},() => {
+        delCpItem({id:cp.id}).then(res=>{
+          if(res.code == 1){
+            that.$msg(res.msg)
+            that.hasRequest = 0
+            that.init()
+          }
+        })
+      })      
+    },
     changeCp(item){
     changeCp(item){
       this.$util.pageTo({url: '/admin/cp/list?skip=1'})
       this.$util.pageTo({url: '/admin/cp/list?skip=1'})
     },
     },

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

@@ -40,6 +40,14 @@ export const delCpClass = data => {
 	return https.get('/cp-class/del', data)
 	return https.get('/cp-class/del', data)
 }
 }
 
 
+export const delCpItem = data => {
+	return https.get('/cp-item/del', data)
+}
+
+export const addCpItem = data => {
+	return https.get('/cp-item/add', data)
+}
+
 export const getCpList = data => {
 export const getCpList = data => {
 	return https.get('/cp/list', data)
 	return https.get('/cp/list', data)
 }
 }