Browse Source

修改提交

王飞 1 year ago
parent
commit
39624e6632

BIN
public/favicon.ico


BIN
public/logo.png


+ 5 - 1
src/api/manage/dict.ts

@@ -5,10 +5,14 @@ export const getTree = (data?: any) => {
   return request.post({ url: '/api/sysDictionary/showTree', data })
 }
 
-export const getDict = (data: any) => {
+export const getDictPage = (data: any) => {
   return request.post({ url: '/api/sysDictionary/page', data })
 }
 
+export const getDict = (data: any) => {
+  return request.post({ url: '/api/sysDictionary/list', data })
+}
+
 export const delTableListApi = (id: string | number): Promise<IResponse> => {
   return request.delete({ url: `/api/sysDictionary/${id}` })
 }

BIN
src/assets/imgs/favicon.ico


BIN
src/assets/imgs/logo.png


+ 23 - 1
src/hooks/web/useValidator.ts

@@ -54,11 +54,33 @@ export const useValidator = () => {
     }
   }
 
+  const isEmail = (val: any, callback: Callback, message: string) => {
+    // 判断是否是邮箱
+    if (!/^\w+([-+.]\w+)*@\w+([-.]\w+)*\.\w+([-.]\w+)*$/g.test(val)) {
+      callback(new Error(message))
+    } else {
+      callback()
+    }
+  }
+
+  const isMobilePhone = (val: any, callback: Callback, message: string) => {
+    // 判断是否是手机号
+    if (
+      !/^(13[0-9]|14[01456879]|15[0-35-9]|16[2567]|17[0-8]|18[0-9]|19[0-35-9])\d{8}$/g.test(val)
+    ) {
+      callback(new Error(message))
+    } else {
+      callback()
+    }
+  }
+
   return {
     required,
     lengthRange,
     notSpace,
     notSpecialCharacters,
-    isEqual
+    isEqual,
+    isEmail,
+    isMobilePhone
   }
 }

+ 37 - 57
src/views/Authorization/Dict/Dict.vue

@@ -3,26 +3,31 @@ import { ContentWrap } from '@/components/ContentWrap'
 import { useI18n } from '@/hooks/web/useI18n'
 import { Table } from '@/components/Table'
 import { ref, unref, reactive } from 'vue'
-import { ElButton, ElButtonGroup, ElTooltip } from 'element-plus'
-import { getTree, saveTableApi, delTableListApi, updateTableApi } from '@/api/manage/dict'
+import { ElButton, ElButtonGroup, ElTooltip, ElTree } from 'element-plus'
+import { getDict, saveTableApi, delTableListApi, updateTableApi } from '@/api/manage/dict'
 import type { DictData, DictRowData } from '@/api/manage/types'
 import { useTable } from '@/hooks/web/useTable'
 import { Search } from '@/components/Search'
 import Write from './components/Write.vue'
-import Detail from './components/Detail.vue'
+// import Detail from './components/Detail.vue'
 import { Dialog } from '@/components/Dialog'
 import { CrudSchema, useCrudSchemas } from '@/hooks/web/useCrudSchemas'
 import { useIcon } from '@/hooks/web/useIcon'
+import { listToTree } from '@/utils/tree'
+
 const EditIcon = useIcon({ icon: 'ep:edit' })
 const DetailIcon = useIcon({ icon: 'ep:document' })
 const DeleteIcon = useIcon({ icon: 'ep:delete' })
 
 const { t } = useI18n()
