Ver código fonte

绩效测算

zhengnaiwen_citu 3 meses atrás
pai
commit
dc146987dd

+ 10 - 0
src/api/salary.js

@@ -245,3 +245,13 @@ export function getSandboxResultList (data) {
 export function getSandboxResultPage (data) {
   return http.post('/sanbox/data/analysis/page', data)
 }
+
+// 机构对比
+export function getSandboxDiffByOrg (data) {
+  return http.post('/sanbox/data/analysis/diff', data)
+}
+
+// 获取列
+export function getSandboxDiffColumn (data) {
+  return http.post('/sanbox/data/analysis/data/column', data)
+}

+ 2 - 1
src/components/AutoComponents/MTable/index.vue

@@ -18,8 +18,9 @@
         <slot name="table-append"></slot>
       </template>
       <template v-for="(header, index) in headers">
-        <!-- <el-table-column v-if="['selection','index'].includes(header.type)" v-bind="header" :key="index" /> -->
+        <el-table-column v-if="['selection','index'].includes(header.type)" v-bind="header" :key="index" />
         <m-table-column
+          v-else
           :key="(header.prop ?? header.label) || index"
           :hideSortable="!($listeners.sortChange || $listeners['sort-change'])"
           :item="header"

+ 37 - 130
src/views/sandbox/sandboxCalculate.vue

@@ -1,157 +1,64 @@
 <template>
-  <m-dialog title="绩效测算"  ref="dialog" width="1200px">
-    <div v-if="!isSuccess" class="d-flex align-center justify-center">
-      正在测算中,请稍后...
+  <m-dialog title="绩效测算"  ref="dialog">
+    <div v-if="!isSuccess" style="height: 200px;" class="d-flex flex-column justify-center align-center">
+      <el-date-picker
+        v-model="month"
+        type="month"
+        placeholder="选择月">
+      </el-date-picker>
+      <m-button :disabled="loading" type="orange" class="mt-3" @click="onStart">
+        {{ loading ? '正在测算中,请稍后...' : '开始测算'}}
+      </m-button>
     </div>
-    <div v-loading="loading">
-      <template v-if="isSuccess">
-        <m-card shadow="never">
-          <el-radio-group v-model="choose" @input="getList">
-            <el-radio
-              v-for="item in radioItems"
-              :key="item.id"
-              :label="item.id"
-            >
-              {{ item.name }}
-            </el-radio>
-          </el-radio-group>
-        </m-card>
-
-        <m-search class="mt-3" shadow="never" :items="searchItems" v-model="searchValues" @search="onSearch"></m-search>
-
-        <m-table
-          class="mt-3"
-          shadow="never"
-          clearHeader
-          :items="tableItems"
-          :headers="tableHeaders"
-          :page-size="tablePageInfo.size"
-          :page-current="tablePageInfo.current"
-          :total="tableTotal"
-          @page-change="onPageChange"
-          @sort-change="onSortChange"
-        ></m-table>
+    <div v-if="loading" style="height: 200px;" v-loading="loading"></div>
+    <el-result v-if="isSuccess" icon="success" title="测算完成" subTitle="点击查看测算结果">
+      <template slot="extra">
+        <el-button @click="onReset">重新测算</el-button>
+        <el-button type="orange" @click="onDetails">查看结果</el-button>
       </template>
-    </div>
+    </el-result>
+    <SandboxResult ref="sandboxResultRefs" append-to-body></SandboxResult>
   </m-dialog>
 </template>
 
 <script>
-import {
-  getSandboxResultList,
-  getSandboxResultPage
-} from '@/api/salary'
+import SandboxResult from './sandboxResult.vue'
 export default {
   name: 'sandboxCalculate',
+  components: {
+    SandboxResult
+  },
   data () {
     return {
-      choose: null,
       loading: false,
       isSuccess: false,
-      radioItems: [],
-      tableTotal: 0,
-      tableOrders: [],
-      tablePageInfo: {
-        size: 10,
-        current: 1
-      },
-      tableItems: [],
-      tableHeaders: [],
-      searchValues: {}
-    }
-  },
-  computed: {
-    searchItems () {
-      return [
-        {
-          label: '列名',
-          prop: 'column',
-          type: 'select',
-          options: {
-            placeholder: '请选择列名',
-            items: this.tableHeaders.map(e => {
-              return {
-                label: e.label,
-                value: e.prop
-              }
-            })
-          }
-        },
-        {
-          label: '值',
-          prop: 'value',
-          type: 'input',
-          options: {
-            placeholder: '请输入值'
-          }
-        }
-      ]
+      month: null,
+      itemData: {}
     }
   },
   methods: {
     async open (item) {
-      console.log(item)
+      this.month = null
+      this.itemData = item
       this.isSuccess = false
       this.$refs.dialog.open()
-      this.loading = true
-      try {
-        const { data } = await getSandboxResultList({
-          modelName: item.title
-        })
-        this.radioItems = data || []
-        if (this.radioItems.length) {
-          this.choose = this.radioItems[0].id
-        }
-        await this.getList()
-        this.isSuccess = true
-      } catch (error) {
-        this.$message.error(error)
-      } finally {
-        this.loading = false
-      }
     },
-    async getList () {
+    onStart () {
+      if (!this.month) {
+        this.$message.error('请选择月份')
+        return
+      }
       this.loading = true
-      const item = this.radioItems.find(e => e.id === this.choose)
-      try {
-        const param = {
-          page: {
-            ...this.tablePageInfo,
-            orders: this.tableOrders
-          },
-          id: this.choose,
-          type: item.node_type
-          // query: [{ column: item, compare: '=', value: '当期个人贷款月累计收息' }]
-        }
-        if (this.searchValues.column && this.searchValues.value) {
-          param.query = [{ column: this.searchValues.column, compare: '=', value: this.searchValues.value }]
-        }
-        const { data } = await getSandboxResultPage(param)
-        this.tableHeaders = data.dataColumn.map(e => {
-          return {
-            label: e.name,
-            prop: e.enName
-          }
-        })
-        this.tableItems = data.page.records
-        this.tableTotal = data.page.total
-      } catch (error) {
-        this.$message.error(error)
-      } finally {
+      setTimeout(() => {
         this.loading = false
-      }
-    },
-    onSearch () {
-      this.tablePageInfo.current = 1
-      this.getList()
+        this.isSuccess = true
+      }, 3000)
     },
-    onPageChange (index) {
-      this.tablePageInfo.current = index
-      this.getList()
+    onReset () {
+      this.isSuccess = false
     },
-    onSortChange (v) {
-      this.tableOrders = v
-      this.getList()
+    onDetails () {
+      this.$refs.sandboxResultRefs.open()
     }
   }
 }

+ 125 - 0
src/views/sandbox/sandboxComparison.vue

@@ -0,0 +1,125 @@
+<template>
+  <m-dialog title="对比" ref="dialog" v-bind="$attrs" width="1200px">
+    <m-search shadow="never" :items="searchItems" v-model="searchValues" @search="onSearch"></m-search>
+    <m-table
+      v-loading="loading"
+      class="mt-3"
+      shadow="never"
+      clearHeader
+      :items="items"
+      :headers="headers"
+      :total="total"
+      :page-size="pageInfo.size"
+      :page-current="pageInfo.current"
+      @page-change="onPageChange"
+      @sort-change="onSortChange"
+    ></m-table>
+  </m-dialog>
+</template>
+
+<script>
+import {
+  getSandboxDiffByOrg,
+  getSandboxDiffColumn
+} from '@/api/salary'
+export default {
+  name: 'SandboxComparison',
+  data () {
+    return {
+      loading: false,
+      searchValues: {},
+      headers: [
+        { label: '机构编码', prop: 'institution_code' },
+        { label: '绩效', prop: 'amount' },
+        { label: '版本', prop: 'performance_solution_version' }
+      ],
+      items: [],
+      total: 0,
+      orders: [],
+      pageInfo: {
+        size: 10,
+        current: 1
+      },
+      columnItems: []
+    }
+  },
+  computed: {
+    searchItems () {
+      return [
+        {
+          label: '名称',
+          key: 'name',
+          type: 'input',
+          options: {
+            placeholder: '请输入名称'
+          }
+        },
+        {
+          label: '对比列',
+          prop: 'column',
+          type: 'select',
+          options: {
+            placeholder: '请选择列名',
+            items: this.columnItems
+          }
+        }
+      ]
+    }
+  },
+  methods: {
+    open () {
+      this.$refs.dialog.open()
+      this.onGetSandboxDiffColumn()
+      this.onInit()
+    },
+    async onInit () {
+      this.loading = true
+      try {
+        const { data } = await getSandboxDiffByOrg({
+          id: '287',
+          type: 'DataModel',
+          diffTitle: ['institution_code'],
+          diffData: ['amount'],
+          uuid: 1,
+          version: ['1', '2']
+        })
+        this.items = data.records
+        this.total = data.total
+      } catch (error) {
+        this.$message.error(error)
+      } finally {
+        this.loading = false
+      }
+    },
+    async onGetSandboxDiffColumn () {
+      try {
+        const { data } = await getSandboxDiffColumn({
+          id: '287',
+          type: 'DataModel'
+        })
+        this.columnItems = data.map(e => {
+          return {
+            label: e.name,
+            value: e.enName
+          }
+        })
+      } catch (error) {
+        this.$message.error(error)
+      }
+    },
+    onSearch () {
+      console.log(this.searchValues)
+    },
+    onSortChange (v) {
+      this.orders = v
+    },
+    onPageChange (index) {
+      this.pageInfo.current = index
+    }
+  }
+}
+</script>
+
+<style lang="scss" scoped>
+
+</style>

+ 1 - 1
src/views/sandbox/sandboxDetails.vue

@@ -1,5 +1,5 @@
 <template>
-  <m-dialog title="规则详情" ref="dialog">
+  <m-dialog title="规则详情" ref="dialog" v-bind="$attrs">
     <SolutionDetails :item-data="itemData"></SolutionDetails>
   </m-dialog>
 </template>

+ 46 - 9
src/views/sandbox/sandboxHistory.vue

@@ -7,33 +7,52 @@
       :items="items"
       @sort-change="onSortChange"
       @page-change="onPageChange"
+      @selection-change="onSelectionChange"
     >
+      <template #header>
+        <div class="text-right">
+          <m-button type="orange" @click="onComparison">已选项对比</m-button>
+        </div>
+      </template>
       <template #actions="{ row }">
-        <m-button text type="primary" @click="open(row)">查看方案</m-button>
-        <m-button text type="primary" @click="open(row)">查看结果</m-button>
+        <m-button text type="primary" @click="onDetails(row)">查看方案</m-button>
+        <m-button text type="primary" @click="onResult(row)">查看结果</m-button>
       </template>
     </m-table>
+    <SandboxResult ref="sandboxResultRefs" append-to-body></SandboxResult>
+    <SandboxDetails ref="sandboxDetailsRefs" append-to-body></SandboxDetails>
+    <SandboxComparison ref="sandboxComparisonRefs" append-to-body></SandboxComparison>
   </m-dialog>
 </template>
 
 <script>
+import SandboxResult from './sandboxResult.vue'
+import SandboxDetails from './sandboxDetails.vue'
+import SandboxComparison from './sandboxComparison.vue'
 export default {
   name: 'sandboxHistory',
+  components: {
+    SandboxResult,
+    SandboxDetails,
+    SandboxComparison
+  },
   data () {
     return {
+      select: [],
       headers: [
+        { type: 'selection', width: 55, prop: 'selection' },
         { label: '测算时间', prop: 'time' },
         { label: '方案名称', prop: 'name' },
         { label: '绩效汇总', prop: 'performance' },
         { label: '操作', prop: 'actions' }
       ],
       items: [
-        { time: '2020-01-01 12:00:00', name: '方案1', performance: '100' },
-        { time: '2020-01-01 12:00:00', name: '方案2', performance: '100' },
-        { time: '2020-01-01 12:00:00', name: '方案3' },
-        { time: '2020-01-01 12:00:00', name: '方案4' },
-        { time: '2020-01-01 12:00:00', name: '方案5' },
-        { time: '2020-01-01 12:00:00', name: '方案6' }
+        { id: 0, time: '2020-01-01 12:00:00', name: '方案1', performance: '100' },
+        { id: 1, time: '2020-01-01 12:00:00', name: '方案2', performance: '100' },
+        { id: 2, time: '2020-01-01 12:00:00', name: '方案3' },
+        { id: 3, time: '2020-01-01 12:00:00', name: '方案4' },
+        { id: 4, time: '2020-01-01 12:00:00', name: '方案5' },
+        { id: 5, time: '2020-01-01 12:00:00', name: '方案6' }
       ]
     }
   },
@@ -42,7 +61,25 @@ export default {
       this.$refs.dialog.open()
     },
     onSortChange () {},
-    onPageChange () {}
+    onPageChange () {},
+    onDetails (item) {
+      this.$refs.sandboxDetailsRefs.open({
+        performanceSolutionId: '1940675479925174274'
+      })
+    },
+    onResult (item) {
+      this.$refs.sandboxResultRefs.open()
+    },
+    onSelectionChange (v) {
+      this.select = v.map(e => e.id)
+    },
+    onComparison () {
+      if (!this.select.length) {
+        this.$message.warning('请选择对比项')
+        return
+      }
+      this.$refs.sandboxComparisonRefs.open()
+    }
   }
 }
 </script>

+ 160 - 0
src/views/sandbox/sandboxResult.vue

@@ -0,0 +1,160 @@
+<template>
+  <m-dialog title="计算结果" ref="dialog" v-bind="$attrs" width="1200px">
+    <div v-loading="loading">
+      <m-card shadow="never">
+        <el-radio-group v-model="choose" @input="getList">
+          <el-radio
+            v-for="item in radioItems"
+            :key="item.id"
+            :label="item.id"
+          >
+            {{ item.name }}
+          </el-radio>
+        </el-radio-group>
+      </m-card>
+
+      <m-search class="mt-3" shadow="never" :items="searchItems" v-model="searchValues" @search="onSearch"></m-search>
+
+      <m-table
+        class="mt-3"
+        shadow="never"
+        clearHeader
+        :items="tableItems"
+        :headers="tableHeaders"
+        :page-size="tablePageInfo.size"
+        :page-current="tablePageInfo.current"
+        :total="tableTotal"
+        @page-change="onPageChange"
+        @sort-change="onSortChange"
+      ></m-table>
+    </div>
+  </m-dialog>
+</template>
+
+<script>
+import {
+  getSandboxResultList,
+  getSandboxResultPage
+} from '@/api/salary'
+export default {
+  name: 'sandboxResult',
+  data () {
+    return {
+      loading: false,
+      isSuccess: false,
+      radioItems: [],
+      tableTotal: 0,
+      tableOrders: [],
+      tablePageInfo: {
+        size: 10,
+        current: 1
+      },
+      tableItems: [],
+      tableHeaders: [],
+      searchValues: {},
+      choose: null
+    }
+  },
+  computed: {
+    searchItems () {
+      return [
+        {
+          label: '列名',
+          prop: 'column',
+          type: 'select',
+          options: {
+            placeholder: '请选择列名',
+            items: this.tableHeaders.map(e => {
+              return {
+                label: e.label,
+                value: e.prop
+              }
+            })
+          }
+        },
+        {
+          label: '值',
+          prop: 'value',
+          type: 'input',
+          options: {
+            placeholder: '请输入值'
+          }
+        }
+      ]
+    }
+  },
+  methods: {
+    open () {
+      this.$refs.dialog.open()
+      this.getSandboxResultList()
+    },
+    async getSandboxResultList () {
+      this.loading = true
+      try {
+        const { data } = await getSandboxResultList({
+          modelName: '客户维业绩流水账'
+        })
+        this.radioItems = data || []
+        if (this.radioItems.length) {
+          this.choose = this.radioItems[0].id
+        }
+        await this.getList()
+        this.isSuccess = true
+      } catch (error) {
+        this.$message.error(error)
+      } finally {
+        this.loading = false
+      }
+    },
+
+    async getList () {
+      this.loading = true
+      const item = this.radioItems.find(e => e.id === this.choose)
+      try {
+        const param = {
+          page: {
+            ...this.tablePageInfo,
+            orders: this.tableOrders
+          },
+          id: this.choose,
+          type: item.node_type
+          // query: [{ column: item, compare: '=', value: '当期个人贷款月累计收息' }]
+        }
+        if (this.searchValues.column && this.searchValues.value) {
+          param.query = [{ column: this.searchValues.column, compare: '=', value: this.searchValues.value }]
+        }
+        const { data } = await getSandboxResultPage(param)
+        this.tableHeaders = data.dataColumn.map(e => {
+          return {
+            label: e.name,
+            prop: e.enName
+          }
+        })
+        this.tableItems = data.page.records
+        this.tableTotal = data.page.total
+      } catch (error) {
+        this.$message.error(error)
+      } finally {
+        this.loading = false
+      }
+    },
+    onSearch () {
+      this.tablePageInfo.current = 1
+      this.getList()
+    },
+    onPageChange (index) {
+      this.tablePageInfo.current = index
+      this.getList()
+    },
+    onSortChange (v) {
+      this.tableOrders = v
+      this.getList()
+    }
+
+  }
+}
+</script>
+
+<style lang="scss" scoped>
+
+</style>