ludc
2024-09-02 b9f3e4a899013ce21de3fc1ac127d137c7494595
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
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
<template>
  <el-container>
 
    <el-aside>
      <basic-container>
        <div ref="TreeBox" style="height: calc(100vh - 144px);!important;">
          <!-- 左侧树 -->
          <div style="height:  calc(100vh - 220px);">
            <div style="margin-bottom: 10px;display: flex;justify-content: center">
              <el-radio v-model="treeRadio" label="0" @input="TreeRadioChange">业务类型树</el-radio>
              <el-radio v-model="treeRadio" label="1" @input="TreeRadioChange">链接类型树</el-radio>
            </div>
            <avue-tree v-loading="treeLoading" :data="treeData" :option="treeOption" @node-click="nodeClick">
          <span slot-scope="{ node, data }" class="el-tree-node__label">
           <span style="font-size: 15px">
              <i class="el-icon-s-promotion"></i>
                {{ (node || {}).label }}
            </span>
          </span>
            </avue-tree>
          </div>
        </div>
      </basic-container>
    </el-aside>
 
    <el-main>
      <basic-container>
        <avue-crud
          v-if="!tableStatus"
          :data="data"
          :option="option"
          :page.sync="page"
          @size-change="sizeChange"
          @current-change="currentChange">
          <template slot="menuLeft">
            <div style="display: flex; align-items: center;">
               <span style="display: inline-block; margin-right: 10px;">
                <el-radio v-model="tableRadio" label="0" @input="tableRadioChange">表单</el-radio>
                <el-radio v-model="tableRadio" label="1" @input="tableRadioChange">表格<span style="color: red;">(先导入表单,再导入表格!)</span></el-radio>
               </span>
              <span style="display: flex;align-items: center; margin-right: 10px;">
                <p style="display: flex; flex-shrink: 0;font-size: 14px">名称:</p>
                <el-input v-model="input" placeholder="请输入内容" size="mini"></el-input>
              </span>
              <span style="display: flex; align-items: center;">
                <p
                  style="display: flex; align-items: center; margin: 0 10px 0 0;flex-shrink: 0;font-size: 14px">克隆目标:</p>
                <el-input v-model="input" placeholder="请输入内容" size="mini" style="margin-right: 10px;"></el-input>
                <el-button plain size="mini" type="success">克隆目标</el-button>
              </span>
            </div>
          </template>
          <template slot="menu" slot-scope="scope">
            <el-button icon="el-icon-edit" size="small" type="text" @click="editBtnClick(scope.row)">编辑
            </el-button>
            <el-button icon="el-icon-delete" size="small" type="text" @click="rowDeleteHandler(scope.row)">删除
            </el-button>
          </template>
        </avue-crud>
        <div v-if="!tableStatus" style="display: flex;justify-content: center;margin-top: 15px">
          <el-button icon="el-icon-plus" plain size="small" type="primary" @click="addClickHandler">增加</el-button>
          <el-button icon="el-icon-delete" plain size="small" type="danger">删除</el-button>
          <el-button icon="el-icon-document-add" plain size="small" type="primary">克隆</el-button>
          <el-button icon="el-icon-upload2" plain size="small" type="primary" @click="upLoadHandler">导入</el-button>
          <el-button icon="el-icon-download" plain size="small" type="primary" @click="downLoadHandler">导出</el-button>
        </div>
      </basic-container>
    </el-main>
    <form-dialog ref="formDialog"></form-dialog>
    <table-dialog ref="tableDialog"></table-dialog>
  </el-container>
</template>
 
<script>
import basicOption from "@/util/basic-option";
import FormDialog from "@/views/modelingMenu/ui/formDefine/components/formDialog";
import TableDialog from "@/views/modelingMenu/ui/formDefine/components/tableDialog"
import {gridPortalVIDatas} from "@/api/UI/formDefine/api"
import {getBizTypes} from "@/api/modeling/businessType/api";
import {gridLink} from "@/api/modeling/linkType/api";
import func from "@/util/func";
 
