yangfeng
2024-03-07 5de621e943d9605d10e2ac5d46658c0626a68caa
Merge branch 'master' of http://192.168.5.5:10010/r/web/SRM
2个文件已添加
11个文件已修改
386 ■■■■ 已修改文件
src/api/admin/user.js 20 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
src/common/untils/request.js 68 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
src/components/layout/components/appHeader/components/updatePassWord.vue 182 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
src/components/layout/components/appHeader/index.vue 34 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
src/components/layout/components/appsidebar/index.vue 18 ●●●● 补丁 | 查看 | 原始文档 | blame | 历史
src/components/makepager/CommonFormTableView.vue 18 ●●●● 补丁 | 查看 | 原始文档 | blame | 历史
src/router/index.js 3 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
src/store/index.js 4 ●●●● 补丁 | 查看 | 原始文档 | blame | 历史
src/views/purchaseManage/purchase/components/AddPurchase.vue 7 ●●●● 补丁 | 查看 | 原始文档 | blame | 历史
src/views/purchaseManage/purchase/index.vue 8 ●●●● 补丁 | 查看 | 原始文档 | blame | 历史
src/views/supplierManage/supplier/AddNewProduct.vue 12 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
src/views/supplierManage/supplier/AddSupplier.vue 5 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
src/views/supplierManage/supplier/index.vue 7 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
src/api/admin/user.js
New file
@@ -0,0 +1,20 @@
import request from "@/common/untils/request"
// 重置密码
export function initPassword(data) {
  return request({
    url: "/api/user/initPassword",
    method: "post",
    data,
  });
}
// 设置新密码
export function modifiedPwd(data) {
  return request({
    url: "/api/user/modifiedPwd",
    method: "post",
    data,
  });
}
src/common/untils/request.js
@@ -2,11 +2,36 @@
import { Message } from "element-ui"
// import router from '@/router'
// 开发环境下将自己的token复制到这里, 也可以在浏览器中手动添加token到cookie中,cookie中的token优先
const DEV_TOKEN =  ''
function environmentType(){
  let type
  if (location.href.includes('192.168.20.119')) {
      type = 'test'
  } else if (location.href.includes('192.168') || location.href.includes('localhost')) {
      type = 'dev'
  } else {
      type = 'prod'
  }
  return type
}
const isDev = environmentType() === 'dev'
const Axios = axios.create({
  responseType: "json",
  withCredentials: true // 是否允许带cookie这些
})
const getApsPage = () => {
  // 首页部署在各个环境的端口
  const loginPathMap = {
      prod:`//${window.location.hostname}:9080`,
      test:`//192.168.20.119:9080`,
      dev: `//192.168.8.107:8080`
  }
  return loginPathMap[environmentType()]
}
/* //POST传参序列化(添加请求拦截器) */
Axios.interceptors.request.use(
@@ -20,6 +45,9 @@
      /(?:(?:^|.*;\s*)token\s*=\s*([^;]*).*$)|^.*$/,
      "$1",
    );
    if (isDev){
      token = token || DEV_TOKEN
    }
    if (token) {
      config.headers.Authorization = "Bearer " + token;
    }
