Explorar el Código

Merge branch 'company' of http://120.46.155.214:3000/xiaodai2022/order-ui-pc into company

xiaodai2022 hace 2 años
padre
commit
87751f3073

+ 1 - 1
src/apis/axios.js

@@ -75,7 +75,7 @@ export default async(
         const code = response.data.code
         const message = response.data.message
 
-        if (code >= 100 && code <= 104 && message !== '账户已禁用') {
+        if (code >= 100 && code <= 104 && message !== '账户已禁用' && message !== '没有该公司的默认角色') {
           removeToken()
           removeMenu()
           removeBtn()

+ 7 - 17
src/apis/service/goodStore/grossProfit/index.js

@@ -1,23 +1,13 @@
 // 物业管理员
-import http from "@/apis/axios";
-const api = "admin/";
+import http from '@/apis/axios'
+const api = 'admin/'
 export default {
   // 分页查询
-  list: (data, params) => http(api + "scpList", data, "post", params),
-  // 添加
-  add: (data, params) => http(api + "scpAdd", data, "post", params),
-  // 删除
-  delete: (data, params) => http(api + "delete", data, "post", params),
+  list: (data, params) => http(api + 'scpList', data, 'post', params),
   // 详情
-  detail: (data, params) => http(api + "catinfo", data, "post", params),
-  // 更新
-  update: (data, params) => http(api + "catedit", data, "post", params),
+  detail: (data, params) => http(api + 'scpInfo', data, 'post', params),
   // 修改状态
-  status: (data, params) => http(api + "catstatus", data, "post", params),
-  // 商品分类列表
-  goodsList: (data, params) => http(api + "catlist", data, "post", params),
-  // 全部规格列表
-  specstitle: (data, params) => http(api + "specstitle", data, "post", params),
+  status: (data, params) => http(api + 'scpStatus', data, 'post', params),
   // 修改毛利率
-  editRate: (data, params) => http(api + "catratedit", data, "post", params)
-};
+  editRate: (data, params) => http(api + 'scpSet', data, 'post', params)
+}

+ 12 - 0
src/apis/service/goodStore/platformGrossProfit/index.js

@@ -0,0 +1,12 @@
+// 物业管理员
+import http from '@/apis/axios'
+const api = 'admin/'
+
+export default {
+  // 分页查询
+  list: (data, params) => http(api + 'spcpList', data, 'post', params),
+  // 设置毛利
+  setSpcp: (data, params) => http(api + 'spcpSet', data, 'post', params),
+  // 设置状态
+  status: (data, params) => http(api + 'spcpStatus', data, 'post', params)
+}

+ 12 - 12
src/apis/service/goodStore/sort/index.js

@@ -1,23 +1,23 @@
 // 物业管理员
-import http from "@/apis/axios";
-const api = "admin/";
+import http from '@/apis/axios'
+const api = 'admin/'
 export default {
   // 添加
-  add: (data, params) => http(api + "catcreate", data, "post", params),
+  add: (data, params) => http(api + 'catcreate', data, 'post', params),
   // 删除
-  delete: (data, params) => http(api + "delete", data, "post", params),
+  delete: (data, params) => http(api + 'delete', data, 'post', params),
   // 分页查询
-  list: (data, params) => http(api + "catplist", data, "post", params),
+  list: (data, params) => http(api + 'catplist', data, 'post', params),
   // 详情
-  detail: (data, params) => http(api + "catinfo", data, "post", params),
+  detail: (data, params) => http(api + 'catinfo', data, 'post', params),
   // 更新
-  update: (data, params) => http(api + "catedit", data, "post", params),
+  update: (data, params) => http(api + 'catedit', data, 'post', params),
   // 修改状态
-  status: (data, params) => http(api + "catstatus", data, "post", params),
+  status: (data, params) => http(api + 'catstatus', data, 'post', params),
   // 商品分类列表
-  goodsList: (data, params) => http(api + "catlist", data, "post", params),
+  goodsList: (data, params) => http(api + 'catlist', data, 'post', params),
   // 全部规格列表
-  specstitle: (data, params) => http(api + "specstitle", data, "post", params),
+  specstitle: (data, params) => http(api + 'specstitle', data, 'post', params),
   // 修改毛利率
-  editRate: (data, params) => http(api + "catratedit", data, "post", params),
-};
+  editRate: (data, params) => http(api + 'catratedit', data, 'post', params)
+}

+ 10 - 10
src/apis/service/serviceParam/workCompany/index.js

@@ -1,18 +1,18 @@
-import http from "@/apis/axios";
-const api = "admin/";
+import http from '@/apis/axios'
+const api = 'admin/'
 export default {
   // 列表
-  list: (data, params) => http(api + "businesslist", data, "post", params),
+  list: (data, params) => http(api + 'businesslist', data, 'post', params),
   // 新建
-  add: (data, params) => http(api + "businesscreate", data, "post", params),
+  add: (data, params) => http(api + 'businesscreate', data, 'post', params),
   // 删除
-  delete: (data, params) => http(api + "businessdel", data, "post", params),
+  delete: (data, params) => http(api + 'businessdel', data, 'post', params),
   // 详情
-  detail: (data, params) => http(api + "businesssinfo", data, "post", params),
+  detail: (data, params) => http(api + 'businesssinfo', data, 'post', params),
   // 更新
-  update: (data, params) => http(api + "businessedit", data, "post", params),
+  update: (data, params) => http(api + 'businessedit', data, 'post', params),
   // 状态
-  status: (data, params) => http(api + "businessstatus", data, "post", params),
+  status: (data, params) => http(api + 'businessstatus', data, 'post', params),
   // 企业性质
-  businesstitle: (data, params) => http(api + "businesstitle", data, "post", params),
-};
+  businesstitle: (data, params) => http(api + 'businesstitle', data, 'post', params)
+}

+ 6 - 6
src/apis/service/youzan/othsearchSort/index.js

@@ -1,10 +1,10 @@
 // 物业管理员
-import http from "@/apis/axios";
-const api = "admin/";
+import http from '@/apis/axios'
+const api = 'admin/'
+
 export default {
- 
   // 分页查询
-  list: (data, params) => http(api + "catplatall", data, "post", params),
+  list: (data, params) => http(api + 'catplatall', data, 'post', params),
   // 更新
-  update: (data, params) => http(api + "catplatedit", data, "post", params),
-};
+  update: (data, params) => http(api + 'catplatedit', data, 'post', params)
+}

+ 4 - 4
src/apis/userAxios.js

@@ -12,7 +12,7 @@ const header = {
   // "Content-Type": "application/x-www-form-urlencoded; charset=UTF-8"
 }
 window.ajaxTimeout = 20000
-export default async (
+export default async(
   url = '',
   data = {},
   type = 'GET',
@@ -92,10 +92,10 @@ export default async (
       })
       .catch(res => {
         if (res.response && res.response.data) {
-          reject(res.response.data);
+          reject(res.response.data)
         } else {
-          reject(res);
+          reject(res)
         }
-      });
+      })
   })
 }

+ 2 - 2
src/assets/js/statusList.js

