|
@@ -1,30 +1,48 @@
|
|
|
<template>
|
|
|
<BasicTable @register="registerTable">
|
|
|
<template #toolbar>
|
|
|
- <div class="w-2/5 flex">
|
|
|
+ <div class="w-2/5 flex justify-end">
|
|
|
<!-- <Search @search="value => handleSearch('search', value)" placeholder="项目名称/项目编号" /> -->
|
|
|
<a-button @click="showModalFn" class="ml-3"><PlusOutlined />新增账号</a-button>
|
|
|
</div>
|
|
|
</template>
|
|
|
</BasicTable>
|
|
|
<BasicModal @register="registerModal" @ok="submitModal">
|
|
|
- <BasicForm @register="registerForm" ref="formElRef" />
|
|
|
+ <BasicForm @register="registerForm" ref="formElRef">
|
|
|
+ <template #role="{ model, field }">
|
|
|
+ <span v-if="hasAdmin" class="text-red">已存在管理员</span>
|
|
|
+ <a-radio-group v-else v-model:value="model[field]">
|
|
|
+ <a-radio value="1">设为<Icon icon="clarity:administrator-solid" />管理员</a-radio>
|
|
|
+ </a-radio-group>
|
|
|
+ </template>
|
|
|
+ </BasicForm>
|
|
|
</BasicModal>
|
|
|
</template>
|
|
|
<script lang="ts">
|
|
|
import { computed, defineComponent, PropType, ref, watch } from 'vue'
|
|
|
import { BasicTable, useTable } from '/@/components/Table'
|
|
|
import { BasicModal, useModal } from '/@/components/Modal'
|
|
|
+ import { PlusOutlined } from '@ant-design/icons-vue'
|
|
|
import { BasicForm, FormActionType, FormSchema, useForm } from '/@/components/Form/index'
|
|
|
import { getTableColumns } from './tableData'
|
|
|
- import { getProjectAccount } from '/@/api/sys/project'
|
|
|
+ import { getProjectAccount, addProjectAccount } from '/@/api/sys/project'
|
|
|
import { useGo } from '/@/hooks/web/usePage'
|
|
|
+ import { propTypes } from '/@/utils/propTypes'
|
|
|
+ import { Radio } from 'ant-design-vue'
|
|
|
+ import { Icon } from '/@/components/Icon/index'
|
|
|
+ import { AddProjectAccountParams } from '/@/api/sys/model/projectModel'
|
|
|
+ import { useMessage } from '/@/hooks/web/useMessage'
|
|
|
+
|
|
|
export default defineComponent({
|
|
|
name: 'ProjectDetailAccount',
|
|
|
components: {
|
|
|
BasicTable,
|
|
|
BasicModal,
|
|
|
- BasicForm
|
|
|
+ BasicForm,
|
|
|
+ PlusOutlined,
|
|
|
+ ARadio: Radio,
|
|
|
+ ARadioGroup: Radio.Group,
|
|
|
+ Icon
|
|
|
},
|
|
|
props: {
|
|
|
id: {
|
|
@@ -34,14 +52,16 @@
|
|
|
activeId: {
|
|
|
type: String as PropType<string>,
|
|
|
default: '1'
|
|
|
- }
|
|
|
+ },
|
|
|
+ hasAdmin: propTypes.bool
|
|
|
},
|
|
|
setup(props) {
|
|
|
const formElRef = ref<Nullable<FormActionType>>(null)
|
|
|
-
|
|
|
+ const { createMessage } = useMessage()
|
|
|
const go = useGo()
|
|
|
- const [registerTable, { setTableData }] = useTable({
|
|
|
+ const [registerTable, { setTableData, reload }] = useTable({
|
|
|
columns: getTableColumns(() => go('/acount/detail')),
|
|
|
+ showTableSetting: true,
|
|
|
canResize: true
|
|
|
})
|
|
|
const fetchTableData = async (projectId: string) => {
|
|
@@ -78,6 +98,34 @@
|
|
|
component: 'Input',
|
|
|
label: '姓名',
|
|
|
required: true
|
|
|
+ },
|
|
|
+ {
|
|
|
+ field: 'company',
|
|
|
+ component: 'Input',
|
|
|
+ label: '单位名称',
|
|
|
+ required: true
|
|
|
+ },
|
|
|
+ {
|
|
|
+ field: 'position',
|
|
|
+ component: 'Input',
|
|
|
+ label: '角色/职位',
|
|
|
+ required: true
|
|
|
+ },
|
|
|
+ {
|
|
|
+ field: 'mobile',
|
|
|
+ component: 'Input',
|
|
|
+ label: '手机'
|
|
|
+ },
|
|
|
+ {
|
|
|
+ field: 'telephone',
|
|
|
+ component: 'Input',
|
|
|
+ label: '电话'
|
|
|
+ },
|
|
|
+ {
|
|
|
+ field: 'role',
|
|
|
+ label: '特殊账号',
|
|
|
+ component: 'RadioGroup',
|
|
|
+ slot: 'role'
|
|
|
}
|
|
|
])
|
|
|
const [registerForm] = useForm({
|
|
@@ -89,18 +137,28 @@
|
|
|
async function showModalFn() {
|
|
|
openModal()
|
|
|
setModalProps({
|
|
|
- title: '新增项目',
|
|
|
+ title: '新增账号',
|
|
|
okText: '确认添加'
|
|
|
})
|
|
|
}
|
|
|
|
|
|
function submitModal() {
|
|
|
- formElRef.value?.validate().then(() => {
|
|
|
- // createProject(values)
|
|
|
+ formElRef.value?.validate().then((values: any) => {
|
|
|
+ try {
|
|
|
+ createProjectAccount({ ...values, projectId: props.id })
|
|
|
+ } finally {
|
|
|
+ reload()
|
|
|
+ openModal(false)
|
|
|
+ createMessage.success('新建账号成功')
|
|
|
+ }
|
|
|
})
|
|
|
}
|
|
|
|
|
|
- return { registerTable, registerModal, registerForm, showModalFn, submitModal }
|
|
|
+ async function createProjectAccount(values: AddProjectAccountParams) {
|
|
|
+ await addProjectAccount(values)
|
|
|
+ }
|
|
|
+
|
|
|
+ return { formElRef, registerTable, registerModal, registerForm, showModalFn, submitModal }
|
|
|
}
|
|
|
})
|
|
|
</script>
|