@@ -36,16 +64,44 @@
    /* //对响应数据做些事 */
    if (res.data.code === 200) {
      return res.data ? res.data : {}
    } else {
      Message({
        message: res.data.msg,
        type: "error",
        duration: 5 * 1000
      })
    } else if([2012,2013,2014,2015].includes(res.data.code)){
      if (isDev){
        alert("JWT失效,即将跳转至登录页..")
        window.location = getApsPage()+'/login'
      }else {
        //   JWT鉴权失效 跳转到登录页
        window.location = getApsPage()+'/login'
      }
      // Message({
      //   message: res.data.msg,
      //   type: "error",
      //   duration: 5 * 1000
      // })
      return Promise.reject(res.data)
    }else if([2036].includes(res.data.code)){
      if (isDev){
        window.location = getApsPage()+'/commonWeb?resetPwd=true'
      }else {
        //   JWT鉴权失效 跳转到登录页
        window.location = getApsPage()+'/commonWeb?resetPwd=true'
      }
      return Promise.reject(res.data)
      // if(window.location.pathname && window.location.pathname !== '/login'){
      //   window.location = window.location.origin+'/login'
      // }
    }
  },
  (error) => {
    if(error.response.status === 401){
      if (isDev){
        alert("JWT失效,即将跳转至登录页..")
        window.location = getApsPage()+'/login'
      }else {
        //   JWT鉴权失效 跳转到登录页
        window.location = getApsPage()+'/login'
      }
    }
    let { message } = error
    if (message === "Network Error") {
      message = "后端接口连接异常"
src/components/layout/components/appHeader/components/updatePassWord.vue
New file
@@ -0,0 +1,182 @@
<template>
  <div>
    <el-dialog
      title="修改密码"
      :visible.sync="editConfig.dialogVisible"
      width="30%"
      :before-close="handleClose">
      <el-form :label-position="labelPosition" :model="ruleForm"  :rules="rules" ref="ruleForm" label-width="100px" class="demo-ruleForm">
        <el-form-item label="旧密码:" prop="oldPass">
          <el-input type="password" clearable v-model="ruleForm.oldPass" autocomplete="off"></el-input>
        </el-form-item>
        <el-form-item label="新密码:" prop="pass">
          <el-input type="password" clearable v-model="ruleForm.pass" autocomplete="off"></el-input>
        </el-form-item>
        <el-form-item label="确认密码:" prop="checkPass">
          <el-input type="password"  clearable v-model="ruleForm.checkPass" autocomplete="off"></el-input>
        </el-form-item>
        <el-form-item>
          <el-button type="primary" @click="submitForm('ruleForm')" style="margin-bottom:20px;">确认</el-button>
        </el-form-item>
      </el-form>
    </el-dialog>
  </div>
</template>
<script>
import { modifiedPwd } from "@/api/admin/user";
export default {
  props: {
    editCommonConfig: {
      type: Object,
      default: () => {
        return {
          dialogVisible:false,
          userId:"",
        };
      },
    },
  },
  data() {
    var validatePass = (rule, value, callback) => {
      if (value === '') {
        callback(new Error('请输入旧密码'));
      }else{
        callback();
      }
    };
    var validatePass1 = (rule, value, callback) => {
      if (value === '') {
        callback(new Error('请输入新密码'));
      } else {
        if (this.ruleForm.checkPass !== '') {
          this.$refs.ruleForm.validateField('checkPass');
        }
        callback();
      }
    };
    var validatePass2 = (rule, value, callback) => {
      if (value === '') {
        callback(new Error('请再次输入密码'));
      } else if (value !== this.ruleForm.pass) {
        callback(new Error('两次输入密码不一致!'));
      } else {
        callback();
      }
    };
    return {
      editConfig:this.editCommonConfig,
      // dialogVisible: false
      ruleForm: {
        oldPass:'',
        pass: '',
        checkPass: '',
      },
      rules: {
        oldPass: [
          { validator: validatePass, trigger: 'blur', required: true, }
        ],
        pass: [
          { validator: validatePass1, trigger: 'blur', required: true, }
        ],
        checkPass: [
          { validator: validatePass2, trigger: 'blur', required: true, }
        ],
      },
      labelPosition:"left",
      userId : '',
    };
  },
  computed: {
  },
  created() {
  },
  mounted() {
  },
  watch: {
  },
  methods: {
    //
    environmentType(){
      let type
      if (location.href.includes('192.168.20.119')) {
        type = 'test'
      } else if (location.href.includes('192.168') || location.href.includes('localhost')) {
        type = 'dev'
      } else {
        type = 'prod'
      }
      return type
    },
    //
    getApsPage(){
      // 首页部署在各个环境的端口
      const loginPathMap = {
        prod:`//${window.location.hostname}:9080`,
        test:`//192.168.20.119:9080`,
        // 想跳到本地启动的登录页的话需要把dev改成你本地项目路径
        dev: `//192.168.8.108:8080`
      }
      return loginPathMap[this.environmentType()]
    },
    handleClose(done){
      done();
    },
    modifiedPwd(params){
      modifiedPwd(params).then((res)=>{
        if(res.code==200){
          this.editConfig.dialogVisible=false
          alert("密码修改成功,请重新登录!")
          window.location = this.getApsPage()+'/login'
        }
      })
    },
    submitForm(formName) {
      this.$refs[formName].validate((valid) => {
        if (valid) {
          console.log(this.ruleForm,"看看表单")
          this.modifiedPwd({
            userId:this.editConfig.userId,
            oldPwd:this.ruleForm.oldPass,
            newPwd:this.ruleForm.pass,
          })
        } else {
          console.log('error submit!!');
          return false;
        }
      });
    },
  },
  components: {
  },
};
</script>
<style scoped lang="scss">
.el-form{
  margin-top:20px;
}
::v-deep {
  .el-form-item__content{
    display: flex;
    flex-direction: row-reverse;
  }
  .el-dialog__header{
    .el-dialog__title{
      font-size:18px;
    }
  }
  .el-form{
    margin:20px;
  }
}
</style>
src/components/layout/components/appHeader/index.vue
@@ -4,29 +4,53 @@
    <div class="header-user-info">
      <div class="avatar"><el-avatar icon="el-icon-user-solid"></el-avatar></div>
      <el-dropdown @command="handleCommand">
        <div class="el-dropdown-link">{{ username }}<i class="el-icon-arrow-down el-icon--right"></i></div>
        <div class="el-dropdown-link">你好  {{ username }}<i class="el-icon-arrow-down el-icon--right"></i></div>
        <el-dropdown-menu slot="dropdown">
          <el-dropdown-item command="logout">退出</el-dropdown-item>
          <el-dropdown-item @click.native="updatePwd">
            <d2-icon name="unlock" class="d2-mr-5" />
            修改密码
          </el-dropdown-item>
        </el-dropdown-menu>
      </el-dropdown>
      <UpdatePassWord :editCommonConfig="editConfig"></UpdatePassWord>
    </div>
  </div>
</template>
<script>
import Cookies from "js-cookie"
import UpdatePassWord from "./components/updatePassWord"
export default {
  name: "SalesLead",
  props: {
    headerTitle: String
  },
  components:{
    UpdatePassWord,
  },
  data() {
    return {
      username: ""
      username: "",
      editConfig:{
        dialogVisible:false,
        userId:"",
      }
    }
  },
  created(){
    const userObj = Cookies.get('userObj');
    if (userObj) {
      let userInfo = JSON.parse(userObj);
      this.editConfig.userId=userInfo.id
      this.username=userInfo.nickName
    } else {
      console.log('Object not found in cookie');
    }
  },
  mounted() {
    this.username = document.cookie.replace(/(?:(?:^|.*;\s*)username\s*=\s*([^;]*).*$)|^.*$/, "$1")
    // this.username = document.cookie.replace(/(?:(?:^|.*;\s*)username\s*=\s*([^;]*).*$)|^.*$/, "$1")
  },
  methods: {
    environmentType() {
@@ -77,6 +101,10 @@
            })
          })
      }
    },
    updatePwd(){
      this.editConfig.dialogVisible=true
    }
  }
}
src/components/layout/components/appsidebar/index.vue
@@ -25,18 +25,17 @@
        </el-submenu>
        
      </el-menu>
      <el-empty v-if="this.menus===null||this.menus===undefined||this.menus.length===0" :image-size="130" description="没有侧栏菜单"></el-empty>
    </div>
  </div>
