模版调整

This commit is contained in:
Jason 2022-08-12 18:54:09 +08:00
parent 3f092d3573
commit df39931b4b
2 changed files with 24 additions and 9 deletions

View File

@ -39,16 +39,24 @@
</template>
<script lang="ts" setup>
import type { FormInstance } from 'element-plus'
import { postEdit, postAdd } from '@/api/org/post'
import { postEdit, postAdd } from '@/api/org/post' //
import Popup from '@/components/popup/index.vue'
import feedback from '@/utils/feedback'
import type { PropType } from 'vue'
defineProps({
dictData: {
type: Object as PropType<Record<string, any[]>>,
default: () => ({})
}
})
const emit = defineEmits(['success', 'close'])
const formRef = shallowRef<FormInstance>()
const popupRef = shallowRef<InstanceType<typeof Popup>>()
const mode = ref('add')
const popupTitle = computed(() => {
return mode.value == 'edit' ? '编辑岗位' : '新增岗位'
return mode.value == 'edit' ? '编辑岗位' : '新增岗位' //
})
//
const formData = reactive({
id: '',
name: '',
@ -57,7 +65,7 @@ const formData = reactive({
remark: '',
isStop: 1
})
//
const formRules = {
code: [
{
@ -77,7 +85,7 @@ const formRules = {
const handleSubmit = async () => {
await formRef.value?.validate()
mode.value == 'edit' ? await postEdit(formData) : await postAdd(formData)
mode.value == 'edit' ? await postEdit(formData) : await postAdd(formData) //
popupRef.value?.close()
feedback.msgSuccess('操作成功')
emit('success')

View File

@ -65,11 +65,17 @@
<pagination v-model="pager" @change="getLists" />
</div>
</el-card>
<edit-popup v-if="showEdit" ref="editRef" @success="getLists" @close="showEdit = false" />
<edit-popup
v-if="showEdit"
ref="editRef"
:dict-data="dictData"
@success="getLists"
@close="showEdit = false"
/>
</div>
</template>
<script lang="ts" setup>
import { postDelete, postLists } from '@/api/org/post'
import { postDelete, postLists } from '@/api/org/post' //
import { useDictData } from '@/hooks/useDictOptions'
import { usePaging } from '@/hooks/usePaging'
import feedback from '@/utils/feedback'
@ -77,17 +83,18 @@ import EditPopup from './edit.vue'
const editRef = shallowRef<InstanceType<typeof EditPopup>>()
const showEdit = ref(false)
const queryParams = reactive({
//
code: '',
name: '',
isStop: ''
})
const { pager, getLists, resetPage, resetParams } = usePaging({
fetchFun: postLists,
fetchFun: postLists, //
params: queryParams
})
//
//
const { dictData } = useDictData<{
dict_sex: any[]
}>(['dict_sex'])
@ -106,7 +113,7 @@ const handleEdit = async (data: any) => {
}
const handleDelete = async (id: number) => {
await postDelete({ id })
await postDelete({ id }) // id
feedback.msgSuccess('删除成功')
getLists()
}