zuozhengqing
2023-12-19 3b6eee772d06d27c5de4281824940c568b85a1f3
vuex存储菜单信息,修改采购管理和供应商管理接口参数
6个文件已修改
35 ■■■■ 已修改文件
src/components/layout/components/appsidebar/index.vue 10 ●●●● 补丁 | 查看 | 原始文档 | blame | 历史
src/router/index.js 3 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
src/store/index.js 4 ●●●● 补丁 | 查看 | 原始文档 | blame | 历史
src/views/purchaseManage/purchase/index.vue 8 ●●●● 补丁 | 查看 | 原始文档 | blame | 历史
src/views/supplierManage/supplier/AddNewProduct.vue 6 ●●●● 补丁 | 查看 | 原始文档 | blame | 历史
src/views/supplierManage/supplier/AddSupplier.vue 4 ●●●● 补丁 | 查看 | 原始文档 | blame | 历史
src/components/layout/components/appsidebar/index.vue
@@ -30,13 +30,11 @@
</template>
<script>
import {getMenuTreeByRole} from "@/api/menus/index"
export default {
  name: "AppSidebar",
  props: {},
  data() {
    return {
      menus:[]
    }
  },
  watch: {},
@@ -46,13 +44,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() {
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/index.vue
@@ -265,7 +265,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
@@ -303,7 +303,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()
@@ -326,7 +326,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()
@@ -348,7 +348,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
@@ -156,11 +156,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 +185,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
@@ -392,13 +392,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 || ""