AdaKing88
2023-08-23 ae35159387a55199e8ab150ebb97d89d68a235bd
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
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
<#-- noinspection JSDuplicatedDeclaration,RequiredAttributes,NpmUsedModulesInstalled -->
<#-- ** 引入全局工具方法 ** -->
<#--<#include "/common/utils.ftl">-->
<#include "../../../../../../common/utils.ftl">
<#-- ** 定义全局使用的变量 ** -->
<#-- 是否有查询条件 -->
<#assign query_flag=false>
<#-- 是否有下拉查询条件 -->
<#assign query_field_select=false>
<#-- 是否有日期查询条件 -->
<#assign query_field_date=false>
<#-- 是否有字典 -->
<#assign list_need_dict=false>
<#-- 是否有分类字典 -->
<#assign list_need_category=false>
<#-- 是否有省市区 -->
<#assign list_need_pca=false>
<#-- 是否有用户选择 -->
<#assign query_sel_user=false>
<#-- 是否有部门选择 -->
<#assign query_sel_dep=false>
<#-- 是否有下拉多选框 -->
<#assign query_sel_multi=false>
<#-- 是否有下拉搜索框 -->
<#assign query_sel_search=false>
<#-- 是否有省市区组件 -->
<#assign query_field_pca=false>
<#-- 是否有分类字典树 -->
<#assign query_sel_cat=false>
<template>
  <a-card class="j-inner-table-wrapper" :bordered="false">
 
    <!-- 查询区域 begin -->
    <div class="table-page-search-wrapper">
      <a-form layout="inline">
        <a-row :gutter="24">