@@ -1,6 +1,6 @@
 const statusList = [
-  { name: "启用", code: "1" },
-  { name: "禁用", code: "0" },
+  { name: "启用", code: 1 },
+  { name: "禁用", code: 0 },
 ];
 const cg_order_type_options = [
   { id: "1", label: "备库单" },

+ 41 - 10
src/layout/components/company-select/index.vue

@@ -1,12 +1,16 @@
 <template>
   <el-select
-    style="width:380px"
-    :size="size"
-    :placeholder="placeholder"
+    v-loading.fullscreen="companyChangeLoading"
+    :element-loading-text="'正在切换至 ' + getUserCompany().name + ' ......'"
+    element-loading-background="rgba(0, 0, 0, 0.8)"
+    element-loading-spinner="el-icon-loading"
     :value="value ? value : currentCompany"
     :remote-method="handleRemoteSearch"
+    :placeholder="placeholder"
+    style="width:380px"
     :disabled="disabled"
     reserve-keyword
+    :size="size"
     filterable
     remote
     @change="setCurrentCompany"
@@ -18,7 +22,7 @@
       v-for="(company, index) in companylist"
       :key="index"
       class="custom-company"
-      :label="company.code + '/' + company.name"
+      :label="company.code + ' / ' + company.name"
       :value="company.code"
     />
 
@@ -35,6 +39,8 @@
 import { mapState } from 'vuex'
 import { convertCompanylist } from '@/utils'
 import { requsetSupertubeCompany, requsetUserBindingCompany } from '@/apis/user'
+import { isBusinessCompany, isOnlyBusinessCompanyPath } from './utils'
+import { getUserCompany } from '@/utils/auth'
 
 export default {
   /**
@@ -81,6 +87,7 @@ export default {
     return {
       ScrollWrapper: null,
       initialization: true,
+      companyChangeLoading: false,
       state: {
         loading: false,
         noMore: false
@@ -101,6 +108,7 @@ export default {
     this.ScrollWrapper && this.removeEvent(this.ScrollWrapper)
   },
   methods: {
+    getUserCompany,
     async initalData() {
       // 区分是否超管用户请求不同接口
       this.state.loading = true
@@ -129,16 +137,23 @@ export default {
       this.$emit('update:value', currentCompany)
       this.$emit('change', currentCompany)
       if (!this.global) return null // 作为通用组件使用不设置全局选中公司
+
+      // 只能选择业务公司的页面
+      const path = this.$route.path
+      if (isOnlyBusinessCompanyPath(path) && !isBusinessCompany(currentCompany)) {
+        this.$message.warning('该页面只能选择业务公司')
+        return
+      }
+
       this.$store.commit('user/setCurrentCompany', currentCompany)
       if (this.isSupertube) return null // 超管用户不刷新路由
+
       this.changeRouterWithCompany()
     },
 
     async changeRouterWithCompany() {
       const { path, query } = this.$route
-
       query.redirect = path
-
       const keys = Object.keys(query).filter(key => key && key !== 'error')
 
       // 1.保存透传参数
@@ -149,17 +164,29 @@ export default {
       }
 
       // 2.重新获取用户信息和菜单
+      this.companyChangeLoading = true
       const result = await this.$store.dispatch('user/reloadMenulist')
+      this.companyChangeLoading = false
 
       switch (result) {
+        /**
+         * 登出
+        */
         case 'noToken':
           await this.$store.dispatch('user/logout')
           this.$router.push(`/login`)
           break
+
+          /**
+          * 角色异常或该公司禁用,清空菜单返回首页
+          */
         case 'disabled':
-          // 角色异常或该公司禁用,请检查账号或者角色设置"
           this.$store.dispatch('user/disabledCompany')
           break
+
+          /**
+           * 切换路由
+          */
         default:
           queryString = keys.reduce(chunk, '?')
           this.$router.replace('/reload' + queryString)
@@ -191,7 +218,7 @@ export default {
       if (height + scrollTop >= scrollHeight && isAllowLoad) {
         const list = await this.loadMore()
         // 保存到全局
-        this.$store.commit('user/setCompanylist', [...this.companylist, ...convertCompanylist(list)])
+        this.$store.commit('user/setCompanylist', [...this.companylist, ...(this.isSupertube ? list : convertCompanylist(list))])
       }
     },
 
@@ -201,16 +228,20 @@ export default {
       this.state.loading = true
 
       const { page, size, name } = this.params
+
+      const nameProp = this.isSupertube ? 'name' : 'companyName'
+
       const params = {
-        [this.isSupertube ? 'name' : 'companyName']: name,
+        [nameProp]: name,
         page,
         size
       }
 
       const { data } = await api(params)
-
       this.state.loading = false
+
       const isTransboundary = this.companylist.length >= Number(data.count) // 是否越界
+
       if (isTransboundary) {
         this.state.noMore = true
         this.sate.loading = false

+ 6 - 0
src/layout/components/company-select/utils.js

@@ -0,0 +1,6 @@
+// 配置选择公司必须为业务公司的路由
+export const onlyBusinessCompanyPath = ['/goodStore/grossProfit', '/goodStore/platformGrossProfit']
+// 路由是否必须选择业务公司
+export const isOnlyBusinessCompanyPath = path => onlyBusinessCompanyPath.includes(path)
+// 公司是否为业务公司
+export const isBusinessCompany = code => code.indexOf('GS') >= 0

+ 14 - 5
src/mixins/companyHelper.js

@@ -1,14 +1,13 @@
 import { mapState } from 'vuex'
 
-const _mapState = {
+const state = {
   isSupertube: state => state.user.isSupertube, // 是否超管
-  currentCompany: (state) => state.user.currentCompany // 当前选中的业务公司
+  currentCompany: (state) => state.user.currentCompany, // 当前选中的业务公司
+  companylist: (state) => state.user.companylist
 }
 
 const companyHelper = {
-  computed: {
-    ...mapState(_mapState)
-  },
+  computed: { ...mapState(state) },
   methods: {
     /**
      * 当前公司发生改变时默认执行的方法,重置列表数据
@@ -21,6 +20,7 @@ const companyHelper = {
       if (parmValue) this.parmValue.page = 1
       this.searchList()
     },
+
     /**
      * 判断当前是否有选中公司 没有选中返回false并提示警告信息
     */
@@ -28,6 +28,15 @@ const companyHelper = {
       const current = this.currentCompany
       if (!current) this.$message.warning(message)
       return !!current
+    },
+
+    /**
+     * 获取公司编码和名称根据code
+    */
+    getCompanyWithCode(code) {
+      const _code = code || this.currentCompany
+      if (!this.companylist || this.companylist.length === 0 || !_code) return {}
+      return this.companylist.find(({ code }) => code === _code) || {}
     }
   },
   watch: {

+ 6 - 2
src/store/getters.js

@@ -17,7 +17,11 @@ const getters = {
   mainList: state => state.user.mainList,
   business_company: state => state.user.business_company,
   business_companyNo: state => state.user.business_companyNo,
-  private_field: state => state.user.private_field,
-  roleProcess: state => state.user.roleProcess,
+  private_field: state => {
+    if (!state.user.private_field) return []
+    if (typeof state.user.private_field === 'string') return JSON.parse(state.user.private_field)
+    return state.user.private_field
+  },
+  roleProcess: state => state.user.roleProcess
 }
 export default getters

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

@@ -161,7 +161,8 @@ const actions = {
     const company = getUserCompany()
 
     MessageBox
-     .alert(`公司 ${company.name} 角色异常或该公司禁用,请检查账号或者角色设置`, '公司角色异常')
+     .alert(`公司 ${company.name} 角色异常或该公司禁用,请检查账号或者角色设置`, '公司角色异常',
+      {type:'warning', confirmButtonText:'前往首页'})
      .then(() => router.push("/reload?redirect=welcome/dashboard"))
      .catch(() => router.push("/reload?redirect=welcome/dashboard"))
   },
@@ -290,11 +291,11 @@ const actions = {
            }
 
           //非超管用户获取保存 流程权限 & 关键字字段 & 设置默认业务公司
-          let _current_company_ = ''
+          let defaultCompany = ''
           if(!isSupertube){
-             //查找默认的业务公司 设置到全局的currentCompany
-             _current_company_ =  _companylist[0];
-            const result = dispatch('getRoleInfo', _current_company_)
+            //查找默认的业务公司 设置到全局的currentCompany
+            defaultCompany =  _companylist[0];
+            const result = dispatch('getRoleInfo', defaultCompany)
 
             if(result === 'noToken') {
               resolve('noToken')
@@ -303,7 +304,7 @@ const actions = {
           }
 
           //保存默认公司
-          commit('setCurrentCompany', _current_company_ ? _current_company_.code : '')
+          commit('setCurrentCompany', defaultCompany ? defaultCompany.code : '')
           //获取菜单
           const { mcode, mdata, mmsg } = await getRoleMenuList();
 
@@ -412,7 +413,7 @@ async function getRoleMenuList() {
   const { code, data, meaasge, message } = await menuList({});
 
   //menu接受账户异常:禁用 并返回
-  if(message === '账户已禁用'){
+  if(message === '账户已禁用' || message === "没有该公司的默认角色"){
     return {
       mdata:{},
       mmsg:'账号被禁用',

+ 3 - 3
src/utils/auth.js

@@ -38,7 +38,7 @@ export function removeToken() {
 }
 
 export function getMenu() {
-  const menu = Cookies.get(MenuKey)
+  const menu = localStorage.getItem(MenuKey)
   if (menu) {
     return JSON.parse(menu)
   } else {
@@ -47,11 +47,11 @@ export function getMenu() {
 }
 
 export function setMenu(menu) {
-  return Cookies.set(MenuKey, menu)
+  return localStorage.setItem(MenuKey, JSON.stringify(menu))
 }
 
 export function removeMenu() {
-  return Cookies.remove(MenuKey)
+  return localStorage.removeItem(MenuKey)
 }
 
 export function getBtn() {

+ 110 - 109
src/views/goodStore/grossProfit/addEdit.vue

@@ -31,10 +31,9 @@
                 placeholder="分类名称"
                 maxlength="20"
               >
-                <template slot="prepend" v-if="pid_name">{{
+                <template v-if="pid_name" slot="prepend">{{
                   pid_name
-                }}</template></el-input
-              >
+                }}</template></el-input>
             </el-form-item>
             <el-form-item label="分类规格" prop="specs_id">
               <el-select
@@ -49,11 +48,10 @@
                   :key="item.id"
                   :label="item.spec_name"
                   :value="item.id"
-                >
-                </el-option>
+                />
               </el-select>
             </el-form-item>
-            <!-- 
+            <!--
             <el-form-item label="财务核算码" prop="fund_code">
               <el-input
                 v-model="ruleForm.fund_code"
@@ -61,7 +59,7 @@
                 placeholder="财务核算码"
                 maxlength="50"
               />
-             </el-form-item> 
+             </el-form-item>
             -->
             <el-form-item label="售后说明" prop="cat_desc">
               <el-input
@@ -77,8 +75,11 @@
           </el-form>
         </el-col>
         <el-col :span="24" style="text-align: right">
-          <el-button v-if="id !== '007'" type="primary" @click="submitForm"
-            >保 存
+          <el-button
+            v-if="id !== '007'"
+            type="primary"
+            @click="submitForm"
+          >保 存
           </el-button>
           <el-button @click="showModelThis = false">{{
             id == "007" ? "关 闭" : "取 消"
@@ -89,191 +90,191 @@
   </el-dialog>
 </template>
 <script>
-import asyncRequest from "@/apis/service/goodStore/sort";
-import resToken from "@/mixins/resToken";
-import { isChinese } from "@/utils/validate";
+import asyncRequest from '@/apis/service/goodStore/sort'
+import resToken from '@/mixins/resToken'
+import { isChinese } from '@/utils/validate'
 export default {
-  name: "sort",
-  props: ["showModel", "id", "sitem", "titleList"],
+  name: 'Sort',
   mixins: [resToken],
+  props: ['showModel', 'id', 'sitem', 'titleList'],
   data() {
     const validate_fund_code = (rule, value, callback) => {
-      if (value === "") {
-        callback();
+      if (value === '') {
+        callback()
       } else if (isChinese(value)) {
-        callback(new Error("财务核算码不能包含汉字!"));
+        callback(new Error('财务核算码不能包含汉字!'))
       } else {
-        callback();
+        callback()
       }
-    };
+    }
     return {
       loading: false,
-      title: "添加分类",
-      pid_name: "",
+      title: '添加分类',
+      pid_name: '',
       showModelThis: this.showModel,
       specOptions: [],
       ruleForm: {
-        id: "",
-        cat_name: "",
+        id: '',
+        cat_name: '',
         specs_id: [],
-        cat_desc: "",
+        cat_desc: ''
       },
       rulesThis: this.rules,
       rules: {
         cat_name: [
-          { required: true, message: "分类名称不能为空", trigger: "blur" },
+          { required: true, message: '分类名称不能为空', trigger: 'blur' }
         ],
         specs_id: [
           {
-            type: "array",
+            type: 'array',
             required: true,
-            message: "请至少选择一个分类规格",
-            trigger: "change",
-          },
+            message: '请至少选择一个分类规格',
+            trigger: 'change'
+          }
         ],
         fund_code: [
-          { required: false, validator: validate_fund_code, trigger: "blur" },
+          { required: false, validator: validate_fund_code, trigger: 'blur' }
         ],
 
-        cat_desc: [{ required: false, message: "", trigger: "blur" }],
-      },
-    };
+        cat_desc: [{ required: false, message: '', trigger: 'blur' }]
+      }
+    }
   },
   watch: {
-    showModel: function (val) {
-      this.showModelThis = val;
+    showModel: function(val) {
+      this.showModelThis = val
       if (val) {
-        this.initForm();
+        this.initForm()
       }
     },
     showModelThis(val) {
       if (!val) {
-        this.$emit("cancel");
+        this.$emit('cancel')
       }
-    },
+    }
   },
   methods: {
     async initForm() {
-      this.loading = true;
-      this.pid_name = "";
+      this.loading = true
+      this.pid_name = ''
       this.titleList.forEach((e, i) => {
-        this.pid_name += i !== 0 ? `${e.titleName}/` : "";
-      });
-      await this.resetForm();
-      if (this.id === "003") {
-        this.title = "添加分类";
-        this.rulesThis = this.rules;
-      } else if (this.id === "005") {
-        this.title = "修改分类";
-        this.rulesThis = this.rules;
-        await this.initData();
+        this.pid_name += i !== 0 ? `${e.titleName}/` : ''
+      })
+      await this.resetForm()
+      if (this.id === '003') {
+        this.title = '添加分类'
+        this.rulesThis = this.rules
+      } else if (this.id === '005') {
+        this.title = '修改分类'
+        this.rulesThis = this.rules
+        await this.initData()
       } else {
-        this.title = "分类详情";
-        this.rulesThis = {};
-        await this.initData();
+        this.title = '分类详情'
+        this.rulesThis = {}
+        await this.initData()
       }
 
-      await this.getAllSpecs();
+      await this.getAllSpecs()
 
-      this.loading = false;
+      this.loading = false
     },
 
     async resetForm() {
       // 重置
       await this.$nextTick(() => {
         if (this.$refs.ruleForm) {
-          this.$refs.ruleForm.resetFields();
-          this.$refs.ruleForm.clearValidate();
-          const { id, cat_name, cat_desc } = this.sitem;
+          this.$refs.ruleForm.resetFields()
+          this.$refs.ruleForm.clearValidate()
+          const { id, cat_name, cat_desc } = this.sitem
           this.ruleForm = {
-            pid: this.titleList[this.titleList.length - 1].id || "",
-            id: id || "",
-            cat_name: cat_name || "",
+            pid: this.titleList[this.titleList.length - 1].id || '',
+            id: id || '',
+            cat_name: cat_name || '',
             specs_id: [],
-            cat_desc: cat_desc || "",
-          };
+            cat_desc: cat_desc || ''
+          }
         }
-      });
+      })
     },
 
     async getAllSpecs() {
-      this.specOptions = [];
-      let res = await asyncRequest.specstitle({});
+      this.specOptions = []
+      const res = await asyncRequest.specstitle({})
       if (res && res.code === 0) {
-        this.specOptions = res.data;
+        this.specOptions = res.data
       } else if (res && res.code >= 100 && res.code <= 104) {
-        this.specOptions = [];
-        await this.logout();
+        this.specOptions = []
+        await this.logout()
       } else {
-        this.specOptions = [];
-        this.$message.warning(res.message);
+        this.specOptions = []
+        this.$message.warning(res.message)
       }
     },
 
     async initData() {
-      const res = await asyncRequest.detail({ id: this.sitem.id });
+      const res = await asyncRequest.detail({ id: this.sitem.id })
       if (res && res.code === 0 && res.data) {
-        const { pid, id, cat_name, cat_desc, spec, fund_code } = res.data;
-        let specs_id = [];
+        const { pid, id, cat_name, cat_desc, spec, fund_code } = res.data
+        const specs_id = []
         if (spec && spec.length > 0) {
           spec.forEach((e) => {
-            specs_id.push(e.id);
-          });
+            specs_id.push(e.id)
+          })
         }
         this.ruleForm = {
-          pid: pid || "",
-          id: id || "",
-          cat_name: cat_name || "",
+          pid: pid || '',
+          id: id || '',
+          cat_name: cat_name || '',
           specs_id: specs_id || [],
-          fund_code: fund_code || "",
-          cat_desc: cat_desc || "",
-        };
-        this.$refs.ruleForm.resetFields();
-        this.$refs.ruleForm.clearValidate();
+          fund_code: fund_code || '',
+          cat_desc: cat_desc || ''
+        }
+        this.$refs.ruleForm.resetFields()
+        this.$refs.ruleForm.clearValidate()
       } else if (res && res.code >= 100 && res.code <= 104) {
-        await this.logout();
+        await this.logout()
       } else {
-        this.$message.warning(res.message);
+        this.$message.warning(res.message)
       }
     },
-    
+
     async submitForm() {
-      await this.$refs.ruleForm.validate(async (valid) => {
+      await this.$refs.ruleForm.validate(async(valid) => {
         if (valid) {
           if (!this.loading) {
-            this.loading = true;
-            let model = JSON.parse(JSON.stringify(this.ruleForm));
-            let res = {};
-            if (this.id === "003") {
-              delete model["id"];
-              res = await asyncRequest.add(model);
+            this.loading = true
+            const model = JSON.parse(JSON.stringify(this.ruleForm))
+            let res = {}
+            if (this.id === '003') {
+              delete model['id']
+              res = await asyncRequest.add(model)
             } else {
-              res = await asyncRequest.update(model);
+              res = await asyncRequest.update(model)
             }
-            this.loading = false;
+            this.loading = false
             if (res && res.code === 0) {
-              const title = this.id === "add" ? "添加成功!" : "修改成功!";
+              const title = this.id === 'add' ? '添加成功!' : '修改成功!'
               this.$notify.success({
                 title,
-                message: "",
-              });
-              this.showModelThis = false;
+                message: ''
+              })
+              this.showModelThis = false
               // 刷新
-              this.$emit("refresh");
+              this.$emit('refresh')
             } else if (res && res.code >= 100 && res.code <= 104) {
-              await this.logout();
+              await this.logout()
             } else {
-              this.$message.warning(res.message);
+              this.$message.warning(res.message)
             }
           }
         } else {
-          console.log("error submit!!");
-          return false;
+          console.log('error submit!!')
+          return false
         }
-      });
-    },
-  },
-};
+      })
+    }
+  }
+}
 </script>
 
 <style lang="scss" scoped>

+ 128 - 166
src/views/goodStore/grossProfit/addEditRate.vue

@@ -1,7 +1,7 @@
 <template>
   <el-dialog
     v-loading="loading"
-    :title="'设置毛利率'"
+    :title="title"
     :center="true"
     align="left"
     top="12vh"
@@ -24,6 +24,7 @@
             :rules="rulesThis"
             label-width="110px"
             class="demo-ruleForm"
+            :disabled="isDetail"
           >
             <el-form-item label="分类名称" prop="cat_name">
               <el-input
@@ -31,19 +32,18 @@
                 disabled
                 placeholder="分类名称"
                 maxlength="20"
-                ><template slot="prepend" v-if="pid_name">{{
-                  pid_name
-                }}</template></el-input
-              >
+              ><template v-if="pid_name" slot="prepend">{{
+                pid_name
+              }}</template></el-input>
             </el-form-item>
-            <el-form-item label="财务核算码" prop="fund_code">
+            <!-- <el-form-item label="财务核算码" prop="fund_code">
               <el-input
                 v-model="ruleForm.fund_code"
                 disabled
                 placeholder="财务核算码"
                 maxlength="50"
               />
-            </el-form-item>
+            </el-form-item> -->
             <el-form-item label="预算→成本" prop="order_rate">
               <digital-input
                 :values="ruleForm.order_rate"
@@ -115,29 +115,15 @@
                 @reschange="rate_change($event, 'low_rate')"
               />
             </el-form-item>
-            <!-- <el-form-item label="BOSS毛利率" prop="lower_rate">
-              <digital-input
-                :values="ruleForm.lower_rate"
-                :placeholder="'BOSS毛利率'"
-                :min="-100"
-                :max="100000000000"
-                :position="'right'"
-                :precision="2"
-                :size="'mini'"
-                :controls="false"
-                :append="'%'"
-                @reschange="rate_change($event, 'lower_rate')"
-              />
-            </el-form-item>-->
           </el-form>
         </el-col>
         <el-col :span="24" style="text-align: right">
           <el-button
-            v-if="id !== '007'"
+            v-if="id !== '007' && !isDetail"
             type="primary"
             :size="'small'"
             @click="submitForm"
-            >保 存
+          >保 存
           </el-button>
           <el-button :size="'small'" @click="showModelThis = false">{{
             id == "007" ? "关 闭" : "取 消"
@@ -149,133 +135,141 @@
 </template>
 
 <script>
-import asyncRequest from "@/apis/service/goodStore/sort";
-import resToken from "@/mixins/resToken";
+import asyncRequest from '@/apis/service/goodStore/grossProfit'
+import companyHelper from '@/mixins/companyHelper'
+import resToken from '@/mixins/resToken'
+
 export default {
-  name: "sort",
-  props: ["showModel", "id", "sitem", "titleList"],
-  mixins: [resToken],
+  name: 'Sort',
+  mixins: [resToken, companyHelper],
+  props: ['showModel', 'id', 'sitem', 'titleList', 'isDetail'],
   data() {
     const validate_rate = (rule, value, callback) => {
-      const { required } = rule;
-      if (value === "" && required) {
-        callback(new Error("主管利率毛利率不能为空!"));
+      const { required } = rule
+      if (value === '' && required) {
+        callback(new Error('主管利率毛利率不能为空!'))
       } else {
-        callback();
+        callback()
       }
-    };
+    }
     const validate_order_rate = (rule, value, callback) => {
-      const { required } = rule;
-      if (value === "" && required) {
-        callback(new Error("预算→成本毛利率不能为空!"));
+      const { required } = rule
+      if (value === '' && required) {
+        callback(new Error('预算→成本毛利率不能为空!'))
       } else {
-        callback();
+        callback()
       }
-    };
+    }
     const validate_sale_rate = (rule, value, callback) => {
-      const { required } = rule;
-      if (value === "" && required) {
-        callback(new Error("成本→售价毛利率不能为空!"));
+      const { required } = rule
+      if (value === '' && required) {
+        callback(new Error('成本→售价毛利率不能为空!'))
       } else {
-        callback();
+        callback()
       }
-    };
+    }
 
     const validate_lower_rate = (rule, value, callback) => {
-      const { required } = rule;
-      if (value === "" && required) {
-        callback(new Error("BOSS毛利率不能为空!"));
+      const { required } = rule
+      if (value === '' && required) {
+        callback(new Error('BOSS毛利率不能为空!'))
       } else {
-        callback();
+        callback()
       }
-    };
+    }
     const validate_low_rate = (rule, value, callback) => {
-      const { required } = rule;
-      if (value === "" && required) {
-        callback(new Error("项目最低毛利率不能为空!"));
+      const { required } = rule
+      if (value === '' && required) {
+        callback(new Error('项目最低毛利率不能为空!'))
       } else {
-        callback();
+        callback()
       }
-    };
+    }
     const validate_money_rate = (rule, value, callback) => {
-      const { required } = rule;
-      if (value === "" && required) {
-        callback(new Error("财务毛利率不能为空!"));
+      const { required } = rule
+      if (value === '' && required) {
+        callback(new Error('财务毛利率不能为空!'))
       } else {
-        callback();
+        callback()
       }
-    };
+    }
     return {
       loading: false,
       showModelThis: this.showModel,
-      pid_name: "",
+      pid_name: '',
       ruleForm: {
-        id: "",
-        cat_name: "",
-        order_rate: "0",
-        sale_rate: "0",
-        lower_rate: "0",
-        rate: "0",
-        low_rate: "0",
-        money_rate: "0",
+        id: '',
+        cat_name: '',
+        order_rate: '0',
+        sale_rate: '0',
+        lower_rate: '0',
+        rate: '0',
+        low_rate: '0',
+        money_rate: '0'
       },
       rulesThis: this.rules,
       rules: {
         order_rate: [
-          { required: true, validator: validate_order_rate, trigger: "blur" },
+          { required: true, validator: validate_order_rate, trigger: 'blur' }
         ],
         sale_rate: [
-          { required: true, validator: validate_sale_rate, trigger: "blur" },
+          { required: true, validator: validate_sale_rate, trigger: 'blur' }
         ],
         lower_rate: [
-          { required: false, validator: validate_lower_rate, trigger: "blur" },
+          { required: false, validator: validate_lower_rate, trigger: 'blur' }
         ],
-        rate: [{ required: true, validator: validate_rate, trigger: "blur" }],
+        rate: [{ required: true, validator: validate_rate, trigger: 'blur' }],
         low_rate: [
-          { required: true, validator: validate_low_rate, trigger: "blur" },
+          { required: true, validator: validate_low_rate, trigger: 'blur' }
         ],
         money_rate: [
-          { required: true, validator: validate_money_rate, trigger: "blur" },
-        ],
-      },
-    };
+          { required: true, validator: validate_money_rate, trigger: 'blur' }
+        ]
+      }
+    }
+  },
+  computed: {
+    title() {
+      const base = '毛利率'
+      const prefix = this.isDetail ? '查看' : '设置'
+      return prefix + base
+    }
   },
   watch: {
-    showModel: function (val) {
-      this.showModelThis = val;
+    showModel: function(val) {
+      this.showModelThis = val
       if (val) {
-        this.initForm();
+        this.initForm()
       }
     },
     showModelThis(val) {
       if (!val) {
-        this.$emit("cancel");
+        this.$emit('cancel')
       }
-    },
+    }
   },
   methods: {
     async initForm() {
-      this.loading = true;
-      this.pid_name = "";
+      this.loading = true
+      this.pid_name = ''
       this.titleList.forEach((e, i) => {
-        this.pid_name += i !== 0 ? `${e.titleName}/` : "";
-      });
-      this.rulesThis = this.rules;
-      await this.resetForm();
-      await this.initData();
-      this.loading = false;
+        this.pid_name += i !== 0 ? `${e.titleName}/` : ''
+      })
+      this.rulesThis = this.rules
+      await this.resetForm()
+      this.loading = false
     },
 
     async resetForm() {
       // 重置
       await this.$nextTick(() => {
         if (this.$refs.ruleForm) {
-          this.$refs.ruleForm.resetFields();
-          this.$refs.ruleForm.clearValidate();
-          
+          this.$refs.ruleForm.resetFields()
+          this.$refs.ruleForm.clearValidate()
+
           const {
             pid,
-            id,
+            cat_id,
             cat_name,
             order_rate,
             sale_rate,
@@ -283,97 +277,65 @@ export default {
             rate,
             fund_code,
             low_rate,
-            money_rate,
-          } = this.sitem;
-          
+            money_rate
+          } = this.sitem
+
           this.ruleForm = {
-            pid: pid || "",
-            id: id || "",
-            cat_name: cat_name || "",
-            fund_code: fund_code || "",
-            order_rate: order_rate || "0",
-            sale_rate: sale_rate || "0",
-            lower_rate: lower_rate || "0",
-            rate: rate || "0",
-            low_rate: low_rate || "0",
-            money_rate: money_rate || "0",
-          };
+            pid: pid || '',
+            cat_id: cat_id || '',
+            cat_name: cat_name || '',
+            fund_code: fund_code || '',
+            order_rate: order_rate || '0',
+            sale_rate: sale_rate || '0',
+            lower_rate: lower_rate || '0',
+            rate: rate || '0',
+            low_rate: low_rate || '0',
+            money_rate: money_rate || '0'
+          }
         }
-      });
+      })
     },
     rate_change(e, key) {
-      this.ruleForm[key] = e + "";
-      this.$refs.ruleForm.validateField(key);
+      this.ruleForm[key] = e + ''
+      this.$refs.ruleForm.validateField(key)
     },
 
