Bladeren bron

feat: ✨ 员工管理接口联调

zhangtao 3 dagen geleden
bovenliggende
commit
300f511a99

+ 5 - 0
src/api/apiDefinitions.ts

@@ -1,5 +1,10 @@
 export default {
+  "app.appCategory": ["GET", "/app/appCategory/list"],
   "user.loginUser": ["POST", "/sys/loginApp"],
   "courses.list": ["GET", "/app/appCourese/list"],
   "courses.getCourseDetail": ["GET", "/app/appCourese/queryById"],
+  "sys.staff": ["GET", "/staff/staff/list"],
+  "sys.updateStatus": ["PUT", "/staff/staff/updateStatus"],
+  "sys.findByDeptTree": ["GET", "/sys/sysDepart/findByDepTree"],
+  "sys.rolelist": ["GET", "/sys/role/list"],
 };

+ 1 - 1
src/api/core/handlers.ts

@@ -78,7 +78,7 @@ export async function handleAlovaResponse(
     console.log("[Alova Response]", json);
   }
   // Return data for successful responses
-  return json;
+  return json.result;
 }
 
 // Handle request errors

+ 3 - 0
src/components.d.ts

@@ -22,6 +22,7 @@ declare module 'vue' {
     WdDivider: typeof import('wot-design-uni/components/wd-divider/wd-divider.vue')['default']
     WdDropMenu: typeof import('wot-design-uni/components/wd-drop-menu/wd-drop-menu.vue')['default']
     WdDropMenuItem: typeof import('wot-design-uni/components/wd-drop-menu-item/wd-drop-menu-item.vue')['default']
+    WdForm: typeof import('wot-design-uni/components/wd-form/wd-form.vue')['default']
     WdIcon: typeof import('wot-design-uni/components/wd-icon/wd-icon.vue')['default']
     WdInput: typeof import('wot-design-uni/components/wd-input/wd-input.vue')['default']
     WdMessageBox: typeof import('wot-design-uni/components/wd-message-box/wd-message-box.vue')['default']
@@ -29,6 +30,8 @@ declare module 'vue' {
     WdNoticeBar: typeof import('wot-design-uni/components/wd-notice-bar/wd-notice-bar.vue')['default']
     WdNotify: typeof import('wot-design-uni/components/wd-notify/wd-notify.vue')['default']
     WdPopup: typeof import('wot-design-uni/components/wd-popup/wd-popup.vue')['default']
+    WdRadio: typeof import('wot-design-uni/components/wd-radio/wd-radio.vue')['default']
+    WdRadioGroup: typeof import('wot-design-uni/components/wd-radio-group/wd-radio-group.vue')['default']
     WdRate: typeof import('wot-design-uni/components/wd-rate/wd-rate.vue')['default']
     WdSearch: typeof import('wot-design-uni/components/wd-search/wd-search.vue')['default']
     WdSelectPicker: typeof import('wot-design-uni/components/wd-select-picker/wd-select-picker.vue')['default']

+ 5 - 2
src/components/customFormItem/index.vue

@@ -4,14 +4,17 @@
       <view class="text-#FB5B5B font-semibold" v-if="required">*</view>
       <view class="font-semibold ml20rpx label">{{ label }}</view>
     </view>
-    <view class="bg-#F6F6F6 rounded-16rpx input mt20rpx">
+    <view
+      class="rounded-16rpx input mt20rpx"
+      :style="{ background: bg ? bg : '#F6F6F6' }"
+    >
       <slot></slot>
     </view>
   </view>
 </template>
 
 <script setup lang="ts">
-const props = defineProps<{ label: string; required?: boolean }>();
+const props = defineProps<{ label: string; required?: boolean; bg?: string }>();
 </script>
 
 <style scoped lang="scss">

+ 6 - 2
src/config/index.ts

@@ -2,9 +2,9 @@ const mapEnvVersion = {
   /**
    * 	开发版
    */
-  // develop: "http://192.168.1.166:8080/jeecg-boot",
+  develop: "http://192.168.1.166:8080/jeecg-boot",
   // develop: "http://192.168.1.34:8080/jeecg-boot",
-  develop: "http://192.168.0.11:8080/jeecg-boot",
+  // develop: "http://192.168.0.11:8080/jeecg-boot",
   /**
    * 	体验版
    */
@@ -20,3 +20,7 @@ const mapEnvVersion = {
  */
 export const BASE_URL =
   mapEnvVersion[uni.getAccountInfoSync().miniProgram.envVersion];
+
+// export const BASE_UPLOADURL = "http://192.168.0.11:8080/jeecg-boot/upload";
+export const BASE_UPLOADURL =
+  "http://192.168.1.166:8080/jeecg-boot/sys/common/upload";

+ 2 - 1
src/pages/login/index.vue

@@ -97,7 +97,8 @@ async function handleLogin() {
     mask: true,
   });
   setTimeout(() => {
-    handleClickLeft();
+    // handleClickLeft();
+    uni.reLaunch({ url: "/pages/index/index" });
   }, 2000);
 }
 </script>

+ 49 - 8
src/subPack/EmployeeList/index.vue

@@ -1,20 +1,30 @@
 <template>
   <view class="px32rpx py-20rpx">
     <!-- <view class="bg-white p24rpx rounded-32rpx box-border"> </view> -->
-    <wd-card type="rectangle" v-for="item in 10">
+    <wd-card type="rectangle" v-for="item in data">
       <template #title>
         <view class="flex items-center">
-          <view class="font-semibold text-32rpx">昵称 艾卡西亚大暴雨</view>
-          <view class="px16rpx py4rpx text-white ml20rpx">正常</view>
+          <view class="font-semibold text-32rpx"> {{ item.realname }}</view>
+          <view
+            class="px16rpx py4rpx text-white ml20rpx rounded-8rpx"
+            :class="[
+              item.status == 1
+                ? 'bg-[rgb(68,207,142,1)]'
+                : 'bg-[rgb(255,88,105,1)]',
+            ]"
+            >{{ statusText[item.status] }}</view
+          >
         </view>
       </template>
-      <view class="text-[rgb(0,0,0,0.3)]"
-        >观山湖一店、观山湖二店、观山湖三店、观山湖四店、观山
-        湖五店、观山湖六店、</view
-      >
+      <view class="text-[rgb(0,0,0,0.3)]">{{ item.departName }}</view>
       <template #footer>
         <view class="flex items-center justify-between w-full">
-          <wd-switch />
+          <wd-switch
+            v-model:model-value="item.status"
+            :active-value="1"
+            :inactive-value="0"
+            @change="handleChange($event, item.id)"
+          />
           <view class="flex items-center">
             <view class="mr20rpx">
               <commonbtn bg-color="rgba(255,88,105,0.2)"
@@ -34,11 +44,42 @@
 </template>
 
 <script setup lang="ts">
+import { createGlobalLoadingMiddleware } from "@/api/core/middleware";
+import { type SwitchBeforeChangeOption } from "wot-design-uni/components/wd-switch/types";
+const statusText = ["关闭", "正常"];
 function handleAdd() {
   uni.navigateTo({
     url: "/subPack/EmployeeListAdd/index?type=0",
   });
 }
+const { loading, data, page, pageSize, pageCount, total, refresh } =
+  usePagination(
+    (page, pageSize) =>
+      Apis.sys.staff({
+        data: { page, pageSize },
+      }),
+    {
+      middleware: createGlobalLoadingMiddleware(),
+      data: (resp) => resp.records,
+      initialPage: 1, // 初始页码,默认为1
+      initialPageSize: 10, // 初始每页数据条数,默认为10
+    },
+  ).onError((error) => {});
+const { send: uploadStatus } = useRequest(
+  (status, id) =>
+    Apis.sys.updateStatus({
+      data: { status, id },
+    }),
+
+  {
+    middleware: createGlobalLoadingMiddleware(),
+    immediate: false,
+  },
+).onError((error) => {});
+async function handleChange(e: SwitchBeforeChangeOption, id: string) {
+  await uploadStatus(e.value, id);
+  refresh();
+}
 </script>
 
 <style scoped>

+ 2 - 0
src/subPack/EmployeeListAdd/components/tree/index.vue

@@ -339,6 +339,8 @@ export default {
         default:
           break;
       }
+      console.log("选择===========", item, index);
+
       //子节点 全部选中
       this._onItemChildSelect(item, index);
       //父节点 选中状态变化

+ 47 - 0
src/subPack/EmployeeListAdd/components/upload/index.vue

@@ -0,0 +1,47 @@
+<template>
+  <wd-upload
+    v-bind="{
+      ...props,
+      action: BASE_UPLOADURL,
+      header: {
+        'x-access-token': `${token}`,
+        'content-type': 'multipart/form-data;',
+      },
+    }"
+    @oversize="handleOversize"
+    @success="handleSuccess"
+  ></wd-upload>
+  <view v-if="tip" class="text-[rgba(0,0,0,0.30)] text-24rpx">{{ tip }}</view>
+</template>
+
+<script setup lang="ts">
+import { BASE_UPLOADURL } from "@/config";
+import {
+  uploadProps,
+  type UploadOversizeEvent,
+  type UploadSuccessEvent,
+} from "wot-design-uni/components/wd-upload/types";
+const props = defineProps({
+  ...uploadProps,
+  tip: {
+    type: String,
+    default: "",
+  },
+});
+
+const { token } = useUserStore();
+
+function handleOversize(e: UploadOversizeEvent) {
+  console.log(e.file, "微博读书2222");
+  uni.showToast({
+    title: "文件过大",
+    icon: "none",
+  });
+}
+function handleSuccess(e: UploadSuccessEvent) {
+  const { file, fileList, formData } = e;
+  console.log(file, fileList, formData);
+}
+</script>
+
+<style scoped></style>

