setup版本代码优化

This commit is contained in:
piexlmax
2021-12-31 03:04:38 +08:00
parent 7fd4b1d0f5
commit 236d3c7f33
11 changed files with 80 additions and 41 deletions
-2
View File
@@ -37,10 +37,8 @@ const props = defineProps({
}
})
const path = ref(import.meta.env.VITE_BASE_API)
const token = computed(()=>store.getters['user/token'])
const showImageUrl = computed(()=>(props.imageUrl && props.imageUrl.slice(0, 4) !== 'http') ? path.value + props.imageUrl : props.imageUrl)
const beforeImageUpload = (file) => {
const isJPG = file.type === 'image/jpeg'
+4 -2
View File
@@ -116,14 +116,14 @@ export default {
<script setup>
import { ref } from 'vue'
import { Commits, Members } from '@/api/github'
const members = ref([])
const dataTimeline = ref([])
const page = ref(0)
const loadMore = () => {
page.value++
loadCommits()
}
const dataTimeline = ref([])
const loadCommits = () => {
Commits(page.value).then(({ data }) => {
data.forEach((element) => {
@@ -138,6 +138,8 @@ const loadCommits = () => {
})
})
}
const members = ref([])
const loadMembers = () => {
Members().then(({ data }) => {
members.value = data
+2 -2
View File
@@ -81,8 +81,6 @@ import { ref } from 'vue'
import { ElMessage } from 'element-plus'
import { formatDate } from '@/utils/format'
const dialogFormVisible = ref(false)
const type = ref('')
const form = ref({
customerName: '',
customerPhoneData: ''
@@ -117,6 +115,8 @@ const getTableData = async() => {
getTableData()
const dialogFormVisible = ref(false)
const type = ref('')
const updateCustomer = async(row) => {
const res = await getExaCustomer({ ID: row.ID })
type.value = 'update'
+2 -1
View File
@@ -82,7 +82,6 @@ const store = useStore()
const path = ref(import.meta.env.VITE_BASE_API)
const token = computed(() => store.getters['user/token'])
const fullscreenLoading = ref(false)
const imageUrl = ref('')
const page = ref(1)
@@ -139,6 +138,8 @@ const deleteFileFunc = async(row) => {
})
})
}
const fullscreenLoading = ref(false)
const checkFile = (file) => {
fullscreenLoading.value = true
const isJPG = file.type === 'image/jpeg'
+3
View File
@@ -222,6 +222,9 @@ const handleCurrentChange = (val) => {
// 排序
const sortChange = ({ prop, order }) => {
if (prop) {
if (prop === 'ID') {
prop = 'id'
}
searchInfo.value.orderKey = toSQLLine(prop)
searchInfo.value.desc = order === 'descending'
}
@@ -217,8 +217,6 @@ import { formatBoolean, formatDate } from '@/utils/format'
const router = useRouter()
const dialogFormVisible = ref(false)
const type = ref('')
const formData = ref({
name: null,
type: null,
@@ -306,6 +304,8 @@ const toDetile = (row) => {
})
}
const dialogFormVisible = ref(false)
const type = ref('')
const updateSysDictionaryFunc = async(row) => {
const res = await findSysDictionary({ ID: row.ID })
type.value = 'update'
@@ -133,8 +133,6 @@ import { ElMessage } from 'element-plus'
import { formatBoolean, formatDate } from '@/utils/format'
const route = useRoute()
const dialogFormVisible = ref(false)
const type = ref('')
const formData = ref({
label: null,
value: null,
@@ -212,6 +210,8 @@ const getTableData = async() => {
getTableData()
const type = ref('')
const dialogFormVisible = ref(false)
const updateSysDictionaryDetailFunc = async(row) => {
const res = await findSysDictionaryDetail({ ID: row.ID })
type.value = 'update'
@@ -173,11 +173,10 @@ const getTableData = async() => {
}
}
const deleteVisible = ref(false)
const multipleSelection = ref([])
getTableData()
const deleteVisible = ref(false)
const multipleSelection = ref([])
const handleSelectionChange = (val) => {
multipleSelection.value = val
}
-1
View File
@@ -136,7 +136,6 @@ import { setUserInfo, resetPassword } from '@/api/user.js'
import { nextTick, ref, watch } from 'vue'
import { ElMessage, ElMessageBox } from 'element-plus'
const path = ref(import.meta.env.VITE_BASE_API)
// 初始化相关
const setAuthorityOptions = (AuthorityData, optionsData) => {
AuthorityData &&