Browse Source

bug 修复

lilei 4 years ago
parent
commit
bfd389c7d6

+ 50 - 24
src/views/salesManagement/salesQuery/chooseCustomModal.vue

@@ -19,7 +19,15 @@
     >
       <a-row :gutter="15">
         <a-col :span="8">
-          <a-form-model-item label="客户名称" prop="buyerSn">
+          <a-form-model-item v-if="isNew" label="客户名称" prop="buyerName">
+            <a-input
+              id="chooseCustom-buyerName"
+              :maxLength="60"
+              v-model="form.buyerName"
+              placeholder="请输入客户名称"
+              allowClear />
+          </a-form-model-item>
+          <a-form-model-item v-else label="客户名称" prop="buyerSn">
             <a-select
               id="chooseCustom-buyerSn"
               show-search
@@ -33,9 +41,10 @@
           </a-form-model-item>
         </a-col>
         <a-col :span="16">
-          <a-form-model-item><a-button type="dashed" icon="plus">
-            新增
-          </a-button>(未搜索到客户时点击新增按钮)</a-form-model-item>
+          <a-form-model-item>
+            <a-button type="dashed" @click="custModeChange" :icon="!isNew?'plus':'check'">{{ !isNew?'新增':'选择' }}</a-button>
+            ({{ !isNew?'点击新增按钮直接输入客户名称':'点击选择按钮直接选择客户' }})
+          </a-form-model-item>
         </a-col>
       </a-row>
       <a-row :gutter="15">
