Просмотр исходного кода

修改单独登录报工信息

695593266@qq.com 9 месяцев назад
Родитель
Сommit
75d48f8c78
4 измененных файлов с 244 добавлено и 60 удалено
  1. 29 9
      src/api/login/index.js
  2. 8 1
      src/store/modules/user.js
  3. 202 46
      src/views/singleLogin/index.vue
  4. 5 4
      vue.config.js

+ 29 - 9
src/api/login/index.js

@@ -4,7 +4,7 @@ import { setToken } from '@/utils/token-util';
 /**
  * 登录
  */
-export async function login (data) {
+export async function login(data) {
   const res = await request.post('/main/user/login', data);
   if (res.data.code == 0) {
     setToken(res.data.data.token, data.remember);
@@ -15,7 +15,7 @@ export async function login (data) {
 /**
  * 获取用户信息
  */
-export async function getLoginUser (data) {
+export async function getLoginUser(data) {
   const res = await request.get('/system/account/getLoginUser', data);
   if (res.data.code == 0) {
     return res.data.data;
@@ -25,14 +25,16 @@ export async function getLoginUser (data) {
 /**
  * 获取验证码
  */
-export async function getCaptcha (params) {
-  const res = await request.get('/main/user/captcha', {params , responseType:'blob'});
-    return res;
+export async function getCaptcha(params) {
+  const res = await request.get('/main/user/captcha', {
+    params,
+    responseType: 'blob'
+  });
+  return res;
 }
 
-
 // 保存 logo 和项目名称
-export async function logoSave (data) {
+export async function logoSave(data) {
   const res = await request.post('/main/logo/save', data);
   if (res.data.code == 0) {
     return res.data;
@@ -42,12 +44,30 @@ export async function logoSave (data) {
 
 // 获取 logo 和项目名称
 
-export async function logoByCode (code) {
+export async function logoByCode(code) {
   const res = await request.get(`/main/logo/getByCode/${code}`);
   if (res.data.code == 0) {
-    return res.data.data    ;
+    return res.data.data;
   }
   return Promise.reject(new Error(res.data.message));
 }
 
+// 查询工厂列表-分页
+export async function getFactoryarea(params) {
+  const res = await request.get(`/main/factoryarea/page`, {
+    params
+  });
+  if (res.data.code == 0) {
+    return res.data.data;
+  }
+  return Promise.reject(new Error(res.data.message));
+}
 
+//获取用户的工厂,所属工作中中心,班组等信息
+export async function getUserInfo(id) {
+  const res = await request.get(`/main/user/getUserWindow/${id}`);
+  if (res.data.code == 0) {
+    return res.data.data;
+  }
+  return Promise.reject(new Error(res.data.message));
+}

+ 8 - 1
src/store/modules/user.js

@@ -61,6 +61,8 @@ export default {
   state: {
     // 当前登录用户信息
     info: null,
+    // 用户所有信息
+    allInfo: null,
     // 当前登录用户的菜单
     menus: null,
     // 当前登录用户的权限
@@ -82,6 +84,11 @@ export default {
     setMenus(state, menus) {
       state.menus = menus;
     },
+    //用户的详情
+    setAllUserInfo(state, info) {
+      localStorage.setItem('all', JSON.stringify(info));
+      state.allInfo = info;
+    },
     // 设置登录用户的权限
     setAuthorities(state, authorities) {
       // console.log(authorities,'authorities')
@@ -140,7 +147,7 @@ export default {
     // },
     //动态路由
     async fetchUserInfo({ commit, state }) {
-      let currentUser = getCurrentUser()
+      let currentUser = getCurrentUser();
 
       const result = await getResourcesTree({
         groupId: currentUser.currentGroupId,

+ 202 - 46
src/views/singleLogin/index.vue

@@ -31,49 +31,6 @@
         />
       </el-form-item>
 
-      <el-form-item prop="loginPwd">
-        <el-input
-          show-password
-          v-model="form.factory"
-          disabled
-          placeholder="所属工厂"
-        />
-      </el-form-item>
-
-      <el-form-item prop="loginPwd">
-        <el-input
-          show-password
-          v-model="form.workCenter"
-          disabled
-          placeholder="所属工作中心"
-        />
-      </el-form-item>
-      <el-form-item prop="loginPwd">
-        <el-input
-          show-password
-          v-model="form.team"
-          disabled
-          placeholder="所属班组"
-        />
-      </el-form-item>
-      <el-form-item prop="loginPwd">
-        <el-input
-          show-password
-          v-model="form.desk"
-          disabled
-          placeholder="工位"
-        />
-      </el-form-item>
-
-      <el-form-item prop="loginPwd">
-        <el-input
-          show-password
-          v-model="form.device"
-          disabled
-          placeholder="设备"
-        />
-      </el-form-item>
-
       <el-form-item prop="captcha">
         <div class="login-input-group">
           <el-input
@@ -147,13 +104,125 @@
         <el-radio-button label="1">居右</el-radio-button>
       </el-radio-group>
     </div> -->
+
+    <el-dialog
+      title="用户信息"
+      :visible.sync="isInfo"
+      append-to-body
+      width="30%"
+      center
+      :close-on-click-modal="false"
+      @close="closeInfo"
+    >
+      <el-form :model="infoForm" label-position="right" label-width="100px">
+        <el-form-item prop="factory" label="所属工厂">
+          <el-input
+            v-model="infoForm.factoryName"
+            disabled
+            placeholder="所属工厂"
+            style="width: 240px"
+          />
+        </el-form-item>
+
+        <el-form-item prop="team" label="班组">
+          <el-select
+            style="width: 240px"
+            clearable
+            v-model="infoForm.teamId"
+            filterable
+            placeholder="请选择班组"
+            @change="changeTeam(infoForm.teamId)"
+          >
+            <el-option
+              v-for="item in teamList"
+              :label="item.teamName"
+              :value="item.teamId"
+              :key="item.teamId"
+            ></el-option>
+          </el-select>
+        </el-form-item>
+
+        <el-form-item prop="workCenter" label="工作中心">
+          <el-select
+            style="width: 240px"
+            clearable
+            v-model="infoForm.centerId"
+            filterable
+            placeholder="请选择工作中心"
+            @change="changeWorlCenter(infoForm.centerId)"
+          >
+            <el-option
+              v-for="item in workCenterList"
+              :label="item.centerName"
+              :value="item.centerId"
+              :key="item.centerId"
+            ></el-option>
+          </el-select>
+          <!-- <el-input
+            v-model="infoForm.workCenter"
+            disabled
+            placeholder="所属工作中心"
+            style="width: 240px"
+          /> -->
+        </el-form-item>
+        <el-form-item prop="desk" label="工位">
+          <!-- <el-input
+            v-model="infoForm.desk"
+            disabled
+            placeholder="工位"
+            style="width: 240px"
+          /> -->
+          <el-select
+            style="width: 240px"
+            clearable
+            v-model="infoForm.workStationId"
+            filterable
+            placeholder="请选择工位"
+          >
+            <el-option
+              v-for="item in workStationList"
+              :label="item.workStationName"
+              :value="item.workStationId"
+              :key="item.workStationId"
+            ></el-option>
+          </el-select>
+        </el-form-item>
+
+        <el-form-item prop="device" label="设备">
+          <!-- <el-input
+            v-model="infoForm.device"
+            disabled
+            placeholder="设备"
+            style="width: 240px"
+          /> -->
+          <el-select
+            style="width: 240px"
+            clearable
+            v-model="infoForm.deviceId"
+            filterable
+            placeholder="请选择设备"
+          >
+            <el-option
+              v-for="item in deviceList"
+              :label="item.deviceName"
+              :value="item.deviceId"
+              :key="item.deviceId"
+            ></el-option>
+          </el-select>
+        </el-form-item>
+      </el-form>
+      <div slot="footer" class="dialog-footer">
+        <el-button @click="isInfo = false">取 消</el-button>
+        <el-button type="primary" @click="infoClick">确 定</el-button>
+      </div>
+    </el-dialog>
   </div>
 </template>
 
 <script>
   import I18nIcon from '@/layout/components/i18n-icon.vue';
   import { getToken } from '@/utils/token-util';
-  import { login, getCaptcha } from '@/api/login';
+  import { login, getCaptcha, getUserInfo } from '@/api/login';
   import xyy from '@/assets/xyy.jpg';
   import { getPathAddress } from '@/api/system/file';
   import { setCurrentUser } from '@/utils/token-util';
@@ -189,10 +258,25 @@
           workCenter: '',
           desk: ''
         },
+        infoForm: {
+          factoryId: '',
+          centerId: '',
+          teamId: '',
+          workStationId: '',
+          deviceId: '',
+          factoryName: ''
+        },
         // 验证码base64数据
         captcha: '',
         // 验证码内容, 实际项目去掉
-        text: ''
+        text: '',
+        isInfo: false,
+        factoryList: [],
+        workCenterList: [],
+        teamList: [],
+        deviceList: [],
+        workStationList: [],
+        userData: null
       };
     },
     computed: {
@@ -294,8 +378,80 @@
       /* 跳转到首页 */
       goHome() {
         localStorage.setItem('singleUserInfo', '1');
+        this.isInfo = true;
+        // this.getFactoryList();
+
+        this.getUserAllInfo();
+        // this.$router.push(this.$route?.query?.from ?? '/').catch(() => {});
+      },
+
+      async getUserAllInfo() {
+        this.infoForm.factoryId = '';
+        this.infoForm.centerId = '';
+        this.infoForm.teamId = '';
+        this.infoForm.workStationId = '';
+        this.infoForm.deviceId = '';
+        this.infoForm.factoryName = '';
+
+        await getUserInfo(this.$store.state.user.info.userId).then((res) => {
+          this.infoForm.factoryName = res.factoryName;
+          this.infoForm.factoryId = res.factoryId;
+          this.teamList = res.teamList;
+          this.userData = res;
+        });
+      },
+
+      changeWorlCenter(centerId) {
+        this.infoForm.centerId = centerId;
+        this.infoForm.workStationId = '';
+
+        const workCenterData = this.workCenterList.find(
+          (item) => item.centerId == centerId
+        );
+        if (workCenterData) {
+          if (this.userData.workStationList.length != 0) {
+            this.workStationList = this.userData.workStationList.filter(
+              (item) => item.centerId == centerId
+            );
+          }
+        }
+      },
+
+      changeTeam(teamId) {
+        this.infoForm.teamId = teamId;
+        this.infoForm.deviceId = '';
+        this.infoForm.centerId = '';
+
+        const teamData = this.teamList.find((item) => item.teamId == teamId);
+
+        if (teamData) {
+          this.teamList = this.userData.deviceList.filter(
+            (it) => it.teamId == teamData.teamId
+          );
+        }
+
+        if (this.userData.deviceList.length != 0) {
+          this.deviceList = this.userData.deviceList.filter(
+            (it) => it.teamId == teamId
+          );
+        }
+      },
+
+      infoClick() {
+        if (!this.infoForm.centerId) {
+          return this.$message.warning('请选择工作中心');
+        }
+
+        if (!this.infoForm.teamId) {
+          return this.$message.warning('请选择班组');
+        }
+
+        this.$store.commit('user/setAllUserInfo', this.infoForm);
         this.$router.push(this.$route?.query?.from ?? '/').catch(() => {});
       },
+
+      closeInfo() {},
+
       /* 更换图形验证码 */
       changeCaptcha() {
         this.form.uuid = this.generateUUID();
@@ -438,7 +594,7 @@
   @media screen and (min-height: 550px) {
     .login-form {
       position: absolute;
-      top: 30%;
+      top: 50%;
       left: 50%;
       transform: translateX(-50%);
       margin-top: -220px;

+ 5 - 4
vue.config.js

@@ -18,16 +18,17 @@ module.exports = {
   devServer: {
     // 代理跨域的配置
     port: 9999,
-    headers: {			
+    headers: {
       // 允许跨域访问子应用页面
-      'Access-Control-Allow-Origin': '*',
+      'Access-Control-Allow-Origin': '*'
     },
     proxy: {
       // 当我们的本地的请求 有/api的时候,就会代理我们的请求地址向另外一个服务器发出请求
       '/api': {
         // target: 'http://124.71.68.31:50001',
-        target: 'http://192.168.1.105:18086',
-
+        // target: 'http://192.168.1.105:18086',
+        // target: 'http://192.168.1.251:18086',
+        target: 'http://192.168.1.125:18086',
         changeOrigin: true, // 只有这个值为true的情况下 才表示开启跨域
         pathRewrite: {
           '^/api': ''