<template>
|
<a-spin :spinning="confirmLoading">
|
<j-form-container :disabled="formDisabled">
|
<!-- 主表单区域 -->
|
<a-form-model ref="form" :model="model" :rules="validatorRules" slot="detail">
|
<a-row>
|
<a-col :span="12" >
|
<a-form-model-item label="操作证编号" :labelCol="labelCol" :wrapperCol="wrapperCol" prop="num">
|
<a-input v-model="model.num" placeholder="请输入操作证编号" ></a-input>
|
</a-form-model-item>
|
</a-col>
|
<a-col :span="12" >
|
<a-form-model-item label="用户ID" :labelCol="labelCol" :wrapperCol="wrapperCol" prop="userId">
|
<j-select-user-by-dep v-model="model.userId" :multi="true" />
|
</a-form-model-item>
|
</a-col>
|
<a-col :span="12" >
|
<a-form-model-item label="发证日期" :labelCol="labelCol" :wrapperCol="wrapperCol" prop="issueDate">
|
<j-date placeholder="请选择发证日期" v-model="model.issueDate" style="width: 100%" />
|
</a-form-model-item>
|
</a-col>
|
<a-col :span="12" >
|
<a-form-model-item label="开始时间" :labelCol="labelCol" :wrapperCol="wrapperCol" prop="startTime">
|
<j-date placeholder="请选择开始时间" v-model="model.startTime" style="width: 100%" />
|
</a-form-model-item>
|
</a-col>
|
<a-col :span="12" >
|
<a-form-model-item label="结束时间" :labelCol="labelCol" :wrapperCol="wrapperCol" prop="endTime">
|
<j-date placeholder="请选择结束时间" v-model="model.endTime" style="width: 100%" />
|
</a-form-model-item>
|
</a-col>
|
<a-col :span="12" >
|
<a-form-model-item label="当前周期分数" :labelCol="labelCol" :wrapperCol="wrapperCol" prop="currentCycleScore">
|
<a-input-number v-model="model.currentCycleScore" placeholder="请输入当前周期分数" style="width: 100%" />
|
</a-form-model-item>
|
</a-col>
|
<a-col :span="12" >
|
<a-form-model-item label="设备统一编码" :labelCol="labelCol" :wrapperCol="wrapperCol" prop="equipmentIds">
|
<j-multi-select-tag type="list_multi" v-model="model.equipmentIds" dictCode="mom_eam_equipment,num,id" placeholder="请选择设备统一编码" />
|
</a-form-model-item>
|
</a-col>
|
<a-col :span="12" >
|
<a-form-model-item label="状态" :labelCol="labelCol" :wrapperCol="wrapperCol" prop="status">
|
<j-dict-select-tag type="list" v-model="model.status" dictCode="certificate_status" placeholder="请选择状态" disabled/>
|
</a-form-model-item>
|
</a-col>
|
<a-col :span="24" >
|
<a-form-model-item label="备注" :labelCol="labelCol" :wrapperCol="wrapperCol" prop="remark">
|
<a-textarea v-model="model.remark" placeholder="请输入备注" ></a-textarea>
|
</a-form-model-item>
|
</a-col>
|
|
</a-row>
|
</a-form-model>
|
</j-form-container>
|
<!-- 子表单区域 -->
|
<a-tabs v-model="activeKey" @change="handleChangeTabs">
|
<a-tab-pane tab="操作证管理明细" :key="refKeys[0]" :forceRender="true">
|
<j-vxe-table
|
keep-source
|
:ref="refKeys[0]"
|
:loading="operationCertificateDetailTable.loading"
|
:columns="operationCertificateDetailTable.columns"
|
:dataSource="operationCertificateDetailTable.dataSource"
|
:maxHeight="300"
|
:disabled="formDisabled"
|
:rowNumber="true"
|
:rowSelection="true"
|
:toolbar="true"
|
/>
|
</a-tab-pane>
|
</a-tabs>
|
</a-spin>
|
</template>
|
|
<script>
|
|
import { getAction } from '@/api/manage'
|
import { JVxeTableModelMixin } from '@/mixins/JVxeTableModelMixin.js'
|
import { JVXETypes } from '@/components/jeecg/JVxeTable'
|
import { getRefPromise,VALIDATE_FAILED} from '@/components/jeecg/JVxeTable/utils/vxeUtils.js'
|
import { validateDuplicateValue } from '@/utils/util'
|
import JFormContainer from '@/components/jeecg/JFormContainer'
|
|
export default {
|
name: 'OperationCertificateForm',
|
mixins: [JVxeTableModelMixin],
|
components: {
|
JFormContainer,
|
},
|
data() {
|
return {
|
labelCol: {
|
xs: { span: 24 },
|
sm: { span: 5 },
|
},
|
wrapperCol: {
|
xs: { span: 24 },
|
sm: { span: 16 },
|
},
|
model:{
|
},
|
// 新增时子表默认添加几行空数据
|
addDefaultRowNum: 1,
|
validatorRules: {
|
num: [
|
{ required: true, message: '请输入操作证编号!'},
|
],
|
currentCycleScore: [
|
{ required: true, message: '请输入当前周期分数!'},
|
{ pattern: /^-?\d+\.?\d*$/, message: '请输入数字!'},
|
],
|
},
|
refKeys: ['operationCertificateDetail', ],
|
tableKeys:['operationCertificateDetail', ],
|
activeKey: 'operationCertificateDetail',
|
// 操作证管理明细
|
operationCertificateDetailTable: {
|
loading: false,
|
dataSource: [],
|
columns: [
|
{
|
title: '证书ID',
|
key: 'operationCertificateId',
|
type: JVXETypes.input,
|
width:"200px",
|
placeholder: '请输入${title}',
|
defaultValue:'',
|
},
|
{
|
title: '类型',
|
key: 'type',
|
type: JVXETypes.input,
|
width:"200px",
|
placeholder: '请输入${title}',
|
defaultValue:'',
|
},
|
{
|
title: '设备id',
|
key: 'equipmentId',
|
type: JVXETypes.input,
|
width:"200px",
|
placeholder: '请输入${title}',
|
defaultValue:'',
|
},
|
{
|
title: '扣分项',
|
key: 'deductionItem',
|
type: JVXETypes.input,
|
width:"200px",
|
placeholder: '请输入${title}',
|
defaultValue:'',
|
},
|
{
|
title: '扣分周期',
|
key: 'period',
|
type: JVXETypes.input,
|
width:"200px",
|
placeholder: '请输入${title}',
|
defaultValue:'',
|
},
|
]
|
},
|
url: {
|
add: "/eam/operationCertificate/add",
|
edit: "/eam/operationCertificate/edit",
|
queryById: "/eam/operationCertificate/queryById",
|
operationCertificateDetail: {
|
list: '/eam/operationCertificate/queryOperationCertificateDetailByMainId'
|
},
|
}
|
}
|
},
|
props: {
|
//表单禁用
|
disabled: {
|
type: Boolean,
|
default: false,
|
required: false
|
}
|
},
|
computed: {
|
formDisabled(){
|
return this.disabled
|
},
|
},
|
created () {
|
},
|
methods: {
|
addBefore(){
|
this.operationCertificateDetailTable.dataSource=[]
|
},
|
getAllTable() {
|
let values = this.tableKeys.map(key => getRefPromise(this, key))
|
return Promise.all(values)
|
},
|
/** 调用完edit()方法之后会自动调用此方法 */
|
editAfter() {
|
this.$nextTick(() => {
|
})
|
// 加载子表数据
|
if (this.model.id) {
|
let params = { id: this.model.id }
|
this.requestSubTableData(this.url.operationCertificateDetail.list, params, this.operationCertificateDetailTable)
|
}
|
},
|
//校验所有一对一子表表单
|
validateSubForm(allValues){
|
return new Promise((resolve,reject)=>{
|
Promise.all([
|
]).then(() => {
|
resolve(allValues)
|
}).catch(e => {
|
if (e.error === VALIDATE_FAILED) {
|
// 如果有未通过表单验证的子表,就自动跳转到它所在的tab
|
this.activeKey = e.index == null ? this.activeKey : this.refKeys[e.index]
|
} else {
|
console.error(e)
|
}
|
})
|
})
|
},
|
/** 整理成formData */
|
classifyIntoFormData(allValues) {
|
let main = Object.assign(this.model, allValues.formValue)
|
return {
|
...main, // 展开
|
operationCertificateDetailList: allValues.tablesValue[0].tableData,
|
}
|
},
|
validateError(msg){
|
this.$message.error(msg)
|
},
|
|
}
|
}
|
</script>
|
|
<style scoped>
|
</style>
|