generated from Leo_Ding/web-template
Merge branch 'master' of https://gitlab.guxuan.icu/Leo_Ding/Hai_Lin_admin
This commit is contained in:
commit
e294c1dd53
@ -152,10 +152,10 @@ function handleCreate() {
|
|||||||
formData.value.status = 'enabled'
|
formData.value.status = 'enabled'
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
//新建基地
|
//新建基地
|
||||||
|
|
||||||
const childHandleOk = async () => {
|
const childHandleOk = async () => {
|
||||||
|
|
||||||
areaFormRef.value.validateFields().then(async (values) => {
|
areaFormRef.value.validateFields().then(async (values) => {
|
||||||
try {
|
try {
|
||||||
const params = { ...formArea.value }
|
const params = { ...formArea.value }
|
||||||
@ -174,6 +174,7 @@ const childHandleOk = async () => {
|
|||||||
* 编辑
|
* 编辑
|
||||||
*/
|
*/
|
||||||
async function handleEdit(record = {}) {
|
async function handleEdit(record = {}) {
|
||||||
|
initData()
|
||||||
showModal({
|
showModal({
|
||||||
type: 'edit',
|
type: 'edit',
|
||||||
title: t('pages.system.user.edit'),
|
title: t('pages.system.user.edit'),
|
||||||
|
|||||||
@ -82,6 +82,55 @@
|
|||||||
</a-row>
|
</a-row>
|
||||||
|
|
||||||
<edit-dialog ref="editDialogRef" @ok="onOk"></edit-dialog>
|
<edit-dialog ref="editDialogRef" @ok="onOk"></edit-dialog>
|
||||||
|
|
||||||
|
<a-modal v-model:visible="showEditModal" title="编辑区域" @ok="submitEdit" @cancel="showEditModal = false">
|
||||||
|
<a-form :model="editFormData">
|
||||||
|
<a-form-item label="选择区域">
|
||||||
|
<a-select v-model:value="currentAreaId" @change="onAreaChange" placeholder="请选择区域">
|
||||||
|
<a-select-option v-for="item in areaList" :key="item.id" :value="item.id">
|
||||||
|
{{ item.name }}
|
||||||
|
</a-select-option>
|
||||||
|
</a-select>
|
||||||
|
</a-form-item>
|
||||||
|
|
||||||
|
<a-form-item label="名称">
|
||||||
|
<a-input v-model:value="editFormData.name" />
|
||||||
|
</a-form-item>
|
||||||
|
|
||||||
|
<a-form-item label="序号">
|
||||||
|
<a-input-number v-model:value="editFormData.sequence" />
|
||||||
|
</a-form-item>
|
||||||
|
|
||||||
|
<a-form-item label="状态">
|
||||||
|
<a-select v-model:value="editFormData.status">
|
||||||
|
<a-select-option value="enabled">启用</a-select-option>
|
||||||
|
<a-select-option value="disabled">禁用</a-select-option>
|
||||||
|
</a-select>
|
||||||
|
</a-form-item>
|
||||||
|
</a-form>
|
||||||
|
</a-modal>
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
<!-- <a-modal v-model:visible="showEditModal" title="编辑区域" @ok="submitEdit" @cancel="showEditModal = false">-->
|
||||||
|
<!-- <a-form :model="editFormData">-->
|
||||||
|
<!-- <a-form-item label="名称">-->
|
||||||
|
<!-- <a-input v-model:value="editFormData.name" />-->
|
||||||
|
<!-- </a-form-item>-->
|
||||||
|
<!-- <a-form-item label="序号">-->
|
||||||
|
<!-- <a-input-number v-model:value="editFormData.sequence" />-->
|
||||||
|
<!-- </a-form-item>-->
|
||||||
|
<!-- <a-form-item label="状态">-->
|
||||||
|
<!-- <a-select v-model:value="editFormData.status">-->
|
||||||
|
<!-- <a-select-option value="enabled">启用</a-select-option>-->
|
||||||
|
<!-- <a-select-option value="disabled">禁用</a-select-option>-->
|
||||||
|
<!-- </a-select>-->
|
||||||
|
<!-- </a-form-item>-->
|
||||||
|
<!-- </a-form>-->
|
||||||
|
<!-- </a-modal>-->
|
||||||
|
|
||||||
|
|
||||||
</template>
|
</template>
|
||||||
|
|
||||||
<script setup>
|
<script setup>
|
||||||
@ -111,6 +160,15 @@ const columns = [
|
|||||||
{ title: t('button.action'), key: 'action', fixed: 'right', width: 100, align: 'center' },
|
{ title: t('button.action'), key: 'action', fixed: 'right', width: 100, align: 'center' },
|
||||||
]
|
]
|
||||||
|
|
||||||
|
const areaList = ref([]); // 列表数据
|
||||||
|
const showEditModal = ref(false);
|
||||||
|
const editFormData = ref({
|
||||||
|
name: '',
|
||||||
|
sequence: 0,
|
||||||
|
status: 'disabled',
|
||||||
|
});
|
||||||
|
const currentAreaId = ref(null);
|
||||||
|
|
||||||
const { listData, loading, showLoading, hideLoading, paginationState, resetPagination, searchFormData } =
|
const { listData, loading, showLoading, hideLoading, paginationState, resetPagination, searchFormData } =
|
||||||
usePagination()
|
usePagination()
|
||||||
|
|
||||||
@ -205,14 +263,65 @@ async function onOk() {
|
|||||||
/**
|
/**
|
||||||
* 编辑基地
|
* 编辑基地
|
||||||
*/
|
*/
|
||||||
function handleCreateJD() {
|
async function handleCreateJD() {
|
||||||
showModal({
|
console.log('createJD');
|
||||||
type: 'edit',
|
try {
|
||||||
title: '编辑地基',
|
showLoading();
|
||||||
|
const { pageSize, current } = paginationState;
|
||||||
|
const { success, data, total } = await apis.recruitment
|
||||||
|
.getAreasList({
|
||||||
|
pageSize,
|
||||||
|
current: current,
|
||||||
|
...searchFormData.value,
|
||||||
})
|
})
|
||||||
initData()
|
.catch(() => {
|
||||||
formData.value.status = 'enabled'
|
throw new Error();
|
||||||
|
});
|
||||||
|
hideLoading();
|
||||||
|
if (config('http.code.success') === success) {
|
||||||
|
areaList.value = data;
|
||||||
|
console.log(areaList.value);
|
||||||
|
openEditModal(data[0] || { name: '', sequence: 0, status: 'enabled' });
|
||||||
|
paginationState.total = total;
|
||||||
}
|
}
|
||||||
|
} catch (error) {
|
||||||
|
hideLoading();
|
||||||
|
console.error('Error in handleCreateJD:', error?.message || error);
|
||||||
|
|
||||||
|
}
|
||||||
|
}
|
||||||
|
function openEditModal(areaItem) {
|
||||||
|
editFormData.value = { ...areaItem };
|
||||||
|
currentAreaId.value = areaItem.id;
|
||||||
|
showEditModal.value = true;
|
||||||
|
}
|
||||||
|
|
||||||
|
function onAreaChange(id) {
|
||||||
|
const target = areaList.value.find(item => item.id === id);
|
||||||
|
if (target) {
|
||||||
|
editFormData.value = { ...target };
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
async function submitEdit() {
|
||||||
|
try {
|
||||||
|
showLoading();
|
||||||
|
const res = await apis.recruitment.updateArea(editFormData.value);
|
||||||
|
hideLoading();
|
||||||
|
if (config('http.code.success') === res.success) {
|
||||||
|
ElMessage.success('修改成功');
|
||||||
|
showEditModal.value = false;
|
||||||
|
handleCreateJD(); // 重新刷新列表
|
||||||
|
} else {
|
||||||
|
ElMessage.error('修改失败');
|
||||||
|
}
|
||||||
|
} catch (error) {
|
||||||
|
hideLoading();
|
||||||
|
console.error('Error in submitEdit:', error);
|
||||||
|
ElMessage.error('请求异常');
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
</script>
|
</script>
|
||||||
|
|
||||||
<style lang="less" scoped></style>
|
<style lang="less" scoped></style>
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user