ソースを参照

隐藏机构删除按钮

yuwenjun1997 3 年 前
コミット
d09e1eba8f
2 ファイル変更34 行追加19 行削除
  1. 32 17
      src/views/normal/club/device/edit.vue
  2. 2 2
      src/views/normal/club/index.vue

+ 32 - 17
src/views/normal/club/device/edit.vue

@@ -8,7 +8,13 @@
       -->
 
       <el-form-item label="设备名称:" prop="productTypeId">
-        <el-select v-model="formData.productTypeId" filterable placeholder="选择设备" style="width:100%" @change="onProductTypeIdChange">
+        <el-select
+          v-model="formData.productTypeId"
+          filterable
+          placeholder="选择设备"
+          style="width: 100%"
+          @change="onProductTypeIdChange"
+        >
           <el-option
             v-for="item in deviceList"
             :key="item.productTypeId"
@@ -23,12 +29,7 @@
       </el-form-item>
 
       <el-form-item v-if="shopType === 2" label="所属品牌:" prop="brandId">
-        <el-select
-          v-model="formData.brandId"
-          placeholder="请选择品牌"
-          style="width: 100%"
-          filterable
-        >
+        <el-select v-model="formData.brandId" placeholder="请选择品牌" style="width: 100%" filterable>
           <el-option v-for="item in brandList" :key="item.id" :label="item.name" :value="item.id" />
         </el-select>
       </el-form-item>
@@ -62,7 +63,7 @@
         </el-radio-group>
       </el-form-item>
       <!-- 二维码授权牌模板 -->
-      <el-form-item v-if="formData.addQrCodeFlag===1" label="选择模板:">
+      <el-form-item v-if="formData.addQrCodeFlag === 1" label="选择模板:">
         <auth-card-template v-model="formData.addTemplateType" :image-list="certificateImageList" />
       </el-form-item>
 
@@ -115,12 +116,26 @@ export default {
       }
       callback()
     }
+
     const valideBrandId = (rules, value, callback) => {
       if (!value) {
         return callback(new Error('所属品牌不能为空'))
       }
       callback()
     }
+
+    const paramListValidate = (rules, value, callback) => {
+      value.every((item) => item.paramName && item.paramContent)
+      const notEmptyList = value.filter((item) => item.paramName.trim() && item.paramContent.trim())
+      if (notEmptyList.length === 0) {
+        callback(new Error('参数列表不能为空'))
+      } else if (notEmptyList.length < 4) {
+        callback(new Error('请填写至少4项参数'))
+      } else {
+        callback()
+      }
+    }
+
     return {
       isLoading: false,
       editType: 'add',
@@ -144,12 +159,12 @@ export default {
         addTemplateType: 1,
         productTypeId: '',
         purchaseWay: '', // 购买渠道
-        invoiceImage: ''// 发票
+        invoiceImage: '' // 发票
       },
       paramList: [], // 参数列表
       rules: {
         certificateImage: [{ required: true, message: '授权牌照不能为空' }],
-        paramList: [{ required: true, message: '参数不能为空' }],
+        paramList: [{ validator: paramListValidate, trigger: 'change' }],
         // productImage: [{ required: true, message: '设备图片不能为空' }], 暂时移除
         snCode: [{ required: true, message: 'SN码不能为空' }, { validator: valideSNcode }],
         // productName: [
@@ -201,7 +216,7 @@ export default {
   methods: {
     // 设备分类修改
     onProductTypeIdChange(value) {
-      const deviceInfo = this.deviceList.find(item => item.productTypeId === value)
+      const deviceInfo = this.deviceList.find((item) => item.productTypeId === value)
       this.formData.productImage = deviceInfo.image
     },
     // 初始化表单数据
@@ -211,7 +226,7 @@ export default {
         return
       }
       this.isLoading = true
-      getProductById({ productId: this.formData.productId }).then(res => {
+      getProductById({ productId: this.formData.productId }).then((res) => {
         console.log(res)
         for (const key in res.data) {
           if (Object.hasOwnProperty.call(res.data, key)) {
@@ -224,7 +239,7 @@ export default {
           }
         }
         // 初始化参数
-        this.paramList = res.data.paramList.map(param => {
+        this.paramList = res.data.paramList.map((param) => {
           param.tip = {}
           param.tip.first = '参数名'
           param.tip.second = '请输入参数信息'
@@ -283,7 +298,7 @@ export default {
     // 提交表单
     submit() {
       this.formData.paramList = this.setParamToFormData()
-      this.$refs.addFormRef.validate(valide => {
+      this.$refs.addFormRef.validate((valide) => {
         if (valide) {
           this.save()
         }
@@ -297,7 +312,7 @@ export default {
       this.formData.createBy = this.proxyInfo?.authUserId || this.authUserId
       this.formData.authUserId = this.proxyInfo?.authUserId || this.authUserId
       saveProduct(this.formData)
-        .then(res => {
+        .then((res) => {
           if (res.code !== 0) return
           const h = this.$createElement
           const tip = this.editType === 'add' ? '添加' : '修改'
@@ -318,12 +333,12 @@ export default {
 
     // 保存参数到formdata
     setParamToFormData() {
-      return this.paramList.filter(item => item.paramContent !== '' && item.paramName !== '')
+      return this.paramList.filter((item) => item.paramContent !== '' && item.paramName !== '')
     },
 
     // 获取品牌信息
     getBrandList() {
-      fetchBrandList({ type: 3, authUserId: this.formData.authUserId }).then(res => {
+      fetchBrandList({ type: 3, authUserId: this.formData.authUserId }).then((res) => {
         console.log(res)
         this.brandList = res.data
       })

+ 2 - 2
src/views/normal/club/index.vue

@@ -103,7 +103,7 @@
           <permission-button type="primary" size="mini" @click="$_navigationTo(`club-edit?type=edit&id=${row.authId}`)">
             编辑
           </permission-button>
-          <permission-button type="danger" size="mini" @click="handleRemoveAuth(row)"> 删除 </permission-button>
+          <!-- <permission-button type="danger" size="mini" @click="handleRemoveAuth(row)"> 删除 </permission-button> -->
           <permission-button type="primary" size="mini" @click="$_navigationTo(`device-list?id=${row.authId}`)">
             设备认证
           </permission-button>
@@ -114,7 +114,7 @@
           <permission-button
             type="primary"
             size="mini"
-            :disabled="row.status !== 1"
+            :disabled="row.status !== 1 || row.sendStatus === 0"
             @click="$_navigationTo(`logistics-licensed?id=${row.authId}`)"
           >
             授权牌物流