shish 5 жил өмнө
parent
commit
03081d2847

+ 1 - 1
ghsApp/src/admin/item/components/CommodityStock.vue → ghsApp/src/admin/item/components/ItemStock.vue

@@ -3,7 +3,7 @@
 		<view class="img_bx">
 			<app-img :src="info.cover" alt="花材" mode="aspectFit" :height="160" />
 		</view>
-		<navigator :url="`/pagesStorehouse/stockWarn/detailed?id=${info.itemId}`" class="cmd-info_bx active">
+		<navigator :url="`/admin/item/detail?id=${info.id}`" class="cmd-info_bx active">
 			<view class="tit">{{ info.itemName || "" }}</view>
 			<view class="kc">{{ info.rank || "" }}级</view>
 			<view class="num-open_bx">

+ 429 - 0
ghsApp/src/admin/item/detail.vue

@@ -0,0 +1,429 @@
+<template>
+  <div 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" :arrow="true">
+            <div class="tui-title">分类</div>
+            <picker
+              mode="selector"
+              :value="form.classId"
+              :range="itemClassData"
+              range-key="name"
+              @change="changeItemClassFn"
+              class="tui-input"
+            >
+              <input v-model="form.classId" name="classId" type="text" hidden />
+              <div v-if="form.classId">{{ itemClassSelectedData.name }}</div>
+              <div class="tui-placeholder" v-else>请选择</div>
+            </picker>
+          </tui-list-cell>
+
+        <tui-list-cell class="line-cell" :hover="false">
+          <div class="tui-title">拼音缩写</div>
+          <input
+            v-model="form.py"
+            placeholder-class="phcolor"
+            class="tui-input"
+            name="py"
+            placeholder="请填写拼音首字母缩写"
+            maxlength="50"
+            type="text"
+          />
+        </tui-list-cell>
+
+        <tui-list-cell class="line-cell" :arrow="true">
+          <div class="tui-title">大单位</div>
+          <picker
+            mode="selector"
+            :value="form.bigUnitId"
+            :range="unitData"
+            range-key="name"
+            @change="changeBigUnitFn"
+            class="tui-input"
+          >
+            <input v-model="form.bigUnitId" name="bigUnitId" type="text" hidden />
+            <div v-if="form.bigUnitId">{{ bigUnitSelectedData.name }}</div>
+            <div class="tui-placeholder" v-else>请选择</div>
+          </picker>
+        </tui-list-cell>
+
+
+        <tui-list-cell class="line-cell" :arrow="true">
+          <div class="tui-title">小单位</div>
+          <picker
+            mode="selector"
+            :value="form.smallUnitId"
+            :range="unitData"
+            range-key="name"
+            @change="changeSmallUnitFn"
+            class="tui-input"
+          >
+            <input v-model="form.smallUnitId" name="smallUnitId" type="text" hidden />
+            <div v-if="form.smallUnitId">{{ smallUnitSelectedData.name }}</div>
+            <div class="tui-placeholder" v-else>请选择</div>
+          </picker>
+        </tui-list-cell>
+
+
+        <tui-list-cell class="line-cell" :hover="false">
+          <div class="tui-title">单位比</div>
+          <input
+            v-model="form.ratio"
+            placeholder-class="phcolor"
+            class="tui-input"
+            name="ratio"
+            placeholder="如:1扎=20支,请填写20"
+            maxlength="50"
+            type="number"
+          />
+        </tui-list-cell>
+
+        <tui-list-cell class="line-cell" :hover="false">
+          <div class="tui-title">每扎成本</div>
+          <input
+            v-model="form.cost"
+            placeholder-class="phcolor"
+            class="tui-input"
+            name="cost"
+            placeholder="请填写成本价"
+            maxlength="50"
+            type="digital"
+          />
+        </tui-list-cell>
+
+        <tui-list-cell class="line-cell" :hover="false">
+          <div class="tui-title">每扎加价</div>
+          <input
+            v-model="form.addPrice"
+            placeholder-class="phcolor"
+            class="tui-input"
+            name="addPrice"
+            placeholder="请填写加价"
+            maxlength="50"
+            type="digital"
+          />
+        </tui-list-cell>
+
+        <tui-list-cell class="line-cell" :hover="false">
+          <div class="tui-title">每扎重量</div>
+          <input
+            v-model="form.weight"
+            placeholder-class="phcolor"
+            class="tui-input"
+            name="weight"
+            placeholder="单位:公斤"
+            maxlength="50"
+            type="digital"
+          />
+        </tui-list-cell>
+
+
+        <tui-list-cell class="line-cell" :hover="false">
+          <div class="tui-title">库存预警值</div>
+          <input
+            v-model="form.stockWarning"
+            placeholder-class="phcolor"
+            class="tui-input"
+            name="stockWarning"
+            placeholder="如:1扎=20支,请填写20"
+            maxlength="50"
+            type="number"
+          />
+        </tui-list-cell>
+
+      </div>
+
+      <!-- 花材图片 -->
+      <div class="module-com input-line-wrap goods-wrap">
+        <div class="module-tit">
+          <span>花材图片</span>
+          <span class="app-color-3">(建议比例400X400)</span>
+        </div>
+        <div class="module-det">
+          <app-uploader ref="appUploader" :imgList.sync="itemCover" :isMain="false" :num="1" />
+        </div>
+      </div>
+
+      <!-- button -->
+      <div class="app-footer">
+        <button class="admin-button-com middle default" @click="goBack()">取消</button>
+        <button class="admin-button-com middle blue" formType="submit" @click="status = 1">确认</button>
+      </div>
+    </form>
+  </div>
+</template>
+
+<script>
+import TuiListCell from "@/components/plugin/list-cell";
+import AppUploader from "@/components/app-uploader";
+const form = require("@/utils/formValidation.js");
+import { getAllItemClass } from "@/api/item-class";
+import { getAllUnit } from "@/api/unit";
+import { addProduct,updateProduct,getProductDetail } from "@/api/product";
+
+export default {
+  name: "item-detail",
+  components: {
+    TuiListCell,
+    AppUploader
+  },
+  data() {
+    return {
+      status: 1,
+      form: {
+        id:0,
+        name:"",
+        py:"",
+        ratio:'',
+        bigUnitId:'',
+        smallUnitId:'',
+        classId:'',
+        cost:'',
+        addPrice:'',
+        weight:'',
+        cover:'',
+        stockWarning:''
+      },
+      itemClassSelectedData:{},
+      itemClassData:[],
+      unitData:[],
+      smallUnitSelectedData:{},
+      bigUnitSelectedData:{},
+      itemCover:[]
+    };
+  },
+  computed: {
+  },
+  onLoad(option) {
+    if(option.id){
+      this.form.id = this.option.id
+    }
+  },
+  watch:{
+  },
+  methods: {
+    goBack(){
+      uni.navigateBack({
+						delta: 1
+					});
+    },
+    changeBigUnitFn(e){
+      this.bigUnitSelectedData = this.unitData[e.detail.value];
+      this.form.bigUnitId = this.bigUnitSelectedData.id;
+    },
+    changeSmallUnitFn(e){
+      this.smallUnitSelectedData = this.unitData[e.detail.value];
+      this.form.smallUnitId = this.smallUnitSelectedData.id;
+    },
+    changeItemClassFn(e) {
+        this.itemClassSelectedData = this.itemClassData[e.detail.value];
+        this.form.classId = this.itemClassSelectedData.id;
+    },
+
+    _getDet() {
+      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.itemCover[0] = res.data.shortCover
+
+        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];
+
+      });
+    },
+    init() {
+      
+      this._getAllUnit().then(res=>{
+
+      this._getAllItemClass().then(res => {
+        this._getDet();
+      });
+
+      })
+
+
+
+    },
+    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;
+      }
+      this.form.cover = this.form.cover[0]
+      let host = this.form.id == 0 ? addProduct : updateProduct;
+      let form = JSON.parse(JSON.stringify(this.form));
+      form.cover = this.$util.imgSubstr(form.cover);
+      console.log('aaaaform',this.form)
+      host({
+        ...form
+      }).then(res => {
+        uni.navigateBack({});
+        this.$msg("操作成功!");
+      });
+    },
+    // 表单验证
+    formSubmit(e) {
+      // 表单规则
+      let rules = [
+        {
+          name: "name",
+          rule: ["required"],
+          msg: ["请填写名称"]
+        },
+        {
+          name: "py",
+          rule: ["required"],
+          msg: ["请填写拼音缩写"]
+        },
+        {
+          name: "bigUnitId",
+          rule: ["required"],
+          msg: ["请选择大单位"]
+        },
+        {
+          name: "smallUnitId",
+          rule: ["required"],
+          msg: ["请选择小单位"]
+        },
+        {
+          name: "ratio",
+          rule: ["required"],
+          msg: ["请填写单位比"]
+        },
+        {
+          name: "cost",
+          rule: ["required"],
+          msg: ["请填写成本价"]
+        },
+        {
+          name: "addPrice",
+          rule: ["required"],
+          msg: ["请填写加价"]
+        },
+        {
+          name: "weight",
+          rule: ["required"],
+          msg: ["请填写重量"]
+        },
+        {
+          name: "classId",
+          rule: ["required"],
+          msg: ["请选择分类"]
+        },
+        {
+          name: "stockWarning",
+          rule: ["required"],
+          msg: ["请选择库存预警值"]
+        }
+        // ,
+        // {
+        //   name: "cover",
+        //   rule: ["required"],
+        //   msg: ["请上传图片"]
+        // }
+      ];
+      // 进行表单检查
+      let formData = e.detail.value;
+      console.log('form',formData)
+      let checkRes = form.validation(formData, rules);
+      // 验证通过!
+      if (!checkRes) {
+        setTimeout(() => {
+          this.confirmFn();
+        });
+      } else {
+        this.$msg(checkRes);
+      }
+    }
+  }
+};
+</script>
+<style lang="scss" scoped>
+.app-content {
+  min-height: calc(100vh - 100px);
+  padding-bottom: 100px;
+}
+// 公共模块
+.module-com {
+  margin-bottom: 20px;
+  background-color: #fff;
+  color: $fontColor2;
+  .module-tit {
+    padding: 20px 30px;
+    font-size: 28px;
+  }
+  .module-det {
+    padding: 0 30px;
+  }
+}
+.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: 20px;
+      margin-bottom: 20px;
+      position: relative;
+      z-index: 9999;
+    }
+  }
+}
+.summary-wrap {
+  .goods-summary {
+    height: 400px;
+  }
+}
+.app-footer {
+  justify-content: space-evenly;
+  z-index: 9999;
+  .admin-button-com {
+    width: 46%;
+  }
+}
+</style>

