瀏覽代碼

删除拷贝文件

yuwenjun 3 年之前
父節點
當前提交
8d2777a58f
共有 2 個文件被更改,包括 0 次插入1318 次删除
  1. 0 629
      src/views/supplier/user/add copy.vue
  2. 0 689
      src/views/supplier/user/edit copy.vue

+ 0 - 629
src/views/supplier/user/add copy.vue

@@ -1,629 +0,0 @@
-<template>
-  <div v-loading="isLoading" class="addSupplier">
-    <el-form ref="addFromDataRef" :model="addFromData" :rules="addFromDataRules" label-width="120px" class="addForm">
-      <el-form-item label="供应商类型:" prop="shopType">
-        <el-select
-          v-model="addFromData.shopType"
-          placeholder="请选择供应商类型"
-          style="width: 100%"
-          @change="handleTypeChange"
-        >
-          <el-option label="品牌方" :value="1" />
-          <el-option label="代理商" :value="2" />
-        </el-select>
-      </el-form-item>
-
-      <!-- 供应商名称 -->
-      <el-form-item v-if="addFromData.shopType === 2" label="供应商名称:" prop="shopName">
-        <el-input v-model="addFromData.shopName" placeholder="请输入供应商名称" maxlength="50" show-word-limit />
-      </el-form-item>
-
-      <el-form-item v-if="addFromData.shopType === 1" label="供应商名称:" prop="brandId">
-        <el-select
-          v-model="addFromData.brandId"
-          placeholder="请选择品牌"
-          style="width: 100%"
-          filterable
-          @change="setShopName"
-        >
-          <el-option v-for="item in brandList" :key="item.id" :label="item.name" :value="item.id" />
-        </el-select>
-      </el-form-item>
-      <!-- 供应商名称END -->
-
-      <el-form-item label="手机号:" prop="mobile">
-        <el-input v-model="addFromData.mobile" placeholder="请输入手机号" maxlength="11" show-word-limit @input="handleInput" />
-      </el-form-item>
-
-      <el-form-item label="联系人:" prop="linkMan">
-        <el-input v-model="addFromData.linkMan" placeholder="请输入联系人" />
-      </el-form-item>
-
-      <el-form-item v-if="addFromData.shopType === 2" label="代理品牌:" prop="shopInfo" class="brand-list">
-        <template v-if="supplierBrands !== []">
-          <el-tag v-for="(brand , index) in supplierBrands" :key="index" closable type="success" @close="handleRemove(index)" @click="handleShowInfo(index)">{{ brand.brandName }}</el-tag>
-        </template>
-        <el-tag type="primary" @click="handleShowDialog">添加品牌<span class="el-icon-plus" /></el-tag>
-        <!-- <el-input v-model="addFromData.shopInfo" class="hiddenInput" /> -->
-      </el-form-item>
-
-      <template v-if="addFromData.shopType === 1">
-        <el-form-item label="产地:" prop="countryId">
-          <el-select v-model="addFromData.countryId" placeholder="产地" style="width: 100%" filterable>
-            <el-option
-              v-for="item in countryList"
-              :key="item.countryId"
-              :label="item.countryName"
-              :value="item.countryId"
-            />
-          </el-select>
-        </el-form-item>
-
-        <el-form-item label="品牌logo:" class="no-input" prop="brandAuthLogo">
-          <upload-image
-            ref="uploadImageRef1"
-            :file-list="fileList1"
-            @success="imageUploadSuccess1"
-            @error="imageUploadFaild1"
-            @remove="imageRemove1"
-          />
-          <el-input v-model="addFromData.brandAuthLogo" type="hidden" class="hiddenInput" />
-        </el-form-item>
-
-        <el-form-item label="官网认证链接:">
-          <el-input v-model="addFromData.securityLink" placeholder="请输入官网认证链接" />
-        </el-form-item>
-      </template>
-
-      <el-form-item label="供应商状态:">
-        <el-select v-model="addFromData.shopStatus" placeholder="请选择供应商状态" style="width: 100%">
-          <el-option label="启用" :value="1" />
-          <el-option label="禁用" :value="0" />
-        </el-select>
-      </el-form-item>
-    </el-form>
-    <div class="submit-btn">
-      <el-button type="primary" @click="submit">保存</el-button>
-      <el-button type="warning" @click="$_back()">返回</el-button>
-    </div>
-
-    <!-- 供应商添加品牌的对话框 -->
-    <el-dialog v-loading="dialogLoading" title="添加代理品牌" :visible.sync="showDialog" width="width" @closed="dialogClosed">
-      <el-form ref="brandDataRef" :model="brandData" :rules="brandDataRules" label-width="120px">
-
-        <el-form-item label="选择品牌:" prop="brandId">
-          <el-select
-            v-model="brandData.brandId"
-            placeholder="请选择品牌"
-            style="width: 100%"
-            filterable
-            @change="setShopName"
-          >
-            <el-option v-for="item in brandListCody" :key="item.id" :label="item.name" :value="item.id" />
-          </el-select>
-        </el-form-item>
-
-        <el-form-item label="产地:" prop="countryId">
-          <el-select v-model="brandData.countryId" placeholder="产地" style="width: 100%" filterable>
-            <el-option
-              v-for="item in countryList"
-              :key="item.countryId"
-              :label="item.countryName"
-              :value="item.countryId"
-            />
-          </el-select>
-        </el-form-item>
-
-        <el-form-item label="品牌logo:" class="no-input" prop="brandAuthLogo">
-          <upload-image
-            ref="uploadImageRef1"
-            :file-list="fileList1"
-            @success="imageUploadSuccess1"
-            @error="imageUploadFaild1"
-          />
-          <el-input v-model="brandData.brandAuthLogo" type="hidden" class="hiddenInput" />
-        </el-form-item>
-
-        <el-form-item label="代理声明:">
-          <el-radio-group v-model="brandData.statementType" @change="handleStatementChange">
-            <el-radio :label="1">弹窗</el-radio>
-            <el-radio :label="2">链接</el-radio>
-            <el-radio :label="3">图片</el-radio>
-            <el-radio :label="4">文件</el-radio>
-          </el-radio-group>
-        </el-form-item>
-
-        <el-form-item v-if="brandData.statementType === 1" ref="statement1" label="弹窗:" prop="statementContent">
-          <el-input
-            v-if="brandData.statementType === 1"
-            v-model="brandData.statementContent"
-            type="textarea"
-          />
-        </el-form-item>
-
-        <el-form-item v-else-if="brandData.statementType === 2" ref="statement2" label="链接:" prop="statementLink">
-          <el-input v-if="brandData.statementType === 2" v-model="brandData.statementLink" />
-        </el-form-item>
-
-        <el-form-item
-          v-else-if="brandData.statementType === 3"
-          ref="statement3"
-          label="图片:"
-          class="no-input"
-          prop="statementImage"
-        >
-          <upload-image
-            v-if="brandData.statementType === 3"
-            ref="uploadImageRef2"
-            :file-list="fileList2"
-            tip-title="宽760px"
-            @success="imageUploadSuccess2"
-            @error="imageUploadFaild2"
-            @remove="imageRemove2"
-          />
-          <el-input v-model="brandData.statementImage" type="hidden" class="hiddenInput" />
-        </el-form-item>
-
-        <el-form-item v-else ref="statement4" label="文件:" prop="statementFileId">
-          <upload-file
-            v-if="brandData.statementType === 4"
-            ref="uploadFileRef"
-            :auth-user-id="brandData.authUserId"
-            :brand-id="brandData.brandId"
-            :file-list="fileList3"
-            @success="fileUploadSuccess"
-            @error="fileUploadFaild"
-            @remove="fileRemove"
-          />
-          <el-input v-model="brandData.statementFileId" type="hidden" class="hiddenInput" />
-        </el-form-item>
-
-        <el-form-item label="官网认证链接:">
-          <el-input v-model="brandData.securityLink" placeholder="请输入官网认证链接" />
-        </el-form-item>
-
-      </el-form>
-
-      <div slot="footer">
-        <el-button @click="showDialog = false">取 消</el-button>
-        <el-button type="primary" @click="handleAddBrand">确 定</el-button>
-      </div>
-    </el-dialog>
-
-  </div>
-</template>
-
-<script>
-import UploadImage from '../components/uploadImage'
-import UploadFile from '../components/uploadFile'
-import { mapGetters } from 'vuex'
-import { isMobile } from '@/utils/validate'
-import { fetchBrandList } from '@/api/brand'
-import { addSupplier } from '@/api/supplier'
-
-export default {
-  components: { UploadImage, UploadFile },
-  data() {
-    const valideMobile = (rule, value, callback) => {
-      if (!isMobile(value)) {
-        callback(new Error('手机号格式不正确'))
-      } else {
-        callback()
-      }
-    }
-
-    const valideShopInfo = (rule, value, callback) => {
-      if (value.length <= 0) {
-        callback(new Error('品牌不能为空'))
-      } else {
-        callback()
-      }
-    }
-    return {
-      dialogLoading: false,
-      isLoading: false,
-      // 是否显示对话框
-      showDialog: false,
-      // 需要排除的品牌列表
-      excludeBrand: [],
-      // 上1个选中的品牌
-      prevBrandId: -1,
-      // 品牌列表
-      brandList: [],
-      // 品牌列表处理后的结果
-      brandListCody: [],
-      // 加入的品牌列表
-      supplierBrands: [],
-      // 当前选中的品牌索引在数组中的id
-      currentBrandIndex: '',
-      // 表单校验数据1
-      addFromData: {
-        authUserId: null, // 供应商id
-        shopType: 1, //	供应商类型:1品牌方,2代理商
-        brandId: '', // 品牌id
-        shopName: '', // 供应商名称
-        mobile: '', // 手机号
-        linkMan: '', // 联系人
-        countryId: 1, // 产地国家id
-        brandAuthLogo: '', //	品牌授权logo
-        createBy: '', // 创建人用户id
-        securityLink: '', // 官网认证链接
-        shopStatus: 1, // 供应商状态:0停用 1启用
-        shopInfo: 1
-      },
-      // 表单校验数据2
-      brandData: {
-        isNew: true,
-        brandId: '', // 供应商id
-        countryId: 1, // 产地国家id
-        brandAuthLogo: '', //	品牌授权logo
-        brandName: '',
-        securityLink: '', // 官网认证链接
-        statementType: 1, // 声明类型
-        statementContent: '', // 声明弹窗内容
-        statementFileId: null, // 声明文件id
-        statementImage: '', // 声明图片
-        statementLink: '' // 声明链接
-      },
-      // 表单校验规则1
-      addFromDataRules: {
-        shopType: { required: true, message: '供应商类型不能为空', trigger: 'change' },
-        brandId: { required: true, message: '品牌不能为空', trigger: 'change' },
-        shopName: { required: true, message: '请输入供应商名称', trigger: 'change' },
-        mobile: [
-          { required: true, message: '请输入手机号', trigger: 'blur' },
-          { validator: valideMobile, trigger: 'blur' }
-        ],
-        linkMan: { required: true, message: '联系人不能为空', trigger: 'blur' },
-        countryId: { required: true, message: '产地不能为空', trigger: 'change' },
-        brandAuthLogo: { required: true, message: '品牌logo不能为空', trigger: 'change' },
-        shopInfo: { validator: valideShopInfo, trigger: 'change', required: true }
-      },
-      // 表单校验规则2
-      brandDataRules: {
-        brandId: { required: true, message: '品牌不能为空', trigger: 'change' },
-        countryId: { required: true, message: '产地不能为空', trigger: 'change' },
-        brandAuthLogo: { required: true, message: '品牌logo不能为空', trigger: 'change' },
-        statementContent: { required: true, message: '声明内容不能为空', trigger: 'blur' },
-        statementLink: { required: true, message: '声明链接不能为空', trigger: 'blur' },
-        statementFileId: { required: true, message: '请上传声明文件', trigger: 'change' },
-        statementImage: { required: true, message: '请上传声明图片', trigger: 'change' }
-      },
-      // 上传成功的文件列表
-      fileList1: [], // 已上传的图片列表 品牌logo
-      fileList2: [], // 已上传的图片列表 声明图片
-      fileList3: [] // 已上传的图片列表 声明文件
-    }
-  },
-  computed: {
-    ...mapGetters(['userIdentity', 'name', 'countryList', 'authUserId'])
-  },
-  watch: {
-    excludeBrand() {
-      this.excludeBrandHandle()
-    }
-  },
-  created() {
-    this.initAddForm()
-  },
-  methods: {
-
-    // 初始添加供应商时的表单数据
-    initAddForm() {
-      // this.addFromData.authUserId = this.authUserId
-      this.getBrandList(1)
-      this.addFromData.shopName = ''
-    },
-    // 提交表单数据
-    submit() {
-      this.$refs.addFromDataRef.validate(valide => {
-        if (valide) {
-          console.log('校验通过')
-          if (this.addFromData.shopType === 1) {
-            this.save()
-          } else if (this.addFromData.shopType === 2) {
-            if (this.supplierBrands.length < 1) {
-              this.$alert('请至少添加一个代理品牌', '不满足提交要求', { type: 'warning' })
-              return
-            }
-            this.save()
-          }
-        }
-      })
-    },
-    // 保存
-    save() {
-      this.isLoading = true
-      addSupplier(this.createAddData())
-        .then(res => {
-          if (res.code !== 0) {
-            return
-          }
-          console.log(res)
-          this.$message.success('添加成功')
-          this.$router.replace('/supplier')
-        })
-        .finally(() => {
-          this.isLoading = false
-        })
-    },
-    // 创建请求参数
-    createAddData() {
-      let addData = {}
-      // 参数模板
-      const temp1 = {
-        authUserId: '',
-        createBy: '',
-        linkMan: '',
-        mobile: '',
-        shopName: '',
-        shopStatus: '',
-        shopType: '',
-        shopInfo: []
-      }
-      const temp2 = {
-        brandId: 1,
-        countryId: 2,
-        brandAuthLogo: '',
-        securityLink: '',
-        statementType: 1,
-        statementContent: '',
-        statementFileId: null,
-        statementImage: '',
-        statementLink: ''
-      }
-      // 指定创建者为当前登录的账号id
-      this.addFromData.createBy = this.authUserId
-      for (const key in temp1) {
-        if (Object.hasOwnProperty.call(temp1, key)) {
-          temp1[key] = this.addFromData[key]
-        }
-      }
-      // 如果为品牌方
-      if (this.addFromData.shopType === 1) {
-        for (const key in temp2) {
-          if (Object.hasOwnProperty.call(temp2, key)) {
-            temp2[key] = this.addFromData[key] || ''
-          }
-        }
-        temp2.statementType = 1
-        temp2.statementFileId = null
-        addData = {
-          ...temp1,
-          shopInfo: [temp2]
-        }
-      }
-      // 如果为代理商
-      if (this.addFromData.shopType === 2) {
-        addData = {
-          ...temp1,
-          shopInfo: this.supplierBrands
-        }
-      }
-
-      return addData
-    },
-    // 获取品牌列表
-    getBrandList(type) {
-      // 获取品牌列表
-      fetchBrandList({ type })
-        .then(res => {
-          console.log(res)
-          if (res.code === 0) {
-            this.brandList = res.data
-            this.brandListCody = res.data
-          }
-        })
-        .catch(err => console.log(err))
-    },
-    // 供应商类型切换
-    handleTypeChange(id) {
-      const type = id
-      this.$refs.addFromDataRef.clearValidate()
-      this.addFromData = {
-        authUserId: null, // 供应商id
-        shopType: type, //	供应商类型:1品牌方,2代理商
-        brandId: '', // 品牌id
-        shopName: '', // 供应商名称
-        mobile: '', // 手机号
-        linkMan: '', // 联系人
-        countryId: 1, // 产地国家id
-        brandAuthLogo: '', //	品牌授权logo
-        createBy: '', // 创建人用户id
-        securityLink: '', // 官网认证链接
-        shopStatus: 1, // 供应商状态:0停用 1启用
-        shopInfo: 1
-      }
-      this.fileList1 = []
-      this.getBrandList(type)
-    },
-    // 设置品牌名称
-    setShopName(id) {
-      const selectBrand = this.brandList.filter(item => {
-        return item.id === id
-      })[0]
-      const str = this.addFromData.shopType === 1 ? 'addFromData' : 'brandData'
-      this[str].shopName = selectBrand.name
-      this[str].brandAuthLogo = selectBrand.authLogo
-      this[str].brandId = selectBrand.id
-      if (str === 'brandData') {
-        this[str].brandName = selectBrand.name
-      }
-      if (selectBrand.authLogo) {
-        this.fileList1 = [{ name: '文件已上传', url: selectBrand.authLogo }]
-      }
-    },
-    // 添加品牌对话框开启
-    handleShowDialog() {
-      this.brandData.brandId = ''
-      this.showDialog = true
-    },
-    // 添加品牌
-    handleAddBrand() {
-      // 如果声明类型为文件
-      if (this.brandData.statementType === 4 && (this.brandData.statementFileId === null || this.brandData.statementFileId === '')) {
-        this.brandData.statementFileId = this.brandData.statementFileId === null ? '' : null
-        this.$refs.uploadFileRef.$refs.upload.submit()
-      } else {
-        this.saveBrand()
-      }
-    },
-    // 保存品牌信息
-    saveBrand() {
-      this.$refs.brandDataRef.validate(valid => {
-        if (valid) {
-          const brandInfo = this.clone(this.brandData)
-          console.log(brandInfo)
-          if (brandInfo.isNew) {
-            brandInfo.isNew = false
-            this.supplierBrands.push(brandInfo)
-          } else {
-            this.supplierBrands.splice(this.currentBrandIndex, 1, brandInfo)
-          }
-
-          if (this.addFromData.shopType === 2) {
-            this.excludeBrand.push(this.brandData.brandId)
-            this.prevBrandId = -1
-            console.log('添加:' + this.excludeBrand)
-          }
-
-          this.showDialog = false
-        }
-      })
-    },
-    // 修改
-    handleShowInfo(index) {
-      this.currentBrandIndex = index
-      this.brandData = this.clone(this.supplierBrands[index])
-      this.brandData.isNew = false
-      this.prevBrandId = this.brandData.brandId
-      if (this.addFromData.shopType === 2) {
-        const i = this.excludeBrand.indexOf(this.brandData.brandId)
-        this.excludeBrand.splice(i, 1)
-      }
-      if (this.brandData.brandAuthLogo) {
-        this.fileList1 = [{ name: '文件已上传', url: this.brandData.brandAuthLogo }]
-      }
-      if (this.brandData.statementImage) {
-        this.fileList2 = [{ name: '文件已上传', url: this.brandData.statementImage }]
-      }
-      if (this.brandData.statementFileId) {
-        this.fileList3 = [{ name: '文件已上传', url: '' }]
-      }
-      this.showDialog = true
-    },
-    // 删除
-    handleRemove(index) {
-      const i = this.excludeBrand.indexOf(this.supplierBrands[index].brandId)
-      this.excludeBrand.splice(i, 1)
-      this.supplierBrands.splice(index, 1)
-      console.log('删除:' + this.excludeBrand)
-    },
-    // 对话框关闭
-    dialogClosed() {
-      this.$refs.brandDataRef.resetFields()
-      this.brandData.brandId = ''
-      this.fileList1 = []
-      this.fileList2 = []
-      this.fileList3 = []
-      this.brandData.isNew = true
-      // 如果部位-1 代表没有保存 则恢复到上一次的排除结果
-      if (this.prevBrandId !== -1) {
-        this.excludeBrand.push(this.prevBrandId)
-        this.prevBrandId = -1
-      }
-    },
-    // 声明类型切换
-    handleStatementChange(index) {
-      console.log(index)
-      const ref = 'statement' + index
-      this.$refs[ref].clearValidate()
-    },
-    // 文件上传成功
-    fileUploadSuccess(data) {
-      this.brandData.statementFileId = data.data
-      this.saveBrand()
-    },
-    fileUploadFaild(err, file, fileList) {
-      console.log(err)
-    },
-    fileRemove() {
-      console.log('删除文件')
-      this.brandData.statementFileId = null
-    },
-
-    // 图片上传成功 品牌logo
-    imageUploadSuccess1(data) {
-      const str = this.addFromData.shopType === 1 ? 'addFromData' : 'brandData'
-      this[str].brandAuthLogo = data.data
-    },
-    imageUploadFaild1(err, file, fileList) {
-      console.log(err)
-    },
-    imageRemove1() {
-      const str = this.addFromData.shopType === 1 ? 'addFromData' : 'brandData'
-      this[str].brandAuthLogo = ''
-      console.log('删除文件')
-    },
-
-    // 图片上传成功 声明图片
-    imageUploadSuccess2(data) {
-      this.brandData.statementImage = data.data
-    },
-    imageUploadFaild2(err, file, fileList) {
-      console.log(err)
-    },
-    imageRemove2() {
-      this.brandData.statementImage = ''
-      console.log('删除文件')
-    },
-    // 对品牌列表做排除操作
-    excludeBrandHandle() {
-      this.brandListCody = this.brandList.filter((item, index) => {
-        return this.excludeBrand.indexOf(item.id) === -1
-      })
-    },
-
-    // 克隆
-    clone(data) {
-      const result = {}
-      for (const key in data) {
-        if (Object.hasOwnProperty.call(data, key)) {
-          result[key] = data[key]
-        }
-      }
-      return result
-    },
-    // 输入框输入时
-    handleInput() {
-      this.addFromData.mobile = this.addFromData.mobile.replace(/[^\w\.\/]/ig, '')
-    }
-  }
-}
-</script>
-
-<style lang="scss" scoped>
-.addSupplier {
-    margin-bottom: 80px;
-}
-.addForm {
-    width: 500px;
-    margin: 0 auto;
-    margin-top: 80px;
-    .brand-list{
-      .el-tag{
-        margin-right: 5px;
-        cursor: pointer;
-      }
-    }
-}
-.submit-btn {
-    text-align: center;
-    .el-button {
-        width: 140px;
-    }
-}
-.hiddenInput {
-    display: none;
-}
-</style>

