Browse Source

活动类型页面完成

htc 1 tuần trước cách đây
mục cha
commit
a31bf33b3a
4 tập tin đã thay đổi với 257 bổ sung12 xóa
  1. 60 0
      src/assets/scss/common.scss
  2. 8 8
      src/views/main-navbar.vue
  3. 188 3
      src/views/modules/activity/type.vue
  4. 1 1
      vue.config.js

+ 60 - 0
src/assets/scss/common.scss

@@ -714,3 +714,63 @@ img {
     }
   }
 }
+
+.adf{
+  display: flex;
+}
+.adffc{
+  display: flex;
+  flex-direction: column;
+}
+.adfac{
+  display: flex;
+  align-items: center;
+}
+.adfacjc{
+  display: flex;
+  align-items: center;
+  justify-content: center;
+}
+.adfacjb{
+  display: flex;
+  align-items: center;
+  justify-content: space-between;
+}
+.adffcjb{
+  display: flex;
+  flex-direction: column;
+justify-content: space-between;
+}
+.adffcacjc{
+  display: flex;
+  flex-direction: column;
+  align-items: center;
+  justify-content: center;
+}
+.adffcac{
+  display: flex;
+  flex-direction: column;
+  align-items: center;
+}
+.adffcacjb{
+  display: flex;
+  flex-direction: column;
+  align-items: center;
+  justify-content: space-between;
+}
+
+.el-dialog__title{
+  font-family: PingFang-SC, PingFang-SC;
+  font-weight: bold;
+  font-size: 16px;
+  color: #252525;
+  line-height: 22px;
+}
+.el-dialog__headerbtn .el-dialog__close{
+  color: #646464;
+  font-weight: bold !important;
+}
+.el-button--primary{
+  background-color: #00AE57;
+  border-color: #00AE57;
+}

+ 8 - 8
src/views/main-navbar.vue

