3.2.3 子组件(我的媒资查询)
1、定义ischoose变量,接收父组件传入的ischoose
[AppleScript] 纯文本查看 复制代码
?
1 2 | export default { props : ['ischoose'] , data ( ) { |
2、父组件传的ischoose变量为 true时表示当前是选择媒资文件业务,需要控制页面元素是否显示
1)ischoose=true,选择按钮显示
[AppleScript] 纯文本查看 复制代码
?
1 2 3 4 5 | < el‐table‐ column label = "选择" width = "80" v‐ if = "ischoose == true" > < template slot‐scope = "scope" > < el‐ button size = "small" type = "primary" plain @click = "choose(scope.row)" > 选择 < / el‐ button > < / template > < / el‐table‐ column > |
2)ischoose=false,视频处理按钮显示
[AppleScript] 纯文本查看 复制代码
?
1 2 3 4 5 6 | < el‐table‐ column label = "开始处理" width = "100" v‐ if = "ischoose != true" > < template slot‐scope = "scope" > < el‐ button size = "small" type = "primary" plain @click = "process(scope.row.fileId)" > 开始处理 < / el‐ button > < / template > < / el‐table‐ column > |
3、选择媒资文件方法
用户点击“选择”按钮将向父组件传递媒资文件信息
[AppleScript] 纯文本查看 复制代码
?
01 02 03 04 05 06 07 08 09 10 | choose ( mediaFile ) { if ( mediaFile.processStatus ! = ' 303002 ' & & mediaFile.processStatus ! = ' 303004 ' ) { this.$ message . error ( '该文件未处理,不允许选择' ) ; return ; } if ( !mediaFile.fileUrl ) { this.$ message . error ( '该文件的访问 url 为空,不允许选择' ) ; return ; } / / 调用父组件的choosemedia方法 this.$emit ( 'choosemedia' , mediaFile.fileId , mediaFile.fileOriginalName ) ; } |