|
@@ -18,11 +18,19 @@
|
|
|
<el-option :value="Number(key)" :label="type" v-for="(type, key) in OrganizationTypeDesc" />
|
|
|
</el-select>
|
|
|
</el-form-item>
|
|
|
+
|
|
|
+ <el-form-item label="上级单位" prop="parentId">
|
|
|
+ <el-tree-select :props="{
|
|
|
+ value: 'orgId',
|
|
|
+ label: (data: any) => data.orgName,
|
|
|
+ }" style="width: 300px" v-model="data.parentId" :data="allOrgs" node-key="orgId" clearable>
|
|
|
+ </el-tree-select>
|
|
|
+ </el-form-item>
|
|
|
<el-form-item label="联系人" prop="contact" required>
|
|
|
<el-input v-model="data.contact" style="width: 300px" :maxlength="500" placeholder="请输入" />
|
|
|
</el-form-item>
|
|
|
<el-form-item label="账号" prop="userName" required>
|
|
|
- <el-input v-model="data.userName" style="width: 300px" :maxlength="11" placeholder="请输入手机号" />
|
|
|
+ <el-input v-model="data.userName" style="width: 300px" :maxlength="11" placeholder="请输入手机号" />
|
|
|
</el-form-item>
|
|
|
<el-form-item label="密码" prop="password" required>
|
|
|
<el-input autocomplete="off" readonly onfocus="this.removeAttribute('readonly');" v-model="data.password"
|
|
@@ -51,13 +59,24 @@ import type { FormInstance, FormRules } from "element-plus";
|
|
|
import type { OrganizationType } from '@/request/organization'
|
|
|
import { OrganizationTypeDesc } from '@/store/organization'
|
|
|
|
|
|
-import { ref, reactive, unref, watch } from "vue";
|
|
|
+import { ref, reactive, unref, watch, onMounted } from "vue";
|
|
|
import { View, Hide } from '@element-plus/icons-vue';
|
|
|
import { user } from '@/store/user'
|
|
|
+import {
|
|
|
+ getOrgListFetchList,
|
|
|
+
|
|
|
+} from "@/request";
|
|
|
|
|
|
const addPassFlag = ref(true)//图标显示标识
|
|
|
|
|
|
+type SelectType = {
|
|
|
+ orgName: string,
|
|
|
+ orgId: number
|
|
|
+ children: SelectType[]
|
|
|
+}
|
|
|
+
|
|
|
const baseFormRef = ref<FormInstance>();
|
|
|
+const allOrgs = ref<SelectType[]>([]);
|
|
|
|
|
|
const rules = reactive<FormRules>({
|
|
|
orgName: [
|
|
@@ -87,18 +106,24 @@ const data = ref<OrganizationType & {}>({
|
|
|
orderNum: 0,
|
|
|
orgId: 0,
|
|
|
orgName: "",
|
|
|
- parentId: 0,
|
|
|
+ parentId: null,
|
|
|
password: "",
|
|
|
type: null,
|
|
|
userName: ""
|
|
|
});
|
|
|
|
|
|
-const setParentId = () => {
|
|
|
- if (user.value) {
|
|
|
- const isSuper = user.value.roles.filter(item => item.roleKey === "super_admin").length > 0;
|
|
|
- data.value.parentId = isSuper ? 0 : Number(user.value.orgId)
|
|
|
- }
|
|
|
-}
|
|
|
+// const setParentId = () => {
|
|
|
+// if (user.value) {
|
|
|
+// const isSuper = user.value.roles.filter(item => item.roleKey === "super_admin").length > 0;
|
|
|
+// data.value.parentId = isSuper ? 0 : Number(data.value.parentId)
|
|
|
+// }
|
|
|
+// }
|
|
|
+
|
|
|
+onMounted(async () => {
|
|
|
+ const data = await getOrgListFetchList()
|
|
|
+ // console.log('allOrgs', data);
|
|
|
+ allOrgs.value = data as any as SelectType[]
|
|
|
+})
|
|
|
watch(data, (newValue) => {
|
|
|
data.value.userName = newValue.userName.replace(/[^0-9]/g, '');
|
|
|
}, {
|
|
@@ -110,9 +135,10 @@ defineExpose<QuiskExpose>({
|
|
|
async submit() {
|
|
|
|
|
|
if (unref(baseFormRef)) {
|
|
|
- setParentId();
|
|
|
+ // setParentId();
|
|
|
const res = await unref(baseFormRef)?.validate();
|
|
|
if (res) {
|
|
|
+ console.log('data', data.value)
|
|
|
await props.submit(data.value as any as OrganizationType);
|
|
|
}
|
|
|
} else {
|