Browse Source

添加产品

lilei 3 years ago
parent
commit
e1a80c20ee

+ 12 - 3
src/views/bulkManagement/bulkWarehousingOrder/edit.vue

@@ -222,7 +222,13 @@
       v-model="showNewProduct"
       @cancle="showNewProduct=false"
       :width="800">
-      <newProduct ref="newProduct" :saveing="spinning" :paramsData="paramsData" pageType="modal" @saveOk="saveProductOk"></newProduct>
+      <newProduct
+        ref="newProduct"
+        :saveing="spinning"
+        :paramsData="paramsData"
+        pageType="modal"
+        @cansel="showNewProduct=false"
+        @saveOk="saveProductOk"></newProduct>
     </a-modal>
   </div>
 </template>
@@ -378,7 +384,8 @@ export default {
               supplierName: _this.basicInfoData.supplierName,
               code: _this.queryParam.queryWord,
               putCost: 0,
-              putQty: 1
+              putQty: 1,
+              warehouse: []
             }
             _this.showNewProduct = true
             _this.$nextTick(() => {
@@ -390,6 +397,8 @@ export default {
         if (data.length == 1 && this.showNewProduct) {
           data[0].putCost = this.paramsData.putCost
           data[0].putQty = this.paramsData.putQty
+          data[0].warehouseSn = this.paramsData.warehouse[0] || ''
+          data[0].warehouseLocationSn = this.paramsData.warehouse[1] || ''
           this.handleAdd(data[0])
         }
       }
@@ -397,7 +406,7 @@ export default {
     // 添加产品成功
     saveProductOk (data) {
       this.paramsData = data
-      this.queryParam.queryWord = data.name
+      this.queryParam.queryWord = data.code
       this.$refs.table.refresh(true)
     },
     //  重置

+ 0 - 59
src/views/common/shelfSettleType.js

@@ -1,59 +0,0 @@
-import { productTypeQuery } from '@/api/productType'
-const ProductType = {
-  template: `
-      <a-cascader
-        @change="handleChange"
-        change-on-select
-        :value="defaultVal"
-        expand-trigger="hover"
-        :options="productTypeList"
-        :fieldNames="{ label: 'productTypeName', value: 'productTypeSn', children: 'children' }"
-        :id="id"
-        placeholder="请选择结算方式"
-        allowClear />
-    `,
-  props: {
-    value: {
-      type: Array,
-      defatut: function () {
-        return []
-      }
-    },
-    id: {
-      type: String,
-      default: ''
-    }
-  },
-  data () {
-    return {
-      defaultVal: this.value,
-      productTypeList: []
-    }
-  },
-  watch: {
-    value (newValue, oldValue) {
-      this.defaultVal = newValue
-    }
-  },
-  mounted () {
-    this.getProductType()
-  },
-  methods: {
-    handleChange (value) {
-      this.defaultVal = value
-      this.$emit('change', this.defaultVal)
-    },
-    //  产品分类列表
-    getProductType () {
-      productTypeQuery({}).then(res => {
-        if (res.status == 200) {
-          this.productTypeList = res.data
-        } else {
-          this.productTypeList = []
-        }
-      })
-    }
-  }
-}
-
-export default ProductType

+ 99 - 0
src/views/common/warehouse.js

@@ -0,0 +1,99 @@
+import { warehouseCascadeList } from '@/api/warehouse'
+const Warehouse = {
+  template: `
+        <a-cascader
+          :size="size"
+          @change="handleChange"
+          :value="defaultVal"
+          expand-trigger="hover"
+          :allowClear="allowClear"
+          :options="warehouseCascadeData"
+          :fieldNames="{ label: 'name', value: 'sn', children: 'warehouseLocationList' }"
+          :id="id"
+          placeholder="请选择仓库仓位"
+          style="width: 100%;" />
+    `,
+  props: {
+    value: {
+      type: Array,
+      defatut: function () {
+        return []
+      }
+    },
+    id: {
+      type: String,
+      default: ''
+    },
+    allowClear: {
+      type: Boolean,
+      default: true
+    },
+    size: {
+      type: String,
+      default: 'default'
+    }
+  },
+  data () {
+    return {
+      defaultVal: this.value,
+      warehouseCascadeData: [],
+      defaultWarehouseCascade:[]
+    }
+  },
+  watch: {
+    value (newValue, oldValue) {
+      this.defaultVal = newValue
+    },
+  },
+  mounted () {
+    this.getWarehouseCascade()
+  },
+  methods: {
+    handleChange (value, selectedOptions) {
+      this.defaultVal = value
+      this.$emit('change', this.defaultVal, selectedOptions)
+      this.$emit('input', this.defaultVal)
+    },
+    //  仓库仓位  级联  列表
+    getWarehouseCascade () {
+      const _this = this
+      warehouseCascadeList({}).then(res => {
+        if (res.status == 200) {
+          res.data.filter(item => {
+            // 过滤默认仓库
+            if (item.defaultFlag == 1 && item.wasteFlag == 0) { //  defaultFlag为1,且不是废品仓
+              _this.defaultWarehouseCascade[0] = item.warehouseSn
+              // 过滤默认仓位
+              item.warehouseLocationList.filter(subItem => {
+                if (subItem.defaultFlag == 1 && subItem.wasteFlag == 0) {
+                  _this.defaultWarehouseCascade[1] = subItem.warehouseLocationSn
+                }
+              })
+            }
+          })
+          res.data.map(item => {
+            item.sn = item.warehouseSn
+            if (item.warehouseLocationList) {
+              item.warehouseLocationList.map(subItem => {
+                subItem.sn = subItem.warehouseLocationSn
+              })
+            }
+          })
+          this.warehouseCascadeData = res.data
+          if(this.defaultVal.length==0){
+            this.handleChange(_this.defaultWarehouseCascade)
+          }
+        } else {
+          this.warehouseCascadeData = []
+        }
+      })
+    },
+    setDefaultVal(){
+      if(this.defaultVal.length==0){
+        this.handleChange(this.defaultWarehouseCascade)
+      }
+    }
+  }
+}
+
+export default Warehouse

+ 34 - 10
src/views/productManagement/productInfo/edit.vue

@@ -16,12 +16,6 @@
           :label-col="formItemLayout.labelCol"
           :wrapper-col="formItemLayout.wrapperCol"
         >
-          <a-form-model-item label="供应商" v-if="pageType=='modal'">
-            <a-input
-              disabled
-              v-model.trim="formData.supplierName"
-            />
-          </a-form-model-item>
           <a-form-model-item label="产品名称" prop="name">
             <a-input
               id="productInfoEdit-name"
@@ -178,6 +172,9 @@
               ref="putQty"
               allowClear />
           </a-form-model-item>
+          <a-form-model-item label="仓库仓位" v-if="pageType=='modal'" prop="warehouse">
+            <Warehouse id="productInfoEdit-warehouse" ref="warehouse" @change="warehouseChange" v-model="form.warehouse"></Warehouse>
+          </a-form-model-item>
           <a-form-model-item :wrapper-col="{ span: 12, offset: 6 }" style="text-align: center;">
             <a-button
               type="primary"
@@ -185,7 +182,14 @@
               @click="handleSubmit"
               size="large"
               id="productInfoEdit-btn-submit"
-              style="padding: 0 60px;">保存</a-button>
+              style="padding: 0 50px;">保存</a-button>
+            <a-button
+              type="default"
+              :loading="saveing"
+              @click="handleBack"
+              size="large"
+              id="productInfoEdit-btn-cansel"
+              style="padding: 0 50px;margin-left: 30px;">取消</a-button>
           </a-form-model-item>
         </a-form-model>
         <!-- 新增/编辑产品品牌 -->
@@ -199,12 +203,13 @@
 import { commonMixin } from '@/utils/mixin'
 import { STable, VSelect } from '@/components'
 import productBrandEditModal from '../productBrand/editModal.vue'
+import Warehouse from '@/views/common/warehouse.js'
 import { dealerProductBrandQuery } from '@/api/dealerProductBrand'
 import { dealerProductTypeList } from '@/api/dealerProductType'
 import { dealerProductSave, dealerProductDetail } from '@/api/dealerProduct'
 export default {
   name: 'ProductInfoEdit',
-  components: { STable, VSelect, productBrandEditModal },
+  components: { STable, VSelect, productBrandEditModal, Warehouse },
   mixins: [commonMixin],
   props: {
     pageType: { // 页面表现形式,pages 新页签打开的页面,modal 弹框里的页面
@@ -227,6 +232,11 @@ export default {
       return this.pageType == 'pages' ? !!this.$route.params.id : false
     }
   },
+  watch: {
+    paramsData (newValue, oldValue) {
+      this.formData = newValue
+    }
+  },
   data () {
     return {
       spinning: false,
@@ -247,7 +257,8 @@ export default {
         terminalPrice: '', //  终端价
         carOwnersPrice: '', //  车主价
         putCost: '',
-        putQty: ''
+        putQty: '',
+        warehouse: []
       },
       rules: {
         name: [
@@ -267,6 +278,9 @@ export default {
         ],
         putQty: [
           { required: true, type: 'number', message: '请输入数量', trigger: 'change' }
+        ],
+        warehouse: [
+          { required: true, message: '请选择仓库仓位', trigger: 'blur' }
         ]
       },
       fetching: false,
@@ -276,6 +290,9 @@ export default {
     }
   },
   methods: {
+    warehouseChange () {
+      this.$refs.ruleForm.clearValidate('warehouse')
+    },
     // 搜索品牌
     fetchUser (value) {
       console.log('fetching user', value)
@@ -386,7 +403,11 @@ export default {
     },
     //  返回
     handleBack () {
-      this.$router.push({ path: '/productManagement/productInfo/list' })
+      if (this.pageType == 'pages') {
+        this.$router.push({ path: '/productManagement/productInfo/list' })
+      } else {
+        this.$emit('cansel')
+      }
     },
     //  产品品牌  列表
     getProductBrand (val) {
@@ -426,6 +447,9 @@ export default {
       // 如果是其它页面新建产品
       if (this.pageType == 'modal') {
         this.form = Object.assign(this.form, this.formData)
+        this.$nextTick(() => {
+          this.$refs.warehouse.setDefaultVal()
+        })
       }
     }
   },