+ 6 - 6
ghsApp/src/admin/item/list.vue

@@ -5,7 +5,7 @@
 			<view class="search-bar">
 				<app-search-module v-model="py" placeholder="输入商品名拼音首字母查询" @input="searchFn"/>
 			</view>
-			<view style="padding:10rpx 0 0 8rpx;">
+			<view style="padding:10rpx 0 0 8rpx;" @click="pageTo({ url: '/admin/item/detail' })">
 				<i class="iconfont icontianjiakehu" style="font-size:40rpx;color:#cccccc;"></i>
 				<span style="font-size:30rpx;color:#cccccc;margin-left:2rpx;">添加</span>
 			</view>
@@ -28,12 +28,12 @@
 						<text v-if="tabs[tabIndex].name=='库存预警'&&$util.isEmpty(classItem.child)">当前库存充足</text>
 						<template v-for="(productItem, productIndex) in classItem.child">
 							<view style="height: 200rpx" :id="`class_${classIndex}`" :key="classIndex">
-								<CommodityStock v-if="classItem.isActive"
+								<ItemStock v-if="classItem.isActive"
 								:isPrice="false"
 								:type="tabs[tabIndex].key"
 								:key="productIndex"
 								:info="productItem"
-							></CommodityStock>
+							></ItemStock>
 							</view>
 						</template>
 					</view>
