Sfoglia il codice sorgente

【新增】直接调拨单

莫绍宝 3 anni fa
parent
commit
a5704f066e

+ 6 - 60
src/api/supply/direct.js

@@ -19,63 +19,27 @@ export function getDetail(params) {
 }
 
 // 审批
-export function examineApply(params) {
+export function examineData(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',
+    url: '/requisition/approval',
     method: 'post',
     params
   })
 }
 
 // 删除
-export function deleteApply(params) {
+export function deleteData(params) {
   return request({
-    url: '/invoice/delete',
+    url: '/requisition/delete',
     method: 'post',
     params
   })
 }
 
-// 新增
-export function addApply(params) {
-  return request({
-    url: '/invoice/add',
-    method: 'post',
-    data: params
-  })
-}
-
 // 编辑
-export function editApply(params) {
+export function editData(params) {
   return request({
-    url: '/invoice/update',
+    url: '/requisition/updateRequisition',
     method: 'post',
     data: params
   })
@@ -89,21 +53,3 @@ export function getWarehouseList(params) {
     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
-  })
-}

+ 91 - 154
src/views/supply/direct/components/direct_detail.vue

@@ -3,18 +3,18 @@
     <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="label">直接调拨单号</div>
           <div class="value">{{detailData.id}}</div>
         </el-col>
         <el-col :span="8" class="item">
           <div class="label">申请日期</div>
-          <div class="value">{{detailData.createTime}}</div>
+          <div class="value">{{detailData.orderTime}}</div>
         </el-col>
         <el-col :span="8" class="item">
           <div class="label">单据状态</div>
@@ -24,35 +24,38 @@
           <div class="label">经销商编号</div>
           <div class="value">{{detailData.customerNumber}}</div>
         </el-col>
-        <el-col :span="8" class="item">
+        <el-col :span="16" class="item">
           <div class="label">经销商名称</div>
           <div class="value">{{detailData.customerName}}</div>
         </el-col>
         <el-col :span="8" class="item">
-          <div class="label">仓库</div>
-          <div class="value">{{detailData.correspondName}}</div>
+          <div class="label">销售订单号</div>
+          <div class="value">{{detailData.orderNo}}</div>
+        </el-col>
+        <el-col :span="8" class="item">
+          <div class="label">销售单类型</div>
+          <div class="value">{{detailData.orderType | orderTypeFilter}}</div>
+        </el-col>
+        <el-col :span="8" class="item">
+          <div class="label">调拨类型</div>
+          <div class="value">{{detailData.type | typeFilter}}</div>
+        </el-col>
+        <el-col :span="8" class="item">
+          <div class="label">调出库存组织</div>
+          <div class="value">{{detailData.requsitionOut}}</div>
+        </el-col>
+        <el-col :span="8" class="item">
+          <div class="label">调入库存组织</div>
+          <div class="value">{{detailData.requsitionIn}}</div>
+        </el-col>
+        <el-col :span="8" class="item">
+          <div class="label">调拨方向</div>
+          <div class="value">{{detailData.direction}}</div>
         </el-col>
         <el-col :span="24" class="item">
           <div class="label">备注</div>
           <div class="value">{{detailData.remark}}</div>
         </el-col>
-        <el-col :span="24" class="item file">
-          <div class="label">附件</div>
-          <div class="value">
-            <div class="file-list">
-              <div class="file-item">
-                <el-image v-if="checkFileType(detailData.fileUrl) == 'image'" class="img" :src="imageURL + detailData.fileUrl" :preview-src-list="[imageURL + detailData.fileUrl]"></el-image>
-                <div v-else class="box2" @click="openLink(detailData.fileUrl)">
-                  <img src="@/assets/common/word.png" v-if="checkFileType(detailData.fileUrl) == 'word'" />
-                  <img src="@/assets/common/excel.png" v-if="checkFileType(detailData.fileUrl) == 'excel'" />
-                  <img src="@/assets/common/ppt.png" v-if="checkFileType(detailData.fileUrl) == 'ppt'" />
-                  <img src="@/assets/common/pdf.png" v-if="checkFileType(detailData.fileUrl) == 'pdf'" />
-                  <div class="name ellipsis-3">{{ detailData.fileName }}</div>
-                </div>
-              </div>
-            </div>
-          </div>
-        </el-col>
         <el-col :span="6" class="item">
           <div class="label">制单人</div>
           <div class="value">{{detailData.createBy}}</div>
@@ -69,6 +72,22 @@
           <div class="label">审核日期</div>
           <div class="value">{{detailData.approvalTime}}</div>
         </el-col>
+        <el-col :span="6" class="item">
+          <div class="label">最后更新人</div>
+          <div class="value">{{detailData.updateBy}}</div>
+        </el-col>
+        <el-col :span="6" class="item">
+          <div class="label">最后更新日期</div>
+          <div class="value">{{detailData.updateTime}}</div>
+        </el-col>
+        <el-col :span="6" class="item">
+          <div class="label">关闭人</div>
+          <div class="value">{{detailData.closeName}}</div>
+        </el-col>
+        <el-col :span="6" class="item">
+          <div class="label">关闭日期</div>
+          <div class="value">{{detailData.closeTime}}</div>
+        </el-col>
         <el-col :span="24" class="item">
           <div class="label">审批说明</div>
           <div class="value">{{detailData.approvalRemark}}</div>
@@ -81,22 +100,41 @@
     </div>
 
     <div class="table" style="margin-top: 20px">
-      <el-table :data="detailData.orders" element-loading-text="Loading" border fit highlight-current-row stripe max-height="400">
+      <el-table :data="detailData.results" 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="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="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="totalAmount" min-width="100" show-overflow-tooltip></el-table-column>
+        <el-table-column align="center" label="调出仓库" min-width="100" show-overflow-tooltip>
+          <template slot-scope="">{{detailData.correspondName}}</template>
+        </el-table-column>
+        <el-table-column align="center" label="调出仓位" min-width="100" show-overflow-tooltip>
+          <template slot-scope="">{{detailData.stockName}}</template>
+        </el-table-column>
+        <el-table-column align="center" label="调入仓库" min-width="100" show-overflow-tooltip>
+          <template slot-scope="">{{detailData.inCorrespondName}}</template>
+        </el-table-column>
+        <el-table-column align="center" label="调入仓位" min-width="100" show-overflow-tooltip>
+          <template slot-scope="">{{detailData.inStockName}}</template>
+        </el-table-column>
+        <el-table-column align="center" label="调出库存状态" min-width="110" show-overflow-tooltip>
+          <template slot-scope="">{{detailData.stockStatusType}}</template>
+        </el-table-column>
+        <el-table-column align="center" label="调入库存状态" min-width="110" show-overflow-tooltip>
+          <template slot-scope="">{{detailData.inStockStatusType}}</template>
+        </el-table-column>
+        <el-table-column align="center" label="调出库主" min-width="100" show-overflow-tooltip>
+          <template slot-scope="">{{detailData.requsitionOut}}</template>
+        </el-table-column>
+        <el-table-column align="center" label="调入库主" min-width="100" show-overflow-tooltip>
+          <template slot-scope="">{{detailData.requsitionIn}}</template>
+        </el-table-column>
+
         <el-table-column align="center" label="备注" prop="remark" min-width="160" show-overflow-tooltip></el-table-column>
       </el-table>
     </div>
@@ -125,82 +163,15 @@
     
     <div class="page-footer">
       <div class="footer" :class="classObj">
-        <el-button  type="primary" @click="openDeliverDialog">直调发货</el-button>
-        <el-popconfirm title="确定关闭吗?" @onConfirm="goBack" style="margin-left: 10px;">
-          <el-button slot="reference">关 闭</el-button>
-        </el-popconfirm>
+        <el-button @click="goBack">关 闭</el-button>
       </div>
     </div>
 
-    <el-dialog
-      title="直调发货"
-      :visible.sync="isShowDeliverDialog"
-      width="80%">
-      <el-form ref="deliverForm" :model="deliverForm" label-width="70px" size="small" label-position="left">
-        <el-row :gutter="20">
-          <el-col :xs="24" :sm="8" :lg="8">
-            <el-form-item label="工程订单" prop="orderNum">
-              <el-input v-model="deliverForm.orderNum" placeholder="请输入工程订单"></el-input>
-            </el-form-item>
-          </el-col>
-          <el-col :xs="24" :sm="8" :lg="8" style="height: 51px;">
-            <el-form-item label="发货日期" prop="date">
-              <el-date-picker
-                v-model="deliverForm.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="8" :lg="8">
-            <el-form-item label="发货仓库" prop="warehouse">
-              <el-select v-model="deliverForm.warehouse" placeholder="请选择发货仓库">
-                <el-option
-                  v-for="item in warehouseList"
-                  :key="item.value"
-                  :label="item.label"
-                  :value="item.value">
-                </el-option>
-              </el-select>
-            </el-form-item>
-          </el-col>
-        </el-row>
-      </el-form>
-
-      <div class="table" style="margin-top: 20px">
-        <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="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">
-        <el-button @click="closeDeliverDialog">取 消</el-button>
-        <el-button type="primary" @click="submitDeliverForm">确 定</el-button>
-      </span>
-    </el-dialog>
-
   </div>
 </template>
 
 <script>
 import { getDetail } from "@/api/supply/direct";
-import { getFileUrl } from '@/api/common';
 
 export default {
   name: 'DirectDetail',
@@ -208,28 +179,36 @@ export default {
   props: ['listItem'],
   filters: {
     statusFilter(val) {
-      const statusList = [
+      const MAP = [
         { label: '已保存', value: 'SAVE' },
         { label: '待审核', value: 'WAIT' },
         { label: '审核通过', value: 'OK' },
         { label: '审核驳回', value: 'FAIL' },
         { label: '已关闭', value: 'CLOSE' },
       ];
-      let obj = statusList.find(o => o.value == val);
+      let obj = MAP.find(o => o.value == val);
       return obj ? obj.label : ''
+    },
+    orderTypeFilter(val) {
+      const MAP = [
+        { label: '商用工程订单', value: 'TRADE' },
+        { label: '家用工程订单', value: 'HOME' },
+        { label: '零售单', value: 'RETAIL' },
+        { label: '销售政策单', value: 'RETAIL_POLICY' },
+      ];
+      let obj = MAP.find(o => o.value == val);
+      return obj ? obj.label : ''
+    },
+    typeFilter(val) {
+      const MAP = {
+        1: '组织内调拨',
+      }
+      return MAP[val];
     }
   },
   data() {
     return {
-      imageURL: this.$imageUrl,
       detailData: {},
-
-      isShowDeliverDialog: false,
-      deliverForm: {
-        orderNum: '',
-        date: '',
-      },
-      warehouseList: [],
     }
   },
 
@@ -265,48 +244,6 @@ export default {
       })
     },
 
-    // 检查文件类型
-    checkFileType(url) {
-      if(!url) return '';
-			const fileSuffix = url.substring(url.lastIndexOf(".") + 1);
-
-			if (['jpg', 'jpeg', 'png'].includes(fileSuffix)) {
-				return 'image';
-			}else if (['doc', 'docx', 'dot', 'wps', 'wpt'].includes(fileSuffix)) {
-				return 'word';
-			}else if(['xls', 'xlsx', 'xlt', 'et', 'ett'].includes(fileSuffix)) {
-				return 'excel';
-			}else if(['ppt', 'pptx', 'dps', 'dpt', 'pot', 'pps'].includes(fileSuffix)) {
-				return 'ppt';
-			}else if(['pdf'].includes(fileSuffix)) {
-				return 'pdf';
-			}else {
-        return '';
-      }
-		},
-
-    // 打开链接
-    openLink(url) {
-      getFileUrl({key: url}).then(res => {
-        window.open(res.data);
-      })
-    },
-
-    // 打开 直调发货
-    openDeliverDialog() {
-      this.isShowDeliverDialog = true;
-    },
-
-    // 关闭 直调发货
-    closeDeliverDialog() {
-      this.isShowDeliverDialog = false;
-    },
-
-    // 提交 直调发货
-    submitDeliverForm() {
-
-    },
-
   }
 }
 </script>

