黎星凯
2024-04-15 62b6a7fac3f2acde70b578431147c4a01f19c182
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
<template>
  <div class="app-container">
    <!--左侧树形开始-->
    <el-col :span="5">
      <el-card class="box-card" shadow="never">
        <my-tree ref="searchTree" :tree-list="treeDataList" @setNode="nodeClick" @search="search"></my-tree>
      </el-card>
    </el-col>
    <!--左侧树形结束-->
    <!--右侧列表开始-->
    <el-container>
      <el-card class="box-card" style="width: 100%" shadow="never">
        <!--搜索条件-->
        <div class="filter-container">
          <my-search ref="searchBar" :items="items" @search="fifterForm"></my-search>
        </div>
        <el-row style="margin-top: 8px">
          <el-col>
            <!--列表-->
            <my-table-v2 ref="myTable" :filter="filterFrom" :table="table" />
          </el-col>
        </el-row>
      </el-card>
    </el-container>
    <!-- 添加或修改参数配置对话框 -->
 
    <edit v-if="editSetting.show" :setting="editSetting" @close="editSetting.show = false" @search="search()" />
  </div>
</template>
 
<script>
import myTree from '@/components/myTree/index';
import MyTableV2 from '@/components/myTable/myTableV2';
import SettingIplatform from '@/utils/settingIplatform';
import edit from './edit';
import * as finsystenant from '@/api/baseSetting/finsystenant';
 
export default {
  name: 'Dict',
  components: { MyTableV2, myTree, edit },
  data() {
    return {
      // 树数据
      treeDataList: [],
      constants: this.$constants,
      // 遮罩层
      loading: true,
      // 选中数组
      ids: [],
      // 非单个禁用
      single: true,
      // 非多个禁用
      multiple: true,
      // 显示搜索条件
      showSearch: true,
      // 总条数
      total: 0,
      // 字典表格数据
      typeList: [],
      // 弹出层标题
      title: '',
      // 是否显示弹出层
      open: false,
      // 日期范围
      dateRange: [],
      editSetting: {
        title: '',
        id: '',
        show: false,
      },
      filterFrom: {},
      items: [
        {
          type: 'text',
          dataIndex: 'name',
          label: '部门名称',
          placeholder: '请输入',
          defaultValue: '',
        },
        {
          type: 'text',
          dataIndex: 'code',
          label: '编号',
          placeholder: '请输入',
          defaultValue: '',
        },
        {
          type: 'select',
          dataIndex: 'status',
          label: '状态',
          placeholder: '请选择',
          defaultValue: '1',
          options: [
            {
              value: '1',
              label: '启用',
            },
            {
              value: '0',
              label: '禁用',
            },
          ],
        },
      ],
      table: {
        showIndex: true, // 是否显示序号
        expand: false, // 是否显示详情数据
        url: SettingIplatform.apiBaseURL + '/pc/fin/sys/tenant/department/list', // 请求地址
        // 工具条
        tools: {
          columnsCtrl: {
            // 列控制按钮
            show: false,
          },
          generalExport: {
            // 通用导出按钮
            show: false,
          },
          // 自定义工具条按钮
          custom: [
            {
              name: '新增',
              click: () => {
                this.handleAdd(null);
              },
            },
          ],
        },
        // 列信息
        columns: [
          { title: '编号', field: 'code', align: 'center', width: 80 },
          { title: '部门', field: 'name', align: 'left', minWidth: 200 },
          { title: '顺序号', field: 'orderNum', align: 'center', width: 100 },
          { title: '备注', field: 'remark', align: 'left', minWidth: 200 },
          {
            title: '状态',
            field: 'status',
            align: 'center',
            width: 100,
            formatter: (row) => {
              return { value: row.status === 1 ? '启用' : '禁用' };
            },
          },
        ],
        // 操作信息
        operation: {
          width: 100,
          align: 'center',
          show: true, // 显示操作列
          attr: [
            {
              title: '编辑',
              events: (row) => {
                this.showEdit(row);
              },
            },
          ],
        },
        paging: {
          show: true, // 显示分页
          // 分页信息
          page: {
            small: false,
            pageNum: 1,
            pageSize: 10,
            total: 0,
          },
        },
      },
    };
  },
  created() {
    this.initTreeData();
  },
  methods: {
    // 左侧树初始化
    initTreeData() {
      finsystenant.getTree().then((res) => {
        const content = res || [];
        this.treeDataList.splice(0, this.treeDataList.length);
        this.treeDataList = content;
        if (this.treeDataList && this.treeDataList.length > 0) {
          this.tenantId = this.treeDataList[0].id;
          this.tenantName = this.treeDataList[0].label;
          this.tenantCode = this.treeDataList[0].code;
        }
      });
    },
    nodeClick(param) {
      this.p = Object.assign(
        {},
        {
          id: param.id,
          name: param.name,
        },
      );
      if (this.p.id) {
        this.filterFrom.tenantId = this.p.id;
        this.editSetting.tenantId = this.p.id;
      } else {
        this.filterFrom.tenantId = null;
        this.editSetting.tenantId = null;
      }
      this.search(1);
    },
    fifterForm(params) {
      this.filterFrom = Object.assign(this.filterFrom, params);
      this.search(1);
    },
    // 查询table列表
    search(pageNum) {
      if (pageNum != undefined) {
        this.$refs.myTable.search({pageNum});
      } else {
        this.$refs.myTable.search();
      }
    },
    /** 新增按钮操作 */
    handleAdd() {
      if (this.editSetting.tenantId) {
        this.editSetting.id = null;
        this.editSetting.info = null;
        this.editSetting.title = '新增';
        this.editSetting.show = true;
      } else {
        this.$message.warning('请先选择左侧机构');
      }
    },
    showEdit(row) {
      console.log(row);
      this.editSetting.id = row.id;
      this.editSetting.info = row;
      this.editSetting.title = '编辑';
      this.editSetting.show = true;
    },
  },
};
</script>