Browse Source

feat: 增加同步计量账号功能

lanjianrong 3 năm trước cách đây
mục cha
commit
2c035d17f3

+ 10 - 1
src/api/sys/project.ts

@@ -15,7 +15,8 @@ enum Api {
   AddProject = '/backstage/project/add',
   GetProjectAccount = '/backstage/account',
   AddProjectAccount = '/backstage/account/create',
-  SaveProjectAccount = '/backstage/account/save'
+  SaveProjectAccount = '/backstage/account/save',
+  SyncProjectAccountFormJL = '/backstage/account/sync'
 }
 
 /**
@@ -83,3 +84,11 @@ export function saveProjectAccount(params: AddOrUpdateProjectAccountParams) {
     params
   })
 }
+
+/** 同步计量账号 */
+export function syncProjectAccountFromJL(params: { id: string }) {
+  return defHttp.post({
+    url: Api.SyncProjectAccountFormJL,
+    params
+  })
+}

+ 1 - 1
src/api/sys/user.ts

@@ -57,7 +57,7 @@ export function getXsrfToken(code: string) {
 }
 
 export function logoutApi() {
-  return defHttp.post({
+  return defHttp.get({
     url: Api.Logout
   })
 }

+ 23 - 9
src/views/dashboard/project-detail/components/account.vue

@@ -3,7 +3,10 @@
     <template #toolbar>
       <div class="w-2/5 flex justify-end">
         <!-- <Search @search="value => handleSearch('search', value)" placeholder="项目名称/项目编号" /> -->
-        <a-button v-if="hasPermission" @click="showModalFn" class="ml-3"><PlusOutlined />新增账号</a-button>
+        <a-button @click="syncAccount" class="ml-3">同步计量账号</a-button>
+        <a-button type="primary" v-if="hasPermission" @click="showModalFn" class="ml-3"
+          ><PlusOutlined />新增账号</a-button
+        >
       </div>
     </template>
   </BasicTable>
@@ -29,7 +32,12 @@
   import { PlusOutlined } from '@ant-design/icons-vue'
   import { BasicForm, FormActionType, FormSchema, useForm } from '/@/components/Form/index'
   import { getTableColumns } from './tableData'
-  import { getProjectAccount, addProjectAccount, saveProjectAccount } from '/@/api/sys/project'
+  import {
+    getProjectAccount,
+    addProjectAccount,
+    saveProjectAccount,
+    syncProjectAccountFromJL
+  } from '/@/api/sys/project'
   import { propTypes } from '/@/utils/propTypes'
   import { Switch } from 'ant-design-vue'
   import { Icon } from '/@/components/Icon/index'
@@ -69,7 +77,7 @@
       const formElRef = ref<Nullable<FormActionType>>(null)
       const formType = ref(0) // 0 - 创建账号 1 - 更新账号
       const { createMessage } = useMessage()
-      const [registerTable, { setTableData }] = useTable({
+      const [registerTable, { setTableData, reload }] = useTable({
         columns: getTableColumns((item: ProjectAccountItem) => showUpdateModalFn(item), props.hasPermission),
         showTableSetting: true,
         canResize: true
@@ -151,7 +159,7 @@
           slot: 'role'
         }
       ])
-      const [registerForm, { removeSchemaByFiled, appendSchemaByField }] = useForm({
+      const [registerForm, { removeSchemaByFiled, appendSchemaByField, updateSchema }] = useForm({
         labelWidth: 120,
         schemas,
         showActionButtonGroup: false
@@ -165,14 +173,14 @@
           okText: '确认添加'
         })
         await nextTick()
-        updateSchema({
+        await updateSchema({
           field: 'account',
           componentProps: {
             disabled: false
           }
         })
-        removeSchemaByFiled('password')
-        appendSchemaByField(
+        await removeSchemaByFiled('password')
+        await appendSchemaByField(
           {
             field: 'password',
             component: 'InputPassword',
@@ -181,7 +189,13 @@
           },
           'account'
         )
-        formElRef.value?.resetFields()
+        await formElRef.value?.resetFields()
+      }
+
+      /**同步计量账号 */
+      async function syncAccount() {
+        await syncProjectAccountFromJL({ id: props.id })
+        reload()
       }
 
       async function showUpdateModalFn(item: ProjectAccountItem) {
@@ -231,7 +245,7 @@
         await saveProjectAccount(values)
       }
 
-      return { formElRef, registerTable, registerModal, registerForm, showModalFn, submitModal }
+      return { formElRef, registerTable, registerModal, registerForm, showModalFn, submitModal, syncAccount }
     }
   })
 </script>