Browse Source

子账户管理添加子账户弹窗

chenlei1231 1 month ago
parent
commit
62a822d1e8

+ 91 - 98
src/views/adweb/data/components/CompanyList.vue

@@ -1,118 +1,111 @@
 <template>
-    <div class="company-list">
-        <div v-for="company in companies" :key="company.name" class="company-card">
-            <div class="company-header">
-                <h3 class="company-name">{{ company.name }}</h3>
-                <a-button type="primary" size="small" @click="handleCompareClick(company)">
-                    对比
-                </a-button>
-            </div>
-            
-            <div class="company-stats">
-                <span>共 {{ company.totalRecords }} 条统记录</span>
-                <span>其中 {{ company.matchedRecords }} 条相匹配</span>
-            </div>
-            
-            <div class="company-contact">
-                <div class="contact-item">
-                    <span class="label">联系方式:</span>
-                    <div class="contact-actions">
-                        <a-button 
-                            v-for="action in ['google', 'bing', 'AI邮箱']" 
-                            :key="action"
-                            size="small"
-                        >
-                            {{ action }}
-                        </a-button>
-                    </div>
-                </div>
-                <div class="contact-item">
-                    <span class="label">联系地址:</span>
-                    <span>{{ company.address }}</span>
-                </div>
-                <div class="contact-item" v-if="company.phone">
-                    <span class="label">电话:</span>
-                    <span>{{ company.phone }}</span>
-                </div>
-                <div class="contact-item" v-if="company.email">
-                    <span class="label">邮箱:</span>
-                    <span>{{ company.email }}</span>
-                </div>
-            </div>
+  <div class="company-list">
+    <div v-for="company in companies" :key="company.name" class="company-card">
+      <div class="company-header">
+        <h3 class="company-name">{{ company.name }}</h3>
+        <a-button type="primary" size="small" @click="handleCompareClick(company)"> 对比 </a-button>
+      </div>
+
+      <div class="company-stats">
+        <span>共 {{ company.totalRecords }} 条统记录</span>
+        <span>其中 {{ company.matchedRecords }} 条相匹配</span>
+      </div>
+
+      <div class="company-contact">
+        <div class="contact-item">
+          <span class="label">联系方式:</span>
+          <div class="contact-actions">
+            <a-button v-for="action in ['google', 'bing', 'AI邮箱']" :key="action" size="small">
+              {{ action }}
+            </a-button>
+          </div>
+        </div>
+        <div class="contact-item">
+          <span class="label">联系地址:</span>
+          <span>{{ company.address }}</span>
+        </div>
+        <div class="contact-item" v-if="company.phone">
+          <span class="label">电话:</span>
+          <span>{{ company.phone }}</span>
+        </div>
+        <div class="contact-item" v-if="company.email">
+          <span class="label">邮箱:</span>
+          <span>{{ company.email }}</span>
         </div>
+      </div>
     </div>
+  </div>
 </template>
 
 <script lang="ts" setup>
-import { defineProps, defineEmits } from 'vue';
+  import { defineProps, defineEmits } from 'vue';
 
-const props = defineProps({
+  const props = defineProps({
     companies: {
-        type: Array,
-        required: true,
-        default: () => []
-    }
-});
-
-const emit = defineEmits(['compare']);
+      type: Array,
+      required: true,
+      default: () => [],
+    },
+  });
 
-const handleCompareClick = (company) => {
+  const emit = defineEmits(['compare']);
+  const handleCompareClick = (company) => {
     emit('compare', company);
-};
+  };
 </script>
 
 <style lang="less" scoped>
