1107
This commit is contained in:
@@ -0,0 +1,77 @@
|
||||
<template>
|
||||
<view class="page-body">
|
||||
<image src="../../static/icon/icon-403.svg"></image>
|
||||
<view class="title">
|
||||
<text class="code">403</text>
|
||||
<text class="tips">抱歉,你无权访问该页面</text>
|
||||
<text class="tips">{{ errMsg }}</text>
|
||||
<text class="btn" @tap="to_index_page">返回首页</text>
|
||||
</view>
|
||||
</view>
|
||||
</template>
|
||||
|
||||
<script>
|
||||
export default {
|
||||
data() {
|
||||
return {};
|
||||
},
|
||||
onLoad(query) {
|
||||
this.errMsg = query.errMsg || ''
|
||||
},
|
||||
methods: {
|
||||
to_index_page() {
|
||||
uni.navigateTo({
|
||||
url: "/pages/index/index"
|
||||
});
|
||||
},
|
||||
}
|
||||
}
|
||||
</script>
|
||||
|
||||
<style lang="scss" scoped>
|
||||
page {
|
||||
width: 100%;
|
||||
height: 100%;
|
||||
background-color: #F5F7F9;
|
||||
}
|
||||
.page-body {
|
||||
display: flex;
|
||||
padding-top: 250rpx;
|
||||
justify-content: center;
|
||||
|
||||
.title {
|
||||
display: flex;
|
||||
flex-direction: column;
|
||||
padding-top: 120rpx;
|
||||
margin-left: 200rpx;
|
||||
}
|
||||
.code{
|
||||
margin-bottom: 24px;
|
||||
color: #515a6e;
|
||||
font-weight: 600;
|
||||
font-size: 72px;
|
||||
line-height: 72px;
|
||||
}
|
||||
.tips{
|
||||
margin-bottom: 16px;
|
||||
color: #808695;
|
||||
font-size: 20px;
|
||||
line-height: 28px;
|
||||
}
|
||||
.btn{
|
||||
display: inline-block;
|
||||
color: #fff;
|
||||
background-color: #2d8cf0;
|
||||
border-color: #2d8cf0;
|
||||
width: 200rpx;
|
||||
height: 85rpx;
|
||||
border-radius: 6rpx;
|
||||
text-align: center;
|
||||
line-height: 85rpx;
|
||||
}
|
||||
.btn:hover{
|
||||
cursor: pointer;
|
||||
background-color: #57a3f3 !important;
|
||||
}
|
||||
}
|
||||
</style>
|
||||
@@ -0,0 +1,77 @@
|
||||
<template>
|
||||
<view class="page-body">
|
||||
<image src="../../static/icon/icon-404.svg"></image>
|
||||
<view class="title">
|
||||
<text class="code">404</text>
|
||||
<text class="tips">抱歉,你访问的页面不存在</text>
|
||||
<text class="tips">{{ errMsg }}</text>
|
||||
<text class="btn" @tap="to_index_page">返回首页</text>
|
||||
</view>
|
||||
</view>
|
||||
</template>
|
||||
|
||||
<script>
|
||||
export default {
|
||||
data() {
|
||||
return {};
|
||||
},
|
||||
onLoad(query) {
|
||||
this.errMsg = query.errMsg || ''
|
||||
},
|
||||
methods: {
|
||||
to_index_page() {
|
||||
uni.navigateTo({
|
||||
url: "/pages/index/index"
|
||||
});
|
||||
},
|
||||
}
|
||||
}
|
||||
</script>
|
||||
|
||||
<style lang="scss" scoped>
|
||||
page {
|
||||
width: 100%;
|
||||
height: 100%;
|
||||
background-color: #F5F7F9;
|
||||
}
|
||||
.page-body {
|
||||
display: flex;
|
||||
padding-top: 250rpx;
|
||||
justify-content: center;
|
||||
|
||||
.title {
|
||||
display: flex;
|
||||
flex-direction: column;
|
||||
padding-top: 120rpx;
|
||||
margin-left: 200rpx;
|
||||
}
|
||||
.code{
|
||||
margin-bottom: 24px;
|
||||
color: #515a6e;
|
||||
font-weight: 600;
|
||||
font-size: 72px;
|
||||
line-height: 72px;
|
||||
}
|
||||
.tips{
|
||||
margin-bottom: 16px;
|
||||
color: #808695;
|
||||
font-size: 20px;
|
||||
line-height: 28px;
|
||||
}
|
||||
.btn{
|
||||
display: inline-block;
|
||||
color: #fff;
|
||||
background-color: #2d8cf0;
|
||||
border-color: #2d8cf0;
|
||||
width: 200rpx;
|
||||
height: 85rpx;
|
||||
border-radius: 6rpx;
|
||||
text-align: center;
|
||||
line-height: 85rpx;
|
||||
}
|
||||
.btn:hover{
|
||||
cursor: pointer;
|
||||
background-color: #57a3f3 !important;
|
||||
}
|
||||
}
|
||||
</style>
|
||||
@@ -0,0 +1,77 @@
|
||||
<template>
|
||||
<view class="page-body">
|
||||
<image src="../../static/icon/icon-500.svg"></image>
|
||||
<view class="title">
|
||||
<text class="code">500</text>
|
||||
<text class="tips">抱歉,服务器出错了</text>
|
||||
<text class="tips">{{ errMsg }}</text>
|
||||
<text class="btn" @tap="to_index_page">返回首页</text>
|
||||
</view>
|
||||
</view>
|
||||
</template>
|
||||
|
||||
<script>
|
||||
export default {
|
||||
data() {
|
||||
return {};
|
||||
},
|
||||
onLoad(query) {
|
||||
this.errMsg = query.errMsg || ''
|
||||
},
|
||||
methods: {
|
||||
to_index_page() {
|
||||
uni.navigateTo({
|
||||
url: "/pages/index/index"
|
||||
});
|
||||
},
|
||||
}
|
||||
}
|
||||
</script>
|
||||
|
||||
<style lang="scss" scoped>
|
||||
page {
|
||||
width: 100%;
|
||||
height: 100%;
|
||||
background-color: #F5F7F9;
|
||||
}
|
||||
.page-body {
|
||||
display: flex;
|
||||
padding-top: 250rpx;
|
||||
justify-content: center;
|
||||
|
||||
.title {
|
||||
display: flex;
|
||||
flex-direction: column;
|
||||
padding-top: 120rpx;
|
||||
margin-left: 200rpx;
|
||||
}
|
||||
.code{
|
||||
margin-bottom: 24px;
|
||||
color: #515a6e;
|
||||
font-weight: 600;
|
||||
font-size: 72px;
|
||||
line-height: 72px;
|
||||
}
|
||||
.tips{
|
||||
margin-bottom: 16px;
|
||||
color: #808695;
|
||||
font-size: 20px;
|
||||
line-height: 28px;
|
||||
}
|
||||
.btn{
|
||||
display: inline-block;
|
||||
color: #fff;
|
||||
background-color: #2d8cf0;
|
||||
border-color: #2d8cf0;
|
||||
width: 200rpx;
|
||||
height: 85rpx;
|
||||
border-radius: 6rpx;
|
||||
text-align: center;
|
||||
line-height: 85rpx;
|
||||
}
|
||||
.btn:hover{
|
||||
cursor: pointer;
|
||||
background-color: #57a3f3 !important;
|
||||
}
|
||||
}
|
||||
</style>
|
||||
@@ -0,0 +1,278 @@
|
||||
<template>
|
||||
<vk-data-dialog
|
||||
v-model="value.show"
|
||||
:title="page.title"
|
||||
:top="page.top"
|
||||
:width="page.width"
|
||||
:close-on-click-modal="true"
|
||||
:destroy-on-close="true"
|
||||
mode="form"
|
||||
@open="onOpen"
|
||||
@closed="onClose"
|
||||
>
|
||||
<!-- 页面主体内容开始 -->
|
||||
<vk-data-form
|
||||
ref="form1"
|
||||
v-model="form1.data"
|
||||
:form-type="value.mode"
|
||||
:rules="form1.props.rules"
|
||||
:action="form1.props.action"
|
||||
:columns="form1.props.columns"
|
||||
:loading.sync="form1.props.loading"
|
||||
:labelWidth="form1.props.labelWidth"
|
||||
:show-cancel="page.showCancel"
|
||||
:cancel-text="page.cancelText"
|
||||
:submit-text="page.submitText"
|
||||
@success="onFormSuccess"
|
||||
></vk-data-form>
|
||||
<!-- 页面主体内容结束 -->
|
||||
</vk-data-dialog>
|
||||
</template>
|
||||
|
||||
<script>
|
||||
var pageName = "";
|
||||
var vk = uni.vk; // vk实例
|
||||
var originalForms = {}; // 表单初始化数据
|
||||
var defaultFormData = {
|
||||
appid:"",
|
||||
name:"",
|
||||
title:"",
|
||||
contents:"",
|
||||
platform:[],
|
||||
platformRadio:"",
|
||||
type:"",
|
||||
version:"",
|
||||
min_uni_version:"",
|
||||
url:"",
|
||||
stable_publish:false,
|
||||
is_silently:false,
|
||||
is_mandatory:false,
|
||||
create_env:"upgrade-center",
|
||||
store_list:[],
|
||||
};
|
||||
export default {
|
||||
props: {
|
||||
value: {
|
||||
Type: Object,
|
||||
default: function() {
|
||||
return {
|
||||
show: false,
|
||||
mode: "",
|
||||
item: {
|
||||
stable_publish:""
|
||||
},
|
||||
options:{}
|
||||
};
|
||||
}
|
||||
}
|
||||
},
|
||||
data: function() {
|
||||
// 组件创建时,进行数据初始化
|
||||
return {
|
||||
page: {
|
||||
title: "标题",
|
||||
submitText: "确定",
|
||||
cancelText: "关闭",
|
||||
showCancel: true,
|
||||
top: "2vh",
|
||||
width: "900px"
|
||||
},
|
||||
form1:{
|
||||
// 表单请求数据,此处可以设置默认值
|
||||
data: defaultFormData,
|
||||
// 表单属性
|
||||
props: {
|
||||
// 表单请求地址
|
||||
action:"",
|
||||
// 表单字段显示规则
|
||||
columns:[
|
||||
{ key: "appid", title: "AppID", type: "text", disabled:true },
|
||||
{ key: "name", title: "应用名称", type: "text", disabled:true },
|
||||
{ key: "title", title: "更新标题", type: "text" },
|
||||
{
|
||||
key:"contents", title:"更新内容", type:"textarea",
|
||||
autosize:{ minRows:4, maxRows:10 },
|
||||
maxlength:2000,
|
||||
showWordLimit:true,
|
||||
},
|
||||
{
|
||||
key:"platformRadio", title:"平台", type:"radio",
|
||||
itemWidth:80,
|
||||
data:[
|
||||
{ value:"Android", label:"安卓" },
|
||||
{ value:"iOS", label:"苹果" }
|
||||
],
|
||||
showRule:"type==native_app",
|
||||
disabled:["update"]
|
||||
},
|
||||
{
|
||||
key:"platform", title:"平台", type:"checkbox",
|
||||
itemWidth:80,
|
||||
data:[
|
||||
{ value:"Android", label:"安卓" },
|
||||
{ value:"iOS", label:"苹果" }
|
||||
],
|
||||
showRule:"type==wgt",
|
||||
disabled:["update"]
|
||||
},
|
||||
{ key: "version", title: "版本号", type: "text", tips:"必须大于当前线上发行的版本号", disabled:["update"] },
|
||||
{ key: "min_uni_version", title: "原生App最低版本", type: "text", showRule:"type==wgt" },
|
||||
{ key: "url", title: "AppStore", type: "text",
|
||||
showRule:(formData)=>{
|
||||
return formData.platformRadio === "iOS" && formData.type === "native_app";
|
||||
}
|
||||
},
|
||||
{ key:"apk", title:"上传apk包", type:"file", limit:1, accept:".apk",
|
||||
showRule:(formData)=>{
|
||||
return formData.platformRadio === "Android" && formData.type === "native_app";
|
||||
},
|
||||
watch: ({ value, formData, column, index, $set }) => {
|
||||
$set("url", value);
|
||||
},
|
||||
tips:"上传apk包到当前服务空间的云存储中,上传成功后,会自动使用云存储地址填充下载链接"
|
||||
},
|
||||
{ key:"wgt", title:"上传wgt包", type:"file", limit:1, accept:".wgt",
|
||||
showRule:(formData)=>{
|
||||
return formData.type === "wgt";
|
||||
},
|
||||
watch: ({ value, formData, column, index, $set }) => {
|
||||
$set("url", value);
|
||||
},
|
||||
tips:"上传wgt包到当前服务空间的云存储中,上传成功后,会自动使用云存储地址填充下载链接"
|
||||
},
|
||||
{ key: "url", title: "下载链接", type: "text",
|
||||
showRule:(formData)=>{
|
||||
return formData.platformRadio === "Android" || formData.type === "wgt";
|
||||
}
|
||||
},
|
||||
{
|
||||
key:"store_list", title:"Android应用市场", type:"array<object>",
|
||||
showRule:(formData)=>{
|
||||
return formData.platformRadio === "Android" && formData.type === "native_app" && formData.store_list && formData.store_list.length>0 ? true : false;
|
||||
},
|
||||
rowKey:"id",
|
||||
showAdd:false,
|
||||
showClear:false,
|
||||
showSort:true,
|
||||
// 新增一行时,该行的默认值
|
||||
defaultValue:{
|
||||
|
||||
},
|
||||
rightBtns:['delete'],
|
||||
// 每行每个字段对应的渲染规则
|
||||
columns:[
|
||||
{ key:"enable", title:"是否启用", type:"switch", width:80 },
|
||||
{
|
||||
key:"name", title:"商店名称", type:"text", minWidth:180,
|
||||
disabled: true
|
||||
},
|
||||
{
|
||||
key:"scheme", title:"Scheme", type:"text", minWidth:280,
|
||||
disabled: true
|
||||
},
|
||||
]
|
||||
},
|
||||
{ key:"is_silently", title:"静默更新", type:"switch", activeValue:true, inactiveValue:false, showRule:"type==wgt" },
|
||||
{ key:"is_mandatory", title:"强制更新", type:"switch", activeValue:true, inactiveValue:false },
|
||||
{ key:"stable_publish", title:"上线发行", type:"switch", activeValue:true, inactiveValue:false,
|
||||
disabled: (formData)=>{
|
||||
return this.value.item.stable_publish && this.value.mode === "update";
|
||||
}
|
||||
}
|
||||
],
|
||||
// 表单验证规则
|
||||
rules:{
|
||||
appid: [
|
||||
// 必填
|
||||
{ required: true, message: "appid不能为空", trigger: ['blur','change'] }
|
||||
],
|
||||
contents: [
|
||||
// 必填
|
||||
{ required: true, message: "更新内容不能为空", trigger: ['blur','change'] }
|
||||
],
|
||||
platform: [
|
||||
// 必填
|
||||
{ required: true, message: "平台不能为空", trigger: ['blur','change'] }
|
||||
],
|
||||
platformRadio: [
|
||||
// 必填
|
||||
{ required: true, message: "平台不能为空", trigger: ['blur','change'] }
|
||||
],
|
||||
version: [
|
||||
// 必填
|
||||
{ required: true, message: "版本号不能为空", trigger: ['blur','change'] },
|
||||
{ validator: vk.pubfn.validator("version"), message: '版本号格式必须为:xx.xx.xx(3个数字组成,数字范围1-99,0-99,0-99) 如1.0.1 不可以是1.0.01', trigger: 'blur' }
|
||||
],
|
||||
min_uni_version: [
|
||||
// 必填
|
||||
{ required: true, message: "最低版本号不能为空", trigger: ['blur','change'] },
|
||||
{ validator: vk.pubfn.validator("version"), message: '版本号格式必须为:xx.xx.xx(3个数字组成,数字范围1-99,0-99,0-99) 如1.0.1 不可以是1.0.01', trigger: 'blur' }
|
||||
],
|
||||
url: [
|
||||
// 必填
|
||||
{ required: true, message: "链接不能为空", trigger: ['blur','change'] }
|
||||
],
|
||||
},
|
||||
// add 代表添加 update 代表修改
|
||||
formType:"",
|
||||
// 左侧label的宽度
|
||||
labelWidth: "140px",
|
||||
}
|
||||
},
|
||||
};
|
||||
},
|
||||
mounted() {
|
||||
this.init();
|
||||
},
|
||||
methods: {
|
||||
// 初始化
|
||||
init() {
|
||||
let { value } = this;
|
||||
this.$emit("input", value);
|
||||
originalForms["form1"] = vk.pubfn.copyObject(this.form1);
|
||||
},
|
||||
// 监听 - 页面打开
|
||||
onOpen() {
|
||||
let { value={} } = this;
|
||||
let { item={} } = value;
|
||||
// 每次打开时,重新设置表单的值 = value.item 的值,item通过 vk.pubfn.openForm('表单名',{ item:{ _id:"1" } }) 传递值
|
||||
if(value.mode === "update"){
|
||||
this.form1.props.action = "admin/system/app-upgrade-center/sys/addUpdate";
|
||||
this.page.title = pageName + "修改";
|
||||
this.page.submitText = "修改";
|
||||
if (item.type === "native_app") {
|
||||
item.platformRadio = item.platform[0];
|
||||
}
|
||||
this.form1.data = vk.pubfn.objectAssign(vk.pubfn.copyObject(defaultFormData), vk.pubfn.copyObject(item));
|
||||
}else{
|
||||
this.form1.props.action = "admin/system/app-upgrade-center/sys/addUpdate";
|
||||
this.page.title = pageName + "添加";
|
||||
this.page.submitText = "添加";
|
||||
this.form1.data = vk.pubfn.objectAssign(vk.pubfn.copyObject(defaultFormData), vk.pubfn.copyObject(item));
|
||||
}
|
||||
},
|
||||
// 监听 - 页面关闭
|
||||
onClose() {
|
||||
this.resetForm();
|
||||
},
|
||||
// 监听 - 提交成功后
|
||||
onFormSuccess() {
|
||||
this.value.show = false; // 关闭页面
|
||||
this.$emit("success");
|
||||
},
|
||||
// 表单重置
|
||||
resetForm(){
|
||||
vk.pubfn.resetForm(originalForms, this);
|
||||
},
|
||||
},
|
||||
watch: {
|
||||
|
||||
},
|
||||
// 计算属性
|
||||
computed: {
|
||||
|
||||
}
|
||||
};
|
||||
</script>
|
||||
|
||||
<style lang="scss" scoped></style>
|
||||
@@ -0,0 +1,305 @@
|
||||
<template>
|
||||
<view class="page-body" v-loading="loading">
|
||||
<!-- 页面内容开始 -->
|
||||
|
||||
<!-- 表格搜索组件开始 -->
|
||||
<vk-data-table-query
|
||||
v-model="queryForm1.formData"
|
||||
:columns="queryForm1.columns"
|
||||
:main-columns="['appid','title','type','stable_publish']"
|
||||
@search="search"
|
||||
></vk-data-table-query>
|
||||
<!-- 表格搜索组件结束 -->
|
||||
|
||||
<!-- 自定义按钮区域开始 -->
|
||||
<view>
|
||||
<el-row>
|
||||
<el-dropdown placement="bottom-start" @command="addBtn">
|
||||
<el-button type="success" size="small" icon="el-icon-circle-plus-outline" :disabled="!queryForm1.formData.appid">添加</el-button>
|
||||
<el-dropdown-menu slot="dropdown">
|
||||
<el-dropdown-item command="native_app">原生App安装包</el-dropdown-item>
|
||||
<el-dropdown-item command="wgt">wgt资源包</el-dropdown-item>
|
||||
</el-dropdown-menu>
|
||||
</el-dropdown>
|
||||
|
||||
|
||||
<!-- 批量操作 -->
|
||||
<!-- <el-dropdown v-if="table1.multipleSelection" :split-button="false" trigger="click" @command="batchBtn">
|
||||
<el-button type="danger" size="small" style="margin-left: 20rpx;"
|
||||
:disabled="table1.multipleSelection.length === 0"
|
||||
>
|
||||
批量操作<i class="el-icon-arrow-down el-icon--right"></i>
|
||||
</el-button>
|
||||
<el-dropdown-menu slot="dropdown">
|
||||
<el-dropdown-item :command="1">批量操作1</el-dropdown-item>
|
||||
<el-dropdown-item :command="2">批量操作2</el-dropdown-item>
|
||||
</el-dropdown-menu>
|
||||
</el-dropdown> -->
|
||||
</el-row>
|
||||
</view>
|
||||
<!-- 自定义按钮区域结束 -->
|
||||
|
||||
<!-- 表格组件开始 -->
|
||||
<vk-data-table
|
||||
ref="table1"
|
||||
:action="table1.action"
|
||||
:columns="table1.columns"
|
||||
:query-form-param="queryForm1"
|
||||
:right-btns="['detail_auto','update','delete']"
|
||||
:selection="false"
|
||||
:row-no="true"
|
||||
:pagination="true"
|
||||
:auto-action="false"
|
||||
@update="updateBtn"
|
||||
@delete="deleteBtn"
|
||||
@current-change="currentChange"
|
||||
@selection-change="selectionChange"
|
||||
></vk-data-table>
|
||||
<!-- 表格组件结束 -->
|
||||
|
||||
<!-- 添加或编辑 -->
|
||||
<addUpdate v-model="formDatas.addUpdate" @success="refresh"></addUpdate>
|
||||
|
||||
<!-- 页面内容结束 -->
|
||||
</view>
|
||||
</template>
|
||||
|
||||
<script>
|
||||
var that; // 当前页面对象
|
||||
var vk = uni.vk; // vk实例
|
||||
var originalForms = {}; // 表单初始化数据
|
||||
|
||||
import addUpdate from './form/addUpdate.vue'
|
||||
export default {
|
||||
components:{
|
||||
addUpdate,
|
||||
},
|
||||
data() {
|
||||
// 页面数据变量
|
||||
return {
|
||||
appList:[],
|
||||
// 页面是否请求中或加载中
|
||||
loading:false,
|
||||
// init请求返回的数据
|
||||
data:{
|
||||
|
||||
},
|
||||
// 表格相关开始 -----------------------------------------------------------
|
||||
table1:{
|
||||
// 表格数据请求地址
|
||||
action:"admin/system/app-upgrade-center/sys/getList",
|
||||
// 表格字段显示规则
|
||||
columns:[
|
||||
{ key:"appid", title:"AppID", type:"text", width:120 },
|
||||
{ key:"title", title:"更新标题", type:"text", width:120 },
|
||||
{
|
||||
key: "type", title: "安装包类型", type: "tag", width: 140, size: "small",
|
||||
data:[
|
||||
{ value:"native_app", label:"原生App安装包", tagType:"primary", effect:"light" },
|
||||
{ value:"wgt", label:"Wgt资源包", tagType:"success", effect:"light" }
|
||||
]
|
||||
},
|
||||
{
|
||||
key:"platform", title:"平台", type:"checkbox", width:100, align:"left",
|
||||
itemWidth:80,
|
||||
data:[
|
||||
{ value:"Android", label:"安卓" },
|
||||
{ value:"iOS", label:"苹果" }
|
||||
],
|
||||
},
|
||||
{ key:"store_list", title:"已上架应用市场", type:"text", width:120, align:"left",
|
||||
formatter: (val=[], row, column, index) => {
|
||||
let str = "";
|
||||
val.map((item, index) => {
|
||||
str += item.name;
|
||||
if (index !== val.length - 1) {
|
||||
str += "、";
|
||||
}
|
||||
});
|
||||
if (!str) str = "-";
|
||||
return str;
|
||||
}
|
||||
},
|
||||
{ key:"version", title:"版本号", type:"text", width:100 },
|
||||
{
|
||||
key: "stable_publish", title: "安装包状态", type: "tag", width: 120, size: "small",
|
||||
data:[
|
||||
{ value:true, label:"已上线", tagType:"success", effect:"light" },
|
||||
{ value:false, label:"已下线", tagType:"info", effect:"light" }
|
||||
]
|
||||
},
|
||||
{ key:"create_date", title:"上传时间", type:"time", width:160, sortable:"custom" },
|
||||
{ key:"create_date", title:"距离现在", type:"dateDiff", width:120 },
|
||||
],
|
||||
// 多选框选中的值
|
||||
multipleSelection:[],
|
||||
// 当前高亮的记录
|
||||
selectItem:""
|
||||
},
|
||||
// 表格相关结束 -----------------------------------------------------------
|
||||
// 表单相关开始 -----------------------------------------------------------
|
||||
// 查询表单请求数据
|
||||
queryForm1:{
|
||||
// 查询表单数据源,可在此设置默认值
|
||||
formData:{
|
||||
appid:""
|
||||
},
|
||||
// 查询表单的字段规则 fieldName:指定数据库字段名,不填默认等于key
|
||||
columns:[
|
||||
{
|
||||
key:"appid", title:"所属应用", type:"select", placeholder:"请选择应用", width:140, mode:"=",
|
||||
props:{ value:'appid', label:'name' },
|
||||
data:()=>{
|
||||
return this.appList;
|
||||
}
|
||||
},
|
||||
{ key:"title", title:"标题", type:"text", width:140, mode:"%%" },
|
||||
{
|
||||
key: "type", title: "安装包类型", type: "select", width: 140, placeholder:"请选择类型",
|
||||
data:[
|
||||
{ value:"native_app", label:"原生App安装包" },
|
||||
{ value:"wgt", label:"Wgt资源包" }
|
||||
]
|
||||
},
|
||||
{
|
||||
key: "stable_publish", title: "安装包状态", type: "select", width: 140, placeholder:"请选择状态",
|
||||
data:[
|
||||
{ value:true, label:"已上线" },
|
||||
{ value:false, label:"已下线" }
|
||||
]
|
||||
},
|
||||
{ key:"create_date", title:"上传时间", type:"datetimerange", width:360, mode:"[]" },
|
||||
]
|
||||
},
|
||||
// 其他弹窗表单
|
||||
formDatas:{},
|
||||
// 表单相关结束 -----------------------------------------------------------
|
||||
};
|
||||
},
|
||||
// 监听 - 页面每次【加载时】执行(如:前进)
|
||||
onLoad(options = {}) {
|
||||
that = this;
|
||||
vk = that.vk;
|
||||
that.options = options;
|
||||
that.init(options);
|
||||
},
|
||||
// 监听 - 页面【首次渲染完成时】执行。注意如果渲染速度快,会在页面进入动画完成前触发
|
||||
onReady() {},
|
||||
// 监听 - 页面每次【显示时】执行(如:前进和返回) (页面每次出现在屏幕上都触发,包括从下级页面点返回露出当前页面)
|
||||
onShow() {},
|
||||
// 监听 - 页面每次【隐藏时】执行(如:返回)
|
||||
onHide() {},
|
||||
// 函数
|
||||
methods: {
|
||||
// 页面数据初始化函数
|
||||
init(options) {
|
||||
originalForms["form1"] = vk.pubfn.copyObject(that.form1);
|
||||
vk.callFunction({
|
||||
url: 'admin/system/app/sys/getList',
|
||||
loading:true,
|
||||
data: {
|
||||
pageSize:500,
|
||||
formData:{
|
||||
enable_upgrade_center: true
|
||||
},
|
||||
columns:[
|
||||
{ key:"enable_upgrade_center", type:"select", mode:"=" },
|
||||
]
|
||||
},
|
||||
success: (data) => {
|
||||
that.appList = data.rows;
|
||||
if (options.appid) {
|
||||
that.queryForm1.formData.appid = options.appid;
|
||||
that.search();
|
||||
} else if (data.rows.length > 0) {
|
||||
that.queryForm1.formData.appid = data.rows[0].appid;
|
||||
that.search();
|
||||
}
|
||||
}
|
||||
});
|
||||
},
|
||||
// 页面跳转
|
||||
pageTo(path) {
|
||||
vk.navigateTo(path);
|
||||
},
|
||||
// 表单重置
|
||||
resetForm(){
|
||||
vk.pubfn.resetForm(originalForms, that);
|
||||
},
|
||||
// 搜索
|
||||
search(){
|
||||
that.$refs.table1.search();
|
||||
},
|
||||
// 刷新
|
||||
refresh(){
|
||||
that.$refs.table1.refresh();
|
||||
},
|
||||
// 获取当前选中的行的数据
|
||||
getCurrentRow(){
|
||||
return that.$refs.table1.getCurrentRow();
|
||||
},
|
||||
// 监听 - 行的选中高亮事件
|
||||
currentChange(val){
|
||||
that.table1.selectItem = val;
|
||||
},
|
||||
// 当选择项发生变化时会触发该事件
|
||||
selectionChange(list) {
|
||||
that.table1.multipleSelection = list;
|
||||
},
|
||||
// 显示添加页面
|
||||
addBtn(type){
|
||||
let appid = that.queryForm1.formData.appid;
|
||||
let appInfo = vk.pubfn.getListItem(that.appList, "appid", appid);
|
||||
let item = {
|
||||
appid,
|
||||
type,
|
||||
name: appInfo.name,
|
||||
store_list: appInfo.store_list
|
||||
};
|
||||
vk.pubfn.openForm('addUpdate',{ mode:"add", item });
|
||||
},
|
||||
// 显示修改页面
|
||||
updateBtn({ item }){
|
||||
vk.pubfn.openForm('addUpdate',{ mode:"update", item });
|
||||
},
|
||||
// 删除按钮
|
||||
deleteBtn({ item, deleteFn }){
|
||||
if (item.stable_publish) {
|
||||
this.$message({
|
||||
showClose: true,
|
||||
message: '不可删除已上线的版本',
|
||||
type: 'error'
|
||||
});
|
||||
return false;
|
||||
}
|
||||
deleteFn({
|
||||
action:"admin/system/app-upgrade-center/sys/delete",
|
||||
data:{
|
||||
_id: item._id
|
||||
},
|
||||
});
|
||||
},
|
||||
// 监听 - 批量操作的按钮点击事件
|
||||
batchBtn(index){
|
||||
switch(index){
|
||||
case 1: vk.toast("批量操作按钮1"); break;
|
||||
case 2: vk.toast("批量操作按钮2"); break;
|
||||
default : break;
|
||||
}
|
||||
}
|
||||
},
|
||||
// 监听属性
|
||||
watch: {
|
||||
|
||||
},
|
||||
// 计算属性
|
||||
computed: {
|
||||
|
||||
}
|
||||
};
|
||||
</script>
|
||||
<style lang="scss" scoped>
|
||||
.page-body {
|
||||
|
||||
}
|
||||
</style>
|
||||
@@ -0,0 +1,515 @@
|
||||
<template>
|
||||
<vk-data-dialog
|
||||
v-model="value.show"
|
||||
:title="page.title"
|
||||
:top="page.top"
|
||||
:width="page.width"
|
||||
:close-on-click-modal="true"
|
||||
:destroy-on-close="true"
|
||||
mode="form"
|
||||
@open="onOpen"
|
||||
@closed="onClose"
|
||||
>
|
||||
<!-- 页面主体内容开始 -->
|
||||
<vk-data-form
|
||||
ref="form1"
|
||||
v-model="form1.data"
|
||||
:form-type="value.mode"
|
||||
:rules="form1.props.rules"
|
||||
:action="form1.props.action"
|
||||
:columns="form1.props.columns"
|
||||
:loading.sync="form1.props.loading"
|
||||
:labelWidth="form1.props.labelWidth"
|
||||
:show-cancel="page.showCancel"
|
||||
:cancel-text="page.cancelText"
|
||||
:submit-text="page.submitText"
|
||||
@success="onFormSuccess"
|
||||
></vk-data-form>
|
||||
<!-- 页面主体内容结束 -->
|
||||
</vk-data-dialog>
|
||||
</template>
|
||||
|
||||
<script>
|
||||
var pageName = "应用";
|
||||
var vk = uni.vk; // vk实例
|
||||
var originalForms = {}; // 表单初始化数据
|
||||
export default {
|
||||
props: {
|
||||
value: {
|
||||
Type: Object,
|
||||
default: function() {
|
||||
return {
|
||||
show: false,
|
||||
mode: "",
|
||||
item: {},
|
||||
options:{}
|
||||
};
|
||||
}
|
||||
}
|
||||
},
|
||||
data: function() {
|
||||
// 组件创建时,进行数据初始化
|
||||
return {
|
||||
page: {
|
||||
title: "标题",
|
||||
submitText: "确定",
|
||||
cancelText: "关闭",
|
||||
showCancel: false,
|
||||
top: "1vh",
|
||||
width: "1200px"
|
||||
},
|
||||
form1: {
|
||||
// 表单请求数据,此处可以设置默认值
|
||||
data: {
|
||||
name:"",
|
||||
enable_upgrade_center:false,
|
||||
app_ios:{
|
||||
enable:false
|
||||
}
|
||||
},
|
||||
// 表单属性
|
||||
props: {
|
||||
// 表单请求地址
|
||||
action:"",
|
||||
// 表单字段显示规则
|
||||
columns:[
|
||||
{ key:"", title:"基础信息", type:"bar-title" },
|
||||
{ key:"appid", title:"AppID", type:"text" },
|
||||
{
|
||||
key:"type", title:"应用类型", type:"cascader",
|
||||
data:[
|
||||
{
|
||||
value:"1000",
|
||||
label: "用户端",
|
||||
children:[
|
||||
{
|
||||
value:"1001",
|
||||
label: "通用",
|
||||
children:[
|
||||
{ value:"client", label:"用户端" },
|
||||
]
|
||||
},
|
||||
{
|
||||
value:"1002",
|
||||
label: "商家",
|
||||
children:[
|
||||
{ value:"rider", label:"骑手端" },
|
||||
{ value:"business", label:"商家端" },
|
||||
]
|
||||
},
|
||||
{
|
||||
value:"1003",
|
||||
label: "教育",
|
||||
children:[
|
||||
{ value:"student", label:"学生端" },
|
||||
{ value:"parent", label:"家长端" },
|
||||
{ value:"teacher", label:"教师端" },
|
||||
]
|
||||
},
|
||||
{
|
||||
value:"1999",
|
||||
label: "其他",
|
||||
children:[
|
||||
{ value:"other", label:"其他" },
|
||||
]
|
||||
}
|
||||
]
|
||||
},
|
||||
{
|
||||
value:"2000",
|
||||
label: "管理端",
|
||||
children:[
|
||||
{
|
||||
value:"2001",
|
||||
label: "通用",
|
||||
children:[
|
||||
{ value:"admin", label:"管理端" },
|
||||
]
|
||||
},
|
||||
{
|
||||
value:"2002",
|
||||
label: "商家",
|
||||
children:[
|
||||
{ value:"rider-admin", label:"骑手管理端" },
|
||||
{ value:"business-admin", label:"商家管理端" },
|
||||
]
|
||||
},
|
||||
{
|
||||
value:"2003",
|
||||
label: "教育",
|
||||
children:[
|
||||
{ value:"student-admin", label:"学生管理端" },
|
||||
{ value:"parent-admin", label:"家长管理端" },
|
||||
{ value:"teacher-admin", label:"教师管理端" },
|
||||
]
|
||||
},
|
||||
{
|
||||
value:"2999",
|
||||
label: "其他",
|
||||
children:[
|
||||
{ value:"other-admin", label:"其他管理端" },
|
||||
]
|
||||
}
|
||||
],
|
||||
}
|
||||
],
|
||||
props:{
|
||||
expandTrigger:"hover",
|
||||
emitPath:false,
|
||||
},
|
||||
onChange:(val, formData, column, index, option) => {
|
||||
this.form1.data.name = option.label;
|
||||
}
|
||||
},
|
||||
{ key:"name", title:"应用名称", type:"text",
|
||||
watch: ({ value, formData, column, index, $set }) => {
|
||||
// 此处演示根据选择的值动态改变text1的值
|
||||
let arr = [
|
||||
"app_ios",
|
||||
"app_android",
|
||||
"mp_weixin",
|
||||
"mp_alipay",
|
||||
"mp_baidu",
|
||||
"mp_toutiao",
|
||||
"mp_qq",
|
||||
"mp_kuaishou",
|
||||
"mp_lark",
|
||||
"mp_jd",
|
||||
"mp_dingtalk",
|
||||
"quickapp",
|
||||
];
|
||||
arr.map((item, index) => {
|
||||
this.$set(this.form1.data[item],"name", value);
|
||||
});
|
||||
}
|
||||
},
|
||||
{ key:"introduction", title:"应用简介", type:"text", tips:"一句话描述您的应用的用途" },
|
||||
{
|
||||
key:"description", title:"应用描述", type:"textarea", placeholder:"更详细的应用描述",
|
||||
autosize:{ minRows:4, maxRows:10 },
|
||||
maxlength:200,
|
||||
showWordLimit:true,
|
||||
},
|
||||
{ key:"", title:"App升级中心", type:"bar-title" },
|
||||
{ key:"enable_upgrade_center", title:"是否开启", type:"switch", activeValue:true, inactiveValue:false, tips:"下面的信息为制作统一发布页和APP升级中心所需,若你未用到,则只填上面的基础信息即可。" },
|
||||
{ key:"", title:"图标素材", type:"bar-title", showRule:"enable_upgrade_center==true" },
|
||||
{ key:"icon_url", title:"应用图标", type:"image", limit:1, tips:"建议尺寸:600*600", showRule:"enable_upgrade_center==true" },
|
||||
{ key:"screenshot", title:"应用截图", type:"image", limit:9, tips:"最多9张,建议尺寸:800*1380", showRule:"enable_upgrade_center==true" },
|
||||
{ key:"", title:"H5信息", type:"bar-title", showRule:"enable_upgrade_center==true" },
|
||||
{ key:"h5", title:"链接地址", type:"object", showLabel:false,
|
||||
columns:[
|
||||
{ key:"url", title:"链接地址", type:"text", tips:"您的h5首页访问地址" },
|
||||
],
|
||||
showRule:"enable_upgrade_center==true"
|
||||
},
|
||||
{ key:"", title:"App信息", type:"bar-title",showRule:"enable_upgrade_center==true" },
|
||||
{ key:"app_ios", title:"", type:"object", showLabel:false, showRule:"enable_upgrade_center==true",
|
||||
columns:[
|
||||
{ key:"enable", title:"IOS", type:"switch", activeValue:true, inactiveValue:false },
|
||||
{ key:"name", title:"名称", type:"text", tips:"IOS应用的名称",
|
||||
showRule:(form)=>{
|
||||
return vk.pubfn.getData(form,"app_ios.enable",false);
|
||||
}
|
||||
},
|
||||
{ key:"url", title:"AppStore", type:"text", tips:"AppStore商店的下载链接地址",
|
||||
showRule:(form)=>{
|
||||
return vk.pubfn.getData(form,"app_ios.enable",false);
|
||||
}
|
||||
},
|
||||
]
|
||||
},
|
||||
{ key:"app_android", title:"", type:"object", showLabel:false, showRule:"enable_upgrade_center==true",
|
||||
columns:[
|
||||
{ key:"enable", title:"Android", type:"switch", activeValue:true, inactiveValue:false },
|
||||
{ key:"name", title:"名称", type:"text", tips:"安卓应用的名称",
|
||||
showRule:(form)=>{
|
||||
return vk.pubfn.getData(form,"app_android.enable",false);
|
||||
}
|
||||
},
|
||||
{ key:"apk", title:"上传apk包", type:"file", limit:1, accept:".apk",
|
||||
showRule:(form)=>{
|
||||
return vk.pubfn.getData(form,"app_android.enable",false);
|
||||
},
|
||||
watch: ({ value, formData, column, index, $set }) => {
|
||||
$set("url", value);
|
||||
},
|
||||
tips:"上传apk到当前服务空间的云存储中,上传成功后,会自动使用云存储地址填充下载链接"
|
||||
},
|
||||
{ key:"url", title:"下载链接", type:"text", tips:"安卓应用apk的下载地址",
|
||||
showRule:(form)=>{
|
||||
return vk.pubfn.getData(form,"app_android.enable",false);
|
||||
}
|
||||
},
|
||||
]
|
||||
},
|
||||
{
|
||||
key:"store_list", title:"Android应用市场", type:"array<object>",
|
||||
tips:`<a href="https://ask.dcloud.net.cn/article/39960" target="_blank">常见应用商店schema汇总</a>`,
|
||||
showRule:(form)=>{
|
||||
return vk.pubfn.getData(form,"app_android.enable",false) && form.enable_upgrade_center ? true : false;
|
||||
},
|
||||
rowKey:"id",
|
||||
showAdd:true,
|
||||
showClear:false,
|
||||
showSort:true,
|
||||
// 新增一行时,该行的默认值
|
||||
defaultValue:{
|
||||
enable:true
|
||||
},
|
||||
rightBtns:['delete'],
|
||||
// 每行每个字段对应的渲染规则
|
||||
columns:[
|
||||
{
|
||||
key:"scheme_select", title:"选择已知商店", type:"select", width:120,
|
||||
data:[
|
||||
{ value:"tmast://appdetails?r=XXX&pname=xxx", label:"应用宝" },
|
||||
{ value:"mimarket://details?id=com.xx.xx", label:"小米" },
|
||||
{ value:"samsungapps://ProductDetail/com.xx.xx", label:"三星" },
|
||||
{ value:"appmarket://details?id=com.xx.xx", label:"华为" },
|
||||
{ value:"oppomarket://details?packagename=com.xx.xx", label:"oppo" },
|
||||
{ value:"vivomarket://details?id=com.xx.xx", label:"vivo" },
|
||||
],
|
||||
watch: ({ value, formData, column, index, $set }) => {
|
||||
let item = vk.pubfn.getListItem(column.data, "value", value) || {};
|
||||
let { label="" } = item;
|
||||
$set("scheme", value);
|
||||
$set("name", label);
|
||||
}
|
||||
},
|
||||
{
|
||||
key:"name", title:"商店名称", type:"text", minWidth:180,
|
||||
isUnique:true,
|
||||
rules:[
|
||||
{ required:true, message:"该项不能为空", trigger:["change","blur"] }
|
||||
]
|
||||
},
|
||||
{
|
||||
key:"scheme", title:"Scheme", type:"text", minWidth:280,
|
||||
rules:[
|
||||
{ required:true, message:"该项不能为空", trigger:["change","blur"] },
|
||||
]
|
||||
},
|
||||
{ key:"enable", title:"是否启用", type:"switch", width:80 },
|
||||
]
|
||||
},
|
||||
{ key:"", title:"小程序/快应用信息", type:"bar-title", showRule:"enable_upgrade_center==true" },
|
||||
{ key:"mp_weixin", title:"", type:"object", showLabel:false, showRule:"enable_upgrade_center==true",
|
||||
columns:[
|
||||
{ key:"enable", title:"微信小程序", type:"switch", activeValue:true, inactiveValue:false },
|
||||
{ key:"name", title:"名称", type:"text",
|
||||
showRule:(form)=>{
|
||||
return vk.pubfn.getData(form,"mp_weixin.enable",false);
|
||||
}
|
||||
},
|
||||
{ key:"qrcode_url", title:"小程序码", type:"image", limit:1,
|
||||
showRule:(form)=>{
|
||||
return vk.pubfn.getData(form,"mp_weixin.enable",false);
|
||||
}
|
||||
},
|
||||
]
|
||||
},
|
||||
{ key:"mp_alipay", title:"", type:"object", showLabel:false, showRule:"enable_upgrade_center==true",
|
||||
columns:[
|
||||
{ key:"enable", title:"支付宝小程序", type:"switch", activeValue:true, inactiveValue:false },
|
||||
{ key:"name", title:"名称", type:"text",
|
||||
showRule:(form)=>{
|
||||
return vk.pubfn.getData(form,"mp_alipay.enable",false);
|
||||
}
|
||||
},
|
||||
{ key:"qrcode_url", title:"小程序码", type:"image", limit:1,
|
||||
showRule:(form)=>{
|
||||
return vk.pubfn.getData(form,"mp_alipay.enable",false);
|
||||
}
|
||||
},
|
||||
]
|
||||
},
|
||||
{ key:"mp_baidu", title:"", type:"object", showLabel:false, showRule:"enable_upgrade_center==true",
|
||||
columns:[
|
||||
{ key:"enable", title:"百度小程序", type:"switch", activeValue:true, inactiveValue:false },
|
||||
{ key:"name", title:"名称", type:"text",
|
||||
showRule:(form)=>{
|
||||
return vk.pubfn.getData(form,"mp_baidu.enable",false);
|
||||
}
|
||||
},
|
||||
{ key:"qrcode_url", title:"小程序码", type:"image", limit:1,
|
||||
showRule:(form)=>{
|
||||
return vk.pubfn.getData(form,"mp_baidu.enable",false);
|
||||
}
|
||||
},
|
||||
]
|
||||
},
|
||||
{ key:"mp_toutiao", title:"", type:"object", showLabel:false, showRule:"enable_upgrade_center==true",
|
||||
columns:[
|
||||
{ key:"enable", title:"头条小程序", type:"switch", activeValue:true, inactiveValue:false },
|
||||
{ key:"name", title:"名称", type:"text",
|
||||
showRule:(form)=>{
|
||||
return vk.pubfn.getData(form,"mp_toutiao.enable",false);
|
||||
}
|
||||
},
|
||||
{ key:"qrcode_url", title:"小程序码", type:"image", limit:1,
|
||||
showRule:(form)=>{
|
||||
return vk.pubfn.getData(form,"mp_toutiao.enable",false);
|
||||
}
|
||||
},
|
||||
]
|
||||
},
|
||||
{ key:"mp_qq", title:"", type:"object", showLabel:false, showRule:"enable_upgrade_center==true",
|
||||
columns:[
|
||||
{ key:"enable", title:"QQ小程序", type:"switch", activeValue:true, inactiveValue:false },
|
||||
{ key:"name", title:"名称", type:"text",
|
||||
showRule:(form)=>{
|
||||
return vk.pubfn.getData(form,"mp_qq.enable",false);
|
||||
}
|
||||
},
|
||||
{ key:"qrcode_url", title:"小程序码", type:"image", limit:1,
|
||||
showRule:(form)=>{
|
||||
return vk.pubfn.getData(form,"mp_qq.enable",false);
|
||||
}
|
||||
},
|
||||
]
|
||||
},
|
||||
{ key:"mp_kuaishou", title:"", type:"object", showLabel:false, showRule:"enable_upgrade_center==true",
|
||||
columns:[
|
||||
{ key:"enable", title:"快手小程序", type:"switch", activeValue:true, inactiveValue:false },
|
||||
{ key:"name", title:"名称", type:"text",
|
||||
showRule:(form)=>{
|
||||
return vk.pubfn.getData(form,"mp_kuaishou.enable",false);
|
||||
}
|
||||
},
|
||||
{ key:"qrcode_url", title:"小程序码", type:"image", limit:1,
|
||||
showRule:(form)=>{
|
||||
return vk.pubfn.getData(form,"mp_kuaishou.enable",false);
|
||||
}
|
||||
},
|
||||
]
|
||||
},
|
||||
{ key:"mp_lark", title:"", type:"object", showLabel:false, showRule:"enable_upgrade_center==true",
|
||||
columns:[
|
||||
{ key:"enable", title:"飞书小程序", type:"switch", activeValue:true, inactiveValue:false },
|
||||
{ key:"name", title:"名称", type:"text",
|
||||
showRule:(form)=>{
|
||||
return vk.pubfn.getData(form,"mp_lark.enable",false);
|
||||
}
|
||||
},
|
||||
{ key:"qrcode_url", title:"小程序码", type:"image", limit:1,
|
||||
showRule:(form)=>{
|
||||
return vk.pubfn.getData(form,"mp_lark.enable",false);
|
||||
}
|
||||
},
|
||||
]
|
||||
},
|
||||
{ key:"mp_jd", title:"", type:"object", showLabel:false, showRule:"enable_upgrade_center==true",
|
||||
columns:[
|
||||
{ key:"enable", title:"京东小程序", type:"switch", activeValue:true, inactiveValue:false },
|
||||
{ key:"name", title:"名称", type:"text",
|
||||
showRule:(form)=>{
|
||||
return vk.pubfn.getData(form,"mp_jd.enable",false);
|
||||
}
|
||||
},
|
||||
{ key:"qrcode_url", title:"小程序码", type:"image", limit:1,
|
||||
showRule:(form)=>{
|
||||
return vk.pubfn.getData(form,"mp_jd.enable",false);
|
||||
}
|
||||
},
|
||||
]
|
||||
},
|
||||
{ key:"mp_dingtalk", title:"", type:"object", showLabel:false, showRule:"enable_upgrade_center==true",
|
||||
columns:[
|
||||
{ key:"enable", title:"钉钉小程序", type:"switch", activeValue:true, inactiveValue:false },
|
||||
{ key:"name", title:"名称", type:"text",
|
||||
showRule:(form)=>{
|
||||
return vk.pubfn.getData(form,"mp_dingtalk.enable",false);
|
||||
}
|
||||
},
|
||||
{ key:"qrcode_url", title:"小程序码", type:"image", limit:1,
|
||||
showRule:(form)=>{
|
||||
return vk.pubfn.getData(form,"mp_dingtalk.enable",false);
|
||||
}
|
||||
},
|
||||
]
|
||||
},
|
||||
{ key:"quickapp", title:"", type:"object", showLabel:false, showRule:"enable_upgrade_center==true",
|
||||
columns:[
|
||||
{ key:"enable", title:"快应用", type:"switch", activeValue:true, inactiveValue:false },
|
||||
{ key:"name", title:"名称", type:"text",
|
||||
showRule:(form)=>{
|
||||
return vk.pubfn.getData(form,"quickapp.enable",false);
|
||||
}
|
||||
},
|
||||
{ key:"qrcode_url", title:"快应用码", type:"image", limit:1,
|
||||
showRule:(form)=>{
|
||||
return vk.pubfn.getData(form,"quickapp.enable",false);
|
||||
}
|
||||
},
|
||||
]
|
||||
},
|
||||
],
|
||||
// 表单验证规则
|
||||
rules:{
|
||||
appid: [
|
||||
{ required: true, message: '应用的AppID为必填字段', trigger: 'blur' },
|
||||
],
|
||||
name: [
|
||||
{ required: true, message: '应用名称为必填字段', trigger: 'blur' }
|
||||
],
|
||||
type: [
|
||||
{ required: true, message: '应用类型为必填字段', trigger: 'blur' }
|
||||
]
|
||||
},
|
||||
// 左侧label的宽度
|
||||
labelWidth: "140px",
|
||||
}
|
||||
}
|
||||
};
|
||||
},
|
||||
mounted() {
|
||||
this.init();
|
||||
},
|
||||
methods: {
|
||||
// 初始化
|
||||
init() {
|
||||
let { value } = this;
|
||||
this.$emit("input", value);
|
||||
originalForms["form1"] = vk.pubfn.copyObject(this.form1);
|
||||
},
|
||||
// 监听 - 页面打开
|
||||
onOpen() {
|
||||
let { value={} } = this;
|
||||
let { item={} } = value;
|
||||
// 每次打开时,重新设置表单的值 = value.item 的值,item通过 vk.pubfn.openForm('表单名',{ item:{ _id:"1" } }) 传递值
|
||||
if(value.mode === "update"){
|
||||
this.form1.props.action = "admin/system/app/sys/update";
|
||||
this.page.title = pageName + "修改";
|
||||
this.page.submitText = "修改";
|
||||
this.form1.data = vk.pubfn.copyObject(item);
|
||||
}else{
|
||||
this.form1.props.action = "admin/system/app/sys/add";
|
||||
this.page.title = pageName + "添加";
|
||||
this.page.submitText = "添加";
|
||||
}
|
||||
},
|
||||
// 监听 - 页面关闭
|
||||
onClose() {
|
||||
this.resetForm();
|
||||
},
|
||||
// 监听 - 提交成功后
|
||||
onFormSuccess() {
|
||||
this.value.show = false; // 关闭页面
|
||||
this.$emit("success");
|
||||
},
|
||||
// 表单重置
|
||||
resetForm(){
|
||||
vk.pubfn.resetForm(originalForms, this);
|
||||
},
|
||||
},
|
||||
watch: {
|
||||
|
||||
},
|
||||
// 计算属性
|
||||
computed: {
|
||||
|
||||
}
|
||||
};
|
||||
</script>
|
||||
|
||||
<style lang="scss" scoped></style>
|
||||
@@ -0,0 +1,207 @@
|
||||
<template>
|
||||
<vk-data-dialog
|
||||
v-model="value.show"
|
||||
:title="page.title"
|
||||
:top="page.top"
|
||||
:width="page.width"
|
||||
:close-on-click-modal="true"
|
||||
center
|
||||
@open="onOpen"
|
||||
@closed="onClose"
|
||||
>
|
||||
<view class="uni-container">
|
||||
|
||||
<h3 class="text-separated" style="padding: 0 0 20rpx 0;">步骤1:了解“统一发布页”</h3>
|
||||
|
||||
<view style="margin-top: 20rpx;">
|
||||
<view class="text-separated">
|
||||
<text class="strong">uni-portal </text>
|
||||
<text>是 uni-app 提供的一套开箱即用的“统一发布页”。</text>
|
||||
</view>
|
||||
<view class="text-separated">
|
||||
<text class="strong">uni-portal </text>
|
||||
<text>可作为面向用户的统一业务名片,在一个页面集中展现:App下载地址、小程序二维码、H5访问链接等信息。</text>
|
||||
</view>
|
||||
|
||||
<!-- #ifdef H5 -->
|
||||
<view class="text-separated">
|
||||
<text style="font-size: 16px;">uni-app 官方示例的发布页就是基于<text class="strong">uni-portal </text> 制作的,<a
|
||||
href="https://hellouniapp.dcloud.net.cn/portal" target="_blank" class="a-label">点击体验</a>
|
||||
</text>
|
||||
</view>
|
||||
<!-- #endif -->
|
||||
</view>
|
||||
|
||||
<h3 class="text-separated" style="padding: 40rpx 0 20rpx 0;">步骤2:获取“统一发布页”</h3>
|
||||
<view class="flex text-separated" style="margin-top: 20rpx;">
|
||||
<text>
|
||||
<view class="strong">uni-portal </view> 可根据「应用管理」中所填写的应用信息,一键生成发布页:
|
||||
</text>
|
||||
<button class="custom-button" size="mini" type="primary" @click="publish"
|
||||
style="margin: 0;">生成并下载发布页</button>
|
||||
</view>
|
||||
|
||||
<h3 class="text-separated" style="padding: 40rpx 0 20rpx 0;">步骤3:上传“统一发布页”</h3>
|
||||
|
||||
<view style="margin-top: 20rpx;">
|
||||
<view class="text-separated">
|
||||
<text>
|
||||
步骤2下载的“统一发布页”,是一个静态HTML页面,你可以直接在本地浏览器中打开访问。
|
||||
</text>
|
||||
</view>
|
||||
|
||||
<view class="text-separated">
|
||||
<text>
|
||||
为了让用户访问到这个“统一发布页”,你需要将该静态HTML文件上传到你的服务器中;推荐使用<a href="https://uniapp.dcloud.io/uniCloud/hosting"
|
||||
target="_blank" class="a-label" style="padding: 5px;">前端网页托管</a>,因为前端网页托管具备使用更简单、价格更便宜、访问更快等优点。
|
||||
</text>
|
||||
</view>
|
||||
</view>
|
||||
</view>
|
||||
<template v-slot:footer>
|
||||
<el-button :loading="page.loading" type="primary" size="small" style="width: 80px;" @click="close">{{ page.submitText }}</el-button>
|
||||
</template>
|
||||
</vk-data-dialog>
|
||||
</template>
|
||||
|
||||
<script>
|
||||
var vk = uni.vk; // vk实例
|
||||
var download = function(content, filename) {
|
||||
let eleLink = document.createElement('a');
|
||||
eleLink.download = filename;
|
||||
eleLink.style.display = 'none';
|
||||
let blob = new Blob([content]);
|
||||
eleLink.href = URL.createObjectURL(blob);
|
||||
document.body.appendChild(eleLink);
|
||||
eleLink.click();
|
||||
document.body.removeChild(eleLink);
|
||||
};
|
||||
export default {
|
||||
props: {
|
||||
value: {
|
||||
Type: Object,
|
||||
default: function() {
|
||||
return {
|
||||
show: false,
|
||||
item: {},
|
||||
};
|
||||
}
|
||||
}
|
||||
},
|
||||
data: function() {
|
||||
// 组件创建时,进行数据初始化
|
||||
return {
|
||||
page: {
|
||||
title: "生成统一发布页",
|
||||
submitText: "关闭",
|
||||
top: "5vh",
|
||||
width: "800px",
|
||||
loading: false
|
||||
},
|
||||
id: ""
|
||||
};
|
||||
},
|
||||
mounted() {
|
||||
this.init();
|
||||
},
|
||||
methods: {
|
||||
// 初始化
|
||||
init() {
|
||||
let { value } = this;
|
||||
this.$emit("input", value);
|
||||
},
|
||||
// 监听 - 页面打开
|
||||
onOpen() {
|
||||
let { value = {} } = this;
|
||||
let { item={} } = value;
|
||||
this.id = item._id;
|
||||
},
|
||||
// 监听 - 页面关闭
|
||||
onClose() {
|
||||
|
||||
},
|
||||
close(){
|
||||
this.$emit("input", false);
|
||||
},
|
||||
publish() {
|
||||
if (!this.id) {
|
||||
uni.showModal({
|
||||
content: '页面出错,请返回重进',
|
||||
showCancel: false,
|
||||
success(res) {
|
||||
uni.redirectTo({
|
||||
url: '/pages/system/app/list'
|
||||
})
|
||||
}
|
||||
})
|
||||
return
|
||||
}
|
||||
vk.callFunction({
|
||||
url: 'admin/system/app/sys/createPublishHtml',
|
||||
title: '生成中...',
|
||||
data: {
|
||||
id: this.id
|
||||
},
|
||||
success: (res) => {
|
||||
if ('download' in document.createElement('a')) {
|
||||
download(res.body, 'uni-publish.html');
|
||||
} else {
|
||||
vk.toast('浏览器不支持');
|
||||
}
|
||||
}
|
||||
});
|
||||
}
|
||||
},
|
||||
watch: {
|
||||
|
||||
},
|
||||
// 计算属性
|
||||
computed: {
|
||||
|
||||
}
|
||||
};
|
||||
</script>
|
||||
|
||||
<style lang="scss" scoped>
|
||||
.strong {
|
||||
padding: 10rpx;
|
||||
display: inline-block;
|
||||
color: #c7254e;
|
||||
}
|
||||
|
||||
.a-label {
|
||||
text-decoration: none;
|
||||
color: #0366d6;
|
||||
font-weight: bold;
|
||||
padding: 10rpx;
|
||||
}
|
||||
|
||||
.text-separated {
|
||||
line-height: 2em;
|
||||
color: #2c3e50;
|
||||
}
|
||||
|
||||
.tip {
|
||||
display: flex;
|
||||
flex-direction: column;
|
||||
align-items: flex-start;
|
||||
background-color: #f3f5f7;
|
||||
color: #2c3e50;
|
||||
padding: 10px;
|
||||
font-size: 32rpx;
|
||||
|
||||
border: {
|
||||
color: #409EFF;
|
||||
left-width: 8px;
|
||||
left-style: solid;
|
||||
}
|
||||
|
||||
text {
|
||||
margin-right: 15px;
|
||||
}
|
||||
|
||||
.custom-button {
|
||||
margin-left: 0px;
|
||||
}
|
||||
}
|
||||
</style>
|
||||
@@ -0,0 +1,215 @@
|
||||
<template>
|
||||
<view class="page-body">
|
||||
<!-- 页面内容开始 -->
|
||||
|
||||
<!-- 表格搜索组件开始 -->
|
||||
<vk-data-table-query
|
||||
v-model="queryForm1.formData"
|
||||
:columns="queryForm1.columns"
|
||||
@search="search"
|
||||
></vk-data-table-query>
|
||||
<!-- 表格搜索组件结束 -->
|
||||
|
||||
<!-- 自定义按钮区域开始 -->
|
||||
<view style="display: flex;height: 32px;">
|
||||
<el-button type="success" size="small" icon="el-icon-circle-plus-outline" @click="addBtn">添加</el-button>
|
||||
<el-alert v-if="!appIdExist" :title="`⚠警告:当前项目的 appId:${currentAppId} 没有在下方表格中,请新增应用或修改应用!`" type="error" style="margin-left: 20px;"> </el-alert>
|
||||
</view>
|
||||
<!-- 自定义按钮区域结束 -->
|
||||
<!-- 表格组件开始 -->
|
||||
<vk-data-table
|
||||
ref="table1"
|
||||
:action="table1.action"
|
||||
:columns="table1.columns"
|
||||
:query-form-param="queryForm1"
|
||||
:right-btns="['update','delete']"
|
||||
:custom-right-btns="table1.customRightBtns"
|
||||
:selection="false"
|
||||
:row-no="true"
|
||||
:pagination="true"
|
||||
@update="updateBtn"
|
||||
@delete="deleteBtn"
|
||||
@current-change="currentChange"
|
||||
@selection-change="selectionChange"
|
||||
></vk-data-table>
|
||||
<!-- 表格组件结束 -->
|
||||
|
||||
<!-- 添加或编辑 -->
|
||||
<addUpdate v-model="formDatas.addUpdate" @success="refresh"></addUpdate>
|
||||
<!-- 生成发布页 -->
|
||||
<createPublishHtml v-model="formDatas.createPublishHtml" @success="refresh"></createPublishHtml>
|
||||
|
||||
<!-- 页面内容结束 -->
|
||||
</view>
|
||||
</template>
|
||||
|
||||
<script>
|
||||
var that; // 当前页面对象
|
||||
var vk = uni.vk; // vk实例
|
||||
|
||||
import addUpdate from './form/addUpdate.vue'
|
||||
import createPublishHtml from './form/createPublishHtml.vue'
|
||||
export default {
|
||||
components:{
|
||||
addUpdate,
|
||||
createPublishHtml,
|
||||
},
|
||||
data() {
|
||||
// 页面数据变量
|
||||
return {
|
||||
// 页面是否请求中或加载中
|
||||
loading:false,
|
||||
// init请求返回的数据
|
||||
data:{
|
||||
|
||||
},
|
||||
// 表格相关开始 -----------------------------------------------------------
|
||||
table1:{
|
||||
// 表格数据请求地址
|
||||
action:"admin/system/app/sys/getList",
|
||||
// 表格字段显示规则
|
||||
columns:[
|
||||
{ key:"appid", title:"AppID", type:"text", width:160, sortable:"custom" },
|
||||
{ key:"type", title:"应用类型", type:"text", width:120, sortable:"custom" },
|
||||
{ key:"name", title:"应用名称", type:"text", width:240, sortable:"custom" },
|
||||
{ key:"description", title:"应用描述", type:"text", minWidth:260 },
|
||||
{ key:"_add_time", title:"添加时间", type:"time", width:160, sortable:"custom" }
|
||||
],
|
||||
// 多选框选中的值
|
||||
multipleSelection:[],
|
||||
// 当前高亮的记录
|
||||
selectItem:"",
|
||||
customRightBtns: [
|
||||
{
|
||||
title: '发布页管理', type: 'primary',
|
||||
onClick:(item)=>{
|
||||
vk.pubfn.openForm('createPublishHtml',{ item });
|
||||
},
|
||||
disabled:"enable_upgrade_center!=true",
|
||||
},
|
||||
{
|
||||
title: '版本管理', type: 'primary',
|
||||
onClick:(item)=>{
|
||||
vk.navigateTo(`/pages_plugs/system/app-upgrade-center/list?appid=${item.appid}`);
|
||||
},
|
||||
disabled:"enable_upgrade_center!=true",
|
||||
}
|
||||
],
|
||||
},
|
||||
// 表格相关结束 -----------------------------------------------------------
|
||||
// 表单相关开始 -----------------------------------------------------------
|
||||
// 查询表单请求数据
|
||||
queryForm1:{
|
||||
// 查询表单数据源,可在此设置默认值
|
||||
formData:{
|
||||
|
||||
},
|
||||
// 查询表单的字段规则 fieldName:指定数据库字段名,不填默认等于key
|
||||
columns:[
|
||||
{ key:"appid", title:"AppID", type:"text", width:160, mode:"%%" },
|
||||
{ key:"name", title:"应用名称", type:"text", width:160, mode:"%%" },
|
||||
{ key:"_add_time", title:"添加时间", type:"datetimerange", width:400, mode:"[]" },
|
||||
]
|
||||
},
|
||||
// 其他弹窗表单
|
||||
formDatas:{},
|
||||
// 表单相关结束 -----------------------------------------------------------
|
||||
appIdExist: true
|
||||
};
|
||||
},
|
||||
// 监听 - 页面每次【加载时】执行(如:前进)
|
||||
onLoad(options = {}) {
|
||||
that = this;
|
||||
vk = that.vk;
|
||||
that.options = options;
|
||||
that.init(options);
|
||||
},
|
||||
// 监听 - 页面【首次渲染完成时】执行。注意如果渲染速度快,会在页面进入动画完成前触发
|
||||
onReady() {},
|
||||
// 监听 - 页面每次【显示时】执行(如:前进和返回) (页面每次出现在屏幕上都触发,包括从下级页面点返回露出当前页面)
|
||||
onShow() {},
|
||||
// 监听 - 页面每次【隐藏时】执行(如:返回)
|
||||
onHide() {},
|
||||
// 函数
|
||||
methods: {
|
||||
// 页面数据初始化函数
|
||||
init(options) {
|
||||
that.checkCurrentAppId();
|
||||
},
|
||||
// 页面跳转
|
||||
pageTo(path) {
|
||||
vk.navigateTo(path);
|
||||
},
|
||||
// 搜索
|
||||
search(){
|
||||
that.$refs.table1.search();
|
||||
},
|
||||
// 刷新
|
||||
refresh(){
|
||||
that.$refs.table1.refresh();
|
||||
that.checkCurrentAppId();
|
||||
},
|
||||
// 获取当前选中的行的数据
|
||||
getCurrentRow(){
|
||||
return that.$refs.table1.getCurrentRow();
|
||||
},
|
||||
// 监听 - 行的选中高亮事件
|
||||
currentChange(val){
|
||||
that.table1.selectItem = val;
|
||||
},
|
||||
// 当选择项发生变化时会触发该事件
|
||||
selectionChange(list) {
|
||||
that.table1.multipleSelection = list;
|
||||
},
|
||||
// 显示添加页面
|
||||
addBtn(){
|
||||
vk.pubfn.openForm('addUpdate',{ mode:"add" });
|
||||
},
|
||||
// 显示修改页面
|
||||
updateBtn({ item }){
|
||||
vk.pubfn.openForm('addUpdate',{ mode:"update", item });
|
||||
},
|
||||
// 删除按钮
|
||||
deleteBtn({ item, deleteFn }){
|
||||
deleteFn({
|
||||
action:"admin/system/app/sys/delete",
|
||||
data:{
|
||||
_id: item._id
|
||||
},
|
||||
});
|
||||
},
|
||||
checkCurrentAppId(){
|
||||
let systemInfo = uni.getSystemInfoSync();
|
||||
if (typeof systemInfo.appId !== "undefined") {
|
||||
that.currentAppId = systemInfo.appId;
|
||||
vk.callFunction({
|
||||
url: 'admin/system/app/sys/getInfo',
|
||||
data: {
|
||||
appid: systemInfo.appId,
|
||||
},
|
||||
success: (data) => {
|
||||
if (data.info && data.info.appid === systemInfo.appId) {
|
||||
that.appIdExist = true;
|
||||
} else {
|
||||
that.appIdExist = false;
|
||||
}
|
||||
}
|
||||
});
|
||||
}
|
||||
}
|
||||
},
|
||||
// 监听属性
|
||||
watch: {
|
||||
|
||||
},
|
||||
// 计算属性
|
||||
computed: {
|
||||
|
||||
}
|
||||
};
|
||||
</script>
|
||||
<style lang="scss" scoped>
|
||||
.page-body {
|
||||
|
||||
}
|
||||
</style>
|
||||
@@ -0,0 +1,171 @@
|
||||
<template>
|
||||
<vk-data-dialog
|
||||
v-model="value.show"
|
||||
:title="page.title"
|
||||
:top="page.top"
|
||||
:width="page.width"
|
||||
mode="form"
|
||||
@open="onOpen"
|
||||
@closed="onClose"
|
||||
>
|
||||
<!-- 页面主体内容开始 -->
|
||||
<vk-data-form
|
||||
ref="form1"
|
||||
v-model="form1.data"
|
||||
:form-type="value.mode"
|
||||
:rules="form1.props.rules"
|
||||
:action="form1.props.action"
|
||||
:columns="form1.props.columns"
|
||||
:loading.sync="form1.props.loading"
|
||||
:labelWidth="form1.props.labelWidth"
|
||||
:before-action="form1.props.beforeAction"
|
||||
:show-cancel="page.showCancel"
|
||||
:cancel-text="page.cancelText"
|
||||
:submit-text="page.submitText"
|
||||
@success="onFormSuccess"
|
||||
></vk-data-form>
|
||||
<!-- 页面主体内容结束 -->
|
||||
</vk-data-dialog>
|
||||
</template>
|
||||
|
||||
<script>
|
||||
var that; // 当前页面对象
|
||||
var vk = uni.vk; // vk实例
|
||||
export default {
|
||||
props: {
|
||||
value: {
|
||||
Type: Object,
|
||||
default: function() {
|
||||
return {
|
||||
show: false,
|
||||
mode: "",
|
||||
item: ""
|
||||
};
|
||||
}
|
||||
}
|
||||
},
|
||||
data: function() {
|
||||
// 组件创建时,进行数据初始化
|
||||
return {
|
||||
page: {
|
||||
title: "导入菜单",
|
||||
submitText: "导入",
|
||||
cancelText: "关闭",
|
||||
showCancel: true,
|
||||
top: "7vh",
|
||||
width:"800px"
|
||||
},
|
||||
form1: {
|
||||
// 表单请求数据,此处可以设置默认值
|
||||
data: {
|
||||
mode: 1,
|
||||
jsonType: 1
|
||||
},
|
||||
// 表单属性
|
||||
props: {
|
||||
// 表单请求地址
|
||||
action: "admin/system/menu/sys/adds",
|
||||
// 表单字段显示规则
|
||||
columns: [
|
||||
{ key: "jsonType", title: "json类型", type: "radio",
|
||||
data: [
|
||||
{ value: 1, label: "树形结构" },
|
||||
{ value: 2, label: "数组结构" },
|
||||
]
|
||||
},
|
||||
{ key:"parent_id", title:"父级菜单Id", type:"text",
|
||||
showRule:"jsonType=1"
|
||||
},
|
||||
{ key: "mode", title: "重复标识是否覆盖", type: "radio",
|
||||
data: [
|
||||
{ value: 1, label: "覆盖" },
|
||||
{ value: 2, label: "忽略" },
|
||||
]
|
||||
},
|
||||
{ key: "menus", title: "JSON内容", type: "textarea",
|
||||
autosize: { minRows: 18, maxRows: 18 }
|
||||
},
|
||||
],
|
||||
// 表单验证规则
|
||||
rules: {
|
||||
menus: [
|
||||
{ required: true, message: "不能为空", trigger: "change" },
|
||||
]
|
||||
},
|
||||
// add 代表添加 update 代表修改
|
||||
formType: "",
|
||||
// 表单是否在请求中
|
||||
loading: false,
|
||||
// 是否显示表单1 的弹窗
|
||||
show: false,
|
||||
labelWidth:"140px",
|
||||
beforeAction(formData){
|
||||
try {
|
||||
let menus = JSON.parse(formData.menus);
|
||||
if(Object.prototype.toString.call(menus) === '[object Object]'){
|
||||
menus = [menus];
|
||||
}
|
||||
if(formData.jsonType == 1){
|
||||
menus.map((item, index) => {
|
||||
item.parent_id = formData.parent_id;
|
||||
});
|
||||
menus = vk.pubfn.treeToArray(menus,{
|
||||
id:"menu_id",
|
||||
parent_id:"parent_id",
|
||||
children:"children"
|
||||
});
|
||||
}
|
||||
return {
|
||||
menus
|
||||
};
|
||||
}catch(err){
|
||||
vk.toast("json解析失败","none");
|
||||
console.error(err);
|
||||
return false;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
};
|
||||
},
|
||||
mounted() {
|
||||
that = this;
|
||||
that.init();
|
||||
},
|
||||
methods: {
|
||||
// 初始化
|
||||
init() {
|
||||
let { value } = that;
|
||||
that.$emit("input", value);
|
||||
},
|
||||
// 监听 - 页面打开
|
||||
onOpen() {
|
||||
that = this;
|
||||
let { value={} } = that;
|
||||
let { menu_id } = value.item || {};
|
||||
that.form1.data.parent_id = menu_id;
|
||||
},
|
||||
// 监听 - 页面关闭
|
||||
onClose() {
|
||||
that.$refs.form1.resetForm(); // 关闭时,重置表单
|
||||
},
|
||||
// 监听 - 提交成功后
|
||||
onFormSuccess() {
|
||||
that.value.show = false; // 关闭页面
|
||||
that.$emit("success");
|
||||
},
|
||||
},
|
||||
// 监听属性
|
||||
watch: {
|
||||
|
||||
},
|
||||
// 计算属性
|
||||
computed: {
|
||||
|
||||
}
|
||||
};
|
||||
</script>
|
||||
|
||||
<style lang="scss" scoped>
|
||||
|
||||
</style>
|
||||
@@ -0,0 +1,218 @@
|
||||
<template>
|
||||
<vk-data-dialog
|
||||
v-model="value.show"
|
||||
:title="page.title"
|
||||
:top="page.top"
|
||||
:width="page.width"
|
||||
mode="form"
|
||||
@open="onOpen"
|
||||
@closed="onClose"
|
||||
>
|
||||
<!-- 页面主体内容开始 -->
|
||||
<vk-data-form
|
||||
v-loading="page.loading"
|
||||
ref="form1"
|
||||
v-model="form1.data"
|
||||
:form-type="value.mode"
|
||||
:rules="form1.props.rules"
|
||||
:action="form1.props.action"
|
||||
:columns="form1.props.columns"
|
||||
:loading.sync="form1.props.loading"
|
||||
:labelWidth="form1.props.labelWidth"
|
||||
:before-action="form1.props.beforeAction"
|
||||
:show-cancel="page.showCancel"
|
||||
:cancel-text="page.cancelText"
|
||||
:submit-text="page.submitText"
|
||||
@success="onFormSuccess"
|
||||
>
|
||||
<template v-slot:refresh>
|
||||
<view style="margin-left: 30px;">
|
||||
<text style="color: #66b1ff;text-decoration: underline;cursor: pointer;" @click="getList()">刷新数据</text>
|
||||
</view>
|
||||
</template>
|
||||
|
||||
<template v-slot:permissionList>
|
||||
<el-tree
|
||||
ref="tree"
|
||||
:data="data.treeData"
|
||||
:node-key="data.nodeKey"
|
||||
:default-checked-keys="data.checkedKeys"
|
||||
:props="{
|
||||
children: 'children',
|
||||
label: 'label'
|
||||
}"
|
||||
show-checkbox
|
||||
default-expand-all
|
||||
expand-on-click-node
|
||||
></el-tree>
|
||||
</template>
|
||||
</vk-data-form>
|
||||
<!-- 页面主体内容结束 -->
|
||||
</vk-data-dialog>
|
||||
</template>
|
||||
|
||||
<script>
|
||||
var that; // 当前页面对象
|
||||
var vk = uni.vk; // vk实例
|
||||
export default {
|
||||
props: {
|
||||
value: {
|
||||
Type: Object,
|
||||
default: function() {
|
||||
return {
|
||||
show: false,
|
||||
mode: "",
|
||||
item: ""
|
||||
};
|
||||
}
|
||||
}
|
||||
},
|
||||
data: function() {
|
||||
// 组件创建时,进行数据初始化
|
||||
return {
|
||||
data:{
|
||||
list:[],
|
||||
info:{},
|
||||
// 权限的树形结构数据
|
||||
treeData: [],
|
||||
// 默认选中的权限列表
|
||||
checkedKeys:[],
|
||||
// 树的唯一标识
|
||||
nodeKey:"permission_id",
|
||||
},
|
||||
page: {
|
||||
title: "权限赋予",
|
||||
submitText: "确定",
|
||||
cancelText: "关闭",
|
||||
showCancel: true,
|
||||
top: "7vh",
|
||||
width:"800px",
|
||||
loading: false
|
||||
},
|
||||
form1: {
|
||||
// 表单请求数据,此处可以设置默认值
|
||||
data: {
|
||||
menu_id:"",
|
||||
reset:true,
|
||||
permissionList:[]
|
||||
},
|
||||
// 表单属性
|
||||
props: {
|
||||
// 表单请求地址
|
||||
action: "admin/system/menu/sys/bindPermission",
|
||||
// 表单字段显示规则
|
||||
columns: [
|
||||
// 常用字段类型
|
||||
{ key: "refresh", title: "", type: "text", showLabel:false },
|
||||
{ key: "permissionList", title: "权限列表", type: "text" }
|
||||
],
|
||||
// 表单验证规则
|
||||
rules: {
|
||||
|
||||
},
|
||||
labelWidth: "100px",
|
||||
beforeAction:function(formData){
|
||||
let checkedKeys = that.$refs.tree.getCheckedKeys();
|
||||
let halfCheckedKeys = that.$refs.tree.getHalfCheckedKeys();
|
||||
let allCheckedKeys = checkedKeys.concat(halfCheckedKeys);
|
||||
// 去除空属性
|
||||
for(let i = 0;i<allCheckedKeys.length;i++){
|
||||
if(vk.pubfn.isNull(allCheckedKeys[i])){
|
||||
allCheckedKeys.splice(i, 1);
|
||||
i--;
|
||||
}
|
||||
}
|
||||
formData.permissionList = allCheckedKeys;
|
||||
return formData;
|
||||
}
|
||||
}
|
||||
}
|
||||
};
|
||||
},
|
||||
mounted() {
|
||||
that = this;
|
||||
that.init();
|
||||
},
|
||||
methods: {
|
||||
// 初始化
|
||||
init() {
|
||||
let { value } = that;
|
||||
that.$emit("input", value);
|
||||
},
|
||||
// 监听 - 页面打开
|
||||
onOpen() {
|
||||
that = this;
|
||||
let { value={} } = that;
|
||||
let { item } = value;
|
||||
let { menu_id, name, permission = [] } = item;
|
||||
that.page.title = `权限赋予(${name})`;
|
||||
that.data.info = item;
|
||||
that.form1.data.menu_id = menu_id;
|
||||
that.form1.data.permissionList = permission;
|
||||
if (vk.pubfn.isNotNull(that.data.treeData)){
|
||||
that.initData();
|
||||
return;
|
||||
}
|
||||
that.getList();
|
||||
},
|
||||
getList(){
|
||||
// 执行请求
|
||||
vk.callFunction({
|
||||
url: 'admin/system/permission/sys/getAll',
|
||||
data: {},
|
||||
loading:{ that, name:"page.loading" },
|
||||
success: (data) => {
|
||||
let rows = [{
|
||||
label :"全选",
|
||||
permission_id :"",
|
||||
children : data.rows
|
||||
}];
|
||||
// 渲染树
|
||||
that.data.treeData = rows;
|
||||
that.data.list = data.list;
|
||||
that.initData();
|
||||
}
|
||||
});
|
||||
},
|
||||
initData(){
|
||||
let { value={} } = that;
|
||||
let { item } = value;
|
||||
let { menu_id, name, permission = [] } = item;
|
||||
let currentPermission = vk.pubfn.copyObject(permission);
|
||||
// 设置当前选中用户的权限列表
|
||||
// 去除所有含有子元素的权限
|
||||
for(let i in that.data.list){
|
||||
let item = that.data.list[i];
|
||||
let index = currentPermission.indexOf(item.parent_id);
|
||||
if(index > -1){
|
||||
currentPermission.splice(index, 1);
|
||||
}
|
||||
}
|
||||
that.data.checkedKeys = currentPermission;
|
||||
that.$refs.tree.setCheckedKeys(currentPermission);
|
||||
},
|
||||
// 监听 - 页面关闭
|
||||
onClose() {
|
||||
that.$refs.form1.resetForm(); // 关闭时,重置表单
|
||||
},
|
||||
// 监听 - 提交成功后
|
||||
onFormSuccess(res) {
|
||||
that.$set(that.value.item, "permission", that.form1.data.permissionList);
|
||||
that.value.show = false; // 关闭页面
|
||||
that.$emit("success");
|
||||
}
|
||||
},
|
||||
// 监听属性
|
||||
watch: {
|
||||
|
||||
},
|
||||
// 计算属性
|
||||
computed: {
|
||||
|
||||
}
|
||||
};
|
||||
</script>
|
||||
|
||||
<style lang="scss" scoped>
|
||||
|
||||
</style>
|
||||
@@ -0,0 +1,364 @@
|
||||
<template>
|
||||
<view class="page-body">
|
||||
<!-- 页面内容开始 -->
|
||||
|
||||
<!-- 自定义按钮区域开始 -->
|
||||
<view class="vk-table-button-box">
|
||||
<el-button type="success" size="small" icon="el-icon-circle-plus-outline" @click="addBtn">添加</el-button>
|
||||
<el-button type="primary" size="small" icon="el-icon-s-tools" :disabled="!table1.selectItem" @click="bindPermissionBtn">设置内置权限</el-button>
|
||||
<el-button type="success" size="small" icon="el-icon-circle-plus-outline" @click="addMenuByJsonBtn">通过JSON数组批量导入菜单</el-button>
|
||||
</view>
|
||||
<!-- 自定义按钮区域结束 -->
|
||||
|
||||
<!-- 表格组件开始 -->
|
||||
<vk-data-table
|
||||
ref="table1"
|
||||
:action="table1.action"
|
||||
:columns="table1.columns"
|
||||
:query-form-param="queryForm1"
|
||||
:right-btns="['detail_auto','update','delete']"
|
||||
:default-expand-all="false"
|
||||
@update="updateBtn"
|
||||
@delete="deleteBtn"
|
||||
@current-change="currentChange"
|
||||
@selection-change="selectionChange"
|
||||
>
|
||||
<!-- 排序值 -->
|
||||
<template v-slot:sort="{ row, column, index }">
|
||||
<el-input v-model="row.sort" size="mini" @change="sortChange($event, row)"/>
|
||||
</template>
|
||||
</vk-data-table>
|
||||
<!-- 表格组件结束 -->
|
||||
|
||||
<!-- 添加或编辑的弹窗开始 -->
|
||||
<vk-data-dialog
|
||||
v-model="form1.props.show"
|
||||
:title="form1.props.title"
|
||||
width="700px"
|
||||
mode="form"
|
||||
>
|
||||
<vk-data-form
|
||||
v-model="form1.data"
|
||||
:rules="form1.props.rules"
|
||||
:action="form1.props.action"
|
||||
:form-type="form1.props.formType"
|
||||
:columns='form1.props.columns'
|
||||
label-width="80px"
|
||||
@success="formSuccess"
|
||||
></vk-data-form>
|
||||
</vk-data-dialog>
|
||||
<!-- 添加或编辑的弹窗结束 -->
|
||||
|
||||
<!-- 设置角色权限组件 -->
|
||||
<bindPermission v-model="formDatas.bindPermission"></bindPermission>
|
||||
|
||||
<!-- 通过JSON批量导入菜单 -->
|
||||
<addMenuByJson v-model="formDatas.addMenuByJson" @success="refresh"></addMenuByJson>
|
||||
<!-- 页面内容结束 -->
|
||||
</view>
|
||||
</template>
|
||||
|
||||
<script>
|
||||
import bindPermission from './form/bindPermission.vue'
|
||||
import addMenuByJson from './form/addMenuByJson.vue'
|
||||
var that; // 当前页面对象
|
||||
var vk = uni.vk; // vk实例
|
||||
var originalForms = {}; // 表单初始化数据
|
||||
|
||||
const matchModeData = [
|
||||
{ value:0, label:"完整路径" },
|
||||
{ value:1, label:"通配符" },
|
||||
{ value:2, label:"正则表达式" }
|
||||
];
|
||||
const curdCategoryData = [
|
||||
{ value:1, label:"增", tagType:"success" },
|
||||
{ value:2, label:"删", tagType:"danger" },
|
||||
{ value:3, label:"改", tagType:"" },
|
||||
{ value:4, label:"查", tagType:"info" },
|
||||
{ value:5, label:"特殊", icon:"info" },
|
||||
{ value:0, label:"其他", icon:"info" },
|
||||
];
|
||||
const levelDate = [
|
||||
{ value:1, label:"子弹级", tagType:"success" },
|
||||
{ value:2, label:"炸弹级", tagType:"" },
|
||||
{ value:3, label:"榴弹级", tagType:"warning" },
|
||||
{ value:4, label:"核弹级", tagType:"danger" },
|
||||
{ value:0, label:"其他", tagType:"info" },
|
||||
];
|
||||
export default {
|
||||
components:{
|
||||
bindPermission,
|
||||
addMenuByJson
|
||||
},
|
||||
data() {
|
||||
// 页面数据变量
|
||||
return {
|
||||
// 页面是否请求中或加载中
|
||||
loading:false,
|
||||
// init请求返回的数据
|
||||
data:{
|
||||
|
||||
},
|
||||
// 表格相关开始 -----------------------------------------------------------
|
||||
table1:{
|
||||
// 表格数据请求地址
|
||||
action:"admin/system/menu/sys/getAll",
|
||||
// 表格字段显示规则
|
||||
columns: [
|
||||
/* { key:"icon", title:"图标", type:"icon", width:100, defaultValue: "el-icon-tickets"}, */
|
||||
{ key:"name", title:"菜单名称", type:"html", width:340, align:"left",
|
||||
formatter:function(val, row, column, index){
|
||||
let icon = row.icon || "el-icon-tickets";
|
||||
if(icon.indexOf("vk-icon") > -1) icon = "vk-icon " + icon;
|
||||
return `<i class="${icon}" style="margin-right: 10px;"></i><text>${row.name}</text>`;
|
||||
}
|
||||
},
|
||||
{ key:"menu_id", title:"菜单唯一标识", type:"text", width:350, align:"left" },
|
||||
{ key:"url", title:"菜单URL", type:"text", width:250, align:"left" },
|
||||
{ key:"comment", title:"备注", type:"text", width:200, align:"left" },
|
||||
{ key:"permission", title:"菜单内置权限表", type:"text", width:120, defaultValue:"无" },
|
||||
{ key:"sort", title:"排序值", type:"number", width:100 },
|
||||
{
|
||||
key: "enable", title: "是否启用", type: "switch",
|
||||
activeValue: true,
|
||||
inactiveValue: false,
|
||||
width: 80,
|
||||
watch: (res) => {
|
||||
let { value, row, change } = res;
|
||||
vk.callFunction({
|
||||
url: "admin/system/menu/sys/updateBase",
|
||||
title: value ? "启用中..." : "关闭中...",
|
||||
data: {
|
||||
_id: row._id,
|
||||
enable: value
|
||||
},
|
||||
success: data => {
|
||||
change(value); // 这一步是让表格行内的开关改变显示状态
|
||||
}
|
||||
});
|
||||
}
|
||||
},
|
||||
{
|
||||
key: "hidden_menu", title: "是否显示", type: "switch",
|
||||
activeValue: false,
|
||||
inactiveValue: true,
|
||||
width: 80,
|
||||
watch: (res) => {
|
||||
let { value, row, change } = res;
|
||||
vk.callFunction({
|
||||
url: "admin/system/menu/sys/updateBase",
|
||||
title: "请求中...",
|
||||
data: {
|
||||
_id: row._id,
|
||||
hidden_menu: value
|
||||
},
|
||||
success: data => {
|
||||
change(value); // 这一步是让表格行内的开关改变显示状态
|
||||
}
|
||||
});
|
||||
}
|
||||
},
|
||||
|
||||
{ key:"parent_id", title:"父级菜单Id", type:"text", width:250, align:"left" },
|
||||
],
|
||||
// 多选框选中的值
|
||||
multipleSelection:[],
|
||||
// 当前高亮的记录
|
||||
selectItem:"",
|
||||
},
|
||||
formDatas:{},
|
||||
// 表格相关结束 -----------------------------------------------------------
|
||||
// 表单相关开始-----------------------------------------------------------
|
||||
// 查询表单请求数据
|
||||
queryForm1:{
|
||||
// 查询表单数据源,可在此设置默认值
|
||||
formData:{
|
||||
|
||||
},
|
||||
// 查询表单的字段规则 fieldName:指定数据库字段名,不填默认等于key
|
||||
columns:[
|
||||
|
||||
]
|
||||
},
|
||||
form1: {
|
||||
// 表单请求数据,此处可以设置默认值
|
||||
data: {
|
||||
sort:0,
|
||||
enable:true,
|
||||
url:""
|
||||
},
|
||||
// 表单属性
|
||||
props: {
|
||||
// 表单请求地址
|
||||
action:"",
|
||||
// 表单字段显示规则
|
||||
columns:[
|
||||
{ key:"", title:"基础属性", type:"bar-title" },
|
||||
{ key:"menu_id", title:"菜单标识", type:"text", tips:"设置一个能表达唯一含义的标识", show:["add"] },
|
||||
{ key:"name", title:"菜单名称", type:"text", tips:"设置菜单的名称" },
|
||||
{ key:"icon", title:"图标", type:"icon", tips:"设置一个能表达权限含义的图标" },
|
||||
{ key:"url", title:"URL", type:"text", tips:"页面路径,本地路径需以 / 开头 网络路径需带http:// 或 https://" },
|
||||
{ key:"sort", title:"排序值", type:"number", tips:"越小越显示在前面" },
|
||||
{ key:"parent_id", title:"父级菜单", type:"tree-select", tips:"父级的menu_id" ,
|
||||
action:"admin/system/menu/sys/getAll",
|
||||
props: { list:"rows", value:"menu_id", label:"label", children:"children" },
|
||||
},
|
||||
{ key:"comment", title:"备注", type:"textarea",maxlength:"99",showWordLimit:true,autosize:{ minRows: 2, maxRows: 10 },
|
||||
tips:"设置一个备注来更详细的描述此权限的含义"
|
||||
},
|
||||
{ key:"enable", title:"是否启用", type:"switch",
|
||||
tips:"当关闭时,菜单将失效,再次启用时,菜单会恢复。"
|
||||
},
|
||||
{ key:"hidden_menu", title:"是否隐藏", type:"switch",
|
||||
tips:"当设为true时,菜单不显示在左侧菜单列表中。"
|
||||
},
|
||||
],
|
||||
// 表单对应的验证规则
|
||||
rules: {
|
||||
menu_id:[
|
||||
{ required:true, message:'菜单标识不能为空', trigger:'blur' },
|
||||
{ min: 2, max: 40, message:'长度在 2 到 40 个字符', trigger:'blur' },
|
||||
],
|
||||
name:[
|
||||
{ required:true, message:'菜单名称不能为空', trigger:'blur' },
|
||||
],
|
||||
sort:[
|
||||
{ type:'number', message:'排序值必须为数字'}
|
||||
]
|
||||
},
|
||||
// add 代表添加 update 代表修改
|
||||
formType:'',
|
||||
// 是否显示表单1 的弹窗
|
||||
show:false,
|
||||
}
|
||||
},
|
||||
// 表单相关结束-----------------------------------------------------------
|
||||
};
|
||||
},
|
||||
// 监听 - 页面每次【加载时】执行(如:前进)
|
||||
onLoad(options = {}) {
|
||||
that = this;
|
||||
vk = that.vk;
|
||||
that.options = options;
|
||||
that.init(options);
|
||||
},
|
||||
// 监听 - 页面【首次渲染完成时】执行。注意如果渲染速度快,会在页面进入动画完成前触发
|
||||
onReady() {},
|
||||
// 监听 - 页面每次【显示时】执行(如:前进和返回) (页面每次出现在屏幕上都触发,包括从下级页面点返回露出当前页面)
|
||||
onShow() {},
|
||||
// 监听 - 页面每次【隐藏时】执行(如:返回)
|
||||
onHide() {},
|
||||
// 函数
|
||||
methods: {
|
||||
// 页面数据初始化函数
|
||||
init(options) {
|
||||
originalForms["form1"] = vk.pubfn.copyObject(that.form1);
|
||||
},
|
||||
// 页面跳转
|
||||
pageTo(path) {
|
||||
vk.navigateTo(path);
|
||||
},
|
||||
// 表单重置
|
||||
resetForm(){
|
||||
vk.pubfn.resetForm(originalForms, that);
|
||||
},
|
||||
// 搜索
|
||||
search(){
|
||||
that.$refs.table1.query();
|
||||
},
|
||||
// 刷新
|
||||
refresh(){
|
||||
that.$refs.table1.refresh();
|
||||
},
|
||||
// 获取当前选中的行的数据
|
||||
getCurrentRow(key){
|
||||
return that.$refs.table1.getCurrentRow(key);
|
||||
},
|
||||
// 监听 - 行的选中高亮事件
|
||||
currentChange(val){
|
||||
that.table1.selectItem = val;
|
||||
},
|
||||
// 当选择项发生变化时会触发该事件
|
||||
selectionChange(list) {
|
||||
that.table1.multipleSelection = list;
|
||||
},
|
||||
// 显示添加页面
|
||||
addBtn(){
|
||||
that.resetForm();
|
||||
that.form1.props.action = 'admin/system/menu/sys/add';
|
||||
that.form1.props.formType = 'add';
|
||||
that.form1.props.title = '添加';
|
||||
that.form1.props.show = true;
|
||||
let currentRow = that.getCurrentRow();
|
||||
if(currentRow && currentRow.menu_id){
|
||||
that.$set(that.form1.data,"parent_id", currentRow.menu_id);
|
||||
that.$set(that.form1.data,"menu_id", currentRow.menu_id+"-");
|
||||
}
|
||||
},
|
||||
// 显示修改页面
|
||||
updateBtn({ item }){
|
||||
that.form1.props.action = 'admin/system/menu/sys/update';
|
||||
that.form1.props.formType = 'update';
|
||||
that.form1.props.title = '编辑';
|
||||
that.form1.props.show = true;
|
||||
that.form1.data = item;
|
||||
},
|
||||
formSuccess(){
|
||||
that.form1.props.show = false;
|
||||
// 下面的写法是为了部分修改完成后,减少一次再次请求数据库的查询
|
||||
if(that.form1.props.formType === "update"){
|
||||
let item = that.getCurrentRow(true);
|
||||
if(item.parent_id !== that.form1.data.parent_id){
|
||||
that.refresh();
|
||||
}else{
|
||||
vk.pubfn.objectAssignForVue(item, that.form1.data, that);
|
||||
}
|
||||
}else{
|
||||
that.refresh();
|
||||
}
|
||||
},
|
||||
// 删除按钮
|
||||
deleteBtn({ item, deleteFn }){
|
||||
deleteFn({
|
||||
action:"admin/system/menu/sys/delete",
|
||||
data:{
|
||||
menu_id: item.menu_id
|
||||
},
|
||||
});
|
||||
},
|
||||
// 设置内置权限
|
||||
bindPermissionBtn(){
|
||||
let item = that.getCurrentRow(true);
|
||||
vk.pubfn.openForm('bindPermission',{ item });
|
||||
},
|
||||
addMenuByJsonBtn(){
|
||||
let item = that.getCurrentRow();
|
||||
vk.pubfn.openForm('addMenuByJson',{ item });
|
||||
},
|
||||
// 修改排序值
|
||||
sortChange(sort, item){
|
||||
vk.callFunction({
|
||||
url: 'admin/system/menu/sys/updateBase',
|
||||
data: {
|
||||
_id: item._id,
|
||||
sort: Number(sort)
|
||||
},
|
||||
success: (data) => {
|
||||
|
||||
}
|
||||
});
|
||||
},
|
||||
},
|
||||
// 监听属性
|
||||
watch: {
|
||||
|
||||
},
|
||||
// 计算属性
|
||||
computed: {
|
||||
|
||||
}
|
||||
};
|
||||
</script>
|
||||
<style lang="scss" scoped>
|
||||
|
||||
</style>
|
||||
@@ -0,0 +1,105 @@
|
||||
<template>
|
||||
<vk-data-dialog
|
||||
v-model="value.show"
|
||||
:title="page.title"
|
||||
:top="page.top"
|
||||
:width="page.width"
|
||||
:close-on-click-modal="true"
|
||||
@open="onOpen"
|
||||
@closed="onClose"
|
||||
>
|
||||
<vk-data-input-radio
|
||||
v-model="form1.curd_category"
|
||||
:localdata="localdata"
|
||||
option-type="button"
|
||||
@change="onChange"
|
||||
></vk-data-input-radio>
|
||||
<!-- 页面主体内容结束 -->
|
||||
</vk-data-dialog>
|
||||
</template>
|
||||
|
||||
<script>
|
||||
var that; // 当前页面对象
|
||||
var vk = uni.vk; // vk实例
|
||||
|
||||
export default {
|
||||
props: {
|
||||
value: {
|
||||
Type: Object,
|
||||
default: function() {
|
||||
return {
|
||||
show: false,
|
||||
mode: "",
|
||||
item: {}
|
||||
};
|
||||
}
|
||||
}
|
||||
},
|
||||
data: function() {
|
||||
// 组件创建时,进行数据初始化
|
||||
return {
|
||||
page: {
|
||||
title: "修改权限分类",
|
||||
top: "20vh",
|
||||
width: "460px"
|
||||
},
|
||||
form1:{
|
||||
_id:"",
|
||||
},
|
||||
localdata:[
|
||||
{ value:1, label:"增加", tagType:"success" },
|
||||
{ value:2, label:"删除", tagType:"danger" },
|
||||
{ value:3, label:"修改", tagType:"" },
|
||||
{ value:4, label:"查询", tagType:"info" },
|
||||
{ value:5, label:"特殊", tagType:"warning" },
|
||||
{ value:0, label:"其他", tagType:"warning" },
|
||||
],
|
||||
};
|
||||
},
|
||||
mounted() {
|
||||
that = this;
|
||||
that.init();
|
||||
},
|
||||
methods: {
|
||||
// 初始化
|
||||
init() {
|
||||
let { value } = that;
|
||||
that.$emit("input", value);
|
||||
},
|
||||
// 监听 - 页面打开
|
||||
onOpen() {
|
||||
that = this;
|
||||
let { item={} } = that.value;
|
||||
// 每次打开时,重新设置表单的值 = value.item 的值,item通过 vk.pubfn.openForm('表单名',{ item:{ _id:"1" } }) 传递值
|
||||
that.form1 = {
|
||||
_id: item._id,
|
||||
curd_category: item.curd_category
|
||||
}
|
||||
},
|
||||
// 监听 - 页面关闭
|
||||
onClose() {
|
||||
//that.$refs.form1.resetForm(); // 关闭时,重置表单
|
||||
},
|
||||
onChange(value){
|
||||
vk.callFunction({
|
||||
url: 'admin/system/permission/sys/updateCategory',
|
||||
title:'请求中...',
|
||||
data:that.form1,
|
||||
success:function(data){
|
||||
that.$set(that.value.item,"curd_category",value);
|
||||
that.value.show = false; // 关闭页面
|
||||
that.$emit("success");
|
||||
}
|
||||
});
|
||||
},
|
||||
},
|
||||
// 监听属性
|
||||
watch: {
|
||||
|
||||
},
|
||||
// 计算属性
|
||||
computed: {}
|
||||
};
|
||||
</script>
|
||||
|
||||
<style lang="scss" scoped></style>
|
||||
@@ -0,0 +1,106 @@
|
||||
<template>
|
||||
<vk-data-dialog
|
||||
v-model="value.show"
|
||||
:title="page.title"
|
||||
:top="page.top"
|
||||
:width="page.width"
|
||||
:close-on-click-modal="true"
|
||||
@open="onOpen"
|
||||
@closed="onClose"
|
||||
>
|
||||
<vk-data-input-radio
|
||||
v-model="form1.level"
|
||||
:localdata="localdata"
|
||||
option-type="button"
|
||||
@change="onChange"
|
||||
></vk-data-input-radio>
|
||||
<!-- 页面主体内容结束 -->
|
||||
</vk-data-dialog>
|
||||
</template>
|
||||
|
||||
<script>
|
||||
var that; // 当前页面对象
|
||||
var vk = uni.vk; // vk实例
|
||||
|
||||
export default {
|
||||
props: {
|
||||
value: {
|
||||
Type: Object,
|
||||
default: function() {
|
||||
return {
|
||||
show: false,
|
||||
mode: "",
|
||||
item: {}
|
||||
};
|
||||
}
|
||||
}
|
||||
},
|
||||
data: function() {
|
||||
// 组件创建时,进行数据初始化
|
||||
return {
|
||||
page: {
|
||||
title: "修改权限分类",
|
||||
top: "20vh",
|
||||
width: "460px"
|
||||
},
|
||||
form1:{
|
||||
_id:"",
|
||||
},
|
||||
localdata:[
|
||||
{ value:1, label:"子弹级", tagType:"success" },
|
||||
{ value:2, label:"炸弹级", tagType:"" },
|
||||
{ value:3, label:"榴弹级", tagType:"warning" },
|
||||
{ value:4, label:"核弹级", tagType:"danger" },
|
||||
{ value:0, label:"其他", tagType:"info" },
|
||||
],
|
||||
};
|
||||
},
|
||||
mounted() {
|
||||
that = this;
|
||||
that.init();
|
||||
},
|
||||
methods: {
|
||||
// 初始化
|
||||
init() {
|
||||
let { value } = that;
|
||||
that.$emit("input", value);
|
||||
},
|
||||
// 监听 - 页面打开
|
||||
onOpen() {
|
||||
that = this;
|
||||
let { item={} } = that.value;
|
||||
// 每次打开时,重新设置表单的值 = value.item 的值,item通过 vk.pubfn.openForm('表单名',{ item:{ _id:"1" } }) 传递值
|
||||
that.form1 = {
|
||||
_id: item._id,
|
||||
level: item.level
|
||||
}
|
||||
},
|
||||
// 监听 - 页面关闭
|
||||
onClose() {
|
||||
//that.$refs.form1.resetForm(); // 关闭时,重置表单
|
||||
},
|
||||
onChange(value){
|
||||
vk.callFunction({
|
||||
url: 'admin/system/permission/sys/updateLevel',
|
||||
title:'请求中...',
|
||||
data:that.form1,
|
||||
success:function(data){
|
||||
that.$set(that.value.item,"level",value);
|
||||
that.value.show = false; // 关闭页面
|
||||
that.$emit("success");
|
||||
}
|
||||
});
|
||||
},
|
||||
},
|
||||
// 监听属性
|
||||
watch: {
|
||||
|
||||
},
|
||||
// 计算属性
|
||||
computed: {
|
||||
|
||||
}
|
||||
};
|
||||
</script>
|
||||
|
||||
<style lang="scss" scoped></style>
|
||||
@@ -0,0 +1,386 @@
|
||||
<template>
|
||||
<view class="page-body">
|
||||
<!-- 页面内容开始 -->
|
||||
|
||||
<!-- 自定义按钮区域开始 -->
|
||||
<view class="vk-table-button-box">
|
||||
<el-button type="success" size="small" icon="el-icon-circle-plus-outline" @click="addBtn">添加</el-button>
|
||||
</view>
|
||||
<!-- 自定义按钮区域结束 -->
|
||||
|
||||
<!-- 表格组件开始 -->
|
||||
<vk-data-table
|
||||
ref="table1"
|
||||
:action="table1.action"
|
||||
:columns="table1.columns"
|
||||
:query-form-param="queryForm1"
|
||||
:right-btns="['detail_auto','update','delete']"
|
||||
:default-expand-all="false"
|
||||
@update="updateBtn"
|
||||
@delete="deleteBtn"
|
||||
@current-change="currentChange"
|
||||
@selection-change="selectionChange"
|
||||
@cell-click="cellClick"
|
||||
>
|
||||
<!-- 排序值 -->
|
||||
<template v-slot:sort="{ row, column, index }">
|
||||
<el-input v-model="row.sort" size="mini" @change="sortChange($event, row)"/>
|
||||
</template>
|
||||
</vk-data-table>
|
||||
<!-- 表格组件结束 -->
|
||||
|
||||
<!-- 添加或编辑的弹窗开始 -->
|
||||
<vk-data-dialog
|
||||
v-model="form1.props.show"
|
||||
:title="form1.props.title"
|
||||
width="700px"
|
||||
mode="form"
|
||||
>
|
||||
<vk-data-form
|
||||
v-model="form1.data"
|
||||
:rules="form1.props.rules"
|
||||
:action="form1.props.action"
|
||||
:form-type="form1.props.formType"
|
||||
:columns='form1.props.columns'
|
||||
label-width="80px"
|
||||
@success="formSuccess"
|
||||
></vk-data-form>
|
||||
</vk-data-dialog>
|
||||
<!-- 添加或编辑的弹窗结束 -->
|
||||
<!-- 修改分类 -->
|
||||
<updateCategory v-model="formDatas.updateCategory"></updateCategory>
|
||||
<!-- 修改等级 -->
|
||||
<updateLevel v-model="formDatas.updateLevel"></updateLevel>
|
||||
<!-- 页面内容结束 -->
|
||||
</view>
|
||||
</template>
|
||||
|
||||
<script>
|
||||
var that; // 当前页面对象
|
||||
var vk = uni.vk; // vk实例
|
||||
var originalForms = {}; // 表单初始化数据
|
||||
|
||||
const matchModeData = [
|
||||
{ value:0, label:"完整路径" },
|
||||
{ value:1, label:"通配符" },
|
||||
{ value:2, label:"正则表达式" }
|
||||
];
|
||||
|
||||
import updateCategory from './form/updateCategory'
|
||||
import updateLevel from './form/updateLevel'
|
||||
|
||||
export default {
|
||||
components:{
|
||||
updateCategory,
|
||||
updateLevel
|
||||
},
|
||||
data() {
|
||||
// 页面数据变量
|
||||
return {
|
||||
// 页面是否请求中或加载中
|
||||
loading:false,
|
||||
// init请求返回的数据
|
||||
data:{
|
||||
|
||||
},
|
||||
// 表格相关开始 -----------------------------------------------------------
|
||||
table1:{
|
||||
// 表格数据请求地址
|
||||
action:"admin/system/permission/sys/getAll",
|
||||
// 表格字段显示规则
|
||||
columns: [
|
||||
{ key:"permission_id", title:"权限标识", type:"text", width:310, align:"left",
|
||||
treeNode:true
|
||||
},
|
||||
{ key:"permission_name", title:"权限名称", type:"text", width:120, align:"left" },
|
||||
{ key:"comment", title:"备注", type:"text", width:180, align:"left" },
|
||||
{ key:"url", title:"URL", type:"text", width:250, align:"left" },
|
||||
{ key:"match_mode", title:"匹配模式", type:"text", width:100,
|
||||
formatter:function(val, row, column, index){
|
||||
if(typeof val === "undefined" || row.type == 0 || !row.url || row.url.length == 0) return "";
|
||||
return matchModeData[val].label;
|
||||
}
|
||||
},
|
||||
{ key:"curd_category", title:"权限分类", type:"tag", width:100,
|
||||
data: [
|
||||
{ value:1, label:"增", tagType:"success" },
|
||||
{ value:2, label:"删", tagType:"danger" },
|
||||
{ value:3, label:"改", tagType:"" },
|
||||
{ value:4, label:"查", tagType:"info" },
|
||||
{ value:5, label:"特", tagType:"warning" },
|
||||
//{ value:0, label:"其他", tagType:"warning" },
|
||||
]
|
||||
},
|
||||
{ key:"level", title:"权限级别", type:"tag", width:100,
|
||||
data: [
|
||||
{ value:1, label:"子弹级", tagType:"success" },
|
||||
{ value:2, label:"炸弹级", tagType:"" },
|
||||
{ value:3, label:"榴弹级", tagType:"warning" },
|
||||
{ value:4, label:"核弹级", tagType:"danger" },
|
||||
]
|
||||
},
|
||||
{ key:"sort", title:"排序值", type:"number", width:80 },
|
||||
{
|
||||
key: "enable", title: "是否启用", type: "switch",
|
||||
activeValue: true,
|
||||
inactiveValue: false,
|
||||
width: 80,
|
||||
watch: (res) => {
|
||||
let { value, row, change } = res;
|
||||
vk.callFunction({
|
||||
url: "admin/system/permission/sys/updateBase",
|
||||
title: value ? "启用中..." : "关闭中...",
|
||||
data: {
|
||||
_id: row._id,
|
||||
enable: value
|
||||
},
|
||||
success: data => {
|
||||
change(value); // 这一步是让表格行内的开关改变显示状态
|
||||
}
|
||||
});
|
||||
}
|
||||
}
|
||||
],
|
||||
// 多选框选中的值
|
||||
multipleSelection:[],
|
||||
// 当前高亮的记录
|
||||
selectItem:"",
|
||||
},
|
||||
// 表格相关结束 -----------------------------------------------------------
|
||||
// 表单相关开始-----------------------------------------------------------
|
||||
// 查询表单请求数据
|
||||
queryForm1:{
|
||||
// 查询表单数据源,可在此设置默认值
|
||||
formData:{
|
||||
|
||||
},
|
||||
// 查询表单的字段规则 fieldName:指定数据库字段名,不填默认等于key
|
||||
columns:[
|
||||
|
||||
]
|
||||
},
|
||||
form1: {
|
||||
// 表单请求数据,此处可以设置默认值
|
||||
data: {
|
||||
sort:0,
|
||||
enable:true,
|
||||
match_mode:0,
|
||||
url:[""]
|
||||
},
|
||||
// 表单属性
|
||||
props: {
|
||||
// 表单请求地址
|
||||
action:"",
|
||||
// 表单字段显示规则
|
||||
columns:[
|
||||
{ key:"", title:"基础属性", type:"bar-title" },
|
||||
{ key:"permission_id", title:"标识", type:"text", disabled:["update"],
|
||||
tips:"全局唯一,添加后不可修改,请尽量语义化。如:user-manage、user-add"
|
||||
},
|
||||
{ key:"permission_name", title:"名称", type:"text",
|
||||
tips:"起一个容易表达权限含义的名称"
|
||||
},
|
||||
{
|
||||
key:"url", title:"URL", type:"array<string>", tips:"云函数路径,若该权限只是父权限分组用,点击清空即可。",
|
||||
isUnique:true,
|
||||
rules:[
|
||||
{ required:true, message:"该项不能为空", trigger:["change","blur"] },
|
||||
]
|
||||
},
|
||||
{ key:"match_mode", title:"匹配模式", type:"radio", width:100,
|
||||
data:matchModeData,
|
||||
tips:"选择合适的匹配模式"
|
||||
},
|
||||
{ key:"parent_id", title:"父级权限", type:"tree-select", tips:"父级的permission_id" ,
|
||||
action:"admin/system/permission/sys/getAll",
|
||||
props: { list:"rows", value:"permission_id", label:"label", children:"children" },
|
||||
},
|
||||
{ key:"sort", title:"排序值", type:"number", tips:"越小越显示在前面" },
|
||||
{ key:"comment", title:"备注", type:"textarea",maxlength:"99",showWordLimit:true,autosize:{ minRows: 2, maxRows: 10 },
|
||||
tips:"设置一个备注来更详细的描述此权限的含义"
|
||||
},
|
||||
{ key:"enable", title:"是否启用", type:"switch",
|
||||
tips:"当关闭时,权限将失效,再次启用时,权限会恢复。"
|
||||
},
|
||||
{ key:"", title:"高级属性", type:"bar-title" },
|
||||
{ key:"curd_category", title:"权限分类", type:"radio", width:100,
|
||||
data:[
|
||||
{ value:1, label:"增", tagType:"success" },
|
||||
{ value:2, label:"删", tagType:"danger" },
|
||||
{ value:3, label:"改", tagType:"" },
|
||||
{ value:4, label:"查", tagType:"info" },
|
||||
{ value:5, label:"特", tagType:"warning" },
|
||||
{ value:0, label:"其他", tagType:"warning" },
|
||||
],
|
||||
tips:"给权限分一个类,方便查询和表达含义"
|
||||
},
|
||||
{ key:"level", title:"权限级别", type:"radio", width:100,
|
||||
data:[
|
||||
{ value:1, label:"子弹级", tagType:"success" },
|
||||
{ value:2, label:"炸弹级", tagType:"" },
|
||||
{ value:3, label:"榴弹级", tagType:"warning" },
|
||||
{ value:4, label:"核弹级", tagType:"danger" },
|
||||
{ value:0, label:"其他", tagType:"info" },
|
||||
],
|
||||
tips:"给权限(菜单)一个级别,方便查询和表达重要程度"
|
||||
},
|
||||
],
|
||||
// 表单对应的验证规则
|
||||
rules: {
|
||||
permission_id:[
|
||||
{ required:true, message:'权限标识不能为空', trigger:'blur' },
|
||||
],
|
||||
permission_name:[
|
||||
{ required:true, message:'权限名称不能为空', trigger:'blur' },
|
||||
],
|
||||
sort:[
|
||||
{ type:'number', message:'排序值必须为数字'}
|
||||
]
|
||||
},
|
||||
// add 代表添加 update 代表修改
|
||||
formType:'',
|
||||
// 是否显示表单1 的弹窗
|
||||
show:false,
|
||||
}
|
||||
},
|
||||
// 其他表单属性容器(请勿修改)
|
||||
formDatas:{},
|
||||
// 表单相关结束-----------------------------------------------------------
|
||||
|
||||
};
|
||||
},
|
||||
// 监听 - 页面每次【加载时】执行(如:前进)
|
||||
onLoad(options = {}) {
|
||||
that = this;
|
||||
vk = that.vk;
|
||||
that.options = options;
|
||||
that.init(options);
|
||||
},
|
||||
// 监听 - 页面【首次渲染完成时】执行。注意如果渲染速度快,会在页面进入动画完成前触发
|
||||
onReady() {},
|
||||
// 监听 - 页面每次【显示时】执行(如:前进和返回) (页面每次出现在屏幕上都触发,包括从下级页面点返回露出当前页面)
|
||||
onShow() {},
|
||||
// 监听 - 页面每次【隐藏时】执行(如:返回)
|
||||
onHide() {},
|
||||
// 函数
|
||||
methods: {
|
||||
// 页面数据初始化函数
|
||||
init(options) {
|
||||
originalForms["form1"] = vk.pubfn.copyObject(that.form1);
|
||||
},
|
||||
// 页面跳转
|
||||
pageTo(path) {
|
||||
vk.navigateTo(path);
|
||||
},
|
||||
// 表单重置
|
||||
resetForm(){
|
||||
vk.pubfn.resetForm(originalForms, that);
|
||||
},
|
||||
// 搜索
|
||||
search(){
|
||||
that.$refs.table1.query();
|
||||
},
|
||||
// 刷新
|
||||
refresh(){
|
||||
that.$refs.table1.refresh();
|
||||
},
|
||||
// 获取当前选中的行的数据
|
||||
getCurrentRow(key){
|
||||
return that.$refs.table1.getCurrentRow(key);
|
||||
},
|
||||
// 监听 - 行的选中高亮事件
|
||||
currentChange(val){
|
||||
that.table1.selectItem = val;
|
||||
},
|
||||
// 当选择项发生变化时会触发该事件
|
||||
selectionChange(list) {
|
||||
that.table1.multipleSelection = list;
|
||||
},
|
||||
// 显示添加页面
|
||||
addBtn(){
|
||||
that.resetForm();
|
||||
that.form1.props.action = 'admin/system/permission/sys/add';
|
||||
that.form1.props.formType = 'add';
|
||||
that.form1.props.title = '添加';
|
||||
that.form1.props.show = true;
|
||||
let currentRow = that.getCurrentRow();
|
||||
if(currentRow && currentRow.permission_id){
|
||||
// 设置的方法
|
||||
that.$set(that.form1.data,"parent_id", currentRow.permission_id);
|
||||
that.$set(that.form1.data,"permission_id", currentRow.permission_id+"-");
|
||||
}
|
||||
},
|
||||
// 显示修改页面
|
||||
updateBtn({ item }){
|
||||
that.form1.props.action = 'admin/system/permission/sys/update';
|
||||
that.form1.props.formType = 'update';
|
||||
that.form1.props.title = '编辑';
|
||||
that.form1.props.show = true;
|
||||
that.form1.data = item;
|
||||
},
|
||||
formSuccess(){
|
||||
that.form1.props.show = false;
|
||||
// 下面的写法是为了部分修改完成后,减少一次再次请求数据库的查询
|
||||
if(that.form1.props.formType === "update"){
|
||||
let item = that.getCurrentRow(true);
|
||||
if(item.parent_id !== that.form1.data.parent_id){
|
||||
that.refresh();
|
||||
}else{
|
||||
vk.pubfn.objectAssign(item, that.form1.data);
|
||||
}
|
||||
}else{
|
||||
that.refresh();
|
||||
}
|
||||
},
|
||||
// 删除按钮
|
||||
deleteBtn({ item, deleteFn }){
|
||||
deleteFn({
|
||||
action:"admin/system/permission/sys/delete",
|
||||
data:{
|
||||
permission_id: item.permission_id
|
||||
},
|
||||
});
|
||||
},
|
||||
cellClick(row, column, cell, event){
|
||||
let key = column.property;
|
||||
if(key === "curd_category"){
|
||||
// 修改分类
|
||||
let item = that.getCurrentRow(true);
|
||||
vk.pubfn.openForm('updateCategory', { item });
|
||||
}else if(key === "level"){
|
||||
// 修改等级
|
||||
let item = that.getCurrentRow(true);
|
||||
vk.pubfn.openForm('updateLevel', { item });
|
||||
}
|
||||
},
|
||||
// 修改排序值
|
||||
sortChange(sort, item){
|
||||
vk.callFunction({
|
||||
url: 'admin/system/permission/sys/updateBase',
|
||||
data: {
|
||||
_id: item._id,
|
||||
sort: Number(sort)
|
||||
},
|
||||
success: (data) => {
|
||||
|
||||
}
|
||||
});
|
||||
},
|
||||
},
|
||||
// 监听属性
|
||||
watch: {
|
||||
|
||||
},
|
||||
// 过滤器
|
||||
filters: {
|
||||
|
||||
},
|
||||
// 计算属性
|
||||
computed: {
|
||||
|
||||
}
|
||||
};
|
||||
</script>
|
||||
<style lang="scss" scoped>
|
||||
|
||||
</style>
|
||||
@@ -0,0 +1,215 @@
|
||||
<template>
|
||||
<vk-data-dialog
|
||||
v-model="value.show"
|
||||
:title="page.title"
|
||||
:top="page.top"
|
||||
:width="page.width"
|
||||
mode="form"
|
||||
@open="onOpen"
|
||||
@closed="onClose"
|
||||
>
|
||||
<!-- 页面主体内容开始 -->
|
||||
<vk-data-form
|
||||
v-loading="page.loading"
|
||||
ref="form1"
|
||||
v-model="form1.data"
|
||||
:form-type="value.mode"
|
||||
:rules="form1.props.rules"
|
||||
:action="form1.props.action"
|
||||
:columns="form1.props.columns"
|
||||
:loading.sync="form1.props.loading"
|
||||
:labelWidth="form1.props.labelWidth"
|
||||
:before-action="form1.props.beforeAction"
|
||||
:show-cancel="page.showCancel"
|
||||
:cancel-text="page.cancelText"
|
||||
:submit-text="page.submitText"
|
||||
@success="onFormSuccess"
|
||||
>
|
||||
<template v-slot:menuList>
|
||||
<el-tree
|
||||
ref="tree"
|
||||
:data="data.treeData"
|
||||
:node-key="data.nodeKey"
|
||||
:default-checked-keys="data.checkedKeys"
|
||||
:props="{
|
||||
children: 'children',
|
||||
label: 'label'
|
||||
}"
|
||||
show-checkbox
|
||||
default-expand-all
|
||||
expand-on-click-node
|
||||
></el-tree>
|
||||
</template>
|
||||
</vk-data-form>
|
||||
<!-- 页面主体内容结束 -->
|
||||
</vk-data-dialog>
|
||||
</template>
|
||||
|
||||
<script>
|
||||
var that; // 当前页面对象
|
||||
var vk = uni.vk; // vk实例
|
||||
export default {
|
||||
props: {
|
||||
value: {
|
||||
Type: Object,
|
||||
default: function() {
|
||||
return {
|
||||
show: false,
|
||||
mode: "",
|
||||
item: ""
|
||||
};
|
||||
}
|
||||
}
|
||||
},
|
||||
data: function() {
|
||||
// 组件创建时,进行数据初始化
|
||||
return {
|
||||
data:{
|
||||
list:[],
|
||||
// 权限的树形结构数据
|
||||
treeData: [],
|
||||
// 默认选中的权限列表
|
||||
checkedKeys:[],
|
||||
// 树的唯一标识
|
||||
nodeKey:"menu_id",
|
||||
},
|
||||
page: {
|
||||
title: "菜单赋予",
|
||||
submitText: "确定",
|
||||
cancelText: "关闭",
|
||||
showCancel: true,
|
||||
top: "7vh",
|
||||
width:"800px",
|
||||
loading: false
|
||||
},
|
||||
form1: {
|
||||
// 表单请求数据,此处可以设置默认值
|
||||
data: {
|
||||
role_id:"",
|
||||
reset:true,
|
||||
menuList:[],
|
||||
addPermission:true
|
||||
},
|
||||
// 表单属性
|
||||
props: {
|
||||
// 表单请求地址
|
||||
action: "admin/system/role/sys/bindMenu",
|
||||
// 表单字段显示规则
|
||||
columns: [
|
||||
{ key: "addPermission", title: "同时赋予菜单内置权限", type: "switch" },
|
||||
{ key: "menuList", title: "菜单列表", type: "text", showLabel:false },
|
||||
],
|
||||
// 表单验证规则
|
||||
rules: {
|
||||
|
||||
},
|
||||
labelWidth: "160px",
|
||||
beforeAction:function(formData){
|
||||
let checkedKeys = that.$refs.tree.getCheckedKeys();
|
||||
let halfCheckedKeys = that.$refs.tree.getHalfCheckedKeys();
|
||||
let allCheckedKeys = checkedKeys.concat(halfCheckedKeys);
|
||||
// 去除空属性
|
||||
for(let i = 0;i<allCheckedKeys.length;i++){
|
||||
if(vk.pubfn.isNull(allCheckedKeys[i])){
|
||||
allCheckedKeys.splice(i, 1);
|
||||
i--;
|
||||
}
|
||||
}
|
||||
formData.menuList = allCheckedKeys;
|
||||
return formData;
|
||||
}
|
||||
}
|
||||
}
|
||||
};
|
||||
},
|
||||
mounted() {
|
||||
that = this;
|
||||
that.init();
|
||||
},
|
||||
methods: {
|
||||
// 初始化
|
||||
init() {
|
||||
let { value } = that;
|
||||
that.$emit("input", value);
|
||||
},
|
||||
// 监听 - 页面打开
|
||||
onOpen() {
|
||||
that = this;
|
||||
let { value={} } = that;
|
||||
let { item } = value;
|
||||
let { role_id, role_name, menu = [] } = item;
|
||||
|
||||
that.page.title = `菜单赋予(${role_name})`;
|
||||
|
||||
that.form1.data.role_id = role_id;
|
||||
that.form1.data.menuList = menu;
|
||||
if (vk.pubfn.isNotNull(that.data.treeData)){
|
||||
that.initData();
|
||||
return;
|
||||
}
|
||||
that.getList();
|
||||
},
|
||||
getList(){
|
||||
vk.callFunction({
|
||||
url: 'admin/system/menu/sys/getAll',
|
||||
loading:{ that, name:"page.loading" },
|
||||
data: {},
|
||||
success: (data) => {
|
||||
let rows = [{
|
||||
label :"全选",
|
||||
menu_id :"",
|
||||
children : data.rows
|
||||
}];
|
||||
// 渲染树
|
||||
that.data.treeData = rows;
|
||||
that.data.list = data.list;
|
||||
that.initData();
|
||||
}
|
||||
});
|
||||
},
|
||||
initData(){
|
||||
let { value={} } = that;
|
||||
let { item } = value;
|
||||
let { role_id, role_name, menu = [] } = item;
|
||||
|
||||
let current = vk.pubfn.copyObject(menu);
|
||||
// 设置当前选中用户的权限列表
|
||||
// 去除所有含有子元素的权限
|
||||
for(let i in that.data.list){
|
||||
let item = that.data.list[i];
|
||||
let index = current.indexOf(item.parent_id);
|
||||
if(index > -1){
|
||||
current.splice(index, 1);
|
||||
}
|
||||
}
|
||||
that.data.checkedKeys = current;
|
||||
that.$refs.tree.setCheckedKeys(current);
|
||||
},
|
||||
// 监听 - 页面关闭
|
||||
onClose() {
|
||||
that.$refs.form1.resetForm(); // 关闭时,重置表单
|
||||
},
|
||||
// 监听 - 提交成功后
|
||||
onFormSuccess(res) {
|
||||
if (res.data.info) {
|
||||
that.$set(that.value.item, "menu", res.data.info.menu);
|
||||
that.$set(that.value.item, "stats_count_info", res.data.info.stats_count_info);
|
||||
}
|
||||
that.value.show = false; // 关闭页面
|
||||
that.$emit("success");
|
||||
}
|
||||
},
|
||||
// 监听属性
|
||||
watch: {
|
||||
|
||||
},
|
||||
// 计算属性
|
||||
computed: {
|
||||
|
||||
}
|
||||
};
|
||||
</script>
|
||||
|
||||
<style lang="scss" scoped>
|
||||
|
||||
</style>
|
||||
@@ -0,0 +1,264 @@
|
||||
<template>
|
||||
<vk-data-dialog
|
||||
v-model="value.show"
|
||||
:title="page.title"
|
||||
:top="page.top"
|
||||
:width="page.width"
|
||||
mode="form"
|
||||
@open="onOpen"
|
||||
@closed="onClose"
|
||||
>
|
||||
<!-- 页面主体内容开始 -->
|
||||
<vk-data-form
|
||||
v-loading="page.loading"
|
||||
ref="form1"
|
||||
v-model="form1.data"
|
||||
:form-type="value.mode"
|
||||
:rules="form1.props.rules"
|
||||
:action="form1.props.action"
|
||||
:columns="form1.props.columns"
|
||||
:loading.sync="form1.props.loading"
|
||||
:labelWidth="form1.props.labelWidth"
|
||||
:before-action="form1.props.beforeAction"
|
||||
:show-cancel="page.showCancel"
|
||||
:cancel-text="page.cancelText"
|
||||
:submit-text="page.submitText"
|
||||
@success="onFormSuccess"
|
||||
>
|
||||
<template v-slot:permissionList>
|
||||
<el-tree
|
||||
ref="tree"
|
||||
:data="data.treeData"
|
||||
:node-key="data.nodeKey"
|
||||
:default-checked-keys="data.checkedKeys"
|
||||
:props="{
|
||||
children: 'children',
|
||||
label: 'label'
|
||||
}"
|
||||
show-checkbox
|
||||
default-expand-all
|
||||
expand-on-click-node
|
||||
></el-tree>
|
||||
</template>
|
||||
</vk-data-form>
|
||||
<!-- 页面主体内容结束 -->
|
||||
</vk-data-dialog>
|
||||
</template>
|
||||
|
||||
<script>
|
||||
var that; // 当前页面对象
|
||||
var vk = uni.vk; // vk实例
|
||||
export default {
|
||||
props: {
|
||||
value: {
|
||||
Type: Object,
|
||||
default: function() {
|
||||
return {
|
||||
show: false,
|
||||
mode: "",
|
||||
item: ""
|
||||
};
|
||||
}
|
||||
}
|
||||
},
|
||||
data: function() {
|
||||
// 组件创建时,进行数据初始化
|
||||
return {
|
||||
data:{
|
||||
list:[],
|
||||
info:{},
|
||||
// 权限的树形结构数据
|
||||
treeData: [],
|
||||
// 默认选中的权限列表
|
||||
checkedKeys:[],
|
||||
// 树的唯一标识
|
||||
nodeKey:"permission_id",
|
||||
},
|
||||
page: {
|
||||
title: "权限赋予",
|
||||
submitText: "确定",
|
||||
cancelText: "关闭",
|
||||
showCancel: true,
|
||||
top: "7vh",
|
||||
width:"800px",
|
||||
loading: false
|
||||
},
|
||||
form1: {
|
||||
// 表单请求数据,此处可以设置默认值
|
||||
data: {
|
||||
role_id:"",
|
||||
reset:true,
|
||||
permissionList:[],
|
||||
stats_count_info:{}
|
||||
},
|
||||
// 表单属性
|
||||
props: {
|
||||
// 表单请求地址
|
||||
action: "admin/system/role/sys/bindPermission",
|
||||
// 表单字段显示规则
|
||||
columns: [
|
||||
// 常用字段类型
|
||||
{ key: "permissionList", title: "权限列表", type: "text" }
|
||||
],
|
||||
// 表单验证规则
|
||||
rules: {
|
||||
|
||||
},
|
||||
labelWidth: "100px",
|
||||
beforeAction:function(formData){
|
||||
let checkedKeys = that.$refs.tree.getCheckedKeys();
|
||||
let halfCheckedKeys = that.$refs.tree.getHalfCheckedKeys();
|
||||
let allCheckedKeys = checkedKeys.concat(halfCheckedKeys);
|
||||
// 去除空属性
|
||||
for(let i = 0;i<allCheckedKeys.length;i++){
|
||||
if(vk.pubfn.isNull(allCheckedKeys[i])){
|
||||
allCheckedKeys.splice(i, 1);
|
||||
i--;
|
||||
}
|
||||
}
|
||||
formData.permissionList = allCheckedKeys;
|
||||
let menuNum = vk.pubfn.getData(that.data,"info.stats_count_info.type[0].count",0);
|
||||
if(typeof menuNum !== "number") menuNum = 0;
|
||||
let list = vk.pubfn.treeToArray(that.data.treeData, {
|
||||
id:"permission_id",
|
||||
parent_id:"parent_id",
|
||||
children:"children",
|
||||
deleteChildren:true
|
||||
});
|
||||
let stats_count_info = {
|
||||
// 各个分类有多少个数量
|
||||
curd_category: [
|
||||
{ type: 0, label: "未分类", count: 0 },
|
||||
{ type: 1, label: "增", count: 0 },
|
||||
{ type: 2, label: "删", count: 0 },
|
||||
{ type: 3, label: "改", count: 0 },
|
||||
{ type: 4, label: "查", count: 0 },
|
||||
{ type: 5, label: "特殊", count: 0 }
|
||||
],
|
||||
// 各个等级有多少个数量
|
||||
level: [
|
||||
{ type: 0, label: "未分类", count: 0 },
|
||||
{ type: 1, label: "子弹级", count: 0 },
|
||||
{ type: 2, label: "炸弹级", count: 0 },
|
||||
{ type: 3, label: "榴弹级", count: 0 },
|
||||
{ type: 4, label: "核弹级", count: 0 }
|
||||
],
|
||||
// 各个模式有多少个数量
|
||||
match_mode: [
|
||||
{ type: 0, label: "完整路径", count: 0 },
|
||||
{ type: 1, label: "通配符", count: 0 },
|
||||
{ type: 2, label: "正则表达式", count: 0 }
|
||||
],
|
||||
// 菜单和权限分别多少个数量
|
||||
type: [
|
||||
{ type: 0, label: "菜单", count: menuNum },
|
||||
{ type: 1, label: "权限", count: 0 }
|
||||
]
|
||||
};
|
||||
allCheckedKeys.forEach((value,index,arr)=>{
|
||||
let res = vk.pubfn.getListItem(list,"permission_id",value);
|
||||
let { curd_category=0, level=0, match_mode=0, url } = res;
|
||||
if(vk.pubfn.isNotNull(url)){
|
||||
stats_count_info["type"][1].count++;
|
||||
stats_count_info["curd_category"][curd_category].count++;
|
||||
stats_count_info["level"][level].count++;
|
||||
stats_count_info["match_mode"][match_mode].count++;
|
||||
};
|
||||
});
|
||||
formData.stats_count_info = stats_count_info;
|
||||
return formData;
|
||||
}
|
||||
}
|
||||
}
|
||||
};
|
||||
},
|
||||
mounted() {
|
||||
that = this;
|
||||
that.init();
|
||||
},
|
||||
methods: {
|
||||
// 初始化
|
||||
init() {
|
||||
let { value } = that;
|
||||
that.$emit("input", value);
|
||||
},
|
||||
// 监听 - 页面打开
|
||||
onOpen() {
|
||||
that = this;
|
||||
let { value={} } = that;
|
||||
let { item } = value;
|
||||
let { role_id, role_name, permission = [] } = item;
|
||||
that.page.title = `权限赋予(${role_name})`;
|
||||
that.data.info = item;
|
||||
that.form1.data.role_id = role_id;
|
||||
that.form1.data.permissionList = permission;
|
||||
if (vk.pubfn.isNotNull(that.data.treeData)){
|
||||
that.initData();
|
||||
return;
|
||||
}
|
||||
that.getList();
|
||||
},
|
||||
getList(){
|
||||
// 执行请求
|
||||
vk.callFunction({
|
||||
url: 'admin/system/permission/sys/getAll',
|
||||
data: {},
|
||||
loading:{ that, name:"page.loading" },
|
||||
success: (data) => {
|
||||
let rows = [{
|
||||
label :"全选",
|
||||
permission_id :"",
|
||||
children : data.rows
|
||||
}];
|
||||
// 渲染树
|
||||
that.data.treeData = rows;
|
||||
that.data.list = data.list;
|
||||
that.initData();
|
||||
}
|
||||
});
|
||||
},
|
||||
initData(){
|
||||
let { value={} } = that;
|
||||
let { item } = value;
|
||||
let { menu_id, name, permission = [] } = item;
|
||||
let current = vk.pubfn.copyObject(permission);
|
||||
// 设置当前选中用户的权限列表
|
||||
// 去除所有含有子元素的权限
|
||||
for(let i in that.data.list){
|
||||
let item = that.data.list[i];
|
||||
let index = current.indexOf(item.parent_id);
|
||||
if(index > -1){
|
||||
current.splice(index, 1);
|
||||
}
|
||||
}
|
||||
that.data.checkedKeys = current;
|
||||
that.$refs.tree.setCheckedKeys(current);
|
||||
},
|
||||
// 监听 - 页面关闭
|
||||
onClose() {
|
||||
that.$refs.form1.resetForm(); // 关闭时,重置表单
|
||||
},
|
||||
// 监听 - 提交成功后
|
||||
onFormSuccess(res) {
|
||||
if (res.data.info) {
|
||||
that.$set(that.value.item, "permission", res.data.info.permission);
|
||||
that.$set(that.value.item, "stats_count_info", res.data.info.stats_count_info);
|
||||
}
|
||||
that.value.show = false; // 关闭页面
|
||||
that.$emit("success");
|
||||
}
|
||||
},
|
||||
// 监听属性
|
||||
watch: {
|
||||
|
||||
},
|
||||
// 计算属性
|
||||
computed: {
|
||||
|
||||
}
|
||||
};
|
||||
</script>
|
||||
|
||||
<style lang="scss" scoped>
|
||||
|
||||
</style>
|
||||
@@ -0,0 +1,340 @@
|
||||
<template>
|
||||
<view class="page-body">
|
||||
<!-- 页面内容开始 -->
|
||||
|
||||
<!-- 表格搜索组件开始 -->
|
||||
<vk-data-table-query
|
||||
v-model="queryForm1.formData"
|
||||
:columns="queryForm1.columns"
|
||||
@search="search"
|
||||
></vk-data-table-query>
|
||||
<!-- 表格搜索组件结束 -->
|
||||
|
||||
<!-- 自定义按钮区域开始 -->
|
||||
<view class="vk-table-button-box">
|
||||
<el-button type="success" size="small" icon="el-icon-circle-plus-outline" @click="addBtn">添加</el-button>
|
||||
<el-button type="primary" size="small" icon="el-icon-s-tools" :disabled="!table1.selectItem" @click="bindPermissionBtn">权限赋予</el-button>
|
||||
<el-button type="danger" size="small" icon="el-icon-s-tools" :disabled="!table1.selectItem" @click="bindMenu">菜单赋予</el-button>
|
||||
</view>
|
||||
<!-- 自定义按钮区域结束 -->
|
||||
<!-- 表格组件开始 -->
|
||||
<vk-data-table
|
||||
ref="table1"
|
||||
:action="table1.action"
|
||||
:columns="table1.columns"
|
||||
:query-form-param="queryForm1"
|
||||
:right-btns="['detail_auto','update','delete']"
|
||||
:selection="false"
|
||||
:row-no="true"
|
||||
:pagination="true"
|
||||
@update="updateBtn"
|
||||
@delete="deleteBtn"
|
||||
@current-change="currentChange"
|
||||
@selection-change="selectionChange"
|
||||
></vk-data-table>
|
||||
<!-- 表格组件结束 -->
|
||||
|
||||
<!-- 添加或编辑的弹窗开始 -->
|
||||
<vk-data-dialog
|
||||
v-model="form1.props.show"
|
||||
:title="form1.props.title"
|
||||
width="500px"
|
||||
mode="form"
|
||||
>
|
||||
<vk-data-form
|
||||
v-model="form1.data"
|
||||
:rules="form1.props.rules"
|
||||
:action="form1.props.action"
|
||||
:form-type="form1.props.formType"
|
||||
:columns='form1.props.columns'
|
||||
label-width="80px"
|
||||
@success="form1.props.show = false;refresh();"
|
||||
></vk-data-form>
|
||||
</vk-data-dialog>
|
||||
<!-- 添加或编辑的弹窗结束 -->
|
||||
|
||||
<!-- 角色赋予权限弹窗 -->
|
||||
<bindPermission v-model="formDatas.bindPermission"></bindPermission>
|
||||
<!-- 角色赋予菜单弹窗 -->
|
||||
<bindMenu v-model="formDatas.bindMenu"></bindMenu>
|
||||
|
||||
<!-- 页面内容结束 -->
|
||||
</view>
|
||||
</template>
|
||||
|
||||
<script>
|
||||
var that; // 当前页面对象
|
||||
var vk = uni.vk; // vk实例
|
||||
var originalForms = {}; // 表单初始化数据
|
||||
|
||||
import bindPermission from './form/bindPermission'
|
||||
import bindMenu from './form/bindMenu'
|
||||
export default {
|
||||
components:{
|
||||
bindPermission,
|
||||
bindMenu
|
||||
},
|
||||
data() {
|
||||
// 页面数据变量
|
||||
return {
|
||||
// 页面是否请求中或加载中
|
||||
loading:false,
|
||||
// init请求返回的数据
|
||||
data:{
|
||||
|
||||
},
|
||||
// 表格相关开始 -----------------------------------------------------------
|
||||
table1:{
|
||||
// 表格数据请求地址
|
||||
action:"admin/system/role/sys/getList",
|
||||
// 表格字段显示规则
|
||||
columns: [
|
||||
{ key:"role_id", title:"角色标识", type:"text", width:220 },
|
||||
{ key:"role_name", title:"角色名称", type:"text", width:130 },
|
||||
{ key:"comment", title:"备注", type:"text", minWidth:180 },
|
||||
{ key:"permissionList", title:"拥有的权限", type:"text", minWidth:290, align:"left",
|
||||
formatter:(val, row, column, index)=>{
|
||||
let str = "";
|
||||
if(row.role_id === "admin"){
|
||||
str = "系统内置角色 - 拥有所有权限";
|
||||
}else if(vk.pubfn.isNull(val)){
|
||||
str = "该角色未赋予任何权限";
|
||||
}else{
|
||||
val.map((item, index) => {
|
||||
if(vk.pubfn.isNotNull(item.url)){
|
||||
str += item.permission_name;
|
||||
if (index !== val.length - 1) {
|
||||
str += "、";
|
||||
}
|
||||
}
|
||||
});
|
||||
}
|
||||
return str;
|
||||
}
|
||||
},
|
||||
{ key:"menuList", title:"拥有的菜单", type:"text", minWidth:290, align:"left",
|
||||
formatter:(val, row, column, index)=>{
|
||||
let str = "";
|
||||
if(row.role_id === "admin"){
|
||||
str = "系统内置角色 - 拥有所有菜单";
|
||||
}else if(vk.pubfn.isNull(val)){
|
||||
str = "该角色未赋予任何菜单";
|
||||
}else{
|
||||
val.map((item, index) => {
|
||||
str += item.name;
|
||||
if (index !== val.length - 1) {
|
||||
str += "、";
|
||||
}
|
||||
});
|
||||
}
|
||||
return str;
|
||||
}
|
||||
},
|
||||
// 系统
|
||||
{ key:"stats_count_info", title:"统计信息", type:"html", width:220, align:"left", show: ["detail"],
|
||||
formatter:(val, row, column, index)=>{
|
||||
console.log(`val`,val);
|
||||
let str = ``;
|
||||
if(row.role_id === "admin"){
|
||||
return "拥有所有权限";
|
||||
}
|
||||
for (let value in val) {
|
||||
switch(value){
|
||||
case "curd_category":
|
||||
str+= `分类: `;
|
||||
break;
|
||||
case "level":
|
||||
str+= `等级: `;
|
||||
break;
|
||||
case "match_mode":
|
||||
str+= `模式: `;
|
||||
break;
|
||||
default:
|
||||
str+= `菜单和权限: `;
|
||||
break;
|
||||
};
|
||||
for (let [index, item] of val[value].entries()) {
|
||||
str += `${item.label} : ${item.count}个 `;
|
||||
};
|
||||
str +=`<br/>`;
|
||||
};
|
||||
return str;
|
||||
}
|
||||
},
|
||||
{
|
||||
key: "enable", title: "是否启用", type: "switch",
|
||||
activeValue: true,
|
||||
inactiveValue: false,
|
||||
width: 80,
|
||||
watch: (res) => {
|
||||
let { value, row, change } = res;
|
||||
vk.callFunction({
|
||||
url: "admin/system/role/sys/updateBase",
|
||||
title: value ? "启用中..." : "关闭中...",
|
||||
data: {
|
||||
_id: row._id,
|
||||
enable: value
|
||||
},
|
||||
success: data => {
|
||||
change(value); // 这一步是让表格行内的开关改变显示状态
|
||||
}
|
||||
});
|
||||
}
|
||||
}
|
||||
],
|
||||
// 多选框选中的值
|
||||
multipleSelection:[],
|
||||
// 当前高亮的记录
|
||||
selectItem:"",
|
||||
},
|
||||
// 表格相关结束 -----------------------------------------------------------
|
||||
// 表单相关开始-----------------------------------------------------------
|
||||
// 查询表单请求数据
|
||||
queryForm1:{
|
||||
// 查询表单数据源,可在此设置默认值
|
||||
formData:{
|
||||
|
||||
},
|
||||
// 查询表单的字段规则 fieldName:指定数据库字段名,不填默认等于key
|
||||
columns:[
|
||||
{ key:"role_id", title:"角色标识", type:"text", width: 160, mode:"%%" },
|
||||
{ key:"role_name", title:"角色名称", type:"text", width: 160, mode:"%%" },
|
||||
{ key:"_add_time", title:"添加时间", type:"datetimerange", width:400 },
|
||||
]
|
||||
},
|
||||
form1: {
|
||||
// 表单请求数据,此处可以设置默认值
|
||||
data: {
|
||||
enable:true,
|
||||
},
|
||||
// 表单属性
|
||||
props: {
|
||||
// 表单请求地址
|
||||
action:"",
|
||||
// 表单字段显示规则
|
||||
columns:[
|
||||
{ key:"role_id", title:"角色标识", type:"text", show:["add"] },
|
||||
{ key:"role_name", title:"角色名称", type:"text" },
|
||||
{ key:"comment", title:"备注", type:"textarea",
|
||||
maxlength:"99", showWordLimit:true, autosize:{ minRows: 2, maxRows: 10 } ,
|
||||
},
|
||||
{ key:"enable", title:"是否启用", type:"switch" }
|
||||
],
|
||||
// 表单验证规则
|
||||
rules:{
|
||||
role_id:[
|
||||
{ required:true, message:'角色标识不能为空', trigger:'blur' },
|
||||
],
|
||||
role_name:[
|
||||
{ required:true, message:'角色名称不能为空', trigger:'change' }
|
||||
],
|
||||
},
|
||||
// add 代表添加 update 代表修改
|
||||
formType:'',
|
||||
// 是否显示表单1 的弹窗
|
||||
show:false,
|
||||
}
|
||||
},
|
||||
// 其他表单属性容器(请勿修改)
|
||||
formDatas:{},
|
||||
// 表单相关结束-----------------------------------------------------------
|
||||
};
|
||||
},
|
||||
// 监听 - 页面每次【加载时】执行(如:前进)
|
||||
onLoad(options = {}) {
|
||||
that = this;
|
||||
vk = that.vk;
|
||||
that.options = options;
|
||||
that.init(options);
|
||||
},
|
||||
// 监听 - 页面【首次渲染完成时】执行。注意如果渲染速度快,会在页面进入动画完成前触发
|
||||
onReady() {},
|
||||
// 监听 - 页面每次【显示时】执行(如:前进和返回) (页面每次出现在屏幕上都触发,包括从下级页面点返回露出当前页面)
|
||||
onShow() {},
|
||||
// 监听 - 页面每次【隐藏时】执行(如:返回)
|
||||
onHide() {},
|
||||
// 函数
|
||||
methods: {
|
||||
// 页面数据初始化函数
|
||||
init(options) {
|
||||
originalForms["form1"] = vk.pubfn.copyObject(that.form1);
|
||||
},
|
||||
// 页面跳转
|
||||
pageTo(path) {
|
||||
vk.navigateTo(path);
|
||||
},
|
||||
// 表单重置
|
||||
resetForm(){
|
||||
vk.pubfn.resetForm(originalForms, that);
|
||||
},
|
||||
// 搜索
|
||||
search(){
|
||||
that.$refs.table1.query();
|
||||
},
|
||||
// 刷新
|
||||
refresh(){
|
||||
that.$refs.table1.refresh();
|
||||
},
|
||||
// 获取当前选中的行的数据
|
||||
getCurrentRow(key){
|
||||
return that.$refs.table1.getCurrentRow(key);
|
||||
},
|
||||
// 监听 - 行的选中高亮事件
|
||||
currentChange(val){
|
||||
that.table1.selectItem = val;
|
||||
},
|
||||
// 当选择项发生变化时会触发该事件
|
||||
selectionChange(list) {
|
||||
that.table1.multipleSelection = list;
|
||||
},
|
||||
// 显示添加页面
|
||||
addBtn(){
|
||||
that.resetForm();
|
||||
that.form1.props.action = 'admin/system/role/sys/add';
|
||||
that.form1.props.formType = 'add';
|
||||
that.form1.props.title = '添加';
|
||||
that.form1.props.show = true;
|
||||
},
|
||||
// 显示修改页面
|
||||
updateBtn({ item }){
|
||||
that.form1.props.action = 'admin/system/role/sys/update';
|
||||
that.form1.props.formType = 'update';
|
||||
that.form1.props.title = '编辑';
|
||||
that.form1.props.show = true;
|
||||
that.form1.data = item;
|
||||
},
|
||||
// 删除按钮
|
||||
deleteBtn({ item, deleteFn }){
|
||||
deleteFn({
|
||||
action:"admin/system/role/sys/delete",
|
||||
data:{
|
||||
role_id: item.role_id
|
||||
},
|
||||
});
|
||||
},
|
||||
// 权限赋予按钮
|
||||
bindPermissionBtn(){
|
||||
let item = that.getCurrentRow(true);
|
||||
vk.pubfn.openForm('bindPermission',{ item });
|
||||
},
|
||||
// 菜单赋予绑定按钮
|
||||
bindMenu(){
|
||||
let item = that.getCurrentRow(true);
|
||||
vk.pubfn.openForm('bindMenu',{ item });
|
||||
}
|
||||
},
|
||||
// 监听属性
|
||||
watch: {
|
||||
|
||||
},
|
||||
// 计算属性
|
||||
computed: {
|
||||
|
||||
}
|
||||
};
|
||||
</script>
|
||||
<style lang="scss" scoped>
|
||||
::v-deep .el-tree-node__content .el-checkbox {
|
||||
margin-right: 8px;
|
||||
}
|
||||
</style>
|
||||
@@ -0,0 +1,160 @@
|
||||
<template>
|
||||
<vk-data-dialog
|
||||
v-model="value.show"
|
||||
:title="page.title"
|
||||
:top="page.top"
|
||||
:width="page.width"
|
||||
mode="form"
|
||||
@open="onOpen"
|
||||
@closed="onClose"
|
||||
>
|
||||
<!-- 页面主体内容开始 -->
|
||||
<vk-data-form
|
||||
ref="form1"
|
||||
:form-type="value.mode"
|
||||
v-loading="page.loading"
|
||||
v-model="form1.data"
|
||||
:rules="form1.props.rules"
|
||||
:action="form1.props.action"
|
||||
:columns="form1.props.columns"
|
||||
:loading.sync="form1.props.loading"
|
||||
:labelWidth="form1.props.labelWidth"
|
||||
:show-cancel="page.showCancel"
|
||||
:cancel-text="page.cancelText"
|
||||
:submit-text="page.submitText"
|
||||
@success="onFormSuccess"
|
||||
>
|
||||
<template v-slot:user_id>
|
||||
<view style="display: flex;align-items: center;">
|
||||
<el-avatar v-if="data.avatar" :src="data.avatar" fit="cover"></el-avatar>
|
||||
<text style="margin-left: 10px;">{{ data.nickname }}(ID:{{ data._id }})</text>
|
||||
</view>
|
||||
</template>
|
||||
</vk-data-form>
|
||||
<!-- 页面主体内容结束 -->
|
||||
</vk-data-dialog>
|
||||
</template>
|
||||
|
||||
<script>
|
||||
var that; // 当前页面对象
|
||||
var vk = uni.vk; // vk实例
|
||||
export default {
|
||||
props: {
|
||||
value: {
|
||||
Type: Object,
|
||||
default: function() {
|
||||
return {
|
||||
show: false,
|
||||
mode: "",
|
||||
item: ""
|
||||
};
|
||||
}
|
||||
}
|
||||
},
|
||||
data: function() {
|
||||
// 组件创建时,进行数据初始化
|
||||
return {
|
||||
// 页面基础数据
|
||||
page: {
|
||||
title: "角色绑定",
|
||||
submitText: "绑定",
|
||||
cancelText: "关闭",
|
||||
showCancel: true,
|
||||
top: "7vh",
|
||||
width:"820px",
|
||||
loading: false
|
||||
},
|
||||
data:{
|
||||
|
||||
},
|
||||
form1: {
|
||||
// 表单请求数据,此处可以设置默认值
|
||||
data: {
|
||||
user_id: "",
|
||||
roleList: [],
|
||||
reset: true
|
||||
},
|
||||
// 表单属性
|
||||
props: {
|
||||
// 表单请求地址
|
||||
action: "admin/system/user/sys/bindRole",
|
||||
// 表单字段显示规则
|
||||
columns: [
|
||||
{ key:"user_id", title:"用户", type:"text" },
|
||||
{
|
||||
key: "roleList", title: "角色列表", type: "table-select", placeholder:"选择角色",
|
||||
action:"admin/system/role/sys/getList",
|
||||
columns:[
|
||||
{ key:"role_name", title:"角色昵称", type:"text", nameKey:true },
|
||||
{ key:"role_id", title:"角色标识", type:"text", idKey:true },
|
||||
{ key:"comment", title:"备注", type:"text" },
|
||||
],
|
||||
formData:{
|
||||
enable:true
|
||||
},
|
||||
queryColumns:[
|
||||
{ key: "role_name", title: "角色昵称", type: "text", width: 150, mode: "%%" },
|
||||
{ key: "role_id", title: "角色标识", type: "text", width: 150, mode: "%%" },
|
||||
{ key: "enable", type: "text", mode: "=", hidden:true }
|
||||
],
|
||||
multiple:true,
|
||||
pageSize:10, // 只有5和10可以选
|
||||
},
|
||||
],
|
||||
// 表单验证规则
|
||||
rules: {
|
||||
user_id: [
|
||||
{ "required": true, "message": "user_id不能为空", "trigger": "change" }
|
||||
]
|
||||
},
|
||||
// label宽度
|
||||
labelWidth:"100px",
|
||||
// label对其方式
|
||||
labelPosition:"left",
|
||||
}
|
||||
}
|
||||
};
|
||||
},
|
||||
mounted() {
|
||||
that = this;
|
||||
that.init();
|
||||
},
|
||||
methods: {
|
||||
// 初始化
|
||||
init() {
|
||||
let { value } = that;
|
||||
that.$emit("input", value);
|
||||
},
|
||||
// 监听 - 页面打开
|
||||
onOpen() {
|
||||
that = this;
|
||||
let { value } = that;
|
||||
let { role = [], _id } = value.item;
|
||||
that.data = value.item;
|
||||
that.form1.props.show = true;
|
||||
that.form1.data.user_id = _id;
|
||||
that.form1.data.roleList = role;
|
||||
},
|
||||
// 监听 - 页面关闭
|
||||
onClose() {
|
||||
that.$refs.form1.resetForm(); // 关闭时,重置表单
|
||||
},
|
||||
// 表单提交成功后
|
||||
onFormSuccess() {
|
||||
that.$set(that.value.item, "role", that.form1.data.roleList);
|
||||
that.value.show = false; // 关闭页面
|
||||
that.$emit("success");
|
||||
}
|
||||
},
|
||||
// 监听属性
|
||||
watch: {
|
||||
|
||||
},
|
||||
// 计算属性
|
||||
computed: {}
|
||||
};
|
||||
</script>
|
||||
|
||||
<style lang="scss" scoped>
|
||||
|
||||
</style>
|
||||
@@ -0,0 +1,146 @@
|
||||
<template>
|
||||
<vk-data-dialog
|
||||
v-model="value.show"
|
||||
:title="page.title"
|
||||
:top="page.top"
|
||||
:width="page.width"
|
||||
mode="form"
|
||||
@open="onOpen"
|
||||
@closed="onClose"
|
||||
>
|
||||
<!-- 页面主体内容开始 -->
|
||||
<vk-data-form
|
||||
ref="form1"
|
||||
:form-type="value.mode"
|
||||
v-loading="page.loading"
|
||||
v-model="form1.data"
|
||||
:rules="form1.props.rules"
|
||||
:action="form1.props.action"
|
||||
:columns="form1.props.columns"
|
||||
:loading.sync="form1.props.loading"
|
||||
:labelWidth="form1.props.labelWidth"
|
||||
:show-cancel="page.showCancel"
|
||||
:cancel-text="page.cancelText"
|
||||
:submit-text="page.submitText"
|
||||
@success="onFormSuccess"
|
||||
>
|
||||
<template v-slot:user_id>
|
||||
<view style="display: flex;align-items: center;">
|
||||
<el-avatar v-if="data.avatar" :src="data.avatar" fit="cover"></el-avatar>
|
||||
<text style="margin-left: 10px;">{{ data.nickname }}(ID:{{ data._id }})</text>
|
||||
</view>
|
||||
</template>
|
||||
</vk-data-form>
|
||||
<!-- 页面主体内容结束 -->
|
||||
</vk-data-dialog>
|
||||
</template>
|
||||
|
||||
<script>
|
||||
var that; // 当前页面对象
|
||||
var vk = uni.vk; // vk实例
|
||||
export default {
|
||||
props: {
|
||||
value: {
|
||||
Type: Object,
|
||||
default: function() {
|
||||
return {
|
||||
show: false,
|
||||
mode: "",
|
||||
item: ""
|
||||
};
|
||||
}
|
||||
}
|
||||
},
|
||||
data: function() {
|
||||
// 组件创建时,进行数据初始化
|
||||
return {
|
||||
// 页面基础数据
|
||||
page: {
|
||||
title: "重置密码",
|
||||
submitText: "修改",
|
||||
cancelText: "关闭",
|
||||
showCancel: true,
|
||||
top: "7vh",
|
||||
width:"600px",
|
||||
loading: false
|
||||
},
|
||||
data:{
|
||||
|
||||
},
|
||||
form1: {
|
||||
// 表单请求数据,此处可以设置默认值
|
||||
data: {
|
||||
user_id: "",
|
||||
password:""
|
||||
},
|
||||
// 表单属性
|
||||
props: {
|
||||
// 表单请求地址
|
||||
action: "admin/system/user/sys/resetPassword",
|
||||
// 表单字段显示规则
|
||||
columns: [
|
||||
{ key:"user_id", title:"用户", type:"text" },
|
||||
{ key:"password", title:"新密码", type:"password", showPassword:true },
|
||||
],
|
||||
// 表单验证规则
|
||||
rules: {
|
||||
user_id: [
|
||||
{ "required": true, "message": "user_id不能为空", "trigger": "change" }
|
||||
],
|
||||
password:[
|
||||
{ required:true, message:'新密码不能为空', trigger:'change' },
|
||||
{ validator:vk.pubfn.validator("password"), message: '密码长度在6~18之间,只能包含字母、数字和下划线', trigger: 'change' }
|
||||
],
|
||||
},
|
||||
// label宽度
|
||||
labelWidth:"100px",
|
||||
// label对其方式
|
||||
labelPosition:"left",
|
||||
}
|
||||
}
|
||||
};
|
||||
},
|
||||
mounted() {
|
||||
that = this;
|
||||
that.init();
|
||||
},
|
||||
methods: {
|
||||
// 初始化
|
||||
init() {
|
||||
let { value } = that;
|
||||
that.$emit("input", value);
|
||||
},
|
||||
// 监听 - 页面打开
|
||||
onOpen() {
|
||||
that = this;
|
||||
let { item={} } = that.value;
|
||||
let data = vk.pubfn.copyObject(item);
|
||||
that.data = data;
|
||||
that.form1.data = {
|
||||
user_id: data._id,
|
||||
password: ""
|
||||
};
|
||||
},
|
||||
// 监听 - 页面关闭
|
||||
onClose() {
|
||||
that.$refs.form1.resetForm(); // 关闭时,重置表单
|
||||
},
|
||||
// 表单提交成功后
|
||||
onFormSuccess() {
|
||||
that.value.show = false; // 关闭页面
|
||||
that.$emit("success");
|
||||
},
|
||||
|
||||
},
|
||||
// 监听属性
|
||||
watch: {
|
||||
|
||||
},
|
||||
// 计算属性
|
||||
computed: {}
|
||||
};
|
||||
</script>
|
||||
|
||||
<style lang="scss" scoped>
|
||||
|
||||
</style>
|
||||
@@ -0,0 +1,178 @@
|
||||
<template>
|
||||
<vk-data-dialog
|
||||
v-model="value.show"
|
||||
:title="page.title"
|
||||
:top="page.top"
|
||||
:width="page.width"
|
||||
:close-on-click-modal="true"
|
||||
mode="form"
|
||||
@open="onOpen"
|
||||
@closed="onClose"
|
||||
>
|
||||
<!-- 页面主体内容开始 -->
|
||||
<vk-data-form
|
||||
ref="form1"
|
||||
v-model="form1.data"
|
||||
:form-type="value.mode"
|
||||
:rules="form1.props.rules"
|
||||
:action="form1.props.action"
|
||||
:columns="form1.props.columns"
|
||||
:loading.sync="form1.props.loading"
|
||||
:labelWidth="form1.props.labelWidth"
|
||||
:before-action="form1.props.beforeAction"
|
||||
:show-cancel="page.showCancel"
|
||||
:cancel-text="page.cancelText"
|
||||
:submit-text="page.submitText"
|
||||
@success="onFormSuccess"
|
||||
></vk-data-form>
|
||||
<!-- 页面主体内容结束 -->
|
||||
</vk-data-dialog>
|
||||
</template>
|
||||
|
||||
<script>
|
||||
var that; // 当前页面对象
|
||||
var vk = uni.vk; // vk实例
|
||||
export default {
|
||||
props: {
|
||||
value: {
|
||||
Type: Object,
|
||||
default: function() {
|
||||
return {
|
||||
show: false,
|
||||
mode: "",
|
||||
item: {}
|
||||
};
|
||||
}
|
||||
}
|
||||
},
|
||||
data: function() {
|
||||
// 组件创建时,进行数据初始化
|
||||
return {
|
||||
page: {
|
||||
title: "标题",
|
||||
submitText: "确定",
|
||||
cancelText: "关闭",
|
||||
showCancel: true,
|
||||
top: "7vh",
|
||||
width: "800px"
|
||||
},
|
||||
form1: {
|
||||
// 表单请求数据,此处可以设置默认值
|
||||
data: {
|
||||
login_appid_type:1,
|
||||
mode:1
|
||||
},
|
||||
// 表单属性
|
||||
props: {
|
||||
// 表单请求地址
|
||||
action: "admin/system/user/sys/batchUpdateAppLogin",
|
||||
// 表单字段显示规则
|
||||
columns: [
|
||||
{
|
||||
key:"login_appid_type", title:"登录权限", type:"radio",
|
||||
optionType:"button",
|
||||
data:[
|
||||
{ value:1, label:"部分应用" },
|
||||
{ value:0, label:"全部应用" }
|
||||
]
|
||||
},
|
||||
{
|
||||
key:"mode", title:"模式", type:"radio",
|
||||
optionType:"button",
|
||||
data:[
|
||||
{ value:1, label:"覆盖" },
|
||||
{ value:2, label:"新增" },
|
||||
{ value:3, label:"移除" }
|
||||
],
|
||||
showRule:"login_appid_type=1",
|
||||
},
|
||||
{
|
||||
key:"dcloud_appid", title:"可登录的应用", type:"checkbox",
|
||||
border:true,
|
||||
itemWidth:100,
|
||||
data:[],
|
||||
props:{ value:"appid", label:"name" },
|
||||
showRule:"login_appid_type=1&&mode=1"
|
||||
},
|
||||
{
|
||||
key:"dcloud_appid", title:"可登录的应用", type:"radio",
|
||||
border:true,
|
||||
itemWidth:100,
|
||||
data:[],
|
||||
props:{ value:"appid", label:"name" },
|
||||
showRule:"login_appid_type=1&&mode!=1"
|
||||
},
|
||||
],
|
||||
// 表单验证规则
|
||||
rules: {
|
||||
|
||||
},
|
||||
// 左侧label的宽度
|
||||
labelWidth: "100px",
|
||||
// 提交前执行
|
||||
beforeAction:function(formData){
|
||||
let allow_login_background = false;
|
||||
if(!formData.login_appid_type){
|
||||
allow_login_background = true;
|
||||
}else{
|
||||
if(typeof formData.dcloud_appid === "object"){
|
||||
formData.dcloud_appid.map((appid, index) => {
|
||||
let item = vk.pubfn.getListItem(that.value.item.dcloudAppidData, "appid", appid);
|
||||
if(item.type === "admin"){
|
||||
allow_login_background = true;
|
||||
}
|
||||
});
|
||||
}else{
|
||||
let item = vk.pubfn.getListItem(that.value.item.dcloudAppidData, "appid", formData.dcloud_appid);
|
||||
if(item.type === "admin"){
|
||||
allow_login_background = true;
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
formData.user_ids = that.value.item.user_ids;
|
||||
formData.allow_login_background = allow_login_background;
|
||||
return formData;
|
||||
}
|
||||
}
|
||||
}
|
||||
};
|
||||
},
|
||||
mounted() {
|
||||
that = this;
|
||||
that.init();
|
||||
},
|
||||
methods: {
|
||||
// 初始化
|
||||
init() {
|
||||
let { value } = that;
|
||||
that.$emit("input", value);
|
||||
},
|
||||
// 监听 - 页面打开
|
||||
onOpen() {
|
||||
that = this;
|
||||
let { item={} } = that.value;
|
||||
// 每次打开时,重新设置表单的值 = value.item 的值,item通过 vk.pubfn.openForm('表单名',{ item:{ _id:"1" } }) 传递值
|
||||
that.form1.props.columns[2].data = item.dcloudAppidData;
|
||||
that.form1.props.columns[3].data = item.dcloudAppidData;
|
||||
},
|
||||
// 监听 - 页面关闭
|
||||
onClose() {
|
||||
//that.$refs.form1.resetForm(); // 关闭时,重置表单
|
||||
},
|
||||
// 监听 - 提交成功后
|
||||
onFormSuccess() {
|
||||
that.value.show = false; // 关闭页面
|
||||
that.$emit("success");
|
||||
}
|
||||
},
|
||||
// 监听属性
|
||||
watch: {
|
||||
|
||||
},
|
||||
// 计算属性
|
||||
computed: {}
|
||||
};
|
||||
</script>
|
||||
|
||||
<style lang="scss" scoped></style>
|
||||
@@ -0,0 +1,473 @@
|
||||
<template>
|
||||
<view class="page-body">
|
||||
<!-- 请不要修改此页面的代码,因为更新后会覆盖,你自己系统的用户管理不应该在这个页面上开发,你应该复制整个页面,在别的目录创建用户管理。 -->
|
||||
<!-- 请不要修改此页面的代码,因为更新后会覆盖,你自己系统的用户管理不应该在这个页面上开发,你应该复制整个页面,在别的目录创建用户管理。 -->
|
||||
<!-- 请不要修改此页面的代码,因为更新后会覆盖,你自己系统的用户管理不应该在这个页面上开发,你应该复制整个页面,在别的目录创建用户管理。 -->
|
||||
<!-- 请不要修改此页面的代码,因为更新后会覆盖,你自己系统的用户管理不应该在这个页面上开发,你应该复制整个页面,在别的目录创建用户管理。 -->
|
||||
<!-- 请不要修改此页面的代码,因为更新后会覆盖,你自己系统的用户管理不应该在这个页面上开发,你应该复制整个页面,在别的目录创建用户管理。 -->
|
||||
<!-- 请不要修改此页面的代码,因为更新后会覆盖,你自己系统的用户管理不应该在这个页面上开发,你应该复制整个页面,在别的目录创建用户管理。 -->
|
||||
|
||||
<!-- 页面内容开始 -->
|
||||
|
||||
<!-- 表格搜索组件开始 -->
|
||||
<vk-data-table-query
|
||||
v-model="queryForm1.formData"
|
||||
:columns="queryForm1.columns"
|
||||
@search="search"
|
||||
></vk-data-table-query>
|
||||
<!-- 表格搜索组件结束 -->
|
||||
|
||||
<!-- 自定义按钮区域开始 -->
|
||||
<view class="vk-table-button-box">
|
||||
<el-button type="success" size="small" icon="el-icon-circle-plus-outline" @click="addBtn">添加</el-button>
|
||||
<!-- 批量操作 -->
|
||||
<el-dropdown v-if="table1.multipleSelection" :split-button="false" trigger="click" @command="batchBtn">
|
||||
<el-button type="danger" size="small"
|
||||
:disabled="table1.multipleSelection.length === 0"
|
||||
>
|
||||
批量操作<i class="el-icon-arrow-down el-icon--right"></i>
|
||||
</el-button>
|
||||
<el-dropdown-menu slot="dropdown">
|
||||
<el-dropdown-item :command="1">账号批量解冻</el-dropdown-item>
|
||||
<el-dropdown-item :command="2">账号批量冻结</el-dropdown-item>
|
||||
<el-dropdown-item :command="3">批量设置可登录的应用</el-dropdown-item>
|
||||
</el-dropdown-menu>
|
||||
</el-dropdown>
|
||||
|
||||
<el-button type="primary" size="small" icon="el-icon-s-tools" :disabled="!table1.selectItem" @click="bindRoleBtn">角色绑定</el-button>
|
||||
<el-button type="primary" size="small" icon="el-icon-warning-outline" :disabled="!table1.selectItem" @click="resetPasswordBtn">重置密码</el-button>
|
||||
</view>
|
||||
<!-- 自定义按钮区域结束 -->
|
||||
|
||||
<!-- 表格组件开始 -->
|
||||
<vk-data-table
|
||||
ref="table1"
|
||||
:action="table1.action"
|
||||
:columns="table1.columns"
|
||||
:query-form-param="queryForm1"
|
||||
:right-btns="['detail_auto','update','delete']"
|
||||
:selection="true"
|
||||
:row-no="true"
|
||||
:pagination="true"
|
||||
@update="updateBtn"
|
||||
@delete="deleteBtn"
|
||||
@current-change="currentChange"
|
||||
@selection-change="selectionChange"
|
||||
></vk-data-table>
|
||||
<!-- 表格组件结束 -->
|
||||
|
||||
<!-- 添加或编辑的弹窗开始 -->
|
||||
<vk-data-dialog
|
||||
v-model="form1.props.show"
|
||||
:title="form1.props.title"
|
||||
width="580px"
|
||||
top="4vh"
|
||||
mode="form"
|
||||
>
|
||||
<vk-data-form
|
||||
ref="form1"
|
||||
v-model="form1.data"
|
||||
:rules="form1.props.rules"
|
||||
:action="form1.props.action"
|
||||
:form-type="form1.props.formType"
|
||||
:columns='form1.props.columns'
|
||||
label-width="120px"
|
||||
max-height="700px"
|
||||
@success="form1.props.show = false;refresh();"
|
||||
></vk-data-form>
|
||||
</vk-data-dialog>
|
||||
<!-- 添加或编辑的弹窗结束 -->
|
||||
|
||||
<!-- 用户角色授权弹窗 -->
|
||||
<bindRole v-model="formDatas.bindRole"></bindRole>
|
||||
<!-- 重置密码弹窗 -->
|
||||
<resetPassword v-model="formDatas.resetPassword"></resetPassword>
|
||||
<!-- 批量设置用户允许登录的客户端 -->
|
||||
<setAuthorizedAppLogin v-model="formDatas.setAuthorizedAppLogin" @success="refresh"></setAuthorizedAppLogin>
|
||||
|
||||
<!-- 页面内容结束 -->
|
||||
</view>
|
||||
</template>
|
||||
|
||||
<script>
|
||||
var that; // 当前页面对象
|
||||
var vk = uni.vk; // vk实例
|
||||
var originalForms = {}; // 表单初始化数据
|
||||
var genderData = [
|
||||
{ value:1, label:"男"},
|
||||
{ value:2, label:"女"},
|
||||
{ value:0, label:"保密"}
|
||||
];
|
||||
var dcloudAppidData = [];
|
||||
|
||||
import bindRole from './form/bindRole'
|
||||
import resetPassword from './form/resetPassword'
|
||||
import setAuthorizedAppLogin from './form/setAuthorizedAppLogin'
|
||||
|
||||
export default {
|
||||
components:{
|
||||
bindRole,
|
||||
resetPassword,
|
||||
setAuthorizedAppLogin
|
||||
},
|
||||
data() {
|
||||
// 页面数据变量
|
||||
return {
|
||||
// 页面是否请求中或加载中
|
||||
loading:false,
|
||||
// init请求返回的数据
|
||||
data:{
|
||||
|
||||
},
|
||||
// 表格相关开始 -----------------------------------------------------------
|
||||
table1:{
|
||||
// 表格数据请求地址
|
||||
action:"admin/system/user/sys/getList",
|
||||
// 表格字段显示规则
|
||||
columns: [
|
||||
{ key:"avatar", title:"头像", type:"avatar", width:80 },
|
||||
{ key:"username", title:"用户名", type:"text", width:180, defaultValue:'未设置' },
|
||||
{ key:"nickname", title:"昵称", type:"text", width:180, defaultValue:'未设置' },
|
||||
{ key:"mobile", title:"手机号", type:"text", width:120, defaultValue:"未绑定" },
|
||||
{ key:"appList", title:"可登录的应用", type:"html", width:220,
|
||||
formatter: function(val, row, column, index) {
|
||||
if(typeof row.dcloud_appid === "undefined") return "全部应用";
|
||||
if(row.dcloud_appid.length === 0) return "未绑定任何应用";
|
||||
if(val.length === 0 && row.dcloud_appid.length > 0) return row.dcloud_appid;
|
||||
let str = "";
|
||||
val.map((item, index) => {
|
||||
str += `、${item.name}`;
|
||||
});
|
||||
if(str) str = str.substring(1);
|
||||
return str;
|
||||
}
|
||||
},
|
||||
{ key:"role", title:"角色", type:"text", width:120, defaultValue:'无' },
|
||||
{ key:"comment", title:"备注", type:"text", width:160 },
|
||||
{ key:"allow_login_background", title:"允许登录后台", type:"tag", width: 140, defaultValue:false, sortable:"custom",
|
||||
data:[
|
||||
{ value:true, label:"允许", tagType:"success" },
|
||||
{ value:false, label:"禁止", tagType:"danger" }
|
||||
]
|
||||
},
|
||||
{ key:"status", title:"账户状态", type:"tag", width:120, defaultValue:0, sortable:"custom",
|
||||
data:[
|
||||
{ value:0, label:"正常", tagType:"success" },
|
||||
{ value:1, label:"冻结", tagType:"danger" },
|
||||
{ value:2, label:"审核中", tagType:"primary" },
|
||||
{ value:3, label:"审核拒绝", tagType:"info" }
|
||||
]
|
||||
},
|
||||
{ key:"gender", title:"性别", type:"radio", width:80, defaultValue:0, sortable:"custom",
|
||||
data:genderData
|
||||
},
|
||||
{ key:"register_date", title:"注册时间", type:"time", width:160, sortable:"custom" },
|
||||
{ key:"last_login_date", title:"最后登录时间", type:"dateDiff", width:130, defaultValue:'从未登录过', sortable:"custom" },
|
||||
{ key:"last_login_ip", title:"最后登录ip", type:"text", width:120, defaultValue:'从未登录过' },
|
||||
{ key:"_id", title:"id", type:"text", width:280 },
|
||||
],
|
||||
// 多选框选中的值
|
||||
multipleSelection:[],
|
||||
// 当前高亮的记录
|
||||
selectItem:"",
|
||||
},
|
||||
// 表格相关结束 -----------------------------------------------------------
|
||||
// 表单相关开始-----------------------------------------------------------
|
||||
// 查询表单请求数据
|
||||
queryForm1:{
|
||||
// 查询表单数据源,可在此设置默认值
|
||||
formData:{
|
||||
dcloud_appid:""
|
||||
//allow_login_background : true,
|
||||
},
|
||||
// 查询表单的字段规则 fieldName:指定数据库字段名,不填默认等于key
|
||||
columns:[
|
||||
{ key:"dcloud_appid", title:"所属应用", type:"select", width:160, mode:"custom",
|
||||
data:[],
|
||||
props:{ value:"appid", label:"name" }
|
||||
},
|
||||
{ key:"username", title:"用户名", type:"text", width:160, mode:"%%" },
|
||||
{ key:"nickname", title:"昵称", type:"text", width:140, mode:"%%" },
|
||||
{ key:"mobile", title:"手机号", type:"text", width:140, mode:"%%" },
|
||||
{ key:"_id", title:"ID", type:"text", width:140, mode:"=" },
|
||||
{ key:"register_date", title:"注册时间", type:"datetimerange", width:380, mode:"[]" },
|
||||
{ key:"allow_login_background", hidden:true, mode:"=" },
|
||||
]
|
||||
},
|
||||
form1: {
|
||||
// 表单请求数据,此处可以设置默认值
|
||||
data: {
|
||||
gender:0,
|
||||
login_appid_type:1,
|
||||
allow_login_background:false
|
||||
},
|
||||
// 表单属性
|
||||
props: {
|
||||
// 表单请求地址
|
||||
action:"",
|
||||
// 表单字段显示规则
|
||||
columns:[
|
||||
{ key:"username", title:"用户名", type:"text", show:["add"] },
|
||||
{ key:"nickname", title:"昵称", type:"text" },
|
||||
{ key:"gender", title:"性别", type:"radio",
|
||||
data: genderData
|
||||
},
|
||||
{ key:"password", title:"密码", type:"text", tips:"若密码为空,则默认为234567", show:["add"] },
|
||||
{ key:"mobile", title:"手机号", type:"text" },
|
||||
{
|
||||
key:"login_appid_type", title:"登录权限", type:"radio",
|
||||
optionType:"button",
|
||||
data:[
|
||||
{ value:1, label:"部分应用" },
|
||||
{ value:0, label:"全部应用" }
|
||||
],
|
||||
onChange:function(val, formData, column, index, option){
|
||||
if(val === 1){
|
||||
that.form1.data.allow_login_background = false
|
||||
}else{
|
||||
that.form1.data.allow_login_background = true;
|
||||
}
|
||||
}
|
||||
},
|
||||
{
|
||||
key:"dcloud_appid", title:"可登录的应用", type:"checkbox",
|
||||
border:true,
|
||||
itemWidth:100,
|
||||
data:[],
|
||||
props:{ value:"appid", label:"name" },
|
||||
showRule:"login_appid_type=1",
|
||||
onChange:function(val, formData, column, index, option=[]){
|
||||
let allow_login_background = false;
|
||||
option.map((item={}, index) => {
|
||||
if(item.type && item.type.indexOf("admin") > -1){
|
||||
allow_login_background = true;
|
||||
}
|
||||
});
|
||||
if(that.form1.data.login_appid_type === 1){
|
||||
that.form1.data.allow_login_background = allow_login_background;
|
||||
}else{
|
||||
that.form1.data.allow_login_background = true;
|
||||
}
|
||||
}
|
||||
},
|
||||
// {
|
||||
// key:"allow_login_background", title:"允许登录后台?", type:"switch",
|
||||
// tips:"只有同时设置可登录的应用有管理端以及允许登后台,该用户才能登录管理端"
|
||||
// },
|
||||
{ key:"comment", title:"备注", type:"textarea",
|
||||
maxlength:"99", showWordLimit:true, autosize:{ minRows: 2, maxRows: 10 } ,
|
||||
},
|
||||
],
|
||||
// 表单对应的验证规则
|
||||
rules:{
|
||||
username:[
|
||||
{
|
||||
required: true,
|
||||
validator:vk.pubfn.validator("username"),
|
||||
message: '用户名以字母开头,长度在6~18之间,只能包含字母、数字和下划线',
|
||||
trigger: 'blur'
|
||||
}
|
||||
],
|
||||
nickname: [
|
||||
{ required:true, message:'昵称为必填字段', trigger:'blur' },
|
||||
{ min:2, max:20, message:'昵称长度在 2 到 20 个字符', trigger:'blur' }
|
||||
],
|
||||
password: [
|
||||
{ validator:vk.pubfn.validator("password"), message: '密码长度在6~18之间,只能包含字母、数字和下划线', trigger: 'blur' }
|
||||
],
|
||||
mobile:[
|
||||
{ validator:vk.pubfn.validator("mobile"), message: '手机号格式错误', trigger: 'blur' }
|
||||
]
|
||||
},
|
||||
// add 代表添加 update 代表修改
|
||||
formType:'',
|
||||
// 是否显示表单1 的弹窗
|
||||
show: false,
|
||||
}
|
||||
},
|
||||
// 其他表单属性容器(请勿修改)
|
||||
formDatas:{},
|
||||
// 表单相关结束-----------------------------------------------------------
|
||||
};
|
||||
},
|
||||
// 监听 - 页面每次【加载时】执行(如:前进)
|
||||
onLoad(options = {}) {
|
||||
that = this;
|
||||
vk = that.vk;
|
||||
that.options = options;
|
||||
that.init(options);
|
||||
},
|
||||
// 监听 - 页面【首次渲染完成时】执行。注意如果渲染速度快,会在页面进入动画完成前触发
|
||||
onReady() {},
|
||||
// 监听 - 页面每次【显示时】执行(如:前进和返回) (页面每次出现在屏幕上都触发,包括从下级页面点返回露出当前页面)
|
||||
onShow() {},
|
||||
// 监听 - 页面每次【隐藏时】执行(如:返回)
|
||||
onHide() {},
|
||||
// 函数
|
||||
methods: {
|
||||
// 页面数据初始化函数
|
||||
init(options) {
|
||||
originalForms["form1"] = vk.pubfn.copyObject(that.form1);
|
||||
that.getAppList();
|
||||
},
|
||||
// 获取应用列表
|
||||
getAppList(obj){
|
||||
// 请在store/modules/$app.js文件里增加代码 appList: lifeData.$app.appList || []
|
||||
vk.callFunction({
|
||||
url: 'admin/system/app/sys/getList',
|
||||
data:{},
|
||||
success:function(data){
|
||||
dcloudAppidData = data.rows;
|
||||
let dcloudAppidData1 = vk.pubfn.copyObject(data.rows);
|
||||
let dcloudAppidData2 = vk.pubfn.copyObject(data.rows);
|
||||
let index1 = vk.pubfn.getListIndex(that.form1.props.columns, "key", "dcloud_appid");
|
||||
that.form1.props.columns[index1].data = dcloudAppidData1;
|
||||
dcloudAppidData2.unshift({
|
||||
appid:"___error___",
|
||||
name:"不存在的应用"
|
||||
});
|
||||
dcloudAppidData2.unshift({
|
||||
appid:"___empty-array___",
|
||||
name:"未绑定应用"
|
||||
});
|
||||
dcloudAppidData2.unshift({
|
||||
appid:"___non-existent___",
|
||||
name:"全部应用"
|
||||
});
|
||||
let index2 = vk.pubfn.getListIndex(that.queryForm1.columns, "key", "dcloud_appid");
|
||||
that.queryForm1.columns[index2].data = dcloudAppidData2;
|
||||
let appids = [];
|
||||
dcloudAppidData.map((item, index) => {
|
||||
appids.push(item.appid);
|
||||
});
|
||||
that.queryForm1.formData.appids = appids;
|
||||
}
|
||||
});
|
||||
},
|
||||
// 页面跳转
|
||||
pageTo(path) {
|
||||
vk.navigateTo(path);
|
||||
},
|
||||
// 表单重置
|
||||
resetForm(){
|
||||
vk.pubfn.resetForm(originalForms, that);
|
||||
},
|
||||
// 搜索
|
||||
search(){
|
||||
that.$refs.table1.query();
|
||||
},
|
||||
// 刷新
|
||||
refresh(){
|
||||
that.$refs.table1.refresh();
|
||||
},
|
||||
// 获取当前选中的行的数据
|
||||
getCurrentRow(key){
|
||||
return that.$refs.table1.getCurrentRow(key);
|
||||
},
|
||||
// 监听 - 行的选中高亮事件
|
||||
currentChange(val){
|
||||
that.table1.selectItem = val;
|
||||
},
|
||||
// 当选择项发生变化时会触发该事件
|
||||
selectionChange(list) {
|
||||
that.table1.multipleSelection = list;
|
||||
},
|
||||
// 显示添加页面
|
||||
addBtn(){
|
||||
that.resetForm();
|
||||
that.form1.props.action = 'admin/system/user/sys/add';
|
||||
that.form1.props.formType = 'add';
|
||||
that.form1.props.title = '添加';
|
||||
that.form1.props.show = true;
|
||||
},
|
||||
// 显示修改页面
|
||||
updateBtn({ item }){
|
||||
that.form1.props.action = 'admin/system/user/sys/update';
|
||||
that.form1.props.formType = 'update';
|
||||
that.form1.props.title = '编辑';
|
||||
that.form1.props.show = true;
|
||||
item.login_appid_type = typeof item.dcloud_appid === "undefined" ? 0 :1;
|
||||
that.form1.data = item;
|
||||
},
|
||||
// 删除按钮
|
||||
deleteBtn({ item, deleteFn }){
|
||||
deleteFn({
|
||||
action:"admin/system/user/sys/delete",
|
||||
data:{
|
||||
_id: item._id
|
||||
}
|
||||
});
|
||||
},
|
||||
// 监听 - 批量操作的按钮点击事件
|
||||
batchBtn(index){
|
||||
switch(index){
|
||||
case 1: that.frozen(0); break;
|
||||
case 2: that.frozen(1); break;
|
||||
case 3: that.setAuthorizedAppLogin(); break;
|
||||
default: break;
|
||||
}
|
||||
},
|
||||
// 角色绑定按钮
|
||||
bindRoleBtn(){
|
||||
let item = that.getCurrentRow(true);
|
||||
vk.pubfn.openForm('bindRole',{ item });
|
||||
},
|
||||
// 重置密码按钮
|
||||
resetPasswordBtn(){
|
||||
let item = that.getCurrentRow(true);
|
||||
vk.pubfn.openForm('resetPassword',{ item });
|
||||
},
|
||||
//账户批量冻结/解冻
|
||||
frozen(status){
|
||||
let user_ids = [];
|
||||
that.table1.multipleSelection.map((item,index)=>{
|
||||
user_ids.push(item._id);
|
||||
});
|
||||
vk.callFunction({
|
||||
url: 'admin/system/user/sys/batchUpdateStatus',
|
||||
title:'请求中...',
|
||||
data:{
|
||||
user_ids,
|
||||
status
|
||||
},
|
||||
success:function(data) {
|
||||
that.$notify({
|
||||
message:'批量操作成功!',
|
||||
type:'success'
|
||||
});
|
||||
that.refresh();
|
||||
}
|
||||
});
|
||||
},
|
||||
// 批量设置允许登录的客户端
|
||||
setAuthorizedAppLogin(){
|
||||
let user_ids = [];
|
||||
that.table1.multipleSelection.map((item,index)=>{
|
||||
user_ids.push(item._id);
|
||||
});
|
||||
that.formDatas.setAuthorizedAppLogin = {
|
||||
show:true,
|
||||
item:{
|
||||
user_ids,
|
||||
dcloudAppidData
|
||||
}
|
||||
};
|
||||
}
|
||||
},
|
||||
// 监听属性
|
||||
watch: {
|
||||
|
||||
},
|
||||
// 过滤器
|
||||
filters: {
|
||||
|
||||
},
|
||||
// 计算属性
|
||||
computed: {
|
||||
|
||||
}
|
||||
};
|
||||
</script>
|
||||
<style lang="scss" scoped>
|
||||
|
||||
</style>
|
||||
@@ -0,0 +1,119 @@
|
||||
<template>
|
||||
<view class="page-body">
|
||||
<!-- 页面内容开始 -->
|
||||
|
||||
<!-- 表格搜索组件开始 -->
|
||||
<vk-data-table-query
|
||||
v-model="queryForm1.formData"
|
||||
:columns="queryForm1.columns"
|
||||
@search="search"
|
||||
></vk-data-table-query>
|
||||
<!-- 表格搜索组件结束 -->
|
||||
<!-- 表格组件开始 -->
|
||||
<vk-data-table
|
||||
ref="table1"
|
||||
:action="table1.action"
|
||||
:columns="table1.columns"
|
||||
:query-form-param="queryForm1"
|
||||
:right-btns="['detail_auto']"
|
||||
:row-no="true"
|
||||
:pagination="true"
|
||||
></vk-data-table>
|
||||
<!-- 表格组件结束 -->
|
||||
<!-- 页面内容结束 -->
|
||||
</view>
|
||||
</template>
|
||||
|
||||
<script>
|
||||
var that; // 当前页面对象
|
||||
var vk = uni.vk; // vk实例
|
||||
|
||||
export default {
|
||||
data() {
|
||||
// 页面数据变量
|
||||
return {
|
||||
// 页面是否请求中或加载中
|
||||
loading: false,
|
||||
// init请求返回的数据
|
||||
data: {},
|
||||
// 表格相关开始 -----------------------------------------------------------
|
||||
table1: {
|
||||
// 表格数据请求地址
|
||||
action: "admin/system_uni/admin-log/sys/getList",
|
||||
// 表格字段显示规则
|
||||
columns: [
|
||||
{ key: "user_id", title: "操作者用户ID", type: "text", width: 120 },
|
||||
{ key: "user_name", title: "操作者用户昵称", type: "text", width: 120 },
|
||||
{ key: "title", title: "标题", type: "text", width: 140 },
|
||||
{ key: "url", title: "url", type: "text", width: 280 },
|
||||
{ key: "_add_time", title: "添加时间", type: "time", width: 140 },
|
||||
{ key: "_add_time", title: "距离现在", type: "dateDiff", width: 120 },
|
||||
{ key: "request_param", title: "请求参数", type: "json", width: 300 },
|
||||
{ key: "response", title: "返回参数", type: "json", width: 300 },
|
||||
{ key: "ip", title: "ip地址", type: "text", width: 140 },
|
||||
{ key: "request_id", title: "请求id", type: "text", width: 280 }
|
||||
],
|
||||
// 多选框选中的值
|
||||
multipleSelection: [],
|
||||
// 当前高亮的记录
|
||||
selectItem: ""
|
||||
},
|
||||
// 表格相关结束 -----------------------------------------------------------
|
||||
// 表单相关开始 -----------------------------------------------------------
|
||||
// 查询表单请求数据
|
||||
queryForm1: {
|
||||
// 查询表单数据源,可在此设置默认值
|
||||
formData: {},
|
||||
// 查询表单的字段规则 fieldName:指定数据库字段名,不填默认等于key
|
||||
columns: [
|
||||
{ key: "user_id", title: "用户ID", type: "text", mode: "=" },
|
||||
{ key: "title", title: "标题", type: "text", mode: "%%" },
|
||||
{ key: "ip", title: "ip地址", type: "text", mode: "%%" },
|
||||
{ key: "_add_time", title: "添加时间", type: "datetimerange", width: 400, mode: "[]" }
|
||||
]
|
||||
}
|
||||
// 表单相关结束 -----------------------------------------------------------
|
||||
};
|
||||
},
|
||||
// 监听 - 页面每次【加载时】执行(如:前进)
|
||||
onLoad(options = {}) {
|
||||
that = this;
|
||||
vk = that.vk;
|
||||
that.options = options;
|
||||
that.init(options);
|
||||
},
|
||||
// 监听 - 页面【首次渲染完成时】执行。注意如果渲染速度快,会在页面进入动画完成前触发
|
||||
onReady() {},
|
||||
// 监听 - 页面每次【显示时】执行(如:前进和返回) (页面每次出现在屏幕上都触发,包括从下级页面点返回露出当前页面)
|
||||
onShow() {},
|
||||
// 监听 - 页面每次【隐藏时】执行(如:返回)
|
||||
onHide() {},
|
||||
// 函数
|
||||
methods: {
|
||||
// 页面数据初始化函数
|
||||
init(options) {},
|
||||
// 搜索
|
||||
search(obj) {
|
||||
that.$refs.table1.query(obj);
|
||||
},
|
||||
// 刷新
|
||||
refresh() {
|
||||
that.$refs.table1.refresh();
|
||||
}
|
||||
},
|
||||
watch: {
|
||||
|
||||
},
|
||||
// 过滤器
|
||||
filters: {
|
||||
|
||||
},
|
||||
// 计算属性
|
||||
computed: {
|
||||
|
||||
}
|
||||
};
|
||||
</script>
|
||||
<style lang="scss" scoped>
|
||||
|
||||
</style>
|
||||
@@ -0,0 +1,128 @@
|
||||
<template>
|
||||
<vk-data-dialog
|
||||
v-model="value.show"
|
||||
:title="page.title"
|
||||
:top="page.top"
|
||||
:width="page.width"
|
||||
:close-on-click-modal="true"
|
||||
mode="form"
|
||||
>
|
||||
<!-- 页面主体内容开始 -->
|
||||
<vk-data-form
|
||||
ref="form1"
|
||||
v-model="form1.data"
|
||||
:form-type="value.mode"
|
||||
:rules="form1.props.rules"
|
||||
:action="form1.props.action"
|
||||
:columns="form1.props.columns"
|
||||
:loading.sync="form1.props.loading"
|
||||
:labelWidth="form1.props.labelWidth"
|
||||
:show-cancel="page.showCancel"
|
||||
:cancel-text="page.cancelText"
|
||||
:submit-text="page.submitText"
|
||||
@success="onFormSuccess"
|
||||
></vk-data-form>
|
||||
<!-- 页面主体内容结束 -->
|
||||
</vk-data-dialog>
|
||||
</template>
|
||||
|
||||
<script>
|
||||
var that; // 当前页面对象
|
||||
var vk = uni.vk; // vk实例
|
||||
export default {
|
||||
props: {
|
||||
value: {
|
||||
Type: Object,
|
||||
default: function() {
|
||||
return {
|
||||
show: false,
|
||||
mode: "",
|
||||
item: {}
|
||||
};
|
||||
}
|
||||
}
|
||||
},
|
||||
data: function() {
|
||||
// 组件创建时,进行数据初始化
|
||||
return {
|
||||
page: {
|
||||
title: "添加分组",
|
||||
submitText: "确定",
|
||||
cancelText: "关闭",
|
||||
showCancel: true,
|
||||
top: "14vh",
|
||||
width: "450px"
|
||||
},
|
||||
form1: {
|
||||
// 表单请求数据,此处可以设置默认值
|
||||
data: {},
|
||||
// 表单属性
|
||||
props: {
|
||||
// 表单请求地址
|
||||
action: "admin/system_uni/uni-id-files/categories/sys/add",
|
||||
// 表单字段显示规则
|
||||
columns: [
|
||||
// 常用字段类型
|
||||
{ key: "name", title: "名称", type: "text" }
|
||||
],
|
||||
// 表单验证规则
|
||||
rules: {
|
||||
name: [
|
||||
{ required: true, message: '名称不能为空', trigger: 'change' },
|
||||
{ max: 16, message: '最多16字', trigger: 'change' }
|
||||
],
|
||||
},
|
||||
labelWidth: "60px"
|
||||
}
|
||||
}
|
||||
};
|
||||
},
|
||||
mounted() {
|
||||
that = this;
|
||||
that.init();
|
||||
},
|
||||
methods: {
|
||||
// 初始化
|
||||
init() {
|
||||
let { value } = that;
|
||||
that.$emit("input", value);
|
||||
},
|
||||
// 监听 - 页面打开
|
||||
onOpen() {
|
||||
that = this;
|
||||
let { item } = that.value;
|
||||
that.form1.data = {
|
||||
_id: item._id,
|
||||
name: item.name
|
||||
};
|
||||
},
|
||||
// 监听 - 页面关闭
|
||||
onClose() {
|
||||
that.$refs.form1.resetForm(); // 关闭时,重置表单
|
||||
},
|
||||
// 监听 - 提交成功后
|
||||
onFormSuccess() {
|
||||
that.value.show = false; // 关闭页面
|
||||
that.$emit("success");
|
||||
}
|
||||
},
|
||||
watch: {
|
||||
"value.show": {
|
||||
handler(newValue, oldValue) {
|
||||
let that = this;
|
||||
if (newValue) {
|
||||
that.onOpen();
|
||||
} else {
|
||||
that.onClose();
|
||||
}
|
||||
}
|
||||
}
|
||||
},
|
||||
// 过滤器
|
||||
filters: {},
|
||||
// 计算属性
|
||||
computed: {}
|
||||
};
|
||||
</script>
|
||||
|
||||
<style lang="scss" scoped></style>
|
||||
@@ -0,0 +1,107 @@
|
||||
<template>
|
||||
<vk-data-dialog
|
||||
v-model="value.show"
|
||||
:title="page.title"
|
||||
:top="page.top"
|
||||
:width="page.width"
|
||||
:close-on-click-modal="true"
|
||||
:show-fullscreen="false"
|
||||
:show-header="false"
|
||||
:destroy-on-close="true"
|
||||
mode="form"
|
||||
>
|
||||
<!-- 页面主体内容开始 -->
|
||||
<image v-if="value.item.type === 'image'" :src="value.item.url" mode="widthFix" style="width: 100%;display: block;"></image>
|
||||
<view v-else-if="value.item.type === 'video' && value.show" :style="styleCom" style="margin: auto;">
|
||||
<video :src="value.item.url" autoplay object-fit="cover" style="width: 100%;height: 100%;display: block;"></video>
|
||||
</view>
|
||||
<!-- 页面主体内容结束 -->
|
||||
</vk-data-dialog>
|
||||
</template>
|
||||
|
||||
<script>
|
||||
var that; // 当前页面对象
|
||||
var vk = uni.vk; // vk实例
|
||||
export default {
|
||||
props: {
|
||||
value: {
|
||||
Type: Object,
|
||||
default: function() {
|
||||
return {
|
||||
show: false,
|
||||
mode: "",
|
||||
item: {}
|
||||
};
|
||||
}
|
||||
}
|
||||
},
|
||||
data: function() {
|
||||
// 组件创建时,进行数据初始化
|
||||
return {
|
||||
page: {
|
||||
title: "预览",
|
||||
submitText: "确定",
|
||||
cancelText: "关闭",
|
||||
showCancel: true,
|
||||
top: "2vh",
|
||||
width: "600px"
|
||||
},
|
||||
styleCom:{}
|
||||
};
|
||||
},
|
||||
mounted() {
|
||||
that = this;
|
||||
that.init();
|
||||
},
|
||||
methods: {
|
||||
// 初始化
|
||||
init() {
|
||||
let { value } = that;
|
||||
that.$emit("input", value);
|
||||
},
|
||||
// 监听 - 页面打开
|
||||
onOpen() {
|
||||
that = this;
|
||||
let { item } = that.value;
|
||||
let { width, height=700, type } = item;
|
||||
//if(type === "video"){
|
||||
let showWidth = width;
|
||||
let showHeight = height;
|
||||
let maxHeight = 700;
|
||||
if(height > maxHeight){
|
||||
showHeight = maxHeight;
|
||||
showWidth = width / height * maxHeight;
|
||||
}
|
||||
that.styleCom = {
|
||||
width : `${showWidth}px`,
|
||||
height : `${showHeight}px`
|
||||
};
|
||||
that.page.width = that.styleCom.width;
|
||||
that.$set(that.value.item,"play",true);
|
||||
//}
|
||||
},
|
||||
// 监听 - 页面关闭
|
||||
onClose() {
|
||||
that.$set(that.value.item,"play",false);
|
||||
}
|
||||
},
|
||||
watch: {
|
||||
"value.show": {
|
||||
handler(newValue, oldValue) {
|
||||
let that = this;
|
||||
if (newValue) {
|
||||
that.onOpen();
|
||||
} else {
|
||||
that.onClose();
|
||||
}
|
||||
}
|
||||
}
|
||||
},
|
||||
// 过滤器
|
||||
filters: {},
|
||||
// 计算属性
|
||||
computed: {}
|
||||
};
|
||||
</script>
|
||||
|
||||
<style lang="scss" scoped></style>
|
||||
@@ -0,0 +1,130 @@
|
||||
<template>
|
||||
<vk-data-dialog
|
||||
v-model="value.show"
|
||||
:title="page.title"
|
||||
:top="page.top"
|
||||
:width="page.width"
|
||||
:close-on-click-modal="true"
|
||||
mode="form"
|
||||
>
|
||||
<!-- 页面主体内容开始 -->
|
||||
<vk-data-form
|
||||
ref="form1"
|
||||
v-model="form1.data"
|
||||
:form-type="value.mode"
|
||||
:rules="form1.props.rules"
|
||||
:action="form1.props.action"
|
||||
:columns="form1.props.columns"
|
||||
:loading.sync="form1.props.loading"
|
||||
:labelWidth="form1.props.labelWidth"
|
||||
:show-cancel="page.showCancel"
|
||||
:cancel-text="page.cancelText"
|
||||
:submit-text="page.submitText"
|
||||
@success="onFormSuccess"
|
||||
></vk-data-form>
|
||||
<!-- 页面主体内容结束 -->
|
||||
</vk-data-dialog>
|
||||
</template>
|
||||
|
||||
<script>
|
||||
var that; // 当前页面对象
|
||||
var vk = uni.vk; // vk实例
|
||||
export default {
|
||||
props: {
|
||||
value: {
|
||||
Type: Object,
|
||||
default: function() {
|
||||
return {
|
||||
show: false,
|
||||
mode: "",
|
||||
item: {}
|
||||
};
|
||||
}
|
||||
}
|
||||
},
|
||||
data: function() {
|
||||
// 组件创建时,进行数据初始化
|
||||
return {
|
||||
page: {
|
||||
title: "修改分组名称",
|
||||
submitText: "确定",
|
||||
cancelText: "关闭",
|
||||
showCancel: true,
|
||||
top: "14vh",
|
||||
width: "450px"
|
||||
},
|
||||
form1: {
|
||||
// 表单请求数据,此处可以设置默认值
|
||||
data: {},
|
||||
// 表单属性
|
||||
props: {
|
||||
// 表单请求地址
|
||||
action: "admin/system_uni/uni-id-files/categories/sys/update",
|
||||
// 表单字段显示规则
|
||||
columns: [
|
||||
// 常用字段类型
|
||||
{ key: "name", title: "名称", type: "text" }
|
||||
],
|
||||
// 表单验证规则
|
||||
rules: {
|
||||
name: [
|
||||
{ required: true, message: '名称不能为空', trigger: 'change' },
|
||||
{ max: 16, message: '最多16字', trigger: 'change' }
|
||||
],
|
||||
},
|
||||
labelWidth: "60px"
|
||||
}
|
||||
}
|
||||
};
|
||||
},
|
||||
mounted() {
|
||||
that = this;
|
||||
that.init();
|
||||
},
|
||||
methods: {
|
||||
// 初始化
|
||||
init() {
|
||||
let { value } = that;
|
||||
that.$emit("input", value);
|
||||
},
|
||||
// 监听 - 页面打开
|
||||
onOpen() {
|
||||
that = this;
|
||||
let { item } = that.value;
|
||||
that.form1.data = {
|
||||
_id: item._id,
|
||||
name: item.name
|
||||
};
|
||||
},
|
||||
// 监听 - 页面关闭
|
||||
onClose() {
|
||||
// that.$refs.form1.resetForm(); // 关闭时,重置表单
|
||||
},
|
||||
// 监听 - 提交成功后
|
||||
onFormSuccess() {
|
||||
// 此代码用处是直接将修改结果显示到页面上,而不需要进行数据库查询。
|
||||
that.value.item.name = that.form1.data.name;
|
||||
that.value.show = false; // 关闭页面
|
||||
that.$emit("success");
|
||||
}
|
||||
},
|
||||
watch: {
|
||||
"value.show": {
|
||||
handler(newValue, oldValue) {
|
||||
let that = this;
|
||||
if (newValue) {
|
||||
that.onOpen();
|
||||
} else {
|
||||
that.onClose();
|
||||
}
|
||||
}
|
||||
}
|
||||
},
|
||||
// 过滤器
|
||||
filters: {},
|
||||
// 计算属性
|
||||
computed: {}
|
||||
};
|
||||
</script>
|
||||
|
||||
<style lang="scss" scoped></style>
|
||||
@@ -0,0 +1,137 @@
|
||||
<template>
|
||||
<vk-data-dialog
|
||||
v-model="value.show"
|
||||
:title="page.title"
|
||||
:top="page.top"
|
||||
:width="page.width"
|
||||
:close-on-click-modal="true"
|
||||
mode="form"
|
||||
>
|
||||
<!-- 页面主体内容开始 -->
|
||||
<vk-data-form
|
||||
ref="form1"
|
||||
v-model="form1.data"
|
||||
:form-type="value.mode"
|
||||
:rules="form1.props.rules"
|
||||
:action="form1.props.action"
|
||||
:columns="form1.props.columns"
|
||||
:loading.sync="form1.props.loading"
|
||||
:labelWidth="form1.props.labelWidth"
|
||||
:show-cancel="page.showCancel"
|
||||
:cancel-text="page.cancelText"
|
||||
:submit-text="page.submitText"
|
||||
@success="onFormSuccess"
|
||||
>
|
||||
<template v-slot:category_id="{ form, keyName }">
|
||||
<vk-data-input-radio
|
||||
width="100%"
|
||||
v-model="form[keyName]"
|
||||
:localdata="value.list"
|
||||
:props="{ value:'_id', label:'name' }"
|
||||
placeholder="请选择分组"
|
||||
border
|
||||
:item-width="300"
|
||||
></vk-data-input-radio>
|
||||
</template>
|
||||
</vk-data-form>
|
||||
<!-- 页面主体内容结束 -->
|
||||
</vk-data-dialog>
|
||||
</template>
|
||||
|
||||
<script>
|
||||
var that; // 当前页面对象
|
||||
var vk = uni.vk; // vk实例
|
||||
export default {
|
||||
props: {
|
||||
value: {
|
||||
Type: Object,
|
||||
default: function() {
|
||||
return {
|
||||
show: false,
|
||||
mode: "",
|
||||
item: {},
|
||||
list:[]
|
||||
};
|
||||
}
|
||||
}
|
||||
},
|
||||
data: function() {
|
||||
// 组件创建时,进行数据初始化
|
||||
return {
|
||||
page: {
|
||||
title: "修改分组",
|
||||
submitText: "确定",
|
||||
cancelText: "关闭",
|
||||
showCancel: true,
|
||||
top: "14vh",
|
||||
width: "450px"
|
||||
},
|
||||
form1: {
|
||||
// 表单请求数据,此处可以设置默认值
|
||||
data: {},
|
||||
// 表单属性
|
||||
props: {
|
||||
// 表单请求地址
|
||||
action: "admin/system_uni/uni-id-files/files/kh/update",
|
||||
// 表单字段显示规则
|
||||
columns: [
|
||||
{
|
||||
key:"category_id", title:"分组", type:"select", placeholder:"请选择分组",
|
||||
}
|
||||
],
|
||||
// 表单验证规则
|
||||
rules: {},
|
||||
labelWidth: "60px"
|
||||
}
|
||||
}
|
||||
};
|
||||
},
|
||||
mounted() {
|
||||
that = this;
|
||||
that.init();
|
||||
},
|
||||
methods: {
|
||||
// 初始化
|
||||
init() {
|
||||
let { value } = that;
|
||||
that.$emit("input", value);
|
||||
},
|
||||
// 监听 - 页面打开
|
||||
onOpen() {
|
||||
that = this;
|
||||
let { item } = that.value;
|
||||
that.form1.data = {
|
||||
_id: item._id,
|
||||
category_id: item.category_id
|
||||
};
|
||||
},
|
||||
// 监听 - 页面关闭
|
||||
onClose() {
|
||||
// that.$refs.form1.resetForm(); // 关闭时,重置表单
|
||||
},
|
||||
// 监听 - 提交成功后
|
||||
onFormSuccess() {
|
||||
that.value.show = false; // 关闭页面
|
||||
that.$emit("success");
|
||||
}
|
||||
},
|
||||
watch: {
|
||||
"value.show": {
|
||||
handler(newValue, oldValue) {
|
||||
let that = this;
|
||||
if (newValue) {
|
||||
that.onOpen();
|
||||
} else {
|
||||
that.onClose();
|
||||
}
|
||||
}
|
||||
}
|
||||
},
|
||||
// 过滤器
|
||||
filters: {},
|
||||
// 计算属性
|
||||
computed: {}
|
||||
};
|
||||
</script>
|
||||
|
||||
<style lang="scss" scoped></style>
|
||||
@@ -0,0 +1,128 @@
|
||||
<template>
|
||||
<vk-data-dialog
|
||||
v-model="value.show"
|
||||
:title="page.title"
|
||||
:top="page.top"
|
||||
:width="page.width"
|
||||
:close-on-click-modal="true"
|
||||
mode="form"
|
||||
>
|
||||
<!-- 页面主体内容开始 -->
|
||||
<vk-data-form
|
||||
ref="form1"
|
||||
v-model="form1.data"
|
||||
:form-type="value.mode"
|
||||
:rules="form1.props.rules"
|
||||
:action="form1.props.action"
|
||||
:columns="form1.props.columns"
|
||||
:loading.sync="form1.props.loading"
|
||||
:labelWidth="form1.props.labelWidth"
|
||||
:show-cancel="page.showCancel"
|
||||
:cancel-text="page.cancelText"
|
||||
:submit-text="page.submitText"
|
||||
@success="onFormSuccess"
|
||||
></vk-data-form>
|
||||
<!-- 页面主体内容结束 -->
|
||||
</vk-data-dialog>
|
||||
</template>
|
||||
|
||||
<script>
|
||||
var that; // 当前页面对象
|
||||
var vk = uni.vk; // vk实例
|
||||
export default {
|
||||
props: {
|
||||
value: {
|
||||
Type: Object,
|
||||
default: function() {
|
||||
return {
|
||||
show: false,
|
||||
mode: "",
|
||||
item: {}
|
||||
};
|
||||
}
|
||||
}
|
||||
},
|
||||
data: function() {
|
||||
// 组件创建时,进行数据初始化
|
||||
return {
|
||||
page: {
|
||||
title: "修改文件名称",
|
||||
submitText: "确定",
|
||||
cancelText: "关闭",
|
||||
showCancel: true,
|
||||
top: "14vh",
|
||||
width: "450px"
|
||||
},
|
||||
form1: {
|
||||
// 表单请求数据,此处可以设置默认值
|
||||
data: {},
|
||||
// 表单属性
|
||||
props: {
|
||||
// 表单请求地址
|
||||
action: "admin/system_uni/uni-id-files/files/kh/update",
|
||||
// 表单字段显示规则
|
||||
columns: [
|
||||
{ key: "display_name", title: "名称", type: "text" },
|
||||
],
|
||||
// 表单验证规则
|
||||
rules: {
|
||||
display_name: [
|
||||
{ required: true, message: '名称不能为空', trigger: 'change' },
|
||||
{ max: 32, message: '最多32字', trigger: 'change' }
|
||||
],
|
||||
},
|
||||
labelWidth: "60px"
|
||||
}
|
||||
}
|
||||
};
|
||||
},
|
||||
mounted() {
|
||||
that = this;
|
||||
that.init();
|
||||
},
|
||||
methods: {
|
||||
// 初始化
|
||||
init() {
|
||||
let { value } = that;
|
||||
that.$emit("input", value);
|
||||
},
|
||||
// 监听 - 页面打开
|
||||
onOpen() {
|
||||
that = this;
|
||||
let { item } = that.value;
|
||||
that.form1.data = {
|
||||
_id: item._id,
|
||||
display_name: item.display_name
|
||||
};
|
||||
},
|
||||
// 监听 - 页面关闭
|
||||
onClose() {
|
||||
// that.$refs.form1.resetForm(); // 关闭时,重置表单
|
||||
},
|
||||
// 监听 - 提交成功后
|
||||
onFormSuccess() {
|
||||
that.value.item.display_name = that.form1.data.display_name;
|
||||
that.value.show = false; // 关闭页面
|
||||
that.$emit("success");
|
||||
}
|
||||
},
|
||||
watch: {
|
||||
"value.show": {
|
||||
handler(newValue, oldValue) {
|
||||
let that = this;
|
||||
if (newValue) {
|
||||
that.onOpen();
|
||||
} else {
|
||||
that.onClose();
|
||||
}
|
||||
}
|
||||
}
|
||||
},
|
||||
// 过滤器
|
||||
filters: {},
|
||||
// 计算属性
|
||||
computed: {}
|
||||
};
|
||||
</script>
|
||||
|
||||
<style lang="scss" scoped></style>
|
||||
@@ -0,0 +1,131 @@
|
||||
<template>
|
||||
<vk-data-dialog
|
||||
v-model="value.show"
|
||||
:title="page.title"
|
||||
:top="page.top"
|
||||
:width="page.width"
|
||||
:close-on-click-modal="true"
|
||||
mode="form"
|
||||
>
|
||||
<!-- 页面主体内容开始 -->
|
||||
<vk-data-form
|
||||
ref="form1"
|
||||
v-model="form1.data"
|
||||
:form-type="value.mode"
|
||||
:rules="form1.props.rules"
|
||||
:action="form1.props.action"
|
||||
:columns="form1.props.columns"
|
||||
:loading.sync="form1.props.loading"
|
||||
:labelWidth="form1.props.labelWidth"
|
||||
:show-cancel="page.showCancel"
|
||||
:cancel-text="page.cancelText"
|
||||
:submit-text="page.submitText"
|
||||
@success="onFormSuccess"
|
||||
></vk-data-form>
|
||||
<!-- 页面主体内容结束 -->
|
||||
</vk-data-dialog>
|
||||
</template>
|
||||
|
||||
<script>
|
||||
var that; // 当前页面对象
|
||||
var vk = uni.vk; // vk实例
|
||||
export default {
|
||||
props: {
|
||||
value: {
|
||||
Type: Object,
|
||||
default: function() {
|
||||
return {
|
||||
show: false,
|
||||
mode: "",
|
||||
item: {}
|
||||
};
|
||||
}
|
||||
}
|
||||
},
|
||||
data: function() {
|
||||
// 组件创建时,进行数据初始化
|
||||
return {
|
||||
page: {
|
||||
title: "编辑视频信息",
|
||||
submitText: "确定",
|
||||
cancelText: "关闭",
|
||||
showCancel: true,
|
||||
top: "14vh",
|
||||
width: "450px"
|
||||
},
|
||||
form1: {
|
||||
// 表单请求数据,此处可以设置默认值
|
||||
data: {},
|
||||
// 表单属性
|
||||
props: {
|
||||
// 表单请求地址
|
||||
action: "admin/system_uni/uni-id-files/files/kh/update",
|
||||
// 表单字段显示规则
|
||||
columns: [
|
||||
{ key: "display_name", title: "名称", type: "text" },
|
||||
{ key: "cover_image", title: "封面图", type: "image", limit:1 },
|
||||
],
|
||||
// 表单验证规则
|
||||
rules: {
|
||||
display_name: [
|
||||
{ required: true, message: '名称不能为空', trigger: 'change' },
|
||||
{ max: 32, message: '最多32字', trigger: 'change' }
|
||||
],
|
||||
},
|
||||
labelWidth: "60px"
|
||||
}
|
||||
}
|
||||
};
|
||||
},
|
||||
mounted() {
|
||||
that = this;
|
||||
that.init();
|
||||
},
|
||||
methods: {
|
||||
// 初始化
|
||||
init() {
|
||||
let { value } = that;
|
||||
that.$emit("input", value);
|
||||
},
|
||||
// 监听 - 页面打开
|
||||
onOpen() {
|
||||
that = this;
|
||||
let { item } = that.value;
|
||||
that.form1.data = {
|
||||
_id: item._id,
|
||||
display_name: item.display_name,
|
||||
cover_image: item.cover_image
|
||||
};
|
||||
},
|
||||
// 监听 - 页面关闭
|
||||
onClose() {
|
||||
// that.$refs.form1.resetForm(); // 关闭时,重置表单
|
||||
},
|
||||
// 监听 - 提交成功后
|
||||
onFormSuccess() {
|
||||
that.$set(that.value.item,"display_name",that.form1.data.display_name);
|
||||
that.$set(that.value.item,"cover_image",that.form1.data.cover_image);
|
||||
that.value.show = false; // 关闭页面
|
||||
that.$emit("success");
|
||||
}
|
||||
},
|
||||
watch: {
|
||||
"value.show": {
|
||||
handler(newValue, oldValue) {
|
||||
let that = this;
|
||||
if (newValue) {
|
||||
that.onOpen();
|
||||
} else {
|
||||
that.onClose();
|
||||
}
|
||||
}
|
||||
}
|
||||
},
|
||||
// 过滤器
|
||||
filters: {},
|
||||
// 计算属性
|
||||
computed: {}
|
||||
};
|
||||
</script>
|
||||
|
||||
<style lang="scss" scoped></style>
|
||||
@@ -0,0 +1,143 @@
|
||||
<template>
|
||||
<vk-data-dialog
|
||||
v-model="value.show"
|
||||
:title="page.title"
|
||||
:top="page.top"
|
||||
:width="page.width"
|
||||
:close-on-click-modal="false"
|
||||
:show-fullscreen="false"
|
||||
:show-close="false"
|
||||
:destroy-on-close="true"
|
||||
mode="form"
|
||||
>
|
||||
<!-- 页面主体内容开始 -->
|
||||
<view class="body" v-if="total>1">
|
||||
<view>
|
||||
<text>总进度:{{ currentIndex+1 }} / {{ total }}</text>
|
||||
<el-progress :percentage="totalPercentage"></el-progress>
|
||||
</view>
|
||||
<view style="margin-top: 10px;">
|
||||
<text>文件{{currentIndex+1}}进度:</text>
|
||||
<el-progress :percentage="currentPercentage"></el-progress>
|
||||
</view>
|
||||
<view style="margin-top: 10px;text-align: center;">正在上传第 {{currentIndex+1}} 个文件</view>
|
||||
</view>
|
||||
<view class="body" v-else>
|
||||
<view style="text-align: center;">
|
||||
<el-progress :percentage="currentPercentage" type="circle"></el-progress>
|
||||
</view>
|
||||
</view>
|
||||
<!-- 页面主体内容结束 -->
|
||||
</vk-data-dialog>
|
||||
</template>
|
||||
|
||||
<script>
|
||||
var that; // 当前页面对象
|
||||
var vk = uni.vk; // vk实例
|
||||
export default {
|
||||
props: {
|
||||
value: {
|
||||
Type: Object,
|
||||
default: function() {
|
||||
return {
|
||||
show: false,
|
||||
mode: "",
|
||||
item: {}
|
||||
};
|
||||
}
|
||||
}
|
||||
},
|
||||
data: function() {
|
||||
// 组件创建时,进行数据初始化
|
||||
return {
|
||||
page: {
|
||||
title: "上传进度",
|
||||
submitText: "确定",
|
||||
cancelText: "关闭",
|
||||
showCancel: true,
|
||||
top: "40vh",
|
||||
width: "500px"
|
||||
},
|
||||
total:0,
|
||||
totalPercentage: 0, // 总进度
|
||||
currentPercentage: 0, // 当前文件进度
|
||||
currentIndex: 0,
|
||||
};
|
||||
},
|
||||
mounted() {
|
||||
that = this;
|
||||
that.init();
|
||||
},
|
||||
methods: {
|
||||
// 初始化
|
||||
init() {
|
||||
let { value } = that;
|
||||
that.$emit("input", value);
|
||||
},
|
||||
// 监听 - 页面打开
|
||||
onOpen() {
|
||||
that = this;
|
||||
let { item={} } = that.value;
|
||||
that.upload(item);
|
||||
},
|
||||
// 监听 - 页面关闭
|
||||
onClose() {
|
||||
|
||||
},
|
||||
async upload(item){
|
||||
let that = this;
|
||||
let { vk } = that;
|
||||
let { tempFilePaths, tempFiles, categoryId, fileType } = item;
|
||||
that.total = tempFilePaths.length;
|
||||
that.totalPercentage = 0;
|
||||
for (let i = 0; i < tempFilePaths.length; i++) {
|
||||
that.currentPercentage = 0;
|
||||
that.currentIndex = i;
|
||||
let percentage = vk.pubfn.toDecimal((i+1) / tempFilePaths.length * 100, 0);
|
||||
try {
|
||||
await vk.uploadFile({
|
||||
filePath: tempFilePaths[i],
|
||||
file: tempFiles[i],
|
||||
needSave: true,
|
||||
fileType,
|
||||
category_id: categoryId,
|
||||
onUploadProgress:(progressRes) => {
|
||||
// 上传过程中
|
||||
that.currentPercentage = progressRes.progress;
|
||||
},
|
||||
});
|
||||
that.totalPercentage = percentage;
|
||||
} catch(err){
|
||||
console.error(err);
|
||||
}
|
||||
}
|
||||
that.onSuccess();
|
||||
},
|
||||
// 监听 - 提交成功后
|
||||
onSuccess() {
|
||||
that.value.show = false; // 关闭页面
|
||||
that.$emit("success");
|
||||
}
|
||||
},
|
||||
watch: {
|
||||
"value.show": {
|
||||
handler(newValue, oldValue) {
|
||||
let that = this;
|
||||
if (newValue) {
|
||||
that.onOpen();
|
||||
} else {
|
||||
that.onClose();
|
||||
}
|
||||
}
|
||||
}
|
||||
},
|
||||
// 计算属性
|
||||
computed: {}
|
||||
};
|
||||
</script>
|
||||
|
||||
<style lang="scss" scoped>
|
||||
.body{
|
||||
padding: 30px;
|
||||
}
|
||||
</style>
|
||||
@@ -0,0 +1,704 @@
|
||||
<template>
|
||||
<view class="page-body">
|
||||
<!-- 页面内容开始 -->
|
||||
<view class="header">
|
||||
<view class="header-item" style="margin-left:0;">
|
||||
<el-button type="primary" :round="false" size="small" icon="el-icon-plus upload-btn" @click="uploadFile" > 上传 </el-button>
|
||||
</view>
|
||||
<view class="header-item">
|
||||
<el-radio-group v-model="queryForm1.formData.type" size="small" @change="getList">
|
||||
<el-radio-button label="image">图片</el-radio-button>
|
||||
<el-radio-button label="video">视频</el-radio-button>
|
||||
<el-radio-button label="other">其他</el-radio-button>
|
||||
</el-radio-group>
|
||||
</view>
|
||||
<view class="header-item">
|
||||
<el-input class="search-input input-border-radius-4004" size="small" type="text" clearable placeholder="请输入名称搜索..." v-model="queryForm1.formData.display_name" @keyup.enter.native="getList" @clear="getList" />
|
||||
<el-button type="primary" :loading="loading.main" :round="false" size="small" icon="el-icon-search" @click.stop="getList" style="border-radius: 0 4px 4px 0;" ></el-button>
|
||||
</view>
|
||||
<view class="header-item">
|
||||
<el-input class="search-input input-border-radius-4004" size="small" type="text" clearable placeholder="请输入URL搜索..." v-model="queryForm1.formData.url" @keyup.enter.native="getList" @clear="getList" />
|
||||
<el-button type="primary" :loading="loading.main" :round="false" size="small" icon="el-icon-search" @click.stop="getList" style="border-radius: 0 4px 4px 0;" ></el-button>
|
||||
</view>
|
||||
</view>
|
||||
<view class="nav" v-loading="loading.nav">
|
||||
<view
|
||||
class="nav-list"
|
||||
v-for="(item, index) of data.navList" :key="index"
|
||||
:class="queryForm1.formData.category_id == item._id ? 'selected-nav' : ''"
|
||||
@click.stop="queryByCategory(item._id)"
|
||||
>
|
||||
<text class="nav-name text-one">{{ item.name }}</text>
|
||||
<view class="nav-btn">
|
||||
<view v-if="index > 1" class="btn el-icon-edit" @click.stop="vk.pubfn.openForm('updateCategory', { item })" ></view>
|
||||
<el-popconfirm v-if="index > 1" title="确定删除该分组吗?(组内图片不会删除)" @confirm="deleteCategory(item._id, index)" >
|
||||
<view slot="reference" class="btn el-icon-delete" @click.stop="stop"></view>
|
||||
</el-popconfirm>
|
||||
</view>
|
||||
</view>
|
||||
|
||||
<view class="add-group" @click.stop="vk.pubfn.openForm('addCategory')">添加分组</view>
|
||||
</view>
|
||||
<view class="main" v-loading="loading.main">
|
||||
<!-- 内容详情 -->
|
||||
<view
|
||||
class="content-item"
|
||||
:class="[selectedIds.includes(item._id) ? 'choose-image' : '']"
|
||||
v-for="(item, index) in data.content.rows" :key="index"
|
||||
@click.stop="clickFile(item)"
|
||||
>
|
||||
<view class="item-file">
|
||||
<image :src="item.url" mode="aspectFit" v-if="item.type === 'image'"></image>
|
||||
<view class="vk-contents" v-else-if="item.type === 'video'">
|
||||
<image :src="item | coverImageFilter" mode="aspectFit"></image>
|
||||
<view class="duration">{{ item.duration | durationFilter }}</view>
|
||||
<view class="size">{{ item.size | sizeFilter(["B","KB","MB","GB"],1024,1,"MB") }}</view>
|
||||
<vk-data-icon :name="item.play ?'el-icon-video-pause':'el-icon-video-play'" size="40" color="#d9d9d9" class="video-play-btn" @click="preview(item)"></vk-data-icon>
|
||||
</view>
|
||||
|
||||
<view :src="item.url" class="other-icon" v-else>
|
||||
<vk-data-icon name="el-icon-document" size="80" color="#d5d5de"></vk-data-icon>
|
||||
<view class="size">{{ item.size | sizeFilter(["B","KB","MB","GB"],1024,1) }}</view>
|
||||
<view class="suffix">{{ item.original_name | suffixFilter }}</view>
|
||||
</view>
|
||||
</view>
|
||||
<view class="tips">
|
||||
<text class="title">{{ item.display_name }}</text>
|
||||
<text class="operation" v-if="item.type === 'video'" @click="vk.pubfn.openForm('updateVideo', { item })">编辑</text>
|
||||
<text class="operation" v-else @click="vk.pubfn.openForm('updateFileName', { item })">改名</text>
|
||||
<el-tooltip class="operation" placement="bottom">
|
||||
<text>链接</text>
|
||||
<view slot="content">
|
||||
<view style="text-align: center;">
|
||||
<el-button type="text" @click="copyFileUrl(item.url)" style="margin-left: 0px;"> 复制 </el-button>
|
||||
<el-button type="text" @click="preview(item)" style="margin-left: 30px;"> 预览 </el-button>
|
||||
</view>
|
||||
<view>{{ item.url }}</view>
|
||||
</view>
|
||||
</el-tooltip>
|
||||
<text class="operation" @click="vk.pubfn.openForm('updateFileCategory', { item, list: data.navList })" > 分组 </text>
|
||||
<el-popconfirm class="operation" title="确定删除吗?" @confirm="deleteFile(item._id)">
|
||||
<text slot="reference" @click.stop="stop">删除</text>
|
||||
</el-popconfirm>
|
||||
</view>
|
||||
</view>
|
||||
<!-- 上传的按钮 -->
|
||||
<view class="update-img" @click.stop="uploadFile"></view>
|
||||
</view>
|
||||
<view class="footer" :class="selectedIds.length ? '' : 'no-selected'">
|
||||
<label :style="data.content.rows.length ? '' : 'pointer-events: none;'" class="footer-label" @click.stop="selectAll" >
|
||||
<checkbox style="transform: scale(0.6);" class="checkbox" :checked="selectedIds.length ? true : false" />
|
||||
<text>已选</text>
|
||||
<text class="num">{{ selectedIds.length }} / {{ data.content.rows.length }}</text>
|
||||
<text>项</text>
|
||||
</label>
|
||||
<text class="footer-item" @click.stop=" vk.pubfn.openForm('updateFileCategory', { item: { _id: selectedIds }, list: data.navList }) " >
|
||||
保存到组
|
||||
</text>
|
||||
<el-popconfirm class="footer-item" title="确定删除吗?" @confirm="deleteFile(selectedIds)" >
|
||||
<text slot="reference">删除</text>
|
||||
</el-popconfirm>
|
||||
<!-- 底部分页内容 -->
|
||||
<el-pagination
|
||||
class="paging"
|
||||
background
|
||||
:total="data.content.total"
|
||||
:current-page="queryForm1.pageIndex"
|
||||
:page-size="queryForm1.pageSize"
|
||||
:page-sizes="[30, 50, 100]"
|
||||
:pager-count="5"
|
||||
layout="total, sizes, prev, pager, next, jumper"
|
||||
@size-change=" val => { queryForm1.pageSize = val; getList(); } "
|
||||
@current-change=" val => { queryForm1.pageIndex = val; getList(); } "
|
||||
></el-pagination>
|
||||
</view>
|
||||
<!-- 页面内容结束 -->
|
||||
|
||||
<!-- 弹窗列表 -->
|
||||
<addCategory v-model="formDatas.addCategory" @success="getNavList"></addCategory>
|
||||
<updateCategory v-model="formDatas.updateCategory"></updateCategory>
|
||||
<updateFileCategory v-model="formDatas.updateFileCategory" @success="getList();selectedIds = [];"></updateFileCategory>
|
||||
<updateFileName v-model="formDatas.updateFileName"></updateFileName>
|
||||
<updateVideo v-model="formDatas.updateVideo"></updateVideo>
|
||||
<preview v-model="formDatas.preview"></preview>
|
||||
<uploadProgress v-model="formDatas.uploadProgress" @success="getList();"></uploadProgress>
|
||||
|
||||
|
||||
</view>
|
||||
</template>
|
||||
|
||||
<script>
|
||||
var that; // 当前页面对象
|
||||
var vk = uni.vk; // vk实例
|
||||
|
||||
import addCategory from "./form/addCategory";
|
||||
import updateCategory from "./form/updateCategory";
|
||||
import updateFileCategory from "./form/updateFileCategory";
|
||||
import updateFileName from "./form/updateFileName";
|
||||
import updateVideo from "./form/updateVideo";
|
||||
import preview from "./form/preview";
|
||||
import uploadProgress from "./form/uploadProgress";
|
||||
|
||||
export default {
|
||||
components: {
|
||||
addCategory,
|
||||
updateCategory,
|
||||
updateFileCategory,
|
||||
updateFileName,
|
||||
updateVideo,
|
||||
preview,
|
||||
uploadProgress
|
||||
},
|
||||
data() {
|
||||
// 页面数据变量
|
||||
return {
|
||||
// 选中的
|
||||
selectedIds: [],
|
||||
// 页面是否请求中或加载中
|
||||
loading: {
|
||||
nav: false,
|
||||
main: false
|
||||
},
|
||||
// init请求返回的数据
|
||||
data: {
|
||||
// 分组列表
|
||||
navList: [],
|
||||
// 文件数据
|
||||
content: {
|
||||
rows: [],
|
||||
total: 0
|
||||
}
|
||||
},
|
||||
// 查询表单
|
||||
queryForm1: {
|
||||
pageIndex: 1,
|
||||
pageSize: 30,
|
||||
formData: {
|
||||
display_name: "",
|
||||
category_id: "",
|
||||
type: "image"
|
||||
},
|
||||
columns: [
|
||||
{ key: "display_name", title: "名称", type: "text", mode: "%%" },
|
||||
{ key: "url", title: "URL", type: "text", mode: "=" },
|
||||
{ key: "category_id", title: "分类id", type: "text", mode: "=" },
|
||||
{ key: "type", title: "文件类型", type: "text", mode: "=" }
|
||||
]
|
||||
},
|
||||
formDatas: {}
|
||||
// 表单相关开始 -----------------------------------------------------------
|
||||
};
|
||||
},
|
||||
// 监听 - 页面每次【加载时】执行(如:前进)
|
||||
onLoad(options = {}) {
|
||||
that = this;
|
||||
vk = that.vk;
|
||||
that.options = options;
|
||||
that.init(options);
|
||||
},
|
||||
// 监听 - 页面【首次渲染完成时】执行。注意如果渲染速度快,会在页面进入动画完成前触发
|
||||
onReady() {},
|
||||
// 监听 - 页面每次【显示时】执行(如:前进和返回) (页面每次出现在屏幕上都触发,包括从下级页面点返回露出当前页面)
|
||||
onShow() {},
|
||||
// 监听 - 页面每次【隐藏时】执行(如:返回)
|
||||
onHide() {},
|
||||
// 函数
|
||||
methods: {
|
||||
// 页面数据初始化函数
|
||||
init(options) {
|
||||
that.getNavList();
|
||||
that.getList();
|
||||
},
|
||||
// 获取文件列表
|
||||
getList() {
|
||||
let { queryForm1, selectedIds } = that;
|
||||
vk.callFunction({
|
||||
url: "admin/system_uni/uni-id-files/files/kh/getList",
|
||||
loading: { that, name: "loading.main" },
|
||||
data: queryForm1,
|
||||
success: function(data) {
|
||||
that.data.content = data;
|
||||
selectedIds.length = 0;
|
||||
}
|
||||
});
|
||||
},
|
||||
// 获取分类列表
|
||||
getNavList() {
|
||||
vk.callFunction({
|
||||
url: "admin/system_uni/uni-id-files/categories/kh/getList",
|
||||
loading: { that, name: "loading.nav" },
|
||||
data: {
|
||||
pageIndex: 1,
|
||||
pageSize: 100
|
||||
},
|
||||
success: function(data) {
|
||||
that.data.navList = [
|
||||
{ _id: "", name: "全部" },
|
||||
{ _id: "null", name: "未分组" },
|
||||
...data.rows
|
||||
];
|
||||
}
|
||||
});
|
||||
},
|
||||
// 查询指定分类下的文件列表
|
||||
queryByCategory(category_id) {
|
||||
if (that.queryForm1.formData.category_id != category_id) {
|
||||
that.queryForm1.formData.category_id = category_id;
|
||||
that.getList();
|
||||
}
|
||||
},
|
||||
// 删除分组
|
||||
deleteCategory(_id, index) {
|
||||
vk.callFunction({
|
||||
url: "admin/system_uni/uni-id-files/categories/sys/delete",
|
||||
loading: { that, name: "loading.nav" },
|
||||
data: {
|
||||
_id
|
||||
},
|
||||
success: function(data) {
|
||||
that.data.navList.splice(index, 1);
|
||||
}
|
||||
});
|
||||
},
|
||||
// 删除
|
||||
deleteFile(ids) {
|
||||
vk.callFunction({
|
||||
url: "admin/system_uni/uni-id-files/files/kh/delete",
|
||||
title:"请求中...",
|
||||
data: {
|
||||
_id: ids
|
||||
},
|
||||
success: function(data) {
|
||||
if(data.num>0){
|
||||
if (typeof ids !== "object") ids = [ids];
|
||||
ids.map(id => {
|
||||
let index = vk.pubfn.getListIndex(that.data.content.rows, "_id", id);
|
||||
if (index > -1) {
|
||||
that.data.content.rows.splice(index, 1);
|
||||
}
|
||||
});
|
||||
that.selectedIds = [];
|
||||
}
|
||||
}
|
||||
});
|
||||
},
|
||||
uploadFile(){
|
||||
let type = that.queryForm1.formData.type;
|
||||
let fileType;
|
||||
let extension = [];
|
||||
if(type === "image"){
|
||||
extension = ["png", "jpg", "jpeg", "gif", "bmp", "svg", "webp", "jfif", "dpg"];
|
||||
fileType = "image";
|
||||
}else if(type === "video"){
|
||||
extension = ["avi", "mp3", "mp4", "3gp", "mov", "rmvb", "rm", "flv", "mkv", "wmv", "m3u8", "mpg", "mpeg", "dat", "asf"];
|
||||
fileType = "video";
|
||||
}else if(type === "other"){
|
||||
extension = ["txt","pdf","xls","xlsx","ppt","pptx","doc","docx","rar","zip"];
|
||||
}
|
||||
uni.chooseFile({
|
||||
extension,
|
||||
success: async res => {
|
||||
let item = {
|
||||
tempFilePaths: res.tempFilePaths,
|
||||
tempFiles: res.tempFiles,
|
||||
categoryId: that.queryForm1.formData.category_id,
|
||||
fileType,
|
||||
};
|
||||
vk.pubfn.openForm('uploadProgress', { item });
|
||||
// vk.showLoading("上传中...");
|
||||
// for (let i = 0; i < res.tempFilePaths.length; i++) {
|
||||
// let percentage = vk.pubfn.toDecimal((i+1) / res.tempFilePaths.length * 100, 0);
|
||||
// try {
|
||||
// await vk.uploadFile({
|
||||
// filePath: res.tempFilePaths[i],
|
||||
// file: res.tempFiles[i],
|
||||
// needSave: true,
|
||||
// fileType,
|
||||
// category_id: that.queryForm1.formData.category_id,
|
||||
// onUploadProgress:function(progressRes){
|
||||
// // 上传过程中
|
||||
// vk.showLoading(`文件${i+1}:${progressRes.progress}%\n`);
|
||||
// },
|
||||
// });
|
||||
// vk.showLoading(`总上传进度:${percentage}%`);
|
||||
// } catch(err){
|
||||
// console.error(err);
|
||||
// }
|
||||
// }
|
||||
// vk.hideLoading();
|
||||
// that.getList();
|
||||
}
|
||||
});
|
||||
},
|
||||
// 复制文件的URL
|
||||
copyFileUrl(data) {
|
||||
uni.setClipboardData({
|
||||
data,
|
||||
success: res => {
|
||||
that.$message({
|
||||
message: "URL已复制",
|
||||
type: "success"
|
||||
});
|
||||
}
|
||||
});
|
||||
},
|
||||
// 预览
|
||||
preview(item){
|
||||
let { type, url } = item;
|
||||
if(type === "image"){
|
||||
vk.pubfn.openForm('preview', { item })
|
||||
}else if(type === "video"){
|
||||
vk.pubfn.openForm('preview', { item })
|
||||
}else{
|
||||
vk.toast("暂不支持该类型文件的预览");
|
||||
}
|
||||
},
|
||||
// 点击了文件
|
||||
clickFile(item) {
|
||||
let index = that.selectedIds.indexOf(item._id);
|
||||
if (index > -1) {
|
||||
that.selectedIds.splice(index, 1);
|
||||
} else {
|
||||
that.selectedIds.push(item._id);
|
||||
}
|
||||
},
|
||||
// 全选
|
||||
selectAll() {
|
||||
if (that.selectedIds.length &&that.data.content.rows.length == that.selectedIds.length) {
|
||||
that.selectedIds = [];
|
||||
} else {
|
||||
that.data.content.rows.forEach((value, index, arr) => {
|
||||
if (!that.selectedIds.includes(value._id)) {
|
||||
that.selectedIds.push(value._id);
|
||||
}
|
||||
});
|
||||
}
|
||||
},
|
||||
stop() {}
|
||||
},
|
||||
watch: {},
|
||||
// 过滤器
|
||||
filters: {
|
||||
suffixFilter(name=""){
|
||||
let arr = name.split(".");
|
||||
return arr[arr.length-1];
|
||||
},
|
||||
coverImageFilter(item){
|
||||
let src = "";
|
||||
let { cover_image, url, width=600, height=600 } = item;
|
||||
if(cover_image){
|
||||
src = cover_image;
|
||||
}else{
|
||||
src = `${url}?x-oss-process=video/snapshot,t_1000,f_jpg,w_${width},h_${height},m_fast`;
|
||||
}
|
||||
console.log('src: ', src)
|
||||
return src;
|
||||
},
|
||||
durationFilter(value){
|
||||
let result = parseInt(value);
|
||||
let h = Math.floor(result / 3600) < 10 ? '0' + Math.floor(result / 3600) : Math.floor(result / 3600);
|
||||
let m = Math.floor((result / 60 % 60)) < 10 ? '0' + Math.floor((result / 60 % 60)) : Math.floor((result / 60 % 60));
|
||||
let s = Math.floor((result % 60)) < 10 ? '0' + Math.floor((result % 60)) : Math.floor((result % 60));
|
||||
return `${h}:${m}:${s}`;
|
||||
}
|
||||
},
|
||||
// 计算属性
|
||||
computed: {}
|
||||
};
|
||||
</script>
|
||||
<style lang="scss" scoped>
|
||||
page,
|
||||
.page-body {
|
||||
width: 100%;
|
||||
height: 100%;
|
||||
}
|
||||
// 页面主体内容区域
|
||||
.page-body {
|
||||
display: grid;
|
||||
grid-template-columns: 180px auto;
|
||||
grid-template-rows: 35px auto 40px;
|
||||
grid-gap: 8px 0px;
|
||||
position: relative;
|
||||
}
|
||||
.header {
|
||||
display: flex;
|
||||
align-items: center;
|
||||
grid-column: 1 / -1;
|
||||
font-size: 14px;
|
||||
user-select: none;
|
||||
.el-button {
|
||||
height: 32px;
|
||||
}
|
||||
}
|
||||
// 搜索
|
||||
.header-item {
|
||||
margin-left: 20px;
|
||||
height: 100%;
|
||||
display: flex;
|
||||
border-radius: 4px;
|
||||
overflow: hidden;
|
||||
.search-input {
|
||||
width: 200px;
|
||||
|
||||
}
|
||||
.el-button {
|
||||
height: 32px;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
.nav {
|
||||
height: 100%;
|
||||
grid-row: 2 / -1;
|
||||
border: 1px solid #e4e2e2;
|
||||
display: grid;
|
||||
grid-template-rows: repeat(auto-fill, 40px);
|
||||
color: #59607b;
|
||||
font-size: 12px;
|
||||
overflow-y: auto;
|
||||
box-sizing: border-box;
|
||||
padding-bottom: 10px;
|
||||
}
|
||||
.nav-list {
|
||||
cursor: pointer;
|
||||
border-bottom: 1px solid #e4e2e2;
|
||||
box-sizing: border-box;
|
||||
height: 40px;
|
||||
overflow: hidden;
|
||||
transition: all 0.3s;
|
||||
background-color: #f6f4f4;
|
||||
padding-left: 10px;
|
||||
display: flex;
|
||||
align-items: center;
|
||||
> i {
|
||||
font-size: 13px;
|
||||
place-self: center;
|
||||
}
|
||||
&:hover {
|
||||
color: #108ee9;
|
||||
}
|
||||
.nav-name {
|
||||
flex: 1;
|
||||
}
|
||||
.nav-btn {
|
||||
width: 44px;
|
||||
display: flex;
|
||||
align-items: center;
|
||||
.btn {
|
||||
width: 22px;
|
||||
display: block;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// 选中的分栏
|
||||
.selected-nav {
|
||||
background-color: #ecf6fd !important;
|
||||
color: #108ee9 !important;
|
||||
}
|
||||
// 添加分组的按钮
|
||||
.add-group {
|
||||
width: 60%;
|
||||
margin: 5px auto;
|
||||
padding: 5px 0px;
|
||||
text-align: center;
|
||||
border: 1px dashed #108ee9;
|
||||
color: #108ee9;
|
||||
cursor: pointer;
|
||||
}
|
||||
.add-group:hover {
|
||||
background-color: #108ee9;
|
||||
color: #ffffff;
|
||||
opacity: 0.9;
|
||||
}
|
||||
.add-group:active {
|
||||
background-color: #108ee9;
|
||||
color: #ffffff;
|
||||
}
|
||||
// 内容详情
|
||||
.main {
|
||||
display: grid;
|
||||
grid-template-columns: repeat(auto-fill, 135px);
|
||||
grid-template-rows: repeat(auto-fill, 180px);
|
||||
grid-gap: 20px;
|
||||
place-content: start center;
|
||||
overflow-y: auto;
|
||||
min-width: 700px;
|
||||
}
|
||||
.update-img,
|
||||
.content-item {
|
||||
width: 135px;
|
||||
height: 180px;
|
||||
border: 1px solid #e4e2e2;
|
||||
cursor: pointer;
|
||||
background-color: transparent;
|
||||
transition: all 0.25s;
|
||||
position: relative;
|
||||
overflow: hidden;
|
||||
}
|
||||
// 被选中的
|
||||
.choose-image {
|
||||
background-color: #ecf6fd !important;
|
||||
border: 1px solid #daedff;
|
||||
.tips{
|
||||
background-color: #ecf6fd;
|
||||
}
|
||||
}
|
||||
.content-item:hover {
|
||||
background-color: #ecf6fd;
|
||||
border: 1px solid #daedff;
|
||||
}
|
||||
.item-file {
|
||||
width: 100%;
|
||||
height: 150px;
|
||||
position: relative;
|
||||
image {
|
||||
width: 100%;
|
||||
height: 100%;
|
||||
}
|
||||
.suffix{
|
||||
position: absolute;
|
||||
top:2px;
|
||||
right: 6px;
|
||||
font-size: 12px;
|
||||
color: #a7a7a7;
|
||||
}
|
||||
.duration{
|
||||
position: absolute;
|
||||
bottom:0px;
|
||||
left: 0px;
|
||||
font-size: 12px;
|
||||
color: #FFFFFF;
|
||||
background-color: #b2b2b2;
|
||||
padding: 0px 2px;
|
||||
}
|
||||
.size{
|
||||
position: absolute;
|
||||
bottom:0px;
|
||||
right: 0px;
|
||||
font-size: 12px;
|
||||
color: #FFFFFF;
|
||||
background-color: #b2b2b2;
|
||||
padding: 0px 2px;
|
||||
}
|
||||
.video-play-btn{
|
||||
position: absolute;
|
||||
top:54px;
|
||||
left:47px;
|
||||
background-color: rgba(66,66,66,0.6);
|
||||
border-radius: 50%;
|
||||
}
|
||||
|
||||
.other-icon{
|
||||
display: flex;
|
||||
width: 100%;
|
||||
height: 100%;
|
||||
justify-content: center;
|
||||
align-items: center;
|
||||
}
|
||||
}
|
||||
.content-item:hover > .tips {
|
||||
transform: translateY(0%) !important;
|
||||
}
|
||||
// 上传按钮
|
||||
.update-img {
|
||||
display: flex;
|
||||
align-items: center;
|
||||
justify-content: center;
|
||||
flex-direction: column;
|
||||
color: #d5d5de;
|
||||
&::before {
|
||||
line-height: 1;
|
||||
font-size: 45px;
|
||||
content: "+";
|
||||
}
|
||||
&::after {
|
||||
content: "上传";
|
||||
font-size: 12px;
|
||||
}
|
||||
}
|
||||
.tips {
|
||||
position: absolute;
|
||||
height: 60px;
|
||||
right: 0px;
|
||||
bottom: 0px;
|
||||
left: 0px;
|
||||
background-color: #fff;
|
||||
transition: all 0.4s;
|
||||
transform: translateY(50%);
|
||||
display: grid;
|
||||
grid-template-columns: repeat(4, 1fr);
|
||||
grid-template-rows: repeat(2, 1fr);
|
||||
grid-gap: 5px 0px;
|
||||
font-size: 13px;
|
||||
place-items: center;
|
||||
}
|
||||
.title {
|
||||
text-align: center;
|
||||
grid-column: 1 / -1;
|
||||
width: 100%;
|
||||
white-space: nowrap;
|
||||
overflow: hidden;
|
||||
text-overflow: ellipsis;
|
||||
}
|
||||
.operation {
|
||||
height: 100%;
|
||||
display: flex;
|
||||
align-items: center;
|
||||
justify-content: center;
|
||||
&:hover {
|
||||
color: #108ee9;
|
||||
}
|
||||
}
|
||||
// 保存到组、删除、下载链接
|
||||
.footer {
|
||||
background-color: #f4faff;
|
||||
display: flex;
|
||||
align-items: center;
|
||||
font-size: 12px;
|
||||
color: #3091f2;
|
||||
}
|
||||
.paging {
|
||||
flex: 1;
|
||||
display: flex;
|
||||
align-items: center;
|
||||
justify-content: flex-end;
|
||||
}
|
||||
.footer-item {
|
||||
padding: 2px 9px;
|
||||
border: 1px solid #3091f2;
|
||||
margin-left: 8px;
|
||||
cursor: pointer;
|
||||
background-color: #ffffff;
|
||||
}
|
||||
|
||||
.no-selected {
|
||||
.footer-item {
|
||||
pointer-events: none;
|
||||
color: #ced0d5;
|
||||
background-color: #fff;
|
||||
border-color: #ebeef5 !important;
|
||||
}
|
||||
}
|
||||
|
||||
.footer-label {
|
||||
display: flex;
|
||||
align-items: center;
|
||||
user-select: none;
|
||||
color: #59607b;
|
||||
.checkbox {
|
||||
margin: 0;
|
||||
padding: 0;
|
||||
outline: none;
|
||||
}
|
||||
}
|
||||
.num {
|
||||
min-width: 50px;
|
||||
text-align: center;
|
||||
margin: 0 10px;
|
||||
color: #3091f2;
|
||||
}
|
||||
::v-deep .input-border-radius-4004 .el-input__inner{
|
||||
border-radius: 4px 0px 0px 4px;
|
||||
}
|
||||
</style>
|
||||
@@ -0,0 +1,182 @@
|
||||
<template>
|
||||
<view class="page-body">
|
||||
<!-- 页面内容开始 -->
|
||||
|
||||
<!-- 表格搜索组件开始 -->
|
||||
<vk-data-table-query
|
||||
v-model="queryForm1.formData"
|
||||
:columns="queryForm1.columns"
|
||||
@search="search"
|
||||
></vk-data-table-query>
|
||||
<!-- 表格搜索组件结束 -->
|
||||
<!-- 表格组件开始 -->
|
||||
<vk-data-table
|
||||
ref="table1"
|
||||
:action="table1.action"
|
||||
:columns="table1.columns"
|
||||
:query-form-param="queryForm1"
|
||||
:right-btns="['detail_auto']"
|
||||
:row-no="true"
|
||||
:pagination="true"
|
||||
></vk-data-table>
|
||||
<!-- 表格组件结束 -->
|
||||
<!-- 页面内容结束 -->
|
||||
</view>
|
||||
</template>
|
||||
|
||||
<script>
|
||||
var that; // 当前页面对象
|
||||
var vk = uni.vk; // vk实例
|
||||
var dcloudAppidData = [];
|
||||
|
||||
export default {
|
||||
data() {
|
||||
// 页面数据变量
|
||||
return {
|
||||
// 页面是否请求中或加载中
|
||||
loading: false,
|
||||
// init请求返回的数据
|
||||
data: {},
|
||||
// 表格相关开始 -----------------------------------------------------------
|
||||
table1: {
|
||||
// 表格数据请求地址
|
||||
action: "admin/system_uni/uni-id-log/sys/getList",
|
||||
// 表格字段显示规则
|
||||
columns: [
|
||||
{ key:"appList", title:"登录的应用", type:"html", width:220,
|
||||
formatter: function(val, row, column, index) {
|
||||
if(typeof row.dcloud_appid === "undefined") return "全部应用";
|
||||
if(row.dcloud_appid.length === 0) return "未绑定任何应用";
|
||||
if(val.length === 0 && row.dcloud_appid.length > 0) return row.dcloud_appid;
|
||||
let str = "";
|
||||
val.map((item, index) => {
|
||||
str += `、${item.name}`;
|
||||
});
|
||||
if(str) str = str.substring(1);
|
||||
return str;
|
||||
}
|
||||
},
|
||||
{ key: "userInfo", title: "用户信息", type: "userInfo", width: 150 },
|
||||
{ key: "ip", title: "ip地址", type: "text", width: 150 },
|
||||
{ key: "type", title: "日志类型", type: "text", width: 120 },
|
||||
{ key: "login_type", title: "登录类型", type: "select", width: 120,
|
||||
data:[
|
||||
{ value: "phone", label:"手机短信" },
|
||||
{ value: "password", label:"账号密码" },
|
||||
{ value: "weixin", label:"微信登录" },
|
||||
{ value: "alipay", label:"支付宝登录" },
|
||||
{ value: "weixinPhoneNumber", label:"微信手机号" },
|
||||
{ value: "token", label:"token" }
|
||||
]
|
||||
},
|
||||
{ key: "os", title: "操作系统", type: "text", width: 120 },
|
||||
{ key: "platform", title: "平台信息", type: "text", width: 120 },
|
||||
{ key: "device_id", title: "设备唯一标识", type: "text", width: 120 },
|
||||
{ key: "_add_time", title: "添加时间", type: "time", width: 160 },
|
||||
{ key: "_add_time", title: "距离现在", type: "dateDiff", width: 120 },
|
||||
{ key: "ua", title: "userAgent", type: "text", width: 400 },
|
||||
{ key: "user_id", title: "用户ID", type: "text", width: 220 },
|
||||
],
|
||||
// 多选框选中的值
|
||||
multipleSelection: [],
|
||||
// 当前高亮的记录
|
||||
selectItem: ""
|
||||
},
|
||||
// 表格相关结束 -----------------------------------------------------------
|
||||
// 表单相关开始 -----------------------------------------------------------
|
||||
// 查询表单请求数据
|
||||
queryForm1: {
|
||||
// 查询表单数据源,可在此设置默认值
|
||||
formData: {
|
||||
dcloud_appid:""
|
||||
},
|
||||
// 查询表单的字段规则 fieldName:指定数据库字段名,不填默认等于key
|
||||
columns: [
|
||||
{ key:"dcloud_appid", title:"所属应用", type:"select", width:160, mode:"custom",
|
||||
data:[],
|
||||
props:{ value:"appid", label:"name" }
|
||||
},
|
||||
{ key: "user_id", title: "用户ID", type: "text", width:140, mode: "=" },
|
||||
{ key: "ip", title: "ip地址", type: "text", width:140, mode: "%%" },
|
||||
{ key: "device_id", title: "设备唯一标识", type: "text", width:180, mode: "%%" },
|
||||
{ key: "_add_time", title: "添加时间", type: "datetimerange", width: 380, mode: "[]" }
|
||||
]
|
||||
},
|
||||
// 表单相关结束 -----------------------------------------------------------
|
||||
};
|
||||
},
|
||||
// 监听 - 页面每次【加载时】执行(如:前进)
|
||||
onLoad(options = {}) {
|
||||
that = this;
|
||||
vk = that.vk;
|
||||
that.options = options;
|
||||
that.init(options);
|
||||
},
|
||||
// 监听 - 页面【首次渲染完成时】执行。注意如果渲染速度快,会在页面进入动画完成前触发
|
||||
onReady() {},
|
||||
// 监听 - 页面每次【显示时】执行(如:前进和返回) (页面每次出现在屏幕上都触发,包括从下级页面点返回露出当前页面)
|
||||
onShow() {},
|
||||
// 监听 - 页面每次【隐藏时】执行(如:返回)
|
||||
onHide() {},
|
||||
// 函数
|
||||
methods: {
|
||||
// 页面数据初始化函数
|
||||
init(options) {
|
||||
that.getAppList();
|
||||
},
|
||||
// 获取应用列表
|
||||
getAppList(obj){
|
||||
// 请在store/modules/$app.js文件里增加代码 appList: lifeData.$app.appList || []
|
||||
vk.callFunction({
|
||||
url: 'admin/system/app/sys/getList',
|
||||
data:{},
|
||||
success:function(data){
|
||||
dcloudAppidData = data.rows;
|
||||
let dcloudAppidData2 = vk.pubfn.copyObject(data.rows);
|
||||
dcloudAppidData2.unshift({
|
||||
appid:"___error___",
|
||||
name:"不存在的应用"
|
||||
});
|
||||
dcloudAppidData2.unshift({
|
||||
appid:"___empty-array___",
|
||||
name:"未绑定应用"
|
||||
});
|
||||
dcloudAppidData2.unshift({
|
||||
appid:"___non-existent___",
|
||||
name:"全部应用"
|
||||
});
|
||||
let index2 = vk.pubfn.getListIndex(that.queryForm1.columns, "key", "dcloud_appid");
|
||||
that.queryForm1.columns[index2].data = dcloudAppidData2;
|
||||
let appids = [];
|
||||
dcloudAppidData.map((item, index) => {
|
||||
appids.push(item.appid);
|
||||
});
|
||||
that.queryForm1.formData.appids = appids;
|
||||
}
|
||||
});
|
||||
},
|
||||
// 搜索
|
||||
search(obj) {
|
||||
that.$refs.table1.query(obj);
|
||||
},
|
||||
// 刷新
|
||||
refresh() {
|
||||
that.$refs.table1.refresh();
|
||||
}
|
||||
},
|
||||
watch: {
|
||||
|
||||
},
|
||||
// 过滤器
|
||||
filters: {
|
||||
|
||||
},
|
||||
// 计算属性
|
||||
computed: {
|
||||
|
||||
}
|
||||
};
|
||||
</script>
|
||||
<style lang="scss" scoped>
|
||||
|
||||
</style>
|
||||
@@ -0,0 +1,289 @@
|
||||
<template>
|
||||
<view class="page-body">
|
||||
<!-- 页面内容开始 -->
|
||||
<!-- 表格搜索组件开始 -->
|
||||
<vk-data-table-query
|
||||
v-model="queryForm1.formData"
|
||||
:columns="queryForm1.columns"
|
||||
@search="search"
|
||||
>
|
||||
<template slot="right-btns">
|
||||
<el-button type="success" icon="el-icon-circle-plus-outline" @click="addBtn">
|
||||
添加
|
||||
</el-button>
|
||||
</template>
|
||||
</vk-data-table-query>
|
||||
<!-- 表格搜索组件结束 -->
|
||||
|
||||
<!-- 表格组件开始 -->
|
||||
<vk-data-table
|
||||
ref="table1"
|
||||
:action="table1.action"
|
||||
:columns="table1.columns"
|
||||
:query-form-param="queryForm1"
|
||||
:right-btns="['detail_auto', 'update', 'delete']"
|
||||
:row-no="true"
|
||||
:pagination="true"
|
||||
@update="updateBtn"
|
||||
@delete="deleteBtn"
|
||||
@current-change="currentChange"
|
||||
@selection-change="selectionChange"
|
||||
>
|
||||
<!-- 排序值 -->
|
||||
<template v-slot:sort="{ row, column, index }">
|
||||
<el-input v-model="row.sort" size="mini" @change="sortChange($event, row)"/>
|
||||
</template>
|
||||
</vk-data-table>
|
||||
<!-- 表格组件结束 -->
|
||||
|
||||
<!-- 添加或编辑的弹窗开始 -->
|
||||
<vk-data-dialog
|
||||
v-model="form1.props.show"
|
||||
:title="form1.props.title"
|
||||
width="800px"
|
||||
mode="form"
|
||||
>
|
||||
<vk-data-form
|
||||
ref="form1"
|
||||
v-model="form1.data"
|
||||
:rules="form1.props.rules"
|
||||
:action="form1.props.action"
|
||||
:form-type="form1.props.formType"
|
||||
:columns='form1.props.columns'
|
||||
label-width="100px"
|
||||
@success="form1.props.show = false;refresh();"
|
||||
></vk-data-form>
|
||||
</vk-data-dialog>
|
||||
<!-- 添加或编辑的弹窗结束 -->
|
||||
|
||||
<!-- 页面内容结束 -->
|
||||
</view>
|
||||
</template>
|
||||
|
||||
<script>
|
||||
var that; // 当前页面对象
|
||||
var vk = uni.vk; // vk实例
|
||||
var originalForms = {}; // 表单初始化数据
|
||||
|
||||
var typeData = [
|
||||
{ value: "image", label: "图片" },
|
||||
{ value: "swiper", label: "图片轮播" },
|
||||
{ value: "grid-btn", label: "宫格按钮" },
|
||||
{ value: "notice", label: "通知" },
|
||||
{ value: "text", label: "文本" },
|
||||
{ value: "rich-text", label: "富文本" },
|
||||
{ value: "button", label: "按钮" },
|
||||
{ value: "custom", label: "自定义" }
|
||||
];
|
||||
|
||||
export default {
|
||||
data() {
|
||||
// 页面数据变量
|
||||
return {
|
||||
// 页面是否请求中或加载中
|
||||
loading: false,
|
||||
// init请求返回的数据
|
||||
data: {},
|
||||
// 表格相关开始 -----------------------------------------------------------
|
||||
table1: {
|
||||
// 表格数据请求地址
|
||||
action: "admin/system_uni/components-dynamic/sys/getList",
|
||||
// 表格字段显示规则
|
||||
columns: [
|
||||
{ key: "sort", title: "排序值", type: "number", width: 100, sortable: "custom" },
|
||||
{ key: "data_id", title: "组件数据id", type: "text", width: 200 },
|
||||
{ key: "title", title: "数据标题", type: "text", width: 200 },
|
||||
{ key: "description", title: "数据描述", type: "textarea" },
|
||||
{ key: "data", title: "组件数据", type: "json", width: 200 },
|
||||
{
|
||||
key: "show", title: "是否显示", type: "switch",
|
||||
activeValue: true,
|
||||
inactiveValue: false,
|
||||
width: 80,
|
||||
watch: (res) => {
|
||||
let { value, row, change } = res;
|
||||
vk.callFunction({
|
||||
url: "admin/system_uni/components-dynamic/sys/update",
|
||||
title: "请求中...",
|
||||
data: {
|
||||
_id: row._id,
|
||||
show: value
|
||||
},
|
||||
success: data => {
|
||||
change(value); // 这一步是让表格行内的开关改变显示状态
|
||||
}
|
||||
});
|
||||
}
|
||||
},
|
||||
{
|
||||
key: "type", title: "type", type: "select", width: 120,
|
||||
data: typeData
|
||||
},
|
||||
{ key: "name", title: "name", type: "text", width: 120 },
|
||||
{ key: "_add_time", title: "添加时间", type: "time", width: 200 },
|
||||
{ key: "_add_time", title: "距离现在", type: "dateDiff", width: 120 }
|
||||
],
|
||||
// 多选框选中的值
|
||||
multipleSelection: [],
|
||||
// 当前高亮的记录
|
||||
selectItem: ""
|
||||
},
|
||||
// 表格相关结束 -----------------------------------------------------------
|
||||
// 表单相关开始 -----------------------------------------------------------
|
||||
// 查询表单请求数据
|
||||
queryForm1: {
|
||||
// 查询表单数据源,可在此设置默认值
|
||||
formData: {},
|
||||
// 查询表单的字段规则 fieldName:指定数据库字段名,不填默认等于key
|
||||
columns: [
|
||||
{ key: "data_id", title: "组件数据ID", type: "text", width: 180, mode: "%%" },
|
||||
{ key: "title", title: "数据标题", type: "text", width: 180, mode: "%%" },
|
||||
{
|
||||
key: "type", title: "type", type: "select", width: 160, mode: "=",
|
||||
data: [
|
||||
{ value: "", label: "全部" },
|
||||
...typeData
|
||||
]
|
||||
},
|
||||
{ key: "name", title: "name", type: "text", width: 160, mode: "%%" },
|
||||
{ key: "_add_time", title: "添加时间", type: "datetimerange", width: 380, mode: "[]" }
|
||||
]
|
||||
},
|
||||
form1: {
|
||||
// 表单请求数据,此处可以设置默认值
|
||||
data: {
|
||||
sort: 0,
|
||||
show: true
|
||||
},
|
||||
// 表单属性
|
||||
props: {
|
||||
// 表单请求地址
|
||||
action: "",
|
||||
// 表单字段显示规则
|
||||
columns: [
|
||||
{ key:"", title:"基础", type:"bar-title" },
|
||||
{ key: "data_id", title: "组件数据id", type: "text", show: ["add"] },
|
||||
{ key: "title", title: "数据标题", type: "text" },
|
||||
{ key: "data", title: "组件数据", type: "json" },
|
||||
{ key: "description", title: "数据描述", type: "textarea" },
|
||||
{ key:"", title:"扩展", type:"bar-title" },
|
||||
{ key: "sort", title: "排序值", type: "number" },
|
||||
{ key: "show", title: "是否显示", type: "switch", activeValue: true, inactiveValue: false },
|
||||
{
|
||||
key: "type", title: "type", type: "select",
|
||||
data: typeData
|
||||
},
|
||||
{ key: "name", title: "name", type: "text", tips:"同一页面可以设置相同的name" },
|
||||
],
|
||||
// 表单验证规则
|
||||
rules: {
|
||||
title: [{ required: true, message: "数据标题不能为空", trigger: "blur" }],
|
||||
data_id: [{ required: true, message: "组件数据id不能为空", trigger: "change" }]
|
||||
},
|
||||
// add 代表添加 update 代表修改
|
||||
formType: "",
|
||||
// 是否显示表单的弹窗
|
||||
show: false
|
||||
}
|
||||
},
|
||||
// 表单相关结束 -----------------------------------------------------------
|
||||
};
|
||||
},
|
||||
// 监听 - 页面每次【加载时】执行(如:前进)
|
||||
onLoad(options = {}) {
|
||||
that = this;
|
||||
vk = that.vk;
|
||||
that.options = options;
|
||||
that.init(options);
|
||||
},
|
||||
// 监听 - 页面【首次渲染完成时】执行。注意如果渲染速度快,会在页面进入动画完成前触发
|
||||
onReady() {},
|
||||
// 监听 - 页面每次【显示时】执行(如:前进和返回) (页面每次出现在屏幕上都触发,包括从下级页面点返回露出当前页面)
|
||||
onShow() {},
|
||||
// 监听 - 页面每次【隐藏时】执行(如:返回)
|
||||
onHide() {},
|
||||
// 函数
|
||||
methods: {
|
||||
// 页面数据初始化函数
|
||||
init(options) {
|
||||
originalForms["form1"] = vk.pubfn.copyObject(that.form1);
|
||||
},
|
||||
// 页面跳转
|
||||
pageTo(path) {
|
||||
vk.navigateTo(path);
|
||||
},
|
||||
// 表单重置
|
||||
resetForm() {
|
||||
vk.pubfn.resetForm(originalForms, that);
|
||||
},
|
||||
// 搜索
|
||||
search(obj) {
|
||||
that.$refs.table1.query(obj);
|
||||
},
|
||||
// 刷新
|
||||
refresh() {
|
||||
that.$refs.table1.refresh();
|
||||
},
|
||||
// 获取当前选中的行的数据
|
||||
getCurrentRow() {
|
||||
return that.$refs.table1.getCurrentRow();
|
||||
},
|
||||
// 监听 - 行的选中高亮事件
|
||||
currentChange(val) {
|
||||
that.table1.selectItem = val;
|
||||
},
|
||||
// 当选择项发生变化时会触发该事件
|
||||
selectionChange(list) {
|
||||
that.table1.multipleSelection = list;
|
||||
},
|
||||
// 显示添加页面
|
||||
addBtn() {
|
||||
that.resetForm();
|
||||
that.form1.props.action = "admin/system_uni/components-dynamic/sys/add";
|
||||
that.form1.props.formType = "add";
|
||||
that.form1.props.title = "添加";
|
||||
that.form1.props.show = true;
|
||||
},
|
||||
// 显示修改页面
|
||||
updateBtn({ item }) {
|
||||
that.form1.props.action = "admin/system_uni/components-dynamic/sys/update";
|
||||
that.form1.props.formType = "update";
|
||||
that.form1.props.title = "编辑";
|
||||
that.form1.props.show = true;
|
||||
that.form1.data = item;
|
||||
},
|
||||
// 删除按钮
|
||||
deleteBtn({ item, deleteFn }) {
|
||||
deleteFn({
|
||||
action: "admin/system_uni/components-dynamic/sys/delete",
|
||||
data: {
|
||||
_id: item._id
|
||||
}
|
||||
});
|
||||
},
|
||||
// 修改排序值
|
||||
sortChange(sort, item){
|
||||
vk.callFunction({
|
||||
url: 'admin/system_uni/components-dynamic/sys/update',
|
||||
data: {
|
||||
_id: item._id,
|
||||
sort: Number(sort)
|
||||
},
|
||||
success: (data) => {
|
||||
|
||||
}
|
||||
});
|
||||
},
|
||||
},
|
||||
watch: {
|
||||
|
||||
},
|
||||
// 计算属性
|
||||
computed: {
|
||||
|
||||
}
|
||||
};
|
||||
</script>
|
||||
<style lang="scss" scoped>
|
||||
|
||||
</style>
|
||||
@@ -0,0 +1,221 @@
|
||||
<template>
|
||||
<view class="page-body">
|
||||
<!-- 页面内容开始 -->
|
||||
|
||||
<!-- 表格搜索组件开始 -->
|
||||
|
||||
<vk-data-table-query
|
||||
v-model="queryForm1.formData"
|
||||
:columns="queryForm1.columns"
|
||||
@search="search"
|
||||
>
|
||||
<template slot="right-btns">
|
||||
<el-button type="success" icon="el-icon-circle-plus-outline" @click="addBtn">
|
||||
添加
|
||||
</el-button>
|
||||
</template>
|
||||
</vk-data-table-query>
|
||||
<!-- 表格搜索组件结束 -->
|
||||
|
||||
<!-- 表格组件开始 -->
|
||||
<vk-data-table
|
||||
ref="table1"
|
||||
:action="table1.action"
|
||||
:columns="table1.columns"
|
||||
:query-form-param="queryForm1"
|
||||
:right-btns="['detail_auto', 'update', 'delete']"
|
||||
:row-no="true"
|
||||
:pagination="true"
|
||||
@update="updateBtn"
|
||||
@delete="deleteBtn"
|
||||
@current-change="currentChange"
|
||||
@selection-change="selectionChange"
|
||||
></vk-data-table>
|
||||
<!-- 表格组件结束 -->
|
||||
|
||||
<!-- 添加或编辑的弹窗开始 -->
|
||||
<vk-data-dialog
|
||||
v-model="form1.props.show"
|
||||
:title="form1.props.title"
|
||||
width="800px"
|
||||
mode="form"
|
||||
>
|
||||
<vk-data-form
|
||||
ref="form1"
|
||||
v-model="form1.data"
|
||||
:rules="form1.props.rules"
|
||||
:action="form1.props.action"
|
||||
:form-type="form1.props.formType"
|
||||
:columns='form1.props.columns'
|
||||
label-width="80px"
|
||||
@success="form1.props.show = false;refresh();"
|
||||
></vk-data-form>
|
||||
</vk-data-dialog>
|
||||
<!-- 添加或编辑的弹窗结束 -->
|
||||
<!-- 页面内容结束 -->
|
||||
</view>
|
||||
</template>
|
||||
|
||||
<script>
|
||||
var that; // 当前页面对象
|
||||
var vk = uni.vk; // vk实例
|
||||
var originalForms = {}; // 表单初始化数据
|
||||
|
||||
export default {
|
||||
data() {
|
||||
// 页面数据变量
|
||||
return {
|
||||
// 页面是否请求中或加载中
|
||||
loading: false,
|
||||
// init请求返回的数据
|
||||
data: {},
|
||||
// 表格相关开始 -----------------------------------------------------------
|
||||
table1: {
|
||||
// 表格数据请求地址
|
||||
action: "admin/system_uni/global-data/sys/getList",
|
||||
// 表格字段显示规则
|
||||
columns: [
|
||||
{ key: "key", title: "键名", type: "text", width: 200 },
|
||||
{ key: "value", title: "键值", type: "json", width: 200 },
|
||||
{ key: "_add_time", title: "添加时间", type: "time", width: 160 },
|
||||
{ key: "_add_time", title: "距离现在", type: "dateDiff", width: 120 },
|
||||
{ key: "expired_at", title: "过期时间", type: "time", width: 160, defaultValue: "无" },
|
||||
{ key: "comment", title: "备注", type: "text", width: 300 }
|
||||
],
|
||||
// 多选框选中的值
|
||||
multipleSelection: [],
|
||||
// 当前高亮的记录
|
||||
selectItem: ""
|
||||
},
|
||||
// 表格相关结束 -----------------------------------------------------------
|
||||
// 表单相关开始 -----------------------------------------------------------
|
||||
// 查询表单请求数据
|
||||
queryForm1: {
|
||||
// 查询表单数据源,可在此设置默认值
|
||||
formData: {},
|
||||
// 查询表单的字段规则 fieldName:指定数据库字段名,不填默认等于key
|
||||
columns: [
|
||||
{ key: "key", type: "text", title: "键名搜索", mode: "%%" },
|
||||
{ key: "value", type: "text", title: "键值搜索", mode: "%%" },
|
||||
{ key: "_add_time", type: "datetimerange", title: "添加时间", width: 400, mode: "[]" }
|
||||
]
|
||||
},
|
||||
form1: {
|
||||
// 表单请求数据,此处可以设置默认值
|
||||
data: {
|
||||
|
||||
},
|
||||
// 表单属性
|
||||
props: {
|
||||
// 表单请求地址
|
||||
action: "",
|
||||
// 表单字段显示规则
|
||||
columns: [
|
||||
{ key: "key", title: "键名", type: "text", placeholder: "请输入键名", disabled:["update"], tips: "键名唯一,且不能修改" },
|
||||
{ key: "value", title: "键值", type: "json", placeholder: "请输入键值" },
|
||||
{ key: "expired_at", title: "过期时间", type: "date", dateType: "datetime", placeholder: "请选择过期时间", tips: "若不设置过期时间则代表永不过期" },
|
||||
{ key: "comment", title: "备注", type: "textarea", placeholder: "请输入备注" }
|
||||
],
|
||||
// 表单验证规则
|
||||
rules: {
|
||||
key: [{ required: true, message: "键名不能为空", trigger: "blur" }],
|
||||
value: [{ required: true, message: "键值不能为空", trigger: "change" }]
|
||||
},
|
||||
// add 代表添加 update 代表修改
|
||||
formType: "",
|
||||
// 是否显示表单的弹窗
|
||||
show: false
|
||||
}
|
||||
},
|
||||
// 表单相关结束 -----------------------------------------------------------
|
||||
};
|
||||
},
|
||||
// 监听 - 页面每次【加载时】执行(如:前进)
|
||||
onLoad(options = {}) {
|
||||
that = this;
|
||||
vk = that.vk;
|
||||
that.options = options;
|
||||
that.init(options);
|
||||
},
|
||||
// 监听 - 页面【首次渲染完成时】执行。注意如果渲染速度快,会在页面进入动画完成前触发
|
||||
onReady() {},
|
||||
// 监听 - 页面每次【显示时】执行(如:前进和返回) (页面每次出现在屏幕上都触发,包括从下级页面点返回露出当前页面)
|
||||
onShow() {},
|
||||
// 监听 - 页面每次【隐藏时】执行(如:返回)
|
||||
onHide() {},
|
||||
// 函数
|
||||
methods: {
|
||||
// 页面数据初始化函数
|
||||
init(options) {
|
||||
originalForms["form1"] = vk.pubfn.copyObject(that.form1);
|
||||
},
|
||||
// 页面跳转
|
||||
pageTo(path) {
|
||||
vk.navigateTo(path);
|
||||
},
|
||||
// 表单重置
|
||||
resetForm() {
|
||||
vk.pubfn.resetForm(originalForms, that);
|
||||
},
|
||||
// 搜索
|
||||
search(obj) {
|
||||
that.$refs.table1.query(obj);
|
||||
},
|
||||
// 刷新
|
||||
refresh() {
|
||||
that.$refs.table1.refresh();
|
||||
},
|
||||
// 获取当前选中的行的数据
|
||||
getCurrentRow() {
|
||||
return that.$refs.table1.getCurrentRow();
|
||||
},
|
||||
// 监听 - 行的选中高亮事件
|
||||
currentChange(val) {
|
||||
that.table1.selectItem = val;
|
||||
},
|
||||
// 当选择项发生变化时会触发该事件
|
||||
selectionChange(list) {
|
||||
that.table1.multipleSelection = list;
|
||||
},
|
||||
// 显示添加页面
|
||||
addBtn() {
|
||||
that.resetForm();
|
||||
that.form1.props.action = "admin/system_uni/global-data/sys/add";
|
||||
that.form1.props.formType = "add";
|
||||
that.form1.props.title = "添加";
|
||||
that.form1.props.show = true;
|
||||
},
|
||||
// 显示修改页面
|
||||
updateBtn({ item }) {
|
||||
that.form1.props.action = "admin/system_uni/global-data/sys/update";
|
||||
that.form1.props.formType = "update";
|
||||
that.form1.props.title = "编辑";
|
||||
that.form1.props.show = true;
|
||||
that.form1.data = item;
|
||||
},
|
||||
// 删除按钮
|
||||
deleteBtn({ item, deleteFn }) {
|
||||
deleteFn({
|
||||
action: "admin/system_uni/global-data/sys/delete",
|
||||
data: {
|
||||
_id: item._id
|
||||
}
|
||||
});
|
||||
}
|
||||
},
|
||||
watch: {
|
||||
|
||||
},
|
||||
// 过滤器
|
||||
filters: {
|
||||
|
||||
},
|
||||
// 计算属性
|
||||
computed: {
|
||||
|
||||
}
|
||||
};
|
||||
</script>
|
||||
<style lang="scss" scoped>
|
||||
|
||||
</style>
|
||||
@@ -0,0 +1,227 @@
|
||||
<template>
|
||||
<view class="page-body">
|
||||
<!-- 页面内容开始 -->
|
||||
|
||||
<!-- 表格搜索组件开始 -->
|
||||
<vk-data-table-query
|
||||
v-model="queryForm1.formData"
|
||||
:columns="queryForm1.columns"
|
||||
:main-columns="['out_trade_no', 'transaction_id', 'type', 'status', '_add_time']"
|
||||
@search="search"
|
||||
></vk-data-table-query>
|
||||
<!-- 表格搜索组件结束 -->
|
||||
<!-- 表格组件开始 -->
|
||||
<vk-data-table
|
||||
ref="table1"
|
||||
:action="table1.action"
|
||||
:columns="table1.columns"
|
||||
:query-form-param="queryForm1"
|
||||
:right-btns="['detail_auto']"
|
||||
:row-no="false"
|
||||
:pagination="true"
|
||||
@current-change="currentChange"
|
||||
@selection-change="selectionChange"
|
||||
>
|
||||
<template v-slot:button1="{ row }">
|
||||
<view v-if="row.status <= 0">-</view>
|
||||
<el-tag type="success" effect="dark" v-else-if="row.user_order_success">成功</el-tag>
|
||||
<el-button type="danger" size="mini" v-else-if="row.status === 1" @click="afreshNotice(row)">重新推送</el-button>
|
||||
<view v-else-if="row.refund_fee>0">失败,但已退款</view>
|
||||
<view v-else>未知</view>
|
||||
</template>
|
||||
</vk-data-table>
|
||||
<!-- 表格组件结束 -->
|
||||
<!-- 页面内容结束 -->
|
||||
</view>
|
||||
</template>
|
||||
|
||||
<script>
|
||||
var that; // 当前页面对象
|
||||
var vk = uni.vk; // vk实例
|
||||
var originalForms = {}; // 表单初始化数据
|
||||
|
||||
const payTypeData = [
|
||||
{ label: "官方渠道 - 微信 - 小程序", value: "wxpay_mp-weixin", tagType: "success" },
|
||||
{ label: "官方渠道 - 微信 - APP", value: "wxpay_app-plus", tagType: "success" },
|
||||
{ label: "官方渠道 - 微信 - H5", value: "wxpay_h5", tagType: "success" },
|
||||
{ label: "官方渠道 - 微信 - MWEB", value: "wxpay_mweb", tagType: "success" },
|
||||
{ label: "官方渠道 - 微信 - 公众号", value: "wxpay_h5-weixin", tagType: "success" },
|
||||
{ label: "官方渠道 - 支付宝 - 小程序", value: "alipay_mp-alipay", tagType: "primary" },
|
||||
{ label: "官方渠道 - 支付宝 - APP", value: "alipay_app-plus", tagType: "primary" },
|
||||
{ label: "官方渠道 - 支付宝 - H5", value: "alipay_h5", tagType: "primary" },
|
||||
|
||||
{ label: "VksPay - 微信 - 小程序", value: "vkspay_mp-weixin", tagType: "success" },
|
||||
{ label: "VksPay - 微信 - APP", value: "vkspay_app-plus", tagType: "success" },
|
||||
{ label: "VksPay - 微信 - H5", value: "vkspay_h5", tagType: "success" }, // 收银台接口 公众号、H5、MWEB、PC扫码均为H5
|
||||
{ label: "VksPay - 微信 - MWEB", value: "vkspay_mweb", tagType: "success" },
|
||||
{ label: "VksPay - 微信 - 公众号", value: "vkspay_h5-weixin", tagType: "success" },
|
||||
{ label: "VksPay - 支付宝 - 小程序", value: "vkspay_mp-alipay", tagType: "primary" },
|
||||
{ label: "VksPay - 支付宝 - APP", value: "vkspay_app-plus", tagType: "primary" },
|
||||
{ label: "VksPay - 支付宝 - H5", value: "vkspay_h5", tagType: "primary" },
|
||||
|
||||
];
|
||||
const orderTypeData = [
|
||||
{ label: "商品订单", value: "goods" },
|
||||
{ label: "充值订单", value: "recharge" },
|
||||
{ label: "VIP购买订单", value: "vip" },
|
||||
{ label: "其他订单", value: "other" }
|
||||
];
|
||||
|
||||
const statusData = [
|
||||
{ label: "已关闭", value: -1, tagType: "info" },
|
||||
{ label: "未支付", value: 0, tagType: "info" },
|
||||
{ label: "已支付", value: 1, tagType: "success" },
|
||||
{ label: "已部分退款", value: 2, tagType: "warning" },
|
||||
{ label: "已全额退款", value: 3, tagType: "danger" },
|
||||
];
|
||||
|
||||
export default {
|
||||
data() {
|
||||
// 页面数据变量
|
||||
return {
|
||||
// 页面是否请求中或加载中
|
||||
loading: false,
|
||||
// init请求返回的数据
|
||||
data: {},
|
||||
// 表格相关开始 -----------------------------------------------------------
|
||||
table1: {
|
||||
// 表格数据请求地址
|
||||
action: "admin/system_uni/pay-orders/sys/getList",
|
||||
// 表格字段显示规则
|
||||
columns: [
|
||||
{ key: "button1", title: "回调通知状态", type: "text", width: 120, fixed:"right" },
|
||||
{ key: "out_trade_no", title: "商户订单号", type: "text", width: 200 },
|
||||
{ key: "type", title: "订单类型", type: "select", width: 100,
|
||||
data: orderTypeData
|
||||
},
|
||||
{
|
||||
key: "pay_type", title: "支付类型", type: "tag", width: 180,
|
||||
data: payTypeData
|
||||
},
|
||||
{ key: "status", title: "订单状态", type: "tag", width: 110,
|
||||
data: statusData
|
||||
},
|
||||
{ key: "create_date", title: "创建时间", type: "time", width: 160 },
|
||||
{ key: "pay_date", title: "支付时间", type: "time", width: 160 },
|
||||
{ key: "total_fee", title: "总金额", type: "money", width: 110 },
|
||||
{ key: "refund_fee", title: "总退款金额", type: "money", width: 110, defaultValue:"-" },
|
||||
{ key: "refund_num", title: "退款次数", type: "number", width: 80, defaultValue:"-" },
|
||||
{ key: "transaction_id", title: "支付平台订单号", type: "text", width: 260, defaultValue:"-" },
|
||||
{ key: "openid", title: "用户openid", type: "text", width: 280, show: ["detail"] },
|
||||
{
|
||||
key: "refund_list", title: "退款详情", type: "table", width: 360, show: ["detail"],
|
||||
columns:[
|
||||
{ key: "out_refund_no", title: "退款单号", type: "text", minWidth: 200 },
|
||||
{ key: "refund_date", title: "退款时间", type: "time", width: 180 },
|
||||
{ key: "refund_fee", title: "退款金额", type: "money", width: 140 },
|
||||
{ key: "refund_desc", title: "退款备注", type: "text", minWidth: 180 },
|
||||
]
|
||||
},
|
||||
{ key: "original_data", title: "原始数据", type: "json", width: 300, show: ["detail"] },
|
||||
//{ key: "wxpay_info", title: "微信支付特有数据", type: "json", width: 360, show: ["detail"] },
|
||||
//{ key: "alipay_info", title: "支付宝支付特有数据", type: "json", width: 300, show: ["detail"] },
|
||||
],
|
||||
// 多选框选中的值
|
||||
multipleSelection: [],
|
||||
// 当前高亮的记录
|
||||
selectItem: ""
|
||||
},
|
||||
// 表格相关结束 -----------------------------------------------------------
|
||||
// 表单相关开始 -----------------------------------------------------------
|
||||
// 查询表单请求数据
|
||||
queryForm1: {
|
||||
// 查询表单数据源,可在此设置默认值
|
||||
formData: {},
|
||||
// 查询表单的字段规则 fieldName:指定数据库字段名,不填默认等于key
|
||||
columns: [
|
||||
{ key: "out_trade_no", title: "商户订单号", type: "text", width:150, mode: "%%", },
|
||||
{ key: "transaction_id", title: "支付平台订单号", type: "text", width:150, mode: "%%", },
|
||||
{
|
||||
key: "type", title: "订单类型", type: "select", width:150, mode: "=",
|
||||
data: orderTypeData
|
||||
},
|
||||
{ key: "status", title: "订单状态", type: "select", width: 150, mode: "=",
|
||||
data: statusData
|
||||
},
|
||||
{ key: "_add_time", title: "添加时间", type: "datetimerange", width:340, mode: "[]" },
|
||||
{
|
||||
key: "pay_type", title: "支付类型", type: "select", mode: "=",
|
||||
data: payTypeData
|
||||
},
|
||||
{ key: "total_fee_min", title: "金额范围", type: "money", mode: ">=", fieldName:"total_fee" },
|
||||
{ key: "total_fee_max", title: "-", type: "money", mode: "<=", fieldName:"total_fee" }
|
||||
]
|
||||
}
|
||||
// 表单相关结束 -----------------------------------------------------------
|
||||
};
|
||||
},
|
||||
// 监听 - 页面每次【加载时】执行(如:前进)
|
||||
onLoad(options = {}) {
|
||||
that = this;
|
||||
vk = that.vk;
|
||||
that.options = options;
|
||||
that.init(options);
|
||||
},
|
||||
// 监听 - 页面【首次渲染完成时】执行。注意如果渲染速度快,会在页面进入动画完成前触发
|
||||
onReady() {},
|
||||
// 监听 - 页面每次【显示时】执行(如:前进和返回) (页面每次出现在屏幕上都触发,包括从下级页面点返回露出当前页面)
|
||||
onShow() {},
|
||||
// 监听 - 页面每次【隐藏时】执行(如:返回)
|
||||
onHide() {},
|
||||
// 函数
|
||||
methods: {
|
||||
// 页面数据初始化函数
|
||||
init(options) {
|
||||
originalForms["form1"] = vk.pubfn.copyObject(that.form1);
|
||||
},
|
||||
// 页面跳转
|
||||
pageTo(path) {
|
||||
vk.navigateTo(path);
|
||||
},
|
||||
// 表单重置
|
||||
resetForm() {
|
||||
vk.pubfn.resetForm(originalForms, that);
|
||||
},
|
||||
// 搜索
|
||||
search(obj) {
|
||||
that.$refs.table1.query(obj);
|
||||
},
|
||||
// 刷新
|
||||
refresh() {
|
||||
that.$refs.table1.refresh();
|
||||
},
|
||||
// 获取当前选中的行的数据
|
||||
getCurrentRow() {
|
||||
return that.$refs.table1.getCurrentRow();
|
||||
},
|
||||
// 监听 - 行的选中高亮事件
|
||||
currentChange(val) {
|
||||
that.table1.selectItem = val;
|
||||
},
|
||||
// 当选择项发生变化时会触发该事件
|
||||
selectionChange(list) {
|
||||
that.table1.multipleSelection = list;
|
||||
},
|
||||
// 重新推送
|
||||
afreshNotice(row){
|
||||
vk.callFunction({
|
||||
url: 'admin/system_uni/pay-orders/sys/afreshNotice',
|
||||
title: '请求中...',
|
||||
data: {
|
||||
_id: row._id
|
||||
},
|
||||
success: (data) => {
|
||||
// 刷新数据
|
||||
that.refresh();
|
||||
}
|
||||
});
|
||||
}
|
||||
},
|
||||
watch: {},
|
||||
// 计算属性
|
||||
computed: {}
|
||||
};
|
||||
</script>
|
||||
<style lang="scss" scoped>
|
||||
|
||||
</style>
|
||||
Reference in New Issue
Block a user