export default {
  name: "index",
  components: {FormDialog, TableDialog},
  data() {
    return {
      page: {
        currentPage: 1,
        pageSize: 10,
        total: 0,
        pageSizes: [10, 30, 50, 100],
      },
      nodeRow: {},
      treeLoading: false,
      option: {
        ...basicOption,
        addBtn: false,
        editBtn: false,
        delBtn: false,
        column: [
          {
            label: '业务名称',
            prop: 'typeName',
          },
          {
            label: '名称',
            prop: 'viName',
            sortable: true,
          },
          {
            label: '类型',
            prop: 'viTypeText',
          },
        ]
      },
      data: [],
      tableRadio: "",
      treeRadio: "0",
      treeData: [],
      treeOption: {
        addBtn: false
      }
    }
  },
  created() {
    this.getTreeList();
  },
  computed: {
    tableStatus() {
      return func.isEmptyObject(this.nodeRow)
    }
  },
  methods: {
    // 右侧新增
    addClickHandler() {
      if (!this.tableRadio) {
        this.$message.error('请在表格上方选择新增类型');
        return;
      }
 
      this.tableRadio === "0" ? this.$refs.formDialog.visible = true : this.$refs.tableDialog.visible = true;
    },
 
    // 初始化树请求
    getTreeList() {
      this.treeLoading = true;
      getBizTypes().then(res => {
        const data = res.data.data.map(item => {
          item.label = item.attributes.id;
          return item;
        });
        this.treeData = data;
        this.treeLoading = false;
      })
    },
 
    // 左侧业务类型切换
    TreeRadioChange(val) {
      this.treeLoading = true;
      this.resetTable();
      if (val === "0") {
        getBizTypes().then(res => {
          const data = res.data.data.map(item => {
            item.label = item.attributes.id;
            return item;
          });
          this.treeData = data;
          this.treeLoading = false;
        })
      } else {
        gridLink().then(res => {
          const data = res.data.data.map(item => {
            item.label = item.name;
            return item;
          });
          this.treeData = data;
          this.treeLoading = false;
        })
      }
    },
 
    // 左侧树点击
    nodeClick(row) {
      console.log(row);
      this.tableRadio = null;
      this.nodeRow = row;
      this.getRightPortalVIDatas(row);
    },
 
    // 重置表格展示信息 和 表格表单选项
    resetTable() {
      this.data = [];
      this.tableRadio = null;
    },
 
    // 右侧 表格 表单 信息查询
    getRightPortalVIDatas() {
      const params = {
        'conditionMap[typeName]': this.treeRadio === '0' ? this.nodeRow.attributes.id : this.nodeRow.name,
        'conditionMap[viType]': this.tableRadio === '0' ? 'Form' : this.tableRadio === '1' ? 'Table' : '',
        'conditionMap[viTypeFlag]': this.treeRadio === '0' ? 'BtmType' : this.treeRadio === '1' ? 'LinkType' : '',
      }
      gridPortalVIDatas(this.page.currentPage, this.page.pageSize, params).then(res => {
        console.log(res);
        if (res.data.code === 200) {
          const data = res.data.data;
          this.data = data;
          this.page.total = res.data.total;
        }
      })
    },
 
    sizeChange(val) {
      this.page.pageSize = val;
      this.getRightPortalVIDatas();
    },
 
    // 页码
    currentChange(val) {
      this.page.currentPage = val;
      this.getRightPortalVIDatas();
    },
 
    // 表格 表单切换
    tableRadioChange() {
      this.getRightPortalVIDatas();
    },
 
  }
}
</script>
 
<style lang="scss" scoped>
::v-deep {
  .el-scrollbar__wrap {
    overflow: auto !important;
  }
 
  .headerCon {
    .el-button {
      width: 82px;
    }
  }
}
 
.headerCon {
  display: flex;
  flex-wrap: wrap;
  margin-bottom: 5px;
 
  .el-button + .el-button {
    margin-left: 5px;
  }
 
  .el-button {
    margin-top: 5px;
  }
}
 
.headerCon > .el-button:nth-child(4) {
  margin-left: 0;
}
 
.headerCon > .el-button:nth-child(7) {
  margin-left: 0;
}
 
 
.smallBtn {
  width: 82px;
  text-align: center;
  padding-left: 4.5px;
}
 
</style>