Blame view

ant-design-vue-jeecg/src/components/jeecg/JEditableTable.vue 126 KB
1
<!-- JEditableTable -->
2
<!-- @version 1.6.2 -->
3
4
5
6
<!-- @author sjlei -->
<template>
  <a-spin :spinning="loading">
7
8
9
10
11
12
13
    <a-row type="flex">
      <a-col>
        <slot name="buttonBefore" :target="getVM()"/>
      </a-col>
      <a-col>
        <!-- 操作按钮 -->
        <div v-if="actionButton" class="action-button">
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
          <a-button-group v-if="buttonPermission('add')">
            <a-button type="primary" icon="plus" @click="handleClickAdd" :disabled="disabled">新增</a-button>
            <a-popover v-if="addButtonSettings" placement="right" overlayClassName="j-add-btn-settings">
              <a-row slot="title">
                <a-col :span="12">选项</a-col>
                <a-col :span="12" style="text-align: right;">
                  <a-tooltip title="保存为默认值">
                    <a-button type="link" icon="save" size="small" style="position: relative;left:4px;" @click="onAddButtonSettingsSave"/>
                  </a-tooltip>
                </a-col>
              </a-row>
              <template slot="content">
                <a-form-model layout="horizontal" :labelCol="{span:8}" :wrapperCol="{span:16}">
                  <a-form-model-item label="添加行数">
                    <a-input-number v-model="settings.addRowNum" :min="1"/>
                  </a-form-model-item>
                  <a-form-model-item label="添加位置">
                    <a-input-number v-model="settings.addIndex" :min="0" :max="rows.length"/>
                    <p style="font-size: 12px;color:#aaa;line-height: 14px;text-align: right;margin: 0;">0 = 最底部</p>
                  </a-form-model-item>
                  <a-divider style="margin: 8px 0;"/>
                  <a-checkbox v-model="settings.addScrollToBottom">添加后滚动到底部</a-checkbox>
                </a-form-model>
              </template>
              <a-button icon="setting" type="primary"></a-button>
            </a-popover>
          </a-button-group>
41
          <span class="gap"></span>
42
43
44
45
          <template v-if="selectedRowIds.length>0">
            <a-popconfirm
              :title="`确定要删除这 ${selectedRowIds.length} 项吗?`"
              @confirm="handleConfirmDelete">
46
              <a-button v-if="buttonPermission('batch_delete')" type="primary" icon="minus" :disabled="disabled">删除</a-button>
47
48
49
50
51
52
53
54
55
56
57
58
59
              <span class="gap"></span>
            </a-popconfirm>
            <template v-if="showClearSelectButton">
              <a-button icon="delete" @click="handleClickClearSelection">清空选择</a-button>
              <span class="gap"></span>
            </template>
          </template>
        </div>
      </a-col>
      <a-col>
        <slot name="buttonAfter" :target="getVM()"/>
      </a-col>
    </a-row>
60
61
62
    <slot name="actionButtonAfter" :target="getVM()"/>
63
64
    <div :id="`${caseId}inputTable`" class="input-table">
      <!-- 渲染表头 -->
65
66
      <div class="thead" ref="thead">
        <div class="tr" :style="{width: this.realTrWidth}">
67
          <!-- 左侧固定td  -->
68
          <div v-if="dragSort" class="td td-ds" :style="style.tdLeft">
69
70
            <span></span>
          </div>
71
72
73
74
75
76
77
78
79
80
81
82
83
84
          <div v-if="rowSelection" class="td td-cb" :style="style.tdLeft">
            <!--:indeterminate="true"-->
            <a-checkbox
              :checked="getSelectAll"
              :indeterminate="getSelectIndeterminate"
              @change="handleChangeCheckedAll"
            />
          </div>
          <div v-if="rowNumber" class="td td-num" :style="style.tdLeft">
            <span>#</span>
          </div>
          <!-- 右侧动态生成td -->
          <template v-for="col in columns">
            <div
85
              v-show="col.type !== formTypes.hidden"
86
87
              class="td"
              :key="col.key"
88
              :style="buildTdStyle(col)">
89
90
91
92
93
94
95

              <span>{{ col.title }}</span>
            </div>
          </template>
        </div>
      </div>
96
      <div class="scroll-view" ref="scrollView" :style="{'max-height':maxHeight+'px'}">
97
98
99
100
101
102
103
104
105
106
        <!-- 渲染主体 body -->
        <div :id="`${caseId}tbody`" class="tbody" :style="tbodyStyle">
          <!-- 扩展高度 -->
          <div class="tr-expand" :style="`height:${getExpandHeight}px; z-index:${loading?'11':'9'};`"></div>
          <!-- 无数据时显示 -->
          <div v-if="rows.length===0" class="tr-nodata">
            <span>暂无数据</span>
          </div>
107
          <!-- v-model="rows"-->
108
109
110
111
112
113
          <draggable
            :value="rows"
            handle=".td-ds-icons"
            @start="handleDragMoveStart"
            @end="handleDragMoveEnd"
          >
114
115
116
117
118
119

            <!-- 动态生成tr -->
            <template v-for="(row,rowIndex) in rows">
              <!-- tr 只加载可见的和预加载的总共十条数据 -->
              <div
                v-if="
120
121
122
                rowIndex >= parseInt(`${(scrollTop-rowHeight) / rowHeight}`) &&
                  (parseInt(`${scrollTop / rowHeight}`) + 9) > rowIndex
              "
123
124
125
126
127
                :id="`${caseId}tbody-tr-${rowIndex}`"
                :data-idx="rowIndex"
                class="tr"
                :class="selectedRowIds.indexOf(row.id) !== -1 ? 'tr-checked' : ''"
                :style="buildTrStyle(rowIndex)"
128
129
130
                :key="row.id"
                @click="handleClickTableRow"
              >
131
132
                <!-- 左侧固定td  -->
133
                <div v-if="dragSort" class="td td-ds" :style="style.tdLeft" @dblclick="_handleRowInsertDown(rowIndex)" >
134
135
136
137
138
139
140
141
142
143
144
145
146
                  <a-dropdown :trigger="['click']" :getPopupContainer="getParentContainer">
                    <div class="td-ds-icons">
                      <a-icon type="align-left"/>
                      <a-icon type="align-right"/>
                    </div>

                    <a-menu slot="overlay">
                      <a-menu-item key="0" :disabled="rowIndex===0" @click="_handleRowMoveUp(rowIndex)">向上移</a-menu-item>
                      <a-menu-item key="1" :disabled="rowIndex===(rows.length-1)" @click="_handleRowMoveDown(rowIndex)">向下移</a-menu-item>
                      <a-menu-divider/>
                      <a-menu-item key="3" @click="_handleRowInsertDown(rowIndex)">插入一行</a-menu-item>
                    </a-menu>
                  </a-dropdown>
147
                </div>
148
149
150
151
                <div v-if="rowSelection" class="td td-cb" :style="style.tdLeft">
                  <!-- 此 v-for 只是为了拼接 id 字符串 -->
                  <template v-for="(id,i) in [`${row.id}`]">
152
153
154
                    <a-checkbox
                      :id="id"
                      :key="i"
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
                      :checked="selectedRowIds.indexOf(id) !== -1"
                      @change="handleChangeLeftCheckbox"/>
                  </template>
                </div>
                <div v-if="rowNumber" class="td td-num" :style="style.tdLeft">
                  <span>{{ rowIndex+1 }}</span>
                </div>
                <!-- 右侧动态生成td -->
                <div
                  class="td"
                  v-for="col in columns"
                  v-show="col.type !== formTypes.hidden"
                  :key="col.key"
                  :style="buildTdStyle(col)">

                  <!-- 此 v-for 只是为了拼接 id 字符串 -->
                  <template v-for="(id,i) in [`${col.key}${row.id}`]">

                    <!-- native input -->
                    <label :key="i" v-if="col.type === formTypes.input || col.type === formTypes.inputNumber">
175
                      <a-tooltip v-bind="buildTooltipProps(row, col, id)">
176
                        <input
177
                          v-if="isEditRow(row, col)"
178
179
180
181
                          :id="id"
                          v-bind="buildProps(row,col)"
                          :data-input-number="col.type === formTypes.inputNumber"
                          :placeholder="replaceProps(col, col.placeholder)"
182
                          @blur="(e)=>{handleBlurCommono(e.target,rowIndex,row,col)}"
183
                          @input="(e)=>{handleInputCommono(e.target,rowIndex,row,col)}"
184
185
186
187
188
189
190
                        />
                        <span
                          v-else
                          class="j-td-span no-edit"
                          :class="{disabled: buildProps(row,col).disabled}"
                          @click="handleEditRow(row, col)"
                        >{{ inputValues[rowIndex][col.key] }}</span>
191
192
193
194
195
196
197
198
199
200
201
202
203
204
                      </a-tooltip>
                    </label>
                    <!-- checkbox -->
                    <template v-else-if="col.type === formTypes.checkbox">
                      <a-checkbox
                        :key="i"
                        :id="id"
                        v-bind="buildProps(row,col)"
                        :checked="checkboxValues[id]"
                        @change="(e)=>handleChangeCheckboxCommon(e,row,col)"
                      />
                    </template>
                    <!-- select -->
                    <template v-else-if="col.type === formTypes.select">
205
                      <a-tooltip v-bind="buildTooltipProps(row, col, id)">
206
                        <a-select
207
                          v-if="isEditRow(row, col)"
208
209
210
211
212
213
214
215
                          :id="id"
                          :key="i"
                          v-bind="buildProps(row,col)"
                          style="width: 100%;"
                          :value="selectValues[id]"
                          :options="col.options"
                          :getPopupContainer="getParentContainer"
                          :placeholder="replaceProps(col, col.placeholder)"
216
                          :filterOption="(i,o)=>handleSelectFilterOption(i,o,col)"
217
                          :maxTagCount="1"
218
219
220
                          @change="(v)=>handleChangeSelectCommon(v,id,row,col)"
                          @search="(v)=>handleSearchSelect(v,id,row,col)"
                          @blur="(v)=>handleBlurSearch(v,id,row,col)"
221
                          allowClear
222
223
224
225
226
227
228
                        />
                        <span
                          v-else
                          class="j-td-span no-edit"
                          :class="{disabled: buildProps(row,col).disabled}"
                          @click.stop="handleEditRow(row, col)"
                        >{{ getSelectTranslateText(selectValues[id], row, col) }}</span>
229
230
                      </a-tooltip>
                    </template>
231
232
233
234
235
236
237
238
239
240
241
242
243

                    <!-- 部门选择 -->
                    <template v-else-if="col.type === formTypes.sel_depart">
                      <a-tooltip v-bind="buildTooltipProps(row, col, id)">
                        <j-select-depart
                          v-if="isEditRow(row, col)"
                          :id="id"
                          :key="i"
                          v-bind="buildProps(row,col)"
                          style="width: 100%;"
                          :value="departCompValues[id]"
                          :placeholder="replaceProps(col, col.placeholder)"
                          :trigger-change="true"
244
                          :multi="isMultipleSelect(col)"
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
                          @change="(v)=>handleChangeDepartCommon(v,id,row,col)"
                        />
                        <span
                          v-else
                          class="j-td-span no-edit"
                          :class="{disabled: buildProps(row,col).disabled}"
                          @click="handleEditRow(row, col)"
                        >{{ departCompValues[id] }}</span>
                      </a-tooltip>
                    </template>

                    <!-- 用户选择 -->
                    <template v-else-if="col.type === formTypes.sel_user">
                      <a-tooltip v-bind="buildTooltipProps(row, col, id)">
                        <j-select-user-by-dep
                          v-if="isEditRow(row, col)"
                          :id="id"
                          :key="i"
                          v-bind="buildProps(row,col)"
                          style="width: 100%;"
                          :value="userCompValues[id]"
                          :placeholder="replaceProps(col, col.placeholder)"
                          :trigger-change="true"
268
                          :multi="isMultipleSelect(col)"
269
270
271
272
273
274
275
276
277
278
279
                          @change="(v)=>handleChangeUserCommon(v,id,row,col)"
                        />
                        <span
                          v-else
                          class="j-td-span no-edit"
                          :class="{disabled: buildProps(row,col).disabled}"
                          @click="handleEditRow(row, col)"
                        >{{ userCompValues[id] }}</span>
                      </a-tooltip>
                    </template>
280
281
                    <!-- date -->
                    <template v-else-if="col.type === formTypes.date || col.type === formTypes.datetime">
282
                      <a-tooltip v-bind="buildTooltipProps(row, col, id)">
283
                        <j-date
284
                          v-if="isEditRow(row, col)"
285
286
287
288
289
290
291
292
293
294
                          :id="id"
                          :key="i"
                          v-bind="buildProps(row,col)"
                          style="width: 100%;"
                          :value="jdateValues[id]"
                          :getCalendarContainer="getParentContainer"
                          :placeholder="replaceProps(col, col.placeholder)"
                          :trigger-change="true"
                          :showTime="col.type === formTypes.datetime"
                          :dateFormat="col.type === formTypes.date? 'YYYY-MM-DD':'YYYY-MM-DD HH:mm:ss'"
295
                          allowClear
296
297
298
299
300
301
302
303
                          @change="(v)=>handleChangeJDateCommon(v,id,row,col,col.type === formTypes.datetime)"
                        />
                        <span
                          v-else
                          class="j-td-span no-edit"
                          :class="{disabled: buildProps(row,col).disabled}"
                          @click="handleEditRow(row, col)"
                        >{{ jdateValues[id] }}</span>
304
                      </a-tooltip>
305
                    </template>
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

                    <!-- time -->
                    <template v-else-if="col.type === formTypes.time">
                      <a-tooltip v-bind="buildTooltipProps(row, col, id)">
                        <j-time
                          v-if="isEditRow(row, col)"
                          :id="id"
                          :key="i"
                          v-bind="buildProps(row,col)"
                          style="width: 100%;"
                          :value="jdateValues[id]"
                          :getCalendarContainer="getParentContainer"
                          :placeholder="replaceProps(col, col.placeholder)"
                          allowClear
                          @change="(v)=>handleChangeJDateCommon(v,id,row,col)"
                        />
                        <span
                          v-else
                          class="j-td-span no-edit"
                          :class="{disabled: buildProps(row,col).disabled}"
                          @click="handleEditRow(row, col)"
                        >{{ jdateValues[id] }}</span>
                      </a-tooltip>
                    </template>
331
                    <!-- input_pop -->
332
                    <template v-else-if="col.type === formTypes.input_pop||col.type === 'textarea'">
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
                      <a-tooltip v-bind="buildTooltipProps(row, col, id)">
                        <j-input-pop
                          v-if="isEditRow(row, col)"
                          :id="id"
                          :key="i"
                          :width="300"
                          :height="210"
                          :pop-container="`${caseId}tbody`"
                          v-bind="buildProps(row,col)"
                          style="width: 100%;"
                          :value="jInputPopValues[id]"
                          :getCalendarContainer="getParentContainer"
                          :placeholder="replaceProps(col, col.placeholder)"
                          @change="(v)=>handleChangeJInputPopCommon(v,id,row,col)"
                        />
348
                        <span
349
350
351
352
353
                          v-else
                          class="j-td-span no-edit"
                          :class="{disabled: buildProps(row,col).disabled}"
                          @click="handleEditRow(row, col)"
                        >{{ jInputPopValues[id] }}</span>
354
355
                      </a-tooltip>
                    </template>
356
                    <!-- upload -->
357
358
359
360
361
362
363
                    <div v-else-if="col.type === formTypes.upload" :key="i">
                      <template v-if="uploadValues[id] != null" v-for="(file,fileKey) of [(uploadValues[id]||{})]">
                        <a-input
                          :key="fileKey"
                          :readOnly="true"
                          :value="file.name"
                        >
364
365
366
367
368
369
370
371
                          <template slot="addonBefore" style="width: 30px">
                            <a-tooltip v-if="file.status==='uploading'" :title="`上传中(${Math.floor(file.percent)}%)`">
                              <a-icon type="loading"/>
                            </a-tooltip>
                            <a-tooltip v-else-if="file.status==='done'" title="上传完成">
                              <a-icon type="check-circle" style="color:#00DB00;"/>
                            </a-tooltip>
372
                            <a-tooltip v-else :title="file.message||'上传失败'">
