♻️ Refactoring code. 格式化代码

This commit is contained in:
aeizzz 2023-03-02 14:10:13 +08:00
parent 71cac61b59
commit 24f4177d8c
13 changed files with 31 additions and 372 deletions

View File

@ -2,7 +2,7 @@
<div class="head-container">
<el-input v-model="searchName" :placeholder="placeholder" clearable style="margin-bottom: 20px"
@change="getDeptTree" />
<el-tree :data="state.List" :props="props" :expand-on-click-node="false" ref="deptTreeRef"
<el-tree :data="state.List" :props="props.props" :expand-on-click-node="false" ref="deptTreeRef"
:loading="state.localLoading" node-key="id" highlight-current default-expand-all @node-click="handleNodeClick" />
</div>
</template>
@ -13,7 +13,7 @@ import { onMounted, reactive, ref, unref } from "vue";
const emit = defineEmits(['search', 'nodeClick'])
const { placeholder, props, query, loading } = defineProps({
const props = defineProps({
props: {
type: Object,
default: () => {
@ -40,7 +40,7 @@ const { placeholder, props, query, loading } = defineProps({
const state = reactive({
List: [],
localLoading: loading
localLoading: props.loading
})
@ -51,9 +51,9 @@ const handleNodeClick = (item: any) => {
}
const getDeptTree = () => {
if (query instanceof Function) {
if (props.query instanceof Function) {
state.localLoading = true
const result = query(unref(searchName))
const result = props.query(unref(searchName))
if ((typeof result === 'object' || typeof result === 'function') && typeof result.then === 'function') {
result.then((r: any) => {
state.List = r.data

View File

@ -74,7 +74,6 @@
<div class="vue3-cron-div">
<el-button
class="language"
type="text"
@click="state.language = state.language === 'en' ? 'cn' : 'en'"
>{{ state.language === 'en' ? 'cn' : 'en' }}</el-button
>

View File

@ -87,7 +87,7 @@
}
}
},
setup(props,context){
setup(props){
const {mode,captchaType} = toRefs(props)
const { proxy } = getCurrentInstance();
let secretKey = ref(''), //ase

View File

@ -101,8 +101,8 @@ export default {
}
}
},
setup(props, context) {
const {mode, captchaType, vSpace, imgSize, barSize, type, blockSize, explain} = toRefs(props)
setup(props) {
const {mode, captchaType, type, blockSize, explain} = toRefs(props)
const { proxy } = getCurrentInstance();
let secretKey = ref(''), //ase
passFlag = ref(''), //
@ -198,10 +198,11 @@ export default {
//
function start(e) {
e = e || window.event
let x = null
if (!e.touches) { //PC
var x = e.clientX;
x = e.clientX;
} else { //
var x = e.touches[0].pageX;
x = e.touches[0].pageX;
}
startLeft.value = Math.floor(x - barArea.value.getBoundingClientRect().left);
startMoveTime.value = +new Date(); //

View File

@ -7,9 +7,9 @@
<img class="material-img" :src="item.url" />
<p class="item-name">{{ item.name }}</p>
<el-row class="ope-row">
<el-button size="mini" type="success" @click="selectMaterial(item)"
<el-button type="success" @click="selectMaterial(item)"
>选择
<el-icon class="el-icon--right"><el-icon-circle-check /></el-icon>
<el-icon class="el-icon--right"></el-icon>
</el-button>
</el-row>
</div>
@ -23,10 +23,7 @@
<el-table v-loading="state.loading" :data="state.dataList">
<el-table-column label="编号" align="center" prop="mediaId" />
<el-table-column label="文件名" align="center" prop="name" />
<el-table-column label="语音" align="center">
<template v-slot="scope">
<wx-voice-player :url="scope.row.url" />
</template>
<el-table-column label="语音" align="center" prop="url">
</el-table-column>
<el-table-column
label="上传时间"
@ -46,8 +43,6 @@
>
<template v-slot="scope">
<el-button
size="mini"
type="text"
icon="el-icon-circle-plus"
@click="selectMaterial(scope.row)"
>选择</el-button
@ -86,8 +81,6 @@
>
<template v-slot="scope">
<el-button
size="mini"
type="text"
icon="el-icon-circle-plus"
@click="selectMaterial(scope.row)"
>选择</el-button
@ -105,10 +98,8 @@
<div v-if="item.content && item.content.newsItem" class="waterfall-item" :key="item.id">
<wx-news :obj-data="item.content.newsItem"></wx-news>
<el-row class="ope-row">
<el-button size="mini" type="success" @click="selectMaterial(item)">
选择<el-icon class="el-icon--right"
><el-icon-circle-check
/></el-icon>
<el-button type="success" @click="selectMaterial(item)">
选择<el-icon class="el-icon--right"/>
</el-button>
</el-row>
</div>

View File

@ -1,9 +1,9 @@
<template>
<el-tabs v-model="props.objData.repType" type="border-card" @tab-click="handleClick" style="width: 100%;">
<el-tabs v-model="objData.repType" type="border-card" @tab-click="handleClick" style="width: 100%;">
<el-tab-pane name="text" label="text">
<template #label><i class="el-icon-document"></i> 文本</template>
<el-input
v-model="props.objData.repContent"
v-model="objData.repContent"
type="textarea"
:rows="5"
placeholder="请输入内容">
@ -23,7 +23,7 @@
<div v-if="!objData.repUrl" style="width: 100%;">
<el-row style="text-align: center">
<el-col :span="12" class="col-select">
<el-button type="success" @click="openMaterial({type: 'image',accountId: props.objData.appId})">素材库选择<i class="el-icon-circle-check el-icon--right"></i>
<el-button type="success" @click="openMaterial({type: 'image',accountId: props.objData.appId})">素材库选择<i class="fansel-icon--right"></i>
</el-button>
</el-col>
<el-col :span="12" class="col-add">
@ -49,7 +49,7 @@
<div v-if="!objData.repName" style="width: 100%;">
<el-row style="text-align: center">
<el-col :span="12" class="col-select">
<el-button type="success" @click="openMaterial({type: 'voice',accountId: props.objData.appId})">素材库选择<i class="el-icon-circle-check el-icon--right"></i>
<el-button type="success" @click="openMaterial({type: 'voice',accountId: props.objData.appId})">素材库选择<i class="fansel-icon--right"></i>
</el-button>
</el-col>
<el-col :span="12" class="col-add">
@ -71,7 +71,7 @@
</div>
<div style="margin: 20px 0;"></div>
<div style="text-align: center">
<el-button type="success" @click="openMaterial({type: 'video',accountId: props.objData.appId})">素材库选择<i class="el-icon-circle-check el-icon--right"></i>
<el-button type="success" @click="openMaterial({type: 'video',accountId: props.objData.appId})">素材库选择<i class="fansel-icon--right"></i>
</el-button>
</div>
</el-row>
@ -90,7 +90,7 @@
<div v-if="!objData.content" style="width: 100%;">
<el-row style="text-align: center">
<el-col :span="24" class="col-select2">
<el-button type="success" @click="openMaterial({type: 'news',accountId: props.objData.appId})">素材库选择<i class="el-icon-circle-check el-icon--right"></i>
<el-button type="success" @click="openMaterial({type: 'news',accountId: props.objData.appId})">素材库选择<i class="fansel-icon--right"></i>
</el-button>
</el-col>
</el-row>
@ -113,6 +113,7 @@ const WxFileUpload = defineAsyncComponent(() => import("/@/components/wechart/fi
const WxNews = defineAsyncComponent(() => import("/@/components/wechart/wx-news/index.vue"))
const props = defineProps({
objData: {
type: Object,
@ -154,13 +155,12 @@ const openMaterial = (data: any) => {
const dialogNewsRef = ref()
const selectMaterial = (item, appId) => {
const tempObjItem = {
let tempObjItem = {
repType: '',
repMediaId: '',
media_id: '',
content: ''
}
} as any
tempObjItem.repType = props.objData.repType
tempObjItem.repMediaId = item.mediaId
tempObjItem.media_id = item.mediaId
@ -192,7 +192,7 @@ const selectMaterial = (item, appId) => {
}
}
const handelImage = (response, file, fileList) => {
const handelImage = (response) => {
if (response.code === 0) {
const item = response.data
selectMaterial(item,props.objData.appId)

View File

@ -1,6 +1,5 @@
import axios, { AxiosInstance, InternalAxiosRequestConfig } from 'axios';
import errorCode from './errorCode'
import { ElMessage, ElMessageBox } from 'element-plus';
import { ElMessageBox } from 'element-plus';
import { Session, Local } from '/@/utils/storage';
import qs from 'qs';
@ -20,6 +19,7 @@ const service: AxiosInstance = axios.create({
service.interceptors.request.use((config: InternalAxiosRequestConfig) => {
// get查询参数序列化
if (config.method === 'get') {
// @ts-ignore
config.paramsSerializer = (params: any) => {
return qs.stringify(params, { arrayFormat: 'repeat' })
}
@ -51,7 +51,6 @@ service.interceptors.response.use((res: any) => {
return res.data;
}, error => {
const status = Number(error.response.status) || 200
const message = error.response.data.msg || errorCode[status] || errorCode['default']
if (status === 424) {
ElMessageBox.confirm('令牌状态已过期,请点击重新登录', '系统提示', {
confirmButtonText: '重新登录',

View File

@ -153,7 +153,6 @@ const handleClick = (tab: TabsPaneContext) => {
}
}
const emit = defineEmits(['refreshDataList'])
const visible = ref(false)
const sortable = ref() as any

View File

@ -24,7 +24,6 @@
<script setup lang="ts" name="preview">
import { useGeneratorPreviewApi } from '/@/api/gen/table';
import { handleTree } from '/@/utils/other';
import {validatePhone} from "/@/api/admin/user";
const visible = ref(false)
// ======== ========

View File

@ -29,16 +29,12 @@
<el-table-column label="操作" prop="action" show-overflow-tooltip>
<template #default="scope">
<el-button
type="text"
icon="el-icon-edit"
size="small"
plain
@click="handleEdit(scope.row)">编辑
</el-button>
<el-button
type="text"
icon="el-icon-delete"
size="small"
plain
@click="handleDel(scope.row)">删除
</el-button>
@ -71,16 +67,12 @@
<el-table-column label="操作" prop="action" show-overflow-tooltip>
<template #default="scope">
<el-button
type="text"
icon="el-icon-edit"
size="small"
plain
@click="handleEdit(scope.row)">编辑
</el-button>
<el-button
type="text"
icon="el-icon-delete"
size="small"
plain
@click="handleDel(scope.row)">删除
</el-button>
@ -115,16 +107,12 @@
<el-table-column label="操作" prop="action" show-overflow-tooltip>
<template #default="scope">
<el-button
type="text"
icon="el-icon-edit"
size="small"
plain
@click="handleEdit(scope.row)">编辑
</el-button>
<el-button
type="text"
icon="el-icon-delete"
size="small"
plain
@click="handleDel(scope.row)">删除
</el-button>

View File

@ -1,315 +0,0 @@
<template>
<el-dialog :title="form.id ? $t('common.editBtn') : $t('common.addBtn')" v-model="visible"
:close-on-click-modal="false" draggable>
<el-form ref="dataFormRef" :model="form" :rules="dataRules" formDialogRef label-width="90px" v-loading="loading">
<el-row :gutter="24">
<el-col :span="24" class="mb20">
<el-form-item :label="t('wx-fans-msg.appName')" prop="appName">
<el-input v-model="form.appName" :placeholder="t('wx-fans-msg.inputAppNameTip')"/>
</el-form-item>
</el-col>
<el-col :span="24" class="mb20">
<el-form-item :label="t('wx-fans-msg.appLogo')" prop="appLogo">
<el-input v-model="form.appLogo" :placeholder="t('wx-fans-msg.inputAppLogoTip')"/>
</el-form-item>
</el-col>
<el-col :span="24" class="mb20">
<el-form-item :label="t('wx-fans-msg.wxUserId')" prop="wxUserId">
<el-input v-model="form.wxUserId" :placeholder="t('wx-fans-msg.inputWxUserIdTip')"/>
</el-form-item>
</el-col>
<el-col :span="24" class="mb20">
<el-form-item :label="t('wx-fans-msg.nickName')" prop="nickName">
<el-input v-model="form.nickName" :placeholder="t('wx-fans-msg.inputNickNameTip')"/>
</el-form-item>
</el-col>
<el-col :span="24" class="mb20">
<el-form-item :label="t('wx-fans-msg.headimgUrl')" prop="headimgUrl">
<el-input v-model="form.headimgUrl" :placeholder="t('wx-fans-msg.inputHeadimgUrlTip')"/>
</el-form-item>
</el-col>
<el-col :span="24" class="mb20">
<el-form-item :label="t('wx-fans-msg.type')" prop="type">
<el-radio-group v-model="form.type">
<el-radio label="消息分类" border>消息分类</el-radio>
</el-radio-group>
</el-form-item>
</el-col>
<el-col :span="24" class="mb20">
<el-form-item :label="t('wx-fans-msg.repType')" prop="repType">
<el-radio-group v-model="form.repType">
<el-radio :label="item.value" v-for="(item, index) in repType" border :key="index">{{ item.label }}
</el-radio>
</el-radio-group>
</el-form-item>
</el-col>
<el-col :span="24" class="mb20">
<el-form-item :label="t('wx-fans-msg.repEvent')" prop="repEvent">
<el-radio-group v-model="form.repEvent">
<el-radio label="事件类型" border>事件类型</el-radio>
</el-radio-group>
</el-form-item>
</el-col>
<el-col :span="24" class="mb20">
<el-form-item :label="t('wx-fans-msg.repContent')" prop="repContent">
<el-input type="textarea" v-model="form.repContent" :placeholder="t('wx-fans-msg.inputRepContentTip')"/>
</el-form-item>
</el-col>
<el-col :span="24" class="mb20">
<el-form-item :label="t('wx-fans-msg.repMediaId')" prop="repMediaId">
<el-input v-model="form.repMediaId" :placeholder="t('wx-fans-msg.inputRepMediaIdTip')"/>
</el-form-item>
</el-col>
<el-col :span="24" class="mb20">
<el-form-item :label="t('wx-fans-msg.repName')" prop="repName">
<el-input v-model="form.repName" :placeholder="t('wx-fans-msg.inputRepNameTip')"/>
</el-form-item>
</el-col>
<el-col :span="24" class="mb20">
<el-form-item :label="t('wx-fans-msg.repDesc')" prop="repDesc">
<el-input v-model="form.repDesc" :placeholder="t('wx-fans-msg.inputRepDescTip')"/>
</el-form-item>
</el-col>
<el-col :span="24" class="mb20">
<el-form-item :label="t('wx-fans-msg.repUrl')" prop="repUrl">
<el-input v-model="form.repUrl" :placeholder="t('wx-fans-msg.inputRepUrlTip')"/>
</el-form-item>
</el-col>
<el-col :span="24" class="mb20">
<el-form-item :label="t('wx-fans-msg.repHqUrl')" prop="repHqUrl">
<el-input v-model="form.repHqUrl" :placeholder="t('wx-fans-msg.inputRepHqUrlTip')"/>
</el-form-item>
</el-col>
<el-col :span="24" class="mb20">
<el-form-item :label="t('wx-fans-msg.content')" prop="content">
<el-input v-model="form.content" :placeholder="t('wx-fans-msg.inputContentTip')"/>
</el-form-item>
</el-col>
<el-col :span="24" class="mb20">
<el-form-item :label="t('wx-fans-msg.repThumbMediaId')" prop="repThumbMediaId">
<el-input v-model="form.repThumbMediaId" :placeholder="t('wx-fans-msg.inputRepThumbMediaIdTip')"/>
</el-form-item>
</el-col>
<el-col :span="24" class="mb20">
<el-form-item :label="t('wx-fans-msg.repThumbUrl')" prop="repThumbUrl">
<el-input v-model="form.repThumbUrl" :placeholder="t('wx-fans-msg.inputRepThumbUrlTip')"/>
</el-form-item>
</el-col>
<el-col :span="24" class="mb20">
<el-form-item :label="t('wx-fans-msg.repLocationX')" prop="repLocationX">
<el-input v-model="form.repLocationX" :placeholder="t('wx-fans-msg.inputRepLocationXTip')"/>
</el-form-item>
</el-col>
<el-col :span="24" class="mb20">
<el-form-item :label="t('wx-fans-msg.repLocationY')" prop="repLocationY">
<el-input v-model="form.repLocationY" :placeholder="t('wx-fans-msg.inputRepLocationYTip')"/>
</el-form-item>
</el-col>
<el-col :span="24" class="mb20">
<el-form-item :label="t('wx-fans-msg.repScale')" prop="repScale">
<el-input v-model="form.repScale" :placeholder="t('wx-fans-msg.inputRepScaleTip')"/>
</el-form-item>
</el-col>
<el-col :span="24" class="mb20">
<el-form-item :label="t('wx-fans-msg.readFlag')" prop="readFlag">
<el-radio-group v-model="form.readFlag">
<el-radio :label="item.value" v-for="(item, index) in response_type" border :key="index">{{ item.label }}
</el-radio>
</el-radio-group>
</el-form-item>
</el-col>
<el-col :span="24" class="mb20">
<el-form-item :label="t('wx-fans-msg.appId')" prop="appId">
<el-input v-model="form.appId" :placeholder="t('wx-fans-msg.inputAppIdTip')"/>
</el-form-item>
</el-col>
<el-col :span="24" class="mb20">
<el-form-item :label="t('wx-fans-msg.openId')" prop="openId">
<el-input v-model="form.openId" :placeholder="t('wx-fans-msg.inputOpenIdTip')"/>
</el-form-item>
</el-col>
<el-col :span="24" class="mb20">
<el-form-item :label="t('wx-fans-msg.remark')" prop="remark">
<el-input v-model="form.remark" :placeholder="t('wx-fans-msg.inputRemarkTip')"/>
</el-form-item>
</el-col>
<el-col :span="24" class="mb20">
<el-form-item :label="t('wx-fans-msg.delFlag')" prop="delFlag">
<el-input v-model="form.delFlag" :placeholder="t('wx-fans-msg.inputDelFlagTip')"/>
</el-form-item>
</el-col>
<el-col :span="24" class="mb20">
<el-form-item :label="t('wx-fans-msg.createTime')" prop="createTime">
<el-input v-model="form.createTime" :placeholder="t('wx-fans-msg.inputCreateTimeTip')"/>
</el-form-item>
</el-col>
<el-col :span="24" class="mb20">
<el-form-item :label="t('wx-fans-msg.updateTime')" prop="updateTime">
<el-input v-model="form.updateTime" :placeholder="t('wx-fans-msg.inputUpdateTimeTip')"/>
</el-form-item>
</el-col>
<el-col :span="24" class="mb20">
<el-form-item :label="t('wx-fans-msg.tenantId')" prop="tenantId">
<el-input v-model="form.tenantId" :placeholder="t('wx-fans-msg.inputTenantIdTip')"/>
</el-form-item>
</el-col>
</el-row>
</el-form>
<template #footer>
<span class="dialog-footer">
<el-button @click="visible = false">{{ $t('common.cancelButtonText') }}</el-button>
<el-button type="primary" @click="onSubmit">{{ $t('common.confirmButtonText') }}</el-button>
</span>
</template>
</el-drawer>
</template>
<script setup lang="ts" name="WxMsgDialog">
// /
import { useDict } from '/@/hooks/dict';
const emit = defineEmits(['refresh']);
import { useMessage } from "/@/hooks/message";
import { getObj, addObj, putObj } from '/@/api/mp/wx-fans-msg'
import { useI18n } from "vue-i18n"
import { rule } from '/@/utils/validate';
const { t } = useI18n();
//
const dataFormRef = ref();
const visible = ref(false)
const loading = ref(false)
//
const { response_type } = useDict('response_type')
//
const form = reactive({
id: '',
appName: '',
appLogo: '',
wxUserId: '',
nickName: '',
headimgUrl: '',
type: '',
repType: '',
repEvent: '',
repContent: '',
repMediaId: '',
repName: '',
repDesc: '',
repUrl: '',
repHqUrl: '',
content: '',
repThumbMediaId: '',
repThumbUrl: '',
repLocationX: '',
repLocationY: '',
repScale: '',
readFlag: '',
appId: '',
openId: '',
remark: '',
delFlag: '',
createTime: '',
updateTime: '',
tenantId: '',
});
//
const dataRules = ref({
})
//
const openDialog = (id: string) => {
visible.value = true
form.id = ''
//
if (dataFormRef.value) {
dataFormRef.value.resetFields()
}
// wxMsg
if (id) {
form.id = id
getwxMsgData(id)
}
};
//
const onSubmit = () => {
dataFormRef.value.validate((valid: boolean) => {
if (!valid) {
return false
}
//
if (form.id) {
loading.value = true
putObj(form).then(() => {
useMessage().success(t('common.editSuccessText'))
visible.value = false //
emit('refresh')
}).catch((err: any) => {
useMessage().error(err.msg)
}).finally(() => {
loading.value = false
})
} else {
loading.value = true
addObj(form).then(() => {
useMessage().success(t('common.addSuccessText'))
visible.value = false //
emit('refresh')
}).catch((err: any) => {
useMessage().error(err.msg)
}).finally(() => {
loading.value = false
})
}
})
}
//
const getwxMsgData = (id: string) => {
//
loading.value = true
getObj(id).then((res: any) => {
Object.assign(form, res.data)
}).finally(() => {
loading.value = false
})
};
//
defineExpose({
openDialog
});
</script>

View File

@ -154,7 +154,6 @@ const isActiveAddNews = ref(0)
const articlesMediaId = ref()
const openDialog = (data: any,item?: any,mediaId?: any,type: any = 'add') => {
console.log(data,item,mediaId,type,'data,item,mediaId,type')
//
accountId.value = data.accountId
uploadData.appId = data.accountId
@ -187,8 +186,7 @@ const openMaterial = () => {
})
}
const handleImageChange = (response, file, fileList) => {
console.log(response, file, fileList,'response, file, fileList')
const handleImageChange = (response) => {
articlesAdd.value[isActiveAddNews.value].thumbMediaId = response.data.mediaId
articlesAdd.value[isActiveAddNews.value].thumbUrl = response.data.url
}

View File

@ -104,7 +104,7 @@
<el-row>
<el-col :span="24" style="text-align: center">
<el-button type="success" @click="openMaterial">
素材库选择<i class="el-icon-circle-check el-icon--right"></i>
素材库选择<i class="fansel-icon--right"></i>
</el-button>
</el-col>
</el-row>