|
|
@@ -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>
|