shish 5 anni fa
parent
commit
242c0b6824

+ 86 - 37
ghsApp/src/admin/item/detail.vue

@@ -48,7 +48,7 @@
 							<tui-list-cell class="line-cell" :hover="false">
 								<div class="tui-title">库存</div>
 								<input v-model="form.stock" style="width:340rpx;" placeholder-class="phcolor" @focus="form.stock=''" @input="changeStock($event)" class="tui-input" name="stock" placeholder="请输入" type="digit"/>
-                <button class="admin-button-com blue small" @click="goStockDetail(productInfo.id,productInfo.itemId)">查看明细</button>
+                <button v-if="productData.id" class="admin-button-com blue small" @click="goStockDetail(productData.id)">查看明细</button>
 							</tui-list-cell>
         <tui-list-cell class="line-cell" :arrow="true">
           <div class="tui-title">大单位</div>
@@ -66,7 +66,6 @@
           </picker>
         </tui-list-cell>
 
-
         <tui-list-cell class="line-cell" :arrow="true">
           <div class="tui-title">小单位</div>
           <picker
@@ -83,7 +82,6 @@
           </picker>
         </tui-list-cell>
 
-
         <tui-list-cell class="line-cell" :hover="false">
           <div class="tui-title">单位比</div>
           <input
@@ -150,7 +148,7 @@
         </tui-list-cell>
 
         <tui-list-cell class="line-cell" :hover="false">
-          <div class="tui-title">状态</div>
+          <div class="tui-title">上架状态</div>
           <div class="switch_bx">
             <switch :checked="form.status == 2 ? false : true" @change="statusChange" style="transform: scale(0.8,0.8)" />
             <text v-if="form.status == 1">上架</text>
@@ -158,9 +156,17 @@
           </div>
         </tui-list-cell>
 
+        <tui-list-cell class="line-cell" :hover="false">
+          <div class="tui-title">状态</div>
+          <div class="switch_bx">
+            <switch :checked="form.delStatus == 0 ? true : false" @change="delStatusChange" style="transform: scale(0.8,0.8)" />
+            <text v-if="form.delStatus == 0">启用</text>
+            <text v-else>停用</text>
+          </div>
+        </tui-list-cell>
+
       </div>
 
-      <!-- 花材图片 -->
       <div class="module-com input-line-wrap goods-wrap">
         <div class="module-tit">
           <span>花材图片</span>
@@ -171,10 +177,10 @@
         </div>
       </div>
 
-      <!-- button -->
       <div class="app-footer">
         <button class="admin-button-com big default" @click="goBack()">取消</button>
-        <button class="admin-button-com big blue" formType="submit" @click="status = 1">确认</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>
       </div>
     </form>
   </div>
@@ -187,6 +193,7 @@ const form = require("@/utils/formValidation.js");
 import { getAllItemClass } from "@/api/item-class";
 import { getAllUnit } from "@/api/unit";
 import { addProduct,updateProduct,getProductDetail,py } from "@/api/product";