+ 110 - 122
src/views/supply/direct/components/direct_examine.vue

@@ -3,18 +3,18 @@
     <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="label">直接调拨单号</div>
           <div class="value">{{detailData.id}}</div>
         </el-col>
         <el-col :span="8" class="item">
           <div class="label">申请日期</div>
-          <div class="value">{{detailData.createTime}}</div>
+          <div class="value">{{detailData.orderTime}}</div>
         </el-col>
         <el-col :span="8" class="item">
           <div class="label">单据状态</div>
@@ -24,29 +24,37 @@
           <div class="label">经销商编号</div>
           <div class="value">{{detailData.customerNumber}}</div>
         </el-col>
-        <el-col :span="8" class="item">
+        <el-col :span="16" class="item">
           <div class="label">经销商名称</div>
           <div class="value">{{detailData.customerName}}</div>
         </el-col>
         <el-col :span="8" class="item">
-          <div class="label">仓库</div>
-          <div class="value">{{detailData.correspondName}}</div>
+          <div class="label">销售订单号</div>
+          <div class="value">{{detailData.orderNo}}</div>
         </el-col>
-        <el-col :span="24" class="item">
-          <div class="label">备注</div>
-          <div class="value">{{detailData.remark}}</div>
+        <el-col :span="8" class="item">
+          <div class="label">销售单类型</div>
+          <div class="value">{{detailData.orderType | orderTypeFilter}}</div>
         </el-col>
         <el-col :span="8" class="item">
