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

+ 48 - 26
src/views/salesManagement/salesQuery/chooseCustomModal.vue

@@ -1,7 +1,7 @@
 <template>
   <a-modal
     v-model="opened"
-    title="选择客户"
+    :title="title"
     centered
     :maskClosable="false"
     :confirmLoading="confirmLoading"
@@ -20,18 +20,16 @@
       <a-row :gutter="15">
         <a-col :span="8">
           <a-form-model-item label="客户名称" prop="buyerSn">
-            <a-auto-complete
+            <a-select
               id="chooseCustom-buyerSn"
+              show-search
               placeholder="请选择客户"
-              allowClear
               v-model="form.buyerSn"
               :filter-option="filterOption"
               @select="custSelect"
               @change="custChange">
-              <template slot="dataSource">
-                <a-select-option v-for="item in custAllList" :key="item.customerSn" :title="item.id">{{ item.customerName }}</a-select-option>
-              </template>
-            </a-auto-complete>
+              <a-select-option v-for="item in custAllList" :key="item.id" :value="item.customerSn">{{ item.customerName }}</a-select-option>
+            </a-select>
           </a-form-model-item>
         </a-col>
         <a-col :span="16">
@@ -109,7 +107,7 @@
               <a-col :span="20">
                 <v-select
                   code="PRICE_TYPE"
-                  :disabled="!isEdit"
+                  :disabled="isEdit"
                   id="chooseCustom-priceType"
                   v-model="form.priceType"
                   allowClear
@@ -193,6 +191,7 @@ export default {
   data () {
     return {
       opened: this.show,
+      title: '选择客户',
       confirmLoading: false,
       formItemLayout: {
         labelCol: { span: 8 },
@@ -200,7 +199,7 @@ export default {
       },
       form: {
         buyerName: '', // 客户名称
-        buyerSn: '', // 客户sn
+        buyerSn: undefined, // 客户sn
         consigneeTel: '', //  联系电话
         consigneeName: '', //  联系人
         shippingAddressProvinceSn: undefined, //  省
@@ -211,7 +210,7 @@ export default {
         shippingAddressCountyName: '',
         shippingAddress: '', //  详细地址
         fax: '', //  客户传真
-        dispatchType: '', //  配送方式
+        dispatchType: undefined, //  配送方式
         satelliteFlag: 0, //  是否卫星仓客户
         customerTypeSn: undefined, //  客户类型
         priceType: '', //  价格类型
@@ -264,7 +263,8 @@ export default {
       addrDistrictList: [], //  区下拉
       userList: [], // 业务员 下拉
       custId: undefined, // 客户id
-      isEdit: true, //  是否可编辑
+      isEdit: false, //  是否可编辑
+      isChangeCust: false, // 是否更换客户
       interId: null
     }
   },
@@ -276,10 +276,29 @@ export default {
     // 客户 select
     custSelect (v) {
       console.log(v, 'custSelect')
+      const _this = this
       const cust = this.custAllList.find(item => item.customerSn == v)
+      if (this.isEdit) {
+        // 变更了客户信息
+        if (cust.customerSn !== this.form.customerSn) {
+          this.isChangeCust = true
+          this.$confirm({
+            title: '提示',
+            content: '更换客户后信息需要重新完善,确认要更换吗?',
+            centered: true,
+            onOk () {
+              _this.custId = cust.id
+              _this.form.buyerName = cust.customerName
+              _this.isEdit = false
+              _this.getDetail()
+              _this.$emit('updateData')
+            }
+          })
+          return
+        }
+      }
       this.custId = cust.id
       this.form.buyerName = cust.customerName
-      this.isEdit = false
       this.getDetail()
     },
     // 客户 change
@@ -287,17 +306,15 @@ export default {
       console.log(val, 'custChange')
       this.$refs.ruleForm.resetFields()
       this.custId = undefined
-      this.isEdit = true
     },
     // 编辑客户信息
     editCust (data) {
       console.log(data)
+      this.title = '编辑客户信息'
+      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.interId = setInterval(() => {
-
-      // }, 100)
     },
     //  获取详情
     getDetail () {
@@ -364,22 +381,27 @@ export default {
         if (valid) {
           // 保存客户信息
           _this.handleSaveCust()
-          // 新建或编辑销售单
-          const form = this.form
-          console.log(form, 'save data')
-          salesSave(form).then(res => {
-            if (res.status == 200) {
-              _this.$message.success(res.message)
-              _this.$emit('ok', res.data)
-              _this.cancel()
-            }
-          })
+          // 保存销售单
+          _this.salesSaveFun()
         } else {
           console.log('error submit!!')
           return false
         }
       })
     },
+    // 新建或编辑销售单
+    salesSaveFun () {
+      const _this = this
+      const form = this.form
+      console.log(form, 'save data')
+      salesSave(form).then(res => {
+        if (res.status == 200) {
+          _this.$message.success(res.message)
+          _this.$emit('ok', res.data)
+          _this.cancel()
+        }
+      })
+    },
     cancel () {
       this.opened = false
       this.$refs.ruleForm.resetFields()

+ 4 - 10
src/views/salesManagement/salesQuery/edit.vue

@@ -25,7 +25,7 @@
       <!-- 查询条件 -->
       <a-row :gutter="15">
         <a-col :span="18">
-          <a-form-model layout="inline" :model="productForm" @submit="handleSearch">
+          <a-form-model layout="inline" :model="productForm">
             <a-form-model-item label="产品编码">
               <a-input v-model="productForm.code" placeholder="输入产品编码" />
             </a-form-model-item>
@@ -82,7 +82,7 @@
       </s-table>
     </a-card>
     <!-- 选择客户弹框 -->
-    <choose-custom-modal ref="custModal" :show="openModal" @ok="chooseCustomOk" @cancel="openModal=false" />
+    <choose-custom-modal ref="custModal" :show="openModal" @updateData="getOrderDetail" @cancel="openModal=false" />
   </div>
 </template>
 
@@ -127,6 +127,7 @@ export default {
       // 加载数据方法 必须为 Promise 对象
       loadData: parameter => {
         this.disabled = true
+        this.productForm.id = this.$route.params.id
         return salesDetailList(Object.assign(parameter, this.productForm)).then(res => {
           const data = res.data
           const no = (data.pageNo - 1) * data.pageSize
@@ -173,13 +174,6 @@ export default {
           this.$message.info(res.message)
         })
       }
-    },
-    handleSearch () {
-
-    },
-    // 选择客户成功
-    chooseCustomOk (data) {
-
     },
     // 编辑客户信息
     handleEdit () {
@@ -231,7 +225,7 @@ export default {
         }
       })
     },
-    //  详情
+    //  销售单详情
     getOrderDetail () {
       salesDetail({ id: this.$route.params.id }).then(res => {
         if (res.status == 200) {

+ 2 - 2
src/views/salesManagement/salesQuery/list.vue

@@ -217,7 +217,7 @@ export default {
     },
     // 选择客户成功
     chooseCustomOk (data) {
-      this.$router.push({ name: 'salesAdd', params: { id: data.id } })
+      this.$router.push({ name: 'salesAdd', params: { id: data.id, salesBillSn: data.salesBillSn } })
     },
     //  审核
     handleEexamine (row) {
@@ -266,7 +266,7 @@ export default {
     },
     // 编辑
     handleEdit (row) {
-      this.$router.push({ name: 'salesEdit', params: { id: row.id } })
+      this.$router.push({ name: 'salesEdit', params: { id: row.id, salesBillSn: row.salesBillSn } })
     },
     // 删除
     handleDel (row) {