Browse Source

添加商品销售详情报表,修改pos点单

许智捷 2 years ago
parent
commit
1fd811c321

+ 44 - 21
src/views/pos/diandan.vue

@@ -49,10 +49,10 @@
         <p>数量:{{ sum }}</p>
         <div v-if="this.posTableState === 1">
           <a-button @click="placeOrder" :disabled="btnDisabled">下单</a-button>
-<!--          <a-button @click="addClear" :disabled="btnDisabled">清空新加</a-button>-->
+          <!--          <a-button @click="addClear" :disabled="btnDisabled">清空新加</a-button>-->
         </div>
         <div v-else style="display: flex; gap: 5px; flex-flow: wrap">
-          <a-button  @click="clean" :disabled="btnDisabled">清空</a-button>
+          <a-button @click="clean" :disabled="btnDisabled">清空</a-button>
           <!-- <a-button @click="handleAdd" :disabled="btnDisabled">备注</a-button> -->
           <!-- <a-button :disabled="btnDisabled">退货</a-button> -->
           <div v-if="posTableId === ''">
@@ -66,8 +66,9 @@
           >
           <a-button
             v-else
-            @click="handleSelectCheckInRoomOrder"
-          >挂房帐</a-button
+            @click="handleSelectCheckInRoomOrder">
+            挂房帐
+          </a-button
           >
           <a-button
             :disabled="btnDisabled"
@@ -102,10 +103,14 @@
                   ¥{{ item.sellingPrice.toFixed(2) }}
                 </div>
                 <div style="margin-top: 10px">库{{ item.inventory }}</div>
+<!--                <div-->
+<!--                  v-if="item.isSellClear"-->
+<!--                  style="display: flex; justify-content: right">-->
+<!--                  <a-tag color="#f50"> 沽清 </a-tag>-->
+<!--                </div>-->
                 <div
-                  v-if="item.isSellClear"
-                  style="display: flex; justify-content: right"
-                >
+                    v-if="item.inventory <= 0"
+                    style="display: flex; justify-content: right">
                   <a-tag color="#f50"> 沽清 </a-tag>
                 </div>
               </template>
@@ -148,7 +153,7 @@
         </a-row>
       </a-card>
     </div>
-    <payment-modal ref="modalPaymentForm" @ok="modalFormOk"></payment-modal>
+    <payment-modal ref="modalPaymentForm" @ok="modalFormOk" @close="modalFormClose"></payment-modal>
     <goods-modal ref="modalGoodsForm" @ok="modalFormOk2"></goods-modal>
     <picking-goods-order-modal
       ref="modalPickingGoodsOrderForm"