-    async initData() {
-      const { code, data, message } = await asyncRequest.detail({
-        id: this.sitem.id,
-      });
-      if (code === 0) {
-        const {
-          pid,
-          id,
-          cat_name,
-          order_rate,
-          sale_rate,
-          lower_rate,
-          rate,
-          fund_code,
-          low_rate,
-          money_rate,
-        } = data;
-        this.ruleForm = {
-          pid: pid || "",
-          id: id || "",
-          cat_name: cat_name || "",
-          fund_code: fund_code || "",
-          order_rate: order_rate || "0",
-          sale_rate: sale_rate || "0",
-          lower_rate: lower_rate || "0",
-          rate: rate || "0",
-          low_rate: low_rate || "0",
-          money_rate: money_rate || "0",
-        };
-      } else if (code >= 100 && code <= 104) {
-        await this.logout();
-      } else {
-        this.$message.warning(message);
-      }
-    },
     async submitForm() {
-      await this.$refs.ruleForm.validate(async (valid) => {
+      if (!this.isHasCurrentCompany()) return
+
+      await this.$refs.ruleForm.validate(async(valid) => {
         if (valid) {
           if (!this.loading) {
-            this.loading = true;
-            let model = JSON.parse(JSON.stringify(this.ruleForm));
-            delete model["cat_name"];
-            delete model["pid"];
-            delete model["fund_code"];
-            let res = await asyncRequest.editRate(model);
-            this.loading = false;
+            this.loading = true
+            const model = JSON.parse(JSON.stringify(this.ruleForm))
+            model.companyNo = this.currentCompany
+            delete model['cat_name']
+            delete model['pid']
+            delete model['fund_code']
+            const res = await asyncRequest.editRate(model)
+            this.loading = false
             if (res && res.code === 0) {
               this.$notify.success({
-                title: "毛利率设置成功!",
-                message: "",
-              });
-              this.showModelThis = false;
+                title: '毛利率设置成功!',
+                message: ''
+              })
+              this.showModelThis = false
               // 刷新
-              this.$emit("refresh");
+              this.$emit('refresh')
             } else if (res && res.code >= 100 && res.code <= 104) {
-              await this.logout();
+              await this.logout()
             } else {
-              this.$message.warning(res.message);
+              this.$message.warning(res.message)
             }
           }
         } else {
-          console.log("error submit!!");
-          return false;
+          console.log('error submit!!')
+          return false
         }
-      });
-    },
-  },
-};
+      })
+    }
+  }
+}
 </script>
 
    <style lang="scss" scoped>

