index.vue 10 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357
  1. <template>
  2. <div class="app-container">
  3. <div class="header">
  4. <el-form :inline="true" :model="formInline1">
  5. <el-form-item label="玩家Id">
  6. <el-input v-model="formInline1.playerId" placeholder="请输入玩家ID" @keyup.enter="onSubmit" />
  7. </el-form-item>
  8. <el-form-item>
  9. <el-button type="primary" @click="onSubmit">查询</el-button>
  10. </el-form-item>
  11. <el-form-item>
  12. <el-button type="primary" @click="cpPlayer">复制账号</el-button>
  13. </el-form-item>
  14. </el-form>
  15. </div>
  16. <div class="footer">
  17. <el-collapse v-model="collapse" accordion>
  18. <el-collapse-item name="0" title="基本信息" :class="{ 'active-item': collapse === '0' }">
  19. <playerInfo :ruleForm="ruleForm"></playerInfo>
  20. </el-collapse-item>
  21. <el-collapse-item name="1" title="道具信息">
  22. <itemInfo :its="its" :ruleForm="ruleForm" :callback="addItem"></itemInfo>
  23. </el-collapse-item>
  24. <el-collapse-item name="2" title="关卡信息">
  25. <msaInfo :msa="msa" :ruleForm="ruleForm" :callback="handleCustomEvent" :callback1="resetMsa"></msaInfo>
  26. </el-collapse-item>
  27. <el-collapse-item name="3" title="英雄信息">
  28. <heroInfo :hrs="hrs" :ruleForm="ruleForm" :callback="hrsEvent" :callback1="hrsEditEvent"></heroInfo>
  29. </el-collapse-item>
  30. <el-collapse-item name="4" title="图纸信息">
  31. <bpInfo :bps="bps" :ruleForm="ruleForm" :callback="bpsEvent" :callback1="bpsEditEvent"></bpInfo>
  32. </el-collapse-item>
  33. <el-collapse-item name="5" title="遗物信息">
  34. <relicInfo :rls="rls" :ruleForm="ruleForm" :callback="rdmEvent" :callback1="relicEvent"></relicInfo>
  35. </el-collapse-item>
  36. </el-collapse>
  37. </div>
  38. </div>
  39. <!-- 模态框 -->
  40. <el-dialog title="复制账号" v-model="showModal" @close="closeModal" width="350px">
  41. <el-form-item label="复制玩家">
  42. <el-input v-model="fromPlayerID" placeholder="输入复制玩家ID" :maxlength="8"
  43. style="width: 200px;position: relative; left: 20px;" />
  44. </el-form-item>
  45. <el-form-item label="目标玩家">
  46. <el-input v-model="toPlayerID" placeholder="输入目标玩家ID" :maxlength="8"
  47. style="width: 200px;position: relative; left: 20px;" />
  48. </el-form-item>
  49. <span slot="footer" class="dialog-footer" style="position: absolute; right: 20px; bottom: 10px;">
  50. <el-button type="primary" @click="savePlayer">复制</el-button>
  51. <el-button @click="closeModal">关闭</el-button>
  52. </span>
  53. </el-dialog>
  54. </template>
  55. <script lang="ts" setup name="inline-table">
  56. import playerInfo from "@/components/player/playerInfo/index.vue"
  57. import itemInfo from "@/components/player/itemInfo/index.vue"
  58. import msaInfo from "@/components/player/msaInfo/index.vue"
  59. import heroInfo from "@/components/player/heroInfo/index.vue"
  60. import bpInfo from "@/components/player/BPInfo/index.vue"
  61. import relicInfo from "@/components/player/relicInfo/index.vue"
  62. import { reactive, ref, toRefs, defineEmits } from 'vue'
  63. import { FormInstance, ElMessage } from 'element-plus'
  64. import playerApi from '@/api/player'
  65. import { formatDate } from '../../common/date'
  66. const formInline1 = reactive({
  67. playerId: ''
  68. })
  69. const fromPlayerID = ref("");
  70. const toPlayerID = ref("");
  71. const collapse = ref('0');
  72. const showModal = ref<Boolean>(false);
  73. const ruleForm = reactive({
  74. id: '',
  75. aId: '',
  76. nm: '',
  77. gId: '',
  78. lv: '',
  79. vLv: '',
  80. tmp: '',
  81. atu: '',
  82. gld: '',
  83. btm: '',
  84. btn: '',
  85. stm: '',
  86. stn: '',
  87. aby: '',
  88. ctm: '',
  89. llTm: '',
  90. luTm: ''
  91. });
  92. const its = reactive([]);
  93. const msa = reactive([]);
  94. const hrs = reactive([]);
  95. const bps = reactive([]);
  96. const rls = reactive([]);
  97. const onSubmit = async () => {
  98. let resp = playerApi.queryPlayerInfo(formInline1);
  99. let data = (await resp).data.result;
  100. let jsonData = JSON.parse(data);
  101. if (data != '未找到此角色') {
  102. ruleForm.id = jsonData.id;
  103. ruleForm.aId = jsonData.aId;
  104. ruleForm.nm = jsonData.nm;
  105. ruleForm.gId = jsonData.gId;
  106. ruleForm.lv = jsonData.lv;
  107. ruleForm.vLv = jsonData.vLv;
  108. ruleForm.tmp = jsonData.tmp == null ? 0 : jsonData.tmp;
  109. ruleForm.atu = jsonData.atu;
  110. ruleForm.gld = jsonData.gld == null ? '无' : jsonData.gld;
  111. ruleForm.btm = jsonData.btm == null ? '无' : formatDate(new Date(jsonData.btm * 1000), 'yyyy-MM-dd hh:mm:ss');
  112. ruleForm.btn = jsonData.btn == null ? '无' : jsonData.btn;
  113. ruleForm.stm = jsonData.stm == null ? '无' : formatDate(new Date(jsonData.stm * 1000), 'yyyy-MM-dd hh:mm:ss');
  114. ruleForm.stn = jsonData.stn == null ? '无' : jsonData.stn;
  115. ruleForm.aby = jsonData.aby == null ? 0 : jsonData.aby;
  116. ruleForm.ctm = jsonData.ctm == null ? '无' : formatDate(new Date(jsonData.ctm * 1000), 'yyyy-MM-dd hh:mm:ss');
  117. ruleForm.llTm = jsonData.llTm == null ? '无' : formatDate(new Date(jsonData.llTm * 1000), 'yyyy-MM-dd hh:mm:ss');
  118. if (jsonData.luTm == 0) {
  119. ruleForm.luTm = '在线'
  120. } else {
  121. ruleForm.luTm = jsonData.luTm == null ? '无' : formatDate(new Date(jsonData.luTm * 1000), 'yyyy-MM-dd hh:mm:ss');
  122. }
  123. const itemKeys = Object.keys(jsonData.its);
  124. for (let i = 0; i < itemKeys.length; i++) {
  125. const json = jsonData.its[itemKeys[i]];
  126. json['editing'] = false;
  127. json['tempCount'] = json['count'];
  128. json['id'] = itemKeys[i];
  129. }
  130. console.log(jsonData);
  131. its.splice(0, its.length);
  132. its.push(...Object.values(jsonData.its));
  133. msa.splice(0, msa.length);
  134. msa.push(...Object.values(jsonData.msa));
  135. hrs.splice(0, hrs.length);
  136. hrs.push(...Object.values(jsonData.hrs));
  137. const bluePrintKeys = Object.keys(jsonData.bps);
  138. for (let i = 0; i < bluePrintKeys.length; i++) {
  139. const json = jsonData.bps[bluePrintKeys[i]];
  140. json['id'] = bluePrintKeys[i];
  141. }
  142. bps.splice(0, bps.length);
  143. bps.push(...Object.values(jsonData.bps));
  144. const relicKeys = Object.keys(jsonData.rls);
  145. for (let i = 0; i < relicKeys.length; i++) {
  146. const json = jsonData.rls[relicKeys[i]];
  147. const rat = json['rat'];
  148. const ratValue = rat[Object.keys(rat) + '']
  149. json['rat'] = Object.keys(rat)[0];
  150. json['ratValue'] = ratValue;
  151. json['id'] = relicKeys[i];
  152. }
  153. rls.splice(0, rls.length);
  154. rls.push(...Object.values(jsonData.rls));
  155. console.log(rls);
  156. }
  157. }
  158. const cpPlayer = () => {
  159. showModal.value = true;
  160. }
  161. const savePlayer = () => {
  162. let data = {
  163. fromPlayerID: fromPlayerID.value,
  164. toPlayerID: toPlayerID.value,
  165. srvI:ruleForm.gId
  166. }
  167. playerApi.copeRole(data).then((resp) => {
  168. let msg = resp.data.result;
  169. if (msg === '角色拷贝成功') {
  170. ElMessage({
  171. message: "角色拷贝成功",
  172. type: 'success',
  173. duration: 3000
  174. });
  175. showModal.value = false;
  176. } else {
  177. ElMessage({
  178. message: "角色拷贝失败",
  179. type: 'error',
  180. duration: 3000
  181. });
  182. }
  183. });
  184. }
  185. const closeModal = () => {
  186. fromPlayerID.value = "";
  187. toPlayerID.value = "";
  188. showModal.value = false;
  189. }
  190. const handleCustomEvent = (data: string) => {
  191. msa.push(JSON.parse(data));
  192. }
  193. const addItem = (data: any) => {
  194. let jsonData = JSON.parse(data);
  195. const count = jsonData['count'];
  196. jsonData['count'] = count['$numberLong']
  197. jsonData['tempCount'] = count['$numberLong']
  198. its.push(jsonData);
  199. }
  200. const bpsEvent = (data: string) => {
  201. bps.push(JSON.parse(data));
  202. }
  203. const bpsEditEvent = (data: any) => {
  204. let regex = new RegExp(data.heroID, "i");
  205. let index = hrs.map((hero: { id: string }, index) => {
  206. if (regex.test(hero.id)) {
  207. return index;
  208. }
  209. }).filter(index => index !== undefined);
  210. hrs[index[0]].lv = data.heroLv;
  211. hrs[index[0]].alv = data.heroAlv;
  212. }
  213. const rdmEvent = (data: any) => {
  214. let regex = new RegExp(data.rlsId, "i");
  215. let index = rls.map((relic: { id: string }, index) => {
  216. if (regex.test(relic.id)) {
  217. return index;
  218. }
  219. }).filter(index => index !== undefined);
  220. rls[index[0]].rdm[data.rdmIndex].typ = data.rdmType;
  221. rls[index[0]].rdm[data.rdmIndex].val = data.rdmVal;
  222. rls[index[0]].rdm[data.rdmIndex].sTs = data.rdmsTs;
  223. }
  224. const relicEvent = (data: any) => {
  225. for (let index = 0; index < data.length; index++) {
  226. const element = JSON.parse(data[index]);
  227. let regex = new RegExp(element.id, "i");
  228. let index2 = rls.map((relic: { id: string }, index2) => {
  229. if (regex.test(relic.id)) {
  230. return index2;
  231. }
  232. }).filter(index2 => index2 !== undefined);
  233. const rat = element['rat'];
  234. const ratValue = rat[Object.keys(rat) + '']
  235. element['rat'] = Object.keys(rat)[0];
  236. element['ratValue'] = ratValue;
  237. const exp = element['exp'];
  238. element['exp'] = exp['$numberLong']
  239. if (index2.length > 0) {
  240. rls[index2[0]] = element;
  241. } else {
  242. rls.push(element);
  243. }
  244. }
  245. }
  246. const hrsEvent = (data: string) => {
  247. hrs.push(JSON.parse(data));
  248. }
  249. const hrsEditEvent = (data: any) => {
  250. let regex = new RegExp(data.heroID, "i");
  251. let index = hrs.map((hero: { id: string }, index) => {
  252. if (regex.test(hero.id)) {
  253. return index;
  254. }
  255. }).filter(index => index !== undefined);
  256. hrs[index[0]].lv = data.heroLv;
  257. hrs[index[0]].alv = data.heroAlv;
  258. }
  259. const resetMsa = (data: any) => {
  260. let regex = new RegExp(data.id, "i");
  261. let index = msa.map((stage: { id: string }, index) => {
  262. if (regex.test(stage.id)) {
  263. return index;
  264. }
  265. }).filter(index => index !== undefined);
  266. msa[index[0]].msIc = !data.msIc;
  267. msa[index[0]].msLc = data.msLc;
  268. msa[index[0]].msi = data.msi;
  269. }
  270. const submitForm = async (formEl: FormInstance | undefined) => {
  271. console.log('--FORM---', ruleForm)
  272. if (!formEl) return
  273. }
  274. const resetForm = (formEl: FormInstance | undefined) => {
  275. if (!formEl) return
  276. formEl.resetFields()
  277. }
  278. </script>
  279. <style scoped lang="scss">
  280. .header {
  281. display: flex;
  282. padding: 16px 16px 0px 16px;
  283. margin-bottom: 16px;
  284. border-radius: 4px;
  285. background: white;
  286. box-shadow: 0 0 12px rgb(0 0 0 / 5%);
  287. }
  288. .footer {
  289. flex: 1;
  290. display: flex;
  291. padding: 16px;
  292. flex-direction: column;
  293. border-radius: 4px;
  294. overflow: hidden;
  295. background: white;
  296. box-shadow: 0 0 12px rgb(0 0 0 / 5%);
  297. }
  298. </style>