Browse Source

日期控件点击时再加载

master
han\hanst 2 days ago
parent
commit
5e8fdd4b1c
  1. 125
      src/views/modules/sampleTracking/projectProofTracking.vue

125
src/views/modules/sampleTracking/projectProofTracking.vue

@ -48,7 +48,7 @@
style="margin-top: 3px; margin-left: 10px" style="margin-top: 3px; margin-left: 10px"
placement="top"> placement="top">
<template slot="content"> <template slot="content">
<div>- 已完成后双击日期选择框可回退为未完成</div>
<div>- 单击日期可修改已完成后双击日期可回退为未完成</div>
<div>- 双击Comments可编辑回车或点击保存</div> <div>- 双击Comments可编辑回车或点击保存</div>
</template> </template>
<i class="el-icon-question default-process-tip-icon"></i> <i class="el-icon-question default-process-tip-icon"></i>
@ -322,7 +322,10 @@
</div> </div>
</template> </template>
<template v-else> <template v-else>
<!-- 默认只渲染文本避免每行每列都挂 el-date-picker同一时刻最多一个日期组件 -->
<el-date-picker <el-date-picker
v-if="isProcessDateEditing(scope.row, item)"
ref="processDateEditPicker"
class="proof-process-date-picker" class="proof-process-date-picker"
v-model="scope.row[item.actualField]" v-model="scope.row[item.actualField]"
type="date" type="date"
@ -331,8 +334,15 @@
placeholder="" placeholder=""
style="width: 100px" style="width: 100px"
@change="handleProcessDateChange(scope.row, item, $event)" @change="handleProcessDateChange(scope.row, item, $event)"
@blur="handleProcessDatePickerBlur"
@dblclick.native.stop="handleProcessDateDoubleClick(scope.row, item)" @dblclick.native.stop="handleProcessDateDoubleClick(scope.row, item)"
/> />
<span
v-else
class="process-date-display process-date-display--editable"
@click.stop="handleProcessDateDisplayClick(scope.row, item)"
@dblclick.stop="handleProcessDateDisplayDblClick(scope.row, item)"
>{{ scope.row[item.actualField] || '' }}</span>
<el-button <el-button
v-if="!isProcessStatusComplete(scope.row, item)" v-if="!isProcessStatusComplete(scope.row, item)"
class="process-complete-btn" class="process-complete-btn"
@ -1870,6 +1880,8 @@ export default {
commentsEditingTrackingId: null, commentsEditingTrackingId: null,
commentsDraft: '', commentsDraft: '',
commentsSaveLoading: false, commentsSaveLoading: false,
//
processDateEditingKey: '',
oneKeyDialogVisible: false, oneKeyDialogVisible: false,
oneKeyDialogMode: 'create', oneKeyDialogMode: 'create',
@ -1930,6 +1942,8 @@ export default {
deactivated () { deactivated () {
this.unbindTrackingTableResize() this.unbindTrackingTableResize()
this.destroyDefaultProcessConfigSortable() this.destroyDefaultProcessConfigSortable()
this.clearProcessDateEditClickTimer()
this.exitProcessDateEdit()
}, },
beforeDestroy () { beforeDestroy () {
if (this.$store.state.common.contentIsNeedRefresh) { if (this.$store.state.common.contentIsNeedRefresh) {
@ -1939,6 +1953,8 @@ export default {
buNo: this.searchData.buNo buNo: this.searchData.buNo
} }
} }
this.clearProcessDateEditClickTimer()
this.exitProcessDateEdit()
this.unbindTrackingTableResize() this.unbindTrackingTableResize()
}, },
watch: { watch: {
@ -4319,6 +4335,9 @@ export default {
inData.proofingStatusList = normalizedProofingStatusList inData.proofingStatusList = normalizedProofingStatusList
this.applyProofTrackingSearchFilters(inData) this.applyProofTrackingSearchFilters(inData)
this.dataListLoading = true this.dataListLoading = true
//
this.clearProcessDateEditClickTimer()
this.exitProcessDateEdit()
searchProofTracking(inData).then(({ data }) => { searchProofTracking(inData).then(({ data }) => {
this.dataListLoading = false this.dataListLoading = false
this.resetProcessTooltip() this.resetProcessTooltip()
@ -6148,6 +6167,83 @@ export default {
this.$message.error('新增打样异常') this.$message.error('新增打样异常')
}) })
}, },
isProcessDateEditing (row, processCol) {
const editingKey = this.processDateEditingKey
if (!editingKey) {
return false
}
return this.getProcessCacheKey(row, processCol) === editingKey
},
clearProcessDateEditClickTimer () {
if (this._processDateEditClickTimer) {
clearTimeout(this._processDateEditClickTimer)
this._processDateEditClickTimer = null
}
},
exitProcessDateEdit () {
this.processDateEditingKey = ''
},
openProcessDateEditPicker (retried) {
let picker = this.$refs.processDateEditPicker
// v-forVue2 使 v-if ref
if (Array.isArray(picker)) {
picker = picker.filter(item => item)[0]
}
if (!picker) {
if (!retried) {
this.$nextTick(() => {
this.openProcessDateEditPicker(true)
})
}
return
}
if (typeof picker.focus === 'function') {
picker.focus()
}
// focus
picker.pickerVisible = true
},
startProcessDateEdit (row, processCol) {
if (!row || !processCol || this.isTrackingRowProcessReadonly(row)) {
return
}
const nextKey = this.getProcessCacheKey(row, processCol)
if (!nextKey) {
return
}
this.hideProcessTooltip()
this.processDateEditingKey = nextKey
this.$nextTick(() => {
this.openProcessDateEditPicker()
})
},
handleProcessDateDisplayClick (row, processCol) {
if (!row || !processCol || this.isTrackingRowProcessReadonly(row)) {
return
}
this.clearProcessDateEditClickTimer()
// 退
if (this.isProcessStatusComplete(row, processCol)) {
this._processDateEditClickTimer = setTimeout(() => {
this._processDateEditClickTimer = null
this.startProcessDateEdit(row, processCol)
}, 250)
return
}
this.startProcessDateEdit(row, processCol)
},
handleProcessDateDisplayDblClick (row, processCol) {
this.clearProcessDateEditClickTimer()
if (this.isProcessStatusComplete(row, processCol)) {
this.handleProcessDateDoubleClick(row, processCol)
return
}
this.startProcessDateEdit(row, processCol)
},
handleProcessDatePickerBlur () {
// pickerVisible false blur
this.exitProcessDateEdit()
},
handleProcessDateChange (row, processCol, dateVal) { handleProcessDateChange (row, processCol, dateVal) {
if (!row || !processCol) { if (!row || !processCol) {
return return
@ -7268,6 +7364,15 @@ export default {
color: #8c8c8c; color: #8c8c8c;
} }
.process-cell.is-complete .process-date-display {
color: #8c8c8c;
}
.process-cell.is-complete .process-date-display--editable:hover {
background: #ececec;
border-color: #d5d7de;
}
.process-cell.is-complete .link-date { .process-cell.is-complete .link-date {
color: #8c8c8c; color: #8c8c8c;
} }
@ -7306,6 +7411,24 @@ export default {
margin-right: 32px; margin-right: 32px;
} }
.process-date-display--editable {
min-width: 100px;
min-height: 24px;
line-height: 24px;
margin-right: 0;
padding: 0 6px;
border: 1px solid transparent;
border-radius: 4px;
cursor: pointer;
user-select: none;
box-sizing: border-box;
}
.process-date-display--editable:hover {
border-color: #dcdfe6;
background: #fff;
}
.process-complete-btn { .process-complete-btn {
padding: 4px 8px; padding: 4px 8px;
min-width: 12px; min-width: 12px;

Loading…
Cancel
Save