瀏覽代碼

(╯°□°)╯︵ ┻━┻

aliyun0758874076 1 年之前
父節點
當前提交
da5dbeb770
共有 3 個文件被更改,包括 113 次插入55 次删除
  1. 2 2
      .eslintrc.js
  2. 27 19
      src/views/commodity/commoditySystem/addCommodity.vue
  3. 84 34
      src/views/commodity/commoditySystem/addComponent.vue

+ 2 - 2
.eslintrc.js

@@ -142,7 +142,7 @@ module.exports = {
     'vue/no-reserved-component-names': 'error', // disallowVueBuiltInComponents/disallowVue3BuiltInComponents (boolean)...如果true,不允许Vue.js 2/3.x内置组件名。默认值为false.
     'vue/no-reserved-keys': 'error', // 这条规则禁止使用保留名称 (打开新窗口)以避免冲突和意外行为,不允许覆盖保留关键字。(对象)选项有reserved (string[])内部附加受限属性的数组groups。默认值为空。groups (string[])要在其中搜索重复项的附加组名数组。默认值为空。
     'vue/no-reserved-props': ['error', {
-      'vueVersion': 3
+      'vueVersion': 2
     }], // vueVersion (2 | 3)...指定您正在使用的Vue版本。默认值为3
     'vue/no-setup-props-destructure': 'error', // This rule reports the destructuring of props passed to setup causing the value to lose reactivity.析构props传递给setup会导致数值失去反应性。此外,在根范围内析构setup()应该出错,但在嵌套回调或返回的呈现函数中正常:
     'vue/no-shared-component-data': 'error', // 将组件的data数据属性强制为函数(除了new Vue),即强制data必须是一个带返回值的函数。因为如果当data的值是一个对象,那它由组件的所有实例共享。
@@ -1429,4 +1429,4 @@ Instead change the require of definition.js in D:\。。。\node_modules\babel-e
 解决方法:
 方法1,将node版本升级到xx以上,根据官网(https://eslint.org/docs/user-guide/getting-started)介绍,node版本需要^12.22.0, ^14.17.0, or >=16.0.0才行。
 方法2,将 eslint 降级到版本6.8.0(7.0.0 之前的最后一个版本)。此版本仍包含createRequire(可以读取CommonJS模块)这里用的是"devDependencies": {"babel-eslint": "^10.1.0","eslint": "^6.8.0","eslint-plugin-vue": "^9.3.0"}。(但是如果用的是最新的全局的eslint包,也不会报此错误)
-*/
+*/

+ 27 - 19
src/views/commodity/commoditySystem/addCommodity.vue

@@ -42,18 +42,23 @@
           </div>
           <div class="rightCom">
             <el-form-item label="官方分类" prop="classifyId">
-              <el-cascader v-model="form.classifyId" :options="classifyList" clearable :props="{
-                checkStrictly: false,
-                label: 'categoryName',
-                value: 'id',
-                children: 'childs'
-              }" @change="handleChangeCascader" />
+              <el-cascader
+                v-model="form.classifyId" :options="classifyList" clearable :props="{
+                  checkStrictly: false,
+                  label: 'categoryName',
+                  value: 'id',
+                  children: 'childs'
+                }"
+                @change="handleChangeCascader"
+              />
             </el-form-item>
 
             <el-form-item label="商品分组" prop="shopGroupId">
               <el-select v-model="form.shopGroupId" placeholder="请选择商品分组" clearable>
-                <el-option v-for="(item, index) in groupList" :key="index" :label="item.groupName"
-                  :value="item.shopGroupId" />
+                <el-option
+                  v-for="(item, index) in groupList" :key="index" :label="item.groupName"
+                  :value="item.shopGroupId"
+                />
               </el-select>
             </el-form-item>
             <el-form-item label="品牌">
@@ -94,8 +99,11 @@
             </el-form-item>
             <el-form-item v-if="form.ifCredit" class="form-item-long" label="单笔最大抵扣" prop="creditLimit">
               <!-- <el-input v-model="form.creditLimit" type="number" placeholder="请输入单笔最大抵扣" /> -->