373
374
375
376
                              <a-icon type="exclamation-circle" style="color:red;"/>
                            </a-tooltip>
                          </template>
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
                          <template v-if="col.allowDownload!==false || col.allowRemove!==false" slot="addonAfter" style="width: 30px">
                            <a-dropdown :trigger="['click']" placement="bottomRight" :getPopupContainer="getParentContainer">
                              <a-tooltip title="操作" :getPopupContainer="getParentContainer">
                                <a-icon
                                  v-if="file.status!=='uploading'"
                                  type="setting"
                                  style="cursor: pointer;"/>
                              </a-tooltip>

                              <a-menu slot="overlay">
                                <a-menu-item v-if="col.allowDownload!==false" @click="handleClickDownloadFile(id)">
                                  <span><a-icon type="download"/>&nbsp;下载</span>
                                </a-menu-item>
                                <a-menu-item v-if="col.allowRemove!==false" @click="handleClickDelFile(id)">
                                  <span><a-icon type="delete"/>&nbsp;删除</span>
                                </a-menu-item>
                              </a-menu>
                            </a-dropdown>
395
396
397
398
399
400
                          </template>

                        </a-input>
                      </template>

                      <div :hidden="uploadValues[id] != null">
401
402
403
                        <a-tooltip v-bind="buildTooltipProps(row, col, id)">
                          <a-upload
                            name="file"
404
                            :data="{'isup':1, ...(col.data||{})}"
405
406
407
408
409
410
411
412
413
                            :multiple="false"
                            :action="col.action"
                            :headers="uploadGetHeaders(row,col)"
                            :showUploadList="false"
                            v-bind="buildProps(row,col)"
                            @change="(v)=>handleChangeUpload(v,id,row,col)"
                          >
                            <a-button icon="upload">{{ col.placeholder }}</a-button>
                          </a-upload>
414
                        </a-tooltip>
415
                      </div>
416
417
                    </div>
418
419
420
                    <!-- update-begin-author:taoyan date:0827 for:popup -->
                    <template v-else-if="col.type === formTypes.popup">
421
422
423
424
425
426
427
428
429
430
431
432
433
434
                      <a-tooltip v-bind="buildTooltipProps(row, col, id)">
                        <j-popup
                          v-if="isEditRow(row, col)"
                          :id="id"
                          :key="i"
                          v-bind="buildProps(row,col)"
                          :placeholder="replaceProps(col, col.placeholder)"
                          style="width: 100%;"
                          :value="getPopupValue(id)"
                          :field="col.field || col.key"
                          :org-fields="col.orgFields"
                          :dest-fields="col.destFields"
                          :code="col.popupCode"
                          :groupId="caseId"
435
436
                          :param="col.param"
                          :sorter="col.sorter"
437
438
                          @input="(value,others)=>popupCallback(value,others,id,row,col,rowIndex)"
                        />
439
                        <span
440
441
442
443
444
                          v-else
                          class="j-td-span no-edit"
                          :class="{disabled: buildProps(row,col).disabled}"
                          @click="handleEditRow(row, col)"
                        >{{ getPopupValue(id) }}</span>
445
446
447
448
449
450
                      </a-tooltip>
                    </template>
                    <!-- update-end-author:taoyan date:0827 for:popup -->

                    <!-- update-beign-author:taoyan date:0827 for:文件/图片逻辑新增 -->
                    <div v-else-if="col.type === formTypes.file" :key="i">
451
                      <template v-if="hasUploadValue(id)" v-for="(file,fileKey) of [(uploadValues[id]||{})]">
452
453
454
455
456
                        <div :key="fileKey" style="position: relative;">
                          <a-tooltip v-if="file.status==='uploading'" :title="`上传中(${Math.floor(file.percent)}%)`">
                            <a-icon type="loading" style="color:red;"/>
                            <span style="color:red;margin-left:5px">{{  file.status }}</span>
                          </a-tooltip>
457
458
459
460
461
                          <a-tooltip v-else-if="file.status==='done'" :title="file.name">
                            <a-icon type="paper-clip" />
                            <span style="margin-left:5px">{{ getEllipsisWord(file.name,5) }}</span>
                          </a-tooltip>
462
463
464
465
                          <a-tooltip v-else :title="file.message||'上传失败'">
                            <a-icon type="exclamation-circle" style="color:red;"/>
                            <span style="margin-left:5px">{{ getEllipsisWord(file.name,5) }}</span>
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
                          </a-tooltip>

                          <template style="width: 30px">
                            <a-dropdown :trigger="['click']" placement="bottomRight" :getPopupContainer="getParentContainer" style="margin-left: 10px;">
                              <a-tooltip title="操作" :getPopupContainer="getParentContainer">
                                <a-icon v-if="file.status!=='uploading'" type="setting" style="cursor: pointer;"/>
                              </a-tooltip>

                              <a-menu slot="overlay">
                                <a-menu-item v-if="col.allowDownload!==false" @click="handleClickDownFileByUrl(id)">
                                  <span><a-icon type="download"/>&nbsp;下载</span>
                                </a-menu-item>
                                <a-menu-item @click="handleClickDelFile(id)">
                                  <span><a-icon type="delete"/>&nbsp;删除</span>
                                </a-menu-item>
481
                                <a-menu-item @click="handleMoreOperation(id,col,col)">
482
483
484
485
486
487
                                  <span><a-icon type="bars" /> 更多</span>
                                </a-menu-item>
                              </a-menu>
                            </a-dropdown>
                          </template>
                        </div>
488
489
                      </template>
490
                      <div :hidden="hasUploadValue(id)">
491
492
493
494
495
496
497
498
499
500
501
502
503
                        <a-tooltip v-bind="buildTooltipProps(row, col, id)">
                          <a-upload
                            name="file"
                            :data="{'isup':1}"
                            :multiple="false"
                            :action="getUploadAction(col.action)"
                            :headers="uploadGetHeaders(row,col)"
                            :showUploadList="false"
                            v-bind="buildProps(row,col)"
                            @change="(v)=>handleChangeUpload(v,id,row,col)"
                          >
                            <a-button icon="upload">上传文件</a-button>
                          </a-upload>
504
                        </a-tooltip>
505
506
507
508
509
                      </div>

                    </div>

                    <div v-else-if="col.type === formTypes.image" :key="i">
510
                      <template v-if="hasUploadValue(id)" v-for="(file,fileKey) of [(uploadValues[id]||{})]">
511
                        <div :key="fileKey" style="position: relative;">
512
513
514
515
                          <template v-if="!uploadValues[id] || !(uploadValues[id]['url'] || uploadValues[id]['path'] || uploadValues[id]['message'])">
                            <a-icon type="loading"/>
                          </template>
                          <template v-else-if="uploadValues[id]['path']">
516
                            <img class="j-editable-image" :src="getCellImageView(id)" alt="无图片" @click="handleMoreOperation(id,'img',col)"/>
517
                          </template>
518
519
520
                          <a-tooltip v-else :title="file.message||'上传失败'" @click="handleClickShowImageError(id)">
                            <a-icon type="exclamation-circle" style="color:red;"/>
                          </a-tooltip>
521
522

                          <template style="width: 30px">
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
                            <a-dropdown :trigger="['click']" placement="bottomRight" :getPopupContainer="getParentContainer" style="margin-left: 10px;">
                              <a-tooltip title="操作" :getPopupContainer="getParentContainer">
                                <a-icon
                                  v-if="file.status!=='uploading'"
                                  type="setting"
                                  style="cursor: pointer;"/>
                              </a-tooltip>

                              <a-menu slot="overlay">
                                <a-menu-item v-if="col.allowDownload!==false" @click="handleClickDownFileByUrl(id)">
                                  <span><a-icon type="download"/>&nbsp;下载</span>
                                </a-menu-item>
                                <a-menu-item @click="handleClickDelFile(id)">
                                  <span><a-icon type="delete"/>&nbsp;删除</span>
                                </a-menu-item>
538
                                <a-menu-item @click="handleMoreOperation(id,'img',col)">
539
540
541
542
                                  <span><a-icon type="bars" /> 更多</span>
                                </a-menu-item>
                              </a-menu>
                            </a-dropdown>
543
544
545
546
547
                          </template>

                        </div>
                      </template>
548
                      <div :hidden="hasUploadValue(id)">
549
550
551
552
553
554
555
556
557
558
559
560
561
                        <a-tooltip v-bind="buildTooltipProps(row, col, id)">
                          <a-upload
                            name="file"
                            :data="{'isup':1}"
                            :multiple="false"
                            :action="getUploadAction(col.action)"
                            :headers="uploadGetHeaders(row,col)"
                            :showUploadList="false"
                            v-bind="buildProps(row,col)"
                            @change="(v)=>handleChangeUpload(v,id,row,col)"
                          >
                            <a-button icon="upload">上传图片</a-button>
                          </a-upload>
562
                        </a-tooltip>
563
564
565
566
567
568
569
                      </div>

                    </div>
                    <!-- update-end-author:taoyan date:0827 for:图片逻辑新增 -->

                    <!-- radio-begin -->
                    <template v-else-if="col.type === formTypes.radio">
570
571
572
573
574
575
576
577
578
                      <a-tooltip v-bind="buildTooltipProps(row, col, id)">
                        <a-radio-group
                          :id="id"
                          :key="i"
                          v-bind="buildProps(row,col)"
                          :value="radioValues[id]"
                          @change="(e)=>handleRadioChange(e.target.value,id,row,col)">
                          <a-radio v-for="(item, key) in col.options" :key="key" :value="item.value">{{ item.text }}</a-radio>
                        </a-radio-group>
579
580
581
582
583
584
                      </a-tooltip>
                    </template>
                    <!-- radio-end -->

                    <!-- select多选 -begin -->
                    <template v-else-if="col.type === formTypes.list_multi">
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
                      <a-tooltip v-bind="buildTooltipProps(row, col, id)">
                        <a-select
                          v-if="isEditRow(row, col)"
                          :id="id"
                          :key="i"
                          mode="multiple"
                          :maxTagCount="1"
                          v-bind="buildProps(row,col)"
                          style="width: 100%;"
                          :value="multiSelectValues[id]"
                          :options="col.options"
                          :getPopupContainer="getParentContainer"
                          :placeholder="replaceProps(col, col.placeholder)"
                          @change="(v)=>handleMultiSelectChange(v,id,row,col)"
                          allowClear
                        />
601
                        <span
602
603
604
605
606
                          v-else
                          class="j-td-span no-edit"
                          :class="{disabled: buildProps(row,col).disabled}"
                          @click="handleEditRow(row, col)"
                        >{{ getSelectTranslateText(multiSelectValues[id], row, col) }} </span>
607
608
609
610
611
612
                      </a-tooltip>
                    </template>
                    <!-- select多选 -end -->

                    <!-- select搜索 -begin -->
                    <template v-else-if="col.type === formTypes.sel_search">
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
                      <a-tooltip v-bind="buildTooltipProps(row, col, id)">
                        <a-select
                          v-if="isEditRow(row, col)"
                          :id="id"
                          :key="i"
                          showSearch
                          optionFilterProp="children"
                          :filterOption="filterOption"
                          v-bind="buildProps(row,col)"
                          style="width: 100%;"
                          :value="searchSelectValues[id]"
                          :options="col.options"
                          :getPopupContainer="getParentContainer"
                          :placeholder="replaceProps(col, col.placeholder)"
                          @change="(v)=>handleSearchSelectChange(v,id,row,col)"
                          allowClear
                        />
630
                        <span
631
632
633
634
635
                          v-else
                          class="j-td-span no-edit"
                          :class="{disabled: buildProps(row,col).disabled}"
                          @click="handleEditRow(row, col)"
                        >{{ getSelectTranslateText(searchSelectValues[id], row, col) }}</span>
636
637
638
639
                      </a-tooltip>
                    </template>
                    <!-- select搜索 -end -->
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
                    <!-- select异步搜索 -begin -->
                    <template v-else-if="col.type === formTypes.sel_search_async">
                      <a-tooltip v-bind="buildTooltipProps(row, col, id)">
                        <j-search-select-tag
                          v-if="isEditRow(row, col)"
                          :id="id"
                          :key="i"
                          :value="searchSelectAsyncValues[id]"
                          :placeholder="replaceProps(col, col.placeholder)"
                          :dict="col.dict"
                          :async="true"
                          :getPopupContainer="getParentContainer"
                          v-bind="buildProps(row,col)"
                          style="width: 100%;"
                          @change="(v)=>handleSearchSelectAsyncChange(v,id,row,col)"
                        >
                        </j-search-select-tag>
                        <span
                          v-else
                          class="j-td-span no-edit"
                          :class="{disabled: buildProps(row,col).disabled}"
                          @click="handleEditRow(row, col)"
                        >{{ searchSelectAsyncValues[id] }}</span>
                      </a-tooltip>
                    </template>
                    <!-- select异步搜索 -end -->
667
                    <div v-else-if="col.type === formTypes.slot" :key="i">
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
                      <a-tooltip v-bind="buildTooltipProps(row, col, id)">
                        <slot
                          :name="(col.slot || col.slotName) || col.key"
                          :index="rowIndex"
                          :text="slotValues[id]"
                          :value="slotValues[id]"
                          :column="col"
                          :rowId="getCleanId(row.id)"
                          :getValue="()=>_getValueForSlot(row.id)"
                          :caseId="caseId"
                          :allValues="_getAllValuesForSlot()"
                          :target="getVM()"
                          :handleChange="(v)=>handleChangeSlotCommon(v,id,row,col)"
                          :isNotPass="notPassedIds.includes(col.key+row.id)"
                        />
683
                      </a-tooltip>
684
                    </div>
685
686
                    <!-- else (normal) -->
687
                    <span class="comp-normal" v-else :key="i" :title="inputValues[rowIndex][col.key]" v-bind="buildProps(row,col)">{{ inputValues[rowIndex][col.key] }}</span>
688
689
                  </template>
                </div>
690
              </div>
691
              <!-- -- tr end -- -->
692
693
694
            </template>
          </draggable>
695
696
697
698
699
700
701
702
703
704
705

          <!-- 统计行 -->
          <div
            v-if="showStatisticsRow"
            class="tr"
            :style="{
              ...buildTrStyle(rows.length),
              height: '32px'
            }"
          >
706
            <div v-if="dragSort" class="td td-ds" :style="style.tdLeft">
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
            </div>
            <div v-if="rowSelection" class="td td-cb" :style="style.tdLeft">
              统计
            </div>
            <div v-if="rowNumber" class="td td-num" :style="style.tdLeft">
              <span v-if="!rowSelection">统计</span>
            </div>

            <!-- 右侧动态生成td -->
            <template v-for="col in columns">
              <div
                :key="col.key"
                class="td"
                v-show="col.type !== formTypes.hidden"
                :style="buildTdStyle(col)"
              >
                <span
                  v-show="col.type === formTypes.inputNumber"
                  style="padding: 0 5px;"
                >{{statisticsColumns[col.key]}}</span>
              </div>
            </template>

          </div>
732
        </div>
733
      </div>
734
      <j-file-pop ref="filePop" @ok="handleFileSuccess" :number="number"></j-file-pop>
735
736
737
738
739
    </div>
  </a-spin>
</template>

<script>
740
  import Vue from 'vue'
741
  import Draggable from 'vuedraggable'
742
  import { ACCESS_TOKEN } from '@/store/mutation-types'
743
  import { FormTypes, VALIDATE_NO_PASSED } from '@/utils/JEditableTableUtil'
744
  import { cloneObject, getEventPath, randomNumber, randomString } from '@/utils/util'
745
  import JDate from '@/components/jeecg/JDate'
746
  import { filterDictText, initDictOptions } from '@/components/dict/JDictSelectUtil'
747
  import { getFileAccessHttpUrl } from '@/api/manage'
748
749
  import JInputPop from '@/components/jeecg/minipop/JInputPop'
  import JFilePop from '@/components/jeecg/minipop/JFilePop'
750
  import { getNoAuthCols } from '@/utils/authFilter'
