فهرست منبع

销售单对接

lilei 4 سال پیش
والد
کامیت
17e8507628

+ 4 - 11
src/api/sales.js

@@ -91,22 +91,15 @@ export const salesWriteSubmit = (params) => {
     method: 'post'
   })
 }
-//  销售 新增
-export const salesInsert = (params) => {
+//  销售 新增或编辑
+export const salesSave = (params) => {
   return axios({
-    url: '/sales/insert',
-    data: params,
-    method: 'post'
-  })
-}
-//  销售 修改
-export const salesUpdate = (params) => {
-  return axios({
-    url: '/sales/update',
+    url: '/sales/save',
     data: params,
     method: 'post'
   })
 }
+
 //  销售 删除
 export const salesDel = (params) => {
   return axios({

+ 1 - 2
src/api/salesDetail.js

@@ -39,8 +39,7 @@ export const salesDetailUpdateQty = (params) => {
 export const salesDetailDel = (params) => {
   return axios({
     url: `/salesDetail/delete/${params.id}`,
-    data: params,
-    method: 'post'
+    method: 'get'
   })
 }
 //  销售详情 整单删除

+ 10 - 2
src/views/common/editInput.js

@@ -4,8 +4,8 @@ const EditableCell = {
         <div class="editable-cell-input-wrapper">
           <a-input-number 
           size="small" 
-          :min="0.1" 
-          :max="100000" 
+          :min="min" 
+          :max="max" 
           :value="value" 
           :precision="precision"
           :step="step"
@@ -29,6 +29,14 @@ const EditableCell = {
     step: {
       type: [Number],
       default: 1
+    },
+    min: {
+      type: [Number],
+      default: 0
+    },
+    max: {
+      type: [Number],
+      default: 999999
     }
   },
   data() {

+ 9 - 20
src/views/salesManagement/salesQuery/chooseCustomModal.vue

@@ -181,7 +181,7 @@
 <script>
 import { getArea } from '@/api/data'
 import { custAllList, custFindById, custSave, updateByCustomerSn } from '@/api/customer'
-import { salesInsert, salesUpdate } from '@/api/sales'
+import { salesSave } from '@/api/sales'
 import { getUserAllList } from '@/api/power-user'
 import { VSelect } from '@/components'
 export default {
@@ -364,27 +364,16 @@ export default {
         if (valid) {
           // 保存客户信息
           _this.handleSaveCust()
-          // 新建销售单
+          // 新建或编辑销售单
           const form = this.form
           console.log(form, 'save data')
-          // 编辑
-          if (this.form.id) {
-            salesUpdate(form).then(res => {
-              if (res.status == 200) {
-                _this.$message.success(res.message)
-                _this.$emit('ok', res.data)
-                _this.cancel()
-              }
-            })
-          } else {
-            salesInsert(form).then(res => {
-              if (res.status == 200) {
-                _this.$message.success(res.message)
-                _this.$emit('ok', res.data)
-                _this.cancel()
-              }
-            })
-          }
+          salesSave(form).then(res => {
+            if (res.status == 200) {
+              _this.$message.success(res.message)
+              _this.$emit('ok', res.data)
+              _this.cancel()
+            }
+          })
         } else {
           console.log('error submit!!')
           return false

+ 42 - 17
src/views/salesManagement/salesQuery/edit.vue

@@ -57,23 +57,23 @@
         bordered>
         <!-- 售价 -->
         <template slot="price" slot-scope="text, record">
-          <a-input-number
+          <editable-cell
+            :text="record.price"
             id="salesEdit-price"
-            :value="record.price"
-            :precision="0"
-            :min="0"
             :max="999999"
-            placeholder="请输入" />
+            :min="0"
+            :precision="2"
+            @change="onCellChange(record.id, 'price', $event)" />
         </template>
         <!-- 销售数量 -->
         <template slot="salesNums" slot-scope="text, record">
-          <a-input-number
+          <editable-cell
+            :text="record.qty"
             id="salesEdit-salesNums"
-            :value="record.qty"
-            :precision="0"
-            :min="0"
             :max="999999"
-            placeholder="请输入" />
+            :min="1"
+            :precision="0"
+            @change="onCellChange(record.id, 'qty', $event)" />
         </template>
         <!-- 操作 -->
         <template slot="action" slot-scope="text, record">
@@ -91,10 +91,11 @@ import { STable, VSelect } from '@/components'
 import queryPart from './queryPart.vue'
 import chooseCustomModal from './chooseCustomModal.vue'
 import { salesDetail } from '@/api/sales'
+import EditableCell from '@/views/common/editInput.js'
 import { salesDetailList, salesDetailInsert, salesDetailUpdatePrice, salesDetailUpdateQty, salesDetailDel, salesDetailDelAll } from '@/api/salesDetail'
 export default {
   name: 'SalesDetail',
-  components: { STable, VSelect, queryPart, chooseCustomModal },
+  components: { STable, VSelect, queryPart, chooseCustomModal, EditableCell },
   data () {
     return {
       orderId: null, // 销售单id
@@ -133,21 +134,45 @@ export default {
             data.list[i].no = no + i + 1
           }
           this.disabled = false
+          this.dataSource = data.list
           return data
         })
       }
     }
   },
   methods: {
-    onCellChange (key, dataIndex, value) {
-      console.log(key, dataIndex, value)
-      console.log(this.dataSource)
+    onCellChange (id, key, value) {
+      console.log(id, key, value)
       const dataSource = [...this.dataSource]
-      const target = dataSource.find(item => item.id === key)
-      if (target) {
-        target[dataIndex] = Number(value)
+      const row = dataSource.find(item => item.id === id)
+      if (row) {
+        row[key] = Number(value)
         this.dataSource = dataSource
       }
+      // 修改价格
+      if (key == 'price') {
+        salesDetailUpdatePrice({
+          salesBillSn: row.salesBillSn,
+          productSn: row.productSn,
+          price: row.price
+        }).then(res => {
+          if (res.status == 200) {
+            this.$refs.table.refresh(true)
+          }
+          this.$message.info(res.message)
+        })
+      }
+      if (key == 'qty') {
+        salesDetailUpdateQty({
+          id: row.id,
+          qty: row.qty
+        }).then(res => {
+          if (res.status == 200) {
+            this.$refs.table.refresh(true)
+          }
+          this.$message.info(res.message)
+        })
+      }
     },
     handleSearch () {
 

+ 6 - 10
src/views/salesManagement/salesQuery/list.vue

@@ -126,15 +126,11 @@
       </template>
       <!-- 操作 -->
       <template slot="action" slot-scope="text, record">
-        <a-button size="small" type="link" @click="handleEexamine(record)" id="salesManagementList-eexamine-btn">审核</a-button>
-        <a-divider type="vertical" style="margin: 0;" />
-        <a-button size="small" type="link" @click="handleSend(record)" id="salesManagementList-send-btn">出库</a-button>
-        <a-divider type="vertical" style="margin: 0;" />
-        <a-button size="small" type="link" @click="handleDetail(record)" id="salesManagementList-detail-btn">详情</a-button>
-        <a-divider type="vertical" style="margin: 0;" />
-        <a-button size="small" type="link" @click="handleEdit(record)" id="salesManagementList-edit-btn">编辑</a-button>
-        <a-divider type="vertical" style="margin: 0;" />
-        <a-button size="small" type="link" @click="handleDel(record)" id="salesManagementList-del-btn">删除</a-button>
+        <a-button size="small" type="primary" class="button-warning" @click="handleEexamine(record)" id="salesManagementList-eexamine-btn">审核</a-button>
+        <a-button size="small" type="primary" class="button-primary" @click="handleSend(record)" id="salesManagementList-send-btn">出库</a-button>
+        <a-button size="small" type="primary" class="button-success" @click="handleDetail(record)" id="salesManagementList-detail-btn">详情</a-button>
+        <a-button size="small" type="primary" class="button-info" @click="handleEdit(record)" id="salesManagementList-edit-btn">编辑</a-button>
+        <a-button size="small" type="primary" class="button-error" @click="handleDel(record)" id="salesManagementList-del-btn">删除</a-button>
       </template>
     </s-table>
     <!-- 选择客户弹框 -->
@@ -185,7 +181,7 @@ export default {
         { title: '急件', dataIndex: 'urgentFlag', width: 100, align: 'center', customRender: function (text) { return text || '--' } },
         { title: '业务状态', scopedSlots: { customRender: 'auditStatus' }, width: 110, align: 'center' },
         { title: '财务状态', scopedSlots: { customRender: 'financialStatus' }, width: 110, align: 'center' },
-        { title: '操作', scopedSlots: { customRender: 'action' }, width: 260, align: 'center', fixed: 'right' }
+        { title: '操作', scopedSlots: { customRender: 'action' }, width: 300, align: 'center', fixed: 'right' }
       ],
       // 加载数据方法 必须为 Promise 对象
       loadData: parameter => {

+ 4 - 4
src/views/salesManagement/salesQuery/queryPart.vue

@@ -94,16 +94,16 @@
       <template slot="price" slot-scope="text, record">
         <a-input-number
           id="productInfoList-price"
-          :value="record.dealerProduct.cityPrice"
+          :value="record.dealerProduct.cityPrice||0"
           :precision="0"
           :min="0"
           :max="999999"
           placeholder="请输入" />
       </template>
       <!-- 销售数量 -->
-      <template slot="salesNums" slot-scope="text, record">
+      <template slot="nums" slot-scope="text, record">
         <a-input-number
-          id="productInfoList-salesNums"
+          id="productInfoList-nums"
           :value="record.salesNums"
           :precision="0"
           :min="0"
@@ -159,7 +159,7 @@ export default {
         { title: '仓库', dataIndex: 'warehouseSn', width: 100, align: 'center', sorter: true },
         { title: '仓位', dataIndex: 'warehouseLocationSn', width: 100, align: 'center' },
         { title: '售价', scopedSlots: { customRender: 'price' }, width: 150, align: 'center' },
-        { title: '销售数量', scopedSlots: { customRender: 'salesNums' }, width: 150, align: 'center' },
+        { title: '销售数量', scopedSlots: { customRender: 'nums' }, width: 150, align: 'center' },
         { title: '单位', dataIndex: 'unit', width: 100, align: 'center' },
         { title: '操作', scopedSlots: { customRender: 'action' }, width: 170, align: 'center', fixed: 'right' }
       ],