sunny 1 vuosi sitten
vanhempi
commit
72f80f4836
2 muutettua tiedostoa jossa 78 lisäystä ja 83 poistoa
  1. 45 0
      src/api/commendManage.js
  2. 33 83
      src/views/commendManage/commendList.vue

+ 45 - 0
src/api/commendManage.js

@@ -0,0 +1,45 @@
+import request from '@/utils/request'
+
+export function createItem(data) {
+  return request({
+    url: '/mall-integral-obtain/commend/add',
+    method: 'post',
+    data
+  })
+}
+
+export function updateItem(data) {
+  return request({
+    url: '/mall-integral-obtain/commend/edit',
+    method: 'post',
+    data
+  })
+}
+
+export function list(query) {
+  return request({
+    url: '/mall-integral-obtain/commend/page',
+    method: 'get',
+    params:query
+  })
+}
+
+export function state(query) {
+  return request({
+    url: '/mall-integral-obtain/commend/modify/status',
+    method: 'post',
+    params:query
+  })
+}
+
+export function types(query) {
+  return request({
+    url: '/mall-integral-obtain/commend/types',
+    method: 'get',
+    params:query
+  })
+}
+
+
+
+

+ 33 - 83
src/views/commendManage/commendList.vue

@@ -8,13 +8,11 @@
       </el-select>
       <el-button class="filter-item" type="primary" v-waves icon="el-icon-search" @click="handleFilter">查找</el-button>
       <el-button class="filter-item" type="primary" @click="handleCreate" icon="el-icon-edit">添加</el-button>
-      <!-- <el-button class="filter-item" type="warning" icon="el-icon-delete" @click="delAll">批量删除</el-button> -->
     </div>
 
     <!-- 查询结果 -->
-    <el-table size="small" :data="list" v-loading="listLoading" @selection-change="handleSelectionChange"
+    <el-table size="small" :data="list" v-loading="listLoading"
       element-loading-text="正在查询中。。。" border fit highlight-current-row>
-      <el-table-column type="selection" width="55px"> </el-table-column>
       <el-table-column type="index" label="序号" header-align="center" align="center">
       </el-table-column>
       <el-table-column align="center" min-width="100px" label="标题" prop="title">
@@ -32,7 +30,7 @@
             @click="changeState(scope.row.commendId, 1)">开启</el-button>
           <el-button v-if="scope.row.status == 1" type="warning" size="small"
             @click="changeState(scope.row.commendId, 0)">关闭</el-button>
-          <el-button type="danger" size="mini" @click="handleDelete(scope.row)">删除</el-button>
+          <el-button type="danger" size="mini" @click="handleDelete(scope.row.commendId, -1)">删除</el-button>
         </template>
       </el-table-column>
     </el-table>
@@ -52,18 +50,14 @@
         <el-form-item label="标题" prop="title">
           <el-input style="width: 350px" v-model="dataForm.title"></el-input>
         </el-form-item>
-        <!-- <el-form-item label="日期" prop="pubDate">
-          <el-date-picker v-model="dataForm.pubDate" type="date" value-format="yyyy-MM-dd" placeholder="选择日期"
-            style="width: 350px"></el-date-picker>
-        </el-form-item> -->
         <el-form-item label="类型" prop="type">
           <el-select @change="changeType" v-model="dataForm.type" filterable placeholder="请选择" style="width: 350px">
             <el-option :key="item.type" v-for="item in typeList" :label="item.name" :value="item.type">
             </el-option>
           </el-select>
         </el-form-item>
-        <el-form-item label="表彰人" prop="recipients">
-          <el-select v-model="dataForm.recipients" multiple filterable placeholder="请选择" style="width: 350px">
+        <el-form-item label="表彰人" prop="recipientsArry">
+          <el-select v-model="dataForm.recipientsArry" multiple filterable placeholder="请选择" style="width: 350px">
             <el-option :key="item.loginId" v-for="item in recipientsList" :label="item.userName" :value="item.loginId">
             </el-option>
           </el-select>
@@ -114,12 +108,12 @@
   
 <script>
 import {
-  listNews,
-  createNews,
-  updateNews,
-  deleteNews,
-  deleteAllNews,
-} from "@/api/newsCenter";
+  createItem,
+  updateItem,
+  list,
+  state,
+  types,
+} from "@/api/commendManage";
 import { allUserList } from "@/api/public";
 import waves from "@/directive/waves"; // 水波纹指令
 import Tinymce from "@/components/Tinymce";