+const treeEl = ref<typeof ElTree>()
+const currentNodeKey = ref('')
+const dictList = ref<DictRowData[]>([])
 
 const { tableRegister, tableState, tableMethods } = useTable({
   fetchDataApi: async () => {
-    const res = await getTree({
-      pid: '',
+    const res = await getDict({
+      pid: currentNodeKey.value,
       ...unref(searchParams)
     })
     return {
@@ -177,33 +182,16 @@ const dialogTitle = ref('')
 const currentRow = ref<DictData>()
 const actionType = ref('')
 
-const load = async (
-  row: DictRowData,
-  _treeNode: unknown,
-  resolve: (date: DictRowData[]) => void
-) => {
-  const res = await getTree({
-    pid: row.id,
-    ...unref(searchParams)
-  })
-  resolve(
-    res.data.map((e: DictRowData) => {
-      return {
-        ...e,
-        hasChildren: true
-      }
-    })
-  )
+getDict({ pid: '' }).then((res) => {
+  dictList.value = listToTree(res.data)
+})
+const currentChange = (data: DictRowData) => {
+  currentNodeKey.value = data.id
+  getList()
 }
 
-const AddAction = (key: string) => {
+const AddAction = () => {
   dialogTitle.value = '新增'
-  currentRow.value = undefined
-  if (key) {
-    currentRow.value = {
-      pid: key
-    }
-  }
   dialogVisible.value = true
   actionType.value = 'add'
 }
@@ -228,7 +216,7 @@ const action = (row: DictData, type: string) => {
 }
 
 const writeRef = ref<ComponentRef<typeof Write>>()
-const tableRef = ref<ComponentRef<typeof Table>>()
+// const tableRef = ref<ComponentRef<typeof Table>>()
 const saveLoading = ref(false)
 const save = async (action) => {
   const write = unref(writeRef)
@@ -258,8 +246,22 @@ const save = async (action) => {
 </script>
 
 <template>
-  <div>
-    <ContentWrap>
+  <div class="flex w-100% h-100%">
+    <ContentWrap class="flex-1">
+      <ElTree
+        ref="treeEl"
+        :data="dictList"
+        default-expand-all
+        node-key="id"
+        :current-node-key="currentNodeKey"
+        :highlight-current="true"
+        :props="{
+          label: 'name'
+        }"
+        @current-change="currentChange"
+      />
+    </ContentWrap>
+    <ContentWrap class="flex-[3] ml-20px">
       <Search
         :schema="allSchemas.searchSchema"
         @reset="setSearchParams"
@@ -267,46 +269,24 @@ const save = async (action) => {
       />
 
       <div class="mb-10px">
-        <ElButton type="primary" @click="AddAction('')">{{ t('exampleDemo.add') }}</ElButton>
+        <ElButton type="primary" @click="AddAction">{{ t('exampleDemo.add') }}</ElButton>
       </div>
       <Table
-        ref="tableRef"
         v-model:current-page="currentPage"
         v-model:page-size="pageSize"
         :columns="allSchemas.tableColumns"
         :data="dataList"
         :loading="loading"
-        row-key="id"
-        :load="load"
         @register="tableRegister"
       />
     </ContentWrap>
 
     <Dialog v-model="dialogVisible" :title="dialogTitle">
-      <Write
-        v-if="actionType !== 'detail'"
-        ref="writeRef"
-        :form-schema="allSchemas.formSchema"
-        :current-row="currentRow"
-      />
-
-      <Detail
-        v-if="actionType === 'detail'"
-        ref="detailRef"
-        :columns="allSchemas"
-        :row-data="currentRow"
-      />
-
+      <Write ref="writeRef" :form-schema="allSchemas.formSchema" :current-row="currentRow" />
       <template #footer>
-        <ElButton
-          v-if="actionType !== 'detail'"
-          type="primary"
-          :loading="saveLoading"
-          @click="save(actionType)"
-        >
+        <ElButton type="primary" :loading="saveLoading" @click="save">
           {{ t('exampleDemo.save') }}
         </ElButton>
-
         <ElButton @click="dialogVisible = false">{{ t('dialogDemo.close') }}</ElButton>
       </template>
     </Dialog>

+ 2 - 2
src/views/Authorization/Dict/components/Detail.vue

@@ -4,7 +4,7 @@ import { useI18n } from '@/hooks/web/useI18n'
 import { Table } from '@/components/Table'
 import { ref, unref, PropType, reactive } from 'vue'
 import { ElButton, ElButtonGroup, ElTooltip } from 'element-plus'
-import { getTree, saveTableApi, delTableListApi, updateTableApi } from '@/api/manage/dict'
+import { getDict, saveTableApi, delTableListApi, updateTableApi } from '@/api/manage/dict'
 import type { DictData, DictRowData } from '@/api/manage/types'
 import { useTable } from '@/hooks/web/useTable'
 import { Search } from '@/components/Search'
@@ -27,7 +27,7 @@ const { t } = useI18n()
 
 const { tableRegister, tableState, tableMethods } = useTable({
   fetchDataApi: async () => {
-    const res = await getTree({
+    const res = await getDict({
       pid: props.rowData?.id,
       ...unref(searchParams)
     })

+ 1 - 1
src/views/Authorization/User/User.vue

@@ -2,7 +2,7 @@
 import { ContentWrap } from '@/components/ContentWrap'
 import { useI18n } from '@/hooks/web/useI18n'
 import { Table } from '@/components/Table'
-import { ref, unref, watch, reactive, nextTick } from 'vue'
+import { ref, unref, watch, reactive } from 'vue'
 import { ElButton, ElTree, ElTooltip, ElButtonGroup } from 'element-plus'
 import { getUserList, addUser, updataUser, deleteUserById, getRoleApi } from '@/api/department'
 import type { DepartmentUserItem } from '@/api/department/types'

+ 12 - 2
src/views/Manage/Company/components/Write.vue

@@ -5,7 +5,7 @@ import { PropType, reactive, watch } from 'vue'
 import { CompanyData } from '@/api/manage/types'
 import { useValidator } from '@/hooks/web/useValidator'
 
-const { required } = useValidator()
+const { required, isEmail } = useValidator()
 
 const props = defineProps({
   currentRow: {
@@ -19,7 +19,17 @@ const props = defineProps({
 })
 
 const rules = reactive({
-  companyName: [required()]
+  companyName: [required()],
+  companyEmail: [
+    required(),
+    {
+      validator: (_rule: any, value: any, callback: any) => {
+        isEmail(value, callback, '请输入正确的邮箱地址')
+      },
+      trigger: 'blur',
+      message: '请输入正确的邮箱地址'
+    }
+  ]
 })
 
 const { formRegister, formMethods } = useForm()

+ 3 - 0
src/views/Manage/File/components/Write.vue

@@ -19,6 +19,9 @@ const props = defineProps({
 })
 
 const rules = reactive({
+  name: [required()],
+  version: [required()],
+  code: [required()],
   virtualPath: [required()]
 })
 

+ 21 - 24
src/views/Manage/Img/ImgPage.vue

@@ -19,6 +19,9 @@ import Write from './components/Write.vue'
 import { useIcon } from '@/hooks/web/useIcon'
 import { uploadFile } from '@/api/common'
 import { Qrcode } from '@/components/Qrcode'
+import { DictRowData } from '@/api/manage/types'
+import { getDict } from '@/api/manage/dict'
+
 defineOptions({
   name: 'ImgPage'
 })
@@ -72,6 +75,13 @@ useEmitt({
     getList()
   }
 })
+const bannerTypeList = ref<DictRowData[]>([])
+
+getDict({
+  pid: '1693799827333287937'
+}).then((res) => {
+  bannerTypeList.value = res.data
+})
 
 const { t } = useI18n()
 const appStore = usePageStore()
@@ -85,34 +95,22 @@ const crudSchemas: CrudSchema[] = [
     table: {
       hidden: false,
       formatter: (_: Recordable, _colomun, cellValue: string) => {
-        return cellValue
-          ? cellValue === '0'
-            ? '首页Banner'
-            : cellValue === '1'
-            ? '公司图片'
-            : cellValue === '2'
-            ? '合作logo'
-            : ''
-          : ''
+        let option = bannerTypeList.value.find((item) => item.code === cellValue)
+        return option ? option.name : ''
       }
     },
     form: {
       component: 'Select',
-      componentProps: {
-        options: [
-          {
-            label: '首页Banner',
-            value: '0'
-          },
-          {
-            label: '公司图片',
-            value: '1'
-          },
-          {
-            label: '合作logo',
-            value: '2'
+      optionApi: async () => {
+        const res = await getDict({
+          pid: '1693799827333287937'
+        })
+        return res.data.map((e: DictRowData) => {
+          return {
+            label: e.name,
+            value: e.code
           }
-        ]
+        })
       }
     }
   },
@@ -304,7 +302,6 @@ const save = async () => {
       if (formData.id) {
         let res = await updateTableApi(formData)
         if (res) {
-          currentPage.value = 1
           getList()
         }
       } else {

+ 0 - 15
src/views/Manage/News/components/Write.vue

@@ -49,21 +49,6 @@ const schema = reactive<FormSchema[]>([
       placeholder: '请输入'
     }
   },
-  {
-    field: 'date',
-    label: '日期范围',
-    component: 'DatePicker',
-    formItemProps: {
-      rules: [required()]
-    },
-    colProps: {
-      span: 24
-    },
-    componentProps: {
-      type: 'daterange',
-      placeholder: '请输入'
-    }
-  },
   {
     field: 'categoryId',
     label: '文章类目',