1107
This commit is contained in:
@@ -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>
|
||||
Reference in New Issue
Block a user