@@ -54,7 +54,7 @@
 <script>
 import AppSearchModule from "@/components/module/app-search";
 import AppWrapperEmpty from "@/components/app-wrapper-empty";
-import CommodityStock from "./components/CommodityStock";
+import ItemStock from "./components/ItemStock";
 import { STOCK_TYPE } from "@/utils/declare";
 import productMins from "@/mixins/product";
 import productContraposeMins from "@/mixins/productContrapose";
@@ -62,11 +62,11 @@ import { selectShop } from "@/mixins";
 import { mapGetters } from "vuex";
 import DorpdownSelect from "@/components/module/dorpdownSelect";
 export default {
-	name: "stock_manage",
+	name: "item_list",
 	components: {
 		AppSearchModule,
 		AppWrapperEmpty,
-		CommodityStock,
+		ItemStock,
 		DorpdownSelect
 	},
 	mixins: [productMins, selectShop,productContraposeMins],

+ 2 - 2
ghsApp/src/admin/itemClass/list.vue

@@ -52,7 +52,7 @@
 					<div class="inp-list-line">
 						<div class="line-label">顺序</div>
 						<div class="line-input">
-							<input type="text" v-model="replaceForm.inTurn" :adjust-position="false" class="inp-input" placeholder="越大越靠前" />
+							<input type="number" v-model="replaceForm.inTurn" :adjust-position="false" class="inp-input" placeholder="越大越靠前" />
 						</div>
 					</div>
 				</div>
@@ -71,7 +71,7 @@ import AppWrapperEmpty from '@/components/app-wrapper-empty'
 import { list } from '@/mixins'
 import { getList,addClass,updateClass} from '@/api/item-class'
 export default {
-	name: 'category-manage',
+	name: 'item-class-list',
 	components: {
 		ModalModule,
 		AppUploader,

+ 5 - 1
ghsApp/src/api/item-class/index.js

@@ -10,4 +10,8 @@ export const addClass = data => {
 
 export const updateClass = data => {
 	return https.post('/item-class/update', data)
-}
+}
+
+export const getAllItemClass = data => {
+	return https.get('/item-class/all', data)
+}

+ 14 - 0
ghsApp/src/api/product/index.js

@@ -33,3 +33,17 @@ export const autoPriceByIdApi = data => {
 export const changePriceByIdApi = data => {
 	return https.post("/product/change-price", data);
 };
+
+//添加花材
+export const addProduct = data => {
+	return https.post("/product/add", data);
+};
+
+//修改花材
+export const updateProduct = data => {
+	return https.post("/product/update", data);
+};
+
+export const getProductDetail = data => {
+	return https.get("/product/detail", data);
+};

+ 5 - 0
ghsApp/src/api/unit/index.js

@@ -0,0 +1,5 @@
+import https from '@/plugins/luch-request_0.0.7/request'
+
+export const getAllUnit = data => {
+	return https.get('/unit/get-all-unit', data)
+}

+ 6 - 0
ghsApp/src/pages.json

@@ -771,6 +771,12 @@
 					"style": {
 						"navigationBarTitleText": "花材列表"
 					}
+				},
+				{
+					"path": "detail",
+					"style": {
+						"navigationBarTitleText": "花材详情"
+					}
 				}
 			]
 		},

+ 3 - 3
ghsApp/src/utils/config.js

@@ -3,7 +3,7 @@ import CONSTANT from '@/constant'
 import UTIL from '@/utils/util'
 
 import { getList as getLevelList } from '@/api/level'
-import { categoryListB as getCategoryList, usageListB as getUsageList } from '@/api/goods'
+import { getAll, usageListB as getUsageList } from '@/api/item-class'
 import { getFestList } from '@/api/common'
 import { orderRelate as getOrderRelate } from '@/api/order'
 
@@ -27,7 +27,7 @@ export async function getLevel(update) {
 }
 
 /**
- * 获取分类列表
+ * 获取花材分类列表
  * @parmas update为true时会重新触发请求,重置vuex的数据
  */
 export async function getCategory(update) {
@@ -35,7 +35,7 @@ export async function getCategory(update) {
 	if (!UTIL.isEmpty(data) && !update) {
 		return data
 	}
-	await getCategoryList().then(res => {
+	await getAll().then(res => {
 		data = res.data
 		store.dispatch('setCategory', data)
 	}).catch(() => {