This commit is contained in:
shengchanzhe 2023-07-17 00:09:27 +08:00
parent 1f80c08c4f
commit 1b8b4ece88
5 changed files with 1060 additions and 305 deletions

View File

@ -1,224 +0,0 @@
<template>
<div class="edit-popup">
<popup
ref="popupRef"
:title="popupTitle"
:async="true"
width="550px"
@confirm="handleSubmit"
@close="handleClose"
>
<el-form ref="formRef" :model="formData" label-width="90px" :rules="formRules">
<el-form-item label="上上级公司" prop="level_two">
<el-input v-model="formData.level_two" clearable placeholder="请输入上上级公司" />
</el-form-item>
<el-form-item label="上级公司" prop="level_one">
<el-input v-model="formData.level_one" clearable placeholder="请输入上级公司" />
</el-form-item>
<el-form-item label="公司名称" prop="company_name">
<el-input v-model="formData.company_name" clearable placeholder="请输入公司名称" />
</el-form-item>
<el-form-item label="组织机构代码" prop="organization_code">
<el-input v-model="formData.organization_code" clearable placeholder="请输入组织机构代码" />
</el-form-item>
<el-form-item label="市" prop="city">
<el-input v-model="formData.city" clearable placeholder="请输入市" />
</el-form-item>
<el-form-item label="区" prop="area">
<el-input v-model="formData.area" clearable placeholder="请输入区" />
</el-form-item>
<el-form-item label="镇" prop="street">
<el-input v-model="formData.street" clearable placeholder="请输入镇" />
</el-form-item>
<el-form-item label="公司类型" prop="company_type">
<el-input v-model="formData.company_type" clearable placeholder="请输入公司类型" />
</el-form-item>
<el-form-item label="主联系人姓名" prop="master_name">
<el-input v-model="formData.master_name" clearable placeholder="请输入主联系人姓名" />
</el-form-item>
<el-form-item label="主联系人职务" prop="master_position">
<el-input v-model="formData.master_position" clearable placeholder="请输入主联系人职务" />
</el-form-item>
<el-form-item label="主联系人手机" prop="master_phone">
<el-input v-model="formData.master_phone" clearable placeholder="请输入主联系人手机" />
</el-form-item>
<el-form-item label="主联系人邮箱" prop="master_email">
<el-input v-model="formData.master_email" clearable placeholder="请输入主联系人邮箱" />
</el-form-item>
<el-form-item label="其他联系人" prop="other_contacts">
<el-input v-model="formData.other_contacts" clearable placeholder="请输入其他联系人" />
</el-form-item>
<el-form-item label="片区经理" prop="area_manager">
<el-input v-model="formData.area_manager" clearable placeholder="请输入片区经理" />
</el-form-item>
<el-form-item label="是否签约" prop="is_contract">
<el-input v-model="formData.is_contract" clearable placeholder="请输入是否签约" />
</el-form-item>
<el-form-item label="账号" prop="account">
<el-input v-model="formData.account" clearable placeholder="请输入账号" />
</el-form-item>
<el-form-item label="密码" prop="password">
<el-input v-model="formData.password" clearable placeholder="请输入密码" />
</el-form-item>
<el-form-item label="预存金" prop="deposit">
<el-input v-model="formData.deposit" clearable placeholder="请输入预存金" />
</el-form-item>
<el-form-item label="预存时间" prop="deposit_time">
<el-input v-model="formData.deposit_time" clearable placeholder="请输入预存时间" />
</el-form-item>
<el-form-item label="资质信息" prop="qualification">
<el-input v-model="formData.qualification" clearable placeholder="请输入资质信息" />
</el-form-item>
<el-form-item label="状态" prop="status">
<el-input v-model="formData.status" clearable placeholder="请输入状态" />
</el-form-item>
</el-form>
</popup>
</div>
</template>
<script lang="ts" setup name="companyEdit">
import type { FormInstance } from 'element-plus'
import Popup from '@/components/popup/index.vue'
import { apiCompanyAdd, apiCompanyEdit, apiCompanyDetail } from '@/api/company'
import { timeFormat } from '@/utils/util'
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' ? '编辑公司' : '新增公司'
})
//
const formData = reactive({
id: '',
level_two: '',
level_one: '',
company_name: '',
organization_code: '',
city: '',
area: '',
street: '',
company_type: '',
master_name: '',
master_position: '',
master_phone: '',
master_email: '',
other_contacts: '',
area_manager: '',
is_contract: '',
account: '',
password: '',
deposit: '',
deposit_time: '',
qualification: '',
status: '',
})
//
const formRules = reactive<any>({
company_name: [{
required: true,
message: '请输入公司名称',
trigger: ['blur']
}],
organization_code: [{
required: true,
message: '请输入组织机构代码',
trigger: ['blur']
}],
master_name: [{
required: true,
message: '请输入主联系人姓名',
trigger: ['blur']
}],
master_position: [{
required: true,
message: '请输入主联系人职务',
trigger: ['blur']
}],
master_phone: [{
required: true,
message: '请输入主联系人手机',
trigger: ['blur']
}],
master_email: [{
required: true,
message: '请输入主联系人邮箱',
trigger: ['blur']
}],
account: [{
required: true,
message: '请输入账号',
trigger: ['blur']
}],
password: [{
required: true,
message: '请输入密码',
trigger: ['blur']
}]
})
//
const setFormData = async (data: Record<any, any>) => {
for (const key in formData) {
if (data[key] != null && data[key] != undefined) {
//@ts-ignore
formData[key] = data[key]
}
}
}
const getDetail = async (row: Record<string, any>) => {
const data = await apiCompanyDetail({
id: row.id
})
setFormData(data)
}
//
const handleSubmit = async () => {
await formRef.value?.validate()
const data = { ...formData, }
mode.value == 'edit'
? await apiCompanyEdit(data)
: await apiCompanyAdd(data)
popupRef.value?.close()
emit('success')
}
//
const open = (type = 'add') => {
mode.value = type
popupRef.value?.open()
}
//
const handleClose = () => {
emit('close')
}
defineExpose({
open,
setFormData,
getDetail
})
</script>

