Browse Source

静态动态

master
wangyufei 4 weeks ago
parent
commit
4605a2198b
  1. 6
      src/components/BasicForm/src/BasicForm.vue
  2. 69
      src/views/battery/monomer/index.vue
  3. 277
      src/views/battery/monomer/monomer.data.ts

6
src/components/BasicForm/src/BasicForm.vue

@ -1134,7 +1134,13 @@ const buttonOperationClick = (row, label, index) => {
emit('buttonOperationClick', row, label, index)
}
const updateFormAllSchemas = (formAllSchemas)=>{
formSchema.value = formAllSchemas?.formSchema
}
defineExpose({
updateFormAllSchemas,
open,
formRef,
opensearchTable,

69
src/views/battery/monomer/index.vue

@ -43,13 +43,14 @@
<BasicForm
ref="basicFormRef"
@success="formsSuccess"
:rules="MonomerRules"
:formAllSchemas="Monomer.allSchemas"
:rules="formRules"
:formAllSchemas="formAllSchemas"
:apiUpdate="MonomerApi.updateMonomer"
:apiCreate="MonomerApi.createMonomer"
@searchTableSuccess="searchTableSuccess"
:isBusiness="false"
>
<template #tableForm>
<!-- 单体产线设备 -->
<div class="table">
@ -191,7 +192,7 @@
<!-- 详情 -->
<Detail ref="detailRef" :isBasic="true" :allSchemas="Monomer.allSchemas" />
<Detail ref="detailRef" :isBasic="true" :allSchemas="formAllSchemas" />
<!-- 导入 -->
<ImportForm ref="importFormRef" url="/battery/cell-device/import" :importTemplateData="importTemplateData" @success="importSuccess" />
@ -219,7 +220,7 @@ import * as CellPassApi from '@/api/battery/cellPass'
import download from '@/utils/download'
import { Monomer,MonomerRules } from './monomer.data'
import { Monomer,MonomerRules,StaticMonomer,StaticMonomerRules,DynamicMonomer,DynamicMonomerRules} from './monomer.data'
import * as MonomerApi from '@/api/battery/monomer'
import * as defaultButtons from '@/utils/disposition/defaultButtons'
import TableHead from '@/components/TableHead/src/TableHead.vue'
@ -238,6 +239,9 @@ const routeName = ref()
routeName.value = route.name
const tableColumns = ref(Monomer.allSchemas.tableColumns)
const formRules = ref(StaticMonomerRules)
const formAllSchemas = ref(StaticMonomer.allSchemas)
//
const searchTableSuccess = (formField, searchField, val, formRef) => {
nextTick(() => {
@ -330,25 +334,23 @@ const buttonTableClick = async (val, row) => {
const basicFormRef = ref()
const openForm = async (type: string, row?: any) => {
if(isStatic.value){
//
formRules.value = StaticMonomerRules
formAllSchemas.value = StaticMonomer.allSchemas
basicFormRef.value.updateFormAllSchemas(StaticMonomer.allSchemas)
}else{
//
formRules.value = DynamicMonomerRules
formAllSchemas.value = DynamicMonomer.allSchemas
basicFormRef.value.updateFormAllSchemas(DynamicMonomer.allSchemas)
}
if(type == 'create'&&tableObject.tableList.length>0){
if(isStatic.value){
//
Monomer.allSchemas.formSchema.forEach(item=>{
if(item.field=='type'){
item.value = 'static'
}
})
let defaultRow = await MonomerApi.getMonomer(1)
row = defaultRow
}else{
//
Monomer.allSchemas.formSchema.forEach(item=>{
if(item.field=='type'){
item.value = 'moving'
}
})
}
if(type == 'create'&&isStatic.value){
let defaultRow = await MonomerApi.getMonomer(1)
row = defaultRow
}
if(row){
//
@ -382,15 +384,7 @@ const openForm = async (type: string, row?: any) => {
// form
const formsSuccess = async (formType,data) => {
var isHave =Monomer.allSchemas.formSchema.some(function (item) {
return item.field === 'activeTime' || item.field === 'expireTime';
});
if(isHave){
if(data.activeTime && data.expireTime && data.activeTime >=data.expireTime){
message.error('失效时间要大于生效时间')
return;
}
}
if(data.activeTime==0)data.activeTime = null;
if(data.expireTime==0)data.expireTime = null;
//
@ -419,6 +413,19 @@ const formsSuccess = async (formType,data) => {
/** 详情操作 */
const detailRef = ref()
const openDetail = (row: any, titleName: any, titleValue: any) => {
if(row.type=='static'){
//
formRules.value = StaticMonomerRules
formAllSchemas.value = StaticMonomer.allSchemas
basicFormRef.value.updateFormAllSchemas(StaticMonomer.allSchemas)
}else{
//
formRules.value = DynamicMonomerRules
formAllSchemas.value = DynamicMonomer.allSchemas
basicFormRef.value.updateFormAllSchemas(DynamicMonomer.allSchemas)
}
detailRef.value.openDetail(row, titleName, titleValue, 'basicCellDevice')
}

277
src/views/battery/monomer/monomer.data.ts

@ -4,7 +4,6 @@ import { dateFormatter } from '@/utils/formatTime'
// 表单校验
export const MonomerRules = reactive({
})
export const Monomer = useCrudSchemas(reactive<CrudSchema[]>([
{
label: '数据类型',
@ -575,3 +574,279 @@ export const Monomer = useCrudSchemas(reactive<CrudSchema[]>([
}
}
]))
export const StaticMonomerRules = reactive({
type: [
{ required: true, message: '请选择数据类型', trigger: 'change' },
],
version: [
{ required: true, message: '请填写版本号', trigger: 'change' },
],
author: [
{ required: true, message: '请填写作者', trigger: 'change' },
],
name: [
{ required: true, message: '请填写产线名称', trigger: 'change' },
],
plineId: [
{ required: true, message: '请填写产线ID', trigger: 'change' },
],
ptype: [
{ required: true, message: '请填写产品型号', trigger: 'change' },
],
procImage: [
{ required: true, message: '请填写工艺流程图', trigger: 'change' },
],
procRemark: [
{ required: true, message: '请填写工艺流程说明', trigger: 'change' },
],
})
export const StaticMonomer = useCrudSchemas(reactive<CrudSchema[]>([
{
label: '数据类型',
field: 'type',
sort: 'custom',
isSearch: true,
// form: {
// component: 'InputNumber',
// value: 0
// },
dictType: DICT_TYPE.BATTERY_TYPE,
dictClass: 'string',
isTable: true,
form:{
value:'static',
componentProps:{
disabled:true
}
},
tableForm: {
type: 'Select'
}
},
{
label: '版本号',
field: 'version',
sort: 'custom',
isSearch: false,
},
{
label: '作者',
field: 'author',
sort: 'custom',
isSearch: true,
},
{
label: '产线名称',
field: 'name',
sort: 'custom',
isSearch: true,
},
{
label: '产线ID',
field: 'plineId',
sort: 'custom',
isSearch: true,
},
{
label: '产品型号',
field: 'ptype',
sort: 'custom',
isSearch: true,
},
{
label: '工艺流程图',
field: 'procImage',
sort: 'custom',
isSearch: false,
},
{
label: '工艺流程说明',
field: 'procRemark',
sort: 'custom',
isSearch: false,
},
{
label: '创建时间',
field: 'createTime',
sort: 'custom',
formatter: dateFormatter,
isSearch: true,
search: {
component: 'DatePicker',
componentProps: {
valueFormat: 'YYYY-MM-DD HH:mm:ss',
type: 'datetimerange',
defaultTime: [new Date('1 00:00:00'), new Date('1 23:59:59')]
}
},
isForm: false,
},
{
label: '操作',
field: 'action',
isForm: false,
table: {
width: 150,
fixed: 'right'
}
}
]))
export const DynamicMonomerRules = reactive({
type: [
{ required: true, message: '请选择数据类型', trigger: 'change' },
],
version: [
{ required: true, message: '请填写版本号', trigger: 'change' },
],
author: [
{ required: true, message: '请填写作者', trigger: 'change' },
],
timeStamp: [
{ required: true, message: '请选择数据报送时间', trigger: 'change' },
],
endTime: [
{ required: true, message: '请选择试验结束时间', trigger: 'change' },
],
workNo: [
{ required: true, message: '请填写工作控制号', trigger: 'change' },
],
plineId: [
{ required: true, message: '请填写产线ID', trigger: 'change' },
],
ptype: [
{ required: true, message: '请填写产品型号', trigger: 'change' },
],
testType: [
{ required: true, message: '请填写检测类型', trigger: 'change' },
],
workRemark: [
{ required: true, message: '请填写报检说明', trigger: 'change' },
],
})
export const DynamicMonomer = useCrudSchemas(reactive<CrudSchema[]>([
{
label: '数据类型',
field: 'type',
sort: 'custom',
isSearch: true,
// form: {
// component: 'InputNumber',
// value: 0
// },
dictType: DICT_TYPE.BATTERY_TYPE,
dictClass: 'string',
isTable: true,
form:{
value:'moving',
componentProps:{
disabled:true
}
},
tableForm: {
type: 'Select'
}
},
{
label: '版本号',
field: 'version',
sort: 'custom',
isSearch: false,
},
{
label: '作者',
field: 'author',
sort: 'custom',
isSearch: true,
},
{
label: '数据报送时间',
field: 'timeStamp',
sort: 'custom',
isSearch: false,
formatter: dateFormatter,
form: {
component: 'DatePicker',
componentProps: {
valueFormat: 'YYYY-MM-DD HH:mm:ss',
type: 'datetime',
}
},
},
{
label: '工作控制号',
field: 'workNo',
sort: 'custom',
isSearch: true,
},
{
label: '试验结束时间',
field: 'endTime',
sort: 'custom',
isSearch: false,
formatter: dateFormatter,
form: {
component: 'DatePicker',
componentProps: {
valueFormat: 'YYYY-MM-DD HH:mm:ss',
type: 'datetime',
}
},
},
{
label: '产线ID',
field: 'plineId',
sort: 'custom',
isSearch: true,
},
{
label: '产品型号',
field: 'ptype',
sort: 'custom',
isSearch: true,
},
{
label: '检测类型',
field: 'testType',
sort: 'custom',
isSearch: false,
},
{
label: '报检说明',
field: 'workRemark',
sort: 'custom',
isSearch: false,
},
{
label: '创建时间',
field: 'createTime',
sort: 'custom',
formatter: dateFormatter,
isSearch: true,
search: {
component: 'DatePicker',
componentProps: {
valueFormat: 'YYYY-MM-DD HH:mm:ss',
type: 'datetimerange',
defaultTime: [new Date('1 00:00:00'), new Date('1 23:59:59')]
}
},
isForm: false,
},
{
label: '操作',
field: 'action',
isForm: false,
table: {
width: 150,
fixed: 'right'
}
}
]))

Loading…
Cancel
Save