chenrui 2 anos atrás
pai
commit
318fd32d24

+ 18 - 5
src/views/common/chooseWarehouse.js

@@ -23,7 +23,7 @@ const warehouse = {
       type: Boolean,
       default: false
     },
-    allowClear:{
+    allowClear: {
       type: Boolean,
       default: true
     },
@@ -42,6 +42,10 @@ const warehouse = {
     modeType: {
       type: String,
       default: 'default'
+    },
+    isDefault: { // 是否有默认值
+      type: Boolean,
+      default: undefined
     }
   },
   data () {
@@ -53,7 +57,7 @@ const warehouse = {
     }
   },
   mounted () {
-    if(this.isPermission){
+    if (this.isPermission) {
       this.$store.state.app.defWarehouse = null
       this.$store.state.app.isWarehouse = false
     }
@@ -81,19 +85,28 @@ const warehouse = {
       ajaxName({}).then(res => {
         if (res.status == 200) {
           // 有权限控制的
-          if(this.isPermission){
+          if (this.isPermission) {
             this.$store.state.app.isWarehouse = res.data && res.data.length > 1
             this.$store.state.app.defWarehouse = res.data && res.data[0]
           }
           this.warehouseData = res.data || []
+          let defaultWarehouseVal = {}
+          if (this.isDefault) {
+            defaultWarehouseVal = res.data.find(con => {
+              return con.defaultFlag == 1 ? con.warehouseSn : ''
+            })
+            this.defaultVal = defaultWarehouseVal.warehouseSn
+            this.$emit('load', defaultWarehouseVal.warehouseSn)
+          } else {
+            this.$emit('load')
+          }
         } else {
-          if(this.isPermission){
+          if (this.isPermission) {
             this.$store.state.app.isWarehouse = false
             this.$store.state.app.defWarehouse = null
           }
           this.warehouseData = []
         }
-        this.$emit('load')
       })
     },
     clearData () {

+ 4 - 1
src/views/salesReturnManagement/billOfLading/add.vue

@@ -111,7 +111,7 @@
             </a-col>
             <a-col :spna="24">
               <a-form-model-item label="退货仓库" :label-col="{span:2}" :wrapper-col="{span:20}" prop="warehouseSn">
-                <chooseWarehouse ref="warehouse" v-model="form.warehouseSn" @change="handleWarehouse"></chooseWarehouse>
+                <chooseWarehouse ref="warehouse" @load="loadWarehouseVal" :isDefault="!$route.params.sn" v-model="form.warehouseSn" @change="handleWarehouse"></chooseWarehouse>
               </a-form-model-item>
             </a-col>
             <a-col :spna="24">
@@ -267,6 +267,9 @@ export default {
     }
   },
   methods: {
+    loadWarehouseVal (con) {
+      this.form.warehouseSn = con || undefined
+    },
     // 选择退货仓库
     handleWarehouse (val) {
       this.form.warehouseSn = val