@@ -217,7 +222,7 @@ const columns = [
   {
     title: '售价',
     dataIndex: 'sellingPrice',
-    width: '25%',
+    width: '25%'
   }
 ]
 export default {
@@ -369,6 +374,7 @@ export default {
     this.loadTree()
   },
   methods: {
+    /** 通过桌号查询订单 */
     getOrderByTableId(tableId) {
       getAction('/pos/posOrderGoods/getOrderByTableId', { tableId }).then(resp => {
         if (resp.success) {
@@ -428,6 +434,24 @@ export default {
       this.clean()
       this.loadGoods()
     },
+    /** 不支付,关闭弹窗,要刷新选中的商品表  */
+    modalFormClose() {
+      getAction('/pos/posOrderGoodsDetail/list', {
+        pageNo: 1,
+        pageSize: 99,
+        orderId: this.selectOrderInfo.code
+      }).then((res) => {
+        if (res.success) {
+          this.selectGoodsList = res.result.records;
+          res.result.records.forEach((t) => {
+            t.sellingPrice = t.payMoney
+            t.name = t.goodsName
+            t.id = t.goodsId
+          })
+          this.selectGoodsList = res.result.records
+        }
+      });
+    },
     clean() {
       this.selectGoodsList = []
       this.selectOrderInfo = {}
@@ -565,12 +589,14 @@ export default {
         }
       })
     },
+    /** 结账 */
     handlePayment() {
       if (!this.selectGoodsList || this.selectGoodsList.length <= 0) {
         this.$message.warning('请先选择商品')
         return
       }
       if (this.posTableId === '') {
+        this.handleAdd()
         this.settleAccounts(this.selectOrderInfo.code, this.getParam())
       } else {
         // 桌台结账时,订单在下单的时候就添加了,不用传参
@@ -582,7 +608,7 @@ export default {
       var amount = this.selectGoodsList.reduce(function (total, item) {
         return total + item.sellingPrice * item.num
       }, 0)
-
+      console.log('2222222', params)
       this.$refs.modalPaymentForm.edit({
         billAmount: amount,
         deposit: 0,
@@ -607,7 +633,6 @@ export default {
     pendingOrder() {
       this.selectOrderInfo.isPending = true
       this.handleAdd()
-
     },
     handleAdd(callback) {
       if (!this.selectGoodsList || this.selectGoodsList.length <= 0) {
@@ -618,21 +643,15 @@ export default {
       postAction('/pos/posOrderGoods/add', param)
         .then((res) => {
           if (res.success) {
-            this.$message.success(res.message)
-            this.oldSelectGoodsList = JSON.parse(
-              JSON.stringify(this.selectGoodsList)
-            )
-            // this.selectGoodsList = [];
-            // this.selectOrderInfo = {};
-            // this.selectRoomOrder = {};
+            this.oldSelectGoodsList = JSON.parse(JSON.stringify(this.selectGoodsList))
+            this.selectOrderInfo = res.result
             this.loadGoods()
-            if (this.posTableId !== ''){
+            if (this.posTableId !== '') {
               this.$emit('reTable')
             }
             if (callback) {
               callback(res.result.code)
             }
-            this.clean();
           } else {
             this.$message.warning(res.message)
           }
@@ -679,7 +698,11 @@ export default {
         this.handleAddTempGoods()
         return
       }
-      if (row.isSellClear) {
+      // if (row.isSellClear) {
+      //   this.$message.warning('选择的商品已沽清')
+      //   return
+      // }
+      if (row.inventory <= 0) {
         this.$message.warning('选择的商品已沽清')
         return
       }

+ 1 - 17
src/views/pos/modules/Payment.vue

@@ -584,23 +584,7 @@ export default {
             this.$message.warning('请选择协议单位')
           }
           this.confirmLoading = true
-          if (this.posOrderGoods !== null) {
-            // 大厅 点击结账,点击支付后,先添加账单,再添加支付单
-            postAction('/pos/posOrderGoods/add', this.posOrderGoods)
-                .then((res) => {
-                  if (res.success) {
-                    this.$message.success(res.message)
-                    this.model.orderCode = res.result.code
-                    this.addPayment()
-                  } else {
-                    this.$message.warning('添加订单失败')
-                  }
-                }).finally(() => {
-                  this.confirmLoading = false
-                })
-          } else {
-            this.addPayment()
-          }
+          this.addPayment()
         }
       })
     },

+ 24 - 5
src/views/report/index.vue

@@ -9,6 +9,8 @@
 </template>
 
 <script>
+import { getAction } from '@api/manage'
+
 export default {
   components: {
   },
@@ -16,23 +18,31 @@ export default {
     return {
       demo: [{
         name: '货品库存报表',
-        path: '/report/storageAllCollect'
+        path: '/report/stock/storageAllCollect'
         },
         {
           name: '出库汇总表',
-          path: '/report/storageOutCollect'
+          path: '/report/stock/storageOutCollect'
         },
         {
           name: '入库汇总表',
-          path: '/report/storageInCollect'
+          path: '/report/stock/storageInCollect'
         },
         {
           name: '入库明细表',
-          path: '/report/storageInDetail'
+          path: '/report/stock/storageInDetail'
         },
         {
           name: '出库明细表',
-          path: '/report/storageOutDetail'
+          path: '/report/stock/storageOutDetail'
+        },
+        {
+          name: '商品销售明细报表',
+          path: '/report/room/sellDetail'
+        },
+        {
+          name: '商品销售明细报表',
+          path: '/report/room/sellCollect'
         },
       ]
     };
@@ -43,6 +53,15 @@ export default {
       this.$router.push(item.path)
       this.$router.push()
     }
+  },
+  created() {
+
+    // getAction('/order/cesOrderLeaseGoods/getLeaseRoom').then(resp => {
+    //   console.log(resp.records,"借用")
+    // });
+    // getAction('/fw/fwLivingJx/getJxRooms').then(resp => {
+    //   console.log(resp.records,"叫醒")
+    // })
   }
 };
 </script>

src/views/report/storageAllCollect.vue → src/views/report/stock/storageAllCollect.vue


+ 4 - 4
src/views/report/storageCollectInfo.vue

@@ -9,7 +9,7 @@
               <a-input
                   :allowClear="true"
                   placeholder="商品名称"
-                v-model="queryParam.goodsName"
+                v-model="queryParam.goodName"
               ></a-input>
             </a-form-item>
           </a-col>
@@ -174,8 +174,8 @@ export default {
       },
 
       url: {
-        delete: '/kc/kcDepositoryInGoods/delete',
-        deleteBatch: '/kc/kcDepositoryInGoods/deleteBatch',
+        // delete: '/kc/kcDepositoryInGoods/delete',
+        // deleteBatch: '/kc/kcDepositoryInGoods/deleteBatch',
         exportXlsUrl: '/kc/kcDepositoryInGoods/exportXls',
         importExcelUrl: '/kc/kcDepositoryInGoods/importExcel'
       },
@@ -199,7 +199,7 @@ export default {
       let params = {
         pageSize: this.ipagination.pageSize,
         pageNo: this.ipagination.current,
-        goodsName: this.queryParam.goodsName,
+        goodName: this.queryParam.goodName,
         depositoryId: this.queryParam.depositoryId,
         goodTypeId: this.queryParam.goodTypeId,
         startTime: this.queryParam.startTime,

src/views/report/storageInCollect.vue → src/views/report/stock/storageInCollect.vue


+ 8 - 2
src/views/report/storageInDetail.vue

@@ -21,10 +21,16 @@ export default {
           width: 80
         },
         {
-          title: '库类型',
+          title: '库类型',
           align: 'center',
           dataIndex: '',
-          width: 80
+          width: 80,
+          customRender(text, record) {
+            console.log(text)
+            if (text == null && record.feeId != null) {
+              return '销售出库'
+            }
+          }
         },
         {
           title: '商品名称',

src/views/report/storageOutCollect.vue → src/views/report/stock/storageOutCollect.vue


+ 22 - 6
src/views/report/storageOutDetail.vue

@@ -25,6 +25,12 @@ export default {
           align: 'center',
           dataIndex: 'stockType',
           width: 80,
+          customRender(text, record) {
+            console.log(text)
+            if (text == null && (record.feeId != null || record.feeGoodId)) {
+              return '销售出库'
+            }
+          }
         },
         {
           title: '商品名称',
@@ -57,12 +63,6 @@ export default {
           width: 80,
         },
         {
-          title: '单价',
-          align: 'center',
-          dataIndex: 'price',
-          width: 80
-        },
-        {
           title: '出库数量',
           align: 'center',
           dataIndex: 'num',
@@ -99,6 +99,22 @@ export default {
   created() {
   },
   methods: {
+    getStockType(text){
+      if (text === 1){
+        return '采购入库'
+      } else if (text === 1){
+        return '销售退货'
+      } else if (text === 2){
+        return '盘盈入库'
+      } else if (text === 3){
+        return '其他入库'
+      } else if (text === 4){
+        return '调拨入库'
+      } else if (text === 5){
+
+      }
+    }
+
   }
 };
 </script>

+ 25 - 25
src/views/room/modules/checkIn/PayOrRefund.vue

@@ -29,7 +29,7 @@
                 :labelCol="labelCol"
                 :wrapperCol="wrapperCol"
               >
-              
+
                 {{ model.collection.toFixed(2) }}元
               </a-form-model-item>
               <a-form-model-item
@@ -68,12 +68,12 @@
                   :wrapperCol="wrapperCol"
                   prop="couponFirstAmount"
                 >
-                  
+
                 </a-form-model-item> -->
               </template>
               </a-form-model-item>
               <!-- <a-col :span="24" v-if="model.preferentialType == 2"> -->
-                
+
               <a-form-model-item
                   label="优惠券"
                   :labelCol="labelCol"
@@ -106,7 +106,7 @@
                   {{ couponAmount.toFixed(2) }}元
                 </a-form-model-item>
               <!-- </a-col> -->
-              
+
               <template v-if="model.coupon">
               <!-- <a-col :span="24">
                 <a-form-model-item
@@ -132,11 +132,11 @@
                   </template>
                 </a-form-model-item>
               </a-col> -->
-              
+
               <!-- <a-col :span="24">
-                
+
                 <a-col :span="24">
-                
+
               </a-col>
               </a-col> -->
             </template>
@@ -149,17 +149,17 @@
               </a-form-model-item>
             </a-col>
             <a-col :span="24">
-              
+
             </a-col> -->
 
-            
 
-            
+
+
             <!-- <a-col :span="24">-->
-              
-            </a-col> 
+
+            </a-col>
           </div>
-         <div class="presentation_style" v-if="model.money > 0">应收金额=消费合计/惠后金额-已收合计</div> 
+         <div class="presentation_style" v-if="model.money > 0">应收金额=消费合计/惠后金额-已收合计</div>
           <a-col :span="14" class="receipt_style" v-if="model.money > 0">
             <a-form-model-item
               :label="(this.isRefund ? &quot;退&quot; : &quot;收&quot;) + &quot;款金额&quot;"
@@ -244,7 +244,7 @@
           </a-col>
           <div class="presentation_style_two" v-if="model.money < 0">退款:
             <a-button danger type="link" @click="addCustomRefund">新增自定义退款</a-button>
-          </div> 
+          </div>
           <a-col :span="24" v-if="model.money < 0">
             <a-table :columns="columns" :data-source="feeList" bordered>
               <template slot="payType" slot-scope="text, record, index">
@@ -489,7 +489,7 @@ export default {
         }, 0)
         return sum
       }
-      
+
     },
     // sumAmount() {
     //   var sum = this.payList.reduce(function (total, item) {
@@ -520,7 +520,7 @@ export default {
               ((this.model.consumption * this.model.discount) / 10).toFixed(2)
             )
           }
-          
+
         }
       } else {
         sum = this.model.consumption
@@ -802,7 +802,7 @@ export default {
           // return
           if (this.isRefund) {
             this.feeList.forEach((item) => {
-              // let remark = 
+              // let remark =
               // let money = -money
               fees.push({
                 feeType: this.model.feeType,
@@ -827,7 +827,7 @@ export default {
             })
           })
           }
-          
+
 
           that.confirmLoading = true
           var url =
@@ -888,7 +888,7 @@ export default {
         if (res.success) {
           this.feeList = res.result
         }
-        
+
         let templist = this.feeList
         templist.forEach(e => {
           if (e.returnItem == true) {
@@ -898,7 +898,7 @@ export default {
         })
         // console.log(templist);
         // console.log(returnFeeList);
-        
+
         templist.forEach(e => {
           let returnMoney = returnFeeList.filter(ele => e.id === ele.returnFeeId).reduce((accumulator, ele) => accumulator + ele.money, 0)
           e.returnMoney = returnMoney;
@@ -916,7 +916,7 @@ export default {
             }
           })
         ])
-        
+
         console.log(returnFeeList);
         // templist.forEach(e => {
         //   if (e.returnItem == true) {
@@ -961,13 +961,13 @@ export default {
         //     }
         //   })
         // })
-        
+
         // this.feeList.forEach(item => {
-          
+
         // })
       })
       }
-      
+
     },
     // 新增自定义退款
     addCustomRefund() {
@@ -1013,7 +1013,7 @@ export default {
   /* margin: 0 auto; */
   /* display: inline-block; */
   /* margin-top: 60px; */
-  
+
 }
 .crad_style {
   display: flex;

+ 187 - 165
src/views/stock/modules/DepositoryForm copy.vue

@@ -1,253 +1,264 @@
 <template>
-<a-spin :spinning="confirmLoading">
+  <a-spin :spinning="confirmLoading">
     <j-form-container :disabled="formDisabled">
-        <a-form-model ref="form" :model="model" layout="horizontal" :rules="validatorRules" slot="detail">
-            <a-row :gutter="2" align="top" type="flex">
-                <a-col :span="5" flex>
-                    <a-form-item label="" prop="depositoryList">
-                        <a-select v-model="model.depositoryId" style="width: 100%" placeholder="入仓仓库" :allowClear="true">
-                            <a-select-option v-for="(item, index) in depositoryList" :key="index" :value="item.id">{{ item.name }}</a-select-option>
-                        </a-select>
-                    </a-form-item>
-                </a-col>
-                <a-col :span="5">
-                    <a-form-item label="" prop="supplierList">
-                        <a-select v-model="model.supplierId" style="width: 100%" placeholder="供应商" :allowClear="true">
-                            <a-select-option v-for="(item, index) in supplierList" :key="index" :value="item.id">{{ item.name }}</a-select-option>
-                        </a-select>
-                    </a-form-item>
-                </a-col>
-                <a-col :span="5">
-                    <a-form-item label="" prop="storageTypeList">
-                        <a-select v-model="model.stockType" style="width: 100%" placeholder="入库类型" :allowClear="true">
-                            <a-select-option v-for="(item, index) in storageTypeList" :key="index" :value="item.value">{{ item.title }}</a-select-option>
-                        </a-select>
-                    </a-form-item>
-                </a-col>
-                <a-col :span="6" style="margin-top:5px;">
-                    <a-button :disabled="!model.supplierId" @click="handleGoods" type="primary" icon="plus">批量添加</a-button>
-                </a-col>
-            </a-row>
-        </a-form-model>
+      <a-form-model ref="form" :model="model" layout="horizontal" :rules="validatorRules" slot="detail">
+        <a-row :gutter="2" align="top" type="flex">
+          <a-col :span="5" flex>
+            <a-form-item label="" prop="depositoryList">
+              <a-select v-model="model.depositoryId" style="width: 100%" placeholder="入仓仓库" :allowClear="true">
+                <a-select-option v-for="(item, index) in depositoryList" :key="index" :value="item.id">{{ item.name }}</a-select-option>
+              </a-select>
+            </a-form-item>
+          </a-col>
+          <a-col :span="5">
+            <a-form-item label="" prop="supplierList">
+              <a-select v-model="model.supplierId" style="width: 100%" placeholder="供应商" :allowClear="true">
+                <a-select-option v-for="(item, index) in supplierList" :key="index" :value="item.id">{{ item.name }}</a-select-option>
+              </a-select>
+            </a-form-item>
+          </a-col>
+          <a-col :span="5">
+            <a-form-item label="" prop="storageTypeList">
+              <a-select v-model="model.stockType" style="width: 100%" placeholder="入库类型" :allowClear="true">
+                <a-select-option v-for="(item, index) in storageTypeList" :key="index" :value="item.value">{{ item.title }}</a-select-option>
+              </a-select>
+            </a-form-item>
+          </a-col>
+          <a-col :span="6" style="margin-top:5px;">
+            <a-button :disabled="!model.supplierId" @click="handleGoods" type="primary" icon="plus">批量添加</a-button>
+          </a-col>
+        </a-row>
+      </a-form-model>
     </j-form-container>
 
     <!-- 查询区域-END -->
     <div>
-        <a-table :scroll="{ y: 540 }" ref="table" size="middle" bordered rowKey="id" :columns="columns" :dataSource="dataSource" :pagination="false" :loading="loading" class="j-table-force-nowrap" @change="handleTableChange">
-            <span slot="state" slot-scope="record">
-                {{ record ? "启用" : "停用" }}
-                <!-- {{record}} -->
-            </span>
-            <template slot="price" slot-scope="record">
-                <a-input-number :min="0" placeholder="请输入" v-model="record.bid"></a-input-number>
-            </template>
-            <template slot="num" slot-scope="record">
-                <a-input-number :min="0" v-model="record.num"></a-input-number>
-            </template>
-            <span slot="action" slot-scope="text, record">
-                <!-- <a @click="handleEdit(record)">修改</a>
+      <a-table
+        :scroll="{ y: 540 }"
+        ref="table"
+        size="middle"
+        bordered
+        rowKey="id"
+        :columns="columns"
+        :dataSource="dataSource"
+        :pagination="false"
+        :loading="loading"
+        class="j-table-force-nowrap"
+        @change="handleTableChange">
+        <span slot="state" slot-scope="record">
+          {{ record ? "启用" : "停用" }}
+          <!-- {{record}} -->
+        </span>
+        <template slot="price" slot-scope="record">
+          <a-input-number :min="0" placeholder="请输入" v-model="record.bid"></a-input-number>
+        </template>
+        <template slot="num" slot-scope="record">
+          <a-input-number :min="0" v-model="record.num"></a-input-number>
+        </template>
+        <span slot="action" slot-scope="text, record">
+          <!-- <a @click="handleEdit(record)">修改</a>
                 <a-divider type="vertical" />
                 <a @click="moreSet(record)">更多设置</a>
                 <a-divider type="vertical" /> -->
-                <a-popconfirm title="确定删除吗?" @confirm="() => deleteGoods(record.id)">
-                    <a>删除</a>
-                </a-popconfirm>
-            </span>
-        </a-table>
+          <a-popconfirm title="确定删除吗?" @confirm="() => deleteGoods(record.id)">
+            <a>删除</a>
+          </a-popconfirm>
+        </span>
+      </a-table>
     </div>
 
     <a-row>
-        <a-col :span="12">
-            <a-form-item label="备注" :label-col="labelCol">
-                <a-textarea v-model="model.remarks" :rows="4" />
-            </a-form-item>
-        </a-col>
+      <a-col :span="12">
+        <a-form-item label="备注" :label-col="labelCol">
+          <a-textarea v-model="model.remarks" :rows="4" />
+        </a-form-item>
+      </a-col>
     </a-row>
 
     <supplier-in-goods-modal ref="modalSelectGoodsForm" @ok="selectOk"></supplier-in-goods-modal>
-</a-spin>
+  </a-spin>
 </template>
 
 <script>
 import {
     httpAction,
     getAction
-} from "@/api/manage";
+} from '@/api/manage'
 import {
     validateDuplicateValue
-} from "@/utils/util";
+} from '@/utils/util'
 import {
     JeecgListMixin
-} from "@/mixins/JeecgListMixin";
-import SupplierInGoodsModal from "./DepositorySelectGoods/selectGoodsModal.vue";
+} from '@/mixins/JeecgListMixin'
+import SupplierInGoodsModal from './DepositorySelectGoods/selectGoodsModal.vue'
 export default {
-    name: "PosTypeForm",
+    name: 'PosTypeForm',
     mixins: [JeecgListMixin],
     components: {
-        SupplierInGoodsModal,
+        SupplierInGoodsModal
     },
     props: {
-        //表单禁用
+        // 表单禁用
         disabled: {
             type: Boolean,
             default: false,
-            required: false,
-        },
+            required: false
+        }
     },
-    watch:{
-        "model.supplierId":function(newVal, oldVal){
-            if (newVal!=oldVal) {
-                this.dataSource = [];
+    watch: {
+        'model.supplierId': function(newVal, oldVal) {
+            if (newVal != oldVal) {
+                this.dataSource = []
             }
         }
     },
     data() {
         return {
             model: {
-                code: "",
-                createAt: "",
-                createTime: "",
+                code: '',
+                createAt: '',
+                createTime: '',
                 // depositoryId: "",
-                hotelId: "",
-                id: "",
-                remarks: "",
+                hotelId: '',
+                id: '',
+                remarks: '',
                 status: 0,
                 num: 0,
                 // stockInfo: "",
                 // stockType: 0,
                 // supplierId: "",
-                tenantId: "",
+                tenantId: '',
                 type: 2,
-                verifyAt: "",
-                verifyRemarks: "",
-                verifyTime: ""
+                verifyAt: '',
+                verifyRemarks: '',
+                verifyTime: ''
 
             },
             labelCol: {
                 xs: {
-                    span: 24,
+                    span: 24
                 },
                 sm: {
-                    span: 5,
-                },
+                    span: 5
+                }
             },
             wrapperCol: {
                 xs: {
-                    span: 24,
+                    span: 24
                 },
                 sm: {
-                    span: 16,
-                },
+                    span: 16
+                }
             },
             confirmLoading: false,
             validatorRules: {
                 depositoryList: [{
                     required: true,
-                    message: "请选择入库仓库!",
-                }, ],
+                    message: '请选择入库仓库!'
+                } ],
                 supplierList: [{
                     required: true,
-                    message: "请选择供应商!",
-                }, ],
+                    message: '请选择供应商!'
+                } ],
                 storageTypeList: [{
                     required: true,
-                    message: "请选择入库类型!",
-                }, ],
+                    message: '请选择入库类型!'
+                } ]
             },
             // 表头
             columns: [{
-                    title: "商品名称",
-                    align: "center",
-                    dataIndex: "name",
+                    title: '商品名称',
+                    align: 'center',
+                    dataIndex: 'name'
                 },
                 {
-                    title: "单位",
-                    align: "center",
-                    dataIndex: "goodUnit",
+                    title: '单位',
+                    align: 'center',
+                    dataIndex: 'goodUnit'
                 },
                 {
-                    title: "商品规格",
-                    align: "center",
-                    dataIndex: "spec",
+                    title: '商品规格',
+                    align: 'center',
+                    dataIndex: 'spec'
                 },
                 {
-                    title: "成本价",
-                    align: "center",
+                    title: '成本价',
+                    align: 'center',
                     // dataIndex: "bid",
                     scopedSlots: {
-                        customRender: "price"
-                    },
+                        customRender: 'price'
+                    }
                 },
                 {
-                    title: "出入库数量",
-                    align: "center",
+                    title: '出入库数量',
+                    align: 'center',
                     // dataIndex: "spec",
                     scopedSlots: {
-                        customRender: "num"
-                    },
+                        customRender: 'num'
+                    }
                 },
                 {
                     title: '操作',
                     dataIndex: 'action',
                     key: 'action',
                     scopedSlots: {
-                        customRender: "action"
+                        customRender: 'action'
                     },
                     align: 'center',
-                    fixed: "right",
-                    width: 200,
+                    fixed: 'right',
+                    width: 200
                 }
             ],
             url: {
                 list: 2,
-                add: "/kc/kcStock/add",
-                edit: "/kc/kcStock/edit",
-                queryById: "/kc/kcDepository/queryById",
+                add: '/kc/kcStock/add',
+                edit: '/kc/kcStock/edit',
+                queryById: '/kc/kcDepository/queryById'
             },
             depositoryList: [],
             supplierList: [],
             storageTypeList: [],
             dataSource: []
-        };
+        }
     },
     computed: {
         formDisabled() {
-            return this.disabled;
-        },
+            return this.disabled
+        }
     },
     created() {
-        var _info = JSON.parse(localStorage.getItem("storeInfo"));
+        var _info = JSON.parse(localStorage.getItem('storeInfo'))
         if (_info) {
-            this.model.hotelId = _info.id;
+            this.model.hotelId = _info.id
         }
-        //备份model原始值
-        this.modelDefault = JSON.parse(JSON.stringify(this.model));
-        getAction("/kc/kcDepository/list", {
-            state: 1,
+        // 备份model原始值
+        this.modelDefault = JSON.parse(JSON.stringify(this.model))
+        getAction('/kc/kcDepository/list', {
+            state: 1
         }).then((res) => {
             if (res.success) {
-                this.depositoryList = res.result.records;
+                this.depositoryList = res.result.records
             }
-        });
-        getAction("/kc/kcSupplier/list", {
-            state: 1,
+        })
+        getAction('/kc/kcSupplier/list', {
+            state: 1
         }).then((res) => {
             if (res.success) {
-                this.supplierList = res.result.records;
+                this.supplierList = res.result.records
             }
-        });
-        getAction("/kc/kcStock/storageTypeList", {}).then((res) => {
+        })
+        getAction('/kc/kcStock/storageTypeList', {}).then((res) => {
             if (res.success) {
-                this.storageTypeList = res.result;
+                this.storageTypeList = res.result
             }
-        });
+        })
     },
     methods: {
         handleGoods(row) {
-            this.$refs.modalSelectGoodsForm.add();
-            this.$refs.modalSelectGoodsForm.title = "供货商品";
-            this.$refs.modalSelectGoodsForm.disableSubmit = false;
-            this.$refs.modalSelectGoodsForm.supplierId = this.model.supplierId;
+            this.$refs.modalSelectGoodsForm.add()
+            this.$refs.modalSelectGoodsForm.title = '供货商品'
+            this.$refs.modalSelectGoodsForm.disableSubmit = false
+            this.$refs.modalSelectGoodsForm.supplierId = this.model.supplierId
         },
         /**
          * 删除商品
@@ -256,71 +267,82 @@ export default {
             this.dataSource = this.dataSource.filter(item => item.id !== id)
         },
         selectOk(e) {
-            console.log(e);
+            console.log(e)
             this.dataSource = JSON.parse(JSON.stringify(e))
-            console.log(this.dataSource);
+            console.log(this.dataSource)
         },
         add() {
-            this.edit(this.modelDefault,1);
+            this.edit(this.modelDefault, 1)
         },
         edit(record, type) {
           if (type) {
             return
           }
-            this.model = Object.assign({}, record);
+            this.model = Object.assign({}, record)
             this.model.stockType = this.model.stockType.toString()
-            console.log(this.model);
-            getAction(`/kc/kcStockDetail/list?stockId=${this.model.code}`).then(res=>{
-              console.log(res);
-              if ( res.code==200 ) {
+            console.log(this.model)
+            getAction(`/kc/kcStockDetail/list?stockId=${this.model.code}`).then(res => {
+              console.log(res)
+              if (res.code == 200) {
                 this.dataSource = res.result.records
-                this.dataSource.forEach(ele=>{
+                this.dataSource.forEach(ele => {
                   ele.bid = ele.price
                 })
               }
             })
-            this.visible = true;
+            this.visible = true
         },
         submitForm() {
-            const that = this;
+            if (this.model.depositoryId == null) {
+                this.$message.success('请选择仓库')
+                return
+            }
+            if (this.model.supplierId == null) {
+              this.$message.success('请选择供应商')
+              return
+            }
+            if (this.model.stockType == null) {
+              this.$message.success('请选择入库类型')
+              return
+            }
+            const that = this
             // 触发表单验证
-
             this.$refs.form.validate((valid) => {
                 if (valid) {
-                    that.confirmLoading = true;
-                    let httpurl = "";
-                    let method = "";
+                    that.confirmLoading = true
+                    let httpurl = ''
+                    let method = ''
                     if (!this.model.id) {
-                        httpurl += this.url.add;
-                        method = "post";
+                        httpurl += this.url.add
+                        method = 'post'
                     } else {
-                        httpurl += this.url.edit;
-                        method = "put";
+                        httpurl += this.url.edit
+                        method = 'put'
                     }
                     this.model.stockDetailList = this.dataSource
                     this.model.stockDetailList.forEach(element => {
                         // element.supplierInGoodsId = element.supplierInGoodsId;
                         if (!element.supplierInGoodsId) {
-                            element.supplierInGoodsId = element.id;
+                            element.supplierInGoodsId = element.id
                         }
-                        element.price = element.bid;
-                        element.num = Number(element.num);
-                    });
+                        element.price = element.bid
+                        element.num = Number(element.num)
+                    })
                     httpAction(httpurl, this.model, method)
                         .then((res) => {
                             if (res.success) {
-                                that.$message.success(res.message);
-                                that.$emit("ok");
+                                that.$message.success(res.message)
+                                that.$emit('ok')
                             } else {
-                                that.$message.warning(res.message);
+                                that.$message.warning(res.message)
                             }
                         })
                         .finally(() => {
-                            that.confirmLoading = false;
-                        });
+                            that.confirmLoading = false
+                        })
                 }
-            });
-        },
-    },
-};
+            })
+        }
+    }
+}
 </script>