zhengnaiwen_citu 5 miesięcy temu
rodzic
commit
f6d236697f

+ 31 - 16
src/views/dataChart/privateChart/index.vue

@@ -10,8 +10,8 @@
       :total="total"
       @page-change="onPageChange"
     >
-      <template #status="{ row }">
-        <el-tag size="small" :type="row.status === 1 ? 'success' : 'danger'">{{ row.status === 1 ? '启用' : '停用'}}</el-tag>
+      <template #permission="{ row }">
+        <el-tag size="small" :type="row.permission === 1 ? 'success' : 'warning'">{{ row.permission === 1 ? '已发布' : '未发布' }}</el-tag>
       </template>
       <template #card-tools>
         <m-button type="orange" icon="el-icon-plus" @click="onAdd">新增</m-button>
@@ -20,8 +20,8 @@
         <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 :type="row.permission === 1 ? 'danger' : 'success'" text @click="onStatus(row)">
+          {{ row.permission === 1 ? '取消发布' : '发布' }}
         </m-button>
       </template>
     </m-table>
@@ -35,7 +35,8 @@ import PrivateChartEdit from './privateChartEdit.vue'
 import PrivateEdit from './privateEdit.vue'
 import {
   webSettingList,
-  deleteWebSetting
+  deleteWebSetting,
+  saveWebSetting
 } from '@/api/system'
 export default {
   name: 'PrivateChart',
@@ -48,7 +49,7 @@ export default {
       searchItems: [
         {
           label: '名称',
-          prop: 'name',
+          prop: 'searchName',
           type: 'input',
           options: {
             placeholder: '请输入名称'
@@ -56,14 +57,13 @@ export default {
         }
       ],
       searchValues: {
-        name: null
+        searchName: null
       },
       headers: [
         { label: '名称', prop: 'name' },
-        { label: '制作者', prop: 'author' },
+        { label: '状态', prop: 'permission', align: 'center' },
+        { label: '描述', prop: 'description' },
         { label: '制作时间', prop: 'createDate' },
-        { label: '状态', prop: 'status' },
-        { label: '描述', prop: 'desc' },
         { label: '操作', prop: 'actions' }
       ],
       items: [],
@@ -84,12 +84,17 @@ export default {
             ...this.pageInfo
           },
           entity: {
-            // ...this.searchValues,
-            webSettingCategory: 'shareChart', // 自定义图表
-            permission: 0 // 私有
+            webSettingCategory: 'shareChart' // 自定义图表
+          },
+          ...this.searchValues,
+          dataType: 0 // 私有
+        })
+        this.items = data.records.map(e => {
+          return {
+            ...e.entity,
+            ...e.entity.content
           }
         })
-        this.items = data.records
         this.total = data.total
       } catch (error) {
         this.$message.error(error)
@@ -119,8 +124,18 @@ export default {
         })
         .catch(_ => {})
     },