<#-- 查询区域 开始循环 -->
<#assign query_field_index=0>
<#list columns as po>
  <#if po.isQuery=='Y'>
      <#assign query_field_dictCode="">
    <#if po.dictTable?default("")?trim?length gt 1>
      <#assign query_field_dictCode="${po.dictTable},${po.dictText},${po.dictField}">
    <#elseif po.dictField?default("")?trim?length gt 1>
      <#assign query_field_dictCode="${po.dictField}">
    </#if>
    <#assign query_flag=true>
    <#-- 定义组件可能会需要的属性 -->
    <#assign attr_showTime="show-time date-format=\"YYYY-MM-DD HH:mm:ss\"">
    <#assign indent="">
    <#-- 将index>=2的查询条件隐藏起来 -->
    <#if query_field_index==2>
      <#-- 由于多了一层标签,所以需要多一层缩进 -->
      <#assign indent="  ">
          <template v-if="toggleSearchStatus">
    </#if>
          <#-- update-begin-author:taoyan date:20220303 for: /issues/3420 内嵌风格,datetime控件样式异常 -->
          <#if po.queryMode?default("")?trim=='group' && po.classType=='datetime'>
          ${indent}<a-col :xl="10" :lg="12" :md="12" :sm="24">
          <#else>
          ${indent}<a-col :xl="6" :lg="7" :md="8" :sm="24">
          </#if>
          <#-- update-end-author:taoyan date:20220303 for: /issues/3420 内嵌风格,datetime控件样式异常 -->
            ${indent}<a-form-item label="${po.filedComment}">
    <#-- 普通查询 -->
    <#if po.queryMode=='single'>
      <#-- 日期组件 -->
      <#if po.classType=='date'>
        <#assign query_field_date=true>
              ${indent}<j-date ${getVModel(po)} ${getPlaceholder(po,"请选择")}/>
      <#-- 日期时间组件 -->
      <#elseif po.classType=='datetime'>
        <#assign query_field_date=true>
              ${indent}<j-date ${getVModel(po)} ${getPlaceholder(po,"请选择")} ${attr_showTime}/>
      <#-- 下拉组件 -->
      <#elseif po.classType=='list' || po.classType=='radio' || po.classType=='checkbox'>
        <#assign query_field_select=true>
        <#-- 下拉或是单选,判断数据字典是表字典还是普通字典 -->
        <#if (po.dictTable!"")?trim?length gt 1>
          ${indent}<j-dict-select-tag ${getVModel(po)} ${getPlaceholder(po,"请选择")} dictCode="${po.dictTable},${po.dictText},${po.dictField}"/>
        <#elseif (po.dictField!"")?trim?length gt 1>
          ${indent}<j-dict-select-tag ${getVModel(po)} ${getPlaceholder(po,"请选择")} dictCode="${po.dictField}"/>
        <#else>
          ${indent}<a-input ${getVModel(po)} ${getPlaceholder(po,"请输入")}/>
        </#if>
      <#-- 用户选择组件 -->
      <#elseif po.classType=='sel_user'>
      <#assign query_sel_user=true>
             ${indent}<j-select-user-by-dep placeholder="请选择${po.filedComment}" v-model="queryParam.${po.fieldName}"/>
      <#-- 部门选择组件 -->
      <#elseif po.classType=='sel_depart'>
      <#assign query_sel_dep=true>
             ${indent}<j-select-depart placeholder="请选择${po.filedComment}" v-model="queryParam.${po.fieldName}"/>
      <#elseif po.classType=='list_multi'>
      <#-- 下拉多选框组件 -->
      <#assign query_sel_multi=true>
             ${indent}<j-multi-select-tag placeholder="请选择${po.filedComment}" dictCode="${query_field_dictCode?default("")}" v-model="queryParam.${po.fieldName}"/>
      <#-- popup组件 -->
      <#elseif po.classType=='popup'>
             ${indent}<j-popup placeholder="请选择${po.filedComment}" v-model="queryParam.${po.fieldName}" code="${po.dictTable}" org-fields="${po.dictField}" dest-fields="${po.dictText}" :field="getPopupField('${po.dictText}')" :multi="${po.extendParams.popupMulti?c}"/>
      <#-- 下拉搜索框 -->
     <#elseif po.classType=='sel_search'>
     <#assign query_sel_search=true>
             ${indent}<j-search-select-tag placeholder="请选择${po.filedComment}" v-model="queryParam.${po.fieldName}" dict="${po.dictTable},${po.dictText},${po.dictField}"/>
     <#elseif po.classType=='pca'>
     <#assign query_field_pca=true>
             ${indent}<j-area-linkage type="cascader" v-model="queryParam.${po.fieldName}" placeholder="请选择省市区"/>
     <#elseif po.classType=='cat_tree'>
     <#assign query_sel_cat=true>
             ${indent}<j-category-select placeholder="请选择${po.filedComment}" v-model="queryParam.${po.fieldName}" pcode="${po.dictField?default("")}"/>
      <#-- 其他都归为输入框组件 -->
      <#else>
             ${indent}<a-input ${getVModel(po)} ${getPlaceholder(po,"请输入")}/>
      </#if>
    <#-- 范围查询 -->
    <#else>
      <#-- 范围日期组件 -->
      <#if po.classType=='date'>
        <#assign query_field_date=true>
          ${indent}<j-date class="query-group-cust" ${getVModel(po, "_begin")} ${getPlaceholder(po, "请选择开始日期",false)}/>
          ${indent}<span class="query-group-split-cust"></span>
          ${indent}<j-date class="query-group-cust" ${getVModel(po, "_end")} ${getPlaceholder(po, "请选择结束日期",false)}/>
      <#-- 范围日期时间组件 -->
      <#elseif po.classType=='datetime'>
        <#assign query_field_date=true>
          ${indent}<j-date class="query-group-cust" ${getVModel(po, "_begin")} ${getPlaceholder(po, "请选择开始时间",false)} ${attr_showTime}/>
          ${indent}<span class="query-group-split-cust"></span>
          ${indent}<j-date class="query-group-cust" ${getVModel(po, "_end")} ${getPlaceholder(po, "请选择结束时间",false)} ${attr_showTime}/>
      <#-- 其他都归为范围输入框组件 -->
      <#else>
          ${indent}<a-input class="query-group-cust" ${getVModel(po, "_begin")} ${getPlaceholder(po, "请输入最开始值",false)}/>
          ${indent}<span class="query-group-split-cust"></span>
          ${indent}<a-input class="query-group-cust" ${getVModel(po, "_end")} ${getPlaceholder(po, "请输入最结束值",false)}/>
      </#if>
    </#if>
            ${indent}</a-form-item>
          ${indent}</a-col>
    <#assign query_field_index=query_field_index+1>
  </#if>
  <#-- 判断是否需要字典 -->
  <#if !list_need_dict && po.fieldShowType != 'popup' && (po.dictField!"")?trim?length gt 1>
    <#assign list_need_dict=true>
  </#if>
  <#-- 判断是否需要分类字典 -->
  <#if po.classType == 'cat_tree' && (po.dictText!"")?trim?length == 0>
    <#assign list_need_category=true>
  </#if>
   <#-- 判断是否需要省市区 -->
  <#if po.classType=='pca'>
  <#assign list_need_pca=true>
  </#if>