View File

@ -636,9 +636,6 @@ const getDetails = async () => {
const data = await apiCompanyDetail({
id: route.query.id
})
if (route.query.id == 0 || undefined) {
return false
}
Object.keys(formData).forEach((key) => {
//@ts-ignore
formData[key] = data[key]
@ -649,16 +646,19 @@ const getDetails = async () => {
getProvinceList()
getdictTypeLists()
getcontract_type()
getDetails()
const create = async () => {
await formRef.value?.validate()
const data = { ...formData }
route.query.id != 0 ? await apiCompanyEdit(data) : await apiCompanyAdd(data)
if (route.query.id) {
await apiCompanyEdit(data)
} else {
await apiCompanyAdd(data)
}
removeTab()
router.back()
}
route.query.id && getDetails()
defineExpose({
open,
setFormData,

View File

@ -0,0 +1,365 @@
<template>
<div class="edit-popup">
<popup
ref="popupRef"
:title="popupTitle"
:async="true"
width="80%"
@confirm="handleSubmit"
@close="handleClose"
>
<el-form ref="formRef" :model="formData" label-width="84px" :rules="formRules">
<div style="font-size: 1.2rem; margin: 10px 0">基本信息创建</div>
<el-col :span="24" class="pt-6 !border-none">
<el-row>
<el-col :span="12">
<el-form-item label="姓名" prop="name">
<el-input
v-model="formData.name"
placeholder="请输入姓名"
clearable
:style="{ width: '100%' }"
>
</el-input>
</el-form-item>
</el-col>
<el-col :span="12">
<el-form-item label="性别" prop="sex">
<el-input
v-model="formData.sex"
placeholder="请输入性别"
clearable
:style="{ width: '100%' }"
>
</el-input>
</el-form-item>
</el-col>
<el-col :span="12">
<el-form-item label="身份证号" prop="id_card">
<el-input
v-model="formData.id_card"
placeholder="请输入身份证号"
clearable
:style="{ width: '100%' }"
>
</el-input>
</el-form-item>
</el-col>
<el-col :span="12">
<el-form-item label="联系电话" prop="phone">
<el-input
v-model="formData.phone"
placeholder="请输入联系电话"
clearable
:style="{ width: '100%' }"
>
</el-input>
</el-form-item>
</el-col>
<el-col :span="3">
<el-form-item label="省" prop="province">
<el-select
v-model="formData.province"
placeholder="请选择省"
clearable
@change="province_change"
:style="{ width: '100%' }"
>
<el-option
v-for="(item, index) in datas.provinceOptions"
:key="index"
:label="item.province_name"
:value="item.province_code"
></el-option>
</el-select>
</el-form-item>
</el-col>
<el-col :span="3">
<el-form-item label="市" prop="city">
<el-select
v-model="formData.city"
placeholder="请选择市"
clearable
@change="city_change"
:style="{ width: '100%' }"
>
<el-option
v-for="(item, index) in datas.cityOptions"
:key="index"
:label="item.city_name"
:value="item.city_code"
></el-option>
</el-select>
</el-form-item>
</el-col>
<el-col :span="3">
<el-form-item label="区" prop="area">
<el-select
v-model="formData.area"
placeholder="请选择区"
clearable
@change="area_change"
:style="{ width: '100%' }"
>
<el-option
v-for="(item, index) in datas.areaOptions"
:key="index"
:label="item.area_name"
:value="item.area_code"
></el-option>
</el-select>
</el-form-item>
</el-col>
<el-col :span="3">
<el-form-item label="镇" prop="street">
<el-select
v-model="formData.street"
placeholder="请选择镇"
clearable
@change="street_change"
:style="{ width: '100%' }"
>
<el-option
v-for="(item, index) in datas.streetOptions"
:key="index"
:label="item.street_name"
:value="item.street_code"
></el-option>
</el-select>
</el-form-item>
</el-col>
<el-col :span="12">
<el-form-item label="村社小队" prop="address">
<el-input
v-model="formData.address"
placeholder="请输入村社小队"
clearable
:style="{ width: '100%' }"
>
</el-input>
</el-form-item>
</el-col>
</el-row>
</el-col>
<!-- 管理员状态 -->
<el-form-item label="管理员状态" v-if="formData.root != 1">
<el-switch v-model="formData.disable" :active-value="0" :inactive-value="1" />
</el-form-item>
</el-form>
</popup>
</div>
</template>
<script lang="ts" setup>
import type { FormInstance, UploadProps } from 'element-plus'
import Popup from '@/components/popup/index.vue'
import { useDictOptions } from '@/hooks/useDictOptions'
import { adminAdd, adminDetail, adminEdit } from '@/api/perms/admin'
import { roleAll } from '@/api/perms/role'
import { jobsAll } from '@/api/org/post'
import { deptAll } from '@/api/org/department'
import { apiCityList, apiAreaList, apiStreetList, apiProvinceList } from '@/api/common'
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' ? '编辑管理员' : '新增管理员'
})
const formData = reactive({
id: '',
account: '',
sex: 1,
id_card: '',
name: '',
province: '',
city: '',
area: '',
street: '',
address: '',
phone: '',
qualification: {
id_card: '',
car_card: '',
bank_account: ''
},
is_contract: 0,
dept_id: [],
jobs_id: [],
role_id: [],
avatar: '',
password: '',
password_confirm: '',
disable: 0,
multipoint_login: 1,
root: 0
})
const datas = reactive({
provinceOptions: [],
cityOptions: [],
areaOptions: [],
streetOptions: [],
dictTypeLists: [],
contract_type: []
})
const passwordConfirmValidator = (rule: object, value: string, callback: any) => {
if (formData.password) {
if (!value) callback(new Error('请再次输入密码'))
if (value !== formData.password) callback(new Error('两次输入密码不一致!'))
}
callback()
}
const formRules = reactive({
account: [
{
required: true,
message: '请输入账号',
trigger: ['blur']
}
],
name: [
{
required: true,
message: '请输入名称',
trigger: ['blur']
}
],
role_id: [
{
type: 'array',
required: true,
message: '请选择角色',
trigger: ['blur']
}
],
password: [
{
required: true,
message: '请输入密码',
trigger: ['blur']
}
] as any[],
password_confirm: [
{
required: true,
message: '请输入确认密码',
trigger: ['blur']
},
{
validator: passwordConfirmValidator,
trigger: 'blur'
}
] as any[]
})
const { optionsData } = useDictOptions<{
role: any[]
jobs: any[]
dept: any[]
}>({
role: {
api: roleAll
},
jobs: {
api: jobsAll
},
dept: {
api: deptAll
}
})
const handleSubmit = async () => {
await formRef.value?.validate()
mode.value == 'edit' ? await adminEdit(formData) : await adminAdd(formData)
popupRef.value?.close()
emit('success')
}
const open = (type = 'add') => {
mode.value = type
popupRef.value?.open()
}
//
function province_change(value: string) {
formData.province = value
getCityList(value)
}
function city_change(value: string) {
formData.city = value
getAreaList(value)
}
function area_change(value: string) {
formData.area = value
getStreetList(value)
}
function street_change(value: string) {
formData.street = value
}
const getProvinceList = async () => {
const data = await apiProvinceList({})
datas['provinceOptions'] = data
}
const getCityList = async (id: any) => {
const data = await apiCityList({ city: id })
datas['cityOptions'] = data
}
const getAreaList = async (id: any) => {
const data = await apiAreaList({ area: id })
datas['areaOptions'] = data
}
const getStreetList = async (id: any) => {
const data = await apiStreetList({ street: id })
datas['streetOptions'] = data
}
const handleAvatarSuccess: UploadProps['onSuccess'] = (response, uploadFile) => {
formData.qualification.id_card = response.data.uri
}
const beforeAvatarUpload: UploadProps['beforeUpload'] = (rawFile) => {
return true
}
const handleAvatarSuccess_two: UploadProps['onSuccess'] = (response, uploadFile) => {
formData.qualification.car_card = response.data.uri
}
const beforeAvatarUpload_two: UploadProps['beforeUpload'] = (rawFile) => {
return true
}
const handleAvatarSuccess_three: UploadProps['onSuccess'] = (response, uploadFile) => {
formData.qualification.bank_account = response.data.uri
}
const beforeAvatarUpload_three: UploadProps['beforeUpload'] = (rawFile) => {
return true
}
const setFormData = async (row: any) => {
formRules.password = []
formRules.password_confirm = [
{
validator: passwordConfirmValidator,
trigger: 'blur'
}
]
const data = await adminDetail({
id: row.id
})
for (const key in formData) {
if (data[key] != null && data[key] != undefined) {
//@ts-ignore
formData[key] = data[key]
}
}
}
const handleClose = () => {
emit('close')
}
defineExpose({
open,
setFormData
})
</script>

View File

@ -0,0 +1,265 @@
<template>
<div class="edit-popup">
<popup
ref="popupRef"
:title="popupTitle"
:async="true"
width="550px"
@confirm="handleSubmit"
@close="handleClose"
>
<el-form ref="formRef" :model="formData" label-width="84px" :rules="formRules">
<!-- 账号输入框 -->
<el-form-item label="账号" prop="account">
<el-input
v-model="formData.account"
:disabled="formData.root == 1"
placeholder="请输入账号"
clearable
/>
</el-form-item>
<!-- 管理员头像 -->
<el-form-item label="头像">
<div>
<div>
<material-picker v-model="formData.avatar" :limit="1" />
</div>
<div class="form-tips">建议尺寸100*100px支持jpgjpegpng格式</div>
</div>
</el-form-item>
<!-- 名称输入框 -->
<el-form-item label="名称" prop="name">
<el-input v-model="formData.name" placeholder="请输入名称" clearable />
</el-form-item>
<el-form-item label="归属部门" prop="dept_id">
<el-tree-select
class="flex-1"
v-model="formData.dept_id"
:data="optionsData.dept"
clearable
multiple
node-key="id"
:props="{
value: 'id',
label: 'name',
disabled(data: any) {
return data.status !== 1
}
}"
check-strictly
:default-expand-all="true"
placeholder="请选择上级部门"
/>
</el-form-item>
<el-form-item label="岗位" prop="jobs_id">
<el-select
class="flex-1"
v-model="formData.jobs_id"
clearable
multiple
placeholder="请选择岗位"
>
<el-option
v-for="(item, index) in optionsData.jobs"
:key="index"
:label="item.name"
:value="item.id"
/>
</el-select>
</el-form-item>
<!-- 角色选择框 -->
<el-form-item label="角色" prop="role_id">
<el-select
v-model="formData.role_id"
:disabled="formData.root == 1"
class="flex-1"
multiple
placeholder="请选择角色"
clearable
>
<el-option v-if="formData.root == 1" label="系统管理员" :value="0" />
<el-option
v-for="(item, index) in optionsData.role"
:key="index"
:label="item.name"
:value="item.id"
/>
</el-select>
</el-form-item>
<!-- 密码输入框 -->
<el-form-item label="密码" prop="password">
<el-input
v-model="formData.password"
show-password
clearable
placeholder="请输入密码"
/>
</el-form-item>
<!-- 确认密码输入框 -->
<el-form-item label="确认密码" prop="password_confirm">
<el-input
v-model="formData.password_confirm"
show-password
clearable
placeholder="请输入确认密码"
/>
</el-form-item>
<!-- 管理员状态 -->
<el-form-item label="管理员状态" v-if="formData.root != 1">
<el-switch v-model="formData.disable" :active-value="0" :inactive-value="1" />
</el-form-item>
<!-- 多处登录 -->
<el-form-item label="多处登录">
<div>
<el-switch
v-model="formData.multipoint_login"
:active-value="1"
:inactive-value="0"
/>
<div class="form-tips">允许多人同时在线登录</div>
</div>
</el-form-item>
</el-form>
</popup>
</div>
</template>
<script lang="ts" setup>
import type { FormInstance } from 'element-plus'
import Popup from '@/components/popup/index.vue'
import { useDictOptions } from '@/hooks/useDictOptions'
import { adminAdd, adminDetail, adminEdit } from '@/api/perms/admin'
import { roleAll } from '@/api/perms/role'
import { jobsAll } from '@/api/org/post'
import { deptAll } from '@/api/org/department'
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' ? '编辑管理员' : '新增管理员'
})
const formData = reactive({
id: '',
account: '',
name: '',
dept_id: [],
jobs_id: [],
role_id: [],
avatar: '',
password: '',
password_confirm: '',
disable: 0,
multipoint_login: 1,
root: 0
})
const passwordConfirmValidator = (rule: object, value: string, callback: any) => {
if (formData.password) {
if (!value) callback(new Error('请再次输入密码'))
if (value !== formData.password) callback(new Error('两次输入密码不一致!'))
}
callback()
}
const formRules = reactive({
account: [
{
required: true,
message: '请输入账号',
trigger: ['blur']
}
],
name: [
{
required: true,
message: '请输入名称',
trigger: ['blur']
}
],
role_id: [
{
type: 'array',
required: true,
message: '请选择角色',
trigger: ['blur']
}
],
password: [
{
required: true,
message: '请输入密码',
trigger: ['blur']
}
] as any[],
password_confirm: [
{
required: true,
message: '请输入确认密码',
trigger: ['blur']
},
{
validator: passwordConfirmValidator,
trigger: 'blur'
}
] as any[]
})
const { optionsData } = useDictOptions<{
role: any[]
jobs: any[]
dept: any[]
}>({
role: {
api: roleAll
},
jobs: {
api: jobsAll
},
dept: {
api: deptAll
}
})
const handleSubmit = async () => {
await formRef.value?.validate()
mode.value == 'edit' ? await adminEdit(formData) : await adminAdd(formData)
popupRef.value?.close()
emit('success')
}
const open = (type = 'add') => {
mode.value = type
popupRef.value?.open()
}
const setFormData = async (row: any) => {
formRules.password = []
formRules.password_confirm = [
{
validator: passwordConfirmValidator,
trigger: 'blur'
}
]
const data = await adminDetail({
id: row.id
})
for (const key in formData) {
if (data[key] != null && data[key] != undefined) {
//@ts-ignore
formData[key] = data[key]
}
}
}
const handleClose = () => {
emit('close')
}
defineExpose({
open,
setFormData
})
</script>

View File

@ -4,11 +4,324 @@
ref="popupRef"
:title="popupTitle"
:async="true"
width="550px"
width="80%"
@confirm="handleSubmit"
@close="handleClose"
>
<el-form ref="formRef" :model="formData" label-width="84px" :rules="formRules">
<div style="font-size: 1.2rem; margin: 10px 0">基本信息创建</div>
<el-col :span="24" class="pt-6 !border-none">
<el-row>
<el-col :span="12">
<el-form-item label="姓名" prop="name">
<el-input
v-model="formData.name"
placeholder="请输入姓名"
clearable
:style="{ width: '100%' }"
>
</el-input>
</el-form-item>
</el-col>
<el-col :span="12">
<el-form-item label="性别" prop="sex">
<el-input
v-model="formData.sex"
placeholder="请输入性别"
clearable
:style="{ width: '100%' }"
>
</el-input>
</el-form-item>
</el-col>
<el-col :span="12">
<el-form-item label="身份证号" prop="id_card">
<el-input
v-model="formData.id_card"
placeholder="请输入身份证号"
clearable
:style="{ width: '100%' }"
>
</el-input>
</el-form-item>
</el-col>
<el-col :span="12">
<el-form-item label="联系电话" prop="phone">
<el-input
v-model="formData.phone"
placeholder="请输入联系电话"
clearable
:style="{ width: '100%' }"
>
</el-input>
</el-form-item>
</el-col>
<el-col :span="3">
<el-form-item label="省" prop="province">
<el-select
v-model="formData.province"
placeholder="请选择省"
clearable
@change="province_change"
:style="{ width: '100%' }"
>
<el-option
v-for="(item, index) in datas.provinceOptions"
:key="index"
:label="item.province_name"
:value="item.province_code"
></el-option>
</el-select>
</el-form-item>
</el-col>
<el-col :span="3">
<el-form-item label="市" prop="city">
<el-select
v-model="formData.city"
placeholder="请选择市"
clearable
@change="city_change"
:style="{ width: '100%' }"
>
<el-option
v-for="(item, index) in datas.cityOptions"
:key="index"
:label="item.city_name"
:value="item.city_code"
></el-option>
</el-select>
</el-form-item>
</el-col>
<el-col :span="3">
<el-form-item label="区" prop="area">
<el-select
v-model="formData.area"
placeholder="请选择区"
clearable
@change="area_change"
:style="{ width: '100%' }"
>
<el-option
v-for="(item, index) in datas.areaOptions"
:key="index"
:label="item.area_name"
:value="item.area_code"
></el-option>
</el-select>
</el-form-item>
</el-col>
<el-col :span="3">
<el-form-item label="镇" prop="street">
<el-select
v-model="formData.street"
placeholder="请选择镇"
clearable
@change="street_change"
:style="{ width: '100%' }"
>
<el-option
v-for="(item, index) in datas.streetOptions"
:key="index"
:label="item.street_name"
:value="item.street_code"
></el-option>
</el-select>
</el-form-item>
</el-col>
<el-col :span="12">
<el-form-item label="村社小队" prop="address">
<el-input
v-model="formData.address"
placeholder="请输入村社小队"
clearable
:style="{ width: '100%' }"
>
</el-input>
</el-form-item>
</el-col>
</el-row>
</el-col>
<el-col :span="24">
<el-form-item label="授权身份" prop="role_id">
<el-select
v-model="formData.role_id"
:disabled="formData.root == 1"
class="flex-1"
multiple
placeholder="请选择授权身份"
clearable
>
<el-option v-if="formData.root == 1" label="系统管理员" :value="0" />
<el-option
v-for="(item, index) in optionsData.role"
:key="index"
:label="item.name"
:value="item.id"
/>
</el-select>
</el-form-item>
</el-col>
<div style="font-size: 1.2rem; margin: 10px 0">资质信息</div>
<el-col :span="24">
<el-row>
<el-col :span="8">
<el-form-item label="身份证" prop="id_card" required>
<el-upload
v-model="formData.qualification.id_card"
class="avatar-uploader"
:data="{ cid: 1 }"
action="https://worker-task.lihaink.cn/api/upload/image"
:show-file-list="false"
:on-success="handleAvatarSuccess"
:before-upload="beforeAvatarUpload"
>
<img
v-if="formData.qualification.id_card"
:src="formData.qualification.id_card"
class="avatar"
/>
<el-icon v-else class="avatar-uploader-icon">
<Plus />
</el-icon>
</el-upload>
</el-form-item>
</el-col>
<el-col :span="8">
<el-form-item label="行驶证" prop="car_card" required>
<el-upload
v-model="formData.qualification.car_card"
class="avatar-uploader"
:data="{ cid: 1 }"
action="https://worker-task.lihaink.cn/api/upload/image"
:show-file-list="false"
:on-success="handleAvatarSuccess_two"
:before-upload="beforeAvatarUpload_two"
>
<img
v-if="formData.qualification.car_card"
:src="formData.qualification.car_card"
class="avatar"
/>
<el-icon v-else class="avatar-uploader-icon">
<Plus />
</el-icon>
</el-upload>
</el-form-item>
</el-col>
<el-col :span="8">
<el-form-item label="银行卡号" prop="bank_account" required>
<el-upload
v-model="formData.qualification.bank_account"
class="avatar-uploader"
:data="{ cid: 1 }"
action="https://worker-task.lihaink.cn/api/upload/image"
:show-file-list="false"
:on-success="handleAvatarSuccess_three"
:before-upload="beforeAvatarUpload_three"
>
<img
v-if="formData.qualification.bank_account"
:src="formData.qualification.bank_account"
class="avatar"
/>
<el-icon v-else class="avatar-uploader-icon"> </el-icon>
</el-upload>
</el-form-item>
</el-col>
</el-row>
</el-col>
<el-col :span="24">
<el-row>
<el-col :span="12">
<el-form-item label="签约姓名" prop="name">
<el-input
v-model="formData.name"
placeholder="请输入签约姓名"
:disabled="true"
clearable
:style="{ width: '100%' }"
></el-input>
</el-form-item>
</el-col>
<el-col :span="12">
<el-form-item label="性别" prop="sex">
<el-input
v-model="formData.sex"
placeholder="请输入性别"
:disabled="true"
clearable
:style="{ width: '100%' }"
></el-input>
</el-form-item>
</el-col>
<el-col :span="12">
<el-form-item label="身份证号" prop="id_card">
<el-input
v-model="formData.id_card"
placeholder="请输入身份证号"
:disabled="true"
clearable
:style="{ width: '100%' }"
></el-input>
</el-form-item>
</el-col>
<el-col :span="12">
<el-form-item label="联系电话" prop="phone">
<el-input
v-model="formData.phone"
placeholder="请输入联系电话"
:disabled="true"
clearable
:style="{ width: '100%' }"
></el-input>
</el-form-item>
</el-col>
<el-col :span="12">
<el-form-item label="合同类型" prop="field124">
<el-input
v-model="formData.field124"
placeholder="请输入合同类型"
:disabled="true"
clearable
:style="{ width: '100%' }"
></el-input>
</el-form-item>
</el-col>
<el-col :span="12">
<el-form-item label="合同编号" prop="field125">
<el-input
v-model="formData.field125"
placeholder="请输入合同编号"
:disabled="true"
clearable
:style="{ width: '100%' }"
></el-input>
</el-form-item>
</el-col>
<el-col :span="24">
<el-form-item label="签约公司" prop="field131">
<el-input
v-model="formData.field131"
placeholder="请输入签约公司【甲方】"
clearable
:style="{ width: '100%' }"
></el-input>
</el-form-item>
</el-col>
</el-row>
</el-col>
<el-col :span="24">
<el-form-item label="上传" prop="field127" required>
<el-upload ref="field127">
<el-button size="small" type="primary" icon="el-icon-upload"
>点击上传</el-button
>
</el-upload>
</el-form-item>
</el-col>
<!-- 账号输入框 -->
<el-form-item label="账号" prop="account">
<el-input
@ -28,67 +341,6 @@
</div>
</el-form-item>
<!-- 名称输入框 -->
<el-form-item label="名称" prop="name">
<el-input v-model="formData.name" placeholder="请输入名称" clearable />
</el-form-item>
<el-form-item label="归属部门" prop="dept_id">
<el-tree-select
class="flex-1"
v-model="formData.dept_id"
:data="optionsData.dept"
clearable
multiple
node-key="id"
:props="{
value: 'id',
label: 'name',
disabled(data: any) {
return data.status !== 1
}
}"
check-strictly
:default-expand-all="true"
placeholder="请选择上级部门"
/>
</el-form-item>
<el-form-item label="岗位" prop="jobs_id">
<el-select
class="flex-1"
v-model="formData.jobs_id"
clearable
multiple
placeholder="请选择岗位"
>
<el-option
v-for="(item, index) in optionsData.jobs"
:key="index"
:label="item.name"
:value="item.id"
/>
</el-select>
</el-form-item>
<!-- 角色选择框 -->
<el-form-item label="角色" prop="role_id">
<el-select
v-model="formData.role_id"
:disabled="formData.root == 1"
class="flex-1"
multiple
placeholder="请选择角色"
clearable
>
<el-option v-if="formData.root == 1" label="系统管理员" :value="0" />
<el-option
v-for="(item, index) in optionsData.role"
:key="index"
:label="item.name"
:value="item.id"
/>
</el-select>
</el-form-item>
<!-- 密码输入框 -->
<el-form-item label="密码" prop="password">
<el-input
@ -113,30 +365,20 @@
<el-form-item label="管理员状态" v-if="formData.root != 1">
<el-switch v-model="formData.disable" :active-value="0" :inactive-value="1" />
</el-form-item>
<!-- 多处登录 -->
<el-form-item label="多处登录">
<div>
<el-switch
v-model="formData.multipoint_login"
:active-value="1"
:inactive-value="0"
/>
<div class="form-tips">允许多人同时在线登录</div>
</div>
</el-form-item>
</el-form>
</popup>
</div>
</template>
<script lang="ts" setup>
import type { FormInstance } from 'element-plus'
import type { FormInstance, UploadProps } from 'element-plus'
import Popup from '@/components/popup/index.vue'
import { useDictOptions } from '@/hooks/useDictOptions'
import { adminAdd, adminDetail, adminEdit } from '@/api/perms/admin'
import { roleAll } from '@/api/perms/role'
import { jobsAll } from '@/api/org/post'
import { deptAll } from '@/api/org/department'
import { apiCityList, apiAreaList, apiStreetList, apiProvinceList } from '@/api/common'
const emit = defineEmits(['success', 'close'])
const formRef = shallowRef<FormInstance>()
const popupRef = shallowRef<InstanceType<typeof Popup>>()
@ -147,7 +389,21 @@ const popupTitle = computed(() => {
const formData = reactive({
id: '',
account: '',
sex: 1,
id_card: '',
name: '',
province: '',
city: '',
area: '',
street: '',
address: '',
phone: '',
qualification: {
id_card: '',
car_card: '',
bank_account: ''
},
is_contract: 0,
dept_id: [],
jobs_id: [],
role_id: [],
@ -158,6 +414,14 @@ const formData = reactive({
multipoint_login: 1,
root: 0
})
const datas = reactive({
provinceOptions: [],
cityOptions: [],
areaOptions: [],
streetOptions: [],
dictTypeLists: [],
contract_type: []
})
const passwordConfirmValidator = (rule: object, value: string, callback: any) => {
if (formData.password) {
if (!value) callback(new Error('请再次输入密码'))
@ -235,6 +499,60 @@ const open = (type = 'add') => {
popupRef.value?.open()
}
const handleAvatarSuccess: UploadProps['onSuccess'] = (response, uploadFile) => {
formData.qualification.id_card = response.data.uri
}
const beforeAvatarUpload: UploadProps['beforeUpload'] = (rawFile) => {
return true
}
const handleAvatarSuccess_two: UploadProps['onSuccess'] = (response, uploadFile) => {
formData.qualification.car_card = response.data.uri
}
const beforeAvatarUpload_two: UploadProps['beforeUpload'] = (rawFile) => {
return true
}
const handleAvatarSuccess_three: UploadProps['onSuccess'] = (response, uploadFile) => {
formData.qualification.bank_account = response.data.uri
}
const beforeAvatarUpload_three: UploadProps['beforeUpload'] = (rawFile) => {
return true
}
//
function province_change(value: string) {
formData.province = value
getCityList(value)
}
function city_change(value: string) {
formData.city = value
getAreaList(value)
}
function area_change(value: string) {
formData.area = value
getStreetList(value)
}
function street_change(value: string) {
formData.street = value
}
const getProvinceList = async () => {
const data = await apiProvinceList({})
datas['provinceOptions'] = data
}
const getCityList = async (id: any) => {
const data = await apiCityList({ city: id })
datas['cityOptions'] = data
}
const getAreaList = async (id: any) => {
const data = await apiAreaList({ area: id })
datas['areaOptions'] = data
}
const getStreetList = async (id: any) => {
const data = await apiStreetList({ street: id })
datas['streetOptions'] = data
}
const setFormData = async (row: any) => {
formRules.password = []
formRules.password_confirm = [
@ -257,9 +575,40 @@ const setFormData = async (row: any) => {
const handleClose = () => {
emit('close')
}
getProvinceList()
defineExpose({
open,
setFormData
})
</script>
<style scoped>
.avatar-uploader .avatar {
width: 178px;
height: 178px;
display: block;
}
</style>
<style>
.avatar-uploader .el-upload {
border: 1px dashed var(--el-border-color);
border-radius: 6px;
cursor: pointer;
position: relative;
overflow: hidden;
transition: var(--el-transition-duration-fast);
}
.avatar-uploader .el-upload:hover {
border-color: var(--el-color-primary);
}
.el-icon.avatar-uploader-icon {
font-size: 28px;
color: #8c939d;
width: 178px;
height: 178px;
text-align: center;
}
</style>