Browse Source

引导更新

cm 11 months ago
parent
commit
7a625f132e
4 changed files with 284 additions and 4 deletions
  1. 8 1
      src/api/player.ts
  2. 1 1
      src/api/request.ts
  3. 248 0
      src/components/player/guidesInfo/index.vue
  4. 27 2
      src/views/player/index.vue

+ 8 - 1
src/api/player.ts

@@ -163,10 +163,17 @@ export default {
             data
         });
     },
+    delPlayerGuids(data) {
+        return request({
+            url: '/player/delGuids',
+            method: 'post',
+            data
+        });
+    },
     getSrvList() {
         return request({
             url: '/server/getSrvList',
             method: 'get'
         });
-    },
+    }
 }

+ 1 - 1
src/api/request.ts

@@ -6,7 +6,7 @@ const service = axios.create({
     // 默认请求地址,根据环境的不同可在.env 文件中进行修改
     // baseURL: import.meta.env.VUE_APP_BASE_
     // 本地地址
-    baseURL: "http://localhost:8001/api",
+    baseURL: "http://127.0.0.1:8001/api",
     // 华为云地址
     // baseURL: "http://119.3.30.56:8001/api",
     // 设置接口访问超时时间

+ 248 - 0
src/components/player/guidesInfo/index.vue

@@ -0,0 +1,248 @@
+<template>
+    <div class="container">
+        <!-- 搜索框 -->
+        <el-input v-model="search" placeholder="输入关键字" :maxlength="20" />
+        <el-button class="searchButton" @Click="tableData()" type="primary">搜索</el-button>
+    </div>
+
+    <el-table :data="tableData()" class="table-container" :border="true">
+        <el-table-column prop="group" label="引导组" align="center" />
+        <el-table-column prop="val" label="引导ID" align="center" />
+        <el-table-column label="操作" width="180" align="center">
+            <template #default="scope">
+                <el-button @click="delGuids(scope.row)" type="danger" :icon="Delete">删除引导</el-button>
+            </template>
+        </el-table-column>
+    </el-table>
+
+    <el-pagination style="margin: auto;" class="pagination-container" background layout="prev, pager, next ,total,sizes"
+        :total="state.total" @current-change="handleCurrentChange" @size-change="handleSizeChange" />
+
+    <!-- 模态框 -->
+    <el-dialog :title="dialogTitle" v-model="showModal" @close="closeModal" width="350px">
+
+        <el-form-item label="引导组">
+            <el-input v-model="itemId" placeholder="输入道具ID" :maxlength="10"
+                style="width: 200px;position: relative; left: 41.219px;" />
+        </el-form-item>
+        <el-form-item label="引导ID">
+            <el-input v-model="itemNum" placeholder="请输入道具数量" :maxlength="5"
+                style="width: 200px;position: relative; left: 28px;" />
+        </el-form-item>
+
+        <span slot="footer" class="dialog-footer" style="position: absolute; right: 20px; bottom: 10px;">
+            <el-button type="primary" @click="saveItem">保存</el-button>
+            <el-button @click="closeModal">关闭</el-button>
+        </span>
+    </el-dialog>
+</template>
+<script lang="ts" setup>
+import { ElMessageBox, ElMessage } from 'element-plus';
+import { reactive, ref, toRefs, defineComponent } from 'vue'
+import { Edit, Check, Close, Delete } from '@element-plus/icons-vue'
+import playerApi from '@/api/player'
+
+const props = defineProps({
+    guides: Array,
+    ruleForm: Object,
+    callback: {
+        type: Function,
+        required: true
+    }
+});
+
+
+let dialogTitle = ref<string>('');
+
+const showModal = ref<Boolean>(false);
+const itemId = ref("");
+const itemNum = ref<Number>(1);
+const search = ref("");
+
+const state = reactive({
+    page: 1,
+    limit: 10,
+    total: props.guides.length
+});
+
+const tableData = () => {
+    let guides: any = [];
+    if (search.value == "") {
+        state.total = props.guides.length;
+        guides = props.guides;
+    } else {
+        const regex = new RegExp(search.value, 'i');
+        guides = props.guides.filter(
+            (guids: { group: string, val: string }, index) => {
+                return regex.test(guids.group) || regex.test(guids.val);
+            }
+        );
+        state.total = guides.length;
+
+    }
+
+    return guides.filter(
+        (item, index) =>
+            index < state.page * state.limit &&
+            index >= state.limit * (state.page - 1)
+    );
+};
+
+// 分页
+// 删除引导
+const delGuids = (row: any) => {
+    ElMessageBox.confirm('确定要删除该引导吗?', '提示', {
+        confirmButtonText: '确定',
+        cancelButtonText: '取消'
+    }).then(() => {
+        let data = {
+            playerId: props.ruleForm.id,
+            guid: row.group,
+            srvId: props.ruleForm.gId
+        }
+
+        console.log(data);
+
+        let resp = playerApi.delPlayerGuids(data);
+
+        ElMessage({
+            message: "删除成功",
+            type: 'info',
+            duration: 3000
+        });
+        let index = props.guides.indexOf(row);
+        props.guides.splice(index, 1);
+    }).catch(() => { });
+}
+
+const addItem = () => {
+    dialogTitle.value = "添加道具";
+    showModal.value = true;
+}
+
+const closeModal = () => {
+    itemId.value = null;
+    itemNum.value = 1;
+    showModal.value = false;
+    dialogTitle.value = "添加图纸";
+}
+
+// 保存
+const saveItem = () => {
+    let data = {
+        playerId: props.ruleForm.id,
+        itemId: itemId.value,
+        itemNum: itemNum.value,
+        srvId: props.ruleForm.gId
+    }
+
+    // playerApi.addPlayerItem(data).then((resp) => {
+    //     let data = resp.data.result;
+
+    //     if (data === '道具添加失败' || data === '已拥有该道具') {
+    //         ElMessage({
+    //             message: data,
+    //             type: 'error',
+    //             duration: 3000
+    //         });
+    //     } else {
+    //         props.callback(data)
+    //     }
+    // });
+
+    showModal.value = false;
+}
+
+const handleCurrentChange = (e) => {
+    state.page = e;
+};
+
+const handleSizeChange = (e) => {
+    state.limit = e;
+};
+
+
+// 道具修改
+const handlEditClick = (row: any) => {
+    row.editing = true;
+    row.tempCount = row.count;
+};
+
+const handleSaveClick = (row: any) => {
+    // row.editing = false;
+
+    ElMessageBox.confirm('确定要修改道具数量吗?', '提示', {
+        confirmButtonText: '确定',
+        cancelButtonText: '取消'
+    }).then(() => {
+        row.editing = false;
+        let data = {
+            playerId: props.ruleForm.id,
+            itemId: row.id,
+            itemNum: row.tempCount,
+            srvId: props.ruleForm.gId
+        }
+
+        let resp = playerApi.editPlayerItem(data);
+
+        row.count = row.tempCount;
+        ElMessage({
+            message: "修改成功",
+            type: 'info',
+            duration: 3000
+        });
+    }).catch(() => { });
+};
+
+const handleCancelClick = (row: any) => {
+    row.editing = false;
+    row.tempCount = row.count;
+};
+</script>
+
+<style>
+.con {
+    display: flex;
+    align-items: center;
+}
+
+.input-container {
+    align-items: center;
+    width: 250px;
+}
+
+
+.searchButton {
+    margin-right: 10px;
+}
+
+.button-container {
+    position: relative;
+    left: 1%;
+    transform: translateY(-8%);
+}
+
+.container {
+    display: flex;
+    align-items: center;
+    width: 200px;
+    margin-bottom: 20px;
+}
+
+.edit-button {
+    position: absolute;
+    top: 50%;
+    left: 400px;
+    transform: translateY(-50%);
+}
+
+.table-container {
+    display: grid;
+    grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
+}
+
+.pagination-container {
+    display: flex;
+    justify-content: center;
+}
+</style>

+ 27 - 2
src/views/player/index.vue

@@ -37,6 +37,9 @@
         <el-collapse-item name="5" title="遗物信息">
           <relicInfo :rls="rls" :ruleForm="ruleForm" :callback="rdmEvent" :callback1="relicEvent"></relicInfo>
         </el-collapse-item>
+        <el-collapse-item name="6" title="引导信息">
+          <guidesInfo :guides="guides" :ruleForm="ruleForm" :callback="addGuides"></guidesInfo>
+        </el-collapse-item>
       </el-collapse>
     </div>
   </div>
@@ -63,6 +66,7 @@
 <script lang="ts" setup name="inline-table">
 import playerInfo from "@/components/player/playerInfo/index.vue"
 import itemInfo from "@/components/player/itemInfo/index.vue"
+import guidesInfo from "@/components/player/guidesInfo/index.vue"
 import msaInfo from "@/components/player/msaInfo/index.vue"
 import heroInfo from "@/components/player/heroInfo/index.vue"
 import bpInfo from "@/components/player/BPInfo/index.vue"
@@ -112,13 +116,17 @@ const bps = reactive([]);
 
 const rls = reactive([]);
 
+const guides = reactive([]);
+
 const onSubmit = async () => {
+
   let resp = playerApi.queryPlayerInfo(formInline1);
 
   let data = (await resp).data.result;
 
   let jsonData = JSON.parse(data);
   if (data != '未找到此角色') {
+
     ruleForm.id = jsonData.id;
     ruleForm.aId = jsonData.aId;
     ruleForm.nm = jsonData.nm;
@@ -142,6 +150,20 @@ const onSubmit = async () => {
     }
 
 
+    guides.splice(0, guides.length);
+    const guidesKeys = Object.keys(jsonData.pgd);
+
+    for (let i = 0; i < guidesKeys.length; i++) {
+      var json = { 'group': 0, 'val': 0 };
+      const k = jsonData.pgd[guidesKeys[i]];
+      json.group = Number(guidesKeys[i]);
+      json.val = k;
+      guides.push(json);
+    }
+
+    console.log(guides);
+
+
     const itemKeys = Object.keys(jsonData.its);
     for (let i = 0; i < itemKeys.length; i++) {
       const json = jsonData.its[itemKeys[i]];
@@ -149,7 +171,6 @@ const onSubmit = async () => {
       json['tempCount'] = json['count'];
       json['id'] = itemKeys[i];
     }
-    console.log(jsonData);
 
     its.splice(0, its.length);
     its.push(...Object.values(jsonData.its));
@@ -186,6 +207,10 @@ const onSubmit = async () => {
   }
 }
 
+const addGuides = () => {
+
+}
+
 const cpPlayer = () => {
   showModal.value = true;
 }
@@ -194,7 +219,7 @@ const savePlayer = () => {
   let data = {
     fromPlayerID: fromPlayerID.value,
     toPlayerID: toPlayerID.value,
-    srvI:ruleForm.gId
+    srvI: ruleForm.gId
   }
 
   playerApi.copeRole(data).then((resp) => {