licp
2024-04-18 caba724b7025dd8801ed590bed3d8d56579d6a8c
src/components/tool/value-table.vue
@@ -131,6 +131,7 @@
                  <span v-else-if="data.linkEvent&&showLink(a.label, data.linkEvent)" style="color:#409EFF;cursor: pointer;"
                     @click="handleLinkEvent(scope.row,data.linkEvent[a.label])">{{scope.row[a.label]}}</span>
            <img style="width: 40px;height: 40px;margin-top: 10px;" :src="javaApi+'/img/'+scope.row[a.label]" v-else-if="showUpload(a.label)&&scope.row[a.label]" alt="">
            <span v-else-if="showCascader(a.label)&&scope.row[a.label]">{{handleTree(data.cascaderField[a.label].tree,scope.row[a.label].split(',')[scope.row[a.label].split(',').length-1])}}</span>
                  <span v-else>{{scope.row[a.label]}}</span>
               </template>
            </el-table-column>
@@ -198,7 +199,16 @@
              <img v-if="upData[a.label]" :src="javaApi+'/img/'+upData[a.label]" class="avatar" style="width: 80px;height: 80px;border-radius: 6px;">
              <i v-else class="el-icon-plus avatar-uploader-icon"></i>
                     </el-upload>
              <el-cascader v-model="upData[a.label]" :options="data.cascaderField[a.label].tree" :show-all-levels="false" v-if="showCascader(a.label)" clearable :props="data.cascaderField.props"></el-cascader>
              <el-cascader
              :value="upData[a.label]"
              :options="data.cascaderField[a.label].tree"
              v-if="showCascader(a.label)"
              :show-all-levels="false"
              clearable
              :props="data.cascaderField.props"
              size="small"
              style="width: 100%;"
              @change="m=>handleCascader(m,a.label)"></el-cascader>
                  </el-col>
               </div>
            </div>
@@ -232,7 +242,7 @@
              <img v-if="upData[a.label]" :src="javaApi+'/img/'+upData[a.label]" class="avatar" style="width: 80px;height: 80px;border-radius: 6px;">
              <i v-else class="el-icon-plus avatar-uploader-icon"></i>
                     </el-upload>
              <el-cascader v-model="upData[a.label]" :options="data.cascaderField[a.label].tree" :show-all-levels="false" v-if="showCascader(a.label)" clearable :props="data.cascaderField.props"></el-cascader>
              <el-cascader :value="upData[a.label]" :options="data.cascaderField[a.label].tree" :show-all-levels="false" v-if="showCascader(a.label)" clearable :props="data.cascaderField.props" size="small" style="width: 100%;" @change="m=>handleCascader(m,a.label)"></el-cascader>
                  </el-col>
               </el-row>
            </div>
@@ -273,7 +283,7 @@
              <img v-if="upData[a.label]" :src="javaApi+'/img/'+upData[a.label]" class="avatar" style="width: 80px;height: 80px;border-radius: 6px;">
              <i v-else class="el-icon-plus avatar-uploader-icon"></i>
                        </el-upload>
              <el-cascader v-model="upData[a.label]" :options="data.cascaderField[a.label].tree" :show-all-levels="false" v-if="showCascader(a.label)" clearable :props="data.cascaderField.props"></el-cascader>
              <el-cascader :options="data.cascaderField[a.label].tree" v-if="showCascader(a.label)" clearable :props="data.cascaderField.props" size="small" style="width: 100%;" :show-all-levels="false" @change="m=>handleCascader(m,a.label)"></el-cascader>
                  </el-col>
               </div>
            </div>
@@ -305,7 +315,7 @@
              <img v-if="upData[a.label]" :src="javaApi+'/img/'+upData[a.label]" class="avatar" style="width: 80px;height: 80px;border-radius: 6px;">
              <i v-else class="el-icon-plus avatar-uploader-icon"></i>
                        </el-upload>
              <el-cascader v-model="upData[a.label]" :options="data.cascaderField[a.label].tree" :show-all-levels="false" v-if="showCascader(a.label)" clearable :props="data.cascaderField.props"></el-cascader>
              <el-cascader :options="data.cascaderField[a.label].tree" v-if="showCascader(a.label)" clearable :props="data.cascaderField.props" size="small" style="width: 100%;" :show-all-levels="false" @change="m=>handleCascader(m,a.label)"></el-cascader>
                  </el-col>
               </el-row>
            </div>
@@ -481,7 +491,7 @@
                  this.$refs.eltable.doLayout()
               })
            }
         }
         },
      },
      mounted() {
         this.data = this.componentData
@@ -701,13 +711,34 @@
          return false;
        }
      },
      handleTree(arr,value){
        let label = ''
        for (let i = 0; i < arr.length; i++) {
          if(arr[i].id==value){
            label = arr[i].name
            return label
          }else if(arr[i].children){
            label = this.handleTree(arr[i].children,value)
          }
        }
        return label
      },
         main(row, val) {
            if (val.method == undefined) return
            else if (val.method == 'doDiy') {
               if (val.id == 'update') {
                  this.upDia = true,
                     this.upData = this.HaveJson(row)
                  this.upData = this.HaveJson(row)
                  this.upHead = this.HaveJson(this.tableHead)
            this.upHead.forEach((item,index)=>{
              if(this.data.cascaderField&&this.data.cascaderField[item.label]){
                if(this.upData[item.label]){
                  this.upData[item.label] = this.upData[item.label].split(',').map(m=>Number(m));
                }else{
                  this.upData[item.label] = []
                }
              }
            })
                  this.upHead = this.upHead.filter(a => a.label != 'createTime' && a.label != 'updateTime')
                  delete this.upData.orderBy
                  delete this.upData.createTime
@@ -780,6 +811,15 @@
                  this.upData[a] = JSON.stringify(this.upData[a])
               }
            }
        this.upHead.forEach((item,index)=>{
          if(this.data.cascaderField&&this.data.cascaderField[item.label]){
            if(this.upData[item.label]){
              this.upData[item.label] = this.upData[item.label].join(',');
            }else{
              this.upData[item.label] = ''
            }
          }
        })
            this.$axios.post(this.upUrl, this.upData, {
               headers: {
                  'Content-Type': 'application/json'
@@ -792,6 +832,7 @@
               this.$message.success('修改成功')
               this.upDia = false
               this.selectList()
          this.$refs.eltable.doLayout();
               this.upLoad = false
            }).catch(e => {
               this.$message.error('修改失败')
@@ -1019,7 +1060,35 @@
            this.selectList()
          }
        }
      }
      },
      handleCascader(e,label){
        this.upData[label] = e;
      },
      // 批量删除
      batchDelete(){
        if(this.multipleSelection&&this.multipleSelection.length>0){
          // this.delUrl
          this.$confirm('是否删除选中的数据?', "警告", {
                     confirmButtonText: "确定",
                     cancelButtonText: "取消",
                     type: "warning"
                  }).then(() => {
                     this.$axios.post(this.delUrl, {
                        id: this.multipleSelection.map(item => item.id).join(',')
                     }).then(res => {
                        if (res.code === 201) {
                           return
                        }
                        this.$message.success('删除成功')
                        this.selectList()
                     }).catch(e => {
                        this.$message.error('删除失败')
                     })
                  }).catch(() => {})
        }else{
          this.$message.error('请选择要删除的数据')
        }
      },
      }
   }
</script>