xiangpei
2025-04-18 ccadf9480d4e6a9dcc227a2a0b1f9ae0612e36fd
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
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
#set($select = "[0]")
<template>
  <div class="view">
    <div class="search-warp">
      <el-form :inline="true" :model="searchForm" class="demo-form-inline" size="small">
        #foreach($field in ${queryInfo.fields})
          <el-form-item label="$!{field.comment}">
            #if(${field.columnType} == "String")
            <el-input clearable @clear="search" v-model="searchForm.$!{field.propertyName}" placeholder="$!{field.comment}"></el-input>
            #elseif(${field.columnType} == "BigDecimal" or ${field.columnType} == "Integer")
            <el-input clearable @clear="search" type="number" v-model="searchForm.$!{field.propertyName}" placeholder="$!{field.comment}"></el-input>
            #end
          </el-form-item>
        #end
        <el-form-item>
          <el-button type="primary" @click="search">查找</el-button>
        </el-form-item>
      </el-form>
    </div>
    <OperateC
            :top-level="topLevel"
            :add="add$!{vueInfo.name}"
            :edit="edit$!{vueInfo.name}"
            :remove="remove$!{vueInfo.name}"
            :add-show="this.$getButtonAuth('$!{vueInfo.lowerName}:add')"
            :remove-show="this.$getButtonAuth('$!{vueInfo.lowerName}:del:batch')"
    ></OperateC>
    <$!{vueInfo.name}Table
            :top-level="topLevel"
            ref="$!{vueInfo.name}TableRef"
            :edit-show="this.$getButtonAuth('$!{vueInfo.lowerName}:edit')"
            :del-show="this.$getButtonAuth('$!{vueInfo.lowerName}:del')"
    ></$!{vueInfo.name}Table>
    <$!{vueInfo.name}Dialog></$!{vueInfo.name}Dialog>
  </div>
</template>
 
<script>
  import $!{vueInfo.name}Dialog from "@/components/dialog/$!{vueInfo.name}Dialog";
  import OperateC from "@/components/OperateC";
  import $!{vueInfo.name}Table from "@/components/table/$!{vueInfo.name}Table";
  import {delete$!{vueInfo.name}ByIds, get$!{vueInfo.name}s} from "@/api/$!{vueInfo.lowerName}";
  export default {
    name: "$!{vueInfo.viewName}",
    components: {$!{vueInfo.name}Dialog, OperateC, $!{vueInfo.name}Table},
    data() {
      return {
        searchForm: {
          #foreach($field in ${queryInfo.fields})
          ${field.propertyName}: #if(${field.columnType} == "String")'', #else null, #end
          #end
        },
        topLevel: 1
      }
    },
    methods: {
      search() {
        this.$refs.$!{vueInfo.name}TableRef.get$!{vueInfo.name}s(this.searchForm)
      },
      add$!{vueInfo.name}() {
        let params = {
          dialogFormVisible: true,
          dialogTitle: "添加$!{table.comment}"
        }
        this.#[[$store]]#.commit("$!{vueInfo.lowerName}/openDialogForm", params);
      },
      edit$!{vueInfo.name}() {
        let selected = this.#[[$store]]#.state.$!{vueInfo.lowerName}.multipleSelection;
        if (selected.length < 1) {
          this.$message.warning("你还没有选中数据哦!");
          return;
        }
        if (selected.length > 1) {
          this.$message.warning("一次只能修改一条数据哦!")
          return;
        }
        this.#[[$store]]#.dispatch("$!{vueInfo.lowerName}/edit$!{vueInfo.name}", selected[0]);
      },
      remove$!{vueInfo.name}() {
        let selected = this.#[[$store]]#.state.$!{vueInfo.lowerName}.multipleSelection;
        if (selected.length < 1) {
          this.$message.warning("请先选择要删除的数据哦!");
          return;
        }
        this.$confirm('确定删除吗?', '提示', {
          confirmButtonText: '确定',
          cancelButtonText: '取消',
          type: 'warning'
        }).then(() => {
          delete$!{vueInfo.name}ByIds(selected).then((res) => {
            this.#[[$message]]#.success(res.data.msg);
            // 刷新
            let params = {
              "current": this.#[[$store]]#.state.$!{vueInfo.lowerName}.currentPage,
              "size": this.#[[$store]]#.state.$!{vueInfo.lowerName}.pageSize
            };
            get$!{vueInfo.name}s(params).then((res) => {
              this.#[[$store]]#.state.$!{vueInfo.lowerName}.tableData = res.data.data;
              this.#[[$store]]#.state.$!{vueInfo.lowerName}.total = res.data.total;
            })
          })
        }).catch(() => {
          this.$message({
            type: 'info',
            message: '已取消删除'
          });
        });
      },
    }
  }
</script>
 
<style scoped>
 
</style>