Ver código fonte

散件入库对接

chenrui 4 anos atrás
pai
commit
61b81c4299

+ 39 - 0
src/api/sparePartsPur.js

@@ -27,6 +27,30 @@ export const sparePartsPurSave = (params) => {
     method: 'post'
   })
 }
+//  散件采购(入库) 提交
+export const sparePartsPurSubmit = (params) => {
+  return axios({
+    url: '/sparePartsPur/submit',
+    data: params,
+    method: 'post'
+  })
+}
+//  散件采购(入库) 入库
+export const sparePartsPurPut = (params) => {
+  return axios({
+    url: '/sparePartsPur/put',
+    data: params,
+    method: 'post'
+  })
+}
+//  散件采购(入库) 删除
+export const sparePartsPurDel = (params) => {
+  return axios({
+    url: `/sparePartsPur/delete/${params.id}`,
+    method: 'get'
+  })
+}
+
 //  散件采购(入库) 详情
 export const sparePartsPurDetail = (params) => {
   return axios({
@@ -53,3 +77,18 @@ export const sparePartsPurDetailCount = (params) => {
     method: 'post'
   })
 }
+//  散件采购(入库) 详情列表 保存
+export const sparePartsPurDetailSave = (params) => {
+  return axios({
+    url: '/sparePartsPur/detail/save',
+    data: params,
+    method: 'post'
+  })
+}
+//  散件采购(入库) 详情列表 删除
+export const sparePartsPurDetailDel = (params) => {
+  return axios({
+    url: `/sparePartsPur/detail/delete/${params.id}`,
+    method: 'get'
+  })
+}

+ 1 - 1
src/config/router.config.js

@@ -1145,7 +1145,7 @@ export const asyncRouterMap = [
                 }
               },
               {
-                path: 'detail/:id',
+                path: 'detail/:id/:sn',
                 name: 'bulkWarehousingOrderDetail',
                 component: () => import(/* webpackChunkName: "shop" */ '@/views/bulkManagement/bulkWarehousingOrder/detail.vue'),
                 meta: {

+ 41 - 42
src/views/bulkManagement/bulkWarehousingOrder/detail.vue

@@ -1,9 +1,14 @@
 <template>
   <div class="bulkWarehousingOrderDetail-wrap">
-    <a-page-header :ghost="false" @back="handleBack" >
+    <a-page-header :ghost="false" :backIcon="false" class="bulkWarehousingOrderDetail-cont" >
       <!-- 自定义的二级文字标题 -->
       <template slot="subTitle">
-        <a id="bulkWarehousingOrderDetail-back-btn" href="javascript:;" @click="handleBack">返回列表</a>
+        <a id="bulkWarehousingOrderDetail-back-btn" href="javascript:;" @click="handleBack"><a-icon type="left" /> 返回列表</a>
+        <p style=" display: inline-block;margin: 0 0 0 60px;color: #000;font-size: 16px;font-weight: 600;">单号:{{ (basicInfoData&&basicInfoData.sparePartsPurchaseSn) || '' }}</p>
+      </template>
+      <template slot="tags">
+        <a-tag color="purple" v-if="basicInfoData&&basicInfoData.stateDictValue">{{ basicInfoData.stateDictValue }}</a-tag>
+        <a-tag color="orange" v-if="basicInfoData&&basicInfoData.settleStateDictValue">{{ basicInfoData.settleStateDictValue }}</a-tag>
       </template>
       <!-- 操作区,位于 title 行的行尾 -->
       <template slot="extra">
@@ -11,23 +16,16 @@
         <a-button key="1" type="primary" id="bulkWarehousingOrderDetail-print-btn">快速打印</a-button>
       </template>
     </a-page-header>
-    <!-- 内容 -->
-    <a-page-header title="单号:CG2021010100001" >
-      <template slot="tags">
-        <a-tag color="blue">审核通过</a-tag>
-        <a-tag color="orange">未结算</a-tag>
-      </template>
-    </a-page-header>
     <!-- 基础信息 -->
     <a-card size="small" :bordered="false" class="bulkWarehousingOrderDetail-cont">
       <a-collapse :activeKey="['1']">
         <a-collapse-panel key="1" header="基础信息">
           <a-descriptions :column="3">
-            <a-descriptions-item label="供应商">箭冠营销中心</a-descriptions-item>
-            <a-descriptions-item label="支付方式">箭冠营销中心</a-descriptions-item>
-            <a-descriptions-item label="采购员工">箭冠营销中心</a-descriptions-item>
-            <a-descriptions-item label="收货人">箭冠营销中心</a-descriptions-item>
-            <a-descriptions-item label="收货地址">箭冠营销中心</a-descriptions-item>
+            <a-descriptions-item label="供应商">{{ (basicInfoData&&basicInfoData.supplierName) || '' }}</a-descriptions-item>
+            <a-descriptions-item label="散件入库类型">{{ (basicInfoData&&basicInfoData.sparePartsTypeName) || '' }}</a-descriptions-item>
+            <a-descriptions-item label="备注">{{ (basicInfoData&&basicInfoData.remarks) || '' }}</a-descriptions-item>
+            <a-descriptions-item label="联系人">{{ (basicInfoData&&basicInfoData.supplierName) || '' }}</a-descriptions-item>
+            <a-descriptions-item label="联系地址">{{ (basicInfoData&&basicInfoData.supplierName) || '' }}</a-descriptions-item>
           </a-descriptions>
         </a-collapse-panel>
       </a-collapse>
@@ -48,7 +46,7 @@
             :rowKey="(record) => record.id"
             :columns="columns"
             :data="loadData"
-            :scroll="{ x: 1060 }"
+            :scroll="{ x: 1080, y: 300 }"
             bordered>
             <!-- 采购数量 -->
             <template slot="purchaseNum" slot-scope="text, record">
@@ -84,6 +82,7 @@
 
 <script>
 import { STable, VSelect } from '@/components'
+import { sparePartsPurDetail, sparePartsPurDetailList } from '@/api/sparePartsPur'
 export default {
   components: { STable, VSelect },
   data () {
@@ -91,52 +90,52 @@ export default {
       // 表头
       columns: [
         { title: '序号', dataIndex: 'no', width: 80, align: 'center', fixed: 'left' },
-        { title: '产品编码', dataIndex: 'creatDate', width: 140, align: 'center', customRender: function (text) { return text || '--' } },
+        { title: '产品编码', dataIndex: 'creatDate', width: 200, align: 'center', customRender: function (text) { return text || '--' } },
         { title: '产品名称', dataIndex: 'custName', align: 'center', customRender: function (text) { return text || '--' } },
-        { title: '原厂编码', dataIndex: 'totalP', width: 140, align: 'center', customRender: function (text) { return text || '--' } },
         { title: '采购单价', dataIndex: 'totalNums', width: 100, align: 'center', customRender: function (text) { return ((text || text == 0) ? text : '--') } },
-        { title: '采购数量', scopedSlots: { customRender: 'purchaseNum' }, width: 100, align: 'center' },
-        { title: '缺货数量', scopedSlots: { customRender: 'outOfStockNum' }, width: 100, align: 'center' },
+        { title: '采购数量', dataIndex: 'totaslNums', width: 100, align: 'center' },
         { title: '单位', dataIndex: 'mementPay', width: 100, align: 'center', customRender: function (text) { return text || '--' } },
-        { title: '采购金额', dataIndex: 'shDate', width: 100, align: 'center', customRender: function (text) { return ((text || text == 0) ? text : '--') } }
+        { title: '采购金额', dataIndex: 'shDate', width: 100, align: 'center', customRender: function (text) { return ((text || text == 0) ? text : '--') } },
+        { title: '仓库', dataIndex: 'shD3ate', width: 100, align: 'center' },
+        { title: '仓位', dataIndex: 'shDaste', width: 100, align: 'center' }
       ],
       // 加载数据方法 必须为 Promise 对象
       loadData: parameter => {
         this.disabled = true
-        // return customerBundleDelayList( Object.assign(parameter, this.queryParam) ).then(res => {
-        //   const data = res.data
-        //   const no = (data.pageNo - 1) * data.pageSize
-        //   for (var i = 0; i < data.list.length; i++) {
-        //     data.list[i].no = no + i + 1
-        //   }
-        //   this.disabled = false
-        //   return data
-        // })
-        const _this = this
-        return new Promise(function (resolve, reject) {
-          const data = {
-            pageNo: 1,
-            pageSize: 10,
-            list: [
-              { id: '1', purchaseNo: 'jgqp11111111111', creatDate: '产品1', custName: 'jgqp111123545', totalP: '箭冠品牌', totalNums: '产品分类1', totalPrice: '5', payType: '122' }
-            ],
-            count: 10
-          }
+        return sparePartsPurDetailList(Object.assign(parameter, this.queryParam)).then(res => {
+          const data = res.data
           const no = (data.pageNo - 1) * data.pageSize
           for (var i = 0; i < data.list.length; i++) {
             data.list[i].no = no + i + 1
           }
-          _this.disabled = false
-          resolve(data)
+          this.disabled = false
+          return data
         })
-      }
+      },
+      basicInfoData: null //  基本信息
     }
   },
   methods: {
     //  返回列表
     handleBack () {
       this.$router.push({ path: '/bulkManagement/bulkWarehousingOrder/list' })
+    },
+    // 基本信息
+    getDetail () {
+      sparePartsPurDetail({ id: this.$route.params.id }).then(res => {
+        if (res.status == 200) {
+          this.basicInfoData = res.data
+        } else {
+          this.basicInfoData = null
+        }
+      })
     }
+  },
+  beforeRouteEnter (to, from, next) {
+    next(vm => {
+      vm.openModal = false
+      vm.getDetail()
+    })
   }
 }
 </script>

+ 415 - 126
src/views/bulkManagement/bulkWarehousingOrder/edit.vue

@@ -1,34 +1,25 @@
 <template>
   <div class="bulkWarehousingOrderEdit-wrap">
     <!-- 内容 -->
-    <a-page-header :ghost="false" @back="handleBack" >
+    <a-page-header :ghost="false" :backIcon="false" class="bulkWarehousingOrderEdit-cont" >
       <!-- 自定义的二级文字标题 -->
       <template slot="subTitle">
-        <a id="bulkWarehousingOrderDetail-back-btn" href="javascript:;" @click="handleBack">返回列表</a>
+        <a id="bulkWarehousingOrderEdit-back-btn" href="javascript:;" @click="handleBack"><a-icon type="left" /> 返回列表</a>
+        <p style=" display: inline-block;margin: 0 0 0 60px;color: #000;font-size: 16px;font-weight: 600;">单号:{{ (basicInfoData&&basicInfoData.sparePartsPurchaseSn) || '' }}</p>
       </template>
       <!-- 操作区,位于 title 行的行尾 -->
       <template slot="extra">
-        <a-button key="2" id="bulkWarehousingOrderDetail-preview-btn">打印预览</a-button>
-        <a-button key="1" type="primary" id="bulkWarehousingOrderDetail-print-btn">快速打印</a-button>
+        <a-button key="2" id="bulkWarehousingOrderEdit-preview-btn">打印预览</a-button>
+        <a-button key="1" type="primary" id="bulkWarehousingOrderEdit-print-btn">快速打印</a-button>
       </template>
     </a-page-header>
-    <!-- 内容 -->
-    <a-page-header title="单号:CG2021010100001" ></a-page-header>
-
     <!-- 基础信息 -->
     <a-card size="small" :bordered="false" class="bulkWarehousingOrderEdit-cont">
       <a-collapse :activeKey="['1']">
         <a-collapse-panel key="1">
           <template slot="header">
             基础信息
-            <!-- <a-button
-              type="primary"
-              shape="circle"
-              size="small"
-              icon="edit"
-              class="edit-circle-btn"
-              id="bulkWarehousingOrderEdit-edit-circle-btn"
-              @click.stop="handleEditInfo" /> -->
+            <!-- <a-button type="primary" shape="circle" size="small" icon="edit" class="edit-circle-btn" id="bulkWarehousingOrderEdit-edit-circle-btn" @click.stop="handleEditInfo" /> -->
           </template>
           <a-descriptions :column="3">
             <a-descriptions-item label="供应商">{{ (basicInfoData&&basicInfoData.supplierName) || '--' }}</a-descriptions-item>
@@ -53,51 +44,60 @@
                 <a-row :gutter="15">
                   <a-col :md="6" :sm="24">
                     <a-form-item label="关键词">
-                      <a-input id="bulkWarehousingOrderEdit-bundleName" v-model.trim="queryParam.bundleName" allowClear placeholder="产品名称/产品编码/原厂编码"/>
+                      <a-input id="bulkWarehousingOrderEdit-queryWord" v-model.trim="queryParam.queryWord" allowClear placeholder="产品名称/产品编码/原厂编码"/>
                     </a-form-item>
                   </a-col>
                   <a-col :md="6" :sm="24">
                     <a-form-item label="产品品牌">
                       <a-select
-                        placeholder="请选择"
-                        id="bulkWarehousingOrderEdit-state"
+                        placeholder="请选择产品品牌"
+                        id="bulkWarehousingOrderEdit-productBrandSn"
                         allowClear
-                        v-model="queryParam.dataSourceNo"
+                        v-model="queryParam.productBrandSn"
                         :showSearch="true"
                         option-filter-prop="children"
                         :filter-option="filterOption">
-                        <a-select-option v-for="item in brandData" :key="item.salesChannelNo" :value="item.salesChannelNo">{{ item.salesChannelName }}</a-select-option>
+                        <a-select-option v-for="item in productBrandList" :key="item.brandSn" :value="item.brandSn">{{ item.brandName }}</a-select-option>
                       </a-select>
                     </a-form-item>
                   </a-col>
                   <a-col :md="6" :sm="24">
-                    <a-form-item label="产品类别">
-                      <a-cascader :options="typeData" id="bulkWarehousingOrderEdit-state" placeholder="请选择产品类别" allowClear v-model="queryParam.brand" />
+                    <a-form-item label="产品分类">
+                      <a-cascader
+                        @change="changeProductType"
+                        change-on-select
+                        v-model="productType"
+                        :options="productTypeList"
+                        :fieldNames="{ label: 'productTypeName', value: 'productTypeSn', children: 'children' }"
+                        id="productInfoList-productType"
+                        placeholder="请选择产品分类"
+                        allowClear />
                     </a-form-item>
                   </a-col>
                   <a-col :md="6" :sm="24">
-                    <a-button style="margin-bottom: 18px;" type="primary" @click="$refs.table.refresh(true)" :disabled="disabled" id="bulkWarehousingOrderEdit-refresh">查询</a-button>
+                    <a-button style="margin-bottom: 18px;" type="primary" @click="getDealerProductList(1)" :disabled="disabled" id="bulkWarehousingOrderEdit-refresh">查询</a-button>
                     <a-button style="margin: 0 0 18px 8px" @click="resetSearchForm" :disabled="disabled" id="bulkWarehousingOrderEdit-reset">重置</a-button>
                   </a-col>
                 </a-row>
               </a-form>
             </div>
             <!-- 列表 -->
-            <s-table
+            <a-table
               class="sTable"
               ref="table"
               size="small"
               :rowKey="(record) => record.id"
               :columns="columns"
               :customRow="handleClickRow"
-              :data="loadData"
-              :scroll="{ x: 1700, y: 300 }"
+              :dataSource="loadData"
+              :scroll="{ x: 1780, y: 300 }"
+              :pagination="paginationProps"
               bordered>
               <!-- 成本价 -->
-              <template slot="costPrice" slot-scope="text, record">
+              <template slot="putCost" slot-scope="text, record">
                 <a-input-number
-                  id="bulkWarehousingOrderEdit-costPrice"
-                  v-model="record.costPrice"
+                  id="bulkWarehousingOrderEdit-putCost"
+                  v-model="record.putCost"
                   :precision="2"
                   :min="0"
                   :max="999999"
@@ -105,10 +105,10 @@
                   style="width: 100%;" />
               </template>
               <!-- 数量 -->
-              <template slot="quantity" slot-scope="text, record">
+              <template slot="putQty" slot-scope="text, record">
                 <a-input-number
-                  id="bulkWarehousingOrderEdit-quantity"
-                  v-model="record.quantity"
+                  id="bulkWarehousingOrderEdit-putQty"
+                  v-model="record.putQty"
                   :precision="0"
                   :min="0"
                   :max="999999"
@@ -116,22 +116,27 @@
                   style="width: 100%;" />
               </template>
               <!-- 仓库 -->
-              <template slot="warehouse" slot-scope="text, record">
-                <a-select id="bulkWarehousingOrderEdit-warehouse" placeholder="请选择" allowClear v-model="record.warehouse" style="width: 100%;">
+              <template slot="warehouseSn" slot-scope="text, record, index">
+                <a-select
+                  id="bulkWarehousingOrderEdit-warehouseSn"
+                  placeholder="请选择"
+                  @change="warehouseChange(record, index)"
+                  v-model="record.warehouseSn"
+                  style="width: 100%;">
                   <a-select-option v-for="item in warehouseList" :key="item.warehouseSn" :value="item.warehouseSn">{{ item.name }}</a-select-option>
                 </a-select>
               </template>
               <!-- 仓位 -->
-              <template slot="position" slot-scope="text, record">
-                <a-select id="bulkWarehousingOrderEdit-position" placeholder="请选择" allowClear v-model="record.position" style="width: 100%;">
-                  <a-select-option v-for="item in warehouseList" :key="item.salesChannelNo" :value="item.salesChannelNo">{{ item.name }}</a-select-option>
+              <template slot="warehouseLocationSn" slot-scope="text, record, index">
+                <a-select id="bulkWarehousingOrderEdit-warehouseLocationSn" placeholder="请选择" v-model="record.warehouseLocationSn" style="width: 100%;">
+                  <a-select-option v-for="item in warehouseLocList[index]" :key="item.warehouseLocationSn" :value="item.warehouseLocationSn">{{ item.name }}</a-select-option>
                 </a-select>
               </template>
               <!-- 操作 -->
               <template slot="action" slot-scope="text, record">
                 <a-button size="small" type="primary" class="button-primary" @click="handleAdd(record)" id="bulkWarehousingOrderEdit-add-btn">添加</a-button>
               </template>
-            </s-table>
+            </a-table>
           </div>
         </a-collapse-panel>
       </a-collapse>
@@ -151,55 +156,71 @@
               <div slot="message">总款数 <strong>{{ (productTotal&&productTotal.productTotalCategory) || 0 }}</strong> ,总数量 <strong>{{ (productTotal&&productTotal.productTotalQty) || 0 }}</strong> ,总成本¥<strong>{{ (productTotal&&productTotal.productTotalCost) || 0 }}</strong></div>
             </a-alert>
             <!-- 列表 -->
-            <s-table
+            <a-table
               class="sTable"
-              ref="table"
+              ref="chooseTable"
               size="small"
               :rowKey="(record) => record.id"
               :columns="chooseColumns"
-              :data="chooseLoadData"
+              :dataSource="chooseLoadData"
+              :scroll="{ x: 1880, y: 300 }"
+              :pagination="choosePaginationProps"
               bordered>
               <!-- 成本价 -->
-              <template slot="costPrice" slot-scope="text, record">
+              <template slot="putCost" slot-scope="text, record">
                 <a-input-number
-                  id="bulkWarehousingOrderEdit-costPrice"
-                  v-model="record.costPrice"
+                  id="bulkWarehousingOrderEdit-choose-putCost"
+                  v-model="record.putCost"
                   :precision="2"
                   :min="0"
                   :max="999999"
-                  placeholder="请输入" />
+                  placeholder="请输入"
+                  @blur="e => putCostChange(e.target.value, record)"
+                  style="width: 100%;" />
               </template>
               <!-- 数量 -->
-              <template slot="quantity" slot-scope="text, record">
+              <template slot="putQty" slot-scope="text, record">
                 <a-input-number
-                  id="bulkWarehousingOrderEdit-quantity"
-                  v-model="record.quantity"
+                  id="bulkWarehousingOrderEdit-choose-putQty"
+                  v-model="record.putQty"
                   :precision="0"
                   :min="0"
                   :max="999999"
-                  placeholder="请输入" />
+                  placeholder="请输入"
+                  @blur="e => putQtyChange(e.target.value, record)"
+                  style="width: 100%;" />
               </template>
               <!-- 仓库 -->
-              <template slot="warehouse" slot-scope="text, record">
-                <a-select id="bulkWarehousingOrderEdit-warehouse" placeholder="请选择" allowClear v-model="record.warehouse">
-                  <a-select-option v-for="item in warehouseList" :key="item.salesChannelNo" :value="item.salesChannelNo">{{ item.salesChannelName }}</a-select-option>
+              <template slot="warehouseSn" slot-scope="text, record, index">
+                <a-select
+                  id="bulkWarehousingOrderEdit-choose-warehouseSn"
+                  placeholder="请选择"
+                  @change="chooseWarehouseChange(record, index)"
+                  v-model="record.warehouseSn"
+                  style="width: 100%;">
+                  <a-select-option v-for="item in chooseWarehouseList" :key="item.warehouseSn" :value="item.warehouseSn">{{ item.name }}</a-select-option>
                 </a-select>
               </template>
               <!-- 仓位 -->
-              <template slot="position" slot-scope="text, record">
-                <a-select id="bulkWarehousingOrderEdit-position" placeholder="请选择" allowClear v-model="record.position">
-                  <a-select-option v-for="item in customeList" :key="item.salesChannelNo" :value="item.salesChannelNo">{{ item.salesChannelName }}</a-select-option>
+              <template slot="warehouseLocationSn" slot-scope="text, record, index">
+                <a-select id="bulkWarehousingOrderEdit-choose-warehouseLocationSn" placeholder="请选择" @change="chooseWarehouseLocChange(record)" v-model="record.warehouseLocationSn" style="width: 100%;">
+                  <a-select-option v-for="item in chooseWarehouseLocList[index]" :key="item.warehouseLocationSn" :value="item.warehouseLocationSn">{{ item.name }}</a-select-option>
                 </a-select>
               </template>
               <!-- 操作 -->
               <template slot="action" slot-scope="text, record">
-                <a-button size="small" type="primary" @click="handleDel(record)" id="bulkWarehousingOrderEdit-del-btn">删除</a-button>
+                <a-button size="small" type="primary" class="button-error" @click="handleDel(record)" id="bulkWarehousingOrderEdit-del-btn">删除</a-button>
               </template>
-            </s-table>
+            </a-table>
           </div>
         </a-collapse-panel>
       </a-collapse>
     </a-card>
+    <a-affix :offset-bottom="0">
+      <div style="text-align: center;width: 100%;background-color: #fff;padding: 30px 0;box-shadow: 0 0 20px #dcdee2;">
+        <a-button type="primary" id="bulkWarehousingOrderEdit-submit" size="large" @click="handleSubmit" style="padding: 0 60px;">提交</a-button>
+      </div>
+    </a-affix>
     <!-- 选择基本信息弹框 -->
     <basic-info-modal :openModal="openModal" @ok="handleOk" @close="openModal=false" />
   </div>
@@ -208,77 +229,81 @@
 <script>
 import { STable, VSelect } from '@/components'
 import basicInfoModal from './basicInfoModal.vue'
-import { sparePartsPurDetail, sparePartsPurDetailList, sparePartsPurDetailCount } from '@/api/sparePartsPur'
+import { getOperationalPrecision } from '@/libs/tools.js'
+import { dealerProductBrandQuery } from '@/api/dealerProductBrand'
+import { dealerProductTypeList } from '@/api/dealerProductType'
+import { sparePartsPurDetail, sparePartsPurDetailList, sparePartsPurDetailCount, sparePartsPurDetailSave, sparePartsPurDetailDel, sparePartsPurSubmit } from '@/api/sparePartsPur'
 import { dealerProductList } from '@/api/dealerProduct'
-import { warehouseAllList } from '@/api/warehouse'
+import { warehouseAllList, warehouseLocAllList } from '@/api/warehouse'
 export default {
   components: { STable, VSelect, basicInfoModal },
   data () {
     return {
       queryParam: {
-        productBrandSn: undefined
-        // productBrandSn: undefined,
+        queryWord: '',
+        productBrandSn: undefined,
+        productTypeSn1: undefined,
+        productTypeSn2: undefined,
+        productTypeSn3: undefined
       },
-      brandData: [], //  产品品牌  下拉数据
-      typeData: [], //  产品类别  下拉数据
+      productBrandList: [], //  产品品牌  下拉数据
+      productTypeList: [], //  产品分类  下拉数据
+      productType: [],
       disabled: false, //  查询、重置按钮是否可操作
       // 表头
       columns: [
+        { title: '序号', dataIndex: 'no', width: 80, align: 'center' },
         { title: '产品编码', dataIndex: 'code', width: 200, align: 'center', sorter: true, customRender: function (text) { return text || '--' } },
         { title: '产品名称', dataIndex: 'name', align: 'center', customRender: function (text) { return text || '--' } },
         { title: '原厂编码', dataIndex: 'origCode', width: 200, align: 'center', customRender: function (text) { return text || '--' } },
         { title: '产品品牌', dataIndex: 'productBrandName', width: 200, align: 'center', sorter: true, customRender: function (text) { return text || '--' } },
         { title: '单位', dataIndex: 'unit', width: 100, align: 'center', customRender: function (text) { return text || '--' } },
-        { title: '成本价', scopedSlots: { customRender: 'costPrice' }, width: 150, align: 'center' },
-        { title: '数量', scopedSlots: { customRender: 'quantity' }, width: 150, align: 'center' },
-        { title: '仓库', scopedSlots: { customRender: 'warehouse' }, width: 200, align: 'center' },
-        { title: '仓位', scopedSlots: { customRender: 'position' }, width: 200, align: 'center' },
+        { title: '成本价', scopedSlots: { customRender: 'putCost' }, width: 150, align: 'center' },
+        { title: '数量', scopedSlots: { customRender: 'putQty' }, width: 150, align: 'center' },
+        { title: '仓库', scopedSlots: { customRender: 'warehouseSn' }, width: 200, align: 'center' },
+        { title: '仓位', scopedSlots: { customRender: 'warehouseLocationSn' }, width: 200, align: 'center' },
         { title: '操作', scopedSlots: { customRender: 'action' }, width: 100, align: 'center', fixed: 'right' }
       ],
-      // 加载数据方法 必须为 Promise 对象
-      loadData: parameter => {
-        this.disabled = true
-        return dealerProductList(Object.assign(parameter, this.queryParam)).then(res => {
-          const data = res.data
-          const no = (data.pageNo - 1) * data.pageSize
-          for (var i = 0; i < data.list.length; i++) {
-            data.list[i].no = no + i + 1
-          }
-          this.disabled = false
-          this.getWarehouseList()
-          console.log('--------数据', data)
-          return data
-        })
+      loadData: [],
+      pageNo: 1, //  分页页码
+      pageSize: 10, //  分页 每页多少条
+      paginationProps: {
+        showSizeChanger: true, //  是否可以改变 pageSize
+        total: 0, //  分页总条数
+        current: 1,
+        onShowSizeChange: (current, pageSize) => this.changePageSize(current, pageSize),
+        onChange: (current) => this.changePage(current)
       },
       // 表头
       chooseColumns: [
-        { title: '产品编码', dataIndex: 'creatDate', align: 'center', sorter: true },
-        { title: '产品名称', dataIndex: 'custName', align: 'center' },
-        { title: '原厂编码', dataIndex: 'totalP', align: 'center' },
-        { title: '产品品牌', dataIndex: 'custsName', align: 'center', sorter: true },
-        { title: '单位', dataIndex: 'custsNdame', align: 'center' },
-        { title: '成本价', scopedSlots: { customRender: 'costPrice' }, align: 'center' },
-        { title: '数量', scopedSlots: { customRender: 'quantity' }, align: 'center' },
-        { title: '成本小计', dataIndex: 'custsNdsame', align: 'center' },
-        { title: '仓库', scopedSlots: { customRender: 'warehouse' }, align: 'center' },
-        { title: '仓位', scopedSlots: { customRender: 'position' }, align: 'center' },
-        { title: '操作', scopedSlots: { customRender: 'action' }, width: 150, align: 'center' }
+        { title: '序号', dataIndex: 'no', width: 80, align: 'center' },
+        { title: '产品编码', dataIndex: 'productCode', width: 200, align: 'center', sorter: true },
+        { title: '产品名称', dataIndex: 'productName', align: 'center', customRender: function (text) { return text || '--' } },
+        { title: '原厂编码', dataIndex: 'productOrigCode', width: 200, align: 'center', customRender: function (text) { return text || '--' } },
+        { title: '产品品牌', dataIndex: 'brandName', width: 200, align: 'center', sorter: true, customRender: function (text) { return text || '--' } },
+        { title: '单位', dataIndex: 'productUnit', width: 100, align: 'center', customRender: function (text) { return text || '--' } },
+        { title: '成本价', scopedSlots: { customRender: 'putCost' }, width: 150, align: 'center' },
+        { title: '数量', scopedSlots: { customRender: 'putQty' }, width: 150, align: 'center' },
+        { title: '成本小计', dataIndex: 'costSubtotal', width: 100, align: 'center' },
+        { title: '仓库', scopedSlots: { customRender: 'warehouseSn' }, width: 200, align: 'center' },
+        { title: '仓位', scopedSlots: { customRender: 'warehouseLocationSn' }, width: 200, align: 'center' },
+        { title: '操作', scopedSlots: { customRender: 'action' }, width: 100, align: 'center', fixed: 'right' }
       ],
-      // 加载数据方法 必须为 Promise 对象
-      chooseLoadData: parameter => {
-        this.disabled = true
-        return sparePartsPurDetailList(Object.assign(parameter, { sparePartsPurchaseSn: this.$route.params.sn })).then(res => {
-          const data = res.data
-          const no = (data.pageNo - 1) * data.pageSize
-          for (var i = 0; i < data.list.length; i++) {
-            data.list[i].no = no + i + 1
-          }
-          this.disabled = false
-          return data
-        })
+      chooseLoadData: [],
+      choosePageNo: 1, //  分页页码
+      choosePageSize: 10, //  分页 每页多少条
+      choosePaginationProps: {
+        showSizeChanger: true, //  是否可以改变 pageSize
+        total: 0, //  分页总条数
+        current: 1,
+        onShowSizeChange: (current, pageSize) => this.changeChoosePageSize(current, pageSize),
+        onChange: (current) => this.changeChoosePage(current)
       },
       openModal: false, // 选择基本信息弹框是否显示
       warehouseList: [], //  仓库  下拉数据
+      warehouseLocList: {}, //  仓位  下拉数据
+      chooseWarehouseList: [], //  已选产品 仓库  下拉数据
+      chooseWarehouseLocList: {}, //  已选产品 仓位  下拉数据
       basicInfoData: null, //  基本信息
       productTotal: null //  合计
     }
@@ -286,25 +311,47 @@ export default {
   methods: {
     //  重置
     resetSearchForm () {
-      this.queryParam.orderBundleNo = ''
-      this.queryParam.orderBundle.custMobile = ''
-      this.queryParam.bundleName = ''
-      this.queryParam.itemName = ''
-      this.oldTime = undefined
-      this.newTime = undefined
-      this.$refs.table.refresh(true)
+      this.queryParam.queryWord = ''
+      this.queryParam.productBrandSn = undefined
+      this.queryParam.productTypeSn1 = ''
+      this.queryParam.productTypeSn2 = ''
+      this.queryParam.productTypeSn3 = ''
+      this.productType = []
+      this.getDealerProductList(1)
     },
     // 双击快速添加
     handleClickRow (record) {
       return {
         on: {
           dblclick: (event) => {
-            console.log(record)
+            this.handleAdd(record)
           }
         }
       }
     },
-    // 获取详情
+    //  分页  一页多少条change
+    changePageSize (current, pageSize) {
+      this.pageNo = current
+      this.pageSize = pageSize
+      this.getDealerProductList()
+    },
+    //  分页 页码change
+    changePage (current) {
+      this.pageNo = current
+      this.getDealerProductList()
+    },
+    //  已选产品 分页  一页多少条change
+    changeChoosePageSize (current, pageSize) {
+      this.choosePageNo = current
+      this.choosePageSize = pageSize
+      this.getChooseDealerProductList()
+    },
+    //  已选产品 分页 页码change
+    changeChoosePage (current) {
+      this.choosePageNo = current
+      this.getChooseDealerProductList()
+    },
+    // 基本信息
     getDetail () {
       sparePartsPurDetail({ id: this.$route.params.id }).then(res => {
         if (res.status == 200) {
@@ -314,18 +361,80 @@ export default {
         }
       })
     },
-    //  添加
-    handleAdd (row) {},
+    //  添加/编辑
+    handleAdd (row, isEdit) {
+      if (!row.putCost) {
+        this.$message.warning('请输入成本价')
+        return
+      }
+      if (!row.putQty) {
+        this.$message.warning('请输入数量')
+        return
+      }
+      if (!row.warehouseSn) {
+        this.$message.warning('请选择仓库')
+        return
+      }
+      if (!row.warehouseLocationSn) {
+        this.$message.warning('请选择仓位')
+        return
+      }
+      const params = {
+        id: isEdit ? row.id : undefined,
+        sparePartsPurchaseSn: this.$route.params.sn,
+        putCost: row.putCost,
+        putQty: row.putQty,
+        productCode: isEdit ? row.productCode : row.code,
+        productOrigCode: (isEdit ? row.productOrigCode : row.origCode) || undefined,
+        productSn: row.productSn,
+        productTypeSn1: row.productTypeSn1,
+        productTypeSn2: row.productTypeSn2,
+        productTypeSn3: row.productTypeSn3,
+        brandSn: isEdit ? row.brandSn : row.productBrandSn,
+        warehouseLocationSn: row.warehouseLocationSn,
+        warehouseSn: row.warehouseSn
+      }
+      sparePartsPurDetailSave(params).then(res => {
+        if (res.status == 200) {
+          this.getChooseDealerProductList()
+        }
+      })
+    },
+    //  提交
+    handleSubmit () {
+      const _this = this
+      sparePartsPurSubmit({ id: this.$route.params.id }).then(res => {
+        if (res.status == 200) {
+          this.$message.success(res.message)
+          setTimeout(() => {
+            _this.handleBack()
+          }, 1000)
+        }
+      })
+    },
     //  删除
-    handleDel (row) {},
+    handleDel (row) {
+      const _this = this
+      this.$confirm({
+        title: '提示',
+        content: '删除后不可恢复,确定要进行删除吗?',
+        centered: true,
+        onOk () {
+          sparePartsPurDetailDel({ id: row.id }).then(res => {
+            if (res.status == 200) {
+              _this.$message.success(res.message)
+              _this.getChooseDealerProductList()
+            }
+          })
+        }
+      })
+    },
     //  编辑基本信息
     handleEditInfo () {
       this.openModal = true
     },
     //  基本信息  保存
-    handleOk () {
-
-    },
+    handleOk () {},
     //  导入明细
     handleImport () {
       console.log(333)
@@ -335,25 +444,201 @@ export default {
       this.$router.push({ path: '/bulkManagement/bulkWarehousingOrder/list' })
     },
     // 仓库下拉数据
-    getWarehouseList () {
+    getWarehouseList (type) {
       warehouseAllList({}).then(res => {
         if (res.status == 200) {
-          this.warehouseList = res.data
-          const defaultFlagInd = this.warehouseList.findIndex(item => item.defaultFlag == 1)
-          console.log(defaultFlagInd, this.loadData)
-          // this.loadData.map(item => {
-          //   item.warehouse = this.warehouseList[defaultFlagInd].warehouseSn
-          // })
+          if (type == 'dealerProduct') { //  全部产品
+            this.warehouseList = res.data
+            const defaultFlagInd = this.warehouseList.findIndex(item => item.defaultFlag == 1)
+            this.loadData.map((item, index) => {
+              // 全部产品中,仓库默认值为默认仓库,则仓位必然也为默认仓位,因此可批量设置默认仓位的值 all
+              // 解决更改后不实时渲染问题
+              this.$set(item, 'warehouseSn', this.warehouseList[defaultFlagInd].warehouseSn)
+              this.$set(item, 'nowWarehouseSn', this.warehouseList[defaultFlagInd].warehouseSn) // 所选仓库sn(为记录上一所选仓库sn)
+              // 每个仓库对应仓位应是独立的
+              this.getWarehouseLocList(this.warehouseList[defaultFlagInd].warehouseSn, index, type, 'all')
+            })
+          } else if (type == 'sparePartsPurDetail') { //  已选产品
+            this.chooseWarehouseList = res.data
+            this.chooseLoadData.map((item, index) => {
+              // 每个仓库对应仓位应是独立的
+              this.getWarehouseLocList(item.warehouseSn, index, type)
+            })
+          }
         } else {
           this.warehouseList = []
+          this.chooseWarehouseList = []
+          this.loadData.map(item => {
+            this.$set(item, 'warehouseSn', undefined)
+            this.$set(item, 'nowWarehouseSn', undefined)
+            this.$set(item, 'warehouseLocationSn', undefined)
+          })
+        }
+      })
+    },
+    // 仓位下拉数据
+    getWarehouseLocList (warehouseSn, ind, type, isAll, isChange) {
+      // warehouseSn仓库sn、ind当前数据下标、type为全部产品或已选产品、isAll为是否设置全部产品内全部仓位的值为默认仓位、isChange为仓库是否change
+      warehouseLocAllList({ warehouseSn: warehouseSn }).then(res => {
+        if (res.status == 200) {
+          //  处理 全部产品和已选产品以及是否有默认仓位下的不同情况
+          this.defaultLocationSet(ind, type, res.data, isAll, isChange)
+        } else {
+          this.$set(this.warehouseLocList, ind, [])
+          this.$set(this.chooseWarehouseLocList, ind, [])
+          this.loadData.map(item => {
+            this.$set(item, 'warehouseLocationSn', undefined)
+          })
+          this.chooseLoadData.map(item => {
+            this.$set(item, 'warehouseLocationSn', undefined)
+          })
         }
       })
     },
+    defaultLocationSet (ind, type, data, isAll, isChange) {
+      let warehouseLocList
+      let loadData
+      if (type == 'dealerProduct') { //  全部产品
+        warehouseLocList = this.warehouseLocList
+        loadData = this.loadData
+      } else if (type == 'sparePartsPurDetail') { //  已选产品
+        warehouseLocList = this.chooseWarehouseLocList
+        loadData = this.chooseLoadData
+      }
+      this.$set(warehouseLocList, ind, data)
+      const defaultFlagInd = warehouseLocList[ind].findIndex(item => item.defaultFlag == 1)
+      //  有默认仓位则默认选择默认仓位,无默认仓位则默认选择第一个仓位
+      if (defaultFlagInd > -1) { //  有默认仓位
+        if (isAll == 'all') { //  批量设置默认仓位的值为默认仓位
+          loadData.map(item => {
+            this.$set(item, 'warehouseLocationSn', warehouseLocList[ind][defaultFlagInd].warehouseLocationSn)
+          })
+        } else {
+          this.$set(loadData[ind], 'warehouseLocationSn', warehouseLocList[ind][defaultFlagInd].warehouseLocationSn)
+        }
+        loadData[ind].nowWarehouseSn = loadData[ind].warehouseSn
+      } else { //  无默认仓位
+        if (warehouseLocList[ind].length > 0) {
+          loadData[ind].warehouseLocationSn = warehouseLocList[ind][0].warehouseLocationSn
+          loadData[ind].nowWarehouseSn = loadData[ind].warehouseSn
+        } else {
+          this.$message.warning('当前仓库无仓位,请选择其他仓库')
+          loadData[ind].warehouseSn = loadData[ind].nowWarehouseSn
+          this.getWarehouseLocList(loadData[ind].warehouseSn, ind, type)
+        }
+      }
+      //  仓库更改时,应与仓位一齐变更
+      if (isChange == 'change' && type == 'sparePartsPurDetail' && warehouseLocList[ind].length > 0) { // 设置已选产品仓库变更时更新数据
+        this.handleAdd(loadData[ind], 'edit')
+      }
+    },
     // 合计
     getDetailCount () {
       sparePartsPurDetailCount({ sparePartsPurchaseSn: this.$route.params.sn }).then(res => {
         if (res.status == 200) {
           this.productTotal = res.data
+        } else {
+          this.productTotal = null
+        }
+      })
+    },
+    // 仓库change
+    warehouseChange (record, index) {
+      this.loadData[index].warehouseLocationSn = undefined
+      this.getWarehouseLocList(this.loadData[index].warehouseSn, index, 'dealerProduct')
+    },
+    // 已选产品 成本价  change
+    putCostChange (val, record) {
+      this.handleAdd(record, 'edit')
+    },
+    // 已选产品 数量  change
+    putQtyChange (val, record) {
+      this.handleAdd(record, 'edit')
+    },
+    // 已选产品 仓库  change
+    chooseWarehouseChange (record, index) {
+      this.chooseLoadData[index].warehouseLocationSn = undefined
+      //  仓库仓位为联动更改,因此应在设置仓位后再进行更改
+      this.getWarehouseLocList(this.chooseLoadData[index].warehouseSn, index, 'sparePartsPurDetail', undefined, 'change')
+    },
+    // 已选产品 仓位  change
+    chooseWarehouseLocChange (record) {
+      this.handleAdd(record, 'edit')
+    },
+    //  产品分类  change
+    changeProductType (val, opt) {
+      this.queryParam.productTypeSn1 = val[0] ? val[0] : ''
+      this.queryParam.productTypeSn2 = val[1] ? val[1] : ''
+      this.queryParam.productTypeSn3 = val[2] ? val[2] : ''
+    },
+    // 产品列表数据
+    getDealerProductList (pageNo) {
+      this.disabled = true
+      this.pageNo = pageNo || this.pageNo
+      const params = Object.assign({ pageNo: this.pageNo, pageSize: this.pageSize }, this.queryParam)
+      dealerProductList(params).then(res => {
+        if (res.status == 200) {
+          const data = res.data
+          this.paginationProps.total = Number(res.data.count) || 0
+          this.paginationProps.current = this.pageNo
+          const no = (data.pageNo - 1) * data.pageSize
+          for (var i = 0; i < data.list.length; i++) {
+            data.list[i].no = no + i + 1
+          }
+          this.loadData = data.list
+          this.getWarehouseList('dealerProduct')
+          this.disabled = false
+        } else {
+          this.paginationProps.total = 0
+          this.paginationProps.current = 1
+          this.loadData = []
+        }
+      })
+    },
+    // 已选产品列表数据
+    getChooseDealerProductList () {
+      const params = {
+        pageNo: this.choosePageNo,
+        pageSize: this.choosePageSize,
+        sparePartsPurchaseSn: this.$route.params.sn
+      }
+      sparePartsPurDetailList(params).then(res => {
+        if (res.status == 200) {
+          const data = res.data
+          this.choosePaginationProps.total = Number(res.data.count) || 0
+          this.choosePaginationProps.current = this.pageNo
+          const no = (data.pageNo - 1) * data.pageSize
+          for (var i = 0; i < data.list.length; i++) {
+            data.list[i].no = no + i + 1
+            // 成本小计  由于数据库内小数位数为4位,页面则需显示2位。因此会做小数运算精度处理
+            data.list[i].costSubtotal = getOperationalPrecision(data.list[i].putCost, data.list[i].putQty)
+          }
+          this.chooseLoadData = data.list
+          this.getWarehouseList('sparePartsPurDetail')
+        } else {
+          this.choosePaginationProps.total = 0
+          this.choosePaginationProps.current = 1
+          this.chooseLoadData = []
+        }
+      })
+    },
+    //  产品品牌  列表
+    getProductBrand () {
+      dealerProductBrandQuery({ 'sysFlag': '0' }).then(res => {
+        if (res.status == 200) {
+          this.productBrandList = res.data
+        } else {
+          this.productBrandList = []
+        }
+      })
+    },
+    //  产品分类  列表
+    getProductType () {
+      dealerProductTypeList({ 'sysFlag': '0' }).then(res => {
+        if (res.status == 200) {
+          this.productTypeList = res.data
+        } else {
+          this.productTypeList = []
         }
       })
     },
@@ -367,7 +652,11 @@ export default {
     next(vm => {
       vm.openModal = false
       vm.getDetail()
+      vm.getDealerProductList()
       vm.getDetailCount()
+      vm.getChooseDealerProductList()
+      vm.getProductBrand()
+      vm.getProductType()
     })
   }
 }

+ 35 - 23
src/views/bulkManagement/bulkWarehousingOrder/list.vue

@@ -98,9 +98,27 @@
       </template>
       <!-- 操作 -->
       <template slot="action" slot-scope="text, record">
-        <a-button size="small" type="primary" @click="handleEdit(record)" class="button-info" id="bulkWarehousingOrderList-edit-btn">编辑</a-button>
-        <a-button size="small" type="primary" @click="handleWarehouse(record)" class="button-warning" id="bulkWarehousingOrderList-warehouse-btn">入库</a-button>
-        <a-button size="small" type="primary" @click="handleDel(record)" class="button-error" id="bulkWarehousingOrderList-del-btn">删除</a-button>
+        <a-button
+          size="small"
+          type="primary"
+          v-if="record.state != 'FINISH'"
+          @click="handleEdit(record)"
+          class="button-info"
+          id="bulkWarehousingOrderList-edit-btn">编辑</a-button>
+        <a-button
+          size="small"
+          type="primary"
+          v-if="record.state == 'WAIT_PUT_WAREHOUSE'"
+          @click="handleWarehouse(record)"
+          class="button-warning"
+          id="bulkWarehousingOrderList-warehouse-btn">入库</a-button>
+        <a-button
+          size="small"
+          type="primary"
+          v-if="record.state != 'FINISH'"
+          @click="handleDel(record)"
+          class="button-error"
+          id="bulkWarehousingOrderList-del-btn">删除</a-button>
       </template>
     </s-table>
     <!-- 选择基本信息弹框 -->
@@ -112,7 +130,7 @@
 import moment from 'moment'
 import { STable, VSelect } from '@/components'
 import basicInfoModal from './basicInfoModal.vue'
-import { sparePartsPurList, sparePartsPurCount } from '@/api/sparePartsPur'
+import { sparePartsPurList, sparePartsPurCount, sparePartsPurDel, sparePartsPurPut } from '@/api/sparePartsPur'
 import { supplierAllList } from '@/api/supplier'
 export default {
   components: { STable, VSelect, basicInfoModal },
@@ -196,7 +214,7 @@ export default {
     },
     //  详情
     handleDetail (row) {
-      this.$router.push({ path: `/bulkManagement/bulkWarehousingOrder/detail/${row.id}` })
+      this.$router.push({ path: `/bulkManagement/bulkWarehousingOrder/detail/${row.id}/${row.sparePartsPurchaseSn}` })
     },
     //  入库
     handleWarehouse (row) {
@@ -206,15 +224,12 @@ export default {
         content: '确定是否入库?',
         centered: true,
         onOk () {
-          // delectRolePower({
-          //   id: row.id
-          // }).then(res => {
-          //   console.log(res, 'res1111')
-          //   if (res.status == 200) {
-          //     _this.$message.success(res.message)
-          //     _this.$refs.table.refresh()
-          //   }
-          // })
+          sparePartsPurPut({ id: row.id }).then(res => {
+            if (res.status == 200) {
+              _this.$message.success(res.message)
+              _this.$refs.table.refresh()
+            }
+          })
         }
       })
     },
@@ -226,15 +241,12 @@ export default {
         content: '删除后不可恢复,确定要进行删除吗?',
         centered: true,
         onOk () {
-          // delectRolePower({
-          //   id: row.id
-          // }).then(res => {
-          //   console.log(res, 'res1111')
-          //   if (res.status == 200) {
-          //     _this.$message.success(res.message)
-          //     _this.$refs.table.refresh()
-          //   }
-          // })
+          sparePartsPurDel({ id: row.id }).then(res => {
+            if (res.status == 200) {
+              _this.$message.success(res.message)
+              _this.$refs.table.refresh()
+            }
+          })
         }
       })
     },