-          <div class="label">制单人</div>
-          <div class="value">{{detailData.createBy}}</div>
+          <div class="label">调拨类型</div>
+          <div class="value">{{detailData.type | typeFilter}}</div>
         </el-col>
         <el-col :span="8" class="item">
-          <div class="label">制单日期</div>
-          <div class="value">{{detailData.createTime}}</div>
+          <div class="label">调出库存组织</div>
+          <div class="value">{{detailData.requsitionOut}}</div>
         </el-col>
         <el-col :span="8" class="item">
-          <div class="label"></div>
-          <div class="value"></div>
+          <div class="label">调入库存组织</div>
+          <div class="value">{{detailData.requsitionIn}}</div>
+        </el-col>
+        <el-col :span="8" class="item">
+          <div class="label">调拨方向</div>
+          <div class="value">{{detailData.direction}}</div>
+        </el-col>
+        <el-col :span="24" class="item">
+          <div class="label">备注</div>
+          <div class="value">{{detailData.remark}}</div>
         </el-col>
       </el-row>
     </div>
@@ -56,33 +64,42 @@
     </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 :data="detailData.results" 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="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 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="totalAmount" min-width="100" show-overflow-tooltip></el-table-column>
+        <el-table-column align="center" label="调出仓库" min-width="100" show-overflow-tooltip>
+          <template slot-scope="">{{detailData.correspondName}}</template>
+        </el-table-column>
+        <el-table-column align="center" label="调出仓位" min-width="100" show-overflow-tooltip>
+          <template slot-scope="">{{detailData.stockName}}</template>
+        </el-table-column>
+        <el-table-column align="center" label="调入仓库" min-width="100" show-overflow-tooltip>
+          <template slot-scope="">{{detailData.inCorrespondName}}</template>
+        </el-table-column>
+        <el-table-column align="center" label="调入仓位" min-width="100" show-overflow-tooltip>
+          <template slot-scope="">{{detailData.inStockName}}</template>
+        </el-table-column>
+        <el-table-column align="center" label="调出库存状态" min-width="110" show-overflow-tooltip>
+          <template slot-scope="">{{detailData.stockStatusType}}</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 align="center" label="调入库存状态" min-width="110" show-overflow-tooltip>
+          <template slot-scope="">{{detailData.inStockStatusType}}</template>
         </el-table-column>
