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