-    onStatus (item) {
-      item.status = item.status === 1 ? 0 : 1
+    async onStatus (item) {
+      try {
+        await saveWebSetting({
+          webSettingId: item.webSettingId,
+          permission: item.permission === 1 ? 0 : 1
+
+        })
+        this.$message.success('修改成功')
+        this.onInit()
+      } catch (error) {
+        this.$message.error(error)
+      }
     },
     onSearch () {
       this.pageInfo.current = 1

+ 1 - 22
src/views/dataChart/privateChart/privateChartEdit.vue

@@ -35,9 +35,6 @@
 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: {
@@ -62,31 +59,13 @@ export default {
       this.$nextTick(async () => {
         // 实例化图例
         this.$refs.privateChartEditShowRefs.onInit()
-        // const { configRefs } = this.$refs.privateChartEditParamsRefs.onGetRefs()
-        if (!item) {
+        if (!item.data) {
           // 获取初始化设置
           const { key } = this.$refs.privateChartEditTypeRefs.getDefault()
           this.key = key
-          // 设置默认参数
-          // const defaultParams = [
-          //   { name: '机构名称', value: 'organizationName' },
-          //   { name: '积分', value: 'integral' },
-          //   { name: '职务', value: 'postName' },
-          //   { name: '绩效', value: 'performance' },
-          //   { name: '姓名', value: 'employeeName' }]
-          // 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
         }
       })
     },

+ 28 - 6
src/views/dataChart/privateChart/privateEdit.vue

@@ -8,6 +8,7 @@
 import {
   saveWebSetting
 } from '@/api/system'
+import { mapGetters } from 'vuex'
 export default {
   name: 'privateEdit',
   data () {
@@ -39,32 +40,53 @@ export default {
         }
       ],
       loading: false,
-      itemData: {}
+      itemData: null
     }
   },
+  computed: {
+    ...mapGetters(['employeeInfo', 'userInfo'])
+  },
   methods: {
     open (item) {
+      this.itemData = item ?? null
       this.$refs.dialog.open()
       if (!item) {
         this.formValues = {
           name: null,
           description: null
         }
-        return
+      } else {
+        this.formValues = {
+          name: this.itemData.name,
+          description: this.itemData.description
+        }
       }
-      this.itemData = item
     },
     async onSure () {
       this.loading = true
-      try {
-        await saveWebSetting({
+      const param = {}
+      if (this.itemData) {
+        Object.assign(param, {
+          webSettingId: this.itemData.webSettingId,
+          content: {
+            ...this.formValues,
+            data: this.itemData.content.data,
+            author: this.employeeInfo?.employeeName || this.userInfo?.name
+          }
+        })
+      } else {
+        Object.assign(param, {
           webSettingCategory: 'shareChart',
           permission: 0,
           content: {
             ...this.formValues,
-            data: null
+            data: null,
+            author: this.employeeInfo?.employeeName || this.userInfo?.name
           }
         })
+      }
+      try {
+        await saveWebSetting(param)
         this.$refs.dialog.close()
         this.$emit('refresh')
       } catch (error) {

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

@@ -10,9 +10,11 @@
       :total="total"
       @page-change="onPageChange"
     >
+      <template #permission="{ row }">
+        <el-tag size="small" :type="row.permission === 1 ? 'success' : 'warning'">{{ row.permission === 1 ? '已发布' : '未发布' }}</el-tag>
+      </template>
       <template #actions="{ row }">
-        <m-button type="primary" text @click="onEdit(row)">编辑</m-button>
-        <m-button type="danger" text @click="onDelete(row)">删除</m-button>
+        <m-button type="primary" text @click="onDetails(row)">查看</m-button>
       </template>
     </m-table>
   </div>
@@ -43,9 +45,9 @@ export default {
       headers: [
         { label: '名称', prop: 'name' },
         { label: '制作者', prop: 'author' },
+        { label: '状态', prop: 'permission', align: 'center' },
+        { label: '描述', prop: 'description' },
         { label: '制作时间', prop: 'createDate' },
-        { label: '状态', prop: 'status' },
-        { label: '描述', prop: 'desc' },
         { label: '操作', prop: 'actions' }
       ],
       items: [],
@@ -71,7 +73,14 @@ export default {
             permission: 1 // 团队共有
           }
         })
-        this.items = data.records
+        this.items = data.records.map(e => {
+          return {
+            ...e.entity,
+            name: e.entity.content?.name ?? null,
+            description: e.entity.content?.description ?? null,
+            author: e.entity.content?.author ?? null
+          }
+        })
         this.total = data.total
       } catch (error) {
         this.message.error(error.message || '请求失败')
@@ -79,25 +88,9 @@ export default {
         this.loading = false
       }
     },
-    onAdd () {
-      this.refs.templateRefs.open()
-    },
-    onEdit (item) {
+    onDetails (item) {
       this.refs.templateRefs.open(item)
     },
-    onDelete (row) {
-      this.confirm('确定删除吗?', '提示')
-        .then(async () => {
-          try {
-            // await ApiName({ id: row.id })
-            this.message.success('删除成功')
-            this.onInit()
-          } catch (error) {
-            this.message.error(error.message || '删除失败')
-          }
-        })
-        .catch(_ => {})
-    },
     onSearch () {
       this.pageInfo.current = 1
       this.onInit()