完成商城下单功能
This commit is contained in:
@@ -18,8 +18,8 @@
|
||||
styleResponsive ? { md: 19, sm: 19, xs: 24 } : { flex: '1' }
|
||||
"
|
||||
>
|
||||
<a-form-item label="选择场馆" name="merchantId">
|
||||
<SelectMerchant
|
||||
<a-form-item label="选择场馆" name="merchantId" v-if="!getMerchantId()">
|
||||
<SelectMerchantMultipleDown
|
||||
:placeholder="`选择场馆`"
|
||||
class="input-item"
|
||||
v-model:value="form.merchantName"
|
||||
@@ -49,7 +49,7 @@
|
||||
allow-clear
|
||||
placeholder="请输入手机号码"
|
||||
maxlength="11"
|
||||
:disabled="isUpdate"
|
||||
:disabled="isUpdate && !isSuperAdmin"
|
||||
v-model:value="form.phone"
|
||||
/>
|
||||
</a-form-item>
|
||||
@@ -73,7 +73,7 @@
|
||||
</template>
|
||||
|
||||
<script lang="ts" setup>
|
||||
import { ref, reactive, watch } from 'vue';
|
||||
import { ref, reactive, watch, computed } from 'vue';
|
||||
import { Form, message } from 'ant-design-vue';
|
||||
import { assignObject } from 'ele-admin-pro';
|
||||
import { addUser, updateUser } from '@/api/system/user';
|
||||
@@ -82,8 +82,12 @@
|
||||
import { storeToRefs } from 'pinia';
|
||||
import { ItemType } from 'ele-admin-pro/es/ele-image-upload/types';
|
||||
import { FormInstance, RuleObject } from 'ant-design-vue/es/form';
|
||||
import { Role } from '@/api/system/role/model';
|
||||
import RoleSelect from './role-select.vue';
|
||||
import { getMerchantId } from '@/utils/common';
|
||||
import { getMerchantName } from '@/utils/merchant';
|
||||
import { useUserStore } from '@/store/modules/user';
|
||||
|
||||
const userStore = useUserStore();
|
||||
|
||||
// 是否是修改
|
||||
const isUpdate = ref(false);
|
||||
@@ -91,6 +95,8 @@
|
||||
// 是否开启响应式布局
|
||||
const themeStore = useThemeStore();
|
||||
const { styleResponsive } = storeToRefs(themeStore);
|
||||
// 当前用户信息
|
||||
const loginUser = computed(() => userStore.info ?? {});
|
||||
|
||||
const props = defineProps<{
|
||||
// 弹窗是否打开
|
||||
@@ -107,10 +113,11 @@
|
||||
// 提交状态
|
||||
const loading = ref(false);
|
||||
// 是否显示最大化切换按钮
|
||||
const maxable = ref(true);
|
||||
// const maxable = ref(true);
|
||||
// 表格选中数据
|
||||
const formRef = ref<FormInstance | null>(null);
|
||||
const images = ref<ItemType[]>([]);
|
||||
const isSuperAdmin = ref<boolean>(false);
|
||||
|
||||
// 用户信息
|
||||
const form = reactive<User>({
|
||||
@@ -120,8 +127,8 @@
|
||||
nickname: '',
|
||||
realName: '',
|
||||
companyName: '',
|
||||
merchantId: undefined,
|
||||
merchantName: undefined,
|
||||
merchantId: getMerchantId(),
|
||||
merchantName: getMerchantName(),
|
||||
sex: undefined,
|
||||
roles: [],
|
||||
roleId: undefined,
|
||||
@@ -217,11 +224,6 @@
|
||||
form.merchantName = item.merchantName;
|
||||
};
|
||||
|
||||
const chooseRoleId = (item: Role) => {
|
||||
form.roleId = item.roleId;
|
||||
form.roleName = item.roleName;
|
||||
};
|
||||
|
||||
const { resetFields } = useForm(form, rules);
|
||||
|
||||
/* 保存编辑 */
|
||||
@@ -236,6 +238,10 @@
|
||||
const formData = {
|
||||
...form
|
||||
};
|
||||
if (getMerchantId()) {
|
||||
form.merchantId = getMerchantId();
|
||||
form.merchantName = getMerchantName();
|
||||
}
|
||||
const saveOrUpdate = isUpdate.value ? updateUser : addUser;
|
||||
saveOrUpdate(formData)
|
||||
.then((msg) => {
|
||||
@@ -257,8 +263,6 @@
|
||||
(visible) => {
|
||||
if (visible) {
|
||||
images.value = [];
|
||||
console.log(props.data);
|
||||
console.log(form);
|
||||
if (props.data) {
|
||||
assignObject(form, props.data);
|
||||
isUpdate.value = true;
|
||||
@@ -266,6 +270,13 @@
|
||||
resetFields();
|
||||
isUpdate.value = false;
|
||||
}
|
||||
const superAdmin = loginUser.value.roles?.filter(
|
||||
(d) => d.roleCode == 'superAdmin'
|
||||
);
|
||||
// 是否超级管理员
|
||||
if (superAdmin && superAdmin.length > 0) {
|
||||
isSuperAdmin.value = true;
|
||||
}
|
||||
} else {
|
||||
resetFields();
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user