-.company-list {
+  .company-list {
     padding: 16px;
-    
+
     .company-card {
-        background: #fff;
-        border: 1px solid #e8e8e8;
-        border-radius: 8px;
-        padding: 16px;
-        margin-bottom: 16px;
-        
-        .company-header {
-            display: flex;
-            justify-content: space-between;
-            align-items: center;
-            margin-bottom: 12px;
-            
-            .company-name {
-                margin: 0;
-                font-size: 16px;
-                font-weight: 500;
-                color: #1890ff;
-            }
+      background: #fff;
+      border: 1px solid #e8e8e8;
+      border-radius: 8px;
+      padding: 16px;
+      margin-bottom: 16px;
+
+      .company-header {
+        display: flex;
+        justify-content: space-between;
+        align-items: center;
+        margin-bottom: 12px;
+
+        .company-name {
+          margin: 0;
+          font-size: 16px;
+          font-weight: 500;
+          color: #1890ff;
         }
-        
-        .company-stats {
-            margin-bottom: 12px;
-            color: #666;
-            
-            span {
-                margin-right: 24px;
-            }
+      }
+
+      .company-stats {
+        margin-bottom: 12px;
+        color: #666;
+
+        span {
+          margin-right: 24px;
         }
-        
-        .company-contact {
-            .contact-item {
-                margin-bottom: 8px;
-                
-                .label {
-                    color: #666;
-                    margin-right: 8px;
-                }
-                
-                .contact-actions {
-                    display: inline-block;
-                    
-                    .ant-btn {
-                        margin-right: 8px;
-                    }
-                }
+      }
+
+      .company-contact {
+        .contact-item {
+          margin-bottom: 8px;
+
+          .label {
+            color: #666;
+            margin-right: 8px;
+          }
+
+          .contact-actions {
+            display: inline-block;
+
+            .ant-btn {
+              margin-right: 8px;
             }
+          }
         }
+      }
     }
-}
-</style> 
+  }
+</style>

+ 60 - 71
src/views/adweb/enquiryPublicRules/publicBlackEmail/modules/EnquiryPublicBlackEmailModal.vue

@@ -1,93 +1,82 @@
 <template>
-  <a-drawer
-    :title="title"
-    :width="width"
-    placement="right"
-    :closable="false"
-    @close="close"
-    v-model:open="visible">
-    <enquiry-public-black-email-form ref="realForm" @ok="submitCallback" :disabled="disableSubmit"
-                                     normal></enquiry-public-black-email-form>
+  <a-drawer :title="title" :width="width" placement="right" :closable="false" @close="close" v-model:open="visible">
+    <enquiry-public-black-email-form ref="realForm" @ok="submitCallback" :disabled="disableSubmit" normal />
     <div class="drawer-footer">
-      <a-button @click="handleCancel" style="margin-bottom: 0;">关闭</a-button>
-      <a-button v-if="!disableSubmit" @click="handleOk" type="primary" style="margin-bottom: 0;">
-        提交
-      </a-button>
+      <a-button @click="handleCancel" style="margin-bottom: 0">关闭</a-button>
+      <a-button v-if="!disableSubmit" @click="handleOk" type="primary" style="margin-bottom: 0"> 提交 </a-button>
     </div>
   </a-drawer>
 </template>
 
 <script lang="ts" name="EnquiryPublicBlackEmailModal" setup>
-import EnquiryPublicBlackEmailForm from './EnquiryPublicBlackEmailForm.vue';
-import {nextTick, ref} from "vue";
+  import EnquiryPublicBlackEmailForm from './EnquiryPublicBlackEmailForm.vue';
+  import { nextTick, ref } from 'vue';
 
-const title = ref("操作");
-const width = ref(800);
-const visible = ref(false);
-const disableSubmit = ref(false);
-const realForm = ref();
+  const title = ref('操作');
+  const width = ref(800);
+  const visible = ref(false);
+  const disableSubmit = ref(false);
+  const realForm = ref();
 
+  const emit = defineEmits(['ok', 'close']);
 
-const emit = defineEmits(["ok", "close"])
+  async function add() {
+    visible.value = true;
+    await nextTick();
 
-async function add() {
-  visible.value = true
-  await nextTick();
+    realForm.value.add();
+  }
 
-  realForm.value.add();
-}
+  async function edit(record) {
+    visible.value = true;
+    await nextTick();
+    realForm.value.edit(record);
+  }
 
-async function edit(record) {
-  visible.value = true
-  await nextTick();
-  realForm.value.edit(record);
-}
+  async function close() {
+    emit('close');
+    await nextTick();
+    visible.value = false;
+  }
 
-async function close() {
-  emit('close');
-  await nextTick();
-  visible.value = false;
-}
+  function handleOk() {
+    realForm.value.submitForm();
+  }
 
-function handleOk() {
-  realForm.value.submitForm()
-}
+  function submitCallback() {
+    emit('ok');
+    visible.value = false;
+  }
 
-function submitCallback() {
-  emit('ok');
-  visible.value = false;
-}
-
-function handleCancel() {
-   close()
-}
-
-defineExpose({
-  title,
-  disableSubmit,
-  add,
-  edit
-});
+  function handleCancel() {
+    close();
+  }
 
+  defineExpose({
+    title,
+    disableSubmit,
+    add,
+    edit,
+  });
 </script>
 
 <style lang="less" scoped>
-/** Button按钮间距 */
-.ant-btn {
-  margin-left: 30px;
-  margin-bottom: 30px;
-  float: right;
-}
+  /** Button按钮间距 */
+  .ant-btn {
+    margin-left: 30px;
+    margin-bottom: 30px;
+    float: right;
+  }
 
-.drawer-footer {
-  position: absolute;
-  bottom: -8px;
-  width: 100%;
-  border-top: 1px solid #e8e8e8;
-  padding: 10px 16px;
-  text-align: right;
-  left: 0;
-  background: #fff;
-  border-radius: 0 0 2px 2px;
-}
+  .drawer-footer {
+    position: absolute;
+    bottom: -8px;
+    width: 100%;
+    border-top: 1px solid #e8e8e8;
+    padding: 10px 16px;
+    text-align: right;
+    left: 0;
+    background: #fff;
+    border-radius: 0 0 2px 2px;
+  }
 </style>

+ 13 - 31
src/views/adweb/enterprise/EnterpriseUserManage.data.ts

@@ -1,4 +1,5 @@
 import { BasicColumn } from '@/components/Table';
+import { render } from '@/utils/common/renderUtils';
 
 export const columns: BasicColumn[] = [
   {
@@ -20,7 +21,7 @@ export const columns: BasicColumn[] = [
   {
     title: '头像',
     align: 'left',
-    dataIndex: 'avatar',
+    customRender: render.renderAvatar,
     width: 80,
   },
   {
@@ -28,7 +29,7 @@ export const columns: BasicColumn[] = [
     align: 'left',
     width: 80,
     dataIndex: 'primaryAccount',
-    customRender: function (text) {
+    customRender: function ({ text }) {
       return text ? '主账户' : '子账户';
     },
   },
@@ -37,17 +38,12 @@ export const columns: BasicColumn[] = [
     align: 'left',
     dataIndex: 'enquiryNum',
   },
-  // {
-  //   title: '负责的产品数',
-  //   align: "left",
-  //   dataIndex: 'productNum',
-  //   scopedSlots: {customRender: "countSlot"}
-  // },
+
   {
     title: '手机号码',
     align: 'left',
     dataIndex: 'phone',
-    customRender: function (text) {
+    customRender: function ({ text }) {
       return text === null ? '--' : text;
     },
   },
@@ -55,7 +51,7 @@ export const columns: BasicColumn[] = [
     title: '邮箱',
     align: 'left',
     dataIndex: 'email',
-    customRender: function (text) {
+    customRender: function ({ text }) {
       return text === null ? '--' : text;
     },
   },
@@ -63,17 +59,10 @@ export const columns: BasicColumn[] = [
     title: '更新时间',
     align: 'left',
     dataIndex: 'updateTime',
-    customRender: function (text) {
+    customRender: function ({ text }) {
       return text === null ? '--' : text;
     },
   },
-  {
-    title: '操作',
-    dataIndex: 'action',
-    fixed: 'right',
-
-    align: 'left',
-  },
 ];
 
 export const subColumns: BasicColumn[] = [
@@ -104,7 +93,7 @@ export const subColumns: BasicColumn[] = [
     align: 'left',
     width: 80,
     dataIndex: 'primaryAccount',
-    customRender: function (text) {
+    customRender: function ({ text }) {
       return text ? '主账户' : '子账户';
     },
   },
@@ -112,7 +101,7 @@ export const subColumns: BasicColumn[] = [
     title: '性别',
     align: 'left',
     dataIndex: 'sex',
-    customRender: function (text) {
+    customRender: function ({ text }) {
       if (text === null) {
         return '-';
       }
@@ -123,7 +112,7 @@ export const subColumns: BasicColumn[] = [
     title: '手机号码',
     align: 'left',
     dataIndex: 'phone',
-    customRender: function (text) {
+    customRender: function ({ text }) {
       return text === null ? '--' : text;
     },
   },
@@ -131,7 +120,7 @@ export const subColumns: BasicColumn[] = [
     title: '邮箱',
     align: 'left',
     dataIndex: 'email',
-    customRender: function (text) {
+    customRender: function ({ text }) {
       return text === null ? '--' : text;
     },
   },
@@ -139,7 +128,7 @@ export const subColumns: BasicColumn[] = [
     title: '更新时间',
     align: 'left',
     dataIndex: 'updateTime',
-    customRender: function (text) {
+    customRender: function ({ text }) {
       return text === null ? '--' : text;
     },
   },
@@ -147,7 +136,7 @@ export const subColumns: BasicColumn[] = [
     title: '主账号询盘',
     align: 'center',
     dataIndex: 'isInquiry',
-    customRender: function (text) {
+    customRender: function ({ text }) {
       return text === 1 ? '不接收' : '接收中';
     },
   },
@@ -158,11 +147,4 @@ export const subColumns: BasicColumn[] = [
 
     align: 'left',
   },
-  {
-    title: '操作',
-    dataIndex: 'action1',
-    fixed: 'right',
-
-    align: 'left',
-  },
 ];

+ 18 - 7
src/views/adweb/enterprise/EnterpriseUserManageList.vue

@@ -15,9 +15,6 @@
               <a-button ghost type="primary" @click="searchReset" preIcon="ant-design:reload-outlined" style="margin-left: 8px">重置</a-button>
               <a-button ghost @click="handleAdd" type="primary" style="margin-left: 8px" preIcon="ant-design:plus-outlined">添加子用户</a-button>
               <a-button ghost type="primary" @click="showRecycleBin" style="margin-left: 8px" preIcon="ant-design:hdd-outlined">回收站</a-button>
-              <!--              <router-link :to="{ path: '/inquery/rules' }" v-if="siteCode !== dictSiteCode">-->
-              <!--                <a-button ghost type="primary" icon="logout" @click="showRecycleBin" style="margin-left: 8px">配置询盘规则</a-button>-->
-              <!--              </router-link>-->
             </span>
           </a-col>
         </a-row>
@@ -25,7 +22,19 @@
     </div>
 
     <!-- table区域-begin -->
-    <div v-if="siteCode !== dictSiteCode"> <BasicTable @register="registerTable" :rowSelection="rowSelection" /></div>
+    <div v-if="siteCode !== dictSiteCode">
+      <BasicTable @register="registerTable" :rowSelection="rowSelection">
+        <template #action="{ record }">
+          <div style="padding: 8px; display: flex; justify-content: space-evenly">
+            <a-tag color="purple" @click="handleEdit(record)" style="cursor: pointer"> 编辑 </a-tag>
+            <a-tag color="green" @click="handleChangePassword(record.username)" style="cursor: pointer"> 重置密码 </a-tag>
+            <a-popconfirm v-if="!record.primaryAccount" title="确定删除吗?" @confirm="() => handleFrozen(record.id, 2)">
+              <a-tag color="red" style="cursor: pointer"> 删除 </a-tag>
+            </a-popconfirm>
+          </div>
+        </template>
+      </BasicTable>
+    </div>
     <!-- table区域-end -->
 
     <!--    table-子账户轮询-begin-->
@@ -88,12 +97,13 @@
 
     <!-- 权限分配 -->
     <enterprise-user-role-modal ref="modalUserRole" />
+
     <!-- 用户回收站 -->
     <enterprise-user-recycle-bin-modal ref="recycleBin" @ok="modalFormOk" />
   </a-card>
 </template>
 
-<script lang="ts" setup name="EnterpriseUserManageList">
+<script lang="ts" setup>
   import '@/assets/less/common.less';
   import EnterpriseUserModal from './modules/EnterpriseUserModal.vue';
 
@@ -105,7 +115,7 @@
   import { BasicTable } from '@/components/Table';
   import { useMessage } from '@/hooks/web/useMessage';
   import { useListPage } from '@/hooks/system/useListPage';
-  import { batchDelete, deleteOne, list } from '@/views/adweb/enquiry/AdwebEnquiry.api';
+  import { batchDelete, deleteOne, list } from '@/views/adweb/enterprise/EnterpriseUserManage.api';
   import { columns, subColumns } from '@/views/adweb/enterprise/EnterpriseUserManage.data';
 
   let subAccountList = reactive([]);
@@ -138,7 +148,7 @@
       },
       striped: true,
       bordered: false,
-      immediate: false, // 不直接触发,通过reload事件触发接口
+      immediate: true, // 不直接触发,通过reload事件触发接口
       beforeFetch: (params) => {
         return Object.assign(params, queryParam);
       },
@@ -250,6 +260,7 @@
    */
   function handleAdd() {
     registerModal.value.disableSubmit = false;
+    registerModal.value.title = '新增';
     registerModal.value.add();
   }
 

+ 131 - 130
src/views/adweb/enterprise/modules/EnterpriseDepartWindow.vue

@@ -33,142 +33,143 @@
   </a-modal>
 </template>
 
-<script lang="ts">
+<script lang="ts" setup>
   import { getAction } from '@/api/manage/manage';
   import { queryIdTree } from '@/views/system/departUser/depart.user.api';
+  import { nextTick, reactive, ref } from 'vue';
+  import { pick } from 'lodash-es';
 
-  export default {
-    name: 'EnterpriseDepartWindow',
+  let checkedKeys = reactive([]);
+  const expandedKeysss = reactive([]);
+  let model = {};
+  const userId = ref();
+  const userDepartModel = { userId: '', departIdList: [] };
+  let departList = [];
+  const modalWidth = ref(400);
+  const departTree = reactive([]);
+  const title = '操作';
+  const visible = ref(false);
+  const labelCol = reactive({
+    xs: { span: 24 },
+    sm: { span: 5 },
+  });
+  const wrapperCol = reactive({
+    xs: { span: 24 },
+    sm: { span: 16 },
+  });
 
-    data() {
-      return {
-        checkedKeys: [], // 存储选中的部门id
-        expandedKeysss: [], //展开的节点
-        userId: '', // 存储用户id
-        model: {}, // 存储SysUserDepartsVO表
-        userDepartModel: { userId: '', departIdList: [] }, // 存储用户id一对多部门信息的对象
-        departList: [], // 存储部门信息
-        modalWidth: 400,
-        departTree: [],
-        title: '操作',
-        visible: false,
-        labelCol: {
-          xs: { span: 24 },
-          sm: { span: 5 },
-        },
-        wrapperCol: {
-          xs: { span: 24 },
-          sm: { span: 16 },
-        },
-        confirmLoading: false,
-        headers: {},
-        form: this.$form.createForm(this),
-        url: {
-          userId: '/sys/user/generateUserId', // 引入生成添加用户情况下的url
-        },
-      };
-    },
-    methods: {
-      add(checkedDepartKeys, userId) {
-        this.checkedKeys = checkedDepartKeys;
-        this.userId = userId;
-        this.edit({});
-      },
-      edit(record) {
-        this.departList = [];
-        this.queryDepartTree();
-        this.form.resetFields();
-        this.visible = true;
-        this.model = Object.assign({}, record);
-        let filedsVal = pick(this.model, 'id', 'userId', 'departIdList');
-        this.$nextTick(() => {
-          this.form.setFieldsValue(filedsVal);
-        });
-      },
-      close() {
-        this.$emit('close');
-        this.visible = false;
-        this.departList = [];
-        this.checkedKeys = [];
-      },
-      handleSubmit() {
-        const that = this;
-        // 触发表单验证
-        this.form.validateFields((err) => {
-          if (!err) {
-            that.confirmLoading = true;
-            if (this.userId == null) {
-              getAction(this.url.userId)
-                .then((res) => {
-                  if (res.success) {
-                    let formData = { userId: res.result, departIdList: this.departList };
-                    console.log(formData);
-                    that.$emit('ok', formData);
-                  }
-                })
-                .finally(() => {
-                  that.departList = [];
-                  that.confirmLoading = false;
-                  that.close();
-                });
-            } else {
-              let formData = { userId: this.userId, departIdList: this.departList };
-              console.log(formData);
-              that.departList = [];
-              that.$emit('ok', formData);
-              that.confirmLoading = false;
-              that.close();
-            }
-          }
-        });
-      },
-      handleCancel() {
-        this.close();
-      },
+  const confirmLoading = ref(false);
+  const headers = reactive({});
+  const form = ref();
+  const url = {
+    userId: '/sys/user/generateUserId', // 引入生成添加用户情况下的url
+  };
+  const emit = defineEmits(['ok', 'close']);
 
-      // 选择部门时作用的API
-      onCheck(checkedKeys, info) {
-        this.departList = [];
-        this.checkedKeys = checkedKeys.checked;
-        let checkedNodes = info.checkedNodes;
-        for (let i = 0; i < checkedNodes.length; i++) {
-          let de = checkedNodes[i].data.props;
-          let depart = { key: '', value: '', title: '' };
-          depart.key = de.value;
-          depart.value = de.value;
-          depart.title = de.title;
-          this.departList.push(depart);
-        }
-        console.log('onCheck', checkedKeys, info);
-      },
-      queryDepartTree() {
-        queryIdTree().then((res) => {
-          if (res.success) {
-            this.departTree = res.result;
-            if (this.checkedKeys && this.checkedKeys.length > 0) {
-              let treekey = [];
-              let arr = res.result;
-              if (arr && arr.length > 0) {
-                arr.forEach((item) => {
-                  treekey.push(item.key);
-                  /*     if(item.children&&item.children.length>0){
-                    item.children.forEach(item1 => {
-                      treekey.push(item1.key);
-                    })
-                  }*/
-                });
-                this.expandedKeysss = treekey;
+  function add(checkedDepartKeys, userId) {
+    checkedKeys = checkedDepartKeys;
+    userId.value = userId;
+    edit({});
+  }
+
+  function edit(record) {
+    departList = [];
+    queryDepartTree();
+    form.value.resetFields();
+    visible.value = true;
+    model = Object.assign({}, record);
+    let filedsVal = pick(model, 'id', 'userId', 'departIdList');
+    nextTick(() => {
+      form.value.setFieldsValue(filedsVal);
+    });
+  }
+
+  function close() {
+    emit('close');
+    visible.value = false;
+    departList = [];
+    checkedKeys = [];
+  }
+
+  function handleSubmit() {
+    // 触发表单验证
+    form.value.validateFields((err) => {
+      if (!err) {
+        confirmLoading.value = true;
+        if (userId.value == null) {
+          getAction(url.userId)
+            .then((res) => {
+              if (res.success) {
+                let formData = { userId: res.result, departIdList: departList };
+                console.log(formData);
+                emit('ok', formData);
               }
-            }
+            })
+            .finally(() => {
+              departList = [];
+              confirmLoading.value = false;
+              close();
+            });
+        } else {
+          let formData = { userId: userId, departIdList: departList };
+          console.log(formData);
+          departList = [];
+          emit('ok', formData);
+          confirmLoading.value = false;
+          close();
+        }
+      }
+    });
+  }
+
+  function handleCancel() {
+    close();
+  }
+
+  // 选择部门时作用的API
+  function onCheck(checkedKeys, info) {
+    departList = [];
+    checkedKeys = checkedKeys.checked;
+    let checkedNodes = info.checkedNodes;
+    for (let i = 0; i < checkedNodes.length; i++) {
+      let de = checkedNodes[i].data.props;
+      let depart = { key: '', value: '', title: '' };
+      depart.key = de.value;
+      depart.value = de.value;
+      depart.title = de.title;
+      departList.push(depart);
+    }
+    console.log('onCheck', checkedKeys, info);
+  }
+
+  function queryDepartTree() {
+    queryIdTree().then((res) => {
+      if (res.success) {
+        departTree = res.result;
+        if (checkedKeys && checkedKeys.length > 0) {
+          let treekey = [];
+          let arr = res.result;
+          if (arr && arr.length > 0) {
+            arr.forEach((item) => {
+              treekey.push(item.key);
+              /*     if(item.children&&item.children.length>0){
+                item.children.forEach(item1 => {
+                  treekey.push(item1.key);
+                })
+              }*/
+            });
+            expandedKeysss = treekey;
           }
-        });
-      },
-      onExpand(expandedKeys) {
-        this.expandedKeysss = expandedKeys;
-      },
-      modalFormOk() {},
-    },
-  };
+        }
+      }
+    });
+  }
+
+  function onExpand(expandedKeys) {
+    expandedKeysss = expandedKeys;
+  }
+
+  function modalFormOk() {}
 </script>
 
 <style lang="less" scoped>
@@ -176,7 +177,7 @@
     padding-top: 10px;
     padding-bottom: 10px;
   }
-  /deep/ .ant-modal {
+  :deep(.ant-modal) {
     height: 700px;
   }
 </style>

+ 63 - 110
src/views/adweb/enterprise/modules/EnterpriseUserModal.vue

@@ -6,7 +6,7 @@
     placement="right"
     :closable="true"
     @close="handleCancel"
-    :visible="visible"
+    v-model:open="visible"
     style="height: 100%; overflow: auto; padding-bottom: 53px"
   >
     <template #title>
@@ -19,55 +19,41 @@
     </template>
 
     <a-spin :spinning="confirmLoading">
-      <a-form :ref="formRef" :model="model">
-        <a-form-item label="用户账号" :labelCol="labelCol" :wrapperCol="wrapperCol">
-          <a-input placeholder="请输入用户账号" v-decorator.trim="['username', validatorRules.username]" :disabled="!!model.id" />
+      <a-form :ref="formRef" :model="model" :rules="formRules">
+        <a-form-item label="用户账号" :labelCol="labelCol" :wrapperCol="wrapperCol" name="username">
+          <a-input placeholder="请输入用户账号" :disabled="!!model.id" />
         </a-form-item>
-        <a-form-item label="用户姓名" :labelCol="labelCol" :wrapperCol="wrapperCol">
-          <a-input placeholder="请输入用户姓名" v-decorator.trim="['realname', validatorRules.realname]" />
+        <a-form-item label="用户姓名" :labelCol="labelCol" :wrapperCol="wrapperCol" name="realname">
+          <a-input placeholder="请输入用户姓名" name="realname" />
         </a-form-item>
         <template v-if="!model.id">
-          <a-form-item label="登录密码" :labelCol="labelCol" :wrapperCol="wrapperCol">
-            <a-input type="password" autocomplete="new-password" placeholder="请输入登录密码" v-decorator="['password', validatorRules.password]" />
+          <a-form-item label="登录密码" :labelCol="labelCol" :wrapperCol="wrapperCol" name="password">
+            <a-input type="password" autocomplete="new-password" placeholder="请输入登录密码" />
           </a-form-item>
-          <a-form-item label="确认密码" :labelCol="labelCol" :wrapperCol="wrapperCol">
-            <a-input
-              type="password"
-              @blur="handleConfirmBlur"
-              placeholder="请重新输入登录密码"
-              v-decorator="['confirmpassword', validatorRules.confirmpassword]"
-            />
+          <a-form-item label="确认密码" :labelCol="labelCol" :wrapperCol="wrapperCol" name="confirmpassword">
+            <a-input type="password" @blur="handleConfirmBlur" placeholder="请重新输入登录密码" />
           </a-form-item>
         </template>
         <template v-if="siteCode === dictSiteCode">
-          <a-form-item label="性别" :labelCol="labelCol" :wrapperCol="wrapperCol">
-            <a-radio-group v-decorator="['sex', { rules: [{ required: true, message: '请选择性别!' }] }]">
+          <a-form-item label="性别" :labelCol="labelCol" :wrapperCol="wrapperCol" name="sex">
+            <a-radio-group>
               <a-radio :value="1">男</a-radio>
               <a-radio :value="2">女</a-radio>
             </a-radio-group>
           </a-form-item>
-          <a-form-item label="工作手机" :labelCol="labelCol" :wrapperCol="wrapperCol">
-            <a-input
-              placeholder="请输入手机号码"
-              v-decorator="['phone', { rules: [{ required: true, message: '请输入工作手机!' }, { validator: validatePhone }] }]"
-            />
+          <a-form-item label="工作手机" :labelCol="labelCol" :wrapperCol="wrapperCol" name="phone">
+            <a-input placeholder="请输入手机号码" />
           </a-form-item>
-          <a-form-item label="企业邮箱" :labelCol="labelCol" :wrapperCol="wrapperCol">
-            <a-input
-              placeholder="请输入邮箱"
-              v-decorator="['email', { rules: [{ required: true, message: '请输入企业邮箱!' }, { validator: validateEmail }] }]"
-            />
+          <a-form-item label="企业邮箱" :labelCol="labelCol" :wrapperCol="wrapperCol" name="email">
+            <a-input placeholder="请输入邮箱" />
           </a-form-item>
         </template>
         <template v-if="siteCode !== dictSiteCode">
-          <a-form-item label="手机号码" :labelCol="labelCol" :wrapperCol="wrapperCol">
-            <a-input placeholder="请输入手机号码" v-decorator="['phone', validatorRules.phone]" />
+          <a-form-item label="手机号码" :labelCol="labelCol" :wrapperCol="wrapperCol" name="phone">
+            <a-input placeholder="请输入手机号码" />
           </a-form-item>
-          <a-form-item label="邮箱" :labelCol="labelCol" :wrapperCol="wrapperCol">
-            <a-input
-              placeholder="请输入邮箱"
-              v-decorator="['email', { rules: [{ type: 'email', message: '请输入正确的邮箱地址', required: isMasterAccount }] }]"
-            />
+          <a-form-item label="邮箱" :labelCol="labelCol" :wrapperCol="wrapperCol" name="email">
+            <a-input placeholder="请输入邮箱" />
           </a-form-item>
         </template>
         <a-form-item label="头像" :labelCol="labelCol" :wrapperCol="wrapperCol">
@@ -83,7 +69,7 @@
   </a-drawer>
 </template>
 
-<script lang="ts" setup name="EnterpriseUserModal">
+<script lang="ts" setup>
   // 引入搜索部门弹出框的组件
   import enterpriseDepartWindow from './EnterpriseDepartWindow.vue';
 
@@ -94,6 +80,7 @@
   import { nextTick, onBeforeMount, reactive, ref } from 'vue';
   import { useUserStore } from '/@/store/modules/user';
   import pick from 'lodash.pick';
+  import type { FormInstance } from 'ant-design-vue';
 
   const userStore = useUserStore();
   const isMasterAccount = ref(false);
@@ -103,7 +90,7 @@
   const confirmDirty = ref(false);
   const modalWidth = ref(800);
   let drawerWidth = ref(700);
-  const formRef = ref();
+  const formRef = ref<FormInstance>();
   const queryParam = reactive({ username: userStore.getUserInfo.username });
   let selectedDepartKeys = reactive([]);
   let checkedDepartKeys = reactive([]);
@@ -114,68 +101,48 @@
   const disableSubmit = ref(false);
   const userDepartModel = reactive({ userId: '', departIdList: [] }); // 保存SysUserDepart的用户部门中间表数据需要的对象
   const dateFormat = ref('YYYY-MM-DD');
-  const validatorRules = reactive({
-    username: {
-      rules: [
-        {
-          required: true,
-          message: '请输入用户账号!',
-        },
-        {
-          validator: validateUsername,
-        },
-      ],
-    },
-    password: {
-      rules: [
-        {
-          required: true,
-          pattern: /^(?=.*[a-zA-Z])(?=.*\d)(?=.*[~!@#$%^&*()_+`\-={}:";'<>?,./]).{8,}$/,
-          message: '密码由8位数字、大小写字母和特殊符号组成!',
-        },
-        {
-          validator: validateToNextPassword,
-        },
-      ],
-    },
-    confirmpassword: {
-      rules: [
-        {
-          required: true,
-          message: '请重新输入登录密码!',
-        },
-        {
-          validator: compareToFirstPassword,
-        },
-      ],
-    },
-    realname: { rules: [{ required: true, message: '请输入用户名称!' }] },
-    phone: { rules: [{ validator: validatePhone }] },
-    email: {
-      rules: [
-        {
-          validator: validateEmail,
-        },
-      ],
-    },
+  const formRules = reactive({
+    username: [
+      { required: true, message: '请输入用户账号', trigger: 'blur' },
+      {
+        validator: validateUsername,
+      },
+    ],
+    password: [
+      {
+        required: true,
+        pattern: /^(?=.*[a-zA-Z])(?=.*\d)(?=.*[~!@#$%^&*()_+`\-={}:";'<>?,./]).{8,}$/,
+        message: '密码由8位数字、大小写字母和特殊符号组成!',
+      },
+      {
+        validator: validateToNextPassword,
+      },
+    ],
+    confirmpassword: [
+      {
+        required: true,
+        message: '请重新输入登录密码!',
+      },
+      {
+        validator: compareToFirstPassword,
+      },
+    ],
+    realname: [{ required: true, message: '请输入用户名称!' }],
+    phone: [{ validator: validatePhone }],
+    email: [
+      {
+        validator: validateEmail,
+      },
+    ],
     roles: {},
-    //  sex:{initialValue:((!model.sex)?"": (model.sex+""))}
-    // workNo: {
-    //   rules: [
-    //     { required: true, message: '请输入工号' },
-    //     { validator: validateWorkNo }
-    //   ]
-    // },
-    telephone: {
-      rules: [{ pattern: /^0\d{2,3}-[1-9]\d{6,7}$/, message: '请输入正确的座机号码' }],
-    },
+    telephone: [{ pattern: /^0\d{2,3}-[1-9]\d{6,7}$/, message: '请输入正确的座机号码' }],
   });
 
   let departIdShow = ref(false);
   const departIds = reactive([]);
-  const title = '操作';
+  const title = ref('操作');
   const visible = ref(false);
-  let model = reactive({ userIdentity: '' });
+  let model = reactive({ userIdentity: '', id: '', tenantId: '' });
   let roleList = reactive([]);
   const selectedRole = ref([]);
   const labelCol = reactive({
@@ -205,6 +172,7 @@
     syncUserByUserName: '/act/process/extActProcess/doSyncUserByUserName', //同步用户到工作流
     queryTenantList: '/sys/tenant/queryList',
   };
+  const emit = defineEmits(['ok', 'close']);
 
   onBeforeMount(() => {
     initTenantList();
@@ -273,7 +241,6 @@
     initialRoleList();
     checkedDepartNameString.value = '';
 
-    formRef.value.resetFields();
     if (record.hasOwnProperty('id')) {
       loadUserRoles(record.id);
       setTimeout(() => {
@@ -283,7 +250,7 @@
     userId.value = record.id;
     model = Object.assign({}, record);
     nextTick(() => {
-      formRef.value.setFieldsValue(pick(model, 'username', 'sex', 'realname', 'email', 'phone', 'activitiSync', 'telephone', 'post'));
+      // formRef.value.setFieldsValue(pick(model, 'username', 'sex', 'realname', 'email', 'phone', 'activitiSync', 'telephone', 'post'));
     });
     visible.value = true;
     //身份为上级显示负责部门,否则不显示
@@ -305,7 +272,7 @@
   }
 
   function close() {
-    $emit('close');
+    emit('close');
     visible.value = false;
     disableSubmit.value = false;
     selectedRole.value = [];
@@ -482,21 +449,6 @@
     });
   }
 
-  // validateWorkNo(rule, value, callback){
-  //   var params = {
-  //     tableName: 'sys_user',
-  //     fieldName: 'work_no',
-  //     fieldVal: value,
-  //     dataId: userId
-  //   };
-  //   duplicateCheck(params).then((res) => {
-  //     if (res.success) {
-  //       callback()
-  //     } else {
-  //       callback("工号已存在!")
-  //     }
-  //   })
-  // },
   function handleConfirmBlur(e) {
     const value = e.target.value;
     confirmDirty.value = confirmDirty.value || !!value;
@@ -597,6 +549,7 @@
 
   defineExpose({
     add,
+    title,
   });
 </script>