+ 174 - 104
src/subPack/EmployeeListAdd/index.vue

@@ -9,54 +9,144 @@
     @click-left="handleClickLeft"
   ></wd-navbar>
   <view class="py20rpx">
-    <view class="bg-white px32rpx py28rpx">
-      <customFormItem label="用户名称" required>
-        <wd-input
-          type="text"
-          placeholder="请输入用户名称"
-          no-border
-          custom-class="inputClass"
-        />
-      </customFormItem>
-      <customFormItem label="归属部门" required>
-        <view @click="handleShow">
+    <wd-form ref="form" :model="formData">
+      <view class="bg-white px32rpx py28rpx">
+        <customFormItem label="用户名称" required>
           <wd-input
             type="text"
-            placeholder="请选择归属部门"
+            placeholder="请输入用户名称"
             no-border
             custom-class="inputClass"
-            readonly
+            v-model:model-value="formData.username"
+            :rules="[{ required: true, message: '请输入用户名称' }]"
+          />
+        </customFormItem>
+        <customFormItem label="归属部门" required>
+          <view @click="handleShow">
+            <wd-input
+              type="text"
+              placeholder="请选择归属部门"
+              no-border
+              custom-class="inputClass"
+              readonly
+              :rules="[{ required: true, message: '请选择归属部门' }]"
+            >
+              <template #suffix>
+                <wd-icon
+                  name="arrow-down"
+                  size="22px"
+                  color="rgba(0,0,0,0.3)"
+                ></wd-icon>
+              </template>
+            </wd-input>
+          </view>
+        </customFormItem>
+        <customFormItem label="登录账号" required>
+          <wd-input
+            type="text"
+            placeholder="请输入登录账号"
+            no-border
+            custom-class="inputClass"
+            :rules="[{ required: true, message: '请输入登录账号' }]"
+          />
+        </customFormItem>
+        <customFormItem label="登录密码" required>
+          <wd-input
+            show-password
+            placeholder="请输入登录密码"
+            no-border
+            :rules="[{ required: true, message: '请输入登录密码' }]"
+            custom-class="inputClass"
+          />
+        </customFormItem>
+        <customFormItem label="角色" required bg="#fff" v-if="rolelist">
+          <wd-radio-group
+            inline
+            v-model:model-value="formData.roleId"
+            shape="dot"
+            :rules="[{ required: true, message: '请选择角色' }]"
           >