+        <el-table-column align="center" label="调出库主" min-width="100" show-overflow-tooltip>
+          <template slot-scope="">{{detailData.requsitionOut}}</template>
+        </el-table-column>
+        <el-table-column align="center" label="调入库主" min-width="100" show-overflow-tooltip>
+          <template slot-scope="">{{detailData.requsitionIn}}</template>
+        </el-table-column>
+
+        <el-table-column align="center" label="备注" prop="remark" min-width="160" show-overflow-tooltip></el-table-column>
       </el-table>
     </div>
 
@@ -96,13 +113,8 @@
           <div class="value">{{userName}}</div>
         </el-col>
         <el-col :span="12" class="item">
-          <div class="label">审批结果</div>
-          <div class="value">
-            <el-radio-group v-model="examineForm.status">
-              <el-radio :label="true">通过</el-radio>
-              <el-radio :label="false">驳回</el-radio>
-            </el-radio-group>
-          </div>
+          <div class="label">审批日期</div>
+          <div class="value">{{getDate()}}</div>
         </el-col>
         <el-col :span="24" class="item">
           <div class="label">审批说明</div>
@@ -113,12 +125,9 @@
     
     <div class="page-footer">
       <div class="footer" :class="classObj">
-        <el-button type="primary" @click="clickSubmitForm" :loading="formLoading">{{ formLoading ? '提交中 ...' : '提 交' }}</el-button>
-        <el-popconfirm
-          title="确定关闭吗?"
-          @onConfirm="goBack"
-          style="margin-left: 10px;"
-        >
+        <el-button type="primary" @click="clickSubmitForm('OK')">审批通过</el-button>
+        <el-button type="warning" @click="clickSubmitForm('FAIL')">审批驳回</el-button>
+        <el-popconfirm title="确定关闭吗?" @onConfirm="goBack" style="margin-left: 10px;">
           <el-button slot="reference">关 闭</el-button>
         </el-popconfirm>
       </div>
@@ -128,7 +137,7 @@
 </template>
 
 <script>
