模版调整
This commit is contained in:
parent
3f092d3573
commit
df39931b4b
|
|
@ -39,16 +39,24 @@
|
||||||
</template>
|
</template>
|
||||||
<script lang="ts" setup>
|
<script lang="ts" setup>
|
||||||
import type { FormInstance } from 'element-plus'
|
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 Popup from '@/components/popup/index.vue'
|
||||||
import feedback from '@/utils/feedback'
|
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 emit = defineEmits(['success', 'close'])
|
||||||
const formRef = shallowRef<FormInstance>()
|
const formRef = shallowRef<FormInstance>()
|
||||||
const popupRef = shallowRef<InstanceType<typeof Popup>>()
|
const popupRef = shallowRef<InstanceType<typeof Popup>>()
|
||||||
const mode = ref('add')
|
const mode = ref('add')
|
||||||
const popupTitle = computed(() => {
|
const popupTitle = computed(() => {
|
||||||
return mode.value == 'edit' ? '编辑岗位' : '新增岗位'
|
return mode.value == 'edit' ? '编辑岗位' : '新增岗位' //要替换
|
||||||
})
|
})
|
||||||
|
//要替换
|
||||||
const formData = reactive({
|
const formData = reactive({
|
||||||
id: '',
|
id: '',
|
||||||
name: '',
|
name: '',
|
||||||
|
|
@ -57,7 +65,7 @@ const formData = reactive({
|
||||||
remark: '',
|
remark: '',
|
||||||
isStop: 1
|
isStop: 1
|
||||||
})
|
})
|
||||||
|
//要替换 ,输入类的请输入,选择类的请选择
|
||||||
const formRules = {
|
const formRules = {
|
||||||
code: [
|
code: [
|
||||||
{
|
{
|
||||||
|
|
@ -77,7 +85,7 @@ const formRules = {
|
||||||
|
|
||||||
const handleSubmit = async () => {
|
const handleSubmit = async () => {
|
||||||
await formRef.value?.validate()
|
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()
|
popupRef.value?.close()
|
||||||
feedback.msgSuccess('操作成功')
|
feedback.msgSuccess('操作成功')
|
||||||
emit('success')
|
emit('success')
|
||||||
|
|
|
||||||
|
|
@ -65,11 +65,17 @@
|
||||||
<pagination v-model="pager" @change="getLists" />
|
<pagination v-model="pager" @change="getLists" />
|
||||||
</div>
|
</div>
|
||||||
</el-card>
|
</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>
|
</div>
|
||||||
</template>
|
</template>
|
||||||
<script lang="ts" setup>
|
<script lang="ts" setup>
|
||||||
import { postDelete, postLists } from '@/api/org/post'
|
import { postDelete, postLists } from '@/api/org/post' //接口要替换
|
||||||
import { useDictData } from '@/hooks/useDictOptions'
|
import { useDictData } from '@/hooks/useDictOptions'
|
||||||
import { usePaging } from '@/hooks/usePaging'
|
import { usePaging } from '@/hooks/usePaging'
|
||||||
import feedback from '@/utils/feedback'
|
import feedback from '@/utils/feedback'
|
||||||
|
|
@ -77,17 +83,18 @@ import EditPopup from './edit.vue'
|
||||||
const editRef = shallowRef<InstanceType<typeof EditPopup>>()
|
const editRef = shallowRef<InstanceType<typeof EditPopup>>()
|
||||||
const showEdit = ref(false)
|
const showEdit = ref(false)
|
||||||
const queryParams = reactive({
|
const queryParams = reactive({
|
||||||
|
//需要替换
|
||||||
code: '',
|
code: '',
|
||||||
name: '',
|
name: '',
|
||||||
isStop: ''
|
isStop: ''
|
||||||
})
|
})
|
||||||
|
|
||||||
const { pager, getLists, resetPage, resetParams } = usePaging({
|
const { pager, getLists, resetPage, resetParams } = usePaging({
|
||||||
fetchFun: postLists,
|
fetchFun: postLists, //接口名要替换
|
||||||
params: queryParams
|
params: queryParams
|
||||||
})
|
})
|
||||||
|
|
||||||
// 获取字典类型数据
|
// 获取字典类型数据,需要替换
|
||||||
const { dictData } = useDictData<{
|
const { dictData } = useDictData<{
|
||||||
dict_sex: any[]
|
dict_sex: any[]
|
||||||
}>(['dict_sex'])
|
}>(['dict_sex'])
|
||||||
|
|
@ -106,7 +113,7 @@ const handleEdit = async (data: any) => {
|
||||||
}
|
}
|
||||||
|
|
||||||
const handleDelete = async (id: number) => {
|
const handleDelete = async (id: number) => {
|
||||||
await postDelete({ id })
|
await postDelete({ id }) // id为主键,需要替换
|
||||||
feedback.msgSuccess('删除成功')
|
feedback.msgSuccess('删除成功')
|
||||||
getLists()
|
getLists()
|
||||||
}
|
}
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue