yuwenjun 4 éve
szülő
commit
b89e9ee165

+ 2 - 1
.env.development

@@ -2,7 +2,8 @@
 ENV = 'development'
 
 # base api
-VUE_APP_BASE_API = 'http://192.168.2.68:8012'
+# VUE_APP_BASE_API = 'http://192.168.2.68:8012'
+VUE_APP_BASE_API = 'https://zplma-b.caimei365.com'
 
 # 文件上传
 VUE_APP_UPLOAD_API='https://zplma-b.caimei365.com'

+ 4 - 1
src/components/qrcode/index.vue

@@ -43,7 +43,8 @@ export default {
     }
   },
   created() {
-    this.qrcodePath = `${this.wwwServer}/product/auth/product-${this.productInfo?.productId}.html`
+    console.log(this.productInfo)
+
     this.initQrcode()
   },
   methods: {
@@ -65,6 +66,7 @@ export default {
     },
     // 初始化二维码
     async initQrcode() {
+      this.qrcodePath = `${this.wwwServer}/product/auth/product-${this.productInfo?.productId}.html`
       // 二维码配置
       const options = {
         width: 192,
@@ -79,6 +81,7 @@ export default {
     },
     // 生成下载的文件
     async createDownFile(callback) {
+      this.qrcodePath = `${this.wwwServer}/product/auth/product-${this.productInfo?.productId}.html`
       const strHeader = this.productInfo.productName
       const strFooter1 = '仪器SN码:'
       const strFooter2 = this.hanldeSNcode(this.productInfo.snCode)

+ 3 - 1
src/layout/components/Sidebar/Logo.vue

@@ -25,7 +25,9 @@ export default {
   data() {
     return {
       title: '正品联盟管理系统',
-      logo: 'https://wpimg.wallstcn.com/69a1c46c-eb1c-4b46-8bd4-e9e686ef5251.png'
+      // logo: 'https://wpimg.wallstcn.com/69a1c46c-eb1c-4b46-8bd4-e9e686ef5251.png'
+      // logo: 'https://zplm-b.caimei365.com/logo.png'
+      logo: 'https://zplm-b.caimei365.com/logo.svg'
     }
   }
 }

+ 4 - 1
src/permission.js

@@ -69,8 +69,11 @@ router.beforeEach(async(to, from, next) => {
     } else {
       // other pages that do not have permission to access are redirected to the login page.
       next(`/login`)
-      Message.error('登录失效,请重新登录!')
+      // Message.error('登录失效,请重新登录!')
+      Message({ message: '登录失效,请重新登录!' })
+      // router.replace('/login')
       NProgress.done()
+      return
     }
   }
 })

+ 1 - 1
src/settings.js

@@ -1,5 +1,5 @@
 module.exports = {
-  title: 'Vue Element Admin',
+  title: '正品联盟后台管理系统',
 
   /**
    * @type {boolean} true | false

+ 4 - 2
src/utils/request.js

@@ -8,7 +8,7 @@ import router from '@/router'
 const service = axios.create({
   baseURL: process.env.VUE_APP_BASE_API, // url = base url + request url
   // withCredentials: true, // send cookies when cross-domain requests
-  timeout: 5000 // request timeout
+  timeout: 6000 // request timeout
 })
 
 // request interceptor
@@ -51,6 +51,7 @@ service.interceptors.response.use(
     if (res.code === -99) {
       Message({ message: '登录失效,请重新登录!' })
       router.replace('/login')
+      return
     }
 
     // 返回不成功
@@ -60,7 +61,8 @@ service.interceptors.response.use(
         type: 'error',
         duration: 5 * 1000
       })
-      return Promise.reject(new Error(res.message || 'Error'))
+      // return Promise.reject(new Error(res.message || 'Error'))
+      return
     } else {
       return res
     }

+ 1 - 1
src/utils/validate.js

@@ -91,7 +91,7 @@ export function isArray(arg) {
  * @returns {Boolean}
  */
 export function isMobile(arg) {
-  const reg = /^(13[0-9]|14[5|7]|15[0|1|2|3|4|5|6|7|8|9]|18[0|1|2|3|5|6|7|8|9])\d{8}$/
+  const reg = /^1[3456789]\d{9}$/
   return reg.test(arg)
 }
 

+ 6 - 2
src/views/login/index.vue

@@ -18,6 +18,7 @@
           type="text"
           tabindex="1"
           autocomplete="on"
+          @input="handleInput"
         />
       </el-form-item>
 
@@ -45,7 +46,7 @@
         </el-form-item>
       </el-tooltip>
 
-      <el-button :loading="loading" type="primary" style="width:100%;margin-bottom:30px;" @click.native.prevent="handleLogin">登录</el-button>
+      <el-button :loading="loading" type="primary" style="width:100%;margin-bottom:44px;" @click.native.prevent="handleLogin">登录</el-button>
     </el-form>
   </div>
 </template>
@@ -62,7 +63,7 @@ export default {
         password: ''
       },
       loginRules: {
-        username: [{ required: true, trigger: 'blur', message: '请输入登录账号' }],
+        username: [{ required: true, trigger: 'blur', message: '请输入登录账号(英文+数字)' }],
         password: [{ required: true, trigger: 'blur', message: '请输入登录密码' }]
       },
       passwordType: 'password',
@@ -143,6 +144,9 @@ export default {
         }
         return acc
       }, {})
+    },
+    handleInput() {
+      this.loginForm.username = this.loginForm.username.replace(/[^\w\.\/]/ig, '')
     }
     // afterQRScan() {
     //   if (e.key === 'x-admin-oauth-code') {

