Bladeren bron

公共组件 参数配置

zhengnaiwen_citu 4 maanden geleden
bovenliggende
commit
65981c0455

+ 1 - 1
src/views/bonus/setting/bonusSettingEdit.vue → src/components/ParamsSetting/ParamsSettingEdit.vue

@@ -13,7 +13,7 @@ import {
   saveBonusSetting
 } from '@/api/bonus'
 export default {
-  name: 'bonusSettingEdit',
+  name: 'ParamsSettingEdit',
   data () {
     return {
       formItems: [

+ 91 - 0
src/components/ParamsSetting/index.vue

@@ -0,0 +1,91 @@
+<template>
+  <div>
+    <m-table
+      v-bind="$attrs"
+      v-loading="loading"
+      :items="items"
+      :headers="headers"
+      :page-size="pageInfo.size"
+      :page-current="pageInfo.current"
+      :total="total"
+      @page-change="onPageChange"
+    >
+      <template #actions="{ row }">
+        <m-button type="primary" text @click="onEdit(row)">编辑</m-button>
+      </template>
+    </m-table>
+    <ParamsSettingEdit ref="paramsSettingEditRefs" @success="onInit"></ParamsSettingEdit>
+  </div>
+</template>
+
+<script>
+import {
+  getBonusSettingPage
+} from '@/api/bonus'
+import ParamsSettingEdit from './ParamsSettingEdit.vue'
+export default {
+  name: 'ParamsSetting',
+  props: {
+    configurationCategory: {
+      type: String,
+      default: '绩效奖金配置'
+    }
+  },
+  components: { ParamsSettingEdit },
+  data () {
+    return {
+      searchValues: {},
+      headers: [
+        { label: '配置名称', prop: 'configurationTitle' },
+        { label: '配置占比', prop: 'configurationValue' },
+        { label: '操作', prop: 'actions', fixed: 'right', width: 300 }
+      ],
+      items: [],
+      total: 0,
+      orders: [],
+      pageInfo: {
+        current: 1,
+        size: 10
+      },
+      loading: false
+    }
+  },
+  created () {
+    this.onInit()
+  },
+  methods: {
+    async onInit () {
+      this.loading = true
+      try {
+        const { data } = await getBonusSettingPage({
+          page: {
+            ...this.pageInfo,
+            orders: this.orders
+          },
+          entity: {
+            ...this.searchValues,
+            configurationCategory: this.configurationCategory
+          }
+        })
+        this.items = data.records
+        this.total = data.total
+      } catch (error) {
+        this.$message.error(error)
+      } finally {
+        this.loading = false
+      }
+    },
+    onEdit (item) {
+      this.$refs.paramsSettingEditRefs.open(item)
+    },
+    onPageChange (index) {
+      this.pageInfo.current = index
+      this.onInit()
+    }
+  }
+}
+</script>
+
+<style lang="scss" scoped>
+  /* 自定义样式 */
+</style>

+ 5 - 108
src/views/bonus/setting/index.vue

@@ -1,122 +1,19 @@
 <template>
   <div class="pa-3 white">
-    <!-- <m-search class="mb-3" :items="searchItems" v-model="searchValues" @search="onSearch"></m-search> -->
-    <m-table
-      v-loading="loading"
-      :items="items"
-      :headers="headers"
-      :page-size="pageInfo.size"
-      :page-current="pageInfo.current"
-      :total="total"
-      @page-change="onPageChange"
-    >
-      <!-- <template #card-tools>
-        <m-button type="orange" icon="el-icon-plus" @click="onAdd">新增</m-button>
-      </template> -->
-      <template #actions="{ row }">
-        <m-button type="primary" text @click="onEdit(row)">编辑</m-button>
-      </template>
-    </m-table>
-    <BonusSettingEdit ref="bonusSettingEditRefs" @success="onInit"></BonusSettingEdit>
+    <ParamsSetting></ParamsSetting>
   </div>
 </template>
 
 <script>
-import {
-  getBonusSettingPage
-} from '@/api/bonus'
-// import { mapGetters } from 'vuex'
-import BonusSettingEdit from './bonusSettingEdit.vue'
+import ParamsSetting from '@/components/ParamsSetting'
 export default {
   name: 'bonusSetting',
-  components: { BonusSettingEdit },
-  data () {
-    return {
-      searchValues: {},
-      headers: [
-        // { label: '适用机构', prop: 'organizationName' },
-        // { label: '适用岗位', prop: 'postName' },
-        { label: '配置名称', prop: 'configurationTitle' },
-        { label: '配置占比', prop: 'configurationValue' },
-        { label: '操作', prop: 'actions', fixed: 'right', width: 300 }
-      ],
-      items: [],
-      total: 0,
-      orders: [],
-      pageInfo: {
-        current: 1,
-        size: 10
-      },
-      loading: false
-    }
-  },
-  // computed: {
-  //   ...mapGetters(['organizationTree']),
-  //   searchItems () {
-  //     return [
-  //       {
-  //         label: '机构',
-  //         prop: 'organizationNo',
-  //         type: 'cascader',
-  //         options: {
-  //           placeholder: '请选择机构',
-  //           options: this.organizationTree,
-  //           showAllLevels: false,
-  //           props: {
-  //             emitPath: false,
-  //             checkStrictly: true,
-  //             value: 'organizationNo',
-  //             label: 'organizationName',
-  //             children: 'child'
-  //           }
-  //         }
-  //       }
-  //     ]
-  //   }
-  // },
-  created () {
-    this.onInit()
-  },
-  methods: {
-    async onInit () {
-      this.loading = true
-      try {
-        const { data } = await getBonusSettingPage({
-          page: {
-            ...this.pageInfo,
-            orders: this.orders
-          },
-          entity: {
-            ...this.searchValues,
-            configurationCategory: '绩效奖金配置'
-          }
-        })
-        this.items = data.records
-        this.total = data.total
-      } catch (error) {
-        this.$message.error(error)
-      } finally {
-        this.loading = false
-      }
-    },
-    onAdd () {
-      this.$refs.bonusSettingEditRefs.open()
-    },
-    onEdit (item) {
-      this.$refs.bonusSettingEditRefs.open(item)
-    },
-    onSearch () {
-      this.pageInfo.current = 1
-      this.onInit()
-    },
-    onPageChange (index) {
-      this.pageInfo.current = index
-      this.onInit()
-    }
+  components: {
+    ParamsSetting
   }
 }
 </script>
 
 <style lang="scss" scoped>
-  /* 自定义样式 */
+
 </style>

+ 3 - 58
src/views/salaryFixed/salaryFixedRules/salaryFixedRulesParam/index.vue

@@ -1,68 +1,13 @@
 <template>
-  <div>
-    <m-table
-      card-title="系数参数设定"
-      :headers="[
-        { label: '配置名称', prop: 'configurationTitle' },
-        { label: '配置值', prop: 'configurationValue' },
-        { label: '操作', prop: 'actions' }
-      ]"
-      :items="items"
-    >
-      <template #actions="{ row }">
-        <el-button type="text" @click="onEdit(row)">编辑</el-button>
-      </template>
-    </m-table>
-    <SalaryFixedRulesParamEdit ref="salaryFixedRulesParamEditRefs" @success="onInit"></SalaryFixedRulesParamEdit>
-  </div>
+  <ParamsSetting configuration-category="基础薪资配置" card-title="系数参数设定"></ParamsSetting>
 </template>
 
 <script>
-import {
-  getBonusSettingPage
-} from '@/api/bonus'
-import SalaryFixedRulesParamEdit from './salaryFixedRulesParamEdit.vue'
+import ParamsSetting from '@/components/ParamsSetting'
 export default {
   name: 'salaryFixedRulesParam',
   components: {
-    SalaryFixedRulesParamEdit
-  },
-  data () {
-    return {
-      loading: false,
-      total: 0,
-      orders: [],
-      pageInfo: {
-        current: 1,
-        size: 10
-      },
-      items: []
-    }
-  },
-  methods: {
-    async onInit () {
-      this.loading = true
-      try {
-        const { data } = await getBonusSettingPage({
-          page: {
-            ...this.pageInfo,
-            orders: this.orders
-          },
-          entity: {
-            configurationCategory: '基础薪资配置'
-          }
-        })
-        this.items = data.records
-        this.total = data.total
-      } catch (error) {
-        this.$message.error(error)
-      } finally {
-        this.loading = false
-      }
-    },
-    onEdit (row) {
-      this.$refs.salaryFixedRulesParamEditRefs.open(row)
-    }
+    ParamsSetting
   }
 }
 </script>

+ 0 - 76
src/views/salaryFixed/salaryFixedRules/salaryFixedRulesParam/salaryFixedRulesParamEdit.vue

@@ -1,76 +0,0 @@
-<template>
-  <m-dialog ref="dialog" title="编辑参数" @sure="onSure">
-    <m-form ref="form" :items="formItems" v-model="formValues">
-      <template #configurationTitle>
-        <el-tag type="primary">{{ formValues.configurationTitle }}</el-tag>
-      </template>
-    </m-form>
-  </m-dialog>
-</template>
-
-<script>
-import {
-  saveBonusSetting
-} from '@/api/bonus'
-export default {
-  name: 'salaryFixedRulesParamEdit',
-  data () {
-    return {
-      formItems: [
-        {
-          label: '参数名称',
-          prop: 'configurationTitle'
-        },
-        {
-          label: '参数值',
-          prop: 'configurationValue',
-          type: 'input',
-          options: {
-            placeholder: '请输入参数值'
-          },
-          rules: [
-            { required: true, message: '请输入参数值', trigger: 'blur' }
-          ]
-        }
-      ],
-      formValues: {
-        configurationTitle: null,
-        configurationValue: null
-      },
-      itemData: {}
-    }
-  },
-  methods: {
-    open (item) {
-      this.itemData = item
-      this.formValues.configurationTitle = item.configurationTitle
-      this.formValues.configurationValue = item.configurationValue
-      this.$refs.dialog.open()
-    },
-    onSure () {
-      this.$refs.form.validate(async valid => {
-        if (!valid) {
-          return
-        }
-        try {
-          await saveBonusSetting({
-            performanceConfigurationId: this.itemData.performanceConfigurationId,
-            ...this.formValues
-          })
-          this.$message.success('保存成功')
-          this.$refs.dialog.close()
-          this.$emit('success')
-        } catch (error) {
-          this.$message.error(error)
-        } finally {
-          this.loading = false
-        }
-      })
-    }
-  }
-}
-</script>
-
-<style lang="scss" scoped>
-
-</style>