Bladeren bron

图表新增

zhengnaiwen_citu 5 maanden geleden
bovenliggende
commit
98f8ec763e

+ 15 - 0
src/api/system.js

@@ -212,3 +212,18 @@ export function saveLabelAll (params) {
 export function webSettingList (params) {
   return http.post('/authentication/web/setting/list', params)
 }
+
+// 统一配置接口 详情
+export function getWebSetting (params) {
+  return http.post('/authentication/web/setting/detail', params)
+}
+
+// 统一配置接口 保存
+export function saveWebSetting (params) {
+  return http.post('/authentication/web/setting/save', params)
+}
+
+// 统一配置接口 删除
+export function deleteWebSetting (params) {
+  return http.post('/authentication/web/setting/del', params)
+}

+ 28 - 23
src/views/dataChart/privateChart/index.vue

@@ -18,22 +18,30 @@
       </template>
       <template #actions="{ row }">
         <m-button type="primary" text @click="onEdit(row)">编辑</m-button>
+        <m-button type="primary" text @click="onConfiguration(row)">配置图表</m-button>
         <m-button type="danger" text @click="onDelete(row)">删除</m-button>
         <m-button :type="row.status === 1 ? 'danger' : 'success'" text @click="onStatus(row)">
           {{ row.status === 1 ? '停用' : '启用' }}
         </m-button>
       </template>
     </m-table>
-    <PrivateChartEdit ref="privateChartEditRefs" fullscreen></PrivateChartEdit>
+    <PrivateChartEdit ref="privateChartEditRefs" fullscreen @refresh="onInit"></PrivateChartEdit>
+    <PrivateEdit ref="privateEditRefs" @refresh="onInit"></PrivateEdit>
   </div>
 </template>
 
 <script>
 import PrivateChartEdit from './privateChartEdit.vue'
+import PrivateEdit from './privateEdit.vue'
+import {
+  webSettingList,
+  deleteWebSetting
+} from '@/api/system'
 export default {
   name: 'PrivateChart',
   components: {
-    PrivateChartEdit
+    PrivateChartEdit,
+    PrivateEdit
   },
   data () {
     return {
@@ -58,22 +66,7 @@ export default {
         { label: '描述', prop: 'desc' },
         { label: '操作', prop: 'actions' }
       ],
-      items: [
-        {
-          name: '图表1',
-          author: '张三',
-          createDate: '2021-01-01',
-          status: 1,
-          desc: '这是一个图表'
-        },
-        {
-          name: '图表2',
-          author: '李四',
-          createDate: '2021-01-02',
-          status: 0,
-          desc: '这是另一个图表'
-        }
-      ],
+      items: [],
       total: 0,
       pageInfo: {
         current: 1,
@@ -86,9 +79,18 @@ export default {
     async onInit () {
       this.loading = true
       try {
-        // const { data } = await ApiName()
-        // this.items = data.list || []
-        // this.total = data.total || 0
+        const { data } = await webSettingList({
+          page: {
+            ...this.pageInfo
+          },
+          entity: {
+            ...this.searchValues,
+            webSettingCategory: 'shareChart', // 自定义图表
+            permission: 0 // 私有
+          }
+        })
+        this.items = data.records
+        this.total = data.total
       } catch (error) {
         this.$message.error(error)
       } finally {
@@ -96,16 +98,19 @@ export default {
       }
     },
     onAdd () {
-      this.$refs.privateChartEditRefs.open()
+      this.$refs.privateEditRefs.open()
     },
     onEdit (item) {
+      this.$refs.privateEditRefs.open(item)
+    },
+    onConfiguration (item) {
       this.$refs.privateChartEditRefs.open(item)
     },
     onDelete (row) {
       this.$confirm('确定删除吗?', '提示')
         .then(async () => {
           try {
-            // await ApiName({ id: row.id })
+            await deleteWebSetting({ webSettingId: row.webSettingId })
             this.$message.success('删除成功')
             this.onInit()
           } catch (error) {

+ 23 - 4
src/views/dataChart/privateChart/privateChartEdit.vue

@@ -1,6 +1,6 @@
 <template>
-  <m-dialog ref="dialog" v-bind="$attrs" title="图表编辑">
-    <div class="pa-3 fullscreen border-box">
+  <m-dialog ref="dialog" v-bind="$attrs" title="图表编辑" @sure="onSure">
+    <div class="pa-3 fullscreen border-box" v-loading="loading">
       <m-card shadow="never" class="fullscreen border-box" :body-style="{ height: '100%', padding: 0 }">
         <div class="d-flex box fullscreen">
           <div class="box-left">
@@ -35,6 +35,9 @@
 import PrivateChartEditShow from './privateChartEditShow.vue'
 import PrivateChartEditType from './privateChartEditType.vue'
 import PrivateChartEditParams from './privateChartEditParams.vue'
+import {
+  getWebSetting
+} from '@/api/system'
 export default {
   name: 'privateChartEdit',
   components: {
@@ -44,6 +47,7 @@ export default {
   },
   data () {
     return {
+      loading: false,
       key: null,
       option: {
         xAxisData: []
@@ -52,9 +56,10 @@ export default {
     }
   },
   methods: {
-    open (item) {
+    async open (item) {
       this.$refs.dialog.open()
-      this.$nextTick(() => {
+      this.loading = true
+      this.$nextTick(async () => {
         // 实例化图例
         this.$refs.privateChartEditShowRefs.onInit()
         // const { configRefs } = this.$refs.privateChartEditParamsRefs.onGetRefs()
@@ -72,6 +77,16 @@ export default {
           // configRefs.onSetConfig(defaultParams)
           this.option.xAxisData = ['星期一', '星期二', '星期三', '星期四', '星期五', '星期六']
           this.setData()
+          this.loading = false
+          return
+        }
+        try {
+          const { data } = await getWebSetting({ webSettingId: item.webSettingId })
+          console.log(data)
+        } catch (error) {
+          this.$message.error(error)
+        } finally {
+          this.loading = false
         }
       })
     },
@@ -92,6 +107,10 @@ export default {
     onChangeConfig (obj) {
       // const { x, y } = obj
       console.log(obj)
+    },
+    onSure () {
+      this.$refs.dialog.close()
+      this.$emit('refresh')
     }
   }
 }

+ 82 - 0
src/views/dataChart/privateChart/privateEdit.vue

@@ -0,0 +1,82 @@
+<template>
+  <m-dialog ref="dialog" title="" @sure="onSure">
+    <m-form :items="formItems" v-model="formValues" v-loading="loading"></m-form>
+  </m-dialog>
+</template>
+
+<script>
+import {
+  saveWebSetting
+} from '@/api/system'
+export default {
+  name: 'privateEdit',
+  data () {
+    return {
+      formValues: {
+        name: null,
+        description: null
+      },
+      formItems: [
+        {
+          label: '图表名称',
+          prop: 'name',
+          type: 'input',
+          rules: [
+            { required: true, message: '请输入图表名称', trigger: 'blur' }
+          ],
+          options: {
+            placeholder: '请输入图表名称'
+          }
+        },
+        {
+          label: '描述',
+          prop: 'description',
+          type: 'input',
+          options: {
+            type: 'textarea',
+            placeholder: '请输入描述'
+          }
+        }
+      ],
+      loading: false,
+      itemData: {}
+    }
+  },
+  methods: {
+    open (item) {
+      this.$refs.dialog.open()
+      if (!item) {
+        this.formValues = {
+          name: null,
+          description: null
+        }
+        return
+      }
+      this.itemData = item
+    },
+    async onSure () {
+      this.loading = true
+      try {
+        await saveWebSetting({
+          webSettingCategory: 'shareChart',
+          permission: 0,
+          content: {
+            ...this.formValues,
+            data: null
+          }
+        })
+        this.$refs.dialog.close()
+        this.$emit('refresh')
+      } catch (error) {
+        this.$message.error(error)
+      } finally {
+        this.loading = false
+      }
+    }
+  }
+}
+</script>
+
+<style lang="scss" scoped>
+
+</style>

+ 22 - 9
src/views/dataChart/shareChart/index.vue

@@ -1,10 +1,6 @@
 <template>
   <div class="pa-3 white">
-    <m-search class="mb-3" :items="searchItems" v-model="searchValue" @search="onSearch">
-      <template #button>
-        <m-button type="orange" icon="el-icon-plus" @click="onAdd">新增</m-button>
-      </template>
-    </m-search>
+    <m-search class="mb-3" :items="searchItems" v-model="searchValue" @search="onSearch"></m-search>
     <m-table
       v-loading="loading"
       :items="items"
@@ -23,6 +19,9 @@
 </template>
 
 <script>
+import {
+  webSettingList
+} from '@/api/system'
 export default {
   name: 'ShareChart',
   data () {
@@ -42,7 +41,12 @@ export default {
         name: null
       },
       headers: [
-        { label: '操作', prop: 'actions', fixed: 'right', width: 300 }
+        { label: '名称', prop: 'name' },
+        { label: '制作者', prop: 'author' },
+        { label: '制作时间', prop: 'createDate' },
+        { label: '状态', prop: 'status' },
+        { label: '描述', prop: 'desc' },
+        { label: '操作', prop: 'actions' }
       ],
       items: [],
       total: 0,
@@ -57,9 +61,18 @@ export default {
     async onInit () {
       this.loading = true
       try {
-        // const { data } = await ApiName()
-        // this.items = data.list || []
-        // this.total = data.total || 0
+        const { data } = await webSettingList({
+          page: {
+            ...this.pageInfo
+          },
+          entity: {
+            ...this.searchValues,
+            webSettingCategory: 'shareChart', // 自定义图表
+            permission: 1 // 团队共有
+          }
+        })
+        this.items = data.records
+        this.total = data.total
       } catch (error) {
         this.message.error(error.message || '请求失败')
       } finally {