+ 93 - 97
src/views/goodStore/grossProfit/index.vue

@@ -81,19 +81,6 @@
                 placeholder="分类名称"
               ></el-input>
             </el-col>
-            <el-col :span="4" style="width: 170px; padding: 0 0 0 10px">
-              <el-input
-                :size="searchSize"
-                v-model="parmValue.company_name"
-                :maxlength="40"
-                @blur="
-                  pageInfo.curr = 1;
-                  parmValue.page = 1;
-                  searchList();
-                "
-                placeholder="创建人部门"
-              ></el-input>
-            </el-col>
             <el-col
               :span="3"
               class="fr"
@@ -110,6 +97,7 @@
           </el-row>
         </div>
       </template>
+
       <template #status="{ scope }">
         <el-tag
           :size="tablebtnSize"
@@ -121,15 +109,34 @@
         ></el-tag>
       </template>
 
+      <template #supplierNo>
+        {{getCompanyWithCode().code}}
+      </template>
+
+      <template #supplierName>
+        {{getCompanyWithCode().name}}
+      </template>
+
+
       <template #operation="{ scope }">
         <el-tooltip
-          v-if="powers.some((i) => i == '007')"
+          v-if="powers.some((i) => i == '061')"
           effect="dark"
-          content="详情"
+          content="查看毛利率"
           placement="top"
         >
           <i class="el-icon-view tb-icon" @click="openModal(scope.row, '007')"></i>
         </el-tooltip>
+
+        <el-tooltip
+          v-if="powers.some((i) => i == '060')"
+          effect="dark"
+          content="设置毛利率"
+          placement="top"
+        >
+          <i class="el-icon-edit tb-icon" @click="setRate(scope.row)"></i>
+        </el-tooltip>
+
         <el-tooltip
           v-if="powers.some((i) => i == '005')"
           effect="dark"
@@ -138,6 +145,7 @@
         >
           <i class="el-icon-edit tb-icon" @click="openModal(scope.row, '005')"></i>
         </el-tooltip>
+       
         <el-tooltip
           v-if="
             powers.some((i) => i == '004') && scope.row.status + '' === '1'
@@ -148,9 +156,10 @@
         >
           <i
             class="el-icon-video-pause tb-icon"
-            @click="changeStatus(scope.row.id, scope.row.status)"
+            @click="changeStatus(scope.row.cat_id, scope.row.status)"
           ></i>
         </el-tooltip>
+
         <el-tooltip
           v-if="
             powers.some((i) => i == '004') && scope.row.status + '' === '0'
@@ -161,9 +170,10 @@
         >
           <i
             class="el-icon-video-play tb-icon"
-            @click="changeStatus(scope.row.id, scope.row.status)"
+            @click="changeStatus(scope.row.cat_id, scope.row.status)"
           ></i>
         </el-tooltip>
+      <!-- 
         <el-tooltip
           v-if="powers.some((i) => i == '006')"
           effect="dark"
@@ -171,15 +181,8 @@
           placement="top"
         >
           <i class="el-icon-delete tb-icon" @click="deleteItem(scope.row.id)"></i>
-        </el-tooltip>
-        <el-tooltip
-          v-if="powers.some((i) => i == '060')"
-          effect="dark"
-          content="设置毛利率"
-          placement="top"
-        >
-          <i class="el-icon-s-check tb-icon" @click="setRate(scope.row)"></i>
-        </el-tooltip>
+        </el-tooltip> -->
+        
         <el-tooltip
           v-if="parseInt(scope.row.level) < 3"
           effect="dark"
@@ -191,19 +194,12 @@
       </template>
     </ex-table>
     <no-auth v-else></no-auth>
-    <!-- 弹窗 新增/修改 -->
-    <add-edit
-      :id="modelId"
-      :show-model="showModel"
-      :sitem="sitem"
-      :titleList="titleList"
-      @refresh="searchList"
-      @cancel="showModel = false"
-    />
+
     <!-- 弹窗 新增/修改 -->
     <add-edit-rate
       :id="modelRateId"
       :show-model="showRateModel"
+      :is-detail="isDetail"
       :sitem="sitemRate"
       :titleList="titleList"
       @refresh="searchList"
