소스 검색

【新增】零售发货申请单

莫绍宝 3 년 전
부모
커밋
1417163a02

+ 92 - 2
src/api/supply/apply.js

@@ -10,9 +10,99 @@ export function getApplyList(params) {
 }
 
 // 获取详情
-export function getDetail(params) {
+export function getApplyDetail(params) {
   return request({
-    url: '/ship/detail',
+    url: '/invoice/detail',
+    method: 'get',
+    params
+  })
+}
+
+// 审批
+export function examineApply(params) {
+  return request({
+    url: '/invoice/approvalInvoice',
+    method: 'post',
+    data: params
+  })
+}
+
+// 获取仓位列表
+export function getPositionList(params) {
+  return request({
+    url: '/stock/listPosition',
+    method: 'get',
+    params
+  })
+}
+
+// 检查库存
+export function checkStock(params) {
+  return request({
+    url: '/invoice/stockNumber',
+    method: 'get',
+    params
+  })
+}
+
+// 申请/撤回
+export function submitApply(params) {
+  return request({
+    url: '/invoice/submit',
+    method: 'post',
+    params
+  })
+}
+
+// 删除
+export function deleteApply(params) {
+  return request({
+    url: '/invoice/delete',
+    method: 'post',
+    params
+  })
+}
+
+// 新增
+export function addApply(params) {
+  return request({
+    url: '/invoice/add',
+    method: 'post',
+    data: params
+  })
+}
+
+// 编辑
+export function editApply(params) {
+  return request({
+    url: '/invoice/update',
+    method: 'post',
+    data: params
+  })
+}
+
+// 获取仓库列表
+export function getWarehouseList(params) {
+  return request({
+    url: '/stock/listStock',
+    method: 'get',
+    params
+  })
+}
+
+// 获取产品列表
+export function getGoodsList(params) {
+  return request({
+    url: '/retail/list',
+    method: 'get',
+    params
+  })
+}
+
+// 获取经销商列表
+export function getDealerList(params) {
+  return request({
+    url: '/customer/list',
     method: 'get',
     params
   })

+ 1 - 1
src/views/setting/account.vue

@@ -147,7 +147,7 @@
           </el-tree>
         </el-form-item>
         <el-form-item label="经销商" prop="dealer" v-show="accountType === 0">
-          <el-select v-model="AccountForm.dealer" placeholder="请选择商" style="width: 100%;">
+          <el-select v-model="AccountForm.dealer" placeholder="请选择经销商" style="width: 100%;">
             <el-option :label="item.name" :value="item.id" v-for="(item, index) in dealerList" :key="index"></el-option>
           </el-select>
         </el-form-item>

+ 60 - 22
src/views/supply/apply/apply_list.vue

@@ -1,6 +1,6 @@
 <template>
   <div class="app-container">
-    <div v-show="!isShowDetail && !isShowExamine">
+    <div v-show="!isShowDetail && !isShowExamine && !isShowForm">
       <!-- 筛选条件 -->
       <div class="screen-container">
         <el-form ref="screenForm" :model="screenForm" label-width="100px" size="small" label-position="left">
@@ -69,31 +69,48 @@
 
       <div class="mymain-container">
         <div class="btn-group clearfix">
+          <div class="fl">
+            <el-button size="small" type="primary" icon="el-icon-plus" @click="toForm()">发货申请</el-button>
+          </div>
           <div class="fr">
             <ExportButton :exUrl="'admin/user/mch/export'" :exParams="exParams" />
           </div>
         </div>
         <div class="table">
           <el-table v-loading="listLoading" :data="dataList" element-loading-text="Loading" border fit highlight-current-row stripe>
-            <el-table-column align="center" label="发货申请单" prop="shipOrderNo" min-width="160" show-overflow-tooltip></el-table-column>
-            <el-table-column align="center" label="发货申请日期" prop="shipTime" min-width="160" show-overflow-tooltip></el-table-column>
-            <el-table-column align="center" label="仓库" prop="stockName" min-width="160" show-overflow-tooltip></el-table-column>
-            <el-table-column align="center" label="经销商编码" prop="specification" min-width="160" show-overflow-tooltip></el-table-column>
-            <el-table-column align="center" label="经销商名称" prop="unit" min-width="160" show-overflow-tooltip></el-table-column>
-            <el-table-column align="center" label="产品名称" prop="number" min-width="160" show-overflow-tooltip></el-table-column>
-            <el-table-column align="center" label="规格型号" prop="number" min-width="160" show-overflow-tooltip></el-table-column>
-            <el-table-column align="center" label="计量单位" prop="number" min-width="160" show-overflow-tooltip></el-table-column>
-            <el-table-column align="center" label="数量" prop="remark" min-width="160" show-overflow-tooltip></el-table-column>
-            <el-table-column align="center" label="备注信息" prop="createBy" min-width="160" show-overflow-tooltip></el-table-column>
-            <el-table-column align="center" label="制单人" prop="createTime" min-width="100" show-overflow-tooltip></el-table-column>
-            <el-table-column align="center" label="制单日期" prop="aaa" min-width="100" show-overflow-tooltip></el-table-column>
-            <el-table-column align="center" label="审核人" prop="aaa" min-width="200" show-overflow-tooltip></el-table-column>
-            <el-table-column align="center" label="审核日期" prop="aaa" min-width="100" show-overflow-tooltip></el-table-column>
-            <el-table-column align="center" label="审核状态" prop="aaa" min-width="100" show-overflow-tooltip></el-table-column>
-            <el-table-column align="center" label="操作" width="120" fixed="right">
+            <el-table-column align="center" label="发货申请单" prop="id" min-width="180" show-overflow-tooltip></el-table-column>
+            <el-table-column align="center" label="发货申请日期" prop="createTime" min-width="160" show-overflow-tooltip></el-table-column>
+            <el-table-column align="center" label="仓库" prop="correspondName" min-width="120" show-overflow-tooltip></el-table-column>
+            <el-table-column align="center" label="经销商编码" prop="customerNumber" min-width="160" show-overflow-tooltip></el-table-column>
+            <el-table-column align="center" label="经销商名称" prop="customerName" min-width="160" show-overflow-tooltip></el-table-column>
+            <el-table-column align="center" label="产品名称" prop="materialName" min-width="160" show-overflow-tooltip></el-table-column>
+            <el-table-column align="center" label="规格型号" prop="specification" min-width="160" show-overflow-tooltip></el-table-column>
+            <el-table-column align="center" label="计量单位" prop="unit" min-width="100" show-overflow-tooltip></el-table-column>
+            <el-table-column align="center" label="数量" prop="qty" min-width="100" show-overflow-tooltip></el-table-column>
+            <el-table-column align="center" label="备注信息" prop="remark" min-width="160" show-overflow-tooltip></el-table-column>
+            <el-table-column align="center" label="制单人" prop="createBy" min-width="100" show-overflow-tooltip></el-table-column>
+            <el-table-column align="center" label="制单日期" prop="createTime" min-width="160" show-overflow-tooltip></el-table-column>
+            <el-table-column align="center" label="审核人" prop="approvalName" min-width="100" show-overflow-tooltip></el-table-column>
+            <el-table-column align="center" label="审核日期" prop="approvalTime" min-width="160" show-overflow-tooltip></el-table-column>
+            <el-table-column align="center" label="审核状态" prop="status" min-width="100" show-overflow-tooltip>
+              <template slot-scope="scope">
+                {{scope.row.status | statusFilter}}
+              </template>
+            </el-table-column>
+            <el-table-column align="center" label="操作" width="180" fixed="right">
               <template slot-scope="scope">
-                <el-button type="text" @click="toExamine(scope.row)">审单</el-button>
+                <el-popconfirm style="margin-right: 10px;" title="确定申请吗?" @onConfirm="handleSubmit(scope.row.id, 2)" v-if="scope.row.status === 1" >
+                  <el-button slot="reference" type="text">申请</el-button>
+                </el-popconfirm>
+                <el-popconfirm style="margin-right: 10px;" title="确定撤回吗?" @onConfirm="handleSubmit(scope.row.id, 1)" v-if="scope.row.status === 2" >
+                  <el-button slot="reference" type="text">撤回</el-button>
+                </el-popconfirm>
+                <el-button type="text" @click="toForm(scope.row)" v-if="scope.row.status === 1">编辑</el-button>
+                <el-button type="text" @click="toExamine(scope.row)" v-if="scope.row.status === 2">审单</el-button>
                 <el-button type="text" @click="toDetail(scope.row)">详情</el-button>
+                <el-popconfirm style="margin-left: 10px;" title="确定删除吗?" @onConfirm="handleDelete(scope.row.id)" >
+                  <el-button slot="reference" type="text">删除</el-button>
+                </el-popconfirm>
               </template>
             </el-table-column>
           </el-table>
@@ -116,20 +133,23 @@
     
     <ApplyDetail :listItem="queryItem" v-if="isShowDetail" @backListFormDetail="backList" />
     <ApplyExamine :listItem="queryItem" v-if="isShowExamine" @backListFormDetail="backList" />
+    <ApplyForm :listItem="queryItem" v-if="isShowForm" @backListFormDetail="backList" />
 
   </div>
 </template>
 
 <script>
-import { getApplyList } from "@/api/supply/apply";
+import { getApplyList, submitApply, deleteApply } from "@/api/supply/apply";
 import ApplyDetail from "@/views/supply/apply/components/apply_detail";
 import ApplyExamine from "@/views/supply/apply/components/apply_examine";
+import ApplyForm from "@/views/supply/apply/components/apply_form";
 
 let that
 export default {
   components: {
     ApplyDetail,
     ApplyExamine,
+    ApplyForm
   },
   filters: {
     statusFilter(val) {
@@ -158,13 +178,13 @@ export default {
         { label: '已保存', value: 1 },
         { label: '待审核', value: 2 },
         { label: '审核通过', value: 3 },
-        { label: '审核驳回', value: 5 },
-        { label: '已退单', value: 4 },
+        { label: '审核驳回', value: 4 },
       ],
 
       queryItem: {},
       isShowDetail: false,
       isShowExamine: false,
+      isShowForm: false,
     }
   },
 
@@ -252,6 +272,12 @@ export default {
       this.getList();
     },
 
+    // 进入表单
+    toForm(item) {
+      this.queryItem = item;
+      this.isShowForm = true;
+    },
+
     // 进入审批
     toExamine(item) {
       this.queryItem = item;
@@ -268,11 +294,23 @@ export default {
       this.queryItem = {};
       this.isShowDetail = false;
       this.isShowExamine = false;
+      this.isShowForm = false;
     },
 
     handleDelete(id) {
+      deleteApply({id}).then(res => {
+        this.$successMsg();
+        this.getList();
+      })
+    },
 
-    }
+    // 申请/撤回
+    handleSubmit(id, status) {
+      submitApply({id, status}).then(res => {
+        this.$successMsg();
+        this.getList();
+      })
+    },
   }
 }
 </script>

+ 88 - 69
src/views/supply/apply/components/apply_detail.vue

@@ -4,62 +4,58 @@
 
     <div id="printData">
       <div class="main-title">
-        <div class="title">工程订单</div>
+        <div class="title">发货申请单信息</div>
       </div>
 
       <div class="diy-table-1">
         <el-row>
           <el-col :span="8" class="item">
             <div class="label">发货申请单号</div>
-            <div class="value">{{detailData.billNo}}</div>
+            <div class="value">{{detailData.id}}</div>
           </el-col>
           <el-col :span="8" class="item">
             <div class="label">申请日期</div>
-            <div class="value">{{detailData.fdate}}</div>
+            <div class="value">{{detailData.createTime}}</div>
           </el-col>
           <el-col :span="8" class="item">
             <div class="label">单据状态</div>
-            <div class="value">{{detailData.srcStockId}}</div>
+            <div class="value">{{detailData.status | statusFilter}}</div>
           </el-col>
           <el-col :span="8" class="item">
             <div class="label">经销商编号</div>
-            <div class="value">{{detailData.destStockId}}</div>
+            <div class="value">{{detailData.customerNumber}}</div>
           </el-col>
           <el-col :span="8" class="item">
             <div class="label">经销商名称</div>
-            <div class="value">{{detailData.approveDate}}</div>
+            <div class="value">{{detailData.customerName}}</div>
           </el-col>
           <el-col :span="8" class="item">
             <div class="label">仓库</div>
-            <div class="value">{{detailData.approverId}}</div>
+            <div class="value">{{detailData.correspondName}}</div>
           </el-col>
-          <el-col :span="8" class="item">
-            <div class="label">工程登录编码</div>
-            <div class="value">{{detailData.approverId}}</div>
+          <el-col :span="24" class="item">
+            <div class="label">备注</div>
+            <div class="value">{{detailData.remark}}</div>
           </el-col>
-          <el-col :span="8" class="item">
+          <el-col :span="6" class="item">
             <div class="label">制单人</div>
-            <div class="value">{{detailData.approverId}}</div>
+            <div class="value">{{detailData.createBy}}</div>
           </el-col>
-          <el-col :span="8" class="item">
+          <el-col :span="6" class="item">
             <div class="label">制单日期</div>
-            <div class="value">{{detailData.approverId}}</div>
+            <div class="value">{{detailData.createTime}}</div>
           </el-col>
-          <el-col :span="24" class="item">
-            <div class="label">备注</div>
-            <div class="value">{{detailData.approverId}}</div>
-          </el-col>
-          <el-col :span="12" class="item">
+          <el-col :span="6" class="item">
             <div class="label">审核人</div>
-            <div class="value">{{detailData.approverId}}</div>
+            <div class="value">{{detailData.approvalName}}</div>
           </el-col>
-          <el-col :span="12" class="item">
+          <el-col :span="6" class="item">
             <div class="label">审核日期</div>
-            <div class="value">{{detailData.approverId}}</div>
+            <div class="value">{{detailData.approvalTime}}</div>
           </el-col>
           <el-col :span="24" class="item">
             <div class="label">审批说明</div>
-            <div class="value">{{detailData.approverId}}</div>
+            <div class="value">{{detailData.approvalRemark}}</div>
           </el-col>
         </el-row>
       </div>
@@ -69,37 +65,46 @@
       </div>
 
       <div class="table" style="margin-top: 20px">
-        <el-table :data="detailData.kingDeeTransferItems" element-loading-text="Loading" border fit highlight-current-row stripe max-height="400">
+        <el-table :data="detailData.orders" element-loading-text="Loading" border fit highlight-current-row stripe max-height="400">
           <el-table-column align="center" label="序号" type="index" width="50"></el-table-column>
-          <el-table-column align="center" label="引用单号" prop="materialNumber" min-width="160" show-overflow-tooltip></el-table-column>
-          <el-table-column align="center" label="单号类型" prop="materialName" min-width="160" show-overflow-tooltip></el-table-column>
-          <el-table-column align="center" label="销售类型" prop="model" min-width="160" show-overflow-tooltip></el-table-column>
-          <el-table-column align="center" label="货品名称" prop="baseUnitId" min-width="160" show-overflow-tooltip></el-table-column>
-          <el-table-column align="center" label="规格型号" prop="qty" min-width="160" show-overflow-tooltip></el-table-column>
-          <el-table-column align="center" label="计量单位" prop="qty" min-width="100" show-overflow-tooltip></el-table-column>
-          <el-table-column align="center" label="数量" prop="qty" min-width="100" show-overflow-tooltip></el-table-column>
-          <el-table-column align="center" label="备注" prop="qty" min-width="160" show-overflow-tooltip></el-table-column>
+          <el-table-column align="center" label="销售类型" prop="saleTypeName" min-width="100" show-overflow-tooltip></el-table-column>
+          <el-table-column align="center" label="发货仓库" prop="stockIds" min-width="160" show-overflow-tooltip>
+            <template slot-scope="scope">
+              <el-tag size="mini" style="margin: 0 5px;" v-for="(item, index) in scope.row.stockIds" :key="index">{{item.name}}</el-tag>
+            </template>
+          </el-table-column>
+          <el-table-column align="center" label="库存数" prop="stockNumber" min-width="100" show-overflow-tooltip></el-table-column>
+          <el-table-column align="center" label="销售订单号" prop="retailOrderId" min-width="180" show-overflow-tooltip></el-table-column>
+          <el-table-column align="center" label="产品编码" prop="materialCode" min-width="120" show-overflow-tooltip></el-table-column>
+          <el-table-column align="center" label="产品名称" prop="materialName" min-width="160" show-overflow-tooltip></el-table-column>
+          <el-table-column align="center" label="规格型号" prop="specification" min-width="160" show-overflow-tooltip></el-table-column>
+          <el-table-column align="center" label="计量单位" prop="unit" min-width="100" show-overflow-tooltip></el-table-column>
+          <el-table-column align="center" label="申请数量" prop="invoiceNum" min-width="100" show-overflow-tooltip></el-table-column>
+          <el-table-column align="center" label="审批数量" prop="approvalNumber" min-width="100" show-overflow-tooltip></el-table-column>
+          <el-table-column align="center" label="备注" prop="remark" min-width="160" show-overflow-tooltip></el-table-column>
         </el-table>
       </div>
 
-      <div class="main-title">
-        <div class="title">审批记录</div>
-      </div>
-      <div class="diy-table-1">
-        <el-row :gutter="0">
-          <el-col :span="12" class="item">
-            <div class="label">审批人</div>
-            <div class="value">2022123233435342</div>
-          </el-col>
-          <el-col :span="12" class="item">
-            <div class="label">审批结果</div>
-            <div class="value">2022123233435342</div>
-          </el-col>
-          <el-col :span="24" class="item">
-            <div class="label">审批说明</div>
-            <div class="value">2022123233435342</div>
-          </el-col>
-        </el-row>
+      <div v-if="isExamine">
+        <div class="main-title">
+          <div class="title">审批记录</div>
+        </div>
+        <div class="diy-table-1">
+          <el-row :gutter="0">
+            <el-col :span="12" class="item">
+              <div class="label">审批人</div>
+              <div class="value">{{detailData.approvalName}}</div>
+            </el-col>
+            <el-col :span="12" class="item">
+              <div class="label">审批结果</div>
+              <div class="value">{{detailData.status | statusFilter}}</div>
+            </el-col>
+            <el-col :span="24" class="item">
+              <div class="label">审批说明</div>
+              <div class="value">{{detailData.approvalRemark}}</div>
+            </el-col>
+          </el-row>
+        </div>
       </div>
       
     </div>
@@ -151,24 +156,23 @@
       </el-form>
 
       <div class="table" style="margin-top: 20px">
-        <el-table :data="detailData.kingDeeTransferItems" element-loading-text="Loading" border fit highlight-current-row stripe max-height="400">
+        <el-table :data="detailData.orders" element-loading-text="Loading" border fit highlight-current-row stripe max-height="400">
           <el-table-column align="center" label="序号" type="index" width="50"></el-table-column>
-          <el-table-column align="center" label="引用记录" prop="materialNumber" min-width="160" show-overflow-tooltip></el-table-column>
-          <el-table-column align="center" label="销售类型" prop="materialName" min-width="160" show-overflow-tooltip></el-table-column>
-          <el-table-column align="center" label="产品编码" prop="model" min-width="160" show-overflow-tooltip></el-table-column>
-          <el-table-column align="center" label="产品名称" prop="baseUnitId" min-width="160" show-overflow-tooltip></el-table-column>
-          <el-table-column align="center" label="规格型号" prop="qty" min-width="160" show-overflow-tooltip></el-table-column>
-          <el-table-column align="center" label="单位" prop="qty" min-width="100" show-overflow-tooltip></el-table-column>
-          <el-table-column align="center" label="总数量" prop="qty" min-width="100" show-overflow-tooltip></el-table-column>
-          <el-table-column align="center" label="是否使用返利" prop="qty" min-width="100" show-overflow-tooltip></el-table-column>
-          <el-table-column align="center" label="返利使用比例" prop="qty" min-width="100" show-overflow-tooltip></el-table-column>
-          <el-table-column align="center" label="是否直调" prop="qty" min-width="100" show-overflow-tooltip></el-table-column>
-          <el-table-column align="center" label="直调数量" prop="qty" min-width="100" show-overflow-tooltip></el-table-column>
-          <el-table-column align="center" label="已发货数量" prop="qty" min-width="100" show-overflow-tooltip></el-table-column>
-          <el-table-column align="center" label="单价" prop="qty" min-width="100" show-overflow-tooltip></el-table-column>
-          <el-table-column align="center" label="金额" prop="qty" min-width="100" show-overflow-tooltip></el-table-column>
-          <el-table-column align="center" label="返利" prop="qty" min-width="100" show-overflow-tooltip></el-table-column>
-          <el-table-column align="center" label="备注" prop="qty" min-width="160" show-overflow-tooltip></el-table-column>
+          <el-table-column align="center" label="销售类型" prop="saleTypeName" min-width="160" show-overflow-tooltip></el-table-column>
+          <el-table-column align="center" label="发货仓库" prop="stockIds" min-width="160" show-overflow-tooltip>
+            <template slot-scope="scope">
+              <span v-for="(item, index) in scope.row.stockIds" :key="index">{{item.name}}</span>
+            </template>
+          </el-table-column>
+          <el-table-column align="center" label="库存数" prop="stockNumber" min-width="160" show-overflow-tooltip></el-table-column>
+          <el-table-column align="center" label="销售订单号" prop="retailOrderId" min-width="160" show-overflow-tooltip></el-table-column>
+          <el-table-column align="center" label="产品编码" prop="materialCode" min-width="160" show-overflow-tooltip></el-table-column>
+          <el-table-column align="center" label="产品名称" prop="materialName" min-width="160" show-overflow-tooltip></el-table-column>
+          <el-table-column align="center" label="规格型号" prop="specification" min-width="160" show-overflow-tooltip></el-table-column>
+          <el-table-column align="center" label="计量单位" prop="unit" min-width="100" show-overflow-tooltip></el-table-column>
+          <el-table-column align="center" label="申请数量" prop="invoiceNum" min-width="100" show-overflow-tooltip></el-table-column>
+          <el-table-column align="center" label="审批数量" prop="approvalNumber" min-width="100" show-overflow-tooltip></el-table-column>
+          <el-table-column align="center" label="备注" prop="remark" min-width="160" show-overflow-tooltip></el-table-column>
         </el-table>
       </div>
       <span slot="footer" class="dialog-footer">
@@ -182,7 +186,7 @@
 
 <script>
 import print from 'vue-print-nb'
-import { getDetail } from "@/api/supply/apply";
+import { getApplyDetail } from "@/api/supply/apply";
 
 export default {
   name: 'ApplyDetail',
@@ -191,6 +195,18 @@ export default {
   directives: {
     print
   },
+  filters: {
+    statusFilter(val) {
+      const statusList = [
+        { label: '已保存', value: 1 },
+        { label: '待审核', value: 2 },
+        { label: '审核通过', value: 3 },
+        { label: '审核驳回', value: 4 },
+      ];
+      let obj = statusList.find(o => o.value == val);
+      return obj ? obj.label : ''
+    }
+  },
   data() {
     return {
       printObj: {
@@ -217,6 +233,9 @@ export default {
         openSidebar: this.sidebar.opened
       }
     },
+    isExamine() {
+      return this.detailData.status === 3 || this.detailData.status === 4
+    },
   },
 
   created() {
@@ -231,7 +250,7 @@ export default {
 
     // 获取详情
     getDetail() {
-      getDetail({id: this.listItem.id}).then(res => {
+      getApplyDetail({id: this.listItem.id}).then(res => {
         this.detailData = res.data;
       })
     },

+ 134 - 43
src/views/supply/apply/components/apply_examine.vue

@@ -3,62 +3,50 @@
     <el-page-header @back="goBack" content="审批"></el-page-header>
 
     <div class="main-title">
-      <div class="title">工程订单</div>
+      <div class="title">发货申请单信息</div>
     </div>
 
     <div class="diy-table-1">
       <el-row>
         <el-col :span="8" class="item">
           <div class="label">发货申请单号</div>
-          <div class="value">{{detailData.billNo}}</div>
+          <div class="value">{{detailData.id}}</div>
         </el-col>
         <el-col :span="8" class="item">
           <div class="label">申请日期</div>
-          <div class="value">{{detailData.fdate}}</div>
+          <div class="value">{{detailData.createTime}}</div>
         </el-col>
         <el-col :span="8" class="item">
           <div class="label">单据状态</div>
-          <div class="value">{{detailData.srcStockId}}</div>
+          <div class="value">{{detailData.status | statusFilter}}</div>
         </el-col>
         <el-col :span="8" class="item">
           <div class="label">经销商编号</div>
-          <div class="value">{{detailData.destStockId}}</div>
+          <div class="value">{{detailData.customerNumber}}</div>
         </el-col>
         <el-col :span="8" class="item">
           <div class="label">经销商名称</div>
-          <div class="value">{{detailData.approveDate}}</div>
+          <div class="value">{{detailData.customerName}}</div>
         </el-col>
         <el-col :span="8" class="item">
           <div class="label">仓库</div>
-          <div class="value">{{detailData.approverId}}</div>
+          <div class="value">{{detailData.correspondName}}</div>
         </el-col>
-        <el-col :span="8" class="item">
-          <div class="label">工程登录编码</div>
-          <div class="value">{{detailData.approverId}}</div>
+        <el-col :span="24" class="item">
+          <div class="label">备注</div>
+          <div class="value">{{detailData.remark}}</div>
         </el-col>
         <el-col :span="8" class="item">
           <div class="label">制单人</div>
-          <div class="value">{{detailData.approverId}}</div>
+          <div class="value">{{detailData.createBy}}</div>
         </el-col>
         <el-col :span="8" class="item">
           <div class="label">制单日期</div>
-          <div class="value">{{detailData.approverId}}</div>
-        </el-col>
-        <el-col :span="24" class="item">
-          <div class="label">备注</div>
-          <div class="value">{{detailData.approverId}}</div>
-        </el-col>
-        <el-col :span="12" class="item">
-          <div class="label">审核人</div>
-          <div class="value">{{detailData.approverId}}</div>
+          <div class="value">{{detailData.createTime}}</div>
         </el-col>
-        <el-col :span="12" class="item">
-          <div class="label">审核日期</div>
-          <div class="value">{{detailData.approverId}}</div>
-        </el-col>
-        <el-col :span="24" class="item">
-          <div class="label">审批说明</div>
-          <div class="value">{{detailData.approverId}}</div>
+        <el-col :span="8" class="item">
+          <div class="label"></div>
+          <div class="value"></div>
         </el-col>
       </el-row>
     </div>
@@ -68,16 +56,33 @@
     </div>
 
     <div class="table" style="margin-top: 20px">
-      <el-table :data="detailData.kingDeeTransferItems" element-loading-text="Loading" border fit highlight-current-row stripe max-height="400">
+      <el-table :data="goodsList" element-loading-text="Loading" border fit highlight-current-row stripe max-height="400">
         <el-table-column align="center" label="序号" type="index" width="50"></el-table-column>
-        <el-table-column align="center" label="引用单号" prop="materialNumber" min-width="160" show-overflow-tooltip></el-table-column>
-        <el-table-column align="center" label="单号类型" prop="materialName" min-width="160" show-overflow-tooltip></el-table-column>
-        <el-table-column align="center" label="销售类型" prop="model" min-width="160" show-overflow-tooltip></el-table-column>
-        <el-table-column align="center" label="货品名称" prop="baseUnitId" min-width="160" show-overflow-tooltip></el-table-column>
-        <el-table-column align="center" label="规格型号" prop="qty" min-width="160" show-overflow-tooltip></el-table-column>
-        <el-table-column align="center" label="计量单位" prop="qty" min-width="100" show-overflow-tooltip></el-table-column>
-        <el-table-column align="center" label="数量" prop="qty" min-width="100" show-overflow-tooltip></el-table-column>
-        <el-table-column align="center" label="备注" prop="qty" min-width="160" show-overflow-tooltip></el-table-column>
+        <el-table-column align="center" label="销售类型" prop="saleTypeName" min-width="100" show-overflow-tooltip></el-table-column>
+        <el-table-column align="center" label="发货仓库" prop="stockIds" min-width="160" show-overflow-tooltip>
+          <template slot-scope="scope">
+            <el-select v-model="scope.row.stockIds" placeholder="请选择发货仓库" size="small" multiple filterable @change="changeWarehouse(scope.$index)">
+              <el-option :label="item.name" :value="item.id" v-for="(item, index) in positionList" :key="index"></el-option>
+            </el-select>
+          </template>
+        </el-table-column>
+        <el-table-column align="center" label="库存数" prop="stockNumber" min-width="100" show-overflow-tooltip></el-table-column>
+        <el-table-column align="center" label="销售订单号" prop="retailOrderId" min-width="180" show-overflow-tooltip></el-table-column>
+        <el-table-column align="center" label="产品编码" prop="materialCode" min-width="120" show-overflow-tooltip></el-table-column>
+        <el-table-column align="center" label="产品名称" prop="materialName" min-width="160" show-overflow-tooltip></el-table-column>
+        <el-table-column align="center" label="规格型号" prop="specification" min-width="160" show-overflow-tooltip></el-table-column>
+        <el-table-column align="center" label="计量单位" prop="unit" min-width="100" show-overflow-tooltip></el-table-column>
+        <el-table-column align="center" label="申请数量" prop="invoiceNum" min-width="100" show-overflow-tooltip></el-table-column>
+        <el-table-column align="center" label="审批数量" prop="approvalNumber" min-width="100" show-overflow-tooltip>
+          <template slot-scope="scope">
+            <el-input v-model="scope.row.approvalNumber" size="small" type="number"></el-input>
+          </template>
+        </el-table-column>
+        <el-table-column align="center" label="备注" prop="remark" min-width="160" show-overflow-tooltip>
+          <template slot-scope="scope">
+            <el-input v-model="scope.row.remark" size="small"></el-input>
+          </template>
+        </el-table-column>
       </el-table>
     </div>
 
@@ -88,7 +93,7 @@
       <el-row :gutter="0">
         <el-col :span="12" class="item">
           <div class="label">审批人</div>
-          <div class="value">2022123233435342</div>
+          <div class="value">{{userName}}</div>
         </el-col>
         <el-col :span="12" class="item">
           <div class="label">审批结果</div>
@@ -123,24 +128,36 @@
 </template>
 
 <script>
-import { getDetail } from "@/api/supply/apply";
+import { getApplyDetail, examineApply, getPositionList, checkStock } from "@/api/supply/apply";
 
 export default {
   name: 'ApplyExamine',
   componentName: 'ApplyExamine',
   props: ['listItem'],
+  filters: {
+    statusFilter(val) {
+      const statusList = [
+        { label: '已保存', value: 1 },
+        { label: '待审核', value: 2 },
+        { label: '审核通过', value: 3 },
+        { label: '审核驳回', value: 4 },
+      ];
+      let obj = statusList.find(o => o.value == val);
+      return obj ? obj.label : ''
+    }
+  },
   data() {
     return {
-      printObj: {
-        id: 'printData'
-      },
       detailData: {},
+      goodsList: [],
+      userName: JSON.parse(localStorage.getItem("supply_user")).nickName,
 
       formLoading: false,
       examineForm: {
         status: true,
         remark: '',
-      }
+      },
+      positionList: [],
     }
   },
 
@@ -168,13 +185,79 @@ export default {
 
     // 获取详情
     getDetail() {
-      getDetail({id: this.listItem.id}).then(res => {
+      getApplyDetail({id: this.listItem.id}).then(res => {
         this.detailData = res.data;
+
+        res.data.orders.forEach((item, index) => {
+          if(item.stockIds && item.stockIds.length > 0) {
+            item.stockIds = item.stockIds.map((it, idx) => {
+              return it.id;
+            });
+          }
+        });
+
+        this.goodsList = res.data.orders;
+        this.getPositionList();
       })
     },
 
+    // 获取仓位列表
+    getPositionList() {
+      getPositionList({
+        correspondId: this.detailData.correspondId
+      }).then((res) => {
+        this.positionList = res.data;
+      })
+    },
+
+    // 修改仓位
+    changeWarehouse(index) {
+      if(this.goodsList[index].stockIds && this.goodsList[index].stockIds.length > 0) {
+        checkStock({
+          materialId: this.goodsList[index].materialId,
+          StockIds: this.goodsList[index].stockIds.join(',')
+        }).then(res => {
+          this.goodsList[index].stockNumber = res.data;
+        })
+      }else {
+        this.goodsList[index].stockNumber = 0;
+      }
+    },
+
+    // 提交审批
     clickSubmitForm() {
+      for(let i=0; i<this.goodsList.length; i++) {
+        if(this.goodsList[i].stockIds && this.goodsList[i].stockIds.length < 1) {
+          this.$errorMsg('请选择发货仓库');
+          return;
+        }
+        if(this.goodsList[i].stockNumber < 1) {
+          this.$errorMsg('库存不足');
+          return;
+        }
+        if(this.goodsList[i].approvalNumber > this.goodsList[i].stockNumber) {
+          this.$errorMsg('审批数量不可大于库存数');
+          return;
+        }
+        if(this.goodsList[i].approvalNumber > this.goodsList[i].invoiceNum) {
+          this.$errorMsg('审批数量不可大于申请数量');
+          return;
+        }
+      }
 
+      this.formLoading = true;
+      examineApply({
+        id: this.listItem.id,
+        status: this.examineForm.status ? 3 : 4,
+        approvalRemark: this.examineForm.remark,
+        orders: this.goodsList
+      }).then(res => {
+        this.$successMsg('审批成功');
+        this.goBack();
+        this.$parent.getList();
+      }).finally(res => {
+        this.formLoading = false;
+      })
     },
 
   }
@@ -200,4 +283,12 @@ export default {
       padding-left: 10px;
     }
   }
+
+  ::v-deep input::-webkit-outer-spin-button,
+  ::v-deep input::-webkit-inner-spin-button {
+    -webkit-appearance: none;
+  }
+  ::v-deep input[type='number'] {
+    -moz-appearance: textfield;
+  }
 </style>

+ 541 - 0
src/views/supply/apply/components/apply_form.vue

@@ -0,0 +1,541 @@
+<template>
+  <div class="detail-container">
+    <el-page-header @back="goBack" :content="listItem ? '编辑':'新增'"></el-page-header>
+
+    <div class="main-title">
+      <div class="title">发货申请单信息</div>
+    </div>
+
+    <el-form ref="mainForm" :model="mainForm" :rules="mainFormRules" label-width="90px" size="small" label-position="right">
+      <el-row :gutter="20">
+        <el-col :xs="24" :sm="12" :lg="8" v-if="listItem">
+          <el-form-item label="订单号" prop="id">
+            <el-input v-model="listItem.id" readonly></el-input>
+          </el-form-item>
+        </el-col>
+        <el-col :xs="24" :sm="12" :lg="8" style="height: 51px;">
+          <el-form-item label="单据日期" prop="date">
+            <el-date-picker
+              v-model="mainForm.date"
+              type="date"
+              value-format="yyyy-MM-dd"
+              style="width: 100%;"
+              placeholder="选择日期">
+            </el-date-picker>
+          </el-form-item>
+        </el-col>
+        <el-col :xs="24" :sm="12" :lg="8" v-if="listItem">
+          <el-form-item label="制单人" prop="serviceName">
+            <el-input v-model="listItem.serviceName" readonly></el-input>
+          </el-form-item>
+        </el-col>
+        <el-col :xs="24" :sm="12" :lg="8">
+          <el-form-item label="经销商" prop="dealer">
+            <el-select v-model="mainForm.dealer" placeholder="请选择经销商" style="width: 100%;">
+              <el-option :label="item.name" :value="item.id" v-for="(item, index) in dealerList" :key="index"></el-option>
+            </el-select>
+          </el-form-item>
+        </el-col>
+        <el-col :xs="24" :sm="24" :lg="24">
+          <el-form-item label="备注" prop="remark">
+            <el-input v-model="mainForm.remark" placeholder="请输入备注"></el-input>
+          </el-form-item>
+        </el-col>
+        <el-col :xs="24" :sm="8" :lg="8">
+          <el-form-item label="附件" prop="fileUrl">
+            <fileUpload :fileList="fileList" />
+          </el-form-item>
+        </el-col>
+      </el-row>
+    </el-form>
+
+    <div class="main-title">
+      <div class="title">货品信息</div>
+      <div>
+        <span style="font-size: 14px; margin-right: 10px">仓库</span>
+        <el-select v-model="screenForm.warehouse" placeholder="请选择发货仓库" size="small" filterable clearable :disabled="goodsList.length > 0">
+          <el-option :label="item.name" :value="item.id" v-for="(item, index) in warehouseList" :key="index"></el-option>
+        </el-select>
+        <el-divider direction="vertical"></el-divider>
+        <el-button type="primary" size="small" icon="el-icon-plus" @click="openDialog">添加引用</el-button>
+      </div>
+    </div>
+
+    <div class="table" style="margin-top: 20px">
+      <el-table :data="goodsList" element-loading-text="Loading" border fit highlight-current-row stripe max-height="400">
+        <el-table-column align="center" label="序号" type="index" width="50"></el-table-column>
+        <el-table-column align="center" label="引用单号" prop="orderId" min-width="180" show-overflow-tooltip></el-table-column>
+        <el-table-column align="center" label="销售类型" prop="saleTypeName" min-width="100" show-overflow-tooltip></el-table-column>
+        <el-table-column align="center" label="产品名称" prop="materialName" min-width="160" show-overflow-tooltip></el-table-column>
+        <el-table-column align="center" label="规格型号" prop="specification" min-width="160" show-overflow-tooltip></el-table-column>
+        <el-table-column align="center" label="单位" prop="unit" min-width="100" show-overflow-tooltip></el-table-column>
+        <el-table-column align="center" label="数量" prop="qty" min-width="80" show-overflow-tooltip></el-table-column>
+        <el-table-column align="center" label="申请数量" prop="invoiceNum" min-width="110" show-overflow-tooltip>
+          <template slot-scope="scope">
+            <el-input v-model="scope.row.invoiceNum" size="small"></el-input>
+          </template>
+        </el-table-column>
+        <el-table-column align="center" label="已申请数量" prop="alreadyInvoiceNum" min-width="100" show-overflow-tooltip></el-table-column>
+        <el-table-column align="center" label="未申请数量" min-width="100" show-overflow-tooltip>
+          <template slot-scope="scope">
+            {{scope.row.qty - scope.row.alreadyInvoiceNum}}
+          </template>
+        </el-table-column>
+        <el-table-column align="center" label="备注" prop="remark" min-width="160" show-overflow-tooltip>
+          <template slot-scope="scope">
+            <el-input v-model="scope.row.remark" size="small"></el-input>
+          </template>
+        </el-table-column>
+        <el-table-column align="center" label="操作" width="100" fixed="right">
+          <template slot-scope="scope">
+            <el-button type="text" @click="deleteItem(scope.row.orderId)">删除</el-button>
+          </template>
+        </el-table-column>
+      </el-table>
+    </div>
+    
+    <div class="page-footer">
+      <div class="footer" :class="classObj">
+        <el-button type="primary" @click="clickSubmitForm">保 存</el-button>
+        <el-popconfirm title="确定关闭吗?" @onConfirm="goBack" style="margin-left: 10px;">
+          <el-button slot="reference">关 闭</el-button>
+        </el-popconfirm>
+      </div>
+    </div>
+
+    <el-dialog title="添加产品" :visible.sync="isShowDialog" width="80%">
+      <el-form ref="screenForm" :model="screenForm" size="small" label-position="left" label-width="70px">
+        <el-row :gutter="20">
+          <el-col :xs="12" :sm="6" :lg="6">
+            <el-form-item prop="warehouse" label="选择仓库">
+              <el-select v-model="screenForm.warehouse" placeholder="请选择仓库" size="small" filterable clearable :disabled="goodsList.length > 0 || tableSelection.length > 0">
+                <el-option :label="item.name" :value="item.id" v-for="(item, index) in warehouseList" :key="index"></el-option>
+              </el-select>
+            </el-form-item>
+          </el-col>
+          <el-col :xs="12" :sm="6" :lg="6">
+            <el-form-item prop="type" label="产品大类">
+              <el-select v-model="screenForm.type" placeholder="选择产品大类" style="width: 100%" :disabled="goodsList.length > 0 || tableSelection.length > 0">
+                <el-option v-for="item in typeList" :key="item.dictCode" :label="item.dictValue" :value="item.dictCode"></el-option>
+              </el-select>
+            </el-form-item>
+          </el-col>
+          <el-col :xs="12" :sm="6" :lg="6">
+            <el-form-item prop="orderNum" label="订单号">
+              <el-input v-model="screenForm.orderNum" placeholder="请输入订单号"></el-input>
+            </el-form-item>
+          </el-col>
+          <el-col :xs="12" :sm="6" :lg="6" class="tr">
+            <el-form-item label="">
+              <el-button size="small" @click="resetScreenForm">清空</el-button>
+              <el-button size="small" type="primary" @click="submitScreenForm">搜索</el-button>
+            </el-form-item>
+          </el-col>
+        </el-row>
+      </el-form>
+
+      <div class="table">
+        <el-table :data="tableGoodsList" element-loading-text="Loading" border fit highlight-current-row stripe height="400" @selection-change="tableSelectionChange">
+          <el-table-column align="center" type="selection" width="55" :selectable='checkboxSelect'></el-table-column>
+          <el-table-column align="center" label="订单号" prop="orderId" min-width="180" show-overflow-tooltip></el-table-column>
+          <el-table-column align="center" label="销售类型" prop="saleTypeName" min-width="100" show-overflow-tooltip></el-table-column>
+          <el-table-column align="center" label="产品名称" prop="materialName" min-width="160" show-overflow-tooltip></el-table-column>
+          <el-table-column align="center" label="规格型号" prop="specification" min-width="160" show-overflow-tooltip></el-table-column>
+          <el-table-column align="center" label="单位" prop="unit" min-width="80" show-overflow-tooltip></el-table-column>
+          <el-table-column align="center" label="数量" prop="qty" min-width="80" show-overflow-tooltip></el-table-column>
+          <el-table-column align="center" label="本次申请数量" prop="invoiceNum" min-width="110" show-overflow-tooltip>
+            <template slot-scope="scope">
+              <el-input v-model="scope.row.invoiceNum" size="small"></el-input>
+            </template>
+          </el-table-column>
+          <el-table-column align="center" label="已申请数量" prop="alreadyInvoiceNum" min-width="100" show-overflow-tooltip></el-table-column>
+          <el-table-column align="center" label="未申请数量" min-width="100" show-overflow-tooltip>
+            <template slot-scope="scope">
+              {{scope.row.qty - scope.row.alreadyInvoiceNum}}
+            </template>
+          </el-table-column>
+          <el-table-column align="center" label="总库存数量" prop="stockAdequate" min-width="100" show-overflow-tooltip>
+            <template slot-scope="scope">
+              {{scope.row.stockAdequate | stockFilter}}
+            </template>
+          </el-table-column>
+          <el-table-column align="center" label="对应库存数量" prop="stockCorrespond" min-width="110" show-overflow-tooltip>
+            <template slot-scope="scope">
+              {{scope.row.stockCorrespond | stockFilter}}
+            </template>
+          </el-table-column>
+        </el-table>
+        <div class="pagination clearfix" style="margin-top: 10px">
+          <div class="fr">
+            <el-pagination
+              @current-change="handleTableCurrentChange"
+              :current-page="currentPage"
+              :page-size="10"
+              background
+              layout="prev, pager, next"
+              :total="listTotal">
+            </el-pagination>
+          </div>
+        </div>
+      </div>
+      
+      <span slot="footer" class="dialog-footer">
+        <el-button @click="closeDialog">取 消</el-button>
+        <el-button type="primary" @click="submitAddGoods">确 定</el-button>
+      </span>
+    </el-dialog>
+
+  </div>
+</template>
+
+<script>
+import { getApplyDetail, addApply, editApply, getGoodsList, getWarehouseList, getDealerList } from "@/api/supply/apply";
+import { getDictList } from '@/api/common'
+import { findElem } from '@/utils/util'
+import fileUpload from '@/components/Common/file-upload.vue'
+
+export default {
+  components: {
+    fileUpload
+  },
+  name: 'ApplyForm',
+  componentName: 'ApplyForm',
+  props: ['listItem'],
+  filters: {
+    stockFilter(val) {
+      const MAP = {
+        0: '不充足',
+        1: '充足'
+      }
+      return MAP[val]
+    }
+  },
+  data() {
+    return {
+      mainForm: {
+        date: '',
+        dealer: '',
+        remark: '',
+      },
+      mainFormRules: {
+        date: [
+          { required: true, message: '请选择单据日期', trigger: 'change' }
+        ],
+        dealer: [
+          { required: true, message: '请选择经销商', trigger: 'change' }
+        ],
+      },
+      dealerList: [],
+      fileList: [],
+      goodsList: [],
+
+      warehouseList: [],
+      isShowDialog: false,
+      screenForm: {
+        warehouse: '',
+        type: '',
+        orderNum: '',
+      },
+      currentPage: 1,
+      listTotal: 0,
+      typeList: [],
+      
+      tableGoodsList: [],
+      tableSelection: [],
+    }
+  },
+
+  computed: {
+    sidebar() {
+      return this.$store.state.app.sidebar
+    },
+    classObj() {
+      return {
+        hideSidebar: !this.sidebar.opened,
+        openSidebar: this.sidebar.opened
+      }
+    },
+  },
+
+  created() {
+    this.getDictList();
+    this.getWarehouseList();
+    this.getDealerList();
+    if(this.listItem) {
+      this.getDetail();
+    }
+  },
+
+  methods: {
+    // 返回列表
+    goBack() {
+      this.$emit('backListFormDetail');
+    },
+
+    // 获取详情
+    getDetail() {
+      getApplyDetail({id: this.listItem.id}).then(res => {
+        let data = res.data;
+        this.mainForm.date = data.orderTime;
+        this.mainForm.dealer = data.customerNumber;
+        this.mainForm.remark = data.remark;
+        this.screenForm.warehouse = data.correspondId;
+        this.fileList = data.fileUrl ? [{
+          url: data.fileUrl,
+          name: data.fileName
+        }] : [];
+        data.orders.forEach(item => {
+          item.orderId = item.id;
+        })
+        this.goodsList = data.orders;
+      })
+    },
+
+    // 获取仓库列表
+    getWarehouseList() {
+      getWarehouseList({
+        pageNum: 1,
+        pageSize: -1
+      }).then((res) => {
+        this.warehouseList = res.data.records;
+      })
+    },
+
+    getDictList() {
+      getDictList({sysDictEnum: 'PRODUCT_TYPE'}).then(res => {
+        this.typeList = res.data;
+      })
+    },
+
+    // 获取经销商列表
+    getDealerList() {
+      getDealerList({
+        pageNum: 1,
+        pageSize: -1,
+        bindUser: false
+      }).then(res => {
+        this.dealerList = res.data.records;
+      })
+    },
+
+    // 获取商品列表
+    getGoodsList() {
+      getGoodsList({
+        pageNum: this.currentPage,
+        pageSize: 10,
+        stockId: this.screenForm.warehouse,
+        mainId: this.screenForm.type,
+        id: this.screenForm.orderNum,
+        // examineStatus: 'OK',
+      }).then(res => {
+        let goodsList = [];
+        res.data.records.forEach(item => {
+          goodsList.push({
+            orderId: item.id,
+            retailId: item.retailId,
+            saleTypeName: item.saleTypeName,
+            materialId: item.materialId,
+            materialCode: item.materialCode,
+            materialName: item.materialName,
+            specification: item.specification,
+            unit: item.unit,
+            qty: item.qty,
+            invoiceNum: item.invoiceNum,
+            alreadyInvoiceNum: item.alreadyInvoiceNum,
+            stockAdequate: item.stockAdequate,
+            stockCorrespond: item.stockCorrespond,
+          })
+        });
+
+        let oldGoodsList = this.goodsList;
+        let newGoodsList = goodsList;
+        for(let i = 0; i < oldGoodsList.length; i++) {
+          let oldItem = oldGoodsList[i]
+          for(let j = 0; j < newGoodsList.length; j++) {
+            let newItem = newGoodsList[j]
+            if(newItem.materialId === oldItem.materialId){
+              newGoodsList[j].selected = true;
+              break;
+            }
+          }
+        }
+
+        this.tableGoodsList = newGoodsList;
+        this.listTotal = res.data.total;
+      })
+    },
+
+    // 查询重复值并禁选
+    checkboxSelect(row, rowIndex) {
+      if (row.selected) {
+        return false // 禁用
+      }else{
+        return true // 不禁用
+      }
+    },
+
+    // 点击 选择商品
+    openDialog() {
+      if(!this.screenForm.warehouse) {
+        return this.$errorMsg('请选择仓库');
+      }
+      this.isShowDialog = true;
+      if(this.screenForm.warehouse && this.screenForm.type) {
+        this.getGoodsList();
+      }
+    },
+
+    // 提交筛选表单
+    submitScreenForm() {
+      if(!this.screenForm.warehouse || !this.screenForm.type) {
+        return this.$errorMsg('请选择仓库和产品大类');
+      }
+      this.currentPage = 1;
+      this.getGoodsList();
+    },
+
+    // 重置筛选表单
+    resetScreenForm() {
+      this.$refs.screenForm.resetFields();
+      this.currentPage = 1;
+      this.tableGoodsList = [];
+      // this.getGoodsList();
+    },
+
+    // 更改列表当前页
+    handleTableCurrentChange(val) {
+      if(this.tableSelection.length > 0) {
+        return this.$errorMsg('已选择产品不可切换');
+      }
+      this.currentPage = val;
+      this.getGoodsList();
+    },
+
+    // 关闭 弹窗
+    closeDialog() {
+      this.isShowDialog = false;
+    },
+
+    // 列表选择
+    tableSelectionChange(val) {
+      this.tableSelection = val;
+    },
+
+    // 数组去重
+    delRepeat(arr1, arr2) {
+      let allArr = arr1.concat(arr2); // 两个数组对象合并
+      let newArr = []; // 存放去重后数据的新数组
+      for(let i=0; i<allArr.length; i++){  // 循环allArr数组对象的内容
+        let flag = true;  // 建立标记,判断数据是否重复,true为不重复
+        for(let j=0; j<newArr.length; j++){  // 循环新数组的内容
+          if(allArr[i].materialId == newArr[j].materialId){ // 让allArr数组对象的内容与新数组的内容作比较,相同的话,改变标记为false
+            flag = false;
+          }
+        }
+        if(flag){ // 判断是否重复
+          newArr.push(allArr[i]); // 不重复的放入新数组。  新数组的内容会继续进行上边的循环。
+        }
+      }
+      return newArr;
+    },
+
+    // 确定 添加产品
+    submitAddGoods() {
+      let allList = this.tableGoodsList;
+      let selectList = this.tableSelection;
+      let submitList = [];
+
+      for(let i = 0; i < allList.length; i++) {
+        for(let j = 0; j < selectList.length; j++) {
+          if(selectList[j].orderId == allList[i].orderId){
+            submitList.push(allList[i]);
+          }
+        }
+      }
+      // this.goodsList = this.goodsList.concat(submitList);
+
+      this.goodsList = this.delRepeat(submitList, this.goodsList);
+      this.isShowDialog = false;
+      this.tableGoodsList = [];
+    },
+
+    // 删除产品
+    deleteItem(id) {
+      this.goodsList = this.goodsList.filter((item) => {
+        return item.orderId != id
+      })
+    },
+
+    // 保存
+    clickSubmitForm() {
+      this.$refs.mainForm.validate((valid) => {
+        if (valid) {
+          for(let i=0; i<this.goodsList.length; i++) {
+            if(!this.goodsList[i].invoiceNum) {
+              this.$errorMsg('请输入申请数量');
+              return;
+            }
+          }
+          for(let i=0; i<this.goodsList.length; i++) {
+            if(this.goodsList[i].invoiceNum > this.goodsList[i].qty) {
+              this.$errorMsg('申请数量不能大于总数量');
+              return;
+            }
+          }
+
+          let customerName = this.dealerList[findElem(this.dealerList, 'id', this.mainForm.dealer)].name;
+          let correspondName = this.warehouseList[findElem(this.warehouseList, 'id', this.screenForm.warehouse)].name;
+          let params = {
+            orderTime: this.mainForm.date + ' 00:00:00',
+            customerNumber: this.mainForm.dealer,
+            customerName,
+            remark: this.mainForm.remark,
+            fileUrl: this.fileList && this.fileList.length > 0 ? this.fileList[0].url : '',
+            fileName: this.fileList && this.fileList.length > 0 ? this.fileList[0].name : '',
+            orderType: 1, // 1零售单 2家用工程 3商用工程
+            correspondId: this.screenForm.warehouse,
+            correspondName,
+            orders: this.goodsList,
+            status: 1, // 1保存 2待审核 3通过 4驳回
+          }
+          if(this.listItem) {
+            params.id = this.listItem.id;
+            editApply(params).then(res => {
+              this.$successMsg('编辑成功');
+              this.goBack();
+              this.$parent.getList();
+            })
+          }else {
+            addApply(params).then(res => {
+              this.$successMsg('添加成功');
+              this.goBack();
+              this.$parent.getList();
+            })
+          }
+        }
+      })
+    },
+  }
+}
+</script>
+
+<style scoped lang="scss">
+  .detail-container {
+    width: 100%;
+    height: 100%;
+  }
+  .main-title {
+    display: flex;
+    justify-content: space-between;
+    align-items: center;
+    margin-top: 20px;
+    height: 60px;
+    border-bottom: 1px solid #DCDFE6;
+    margin-bottom: 20px;
+    .title {
+      font-size: 16px;
+      font-weight: 600;
+      padding-left: 10px;
+    }
+  }
+</style>