751
752
753
754
755
756
  // 行高,需要在实例加载完成前用到
  let rowHeight = 61

  export default {
    name: 'JEditableTable',
757
758
759
760
761
762
763
    components: { JDate, Draggable, JInputPop, JFilePop },
    provide() {
      return {
        parentIsJEditableTable: true,
        getDestroyCleanGroupRequest: () => this.destroyCleanGroupRequest,
      }
    },
764
765
766
767
768
769
770
771
772
    props: {
      // 列信息
      columns: {
        type: Array,
        required: true
      },
      // 数据源
      dataSource: {
        type: Array,
773
774
        required: true,
        default: () => []
775
776
777
778
779
780
      },
      // 是否显示操作按钮
      actionButton: {
        type: Boolean,
        default: false
      },
781
782
783
784
785
      // 是否显示添加按钮选项
      addButtonSettings: {
        type: Boolean,
        default: false
      },
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
      // 是否显示行号
      rowNumber: {
        type: Boolean,
        default: false
      },
      // 是否可选择行
      rowSelection: {
        type: Boolean,
        default: false
      },
      // 页面是否在加载中
      loading: {
        type: Boolean,
        default: false
      },
801
      // 表格内容区域最大高度
802
803
804
805
806
807
808
809
810
811
      maxHeight: {
        type: Number,
        default: 400
      },
      // 要禁用的行
      disabledRows: {
        type: Object,
        default() {
          return {}
        }
812
813
814
815
816
      },
      // 是否禁用全部组件
      disabled: {
        type: Boolean,
        default: false
817
818
819
820
821
822
823
824
825
826
      },
      // 是否可拖拽排序
      dragSort: {
        type: Boolean,
        default: false
      },
      dragSortKey: {
        type: String,
        default: 'orderNum'
      },
827
828
829
830
831
      // 是否一直显示编辑框,如果为false则只有点击的时候才出现输入框
      alwaysEdit: {
        type: Boolean,
        default: true
      },
832
833
834
835
836
      authPre: {
        type: String,
        required: false,
        default: ''
      },
837
838
839
    },
    data() {
      return {
840
841
842
843
        // 是否首次运行
        isFirst: true,
        // 当前实例是否是行编辑
        isJEditableTable: true,
844
845
        // caseId,用于防止有多个实例的时候会冲突
        caseId: `_jet-${randomString(6)}-`,
846
847
        // 临时ID标识,凡是以该标识结尾的ID都是临时ID,不添加到数据库中
        tempId: `_tid-${randomString(6)}`,
848
849
850
851
852
853
854
        // 存储document element 对象
        el: {
          inputTable: null,
          tbody: null
        },
        // 存储各个div的style
        style: {
855
856
          // 'max-height': '400px'
          tbody: { left: '0px' },
857
          // 左侧固定td的style
858
          tdLeft: {},
859
860
861
862
863
864
865
866
867
868
869
870
871
872
873
        },
        // 表单的类型
        formTypes: FormTypes,
        // 行数据
        rows: [],
        // 行高,height + padding + border
        rowHeight,
        // 滚动条顶部距离
        scrollTop: 0,
        // 绑定 select 的值
        selectValues: {},
        // 绑定 checkbox 的值
        checkboxValues: {},
        // 绑定 jdate 的值
        jdateValues: {},
874
875
        // 绑定jinputpop
        jInputPopValues:{},
876
877
        // 绑定插槽数据
        slotValues: {},
878
879
        // file 信息
        uploadValues: {},
880
        //popup信息
881
        popupValues: {},
882
883
884
885
        //部门组件信息
        departCompValues:{},
        //用户组件信息
        userCompValues: {},
886
887
888
889
890
        radioValues: {},
        metaCheckboxValues: {},
        multiSelectValues: {},
        searchSelectValues: {},
891
        searchSelectAsyncValues: {},
892
893
894
895
896
897
898
        // 绑定左侧选择框已选择的id
        selectedRowIds: [],
        // 存储被删除行的id
        deleteIds: [],
        // 存储显示tooltip的信息
        tooltips: {},
        // 存储没有通过验证的inputId
899
900
901
902
903
904
905
906
907
        notPassedIds: [],

        // 当前是否正在拖拽排序
        dragging: false,
        // 是否有统计列
        hasStatisticsColumn: false,
        statisticsColumns: {},
        // 只有在行编辑被销毁时才主动清空GroupRequest的内存
        destroyCleanGroupRequest: false,
908
909
910
911
        // 当前正在编辑的行的id
        currentEditRows: {},
        // 上次push数据的事件,用于判断是否点击过快
        lastPushTimeMap: new Map(),
912
        number:0,
913
        //不显示的按钮编码
914
915
916
917
918
919
920
921
922
923
        excludeCode:[],
        // 选项配置
        settings: {
          // 添加行数
          addRowNum: 1,
          // 添加位置(下标),0 = 最底部
          addIndex: 0,
          // 添加后滚动到底部
          addScrollToBottom: false,
        },
924
925
926
      }
    },
    created() {
927
      this.inputValues = []
928
929
930
      // 当前显示的tr
      this.visibleTrEls = []
      this.disabledRowIds = (this.disabledRowIds || [])
931
932
933
934
935
936
937
      // 解决火狐浏览器下拖拽会打开新的Tab的问题
      document.body.ondrop = (event) => {
        if (this.dragging) {
          event.preventDefault()
          event.stopPropagation()
        }
      }
938
      this.getSavedAddButtonSettings()
939
940
941
942
943
    },
    // 计算属性
    computed: {
      // expandHeight = rows.length * rowHeight
      getExpandHeight() {
944
945
946
947
948
949
950
951
952
        let length = this.rows.length * this.rowHeight
        if (this.showStatisticsRow) {
          length += 34
        }
        return length
      },
      // 是否显示统计行
      showStatisticsRow() {
        return this.hasStatisticsColumn && this.rows.length > 0
953
954
955
956
957
958
959
960
961
962
963
964
      },
      // 获取是否选择了部分
      getSelectIndeterminate() {
        return (this.selectedRowIds.length > 0 &&
          this.selectedRowIds.length < this.rows.length)
      },
      // 获取是否选择了全部
      getSelectAll() {
        return (this.selectedRowIds.length === this.rows.length) && this.rows.length > 0
      },
      tbodyStyle() {
        let style = Object.assign({}, this.style.tbody)
965
966
        // style['max-height'] = `${this.maxHeight}px`
        style['width'] = this.realTrWidth
967
968
969
970
971
972
973
974
        return style
      },
      showClearSelectButton() {
        let count = 0
        for (let key in this.disabledRows) {
          if (this.disabledRows.hasOwnProperty(key)) count++
        }
        return count > 0
975
976
977
978
979
      },
      accessToken() {
        return Vue.ls.get(ACCESS_TOKEN)
      },
      realTrWidth() {
980
        let splice = ' + '
981
982
        let calcWidth = 'calc('
        this.columns.forEach((column, i) => {
983
984
985
986
987
988
989
990
991
992
          let { type, width } = column
          // 隐藏字段不参与计算
          if (type !== FormTypes.hidden) {
            if (typeof width === 'number') {
              calcWidth += width + 'px'
            } else if (typeof width === 'string') {
              calcWidth += width
            } else {
              calcWidth += '120px'
            }
993
            calcWidth += splice
994
995
          }
        })
996
997
998
        if (calcWidth.endsWith(splice)) {
          calcWidth = calcWidth.substring(0, calcWidth.length - splice.length)
        }
999
        calcWidth += ')'
1000
        // console.log('calcWidth: ', calcWidth)
1001
        return calcWidth
1002
1003
1004
1005
      }
    },
    // 侦听器
    watch: {
1006
1007
1008
      rows: {
        immediate: true,
        handler(val, old) {
1009
1010
1011
1012
1013
1014
1015
1016
1017
1018
1019
          // val.forEach(item => {
          //   for (let inputValue of  this.inputValues) {
          //     if (inputValue.id === item.id) {
          //       item['dbFieldName'] = inputValue['dbFieldName']
          //       break
          //     }
          //   }
          // })
          // console.log('watch.rows:', cloneObject({ val, old }))
        }
      },
1020
1021
1022
      dataSource: {
        immediate: true,
        handler: function (newValue) {
1023
1024
1025
          // 兼容IE
          this.getElementPromise('tbody').then(() => {
            this.initialize()
1026
            this._pushByDataSource(newValue)
1027
1028
          })
        }
1029
      },
1030
1031
1032
      columns: {
        immediate: true,
        handler(columns) {
1033
1034
          //列改变的时候重新设置按钮权限信息
          this.loadExcludeCode()
1035
1036
1037
1038
1039
1040
1041
1042
1043
1044
1045
1046
1047
          // 兼容IE
          this.getElementPromise('tbody').then(() => {
            columns.forEach(column => {
              if (column.type === FormTypes.select || column.type === FormTypes.list_multi || column.type === FormTypes.sel_search) {
                // 兼容 旧版本 options
                if (column.options instanceof Array) {
                  column.options = column.options.map(item => {
                    if (item) {
                      return {
                        ...item,
                        text: item.text || item.title,
                        title: item.text || item.title
                      }
1048
                    }
1049
1050
1051
1052
1053
1054
                    return {}
                  })
                }
                if (column.dictCode) {
                  this._loadDictConcatToOptions(column)
                }
1055
              }
1056
            })
1057
1058
1059
          })
        }
      },
1060
1061
      // 当selectRowIds改变时触发事件
      selectedRowIds(newValue) {
1062
        this.$emit('selectRowChange', cloneObject(newValue).map(i => this.getCleanId(i)))
1063
1064
1065
1066
1067
      }
    },
    mounted() {
      let vm = this
      /** 监听滚动条事件 */
1068
      this.getElement('inputTable').onscroll = function (event) {
1069
1070
        vm.syncScrollBar(event.target.scrollLeft)
      }
1071
      this.getElement('tbody').onscroll = function (event) {
1072
1073
1074
1075
        // vm.recalcTrHiddenItem(event.target.scrollTop)
      }

      let { thead, scrollView } = this.$refs
1076
      scrollView.onscroll = function (event) {
1077
1078
1079
1080
1081

        // console.log(event.target.scrollTop, ' - ', event.target.scrollLeft)

        thead.scrollLeft = event.target.scrollLeft
1082
        vm.recalcTrHiddenItem(event.target.scrollTop)
1083
1084
      }
1085
1086
1087
1088
      // 添加事件监听
      this.addEventListener()
1089
1090
    },
    methods: {
1091
1092
1093
1094
1095
      // 判断文件/图片是否存在
      hasUploadValue(id){
        let flag = this.uploadValues[id] != null && this.uploadValues[id].toString().length>0
        return flag;
      },
1096
1097
1098
1099
1100
1101
1102
1103
1104
1105
1106
1107
1108
1109
1110
1111
1112
1113
1114
      getElement(id, noCaseId = false) {
        if (!this.el[id]) {
          this.el[id] = document.getElementById((noCaseId ? '' : this.caseId) + id)
        }
        return this.el[id]
      },

      getElementPromise(id, noCaseId = false) {
        return new Promise((resolve) => {
          let timer = setInterval(() => {
            let element = this.getElement(id, noCaseId)
            if (element) {
              clearInterval(timer)
              resolve(element)
            }
          }, 10)
        })
      },
1115
1116
1117
      /** 初始化列表 */
      initialize() {
        this.visibleTrEls = []
1118
1119
        // 判断是否是首次进入该方法,如果是就不清空行,防止删除了预添加的数据
        if (!this.isFirst) {
1120
         this.clearRow();
1121
1122
1123
        } else {
          this.isFirst = false
        }
1124
      },
1125
1126
1127
1128
1129
1130
1131
1132
1133
1134
1135
1136
1137
1138
1139
      /**清空行*/
      clearRow(){
        // inputValues:用来存储input表单的值
        // 数组里的每项都是一个对象,对象里每个key都是input的rowKey,值就是input的值,其中有个id的字段来区分
        // 示例:
        // [{
        //    id: "_jet-4sp0iu-15541771111770"
        //    dbDefaultVal: "aaa",
        //    dbFieldName: "bbb",
        //    dbFieldTxt: "ccc",
        //    dbLength: 32
        // }]
        this.inputValues = []
        this.rows = []
        this.deleteIds = []
1140
1141
1142
1143
        this.selectedRowIds = []
        this.tooltips = {}
        this.notPassedIds = []
        // 重置values
1144
1145
1146
1147
1148
1149
1150
        this.selectValues = {}
        this.checkboxValues = {}
        this.jdateValues = {}
        this.jInputPopValues = {}
        this.departCompValues = {}
        this.userCompValues = {}
        this.slotValues = {}
1151
1152
1153
1154
1155
1156
1157
1158
1159
1160
        //update-begin-author:shunjlei date:20210415 for:类型赋值错误
        this.uploadValues = {}
        this.popupValues = {}
        this.radioValues = {}
        this.multiSelectValues = {}
        this.searchSelectValues = {}
        this.searchSelectAsyncValues = {}
        //update-end-author:shunjlei date:20210415 for:类型赋值错误

        // 重置滚动条
1161
1162
1163
1164
1165
        this.scrollTop = 0
        this.$nextTick(() => {
          this.getElement('tbody').scrollTop = 0
        })
      },
1166
1167
      /** 同步滚动条状态 */
      syncScrollBar(scrollLeft) {
1168
        // this.style.tbody.left = `${scrollLeft}px`
1169
        // this.getElement('tbody').scrollLeft = scrollLeft
1170
1171
1172
      },
      /** 重置滚动条位置,参数留空则滚动到上次记录的位置 */
      resetScrollTop(top) {
1173
        let { scrollView } = this.$refs
1174
        if (top != null && typeof top === 'number') {
1175
          scrollView.scrollTop = top
1176
        } else {
1177
          scrollView.scrollTop = this.scrollTop
1178
1179
1180
1181
1182
1183
1184
1185
1186
1187
1188
1189
1190
1191
1192
1193
1194
        }
      },
      /** 重新计算需要隐藏或显示的tr */
      recalcTrHiddenItem(top) {
        let diff = top - this.scrollTop
        if (diff < 0) {
          diff = this.scrollTop - top
        }
        // 只有在滚动了百分之三十的行高的距离时才进行更新
        if (diff >= this.rowHeight * 0.3) {
          this.scrollTop = top
          // 更新form表单的值
          this.$nextTick(() => {
            this.updateFormValues()
          })
        }
      },
1195
1196
1197
1198
1199
1200
      /** 生成id */
      generateId(rows) {
        if (!(rows instanceof Array)) {
          rows = this.rows || []
        }
        let timestamp = new Date().getTime()
1201
        return `${this.caseId}${timestamp}${rows.length}${randomNumber(6)}${this.tempId}`
1202
      },
1203
      /** push 一条数据 */
1204
1205
1206
1207
1208
1209
1210
1211
1212
1213
1214
1215
1216
1217
1218
      push(record, update = true, rows, insertIndex = null, setDefaultValue = true) {
        return this._pushByDataSource([record], [insertIndex], update, rows, setDefaultValue)
      },

      /**
       * push 数据
       *
       * @param dataSource 数据源
       * @param insertIndexes 行插入位置,和dataSource的下标一一对应
       * @param update 是否更新
       * @param rows 若不传就使用 this.rows
       * @param setDefaultValue 是否填充默认值
       *
       */
      _pushByDataSource(dataSource, insertIndexes = null, update = true, rows = null, setDefaultValue = false) {
1219
        if (!(rows instanceof Array)) {
1220
1221
1222
1223
1224
          rows = [...this.rows] || []
        }
        let checkboxValues = { ...this.checkboxValues }
        let selectValues = { ...this.selectValues }
        let jdateValues = { ...this.jdateValues }
1225
1226
        let departCompValues = { ...this.departCompValues }
        let userCompValues = { ...this.userCompValues }
1227
1228
1229
1230
1231
1232
1233
        let jInputPopValues = { ...this.jInputPopValues }
        let slotValues = { ...this.slotValues }
        let uploadValues = { ...this.uploadValues }
        let popupValues = { ...this.popupValues }
        let radioValues = { ...this.radioValues }
        let multiSelectValues = { ...this.multiSelectValues }
        let searchSelectValues = { ...this.searchSelectValues }
1234
        let searchSelectAsyncValues = { ...this.searchSelectAsyncValues }
1235
1236
1237
1238
1239
1240
1241
1242
1243
1244
1245
1246
1247
1248
1249
1250
1251
        // 禁用行的id
        let disabledRowIds = (this.disabledRowIds || [])
        dataSource.forEach((data, newValueIndex) => {
          // 不能直接更改数据源的id
          let dataId = data.id
          // 判断源数据是否带有id
          if (dataId == null || dataId === '') {
            dataId = this.generateId(rows)
          } else if(!this.hasCaseId(dataId)) {
            dataId = this.caseId + dataId
          }
          let row = { id: dataId }
          let value = { id: dataId }
          let disabled = false
          this.columns.forEach(column => {
            let inputId = column.key + value.id
            let sourceValue = (data[column.key] == null ? '' : data[column.key]).toString()
1252
1253
1254
1255
1256
1257
1258
            let defaultValue = null;
            if (setDefaultValue) {
              defaultValue = column.defaultValue || (column.defaultValue === 0 ? 0 : '')
              if (defaultValue instanceof Array) {
                defaultValue = defaultValue.join(',')
              }
1259
1260
              sourceValue = (typeof sourceValue === 'number' || sourceValue) ? sourceValue : defaultValue
1261
            }
1262
            let sourceValueIsEmpty = (sourceValue == null || sourceValue === '')
1263
1264
1265
1266
1267
1268
1269
1270
1271
1272
1273
1274
1275
1276
1277
            if (column.type === FormTypes.inputNumber) {
              // 判断是否是排序字段,如果是就赋最大值
              if (column.isOrder === true) {
                value[column.key] = this.getInputNumberMaxValue(column) + 1
              } else {
                value[column.key] = sourceValue
              }
              // 判断是否是统计列
              if (column.statistics) {
                this.hasStatisticsColumn = true
                if (!this.statisticsColumns[column.key]) {
                  this.$set(this.statisticsColumns, column.key, 0)
                }
              }
1278
1279
1280
1281
1282
1283
1284
1285
1286
1287
1288
1289
1290
1291
1292
1293
            } else if (column.type === FormTypes.checkbox) {
              // 判断是否设定了customValue(自定义值)
              if (column.customValue instanceof Array) {
                let customValue = (column.customValue[0] || '').toString()
                if (sourceValueIsEmpty && setDefaultValue) {
                  sourceValue = column.defaultChecked ? customValue : sourceValue
                }
                checkboxValues[inputId] = (sourceValue === customValue)
              } else {
                if (sourceValueIsEmpty && setDefaultValue) {
                  checkboxValues[inputId] = !!column.defaultChecked
                } else {
                  checkboxValues[inputId] = sourceValue
                }
              }
1294
1295
1296
1297
1298
            } else if (column.type === FormTypes.select) {
              if (!sourceValueIsEmpty) {
                // 判断是否是多选
                if (typeof sourceValue === 'string' && (column.props || {})['mode'] === 'multiple') {
1299
                  sourceValue = sourceValue === '' ? [] : sourceValue.split(',')
1300
1301
1302
1303
1304
1305
                }
                selectValues[inputId] = sourceValue
              } else {
                selectValues[inputId] = undefined
              }
1306
            } else if (column.type === FormTypes.date || column.type === FormTypes.datetime || column.type === FormTypes.time) {
1307
1308
1309
1310
1311
1312
1313
              jdateValues[inputId] = sourceValue

            } else if (column.type === FormTypes.slot) {
              slotValues[inputId] = sourceValue

            } else if (column.type === FormTypes.popup) {
              popupValues[inputId] = sourceValue
1314
1315
1316
1317
            } else if (column.type === FormTypes.sel_depart) {
              departCompValues[inputId] = sourceValue
            } else if (column.type === FormTypes.sel_user) {
              userCompValues[inputId] = sourceValue
1318
            } else if (column.type === FormTypes.input_pop || column.type === 'textarea') {
1319
1320
1321
1322
1323
              jInputPopValues[inputId] = sourceValue
            } else if (column.type === FormTypes.radio) {
              radioValues[inputId] = sourceValue
            } else if (column.type === FormTypes.sel_search) {
              searchSelectValues[inputId] = sourceValue
1324
1325
            } else if (column.type === FormTypes.sel_search_async) {
              searchSelectAsyncValues[inputId] = sourceValue
1326
1327
1328
1329
1330
1331
1332
1333
1334
1335
1336
1337
1338
1339
1340
1341
1342
1343
1344
1345
            } else if (column.type === FormTypes.list_multi) {
              if (typeof sourceValue === 'string' && sourceValue.length > 0) {
                multiSelectValues[inputId] = sourceValue.split(',')
              } else {
                multiSelectValues[inputId] = []
              }
            } else if (column.type === FormTypes.upload || column.type === FormTypes.file || column.type === FormTypes.image) {
              if (sourceValue) {
                let fileName = ''
                if (sourceValue.indexOf(',') > 0) {
                  let sourceValue2 = sourceValue.split(',')[0]
                  fileName = sourceValue2.substring(sourceValue2.lastIndexOf('/') + 1)
                } else {
                  fileName = sourceValue.substring(sourceValue.lastIndexOf('/') + 1)
                }
                uploadValues[inputId] = {
                  name: fileName,
                  status: 'done',
                  path: sourceValue
                }
1346
1347
              } else {
                uploadValues[inputId] = null
1348
1349
1350
1351
1352
1353
1354
1355
1356
1357
1358
1359
1360
1361
1362
1363
1364
1365
1366
1367
1368
1369
1370
1371
1372
1373
1374
1375
1376
1377
1378
1379
1380
1381
              }
            } else {
              value[column.key] = sourceValue
            }

            // 解析disabledRows
            for (let columnKey in this.disabledRows) {
              // 判断是否有该属性
              if (this.disabledRows.hasOwnProperty(columnKey) && data.hasOwnProperty(columnKey)) {
                if (disabled !== true) {
                  let temp = this.disabledRows[columnKey]
                  // 禁用规则可以是一个数组
                  if (temp instanceof Array) {
                    disabled = temp.includes(data[columnKey])
                  } else {
                    disabled = (temp === data[columnKey])
                  }
                  if (disabled) {
                    disabledRowIds.push(row.id)
                  }
                }
              }
            }
          })
          // 插入行而不是添加到最后
          let added = false
          if (insertIndexes instanceof Array) {
            let insertIndex = insertIndexes[newValueIndex]
            if (typeof insertIndex === 'number') {
              added = true
              rows.splice(insertIndex, 0, row)
              this.inputValues.splice(insertIndex, 0, value)
            }
          }
1382
1383
1384
1385
1386
1387
          //update-begin-author:lvdandan date:20201105 for:LOWCOD-987 【online】js增强的问题--数据对象带有id,且和现有数据一致时,替换患有数据
          if(-1 !== rows.findIndex(item => item.id === row.id)){
            added = true
            this.inputValues = this.inputValues.map(item => item.id === row.id ? value : item)
          }
          //update-begin-author:lvdandan date:20201105 for:LOWCOD-987 【online】js增强的问题--数据对象带有id,且和现有数据一致时,替换患有数据
1388
1389
1390
          if (!added) {
            rows.push(row)
            this.inputValues.push(value)
1391
1392
          }
        })
1393
        // 启用了拖动排序,就重新计算排序编号
1394
1395
1396
1397
1398
        if (this.dragSort) {
          this.inputValues.forEach((item, index) => {
            item[this.dragSortKey] = (index + 1)
          })
        }
1399
1400
1401
1402
        this.disabledRowIds = disabledRowIds
        this.checkboxValues = checkboxValues
        this.selectValues = selectValues
        this.jdateValues = jdateValues
1403
1404
        this.departCompValues = departCompValues
        this.userCompValues = userCompValues
1405
1406
1407
1408
1409
1410
1411
        this.jInputPopValues = jInputPopValues
        this.slotValues = slotValues
        this.uploadValues = uploadValues
        this.popupValues = popupValues
        this.radioValues = radioValues
        this.multiSelectValues = multiSelectValues
        this.searchSelectValues = searchSelectValues
1412
        this.searchSelectAsyncValues = searchSelectAsyncValues
1413
1414
1415
        // 重新计算所有统计列
        this.recalcAllStatisticsColumns()
        // 更新到 dom
1416
1417
        if (update) {
          this.rows = rows
1418
1419

          // 更新form表单的值
1420
          this.$nextTick(() => {
1421
            this.forceUpdateFormValues()
1422
1423
1424
1425
          })
        }
        return rows
      },
1426
1427
1428
1429
1430
1431
1432
1433
1434
1435
1436
1437
1438
1439
1440
1441
1442
1443
1444
1445
1446
1447
      /** 获取某一数字输入框列中的最大的值 */
      getInputNumberMaxValue(column) {
        let maxNum = 0
        this.inputValues.forEach((item, index) => {
          let val = item[column.key], num
          try {
            num = parseInt(val)
          } catch {
            num = 0
          }
          // 把首次循环的结果当成最大值
          if (index === 0) {
            maxNum = num
          } else {
            maxNum = (num > maxNum) ? num : maxNum
          }
        })
        return maxNum
      },
      /** 添加一行 */
      add(num = 1, forceScrollToBottom = false) {
1448
        if (num < 1) return
1449
        // let timestamp = new Date().getTime()
1450
        let rows = this.rows
1451
        let row
1452
        for (let i = 0; i < num; i++) {
1453
1454
          rows = this.push({}, false, rows)
          row = rows[rows.length - 1]
1455
1456
1457
1458
1459
1460
        }
        this.rows = rows

        this.$nextTick(() => {
          this.updateFormValues()
        })
1461
1462
        // 触发add事件
        this.$emit('added', {
1463
1464
          row: (() => {
            let r = Object.assign({}, row)
1465
            r.id = this.getCleanId(r.id)
1466
1467
            return r
          })(),
1468
1469
          target: this
        })
1470
        // 设置滚动条位置
1471
        let tbody = this.getElement('tbody')
1472
1473
        let offsetHeight = tbody.offsetHeight
        let realScrollTop = tbody.scrollTop + offsetHeight
1474
1475
1476
1477
        if (forceScrollToBottom) {
          this.$nextTick(() => {
            this.resetScrollTop(this.$refs.scrollView.scrollHeight)
          })
1478
1479
        }
      },
1480
1481
1482
1483
1484
      /**
       * 在指定位置添加一行
       * @param insertIndex 添加位置下标
       * @param num 添加的行数,默认1
       */
1485
      insert(insertIndex, num = 1, forceScrollToBottom = false) {
1486
1487
1488
        if (this.checkTooFastClick('insert', 1500)) {
          return
        }
1489
1490
1491
1492
1493
1494
1495
1496
1497
1498
1499
        if (!insertIndex && num < 1) return
        let rows = this.rows
        let newRows = []
        for (let i = 0; i < num; i++) {
          let row = { id: this.generateId(rows) }
          rows = this.push(row, false, rows, insertIndex)
          newRows.push(row)
        }
        // 同步更改
        this.rows = rows
        this.$nextTick(() => {
1500
1501
          this.recalcSortNumber()
          this.forceUpdateFormValues()
1502
1503
1504
1505
1506
        })
        // 触发 insert 事件
        this.$emit('inserted', {
          rows: newRows.map(row => {
            let r = cloneObject(row)
1507
            r.id = this.getCleanId(r.id)
1508
1509
1510
1511
1512
            return r
          }),
          num, insertIndex,
          target: this
        })
1513
1514
1515
1516
1517
1518
        // 设置滚动条位置
        if (forceScrollToBottom) {
          this.$nextTick(() => {
            this.resetScrollTop(this.$refs.scrollView.scrollHeight)
          })
        }
1519
      },
1520
1521
1522
1523
1524
1525
1526
1527
1528
1529
1530
1531
      /** 删除被选中的行 */
      removeSelectedRows() {
        this.removeRows(this.selectedRowIds)
        this.selectedRowIds = []
      },
      /** 删除一行或多行 */
      removeRows(id) {
        let ids = id
        if (!(id instanceof Array)) {
          if (typeof id === 'string') {
            ids = [id]
          } else {
1532
            throw  `JEditableTable.removeRows() 函数需要的参数可以是string或Array类型,但提供的却是${typeof id}`
1533
1534
1535
1536
1537
          }
        }

        let rows = cloneObject(this.rows)
        ids.forEach(removeId => {
1538
          removeId = this.getCleanId(removeId)
1539
1540
1541
          // 找到每个id对应的真实index并删除
          const findAndDelete = (arr) => {
            for (let i = 0; i < arr.length; i++) {
1542
1543
              let currentId = this.getCleanId(arr[i].id)
              if (currentId === removeId) {
1544
1545
1546
1547
1548
1549
1550
                arr.splice(i, 1)
                return true
              }
            }
          }
          // 找到rows对应的index,并删除
          if (findAndDelete(rows)) {
1551
1552
            // 找到values对应的index,并删除
            findAndDelete(this.inputValues)
1553
            // 将caseId去除
1554
            let id = this.getCleanId(removeId)
1555
            this.deleteIds.push(id)
1556
1557
1558
          }
        })
        this.rows = rows
1559
        this.$emit('deleted', this.getDeleteIds(), this)
1560
1561
1562
        this.$nextTick(() => {
          // 更新formValues
          this.updateFormValues()
1563
1564
          // 重新计算统计
          this.recalcAllStatisticsColumns()
1565
        })
1566
1567
1568
        return true
      },
1569
1570
      /** 获取表格表单里的值(异步版) */
      getValuesAsync(options = {}, callback) {
1571
        let { validate, rowIds, deleteTempId } = options
1572
1573
        if (typeof validate !== 'boolean') validate = true
        if (!(rowIds instanceof Array)) rowIds = null
1574
1575
        // 是否删除临时ID,默认为 false
        if (typeof deleteTempId !== 'boolean') deleteTempId = false
1576
1577
        // console.log('options:', { validate, rowIds })
1578
        let asyncCount = 0
1579
        let error = 0
1580
        let inputValues = cloneObject(this.inputValues)
1581
1582
        let tooltips = Object.assign({}, this.tooltips)
        let notPassedIds = cloneObject(this.notPassedIds)
1583
1584
1585
1586
1587
1588
1589
1590
1591
1592
        // 用于存储合并后的值
        let values = []
        // 遍历inputValues来获取每行的值
        for (let value of inputValues) {
          let rowIdsFlag = false
          // 如果带有rowIds,那么就只存这几行的数据
          if (rowIds == null) {
            rowIdsFlag = true
          } else {
            for (let rowId of rowIds) {
1593
              if (this.getCleanId(rowId) === this.getCleanId(value.id)) {
1594
1595
1596
1597
1598
1599
1600
1601
                rowIdsFlag = true
                break
              }
            }
          }

          if (!rowIdsFlag) continue
1602
1603
1604
1605
1606
1607
1608
1609
1610
1611
1612
          this.columns.forEach(column => {
            let inputId = column.key + value.id
            if (column.type === FormTypes.checkbox) {
              let checked = this.checkboxValues[inputId]
              if (column.customValue instanceof Array) {
                value[column.key] = checked ? column.customValue[0] : column.customValue[1]
              } else {
                value[column.key] = checked
              }

            } else if (column.type === FormTypes.select) {
1613
1614
1615
1616
1617
1618
              let selected = this.selectValues[inputId]
              if (selected instanceof Array) {
                value[column.key] = cloneObject(selected)
              } else {
                value[column.key] = selected
              }
1619
1620
            } else if (column.type === FormTypes.date || column.type === FormTypes.datetime || column.type === FormTypes.time) {
1621
1622
              value[column.key] = this.jdateValues[inputId]
1623
1624
1625
1626
1627
1628
            } else if (column.type === FormTypes.sel_depart) {
              value[column.key] = this.departCompValues[inputId]

            } else if (column.type === FormTypes.sel_user) {
              value[column.key] = this.userCompValues[inputId]
1629
            } else if (column.type === FormTypes.input_pop || column.type === 'textarea') {
1630
1631
              value[column.key] = this.jInputPopValues[inputId]
1632
1633
1634
            } else if (column.type === FormTypes.upload) {
              value[column.key] = cloneObject(this.uploadValues[inputId] || null)
1635
1636
            } else if (column.type === FormTypes.image || column.type === FormTypes.file) {
              let currUploadObj = cloneObject(this.uploadValues[inputId] || null)
1637
              if (currUploadObj) {
1638
1639
1640
1641
                value[column.key] = currUploadObj['path'] || null
              }

            } else if (column.type === FormTypes.popup) {
1642
              if (!value[column.key]) {
1643
1644
1645
1646
                value[column.key] = this.popupValues[inputId] || null
              }
            } else if (column.type === FormTypes.radio) {
              value[column.key] = this.radioValues[inputId]
1647
            } else if (column.type === FormTypes.sel_search) {
1648
              value[column.key] = this.searchSelectValues[inputId]
1649
1650
            } else if (column.type === FormTypes.sel_search_async) {
              value[column.key] = this.searchSelectAsyncValues[inputId]
1651
            } else if (column.type === FormTypes.list_multi) {
1652
              if (!this.multiSelectValues[inputId] || this.multiSelectValues[inputId].length === 0) {
1653
                value[column.key] = ''
1654
1655
              } else {
                value[column.key] = this.multiSelectValues[inputId].join(',')
1656
              }
1657
1658
            } else if (column.type === FormTypes.slot) {
              value[column.key] = this.slotValues[inputId]
1659
            }
1660
1661
1662
            // 检查表单验证
1663
            if (validate === true) {
1664
1665
1666
1667
1668
1669
1670
1671
1672
1673
1674
1675
1676
1677
              const handleValidateOneInput = (results) => {
                tooltips[inputId] = results[0]
                if (tooltips[inputId].passed === false) {
                  error++
                  // if (error++ === 0) {
                  // let element = document.getElementById(inputId)
                  // while (element.className !== 'tr') {
                  //   element = element.parentElement
                  // }
                  // this.jumpToId(inputId, element)
                  // }
                }
                tooltips[inputId].visible = false
                notPassedIds = results[1]
1678
              }
1679
1680
1681
1682
1683
1684
              asyncCount++
              let results = this.validateOneInputAsync(value[column.key], value, column, notPassedIds, false, 'getValues', (results) => {
                handleValidateOneInput(results)
                asyncCount--
              })
              handleValidateOneInput(results)
1685
1686
            }
          })
1687
1688
1689
1690
1691
1692
          // 删除 tempId
          if (deleteTempId && this.isTempId(value.id)) {
            delete value.id
          } else {
            value.id = this.getCleanId(value.id)
          }
1693
1694
          values.push(value)
1695
1696
        }
1697
1698
1699
1700
        if (validate === true) {
          this.tooltips = tooltips
          this.notPassedIds = notPassedIds
        }
1701
1702
1703
1704
1705
1706
1707
1708

        const timer = setInterval(() => {
          if (asyncCount === 0) {
            clearInterval(timer)
            if (typeof callback === 'function') {
              callback({ error, values })
            }
          }
1709
        }, 10)
1710
1711
1712
1713
        return { error, values }
      },
1714
1715
1716
1717
1718
      /** 获取表格表单里的值(同步版) */
      getValuesSync(options = {}) {
        return this.getValuesAsync(options)
      },
1719
1720
      /** 获取表格表单里的值 */
      getValues(callback, validate = true, rowIds) {
1721
1722
1723
1724
1725
        this.getValuesAsync({ validate, rowIds }, ({ error, values }) => {
          if (typeof callback === 'function') {
            callback(error, values)
          }
        })
1726
1727
      },
      /** getValues的Promise版 */
1728
      getValuesPromise(validate = true, rowIds, deleteTempId) {
1729
        return new Promise((resolve, reject) => {
1730
          this.getValuesAsync({ validate, rowIds, deleteTempId }, ({ error, values }) => {
1731
1732
1733
1734
1735
1736
            if (error === 0) {
              resolve(values)
            } else {
              reject(VALIDATE_NO_PASSED)
            }
          })
1737
1738
1739
1740
1741
1742
1743
        })
      },
      /** 获取被删除项的id */
      getDeleteIds() {
        return cloneObject(this.deleteIds)
      },
      /** 获取所有的数据,包括values、deleteIds */
1744
      getAll(validate, deleteTempId) {
1745
1746
        return new Promise((resolve, reject) => {
          let deleteIds = this.getDeleteIds()
1747
          this.getValuesPromise(validate, null, deleteTempId).then((values) => {
1748
1749
1750
1751
1752
1753
            resolve({ values, deleteIds })
          }).catch(error => {
            reject(error)
          })
        })
      },
1754
      /** Sync 获取所有的数据,包括values、deleteIds */
1755
1756
      getAllSync(validate, rowIds, deleteTempId) {
        let result = this.getValuesSync({ validate, rowIds, deleteTempId })
1757
1758
1759
1760
1761
1762
1763
        result.deleteIds = this.getDeleteIds()
        return result
      },
      // slot 获取值
      _getValueForSlot(rowId) {
        return this.getValuesSync({ rowIds: [rowId] }).values[0]
      },
1764
1765
1766
1767
1768
1769
      _getAllValuesForSlot() {
        return cloneObject({
          inputValues: this.inputValues,
          selectValues: this.selectValues,
          checkboxValues: this.checkboxValues,
          jdateValues: this.jdateValues,
1770
1771
          departCompValues: this.departCompValues,
          userCompValues: this.userCompValues,
1772
          jInputPopValues: this.jInputPopValues,
1773
          slotValues: this.slotValues,
1774
1775
1776
1777
1778
          uploadValues: this.uploadValues,
          popupValues: this.popupValues,
          radioValues: this.radioValues,
          multiSelectValues: this.multiSelectValues,
          searchSelectValues: this.searchSelectValues,
1779
          searchSelectAsyncValues: this.searchSelectAsyncValues,
1780
1781
        })
      },
1782
1783
1784
1785
1786
      /** 设置某行某列的值 */
      setValues(values) {

        values.forEach(item => {
          let { rowKey, values: newValues } = item
1787
          rowKey = this.getCleanId(rowKey)
1788
1789
1790
          for (let newValueKey in newValues) {
            if (newValues.hasOwnProperty(newValueKey)) {
              let edited = false // 已被修改
1791
1792
1793
1794
1795
1796
1797
1798
1799
1800
1801
1802
1803
1804
1805
1806
1807
1808
1809
1810
1811
1812
1813
1814
1815
1816
1817
1818
1819
1820
1821
1822
1823
1824
              for (let column of this.columns) {
                if (column.key === newValueKey) {
                  let newValue = newValues[newValueKey]
                  this.inputValues.forEach(value => {
                    // 在inputValues中找到了该字段
                    if (rowKey === this.getCleanId(value.id)) {
                      if (value.hasOwnProperty(newValueKey)) {
                        edited = true
                        value[newValueKey] = newValue
                      }
                    }
                  })
                  if (!edited) {
                    let modelKey = `${newValueKey}${this.caseId}${rowKey}`
                    if (column.type === FormTypes.select) {
                      if (newValue !== 0 && !newValue) {
                        edited = this.setOneValue(this.selectValues, modelKey, undefined)
                      } else {
                        edited = this.setOneValue(this.selectValues, modelKey, newValue)
                      }
                    } else if (column.type === FormTypes.checkbox) {
                      // checkbox 特殊处理 CustomValue
                      let key = this.valuesHasOwnProperty(this.checkboxValues, modelKey)
                      // 找到对应的column
                      let sourceValue
                      // 判断是否设定了customValue(自定义值)
                      if (column.customValue instanceof Array) {
                        let customValue = (column.customValue[0] || '').toString()
                        sourceValue = (newValue === customValue)
                      } else {
                        sourceValue = !!newValue
                      }
                      this.$set(this.checkboxValues, key, sourceValue)
                      edited = true
1825
                    } else if (column.type === FormTypes.date || column.type === FormTypes.datetime || column.type === FormTypes.time) {
1826
                      edited = this.setOneValue(this.jdateValues, modelKey, newValue)
1827
1828
1829
1830
                    } else if (column.type === FormTypes.sel_depart) {
                      edited = this.setOneValue(this.departCompValues, modelKey, newValue)
                    } else if (column.type === FormTypes.sel_user) {
                      edited = this.setOneValue(this.userCompValues, modelKey, newValue)
1831
                    } else if (column.type === FormTypes.input_pop || column.type === 'textarea') {
1832
1833
1834
1835
1836
1837
1838
1839
1840
1841
1842
1843
1844
                      edited = this.setOneValue(this.jInputPopValues, modelKey, newValue)
                    } else if (column.type === FormTypes.slot) {
                      edited = this.setOneValue(this.slotValues, modelKey, newValue)
                    } else if (column.type === FormTypes.upload || column.type === FormTypes.image || column.type === FormTypes.file) {
                      edited = this.setOneValue(this.uploadValues, modelKey, newValue)
                    } else if (column.type === FormTypes.popup) {
                      edited = this.setOneValue(this.popupValues, modelKey, newValue)
                    } else if (column.type === FormTypes.radio) {
                      edited = this.setOneValue(this.radioValues, modelKey, newValue)
                    } else if (column.type === FormTypes.list_multi) {
                      edited = this.setOneValue(this.multiSelectValues, modelKey, newValue, true)
                    } else if (column.type === FormTypes.sel_search) {
                      edited = this.setOneValue(this.searchSelectValues, modelKey, newValue)
1845
1846
                    } else if (column.type === FormTypes.sel_search_async) {
                      edited = this.setOneValue(this.searchSelectAsyncValues, modelKey, newValue)
1847
                    } else {
1848
                      edited = false
1849
                    }
1850
1851
1852
                  }
                  if (edited) {
                    this.elemValueChange(column.type, {[newValueKey]: newValue}, column, newValue)
1853
1854
                  }
                }
1855
              }
1856
              if (!edited) {
1857
                console.warn(`JEditableTable.setValues:没有找到"${newValueKey}"列`)
1858
              }
1859
1860
1861
1862
1863
1864
            }
          }
        })
        // 强制更新formValues
        this.forceUpdateFormValues()
      },
1865
1866
1867
1868
1869
1870
1871
1872
      /**
       * 设置单个组件的值
       * @param valuesObject 组件存储值的对象
       * @param modelKey 组件存储值的对象里的key
       * @param value 新值
       * @param isMultiple 是否多选,如果是就会对 value 进行一个 split(',') 的操作
       */
      setOneValue(valuesObject, modelKey, value, isMultiple = false) {
1873
1874
        let key = this.valuesHasOwnProperty(valuesObject, modelKey)
        if (key) {
1875
1876
1877
1878
1879
          // 处理多选数组
          if (isMultiple && !Array.isArray(value)) {
            value = (value || '').toString().trim()
            value = value === '' ? [] : value.split(',')
          }
1880
1881
1882
1883
1884
1885
1886
1887
1888
1889
1890
1891
1892
1893
1894
          this.$set(valuesObject, key, value)
          return true
        }
        return false
      },
      valuesHasOwnProperty(values, ownProperty) {
        let key = ownProperty
        if (values.hasOwnProperty(key)) {
          return key
        }
        if (values.hasOwnProperty(key + this.tempId)) {
          return key + this.tempId
        }
        return null
      },
1895
1896
1897
1898
1899
1900
1901

      /** 跳转到指定位置 */
      // jumpToId(id, element) {
      //   if (element == null) {
      //     element = document.getElementById(id)
      //   }
      //   if (element != null) {
1902
1903
1904
      //     console.log(this.getElement('tbody').scrollTop, element.offsetTop)
      //     this.getElement('tbody').scrollTop = element.offsetTop
      //     console.log(this.getElement('tbody').scrollTop, element.offsetTop)
1905
1906
      //   }
      // },
1907
1908
1909
1910
1911
1912
1913
1914
1915
1916
1917
1918
1919
      /**
       * 验证单个表单,异步版
       *
       * @param value 校验的值
       * @param row 校验的行
       * @param column 校验的列
       * @param notPassedIds 没有通过校验的 id
       * @param update 是否更新到vue中
       * @param validType 校验触发的方式(input、blur等)
       * @param callback
       */
      validateOneInputAsync(value, row, column, notPassedIds, update = false, validType = 'input', callback) {
1920
1921
1922
1923
1924
        let tooltips = Object.assign({}, this.tooltips)
        // let notPassedIds = cloneObject(this.notPassedIds)
        let inputId = column.key + row.id
        tooltips[inputId] = tooltips[inputId] ? tooltips[inputId] : {}
1925
        let [passed, message] = this.validateValue(column, value)
1926
1927
1928

        const nextThen = res => {
          let [passed, message] = res
1929
1930
1931
1932
1933
1934
1935
1936
1937
1938
          // !(passed == null && tooltips[inputId].visible != null)
          if (passed != null) {
            tooltips[inputId].visible = !passed
            tooltips[inputId].passed = passed
            let index = notPassedIds.indexOf(inputId)
            if (!passed) {
              tooltips[inputId].title = this.replaceProps(column, message)
              if (index === -1) notPassedIds.push(inputId)
            } else {
              if (index !== -1) notPassedIds.splice(index, 1)
1939
            }
1940
          }
1941
1942
1943
1944
          // 是否更新到data
          if (update) {
            this.tooltips = tooltips
            this.notPassedIds = notPassedIds
1945
          }
1946
1947
1948
1949
1950
          if (typeof callback === 'function') {
            callback([tooltips[inputId], notPassedIds])
          }
1951
        }
1952
1953
1954

        if (typeof passed === 'function') {
          let executed = false
1955
          passed(validType, value, { id: this.getCleanId(row.id) }, { ...column }, (flag, msg) => {
1956
1957
1958
1959
1960
            if (executed) return
            executed = true
            if (typeof msg === 'string') {
              message = msg
            }
1961
            if (flag == null) {
1962
              nextThen([true, message])
1963
            } else {
1964
              nextThen([!!flag, message])
1965
1966
1967
1968
            }
          }, this)
        } else {
          nextThen([passed, message])
1969
        }
1970
1971
1972
        return [tooltips[inputId], notPassedIds]
      },
1973
1974
1975
1976
1977

      /** 验证单个表单 */
      validateOneInput(value, row, column, notPassedIds, update = false, validType = 'input') {
        return this.validateOneInputAsync(value, row, column, notPassedIds, update, validType)
      },
1978
      /** 通过规则验证值是否正确 */
1979
1980
      validateValue(column, value) {
        let rules = column.validateRules
1981
1982
1983
1984
1985
1986
1987
1988
        let passed = true, message = ''
        // 判断有没有验证规则或验证规则格式正不正确,若条件不符合则默认通过
        if (rules instanceof Array) {
          for (let rule of rules) {
            // 当前值是否为空
            let isNull = (value == null || value === '')
            // 验证规则:非空
            if (rule.required === true && isNull) {
1989
              passed = false
1990
            } else // 使用 else-if 是为了防止一个 rule 中出现两个规则
1991
1992
1993
1994
1995
1996
1997
1998
1999
2000
2001
2002
2003
            // 验证规则:唯一校验
            if (rule.unique === true || rule.pattern === 'only') {
              let { values } = this.getValuesSync({ validate: false })
              let findCount = 0
              for (let val of values) {
                if (val[column.key] === value) {
                  if (++findCount >= 2) {
                    passed = false
                    break
                  }
                }
              }
            } else
2004
2005
            // 验证规则:正则表达式
            if (!!rule.pattern && !isNull) {
2006
2007
2008

              // 兼容 online 的规则
              let foo = [
2009
                { title: '6到16位数字', value: 'n6-16', pattern: /^\d{6,16}$/ },
2010
                { title: '6到16位任意字符', value: '*6-16', pattern: /^.{6,16}$/ },
2011
                { title: '6到18位字母', value: 's6-18', pattern: /^[a-z|A-Z]{6,18}$/ },
2012
2013
2014
2015
2016
                { title: '网址', value: 'url', pattern: /^(?:([A-Za-z]+):)?(\/{0,3})([0-9.\-A-Za-z]+)(?::(\d+))?(?:\/([^?#]*))?(?:\?([^#]*))?(?:#(.*))?$/ },
                { title: '电子邮件', value: 'e', pattern: /^([\w]+\.*)([\w]+)@[\w]+\.\w{3}(\.\w{2}|)$/ },
                { title: '手机号码', value: 'm', pattern: /^1[3456789]\d{9}$/ },
                { title: '邮政编码', value: 'p', pattern: /^[1-9]\d{5}$/ },
                { title: '字母', value: 's', pattern: /^[A-Z|a-z]+$/ },
2017
                { title: '数字', value: 'n', pattern: /^-?\d+(\.?\d+|\d?)$/ },
2018
                { title: '整数', value: 'z', pattern: /^-?\d+$/ },
2019
2020
2021
2022
2023
2024
2025
2026
2027
2028
2029
2030
                { title: '非空', value: '*', pattern: /^.+$/ },
                { title: '金额', value: 'money', pattern: /^(([1-9][0-9]*)|([0]\.\d{0,2}|[1-9][0-9]*\.\d{0,2}))$/ },
              ]
              let flag = false
              for (let item of foo) {
                if (rule.pattern === item.value && item.pattern) {
                  passed = new RegExp(item.pattern).test(value)
                  flag = true
                  break
                }
              }
              if (!flag) passed = new RegExp(rule.pattern).test(value)
2031
2032
2033
            } else
            // 校验规则:自定义函数校验
            if (typeof rule.handler === 'function') {
2034
              return [rule.handler, rule.message]
2035
2036
2037
            }
            // 如果没有通过验证,则跳出循环。如果通过了验证,则继续验证下一条规则
            if (!passed) {
2038
2039
2040
2041
2042
2043
2044
2045
2046
2047
              message = rule.message
              break
            }
          }
        }
        return [passed, message]
      },

      /** 动态更新表单的值 */
      updateFormValues() {
2048
        let trs = this.getElement('tbody').getElementsByClassName('tr')
2049
2050
2051
2052
2053
2054
2055
2056
2057
2058
2059
2060
2061
2062
2063
2064
2065
2066
2067
2068
2069
2070
2071
2072
2073
2074
2075
2076
2077
2078
2079
2080
2081
2082
2083
2084
2085
2086
2087
2088
        let trEls = []
        for (let tr of trs) {
          trEls.push(tr)
        }
        // 获取新增的 tr
        let newTrEls = trEls
        if (this.visibleTrEls.length > 0) {
          newTrEls = []
          for (let tr of trEls) {
            let isNewest = true
            for (let vtr of this.visibleTrEls) {
              if (vtr.id === tr.id) {
                isNewest = false
                break
              }
            }
            if (isNewest) {
              newTrEls.push(tr)
            }
          }
        }
        this.visibleTrEls = trEls
        // 向新增的tr中赋值
        newTrEls.forEach(tr => {
          let { idx } = tr.dataset
          let value = this.inputValues[idx]
          for (let key in value) {
            if (value.hasOwnProperty(key)) {
              let elid = `${key}${value.id}`
              let el = document.getElementById(elid)
              if (el) {
                el.value = value[key]
              }
            }
          }
        })
      },
      /** 强制更新FormValues */
      forceUpdateFormValues() {
        this.visibleTrEls = []
2089
2090
        this.$forceUpdate()
        this.$nextTick(() => this.updateFormValues())
2091
2092
      },
2093
2094
2095
2096
2097
2098
2099
2100
2101
2102
2103
2104
2105
2106
2107
2108
2109
2110
2111
2112
2113
2114
2115
2116
2117
2118
2119
2120
2121
2122
2123
2124
2125
2126
2127
2128
2129
      // 重新计算所有统计列
      recalcAllStatisticsColumns() {
        if (this.hasStatisticsColumn) {
          Object.keys(this.statisticsColumns).forEach(key => this.recalcOneStatisticsColumn(key))
        }
      },
      // 重新计算单个统计列
      recalcOneStatisticsColumn(key) {
        if (this.hasStatisticsColumn) {
          if (this.statisticsColumns.hasOwnProperty(key)) {
            // 计算合计值
            let count = 0
            this.inputValues.forEach(item => {
              let value = item[key]
              if (value && count !== '-') {
                try {
                  count += Number.parseInt(value)
                } catch (e) {
                  count = '-'
                }
              }
            })
            this.statisticsColumns[key] = count
          }
        }
      },

      /** 获取某个统计字段的值 */
      getStatisticsValue(key) {
        if (this.hasStatisticsColumn) {
          if (this.statisticsColumns.hasOwnProperty(key)) {
            return this.statisticsColumns[key]
          }
        }
        return null
      },
2130
2131
2132
2133
2134
2135
2136
2137
2138
2139
2140
2141
2142
2143
2144
2145
2146
2147
2148
2149
2150
2151
2152
2153
2154
2155
2156
2157
2158
      /** 全选或取消全选 */
      handleChangeCheckedAll() {
        let selectedRowIds = []
        if (!this.getSelectAll) {
          this.rows.forEach(row => {
            if ((this.disabledRowIds || []).indexOf(row.id) === -1) {
              selectedRowIds.push(row.id)
            }
          })
        }
        this.selectedRowIds = selectedRowIds
      },
      /** 左侧行选择框change事件 */
      handleChangeLeftCheckbox(event) {
        let { id } = event.target

        if ((this.disabledRowIds || []).indexOf(id) !== -1) {
          return
        }

        let index = this.selectedRowIds.indexOf(id)
        if (index !== -1) {
          this.selectedRowIds.splice(index, 1)
        } else {
          this.selectedRowIds.push(id)
        }

      },
      handleClickAdd() {
2159
2160
2161
2162
2163
2164
        let {addRowNum, addIndex, addScrollToBottom} = this.settings
        if (addIndex <= 0) {
          this.add(addRowNum, addScrollToBottom)
        } else {
          this.insert(addIndex, addRowNum, addScrollToBottom)
        }
2165
2166
2167
2168
      },
      handleConfirmDelete() {
        this.removeSelectedRows()
      },
2169
2170
2171
2172
      handleClickClearSelection() {
        this.clearSelection()
      },
      clearSelection() {
2173
2174
        this.selectedRowIds = []
      },
2175
2176
2177
2178
2179
2180
2181
2182
2183
2184
2185
2186
2187
2188
2189
2190
2191
2192
2193
2194
2195
2196
2197
      // 获取当前选中的行
      getSelection() {
        return this.selectedRowIds.map(id => this.getCleanId(id))
      },
      // 设置当前选中的行
      async setSelection(selectedRowIds) {
        if (Array.isArray(selectedRowIds) && selectedRowIds.length > 0) {
          // 兼容IE
          await this.getElementPromise('tbody')
          await this.$nextTick()
          this.selectedRowIds = selectedRowIds.map(id => {
            let temp = id
            if (!this.hasCaseId(id)) {
              temp = this.caseId + id
            }
            return temp
          })
        }
      },
      // 切换全选状态
      toggleSelectionAll() {
        this.handleChangeCheckedAll()
      },
2198
2199
      /** 用于搜索下拉框中的内容 */
      handleSelectFilterOption(input, option, column) {
2200
        if (column.allowSearch === true || column.allowInput === true) {
2201
2202
2203
2204
          return option.componentOptions.children[0].text.toLowerCase().indexOf(input.toLowerCase()) >= 0
        }
        return true
      },
2205
2206
      /** select 搜索时的事件,用于动态添加options */
      handleSearchSelect(value, id, row, col) {
2207
        if (col.allowSearch !== true && col.allowInput === true) {
2208
2209
2210
2211
2212
2213
2214
2215
2216
2217
2218
2219
2220
2221
2222
2223
2224
2225
2226
2227
2228
2229
2230
2231
2232
2233
2234
2235
2236
2237
2238
2239
2240
2241
          // 是否找到了对应的项,找不到则添加这一项
          let flag = false
          for (let option of col.options) {
            if (option.value.toLocaleString() === value.toLocaleString()) {
              flag = true
              break
            }
          }
          // !!value :不添加空值
          if (!flag && !!value) {
            // searchAdd 是否是通过搜索添加的
            col.options.push({ title: value, value: value, searchAdd: true })
          }

        }
      },
      // blur 失去焦点
      handleBlurSearch(value, id, row, col) {
        if (col.allowInput === true) {
          // 删除无用的因搜索(用户输入)而创建的项
          if (typeof value === 'string') {
            let indexs = []
            col.options.forEach((option, index) => {
              if (option.value.toLocaleString() === value.toLocaleString()) {
                delete option.searchAdd
              } else if (option.searchAdd === true) {
                indexs.push(index)
              }
            })
            // 翻转删除数组中的项
            for (let index of indexs.reverse()) {
              col.options.splice(index, 1)
            }
          }
2242
2243
        }
2244
2245
        // 做单个表单验证
        this.validateOneInput(value, row, col, this.notPassedIds, true, 'blur')
2246
      },
2247
2248
2249
2250
2251
2252
      /** 触发已拖动事件 */
      emitDragged(oldIndex, newIndex) {
        this.$emit('dragged', { oldIndex, newIndex, target: this })
      },
2253
2254
2255
2256
2257
      handleDragMoveStart(event) {
        this.dragging = true
        this.$refs.scrollView.style.overflow = 'hidden'
      },
2258
2259
      /** 拖动结束,交换inputValue中的值 */
      handleDragMoveEnd(event) {
2260
2261
2262
        this.dragging = false
        this.$refs.scrollView.style.overflow = 'auto'
2263
        let { oldIndex, newIndex, item: { dataset: { idx: dataIdx } } } = event
2264
2265
2266
2267
2268
        // 由于动态显示隐藏行导致index有误差,需要算出真实的index
        let diff = Number.parseInt(dataIdx) - oldIndex
        oldIndex += diff
        newIndex += diff
2269
2270
        this.rowResort(oldIndex, newIndex)
2271
        this.emitDragged(oldIndex, newIndex)
2272
2273
      },
2274
2275
2276
2277
2278
2279
2280
2281
2282
2283
2284
2285
2286
      /** 行重新排序 */
      rowResort(oldIndex, newIndex) {
        const sort = (array) => {
          // 存储旧数据,并删除旧项目
          let temp = array[oldIndex]
          array.splice(oldIndex, 1)
          // 向新项目里添加旧数据
          array.splice(newIndex, 0, temp)
        }

        sort(this.rows)
        sort(this.inputValues)
2287
        this.recalcSortNumber()
2288
2289
2290
2291

        this.forceUpdateFormValues()
      },
2292
2293
2294
2295
2296
2297
2298
2299
      /** 重新计算排序字段的数值 */
      recalcSortNumber() {
        if (this.dragSort) {
          // 重置排序字段
          this.inputValues.forEach((val, idx) => val[this.dragSortKey] = (idx + 1))
        }
      },
2300
2301
2302
2303
2304
2305
2306
2307
2308
2309
2310
2311
2312
2313
2314
2315
2316
2317
2318
2319
2320
2321
2322
2323
      /** 当前行向上移一位 */
      _handleRowMoveUp(rowIndex) {
        if (rowIndex > 0) {
          let newIndex = rowIndex - 1
          this.rowResort(rowIndex, newIndex)
          this.emitDragged(rowIndex, newIndex)
        }
      },

      /** 当前行向下移一位 */
      _handleRowMoveDown(rowIndex) {
        if (rowIndex < (this.rows.length - 1)) {
          let newIndex = rowIndex + 1
          this.rowResort(rowIndex, newIndex)
          this.emitDragged(rowIndex, newIndex)
        }
      },

      /** 在当前行下面插入一行 */
      _handleRowInsertDown(rowIndex) {
        let insertIndex = (rowIndex + 1)
        this.insert(insertIndex)
      },
2324
2325
2326
2327
      /* --- common function begin --- */

      /** input事件 */
      handleInputCommono(target, index, row, column) {
2328
        let oldValue = this.inputValues[index][column.key] || ''
2329
        let { value, dataset, selectionStart } = target
2330
2331
        let type = FormTypes.input
        let change = true
2332
        if (`${dataset.inputNumber}` === 'true') {
2333
          type = FormTypes.inputNumber
2334
2335
          // 判断输入的值是否匹配数字正则表达式,不匹配就还原
          if (!/^-?\d+\.?\d*$/.test(value) && (value !== '' && value !== '-')) {
2336
            change = false
2337
2338
            value = oldValue
            target.value = value
2339
            if (typeof selectionStart === 'number') {
2340
2341
2342
2343
2344
2345
2346
2347
              target.selectionStart = selectionStart - 1
              target.selectionEnd = selectionStart - 1
            }
          }
        }
        // 存储输入的值
        this.inputValues[index][column.key] = value
        // 做单个表单验证
2348
        this.validateOneInput(value, row, column, this.notPassedIds, true, 'input')
2349
2350
2351
2352
2353
        if (type === FormTypes.inputNumber) {
          this.recalcOneStatisticsColumn(column.key)
        }
2354
2355
2356
2357
        // 触发valueChange 事件
        if (change) {
          this.elemValueChange(type, row, column, value)
        }
2358
      },
2359
2360
2361
2362
2363
2364
2365
2366
      /** slot Change */
      handleChangeSlotCommon(value, id, row, column) {
        this.slotValues = this.bindValuesChange(value, id, 'slotValues')
        // 做单个表单验证
        this.validateOneInput(value, row, column, this.notPassedIds, true, 'change')
        // 触发valueChange 事件
        this.elemValueChange(FormTypes.slot, row, column, value)
      },
2367
      handleBlurCommono(target, index, row, column) {
2368
2369
2370
2371
2372
2373
2374
2375
2376
2377
        let { value, dataset } = target
        if (dataset && `${dataset.inputNumber}` === 'true') {
          // 判断输入的值是否匹配数字正则表达式,不匹配就置空
          if (!/^-?\d+\.?\d*$/.test(value)) {
            value = ''
          } else {
            value = Number.parseFloat(value)
          }
          target.value = value
        }
2378
2379
2380
2381
2382
2383
        //update--begin--autor:lvdandan-----date:20201126------for:LOWCOD-1088 JEditableTable输入校验提示框位置偏移 #2005
        setTimeout(()=>{
          // 做单个表单验证
          this.validateOneInput(value, row, column, this.notPassedIds, true, 'blur')
        }, 100)
        //update--end--autor:lvdandan-----date:20201126------for:LOWCOD-1088 JEditableTable输入校验提示框位置偏移 #2005
2384
      },
2385
      handleChangeCheckboxCommon(event, row, column) {
2386
2387
        let { id, checked } = event.target
        this.checkboxValues = this.bindValuesChange(checked, id, 'checkboxValues')
2388
2389
2390

        // 触发valueChange 事件
        this.elemValueChange(FormTypes.checkbox, row, column, checked)
2391
2392
2393
2394
      },
      handleChangeSelectCommon(value, id, row, column) {
        this.selectValues = this.bindValuesChange(value, id, 'selectValues')
        // 做单个表单验证
2395
        this.validateOneInput(value, row, column, this.notPassedIds, true, 'change')
2396
2397
2398

        // 触发valueChange 事件
        this.elemValueChange(FormTypes.select, row, column, value)
2399
      },
2400
      handleChangeJDateCommon(value, id, row, column, showTime) {
2401
        this.jdateValues = this.bindValuesChange(value, id, 'jdateValues')
2402
        this.validateOneInput(value, row, column, this.notPassedIds, true, 'change')
2403
2404

        // 触发valueChange 事件
2405
        this.elemValueChange(column.type, row, column, value)
2406
      },
2407
2408
2409
2410
2411
2412
2413
2414
2415
2416
2417
2418
2419
2420
      //部门组件值改变
      handleChangeDepartCommon(value, id, row, column){
        this.departCompValues = this.bindValuesChange(value, id, 'departCompValues')
        this.validateOneInput(value, row, column, this.notPassedIds, true, 'change')
        // 触发valueChange 事件
        this.elemValueChange(FormTypes.sel_depart, row, column, value)
      },
      //用户组件值改变
      handleChangeUserCommon(value, id, row, column){
        this.userCompValues = this.bindValuesChange(value, id, 'userCompValues')
        this.validateOneInput(value, row, column, this.notPassedIds, true, 'change')
        // 触发valueChange 事件
        this.elemValueChange(FormTypes.sel_user, row, column, value)
      },
2421
2422
2423
2424
2425
2426
2427
      handleChangeJInputPopCommon(value, id, row, column){
        this.jInputPopValues = this.bindValuesChange(value, id, 'jInputPopValues')
        // 做单个表单验证
        this.validateOneInput(value, row, column, this.notPassedIds, true, 'change')
        // 触发valueChange 事件
        this.elemValueChange(FormTypes.input_pop, row, column, value)
      },
2428
2429
2430
2431
2432
2433
2434
2435
2436
2437
2438
2439
      handleChangeUpload(info, id, row, column) {
        let { file } = info
        let value = {
          name: file.name,
          type: file.type,
          size: file.size,
          status: file.status,
          percent: file.percent
        }
        if (column.responseName && file.response) {
          value['responseName'] = file.response[column.responseName]
        }
2440
        if (file.status === 'done') {
2441
2442
2443
2444
2445
2446
2447
2448
2449
2450
2451
2452
2453
2454
2455
          if (typeof file.response.success === 'boolean') {
            // 如果文件上传,被拦截器拦下,还会返回最外层的status = done
            // 但是内部的success会返回false并携带异常信息
            // 整个上传操作还是失败的
            // https://github.com/zhangdaiscott/jeecg-boot/issues/2691
            if (file.response.success) {
              value['path'] = file.response[column.responseName]
            } else {
              value['status'] = 'error'
              value['message'] = file.response.message || '未知错误'
            }
          } else {
            // 考虑到如果设置action上传路径为非jeecg-boot后台,可能不会返回 success 属性的情况,就默认为成功
            value['path'] = file.response[column.responseName]
          }
2456
2457
        } else if (file.status === 'error') {
          value['message'] = file.response.message || '未知错误'
2458
        }
2459
        this.uploadValues = this.bindValuesChange(value, id, 'uploadValues')
2460
2461
2462

        // 触发valueChange 事件
        this.elemValueChange(column.type, row, column, value)
2463
      },
2464
2465
2466
2467
2468
2469
2470
2471
2472
2473
2474
2475
      handleMoreOperation(id,flag,column){
        //update-begin-author:wangshuai date:20201021 for:LOWCOD-969 判断传过来的字段是否存在number,用于控制上传文件
        if(column.number){
          this.number = column.number;
        }else{
          this.number = 0;
        }
        //update-end-author:wangshuai date:20201021 for:LOWCOD-969 判断传过来的字段是否存在number,用于控制上传文件
        if(column && column.fieldExtendJson){
          let json = JSON.parse(column.fieldExtendJson);
          this.number = json.uploadnum?json.uploadnum:0;
        }
2476
2477
2478
2479
2480
2481
2482
2483
2484
2485
2486
2487
        //console.log("this.uploadValues[id]",this.uploadValues[id])
        let path = ''
        if(this.uploadValues && this.uploadValues[id]){
          path = this.uploadValues[id].path
        }
        this.$refs.filePop.show(id,path,flag)
      },
      handleFileSuccess(obj){
        if(obj.id){
          this.uploadValues = this.bindValuesChange(obj, obj.id, 'uploadValues')
        }
      },
2488
2489
2490
2491
2492
2493
      handleClickTableRow(event) {
        let {target} = event
        if (target.className === 'td' || target.className === 'tr') {
          // 清空编辑状态
          this.currentEditRows = {}
        }
2494
      },
2495
2496
2497
      // 点击后编辑当前行
      handleEditRow(row, col) {
        if (this.alwaysEdit) {
2498
2499
          return
        }
2500
2501
2502
2503
2504
2505
2506
2507
2508
2509
2510
2511
2512
2513
2514
        // 将点击的组件置为可编辑并还原其他组件的编辑状态
        this.currentEditRows = {
          [row.id]: {
            [col.key]: true
          }
        }
        if (col.type === FormTypes.input || col.type === FormTypes.inputNumber) {
          this.$nextTick(() => {
            this.forceUpdateFormValues()
            // 自动获取焦点
            let el = document.getElementById(`${col.key}${row.id}`)
            if (el) {
              el.focus()
            }
          })
2515
        }
2516
      },
2517
2518
2519
2520
2521
2522
2523
2524
2525
2526
2527
2528
2529
2530
2531
2532
2533
2534
2535

      /** 添加按钮设置保存为默认值 */
      onAddButtonSettingsSave() {
        let obj = {
          addRowNum: this.settings.addRowNum,
          addIndex: this.settings.addIndex,
          addScrollToBottom: this.settings.addScrollToBottom,
        }
        this.$ls.set('jet-add-btn-settings', obj)
        this.$message.success('保存成功')
      },
      /** 获取保存的添加按钮默认值 */
      getSavedAddButtonSettings() {
        let obj= this.$ls.get('jet-add-btn-settings')
        if (obj) {
          Object.assign(this.settings, obj)
        }
      },
2536
2537
2538
2539
2540
      /** 记录用到数据绑定的组件的值 */
      bindValuesChange(value, id, key) {
        this.$set(this[key], id, value)
        return this[key]
      },
2541
2542
2543
2544
2545
2546
      /** value 触发valueChange事件 */
      elemValueChange(type, rowSource, columnSource, value) {
        let column = Object.assign({}, columnSource)
        // 将caseId去除
        let row = Object.assign({}, rowSource)
2547
        row.id = this.getCleanId(row.id)
2548
2549
2550
2551
2552
2553
2554
2555
        // 获取整行的数据
        let { values } = this.getValuesSync({ validate: false, rowIds: [row.id] })
        if (values.length > 0) {
          Object.assign(row, values[0])
        }
        this.$emit('valueChange', { type, row, column, value, target: this })
      },
2556
2557
2558
2559
2560
2561
2562
2563
2564
2565
2566
2567
      /** 获取干净的ID(不包含任何杂质的ID) */
      getCleanId(id) {
        id = this.removeCaseId(id)
        id = this.removeTempId(id)
        return id
      },

      /** 判断某个ID是否包含了caseId */
      hasCaseId(id) {
        return id && id.startsWith(this.caseId)
      },
2568
2569
      /** 将caseId去除 */
      removeCaseId(id) {
2570
2571
2572
2573
2574
2575
2576
2577
2578
2579
2580
2581
2582
2583
2584
2585
2586
        if (this.hasCaseId(id)) {
          return id.substring(this.caseId.length, id.length)
        }
        return id
      },

      // 判断 id 是否是临时Id
      isTempId(id) {
        return (id || '').endsWith(this.tempId)
      },

      /** 将tempId去除 */
      removeTempId(id) {
        if (this.isTempId(id)) {
          return id.substring(0, id.length - this.tempId.length)
        }
        return id;
2587
2588
2589
2590
2591
      },

      handleClickDelFile(id) {
        this.uploadValues[id] = null
      },
2592
2593
2594
      handleClickDownloadFile(id) {
        let { path } = this.uploadValues[id] || {}
        if (path) {
2595
2596
2597
2598
2599
2600
2601
2602
2603
2604
2605
2606
          let url = getFileAccessHttpUrl(path)
          window.open(url)
        }
      },
      handleClickDownFileByUrl(id){
        let { url,path } = this.uploadValues[id] || {}
        if (!url || url.length===0) {
          if(path && path.length>0){
            url = getFileAccessHttpUrl(path.split(',')[0])
          }
        }
        if(url){
2607
2608
2609
          window.open(url)
        }
      },
2610
2611
2612
2613
2614
2615
2616
      handleClickShowImageError(id) {
        let currUploadObj = this.uploadValues[id] || null
        if (currUploadObj && currUploadObj['message']) {
          this.$error({ title: '上传出错', content: '错误信息:' + currUploadObj['message'], maskClosable: true })
        }
      },
2617
2618
2619
2620
      /** 加载数据字典并合并到 options */
      _loadDictConcatToOptions(column) {
        initDictOptions(column.dictCode).then((res) => {
          if (res.success) {
2621
2622
            let newOptions = (column.options || [])// .concat(res.result)
            res.result.forEach(item => {
2623
              // 过滤重复数据
2624
2625
2626
              for (let option of newOptions) if (option.value === item.value) return
              newOptions.push(item)
            })
2627
            this.$set(column, 'options', newOptions)
2628
2629
2630
2631
2632
2633
2634
2635
          } else {
            console.group(`JEditableTable 查询字典(${column.dictCode})发生异常`)
            console.log(res.message)
            console.groupEnd()
          }
        })
      },
2636
2637
2638
2639
2640
      /* --- common function end --- */

      /* --- 以下是辅助方法,多用于动态构造页面中的数据 --- */

      /** 辅助方法:打印日志 */
2641
2642
2643
2644
2645
      log() {
        if (this.$attrs.logger) {
          console.log.apply(null, arguments)
        }
      },
2646
2647
2648
2649
2650
      getVM() {
        return this
      },
2651
2652
2653
2654
2655
2656
2657
2658
2659
2660
2661
2662
2663
2664
2665
2666
2667
2668
2669
2670
2671
      /** 辅助方法:动态构造Tooltip的Props,防止出现不消失的情况 */
      buildTooltipProps(row, col, id) {
        let {notPassedIds, tooltips} = this
        let props = {
          title: (tooltips[id] || {}).title,
          placement: 'top',
          autoAdjustOverflow: true,
          getPopupContainer: this.getParentContainer,
          class: {
            'j-check-failed': false
          },
        }
        let isCheckFailed = notPassedIds.includes(id)
        if (isCheckFailed) {
          props.class['j-check-failed'] = true
        } else {
          props['visible'] = false
        }
        return props
      },
2672
2673
      /** 辅助方法:指定a-select 和 j-data 的父容器 */
      getParentContainer(node) {
2674
2675
2676
2677
2678
2679
2680
2681
2682
2683
2684
2685
2686
2687
2688
2689
2690
2691
2692
2693
2694
2695
2696
2697
2698
2699
2700
2701
2702
2703
2704
2705
2706
2707
2708
2709
        let element = (() => {
          // nodeType 8	: Comment	: 注释
          if (this.$el && this.$el.nodeType !== 8) {
            return this.$el
          }
          let doc = document.getElementById(this.caseId + 'inputTable')
          if (doc != null) {
            return doc
          }
          return node.parentNode.parentNode.parentNode.parentNode.parentNode.parentNode
        })()

        // 递归判断是否带有 overflow: hidden;的父元素
        const ifParent = (child) => {
          let currentOverflow = null
          if (child['currentStyle']) {
            currentOverflow = child['currentStyle']['overflow']
          } else if (window.getComputedStyle) {
            currentOverflow = window.getComputedStyle(child)['overflow']
          }
          if (currentOverflow != null) {
            if (currentOverflow === 'hidden') {
              // 找到了带有 hidden 的标签,判断它的父级是否还有 hidden,直到遇到完全没有 hidden 或 body 的时候才停止递归
              let temp = ifParent(child.parentNode)
              return temp != null ? temp : child.parentNode
            } else
            // 当前标签没有 hidden ,如果有父级并且父级不是 body 的话就继续递归判断父级
            if (child.parentNode && child.parentNode.tagName.toLocaleLowerCase() !== 'body') {
              return ifParent(child.parentNode)
            } else {
              // 直到 body 都没有遇到有 hidden 的标签
              return null
            }
          } else {
            return child
          }
2710
        }
2711
2712
2713

        let temp = ifParent(element)
        return (temp != null) ? temp : element
2714
2715
      },
2716
2717
2718
2719
2720
2721
2722
2723
2724
2725
2726
2727
2728
2729
2730
2731
2732
      /** 辅助方法:替换${...}变量 */
      replaceProps(col, value) {
        if (value && typeof value === 'string') {
          value = value.replace(/\${title}/g, col.title)
          value = value.replace(/\${key}/g, col.key)
          value = value.replace(/\${defaultValue}/g, col.defaultValue)
        }
        return value
      },

      /** view辅助方法:构建 tr style */
      buildTrStyle(index) {
        return {
          'top': `${rowHeight * index}px`
        }
      },
      /** view辅助方法:构建 td style */
2733
      buildTdStyle(col) {
2734
2735
        const isEmptyWidth = (column) => (column.type === FormTypes.hidden || column.width === '0px' || column.width === '0' || column.width === 0)
2736
2737
2738
2739
2740
        let style = {}
        // 计算宽度
        if (col.width) {
          style['width'] = col.width
        } else if (this.columns) {
2741
          style['width'] = `${(100 - 4 * 2) / (this.columns.filter(column => !isEmptyWidth(column))).length}%`
2742
2743
2744
        } else {
          style['width'] = '120px'
        }
2745
        //update-begin-author:lvdandan date:20201116 for:LOWCOD-984 默认风格功能测试附表样式问题 日期时间控件长度太大
2746
        //如果是时间控件设为200px
2747
        if(col.type === FormTypes.datetime){
2748
2749
2750
2751
2752
2753
2754
          style['width'] = '200px'
        }
        if(col.type === FormTypes.sel_user && !col.width){
          style['width'] = '220px'
        }
        if(col.type === FormTypes.sel_depart && !col.width){
          style['width'] = '160px'
2755
2756
2757
        }
        //update-end-author:lvdandan date:20201116 for:LOWCOD-984 默认风格功能测试附表样式问题 日期时间控件长度太大
2758
2759
2760
2761
2762
2763
2764
2765
        // checkbox 居中显示
        let isCheckbox = col.type === FormTypes.checkbox
        if (isCheckbox) {
          style['align-items'] = 'center'
          style['text-align'] = 'center'
          style['padding-left'] = '0'
          style['padding-right'] = '0'
        }
2766
2767
2768
2769
        if (isEmptyWidth(col)) {
          style['padding-left'] = '0'
          style['padding-right'] = '0'
        }
2770
2771
2772
2773
2774
2775
2776
2777
2778
2779
2780
2781
2782
        return style
      },
      /** view辅助方法:构造props */
      buildProps(row, col) {
        let props = {}
        // 解析props
        if (typeof col.props === 'object') {
          for (let prop in col.props) {
            if (col.props.hasOwnProperty(prop)) {
              props[prop] = this.replaceProps(col, col.props[prop])
            }
          }
        }
2783
        // 判断select是否允许输入
2784
        if (col.type === FormTypes.select && (col.allowInput === true || col.allowSearch === true)) {
2785
2786
          props['showSearch'] = true
        }
2787
2788
2789
2790
2791
        if (col.type === FormTypes.sel_depart || col.type === FormTypes.sel_user) {
          let { storeField, textField } = this.getStoreAndTextField(col)
          props['store'] = storeField
          props['text'] = textField
        }
2792
2793
        // 判断是否是禁用的列
2794
        props['disabled'] = (typeof col['disabled'] === 'boolean' ? col['disabled'] : props['disabled'])
2795
2796
2797
2798
2799
        // 判断是否为禁用的行
        if (props['disabled'] !== true) {
          props['disabled'] = ((this.disabledRowIds || []).indexOf(row.id) !== -1)
        }
2800
2801
2802
2803
2804
2805

        // 判断是否禁用全部组件
        if (this.disabled === true) {
          props['disabled'] = true
        }
2806
        return props
2807
      },
2808
2809
2810
2811
2812
2813
2814
2815
2816
2817
2818
2819
2820
2821
2822
2823
2824
2825
2826
2827
2828
2829
2830
2831
2832
2833
2834
2835
2836
2837
2838
2839
2840
2841
2842
2843
2844
      /**获取部门选择 、用户选择的存储字段、展示字段*/
      getStoreAndTextField(col){
        let storeField = '', textField = ''
        if(col.type === FormTypes.sel_depart){
          storeField = 'id'
          textField = 'departName'
        }else if(col.type === FormTypes.sel_user){
          storeField = 'username'
          textField = 'realname'
        }
        if(col.fieldExtendJson){
          // online逻辑
          let tempJson = JSON.parse(col.fieldExtendJson)
          if(tempJson){
            if(tempJson.store){
              storeField = tempJson.store
            }
            if(tempJson.text){
              textField = tempJson.text
            }
          }
        }else{
          // 实际开发逻辑
          if(col.store){
            storeField = col.store
          }
          if(col.text){
            textField = col.text
          }
        }
        return {
          storeField,
          textField
        }
      },
2845
2846
2847
2848
2849
2850
2851
2852
2853
2854
2855
2856
2857
2858
2859
2860
2861
2862
      /** 辅助方法:防止过快点击,如果点击过快的话就返回 true */
      checkTooFastClick(key = 'default', ms = 300) {
        let nowTime = Date.now()
        let lastTime = this.lastPushTimeMap.get(key)
        if (!lastTime) {
          lastTime = nowTime
          this.lastPushTimeMap.set(key, nowTime)
          return false
        }
        let diffTime = nowTime - lastTime
        if (diffTime <= ms) {
          this.$message.warn('你点击的太快了,请慢点点击!')
          return true
        }
        this.lastPushTimeMap.set(key, nowTime)
        return false
      },
2863
2864
2865
2866
2867
2868
2869
      /** upload 辅助方法:获取 headers */
      uploadGetHeaders(row, column) {
        let headers = {}
        if (column.token === true) {
          headers['X-Access-Token'] = this.accessToken
        }
        return headers
2870
2871
      },
      /** 上传请求地址 */
2872
2873
2874
2875
      getUploadAction(value) {
        if (!value) {
          return window._CONFIG['domianURL'] + '/sys/common/upload'
        } else {
2876
2877
2878
2879
          return value
        }
      },
      /** 预览图片地址 */
2880
      getCellImageView(id) {
2881
        let currUploadObj = this.uploadValues[id] || null
2882
2883
2884
2885
2886
2887
2888
        if (currUploadObj) {
          if(currUploadObj['url']){
            return currUploadObj['url'];
          }else if(currUploadObj['path']){
            let readpath = currUploadObj['path'].split(',')[0]
            return getFileAccessHttpUrl(readpath)
          }
2889
        }
2890
        return ''
2891
2892
      },
      /** popup回调 */
2893
      popupCallback(value, others, id, row, column, index) {
2894
        // 存储输入的值
2895
        let popupValue = value
2896
        if (others) {
2897
2898
2899
2900
2901
2902
2903
2904
2905
          let rowKey = this.getCleanId(row.id)
          let setValueItem = {rowKey, values: {}}
          Object.keys(others).forEach(key => {
            // 当前列直接赋值,其他列通过setValues赋值
            if (key === column.key) {
              popupValue = others[key]
            } else {
              setValueItem.values[key] = others[key]
            }
2906
          })
2907
2908
2909
          if (Object.keys(setValueItem).length > 0) {
            this.setValues([setValueItem])
          }
2910
        }
2911
        this.setOneValue(this.popupValues, id, popupValue)
2912
        // 做单个表单验证
2913
        this.validateOneInput(popupValue, row, column, this.notPassedIds, true, 'change')
2914
        // 触发valueChange 事件
2915
        this.elemValueChange('input', row, column, value)
2916
2917
      },
      /** popup输入框回显 */
2918
      getPopupValue(id) {
2919
2920
2921
2922
2923
2924
2925
2926
2927
2928
2929
2930
2931
2932
2933
2934
2935
2936
2937
2938
2939
        return this.popupValues[id]
      },
      handleRadioChange(value, id, row, column) {
        this.radioValues = this.bindValuesChange(value, id, 'radioValues')
        // 做单个表单验证
        this.validateOneInput(value, row, column, this.notPassedIds, true, 'change')
        // 触发valueChange 事件
        this.elemValueChange(FormTypes.radio, row, column, value)
      },
      handleMultiSelectChange(value, id, row, column) {
        this.multiSelectValues = this.bindValuesChange(value, id, 'multiSelectValues')
        // 做单个表单验证
        this.validateOneInput(value, row, column, this.notPassedIds, true, 'change')
        // 触发valueChange 事件
        this.elemValueChange(FormTypes.list_multi, row, column, value)
      },
      handleSearchSelectChange(value, id, row, column) {
        this.searchSelectValues = this.bindValuesChange(value, id, 'searchSelectValues')
        this.validateOneInput(value, row, column, this.notPassedIds, true, 'change')
        this.elemValueChange(FormTypes.sel_search, row, column, value)
      },
2940
2941
2942
2943
2944
      handleSearchSelectAsyncChange(value, id, row, column) {
        this.searchSelectAsyncValues = this.bindValuesChange(value, id, 'searchSelectAsyncValues')
        this.validateOneInput(value, row, column, this.notPassedIds, true, 'change')
        this.elemValueChange(FormTypes.sel_search_async, row, column, value)
      },
2945
2946
2947
      filterOption(input, option) {
        return option.componentOptions.children[0].text.toLowerCase().indexOf(input.toLowerCase()) >= 0
      },
2948
      getEllipsisWord(content, len){
2949
        if(!content || content.length === 0){
2950
2951
2952
2953
2954
2955
          return ''
        }
        if(content.length>len){
          return content.substr(0,len)
        }
        return content;
2956
2957
2958
2959
2960
2961
2962
2963
2964
2965
2966
2967
2968
2969
2970
2971
2972
2973
2974
2975
2976
2977
2978
2979
2980
2981
2982
2983
2984
2985
2986
2987
2988
2989
2990
2991
2992
2993
2994
2995
2996
2997
2998
2999
3000
3001
3002
3003
3004
3005
3006
3007
3008
3009
3010
3011
3012
3013
3014
3015
3016
3017
3018
3019
3020
3021
3022
3023
3024
3025
3026
3027
3028
3029
3030
3031
3032
3033
3034
3035
3036
3037
3038
      },

      /* --------------------------- 2020年5月18日 默认span模式 ------------------------------ */

      /** 获取Select等组件翻译后的文本 */
      getSelectTranslateText(value, row, col) {
        // 翻译支持单选和多选(数组、逗号分割)
        return filterDictText(col.options, value)
      },

      // 判定当前行是否是正在编辑的
      isEditRow(row, col) {
        if (this.alwaysEdit) {
          return true
        }
        let current = this.currentEditRows[row.id]
        return !!(current && current[col.key] === true)
      },

      /* ---- 事件监听 ---- */

      // 鼠标弹起事件,用于清空输入状态
      handleMouseup(event) {
        if (this.alwaysEdit || Object.keys(this.currentEditRows).length === 0) {
          return
        }
        // console.log(this.caseId + 'handleMouseup: ', event)
        let {target} = event
        if (!target){
          return
        }
        let className = target.className || ''
        if (typeof className === 'string') {
          // 点击的标签是span
          if (className.includes('j-td-span') && className.includes('no-edit')) {
            return
          }
          // 点击的标签是下拉
          if (className.includes('ant-select-dropdown-menu-item')) {
            return
          }
        }

        // 事件冒泡路径
        let path = getEventPath(event)
        for (let p of path) {
          // 如果点击的是 tr 就不处理(tr单独处理)
          if ((p.id || '').startsWith(`${this.caseId}tbody-tr`)) {
            return
          }
          let pClassName = p.className || ''
          pClassName = typeof pClassName === 'string' ? pClassName : pClassName.toString()

          /* --- 特殊处理以下组件,点击以下标签时不清空编辑状态 --- */

          // 点击的标签是JInputPop
          if (pClassName.includes('j-input-pop')) {
            return
          }
          // 点击的标签是JPopup的弹出层
          if (pClassName.includes('j-popup-modal')) {
            return
          }
          // 点击的标签是日期选择器的弹出层
          if (pClassName.includes('j-date-picker') || pClassName.includes('ant-calendar-picker-container')) {
            return
          }

        }
        // 清空编辑状态
        this.currentEditRows = {}
      },

      // 添加事件监听
      addEventListener() {
        window.addEventListener('mouseup', this.handleMouseup)
      },
      // 移除事件监听
      removeEventListener() {
        window.removeEventListener('mouseup', this.handleMouseup)
      },
      /* --------------------------- 2020年5月18日 默认span模式 ------------------------------ */
3039
3040
3041
3042
3043
3044
3045
3046
3047
3048
3049
3050
3051
3052
3053
3054
3055
3056
3057
      //获取没有授权的按钮编码
      loadExcludeCode(){
        if(!this.authPre || this.authPre.length==0){
          this.excludeCode = []
        }else{
          let pre = this.authPre
          if(!pre.endsWith(':')){
            pre += ':'
          }
          this.excludeCode = getNoAuthCols(pre)
        }
      },
      //判断button是否显示
      buttonPermission(code){
        if(!this.excludeCode || this.excludeCode.length==0){
          return true
        }else{
          return this.excludeCode.indexOf(code)<0
        }
3058
3059
3060
3061
3062
3063
3064
3065
3066
3067
3068
3069
3070
3071
3072
      },
      // 判断用户、部门组件是否多选
      isMultipleSelect(column){
        let jsonStr = column.fieldExtendJson
        if(jsonStr){
          // online
          let config = JSON.parse(jsonStr)
          if(config && config['multiSelect']==false){
            return false
          }
        }else if(column.multi==false){
          // 实际开发
          return false
        }
        return true;
3073
      }
3074
3075
3076
    },
    beforeDestroy() {
3077
      this.removeEventListener()
3078
      this.destroyCleanGroupRequest = true
3079
3080
    }
3081
3082
3083
3084
3085
3086
3087
3088
3089
3090
3091
3092
3093
3094
3095
3096
3097
3098
3099
3100
3101
3102
  }
</script>

<style lang="less" scoped>

  .action-button {
    margin-bottom: 8px;

    .gap {
      padding-left: 8px;
    }

  }

  /* 设定边框参数 */
  @borderColor: #e8e8e8;
  @border: 1px solid @borderColor;
  /* tr & td 之间的间距 */
  @spacing: 8px;

  .input-table {
    max-width: 100%;
3103
    overflow-x: hidden;
3104
3105
3106
3107
3108
3109
3110
3111
3112
3113
3114
    overflow-y: hidden;
    position: relative;
    border: @border;

    .thead, .tbody {

      .tr, .td {
        display: flex;
      }

      .td {
3115
3116

        /*border-right: 1px solid red;*/
3117
3118
3119
3120
3121
3122
3123
3124
        /*color: white;*/
        /*background-color: black;*/
        /*margin-right: @spacing !important;*/

        padding-left: @spacing;
        flex-direction: column;

        &.td-cb, &.td-num {
3125
3126
3127
          width: 45px;
          min-width: 45px;
          max-width: 50px;
3128
3129
3130
3131
3132
3133
3134
          margin-right: 0;
          padding-left: 0;
          padding-right: 0;
          justify-content: center;
          align-items: center;
        }
3135
        &.td-ds {
3136
3137
3138
          width: 30px;
          min-width: 30px;
          max-width: 35px;
3139
3140
3141
3142
3143
3144
3145
3146
3147
3148
3149
3150
3151
3152
3153
3154
3155
3156
3157
3158
3159
3160
3161
3162
3163
3164
3165
3166
3167
3168
3169
          margin-right: 0;
          padding-left: 0;
          padding-right: 0;
          justify-content: center;
          align-items: center;

          .td-ds-icons {
            position: relative;
            cursor: move;
            width: 100%;
            /*padding: 25% 0;*/
            height: 100%;

            .anticon-align-left,
            .anticon-align-right {
              position: absolute;
              top: 30%;
            }

            .anticon-align-left {
              left: 25%;
            }

            .anticon-align-right {
              right: 25%;
            }
          }


        }
3170
3171
3172
3173
3174
3175
      }

    }

    .thead {
      overflow-y: scroll;
3176
      overflow-x: hidden;
3177
3178
      border-bottom: @border;
3179
      /** 隐藏thead的滑块   */
3180
3181
3182
3183
3184
3185
3186
3187
3188
3189
3190
      &::-webkit-scrollbar-thumb {
        box-shadow: none !important;
        background-color: transparent !important;
      }

      .tr {
        min-width: 100%;
        overflow-y: scroll;
      }
3191
      .td {
3192
        /*flex: 1;*/
3193
3194
3195
3196
3197
3198
3199
3200
3201
3202
3203
        padding: 8px @spacing;
        justify-content: center;
      }

    }

    .tbody {
      position: relative;
      top: 0;
      left: 0;
      overflow-x: hidden;
3204
      overflow-y: hidden;
3205
      min-height: 61px;
3206
3207
      /*max-height: 400px;*/
      min-width: 100%;
3208
3209
3210
3211
3212
3213
3214
3215
3216
3217
3218
3219
3220

      .tr-nodata {
        color: #999;
        line-height: 61px;
        text-align: center;
      }

      .tr {
        /*line-height: 50px;*/

        border-bottom: @border;
        transition: background-color 300ms;
        width: 100%;
3221
3222
        height: 61px;
        overflow: hidden;
3223
3224
3225
3226
3227
3228
3229
3230
3231
3232
3233
3234
3235
3236
3237
3238
3239
3240
3241
3242
3243
        position: absolute;
        left: 0;
        z-index: 10;

        &.tr-checked {
          background-color: #fafafa;
        }

        &:hover {
          background-color: #E6F7FF;
        }

      }

      .tr-expand {
        position: relative;
        z-index: 9;
        background-color: white;
      }

      .td {
3244
        /*flex: 1;*/
3245
        padding: 14px @spacing 14px 0;
3246
3247
3248
3249
3250
3251
3252
3253
3254
3255
3256
3257
3258
3259
3260
3261
3262
3263
3264
3265
3266
3267
3268
3269
3270
3271
3272
3273
3274
3275
3276
3277
3278
3279
3280
3281
3282
3283
3284
3285
3286
3287
        justify-content: center;

        &:last-child {
          padding-right: @spacing;
        }

        input {
          font-variant: tabular-nums;
          box-sizing: border-box;
          margin: 0;
          list-style: none;
          position: relative;
          display: inline-block;
          padding: 4px 11px;
          width: 100%;
          height: 32px;
          font-size: 14px;
          line-height: 1.5;
          color: rgba(0, 0, 0, 0.65);
          background-color: #fff;
          border: 1px solid #d9d9d9;
          border-radius: 4px;
          transition: all 0.3s;
          outline: none;

          &:hover {
            border-color: #4D90FE
          }

          &:focus {
            border-color: #40a9ff;
            box-shadow: 0 0 0 2px rgba(24, 144, 255, 0.2);
            border-right-width: 1px !important;
          }

          &:disabled {
            color: rgba(0, 0, 0, 0.25);
            background: #f5f5f5;
            cursor: not-allowed;
          }

          /* 设置placeholder的颜色 */
3288
3289
3290
3291
          &::-webkit-input-placeholder { /* WebKit browsers */
            color: #ccc;
          }
3292
3293
3294
3295
          &:-moz-placeholder { /* Mozilla Firefox 4 to 18 */
            color: #ccc;
          }
3296
3297
3298
3299
          &::-moz-placeholder { /* Mozilla Firefox 19+ */
            color: #ccc;
          }
3300
3301
3302
3303
3304
3305
3306
          &:-ms-input-placeholder { /* Internet Explorer 10+ */
            color: #ccc;
          }

        }
3307
3308
3309
3310
3311
3312
3313
3314
3315
3316
3317
3318
3319
3320
3321
        .j-editable-image {
          height: 32px;
          max-width: 100px !important;
          cursor: pointer;

          &:hover {
            opacity: 0.8;
          }

          &:active {
            opacity: 0.6;
          }

        }
3322
3323
3324
3325
        /* --------------------------- 2020年5月18日 begin 默认span模式 ------------------------------ */

        label {
          height: 32px;
3326
3327
3328
3329

          &.ant-checkbox-wrapper {
            height: auto;
          }
3330
3331
        }
3332
3333
3334
3335
3336
3337
        .comp-normal {
          white-space: nowrap;
          overflow: hidden;
          text-overflow: ellipsis;
        }
3338
3339
3340
3341
3342
3343
3344
3345
3346
3347
3348
3349
3350
3351
3352
3353
3354
3355
3356
3357
3358
3359
3360
3361
3362
3363
3364
3365
3366
3367
3368
3369
3370
3371
3372
3373
3374
3375
3376
3377
3378
3379
3380
3381
3382
3383
3384
3385
3386
3387
3388
3389
3390
3391
3392
3393
3394
        .j-td-span {
          position: relative;
          padding: 4px 11px;
          border: 1px solid transparent;
          display: inline-block;
          width: 100%;
          max-width: 100%;
          height: 32px;
          cursor: text;
          transition: all 0.3s;
          box-sizing: border-box;
          font-size: 14px;
          line-height: 1.5;
          color: rgba(0, 0, 0, 0.65);
          border-radius: 4px;
          overflow: hidden;
          white-space: nowrap;
          text-overflow: ellipsis;

          &:hover {
            background-color: white;
          }

          &.disabled {
            cursor: not-allowed;

            &:hover {
              color: rgba(0, 0, 0, 0.25);
              background-color: #F5F5F5;
            }
          }

        }

        /* --------------------------- 2020年5月18日 end 默认span模式 ------------------------------ */

        /* --------------------------- 2020年5月28日 begin 新增校验未通过的样式 ------------------------------ */

        .j-check-failed.j-td-span {
          background-color: rgba(255, 0, 0, 0.05);

          &:hover {
            background-color: rgba(255, 0, 0, 0.1);
          }
        }

        .j-check-failed.j-td-span,
        input.j-check-failed,
        .j-check-failed /deep/ input,
        .ant-select.j-check-failed /deep/ .ant-select-selection,
        .ant-upload.j-check-failed /deep/ .ant-btn {
          border-color: red;
          box-shadow: 0 0 0 2px rgba(255, 0, 0, 0.2);
        }

        /* --------------------------- 2020年5月28日 end 新增校验未通过的样式 ------------------------------ */
3395
3396
3397
3398
      }

    }
3399
3400
3401
3402
3403
3404
3405
3406
    .scroll-view {
      overflow: auto;
      overflow-y: scroll;
    }

    .thead, .thead .tr, .scroll-view {
      @scrollBarSize: 6px;
      /* 定义滚动条高宽及背景 高宽分别对应横竖滚动条的尺寸*/
3407
3408
3409
3410
3411
3412
      &::-webkit-scrollbar {
        width: @scrollBarSize;
        height: @scrollBarSize;
        background-color: transparent;
      }
3413
3414
      /* 定义滚动条轨道 */
3415
3416
3417
3418
      &::-webkit-scrollbar-track {
        background-color: #f0f0f0;
      }
3419
3420
      /* 定义滑块 */
3421
3422
3423
3424
3425
3426
3427
3428
3429
3430
3431
3432
3433
3434
3435
3436
3437
3438
3439
3440
3441
3442
3443
3444
3445
3446
3447
3448
3449
3450
3451
3452
3453
      &::-webkit-scrollbar-thumb {
        background-color: #eee;
        box-shadow: inset 0 0 6px rgba(0, 0, 0, 0.3);

        &:hover {
          background-color: #bbb;
        }

        &:active {
          background-color: #888;
        }
      }

    }

    .thead .tr {

      &::-webkit-scrollbar-track {
        background-color: transparent;
      }

      /* IE模式下隐藏 */
      -ms-overflow-style: none;
      -ms-scroll-chaining: chained;
      -ms-content-zooming: zoom;
      -ms-scroll-rails: none;
      -ms-content-zoom-limit-min: 100%;
      -ms-content-zoom-limit-max: 500%;
      -ms-scroll-snap-type: proximity;
      -ms-scroll-snap-points-x: snapList(100%, 200%, 300%, 400%, 500%);
    }
3454
3455
  }
3456
</style>
3457
3458
3459
3460
3461
3462
3463
3464
3465
3466
3467
3468
3469
3470
3471
3472
<style lang="less">
// 新增按钮配置气泡的样式
.j-add-btn-settings {
  width: 240px;

  .ant-form {
    .ant-form-item {
      margin-bottom: 0;

      .ant-input-number {
        width: 100%;
      }
    }
  }
}
</style>