</#list>
<#-- 查询区域-结束循环 -->
<#if query_field_index gt 2>
          </template>
</#if>
<#if query_flag>
          <a-col :xl="6" :lg="7" :md="8" :sm="24">
            <span class="table-page-search-submitButtons table-operator">
              <a-button type="primary" icon="search" @click="searchQuery">查询</a-button>
              <a-button type="primary" icon="reload" @click="searchReset">重置</a-button>
              <a @click="handleToggleSearch" style="margin-left: 8px">
                <span>{{ toggleSearchStatus ? '收起' : '展开' }}</span>
                <a-icon :type="toggleSearchStatus ? 'up' : 'down'"/>
              </a>
            </span>
          </a-col>
</#if>
        </a-row>
      </a-form>
    </div>
    <!-- 查询区域 end -->
 
    <!-- 操作按钮区域 begin -->
    <div class="table-operator">
      <a-button type="primary" icon="plus" @click="handleAdd">新增</a-button>
      <a-button type="primary" icon="download" @click="handleExportXls('${tableVo.ftlDescription}')">导出</a-button>
      <a-upload name="file" :showUploadList="false" :multiple="false" :headers="tokenHeader" :action="importExcelUrl" @change="handleImportExcel">
        <a-button type="primary" icon="import">导入</a-button>
      </a-upload>
      <!-- 高级查询区域 -->
      <j-super-query :fieldList="superFieldList" ref="superQueryModal" @handleSuperQuery="handleSuperQuery"></j-super-query>
      <a-dropdown v-if="selectedRowKeys.length > 0">
        <a-menu slot="overlay">
          <a-menu-item key="1" @click="batchDel">
            <a-icon type="delete"/>
            <span>删除</span>
          </a-menu-item>
        </a-menu>
        <a-button>
          <span>批量操作</span>
          <a-icon type="down"/>
        </a-button>
      </a-dropdown>
    </div>
    <!-- 操作按钮区域 end -->
 
    <!-- table区域 begin -->
    <div>
 
      <a-alert type="info" showIcon style="margin-bottom: 16px;">
        <template slot="message">
          <span>已选择</span>
          <a style="font-weight: 600;padding: 0 4px;">{{ selectedRowKeys.length }}</a>
          <span>项</span>
          <a style="margin-left: 24px" @click="onClearSelected">清空</a>
        </template>
      </a-alert>
 
      <a-table
        ref="table"
        size="middle"
        bordered
        rowKey="id"
        class="j-table-force-nowrap"
        :scroll="{x:true}"
        :loading="loading"
        :columns="columns"
        :dataSource="dataSource"
        :pagination="ipagination"
        :expandedRowKeys="expandedRowKeys"
        :rowSelection="{selectedRowKeys, onChange: onSelectChange}"
        @expand="handleExpand"
        @change="handleTableChange"
      >
 
        <!-- 内嵌table区域 begin -->
        <template slot="expandedRowRender" slot-scope="record">
          <a-tabs tabPosition="top">
<#list subTables as sub>
            <a-tab-pane tab="${sub.ftlDescription}" key="${sub.entityName?uncap_first}" forceRender>
  <#assign subTableCompName=camelToHorizontal("${sub.entityName?uncap_first}", "lower")/>
              <${subTableCompName}-sub-table :record="record"/>
            </a-tab-pane>
