田源
2024-09-27 322b236f53f9aa8e12c6e019c861e2ea1bc4ab16
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
export default {
  buttonClick(item, that) {
    that.formName = item.name;
    const location = item.paramVOS.webUiButtonLocation;
    const method = item.paramVOS.webUiButtonMethods;
    const messageOnlyText = that.selectList.length > 1 ? '只能选择一条数据进行编辑!' : '请选择一条数据进行编辑!';
    const messageAllText = '请至少选择一条数据!'
 
    const handlers = {
      add: () => this.handleAdd(that, location),
      edit: () => this.handleEdit(that, location, messageOnlyText),
      delete: () => this.handleDelete(that, location, messageAllText),
    };
 
    const handler = handlers[method];
    if (handler) {
      handler();
    } else {
      that.$message.error('请重新配置按钮!');
    }
  },
 
  handleAdd(that, location) {
    if (location === 'top') {
      that.visible = true;
    } else {
      that.$message.warning('请重新配置按钮至上方区域!');
    }
 
  },
 
  handleEdit(that, location, messageOnlyText) {
    if (location === 'menu') {
      that.visible = true;
      that.$refs.dynamicForm.form = that.scope.row;
  
    } else if (location === 'top' && that.selectList.length === 1) {
      that.visible = true;
      that.$refs.dynamicForm.form = that.selectList[0];
    } else {
      that.$message.warning(messageOnlyText);
    }
 
  },
 
  handleDelete(that, location, messageAllText) {
    if (location === 'top') {
      if (that.selectList.length <= 0) {
        that.$message.warning(messageAllText);
      } else {
        that.$message.success('删除成功!');
      }
    } else if (location === 'menu') {
      that.$message.success('删除成功!');
    }
 
  },
  menuConfigurationWarning(location) {
    if (location === 'menu') {
      this.$message.warning('请重新配置按钮至上方区域');
      return
    }
  },
  topConfigurationWarning(location) {
    if (location === ' top') {
      this.$message.warning('请重新配置按钮至操作区域');
      return
    }
  }
}