|
@@ -4,7 +4,7 @@ import { apiCustomerUser } from '@/api/customer'
|
|
|
import { isMobileNo, patternEmail } from '@/utils/common'
|
|
|
import { useRoute, useRouter } from 'vue-router'
|
|
|
import PermissionTable from './components/PermissionTable.vue'
|
|
|
-import { dayjs } from 'element-plus'
|
|
|
+import { dayjs, ElMessageBox } from 'element-plus'
|
|
|
import OperationRecord from './components/OperationRecord.vue'
|
|
|
|
|
|
const route = useRoute()
|
|
@@ -12,8 +12,8 @@ const router = useRouter()
|
|
|
|
|
|
const userId = ref(route.query.id || 0)
|
|
|
|
|
|
-const isView=computed(()=>{
|
|
|
- return route.path==='/customer/userDetail'
|
|
|
+const isView = computed(() => {
|
|
|
+ return route.path === '/customer/userDetail'
|
|
|
})
|
|
|
|
|
|
const areaCodeOpts = ref([])
|
|
@@ -96,7 +96,31 @@ function getUserInfo() {
|
|
|
getUserInfo()
|
|
|
|
|
|
|
|
|
-async function handleSave() {
|
|
|
+function handleToEdit() {
|
|
|
+ // 关闭提示
|
|
|
+ formState.isEnabled=true
|
|
|
+ ElMessageBox.close()
|
|
|
+ router.replace({
|
|
|
+ path: '/customer/userEdit',
|
|
|
+ query: {
|
|
|
+ id: userId.value
|
|
|
+ }
|
|
|
+ })
|
|
|
+}
|
|
|
+function checkAddContent(msg) {
|
|
|
+ return h('p', [
|
|
|
+ msg,
|
|
|
+ h(ElButton, {
|
|
|
+ type: 'primary',
|
|
|
+ link: true,
|
|
|
+ onClick: handleToEdit
|
|
|
+ }, '跳转查看')
|
|
|
+ ]);
|
|
|
+}
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+async function handleSave(type) {
|
|
|
await formRef.value.validate()
|
|
|
let params = {
|
|
|
RealName: formState.realName,
|
|
@@ -111,9 +135,27 @@ async function handleSave() {
|
|
|
}
|
|
|
if (userId.value) {
|
|
|
params.UserId = Number(userId.value)
|
|
|
- params.IsEnabled = true
|
|
|
+ params.IsEnabled = formState.isEnabled
|
|
|
+ } else {
|
|
|
+ // 新增用户时进行校验
|
|
|
+ const checkRes = await apiCustomerUser.userAddCheck({
|
|
|
+ AreaCode: formState.areaCode,
|
|
|
+ Phone: formState.phone,
|
|
|
+ Email: formState.email,
|
|
|
+ })
|
|
|
+ if (checkRes.Ret !== 200) return
|
|
|
+ if (checkRes.Data) {
|
|
|
+ userId.value = checkRes.Data.UserId
|
|
|
+ ElMessageBox.confirm(checkAddContent(checkRes.Msg),'操作提示',{
|
|
|
+ autofocus:false,
|
|
|
+ }).then(()=>{
|
|
|
+ // 确认则自动调用编辑保存一次用户信息
|
|
|
+ formState.isEnabled=true
|
|
|
+ handleSave()
|
|
|
+ }).catch(()=>{})
|
|
|
+ return
|
|
|
+ }
|
|
|
}
|
|
|
- console.log(params);
|
|
|
const res = userId.value ? await apiCustomerUser.userEdit(params) : await apiCustomerUser.userAdd(params)
|
|
|
if (res.Ret !== 200) return
|
|
|
ElMessage.success(userId.value ? '编辑成功' : '新增成功')
|
|
@@ -162,10 +204,10 @@ async function handleSave() {
|
|
|
<el-input v-model="formState.email" placeholder="请输入邮箱" />
|
|
|
</el-form-item>
|
|
|
<el-form-item label="营业部/销售" prop="sellerId">
|
|
|
- <all-user-for-depart
|
|
|
- style="width:100%"
|
|
|
+ <all-user-for-depart
|
|
|
+ style="width: 100%"
|
|
|
:props="{
|
|
|
- emitPath:false
|
|
|
+ emitPath: false,
|
|
|
}"
|
|
|
v-model="formState.sellerId"
|
|
|
/>
|
|
@@ -193,10 +235,13 @@ async function handleSave() {
|
|
|
<div class="form-tr-box auth-box">
|
|
|
<div class="auth-box-label">
|
|
|
<span class="text">权限</span>
|
|
|
- <span v-if="$route.path!=='/customer/userAdd'">
|
|
|
- <span style="color: var(--el-color-danger);">*</span>
|
|
|
+ <span v-if="$route.path !== '/customer/userAdd'">
|
|
|
+ <span style="color: var(--el-color-danger)">*</span>
|
|
|
<span>用户状态</span>
|
|
|
- <el-switch v-model="formState.isEnabled" style="margin-left:5px"/>
|
|
|
+ <el-switch
|
|
|
+ v-model="formState.isEnabled"
|
|
|
+ style="margin-left: 5px"
|
|
|
+ />
|
|
|
</span>
|
|
|
</div>
|
|
|
|
|
@@ -209,10 +254,7 @@ async function handleSave() {
|
|
|
</div>
|
|
|
<div class="right-box">
|
|
|
<div style="text-align: right" v-if="!isView">
|
|
|
- <el-button
|
|
|
- type="primary"
|
|
|
- style="width: 120px"
|
|
|
- @click="handleSave"
|
|
|
+ <el-button type="primary" style="width: 120px" @click="handleSave"
|
|
|
>保存</el-button
|
|
|
>
|
|
|
<el-button
|
|
@@ -224,13 +266,13 @@ async function handleSave() {
|
|
|
>
|
|
|
</div>
|
|
|
<!-- 操作记录 -->
|
|
|
- <OperationRecord v-if="userId!==0&&$route.path!=='/customer/userTransform'"/>
|
|
|
+ <OperationRecord />
|
|
|
</div>
|
|
|
</div>
|
|
|
</template>
|
|
|
|
|
|
<style lang="scss" scoped>
|
|
|
-.customer-user-edit-page{
|
|
|
+.customer-user-edit-page {
|
|
|
padding: 20px;
|
|
|
}
|
|
|
.content-box {
|