|
@@ -42,7 +42,7 @@ const title = computed(() => {
|
|
|
|
|
|
type Model = Pick<
|
|
|
Api.Admin.SysDept,
|
|
|
- 'parentId' | 'deptName' | 'orderNum' | 'leader' | 'phone' | 'email' | 'status'>;
|
|
|
+ 'parentId' | 'deptName' | 'sort' | 'leader' | 'phone' | 'email' | 'status'>;
|
|
|
|
|
|
const model: Model = reactive(createDefaultModel());
|
|
|
|
|
@@ -50,7 +50,7 @@ function createDefaultModel(): Model {
|
|
|
return {
|
|
|
parentId: null,
|
|
|
deptName: '',
|
|
|
- orderNum: 10,
|
|
|
+ sort: 10,
|
|
|
leader: '',
|
|
|
phone: '',
|
|
|
email: '',
|
|
@@ -58,12 +58,12 @@ function createDefaultModel(): Model {
|
|
|
};
|
|
|
}
|
|
|
|
|
|
-type RuleKey = Extract<keyof Model, 'parentId' | 'deptName' | 'orderNum' | 'leader' | 'phone' | 'email' | 'status'>;
|
|
|
+type RuleKey = Extract<keyof Model, 'parentId' | 'deptName' | 'sort' | 'leader' | 'phone' | 'email' | 'status'>;
|
|
|
|
|
|
const rules: Record<RuleKey, App.Global.FormRule> = {
|
|
|
parentId: createRequiredRule($t('page.admin.sysDept.form.parentId')),
|
|
|
deptName: defaultRequiredRule,
|
|
|
- orderNum: defaultRequiredRule,
|
|
|
+ sort: defaultRequiredRule,
|
|
|
leader: defaultRequiredRule,
|
|
|
phone: formRules.phone,
|
|
|
email: formRules.email,
|
|
@@ -73,7 +73,7 @@ const rules: Record<RuleKey, App.Global.FormRule> = {
|
|
|
const deptList = ref<CommonType.Option<string>[]>([]);
|
|
|
async function getDeptList() {
|
|
|
const { data } = await fetchDeptList()
|
|
|
- const dept = { deptId: '0', value: '0', deptName: '主类目', label: '主类目', children: [], selectable: false }
|
|
|
+ const dept = { deptId: '0', value: '0', deptName: '主类目', label: '主类目', children: [] }
|
|
|
dept.children = data
|
|
|
deptList.value = [dept]
|
|
|
}
|
|
@@ -87,7 +87,7 @@ async function getDeptDetails() {
|
|
|
let deptId = props.rowData?.deptId + ''
|
|
|
const { data } = await fetchDeptDetail(deptId)
|
|
|
data.status = data.status + ''
|
|
|
- data.orderNum = data.sort
|
|
|
+ //data.orderNum = data.sort
|
|
|
Object.assign(model, data);
|
|
|
}
|
|
|
|
|
@@ -105,24 +105,36 @@ function closeDrawer() {
|
|
|
|
|
|
async function handleSubmit() {
|
|
|
await validate();
|
|
|
+ let formData = {}
|
|
|
+ Object.keys(model).forEach(key => {
|
|
|
+ if (key === 'status' || key === 'parentId') {
|
|
|
+ formData[key] = model[key] - 0
|
|
|
+ } else {
|
|
|
+ formData[key] = model[key]
|
|
|
+ }
|
|
|
+ })
|
|
|
+
|
|
|
let fnMap = {
|
|
|
add: () => {
|
|
|
- const { code, msg } = fetchDeptAdd(model)
|
|
|
- if (code === 200) {
|
|
|
- window.$message?.success(msg);
|
|
|
- closeDrawer();
|
|
|
- emit('submitted');
|
|
|
- }
|
|
|
+ fetchDeptAdd(formData).then(({ code, msg }) => {
|
|
|
+ console.log('code', code)
|
|
|
+ if (code === 200) {
|
|
|
+ window.$message?.success(msg);
|
|
|
+ closeDrawer();
|
|
|
+ emit('submitted');
|
|
|
+ }
|
|
|
+ })
|
|
|
},
|
|
|
edit: () => {
|
|
|
let deptId = props.rowData?.deptId + ''
|
|
|
- const { code, msg } = fetchDeptEdit(model, deptId)
|
|
|
- if (code === 200) {
|
|
|
- window.$message?.success(msg);
|
|
|
- closeDrawer();
|
|
|
- emit('submitted');
|
|
|
- }
|
|
|
- console.log('edit')
|
|
|
+ fetchDeptEdit(formData, deptId).then(({ code, msg }) => {
|
|
|
+ if (code === 200) {
|
|
|
+ window.$message?.success(msg);
|
|
|
+ closeDrawer();
|
|
|
+ emit('submitted');
|
|
|
+ }
|
|
|
+ })
|
|
|
+
|
|
|
}
|
|
|
}
|
|
|
fnMap[props.operateType] && fnMap[props.operateType]()
|
|
@@ -154,8 +166,8 @@ watch(visible, () => {
|
|
|
</AFormItem>
|
|
|
</ACol>
|
|
|
<ACol :span="12" :md="12" :xs="24">
|
|
|
- <AFormItem :label="$t('page.admin.sysDept.orderNum')" name="orderNum">
|
|
|
- <AInputNumber v-model:value="model.orderNum" :min="0" :placeholder="$t('page.admin.sysDept.form.orderNum')"
|
|
|
+ <AFormItem :label="$t('page.admin.sysDept.sort')" name="sort">
|
|
|
+ <AInputNumber v-model:value="model.sort" :min="0" :placeholder="$t('page.admin.sysDept.form.sort')"
|
|
|
allowClear />
|
|
|
</AFormItem>
|
|
|
</ACol>
|