</template>
<script>
import {getMenuTreeByRole} from "@/api/menus/index"
export default {
  name: "AppSidebar",
  props: {},
  data() {
    return {
      menus:[]
    }
  },
  watch: {},
@@ -46,13 +45,7 @@
  },
  methods: {
    getMenuTreeByRole(){
      getMenuTreeByRole().then((res)=>{
        res.data.list.map((item)=>{
          if(item.systemType===4){
            this.menus=item.menus
          }
        })
      })
      this.menus=this.$store.state.menus.menus
    },
    // 监听路由
    initNavMenu() {
@@ -69,4 +62,11 @@
<!-- Add "scoped" attribute to limit CSS to this component only -->
<style lang="scss" scoped>
@import "./index.scss";
::v-deep .el-empty{
  .el-empty__description{
    p{
      color: #dddd;
    }
  }
}
</style>
src/components/makepager/CommonFormTableView.vue
@@ -305,7 +305,7 @@
    handleSelectClient(item, prop, row) {
      this.tableList.tableData.map((ite) => {
        if (ite.name === item.name) {
          ite.ID = row.ID
          ite.id = row.id
          ite.amount = item.amount || 1
          ite.number = item.number
          ite.purchasePrice = item.purchasePrice
@@ -316,13 +316,13 @@
        }
      })
      if (this.detailEnter) {
        this.setEditName(item, row.ID)
        this.setEditName(item, row.id)
      }
      this.$emit("handleProduct",item)
      this.$emit("handleProduct",item,row)
    },
    setEditName(item, ID) {
    setEditName(item, id) {
      let selRow = {
        ID: ID,
        id: id,
        deliveryTime: item.deliveryTime,
        maximumStock: item.maximumStock,
        minimumStock: item.minimumStock,
@@ -350,7 +350,7 @@
      console.log(this.tableList.tableData)
      if (this.detailEnter) {
        this.tableList.tableData.map((ite) => {
          ite.ID
          ite.id
          ite.name = item.name
          ite.amount = item.amount || 1
          ite.number = item.number
@@ -359,12 +359,13 @@
          ite.deliveryTime = item.deliveryTime
          ite.shippingDuration = item.shippingDuration
        })
        this.setEditName(item, this.tableList.tableData[0].ID)
        this.setEditName(item, this.tableList.tableData[0].id)
      } else {
        this.tableList.tableData.map((ite, index) => {
          if (index === this.productIndex) {
            ite.name = item.name
            ite.productId = item.ID
            ite.productId = item.id
            ite.productIndex = this.productIndex+1
            ite.amount = item.amount || 1
            ite.number = item.number
            ite.purchasePrice = item.purchasePrice
@@ -375,7 +376,6 @@
            this.$forceUpdate()
          }
        })
        console.log(this.tableList.tableData, "=====chanp")
      }
    },
src/router/index.js
@@ -6,6 +6,7 @@
import purchaseRouter from "./purchase/index.js"
import productRouter from "./product/index.js"
import {getMenuTreeByRole} from "@/api/menus/index"
import store from '@/store/index.js';
Vue.use(Router)
const login = (resolve) => require(["@/views/other/login/index"], resolve)
@@ -118,6 +119,8 @@
    };
    const foundObject = res.data.list.find(obj => obj.systemType === 4);
    if (foundObject) {
      // 存储进vuex
      store.commit('setMenus', foundObject);
      foundObject.menus.forEach(item => {
        const nextPath = item.children.find(obj => obj.path === routePath);
        if (nextPath) {
src/store/index.js
@@ -6,10 +6,14 @@
export default new Vuex.Store({
  state: {
    menus:[],
  },
  getters: {
  },
  mutations: {
    setMenus(state,payload){
      state.menus = payload
    }
  },
  actions: {
  },
src/views/purchaseManage/purchase/components/AddPurchase.vue
@@ -54,7 +54,7 @@
                  >
                    <el-option
                      v-for="ele in plcBrandList"
                      :key="ele.name"
                      :key="ele.purchaseTypeId"
                      :label="ele.name"
                      :value="ele.id"
                    ></el-option>
@@ -405,6 +405,7 @@
    }
  },
  created() {
    console.log(this.editConfig,"参数")
    this.handleGetBomKindDictList()
    this.$store.dispatch("getSupplier")
    this.formInfo()
@@ -478,13 +479,15 @@
        this.plcBrandList = res.data
        this.setTableForm()
        if (val) {
          // this.plcBrandList.map((item)=>{
          //   item.purchaseTypeId=item.id
          // })
          for (let i in this.plcBrandList) {
            if (this.plcBrandList[i][this.editRow.isDefault]) {
              this.editConfig.infomation.purchaseTypeId = this.editConfig.infomation.purchaseTypeId
                ? this.editConfig.infomation.purchaseTypeId
                : this.plcBrandList[i].id
              this.$set(this.editConfig.infomation, "purchaseTypeId", this.editConfig.infomation.purchaseTypeId)
              break
            }
          }
src/views/purchaseManage/purchase/index.vue
@@ -348,7 +348,7 @@
      this.editConfig.detailEnter = false
      this.editConfig.isDisabled = false
      this.tableLoading = true
      getPurchaseInfo({ id: row.id }).then((res) => {
      getPurchaseInfo({ id: Number(row.id) }).then((res) => {
        if (res.code == 200) {
          this.tableLoading = false
          this.editConfig.visible = true
@@ -386,7 +386,7 @@
          if (!row.supplierName) {
            this.btnEdit(row)
          } else {
            submitPurchase({ id: row.ID, status: 2 }).then((response) => {
            submitPurchase({ id: Number(row.id), status: 2 }).then((response) => {
              if (response.code === 200) {
                this.$message.success("提交成功")
                this.getData()
@@ -409,7 +409,7 @@
        type: "warning"
      }).then(
        () => {
          submitPurchase({ id: row.ID, status: 5 }).then((response) => {
          submitPurchase({ id: Number(row.id), status: 5 }).then((response) => {
            if (response.code === 200) {
              this.$message.success("已取消")
              this.getData()
@@ -431,7 +431,7 @@
        type: "warning"
      })
        .then(() => {
          deletePurchase({ id: row.ID }).then((response) => {
          deletePurchase({ id: Number(row.id) }).then((response) => {
            if (response.code === 200) {
              this.$message.success("删除成功")
              this.getData()
src/views/supplierManage/supplier/AddNewProduct.vue
@@ -22,6 +22,7 @@
            @emptyProductClick="emptyProductClick"
            @clearupProduct="clearupProduct"
            @selCommonName="selCommonName"
            @handleProduct="handleProduct"
          />
        </div>
      </div>
@@ -127,7 +128,7 @@
      let data = this.editConfig.infomation
      let params = {
        deliveryTime: this.deliveryTime || 0,
        id: data.ID || 0,
        id: data.id || 0,
        maximumStock: data.maximumStock || 0,
        minimumStock: data.minimumStock || 0,
        modelNumber: data.modelNumber || "",
@@ -143,6 +144,9 @@
      }
      return params
    },
    handleProduct(item,row){
      this.editConfig.infomation.id=row.id
    },
    setTableForm() {
      if (this.editConfig.title === "添加") {
        this.detailEnter = false
@@ -156,11 +160,11 @@
            number: "",
            price: 0,
            total: 0,
            supplierId: this.supplierId
            supplierId:this.supplierId
          }
        ]
      } else {
        this.tableData = [{ ...this.editConfig.infomation }]
        this.tableData = [{ ...this.editConfig.infomation}]
        this.detailEnter = true
      }
      this.productTableList = {
@@ -185,7 +189,7 @@
      this.tableData.map((item) => {
        if (item.productId === row.productId) {
          item[prop] = val
          item.supplierId = this.supplierId
          item.supplierId =Number(this.supplierId)
          item.deliveryTime = this.deliveryTime
          item.shippingDuration = this.shippingDuration
          item.purchasePrice = this.purchasePrice
src/views/supplierManage/supplier/AddSupplier.vue
@@ -368,6 +368,7 @@
                console.log(err)
              })
          } else {
            params.id=this.editConfig.infomation.id
            updateSupplier(params).then((res) => {
              this.editConfig.visible = false
              if (res.code === 200) {
@@ -392,13 +393,13 @@
        detailAddress: data.detailAddress || "",
        email: data.email || "",
        fileId: this.file_id || 0,
        id: data.id || 0,
        // id: data.id || 0,
        industry: data.industry || "",
        name: data.name || "",
        number: data.number || "",
        phone: data.phone || "",
        responsiblePersonName:
          data.responsiblePersonName || document.cookie.replace(/(?:(?:^|.*;\s*)username\s*=\s*([^;]*).*$)|^.*$/, "$1"),
        data.responsiblePersonName || document.cookie.replace(/(?:(?:^|.*;\s*)username\s*=\s*([^;]*).*$)|^.*$/, "$1"),
        status: data.status || 0,
        supplierType: data.supplierType || "",
        url: data.url || ""
src/views/supplierManage/supplier/index.vue
@@ -356,7 +356,7 @@
    async enableClick(row, value) {
      let status = value === "启用" ? 1 : 0
      await changeSupplierStatus({
        id: row.ID,
        id:Number(row.id),
        status: status
      }).then((res) => {
        if (res.code === 200) {
@@ -385,7 +385,6 @@
    },
    // 修改产品
    editClick(row) {
      console.log(row)
      this.newProductConfig.visible = true
      this.newProductConfig.title = "修改"
      this.newProductConfig.infomation = { ...row }
@@ -418,7 +417,6 @@
      this.selValueList = list
    },
    tableRowClick(row) {
      console.log(row)
      this.productPagerOptions.currPage = 1
      this.selectRow = row
      this.supplierId = row.id
@@ -426,7 +424,7 @@
    },
    // 详情
    async selCommonClick(row) {
      await getPurchaseList({ pageSize: 10, page: 1, supplierId: row.ID }).then((res) => {
      await getPurchaseList({ pageSize: 10, page: 1, supplierId: Number(row.id) }).then((res) => {
        this.commonDetail.productListInfo = res.data.list
      })
      this.commonDetail.visible = true
@@ -448,6 +446,7 @@
      this.editPurchaseConfig.title = "新建"
      this.editPurchaseConfig.infomation = {
        supplierId: this.selectRow.id,
        purchaseTypeId:"2",
        supplierName: this.selectRow.name
      }
    }