-              <el-input-number v-model="form.creditLimit" :controls="false" :max="999999999" :min="0" :precision="0"
-                placeholder="请输入单笔最大抵扣" />
+              <el-input-number
+                v-model="form.creditLimit" :controls="false" :max="999999999" :min="0"
+                :precision="0"
+                placeholder="请输入单笔最大抵扣"
+              />
               <p style="color: #cf0f0f; height: 25px; line-height: 25px;margin-top: 10px">限制一笔订单中该商品最多抵扣多少积分</p>
               <p style="color: #cf0f0f; height: 25px; line-height: 25px">( 注:1积分 = {{ integralProportion }}元 请输入整数 )</p>
             </el-form-item>
@@ -138,7 +146,7 @@ import {
 import { uploadUrl } from '@/utils/request'
 import StyleInformation from './addComponent'
 export default {
-  name: 'bugyellow',
+  name: 'Bugyellow',
   components: {
     Tinymce,
     StyleInformation
@@ -290,14 +298,14 @@ export default {
       dialogImageUrl: '',
       dialogVisible: false,
       rules: {
-        productName: [{ required: true, message: '请输入商品名称', trigger: 'blur' }],
-        shopGroupId: [{ required: true, message: '请选择商品分组', trigger: 'change' }],
-        classifyId: [{ required: true, message: '请选择商品分类', trigger: 'change' }],
-        ifLogistics: [{ required: true, message: '请选择是否需要物流', trigger: 'change' }],
-        shelveState: [{ required: true, message: '请选择是否上架', trigger: 'change' }],
-        ifOversold: [{ required: true, message: '请选择是否允许超卖', trigger: 'change' }],
-        ifCredit: [{ required: true, message: '请选择是否支持积分兑换', trigger: 'change' }],
-        creditLimit: [{ required: true, message: '请输入单笔最大抵扣', trigger: 'blur' }]
+        productName: [ { required: true, message: '请输入商品名称', trigger: 'blur' } ],
+        shopGroupId: [ { required: true, message: '请选择商品分组', trigger: 'change' } ],
+        classifyId: [ { required: true, message: '请选择商品分类', trigger: 'change' } ],
+        ifLogistics: [ { required: true, message: '请选择是否需要物流', trigger: 'change' } ],
+        shelveState: [ { required: true, message: '请选择是否上架', trigger: 'change' } ],
+        ifOversold: [ { required: true, message: '请选择是否允许超卖', trigger: 'change' } ],
+        ifCredit: [ { required: true, message: '请选择是否支持积分兑换', trigger: 'change' } ],
+        creditLimit: [ { required: true, message: '请输入单笔最大抵扣', trigger: 'blur' } ]
       },
       integralList: [],
       integralProportion: '' // 积分兑换金额比例

+ 84 - 34
src/views/commodity/commoditySystem/addComponent.vue

@@ -2,17 +2,24 @@
   <div class="style-information-component">
     <el-form-item label="商品图片" />
     <div class="upload-wrap">
-      <el-upload list-type="picture-card" :on-preview="handlePictureCardPreview" :on-remove="handleRemove"
-        :headers="headers" :data="dataObj" :file-list="form.imgs" :limit="20" :on-success="handleImageSuccess"
-        :action="action">
+      <el-upload
+        list-type="picture-card" :on-preview="handlePictureCardPreview" :on-remove="handleRemove"
+        :headers="headers" :data="dataObj" :file-list="form.imgs" :limit="20"
+        :on-success="handleImageSuccess"
+        :action="action"
+      >
         <i slot="default" class="el-icon-plus" />
         <div slot="file" slot-scope="{ file }">
           <img v-if="!isVideo(file.imgPath)" class="el-upload-list__item-thumbnail" :src="file.imgPath">
-          <video v-else class="el-upload-list__item-thumbnail" style="width: 148px;height: 148px;" 
-            :src="file.imgPath"></video>
+          <video
+            v-else class="el-upload-list__item-thumbnail" style="width: 148px;height: 148px;"
+            :src="file.imgPath"
+          ></video>
           <span class="el-upload-list__item-actions">
-            <span v-if="!isVideo(file.imgPath)" class="el-upload-list__item-preview"
-              @click="handlePictureCardPreview(file)">
+            <span
+              v-if="!isVideo(file.imgPath)" class="el-upload-list__item-preview"
+              @click="handlePictureCardPreview(file)"
+            >
               <i class="el-icon-zoom-in" />
             </span>
             <span @click="playVideo(file.imgPath)">
@@ -42,29 +49,39 @@
           <el-table-column label="售价">
             <template slot-scope="scope">
               <!-- <el-input v-model="scope.row.price" type="number" oninput="value=value.replace(/-/, '')" /> -->
-              <el-input-number v-model="scope.row.price" :controls="false" :max="999999999" :min="0" :precision="2"
-                :step="0.01" />
+              <el-input-number
+                v-model="scope.row.price" :controls="false" :max="999999999" :min="0"
+                :precision="2"
+                :step="0.01"
+              />
             </template>
           </el-table-column>
           <el-table-column label="原价">
             <template slot-scope="scope">
               <!-- <el-input v-model="scope.row.originalPrice" type="number" oninput="value=value.replace(/-/, '')" /> -->
-              <el-input-number v-model="scope.row.originalPrice" :controls="false" :max="999999999" :min="0"
-                :precision="2" :step="0.01" />
+              <el-input-number
+                v-model="scope.row.originalPrice" :controls="false" :max="999999999" :min="0"
+                :precision="2" :step="0.01"
+              />
             </template>
           </el-table-column>
           <el-table-column label="库存">
             <template slot-scope="scope">
               <!-- <el-input v-model="scope.row.stockNumber" type="number" oninput="value=value.replace(/[^\d]/g,'')" /> -->
-              <el-input-number v-model="scope.row.stockNumber" :controls="false" :max="999999999" :min="0"
-                :precision="0" />
+              <el-input-number
+                v-model="scope.row.stockNumber" :controls="false" :max="999999999" :min="0"
+                :precision="0"
+              />
             </template>
           </el-table-column>
           <el-table-column label="重量(KG)">
             <template slot-scope="scope">
               <!-- <el-input v-model="scope.row.weight" type="number" oninput="value=value.replace(/-/, '')" /> -->
-              <el-input-number v-model="scope.row.weight" :controls="false" :max="999" :min="0" :precision="2"
-                :step="0.01" />
+              <el-input-number
+                v-model="scope.row.weight" :controls="false" :max="999" :min="0"
+                :precision="2"
+                :step="0.01"
+              />
             </template>
           </el-table-column>
           <el-table-column label="代金卷最大抵扣额度(一般设置全额抵扣)">
@@ -98,14 +115,17 @@
           <el-form-item label="规格值">
             <div class="attr-value-list">
               <div v-for="(sku, index1) in skuAttr.values" :key="index + '-' + index1" class="main-diagram m-8">
-                <el-input v-model="sku.skuValue" maxlength="10" />
+                <el-input v-model="sku.skuValue" maxlength="10" />{{ index === 0 && index1 === 0 }}
                 <i v-if="index === 0 && index1 === 0" />
                 <i v-else class="el-icon-close delImg" @click="delValue(index, index1)" />
                 <div v-if="skuAttr.needImg && index === 0" class="upload-wrap diagram-upload">
                   <div class="span-wrap">
-                    <el-upload list-type="picture-card" :show-file-list="false" :on-preview="handlePictureCardPreview"
-                      :on-remove="handleRemove" :headers="headers" :data="dataObj" :file-list="[sku]" :multiple="false"
-                      :on-success="handleImageSuccess1" :action="action">
+                    <el-upload
+                      list-type="picture-card" :show-file-list="false" :on-preview="handlePictureCardPreview"
+                      :on-remove="handleRemove" :headers="headers" :data="dataObj" :file-list="[ sku ]"
+                      :multiple="false"
+                      :on-success="handleImageSuccess1" :action="action"
+                    >
                       <i v-if="!sku.image" slot="trigger" class="el-icon-plus" />
                       <div v-else class="attr-value-img">
                         <img class="attr-thumbnail" :src="sku.image">
@@ -132,37 +152,47 @@
             <template slot-scope="scope">
               {{
                 scope.row.skuAttrCodeDTOList &&
-                scope.row.skuAttrCodeDTOList[index]
-                | attrValueFilter(form.skuAttrList)
+                  scope.row.skuAttrCodeDTOList[index]
+                  | attrValueFilter(form.skuAttrList)
               }}
             </template>
           </el-table-column>
           <el-table-column label="售价">
             <template slot-scope="scope">
               <!-- <el-input v-model="scope.row.price" type="number" oninput="value=value.replace(/-/, '')" /> -->
-              <el-input-number v-model="scope.row.price" :controls="false" :max="999999999" :min="0" :precision="2"
-                :step="0.01" />
+              <el-input-number
+                v-model="scope.row.price" :controls="false" :max="999999999" :min="0"
+                :precision="2"
+                :step="0.01"
+              />
             </template>
           </el-table-column>
           <el-table-column label="原价">
             <template slot-scope="scope">
               <!-- <el-input v-model="scope.row.originalPrice" type="number" oninput="value=value.replace(/-/, '')" /> -->
-              <el-input-number v-model="scope.row.originalPrice" :controls="false" :max="999999999" :min="0"
-                :precision="2" :step="0.01" />
+              <el-input-number
+                v-model="scope.row.originalPrice" :controls="false" :max="999999999" :min="0"
+                :precision="2" :step="0.01"
+              />
             </template>
           </el-table-column>
           <el-table-column label="库存">
             <template slot-scope="scope">
               <!-- <el-input v-model="scope.row.stockNumber" type="number" oninput="value=value.replace(/[^\d]/g,'')" /> -->
-              <el-input-number v-model="scope.row.stockNumber" :controls="false" :max="999999999" :min="0"
-                :precision="0" />
+              <el-input-number
+                v-model="scope.row.stockNumber" :controls="false" :max="999999999" :min="0"
+                :precision="0"
+              />
             </template>
           </el-table-column>
           <el-table-column label="重量(KG)">
             <template slot-scope="scope">
               <!-- <el-input v-model="scope.row.weight" type="number" oninput="value=value.replace(/-/, '')" /> -->
-              <el-input-number v-model="scope.row.weight" :controls="false" :max="999" :min="0" :precision="6"
-                :step="0.01" />
+              <el-input-number
+                v-model="scope.row.weight" :controls="false" :max="999" :min="0"
+                :precision="6"
+                :step="0.01"
+              />
             </template>
           </el-table-column>
           <el-table-column label="代金卷最大抵扣额度(一般设置全额抵扣)">
@@ -192,13 +222,17 @@
         </el-table>
       </div>
     </div>
-    <el-dialog :append-to-body="true" :visible.sync="dialogVisible" class="check-image-dialog" title="查看图片"
-      center="center">
+    <el-dialog
+      :append-to-body="true" :visible.sync="dialogVisible" class="check-image-dialog" title="查看图片"
+      center="center"
+    >
       <img width="100%" :src="dialogImageUrl" alt>
     </el-dialog>
 
-    <el-dialog width="30%" :append-to-body="true" :visible.sync="previewVideoVisible" class="check-image-dialog"
-      title="预览视频" center="center">
+    <el-dialog
+      width="30%" :append-to-body="true" :visible.sync="previewVideoVisible" class="check-image-dialog"
+      title="预览视频" center="center"
+    >
       <div style="display: flex; align-items: center; justify-content: center;">
         <video controls autoplay muted style="width: 400px; height: 400px;" :src="dialogVideoUrl"></video>
       </div>
@@ -211,6 +245,8 @@ import { uploadUrl } from '@/utils/request'
 import { getToken } from '@/utils/auth'
 import { isVideo } from '@/utils/index'
 export default {
+  // eslint-disable-next-line vue/match-component-file-name, vue/component-definition-name-casing
+  name: 'addComponent',
   filters: {
     attrValueFilter(map, list) {
       const hasChilds =
@@ -224,6 +260,7 @@ export default {
       }
       const { code, valueCode } = map
       let codeStr = ''
+      // eslint-disable-next-line array-callback-return
       hasChilds.map((item) => {
         const { values } = item
         values &&
@@ -247,6 +284,7 @@ export default {
     },
     voucherList: {
       type: Array,
+      // eslint-disable-next-line vue/require-valid-default-prop
       default: []
     }
   },
@@ -291,7 +329,7 @@ export default {
         return this.form.skuList.slice(0, 1)
       }
       return this.form.skuList
-    },
+    }
 
   },
   watch: {
@@ -355,6 +393,7 @@ export default {
     },
     handleImageSuccess(response) {
       const url = response.data.url
+      // eslint-disable-next-line vue/no-mutating-props
       this.form.imgs.push({
         imgPath: url
       })
@@ -362,6 +401,7 @@ export default {
     // 移除图片
     handleRemove(file) {
       const { imgPath } = file
+      // eslint-disable-next-line vue/no-mutating-props
       this.form.imgs = this.form.imgs.filter((item) => item.imgPath !== imgPath)
     },
     handleRemove1(file) {
@@ -391,6 +431,7 @@ export default {
       // }
     },
     addSkuAttrList() {
+      // eslint-disable-next-line vue/no-mutating-props
       this.form.skuAttrList.push({
         code: '',
         skuName: '',
@@ -409,6 +450,7 @@ export default {
       })
     },
     addAttrValue(index) {
+      // eslint-disable-next-line vue/no-mutating-props
       this.form.skuAttrList[index].values.push({
         skuValue: '',
         valueCode: '',
@@ -423,7 +465,9 @@ export default {
         skuId: newList.skuId,
         valueCode: newList.values[index1].valueCode
       }
+      // eslint-disable-next-line vue/no-mutating-props
       this.form.deletes.push(valueObj)
+      // eslint-disable-next-line vue/no-mutating-props
       this.form.skuAttrList[index].values.splice(index1, 1)
     },
     // 删除规格名
@@ -436,8 +480,10 @@ export default {
           valueCode: ''
         }
         valueObj.valueCode = item.valueCode
+        // eslint-disable-next-line vue/no-mutating-props
         this.form.deletes.push(valueObj)
       })
+      // eslint-disable-next-line vue/no-mutating-props
       this.form.skuAttrList.splice(index, 1)
     },
     delAttrValue1(row, index, arr) {
@@ -483,11 +529,13 @@ export default {
       // this.form.skuList  = skuListArray
       // 获取规格值的所有组合
       const values = []
+      // eslint-disable-next-line array-callback-return
       this.form.skuAttrList.map((skuItem, index) => {
         const attrList = []
         skuItem.code = skuItem.code || 'attr_code_' + index
         const { code } = skuItem
         skuItem.values &&
+          // eslint-disable-next-line array-callback-return
           skuItem.values.map((attrItem, index1) => {
             attrItem.valueCode = skuItem.valueCode || code + '_value_' + index1
             const skuId = attrItem.skuId
@@ -509,6 +557,7 @@ export default {
       if (values.length) {
         doExchange(values, 0)
       }
+      // eslint-disable-next-line vue/no-mutating-props
       this.form.skuList = skuListArray.map((sku1) => {
         const { skuAttrList, skuAttrCodeDTOList } = sku1
         const skuAttrList1 = skuAttrCodeDTOList || skuAttrList
@@ -551,6 +600,7 @@ export default {
     flex-wrap: wrap;
 
     .main-diagram {
+      position: relative;
       width: 180px;
 
       .span-wrap {