</#list>
          </a-tabs>
        </template>
        <!-- 内嵌table区域 end -->
 
        <template slot="htmlSlot" slot-scope="text">
          <div v-html="text"></div>
        </template>
 
        <template slot="imgSlot" slot-scope="text,record">
          <div style="font-size: 12px;font-style: italic;">
            <span v-if="!text">无图片</span>
            <img v-else :src="getImgView(text)" :preview="record.id" alt="" style="max-width:80px;height:25px;"/>
          </div>
        </template>
 
        <#if list_need_pca>
        <template slot="pcaSlot" slot-scope="text">
          <div>{{ getPcaText(text) }}</div>
        </template>
        </#if>
 
        <template slot="fileSlot" slot-scope="text">
          <span v-if="!text" style="font-size: 12px;font-style: italic;">无文件</span>
          <a-button
            v-else
            ghost
            type="primary"
            icon="download"
            size="small"
            @click="downloadFile(text)"
          >
            <span>下载</span>
          </a-button>
        </template>
 
        <template slot="action" slot-scope="text, record">
          <a @click="handleEdit(record)">编辑</a>
          <a-divider type="vertical"/>
          <a-dropdown>
            <a class="ant-dropdown-link">更多 <a-icon type="down" /></a>
            <a-menu slot="overlay">
              <a-menu-item>
                <a-popconfirm title="确定删除吗?" @confirm="handleDelete(record.id)">
                  <a>删除</a>
                </a-popconfirm>
              </a-menu-item>
            </a-menu>
          </a-dropdown>
 
        </template>
 
      </a-table>
    </div>
    <!-- table区域 end -->
 
    <!-- 表单区域 -->
<#assign modalForm=camelToHorizontal("${entityName?uncap_first}", "lower")/>
    <${modalForm}-modal ref="modalForm" @ok="modalFormOk"/>
 
  </a-card>
</template>
 
<script>
 
  import { JeecgListMixin } from '@/mixins/JeecgListMixin'
  import ${entityName}Modal from './modules/${entityName}Modal'
<#list subTables as sub>
  import ${sub.entityName}SubTable from './subTables/${sub.entityName}SubTable'
</#list>
<#if query_field_select>
  import JDictSelectTag from '@/components/dict/JDictSelectTag.vue'
</#if>
<#if query_field_date>
  import JDate from '@/components/jeecg/JDate.vue'
</#if>
<#if list_need_dict>
  import {filterMultiDictText} from '@/components/dict/JDictSelectUtil'
</#if>
<#if list_need_category>
  import { loadCategoryData } from '@/api/api'
</#if>
<#if query_sel_user>
  import JSelectUserByDep from '@/components/jeecgbiz/JSelectUserByDep'
</#if>
<#if query_sel_dep>
  import JSelectDepart from '@/components/jeecgbiz/JSelectDepart'
</#if>
<#if query_sel_multi>
  import JMultiSelectTag from '@/components/dict/JMultiSelectTag'
</#if>
<#if query_sel_search>
  import JSearchSelectTag from '@/components/dict/JSearchSelectTag'
</#if>
<#if query_field_pca>
  import JAreaLinkage from '@comp/jeecg/JAreaLinkage'
</#if>
<#if query_sel_cat>
  import JCategorySelect from '@comp/jeecg/JCategorySelect'