@@ -192,6 +201,7 @@ export default {
     return {
       opened: this.show,
       title: '选择客户',
+      isNew: false,
       confirmLoading: false,
       formItemLayout: {
         labelCol: { span: 8 },
@@ -212,9 +222,7 @@ export default {
         fax: '', //  客户传真
         dispatchType: undefined, //  配送方式
         satelliteFlag: 0, //  是否卫星仓客户
-        customerTypeSn: undefined, //  客户类型
         priceType: '', //  价格类型
-        // payType: '', //  支付方式
         settleStyle: '', //  收款方式
         salesManSn: undefined, //  业务员
         salesManName: '',
@@ -223,9 +231,12 @@ export default {
         remarks: '' //  备注
       },
       rules: {
-        buyerSn: [
+        buyerName: [
           { required: true, message: '请输入客户名称', trigger: ['change', 'blur'] }
         ],
+        buyerSn: [
+          { required: true, message: '请选择客户', trigger: ['change', 'blur'] }
+        ],
         consigneeTel: [
           { required: true, message: '请输入联系电话', trigger: 'blur' }
         ],
@@ -242,13 +253,10 @@ export default {
           { required: true, message: '请输入详细地址', trigger: 'blur' }
         ],
         priceType: [
-          { required: true, message: '请选择价格类型', trigger: 'change' }
+          { required: true, message: '请选择价格类型', trigger: ['change', 'blur'] }
         ],
-        // payType: [
-        //   { required: true, message: '请选择支付方式', trigger: 'change' }
-        // ],
         settleStyle: [
-          { required: true, message: '请选择收款方式', trigger: 'change' }
+          { required: true, message: '请选择收款方式', trigger: ['change', 'blur'] }
         ],
         distributionFlag: [
           { required: true, message: '请选择是否铺货出库', trigger: 'change' }
@@ -269,6 +277,13 @@ export default {
     }
   },
   methods: {
+    custModeChange () {
+      this.isNew = !this.isNew
+      this.isEdit = false
+      this.form.buyerName = ''
+      this.$refs.ruleForm.resetFields()
+      this.custId = undefined
+    },
     // 业务员
     salesManChange (id) {
       this.form.salesManName = this.userList.find(item => item.id == id).name
@@ -291,7 +306,6 @@ export default {
               _this.form.buyerName = cust.customerName
               _this.isEdit = false
               _this.getDetail()
-              _this.$emit('updateData')
             }
           })
           return
@@ -303,7 +317,6 @@ export default {
     },
     // 客户 change
     custChange (val) {
-      console.log(val, 'custChange')
       this.$refs.ruleForm.resetFields()
       this.custId = undefined
     },
@@ -314,7 +327,8 @@ export default {
       this.isEdit = true
       if (data.shippingAddressProvinceSn) { this.getArea('city', data.shippingAddressProvinceSn) }
       if (data.shippingAddressCitySn) { this.getArea('district', data.shippingAddressCitySn) }
-      this.form = Object.assign(this.form, data)
+      // this.form = Object.assign(this.form, data)
+      this.form = data
     },
     //  获取详情
     getDetail () {
@@ -338,7 +352,6 @@ export default {
             fax: data.fax, //  客户传真
             dispatchType: data.dispatchType, //  配送方式
             satelliteFlag: data.satelliteFlag, //  是否卫星仓客户
-            customerTypeSn: data.customerTypeSn, //  客户类型
             priceType: data.priceType, //  价格类型
             settleStyle: data.settleStyleSn //  收款方式
           })
@@ -351,8 +364,7 @@ export default {
     },
     // 保存客户信息
     handleSaveCust () {
-      updateByCustomerSn({
-        customerSn: this.form.buyerSn,
+      const params = {
         customerName: this.form.buyerName,
         contactTel: this.form.consigneeTel, //  联系电话
         contactName: this.form.consigneeName, //  联系人
@@ -364,14 +376,25 @@ export default {
         countyName: this.form.shippingAddressCountyName,
         customerAddr: this.form.shippingAddress, //  详细地址
         dispatchType: this.form.dispatchType, //  配送方式
-        customerTypeSn: this.form.customerTypeSn, //  客户类型
         priceType: this.form.priceType, //  价格类型
         settleStyleSn: this.form.settleStyle //  收款方式
-      }).then(res => {
-        if (res.status != 200) {
-          this.$message.error(res.message)
-        }
-      })
+      }
+      // 更新
+      if (this.form.buyerSn) {
+        params.customerSn = this.form.buyerSn
+        updateByCustomerSn(params).then(res => {
+          if (res.status != 200) {
+            this.$message.error(res.message)
+          }
+        })
+      } else {
+        // 新建
+        custSave(params).then(res => {
+          if (res.status != 200) {
+            this.$message.error(res.message)
+          }
+        })
+      }
     },
     //  保存
     handleSubmit (e) {
@@ -398,6 +421,9 @@ export default {
         if (res.status == 200) {
           _this.$message.success(res.message)
           _this.$emit('ok', res.data)
+          if (_this.form.id) {
+            _this.$emit('updateData')
+          }
           _this.cancel()
         }
       })

+ 5 - 5
src/views/salesManagement/salesQuery/detail.vue

@@ -32,8 +32,8 @@
             <a-descriptions-item label="销售单号">{{ detailData.salesBillNo || '--' }}</a-descriptions-item>
             <a-descriptions-item label="制单人">{{ detailData.operatorName || '--' }}</a-descriptions-item>
             <a-descriptions-item label="业务员">{{ detailData.salesManName || '--' }}</a-descriptions-item>
-            <a-descriptions-item label="业务状态">{{ detailData.auditStatus || '--' }}</a-descriptions-item>
-            <a-descriptions-item label="财务状态">{{ detailData.financialStatus || '--' }}</a-descriptions-item>
+            <a-descriptions-item label="业务状态">{{ detailData.billStatusDictValue || '--' }}</a-descriptions-item>
+            <a-descriptions-item label="财务状态">{{ detailData.financialStatusDictValue || '--' }}</a-descriptions-item>
           </a-descriptions>
         </a-collapse-panel>
       </a-collapse>
@@ -88,13 +88,13 @@ export default {
         { title: '产品编码', dataIndex: 'productCode', width: 140, align: 'center' },
         { title: '产品名称', dataIndex: 'productName', align: 'center', customRender: function (text) { return text || '--' }, ellipsis: true },
         { title: '原厂编码', dataIndex: 'productOrigCode', width: 140, align: 'center', customRender: function (text) { return text || '--' } },
-        { title: '成本价', dataIndex: 'costPrice', width: 100, align: 'center', customRender: function (text) { return ((text || text == 0) ? text : '--') } },
+        { title: '成本价', dataIndex: 'cost', width: 100, align: 'center', customRender: function (text) { return ((text || text == 0) ? text : '--') } },
         { title: '售价', dataIndex: 'price', width: 100, align: 'center', customRender: function (text) { return ((text || text == 0) ? text : '--') } },
         { title: '折后售价', dataIndex: 'discountedPrice', width: 100, align: 'center', customRender: function (text) { return ((text || text == 0) ? text : '--') } },
         { title: '销售数量', dataIndex: 'qty', width: 100, align: 'center', customRender: function (text) { return ((text || text == 0) ? text : '--') } },
         { title: '单位', dataIndex: 'productOrigUnit', width: 100, align: 'center', customRender: function (text) { return text || '--' } },
-        { title: '售价小计', dataIndex: 'salePriceSubtotal', width: 100, align: 'center' },
-        { title: '折后小计', dataIndex: 'discountedAmount', width: 100, align: 'center', customRender: function (text) { return ((text || text == 0) ? text : '--') } },
+        { title: '售价小计', dataIndex: 'totalAmount', width: 100, align: 'center' },
+        { title: '折后小计', dataIndex: 'totalCost', width: 100, align: 'center', customRender: function (text) { return ((text || text == 0) ? text : '--') } },
         { title: '折扣金额', dataIndex: 'discountAmount', width: 100, align: 'center', customRender: function (text) { return ((text || text == 0) ? text : '--') } },
         { title: '仓库', dataIndex: 'warehouseName', width: 100, align: 'center' },
         { title: '仓位', dataIndex: 'warehouseLocationName', width: 100, align: 'center' },

+ 37 - 13
src/views/salesManagement/salesQuery/edit.vue

@@ -20,7 +20,7 @@
     <a-card size="small" :bordered="false" class="salesEdit-cont">
       <!-- 总计 -->
       <a-alert style="margin-bottom: 15px;" type="info">
-        <div slot="message">总售价:<strong>6</strong>;总款数:<strong>6</strong>;总数量:<strong>6</strong>;赠品总数量:<strong>6</strong>;</div>
+        <div slot="message">总售价:<strong>{{ detailData&&detailData.totalAmount || 0 }}</strong>;总款数:<strong>{{ detailData&&detailData.totalCategory || 0 }}</strong>;总数量:<strong>{{ detailData&&detailData.totalQty || 0 }}</strong>;赠品总数量:<strong>{{ detailData&&detailData.giftQty || 0 }}</strong>;</div>
       </a-alert>
       <!-- 查询条件 -->
       <a-row :gutter="15">
@@ -81,6 +81,12 @@
         </template>
       </s-table>
     </a-card>
+    <a-card size="small" :bordered="false" class="salesEdit-cont">
+      <!-- 提交按钮 -->
+      <div style="text-align: center;">
+        <a-button size="large" type="primary" class="button-primary" @click="handleSubmit()" id="productInfoList-handleSubmit">提交</a-button>
+      </div>
+    </a-card>
     <!-- 选择客户弹框 -->
     <choose-custom-modal ref="custModal" :show="openModal" @updateData="getOrderDetail" @cancel="openModal=false" />
   </div>
@@ -90,7 +96,7 @@
 import { STable, VSelect } from '@/components'
 import queryPart from './queryPart.vue'
 import chooseCustomModal from './chooseCustomModal.vue'
-import { salesDetail } from '@/api/sales'
+import { salesDetail, salesWriteSubmit } from '@/api/sales'
 import EditableCell from '@/views/common/editInput.js'
 import { salesDetailList, salesDetailInsert, salesDetailUpdatePrice, salesDetailUpdateQty, salesDetailDel, salesDetailDelAll } from '@/api/salesDetail'
 export default {
@@ -101,6 +107,7 @@ export default {
       orderId: null, // 销售单id
       salesBillSn: null, // 销售单sn
       disabled: false, //  查询、重置按钮是否可操作
+      isInster: false, // 是否正在添加产品
       openModal: false, // 客户弹框
       detailData: null, // 订单基础数据
       dataSource: [],
@@ -119,15 +126,15 @@ export default {
         { title: '仓位', dataIndex: 'warehouseLocationEntity.name', width: 100, align: 'center' },
         { title: '售价', scopedSlots: { customRender: 'price' }, width: 150, align: 'center' },
         { title: '销售数量', scopedSlots: { customRender: 'salesNums' }, width: 150, align: 'center' },
-        { title: '单位', dataIndex: 'dealerProductEntity.unit', width: 100, align: 'center' },
-        { title: '售价小计', dataIndex: 'xj', width: 100, align: 'center' },
-        { title: '折后小计', dataIndex: 'zhxj', width: 100, align: 'center' },
+        { title: '单位', dataIndex: 'dealerProductEntity.unit', width: 100, align: 'center', customRender: function (text) { return text || '--' } },
+        { title: '售价小计', dataIndex: 'totalAmount', width: 100, align: 'center', customRender: function (text) { return ('¥' + text) || '--' } },
+        { title: '折后小计', dataIndex: 'discountedAmount', width: 100, align: 'center', customRender: function (text) { return ('¥' + text) || '--' } },
         { title: '操作', scopedSlots: { customRender: 'action' }, width: 170, align: 'center', fixed: 'right' }
       ],
       // 加载数据方法 必须为 Promise 对象
       loadData: parameter => {
         this.disabled = true
-        this.productForm.id = this.$route.params.id
+        this.productForm.salesBillSn = this.$route.params.sn
         return salesDetailList(Object.assign(parameter, this.productForm)).then(res => {
           const data = res.data
           const no = (data.pageNo - 1) * data.pageSize
@@ -158,7 +165,7 @@ export default {
           price: row.price
         }).then(res => {
           if (res.status == 200) {
-            this.$refs.table.refresh(true)
+            this.resetSearchForm(true)
           }
           this.$message.info(res.message)
         })
@@ -169,7 +176,7 @@ export default {
           qty: row.qty
         }).then(res => {
           if (res.status == 200) {
-            this.$refs.table.refresh(true)
+            this.resetSearchForm(true)
           }
           this.$message.info(res.message)
         })
@@ -181,12 +188,13 @@ export default {
       this.$refs.custModal.editCust(this.detailData)
     },
     //  重置
-    resetSearchForm () {
-      this.$refs.table.refresh()
+    resetSearchForm (flag) {
+      this.$refs.table.refresh(!!flag)
+      this.getOrderDetail()
     },
     //  返回
     handleBack () {
-      this.$router.push({ path: '/salesManagement/salesQuery/list' })
+      this.$router.push({ name: 'salesQueryList' })
     },
     // 整单删除
     delSalerDetailAll () {
@@ -201,7 +209,7 @@ export default {
     handleDel (row) {
       salesDetailDel({ id: row.id }).then(res => {
         if (res.status == 200) {
-          this.resetSearchForm()
+          this.resetSearchForm(true)
         }
         this.$message.info(res.message)
       })
@@ -209,6 +217,11 @@ export default {
     // 添加产品
     insterProduct (row) {
       console.log(row)
+      if (this.isInster) {
+        return
+      }
+      this.$message.loading('正在添加产品...')
+      this.isInster = true
       salesDetailInsert({
         productSn: row.productSn,
         price: row.dealerProduct.cityPrice,
@@ -219,10 +232,11 @@ export default {
         warehouseLocationSn: row.warehouseLocationSn,
         stockSn: row.stockSn
       }).then(res => {
-        console.log(res)
         if (res.status == 200) {
           this.resetSearchForm()
+          this.$message.success('产品添加成功', 2.5)
         }
+        this.isInster = false
       })
     },
     //  销售单详情
@@ -234,6 +248,15 @@ export default {
           this.detailData = null
         }
       })
+    },
+    // 提交销售单
+    handleSubmit () {
+      salesWriteSubmit({ id: this.orderId }).then(res => {
+        if (res.status == 200) {
+          this.handleBack()
+          this.$message.success(res.message)
+        }
+      })
     }
   },
   beforeRouteEnter (to, from, next) {
@@ -241,6 +264,7 @@ export default {
       // 获取销售单详情
       vm.getOrderDetail()
       vm.orderId = vm.$route.params.id
+      vm.salesBillSn = vm.$route.params.sn
     })
   }
 }

+ 18 - 12
src/views/salesManagement/salesQuery/list.vue

@@ -175,7 +175,6 @@ export default {
         { title: '总款数', dataIndex: 'totalCategory', width: 100, align: 'center', customRender: function (text) { return ((text || text == 0) ? text : '--') } },
         { title: '总数量', dataIndex: 'totalQty', width: 100, align: 'center', customRender: function (text) { return ((text || text == 0) ? text : '--') } },
         { title: '总售价', dataIndex: 'totalAmount', width: 100, align: 'center', customRender: function (text) { return ((text || text == 0) ? text : '--') } },
-        { title: '支付方式', dataIndex: 'payType', width: 100, align: 'center', customRender: function (text) { return text || '--' } },
         { title: '收款方式', dataIndex: 'settleStyle', width: 100, align: 'center', customRender: function (text) { return text || '--' } },
         { title: '审核时间', dataIndex: 'auditTime', width: 160, align: 'center', customRender: function (text) { return text || '--' } },
         { title: '急件', dataIndex: 'urgentFlag', width: 100, align: 'center', customRender: function (text) { return text || '--' } },
@@ -217,7 +216,7 @@ export default {
     },
     // 选择客户成功
     chooseCustomOk (data) {
-      this.$router.push({ name: 'salesAdd', params: { id: data.id, salesBillSn: data.salesBillSn } })
+      this.$router.push({ name: 'salesAdd', params: { id: data.id, sn: data.salesBillSn } })
     },
     //  审核
     handleEexamine (row) {
@@ -227,16 +226,23 @@ export default {
         content: '请点击下方按钮确认操作?',
         centered: true,
         okText: '审核通过',
-        canselText: '审核不通过',
+        cancelText: '审核不通过',
         onOk () {
-          salesWriteAudit({
-            id: row.id
-          }).then(res => {
-            if (res.status == 200) {
-              _this.$message.success(res.message)
-              _this.$refs.table.refresh()
-            }
-          })
+          _this.auditOrder(row.id, 'AUDIT_PASS')
+        },
+        onCancel () {
+          _this.auditOrder(row.id, 'AUDIT_REJECT')
+        }
+      })
+    },
+    auditOrder (id, billStatus) {
+      salesWriteAudit({
+        id,
+        billStatus
+      }).then(res => {
+        if (res.status == 200) {
+          this.$message.success(res.message)
+          this.$refs.table.refresh()
         }
       })
     },
@@ -266,7 +272,7 @@ export default {
     },
     // 编辑
     handleEdit (row) {
-      this.$router.push({ name: 'salesEdit', params: { id: row.id, salesBillSn: row.salesBillSn } })
+      this.$router.push({ name: 'salesEdit', params: { id: row.id, sn: row.salesBillSn } })
     },
     // 删除
     handleDel (row) {

+ 49 - 18
src/views/salesManagement/salesQuery/queryPart.vue

@@ -59,7 +59,16 @@
             </a-col>
             <a-col :md="6" :sm="24">
               <a-form-item label="仓库">
-                <v-select code="CHECK_ENABLE_STATE" id="productInfoList-state" v-model="queryParam.warehouseSn" allowClear placeholder="请选择仓库"></v-select>
+                <a-select
+                  placeholder="请选择仓库"
+                  id="productInfoList-warehouseSn"
+                  allowClear
+                  v-model="queryParam.warehouseSn"
+                  :showSearch="true"
+                  option-filter-prop="children"
+                  :filter-option="filterOption">
+                  <a-select-option v-for="item in warehouseList" :key="item.warehouseSn" :value="item.warehouseSn">{{ item.name }}</a-select-option>
+                </a-select>
               </a-form-item>
             </a-col>
           </template>
@@ -89,26 +98,29 @@
       :data="loadData"
       :customRow="handleClickRow"
       :scroll="{ x: 1530, y: 150 }"
+      :pageSize="30"
       bordered>
       <!-- 售价 -->
       <template slot="price" slot-scope="text, record">
-        <a-input-number
-          id="productInfoList-price"
-          :value="record.dealerProduct.cityPrice||0"
-          :precision="0"
-          :min="0"
-          :max="999999"
-          placeholder="请输入" />
+        <div @dblclick.stop>
+          <a-input-number
+            v-model="record.dealerProduct.cityPrice"
+            :precision="2"
+            :min="0"
+            :max="999999"
+            placeholder="请输入" />
+        </div>
       </template>
       <!-- 销售数量 -->
       <template slot="nums" slot-scope="text, record">
-        <a-input-number
-          id="productInfoList-nums"
-          :value="record.salesNums"
-          :precision="0"
-          :min="0"
-          :max="999999"
-          placeholder="请输入" />
+        <div @dblclick.stop>
+          <a-input-number
+            v-model="record.salesNums"
+            :precision="0"
+            :min="0"
+            :max="999999"
+            placeholder="请输入" />
+        </div>
       </template>
       <!-- 操作 -->
       <template slot="action" slot-scope="text, record">
@@ -126,6 +138,7 @@
 import { productBrandQuery } from '@/api/productBrand'
 import { productTypeQuery } from '@/api/productType'
 import { querySumByProductLocation } from '@/api/stock'
+import { warehouseAllList } from '@/api/warehouse'
 import productSalesRecordModal from './productSalesRecordModal.vue'
 import { STable, VSelect } from '@/components'
 export default {
@@ -139,7 +152,6 @@ export default {
         productCode: '', //  产品编码
         productName: '', //  产品名称
         productOrigCode: '', //  原厂编码
-        sysFlag: '1',
         brandSn: undefined, //  产品品牌
         productTypeSn1: '', //  产品一级分类
         productTypeSn2: '', //  产品二级分类
@@ -150,6 +162,7 @@ export default {
       exportLoading: false, // 导出loading
       productBrandList: [], //  下拉数据
       productTypeList: [], //  产品类别  下拉数据
+      warehouseList: [], // 仓库列表
       columns: [
         { title: '序号', dataIndex: 'no', width: 80, align: 'center' },
         { title: '产品编码', dataIndex: 'productCode', width: 140, align: 'center', sorter: true },
@@ -160,7 +173,7 @@ export default {
         { title: '仓位', dataIndex: 'warehouseLocationSn', width: 100, align: 'center' },
         { title: '售价', scopedSlots: { customRender: 'price' }, width: 150, align: 'center' },
         { title: '销售数量', scopedSlots: { customRender: 'nums' }, width: 150, align: 'center' },
-        { title: '单位', dataIndex: 'unit', width: 100, align: 'center' },
+        { title: '单位', dataIndex: 'unit', width: 100, align: 'center', customRender: function (text) { return text || '--' } },
         { title: '操作', scopedSlots: { customRender: 'action' }, width: 170, align: 'center', fixed: 'right' }
       ],
       // 加载数据方法 必须为 Promise 对象
@@ -174,12 +187,18 @@ export default {
             data.list[i].salesNums = 1
           }
           this.disabled = false
+          // 产品品牌
           if (this.productBrandList.length == 0) {
             this.getProductBrand()
           }
+          // 产品分类
           if (this.productTypeList.length == 0) {
             this.getProductType()
           }
+          // 仓库
+          if (this.warehouseList.length == 0) {
+            this.getWarehouse()
+          }
           return data
         })
       },
@@ -190,10 +209,12 @@ export default {
   methods: {
     // 双击列表
     handleClickRow (record) {
+      const _this = this
       return {
         on: {
           dblclick: (event) => {
-            console.log(record)
+            event.stopPropagation()
+            _this.$emit('add', record)
           }
         }
       }
@@ -229,6 +250,16 @@ export default {
       this.itemId = ''
       this.openModal = false
     },
+    // 仓库
+    getWarehouse () {
+      warehouseAllList({}).then(res => {
+        if (res.status == 200) {
+          this.warehouseList = res.data
+        } else {
+          this.warehouseList = []
+        }
+      })
+    },
     //  产品品牌  列表
     getProductBrand () {
       productBrandQuery({}).then(res => {