新增修改

main
zsk 2 years ago
parent af93703ec8
commit f416bd2955

2554
package-lock.json generated

File diff suppressed because it is too large Load Diff

@ -29,6 +29,14 @@ export function addUserApi (data) {
data
});
}
// 更新用户
export function updateUserApi (data) {
return request({
url: `/admin/user/update`,
method: "put",
data
});
}
// 删除用户
export function delUserApi (data) {
return request({

@ -8,8 +8,8 @@
</div>
</div>
<div>
<a-button type="primary" @click="showAdd = true" :icon="h(PlusOutlined)">导入用户</a-button>
<a-button type="" class="g_border_d g_ml_16" @click="handleToForm('add', { id: 0 })" :icon="h(DownloadOutlined)">导出模版</a-button>
<a-button type="primary" @click="openAdd" :icon="h(PlusOutlined)">导入用户</a-button>
<!-- <a-button type="" class="g_border_d g_ml_16" @click="handleToForm('add', { id: 0 })" :icon="h(DownloadOutlined)">导出模版</a-button> -->
<!--
<a-dropdown :trigger="['click']">
<template #overlay>
@ -31,7 +31,7 @@
<template v-if="column.key === 'job'">
<!-- @click="goDetail(record)" -->
<div class="btn g_fs_14 g_cursor_point g_mr_13 g_flex_row_start">
<div class="g_ell_1">{{ "斯琴高娃" }}</div>
<div class="g_ell_1">{{ "" }}</div>
</div>
</template>
<template v-if="column.key === 'age'">
@ -56,8 +56,8 @@
@click="handleApplication(record)"
>
报名
</div>
<div class="btn g_c_main g_fs_14 g_cursor_point g_mr_13" @click="handleToForm('edit', record)">编辑</div> -->
</div> -->
<div class="btn g_c_main g_fs_14 g_cursor_point g_mr_13" @click="handleToForm('edit', record)">编辑</div>
<div class="btn g_c_main g_fs_14 g_cursor_point" @click="handleDel(record)"></div>
</div>
</template>
@ -72,22 +72,79 @@
<a-pagination v-model:current="tableData.page" v-model:page-size="tableData.size" :total="tableData.total" :pageSize="tableData.size" :show-total="(total) => `${total}`" @change="handleModalPage" @showSizeChange="handleModalSize" :show-quick-jumper="tableData.total < tableData.size ? false : true" :showSizeChanger="tableData.total < tableData.size ? false : true" :hideOnSinglePage="false" />
</div>
</div>
<a-modal v-model:open="showAdd" title style="width: 734px" :destroyOnClose="true">
<a-form>
<a-form-item class="g_mb_58" :label-col="{ span: 8 }" name="contactAvatar" :rules="[{ required: false, message: '请选择' }]">
<template #label>
<div class="g_c_6" style="">联系人头像</div>
</template>
<div class="g_flex_row_start" style="min-width: 200px; align-items: end">
<img v-if="addInfo.contactAvatar" :src="addInfo.contactAvatar" class="g_w_60 g_h_60 g_br_6" alt="" />
<img v-else src="https://matripe-cms.oss-cn-beijing.aliyuncs.com/ibocai/defaultAvatar.png" class="g_w_60 g_h_60 g_br_6" alt="" />
<a-button class="g_position_rela g_ml_16">
<DownloadOutlined />更换
<idCardPanel class="g_position_abso img_upload" style :url="addInfo.contactAvatar" @submitEvent="updateAvatar" />
</a-button>
<!-- <a-modal v-model:open="modalInfo.isShow"
:title="modalInfo.title"
width="640px"
centered
:destroyOnClose="true"
:forceRender="true"
>
<div class="g_pt_30 modal-box">
<a-form :model="modalInfo.form"
name="basic"
:label-col="{ span: 6 }"
:wrapper-col="{ span: 18 }"
autocomplete="off"
style="width: 80%;"
class="g_ml_51"
>
<a-form-item label="职位要求标签" name="name" required>
<a-input style="width: 100%" placeholder="请输入职位要求标签" v-model:value="modalInfo.form.name" />
</a-form-item>
<a-form-item label="标签类型" name="typeClassify" required>
<a-select v-model:value="modalInfo.form.typeClassify"
:getPopupContainer="(triggerNode) => triggerNode.parentNode.parentNode"
placeholder="请选择职位分类"
@change="handleUpdateSelect"
>
<a-select-option v-for="item in typeClassifyList" :value="item.id" :title="item.id">{{ item.name }}</a-select-option>
</a-select>
</a-form-item>
<a-form-item label="说明" name="desp">
<a-textarea :rows='6' style="width: 100%" placeholder="请输入职位说明" v-model:value="modalInfo.form.desp" />
</a-form-item>
</a-form>
</div>
<template #footer>
<a-button @click="modalInfo.isShow = false">关闭</a-button>
<a-button @click="submitForm" type="primary">确定</a-button>
</template>
</a-modal> -->
<a-modal v-model:open="showAdd" :title="modalInfo.title" style="width: 734px" :destroyOnClose="true">
<div class="g_pt_30 modal-box">
<a-form :model="modalInfo.form"
name="basic"
:label-col="{ span: 6 }"
:wrapper-col="{ span: 18 }"
autocomplete="off"
style="width: 80%;"
class="g_ml_51"
>
<a-form-item label="姓名" name="name" required>
<a-input style="width: 100%" placeholder="请输入姓名" v-model:value="modalInfo.form.name" />
</a-form-item>
<a-form-item label="电话" name="name" required>
<a-input style="width: 100%" placeholder="请输入电话" v-model:value="modalInfo.form.username" />
</a-form-item>
<a-form-item label="身份证号" name="name">
<a-input style="width: 100%" placeholder="请输入身份证号" v-model:value="modalInfo.form.idcard" />
</a-form-item>
<a-form-item label="备注" name="desp">
<a-textarea :rows='6' style="width: 100%" placeholder="请输入备注" v-model:value="modalInfo.form.description" />
</a-form-item>
</a-form>
</div>
<template #footer>
<a-button @click="showAdd = false" >关闭</a-button>
<a-button @click="submitForm" type="primary">确定</a-button>
</template>
</a-modal>
</div>
</template>
@ -97,7 +154,7 @@ import { ref, onMounted, getCurrentInstance, h, watch } from "vue";
import { PlusOutlined, EllipsisOutlined, UploadOutlined, DownOutlined } from "@ant-design/icons-vue";
import { Modal, message } from "ant-design-vue";
import { useRouter, useRoute } from "vue-router";
import { getUserListApi, updateUserStatusApi, addUserApi, delUserApi } from "../../api/userList/userList";
import { getUserListApi, updateUserStatusApi, addUserApi, delUserApi,updateUserApi } from "../../api/userList/userList";
import { DownloadOutlined } from "@ant-design/icons-vue";
import idCardPanel from "../components/upload/image.vue";
@ -124,6 +181,101 @@ const handleChangeSearch = (e) => {
getTable();
}
};
const modalInfo = ref({
title:'新增用户',
id:0,
form:{
name:"",
username:'',
idcard:'',
description:''
}
})
const submitForm = ()=>{
let url = '',params = {};
params = {
name:modalInfo.value.form.name,
username:modalInfo.value.form.username,
idcard:modalInfo.value.form.idcard,
description:modalInfo.value.form.description,
password:'123456',
id:modalInfo.value.id
}
if (!commonJS.regular(modalInfo.value.form.username, 'tel')) {
message.warning('请输入正确的手机号')
return false
}
if(modalInfo.value.id){
updateUserApi(params).then((res)=>{
showAdd.value = false;
message.success("修改成功");
getTable();
});
}else{
addUserApi(params).then((res)=>{
showAdd.value = false;
message.success("新增成功");
getTable();
});
}
}
const handleToForm = ($type, $data) => {
showAdd.value = true;
console.log($data.id);
modalInfo.value = {
isShow:true,
title:'修改用户',
form:{
name:$data.name,
username:$data.username,
idcard:$data.idcard,
description:$data.description,
},
id:$data.id
}
// updateUserApi({
// description: "",
// idcard: "123123123123123123",
// name: "",
// username: "13214534564",
// password: 123456,
// status: 0,
// username: "",
// }).then(() => {
// message.success("");
// getTable();
// });
// if ($data.id > 0) {
// router.push({
// path: "/merchantManagement/jobForm",
// query: {
// id: $data.id ? $data.id : 0,
// type: $type,
// templateId: $data.templateId ? $data.templateId : 0,
// },
// });
// } else {
// router.push({
// path: "/merchantManagement/jobForm",
// query: {
// id: $data.id ? $data.id : 0,
// type: $type,
// },
// });
// }
};
/* #################### 表格事件 #################### */
const tableData = ref({
@ -148,6 +300,20 @@ const getTable = () => {
});
});
};
const openAdd = () =>{
showAdd.value = true
modalInfo.value.title = "新增用户"
modalInfo.value.id = 0;
modalInfo.value = {
form:{
name:"",
username:'',
idcard:'',
description:''
}
}
}
const columns = ref([
{
title: "序号",
@ -164,9 +330,9 @@ const columns = ref([
},
{
title: "电话(用户名)",
key: "phone",
dataIndex: "phone",
title: "电话",
key: "username",
dataIndex: "username",
ellipsis: true,
width: "140px",
},
@ -194,7 +360,7 @@ const columns = ref([
title: "操作",
key: "state",
dataIndex: "state",
width: "60px",
width: "90px",
ellipsis: true,
},
]);
@ -208,26 +374,7 @@ const handleStatus = (e, $data) => {
});
};
const addInfo = ref({});
/**
* 新增用户
*/
const addUser = (e, $data) => {
addUserApi({
description: "测试备注",
idcard: "123123123123123123",
name: "测试真名",
phone: "13214534564",
password: 123456,
status: 0,
username: "测试用户名",
}).then(() => {
message.success("新增成功");
getTable();
});
};
const updateAvatar = (e)=>{
console.log(e);
}
const goDetail = ($item) => {
console.log($item);
//
@ -269,33 +416,11 @@ const handleApplication = (record) => {
});
};
const handleToForm = ($type, $data) => {
if ($data.id > 0) {
// if ($data.jobType == 1) {
// return false;
// }
router.push({
path: "/merchantManagement/jobForm",
query: {
id: $data.id ? $data.id : 0,
type: $type,
templateId: $data.templateId ? $data.templateId : 0,
},
});
} else {
router.push({
path: "/merchantManagement/jobForm",
query: {
id: $data.id ? $data.id : 0,
type: $type,
},
});
}
};
const handleDel = ($data) => {
commonJS.gConfirmModal(
"删除",
"确认删除该职位吗?",
"确认删除该用户吗?",
() => {
delUserApi($data.id).then(() => {
message.success("删除成功");

Loading…
Cancel
Save