update 企标稽查计划-业务信息调整前端存储

This commit is contained in:
danshihao
2024-01-03 14:41:13 +08:00
parent bb7e444dba
commit f9725d1fc2
4 changed files with 101 additions and 56 deletions
@@ -345,11 +345,13 @@ export default {
async getPageParams (isValidate = true) {
// 去除备注必填
this.validatorRules.remarks.rules[0].required = false
if (this.$refs.inspectionPlanTable.dataSource.length === 0) {
if (isValidate && this.$refs.inspectionPlanTable.dataSource.length === 0) {
this.$message.warning(this.$t('addAtLeastOneRowOfData'))
throw new Error('base')
}
const params = {}
// 业务表信息
params.processEsInspectPlanList = this.$refs.inspectionPlanTable.dataSource
// 收集所有表单信息
let formDataList = []
if (isValidate) {
@@ -28,7 +28,7 @@
<!-- 计划稽查对象 -->
<a-form-item :label="$t('workCenter.esInspectionPlan.planInspectionObjects')" :labelCol="labelCol" :wrapperCol="wrapperCol">
<j-select-depart :placeholder="$t('pleaseSelect') + $t('workCenter.esInspectionPlan.inspectionBasisStandardNumber')"
multi treeOpera :disabled="disabled"
multi treeOpera :disabled="disabled" backDepart @back="backDepartCallback($event, 'inspectObject_dictText')"
v-decorator="['inspectObject', validatorRules.planInspectionObjects]" />
</a-form-item>
<!-- 主责标准化工作组 -->
@@ -52,7 +52,7 @@
<!-- 所属部门 -->
<a-form-item :label="$t('workCenter.esInspectionPlan.department')" :labelCol="labelCol" :wrapperCol="wrapperCol">
<j-select-depart :placeholder="$t('pleaseSelect') + $t('workCenter.esInspectionPlan.inspectionBasisStandardNumber')"
:disabled="disabled"
:disabled="disabled" backDepart @back="backDepartCallback($event, 'belongDept_dictText')"
v-decorator="['belongDept', validatorRules.department]" />
</a-form-item>
<!-- 计划稽查日期 -->
@@ -64,19 +64,20 @@
<!-- 稽查负责人 -->
<a-form-item :label="$t('workCenter.esInspectionPlan.inspectionDirector')" :labelCol="labelCol" :wrapperCol="wrapperCol">
<user-selection :placeholder="$t('pleaseSelect') + $t('workCenter.esInspectionPlan.inspectionDirector')"
type="radio" :nameStr="model.inspectUserDictText"
type="radio" :nameStr="model.inspectUserDictText" @nameChange="nameChangeCallback($event, 'inspectUserDictText')"
v-decorator="['inspectUser', validatorRules.inspectionDirector]" />
</a-form-item>
<!-- 标准化组对接人 -->
<a-form-item :label="$t('workCenter.esInspectionPlan.standardizationGroupContactPerson')" :labelCol="labelCol" :wrapperCol="wrapperCol">
<user-selection :placeholder="$t('pleaseSelect') + $t('workCenter.esInspectionPlan.standardizationGroupContactPerson')"
type="radio" :nameStr="model.standardizationDockingUserDictText"
type="radio" :nameStr="model.standardizationDockingUserDictText" @nameChange="nameChangeCallback($event, 'standardizationDockingUserDictText')"
v-decorator="['standardizationDockingUser', validatorRules.standardizationGroupContactPerson]" />
</a-form-item>
<!-- 征求意见对象 -->
<a-form-item :label="$t('workCenter.esInspectionPlan.solicitingOpinionsFrom')" :labelCol="labelCol" :wrapperCol="wrapperCol">
<user-selection :placeholder="$t('pleaseSelect') + $t('workCenter.esInspectionPlan.solicitingOpinionsFrom')"
type="checkbox" :nameStr="model.objectOfConsultationDictText" :disabled="isFillInComments" :showBtn="!isFillInComments"
@nameChange="nameChangeCallback($event, 'objectOfConsultationDictText')"
v-decorator="['objectOfConsultation', validatorRules.solicitingOpinionsFrom]" />
</a-form-item>
<!-- 备注 -->
@@ -104,7 +105,6 @@ import StandardSelection from '@comp/selection/StandardSelection'
import UserSelection from '@comp/selection/UserSelection'
import { getWorkGroupTreeList } from '@api/api'
import WorkGroupSelection from '@comp/selection/WorkGroupSelection'
import { addInspectPlanTable, editInspectPlanTable } from '@api/workCenter'
import { EsInspectionPlan, StandardSource } from '@/enums/commonEnums'
export default {
@@ -228,7 +228,9 @@ export default {
}
]
}
}
},
// 如果是编辑用到下标记录数据
index: -1
}
},
created () {
@@ -244,6 +246,16 @@ export default {
}
},
methods: {
// 选择人员回调
nameChangeCallback (name, field) {
console.log(name, field)
this.model[field] = name
},
// 选择部门回调
backDepartCallback (data, field) {
console.log(data, field)
this.model[field] = data ? data.map(item => item.text).join(',') : ''
},
add () {
const obj = {}
// 如果是节点2,征求意见对象默认回显自己,并且禁用
@@ -253,7 +265,8 @@ export default {
}
this.edit(obj)
},
edit (record) {
edit (record, index) {
this.index = index
this.visible = true
this.form.resetFields()
this.model = Object.assign({}, record)
@@ -265,22 +278,26 @@ export default {
if (this.confirmLoading) return
this.form.validateFields((err, values) => {
if (!err) {
const params = Object.assign({
projectId: this.projectId
}, this.model, values)
this.confirmLoading = true
const fn = params.id ? editInspectPlanTable : addInspectPlanTable
fn(params).then(res => {
if (res.success) {
this.$emit('ok', params)
this.$message.success(res.message)
this.close()
} else {
this.$message.warn(res.message)
}
}).finally(() => {
this.confirmLoading = false
})
// 调整前端存储
const row = Object.assign({}, this.model, values)
this.$emit('ok', row, this.index)
this.close()
// const params = Object.assign({
// projectId: this.projectId
// }, this.model, values)
// this.confirmLoading = true
// const fn = params.id ? editInspectPlanTable : addInspectPlanTable
// fn(params).then(res => {
// if (res.success) {
// this.$emit('ok', params)
// this.$message.success(res.message)
// this.close()
// } else {
// this.$message.warn(res.message)
// }
// }).finally(() => {
// this.confirmLoading = false
// })
}
})
},
@@ -288,6 +305,7 @@ export default {
this.close()
},
close () {
this.index = -1
this.model = {}
this.visible = false
},
@@ -59,9 +59,9 @@
</div>
<!-- 新增/编辑稽查计划 -->
<inspection-plan-drawer ref="modalForm" @ok="modalFormOk" :project-id="projectId"/>
<inspection-plan-drawer ref="modalForm" @ok="handleAddOrEditCallback" :project-id="projectId"/>
<!-- 节点2填写意见意见回显 -->
<write-opinion-modal ref="writeOpinionModal" @ok="modalFormOk"/>
<write-opinion-modal ref="writeOpinionModal" @ok="handleWriteOpinionCallback"/>
<!-- 节点3所属部门意见-查看 -->
<show-opinion-modal ref="showOpinionModal" @ok="modalFormOk"/>
</div>
@@ -274,6 +274,22 @@ export default {
this.filters.taskId = this.$route.query.taskId
},
methods: {
// 编辑弹框
handleEdit (record, index) {
this.$refs.modalForm.edit(record, index)
this.$refs.modalForm.title = this.$t('edit')
this.$refs.modalForm.disableSubmit = false
},
// 添加回调
handleAddOrEditCallback (row, index) {
console.log(row, index)
// index -1就是添加
if (index === -1) {
this.dataSource.push(row)
} else {
this.dataSource.splice(index, 1, row)
}
},
// 是否显示意见
isShowOpinion (record) {
const list = record.processEsInspectPlanOpinionList || []
@@ -315,8 +331,16 @@ export default {
this.$refs.writeOpinionModal.show(record)
},
// 填写意见
handleWriteOpinion (record) {
this.$refs.writeOpinionModal.show(record)
handleWriteOpinion (record, index) {
this.$refs.writeOpinionModal.show(record, index)
},
// 填写意见回调
handleWriteOpinionCallback (data, index) {
this.dataSource.splice(index, 1, {
...this.dataSource[index],
// 填写意见的数据
processEsInspectPlanOpinion: data
})
},
// 查看所属部门意见
showDepartOpinion (record) {
@@ -34,7 +34,7 @@
<a-form-model-item
prop="opinion"
:label="$t('workCenter.esInspectionPlan.opinion')">
<a-textarea :max-length="500" :rows="4" :disabled="disabled"
<a-textarea :max-length="500" :rows="4"
:placeholder="$t('pleaseEnter') + $t('workCenter.esInspectionPlan.opinion')" v-model="formData.opinion"/>
</a-form-model-item>
</a-form-model>
@@ -45,13 +45,11 @@
<script>
import JTable from '@comp/jero/JTable'
import { fillInOpinionInspectPlanTable } from '@api/workCenter'
export default {
name: 'WriteOpinionModal',
components: { JTable },
data () {
return {
disabled: false,
title: this.$t('workCenter.esInspectionPlan.writeOpinion'),
drawerWidth: 1000,
visible: false,
@@ -109,44 +107,46 @@ export default {
scopedSlots: { customRender: 'text' }
}
],
dataSource: []
dataSource: [],
// 操作的数据下标
index: -1
}
},
methods: {
show (record, disabled) {
// 是否禁用表单
this.disabled = disabled
show (record, index) {
this.index = index
const list = record.processEsInspectPlanOpinionList || []
this.formData.opinion = (list.find(item => item.createBy === this.$store.getters.userInfo.username) || {}).opinion
// 从数组里找到自己的数据显示,或者前端保存数据的字段
const data = list.find(item => item.createBy === this.$store.getters.userInfo.username) || record.processEsInspectPlanOpinion || {}
this.formData.opinion = data.opinion
this.dataSource = [record]
this.model = Object.assign({}, record)
this.visible = true
},
// 确定
handleOk () {
if (this.disabled) {
this.close()
return
}
const that = this
// const that = this
// 触发表单验证
this.$refs.form.validate(valid => {
if (valid) {
that.confirmLoading = true
const formData = Object.assign({}, {
inspectPlanId: this.model.id
}, this.formData)
fillInOpinionInspectPlanTable(formData).then((res) => {
if (res.success) {
that.$message.success(res.message)
that.$emit('ok')
that.close()
} else {
that.$message.warning(res.message)
}
}).finally(() => {
that.confirmLoading = false
})
const data = Object.assign({}, this.formData)
this.$emit('ok', data, this.index)
this.close()
// that.confirmLoading = true
// const formData = Object.assign({}, {
// inspectPlanId: this.model.id
// }, this.formData)
// fillInOpinionInspectPlanTable(formData).then((res) => {
// if (res.success) {
// that.$message.success(res.message)
// that.$emit('ok')
// that.close()
// } else {
// that.$message.warning(res.message)
// }
// }).finally(() => {
// that.confirmLoading = false
// })
} else {
return false
}
@@ -158,6 +158,7 @@ export default {
},
close () {
this.$emit('close')
this.index = -1
this.dataSource = []
this.$refs.form.resetFields()
this.visible = false