@@ -225,10 +221,7 @@ import { mapGetters } from "vuex";
 export default {
   name: "grossProfit",
   mixins: [mixinPage, resToken, companyHelper],
-  components: {
-    addEdit,
-    addEditRate
-  },
+  components: { addEdit, addEditRate },
   computed: {
     //组件SIZE设置
     ...mapGetters(["tablebtnSize", "searchSize", "size"]),
@@ -257,6 +250,7 @@ export default {
         cat_name: "",
         pid: "0"
       },
+      isDetail:false,
       // 状态
       statusOptions: [
         { id: "0", label: "禁用" },
@@ -281,37 +275,36 @@ export default {
         {
           prop: "cat_name",
           label: "分类名称",
-          width: "130px"
-        },
-        {
-          prop: "supplierNo",
-          label: "公司编码"
-        },
-        {
-          prop: "supplierName",
-          label: "公司名称"
+          // width: "130px"
         },
         {
           prop: "status",
           label: "状态",
           _slot_: "status",
-          width: "70px"
+          width: "70px",
         },
         {
-          prop: "status",
-          label: "状态",
-          width: "70px"
+          prop: "level",
+          label: "分类等级",
+          width: "80px",
+        },
+        {
+          prop: "supplierNo",
+          label: "公司编码",
+          width: "260px",
+          _slot_: "supplierNo",
         },
         {
-          prop: "addtime",
-          label: "创建时间",
-          width: "145px"
+          prop: "supplierName",
+          label: "公司名称",
+          width: "260px",
+          _slot_: "supplierName",
         },
         {
           prop: "",
           label: "操作",
           fixed: "right",
-          width: "200px",
+          width: "140px",
           _noset_: true,
           _slot_: "operation"
         }
@@ -335,7 +328,6 @@ export default {
         page: 1, // 页码
         size: 15, // 每页显示条数
         status: "",
-        company_name: "", //创建人部门
         pid: "0",
         cat_name: ""
       };
@@ -349,7 +341,7 @@ export default {
     },
     //查看下一级分类
     async openChildren(item) {
-      this.parmValue.pid = item.id;
+      this.parmValue.pid = item.cat_id;
       this.pageInfo.curr = 1;
       this.parmValue.page = 1;
       await this.searchList();
@@ -364,17 +356,20 @@ export default {
       this.modelRateId = row.id;
       this.sitemRate = row;
       this.showRateModel = true;
+      this.isDetail = false
     },
     // 新建/编辑/详情
     openModal(row, type) {
-      const { status } = row;
-      if (type === "005" && status + '' === "1") {
-        this.$message.warning("禁用后,才可以修改!");
-        return;
-      }
-      this.sitem = row;
-      this.modelId = type;
-      this.showModel = true;
+      // const { status } = row;
+      // if (type === "005" && status + '' === "1") {
+      //   this.$message.warning("禁用后,才可以修改!");
+      //   return;
+      // }
+      
+      this.modelRateId = row.id;
+      this.sitemRate = row;
+      this.showRateModel = true;
+      this.isDetail = type === '007'
     },
     async changeBreadcrumb(index) {
       if (index + 1 === this.titleList.length) {
@@ -393,7 +388,7 @@ export default {
      * @param {String} id id
      * @param {String} status 0-禁用 1-启用
      */
-    async changeStatus(id, status) {
+    async changeStatus(cat_id, status) {
       await this.$confirm(`确定要改为${status + '' === "1" ? "禁用" : "启用"}?`, {
         confirmButtonText: "确定",
         cancelButtonText: "取消",
@@ -403,8 +398,9 @@ export default {
           this.loading = true;
 
           const model = {
-            id: id,
-            status: status + '' === "1" ? "0" : "1"
+            cat_id,
+            companyNo: this.currentCompany || '',
+            status: status  + '' === "1" ? "0" : "1"
           };
 
           const res = await asyncRequest.status(model);
@@ -428,33 +424,33 @@ export default {
           console.log("取消");
         });
     },
-    async deleteItem(id) {
-      await this.$confirm("确定要删除?", {
-        confirmButtonText: "确定",
-        cancelButtonText: "取消",
-        type: "warning"
-      })
-        .then(async () => {
-          const model = {
-            id: id
-          };
-          const res = await asyncRequest.delete(model);
-          if (res && res.code === 0) {
-            this.$notify.success({
-              title: "删除成功",
-              message: ""
-            });
-            this.searchList();
-          } else if (res && res.code >= 100 && res.code <= 104) {
-            await this.logout();
-          } else {
-            this.$message.warning(res.message);
-          }
-        })
-        .catch(() => {
-          console.log("取消");
-        });
-    },
+    // async deleteItem(id) {
+    //   await this.$confirm("确定要删除?", {
+    //     confirmButtonText: "确定",
+    //     cancelButtonText: "取消",
+    //     type: "warning"
+    //   })
+    //     .then(async () => {
+    //       const model = {
+    //         id: id
+    //       };
+    //       const res = await asyncRequest.delete(model);
+    //       if (res && res.code === 0) {
+    //         this.$notify.success({
+    //           title: "删除成功",
+    //           message: ""
+    //         });
+    //         this.searchList();
+    //       } else if (res && res.code >= 100 && res.code <= 104) {
+    //         await this.logout();
+    //       } else {
+    //         this.$message.warning(res.message);
+    //       }
+    //     })
+    //     .catch(() => {
+    //       console.log("取消");
+    //     });
+    // },
     // 刷新表格
     async searchList() {
       if (!this.currentCompany) {
@@ -464,7 +460,7 @@ export default {
         return;
       }
 
-      this.parmValue.supplierNo = this.currentCompany;
+      this.parmValue.companyNo = this.currentCompany;
 
       this.loading = true;
       const res = await asyncRequest.list(this.parmValue);

+ 238 - 137
src/views/goodStore/platformGrossProfit/addEditRate.vue

@@ -1,7 +1,7 @@
 <template>
   <el-dialog
     v-loading="loading"
-    :title="'设置毛利率'"
+    :title="title"
     :center="true"
     align="left"
     top="12vh"
@@ -24,6 +24,7 @@
             :rules="rulesThis"
             label-width="110px"
             class="demo-ruleForm"
+            :disabled="isDetail"
           >
             <el-form-item label="分类名称" prop="cat_name">
               <el-input
@@ -31,18 +32,22 @@
                 disabled
                 placeholder="分类名称"
                 maxlength="20"
-                >
-                <template slot="prepend" v-if="pid_name">
-                  {{ pid_name }}
-                </template>
-               </el-input>
+              ><template v-if="pid_name" slot="prepend">{{
+                pid_name
+              }}</template></el-input>
             </el-form-item>
-            <el-form-item label="财务核算码" prop="fund_code">
-              <el-input
-                v-model="ruleForm.fund_code"
-                disabled
-                placeholder="财务核算码"
-                maxlength="50"
+            <el-form-item label="预算→成本" prop="order_rate">
+              <digital-input
+                :values="ruleForm.order_rate"
+                :placeholder="'预算→成本'"
+                :min="0"
+                :max="100000000000"
+                :position="'right'"
+                :precision="2"
+                :size="'mini'"
+                :controls="false"
+                :append="'%'"
+                @reschange="rate_change($event, 'order_rate')"
               />
             </el-form-item>
             <el-form-item label="成本→售价" prop="sale_rate">
@@ -59,15 +64,58 @@
                 @reschange="rate_change($event, 'sale_rate')"
               />
             </el-form-item>
+
+            <el-form-item label="主管利率" prop="rate">
+              <digital-input
+                :values="ruleForm.rate"
+                :placeholder="'主管利率'"
+                :min="-100"
+                :max="100000000000"
+                :position="'right'"
+                :precision="2"
+                :size="'mini'"
+                :controls="false"
+                :append="'%'"
+                @reschange="rate_change($event, 'rate')"
+              />
+            </el-form-item>
+            <el-form-item label="财务利率" prop="money_rate">
+              <digital-input
+                :values="ruleForm.money_rate"
+                :placeholder="'财务利率'"
+                :min="-100"
+                :max="100000000000"
+                :position="'right'"
+                :precision="2"
+                :size="'mini'"
+                :controls="false"
+                :append="'%'"
+                @reschange="rate_change($event, 'money_rate')"
+              />
+            </el-form-item>
+            <el-form-item label="项目最低毛利" prop="low_rate">
+              <digital-input
+                :values="ruleForm.low_rate"
+                :placeholder="'项目最低毛利'"
+                :min="-100"
+                :max="100000000000"
+                :position="'right'"
+                :precision="2"
+                :size="'mini'"
+                :controls="false"
+                :append="'%'"
+                @reschange="rate_change($event, 'low_rate')"
+              />
+            </el-form-item>
           </el-form>
         </el-col>
         <el-col :span="24" style="text-align: right">
           <el-button
-            v-if="id !== '007'"
+            v-if="id !== '007' && !isDetail"
             type="primary"
             :size="'small'"
             @click="submitForm"
-            >保 存
+          >保 存
           </el-button>
           <el-button :size="'small'" @click="showModelThis = false">{{
             id == "007" ? "关 闭" : "取 消"
@@ -77,123 +125,143 @@
     </el-card>
   </el-dialog>
 </template>
+
 <script>
-import asyncRequest from "@/apis/service/youzan/othsearchSort";
-import resToken from "@/mixins/resToken";
+import asyncRequest from '@/apis/service/goodStore/platformGrossProfit'
+import companyHelper from '@/mixins/companyHelper'
+import resToken from '@/mixins/resToken'
+
 export default {
-  name: "sort",
-  props: ["showModel", "id", "sitem", "titleList"],
-  mixins: [resToken],
+  name: 'Sort',
+  mixins: [resToken, companyHelper],
+  props: ['showModel', 'id', 'sitem', 'titleList', 'isDetail', 'platform_id'],
   data() {
     const validate_rate = (rule, value, callback) => {
-      const { required } = rule;
-      if (value === "" && required) {
-        callback(new Error("主管利率毛利率不能为空!"));
+      const { required } = rule
+      if (value === '' && required) {
+        callback(new Error('主管利率毛利率不能为空!'))
       } else {
-        callback();
+        callback()
       }
-    };
+    }
     const validate_order_rate = (rule, value, callback) => {
-      const { required } = rule;
-      if (value === "" && required) {
-        callback(new Error("预算→成本毛利率不能为空!"));
+      const { required } = rule
+      if (value === '' && required) {
+        callback(new Error('预算→成本毛利率不能为空!'))
       } else {
-        callback();
+        callback()
       }
-    };
+    }
     const validate_sale_rate = (rule, value, callback) => {
-      const { required } = rule;
-      if (value === "" && required) {
-        callback(new Error("成本→售价毛利率不能为空!"));
+      const { required } = rule
+      if (value === '' && required) {
+        callback(new Error('成本→售价毛利率不能为空!'))
       } else {
-        callback();
+        callback()
       }
-    };
+    }
 
     const validate_lower_rate = (rule, value, callback) => {
-      const { required } = rule;
-      if (value === "" && required) {
-        callback(new Error("BOSS毛利率不能为空!"));
+      const { required } = rule
+      if (value === '' && required) {
+        callback(new Error('BOSS毛利率不能为空!'))
       } else {
-        callback();
+        callback()
       }
-    };
+    }
     const validate_low_rate = (rule, value, callback) => {
-      const { required } = rule;
-      if (value === "" && required) {
-        callback(new Error("项目最低毛利率不能为空!"));
+      const { required } = rule
+      if (value === '' && required) {
+        callback(new Error('项目最低毛利率不能为空!'))
       } else {
-        callback();
+        callback()
       }
-    };
+    }
     const validate_money_rate = (rule, value, callback) => {
-      const { required } = rule;
-      if (value === "" && required) {
-        callback(new Error("财务毛利率不能为空!"));
+      const { required } = rule
+      if (value === '' && required) {
+        callback(new Error('财务毛利率不能为空!'))
       } else {
-        callback();
+        callback()
       }
-    };
+    }
     return {
       loading: false,
       showModelThis: this.showModel,
-      pid_name: "",
+      pid_name: '',
       ruleForm: {
-        platform_id: "",
-        cat_id: "",
-        cat_name: "",
-        order_rate: "0",
-        sale_rate: "0",
-        lower_rate: "0",
-        rate: "0",
-        low_rate: "0",
-        money_rate: "0",
+        id: '',
+        cat_name: '',
+        order_rate: '0',
+        sale_rate: '0',
+        lower_rate: '0',
+        rate: '0',
+        low_rate: '0',
+        money_rate: '0'
       },
       rulesThis: this.rules,
       rules: {
-        order_rate: [{ required: true, validator: validate_order_rate, trigger: "blur" }],
-        sale_rate: [{ required: true, validator: validate_sale_rate, trigger: "blur" }],
-        lower_rate: [{ required: false, validator: validate_lower_rate, trigger: "blur" }],
-        rate: [{ required: true, validator: validate_rate, trigger: "blur" }],
-        low_rate: [{ required: true, validator: validate_low_rate, trigger: "blur" }],
-        money_rate: [{ required: true, validator: validate_money_rate, trigger: "blur" }],
-      },
-    };
+        order_rate: [
+          { required: true, validator: validate_order_rate, trigger: 'blur' }
+        ],
+        sale_rate: [
+          { required: true, validator: validate_sale_rate, trigger: 'blur' }
+        ],
+        lower_rate: [
+          { required: false, validator: validate_lower_rate, trigger: 'blur' }
+        ],
+        rate: [{ required: true, validator: validate_rate, trigger: 'blur' }],
+        low_rate: [
+          { required: true, validator: validate_low_rate, trigger: 'blur' }
+        ],
+        money_rate: [
+          { required: true, validator: validate_money_rate, trigger: 'blur' }
+        ]
+      }
+    }
+  },
+  computed: {
+    title() {
+      const base = '毛利率'
+      const prefix = this.isDetail ? '查看' : '设置'
+      return prefix + base
+    }
   },
   watch: {
-    showModel: function (val) {
-      this.showModelThis = val;
+    showModel: function(val) {
+      this.showModelThis = val
       if (val) {
-        this.initForm();
+        this.initForm()
       }
     },
     showModelThis(val) {
       if (!val) {
-        this.$emit("cancel");
+        this.$emit('cancel')
       }
-    },
+    }
   },
   methods: {
     async initForm() {
-      this.loading = true;
-      this.pid_name = "";
+      this.loading = true
+      this.pid_name = ''
       this.titleList.forEach((e, i) => {
-        this.pid_name += i !== 0 ? `${e.titleName}/` : "";
-      });
-      this.rulesThis = this.rules;
-      await this.resetForm();
-      this.loading = false;
+        this.pid_name += i !== 0 ? `${e.titleName}/` : ''
+      })
+      this.rulesThis = this.rules
+      await this.resetForm()
+      this.loading = false
     },
 
     async resetForm() {
       // 重置
       await this.$nextTick(() => {
         if (this.$refs.ruleForm) {
-          this.$refs.ruleForm.resetFields();
-          this.$refs.ruleForm.clearValidate();
+          this.$refs.ruleForm.resetFields()
+          this.$refs.ruleForm.clearValidate()
+
           const {
-            platform_id,
-            id,
+            pid,
+            cat_id,
             cat_name,
             order_rate,
             sale_rate,
@@ -201,77 +269,110 @@ export default {
             rate,
             fund_code,
             low_rate,
-            money_rate,
-          } = this.sitem;
+            money_rate
+          } = this.sitem
+
           this.ruleForm = {
-            platform_id: platform_id + "" || "",
-            cat_id: id || "",
-            cat_name: cat_name || "",
-            fund_code: fund_code || "",
-            order_rate: order_rate || "0",
-            sale_rate: sale_rate || "0",
-            lower_rate: lower_rate || "0",
-            rate: rate || "0",
-            low_rate: low_rate || "0",
-            money_rate: money_rate || "0",
-          };
+            pid: pid || '',
+            cat_id: cat_id || '',
+            cat_name: cat_name || '',
+            fund_code: fund_code || '',
+            order_rate: order_rate || '0',
+            sale_rate: sale_rate || '0',
+            lower_rate: lower_rate || '0',
+            rate: rate || '0',
+            low_rate: low_rate || '0',
+            money_rate: money_rate || '0',
+            platform_id: this.platform_id || ''
+          }
         }
-      });
+      })
     },
+
     rate_change(e, key) {
-      this.ruleForm[key] = e + "";
-      this.$refs.ruleForm.validateField(key);
+      this.ruleForm[key] = e + ''
+      this.$refs.ruleForm.validateField(key)
+    },
+
+    async changeStatus(cat_id, status) {
+      await this.$confirm(`确定要改为${status + '' === '1' ? '禁用' : '启用'}?`, {
+        confirmButtonText: '确定',
+        cancelButtonText: '取消',
+        type: 'warning'
+      })
+        .then(async() => {
+          this.loading = true
+
+          console.log(status + '' === '1' ? '0' : '1')
+
+          const model = {
+            cat_id,
+            platform_id: this.pa,
+            status: status + '' === '1' ? '0' : '1',
+            companyNo: this.currentCompany
+          }
+
+          const res = await asyncRequest.status(model)
+          if (res && res.code === 0) {
+            this.loading = false
+
+            this.$notify.success({
+              title: '状态修改成功!',
+              message: ''
+            })
+
+            await this.searchList()
+          } else if (res && res.code >= 100 && res.code <= 104) {
+            await this.logout()
+          } else {
+            this.loading = false
+            this.$message.warning(res.message)
+          }
+        })
+        .catch(() => {
+          console.log('取消')
+        })
     },
+
     async submitForm() {
-      await this.$refs.ruleForm.validate(async (valid) => {
+      if (!this.isHasCurrentCompany()) return
+
+      await this.$refs.ruleForm.validate(async(valid) => {
         if (valid) {
           if (!this.loading) {
-            this.loading = true;
-            let model = JSON.parse(JSON.stringify(this.ruleForm));
-            delete model["cat_name"];
-            // delete model["pid"];
-            // delete model["fund_code"];
-            const { code, data, message } = await asyncRequest.update(model);
-            this.loading = false;
-            if (code === 0) {
+            this.loading = true
+            const model = JSON.parse(JSON.stringify(this.ruleForm))
+            model.companyNo = this.currentCompany
+            delete model['cat_name']
+            delete model['pid']
+            delete model['fund_code']
+            const res = await asyncRequest.setSpcp(model)
+            this.loading = false
+            if (res && res.code === 0) {
               this.$notify.success({
-                title: "毛利率设置成功!",
-                message: "",
-              });
-              this.showModelThis = false;
+                title: '毛利率设置成功!',
+                message: ''
+              })
+              this.showModelThis = false
               // 刷新
-              this.$emit("refresh");
-            } else if (code >= 100 && code <= 104) {
-              await this.logout();
-            } else if (code === 10004) {
-              const { skuCode } = data;
-              let resList = JSON.parse(JSON.stringify(skuCode));
-
-              let htmlList = "<ul>";
-              resList.forEach((v) => {
-                htmlList += `<li><span>${v.skuCode}__</span><span>${v.good_name}</span></li>`;
-              });
-              htmlList += "</ul>";
-              this.$notify({
-                title: "新毛利已影响以下线上商品售价,请下线后再修改!",
-                dangerouslyUseHTMLString: true,
-                message: htmlList,
-              });
+              this.$emit('refresh')
+            } else if (res && res.code >= 100 && res.code <= 104) {
+              await this.logout()
             } else {
-              this.$message.warning(message);
+              this.$message.warning(res.message)
             }
           }
         } else {
-          console.log("error submit!!");
-          return false;
+          console.log('error submit!!')
+          return false
         }
-      });
-    },
-  },
-};
+      })
+    }
+  }
+}
 </script>
 
-<style lang="scss" scoped>
+   <style lang="scss" scoped>
 .sort {
 }
 </style>

+ 131 - 45
src/views/goodStore/platformGrossProfit/index.vue

@@ -99,16 +99,27 @@
           </el-row>
         </div></template
       >
+      
+
+      <template #companyNo>
+        <div>{{getCompanyWithCode(currentCompany).code}}</div>
+      </template>
+
+      <template #companyName>
+        <div>{{getCompanyWithCode(currentCompany).name}}</div>
+      </template>
+
       <template #status="{ scope }">
         <el-tag
           :size="tablebtnSize"
-          :type="scope.row.status == '0' ? 'warning' : ''"
+          :type="scope.row.status == '1' ? '' : 'warning'"
           v-text="
             (statusOptions.find((item) => item.id == scope.row.status) || {}).label ||
-            '--'
+            '禁用'
           "
         ></el-tag>
       </template>
+
       <template #order_rate="{ scope }">
         <div>
           {{
@@ -167,13 +178,51 @@
 
       <template #operation="{ scope }">
         <el-tooltip
-          v-if="powers.some((i) => i == '005')"
+          v-if="powers.some((i) => i == '061')"
           effect="dark"
-          content="修改毛利率"
+          content="查看毛利率"
           placement="top"
         >
-          <i class="el-icon-s-check tb-icon" @click="setRate(scope.row)"></i>
+          <i class="el-icon-view tb-icon" @click="setRate(scope.row, true)"></i>
         </el-tooltip>
+
+        <el-tooltip
+          v-if="powers.some((i) => i == '060')"
+          effect="dark"
+          content="设置毛利率"
+          placement="top"
+        >
+          <i class="el-icon-edit tb-icon" @click="setRate(scope.row)"></i>
+        </el-tooltip>
+
+        <el-tooltip
+          v-if="
+            powers.some((i) => i == '004') && scope.row.status + '' === '1'
+          "
+          effect="dark"
+          content="禁用"
+          placement="top"
+        >
+          <i
+            class="el-icon-video-pause tb-icon"
+            @click="changeStatus(scope.row.cat_id, scope.row.status)"
+          ></i>
+        </el-tooltip>
+
+        <el-tooltip
+          v-if="
+            powers.some((i) => i == '004') && scope.row.status + '' !== '1'
+          "
+          effect="dark"
+          content="启用"
+          placement="top"
+        >
+          <i
+            class="el-icon-video-play tb-icon"
+            @click="changeStatus(scope.row.cat_id, scope.row.status)"
+          ></i>
+      </el-tooltip>
+        
         <el-tooltip
           v-if="parseInt(scope.row.level) < 3"
           effect="dark"
@@ -184,6 +233,7 @@
         </el-tooltip>
       </template>
     </ex-table>
+
     <no-auth v-else></no-auth>
 
     <!-- 弹窗 新增/修改 -->
@@ -194,18 +244,20 @@
       :titleList="titleList"
       @refresh="searchList"
       @cancel="showRateModel = false"
+      :is-detail="isDetail"
+      :platform_id="parmValue.platform_id"
     />
   </div>
 </template>
 <script>
 import addEditRate from "./addEditRate";
-import asyncRequest from "@/apis/service/youzan/othsearchSort";
+import asyncRequest from "@/apis/service/goodStore/platformGrossProfit";
 import { statusList } from "@/assets/js/statusList";
 import roleLevel from "@/assets/js/roleLevel";
 import mixinPage from "@/mixins/elPaginationHandle";
-import { mapGetters } from "vuex";
-import resToken from "@/mixins/resToken";
 import companyHelper from "@/mixins/companyHelper";
+import resToken from "@/mixins/resToken";
+import { mapGetters } from "vuex";
 
 export default {
   name: "othsearchSort",
@@ -218,13 +270,14 @@ export default {
     ...mapGetters(["tablebtnSize", "searchSize", "size"]),
     powers() {
       const { btnList } = this.$store.getters;
-      const tran = btnList.find((i) => i.menu_route == "othsearchSort") || {};
+      const tran = btnList.find((i) => i.menu_route == "platformGrossProfit") || {};
       const { action } = tran ?? {};
       return action ?? [];
     },
   },
   data() {
     return {
+      isDetail: true,
       private_field:[],
       statusList: statusList,
       roleLevel: roleLevel,
@@ -271,12 +324,12 @@ export default {
         {
           prop: "cat_name",
           label: "分类名称",
-          minwidth: "130px",
+          minWidth: "130px",
         },
         {
           prop: "level",
-          label: "等级",
-          width: "50px",
+          label: "分类等级",
+          width: "80px",
         },
         {
           prop: "status",
@@ -284,45 +337,39 @@ export default {
           _slot_: "status",
           width: "70px",
         },
-        {
-          prop: "platform_name",
-          label: "平台名称",
-          minwidth: "190px",
-        },
+        // {
+        //   prop: "platform_name",
+        //   label: "平台名称",
+        //   minwidth: "190px",
+        // },
         {
           prop: "companyNo",
-          label: "公司编号"
+          label: "公司编号",
+          _slot_:'companyNo',
+          width: "260px"
         },
         {
           prop: "companyName",
-          label: "公司名称"
-        },
-        {
-          prop: "fund_code",
-          label: "财务核算码",
-          width: "150px",
-        },
-        {
-          prop: "sale_rate",
-          label: "成本→售价",
-          _slot_: "sale_rate",
-          width: "90px",
-        },
-        {
-          prop: "creater",
-          label: "创建人",
-          width: "70px",
-        },
-        {
-          prop: "addtime",
-          label: "创建时间",
-          width: "145px",
+          label: "公司名称",
+          _slot_:'companyName',
+          width: "260px"
         },
+        // {
+        //   prop: "fund_code",
+        //   label: "财务核算码",
+        //   width: "150px",
+        // },
+        // {
+        //   prop: "sale_rate",
+        //   label: "成本→售价",
+        //   _slot_: "sale_rate",
+        //   width: "90px",
+        // },
         {
           prop: "",
           label: "操作",
           fixed: "right",
-          width: "110px",
+          width: "140px",
           _noset_: true,
           _slot_: "operation",
         },
@@ -367,7 +414,7 @@ export default {
     },
     //查看下一级分类
     async openChildren(item) {
-      this.parmValue.pid = item.id;
+      this.parmValue.pid = item.cat_id;
       this.pageInfo.curr = 1;
       this.parmValue.page = 1;
       await this.searchList();
@@ -378,11 +425,13 @@ export default {
       this.titleList.push(model);
     },
     //设置毛利率
-    setRate(row) {
+    setRate(row, isDetail = false) {
+      this.isDetail = isDetail;
       this.modelRateId = row.id;
       this.sitemRate = row;
       this.showRateModel = true;
     },
+
     async changeBreadcrumb(index) {
       if (index + 1 === this.titleList.length) {
         return;
@@ -399,6 +448,44 @@ export default {
       await this.searchList();
     },
 
+    async changeStatus(cat_id, status) {
+      await this.$confirm(`确定要改为${status + '' === "1" ? "禁用" : "启用"}?`, {
+        confirmButtonText: "确定",
+        cancelButtonText: "取消",
+        type: "warning"
+      })
+        .then(async () => {
+          this.loading = true;
+
+          const model = {
+            cat_id,
+            platform_id: this.parmValue.platform_id,
+            status: status + '' === "1" ? "0" : "1",
+            companyNo: this.currentCompany
+          };
+
+          const res = await asyncRequest.status(model);
+          if (res && res.code === 0) {
+            this.loading = false;
+
+            this.$notify.success({
+              title: "状态修改成功!",
+              message: ""
+            });
+
+            await this.searchList();
+          } else if (res && res.code >= 100 && res.code <= 104) {
+            await this.logout();
+          } else {
+            this.loading = false;
+            this.$message.warning(res.message);
+          }
+        })
+        .catch(() => {
+          console.log("取消");
+        });
+    },
+
     // 刷新表格
     async searchList() {
       if (this.loading) return;
@@ -414,10 +501,9 @@ export default {
       }
 
       this.parmValue.companyNo = this.currentCompany;
-
-
       this.loading = true;
       const { code, data } = await asyncRequest.list(this.parmValue);
+
       if (code === 0) {
         const { list, count } = data ?? {};
         this.tableData = list ?? [];

+ 3 - 3
src/views/goodStore/sort/index.vue

@@ -197,14 +197,14 @@
             @click="deleteItem(scope.row.id)"
           ></i>
         </el-tooltip>
-        <el-tooltip
+        <!-- <el-tooltip
           v-if="powers.some((i) => i == '060')"
           effect="dark"
           content="设置毛利率"
           placement="top"
         >
           <i class="el-icon-s-check tb-icon" @click="setRate(scope.row)"></i>
-        </el-tooltip>
+        </el-tooltip> -->
         <el-tooltip
           v-if="parseInt(scope.row.level) < 3"
           effect="dark"
@@ -362,7 +362,7 @@ export default {
           prop: "",
           label: "操作",
           fixed: "right",
-          width: "200px",
+          width: "180px",
           _noset_: true,
           _slot_: "operation",
         },

+ 1 - 1
src/views/interest/accountQuery/addEdit.vue

@@ -50,7 +50,7 @@
 
               <el-col :span="24">
                 <el-form-item label="角色">
-                  <el-radio-group v-model="ruleForm.roleid">
+                  <el-radio-group v-model="ruleForm.roleid" :disabled="isDetail">
                     <el-radio v-for="role in rolelist" :key="role.id" :label="role.id">{{ role.role_name }}</el-radio>
                   </el-radio-group>
                 </el-form-item>

+ 3 - 2
src/views/interest/accountQuery/index.vue

@@ -332,9 +332,10 @@ export default {
     },
     async searchList() {
       this.loading = true;
-      this.parmValue.comnpanyNo = this.currentCompany;
-
+      this.parmValue.companyNo = this.currentCompany;
+      
       const res = await asyncRequest.list(this.parmValue);
+
       if (res && res.code === 0 && res.data) {
         this.tableData = res.data.list;
         this.pageInfo.total = Number(res.data.count);

+ 4 - 4
src/views/interest/action/index.vue

@@ -89,8 +89,8 @@
                           <template v-for="children in subItem.action">
                             <el-checkbox
                               :disabled="!powers.some((i) => i == '008')"
-                              :key="'checkItem' + children.id"
                               :label="String(children.id)"
+                              :key="'checkItem' + children.id"
                               @change="
                                 handleCheckedChange(
                                   $event,
@@ -127,9 +127,9 @@
                         >
                           <template v-for="children in subItem.action_data">
                             <el-checkbox
-                              :key="'FieldItem' + children.id"
                               :label="String(children.id)"
                               :disabled="!powers.some((i) => i == '008')"
+                              :key="'FieldItem' + children.id"
                               @change="
                                 handleFieldChange(
                                   $event,
@@ -222,12 +222,12 @@ export default {
         // 选中子节点的数量
         const selectItemLength = item.action.filter(
           (filitem) =>
-            item.checkList.findIndex((finditem) => finditem === filitem.id) > -1
+            item.checkList.findIndex((finditem) => finditem === String(filitem.id)) > -1
         ).length;
         // 未选中子节点的数量
         const noSlectItemLength = item.action.filter(
           (filitem) =>
-            item.checkList.findIndex((finditem) => finditem === filitem.id) == -1
+            item.checkList.findIndex((finditem) => finditem === String(filitem.id)) == -1
         ).length;
         // // 当前节点的index
         // 存在选中子节点且存在未选中子节点为中间态

+ 114 - 115
src/views/youzan/othsearchSort/addEditRate.vue

@@ -31,10 +31,9 @@
                 disabled
                 placeholder="分类名称"
                 maxlength="20"
-                ><template slot="prepend" v-if="pid_name">{{
-                  pid_name
-                }}</template></el-input
-              >
+              ><template v-if="pid_name" slot="prepend">{{
+                pid_name
+              }}</template></el-input>
             </el-form-item>
             <el-form-item label="财务核算码" prop="fund_code">
               <el-input
@@ -137,7 +136,7 @@
             type="primary"
             :size="'small'"
             @click="submitForm"
-            >保 存
+          >保 存
           </el-button>
           <el-button :size="'small'" @click="showModelThis = false">{{
             id == "007" ? "关 闭" : "取 消"
@@ -148,122 +147,122 @@
   </el-dialog>
 </template>
 <script>
-import asyncRequest from "@/apis/service/youzan/othsearchSort";
-import resToken from "@/mixins/resToken";
+import asyncRequest from '@/apis/service/youzan/othsearchSort'
+import resToken from '@/mixins/resToken'
 export default {
-  name: "sort",
-  props: ["showModel", "id", "sitem", "titleList"],
+  name: 'Sort',
   mixins: [resToken],
+  props: ['showModel', 'id', 'sitem', 'titleList'],
   data() {
     const validate_rate = (rule, value, callback) => {
-      const { required } = rule;
-      if (value === "" && required) {
-        callback(new Error("主管利率毛利率不能为空!"));
+      const { required } = rule
+      if (value === '' && required) {
+        callback(new Error('主管利率毛利率不能为空!'))
       } else {
-        callback();
+        callback()
       }
-    };
+    }
     const validate_order_rate = (rule, value, callback) => {
-      const { required } = rule;
-      if (value === "" && required) {
-        callback(new Error("预算→成本毛利率不能为空!"));
+      const { required } = rule
+      if (value === '' && required) {
+        callback(new Error('预算→成本毛利率不能为空!'))
       } else {
-        callback();
+        callback()
       }
-    };
+    }
     const validate_sale_rate = (rule, value, callback) => {
-      const { required } = rule;
-      if (value === "" && required) {
-        callback(new Error("成本→售价毛利率不能为空!"));
+      const { required } = rule
+      if (value === '' && required) {
+        callback(new Error('成本→售价毛利率不能为空!'))
       } else {
-        callback();
+        callback()
       }
-    };
+    }
 
     const validate_lower_rate = (rule, value, callback) => {
-      const { required } = rule;
-      if (value === "" && required) {
-        callback(new Error("BOSS毛利率不能为空!"));
+      const { required } = rule
+      if (value === '' && required) {
+        callback(new Error('BOSS毛利率不能为空!'))
       } else {
-        callback();
+        callback()
       }
-    };
+    }
     const validate_low_rate = (rule, value, callback) => {
-      const { required } = rule;
-      if (value === "" && required) {
-        callback(new Error("项目最低毛利率不能为空!"));
+      const { required } = rule
+      if (value === '' && required) {
+        callback(new Error('项目最低毛利率不能为空!'))
       } else {
-        callback();
+        callback()
       }
-    };
+    }
     const validate_money_rate = (rule, value, callback) => {
-      const { required } = rule;
-      if (value === "" && required) {
-        callback(new Error("财务毛利率不能为空!"));
+      const { required } = rule
+      if (value === '' && required) {
+        callback(new Error('财务毛利率不能为空!'))
       } else {
-        callback();
+        callback()
       }
-    };
+    }
     return {
       loading: false,
       showModelThis: this.showModel,
-      pid_name: "",
+      pid_name: '',
       ruleForm: {
-        platform_id: "",
-        cat_id: "",
-        cat_name: "",
-        order_rate: "0",
-        sale_rate: "0",
-        lower_rate: "0",
-        rate: "0",
-        low_rate: "0",
-        money_rate: "0",
+        platform_id: '',
+        cat_id: '',
+        cat_name: '',
+        order_rate: '0',
+        sale_rate: '0',
+        lower_rate: '0',
+        rate: '0',
+        low_rate: '0',
+        money_rate: '0'
       },
       rulesThis: this.rules,
       rules: {
-        order_rate: [{ required: true, validator: validate_order_rate, trigger: "blur" }],
-        sale_rate: [{ required: true, validator: validate_sale_rate, trigger: "blur" }],
+        order_rate: [{ required: true, validator: validate_order_rate, trigger: 'blur' }],
+        sale_rate: [{ required: true, validator: validate_sale_rate, trigger: 'blur' }],
         lower_rate: [
-          { required: false, validator: validate_lower_rate, trigger: "blur" },
+          { required: false, validator: validate_lower_rate, trigger: 'blur' }
         ],
-        rate: [{ required: true, validator: validate_rate, trigger: "blur" }],
+        rate: [{ required: true, validator: validate_rate, trigger: 'blur' }],
 
-        low_rate: [{ required: true, validator: validate_low_rate, trigger: "blur" }],
-        money_rate: [{ required: true, validator: validate_money_rate, trigger: "blur" }],
-      },
-    };
+        low_rate: [{ required: true, validator: validate_low_rate, trigger: 'blur' }],
+        money_rate: [{ required: true, validator: validate_money_rate, trigger: 'blur' }]
+      }
+    }
   },
   watch: {
-    showModel: function (val) {
-      this.showModelThis = val;
+    showModel: function(val) {
+      this.showModelThis = val
       if (val) {
-        this.initForm();
+        this.initForm()
       }
     },
     showModelThis(val) {
       if (!val) {
-        this.$emit("cancel");
+        this.$emit('cancel')
       }
-    },
+    }
   },
   methods: {
     async initForm() {
-      this.loading = true;
-      this.pid_name = "";
+      this.loading = true
+      this.pid_name = ''
       this.titleList.forEach((e, i) => {
-        this.pid_name += i !== 0 ? `${e.titleName}/` : "";
-      });
-      this.rulesThis = this.rules;
-      await this.resetForm();
-      this.loading = false;
+        this.pid_name += i !== 0 ? `${e.titleName}/` : ''
+      })
+      this.rulesThis = this.rules
+      await this.resetForm()
+      this.loading = false
     },
 
     async resetForm() {
       // 重置
       await this.$nextTick(() => {
         if (this.$refs.ruleForm) {
-          this.$refs.ruleForm.resetFields();
-          this.$refs.ruleForm.clearValidate();
+          this.$refs.ruleForm.resetFields()
+          this.$refs.ruleForm.clearValidate()
           const {
             platform_id,
             id,
@@ -274,74 +273,74 @@ export default {
             rate,
             fund_code,
             low_rate,
-            money_rate,
-          } = this.sitem;
+            money_rate
+          } = this.sitem
           this.ruleForm = {
-            platform_id: platform_id + "" || "",
-            cat_id: id || "",
-            cat_name: cat_name || "",
-            fund_code: fund_code || "",
-            order_rate: order_rate || "0",
-            sale_rate: sale_rate || "0",
-            lower_rate: lower_rate || "0",
-            rate: rate || "0",
-            low_rate: low_rate || "0",
-            money_rate: money_rate || "0",
-          };
+            platform_id: platform_id + '' || '',
+            cat_id: id || '',
+            cat_name: cat_name || '',
+            fund_code: fund_code || '',
+            order_rate: order_rate || '0',
+            sale_rate: sale_rate || '0',
+            lower_rate: lower_rate || '0',
+            rate: rate || '0',
+            low_rate: low_rate || '0',
+            money_rate: money_rate || '0'
+          }
         }
-      });
+      })
     },
     rate_change(e, key) {
-      this.ruleForm[key] = e + "";
-      this.$refs.ruleForm.validateField(key);
+      this.ruleForm[key] = e + ''
+      this.$refs.ruleForm.validateField(key)
     },
     async submitForm() {
-      await this.$refs.ruleForm.validate(async (valid) => {
+      await this.$refs.ruleForm.validate(async(valid) => {
         if (valid) {
           if (!this.loading) {
-            this.loading = true;
-            let model = JSON.parse(JSON.stringify(this.ruleForm));
-            delete model["cat_name"];
+            this.loading = true
+            const model = JSON.parse(JSON.stringify(this.ruleForm))
+            delete model['cat_name']
             // delete model["pid"];
             // delete model["fund_code"];
-            const { code, data, message } = await asyncRequest.update(model);
-            this.loading = false;
+            const { code, data, message } = await asyncRequest.update(model)
+            this.loading = false
             if (code === 0) {
               this.$notify.success({
-                title: "毛利率设置成功!",
-                message: "",
-              });
-              this.showModelThis = false;
+                title: '毛利率设置成功!',
+                message: ''
+              })
+              this.showModelThis = false
               // 刷新
-              this.$emit("refresh");
+              this.$emit('refresh')
             } else if (code >= 100 && code <= 104) {
-              await this.logout();
+              await this.logout()
             } else if (code === 10004) {
-              const { skuCode } = data;
-              let resList = JSON.parse(JSON.stringify(skuCode));
+              const { skuCode } = data
+              const resList = JSON.parse(JSON.stringify(skuCode))
 
-              let htmlList = "<ul>";
+              let htmlList = '<ul>'
               resList.forEach((v) => {
-                htmlList += `<li><span>${v.skuCode}__</span><span>${v.good_name}</span></li>`;
-              });
-              htmlList += "</ul>";
+                htmlList += `<li><span>${v.skuCode}__</span><span>${v.good_name}</span></li>`
+              })
+              htmlList += '</ul>'
               this.$notify({
-                title: "新毛利已影响以下线上商品售价,请下线后再修改!",
+                title: '新毛利已影响以下线上商品售价,请下线后再修改!',
                 dangerouslyUseHTMLString: true,
-                message: htmlList,
-              });
+                message: htmlList
+              })
             } else {
-              this.$message.warning(message);
+              this.$message.warning(message)
             }
           }
         } else {
-          console.log("error submit!!");
-          return false;
+          console.log('error submit!!')
+          return false
         }
-      });
-    },
-  },
-};
+      })
+    }
+  }
+}
 </script>
 
 <style lang="scss" scoped>

+ 73 - 70
vue.config.js

@@ -1,23 +1,23 @@
-"use strict";
-const path = require("path");
-require("babel-polyfill");
-const productionGzipExtensions = ["js", "css"];
-const UglifyJsPlugin = require("uglifyjs-webpack-plugin");
-const CompressionWebpackPlugin = require("compression-webpack-plugin");
-const defaultSettings = require("./src/settings.js");
-const isProduction = process.env.NODE_ENV === "production";
+'use strict'
+const path = require('path')
+require('babel-polyfill')
+const productionGzipExtensions = ['js', 'css']
+const UglifyJsPlugin = require('uglifyjs-webpack-plugin')
+const CompressionWebpackPlugin = require('compression-webpack-plugin')
+const defaultSettings = require('./src/settings.js')
+const isProduction = process.env.NODE_ENV === 'production'
 function resolve(dir) {
-  return path.join(__dirname, dir);
+  return path.join(__dirname, dir)
 }
 
-const name = defaultSettings.title || "采销平台"; // page title
+const name = defaultSettings.title || '采销平台' // page title
 
 // If your port is set to 80,
 // use administrator privileges to execute the command line.
 // For example, Mac: sudo npm run
 // You can change the port by the following method:
 // port = 8080 npm run dev OR npm run dev --port = 8080
-const port = process.env.port || process.env.npm_config_port || 8080; // dev port
+const port = process.env.port || process.env.npm_config_port || 8080 // dev port
 
 // All configuration item explanations can be find in https://cli.vuejs.org/config/
 module.exports = {
@@ -28,12 +28,15 @@ module.exports = {
    * In most cases please use '/' !!!
    * Detail: https://cli.vuejs.org/config/#publicpath
    */
-  publicPath: "/",
-  outputDir: "dist",
-  assetsDir: "static",
-  lintOnSave: false, //process.env.NODE_ENV === 'development'
+  publicPath: '/',
+  outputDir: 'dist',
+  assetsDir: 'static',
+  lintOnSave: false, // process.env.NODE_ENV === 'development'
   productionSourceMap: false,
   devServer: {
+    headers: {
+      'max-http-header-size': 1024000
+    },
     // proxy: {
     //   "/admin": {
     //     target: process.env.NODE_ENV,
@@ -50,121 +53,121 @@ module.exports = {
     open: true,
     overlay: {
       warnings: false,
-      errors: true,
-    },
+      errors: true
+    }
     // before: require('./mock/mock-server.js')
   },
   configureWebpack: (config) => {
     // 入口文件
-    config.entry.app = ["babel-polyfill", "./src/main.js"];
+    config.entry.app = ['babel-polyfill', './src/main.js']
     config.externals = {
-      vue: "Vue",
+      vue: 'Vue',
       // 'vuex': 'Vuex',
-      axios: "axios",
-      "vue-router": "VueRouter",
-    };
+      axios: 'axios',
+      'vue-router': 'VueRouter'
+    }
     if (isProduction) {
       config.plugins.push(
         new CompressionWebpackPlugin({
-          algorithm: "gzip",
-          test: new RegExp("\\.(" + productionGzipExtensions.join("|") + ")$"),
+          algorithm: 'gzip',
+          test: new RegExp('\\.(' + productionGzipExtensions.join('|') + ')$'),
           threshold: 10240,
           // deleteOriginalAssets:true, //删除源文件,不建议
-          minRatio: 0.7,
+          minRatio: 0.7
         })
-      );
+      )
     }
     // 删除console插件
-    let plugins = [
+    const plugins = [
       new UglifyJsPlugin({
         uglifyOptions: {
           compress: {
             // warnings: false, // `warnings` is not a supported option
             drop_console: true,
-            drop_debugger: true,
+            drop_debugger: true
           },
           output: {
             // 去掉注释内容
-            comments: true,
-          },
+            comments: true
+          }
         },
-        cache: true, //启用/禁用文件缓存(类型可布尔也可是字符串)
+        cache: true, // 启用/禁用文件缓存(类型可布尔也可是字符串)
         sourceMap: false,
-        parallel: true,
-      }),
-    ];
+        parallel: true
+      })
+    ]
     // 只有打包生产环境才需要将console删除
     if (isProduction) {
-      config.plugins = [...config.plugins, ...plugins];
+      config.plugins = [...config.plugins, ...plugins]
     }
   },
 
   chainWebpack(config) {
     // it can improve the speed of the first screen, it is recommended to turn on preload
     // it can improve the speed of the first screen, it is recommended to turn on preload
-    config.plugin("preload").tap(() => [
+    config.plugin('preload').tap(() => [
       {
-        rel: "preload",
+        rel: 'preload',
         // to ignore runtime.js
         // https://github.com/vuejs/vue-cli/blob/dev/packages/@vue/cli-service/lib/config/app.js#L171
         fileBlacklist: [/\.map$/, /hot-update\.js$/, /runtime\..*\.js$/],
-        include: "initial",
-      },
-    ]);
+        include: 'initial'
+      }
+    ])
 
     // when there are many pages, it will cause too many meaningless requests
-    config.plugins.delete("prefetch");
+    config.plugins.delete('prefetch')
 
     // set svg-sprite-loader
-    config.module.rule("svg").exclude.add(resolve("src/icons")).end();
+    config.module.rule('svg').exclude.add(resolve('src/icons')).end()
     config.module
-      .rule("icons")
+      .rule('icons')
       .test(/\.svg$/)
-      .include.add(resolve("src/icons"))
+      .include.add(resolve('src/icons'))
       .end()
-      .use("svg-sprite-loader")
-      .loader("svg-sprite-loader")
+      .use('svg-sprite-loader')
+      .loader('svg-sprite-loader')
       .options({
-        symbolId: "icon-[name]",
+        symbolId: 'icon-[name]'
       })
-      .end();
-    //process.env.NODE_ENV !== 'development'
+      .end()
+    // process.env.NODE_ENV !== 'development'
     config.when(true, (config) => {
       config
-        .plugin("ScriptExtHtmlWebpackPlugin")
-        .after("html")
-        .use("script-ext-html-webpack-plugin", [
+        .plugin('ScriptExtHtmlWebpackPlugin')
+        .after('html')
+        .use('script-ext-html-webpack-plugin', [
           {
             // `runtime` must same as runtimeChunk name. default is `runtime`
-            inline: /runtime\..*\.js$/,
-          },
+            inline: /runtime\..*\.js$/
+          }
         ])
-        .end();
+        .end()
       config.optimization.splitChunks({
-        chunks: "all",
+        chunks: 'all',
         cacheGroups: {
           libs: {
-            name: "chunk-libs",
+            name: 'chunk-libs',
             test: /[\\/]node_modules[\\/]/,
             priority: 10,
-            chunks: "initial", // only package third parties that are initially dependent
+            chunks: 'initial' // only package third parties that are initially dependent
           },
           elementUI: {
-            name: "chunk-elementUI", // split elementUI into a single package
+            name: 'chunk-elementUI', // split elementUI into a single package
             priority: 20, // the weight needs to be larger than libs and app or it will be packaged into libs or app
-            test: /[\\/]node_modules[\\/]_?element-ui(.*)/, // in order to adapt to cnpm
+            test: /[\\/]node_modules[\\/]_?element-ui(.*)/ // in order to adapt to cnpm
           },
           commons: {
-            name: "chunk-commons",
-            test: resolve("src/components"), // can customize your rules
+            name: 'chunk-commons',
+            test: resolve('src/components'), // can customize your rules
             minChunks: 3, //  minimum common number
             priority: 5,
-            reuseExistingChunk: true,
-          },
-        },
-      });
+            reuseExistingChunk: true
+          }
+        }
+      })
       // https:// webpack.js.org/configuration/optimization/#optimizationruntimechunk
-      config.optimization.runtimeChunk("single");
-    });
-  },
-};
+      config.optimization.runtimeChunk('single')
+    })
+  }
+}