lilei před 2 roky
rodič
revize
3139f87aae

+ 1 - 1
public/version.json

@@ -1,5 +1,5 @@
 {
   "message": "发现有新版本发布,确定更新系统?",
   "vendorJsVersion": "",
-  "version": 1661314687495
+  "version": 1661400696117
 }

+ 8 - 0
src/api/purchaseReturnApply.js

@@ -85,6 +85,14 @@ export const modifyReturnReason = (params) => {
     method: 'post'
   })
 }
+// 批量修改退货原因
+export const modifyReturnReasonList = (params) => {
+  return axios({
+    url: `/purchaseReturnApply/detail/modifyReturnReasonList`,
+    data: params,
+    method: 'post'
+  })
+}
 //  申请单详情列表  分页
 export const purchaseReturnDetailList = (params) => {
   const url = `/purchaseReturnApply/detail/queryPage/${params.pageNo}/${params.pageSize}`

+ 1 - 0
src/views/common/commonModal.vue

@@ -11,6 +11,7 @@
     :width="416">
     <a-spin :spinning="spinning" tip="Loading...">
       <div class="common-main" v-html="modalHtml"></div>
+      <slot></slot>
       <div class="btn-box">
         <a-button type="primary" class="button-warning" @click="handleCommonCancel" v-if="isCancel">{{ cancelText }}</a-button>
         <a-button type="primary" class="button-info" @click="handleCommonOk">{{ okText }}</a-button>

+ 112 - 0
src/views/common/returnReason.js

@@ -0,0 +1,112 @@
+const ReturnReason = {
+  template: `
+        <a-select
+            allowClear
+            :size="size"
+            mode="combobox"
+            :value="defaultVal"
+            show-search
+            :placeholder="placeholder"
+            option-filter-prop="children"
+            style="width: 100%"
+            :filter-option="filterOption"
+            :dropdownMatchSelectWidth="false"
+            @change="onChange"
+            @blur="onBlur"
+            @focus="open=true"
+            @select="open=false"
+            :open="open"
+          >
+            <a-select-option v-for="item in list" :key="item" :value="item">
+              {{item}}
+            </a-select-option>
+          </a-select>
+    `,
+  props: {
+    value: {
+      type: String,
+      defatut: ''
+    },
+    id: {
+      type: String,
+      default: ''
+    },
+    placeholder: {
+      type: String,
+      default: '请输入退货原因'
+    },
+    size: {
+      type: String,
+      default: 'small'
+    }
+  },
+  data() {
+    return {
+      defaultVal: this.value,
+      open: false,
+      list: [
+        '漏油或者不上油',
+        '外观不良:脏污、破损、脱胶、变形等',
+        '尺寸问题',
+        '泄压',
+        '无法安装',
+        '无法或不便安装',
+        '抖动或跳动',
+        '噪音',
+        '刮雨不干净',
+        '胶条断裂、脱落',
+        '喇叭无声',
+        '声音嘶哑或者变音',
+        '浸水',
+        '伤盘',
+        '摩擦块掉渣,脱落或有残渣',
+        '制动不足,刹车不灵敏',
+        '不耐磨',
+        '冒烟',
+        '缺少感应线',
+        '尺寸不标准',
+        '不点火,间歇式失火',
+        '漏电',
+        '击穿',
+        '烧蚀',
+        '包装型号不符',
+        '整体不亮/部分能亮',
+        '灯珠脱落',
+        '漏电短路',
+        '包装型号不符/包装破损',
+        '召回'
+        ]
+    };
+  },
+  mounted() {
+  },
+  watch: {
+    value(newValue, oldValue) {
+      this.defaultVal = newValue
+    },
+    defaultVal(newValue, oldValue) {
+      if(!newValue){
+        this.open = true
+      }
+    },
+  },
+  methods: {
+    filterOption(input, option) {
+      return (
+        option.componentOptions.children[0].text.toLowerCase().indexOf(input.toLowerCase()) >= 0
+      );
+    },
+    onChange(value) {
+      console.log('onChange', value);
+      this.defaultVal = value;
+      this.$emit('change', value);
+      this.$emit('input', value);
+    },
+    onBlur(value){
+      this.open = false;
+      this.$emit('blur', value);
+    }
+  },
+};
+
+export default ReturnReason

+ 91 - 47
src/views/purchasingManagement/purchaseReturnApplyForm/edit.vue

@@ -73,16 +73,7 @@
               </template>
               <!-- 退货原因 -->
               <template slot="returnReason" slot-scope="text, record">
-                <a-select
-                  style="width:100%;"
-                  size="small"
-                  v-model="record.returnReason"
-                  placeholder="请选择退货原因"
-                  allowClear>
-                  <a-select-option v-for="item in returnReasonList" :value="item.code">
-                    {{ item.dispName }}
-                  </a-select-option>
-                </a-select>
+                <returnReason v-model="record.returnReason"></returnReason>
               </template>
               <!-- 操作 -->
               <template slot="action" slot-scope="text, record">
@@ -114,7 +105,7 @@
             </a-alert>
             <!-- 筛选条件 -->
             <div class="table-page-search-wrapper" style="display:flex;width:100%;">
-              <div style="width:80%;">
+              <div style="flex-grow:1;">
                 <a-form layout="inline" @keyup.enter.native="$refs.table.refresh(true)">
                   <a-row :gutter="15">
                     <a-col :md="6" :sm="24">
@@ -134,12 +125,15 @@
                   </a-row>
                 </a-form>
               </div>
-              <div style="text-align:right;width:20%;">
+              <div>
+                <span style="margin-right: 10px;" v-if="selNums">已选{{ selNums }}项</span>
+                <a-button type="default" style="margin-right: 10px;" class="button-info" @click="openPlSetReason">批量设置退货原因</a-button>
                 <a-button
-                  type="default"
+                  type="primary"
                   id="purchaseReturnEdit-import-btn"
+                  class="button-info"
                   @click="openGuideModal = true"
-                  style="margin-right: 10px;">产品导入</a-button>
+                >产品导入</a-button>
                 <a-button
                   type="primary"
                   class="button-error"
@@ -154,6 +148,8 @@
               ref="chooseTable"
               size="small"
               :rowKey="(record) => record.id"
+              :row-selection="{ columnWidth: 40 }"
+              @rowSelection="rowSelectionFun"
               :columns="chooseColumns"
               :data="chooseLoadData"
               :defaultLoadData="false"
@@ -179,17 +175,7 @@
               </template>
               <!-- 退货原因 -->
               <template slot="returnReason" slot-scope="text, record">
-                <a-select
-                  style="width:100%;"
-                  size="small"
-                  v-model="record.returnReason"
-                  placeholder="请选择退货原因"
-                  @change="e => remarksBlur(e, record)"
-                  allowClear>
-                  <a-select-option v-for="item in returnReasonList" :value="item.code">
-                    {{ item.dispName }}
-                  </a-select-option>
-                </a-select>
+                <returnReason v-model="record.returnReason" @blur="e => remarksBlur(e, record)"></returnReason>
               </template>
               <!-- 操作 -->
               <template slot="action" slot-scope="text, record">
@@ -217,6 +203,16 @@
       :params="{purchaseReturnApplySn: $route.params.sn, purchaseReturnApplyNo:detailData?detailData.purchaseReturnApplyNo:''}"
       @close="openGuideModal=false"
       @ok="hanldeImprotOk" />
+
+    <!-- 批量设置退货原因 -->
+    <commonModal modalTit="批量设置退货原因" :openModal="showPlModal" @cancel="showPlModal=false" @ok="setPlReturnReason">
+      <div style="text-align: center;">
+        <div style="margin-bottom: 15px;font-size: 14px;"><strong>请输入退货原因</strong></div>
+        <div style="line-height: 24px;">
+          <div><returnReason size="large" v-model="plReturnReason"></returnReason></div>
+        </div>
+      </div>
+    </commonModal>
   </div>
 </template>
 
@@ -225,6 +221,8 @@ import { commonMixin } from '@/utils/mixin'
 import { STable, VSelect } from '@/components'
 import Print from '@/views/common/print.vue'
 import { hdPrint } from '@/libs/JGPrint'
+import returnReason from '@/views/common/returnReason'
+import commonModal from '@/views/common/commonModal.vue'
 import ProductType from '../../common/productType.js'
 import importGuideModal from './importGuideModal.vue'
 import {
@@ -239,10 +237,11 @@ import {
   purchaseReturnApplyPrint,
   purchaseReturnApplyExport,
   purchaseReturnApplyCreateList,
-  queryDealerScopeProductPage } from '@/api/purchaseReturnApply'
+  queryDealerScopeProductPage,
+  modifyReturnReasonList } from '@/api/purchaseReturnApply'
 export default {
   name: 'PurchaseReturnEdit',
-  components: { STable, VSelect, Print, ProductType, importGuideModal },
+  components: { STable, VSelect, Print, ProductType, importGuideModal, returnReason, commonModal },
   mixins: [commonMixin],
   data () {
     return {
@@ -293,10 +292,16 @@ export default {
           return data
         })
       },
-      detailData: null
+      detailData: null,
+      rowSelectionInfo: null,
+      plReturnReason: '',
+      showPlModal: false
     }
   },
   computed: {
+    selNums () {
+      return this.rowSelectionInfo && this.rowSelectionInfo.selectedRowKeys.length || 0
+    },
     columns () {
       const arr = [
         { title: '序号', dataIndex: 'no', width: '5%', align: 'center' },
@@ -329,6 +334,10 @@ export default {
     handleBack () {
       this.$router.push({ name: 'purchaseReturnApplyFormList' })
     },
+    // 表格选中项
+    rowSelectionFun (obj) {
+      this.rowSelectionInfo = obj || null
+    },
     // 打印预览/快捷打印
     handlePrint (type, printerType) {
       const _this = this
@@ -378,10 +387,6 @@ export default {
         this.$message.warning('请输入退货数量')
         return
       }
-      if (!row.returnReason) {
-        this.$message.warning('请选择退货原因')
-        return
-      }
       const params = {
         purchaseReturnApplySn: this.$route.params.sn,
         initQty: row.returnQty, //  退货数量
@@ -459,14 +464,17 @@ export default {
       _this.spinning = true
       purchaseReturnSubmit({ sn: _this.$route.params.sn }).then(res => {
         if (res.status == 200) {
-          this.$message.success(res.message)
-          setTimeout(() => {
+          if (res.data.length) {
+            _this.$warning({
+              title: '以下产品请输入退货原因',
+              content: res.data.toString()
+            })
+          } else {
+            _this.$message.success(res.message)
             _this.handleBack()
-            _this.spinning = false
-          }, 1000)
-        } else {
-          _this.spinning = false
+          }
         }
+        _this.spinning = false
       })
     },
     // 已选产品 退货数量修改
@@ -493,19 +501,55 @@ export default {
     },
     // 已选产品 退货原因修改
     remarksBlur (val, record) {
-      if (val && (val != record.returnReasonBackups)) {
+      // 空或没有改变时不保存数据
+      if (!record.returnReason || record.returnReason == record.returnReasonBackups) {
+        record.returnReason = record.returnReasonBackups
+        return
+      }
+      this.spinning = true
+      modifyReturnReason({
+        returnReason: record.returnReason,
+        purchaseReturnApplyDetailSn: record.purchaseReturnApplyDetailSn,
+        purchaseReturnApplySn: this.$route.params.sn
+      }).then(res => {
+        if (res.status == 200) {
+          this.$message.success(res.message)
+          this.$refs.chooseTable.refresh()
+        } else {
+          record.returnReason = record.returnReasonBackups
+        }
+        this.spinning = false
+      })
+    },
+    // 批量设置退货原因
+    openPlSetReason () {
+      if (this.selNums) {
+        this.showPlModal = true
+      } else {
+        this.$message.warning('请先选择产品!')
+      }
+    },
+    setPlReturnReason () {
+      if (this.plReturnReason == '') {
+        this.$message.warning('请输入退货原因!')
+      } else {
         this.spinning = true
-        modifyReturnReason({
-          returnReason: record.returnReason,
-          purchaseReturnApplyDetailSn: record.purchaseReturnApplyDetailSn,
-          purchaseReturnApplySn: this.$route.params.sn
+        const snList = []
+        const arr = this.rowSelectionInfo && this.rowSelectionInfo.selectedRows || []
+        arr.map(item => {
+          snList.push({
+            purchaseReturnApplyDetailSn: item.purchaseReturnApplyDetailSn,
+            returnReason: this.plReturnReason
+          })
+        })
+        modifyReturnReasonList({
+          purchaseReturnApplySn: this.$route.params.sn,
+          detailList: snList
         }).then(res => {
           if (res.status == 200) {
-            this.$message.success(res.message)
+            this.showPlModal = false
             this.$refs.chooseTable.refresh()
-            record.returnReasonBackups = record.returnReason
-          } else {
-            record.returnReason = record.returnReasonBackups
+            this.$refs.chooseTable.clearSelected()
           }
           this.spinning = false
         })