ソースを参照

Merge branch 'deploy_0804' of http://git.chelingzhu.com/jianguan-web/qpls-md-html into deploy_0804

lilei 3 年 前
コミット
dd77948e71
1 ファイル変更56 行追加9 行削除
  1. 56 9
      src/views/productManagement/productInfo/edit.vue

+ 56 - 9
src/views/productManagement/productInfo/edit.vue

@@ -23,6 +23,8 @@
               v-model.trim="form.name"
               @change="filterEmpty"
               placeholder="请输入产品名称(最多100个字符)"
+              ref="name"
+              @keydown.enter.native="nextFocus('name', 'code', $event)"
               allowClear />
           </a-form-model-item>
           <a-form-model-item label="产品编码" prop="code">
@@ -32,6 +34,8 @@
               :disabled="!!$route.params.id"
               v-model="form.code"
               placeholder="请输入产品编码(最多100个字符)"
+              ref="code"
+              @keydown.enter.native="nextFocus('code', 'origCode', $event)"
               allowClear />
           </a-form-model-item>
           <a-form-model-item label="原厂编码" prop="origCode">
@@ -41,12 +45,28 @@
               :disabled="!!$route.params.id"
               v-model="form.origCode"
               placeholder="请输入原厂编码(最多200个字符,多个编码用逗号隔开)"
+              ref="origCode"
+              @keydown.enter.native="nextFocus('origCode', 'unit', $event)"
               allowClear />
           </a-form-model-item>
           <a-form-model-item label="基本单位" prop="unit">
             <a-input-group compact>
-              <a-input style="width: 80%" v-model="form.unit" id="productInfoEdit-unit-input" placeholder="请输入基本单位" allowClear/>
-              <v-select style="width: 20%" code="UNIT" @change="unitChange" id="productInfoEdit-unit" placeholder="快速选择单位"></v-select>
+              <a-input
+                style="width: 80%"
+                v-model="form.unit"
+                id="productInfoEdit-unit-input"
+                placeholder="请输入基本单位"
+                ref="unit"
+                @keydown.enter.native="nextFocus('unit', 'UNIT', $event, 'vSelect')"
+                allowClear/>
+              <v-select
+                style="width: 20%"
+                code="UNIT"
+                @change="unitChange"
+                id="productInfoEdit-unit"
+                ref="UNIT"
+                @keydown.enter.native="nextFocus('UNIT', 'productBrandSn', $event)"
+                placeholder="快速选择单位"></v-select>
             </a-input-group>
           </a-form-model-item>
           <a-form-model-item label="产品品牌" prop="productBrandSn">
@@ -59,8 +79,9 @@
               :filter-option="false"
               :not-found-content="fetching ? undefined : null"
               @search="fetchUser"
-              @change="handleChange"
               style="width: 90%;"
+              ref="productBrandSn"
+              @keydown.enter.native="nextFocus('productBrandSn', 'productType', $event)"
             >
               <a-spin v-if="fetching" slot="notFoundContent" size="small" />
               <a-select-option v-for="item in productBrandList" :key="item.brandSn" :value="item.brandSn" :disabled="item.enabledFlag==0">{{ item.brandName }}</a-select-option>
@@ -84,7 +105,9 @@
               id="productInfoEdit-productType"
               placeholder="请选择产品分类"
               allowClear
-              v-model="form.productType" />
+              v-model="form.productType"
+              ref="productType"
+              @keydown.enter.native="nextFocus('productType', 'specialPrice', $event)" />
           </a-form-model-item>
           <a-form-model-item label="经销批发价" prop="specialPrice">
             <a-input-number
@@ -95,6 +118,8 @@
               :precision="2"
               style="width: 90%;margin-right: 5px;"
               placeholder="请输入经销批发价(1~999999)"
+              ref="specialPrice"
+              @keydown.enter.native="nextFocus('specialPrice', 'terminalPrice', $event)"
               allowClear /><span>元</span>
           </a-form-model-item>
           <a-form-model-item label="终端价" prop="terminalPrice">
@@ -106,6 +131,8 @@
               :precision="2"
               style="width: 90%;margin-right: 5px;"
               placeholder="请输入终端价(1~999999)"
+              ref="terminalPrice"
+              @keydown.enter.native="nextFocus('terminalPrice', 'carOwnersPrice', $event)"
               allowClear /><span>元</span>
           </a-form-model-item>
           <a-form-model-item label="车主价" prop="carOwnersPrice">
@@ -117,6 +144,8 @@
               :precision="2"
               style="width: 90%;margin-right: 5px;"
               placeholder="请输入车主价(1~999999)"
+              ref="carOwnersPrice"
+              @keydown.enter.native="nextFocus('carOwnersPrice', '', $event)"
               allowClear /><span>元</span>
           </a-form-model-item>
           <a-form-model-item :wrapper-col="{ span: 12, offset: 6 }" style="text-align: center;">
@@ -193,11 +222,6 @@ export default {
         }
       })
     },
-    // 调往对象名称  change
-    handleChange (value) {
-      const ind = this.dealerData.findIndex(item => item.dealerSn == value)
-      this.form.targetName = this.dealerData[ind].dealerName
-    },
     filterEmpty () {
       let str = this.form.name
       str = str.replace(/\ +/g, '')
@@ -257,6 +281,22 @@ export default {
         }
       })
     },
+    // 回车键快捷定位表单下一项
+    nextFocus (nowRef, nextRef, event, isComponent) {
+      const _this = this
+      if (_this.$refs[nowRef]) {
+        _this.$nextTick(() => {
+          if (_this.$refs[nextRef]) {
+            event.target.blur()
+            if (isComponent == 'vSelect') {
+              _this.$refs[nextRef].$children[0].focus()
+            } else {
+              _this.$refs[nextRef].focus()
+            }
+          }
+        })
+      }
+    },
     //  产品分类  change
     changeProductType (val, opt) {
       this.form.productTypeSn3 = val[2] ? val[2] : ''
@@ -300,6 +340,13 @@ export default {
     pageInit () {
       this.getProductType()
       this.$refs.ruleForm.resetFields()
+      // 默认首项获取焦点
+      const _this = this
+      setTimeout(() => {
+        if (_this.$refs['name']) {
+          _this.$refs['name'].focus()
+        }
+      }, 300)
       if (this.$route.params.id) { //  编辑页
         this.getGoodsDetail()
       }