+ 0 - 689
src/views/supplier/user/edit copy.vue

@@ -1,689 +0,0 @@
-<template>
-  <div v-loading="isLoading" class="addSupplier">
-    <el-form ref="addFromDataRef" :model="addFromData" :rules="addFromDataRules" label-width="120px" class="addForm">
-      <el-form-item label="供应商类型:" prop="shopType">
-        <el-input v-if="addFromData.shopType===1" placeholder="请输入供应商名称" disabled value="品牌方" />
-        <el-input v-if="addFromData.shopType===2" placeholder="请输入供应商名称" disabled value="代理商" />
-        <el-select
-          v-model="addFromData.shopType"
-          placeholder="请选择供应商类型"
-          style="width: 100%"
-          disabled
-          class="hiddenInput"
-          @change="handleTypeChange"
-        >
-          <el-option label="品牌方" :value="1" />
-          <el-option label="代理商" :value="2" />
-        </el-select>
-      </el-form-item>
-
-      <!-- 供应商名称 -->
-      <el-form-item v-if="addFromData.shopType === 2" label="供应商名称:" prop="shopName">
-        <el-input v-model="addFromData.shopName" placeholder="请输入供应商名称" disabled />
-      </el-form-item>
-
-      <el-form-item v-if="addFromData.shopType === 1" label="供应商名称:" prop="brandId">
-        <el-input v-model="addFromData.shopName" placeholder="请输入供应商名称" disabled />
-        <el-select
-          v-model="addFromData.brandId"
-          disabled
-          placeholder="请选择品牌"
-          style="width: 100%"
-          filterable
-          class="hiddenInput"
-          @change="setShopName"
-        >
-          <el-option v-for="item in brandList" :key="item.id" :label="item.name" :value="item.id" />
-        </el-select>
-      </el-form-item>
-      <!-- 供应商名称END -->
-
-      <el-form-item label="手机号:" prop="mobile">
-        <el-input v-model="addFromData.mobile" placeholder="请输入手机号" maxlength="11" show-word-limit @input="handleInput" />
-      </el-form-item>
-
-      <el-form-item label="联系人:" prop="linkMan">
-        <el-input v-model="addFromData.linkMan" placeholder="请输入联系人" />
-      </el-form-item>
-
-      <el-form-item v-if="addFromData.shopType === 2" label="代理品牌:" prop="shopInfo" class="brand-list">
-        <template v-if="supplierBrands !== []">
-          <el-tag v-for="(brand , index) in supplierBrands" :key="index" closable type="success" @close="handleRemove(index)" @click="handleShowInfo(index)">{{ brand.brandName }}</el-tag>
-        </template>
-        <el-tag type="primary" @click="handleShowDialog">添加品牌<span class="el-icon-plus" /></el-tag>
-      </el-form-item>
-
-      <template v-if="addFromData.shopType === 1">
-        <el-form-item label="产地:" prop="countryId">
-          <el-select v-model="addFromData.countryId" placeholder="产地" style="width: 100%" filterable>
-            <el-option
-              v-for="item in countryList"
-              :key="item.countryId"
-              :label="item.countryName"
-              :value="item.countryId"
-            />
-          </el-select>
-        </el-form-item>
-
-        <el-form-item label="品牌logo:" class="no-input" prop="brandAuthLogo">
-          <upload-image
-            ref="uploadImageRef1"
-            :file-list="fileList1"
-            @success="imageUploadSuccess1"
-            @error="imageUploadFaild1"
-            @remove="imageRemove1"
-          />
-          <el-input v-model="addFromData.brandAuthLogo" type="hidden" class="hiddenInput" />
-        </el-form-item>
-
-        <el-form-item label="官网认证链接:">
-          <el-input v-model="addFromData.securityLink" placeholder="请输入官网认证链接" />
-        </el-form-item>
-      </template>
-
-      <el-form-item label="供应商状态:">
-        <el-select v-model="addFromData.shopStatus" placeholder="请选择供应商状态" style="width: 100%">
-          <el-option label="启用" :value="1" />
-          <el-option label="禁用" :value="0" />
-        </el-select>
-      </el-form-item>
-    </el-form>
-    <div class="submit-btn">
-      <el-button type="primary" @click="submit">保存</el-button>
-      <el-button type="warning" @click="$_back()">返回</el-button>
-    </div>
-
-    <!-- 供应商添加品牌的对话框 -->
-    <el-dialog v-loading="dialogLoading" title="添加代理品牌" :visible.sync="showDialog" width="width" @closed="dialogClosed">
-      <el-form ref="brandDataRef" :model="brandData" :rules="brandDataRules" label-width="120px">
-        <el-form-item label="选择品牌:" prop="brandId">
-          <el-select
-            v-model="brandData.brandId"
-            placeholder="请选择品牌"
-            style="width: 100%"
-            filterable
-            @change="setShopName"
-          >
-            <el-option v-for="item in brandListCody" :key="item.id" :label="item.name" :value="item.id" />
-          </el-select>
-        </el-form-item>
-
-        <el-form-item label="产地:" prop="countryId">
-          <el-select v-model="brandData.countryId" placeholder="产地" style="width: 100%" filterable>
-            <el-option
-              v-for="item in countryList"
-              :key="item.countryId"
-              :label="item.countryName"
-              :value="item.countryId"
-            />
-          </el-select>
-        </el-form-item>
-
-        <el-form-item label="品牌logo:" class="no-input" prop="brandAuthLogo">
-          <upload-image
-            ref="uploadImageRef1"
-            :file-list="fileList1"
-            @success="imageUploadSuccess1"
-            @error="imageUploadFaild1"
-          />
-          <el-input v-model="brandData.brandAuthLogo" type="hidden" class="hiddenInput" />
-        </el-form-item>
-
-        <el-form-item label="代理声明:">
-          <el-radio-group v-model="brandData.statementType" @change="handleStatementChange">
-            <el-radio :label="1">弹窗</el-radio>
-            <el-radio :label="2">链接</el-radio>
-            <el-radio :label="3">图片</el-radio>
-            <el-radio :label="4">文件</el-radio>
-          </el-radio-group>
-        </el-form-item>
-
-        <el-form-item v-if="brandData.statementType === 1" ref="statement1" label="弹窗:" prop="statementContent">
-          <el-input
-            v-if="brandData.statementType === 1"
-            v-model="brandData.statementContent"
-            type="textarea"
-          />
-        </el-form-item>
-
-        <el-form-item v-else-if="brandData.statementType === 2" ref="statement2" label="链接:" prop="statementLink">
-          <el-input v-if="brandData.statementType === 2" v-model="brandData.statementLink" />
-        </el-form-item>
-
-        <el-form-item
-          v-else-if="brandData.statementType === 3"
-          ref="statement3"
-          label="图片:"
-          class="no-input"
-          prop="statementImage"
-        >
-          <upload-image
-            v-if="brandData.statementType === 3"
-            ref="uploadImageRef2"
-            :file-list="fileList2"
-            tip-title="宽760px"
-            @success="imageUploadSuccess2"
-            @error="imageUploadFaild2"
-            @remove="imageRemove2"
-          />
-          <el-input v-model="brandData.statementImage" type="hidden" class="hiddenInput" />
-        </el-form-item>
-
-        <el-form-item v-else ref="statement4" label="文件:" prop="statementFileId">
-          <upload-file
-            v-if="brandData.statementType === 4"
-            ref="uploadFileRef"
-            :auth-user-id="addFromData.authUserId"
-            :brand-id="brandId"
-            :file-list="fileList3"
-            @success="fileUploadSuccess"
-            @error="fileUploadFaild"
-            @remove="fileRemove"
-          />
-          <el-input v-model="brandData.statementFileId" type="hidden" class="hiddenInput" />
-        </el-form-item>
-
-        <el-form-item label="官网认证链接:">
-          <el-input v-model="brandData.securityLink" placeholder="请输入官网认证链接" />
-        </el-form-item>
-
-      </el-form>
-
-      <div slot="footer">
-        <el-button @click="showDialog = false">取 消</el-button>
-        <el-button type="primary" @click="handleAddBrand">确 定</el-button>
-      </div>
-    </el-dialog>
-
-  </div>
-</template>
-
-<script>
-import UploadImage from '../components/uploadImage'
-import UploadFile from '../components/uploadFile'
-import { mapGetters } from 'vuex'
-import { isMobile } from '@/utils/validate'
-import { fetchBrandList } from '@/api/brand'
-import { addSupplier, getSupplierById } from '@/api/supplier'
-
-export default {
-  components: { UploadImage, UploadFile },
-  data() {
-    var valideMobile = (rule, value, callback) => {
-      if (!isMobile(value)) {
-        callback(new Error('手机号格式不正确'))
-      } else {
-        callback()
-      }
-    }
-    const valideShopInfo = (rule, value, callback) => {
-      if (value.length <= 0) {
-        callback(new Error('品牌不能为空'))
-      } else {
-        callback()
-      }
-    }
-    return {
-      brandId: '', // 上传文件时的品牌id
-      supplierId: '',
-      dialogLoading: false,
-      isLoading: false,
-      // 是否显示对话框
-      showDialog: false,
-      // 需要排除的品牌列表
-      excludeBrand: [],
-      // 上1个选中的品牌
-      prevBrandId: -1,
-      // 品牌列表
-      brandList: [],
-      // 品牌列表处理后的结果
-      brandListCody: [],
-      // 加入的品牌列表
-      supplierBrands: [],
-      // 当前选中的品牌索引在数组中的id
-      currentBrandIndex: '',
-      // 表单校验数据1
-      addFromData: {
-        authUserId: null, // 供应商id
-        shopType: 1, //	供应商类型:1品牌方,2代理商
-        brandId: '', // 品牌id
-        shopName: '', // 供应商名称
-        mobile: '', // 手机号
-        linkMan: '', // 联系人
-        countryId: 1, // 产地国家id
-        brandAuthLogo: '', //	品牌授权logo
-        createBy: '', // 创建人用户id
-        securityLink: '', // 官网认证链接
-        shopStatus: 1, // 供应商状态:0停用 1启用
-        shopInfo: 1
-      },
-      // 表单校验数据2
-      brandData: {
-        isNew: true,
-        brandId: '', // 供应商id
-        countryId: 1, // 产地国家id
-        brandAuthLogo: '', //	品牌授权logo
-        brandName: '',
-        securityLink: '', // 官网认证链接
-        statementType: 1, // 声明类型
-        statementContent: '', // 声明弹窗内容
-        statementFileId: null, // 声明文件id
-        statementImage: '', // 声明图片
-        statementLink: '' // 声明链接
-      },
-      // 表单校验规则1
-      addFromDataRules: {
-        shopType: { required: true, message: '供应商类型不能为空', trigger: 'change' },
-        brandId: { required: true, message: '品牌不能为空', trigger: 'change' },
-        shopName: { required: true, message: '请输入供应商名称', trigger: 'change' },
-        mobile: [
-          { required: true, message: '请输入手机号', trigger: 'blur' },
-          { validator: valideMobile, trigger: 'blur' }
-        ],
-        linkMan: { required: true, message: '联系人不能为空', trigger: 'blur' },
-        countryId: { required: true, message: '产地不能为空', trigger: 'change' },
-        brandAuthLogo: { required: true, message: '品牌logo不能为空', trigger: 'change' },
-        shopInfo: { validator: valideShopInfo, trigger: 'change', required: true }
-      },
-      // 表单校验规则2
-      brandDataRules: {
-        brandId: { required: true, message: '品牌不能为空', trigger: 'change' },
-        countryId: { required: true, message: '产地不能为空', trigger: 'change' },
-        brandAuthLogo: { required: true, message: '品牌logo不能为空', trigger: 'change' },
-        statementContent: { required: true, message: '声明内容不能为空', trigger: 'blur' },
-        statementLink: { required: true, message: '声明链接不能为空', trigger: 'blur' },
-        statementFileId: { required: true, message: '请上传声明文件', trigger: 'change' },
-        statementImage: { required: true, message: '请上传声明图片', trigger: 'change' }
-      },
-      // 上传成功的文件列表
-      fileList1: [], // 已上传的图片列表 品牌logo
-      fileList2: [], // 已上传的图片列表 声明图片
-      fileList3: [] // 已上传的图片列表 声明文件
-    }
-  },
-  computed: {
-    ...mapGetters(['name', 'countryList', 'authUserId'])
-  },
-  watch: {
-    excludeBrand(list) {
-      console.log(list)
-      this.brandListCody = this.excludeBrandHandle()
-    }
-  },
-  created() {
-    this.getSupplierData()
-    this.initAddForm()
-    this.supplierId = this.addFromData.authUserId
-  },
-  methods: {
-    // 初始添加供应商时的表单数据
-    initAddForm() {
-      // this.addFromData.authUserId = this.authUserId
-
-      this.addFromData.shopName = ''
-    },
-    // 接口通过id获取数据
-    getSupplierData() {
-      this.isLoading = true
-      const id = this.$route.query.id
-      getSupplierById({ authUserId: id }).then(res => {
-        this.getBrandList(res.data.shopType)
-        this.setFormData(res.data)
-      })
-    },
-    // 将返回结果绑定到对应的表单
-    setFormData(data) {
-      this.addFromData = {
-        ...this.addFromData,
-        ...data
-      }
-      if (this.addFromData.shopType === 1) {
-        this.addFromData = {
-          ...this.addFromData,
-          ...data.shopInfo[0]
-        }
-        if (this.addFromData.brandAuthLogo) {
-          this.fileList1 = [{ name: '', url: this.addFromData.brandAuthLogo }]
-        }
-        this.addFromData.shopInfo = []
-      }
-      if (this.addFromData.shopType === 2) {
-        this.addFromData.shopInfo = []
-        data.shopInfo.forEach((item, index) => {
-          item.index = index
-          item.isNew = false
-          this.excludeBrand.push(item.brandId)
-        })
-        this.supplierBrands = data.shopInfo
-      }
-      this.isLoading = false
-    },
-    // 提交表单数据
-    submit() {
-      this.$refs.addFromDataRef.validate(valide => {
-        if (valide) {
-          console.log('校验通过')
-          if (this.addFromData.shopType === 1) {
-            this.save()
-          } else if (this.addFromData.shopType === 2) {
-            if (this.supplierBrands.length < 1) {
-              this.$alert('请至少添加一个代理品牌', '不满足提交要求', { type: 'warning' })
-              return
-            }
-            this.save()
-          }
-        }
-      })
-    },
-    // 保存
-    save() {
-      this.isLoading = true
-      addSupplier(this.createAddData())
-        .then(res => {
-          console.log(res)
-          this.$message.success('保存成功')
-          this.$router.replace('/supplier')
-        })
-        .finally(() => {
-          this.isLoading = false
-        })
-    },
-    // 创建请求参数
-    createAddData() {
-      let addData = {}
-      // 参数模板
-      const temp1 = {
-        authUserId: '',
-        createBy: '',
-        linkMan: '',
-        mobile: '',
-        shopName: '',
-        shopStatus: '',
-        shopType: '',
-        shopInfo: []
-      }
-      const temp2 = {
-        brandId: 1,
-        countryId: 2,
-        brandAuthLogo: '',
-        securityLink: '',
-        statementType: 1,
-        statementContent: '',
-        statementFileId: null,
-        statementImage: '',
-        statementLink: ''
-      }
-      // 指定创建者为当前登录的账号id
-      this.addFromData.createBy = this.authUserId
-      for (const key in temp1) {
-        if (Object.hasOwnProperty.call(temp1, key)) {
-          temp1[key] = this.addFromData[key]
-        }
-      }
-      // 如果为品牌方
-      if (this.addFromData.shopType === 1) {
-        for (const key in temp2) {
-          if (Object.hasOwnProperty.call(temp2, key)) {
-            temp2[key] = this.addFromData[key] || ''
-          }
-        }
-        temp2.statementType = 1
-        temp2.statementFileId = null
-        addData = {
-          ...temp1,
-          shopInfo: [temp2]
-        }
-      }
-      // 如果为代理商
-      if (this.addFromData.shopType === 2) {
-        addData = {
-          ...temp1,
-          shopInfo: this.supplierBrands
-        }
-      }
-
-      return addData
-    },
-    // 获取品牌列表
-    getBrandList(type) {
-      if (this.addFromData.shopType === 1) {
-        type = 2
-      }
-      // 获取品牌列表
-      fetchBrandList({ type })
-        .then(res => {
-          this.brandList = res.data
-          this.brandListCody = this.excludeBrandHandle()
-        })
-        .catch(err => console.log(err))
-    },
-    // 供应商类型切换
-    handleTypeChange(id) {
-      const type = id
-      this.$refs.addFromDataRef.clearValidate()
-      this.addFromData = {
-        authUserId: null, // 供应商id
-        shopType: type, //	供应商类型:1品牌方,2代理商
-        brandId: '', // 品牌id
-        shopName: '', // 供应商名称
-        mobile: '', // 手机号
-        linkMan: '', // 联系人
-        countryId: 1, // 产地国家id
-        brandAuthLogo: '', //	品牌授权logo
-        createBy: '', // 创建人用户id
-        securityLink: '', // 官网认证链接
-        shopStatus: 1, // 供应商状态:0停用 1启用
-        shopInfo: 1
-      }
-      this.fileList1 = []
-      this.getBrandList(type)
-    },
-    // 设置品牌名称
-    setShopName(id) {
-      const selectBrand = this.brandList.filter(item => {
-        return item.id === id
-      })[0]
-      const str = this.addFromData.shopType === 1 ? 'addFromData' : 'brandData'
-      this[str].shopName = selectBrand.name
-      this[str].brandAuthLogo = selectBrand.authLogo
-      this[str].brandId = selectBrand.id
-      if (str === 'brandData') {
-        this[str].brandName = selectBrand.name
-      }
-
-      if (selectBrand.authLogo) {
-        this.fileList1 = [{ name: '文件已上传', url: selectBrand.authLogo }]
-      }
-      console.log(selectBrand.id)
-      this.brandId = selectBrand.id
-    },
-    // 添加品牌对话框开启
-    handleShowDialog() {
-      try {
-        this.$refs.brandDataRef.clearValidate()
-      } catch (error) {
-        console.log('清空')
-      }
-      this.showDialog = true
-    },
-    // 添加品牌
-    handleAddBrand() {
-      // 如果声明类型为文件
-      if (this.brandData.statementType === 4 && (this.brandData.statementFileId === null || this.brandData.statementFileId === '')) {
-        this.brandData.statementFileId = this.brandData.statementFileId === null ? '' : null
-        console.log(this.brandId)
-        this.$refs.uploadFileRef.$refs.upload.submit()
-      } else {
-        this.saveBrand()
-      }
-    },
-    // 保存品牌信息
-    saveBrand() {
-      this.$refs.brandDataRef.validate(valide => {
-        if (valide) {
-          const brandInfo = this.clone(this.brandData)
-          // brandInfo.brandName = brandInfo.shopName
-          console.log(brandInfo)
-          if (brandInfo.isNew) {
-            brandInfo.isNew = false
-            this.supplierBrands.push(brandInfo)
-          } else {
-            this.supplierBrands.splice(this.currentBrandIndex, 1, brandInfo)
-          }
-          if (this.addFromData.shopType === 2) {
-            this.excludeBrand.push(this.brandData.brandId)
-            this.prevBrandId = -1
-            console.log('添加:' + this.excludeBrand)
-          }
-          this.brandData.brandId = ''
-          this.showDialog = false
-        }
-      })
-    },
-    // 修改
-    handleShowInfo(index) {
-      this.currentBrandIndex = index
-      this.brandData = this.clone(this.supplierBrands[index])
-      this.brandData.isNew = false
-      this.prevBrandId = this.brandData.brandId
-      console.log(this.brandData)
-      if (this.addFromData.shopType === 2) {
-        const i = this.excludeBrand.indexOf(this.brandData.brandId)
-        this.excludeBrand.splice(i, 1)
-      }
-      if (this.brandData.brandAuthLogo) {
-        this.fileList1 = [{ name: '文件已上传', url: this.brandData.brandAuthLogo }]
-      }
-      if (this.brandData.statementImage) {
-        this.fileList2 = [{ name: '文件已上传', url: this.brandData.statementImage }]
-      }
-      if (this.brandData.statementFileId) {
-        const name = this.brandData.statementFileName || '文件已上传'
-        this.fileList3 = [{ name: name, url: '' }]
-      }
-      console.log(this.brandListCody)
-      this.brandId = this.supplierBrands[index].brandId
-      this.showDialog = true
-    },
-    // 删除
-    handleRemove(index) {
-      const i = this.excludeBrand.indexOf(this.supplierBrands[index].brandId)
-      this.excludeBrand.splice(i, 1)
-      this.supplierBrands.splice(index, 1)
-      console.log('删除:' + this.excludeBrand)
-    },
-    // 对话框关闭
-    dialogClosed() {
-      console.log('添加框关闭')
-      this.$refs.brandDataRef.resetFields()
-      this.fileList1 = []
-      this.fileList2 = []
-      this.fileList3 = []
-      this.brandData.brandId = ''
-      this.brandData.statementFileId = ''
-      this.brandData.isNew = true
-      // 如果部位-1 代表没有保存 则恢复到上一次的排除结果
-      if (this.prevBrandId !== -1) {
-        this.excludeBrand.push(this.prevBrandId)
-        this.prevBrandId = -1
-      }
-    },
-    // 声明类型切换
-    handleStatementChange(index) {
-      console.log(index)
-      const ref = 'statement' + index
-      this.$refs[ref].clearValidate()
-      // this.brandData.statementContent = ''
-      // this.brandData.statementLink = ''
-      // this.brandData.statementFileId = ''
-      // this.brandData.statementImage = ''
-    },
-    // 文件上传成功
-    fileUploadSuccess(data) {
-      this.brandData.statementFileId = data.data
-      setTimeout(() => {
-        this.saveBrand()
-      }, 500)
-    },
-    fileUploadFaild(err, file, fileList) {
-      console.log(err)
-    },
-    fileRemove() {
-      console.log('删除文件')
-      this.brandData.statementFileId = null
-    },
-
-    // 图片上传成功 品牌logo
-    imageUploadSuccess1(data) {
-      const str = this.addFromData.shopType === 1 ? 'addFromData' : 'brandData'
-      this[str].brandAuthLogo = data.data
-    },
-    imageUploadFaild1(err, file, fileList) {
-      console.log(err)
-    },
-    imageRemove1() {
-      const str = this.addFromData.shopType === 1 ? 'addFromData' : 'brandData'
-      this[str].brandAuthLogo = ''
-      console.log('删除文件')
-    },
-
-    // 图片上传成功 声明图片
-    imageUploadSuccess2(data) {
-      this.brandData.statementImage = data.data
-    },
-    imageUploadFaild2(err, file, fileList) {
-      console.log(err)
-    },
-    imageRemove2() {
-      this.brandData.statementImage = ''
-      console.log('删除文件')
-    },
-    // 对品牌列表做排除操作
-    excludeBrandHandle() {
-      return this.brandList.filter((item, index) => {
-        return this.excludeBrand.indexOf(item.id) === -1
-      })
-    },
-
-    // 克隆
-    clone(data) {
-      const result = {}
-      for (const key in data) {
-        if (Object.hasOwnProperty.call(data, key)) {
-          result[key] = data[key]
-        }
-      }
-      return result
-    },
-    handleInput() {
-      this.addFromData.mobile = this.addFromData.mobile.replace(/[^\w\.\/]/ig, '')
-    }
-  }
-}
-</script>
-
-<style lang="scss" scoped>
-.addSupplier {
-    margin-bottom: 80px;
-}
-.addForm {
-    width: 500px;
-    margin: 0 auto;
-    margin-top: 80px;
-    .brand-list{
-      .el-tag{
-        margin-right: 5px;
-        cursor: pointer;
-      }
-    }
-}
-.submit-btn {
-    text-align: center;
-    .el-button {
-        width: 140px;
-    }
-}
-.hiddenInput {
-    display: none;
-}
-</style>