Browse Source

表单联动问题

master
zhang_li 10 months ago
parent
commit
f9c84609e1
  1. 69
      src/components/BasicForm/src/BasicForm.vue
  2. 11
      src/components/Form/src/Form.vue
  3. 15
      src/views/eam/device/deviceMaintenanceMain/deviceMaintenanceMain.data.ts
  4. 11
      src/views/eam/device/deviceMaintenanceMain/index.vue

69
src/components/BasicForm/src/BasicForm.vue

@ -14,6 +14,7 @@
:schema="formSchema"
:is-col="true"
@opensearchTable="opensearchTable"
@onChange="onChange"
>
<template #crontab="formSchema" v-if="fromeWhere == 'countPlan'">
<crontab v-model="formSchema.crontab" />
@ -82,6 +83,8 @@
@handleTableSelect="handleTableSelect"
@inpuFocus="inpuFocus"
@buttonOperationClick="buttonOperationClick"
@inputStringBlur="inputStringBlur"
@inputNumberChange="inputNumberChange"
/>
</div>
<div v-if="isBusiness && formType == 'create' && fromeWhere == 'countPlan'">
@ -281,30 +284,39 @@ const opensearchTable = (
if (searchCondition && searchCondition.length > 0) {
//
let filters: any[] = []
searchCondition.forEach((item) => {
for (var i=0; i< searchCondition.length; i++ ) {
// searchCondition.forEach((item) => {
// row
// 20231127 row[item.value]?row[item.value] row?row[item.value] 'null'
if (item.isMainValue) {
_searchCondition[item.key] = formRef.value.formModel[item.value]
? formRef.value.formModel[item.value]
if (searchCondition[i].isMainValue) {
_searchCondition[searchCondition[i].key] = formRef.value.formModel[searchCondition[i].value]
? formRef.value.formModel[searchCondition[i].value]
: props.detailData
? props.detailData[item.value]
? props.detailData[searchCondition[i].value]
: row
? row[item.value]
: 'null'
? row[searchCondition[i].value]
: ''
//
let isNull = false
if (_searchCondition[searchCondition[i].key] == '' || _searchCondition[searchCondition[i].key] == undefined) {
isNull = true
}
if (isNull) {
message.warning(searchCondition[i].message?searchCondition[i].message:'前置条件未选择!')
return
}
} else {
//
if (item.isSearch) {
if (searchCondition[i].isSearch) {
filters.push({
action: item.action,
column: item.key,
value: item.value
action: searchCondition[i].action,
column: searchCondition[i].key,
value: searchCondition[i].value
})
} else {
_searchCondition[item.key] = item.value
_searchCondition[searchCondition[i].key] = searchCondition[i].value
}
}
}
})
if (filters.length > 0) {
_searchCondition.isSearch = true
_searchCondition.filters = filters
@ -333,17 +345,12 @@ const searchTableSuccess = (formField, searchField, val, type, row) => {
/** 打开弹窗 */
const open = async (type: string, row?: any, masterParmas?: any) => {
console.log(2222)
dialogVisible.value = true
console.log(333)
dialogTitle.value = t('action.' + type)
console.log(444)
formType.value = type
console.log(66)
resetForm()
//
// masterIdnumber
console.log(77)
if (masterParmas) {
if (!row) {
row = {
@ -352,10 +359,8 @@ const open = async (type: string, row?: any, masterParmas?: any) => {
}
}
}
console.log(8)
if (row?.id || row?.masterId) {
formLoading.value = true
console.log(99)
try {
nextTick(() => {
formRef.value.setValues(row)
@ -460,7 +465,10 @@ const emit = defineEmits([
'selectChange',
'selectChangeDetail',
'tableFormChange',
'buttonOperationClick'
'buttonOperationClick',
'inputStringBlur',
'onChange',
'inputNumberChange'
])
//
const formSelectChange = (field, val, row) => {
@ -477,6 +485,11 @@ const tableSelectionChange = (val) => {
const tableSortChange = (column, prop, order) => {
emit('tableSortChange', column, prop, order)
}
// -
const inputNumberChange = (field, index, row, val) => {
emit('inputNumberChange', field, index, row, val)
}
//
// const showSelect = (val, statusID) => {
// return getDictForStatusID(val, statusID)
@ -509,6 +522,14 @@ const inpuFocus = (headerItem, row, index) => {
row
)
}
/**
* 监听改变事件
* @param field 当前操作字段
* @param cur 改变后值
*/
const onChange = (field, cur) => {
emit('onChange', field, cur)
}
//
const selectChange = (field, val) => {
@ -529,6 +550,10 @@ const buttonOperationClick = (row, label, index)=> {
emit("buttonOperationClick", row, label, index);
}
const inputStringBlur = (headerItem, row, index)=> {
emit("inputStringBlur", headerItem, row, index);
}
</script>
<style lang="scss" scoped>
.table {

11
src/components/Form/src/Form.vue

@ -54,7 +54,7 @@ export default defineComponent({
vLoading: propTypes.bool.def(false),
labelPosition: propTypes.string.def('left'),
},
emits: ['register','opensearchTable'],
emits: ['register','opensearchTable', 'onChange'],
setup(props, { slots, expose, emit }) {
// element form
const elFormRef = ref<ComponentRef<typeof ElForm>>()
@ -180,6 +180,14 @@ export default defineComponent({
})
}
/**
* 监听改变事件
* @param field 当前操作字段
* @param cur 改变后值
*/
const onChange = (field, cur) => {
emit('onChange', field, cur)
}
// formItem
const renderFormItem = (item: FormSchema) => {
// options
@ -282,6 +290,7 @@ export default defineComponent({
{...(autoSetPlaceholder && setTextPlaceholder(item))}
{...setComponentProps(item)}
style={item.componentProps?.style}
onChange={(e)=>{onChange(item.field, e)}}
{...(notRenderOptions.includes(item?.component as string) &&
item?.componentProps?.options
? { options: item?.componentProps?.options || [] }

15
src/views/eam/device/deviceMaintenanceMain/deviceMaintenanceMain.data.ts

@ -64,12 +64,12 @@ export const DeviceMaintenanceMain = useCrudSchemas(reactive<CrudSchema[]>([
labelField: 'name',
valueField: 'number'
},
onChange: (val) => {
factoryValue.value = Number(deviceList.find((account) => account.number == val)?.factoryAreaNumber)
showFactory.value = true
console.log('factoryValue.value',factoryValue.value)
console.log('showFactory.value',showFactory.value)
}
// onChange: (val) => {
// factoryValue.value = Number(deviceList.find((account) => account.number == val)?.factoryAreaNumber)
// showFactory.value = true
// console.log('factoryValue.value',factoryValue.value)
// console.log('showFactory.value',showFactory.value)
// }
},
}
},
@ -94,10 +94,9 @@ export const DeviceMaintenanceMain = useCrudSchemas(reactive<CrudSchema[]>([
},
form: {
component: 'Select',
show: showFactory.value,
value: factoryValue.value,
api: () => factoryList,
componentProps: {
disabled:false,
optionsAlias: {
labelField: 'name',
valueField: 'id'

11
src/views/eam/device/deviceMaintenanceMain/index.vue

@ -48,6 +48,7 @@
:apiCreate="DeviceMaintenanceMainApi.createDeviceMaintenanceMain"
@searchTableSuccess="searchTableSuccess"
:isBusiness="false"
@onChange="onChange"
/>
<!-- 详情 -->
@ -147,7 +148,15 @@ const butttondata = (row) => {
defaultButtons.verifyOrderBtn({ hide: !(row.status == 'COMPLETED')}), //
]
}
const onChange = (field, cur) => {
//
console.log(field)
console.log(cur)
if(field == 'deviceNumber'){
// DeviceMaintenanceMain.allSchemas.formSchema[1].componentProps.disabled = true
basicFormRef.value.formRef.formModel.factoryAreaNumber=119
}
}
// -
const buttonTableClick = async (val, row) => {
if (val == 'edit') { //

Loading…
Cancel
Save