+ 1 - 1
src/views/supplier/auth/index.vue

@@ -101,7 +101,7 @@ export default {
       if (!time) {
         return ''
       }
-      return formatDate(time, 'yyyy-MM-DD hh:mm:ss')
+      return formatDate(time, 'yyyy-MM-DD HH:mm:ss')
     }
   },
   data() {

+ 28 - 16
src/views/supplier/components/uploadFile.vue

@@ -8,28 +8,32 @@
       :action="action"
       :file-list="fileList"
       :auto-upload="false"
+      :headers="headers"
       :on-success="success"
       :accept="accept"
-      :on-change="handleChange"
-      :class="{hidden:!showUpload}"
-      :on-remove="handleRemove"
+      :before-upload="beforeUpload"
     >
       <el-button slot="trigger" size="mini" type="primary">选取文件</el-button>
-      <el-button style="margin-left: 10px;" size="mini" type="success" @click="uploadFile">上传</el-button>
-      <div slot="tip" class="el-upload__tip">只能上传.doc/.ppt/.pdf文件,且不超过1MB</div>
+      <!-- <el-button style="margin-left: 10px;" size="mini" type="success" @click="uploadFile">上传</el-button> -->
+      <div slot="tip" class="el-upload__tip">只能上传.doc/.ppt/.pdf文件,且不超过2MB</div>
     </el-upload>
   </div>
 </template>
 
 <script>
-
+import { mapGetters } from 'vuex'
 export default {
   props: {
     fileList: {
       type: Array,
       default: () => []
+    },
+    authUserId: {
+      type: Number,
+      default: -1
     }
   },
+
   data() {
     return {
       // 图片上传接口
@@ -37,11 +41,20 @@ export default {
       accept: '.doc,.ppt,.pdf',
       // 请求参数
       params: {
-        authUserId: this.$store.getters.authUserId
+        authUserId: null
+      },
+      headers: {
+        'X-Token': ''
       },
       showUpload: true
     }
   },
+  computed: {
+    ...mapGetters(['token'])
+  },
+  created() {
+    this.headers['X-Token'] = this.token
+  },
   methods: {
     success(response) {
       this.$emit('success', response)
@@ -50,18 +63,17 @@ export default {
       this.$emit('error', err, file, fileList)
     },
     uploadFile() {
+      this.params.authUserId = this.authUserId || -1
       this.$refs.upload.submit()
     },
-    handleChange(file, fileList) {
-      console.log(fileList)
-      if (fileList === 0) {
-        this.showUpload = true
-      } else {
-        this.showUpload = false
+    // 图片上传之前的钩子
+    beforeUpload(file) {
+      this.params.authUserId = this.authUserId || -1
+      const size = file.size
+      if (size > 1024 * 2000) {
+        this.$message.warning('文件上传大小超出限制(≤2MB)')
+        return false
       }
-    },
-    handleRemove(file, fileList) {
-      this.showUpload = true
     }
   }
 }

+ 13 - 16
src/views/supplier/components/uploadImage.vue

@@ -3,6 +3,7 @@
     <el-upload
       ref="upload"
       :action="action"
+      :headers="headers"
       list-type="picture-card"
       :on-preview="handlePictureCardPreview"
       :before-upload="beforeUpload"
@@ -10,11 +11,9 @@
       :accept="accept"
       :auto-upload="true"
       :on-success="success"
-      :on-remove="handleRemove"
       :file-list="fileList"
-      :on-change="handleChange"
-      :class="{hidden:!showUpload}"
     >
+      <!-- :class="{hidden:(hasUpload && fileList===[]) || !hasUpload}" -->
       <i class="el-icon-plus" />
     </el-upload>
     <el-dialog :visible.sync="dialogVisible">
@@ -25,6 +24,7 @@
 
 <script>
 // import { uploadImage } from '@/api/upload'
+import { mapGetters } from 'vuex'
 export default {
   props: {
     fileList: {
@@ -38,10 +38,18 @@ export default {
       dialogVisible: false,
       // 文件上传请求接口
       action: process.env.VUE_APP_UPLOAD_API + '/upload/image',
-      accept: '.jpg,.png,.gif',
-      showUpload: true
+      headers: {
+        'X-Token': ''
+      },
+      accept: '.jpg,.png,.gif'
     }
   },
+  computed: {
+    ...mapGetters(['token'])
+  },
+  created() {
+    this.headers['X-Token'] = this.token
+  },
   methods: {
     // 预览图片
     handlePictureCardPreview(file) {
@@ -63,17 +71,6 @@ export default {
         this.$message.warning('文件上传大小超出限制(≤1MB)')
         return false
       }
-    },
-    handleChange(file, fileList) {
-      console.log(fileList)
-      if (fileList === 0) {
-        this.showUpload = true
-      } else {
-        this.showUpload = false
-      }
-    },
-    handleRemove(file, fileList) {
-      this.showUpload = true
     }
   }
 }

+ 2 - 1
src/views/supplier/product/index.vue

@@ -76,7 +76,7 @@ export default {
       if (!time) {
         return ''
       }
-      return formatDate(time, 'yyyy-MM-DD hh:mm:ss')
+      return formatDate(time, 'yyyy-MM-DD HH:mm:ss')
     }
   },
 
@@ -162,6 +162,7 @@ export default {
     // 显示二维码
     handleShowQRcode(item) {
       this.showQRcode = true
+      console.log(item)
       this.productInfo = item
     }
   }

+ 96 - 37
src/views/supplier/user/add.vue

@@ -14,12 +14,12 @@
       </el-form-item>
 
       <el-form-item v-if="addData.shopType===1" label="供应商名称:" prop="shopName">
-        <el-select v-model="selectedBrandIndex" placeholder="请选择品牌" style="width: 100%" filterable @change="setShopName">
+        <el-select v-model="addData.brandId" placeholder="请选择品牌" style="width: 100%" filterable @change="setShopName">
           <el-option
-            v-for="(item,index) in brandList"
+            v-for="(item) in brandList"
             :key="item.id"
             :label="item.name"
-            :value="index"
+            :value="item.id"
           />
         </el-select>
       </el-form-item>
@@ -77,7 +77,7 @@
           <el-input v-model="addData.statementImage" type="hidden" class="hiddenInput" />
         </el-form-item>
         <el-form-item v-else label="文件:" prop="statementFileId">
-          <upload-file v-if="addData.statementType === 4" ref="uploadFileRef" @success="fileUploadSuccess" @error="fileUploadFaild" />
+          <upload-file v-if="addData.statementType === 4" ref="uploadFileRef" :auth-user-id="addData.authUserId" @success="fileUploadSuccess" @error="fileUploadFaild" />
           <el-input v-model="addData.statementFileId" type="hidden" class="hiddenInput" />
         </el-form-item>
 
@@ -90,7 +90,7 @@
       </el-form-item>
     </el-form>
     <div class="submit-btn">
-      <el-button type="primary" @click="save">保存</el-button>
+      <el-button type="primary" @click="submit">保存</el-button>
       <el-button type="warning" @click="$_back()">返回</el-button>
     </div>
   </div>
@@ -118,7 +118,7 @@ export default {
       isLoading: false,
 
       addData: {
-        authUserId: '', // 供应商id
+        authUserId: null, // 供应商id
         brandAuthLogo: '', //	品牌授权logo
         brandId: '', // 品牌id
         countryId: 1, // 产地国家id
@@ -131,7 +131,7 @@ export default {
         shopType: 1, //	供应商类型:1品牌方,2代理商
         statementContent: '', // 声明弹窗内容
         statementLink: '', // 声明链接
-        statementFileId: '', //	声明文件id
+        statementFileId: -1, //	声明文件id
         statementImage: '', // 声明图片
         statementType: 1 // 代理声明类型:1弹窗 2链接 3图片 4文件(.doc .ppt .pdf)
       },
@@ -147,7 +147,7 @@ export default {
         linkMan: [{ required: true, message: '联系人不能为空', trigger: 'blur' }],
         countryId: [{ required: true, message: '产地不能为空', trigger: 'change' }],
         brandAuthLogo: [{ required: true, message: '品牌logo不能为空' }],
-        brandId: [{ required: true, message: '所属品牌不能为空', trigger: 'change' }],
+        brandId: [{ required: true, message: '所属品牌不能为空', trigger: 'blur' }],
         statementContent: [{ required: true, message: '声明不能为空', trigger: 'blur' }],
         statementLink: [{ required: true, message: '声明链接不能为空', trigger: 'blur' }],
         statementImage: [{ required: true, message: '声明图片不能为空' }],
@@ -170,6 +170,7 @@ export default {
     initAddForm() {
       // this.addData.authUserId = this.authUserId
       this.getBrandList()
+      this.addData.shopName = ''
     },
     // 获取品牌列表
     getBrandList() {
@@ -181,49 +182,80 @@ export default {
         }
       }).catch(err => console.log(err))
     },
-    // 保存表单数据
-    async save() {
+    // 提交表单数据
+    async submit() {
       this.isLoading = true
-      this.addData.createBy = this.authUserId
-      const that = this
-      // this.uploadFile()
-      await this.$refs.addFormRef.validate(valide => {
-        if (!valide) {
-          this.isLoading = false
-          return
-        }
-        addSupplier(that.addData).then(res => {
-          console.log(res)
-          this.$message.success('添加成功')
-          // this.$refs.addFormRef.resetFields()
-        }).finally(() => {
-          this.isLoading = false
-          this.$refs.addFormRef.resetFields()
-          this.addData.securityLink = ''
+      if (this.addData.statementType === 4) {
+        debugger
+        console.log(this.$refs)
+        this.$refs.uploadFileRef.$refs.upload.submit()
+      } else {
+        await this.$refs.addFormRef.validate(valide => {
+          if (!valide) {
+            this.isLoading = false
+            return
+          }
+          this.save()
         })
+      }
+    },
+    // 保存
+    async save() {
+      this.addData.createBy = this.authUserId
+      addSupplier(this.addData).then(res => {
+        console.log(res)
+        this.$message.success('添加成功')
+        this.$refs.addFormRef.resetFields()
+        this.clearFormData()
+        this.$router.replace('/supplier')
+      }).finally(() => {
+        this.isLoading = false
+        this.$refs.addFormRef.resetFields()
+        this.addData.securityLink = ''
       })
     },
     // 设置品牌名称
-    setShopName(index) {
+    setShopName(id) {
       const fileList = []
+      let selectBrand = {}
+      this.brandList.forEach((item, index) => {
+        if (item.id === id) {
+          selectBrand = item
+          return
+        }
+      })
+      console.log(selectBrand)
       if (this.addData.shopType === 1) {
-        this.addData.shopName = this.brandList[index]?.name
+        this.addData.shopName = selectBrand.name
       }
-      this.addData.brandAuthLogo = this.brandList[index]?.authLogo || ''
-      if (this.brandList[index]?.authLogo) {
-        fileList.push({ name: this.addData.shopName, url: this.brandList[index]?.authLogo || '' })
+      this.addData.brandAuthLogo = selectBrand.authLogo
+      if (selectBrand.authLogo) {
+        fileList.push({ name: this.addData.shopName, url: selectBrand.authLogo || '' })
       }
       this.fileList1 = fileList
+      // const fileList = []
+      // if (this.addData.shopType === 1) {
+      //   this.addData.shopName = this.brandList[index]?.name
+      // }
+      // this.addData.brandAuthLogo = this.brandList[index]?.authLogo || ''
+      // if (this.brandList[index]?.authLogo) {
+      //   fileList.push({ name: this.addData.shopName, url: this.brandList[index]?.authLogo || '' })
+      // }
+      // this.fileList1 = fileList
     },
-    // 手动提交上传图片
-    // uploadFile() {
-    //   this.$refs.uploadImageRef1?.$refs.upload.submit()
-    //   this.$refs.uploadImageRef2?.$refs.upload.submit()
-    //   this.$refs.uploadfileRef?.$refs.upload.submit()
-    // },
     // 文件上传成功
     fileUploadSuccess(data) {
       this.addData.statementFileId = data.data
+      // this.uploadFile()
+      console.log(data)
+      this.$refs.addFormRef.validate(valide => {
+        if (!valide) {
+          this.isLoading = false
+          return
+        }
+        console.log(2)
+        this.save()
+      })
     },
     fileUploadFaild(err, file, fileList) {
       console.log(err)
@@ -243,7 +275,34 @@ export default {
     },
     imageUploadFaild2(err, file, fileList) {
       console.log(err)
+    }, // removeImage1() {
+    //   this.fileList1 = []
+    // },
+
+    clearFormData() {
+      this.addData = {
+        authUserId: '', // 供应商id
+        brandAuthLogo: '', //	品牌授权logo
+        brandId: '', // 品牌id
+        countryId: 1, // 产地国家id
+        createBy: '', // 创建人用户id
+        linkMan: '', // 联系人
+        mobile: '', // 手机号
+        securityLink: '', // 官网认证链接
+        shopName: '', // 供应商名称
+        shopStatus: 1, // 供应商状态:0停用 1启用
+        shopType: 1, //	供应商类型:1品牌方,2代理商
+        statementContent: '', // 声明弹窗内容
+        statementLink: '', // 声明链接
+        statementFileId: '', //	声明文件id
+        statementImage: '', // 声明图片
+        statementType: 1 // 代理声明类型:1弹窗 2链接 3图片 4文件(.doc .ppt .pdf)
+      }
+      this.fileList1 = []
+      this.fileList2 = []
+      this.fileList3 = []
     }
+
   }
 }
 </script>

+ 95 - 38
src/views/supplier/user/edit.vue

@@ -2,7 +2,7 @@
   <div v-loading="isLoading" class="addSupplier">
     <el-form ref="addFormRef" :model="addData" :rules="rules" label-width="120px" class="addForm">
       <el-form-item label="供应商类型:" prop="shopType">
-        <el-select v-model="addData.shopType" placeholder="请选择供应商类型" style="width: 100%" @change="getBrandList">
+        <el-select v-model="addData.shopType" placeholder="请选择供应商类型" style="width: 100%" disabled @change="getBrandList">
           <el-option label="品牌方" :value="1" />
           <el-option label="代理商" :value="2" />
         </el-select>
@@ -10,16 +10,16 @@
 
       <!-- 供应商名称 -->
       <el-form-item v-if="addData.shopType===2" label="供应商名称:" prop="shopName">
-        <el-input v-model="addData.shopName" placeholder="请输入供应商名称" />
+        <el-input v-model="addData.shopName" placeholder="请输入供应商名称" disabled />
       </el-form-item>
 
       <el-form-item v-if="addData.shopType===1" label="供应商名称:" prop="shopName">
-        <el-select v-model="selectedBrandIndex" placeholder="请选择品牌" style="width: 100%" filterable @change="setShopName">
+        <el-select v-model="addData.brandId" placeholder="请选择品牌" style="width: 100%" filterable disabled>
           <el-option
-            v-for="(item,index) in brandList"
+            v-for="(item) in brandList"
             :key="item.id"
             :label="item.name"
-            :value="index"
+            :value="item.id"
           />
         </el-select>
       </el-form-item>
@@ -34,10 +34,10 @@
       <el-form-item v-if="addData.shopType===2" label="所属品牌:" prop="brandId">
         <el-select v-model="addData.brandId" placeholder="请选择所属品牌" style="width: 100%" filterable @change="setShopName">
           <el-option
-            v-for="(item,index) in brandList"
+            v-for="(item) in brandList"
             :key="item.id"
             :label="item.name"
-            :value="index"
+            :value="item.id"
           />
         </el-select>
       </el-form-item>
@@ -77,7 +77,7 @@
           <el-input v-model="addData.statementImage" type="hidden" class="hiddenInput" />
         </el-form-item>
         <el-form-item v-else label="文件:" prop="statementFileId">
-          <upload-file v-if="addData.statementType === 4" ref="uploadFileRef" :file-list="fileList3" @success="fileUploadSuccess" @error="fileUploadFaild" />
+          <upload-file v-if="addData.statementType === 4" ref="uploadFileRef" :auth-user-id="addData.authUserId" :file-list="fileList3" @success="fileUploadSuccess" @error="fileUploadFaild" />
           <el-input v-model="addData.statementFileId" type="hidden" class="hiddenInput" />
         </el-form-item>
 
@@ -90,7 +90,7 @@
       </el-form-item>
     </el-form>
     <div class="submit-btn">
-      <el-button type="primary" @click="save">保存</el-button>
+      <el-button type="primary" @click="submit">保存</el-button>
       <el-button type="warning" @click="$_back()">返回</el-button>
     </div>
   </div>
@@ -118,7 +118,7 @@ export default {
       isLoading: false,
 
       addData: {
-        authUserId: '', // 供应商id
+        authUserId: null, // 供应商id
         brandAuthLogo: '', //	品牌授权logo
         brandId: '', // 品牌id
         countryId: 1, // 产地国家id
@@ -151,8 +151,8 @@ export default {
         brandId: [{ required: true, message: '所属品牌不能为空', trigger: 'change' }],
         statementContent: [{ required: true, message: '声明不能为空', trigger: 'blur' }],
         statementLink: [{ required: true, message: '声明链接不能为空', trigger: 'blur' }],
-        statementImage: [{ required: true, message: '声明图片不能为空' }],
-        statementFileId: [{ required: true, message: '声明文件不能为空' }]
+        statementImage: [{ required: false, message: '声明图片不能为空' }],
+        statementFileId: [{ required: false, message: '声明文件不能为空' }]
       },
       fileList1: [], // 已上传的图片列表 品牌logo
       fileList2: [], // 已上传的图片列表 声明图片
@@ -180,6 +180,7 @@ export default {
       getSupplierById({ authUserId: id })
         .then(res => {
           if (res.code === 0) {
+            console.log(res.data)
             this.initAddForm(res.data)
           }
         })
@@ -216,46 +217,102 @@ export default {
     },
 
     // 保存表单数据
-    async save() {
+    // async save() {
+    //   this.isLoading = true
+    //   this.addData.createBy = this.authUserId
+    //   // this.uploadFile()
+    //   await this.$refs.addFormRef.validate(valide => {
+    //     if (!valide) {
+    //       this.isLoading = false
+    //       return
+    //     }
+    //     if (this.addData.statementFileId === 'no file') {
+    //       this.addData.statementFileId = null
+    //     }
+    //     addSupplier(this.addData).then(res => {
+    //       this.$message.success('修改成功')
+    //       // this.$refs.addFormRef.resetFields()
+    //     }).catch(err => {
+    //       console.log(err)
+    //       this.$message.danger('修改失败')
+    //     }).finally(() => {
+    //       this.isLoading = false
+    //       // this.addData.securityLink = ''
+    //     })
+    //   })
+    // },
+    // 提交表单数据
+    async submit() {
       this.isLoading = true
-      this.addData.createBy = this.authUserId
-      // this.uploadFile()
-      await this.$refs.addFormRef.validate(valide => {
-        if (!valide) {
-          this.isLoading = false
-          return
-        }
-        if (this.addData.statementFileId === 'no file') {
-          this.addData.statementFileId = null
-        }
-        addSupplier(this.addData).then(res => {
-          this.$message.success('修改成功')
-          // this.$refs.addFormRef.resetFields()
-        }).catch(err => {
-          console.log(err)
-          this.$message.danger('修改失败')
-        }).finally(() => {
-          this.isLoading = false
-          this.$refs.addFormRef.resetFields()
-          this.addData.securityLink = ''
+      if (this.addData.statementType === 4 && this.addData.statementFileId !== 'no file') {
+        console.log(this.$refs)
+        this.$refs.uploadFileRef.$refs.upload.submit()
+      } else {
+        this.addData.statementFileId = null
+        await this.$refs.addFormRef.validate(valide => {
+          if (!valide) {
+            this.isLoading = false
+            return
+          }
+          this.save()
         })
+      }
+    },
+    // 保存
+    async save() {
+      this.addData.createBy = this.authUserId
+      addSupplier(this.addData).then(res => {
+        console.log(res)
+        this.$message.success('修改成功')
+        // this.$refs.addFormRef.resetFields()
+        // this.clearFormData()
+      }).finally(() => {
+        this.isLoading = false
+        // this.$refs.addFormRef.resetFields()
+        this.addData.securityLink = ''
       })
     },
     // 设置品牌名称
-    setShopName(index) {
+    setShopName(id) {
       const fileList = []
+      let selectBrand = {}
+      this.brandList.forEach((item, index) => {
+        if (item.id === id) {
+          selectBrand = item
+          return
+        }
+      })
+      console.log(selectBrand)
       if (this.addData.shopType === 1) {
-        this.addData.shopName = this.brandList[index]?.name
+        this.addData.shopName = selectBrand.name
       }
-      this.addData.brandAuthLogo = this.brandList[index]?.authLogo || ''
-      if (this.brandList[index]?.authLogo) {
-        fileList.push({ name: this.addData.shopName, url: this.brandList[index]?.authLogo || '' })
+      this.addData.brandAuthLogo = selectBrand.authLogo
+      if (selectBrand.authLogo) {
+        fileList.push({ name: this.addData.shopName, url: selectBrand.authLogo || '' })
       }
       this.fileList1 = fileList
+      // const fileList = []
+      // if (this.addData.shopType === 1) {
+      //   this.addData.shopName = this.brandList[index]?.name
+      // }
+      // this.addData.brandAuthLogo = this.brandList[index]?.authLogo || ''
+      // if (this.brandList[index]?.authLogo) {
+      //   fileList.push({ name: this.addData.shopName, url: this.brandList[index]?.authLogo || '' })
+      // }
+      // this.fileList1 = fileList
     },
     // 文件上传成功
     fileUploadSuccess(data) {
       this.addData.statementFileId = data.data
+      console.log(data)
+      this.$refs.addFormRef.validate(valide => {
+        if (!valide) {
+          this.isLoading = false
+          return
+        }
+        console.log(2)
+        this.save()
+      })
     },
     fileUploadFaild(err, file, fileList) {
       console.log(err)

+ 33 - 4
src/views/supplier/user/index.vue

@@ -5,7 +5,7 @@
       <el-input v-model="listQuery.shopName" placeholder="供应商名称" style="width: 200px;" class="filter-item" @keyup.enter.native="handleFilter" />
       <span>供应商类型:</span>
       <el-select v-model="listQuery.shopType" placeholder="供应商类型" clearable style="width: 200px" class="filter-item">
-        <el-option label="供应商" :value="1" />
+        <el-option label="代理商" :value="1" />
         <el-option label="品牌方" :value="2" />
       </el-select>
       <span>所属品牌:</span>
@@ -39,7 +39,7 @@
       <el-table-column label="供应商类型" width="150px" align="center">
         <template v-slot="{row}">
           <span v-if="row.type === 1">品牌方</span>
-          <span v-if="row.type === 2">供应商</span>
+          <span v-if="row.type === 2">代理商</span>
         </template>
       </el-table-column>
       <el-table-column label="所属品牌" width="150px" align="center" prop="brandName" />
@@ -94,7 +94,7 @@ export default {
       if (!time) {
         return ''
       }
-      return formatDate(time, 'yyyy-MM-DD hh:mm:ss')
+      return formatDate(time, 'yyyy-MM-DD HH:mm:ss')
     }
   },
   data() {
@@ -113,14 +113,43 @@ export default {
         shopType: ''// 供应商类型
       },
       list: [],
-      brandList: [] // 品牌列表
+      brandList: [], // 品牌列表
+      prevData: ''
     }
   },
   created() {
+    // console.log(1)
+    // this.prevData = JSON.parse(window.localStorage.getItem('prevData')) || null
+    // if (this.prevData !== null) {
+    //   this.listQuery.pageNum = this.prevData.prevData
+    //   this.listQuery.pageSize = this.prevData.pageSize
+    // }
     this.getList()
     this.getBrandList()
   },
+  // mounted() {
+  //   if (this.prevData !== null) {
+  //     window.scrollTo(0, this.prevData.scroll)
+  //   }
+  //   this.addEventListenerScroll()
+  // },
   methods: {
+    // addEventListenerScroll() {
+    //   let timer = null
+    //   const that = this
+    //   window.addEventListener('scroll', function() {
+    //     clearTimeout(timer)
+    //     timer = setTimeout(() => {
+    //       // console.log(this.scrollY)
+    //       const data = JSON.stringify({
+    //         scroll: this.scrollY,
+    //         pageNum: that.listQuery.pageNum,
+    //         pageSize: that.listQuery.pageSize
+    //       })
+    //       window.localStorage.setItem('prevData', data)
+    //     }, 200)
+    //   })
+    // },
     // 获取列表数据
     getList() {
       this.listLoading = true