Browse Source

勋章管理修改

sunlupeng 1 year ago
parent
commit
fe5ddd809c

+ 44 - 7
src/api/medalList.js

@@ -2,24 +2,61 @@ import request from '@/utils/request'
 
 export function list(query) {
   return request({
-    url: '/mall-order/page',
-    method: 'post',
+    url: '/medal-type/list',
+    method: 'get',
     params:query
   })
 }
 
-export function updateItem(query) {
+export function createItem(data) {
+  return request({
+    url: '/medal-type/add',
+    method: 'post',
+    data
+  })
+}
+
+export function updateItem(data) {
   return request({
-    url: '/mall-welfare/welfare/edit',
+    url: '/medal-type/edit',
     method: 'post',
-    data:query
+    data
   })
 }
 
-export function stateItem(query) {
+export function deleteitem(query) {
   return request({
-    url: 'mall-welfare/modify/status',
+    url: '/medal-type/remove',
     method: 'post',
     params:query
   })
 }
+
+export function dataList(query) {
+  return request({
+    url: '/medal-level/list',
+    method: 'get',
+    params:query
+  })
+}
+export function dataAdd(data) {
+  return request({
+    url: '/medal-level/add',
+    method: 'post',
+    data
+  })
+}
+export function dataEdit(data) {
+  return request({
+    url: '/medal-level/edit',
+    method: 'post',
+    data
+  })
+}
+export function dataRemove(query) {
+  return request({
+    url: '/medal-level/remove',
+    method: 'post',
+    params:query
+  })
+}

+ 1 - 0
src/permission.js

@@ -45,6 +45,7 @@ const myRoles = [
   'rankingList',
   'medalManage', 
   'medalList', 
+  'medalDataList', 
   'commendManage', 
   'commendList',
   'commendDataList', 

+ 2 - 1
src/router/index.js

@@ -178,7 +178,8 @@ export const asyncRouterMap = [
       icon: 'xunzhang'
     },
     children: [
-      { path: 'medalList', component: _import('medalManage/medalList'), name: 'medalList', meta: { title: '勋章列表', icon: 'xunzhang', noCache: true }},
+      { path: 'medalList', component: _import('medalManage/medalList'), name: 'medalList', meta: { title: '勋章列表', noCache: true }},
+      { path: 'medalDataList/:id', component: _import('medalManage/medalDataList'), name: 'medalDataList', meta: { title: '勋章等级列表', noCache: false, hideTag: true, hidden: true }},
     ]
   },
   {

+ 416 - 0
src/views/medalManage/medalDataList.vue

@@ -0,0 +1,416 @@
+<template>
+    <div class="app-container calendar-list-container">
+
+        <!-- 查询和其他操作 -->
+        <div class="filter-container">
+            <el-input clearable class="filter-item" style="width: 200px;" placeholder="勋章级别"
+                v-model="listQuery.levelName"></el-input>
+            <el-select v-model="listQuery.status" clearable placeholder="状态" style="top: -4px;width: 200px;">
+                <el-option :key="item.dictValue" v-for="item in statusList" :label="item.dictLabel" :value="item.dictValue">
+                </el-option>
+            </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"
+            element-loading-text="正在查询中。。。" border fit highlight-current-row>
+            <el-table-column type="selection" width="55px"> </el-table-column>
+            <el-table-column align="center" min-width="60px" label="勋章级别" prop="levelName">
+            </el-table-column>
+            <el-table-column align="center" min-width="100px" label="级别值" prop="levelPoint">
+            </el-table-column>
+            <el-table-column align="center" min-width="60px" label="图片" prop="imgUrl">
+                <template slot-scope="props">
+                    <img v-if="props.row.imgUrl" style="width: 50px; height: 50px;" :src="props.row.imgUrl">
+                </template>
+            </el-table-column>
+            <el-table-column align="center" min-width="100px" label="状态" prop="statusName">
+            </el-table-column>
+       
+        <el-table-column align="center" min-width="100px" label="创建时间" prop="createTime">
+        </el-table-column>
+            <el-table-column align="center" label="操作" width="240px" class-name="small-padding fixed-width">
+                <template slot-scope="scope">
+                    <el-button type="primary" size="small" @click="handleUpdate(scope.row, false)">编辑</el-button>
+
+                    <el-button type="danger" size="small" @click="handleDelete(scope.row)">删除</el-button>
+                </template>
+            </el-table-column>
+        </el-table>
+
+        <!-- 分页 -->
+        <div class="pagination-container">
+            <el-pagination background @size-change="handleSizeChange" @current-change="handleCurrentChange"
+                :current-page="listQuery.page" :page-sizes="[10, 20, 30, 50]" :page-size="listQuery.limit"
+                layout="total, sizes, prev, pager, next, jumper" :total="total">
+            </el-pagination>
+        </div>
+
+        <!-- 添加或修改对话框 -->
+        <el-dialog
+        :close-on-click-modal="false"
+        :title="textMap[dialogStatus]"
+        :visible.sync="dialogFormVisible"
+        width="40%"
+      >
+        <el-form :rules="rules" ref="dataForm" :model="dataForm" status-icon label-position="left" label-width="80px" style='width: 700px; margin-left:50px;'>
+            <el-form-item  label="勋章类型" prop="medalType">
+              <el-input disabled style="width: 300px" v-model="dataForm.medalType"></el-input>
+            </el-form-item>
+            <el-form-item label="勋章级别" prop="levelName">
+                    <el-input style="width: 300px" v-model="dataForm.levelName"></el-input>
+                </el-form-item>
+                <el-form-item label="级别值" prop="levelPoint">
+                    <el-input-number :precision="0" :step="1" v-model="dataForm.levelPoint"></el-input-number>
+                </el-form-item>
+            <el-form-item style="width: 500px" label="商品图片" prop="imgUrl">
+                    <el-upload :limit="1" :action="fileImgUrl" list-type="picture-card" :file-list="dataForm.images"
+                            :on-success="handleGallerySucess" :on-exceed="handleExceed" :before-upload="uploadBannerImg"
+                            :on-remove="handleRemove">
+                            <i class="el-icon-plus"></i>
+                        </el-upload>
+                </el-form-item>
+              <el-form-item label="状态" prop="status">
+                    <el-radio-group v-model="dataForm.status">
+                        <el-radio v-for="item in statusList" :key="item.dictValue" :label="item.dictValue">{{ item.dictLabel
+                        }}</el-radio>
+                    </el-radio-group>
+                </el-form-item>
+        </el-form>
+        <div slot="footer" class="dialog-footer">
+          <el-button @click="dialogFormVisible = false">取消</el-button>
+          <el-button v-if="dialogStatus == 'create'" type="primary" @click="createData">确定</el-button>
+          <el-button v-else type="primary" @click="updateData">确定</el-button>
+        </div>
+      </el-dialog>
+
+    </div>
+</template>
+  
+<style>
+.demo-table-expand {
+    font-size: 0;
+}
+
+.demo-table-expand label {
+    width: 200px;
+    color: #99a9bf;
+}
+
+.demo-table-expand .el-form-item {
+    margin-right: 0;
+    margin-bottom: 0;
+}
+</style>
+  
+<script>
+import { dataList, dataAdd, dataEdit, dataRemove } from "@/api/medalList";
+import { dataTypeList } from "@/api/public";
+import waves from "@/directive/waves"; // 水波纹指令
+import Tinymce from '@/components/Tinymce'
+
+export default {
+    components: { Tinymce },
+    directives: { waves },
+    data() {
+        return {
+            levelList: [],
+            statusList: [],
+            list: [
+            ],
+            delarr: [],
+            multipleSelection: [],
+            total: 0,
+            listLoading: false,
+            listQuery: {
+                page: 1,
+                limit: 10,
+                medalType:this.$route.params.id,
+                levelName: '',
+                status: '',
+            },
+            dataForm: {
+                medalType: undefined,
+                levelName: undefined,
+                levelPoint: undefined,
+                imgUrl: undefined,
+                status: undefined,
+                images: [],
+            },
+            dialogFormVisible: false,
+            dialogStatus: '',
+            textMap: {
+                update: "编辑",
+                create: "创建",
+            },
+            imageUrl: undefined,
+            rules: {
+                medalType: [{ required: true, message: "勋章类型不能为空", trigger: "blur" }],
+                levelName: [{ required: true, message: "勋章级别不能为空", trigger: "blur" }],
+                levelPoint: [{ required: true, message: "级别值型不能为空", trigger: "blur" }],
+                imgUrl: [{ required: true, message: "请上传图片", trigger: "blur" }],
+                status: [{ required: true, message: "请选择勋章状态", trigger: "blur" }],
+            },
+            fileImgUrl: this.upLoadUrl,
+        }
+    },
+    created() {
+        this.getLevelList();
+        this.getStatusList();
+        this.getList();
+    },
+    methods: {
+        handleRemove(file, fileList) {
+            console.log(file, fileList);
+            if(fileList.length>0){
+                let images = [];
+                for (let i in fileList) {
+                    let response = fileList[i].response;
+                    let url = response.data.url;
+                    images.push(url);
+                    this.dataForm.imgUrl = images.join(",");
+                }
+            }else{
+                this.dataForm.imgUrl = '';
+            }
+            
+        },
+        uploadBannerImg(file) {
+            const isJPGs = file.type === "image/jpeg";
+            console.log(isJPGs);
+        },
+        handleExceed(files, fileList) {
+            this.$message.warning(
+                `当前限制选择 1 个文件,本次选择了 ${files.length} 个文件!,共选择了 ${files.length + fileList.length
+                } 个文件`
+            );
+        },
+        handleGallerySucess(res, file, fileList) {
+            this.dataForm.imgUrl = ""; // 清空画廊图片数组
+
+            let images = [];
+            for (let i in fileList) {
+                let response = fileList[i].response;
+                if (response.errno && response.errno != "0") {
+                    this.$message.error("该图片上传失败,已被移除,请重新上传!");
+                    // 上传失败移除该 file 对象
+                    fileList.splice(i, 1);
+                } else {
+                    let url = response.data.url;
+                    images.push(url);
+                }
+            }
+
+            this.dataForm.imgUrl = images.join(",");
+        },
+        getStatusList() {
+            dataTypeList({ dictType: 'medal_status_option_select' }).then(response => {
+                this.statusList = response.data.data;
+            }).catch(() => { });
+        },
+        getLevelList() {
+            dataTypeList({ dictType: 'medal_level' }).then(response => {
+                this.levelList = response.data.data;
+            }).catch(() => { });
+        },
+        resetForm() {
+            this.dataForm = {
+                medalType: undefined,
+                levelName: undefined,
+                levelPoint: undefined,
+                imgUrl: undefined,
+                status: undefined,
+                images: [],
+            };
+        },
+        handleCreate() {
+            this.resetForm();
+            this.dataForm.medalType = this.$route.params.id;
+            this.dialogFormVisible = true;
+            this.dialogStatus = "create";
+            this.$nextTick(() => {
+                this.$refs["dataForm"].clearValidate();
+            });
+        },
+        createData() {
+            this.$refs["dataForm"].validate((valid) => {
+                if (valid) {
+                    dataAdd(this.dataForm)
+                        .then(() => {
+                            this.getList();
+                            this.dialogFormVisible = false;
+
+                            this.$notify({
+                                title: "成功",
+                                message: "创建成功",
+                                type: "success",
+                                duration: 2000,
+                            });
+                            this.getList()
+                        })
+                }
+            });
+        },
+        getList() {
+            this.listLoading = true
+            dataList(this.listQuery).then(response => {
+                this.list = response.data.data.items
+                this.total = response.data.data.total
+                this.listLoading = false
+            }).catch(() => {
+                this.list = []
+                this.total = 0
+                this.listLoading = false
+            })
+        },
+
+        handleFilter() {
+            this.listQuery.page = 1
+            this.getList()
+        },
+
+        handleSizeChange(val) {
+            this.listQuery.limit = val
+            this.getList()
+        },
+
+        handleCurrentChange(val) {
+            this.listQuery.page = val
+            this.getList()
+        },
+
+        handleUpdate(row) {
+            this.dataForm = Object.assign({}, row);
+            if (this.dataForm.imgUrl) {
+                let images = this.dataForm.imgUrl.split(",");
+                this.dataForm.images = [];
+                for (let i in images) {
+                    let url = images[i];
+                    let name = "image_" + i;
+
+                    this.dataForm.images.push({
+                        name: name,
+                        url: url,
+                        response: { error: "0", data: { url: url } },
+                    });
+                }
+            }
+            this.dialogStatus = 'update'
+            this.dialogFormVisible = true
+            this.$nextTick(() => {
+                this.$refs['dataForm'].clearValidate()
+            })
+        },
+
+        updateData() {
+            this.$refs['dataForm'].validate((valid) => {
+                if (valid) {
+                    dataEdit(this.dataForm).then(() => {
+                        this.dialogFormVisible = false
+                        this.$notify({
+                            title: '成功',
+                            message: '更新成功',
+                            type: 'success',
+                            duration: 2000
+                        })
+                        this.getList()
+                    })
+
+                }
+            })
+        },
+
+        handleDelete(row) {
+
+            this.$confirm('确认删除吗?', '提示', {
+                confirmButtonText: '确定',
+                cancelButtonText: '取消',
+                type: 'warning'
+            }).then(() => {
+                dataRemove({ ids:row.id}).then(response => {
+                    this.$notify({
+                        title: '成功',
+                        message: '删除成功',
+                        type: 'success',
+                        duration: 2000
+                    })
+                    const index = this.list.indexOf(row)
+                    this.list.splice(index, 1)
+                })
+            }).catch(() => {
+
+            })
+
+        },
+        delAll() {
+            this.$confirm("确认删除吗?", "提示", {
+                confirmButtonText: "确定",
+                cancelButtonText: "取消",
+                type: "warning",
+            })
+                .then(() => {
+                    const length = this.multipleSelection.length;
+
+                    if (length > 0) {
+                        for (let i = 0; i < length; i++) {
+                            this.delarr.push(this.multipleSelection[i].id);
+                        }
+                        const  dictCodes = this.delarr.join(",");
+                        dataRemove({  ids:  dictCodes })
+                            .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>
+<style>
+.ad-avatar-uploader .el-upload {
+    border: 1px dashed #d9d9d9;
+    border-radius: 6px;
+    cursor: pointer;
+    position: relative;
+    overflow: hidden;
+}
+
+.ad-avatar-uploader .el-upload:hover {
+    border-color: #409EFF;
+}
+
+.ad-avatar-uploader-icon {
+    font-size: 28px;
+    color: #8c939d;
+    width: 178px;
+    height: 178px;
+    line-height: 178px;
+    text-align: center;
+}
+
+.ad-avatar {
+    display: block;
+}
+</style>
+  

+ 205 - 176
src/views/medalManage/medalList.vue

@@ -2,46 +2,44 @@
     <div class="app-container calendar-list-container exchangeView">
         <!-- 查询和其他操作 -->
         <div class="filter-container">
-            <el-select v-model="listQuery.type" clearable placeholder="勋章类型" style="top: -4px;width: 200px;">
-                <el-option :key="item.type" v-for="item in typeList" :label="item.name" :value="item.type">
+            <el-input clearable class="filter-item" style="width: 200px;" placeholder="勋章名称"
+                v-model="listQuery.name"></el-input>
+            <el-input clearable class="filter-item" style="width: 200px;" placeholder="勋章类型"
+                v-model="listQuery.type"></el-input>
+            <el-select v-model="listQuery.status" clearable placeholder="状态" style="top: -4px;width: 200px;">
+                <el-option :key="item.dictValue" v-for="item in statusList" :label="item.dictLabel" :value="item.dictValue">
                 </el-option>
             </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" element-loading-text="正在查询中。。。" border fit
-            highlight-current-row>
+        <el-table size="small" :data="list" @selection-change="handleSelectionChange" 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="80px" label="勋章类型" prop="type">
-            </el-table-column>
-            <el-table-column align="center" min-width="60px" label="金">
-                <template slot-scope="props">
-                    <img style="width: 50px; height: 50px" :src="props.row.goldMedal">
-                </template>
-            </el-table-column>
-            <el-table-column align="center" min-width="60px" label="银">
-                <template slot-scope="props">
-                    <img style="width: 50px; height: 50px" :src="props.row.silverMedal">
-                </template>
+            <el-table-column align="center" min-width="80px" label="勋章名称" prop="name">
             </el-table-column>
-            <el-table-column align="center" min-width="60px" label="铜">
-                <template slot-scope="props">
-                    <img style="width: 50px; height: 50px" :src="props.row.copperMedal">
-                </template>
+            <el-table-column align="center" min-width="80px" label="勋章类型" prop="type">
+                <template slot-scope="scope">
+                <router-link :to="{name: 'medalDataList', params: { id: scope.row.type }}">
+                    <div style="color: #337ab7;cursor: pointer;">{{ scope.row.type }}</div>
+                </router-link>
+            </template>
             </el-table-column>
             <el-table-column align="center" min-width="80px" label="状态" prop="statusName">
             </el-table-column>
+            <el-table-column align="center" min-width="80px" label="排序" prop="sort">
+            </el-table-column>
             <el-table-column align="center" min-width="150px" label="创建时间" prop="createTime">
             </el-table-column>
             <el-table-column align="center" label="操作" width="240px" class-name="small-padding fixed-width">
                 <template slot-scope="scope">
                     <el-button type="primary" size="small" @click="handleUpdate(scope.row)">编辑</el-button>
-                    <el-button v-if="scope.row.status == 0" type="success" size="small"
-                        @click="changeState(scope.row.welfareId, 1)">开启</el-button>
-                    <el-button v-if="scope.row.status == 1" type="warning" size="small"
-                        @click="changeState(scope.row.welfareId, 0)">关闭</el-button>
+                    <el-button type="danger" size="small" @click="handleDelete(scope.row)">删除</el-button>
                 </template>
             </el-table-column>
         </el-table>
@@ -53,65 +51,36 @@
                 layout="total, sizes, prev, pager, next, jumper" :total="total">
             </el-pagination>
         </div>
-         <!-- 添加或修改对话框 -->
-         <el-dialog :close-on-click-modal="false" title="编辑" :visible.sync="dialogFormVisible" width="40%">
-            <el-form ref="dataForm" :model="dataForm" status-icon label-position="left" label-width="100px">
-                <el-form-item label="勋章类型">
-                    <el-input readonly v-model="dataForm.type" style="width: 330px"></el-input>
+        <!-- 添加或修改对话框 -->
+        <el-dialog
+      :close-on-click-modal="false"
+        :title="textMap[dialogStatus]"
+        :visible.sync="dialogFormVisible"
+        width="40%"
+      >
+        <el-form :rules="rules" ref="dataForm" :model="dataForm" status-icon label-position="left" label-width="80px" style='width: 700px; margin-left:50px;'>
+                <el-form-item label="勋章名称" prop="name">
+                    <el-input v-model="dataForm.name" style="width: 330px"></el-input>
+                </el-form-item>
+                <el-form-item label="勋章类型" prop="type">
+                    <el-input v-model="dataForm.type" style="width: 330px"></el-input>
+                </el-form-item>
+                <el-form-item label="状态" prop="status">
+                    <el-radio-group v-model="dataForm.status">
+                        <el-radio v-for="item in statusList" :key="item.dictValue" :label="item.dictValue">{{ item.dictLabel
+                        }}</el-radio>
+                    </el-radio-group>
+                </el-form-item>
+                <el-form-item label="排序" prop="sort">
+                    <el-input-number :precision="0" :step="1" v-model="dataForm.sort"></el-input-number>
                 </el-form-item>
-                <div style="display: flex;">
-                    <el-form-item style="width: 250px" label="默认勋章">
-                    <el-upload
-                        class="avatar-uploader"
-                        :action="fileImgUrl"
-                        :show-file-list="false"
-                        :on-success="handleMedalSuccess"
-                        :before-upload="beforeAvatarUpload">
-                        <img v-if="dataForm.medal" :src="dataForm.medal" class="avatar">
-                        <i v-else class="el-icon-plus avatar-uploader-icon"></i>
-                    </el-upload>    
-                    </el-form-item>
-                    <el-form-item style="width: 250px" label="金勋章">
-                        <el-upload
-                            class="avatar-uploader"
-                            :action="fileImgUrl"
-                            :show-file-list="false"
-                            :on-success="handleGoldMedalSuccess"
-                            :before-upload="beforeAvatarUpload">
-                            <img v-if="dataForm.goldMedal" :src="dataForm.goldMedal" class="avatar">
-                            <i v-else class="el-icon-plus avatar-uploader-icon"></i>
-                        </el-upload>    
-                    </el-form-item>
-                </div>
-                <div style="display: flex;">
-                    <el-form-item style="width: 250px" label="银勋章">
-                        <el-upload
-                            class="avatar-uploader"
-                            :action="fileImgUrl"
-                            :show-file-list="false"
-                            :on-success="handleSilverMedalSuccess"
-                            :before-upload="beforeAvatarUpload">
-                            <img v-if="dataForm.silverMedal" :src="dataForm.silverMedal" class="avatar">
-                            <i v-else class="el-icon-plus avatar-uploader-icon"></i>
-                        </el-upload>    
-                    </el-form-item>
-                    <el-form-item style="width: 250px" label="铜勋章">
-                        <el-upload
-                            class="avatar-uploader"
-                            :action="fileImgUrl"
-                            :show-file-list="false"
-                            :on-success="handleCopperMedalSuccess"
-                            :before-upload="beforeAvatarUpload">
-                            <img v-if="dataForm.copperMedal" :src="dataForm.copperMedal" class="avatar">
-                            <i v-else class="el-icon-plus avatar-uploader-icon"></i>
-                        </el-upload>    
-                    </el-form-item>
-                </div>
-                
+
+
             </el-form>
             <div slot="footer" class="dialog-footer">
                 <el-button @click="dialogFormVisible = false">取消</el-button>
-                <el-button type="primary" @click="updateData">确定</el-button>
+                <el-button v-if="dialogStatus == 'create'" type="primary" @click="createData">确定</el-button>
+          <el-button v-else type="primary" @click="updateData">确定</el-button>
             </div>
         </el-dialog>
     </div>
@@ -124,23 +93,27 @@
     cursor: pointer;
     position: relative;
     overflow: hidden;
-  }
-  .avatar-uploader .el-upload:hover {
+}
+
+.avatar-uploader .el-upload:hover {
     border-color: #409EFF;
-  }
-  .avatar-uploader-icon {
+}
+
+.avatar-uploader-icon {
     font-size: 28px;
     color: #8c939d;
     width: 80px;
     height: 80px;
     line-height: 80px;
     text-align: center;
-  }
-  .avatar {
+}
+
+.avatar {
     width: 80px;
     height: 80px;
     display: block;
-  }
+}
+
 .demo-table-expand {
     font-size: 0;
 }
@@ -157,7 +130,8 @@
 </style>
   
 <script>
-import { list, updateItem, stateItem } from "@/api/medalList";
+import { list, updateItem, createItem, deleteitem } from "@/api/medalList";
+import { dataTypeList } from "@/api/public";
 import waves from "@/directive/waves"; // 水波纹指令
 import Tinymce from '@/components/Tinymce'
 
@@ -166,114 +140,82 @@ export default {
     directives: { waves },
     data() {
         return {
-            fileImgUrl: this.upLoadUrl,
+            rules: {
+                name: [{ required: true, message: "勋章名称不能为空", trigger: "blur" }],
+                type: [{ required: true, message: "勋章名称不能为空", trigger: "blur" }],
+                status: [{ required: true, message: "请选择勋章状态", trigger: "blur" }],
+                sort: [{ required: true, message: "排序不能为空", trigger: "blur" }],
+            },
+            dialogStatus: '',
+            textMap: {
+                update: "编辑",
+                create: "创建",
+            },
             dialogFormVisible: false,
             dataForm: {
-                type:'',
-                medal:'',
-                goldMedal:'',
-                silverMedal:'',
-                copperMedal:'',
+                name: '',
+                type: '',
+                status: '',
+                sort: '',
             },
-            typeList: [
-                {
-                    type: 0,
-                    name: '当前积分'
-                },
-                {
-                    type: 1,
-                    name: '获取总积分'
-                },
-            ],
-            list: [
-                {
-                    id:'1',
-                    type:'入职年限',
-                    medal:'https://cube.elemecdn.com/3/7c/3ea6beec64369c2642b92c6726f1epng.png',
-                    goldMedal:'https://cube.elemecdn.com/3/7c/3ea6beec64369c2642b92c6726f1epng.png',
-                    silverMedal:'https://cube.elemecdn.com/3/7c/3ea6beec64369c2642b92c6726f1epng.png',
-                    copperMedal:'https://cube.elemecdn.com/3/7c/3ea6beec64369c2642b92c6726f1epng.png',
-                    status:1,
-                    statusName:'开启',
-                    createTime:'2023-4-25',
-                },
-                {
-                    id:'2',
-                    type:'入职年限',
-                    medal:'https://cube.elemecdn.com/3/7c/3ea6beec64369c2642b92c6726f1epng.png',
-                    goldMedal:'https://cube.elemecdn.com/3/7c/3ea6beec64369c2642b92c6726f1epng.png',
-                    silverMedal:'https://cube.elemecdn.com/3/7c/3ea6beec64369c2642b92c6726f1epng.png',
-                    copperMedal:'https://cube.elemecdn.com/3/7c/3ea6beec64369c2642b92c6726f1epng.png',
-                    status:0,
-                    statusName:'关闭',
-                    createTime:'2023-4-25',
-                },
-            ],
+            statusList: [],
+            list: [],
             total: 0,
             listLoading: false,
             listQuery: {
                 page: 1,
                 limit: 10,
+                name: '',
                 type: '',
-                
+                status: '',
+
             },
         }
     },
     created() {
-        // this.getList();
+        this.getStatusList();
+        this.getList();
     },
     methods: {
-        handleMedalSuccess(res,file) {
-            this.dataForm.medal = URL.createObjectURL(file.raw);
-        },
-        handleGoldMedalSuccess(res,file) {
-            this.dataForm.goldMedal = URL.createObjectURL(file.raw);
-        },
-        handleSilverMedalSuccess(res,file) {
-            this.dataForm.silverMedal = URL.createObjectURL(file.raw);
-        },
-        handleCopperMedalSuccess(res,file) {
-            this.dataForm.copperMedal = URL.createObjectURL(file.raw);
-            
-        },
-        beforeAvatarUpload(file) {
-            const isJPG = file.type === 'image/jpeg';
-            const isLt2M = file.size / 1024 / 1024 < 2;
-
-            if (!isJPG) {
-            this.$message.error('上传头像图片只能是 JPG 格式!');
-            }
-            if (!isLt2M) {
-            this.$message.error('上传头像图片大小不能超过 2MB!');
-            }
-            return isJPG && isLt2M;
+        resetForm() {
+            this.dataForm = {
+                name: '',
+                type: '',
+                status: '',
+                sort: '',
+            };
         },
-        handleUpdate(row) {
-            this.dataForm = Object.assign({}, row);
+        handleCreate() {
+            this.resetForm();
             this.dialogFormVisible = true;
+            this.dialogStatus = "create";
+            this.$nextTick(() => {
+                this.$refs["dataForm"].clearValidate();
+            });
         },
-        updateData() {
-            updateItem(this.dataForm).then(() => {
-                this.dialogFormVisible = false
-                this.$notify({
-                    title: '成功',
-                    message: '更新成功',
-                    type: 'success',
-                    duration: 2000
-                })
-                this.getList()
-            })
+        createData() {
+            this.$refs["dataForm"].validate((valid) => {
+                if (valid) {
+                    createItem(this.dataForm)
+                        .then(() => {
+                            this.getList();
+                            this.dialogFormVisible = false;
+
+                            this.$notify({
+                                title: "成功",
+                                message: "创建成功",
+                                type: "success",
+                                duration: 2000,
+                            });
+                            this.getList()
+                        })
+                }
+            });
         },
-        changeState(welfareId, index) {
-            stateItem({ welfareId: welfareId, status: index }).then(response => {
-                this.$notify({
-                    title: '成功',
-                    message: '状态修改成功',
-                    type: 'success',
-                    duration: 2000
-                })
-                this.getList()
-            })
+        getStatusList() {
+            dataTypeList({ dictType: 'medal_status_option_select' }).then(response => {
+                this.statusList = response.data.data;
+            }).catch(() => { });
         },
         getList() {
             this.listLoading = true
@@ -281,7 +223,7 @@ export default {
                 this.list = response.data.data.items
                 this.total = response.data.data.total
                 this.listLoading = false
-            }).catch(() => {})
+            }).catch(() => { })
         },
         handleFilter() {
             this.listQuery.page = 1
@@ -295,6 +237,92 @@ export default {
             this.listQuery.page = val
             this.getList()
         },
+        handleUpdate(row) {
+            this.dataForm = Object.assign({}, row);
+            this.dialogStatus = 'update'
+            this.dialogFormVisible = true
+            this.$nextTick(() => {
+                this.$refs['dataForm'].clearValidate()
+            })
+        },
+
+        updateData() {
+            this.$refs['dataForm'].validate((valid) => {
+                if (valid) {
+                    updateItem(this.dataForm).then(() => {
+                        this.dialogFormVisible = false
+                        this.$notify({
+                            title: '成功',
+                            message: '更新成功',
+                            type: 'success',
+                            duration: 2000
+                        })
+                        this.getList()
+                    })
+
+                }
+            })
+        },
+
+        handleDelete(row) {
+
+            this.$confirm('确认删除吗?', '提示', {
+                confirmButtonText: '确定',
+                cancelButtonText: '取消',
+                type: 'warning'
+            }).then(() => {
+                deleteitem({ ids: row.id }).then(response => {
+                    this.$notify({
+                        title: '成功',
+                        message: '删除成功',
+                        type: 'success',
+                        duration: 2000
+                    })
+                    this.getList()
+                })
+            }).catch(() => {
+
+            })
+
+        },
+        delAll() {
+            this.$confirm("确认删除吗?", "提示", {
+                confirmButtonText: "确定",
+                cancelButtonText: "取消",
+                type: "warning",
+            })
+                .then(() => {
+                    const length = this.multipleSelection.length;
+
+                    if (length > 0) {
+                        for (let i = 0; i < length; i++) {
+                            this.delarr.push(this.multipleSelection[i].id);
+                        }
+                        const dictIds = this.delarr.join(",");
+                        deleteitem({ ids: dictIds })
+                            .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>
@@ -323,6 +351,7 @@ export default {
 .ad-avatar {
     display: block;
 }
+
 .exchangeView .el-dialog__body {
     padding-top: 0px;
 }