-import { getDetail, examineApply, getPositionList, checkStock } from "@/api/supply/direct";
+import { getDetail, examineData } from "@/api/supply/direct";
 
 export default {
   name: 'DirectExamine',
@@ -136,29 +145,42 @@ export default {
   props: ['listItem'],
   filters: {
     statusFilter(val) {
-      const statusList = [
+      const MAP = [
         { label: '已保存', value: 'SAVE' },
         { label: '待审核', value: 'WAIT' },
         { label: '审核通过', value: 'OK' },
         { label: '审核驳回', value: 'FAIL' },
         { label: '已关闭', value: 'CLOSE' },
       ];
-      let obj = statusList.find(o => o.value == val);
+      let obj = MAP.find(o => o.value == val);
+      return obj ? obj.label : ''
+    },
+    orderTypeFilter(val) {
+      const MAP = [
+        { label: '商用工程订单', value: 'TRADE' },
+        { label: '家用工程订单', value: 'HOME' },
+        { label: '零售单', value: 'RETAIL' },
+        { label: '销售政策单', value: 'RETAIL_POLICY' },
+      ];
+      let obj = MAP.find(o => o.value == val);
       return obj ? obj.label : ''
+    },
+    typeFilter(val) {
+      const MAP = {
+        1: '组织内调拨',
+      }
+      return MAP[val];
     }
   },
   data() {
     return {
       detailData: {},
-      goodsList: [],
       userName: JSON.parse(localStorage.getItem("supply_user")).nickName,
 
       formLoading: false,
       examineForm: {
-        status: true,
         remark: '',
       },
-      positionList: [],
     }
   },
 
@@ -179,6 +201,22 @@ export default {
   },
 
   methods: {
+    getDate() {
+      var date = new Date();
+      var seperator1 = "-";
+      var year = date.getFullYear();
+      var month = date.getMonth() + 1;
+      var strDate = date.getDate();
+      if (month >= 1 && month <= 9) {
+          month = "0" + month;
+      }
+      if (strDate >= 0 && strDate <= 9) {
+          strDate = "0" + strDate;
+      }
+      var currentdate = year + seperator1 + month + seperator1 + strDate;
+      return currentdate;
+    },
+
     // 返回列表
     goBack() {
       this.$emit('backListFormDetail');
@@ -188,77 +226,27 @@ export default {
     getDetail() {
       getDetail({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,
-        examineStatus: this.examineForm.status ? 'OK' : 'FAIL',
-        approvalRemark: this.examineForm.remark,
-        orders: this.goodsList
-      }).then(res => {
-        this.$successMsg('审批成功');
-        this.goBack();
-        this.$parent.getList();
-      }).finally(res => {
-        this.formLoading = false;
-      })
+    clickSubmitForm(val) {
+      this.$confirm('此操作将审批订单, 是否继续?', '提示', {
+        confirmButtonText: '确定',
+        cancelButtonText: '取消',
+        type: 'warning'
+      }).then(() => {
+        let params = {
+          id: this.detailData.id,
+          examineStatus: val,
+          approvalRemark: this.examineForm.remark
+        };
+        examineData(params).then(res => {
+          this.$successMsg();
+          this.goBack();
+          this.$parent.getList();
+        })
+      }).catch(() => {});
     },
 
   }

+ 241 - 389
src/views/supply/direct/components/direct_form.vue

@@ -3,47 +3,143 @@
     <el-page-header @back="goBack" :content="listItem ? '编辑':'新增'"></el-page-header>
 
     <div class="main-title">
-      <div class="title">发货申请单信息</div>
+      <div class="title">基本信息</div>
     </div>
 
-    <el-form ref="mainForm" :model="mainForm" :rules="mainFormRules" label-width="90px" size="small" label-position="right">
+    <el-form ref="mainForm" :model="mainForm" :rules="mainFormRules" label-width="100px" size="small" label-position="right">
       <el-row :gutter="20">
         <el-col :xs="24" :sm="12" :lg="8">
-          <el-form-item label="单号" prop="id">
-            <el-input v-model="mainForm.orderNum" placeholder="系统自动生成" readonly></el-input>
+          <el-form-item label="单据编号" prop="id">
+            <el-input v-model="mainForm.id" placeholder="系统自动生成" disabled></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-form-item label="申请日期" prop="orderTime">
             <el-date-picker
-              v-model="mainForm.date"
-              type="date"
-              value-format="yyyy-MM-dd"
+              v-model="mainForm.orderTime"
+              type="datetime"
+              value-format="yyyy-MM-dd HH:mm:ss"
               style="width: 100%;"
               placeholder="选择日期">
             </el-date-picker>
           </el-form-item>
         </el-col>
         <el-col :xs="24" :sm="12" :lg="8">
-          <el-form-item label="制单人" prop="createMan">
-            <el-input v-model="mainForm.createMan" readonly></el-input>
+          <el-form-item label="状态" prop="examineStatus">
+            <el-select v-model="mainForm.examineStatus" style="width: 100%;" disabled>
+              <el-option
+                v-for="(item, index) in statusList" 
+                :key="index"
+                :label="item.label"
+                :value="item.value">
+              </el-option>
+            </el-select>
           </el-form-item>
         </el-col>
-        <el-col :xs="24" :sm="24" :lg="16">
-          <el-form-item label="备注" prop="remark">
-            <el-input v-model="mainForm.remark" placeholder="请输入备注"></el-input>
+        <el-col :xs="24" :sm="12" :lg="8">
+          <el-form-item label="经销商编码" prop="customerNumber">
+            <el-input v-model="mainForm.customerNumber" disabled></el-input>
+          </el-form-item>
+        </el-col>
+        <el-col :xs="24" :sm="12" :lg="16">
+          <el-form-item label="经销商名称" prop="customerName">
+            <el-input v-model="mainForm.customerName" disabled></el-input>
+          </el-form-item>
+        </el-col>
+        <el-col :xs="24" :sm="12" :lg="8">
+          <el-form-item label="销售单号" prop="orderNo">
+            <el-input v-model="mainForm.orderNo" disabled></el-input>
+          </el-form-item>
+        </el-col>
+        <el-col :xs="24" :sm="12" :lg="8">
+          <el-form-item label="销售单类型" prop="orderType">
+            <el-select v-model="mainForm.orderType" style="width: 100%;" disabled>
+              <el-option
+                v-for="(item, index) in orderTypeList" 
+                :key="index"
+                :label="item.label"
+                :value="item.value">
+              </el-option>
+            </el-select>
           </el-form-item>
         </el-col>
         <el-col :xs="24" :sm="12" :lg="8">
-          <el-form-item label="经销商" prop="jxsNum">
-            <el-select v-model="mainForm.jxsNum" placeholder="请选择经销商" style="width: 100%;" disabled>
-              <el-option :label="item.name" :value="item.id" v-for="(item, index) in dealerList" :key="index"></el-option>
+          <el-form-item label="调拨类型" prop="type">
+            <el-select v-model="mainForm.type" style="width: 100%;" disabled>
+              <el-option
+                v-for="(item, index) in typeList" 
+                :key="index"
+                :label="item.label"
+                :value="item.value">
+              </el-option>
+            </el-select>
+          </el-form-item>
+        </el-col>
+        <el-col :xs="24" :sm="12" :lg="8">
+          <el-form-item label="调出库存组织" prop="requsitionOut">
+            <el-input v-model="mainForm.requsitionOut" disabled></el-input>
+          </el-form-item>
+        </el-col>
+        <el-col :xs="24" :sm="12" :lg="8">
+          <el-form-item label="调入库存组织" prop="requsitionIn">
+            <el-input v-model="mainForm.requsitionIn" disabled></el-input>
+          </el-form-item>
+        </el-col>
+        <el-col :xs="24" :sm="12" :lg="8">
+          <el-form-item label="调拨方向" prop="direction">
+            <el-input v-model="mainForm.direction" disabled></el-input>
+          </el-form-item>
+        </el-col>
+        <el-col :xs="24" :sm="12" :lg="8">
+          <el-form-item label="制单人" prop="createBy">
+            <el-input v-model="mainForm.createBy" disabled></el-input>
+          </el-form-item>
+        </el-col>
+        <el-col :xs="24" :sm="12" :lg="8">
+          <el-form-item label="制单日期" prop="createTime">
+            <el-date-picker
+              v-model="mainForm.createTime"
+              type="datetime"
+              value-format="yyyy-MM-dd HH:mm:ss"
+              style="width: 100%;"
+              disabled
+              placeholder="选择日期">
+            </el-date-picker>
+          </el-form-item>
+        </el-col>
+      </el-row>
+      <el-row :gutter="20">
+        <el-col :xs="12" :sm="6" :lg="6">
+          <el-form-item label="调出仓库" prop="correspondId">
+            <el-select v-model="mainForm.correspondId" placeholder="请选择调出仓库" style="width: 100%" filterable @change="changeWarehouse1">
+              <el-option v-for="item in warehouseList1" :key="item.id" :label="item.name" :value="item.id"></el-option>
+            </el-select>
+          </el-form-item>
+        </el-col>
+        <el-col :xs="12" :sm="6" :lg="6">
+          <el-form-item label="调出仓位" prop="stockId">
+            <el-select v-model="mainForm.stockId" placeholder="请调出仓位" style="width: 100%" filterable>
+              <el-option v-for="item in positionList1" :key="item.id" :label="item.name" :value="item.id"></el-option>
+            </el-select>
+          </el-form-item>
+        </el-col>
+        <el-col :xs="12" :sm="6" :lg="6">
+          <el-form-item label="调入仓库" prop="inCorrespondId">
+            <el-select v-model="mainForm.inCorrespondId" placeholder="请选择调入仓库" style="width: 100%" filterable @change="changeWarehouse2">
+              <el-option v-for="item in warehouseList2" :key="item.id" :label="item.name" :value="item.id"></el-option>
             </el-select>
           </el-form-item>
         </el-col>
-        <el-col :xs="24" :sm="8" :lg="8">
-          <el-form-item label="附件" prop="fileUrl">
-            <fileUpload :fileList="fileList" />
+        <el-col :xs="12" :sm="6" :lg="6">
+          <el-form-item label="调入仓位" prop="inStockId">
+            <el-select v-model="mainForm.inStockId" placeholder="请调入仓位" style="width: 100%" filterable>
+              <el-option v-for="item in positionList2" :key="item.id" :label="item.name" :value="item.id"></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-row>
@@ -51,42 +147,44 @@
 
     <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 :data="mainForm.results" 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="materialCode" min-width="160" show-overflow-tooltip></el-table-column>
+        <el-table-column align="center" label="物料代码" prop="materialOldNumber" 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="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 align="center" label="调拨数量" prop="qty" min-width="100" show-overflow-tooltip></el-table-column>
+        <el-table-column align="center" label="总成本" prop="totalAmount" min-width="100" show-overflow-tooltip></el-table-column>
+        <el-table-column align="center" label="调出仓库" min-width="100" show-overflow-tooltip>
+          <template slot-scope="">{{ mainForm.correspondName}}</template>
+        </el-table-column>
+        <el-table-column align="center" label="调出仓位" min-width="100" show-overflow-tooltip>
+          <template slot-scope="">{{ mainForm.stockName}}</template>
+        </el-table-column>
+        <el-table-column align="center" label="调入仓库" min-width="100" show-overflow-tooltip>
+          <template slot-scope="">{{ mainForm.inCorrespondName}}</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="未申请数量" prop="refundableQty" min-width="100" show-overflow-tooltip> </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 align="center" label="调入仓位" min-width="100" show-overflow-tooltip>
+          <template slot-scope="">{{ mainForm.inStockName}}</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.$index)">删除</el-button>
-          </template>
+        <el-table-column align="center" label="调出库存状态" min-width="110" show-overflow-tooltip>
+          <template slot-scope="">{{ mainForm.stockStatusType}}</template>
         </el-table-column>
+        <el-table-column align="center" label="调入库存状态" min-width="110" show-overflow-tooltip>
+          <template slot-scope="">{{ mainForm.inStockStatusType}}</template>
+        </el-table-column>
+        <el-table-column align="center" label="调出货主" min-width="100" show-overflow-tooltip>
+          <template slot-scope="">{{mainForm.requsitionOut}}</template>
+        </el-table-column>
+        <el-table-column align="center" label="调入货主" min-width="100" show-overflow-tooltip>
+          <template slot-="scope">{{mainForm.requsitionIn}}</template>
+        </el-table-column>
+        <el-table-column align="center" label="备注" prop="remark" min-width="160" show-overflow-tooltip></el-table-column>
       </el-table>
     </div>
     
@@ -100,139 +198,96 @@
       </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="未申请数量" prop="refundableQty" min-width="100" show-overflow-tooltip></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></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 { getDetail, addApply, editApply, getGoodsList, getWarehouseList, getDealerList } from "@/api/supply/direct";
-import { getDictList } from '@/api/common'
-import { findElem } from '@/utils/util'
-import fileUpload from '@/components/Common/file-upload.vue'
+import { getDetail, editData, getWarehouseList } from "@/api/supply/direct";
 
 export default {
-  components: {
-    fileUpload
-  },
   name: 'DirectForm',
   componentName: 'DirectForm',
   props: ['listItem'],
-  filters: {
-    stockFilter(val) {
-      const MAP = {
-        0: '不充足',
-        1: '充足'
-      }
-      return MAP[val]
-    }
-  },
   data() {
     return {
-      mainForm: {
-        orderNum: '',
-        date: '',
-        jxsNum: '',
-        remark: '',
-        createMan: '',
-      },
+      statusList: [
+        { label: '已保存', value: 'SAVE' },
+        { label: '待审核', value: 'WAIT' },
+        { label: '审核通过', value: 'OK' },
+        { label: '审核驳回', value: 'FAIL' },
+        { label: '已关闭', value: 'CLOSE' },
+      ],
+      orderTypeList: [
+        { label: '商用工程订单', value: 'TRADE' },
+        { label: '家用工程订单', value: 'HOME' },
+        { label: '零售单', value: 'RETAIL' },
+        { label: '销售政策单', value: 'RETAIL_POLICY' },
+      ],
+      typeList: [
+        { label: '组织内调拨', value: 1 },
+      ],
+      mainForm: {},
       mainFormRules: {
-        date: [
-          { required: true, message: '请选择单据日期', trigger: 'change' }
-        ],
+        orderTime: [{ required: true, message: '请选择单据日期', trigger: 'change' }],
+        remark: [{ required: true, message: '请输入备注', trigger: 'blur' }],
+        correspondId: [{ required: true, message: '请选择调出仓库', trigger: 'change' }],
+        stockId: [{ required: true, message: '请选择调出仓位', trigger: 'change' }],
+        inCorrespondId: [{ required: true, message: '请选择调入仓库', trigger: 'change' }],
+        inStockId: [{ required: true, message: '请选择调入仓位', trigger: 'change' }],
       },
-      dealerList: [],
-      fileList: [],
       goodsList: [],
 
-      warehouseList: [],
-      isShowDialog: false,
-      screenForm: {
-        warehouse: '',
-        type: '',
-        orderNum: '',
-      },
-      currentPage: 1,
-      listTotal: 0,
-      typeList: [],
+      warehouseList1: [],
+      warehouseList2: [],
+      positionList1: [],
+      positionList2: [],
       
-      tableGoodsList: [],
-      tableSelection: [],
     }
   },
 
+  watch: {
+    'mainForm.correspondId': {
+      handler(newValue, oldValue) {
+        if (newValue) {
+          let obj = this.warehouseList1.find(o => o.id == newValue);
+          this.mainForm.correspondName = obj.name;
+          this.positionList1 = obj.kingDeeStocks;
+        }
+      },
+      immediate: true,
+    },
+    'mainForm.inCorrespondId': {
+      handler(newValue, oldValue) {
+        if (newValue) {
+          let obj = this.warehouseList2.find(o => o.id == newValue);
+          this.mainForm.inCorrespondName = obj.name;
+          this.positionList2 = obj.kingDeeStocks;
+        }
+      },
+      immediate: true,
+    },
+    'mainForm.stockId': {
+      handler(newValue, oldValue) {
+        if (newValue) {
+          let obj = this.positionList1.find(o => o.id == newValue);
+          this.mainForm.stockName = obj.name;
+          this.mainForm.stockStatusType = obj.defStockStatusName;
+        }
+      },
+      immediate: true,
+    },
+    'mainForm.inStockId': {
+      handler(newValue, oldValue) {
+        if (newValue) {
+          let obj = this.positionList2.find(o => o.id == newValue);
+          this.mainForm.inStockName = obj.name;
+          this.mainForm.inStockStatusType = obj.defStockStatusName;
+        }
+      },
+      immediate: true,
+    },
+  },
+
   computed: {
     sidebar() {
       return this.$store.state.app.sidebar
@@ -245,15 +300,10 @@ export default {
     },
   },
 
-  created() {
-    this.getDictList();
-    this.getWarehouseList();
-    this.getDealerList();
+  async created() {
+    await this.getWarehouseList();
     if(this.listItem) {
       this.getDetail();
-    }else {
-      this.mainForm.jxsNum = JSON.parse(localStorage.getItem("supply_user")).customerId;
-      this.mainForm.createMan = JSON.parse(localStorage.getItem("supply_user")).nickName;
     }
   },
 
@@ -266,245 +316,47 @@ export default {
     // 获取详情
     getDetail() {
       getDetail({id: this.listItem.id}).then(res => {
-        let data = res.data;
-        this.mainForm.orderNum = data.id;
-        this.mainForm.date = data.orderTime;
-        this.mainForm.jxsNum = data.customerNumber;
-        this.mainForm.createMan = data.createBy;
-        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;
+        this.mainForm = res.data;
       })
     },
 
     // 获取仓库列表
-    getWarehouseList() {
-      getWarehouseList({
-        pageNum: 1,
-        pageSize: -1
-      }).then((res) => {
-        this.warehouseList = res.data.records;
+    async getWarehouseList() {
+      const result = new Promise((resolve, reject) => {
+        getWarehouseList({
+          pageNum: 1,
+          pageSize: -1
+        }).then((res) => {
+          this.warehouseList1 = res.data.records;
+          this.warehouseList2 = res.data.records;
+          resolve(res.data.records);
+        })
       })
+      return result;
     },
 
-    getDictList() {
-      getDictList({sysDictEnum: 'PRODUCT_TYPE'}).then(res => {
-        this.typeList = res.data;
-      })
+    // 更改调出仓库
+    changeWarehouse1() {
+      this.mainForm.stockId = '';
     },
 
-    // 获取经销商列表
-    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',
-        type: 1,
-      }).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,
-            refundableQty: item.refundableQty,
-            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(index) {
-      this.goodsList.splice(index, 1);
-      // this.goodsList = this.goodsList.filter((item) => {
-      //   return item.orderId != id
-      // })
+    // 更改调入仓库
+    changeWarehouse2() {
+      this.mainForm.inStockId = '';
     },
 
     // 保存
     clickSubmitForm(status) {
       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 correspondName = this.warehouseList[findElem(this.warehouseList, 'id', this.screenForm.warehouse)].name;
-          let params = {
-            id: this.listItem ? this.listItem.id : '',
-            orderTime: this.mainForm.date + ' 00:00:00',
-            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,
-            examineStatus: status,
-          }
-          if(this.listItem) {
-            editApply(params).then(res => {
-              this.$successMsg('编辑成功');
-              this.goBack();
-              this.$parent.getList();
-            })
-          }else {
-            addApply(params).then(res => {
-              this.$successMsg('添加成功');
-              this.goBack();
-              this.$parent.getList();
-            })
-          }
+          let { id, orderTime, correspondId, correspondName, stockId, stockName, inCorrespondId, inCorrespondName, inStockId, inStockName, remark }  = this.mainForm;
+          let params = { id, orderTime, correspondId, correspondName, stockId, stockName, inCorrespondId, inCorrespondName, inStockId, inStockName, remark };
+          params.examineStatus = status;
+          editData(params).then(res => {
+            this.$successMsg('编辑成功');
+            this.goBack();
+            this.$parent.getList();
+          })
         }
       })
     },

+ 29 - 4
src/views/supply/direct/direct_list.vue

@@ -70,14 +70,15 @@
       <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>
+            <el-button size="small" type="danger" icon="el-icon-minus" :disabled="multipleSelection.length < 1" @click="batchDelete()">批量删除</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 v-loading="listLoading" :data="dataList" element-loading-text="Loading" border fit highlight-current-row stripe @selection-change="handleSelectionChange">
+            <el-table-column align="center" type="selection" width="55"></el-table-column>
             <el-table-column align="center" label="直接调拨单号" prop="id" min-width="180" show-overflow-tooltip></el-table-column>
             <el-table-column align="center" label="审核状态" prop="examineStatus" min-width="100" show-overflow-tooltip>
               <template slot-scope="scope">
@@ -138,7 +139,7 @@
 </template>
 
 <script>
-import { getList, submitApply, deleteApply } from "@/api/supply/direct";
+import { getList, submitApply, deleteData } from "@/api/supply/direct";
 import DirectDetail from "@/views/supply/direct/components/direct_detail";
 import DirectExamine from "@/views/supply/direct/components/direct_examine";
 import DirectForm from "@/views/supply/direct/components/direct_form";
@@ -185,6 +186,8 @@ export default {
       isShowDetail: false,
       isShowExamine: false,
       isShowForm: false,
+
+      multipleSelection: [],
     }
   },
 
@@ -297,13 +300,35 @@ export default {
       this.isShowForm = false;
     },
 
+    // 删除
     handleDelete(id) {
-      deleteApply({id}).then(res => {
+      deleteData({ids: id}).then(res => {
         this.$successMsg();
         this.getList();
       })
     },
 
+     // 批量删除
+    batchDelete() {
+      this.$confirm('此操作将永久删除, 是否继续?', '提示', {
+        confirmButtonText: '确定',
+        cancelButtonText: '取消',
+        type: 'warning'
+      }).then(() => {
+        let ids = this.multipleSelection.map(item => {
+          return item.id;
+        });
+        deleteData({ids: ids.join(',')}).then(res => {
+          this.$successMsg();
+          this.getList();
+        })
+      }).catch(() => {});
+    },
+
+    handleSelectionChange(val) {
+      this.multipleSelection = val;
+    },
+
     // 申请/撤回
     handleSubmit(id, examineStatus) {
       submitApply({id, examineStatus}).then(res => {

+ 1 - 1
src/views/supply/retail/retail_list.vue

@@ -129,7 +129,7 @@
               <template slot-scope="scope">
                 <el-button type="text" @click="toForm(scope.row)" v-if="scope.row.examineStatus === 'SAVE'">编辑</el-button>
                 <el-button type="text" @click="toExamine(scope.row)" v-if="scope.row.examineStatus === 'WAIT'">审批</el-button>
-                <el-button type="text" @click="toReturn(scope.row)">退订</el-button>
+                <el-button type="text" @click="toReturn(scope.row)" v-if="scope.row.examineStatus === 'OK'">退订</el-button>
                 <el-button type="text" @click="toDetail(scope.row)">详情</el-button>
                 <el-popconfirm style="margin-left: 10px;" title="确定提审吗?" @onConfirm="handleSubmit(scope.row.id)" v-if="scope.row.examineStatus === 'SAVE'" >
                   <el-button slot="reference" type="text">提审</el-button>