-            <template #suffix>
-              <wd-icon
-                name="arrow-down"
-                size="22px"
-                color="rgba(0,0,0,0.3)"
-              ></wd-icon>
-            </template>
-          </wd-input>
-        </view>
-      </customFormItem>
-      <customFormItem label="登录账号" required>
-        <wd-input
-          type="text"
-          placeholder="请输入登录账号"
-          no-border
-          custom-class="inputClass"
-        />
-      </customFormItem>
-      <customFormItem label="登录密码" required>
-        <wd-input
-          show-password
-          placeholder="请输入登录密码"
-          no-border
-          custom-class="inputClass"
-        />
-      </customFormItem>
-    </view>
+            <wd-radio
+              :value="item.id"
+              v-for="item in rolelist.records"
+              :key="item.id"
+              >{{ item.roleName }}</wd-radio
+            >
+          </wd-radio-group>
+        </customFormItem>
+        <customFormItem label="状态" required bg="#fff">
+          <wd-switch
+            v-model="formData.status"
+            :active-value="1"
+            :inactive-value="0"
+          />
+        </customFormItem>
+      </view>
+      <view class="bg-white mt3 px32rpx py28rpx">
+        <customFormItem label="培训项目" required bg="#fff" v-if="categoryList">
+          <wd-checkbox-group
+            inline
+            v-model:model-value="formData.trainingPrograms"
+            :rules="[{ required: true, message: '请选择培训项目' }]"
+          >
+            <wd-checkbox
+              v-model:model-value="item.id"
+              true-value="sting"
+              false-value="string"
+              v-for="item in categoryList.records"
+              :key="item.id"
+              >{{ item.name }}</wd-checkbox
+            >
+          </wd-checkbox-group>
+        </customFormItem>
+        <customFormItem
+          label="无犯罪记录"
+          required
+          bg="#fff"
+          v-if="categoryList"
+        >
+          <upload
+            tip="单张照片,不超过5MB"
+            :max-size="5242880"
+            :sourceType="['camera']"
+            accept="image"
+            :limit="1"
+          ></upload>
+        </customFormItem>
+        <customFormItem label="教学理念" required>
+          <wd-input
+            type="text"
+            placeholder="请输入教学理念"
+            no-border
+            custom-class="inputClass"
+            v-model:model-value="formData.teachingPhilosophy"
+            :rules="[{ required: true, message: '请输入教学理念' }]"
+          />
+        </customFormItem>
+        <customFormItem label="擅长描述" required>
+          <wd-input
+            type="text"
+            placeholder="请输入擅长描述"
+            no-border
+            custom-class="inputClass"
+            v-model:model-value="formData.excelMsg"
+            :rules="[{ required: true, message: '请输入擅长描述' }]"
+          />
+        </customFormItem>
+        <customFormItem label="荣誉证书" required bg="#fff">
+          <upload
+            tip="最多支持2张图片,单张照片不超过5MB"
+            :max-size="5242880"
+            :sourceType="['camera']"
+            accept="image"
+            :limit="2"
+          ></upload>
+        </customFormItem>
+      </view>
+    </wd-form>
   </view>
