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

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

@ -54,7 +54,7 @@ export default defineComponent({
vLoading: propTypes.bool.def(false), vLoading: propTypes.bool.def(false),
labelPosition: propTypes.string.def('left'), labelPosition: propTypes.string.def('left'),
}, },
emits: ['register','opensearchTable'], emits: ['register','opensearchTable', 'onChange'],
setup(props, { slots, expose, emit }) { setup(props, { slots, expose, emit }) {
// element form // element form
const elFormRef = ref<ComponentRef<typeof ElForm>>() 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 // formItem
const renderFormItem = (item: FormSchema) => { const renderFormItem = (item: FormSchema) => {
// options // options
@ -282,6 +290,7 @@ export default defineComponent({
{...(autoSetPlaceholder && setTextPlaceholder(item))} {...(autoSetPlaceholder && setTextPlaceholder(item))}
{...setComponentProps(item)} {...setComponentProps(item)}
style={item.componentProps?.style} style={item.componentProps?.style}
onChange={(e)=>{onChange(item.field, e)}}
{...(notRenderOptions.includes(item?.component as string) && {...(notRenderOptions.includes(item?.component as string) &&
item?.componentProps?.options item?.componentProps?.options
? { options: 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', labelField: 'name',
valueField: 'number' valueField: 'number'
}, },
onChange: (val) => { // onChange: (val) => {
factoryValue.value = Number(deviceList.find((account) => account.number == val)?.factoryAreaNumber) // factoryValue.value = Number(deviceList.find((account) => account.number == val)?.factoryAreaNumber)
showFactory.value = true // showFactory.value = true
console.log('factoryValue.value',factoryValue.value) // console.log('factoryValue.value',factoryValue.value)
console.log('showFactory.value',showFactory.value) // console.log('showFactory.value',showFactory.value)
} // }
}, },
} }
}, },
@ -94,10 +94,9 @@ export const DeviceMaintenanceMain = useCrudSchemas(reactive<CrudSchema[]>([
}, },
form: { form: {
component: 'Select', component: 'Select',
show: showFactory.value,
value: factoryValue.value,
api: () => factoryList, api: () => factoryList,
componentProps: { componentProps: {
disabled:false,
optionsAlias: { optionsAlias: {
labelField: 'name', labelField: 'name',
valueField: 'id' valueField: 'id'

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

@ -48,6 +48,7 @@
:apiCreate="DeviceMaintenanceMainApi.createDeviceMaintenanceMain" :apiCreate="DeviceMaintenanceMainApi.createDeviceMaintenanceMain"
@searchTableSuccess="searchTableSuccess" @searchTableSuccess="searchTableSuccess"
:isBusiness="false" :isBusiness="false"
@onChange="onChange"
/> />
<!-- 详情 --> <!-- 详情 -->
@ -147,7 +148,15 @@ const butttondata = (row) => {
defaultButtons.verifyOrderBtn({ hide: !(row.status == 'COMPLETED')}), // 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) => { const buttonTableClick = async (val, row) => {
if (val == 'edit') { // if (val == 'edit') { //

Loading…
Cancel
Save