</#if>
 <#if list_need_pca>
  import Area from '@/components/_util/Area'
  </#if>
  import '@/assets/less/TableExpand.less'
 
  export default {
    name: '${entityName}List',
    mixins: [JeecgListMixin],
    components: {
      ${entityName}Modal,
<#list subTables as sub>
      ${sub.entityName}SubTable,
</#list>
<#if query_field_date>
      JDate,
</#if>
<#if query_field_select>
      JDictSelectTag,
</#if>
<#if query_sel_user>
      JSelectUserByDep,
</#if>
<#if query_sel_dep>
      JSelectDepart,
</#if>
<#if query_sel_multi>
      JMultiSelectTag,
</#if>
<#if query_sel_search>
      JSearchSelectTag,
</#if>
<#if query_field_pca>
      JAreaLinkage,
</#if>
<#if query_sel_cat>
      JCategorySelect,
</#if>
    },
    data() {
      return {
        description: '${tableVo.ftlDescription}列表管理页面',
        // 表头
        columns: [
          {
            title: '#',
            key: 'rowIndex',
            width: 60,
            align: 'center',
            customRender: (t, r, index) => parseInt(index) + 1
          },
<#-- begin 遍历表头 -->
<#list columns as po>
  <#if po.isShowList == 'Y'>
          {
            title: '${po.filedComment}',
            align: 'center',
            <#if po.sort=='Y'>
            sorter: true,
            </#if>
    <#if po.classType == 'date'>
            dataIndex: '${po.fieldName}',
    <#elseif po.fieldDbType=='Blob'>
           dataIndex: '${po.fieldName}String'
    <#elseif po.classType=='umeditor'>
            dataIndex: '${po.fieldName}',
            scopedSlots: {customRender: 'htmlSlot'}
    <#elseif po.classType=='pca'>
            dataIndex: '${po.fieldName}',
            scopedSlots: {customRender: 'pcaSlot'}
    <#elseif po.classType=='file'>
            dataIndex: '${po.fieldName}',
            scopedSlots: {customRender: 'fileSlot'}
    <#elseif po.classType=='image'>
            dataIndex: '${po.fieldName}',
            scopedSlots: {customRender: 'imgSlot'}
    <#elseif po.classType == 'sel_tree' || po.classType=='list' || po.classType=='list_multi' || po.classType=='sel_search' || po.classType=='radio' || po.classType=='checkbox' || po.classType=='sel_depart' || po.classType=='sel_user'>
            dataIndex: '${po.fieldName}_dictText'
    <#elseif po.classType=='cat_tree'>
      <#if list_need_category>
            dataIndex: '${po.fieldName}',
            customRender: (text) => (text ? filterMultiDictText(this.dictOptions['${po.fieldName}'], text) : '')
      <#else>
            dataIndex: '${po.fieldName}',
            customRender: (text, record) => (text ? record['${dashedToCamel(po.dictText)}'] : '')
      </#if>
    <#elseif po.classType=='switch'>
            dataIndex: '${po.fieldName}',
            <#if po.dictField != 'is_open'>
            customRender: (text) => (!text ? "" : (text == ${po.dictField}[0] ? "是" : "否"))
            <#else>
            customRender: (text) => (!text ? "" : (text == "Y" ? "是" : "否"))
            </#if>
    <#else>
            dataIndex: '${po.fieldName}',
    </#if>
          },
  </#if>
</#list>
<#-- end 遍历表头 -->
          {
            title: '操作',
            dataIndex: 'action',
            align: 'center',
            width:147,
            scopedSlots: { customRender: 'action' },
          },
        ],
        // 字典选项
        dictOptions: {},
        // 展开的行test
        expandedRowKeys: [],
<#assign urlPrefix="/${entityPackage}/${entityName?uncap_first}">
        url: {
          list: '${urlPrefix}/list',
          delete: '${urlPrefix}/delete',
          deleteBatch: '${urlPrefix}/deleteBatch',
          exportXlsUrl: '${urlPrefix}/exportXls',
          importExcelUrl: '${urlPrefix}/importExcel',
        },
        <#if list_need_pca>
        pcaData:'',
        </#if>
        superFieldList:[],
      }
    },
    created() {
      <#if list_need_pca>
      this.pcaData = new Area()
      </#if>
      this.getSuperFieldList();
    },
    computed: {
      importExcelUrl() {
        return window._CONFIG['domianURL'] + this.url.importExcelUrl
      }
    },
    methods: {
     <#if list_need_pca>
      getPcaText(code){
        return this.pcaData.getText(code);
      },
     </#if>
      initDictConfig() {
<#list columns as po>
  <#if (po.isQuery=='Y' || po.isShowList=='Y') && po.classType!='popup'>
    <#if po.classType=='cat_tree' && list_need_category==true>
        loadCategoryData({ code: "${po.dictField?default('')}" }).then((res) => {
          if (res.success) {
            this.$set(this.dictOptions, '${po.fieldName}', res.result)
          }
        })
    </#if>
  </#if>
</#list>
      },
 
      handleExpand(expanded, record) {
        this.expandedRowKeys = []
        if (expanded === true) {
          this.expandedRowKeys.push(record.id)
        }
      },
      getSuperFieldList(){
        <#include "/common/utils.ftl">
        let fieldList=[];
         <#list columns as po>
        fieldList.push(${superQueryFieldList(po)})
         </#list>
        this.superFieldList = fieldList
      }
    }
  }
</script>
<style lang="less" scoped>
  @import '~@assets/less/common.less';
</style>