-
-  <fixdbtn block size="large">确认</fixdbtn>
+  <view class="h-180rpx"></view>
+  <fixdbtn block size="large" @click="handleSubmit">确认</fixdbtn>
   <view class="customPopup">
     <wd-popup
       v-model="treeFlage"
@@ -70,20 +160,26 @@
         <view class="mt28rpx bg-white h-700rpx rounded-32rpx overflow-y-scroll">
           <scroll-view scroll-y>
             <tree
-              :localdata="data"
+              :localdata="deptList"
               valueKey="id"
-              textKey="name"
+              textKey="departName"
               childrenKey="children"
               ref="treePicker"
+              v-model="deptId"
+              @select-change="handleChangeDept"
             ></tree>
           </scroll-view>
         </view>
         <view class="mt24rpx flex items-center justify-between">
           <view class="w332rpx">
-            <wd-button type="info" size="large" block>重置</wd-button>
+            <wd-button type="info" size="large" block @click="handleRect"
+              >重置</wd-button
+            >
           </view>
           <view class="w332rpx">
-            <wd-button size="large" block>确认</wd-button>
+            <wd-button size="large" block @click="handleSubmitDept"
+              >确认</wd-button
+            >
           </view>
         </view>
       </view>
@@ -92,11 +188,31 @@
 </template>
 
 <script setup lang="ts">
+import { BASE_UPLOADURL } from "@/config";
 import tree from "./components/tree/index.vue";
+import upload from "./components/upload/index.vue";
+import { type FormInstance } from "wot-design-uni/components/wd-form/types";
 const titleArr = ["新增员工", "编辑员工"];
 const treePicker = ref();
+const form = ref<FormInstance>();
+const formData = ref({
+  roleId: "",
+  status: 1,
+  password: "",
+  trainingPrograms: [],
+  certificateInnocence:
+    "https://b0.bdstatic.com/920d3e4f7d5d8aeb8680137b987fa262.jpg",
+  teachingPhilosophy: "",
+  excelMsg: "",
+  username: "",
+});
+const deptId = ref([]);
 const type = ref(0);
 const treeFlage = ref(false);
+const { data: deptList } = useRequest(() => Apis.sys.findByDeptTree(), {});
+const { data: rolelist } = useRequest(() => Apis.sys.rolelist(), {});
+const { data: categoryList } = useRequest(() => Apis.app.appCategory(), {});
+
 onLoad((query: any) => {
   type.value = query.type;
 });
@@ -108,64 +224,18 @@ function handleShow() {
 function handleClickLeft() {
   uni.navigateBack();
 }
-const data = [
-  {
-    id: 1,
-    name: "公司1",
-    children: [
-      {
-        id: 11,
-        name: "研发部",
-        children: [
-          {
-            id: 111,
-            name: "张三",
-          },
-          {
-            id: 112,
-            name: "李四",
-          },
-        ],
-      },
-      {
-        id: 12,
-        name: "综合部",
-      },
-    ],
-  },
-  {
-    id: 2,
-    name: "公司2",
-    children: [
-      {
-        id: 21,
-        name: "研发部",
-      },
-      {
-        id: 22,
-        name: "综合部",
-      },
-      {
-        id: 23,
-        name: "财务部",
-      },
-    ],
-  },
-  {
-    id: 3,
-    name: "公司3",
-  },
-  {
-    id: 4,
-    name: "公司4",
-    children: [
-      {
-        id: 41,
-        name: "研发部",
-      },
-    ],
-  },
-];
+function handleSubmit() {
+  console.log(deptId.value, "asd");
+
+  form.value?.validate();
+}
+function handleChangeDept(e) {
+  console.log(e);
+}
+function handleSubmitDept() {
+  console.log(treePicker.value);
+}
+function handleRect() {}
 </script>
 
 <style scoped lang="scss">