|  |  |  | 
|---|
|  |  |  | <template> | 
|---|
|  |  |  | <LoadingLayout :loading="state.loading"> | 
|---|
|  |  |  | <AppContainer> | 
|---|
|  |  |  | <ProTableQueryFilterBar @on-reset="reset"> | 
|---|
|  |  |  | <ProTableQueryFilterBar @on-reset="handleReset"> | 
|---|
|  |  |  | <template #query> | 
|---|
|  |  |  | <QueryFilterItem> | 
|---|
|  |  |  | <FieldSelect | 
|---|
|  |  |  | 
|---|
|  |  |  | :inactive-value="true" | 
|---|
|  |  |  | :before-change="() => setCategoryVis(row)" | 
|---|
|  |  |  | /> | 
|---|
|  |  |  | </template> | 
|---|
|  |  |  | <template #category="{ row }"> | 
|---|
|  |  |  | {{ row.category?.name }} | 
|---|
|  |  |  | </template> | 
|---|
|  |  |  | </ProTableV2> | 
|---|
|  |  |  | </AppContainer> | 
|---|
|  |  |  | 
|---|
|  |  |  | sort: row.sort, | 
|---|
|  |  |  | isDisabled: row.isDisabled, | 
|---|
|  |  |  | field1: row.field1, | 
|---|
|  |  |  | field3: row.field3, | 
|---|
|  |  |  | field2: convertApi2FormUrlOnlyOne(row.field2), | 
|---|
|  |  |  | field4: row.field4, | 
|---|
|  |  |  | }); | 
|---|
|  |  |  | } else { | 
|---|
|  |  |  | handleAdd({ | 
|---|
|  |  |  | 
|---|
|  |  |  | isDisabled: false, | 
|---|
|  |  |  | field1: '', | 
|---|
|  |  |  | field2: [] as UploadUserFile[], | 
|---|
|  |  |  | field3: '', | 
|---|
|  |  |  | field4: '', | 
|---|
|  |  |  | title: '新增字典', | 
|---|
|  |  |  | }, | 
|---|
|  |  |  | editTitle: '编辑字典', | 
|---|
|  |  |  | }); | 
|---|
|  |  |  |  | 
|---|
|  |  |  | async function handleAddOrEdit() { | 
|---|
|  |  |  | 
|---|
|  |  |  | isDisabled: editForm.isDisabled, | 
|---|
|  |  |  | field1: editForm.field1, | 
|---|
|  |  |  | field2: editForm.field2?.[0]?.path ?? '', | 
|---|
|  |  |  | field3: editForm.field3, | 
|---|
|  |  |  | field4: editForm.field4, | 
|---|
|  |  |  | }; | 
|---|
|  |  |  | if (editForm.id) { | 
|---|
|  |  |  | params.id = editForm.id; | 
|---|
|  |  |  | 
|---|
|  |  |  | let res = await dictionaryServices.saveDictionaryData(params); | 
|---|
|  |  |  | if (res) { | 
|---|
|  |  |  | Message.successMessage('操作成功'); | 
|---|
|  |  |  | updateDictionaryDataSelect(); | 
|---|
|  |  |  | updateDictionaryDataSelect(editForm.categoryId); | 
|---|
|  |  |  | getList(paginationState.pageIndex); | 
|---|
|  |  |  | dialogState.dialogVisible = false; | 
|---|
|  |  |  | } | 
|---|
|  |  |  | 
|---|
|  |  |  | isDisabled: !row.isDisabled, | 
|---|
|  |  |  | }; | 
|---|
|  |  |  | let res = await dictionaryServices.setDictionaryDataIsDisabled(params); | 
|---|
|  |  |  | updateDictionaryDataSelect(row.categoryId); | 
|---|
|  |  |  | getList(paginationState.pageIndex); | 
|---|
|  |  |  | return !!res; | 
|---|
|  |  |  | } catch (error) {} | 
|---|
|  |  |  | } | 
|---|
|  |  |  |  | 
|---|
|  |  |  | async function handleReset() { | 
|---|
|  |  |  | try { | 
|---|
|  |  |  | const dictionaryCategoryList = await ensureQueryData(); | 
|---|
|  |  |  | reset({ categoryId: dictionaryCategoryList[0].value }); | 
|---|
|  |  |  | } catch (error) {} | 
|---|
|  |  |  | } | 
|---|
|  |  |  | </script> | 
|---|