模版调整
This commit is contained in:
parent
3f092d3573
commit
df39931b4b
|
|
@ -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')
|
||||
|
|
|
|||
|
|
@ -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()
|
||||
}
|
||||
|
|
|
|||
Loading…
Reference in New Issue