Browse Source

奇龙状态修改

master
shenzhouyu 4 weeks ago
parent
commit
d717f93214
  1. 33
      src/views/modules/project/modules/projectPartModelTable.vue
  2. 35
      src/views/modules/project/modules/projectPartModelTableDetail.vue
  3. 3
      src/views/modules/project/projectIndex.vue
  4. 3
      src/views/modules/project/projectPartIndex.vue
  5. 3
      src/views/modules/project/projectPartProgress.vue
  6. 178
      src/views/modules/project/sysBusinessLogIndex.vue

33
src/views/modules/project/modules/projectPartModelTable.vue

@ -661,6 +661,36 @@ export default {
//
this.originalProjectPartModel = []
},
isBatchRowModified(currentRow, originalRow) {
const compareFields = [
'daysNumber',
'planStartDate',
'planEndDate',
'completionProgress',
'excalCompletionDate',
'roleId',
'partLeaderCode',
'partLeader',
]
return compareFields.some((field) => {
const currentValue = currentRow && currentRow[field] !== undefined && currentRow[field] !== null ? String(currentRow[field]) : ''
const originalValue = originalRow && originalRow[field] !== undefined && originalRow[field] !== null ? String(originalRow[field]) : ''
return currentValue !== originalValue
})
},
buildBatchParams() {
const originalMap = new Map(
(this.originalProjectPartModel || []).map((row) => [row.modelId, row])
)
return this.projectPartModel.map((row) => {
const originalRow = originalMap.get(row.modelId) || {}
const isModified = this.isBatchRowModified(row, originalRow) ? 'Y' : 'N'
return {
...row,
isModified,
}
})
},
batchModel() {
for (var i = 0; i < this.projectPartModel.length; i++) {
/* if (!this.projectPartModel[i].daysNumber) {
@ -678,8 +708,7 @@ export default {
}
}
}
let params = []
params = this.projectPartModel
const params = this.buildBatchParams()
this.batchLoading = true
updateBatchPartModel(params)
.then(({ data }) => {

35
src/views/modules/project/modules/projectPartModelTableDetail.vue

@ -693,6 +693,37 @@ export default {
//
this.originalProjectPartModel = []
},
isBatchRowModified(currentRow, originalRow) {
const compareFields = [
'detailDaysNumber',
'detailPlanStartDate',
'detailPlanEndDate',
'detailCompletionProgress',
'detailExcalCompletionDate',
'roleId',
'detailPartLeaderCode',
'detailPartLeader',
]
return compareFields.some((field) => {
const currentValue = currentRow && currentRow[field] !== undefined && currentRow[field] !== null ? String(currentRow[field]) : ''
const originalValue = originalRow && originalRow[field] !== undefined && originalRow[field] !== null ? String(originalRow[field]) : ''
return currentValue !== originalValue
})
},
buildBatchParams() {
const originalMap = new Map(
(this.originalProjectPartModel || []).map((row) => [row.partModelDetailId, row])
)
return this.projectPartModel.map((row) => {
const originalRow = originalMap.get(row.partModelDetailId) || {}
const isModified = this.isBatchRowModified(row, originalRow) ? 'Y' : 'N'
return {
...row,
isModified,
}
})
},
batchModel() {
for (var i = 0; i < this.projectPartModel.length; i++) {
/* if (!this.projectPartModel[i].detailDaysNumber) {
@ -712,8 +743,8 @@ export default {
return
}
}
let params = []
params = this.projectPartModel
const params = this.buildBatchParams()
this.batchLoading = true
updateBatchPartDetailModel(params)
.then(({ data }) => {

3
src/views/modules/project/projectIndex.vue

@ -685,6 +685,9 @@ export default {
this.getTableUserColumn(this.$route.meta.menuId + 'table1', 1)
this.getDataList()
},
activated() {
this.getDataList()
},
watch: {
activeTable(newVal, oldVal) {
if (this.tabRollbacking) return

3
src/views/modules/project/projectPartIndex.vue

@ -709,6 +709,9 @@ export default {
this.getDataList()
},
activated() {
this.getDataList()
},
watch: {
activeTable(newVal, oldVal) {
if (this.tabRollbacking) return

3
src/views/modules/project/projectPartProgress.vue

@ -823,6 +823,9 @@ export default {
}
this.fetchGanttData()
},
activated() {
this.fetchGanttData()
},
}
</script>

178
src/views/modules/project/sysBusinessLogIndex.vue

@ -51,13 +51,37 @@
<el-table-column prop="operation" header-align="center" align="left" min-width="160" label="操作" />
<el-table-column prop="username" header-align="center" align="center" width="120" label="操作人" />
<el-table-column prop="createDate" header-align="center" align="center" width="170" label="创建时间" />
<el-table-column prop="oldValue" header-align="center" align="center" width="370" label="修改前值" :show-overflow-tooltip="true"/>
<el-table-column prop="newValue" header-align="center" align="center" width="370" label="修改后值" :show-overflow-tooltip="true"/>
<el-table-column fixed="right" header-align="center" align="center" width="100" label="操作">
<template v-for="field in dynamicColumns">
<el-table-column
:key="field + '_old'"
:label="getFieldLabel(field) + '改动前'"
header-align="center"
align="left"
min-width="180"
:show-overflow-tooltip="true"
>
<template slot-scope="scope">
{{ flattenDisplayValue(getFieldRawValue(scope.row.parsedOldValue, field)) }}
</template>
</el-table-column>
<el-table-column
:key="field + '_new'"
:label="getFieldLabel(field) + '改动后'"
header-align="center"
align="left"
min-width="180"
:show-overflow-tooltip="true"
>
<template slot-scope="scope">
{{ flattenDisplayValue(getFieldRawValue(scope.row.parsedNewValue, field)) }}
</template>
</el-table-column>
</template>
<!-- <el-table-column fixed="right" header-align="center" align="center" width="100" label="操作">
<template slot-scope="scope">
<el-link style="cursor: pointer" @click="openDetail(scope.row)">详情</el-link>
</template>
</el-table-column>
</el-table-column> -->
</el-table>
<el-pagination
@ -79,14 +103,11 @@
</el-descriptions>
<div style="margin-top: 12px">
<el-tabs type="border-card">
<el-tab-pane label="修改前(oldValue)">
<pre class="json-pre">{{ prettyJson(detailRow.oldValue) }}</pre>
</el-tab-pane>
<el-tab-pane label="修改后(newValue)">
<pre class="json-pre">{{ prettyJson(detailRow.newValue) }}</pre>
</el-tab-pane>
</el-tabs>
<el-table :data="detailDiffList" border size="mini" max-height="420">
<el-table-column prop="label" label="字段" min-width="220" />
<el-table-column prop="oldValue" label="修改前" min-width="220" />
<el-table-column prop="newValue" label="修改后" min-width="220" />
</el-table>
</div>
</el-dialog>
</div>
@ -116,6 +137,7 @@ export default {
tableHeight: 500,
detailVisible: false,
detailRow: {},
dynamicColumns: [],
}
},
created() {
@ -127,6 +149,85 @@ export default {
})
},
methods: {
isIdField(key) {
if (!key) return false
return /(^id$|_id$|Id$)/.test(String(key))
},
parseJsonObject(val) {
if (val === null || val === undefined || val === '') return {}
if (typeof val === 'object') return val || {}
try {
const parsed = JSON.parse(String(val))
return parsed && typeof parsed === 'object' ? parsed : {}
} catch (e) {
return {}
}
},
getFieldLabelMap() {
return {
detailPlanStartDate: '计划开始时间',
detailPlanEndDate: '计划结束时间',
projectStartDate: '项目开始时间',
planStartDate: '项目计划开始时间',
planEndDate: '项目计划结束时间',
daysNumber: '天数',
}
},
getMappedFieldKeys() {
//
return [
'detailPlanStartDate',
'detailPlanEndDate',
'projectStartDate',
'planStartDate',
'planEndDate',
'daysNumber',
]
},
getFieldRawValue(parsedValue, fieldKey) {
if (parsedValue === null || parsedValue === undefined || parsedValue === '') return undefined
// parsedValue key
if (Array.isArray(parsedValue)) {
const values = []
parsedValue.forEach((item) => {
if (item && typeof item === 'object' && !Array.isArray(item) && Object.prototype.hasOwnProperty.call(item, fieldKey)) {
values.push(item[fieldKey])
}
})
return values.length ? values : undefined
}
if (typeof parsedValue === 'object') {
return Object.prototype.hasOwnProperty.call(parsedValue, fieldKey) ? parsedValue[fieldKey] : undefined
}
return undefined
},
buildDynamicColumns(list) {
// 0/1/2...
this.dynamicColumns = this.getMappedFieldKeys()
},
getFieldLabel(key) {
const map = this.getFieldLabelMap()
return map[key] || key
},
flattenDisplayValue(val) {
if (val === null || val === undefined || val === '') return '-'
const values = []
const pushLeaf = (v) => {
if (v === null || v === undefined || v === '') return
if (Array.isArray(v)) {
v.forEach((it) => pushLeaf(it))
return
}
if (typeof v === 'object') {
Object.values(v).forEach((it) => pushLeaf(it))
return
}
values.push(String(v))
}
pushLeaf(val)
if (!values.length) return '-'
return values.join(';')
},
getDataList() {
this.dataListLoading = true
const params = {
@ -137,10 +238,21 @@ export default {
querySysBusinessLogPage(params)
.then(({ data }) => {
if (data && data.code === 0 && data.page) {
this.dataList = data.page.list || []
const list = data.page.list || []
this.dataList = list.map((item) => {
const parsedOldValue = this.parseJsonObject(item.oldValue)
const parsedNewValue = this.parseJsonObject(item.newValue)
return {
...item,
parsedOldValue,
parsedNewValue,
}
})
this.buildDynamicColumns(this.dataList)
this.totalPage = data.page.totalCount || 0
} else {
this.dataList = []
this.dynamicColumns = []
this.totalPage = 0
}
})
@ -166,21 +278,18 @@ export default {
this.detailRow = JSON.parse(JSON.stringify(row || {}))
this.detailVisible = true
},
prettyJson(val) {
if (val === null || val === undefined || val === '') return ''
if (typeof val === 'object') {
try {
return JSON.stringify(val, null, 2)
} catch (e) {
return String(val)
}
}
const str = String(val)
try {
return JSON.stringify(JSON.parse(str), null, 2)
} catch (e) {
return str
}
getDetailDiffList(row) {
const oldObj = this.parseJsonObject(row.oldValue)
const newObj = this.parseJsonObject(row.newValue)
const mappedKeys = this.getMappedFieldKeys()
return mappedKeys
.filter((k) => !this.isIdField(k))
.map((key) => ({
key,
label: this.getFieldLabel(key),
oldValue: this.flattenDisplayValue(this.getFieldRawValue(oldObj, key)),
newValue: this.flattenDisplayValue(this.getFieldRawValue(newObj, key)),
}))
},
getReviewedLabel(flag) {
if (flag === 'Y') return '已审核'
@ -192,18 +301,15 @@ export default {
return 'status-yellow'
},
},
computed: {
detailDiffList() {
return this.getDetailDiffList(this.detailRow || {})
},
},
}
</script>
<style scoped>
.json-pre {
white-space: pre-wrap;
word-break: break-word;
margin: 0;
font-size: 12px;
line-height: 18px;
}
.status-green {
color: #67c23a;
}

Loading…
Cancel
Save