Browse Source

配置采购管理权限

linwenxin 1 year ago
parent
commit
5c1a430eee

+ 2 - 2
src/components/template/operation_mixin.js

@@ -61,7 +61,7 @@ export default {
                           opt[key]?.click({ row, index, column })
                         }}
                       >
-                        <el-button size="mini" type={opt[key]?.btnType || 'primary'} slot="reference">
+                        <el-button size="mini" type={opt[key]?.btnType || 'text'} slot="reference">
                           {setBtnName(opt[key]?.name, { row, index, column }) || role.moduleName}
                         </el-button>
                       </el-popconfirm>
@@ -70,7 +70,7 @@ export default {
                     return role && (opt[key]?.conditions ? opt[key]?.conditions({ row, index, column }) : true) ? (
                       <el-button
                         size="mini"
-                        type={opt[key]?.btnType || 'primary'}
+                        type={opt[key]?.btnType || 'text'}
                         onClick={() => {
                           opt[key]?.click({ row, index, column })
                         }}

+ 27 - 15
src/views/auxiliaryFittings/purchasingManagement/components/inStorage.vue

@@ -1,7 +1,7 @@
 <template>
   <template-page ref="pageRef" :get-list="getList" :exportList="exportList" :table-attributes="tableAttributes"
     :table-events="tableEvents" :options-evens-group="optionsEvensGroup" :moreParameters="moreParameters"
-    :column-parsing="columnParsing" :operation="operation" :replaceOrNotMap="false">
+    :column-parsing="columnParsing" :operation="operation()" :replaceOrNotMap="false">
     <div class="cartographer">
       <el-dialog :title="({ M: '辅材入库单', P: '配件入库单' })[storageType]" width="100%" :modal="false" :visible.sync="formDialog"
         :before-close="formCancel">
@@ -28,6 +28,7 @@
 <script>
 import TemplatePage from '@/components/template/template-page-1.vue'
 import import_mixin from '@/components/template/import_mixin.js'
+import operation_mixin from '@/components/template/operation_mixin.js'
 import form_tpl from "../mixins/form_tpl.js"
 import { websitPurchaseInList, websitPurchaseInListExport, websitPurchaseInAdd, websitPurchaseInEdit, websitPurchaseInConfirm, websitPurchaseInDetail } from "@/api/purchasingManagement.js"
 export default {
@@ -38,7 +39,7 @@ export default {
     }
   },
   components: { TemplatePage },
-  mixins: [import_mixin, form_tpl],
+  mixins: [import_mixin, form_tpl, operation_mixin],
   data() {
     return {
       formData: {
@@ -78,22 +79,33 @@ export default {
     },
     // 列表导出函数
     exportList: websitPurchaseInListExport,
-    // 操作按钮
-    operation(h, { row, index, column }) {
-      return (
-        <div class='operation-btns'>
-          {row.flag == "SAVE" ? <el-button type="text" onClick={() => {
+
+    operation() {
+      return this.operationBtn({
+        edit: {
+          conditions: ({ row, index, column }) => {
+            return row.flag == "SAVE"
+          },
+          click: ({ row, index, column }) => {
             this.getDetail(row.purchaseId, 1)
-          }}>编辑</el-button> : null}
-          {row.flag == "SAVE" ? <el-button type="text" onClick={() => {
-            this.getDetail(row.purchaseId, 3)
-          }}>审核</el-button> : null}
-          <el-button type="text" onClick={() => {
+          }
+        },
+        detail: {
+          click: ({ row, index, column }) => {
             this.getDetail(row.purchaseId, 2)
-          }}>详情</el-button>
-        </div>
-      )
+          }
+        },
+        examine: {
+          conditions: ({ row, index, column }) => {
+            return row.flag == "SAVE"
+          },
+          click: ({ row, index, column }) => {
+            this.getDetail(row.purchaseId, 3)
+          }
+        },
+      })
     },
+
     getDetail(purchaseId, type) {
       websitPurchaseInDetail({ purchaseId }).then(res => {
         Object.assign(this.formData, res.data, {

+ 27 - 15
src/views/auxiliaryFittings/purchasingManagement/components/retStorage.vue

@@ -1,7 +1,7 @@
 <template>
   <template-page ref="pageRef" :get-list="getList" :exportList="exportList" :table-attributes="tableAttributes"
     :table-events="tableEvents" :options-evens-group="optionsEvensGroup" :moreParameters="moreParameters"
-    :column-parsing="columnParsing" :operation="operation" :replaceOrNotMap="false">
+    :column-parsing="columnParsing" :operation="operation()" :replaceOrNotMap="false">
     <div class="cartographer">
       <el-dialog :title="({ M: '辅材退货单', P: '配件退货单' })[storageType]" width="100%" :modal="false" :visible.sync="formDialog"
         :before-close="formCancel">
@@ -29,6 +29,7 @@
 import TemplatePage from '@/components/template/template-page-1.vue'
 import import_mixin from '@/components/template/import_mixin.js'
 import form_tpl from "../mixins/form_tpl.js"
+import operation_mixin from '@/components/template/operation_mixin.js'
 import { websitPurchaseRetList, websitPurchaseRetListExport, websitPurchaseRetAdd, websitPurchaseRetEdit, websitPurchaseRetConfirm, websitPurchaseRetDetail } from "@/api/purchasingManagement.js"
 export default {
   props: {
@@ -38,7 +39,7 @@ export default {
     }
   },
   components: { TemplatePage },
-  mixins: [import_mixin, form_tpl],
+  mixins: [import_mixin, form_tpl, operation_mixin],
   data() {
     return {
       formData: {
@@ -80,22 +81,33 @@ export default {
     },
     // 列表导出函数
     exportList: websitPurchaseRetListExport,
-    // 操作按钮
-    operation(h, { row, index, column }) {
-      return (
-        <div class='operation-btns'>
-          {row.flag == "SAVE" ? <el-button type="text" onClick={() => {
+
+    operation() {
+      return this.operationBtn({
+        edit: {
+          conditions: ({ row, index, column }) => {
+            return row.flag == "SAVE"
+          },
+          click: ({ row, index, column }) => {
             this.getDetail(row.purchaseRetId, 1)
-          }}>编辑</el-button> : null}
-          {row.flag == "SAVE" ? <el-button type="text" onClick={() => {
-            this.getDetail(row.purchaseRetId, 3)
-          }}>审核</el-button> : null}
-          <el-button type="text" onClick={() => {
+          }
+        },
+        detail: {
+          click: ({ row, index, column }) => {
             this.getDetail(row.purchaseRetId, 2)
-          }}>详情</el-button>
-        </div>
-      )
+          }
+        },
+        examine: {
+          conditions: ({ row, index, column }) => {
+            return row.flag == "SAVE"
+          },
+          click: ({ row, index, column }) => {
+            this.getDetail(row.purchaseRetId, 3)
+          }
+        },
+      })
     },
+
     getDetail(purchaseRetId, type) {
       websitPurchaseRetDetail({ purchaseRetId }).then(res => {
         Object.assign(this.formData, res.data, {

+ 49 - 47
src/views/auxiliaryFittings/purchasingManagement/mixins/form_tpl.js

@@ -10,22 +10,42 @@ import { required, mobileRequired, mobile } from '@/components/template/rules_ve
 export default {
   data() {
     return {
-      // 事件组合
-      optionsEvensGroup: [
+      // 表格属性
+      tableAttributes: {
+        // 启用勾选列
+        selectColumn: false
+      },
+      // 表格事件
+      tableEvents: {
+        'selection-change': this.selectionChange
+      },
+      recordSelected: [],
+      formDialog: false,
+      formDialogType: 0, // 0:新增, 1:编辑, 2:查看, 3:审核
+      formDialogTitles: ['新增', '编辑', '查看', '审核'],
+      pageType: this?.$route?.name,
+      materialCategoryListL1: [],
+      materialCategoryListL2: [],
+      materialNormList: [],
+      peijianList: [],
+      websitPurchaseInList: []
+    }
+  },
+  computed: {
+    // 事件组合
+    optionsEvensGroup(){
+      return [
         [
           [
-            {
-              name: '新建',
-              isRole: true,
+            this.optionsEvensAuth("add", {
               click: this.addData
-            }
+            }),
           ],
         ],
         [
           [
-            {
+            this.optionsEvensAuth("template", {
               isRole: !!~['auxiliaryMaterialsStorage', 'partsStorage'].indexOf(this?.$route?.name),
-              name: '采购入库模板',
               click: () => {
                 commonTemplateDownload({ name: '采购入库模板.xlsx' }, `${this.$route.meta.title}`)
                   .then(res => {
@@ -38,23 +58,24 @@ export default {
                     this.$message.error('下载失败')
                   })
               }
-            }
+            }),
           ],
           [
-            {
-              isRole: !!~['auxiliaryMaterialsStorage', 'partsStorage'].indexOf(this?.$route?.name),
-              name: '导入模板',
-              render: () => {
-                return this.importButton(websitPurchaseInImport, '导入模板', { goodsType: this.storageType })
+            this.optionsEvensAuth("imp", ({ moduleName }) => {
+              return {
+                isRole: !!~['auxiliaryMaterialsStorage', 'partsStorage'].indexOf(this?.$route?.name),
+                name: moduleName,
+                render: () => {
+                  return this.importButton(websitPurchaseInImport, moduleName, { goodsType: this.storageType })
+                }
               }
-            }
+            }),
           ],
         ],
         [
           [
-            {
+            this.optionsEvensAuth("template", {
               isRole: !!~['returnAuxiliaryMaterials', 'partsReturn'].indexOf(this?.$route?.name),
-              name: '采购退货模板',
               click: () => {
                 commonTemplateDownload({ name: '采购退货模板.xlsx' }, `${this.$route.meta.title}`)
                   .then(res => {
@@ -67,41 +88,22 @@ export default {
                     this.$message.error('下载失败')
                   })
               }
-            }
+            }),
           ],
           [
-            {
-              isRole: !!~['returnAuxiliaryMaterials', 'partsReturn'].indexOf(this?.$route?.name),
-              name: '导入模板',
-              render: () => {
-                return this.importButton(websitPurchaseRetImport, '导入模板', { goodsType: this.storageType })
+            this.optionsEvensAuth("imp", ({ moduleName }) => {
+              return {
+                isRole: !!~['returnAuxiliaryMaterials', 'partsReturn'].indexOf(this?.$route?.name),
+                name: moduleName,
+                render: () => {
+                  return this.importButton(websitPurchaseRetImport, moduleName, { goodsType: this.storageType })
+                }
               }
-            }
+            }),
           ],
         ],
-      ],
-      // 表格属性
-      tableAttributes: {
-        // 启用勾选列
-        selectColumn: false
-      },
-      // 表格事件
-      tableEvents: {
-        'selection-change': this.selectionChange
-      },
-      recordSelected: [],
-      formDialog: false,
-      formDialogType: 0, // 0:新增, 1:编辑, 2:查看, 3:审核
-      formDialogTitles: ['新增', '编辑', '查看', '审核'],
-      pageType: this?.$route?.name,
-      materialCategoryListL1: [],
-      materialCategoryListL2: [],
-      materialNormList: [],
-      peijianList: [],
-      websitPurchaseInList: []
-    }
-  },
-  computed: {
+      ]
+    },
     moreParameters() {
       return [
         {