Browse Source

修复table表格的报错

mageAoe 2 years ago
parent
commit
2866f10ef3

+ 0 - 8
components.d.ts

@@ -17,14 +17,9 @@ declare module '@vue/runtime-core' {
     ElBreadcrumb: typeof import('element-plus/es')['ElBreadcrumb']
     ElBreadcrumbItem: typeof import('element-plus/es')['ElBreadcrumbItem']
     ElButton: typeof import('element-plus/es')['ElButton']
-    ElCard: typeof import('element-plus/es')['ElCard']
-    ElCheckbox: typeof import('element-plus/es')['ElCheckbox']
-    ElCheckboxGroup: typeof import('element-plus/es')['ElCheckboxGroup']
     ElCol: typeof import('element-plus/es')['ElCol']
     ElContainer: typeof import('element-plus/es')['ElContainer']
     ElDatePicker: typeof import('element-plus/es')['ElDatePicker']
-    ElDescriptions: typeof import('element-plus/es')['ElDescriptions']
-    ElDescriptionsItem: typeof import('element-plus/es')['ElDescriptionsItem']
     ElDialog: typeof import('element-plus/es')['ElDialog']
     ElDivider: typeof import('element-plus/es')['ElDivider']
     ElDrawer: typeof import('element-plus/es')['ElDrawer']
@@ -43,8 +38,6 @@ declare module '@vue/runtime-core' {
     ElMenuItem: typeof import('element-plus/es')['ElMenuItem']
     ElOption: typeof import('element-plus/es')['ElOption']
     ElPagination: typeof import('element-plus/es')['ElPagination']
-    ElRadio: typeof import('element-plus/es')['ElRadio']
-    ElRadioGroup: typeof import('element-plus/es')['ElRadioGroup']
     ElRow: typeof import('element-plus/es')['ElRow']
     ElScrollbar: typeof import('element-plus/es')['ElScrollbar']
     ElSelect: typeof import('element-plus/es')['ElSelect']
@@ -52,7 +45,6 @@ declare module '@vue/runtime-core' {
     ElTable: typeof import('element-plus/es')['ElTable']
     ElTableColumn: typeof import('element-plus/es')['ElTableColumn']
     ElTag: typeof import('element-plus/es')['ElTag']
-    ElText: typeof import('element-plus/es')['ElText']
     ElTooltip: typeof import('element-plus/es')['ElTooltip']
     ElUpload: typeof import('element-plus/es')['ElUpload']
     Loading: typeof import('./src/components/Loading/index.vue')['default']

+ 1 - 1
src/api/index.ts

@@ -12,7 +12,7 @@ let loadingInstance: LoadingType = {}
 
 const config = {
   // 默认地址请求地址,可在 .env.*** 文件中修改
-  baseURL: import.meta.env.VITE_BZD_ERP_APP_API as string,
+  // baseURL: import.meta.env.VITE_BZD_ERP_APP_API as string,
   // 设置超时时间(10s)
   timeout: ResultEnum.TIMEOUT as number,
   // 跨域时候允许携带凭证

+ 2 - 2
src/components/TableBase/index.vue

@@ -76,7 +76,7 @@ defineExpose({
   </div>
 
   <div class="card table" :style="{ height: cardHeight + 'px' }">
-    <el-table :data="tableData" @row-click="props.rowClick" :border="border">
+    <el-table :data="tableData" @row-click="props.rowClick" :border="border" row-key="prop">
       <!-- 默认插槽 -->
       <slot></slot>
       <template v-for="item in tableColumns" :key="item">
@@ -108,7 +108,7 @@ defineExpose({
         <el-table-column
           v-bind="item"
           :align="item.align ?? 'center'"
-          v-if="item.name === item.prop && item.type !== 'index'"
+          v-if="!item.type && item.prop && item.name === item.prop"
           v-slot="scope"
         >
           <slot :name="item.prop" :row="scope.row"></slot>

+ 40 - 40
src/router/modules/staticRouter.ts

@@ -13,46 +13,46 @@ export const staticRouter: RouteRecordRaw[] = [
       title: '起始页'
     },
     children: [
-      // {
-      //   path: '/list',
-      //   name: 'List',
-      //   component: () => import('@/views/storehouse/List.vue'),
-      //   meta: {
-      //     title: '仓库列表'
-      //   }
-      // },
-      // {
-      //   path: '/classify',
-      //   name: 'Classify',
-      //   component: () => import('@/views/storehouse/Classify.vue'),
-      //   meta: {
-      //     title: '产品分类'
-      //   }
-      // },
-      // {
-      //   path: '/productionList',
-      //   name: 'ProductionList',
-      //   component: () => import('@/views/storehouse/ProductionList.vue'),
-      //   meta: {
-      //     title: '产品列表'
-      //   }
-      // },
-      // {
-      //   path: '/ioTNetworkCard',
-      //   name: 'IoTNetworkCard',
-      //   component: () => import('@/views/storehouse/IoTNetworkCard.vue'),
-      //   meta: {
-      //     title: '物联网卡'
-      //   }
-      // },
-      // {
-      //   path: '/contract',
-      //   name: 'Contract',
-      //   component: () => import('@/views/storehouse/sales/Contract.vue'),
-      //   meta: {
-      //     title: '合同管理'
-      //   }
-      // }
+      {
+        path: '/list',
+        name: 'List',
+        component: () => import('@/views/storehouse/List.vue'),
+        meta: {
+          title: '仓库列表'
+        }
+      },
+      {
+        path: '/classify',
+        name: 'Classify',
+        component: () => import('@/views/storehouse/Classify.vue'),
+        meta: {
+          title: '产品分类'
+        }
+      },
+      {
+        path: '/productionList',
+        name: 'ProductionList',
+        component: () => import('@/views/storehouse/ProductionList.vue'),
+        meta: {
+          title: '产品列表'
+        }
+      },
+      {
+        path: '/ioTNetworkCard',
+        name: 'IoTNetworkCard',
+        component: () => import('@/views/storehouse/IoTNetworkCard.vue'),
+        meta: {
+          title: '物联网卡'
+        }
+      },
+      {
+        path: '/contract',
+        name: 'Contract',
+        component: () => import('@/views/storehouse/sales/Contract.vue'),
+        meta: {
+          title: '合同管理'
+        }
+      }
     ]
   },
   {

+ 0 - 244
src/views/storehouse/sales/Agreement.vue

@@ -1,244 +0,0 @@
-<script setup lang="ts">
-import {
-  Storehouse_IotCard_List,
-  Storehouse_IotCard_Add,
-  Storehouse_IotCard_Edit,
-  Storehouse_IotCard_Del
-} from '@/api/storehouse/index'
-import { GlobalStore } from '@/stores/index'
-import { ref, reactive, nextTick } from 'vue'
-import Drawer from '@/components/Drawer/index.vue'
-import TableBase from '@/components/TableBase/index.vue'
-import type { FormInstance, FormRules } from 'element-plus'
-import { Edit, Delete } from '@element-plus/icons-vue'
-import type { ColumnProps } from '@/components/TableBase/interface/index'
-import { ElMessageBox, ElMessage } from 'element-plus'
-
-const isNew = ref(true)
-const globalStore = GlobalStore()
-const formLabelWidth = ref('120px')
-const ruleFormRef = ref<FormInstance>()
-const drawerRef = ref<InstanceType<typeof Drawer> | null>(null)
-const TableRef = ref<InstanceType<typeof TableBase> | null>(null)
-
-const columns: ColumnProps[] = [
-  { type: 'index', label: '序号', width: 80 },
-  { prop: 'T_iccid', label: '物联网卡号' },
-  { prop: 'T_sn', label: '关联SN' },
-  { prop: 'T_State', label: '状态', name: 'T_State' },
-  { prop: 'T_type', label: '类型' },
-  { prop: 'operation', label: '操作', width: 200, fixed: 'right' }
-]
-
-// 添加仓库名称
-type Fn = () => void
-const form = reactive({
-  T_id: '',
-  T_sn: '',
-  T_type: '',
-  T_state: null,
-  T_iccid: ''
-})
-
-const validate_T_sn = (rule: any, value: any, callback: any) => {
-  if (form.T_state === 2 && value === '') {
-    callback(new Error('请输入关联SN'))
-  } else {
-    callback()
-  }
-}
-
-const rules = reactive<FormRules>({
-  T_iccid: [{ required: true, message: '请输入物联网卡号', trigger: 'blur' }],
-  T_state: [{ required: true, message: '请选择状态', trigger: 'blur' }],
-  T_type: [{ required: true, message: '请输入型号', trigger: 'blur' }],
-  T_sn: [{ validator: validate_T_sn, trigger: 'blur' }]
-})
-
-const callbackDrawer = (done: Fn) => {
-  resetForm(ruleFormRef.value)
-  done()
-}
-const openDrawer = (type: string, row?: any) => {
-  isNew.value = type === 'new' ? true : false
-  nextTick(() => {
-    form.T_id = row.Id
-    form.T_sn = row.T_sn
-    form.T_type = row.T_type
-    form.T_state = row.T_State
-    form.T_iccid = row.T_iccid
-  })
-  drawerRef.value?.openDrawer()
-}
-
-const resetForm = (formEl: FormInstance | undefined) => {
-  if (!formEl) return
-  formEl.resetFields()
-}
-
-const AddUserName = (formEl: FormInstance | undefined) => {
-  if (!formEl) return
-  formEl.validate(async valid => {
-    if (valid) {
-      let res: any = {}
-      if (isNew.value) {
-        console.log(form)
-        res = await Storehouse_IotCard_Add({ User_tokey: globalStore.GET_User_tokey, ...form })
-      } else {
-        res = await Storehouse_IotCard_Edit({
-          User_tokey: globalStore.GET_User_tokey,
-          ...form
-        })
-      }
-      if (res.Code === 200) {
-        ElMessage.success(`${isNew.value ? '添加' : '修改'}物联网卡成功!!`)
-        nextTick(() => {
-          drawerRef.value?.closeDrawer()
-          TableRef.value?.getTableList()
-          resetForm(ruleFormRef.value)
-          isNew.value = true
-        })
-      }
-    } else {
-      return false
-    }
-  })
-}
-
-// 删除
-const UserDelete = (row: any) => {
-  ElMessageBox.confirm('您确定要删除该物联网卡号吗?', '警告', {
-    confirmButtonText: '确定',
-    cancelButtonText: '取消',
-    type: 'warning'
-  })
-    .then(async () => {
-      const res: any = await Storehouse_IotCard_Del({ User_tokey: globalStore.GET_User_tokey, T_id: row.Id })
-      if (res.Code === 200) {
-        ElMessage.success('删除成功!')
-        nextTick(() => {
-          TableRef.value?.getTableList()
-        })
-      }
-    })
-    .catch(() => {
-      ElMessage.warning('取消成功!')
-    })
-}
-
-// 搜索
-const options = reactive([
-  { name: '未使用', id: 1 },
-  { name: '已使用', id: 2 },
-  { name: '已作废', id: 3 }
-])
-const initParam = reactive({
-  User_tokey: globalStore.GET_User_tokey,
-  T_name: '',
-  T_state: ''
-})
-const searchHandle = () => {
-  TableRef.value?.searchTable()
-}
-</script>
-
-<template>
-  <div class="agreement">
-    <TableBase ref="TableRef" :columns="columns" :requestApi="Storehouse_IotCard_List" :initParam="initParam">
-      <template #table-header>
-        <div class="input-suffix">
-          <el-row :gutter="20" style="margin-bottom: 0">
-            <el-col :xl="6" :lg="8" :md="10">
-              <span class="inline-flex items-center">关键词:</span>
-              <el-input
-                v-model="initParam.T_name"
-                type="text"
-                class="w-50 m-2"
-                placeholder="按物联网卡号或SN搜索"
-                @change="searchHandle"
-              />
-            </el-col>
-            <el-col :xl="10" :md="12">
-              <span class="inline-flex items-center">产品分类:</span>
-              <el-select v-model="initParam.T_state" class="w-50 m-2" clearable placeholder="请选择状态~">
-                <el-option v-for="item in options" :key="item.id" :label="item.name" :value="item.id" />
-              </el-select>
-              <el-button type="primary" @click="searchHandle">搜索</el-button>
-            </el-col>
-            <el-col :xl="6" :md="2" class="btn"
-              ><el-button type="primary" @click="openDrawer('new')">添加</el-button></el-col
-            >
-          </el-row>
-        </div>
-      </template>
-      <template #T_State="{ row }">
-        <el-tag v-if="row.T_State === 2" type="success" effect="dark"> 已使用 </el-tag>
-        <el-tag v-else-if="row.T_State === 1" type="warning" effect="dark"> 未使用 </el-tag>
-        <el-tag v-else type="info" effect="dark"> 已作废 </el-tag>
-      </template>
-      <template #right="{ row }">
-        <el-button
-          :disabled="row.T_State === 2"
-          link
-          type="primary"
-          size="small"
-          :icon="Edit"
-          @click="openDrawer('edit', row)"
-          >编辑</el-button
-        >
-        <el-button :disabled="row.T_State === 2" link type="danger" size="small" :icon="Delete" @click="UserDelete(row)"
-          >删除</el-button
-        >
-      </template>
-    </TableBase>
-    <Drawer ref="drawerRef" :handleClose="callbackDrawer">
-      <template #header="{ params }">
-        <h4 :id="params.titleId" :class="params.titleClass">{{ isNew ? '添加' : '编辑' }} - 物联网卡</h4>
-      </template>
-      <el-form ref="ruleFormRef" :model="form" :rules="rules">
-        <el-divider border-style="dashed" />
-        <el-form-item label="物联网卡号:" :label-width="formLabelWidth" prop="T_iccid">
-          <el-input v-model="form.T_iccid" type="text" autocomplete="off" placeholder="请输入物联网卡号" />
-        </el-form-item>
-        <el-form-item label="型号:" :label-width="formLabelWidth" prop="T_type">
-          <el-input v-model="form.T_type" type="text" autocomplete="off" placeholder="请输入型号" />
-        </el-form-item>
-        <el-form-item label="状态:" :label-width="formLabelWidth" prop="T_state">
-          <el-radio-group v-model="form.T_state">
-            <el-radio :label="2">已使用</el-radio>
-            <el-radio :label="1">未使用</el-radio>
-            <el-radio :label="3">已作废</el-radio>
-          </el-radio-group>
-        </el-form-item>
-        <el-form-item label="关联SN:" :label-width="formLabelWidth" prop="T_sn">
-          <el-input v-model="form.T_sn" type="text" autocomplete="off" placeholder="请输入关联SN" />
-        </el-form-item>
-        <el-form-item :label-width="formLabelWidth">
-          <el-button v-if="isNew" color="#626aef" @click="AddUserName(ruleFormRef)">提交</el-button>
-          <el-button v-else color="#626aef" @click="AddUserName(ruleFormRef)">修改</el-button>
-        </el-form-item>
-      </el-form>
-    </Drawer>
-  </div>
-</template>
-
-<style scoped lang="scss">
-.IoTNetworkCard {
-  :deep(.el-drawer__header) {
-    margin-bottom: 0;
-  }
-  .input-suffix {
-    width: 100%;
-    .inline-flex {
-      white-space: nowrap;
-    }
-    .btn {
-      display: flex;
-      justify-content: end;
-    }
-    .w-50 {
-      width: 12.5rem;
-    }
-  }
-}
-</style>

+ 1 - 1
src/views/storehouse/sales/ContractForm.vue

@@ -138,7 +138,7 @@ const columns = [
 ]
 
 const productColumns = [
-  { type: 'selection', width: 80, name: 'selection' },
+  { type: 'selection', width: 80 },
   { prop: 'T_img', label: '产品图片', name: 'T_img' },
   { prop: 'T_name', label: '产品名称' },
   { prop: 'T_class_name', label: '产品分类' },

+ 16 - 16
vite.config.ts

@@ -22,22 +22,22 @@ export default defineConfig(({ mode }: ConfigEnv): UserConfig => {
     },
     server: {
       open: true,
-      host: '0.0.0.0'
-      // proxy: {
-      //   '/api': {
-      //     target: 'https://erp.baozhida.cn',
-      //     changeOrigin: true,
-      //     rewrite: path => path.replace(/^\/api/, '/testapi')
-      //   },
-      //   '/testapi': {
-      //     target: 'https://erp.baozhida.cn',
-      //     changeOrigin: true
-      //   },
-      //   '/ams': {
-      //     target: 'http://erp.baozhida.cn',
-      //     changeOrigin: true
-      //   }
-      // }
+      host: '0.0.0.0',
+      proxy: {
+        '/api': {
+          target: 'https://erp.baozhida.cn',
+          changeOrigin: true,
+          rewrite: path => path.replace(/^\/api/, '/testapi')
+        },
+        '/testapi': {
+          target: 'https://erp.baozhida.cn',
+          changeOrigin: true
+        },
+        '/ams': {
+          target: 'http://erp.baozhida.cn',
+          changeOrigin: true
+        }
+      }
     },
     plugins: [
       vue(),