Kaynağa Gözat

模块修改

“陈博论” 10 ay önce
ebeveyn
işleme
238adb805e

+ 12 - 3
web/src/api/backend/company/index.ts → web/src/api/backend/userCenter/index.ts

@@ -1,10 +1,19 @@
 import createAxios from '/@/utils/axios'
 
+// 添加、编辑
+export function list(data: anyObj) {
+    return createAxios({
+        url: '/admin/userCenter.index/index',
+        method: 'get',
+        params: data,
+    })
+}
+
 
 // 添加、编辑
 export function edit(data: anyObj) {
     return createAxios({
-        url: '/admin/company.index/edit',
+        url: '/admin/userCenter.index/edit',
         method: 'post',
         data: data,
     })
@@ -13,7 +22,7 @@ export function edit(data: anyObj) {
 // 删除
 export function del(data:anyObj) {
     return createAxios({
-        url: '/admin/company.index/delete',
+        url: '/admin/userCenter.index/delete',
         method: 'post',
         data: data,
     })
@@ -22,7 +31,7 @@ export function del(data:anyObj) {
 // 禁用/启用企业 传id
 export function toggleStatus(data:anyObj) {
     return createAxios({
-        url: '/admin/company.index/toggleStatus',
+        url: '/admin/userCenter.index/toggleStatus',
         method: 'post',
         data: data,
     })

+ 21 - 7
web/src/api/backend/userCenter/user.ts

@@ -1,6 +1,15 @@
 import createAxios from '/@/utils/axios'
 
 
+// 列表
+export function list(data: anyObj) {
+    return createAxios({
+        url: '/admin/userCenter.user/index',
+        method: 'get',
+        params: data,
+    })
+}
+
 // 添加、编辑
 export function edit(data: anyObj) {
     return createAxios({
@@ -11,16 +20,21 @@ export function edit(data: anyObj) {
 }
 
 // 删除
-export function del(data:anyObj) {
-    return createAxios({
-        url: '/admin/userCenter.user/delete',
-        method: 'post',
-        data: data,
-    })
+export function del(data: anyObj) {
+    return createAxios(
+        {
+            url: '/admin/userCenter.user/delete',
+            method: 'post',
+            data: data,
+        },
+        {
+            showSuccessMessage: true,
+        }
+    )
 }
 
 // 解除上下级关系
-export function removeSubordinate(data:anyObj) {
+export function removeSubordinate(data: anyObj) {
     return createAxios({
         url: '/userCenter.user/removeSubordinate',
         method: 'get',

+ 6 - 1
web/src/views/backend/product/combo/index.vue

@@ -216,7 +216,12 @@ const baTable = new baTableClass(
             remaining_stock: 0,
             sold_quantity: 0,
         },
-    }
+    },
+    {
+		onTableDblclick: () => {
+			return false
+		},
+	},
 )
 
 // 覆写获取数据方法,基于筛选条件过滤静态数据

+ 14 - 70
web/src/views/backend/product/product/index.vue

@@ -36,7 +36,7 @@
 </template>
 
 <script setup lang="ts">
-import { onMounted, provide } from 'vue'
+import { provide } from 'vue'
 import { cloneDeep } from 'lodash-es'
 import baTableClass from '/@/utils/baTable'
 import Table from '/@/components/table/index.vue'
@@ -48,13 +48,13 @@ import { useI18n } from 'vue-i18n'
 type TableRow = Record<string, any>
 
 defineOptions({
-    name: 'application/product',
+    name: 'product/product',
 })
 
 const { t } = useI18n()
 
 const baTable = new baTableClass(
-    new baTableApi('/admin/auth.Admin/'),
+    new baTableApi('/admin/product.product/'),
     {
         column: [
             { label: '编号', prop: 'id', align: 'center', width: 70 },
@@ -80,7 +80,7 @@ const baTable = new baTableClass(
             },
             {
                 label: '库存状态',
-                prop: 'inventory_status',
+                prop: 'stock_status',
                 align: 'center',
                 render: 'tag',
                 custom: {
@@ -149,73 +149,21 @@ const baTable = new baTableClass(
             package: '',
             description: '',
             image: '',
-            inventory_status: '1',
+            stock_status: '1',
             status: '1',
             type: '1',
             link: '',
         },
-    }
+    },
+    {
+		onTableDblclick: () => {
+			return false
+		},
+	},
 )
 
-// 设置假数据
-baTable.getData = () => {
-    baTable.table.loading = true
-    // 模拟异步请求
-    return new Promise<void>((resolve) => {
-        setTimeout(() => {
-            baTable.table.data = [
-                {
-                    id: 1,
-                    name: '聚德神笔',
-                    image: 'https://picsum.photos/200/300',
-                    package: '聚德神笔套餐A',
-                    inventory_status: '1',
-                    status: '1',
-                    description: '这是聚德神笔',
-                    create_time: '2025-10-13 10:00:00',
-                    type: 1,
-                },
-                {
-                    id: 2,
-                    name: '棱镜',
-                    image: 'https://picsum.photos/300',
-                    package: '棱镜套餐B',
-                    inventory_status: '2',
-                    status: '0',
-                    description: '这是棱镜',
-                    create_time: '2025-10-13 11:00:00',
-                    type: 2,
-                },
-                {
-                    id: 3,
-                    name: '测试产品',
-                    image: 'https://picsum.photos/100',
-                    package: '测试套餐2',
-                    inventory_status: '3',
-                    status: '0',
-                    description: '我是描述内容',
-                    create_time: '2025-10-13 11:00:00',
-                    type: 1,
-                },
-                {
-                    id: 4,
-                    name: '测试产品',
-                    image: 'https://picsum.photos/400',
-                    package: '测试套餐',
-                    inventory_status: '1',
-                    status: '1',
-                    description: '这是一个测试产品',
-                    create_time: '2025-10-14 09:00:00',
-                    type: 2,
-                },
-            ]
-            baTable.table.total = 4
-            baTable.table.loading = false
-            resolve()
-        }, 300)
-    })
-}
-
+baTable.mount()
+baTable.getData()
 provide('baTable', baTable)
 
 const del = (row: TableRow) => {
@@ -231,11 +179,7 @@ const openForm = (type: 'Add' | 'Edit', row?: TableRow) => {
 
 const onAdd = () => openForm('Add')
 const onEdit = (row: TableRow) => openForm('Edit', row)
-
-onMounted(() => {
-    baTable.mount()
-    baTable.getData()
-})
+ 
 </script>
 
 <style scoped lang="scss"></style>

+ 6 - 1
web/src/views/backend/user/group/index.vue

@@ -69,7 +69,12 @@ const baTable = new baTableClass(
         defaultItems: {
             status: 1,
         },
-    }
+    },
+    {
+		onTableDblclick: () => {
+			return false
+		},
+	},
 )
 
 // 利用提交前钩子重写提交操作

+ 44 - 20
web/src/views/backend/company/index.vue → web/src/views/backend/userCenter/index/index.vue

@@ -9,12 +9,10 @@
                 placeholder="企业名称" clearable />
             <el-select class="form-input" v-model="baTable.table.filter!.status" @change="onSearchInput"
                 placeholder="状态" clearable>
-                <el-option label="正常" value="1" />
-                <el-option label="禁用" value="0" />
+                <el-option label="正常" :value="1" />
+                <el-option label="禁用" :value="0" />
             </el-select>
-            <template #quickSearchPrepend>
-                <el-button type="primary" @click="onAdd">添加</el-button>
-            </template>
+            <!-- <el-button type="primary" @click="onAdd" v-auth="'edit'">添加</el-button> -->
         </TableHeader>
 
         <!-- 表格 -->
@@ -23,27 +21,27 @@
             <template #status>
                 <el-table-column prop="status" align="center" label="状态" min-width="150">
                     <template #default="scope">
-                        <el-switch v-model="scope.row.status" active-value="1" inactive-value="0" />
+                        <el-switch @change="changeStatus(scope.row)" v-model="scope.row.status" :active-value="1" :inactive-value="0" />
                     </template>
                 </el-table-column>
             </template>
             <template #operate>
                 <el-table-column prop="operate" align="center" label="操作" min-width="150">
                     <template #default="scope">
-                        <el-button type="primary" size="small" @click="onEdit(scope.row)">编辑</el-button>
-                        <el-button type="danger" size="small" @click="del(scope.row)">删除</el-button>
+                        <el-button type="primary" size="small" @click="onEdit(scope.row)" v-auth="'edit'">编辑</el-button>
+                        <el-button type="danger" size="small" @click="handleDel(scope.row)" v-auth="'delete'">删除</el-button>
                     </template>
                 </el-table-column>
             </template>
         </Table>
 
         <!-- 表单 -->
-        <PopupForm />
+        <PopupForm @success="baTable.getIndex()" />
     </div>
 </template>
 
 <script setup lang="ts">
-import { onMounted, provide, } from 'vue'
+import { provide, } from 'vue'
 import { cloneDeep } from 'lodash-es'
 import baTableClass from '/@/utils/baTable'
 import Table from '/@/components/table/index.vue'
@@ -51,6 +49,8 @@ import TableHeader from '/@/components/table/header/index.vue'
 import PopupForm from './popupForm.vue'
 import { baTableApi } from '/@/api/common'
 import { useI18n } from 'vue-i18n'
+import { toggleStatus,del } from '/@/api/backend/userCenter/index'
+import { ElMessageBox } from 'element-plus'
 
 defineOptions({
     name: 'company/index',
@@ -89,21 +89,27 @@ const baTable = new baTableClass(
                 align: 'center',
                 minWidth: 160
             },
-            {
-                label: '操作',
-                align: 'center',
-                render: 'slot',
-                slotName: 'operate',
-                operator: false,
-            },
+            // {
+            //     label: '操作',
+            //     align: 'center',
+            //     render: 'slot',
+            //     slotName: 'operate',
+            //     operator: false,
+            // },
         ],
         dblClickNotEditColumn: [undefined,],
     },
     {
         defaultItems: {
             status: '1',
+            id: null,
         },
-    }
+    },
+    {
+		onTableDblclick: () => {
+			return false
+		},
+	},
 )
 
 
@@ -117,9 +123,27 @@ const onSearchInput = () => {
     baTable.getData()
 }
 
+// 改变企业状态
+const changeStatus = (row:TableRow)=>{
+    baTable.table.loading = true
+    toggleStatus({id:row.id}).then(()=>{
+        baTable.getIndex()
+    }).finally(()=>{
+        baTable.table.loading = false
+    })
+}
+
 // 删除
-const del = (row: TableRow) => {
-    baTable.onTableAction('delete', { row })
+const handleDel = (row: TableRow) => {
+    ElMessageBox.confirm(`确定删除企业"${row.name}"吗?`, '提示', {
+        confirmButtonText: '确定',
+        cancelButtonText: '取消',
+        type: 'warning',
+    }).then(() => {
+        del({ id: row.id }).then(() => {
+            baTable.getIndex()
+        })
+    })
 }
 
 const openForm = (type: 'Add' | 'Edit', row?: TableRow) => {

+ 36 - 11
web/src/views/backend/company/popupForm.vue → web/src/views/backend/userCenter/index/popupForm.vue

@@ -41,6 +41,7 @@
                             v-model="baTable.form.items!.creator"
                             placeholder="请选择所属人"
                             style="width: 100%"
+                            filterable
                         >
                             <el-option
                                 v-for="item in userOptions"
@@ -72,19 +73,20 @@
 </template>
 
 <script setup lang="ts">
-import { reactive, inject,  useTemplateRef } from 'vue'
+import { ref,reactive, inject,  useTemplateRef,onMounted } from 'vue'
 import { useI18n } from 'vue-i18n'
 import type baTableClass from '/@/utils/baTable'
 import type { FormItemRule } from 'element-plus'
 import { useConfig } from '/@/stores/config'
 import FormItem from '/@/components/formItem/index.vue'
 import { buildValidatorData } from '/@/utils/validate'
-import { edit } from '/@/api/backend/company/index'
+import { edit } from '/@/api/backend/userCenter/index'
+import { list } from '/@/api/backend/userCenter/user'
 
 const config = useConfig()
 const formRef = useTemplateRef('formRef')
 const baTable = inject('baTable') as baTableClass
-
+const emit = defineEmits(['success'])
 const { t } = useI18n()
 
 const rules: Partial<Record<string, FormItemRule[]>> = reactive({
@@ -92,13 +94,21 @@ const rules: Partial<Record<string, FormItemRule[]>> = reactive({
     
 })
 
-const userOptions = [
-    { label: '张三', value: '张三' },
-    { label: '李四', value: '李四' },
-    { label: '王五', value: '王五' },
-    { label: '赵六', value: '赵六' },
-    { label: '刘七', value: '刘七' },
-]
+interface UserOption {
+    label: string
+    value: string
+}
+
+const userOptions = ref<UserOption[]>([])
+
+const getUserList = () => {
+    list({ page: 1, limit: 1000 }).then((res: any) => {
+        userOptions.value = res.data.list.map((item: any) => ({
+            label: item.name,
+            value: item.id,
+        }))
+    })
+}
 
 const statusOptions = {
     '0': '禁用',
@@ -110,11 +120,26 @@ const btnSubmit = () => {
 	formRef.value?.validate((valid: boolean) => {
 		if (valid) {
             baTable.table.loading = true
-			
+
+            let params = {
+                id: baTable.form.items!.id,
+                name: baTable.form.items!.name,
+                status: baTable.form.items!.status,
+                creator: baTable.form.items!.creator,
+            }
+
+            edit(params).then(() => {
+                baTable.table.loading = false
+                baTable.toggleForm()
+                emit('success')
+            })
 		}
 	})
 }
 
+onMounted(() => {
+    getUserList()
+})
 </script>
 
 <style scoped lang="scss">

+ 15 - 5
web/src/views/backend/userCenter/user/index.vue

@@ -24,7 +24,7 @@
                 <el-table-column prop="operate" align="center" label="操作" min-width="210">
                     <template #default="scope">
                         <el-button type="primary" size="small" @click="onEdit(scope.row)">编辑</el-button>
-                        <el-button type="danger" size="small" @click="del(scope.row)">删除</el-button>
+                        <el-button type="danger" size="small" @click="handleDelete(scope.row)">删除</el-button>
                         <el-button type="primary" plain size="small" @click="detail(scope.row)">详情</el-button>
                     </template>
                 </el-table-column>
@@ -32,7 +32,7 @@
         </Table>
 
         <!-- 表单 -->
-        <PopupForm />
+        <PopupForm @success="baTable.getIndex()" />
 
         <!-- 详情弹框 -->
         <DetailDialog ref="detailDialogRef" />
@@ -49,6 +49,8 @@ import PopupForm from './popupForm.vue'
 import DetailDialog from './detailDialog.vue'
 import { baTableApi } from '/@/api/common'
 import { useI18n } from 'vue-i18n'
+import { del } from '/@/api/backend/userCenter/user'
+import { ElMessageBox } from 'element-plus'
 
 defineOptions({
     name: 'userCenter/user',
@@ -71,7 +73,7 @@ const baTable = new baTableClass(
                 label: '邮箱',
                 prop: 'email',
                 align: 'center',
-                minWidth: 150
+                minWidth: 170
             },
             {
                 label: '企业',
@@ -134,8 +136,16 @@ const onSearchInput = () => {
 }
 
 // 删除
-const del = (row: TableRow) => {
-    baTable.onTableAction('delete', { row })
+const handleDelete = (row: TableRow) => {
+    ElMessageBox.confirm(`确定删除用户"${row.name}"吗?`, '提示', {
+        confirmButtonText: '确定',
+        cancelButtonText: '取消',
+        type: 'warning',
+    }).then(() => {
+        del({ id: row.id }).then(() => {
+            baTable.getIndex()
+        })
+    })
 }
 
 const openForm = (type: 'Add' | 'Edit', row?: TableRow) => {

+ 41 - 8
web/src/views/backend/userCenter/user/popupForm.vue

@@ -6,6 +6,8 @@
         :model-value="['Add', 'Edit'].includes(baTable.form.operate!)"
         @close="baTable.toggleForm"
         :destroy-on-close="true"
+        width="600px"
+        style="height: 400px;"
     >
         <template #header>
             <div class="title" v-drag="['.ba-operate-dialog', '.el-dialog__header']" v-zoom="'.ba-operate-dialog'">
@@ -53,6 +55,8 @@
                             v-model="baTable.form.items!.company"
                             placeholder="请选择企业"
                             style="width: 100%"
+                            clearable
+                            filterable
                         >
                             <el-option
                                 v-for="item in companyOptions"
@@ -84,7 +88,7 @@
 </template>
 
 <script setup lang="ts">
-import { reactive, inject,  useTemplateRef } from 'vue'
+import { reactive,ref, inject,  useTemplateRef ,onMounted} from 'vue'
 import { useI18n } from 'vue-i18n'
 import type baTableClass from '/@/utils/baTable'
 import FormItem from '/@/components/formItem/index.vue'
@@ -92,10 +96,12 @@ import type { FormItemRule } from 'element-plus'
 import { useConfig } from '/@/stores/config'
 import { buildValidatorData } from '/@/utils/validate'
 import { edit } from '/@/api/backend/userCenter/user'
+import { list } from '/@/api/backend/userCenter/index'
 
 const config = useConfig()
 const formRef = useTemplateRef('formRef')
 const baTable = inject('baTable') as baTableClass
+const emit = defineEmits(['success'])
 
 const { t } = useI18n()
 
@@ -121,29 +127,56 @@ const rules: Partial<Record<string, FormItemRule[]>> = reactive({
     ],
 })
 
-const companyOptions = [
-    { label: '腾达', value: '腾达' },
-    { label: '聚德科技', value: '聚德科技' },
-    { label: '棱镜科技', value: '棱镜科技' },
-    { label: '测试公司', value: '测试公司' },
-    { label: '示例企业', value: '示例企业' },
-]
+interface CompanyOption {
+    label: string
+    value: string
+}
+
+const companyOptions = ref<CompanyOption[]>([])
 
 const statusOptions = {
     '0': '禁用',
     '1': '启用',
 }
 
+const getCompanyList = () => {
+    list({ page: 1, limit: 1000 }).then((res: any) => {
+        companyOptions.value = res.data.list.map((item: any) => ({
+            label: item.name,
+            value: item.id,
+        }))
+    })
+}
+
 // 提交
 const btnSubmit = () => {
 	formRef.value?.validate((valid: boolean) => {
 		if (valid) {
             baTable.table.loading = true
+
+            let params = {
+                id: baTable.form.items!.id,
+                name: baTable.form.items!.name,
+                email:baTable.form.items!.email,
+                company:baTable.form.items!.company,
+                password:baTable.form.items!.password,
+                status: baTable.form.items!.status,
+            }
+
+            edit(params).then(() => {
+                baTable.toggleForm()
+                emit('success')
+            }).finally(()=>{
+                baTable.table.loading = false
+            })
 			
 		}
 	})
 }
 
+onMounted(() => {
+    getCompanyList()
+})
 </script>
 
 <style scoped lang="scss">