+import { getPtItemDetail } from "@/api/pt-item";
 
 export default {
   name: "item-detail",
@@ -212,6 +219,8 @@ export default {
         cover:'',
         stockWarning:'',
         status:2,
+        delStatus:0,
+        itemId:0,
       },
       itemClassSelectedData:{},
       itemClassData:[],
@@ -219,7 +228,7 @@ export default {
       smallUnitSelectedData:{},
       bigUnitSelectedData:{},
       hasRequest:0,
-      productInfo:null
+      productData:null
     };
   },
   computed: {
@@ -232,12 +241,15 @@ export default {
   watch:{
   },
   methods: {
-    goStockDetail(id,itemId){
-				this.$util.pageTo({url: "/pagesStorehouse/stockWarn/detailed?id="+itemId})
+    goStockDetail(id){
+				this.$util.pageTo({url: "/pagesStorehouse/stockWarn/detailed?id="+id})
 		},
     statusChange(e){
       this.form.status = e.detail.value ? 1 : 2;
     },
+    delStatusChange(e){
+      this.form.delStatus = e.detail.value ? 0 : 1;
+    },
     //如果库存被修改则花材状态变化
     changeStock(event){
       let num = Number(event.target.value)
@@ -278,9 +290,31 @@ export default {
         this.itemClassSelectedData = this.itemClassData[e.detail.value];
         this.form.classId = this.itemClassSelectedData.id;
     },
-    _getDet() {
-      return getProductDetail({ id: this.option.id })
-        .then(res => {
+    //从平台导入花材 shish 20210826
+    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.form.cover = [res.data.shortCover]
+        this.form.stock = ''
+        this.form.itemId = ptItemId
+        this.form.classId = ''
+        this.form.status = 1
+        this.form.delStatus = 0
+        this.form.id = 0
+        this.form.cost = ''
+        this.form.addPrice =''
+
+      })
+    },
+    getDetail() {
+      return getProductDetail({ id: this.option.id }).then(res => {
         if (this.$util.isEmpty(res.data)) {
           return;
         }
@@ -300,35 +334,35 @@ export default {
           e => this.form.bigUnitId == e.id
         )[0];
 
-        this.productInfo = res.data
+        this.productData = res.data
 
       });
     },
     init() {
+
+      //从平台导入花材
+      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];
-        }else{
-          this._getDet();
-        }
-
-      });
-
+        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
-
-
     },
     async _getAllUnit() {
       await getAllUnit().then(res => {
@@ -354,12 +388,28 @@ export default {
       }
 
       this.form.cover = this.form.cover[0]
-      let host = this.form.id == 0 ? addProduct : updateProduct;
+
+      let requestHost = addProduct
+      if(this.form.id && this.form.id != 0){
+        requestHost = updateProduct;
+      }else{
+				if(/(^[1-9]([0-9]+)?(\.[0-9]{1,2})?$)|(^(0){1}$)|(^[0-9]\.[0-9]([0-9])?$)/.test(this.form.stock) == false){
+					uni.showToast({title:"请填写库存,没有请填0",icon:"none"})
+					return;
+				}
+				if(/(^[1-9]([0-9]+)?(\.[0-9]{1,2})?$)|(^(0){1}$)|(^[0-9]\.[0-9]([0-9])?$)/.test(this.form.cost) == false){
+					uni.showToast({title:"请填写成本价",icon:"none"})
+					return;
+				}
+				if(/(^[1-9]([0-9]+)?(\.[0-9]{1,2})?$)|(^(0){1}$)|(^[0-9]\.[0-9]([0-9])?$)/.test(this.form.addPrice) == false){
+					uni.showToast({title:"请填写加价",icon:"none"})
+					return;
+				}
+      }
       let form = JSON.parse(JSON.stringify(this.form));
       form.cover = this.$util.imgSubstr(form.cover);
-      host({
-        ...form
-      }).then(res => {
+      requestHost({...form}).then(res => {
+
         this.$msg("操作成功!");
 
         //返回上一页带参数
@@ -435,7 +485,6 @@ export default {
       ];
       // 进行表单检查
       let formData = e.detail.value;
-      console.log('form',formData)
       let checkRes = form.validation(formData, rules);
       // 验证通过!
       if (!checkRes) {

+ 1 - 2
ghsApp/src/admin/item/list.vue

@@ -6,10 +6,9 @@
 				<app-search-module v-model="py" placeholder="输入拼音首字母查询" @input="searchFn"/>
 			</view>
 			<view style="padding:0 0rpx 0 20rpx;" >
-				<button class="admin-button-com middle blue" @click="pageTo({ url: '/admin/item/detail' })">添加</button>
+				<button class="admin-button-com middle blue" @click="pageTo({ url: '/admin/ptItem/itemList' })">添加花材</button>
 			</view>
 		</view>
-
 		<view class="scroll-middle_bx">
 			<scroll-view scroll-y scroll-with-animation class="tab-view" :scroll-top="scrollTop">
 				<div v-for="(item, index) in filterProductInfo" :key="index" class="tab-bar-item" :class="[classIndex == index ? 'active' : '']" :data-current="index" @tap.stop="swichClass(index)">

+ 17 - 26
ghsApp/src/admin/ptItem/components/Item.vue

@@ -1,15 +1,14 @@
 <template>
-	<view class="item-cmd_bx" v-if="hidden==0">
+	<view class="item-cmd_bx" @click="selectItem(info)">
 		<view class="img_bx" style="background:#eeeeee">
 			<image :src="info.cover" v-if="isImg"></image>
 		</view>
-		<view @click="goItem(info.id,info.itemId)" class="cmd-info_bx" :class="type == STOCK_TYPE.WARN?'':'active'">
+		<view class="cmd-info_bx" :class="type == STOCK_TYPE.WARN?'':'active'">
 			<view class="tit">{{ info.name || "" }}</view>
-			<view class="kc"></view>
+			<view class="kc">{{info.className}}<text v-if="info.select == 2" style="color:#1f1cc0;float:right;margin-right:80rpx;">已添加</text></view>
 			<view class="num-open_bx">
-				<view class="price" v-if="isPrice">¥{{ info.price }}</view>
 				<view class="open-bx warn">
-					单位 <text style="margin-left: 10rpx;">{{ info.bigUnit }}</text>
+					单位:<text>{{ info.bigUnit }}</text>
 				</view>
 			</view>
 		</view>
@@ -71,12 +70,8 @@ export default {
 		}
 	},
 	methods: {
-		goItem(id,itemId){
-			if(this.type == STOCK_TYPE.WARN){
-				this.$util.pageTo({url: "/admin/item/detail?id="+id})
-			}else{
-				this.$util.pageTo({url: "/pagesStorehouse/stockWarn/detailed?id="+itemId})
-			}
+		selectItem(item){
+			this.$emit("selectItem",item);
 		},
 		customNum() {
 			this.$emit("customNum");
@@ -97,10 +92,10 @@ export default {
 <style lang="scss" scoped>
 .item-cmd_bx {
 	position: relative;
-	margin-bottom: 20px;
+	margin-bottom: 10px;
 	.img_bx {
-		height: 160px;
-		width: 160px;
+		height: 150px;
+		width: 150px;
 		position: absolute;
 		left: 0px;
 		top: 0px;
@@ -130,15 +125,15 @@ export default {
 		}
 
 		& .tit {
-			font-size: 28px;
-			font-weight: 400;
+			font-size: 32px;
+			font-weight: bold;
 			color: #333333;
-			padding-top: 10px;
+			padding-top: 0px;
 		}
 		& .kc {
-			color: #999999;
-			font-size: 24px;
-			padding: 10px 0 24px;
+			color: #9e9d9d;
+			font-size: 28px;
+			padding: 17px 0 17px;
 		}
 		& .num-open_bx {
 			display: flex;
@@ -149,16 +144,12 @@ export default {
 				flex: 1;
 			}
 			& .open-bx {
-				color: #333333;
+				color: #9e9d9d;
 				text{
 					font-size: 24rpx;
-					font-weight: 700;
-				}
-				*.warn {
-					color: $redColor;
 				}
 			}
 		}
 	}
 }
-</style>
+</style>

+ 23 - 0
ghsApp/src/admin/ptItem/itemList.vue

@@ -4,6 +4,9 @@
 			<view class="search-bar">
 				<app-search-module v-model="py" placeholder="输入拼音首字母查询" @input="searchFnContrapose"/>
 			</view>
+			<view style="padding:0 0rpx 0 20rpx;" >
+				<button class="admin-button-com middle blue" @click="pageTo({ url: '/admin/item/detail',type:2 })">手动添加</button>
+			</view>
 		</view>
 		<view class="scroll-middle_bx">
 			<block v-if="!$util.isEmpty(filterProductInfoContrapose)">
@@ -17,6 +20,7 @@
 							:info="productItem"
 							:isEdit="true"
 							:modifyStock="modifyStock"
+							@selectItem="selectItem"
 						></ptItemInfo>
 						</view>
 					</template>
@@ -39,6 +43,8 @@ import productContraposeMins from "@/mixins/ptProductContrapose";
 import { selectShop } from "@/mixins";
 import { mapGetters } from "vuex";
 import DorpdownSelect from "@/components/module/dorpdownSelect";
+import { getAllItemClass } from "@/api/item-class";
+
 export default {
 	name: "ptItemList",
 	components: {
@@ -61,6 +67,7 @@ export default {
 					key: STOCK_TYPE.WARN
 				}
 			],
+			allClass:[]
 		};
 	},
 	computed:{
@@ -81,6 +88,22 @@ export default {
 	onShow(){
 	},
 	methods: {
+		init() {
+			let that = this
+			getAllItemClass().then(res => {
+				if (this.$util.isEmpty(res.data)){
+					return false;
+				}
+				that.allClass = res.data
+			});
+		},
+		selectItem(item){
+			if(item.select == 2){
+				this.$msg("已添加")
+				return
+			}
+			this.$util.pageTo({ url: '/admin/item/detail',type:2,query:{ptItemId:item.id}})
+		},
 		affirm(val) {
 			if (val.index === 0) {
 				this.modalCancel();

+ 4 - 0
ghsApp/src/api/pt-item/index.js

@@ -4,3 +4,7 @@ import https from "@/plugins/luch-request_0.0.7/request";
 export const ptItemList = data => {
 	return https.get("/pt-item/list", data);
 };
+
+export const getPtItemDetail = data => {
+	return https.get("/pt-item/detail", data);
+};

+ 1 - 1
ghsApp/src/pages.json

@@ -17,7 +17,7 @@
 		{
 			"root": "admin/ptItem",
 			"pages": [
-				{"path": "itemList","style": {"navigationBarTitleText": "平台花材"}}
+				{"path": "itemList","style": {"navigationBarTitleText": "请选择平台花材"}}
 			]
 		},
 		{

+ 1 - 1
ghsApp/src/pagesPurchase/add.vue

@@ -5,7 +5,7 @@
 				<app-search-module v-model="py" placeholder="输入字母搜索" @input="searchFn"/>
 			</view>
 			<view style="padding:0 0rpx 0 20rpx;" >
-				<button class="admin-button-com middle blue" @click="pageTo({ url: '/admin/item/detail' })">添加花材</button>
+				<button class="admin-button-com middle blue" @click="pageTo({ url: '/admin/ptItem/itemList' })">添加花材</button>
 			</view>
 			<view style="padding:0 0rpx 0 20rpx;" >
 				<button class="admin-button-com middle blue" @click="removeMemory()">清除采购</button>

+ 2 - 7
ghsApp/src/pagesStorehouse/stockWarn/detailed.vue

@@ -1,8 +1,6 @@
 <template>
 	<view class="ex-page">
 		<view class="top-bar" v-if="false">
-<!--			<SelectList :list="selectListData" @search="searchSelectEvent" />-->
-
 				<DorpdownSelect class="bar"
 					:menuObj="menuTimeObj"
 					:typeTime="true"
@@ -38,9 +36,6 @@
 										<view class="info-name">
 											{{ item.addTime }}
 										</view>
-										<!-- <view class="info-type">
-										{{ item.addTime }}
-									</view> -->
 									</view>
 								</view>
 								<view v-else>
@@ -56,7 +51,7 @@
 			</view>
 		</scroll-view>
 
-		<!--		时间段选择-->
+		<!--时间段选择-->
 		<rangeDatePick
 			:show="isShow"
 			start="2000-01-01"
@@ -167,7 +162,7 @@ export default {
 	},
 	onLoad(e) {
 		this.itemId = e.id;
-		this.params.itemId = e.id;
+		this.params.id = e.id;
 		let dateDefaultOption = [];
 		let list = this.getDictionariesInfo.dateDefaultOption;
 		for (let i=0;i<list.length;i++){