@@ -94,14 +94,14 @@ export default {
       this.$router.replace('notice-notice-user')
     },
     getUnReadCount () {
-      this.$http.get(`/sys/notice/mynotice/unread`).then(({ data: res }) => {
-        if (res.code !== 0) {
-          return this.$message.error(res.msg)
-        }
-        if (res.data > 0) {
-          this.messageTip = true
-        }
-      }).catch(() => {})
+      // this.$http.get(`/sys/notice/mynotice/unread`).then(({ data: res }) => {
+      //   if (res.code !== 0) {
+      //     return this.$message.error(res.msg)
+      //   }
+      //   if (res.data > 0) {
+      //     this.messageTip = true
+      //   }
+      // }).catch(() => {})
     },
     // 全屏
     fullscreenHandle () {

+ 188 - 3
src/views/modules/activity/type.vue

@@ -1,8 +1,56 @@
 <template>
     <el-card shadow="never" class="aui-card--fill">
         <div class="mod-home">
-            <h3>活动类型</h3>
+            <div class="title">活动类型管理</div>
+            <div class="query adfacjb">
+              <div class="query-left adfac">
+                <div class="text">活动类型</div>
+                <el-input v-model="queryParams.typeName" placeholder="请输入类型名称" @keyup.enter.native="getList"></el-input>
+              </div>
+              <div class="query-right">
+                <el-button type="default" @click="handleReset">重置</el-button>
+                <el-button type="primary" @click="getList">查询</el-button>
+              </div>
+            </div>
+            <div class="add">
+              <el-button type="primary" @click="handleAdd" v-if="$hasPermission('core:activitytype:save')">新增活动类型</el-button>
+            </div>
+            <el-table :data="dataList" border cell-class-name="vertical-top-cell" v-loading="loading" empty-text="暂无活动类型" style="margin-top: 12px;">
+              <el-table-column prop="typeName" label="类型名称"></el-table-column>
+              <el-table-column prop="typeNo" label="分类编码"></el-table-column>
+              <el-table-column prop="enable" label="状态">
+                <template #default="scope">
+                  <div>{{ scope.row.enable?'启用':'停用' }}</div>
+                </template>
+              </el-table-column>
+              <el-table-column label="操作" width="250">
+                  <template #default="scope">
+                      <el-button link type="text" @click="handleEdit(scope.row)" v-if="$hasPermission('core:activitytype:update')">编辑</el-button>
+                      <el-button link type="text" @click="handleOpenClose(scope.row,1)" v-if="$hasPermission('core:activitytype:openClose')&&scope.row.enable==0">启用</el-button>
+                      <el-button link type="text" @click="handleOpenClose(scope.row,0)" v-if="$hasPermission('core:activitytype:openClose')&&scope.row.enable==1">停用</el-button>
+                      <el-button link type="text" @click="handleDelete(scope.row)" v-if="$hasPermission('core:activitytype:delete')">删除</el-button>
+                  </template>
+              </el-table-column>
+            </el-table>
         </div>
+        <el-dialog width="800px" :visible.sync="show" :title="title" @close="cancel">
+          <el-form ref="typeRef" :model="form" :rules="rules" label-width="100px" style="width: 70%;margin: 0 auto;">
+            <el-form-item label="类型名称" prop="typeName">
+              <el-input v-model="form.typeName" placeholder="请输入类型名称"></el-input>
+            </el-form-item>
+            <el-form-item label="分类编码" prop="typeNo">
+              <el-input v-model="form.typeNo" placeholder="请输入分类编码"></el-input>
+            </el-form-item>
+            <el-form-item label="状态" prop="enable">
+              <el-radio v-model="form.enable" :label="1">启用</el-radio>
+              <el-radio v-model="form.enable" :label="0">停用</el-radio>
+            </el-form-item>
+          </el-form>
+          <div class="demo-drawer__footer" style="display: flex;justify-content: end;margin-top: 300px;">
+            <el-button :loading="buttonLoading" type="primary" @click="submitForm">保 存</el-button>
+            <el-button @click="cancel" style="margin-right: 5%;">取 消</el-button>
+          </div>
+        </el-dialog>
     </el-card>
 </template>
 
@@ -10,15 +58,152 @@
 export default {
   data () {
     return {
-
+      queryParams: {
+        page: 1,
+        limit: 10,
+        typeName: ''
+      },
+      dataList: [],
+      loading: false,
+      show: false,
+      buttonLoading: false,
+      title: '新增活动类型',
+      form: {
+        id: '',
+        typeName: '',
+        typeNo: '',
+        enable: 1
+      },
+      rules: {
+        typeName: [
+          { required: true, message: '请输入类型名称', trigger: 'blur' }
+        ],
+        typeNo: [
+          { required: true, message: '请输入分类编码', trigger: 'blur' }
+        ],
+        enable: [
+          { required: true, message: '请选择状态', trigger: 'change' }
+        ]
+      }
     }
   },
+  mounted () {
+    this.getList()
+  },
   methods: {
-
+    handleReset () {
+      this.queryParams = {
+        page: 1,
+        limit: 10,
+        typeName: ''
+      }
+      this.getList()
+    },
+    handleAdd () {
+      this.title = '新增活动类型'
+      this.show = true
+    },
+    handleEdit (row) {
+      this.$http.get('/core/activity/type/' + row.id).then(res => {
+        if (res.data.code !== 0) return this.$message.error(res.msg)
+        this.form = { ...this.form, ...res.data.data }
+        this.$nextTick(() => {
+          this.title = '编辑活动类型'
+          this.show = true
+          this.$refs.typeRef.clearValidate()
+        })
+      })
+    },
+    cancel () {
+      this.show = false
+      this.form = {
+        id: '',
+        typeName: '',
+        typeNo: '',
+        enable: 1
+      }
+      this.$refs.typeRef.resetFields()
+    },
+    getList () {
+      this.loading = true
+      this.$http.get('/core/activity/type/page', { params: this.queryParams }).then(res => {
+        if (res.data.code !== 0) return this.$message.error(res.msg)
+        this.dataList = res.data.data.list
+        this.loading = false
+      })
+    },
+    submitForm () {
+      this.$refs.typeRef.validate((valid) => {
+        if (valid) {
+          this.$http[this.form.id ? 'put' : 'post']('/core/activity/type', this.form).then(res => {
+            if (res.data.code !== 0) {
+              return this.$message.error(res.msg)
+            }
+            this.$message.success('保存成功')
+            this.cancel()
+            this.getList()
+          })
+        } else {
+          return false
+        }
+      })
+    },
+    handleOpenClose (row, enable) {
+      let dto = JSON.parse(JSON.stringify(row))
+      dto.enable = enable
+      this.$http.put('/core/activity/type', dto).then(res => {
+        if (res.data.code !== 0) return this.$message.error(res.msg)
+        this.$message.success('操作成功')
+        this.getList()
+      })
+    },
+    handleDelete (row) {
+      this.$confirm(`是否确认删除活动类型【${row.typeName}】?`, '提示', {
+        confirmButtonText: '确定',
+        cancelButtonText: '取消',
+        type: 'warning'
+      }).then(() => {
+        this.$http.delete('/core/activity/type', { 'data': [row.id] }).then(res => {
+          if (res.data.code !== 0) return this.$message.error(res.msg)
+          this.$message.success('删除成功')
+          this.getList()
+        })
+      }).catch(() => {
+        this.$message({
+          type: 'info',
+          message: '已取消删除'
+        })
+      })
+    }
   }
 }
 </script>
 
 <style scoped lang="scss">
+  .title{
+    font-family: PingFang-SC, PingFang-SC;
+    font-weight: bold;
+    font-size: 16px;
+    color: #252525;
+    line-height: 22px;
+  }
 
+  .query{
+    margin-top: 23px;
+    &-left{
+      .text{
+        width: 80px;
+        font-family: PingFangSC, PingFang SC;
+        font-weight: 400;
+        font-size: 14px;
+        color: #393939;
+        line-height: 20px;
+        margin-right: 16px;
+      }
+    }
+  }
+
+  .add{
+    margin-top: 24px;
+  }
 </style>

+ 1 - 1
vue.config.js

@@ -12,7 +12,7 @@ module.exports = {
       .loader('svg-sprite-loader')
   },
   // 默认打开eslint效验,如果需要关闭,设置成false即可
-  lintOnSave: true,
+  lintOnSave: false,
   productionSourceMap: false,
   devServer: {
     open: true,