tag and installer&updater use english

This commit is contained in:
xiaomlove
2022-03-08 15:08:56 +08:00
parent a56891132d
commit 718a57539d
67 changed files with 1149 additions and 104 deletions
+3
View File
@@ -49,6 +49,9 @@
<el-menu-item-group>
<el-menu-item index="/medal"><i class="el-icon-menu" />Medal</el-menu-item>
</el-menu-item-group>
<el-menu-item-group>
<el-menu-item index="/tag"><i class="el-icon-menu" />Tag</el-menu-item>
</el-menu-item-group>
<el-menu-item-group>
<el-menu-item index="/setting"><i class="el-icon-menu" />Setting</el-menu-item>
</el-menu-item-group>
+10
View File
@@ -89,6 +89,16 @@ const router = createRouter({
name: 'setting',
component: () => import('../views/setting/index.vue')
},
{
path: '/tag',
name: 'tag',
component: () => import('../views/tag/index.vue')
},
{
path: '/tag-form',
name: 'tag-form',
component: () => import('../views/tag/form.vue')
},
]
})
+15
View File
@@ -157,6 +157,21 @@ const api = {
storeUserMedal: (params) => {
return axios.post('user-medals', params);
},
listTag: (params = {}) => {
return axios.get('tags', {params: params});
},
storeTag: (params = {}) => {
return axios.post('tags', params);
},
updateTag: (id, params = {}) => {
return axios.put('tags/' + id, params);
},
getTag: (id) => {
return axios.get('tags/' + id);
},
deleteTag: (id) => {
return axios.delete('tags/' + id);
},
}
+2
View File
@@ -51,4 +51,6 @@ export const pathMap = {
'setting': "Setting",
'medal': 'Medal',
'medal-form': 'Medal form',
'tag': 'Tag',
'tag-form': 'Tag form'
}
+1 -1
View File
@@ -6,7 +6,7 @@
</div>
<div class="right">
<el-button type="primary" size="small" icon="Plus" @click="handleAdd">Add</el-button>
<el-button type="primary" icon="Plus" @click="handleAdd">Add</el-button>
</div>
</div>
</template>
+1 -1
View File
@@ -6,7 +6,7 @@
</div>
<div class="right">
<el-button type="primary" size="small" icon="Plus" @click="handleAdd">Add</el-button>
<el-button type="primary" icon="Plus" @click="handleAdd">Add</el-button>
</div>
</div>
</template>
+109
View File
@@ -0,0 +1,109 @@
<template>
<div>
<el-row>
<el-col :span="12">
<el-form :model="formData" :rules="rules" ref="formRef" label-width="200px" class="formData">
<el-form-item label="Name" prop="name">
<el-input v-model="formData.name" placeholder=""></el-input>
</el-form-item>
<el-form-item label="Color" prop="color">
<el-input v-model="formData.color" placeholder=""></el-input>
</el-form-item>
<el-form-item label="Priority" prop="priority">
<el-input v-model="formData.priority" placeholder="The higher the value, the higher the ranking"></el-input>
</el-form-item>
<el-form-item>
<el-button type="primary" @click="submitAdd()">Submit</el-button>
</el-form-item>
</el-form>
</el-col>
</el-row>
</div>
</template>
<script>
import { reactive, ref, toRefs, onMounted, onBeforeUnmount, getCurrentInstance } from 'vue'
import { ElMessage } from 'element-plus'
import { useRoute, useRouter } from 'vue-router'
import { localGet } from '../../utils'
import api from "../../utils/api";
export default {
name: 'TagForm',
setup() {
const { proxy } = getCurrentInstance()
console.log('proxy', proxy)
const formRef = ref(null)
const route = useRoute()
const router = useRouter()
const { id } = route.query
const state = reactive({
token: localGet('token') || '',
id: id,
list: [],
formData: {
color: '',
name: '',
priority: ''
},
rules: {
color: [
{ required: 'true', }
],
name: [
{ required: 'true', }
],
},
})
onMounted( async () => {
if (id) {
api.getTag(id).then(res => {
state.formData.name = res.data.name
state.formData.color = res.data.color
state.formData.priority = res.data.priority
})
}
})
onBeforeUnmount(() => {
})
const submitAdd = () => {
formRef.value.validate(async (vaild) => {
if (vaild) {
let params = state.formData;
console.log(params)
if (id) {
await api.updateTag(id, params)
} else {
await api.storeTag(params)
}
await router.push({name: 'tag'})
}
})
}
const listTag = async () => {
let res = await api.listTag()
state.list = res.data
}
const getTag = async (id) => {
let res = await api.getTag(id)
console.log(res)
}
return {
...toRefs(state),
formRef,
submitAdd,
}
}
}
</script>
<style scoped>
</style>
+160
View File
@@ -0,0 +1,160 @@
<template>
<el-card class="">
<template #header>
<div class="nexus-table-header">
<div class="left">
</div>
<div class="right">
<el-button type="primary" icon="Plus" @click="handleAdd">Add</el-button>
</div>
</div>
</template>
<el-table
v-loading="loading"
ref="multipleTable"
:data="tableData"
tooltip-effect="dark"
@selection-change="handleSelectionChange">
<el-table-column
type="selection"
width="55">
</el-table-column>
<el-table-column
prop="id"
label="Id"
width="50"
>
</el-table-column>
<el-table-column
prop="name"
label="Name"
></el-table-column>
<el-table-column
prop="color"
label="Color"
>
</el-table-column>
<el-table-column
prop="priority"
label="Priority"
>
</el-table-column>
<el-table-column
prop="updated_at"
label="Updated at"
></el-table-column>
<el-table-column
prop="created_at"
label="Created at"
></el-table-column>
<el-table-column
label="Action"
width="120"
>
<template #default="scope">
<a style="cursor: pointer; margin-right: 10px" @click="handleEdit(scope.row.id)">Edit</a>
<el-popconfirm
title="Confirm Delete ?"
@confirm="handleDelete(scope.row.id)"
>
<template #reference>
<a style="cursor: pointer">Delete</a>
</template>
</el-popconfirm>
</template>
</el-table-column>
</el-table>
<!--总数超过一页再展示分页器-->
<el-pagination
background
layout="prev, pager, next"
:total="total"
:page-size="perPage"
:current-page="currentPage"
@current-change="changePage"
/>
</el-card>
</template>
<script>
import { onMounted, reactive, ref, toRefs } from 'vue'
import { ElMessage } from 'element-plus'
import { useRouter } from 'vue-router'
import api from '../../utils/api'
import { useTable, renderTableData } from '../../utils/table'
export default {
name: 'TagTable',
setup() {
const multipleTable = ref(null)
const router = useRouter()
const state = useTable()
let extraData = reactive({
agentAllows: []
});
onMounted(() => {
fetchTableData()
})
const fetchTableData = async () => {
state.loading = true
let res = await api.listTag(state.query)
renderTableData(res, state)
state.loading = false
}
const handleAdd = () => {
router.push({ name: 'tag-form' })
}
const handleEdit = (id) => {
router.push({ path: '/tag-form', query: { id } })
}
const handleDelete = async (id) => {
let res = await api.deleteTag(id)
ElMessage.success(res.msg)
state.query.page = 1;
await fetchTableData()
}
const handleSelectionChange = (val) => {
state.multipleSelection = val
}
const changePage = (val) => {
state.query.page = val
fetchTableData()
}
const handleReset = () => {
state.query.family_id = '';
}
return {
...toRefs(state),
extraData,
multipleTable,
handleSelectionChange,
handleAdd,
handleEdit,
handleDelete,
fetchTableData,
changePage,
handleReset,
}
}
}
</script>
<style scoped>
.swiper-container {
min-height: 100%;
}
.el-card.is-always-shadow {
min-height: 100%!important;
}
</style>