@@ -132,20 +126,7 @@ export default {
       typeVisible: false,
       fileImgUrl: this.upLoadUrl,
       recipientsList: [],
-      typeList: [
-        {
-          type: 31,
-          name: "部门表彰",
-        },
-        {
-          type: 32,
-          name: "公司表彰",
-        },
-        {
-          type: 33,
-          name: "客户表彰",
-        },
-      ],
+      typeList: [],
       subTypeList: [
         {
           type: 0,
@@ -446,6 +427,7 @@ export default {
         fileIds: undefined,
         fileName: undefined,
         files: [],
+        recipientsArry:[],
         recipients: undefined,
       },
       dialogFormVisible: false,
@@ -456,7 +438,7 @@ export default {
       },
       rules: {
         title: [{ required: true, message: "标题不能为空", trigger: "blur" }],
-        recipients: [
+        recipientsArry: [
           { required: true, message: "表彰人不能为空", trigger: "blur" },
         ],
         type: [{ required: true, message: "请选择类型", trigger: "blur" }],
@@ -466,10 +448,16 @@ export default {
     };
   },
   created() {
-    // this.getList();
-    // this.getAllUserList(); 
+    this.getTypeList();
+    this.getList();
+    this.getAllUserList(); 
   },
   methods: {
+    getTypeList(){
+      types().then(response => {
+        this.typeList = response.data.data;
+      })
+    },
     changeType(val) {
       if (val == 33) {
         this.typeVisible = true;
@@ -477,8 +465,8 @@ export default {
         this.typeVisible = false;
       }
     },
-    changeState(welfareId, index) {
-      welfareState({ welfareId: welfareId, status: index }).then(response => {
+    changeState(commendId, index) {
+      state({ commendId: commendId, status: index }).then(response => {
         this.$notify({
           title: '成功',
           message: '状态修改成功',
@@ -544,6 +532,7 @@ export default {
         fileIds: undefined,
         fileName: undefined,
         files: [],
+        recipientsArry:[],
         recipients: undefined,
       };
     },
@@ -565,8 +554,8 @@ export default {
     createData() {
       this.$refs["dataForm"].validate((valid) => {
         if (valid) {
-          this.dataForm.recipients = this.dataForm.recipients.split(",");
-          createNews(this.dataForm)
+          this.dataForm.recipients = this.dataForm.recipientsArry.join(",");
+          createItem(this.dataForm)
             .then(() => {
               this.getList();
               this.dialogFormVisible = false;
@@ -585,7 +574,7 @@ export default {
     },
     getList() {
       this.listLoading = true;
-      listNews(this.listQuery)
+      list(this.listQuery)
         .then((response) => {
           this.list = response.data.data.items;
           this.total = response.data.data.total;
@@ -615,7 +604,7 @@ export default {
 
     handleUpdate(row) {
       this.dataForm = Object.assign({}, row);
-      this.dataForm.recipients = this.dataForm.recipients.join(",");
+      this.dataForm.recipientsArry = this.dataForm.recipients.split(",");
       this.dialogStatus = "update";
       this.dialogFormVisible = true;
       this.$nextTick(() => {
@@ -626,7 +615,8 @@ export default {
     updateData() {
       this.$refs["dataForm"].validate((valid) => {
         if (valid) {
-          updateNews(this.dataForm).then(() => {
+          this.dataForm.recipients = this.dataForm.recipientsArry.join(",");
+          updateItem(this.dataForm).then(() => {
             this.dialogFormVisible = false;
             this.$notify({
               title: "成功",
@@ -640,65 +630,25 @@ export default {
       });
     },
 
-    handleDelete(row) {
+    handleDelete(commendId, status) {
       this.$confirm("确认删除吗?", "提示", {
         confirmButtonText: "确定",
         cancelButtonText: "取消",
         type: "warning",
       })
         .then(() => {
-          deleteNews(row).then((response) => {
+          state({commendId:commendId,status:status}).then((response) => {
             this.$notify({
               title: "成功",
               message: "删除成功",
               type: "success",
               duration: 2000,
             });
-            const index = this.list.indexOf(row);
-            this.list.splice(index, 1);
+            this.getList();
           });
         })
         .catch(() => { });
     },
-    delAll() {
-      this.$confirm("确认删除吗?", "提示", {
-        confirmButtonText: "确定",
-        cancelButtonText: "取消",
-        type: "warning",
-      })
-        .then(() => {
-          debugger;
-          const length = this.multipleSelection.length;
-
-          if (length > 0) {
-            for (let i = 0; i < length; i++) {
-              this.delarr.push(this.multipleSelection[i].id);
-            }
-            const newsIds = this.delarr.join(",");
-            deleteAllNews({ newsId: newsIds })
-              .then(() => {
-                this.$notify({
-                  title: "成功",
-                  message: "删除成功",
-                  type: "success",
-                  duration: 2000,
-                });
-                this.getList();
-              })
-              .catch(() => { });
-          } else {
-            this.$notify({
-              title: "警告提示",
-              message: "请选择要删除的信息!",
-              type: "warning",
-            });
-          }
-        })
-        .catch(() => { });
-    },
-    handleSelectionChange(val) {
-      this.multipleSelection = val;
-    },
   },
 };
 </script>