video.Index.js
6.17 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
webpackJsonp([164],[
/* 0 */
/***/ function(module, exports, __webpack_require__) {
/**
* Created by zw on 2016/11/3.
* 视频管理
*/
var $ = __webpack_require__(1);
var common = __webpack_require__(2);
/**
* 列表显示数据
* @type {common.grid}
*/
var g = new common.grid({
el: '#content-list',
hash: false,
complete: function () {
$('#content-list').poptrox({
usePopupCaption: true
});
},
parms: function () {
return {
skn: common.util.__input('content-filter1'),
videoName: common.util.__input('content-filter2')
};
},
//列表显示
columns: [
{display: "视频名称", name: "videoName"},
{display: "关联SKN", name: "skn"},
{
display: '视频',
name: 'url',
render: function (item) {
if (item.url) {
return '<img height="140" width="80" src="' + item.url +'?vframe/jpg/offset/0'+ '">';
} else {
return '';
}
}
},
{display: "视频大小", name: "videoSize",render:function(item) { return item.videoSize+"M"}},
{display: "备注", name: "note"},
{
display: "操作", name: "", render: function (item) {
var arr = [];
arr.push('<a class="btn btn-xs btn-info update" data-index="' + item.__index + '">编辑</a>');
arr.push('<a class="btn btn-xs btn-danger delete" data-index="' + item.__index + '">删除</a>');
return arr.join('');
}
}
]
});
g.init("/video/queryVideosList");
//
var Bll = {
newVideo: {},
rendBoList: function (obj) {
$("#imgTag").attr("src",obj.url+"?vframe/jpg/offset/0");
$("#imgTag").show();
$("#imgATag").hide();
},
toast: function (url, item, datacall) {
$("#imgTag").hide();
if(item.__state == "edit" ){
Bll.newVideo.url=item.url;
Bll.newVideo.fileName=item.fileName;
Bll.newVideo.videoSize=item.fileSize;
Bll.newVideo.id=item.id;
item.url = item.url+"?vframe/jpg/offset/0"
}
var a = new common.dialog({
title: "视频",
width: '50%',
content: common.util.__template2($("#template").html(), item),
button: [
{
value: "提交", callback: function () {
if($.trim($("#videoName").val()) == ""){
common.util.__tip("视频名称不能为空", 'warning');
return false;
}
var data = {};
Bll.newVideo.videoName = $.trim($("#videoName").val());
Bll.newVideo.skn = $.trim($("#skn").val());
Bll.newVideo.note = $.trim($("#note").val());
console.log("提交的参数:"+JSON.stringify(Bll.newVideo));
common.util.__ajax({
url: url,
data: Bll.newVideo
}, function (res) {
if (res.code == '200') {
/*common.util.__tip("上传成功", 'success');*/
g.reload();
a.close();
}
});
return false;
}, css: "btn-primary"
},
{
"value": "取消",
css: "btn-info"
}
]
});
//Bll.rendBoList(Bll.pictureBoList);
// var loadModal = null;
common.edit.ajaxfileupload(".picfile", {
params: {
__type: "import-video",
bucket: "goodsvideo"
},
valid_extensions: ['mp4'],
// onStart: function(params) {
// loadModal = common.dialog.load();
// },
onComplete: function (response) {
console.log("批量接口返回数据",response);
if (response.status && response.code == 200) {
Bll.newVideo.url=response.data.url;
Bll.newVideo.fileName=response.data.fileName;
Bll.newVideo.videoSize=response.data.fileSize;
// if (loadModal) {
// loadModal.close();
// }
Bll.rendBoList(Bll.newVideo);
}
else {
common.util.__tip(response.message, 'warning');
}
}
});
}
};
//添加
$('#addVideo').on('click', function () {
var item = {
"__state":"add",
"videoName": "",
'skn': "",
'url': "",
'note': ""
};
Bll.toast('/video/editVideo', item, function(){
return {
productPhotoAddStrList: ""
}
});
});
//查询按钮--点击事件
$(document).on('click', '#filter-btn', function () {
g.reload(1);
});
//删除--点击事件
$(document).on('click', '.delete', function () {
var item = g.rows[$(this).data("index")];
common.dialog.confirm("警告",
"确认删除?",
function () {
common.util.__ajax({
url: '/video/delVideo',
data: {
id: item.id
}
}, function () {
g.reload(1);
});
});
});
//修改--点击事件
$(document).on('click', '.update', function () {
var item = g.rows[$(this).data("index")];
item.__state="edit";
if(item.url.indexOf("?") > 0){
item.url = item.url.substring(0,item.url.indexOf("?"));
}
console.log("修改"+ item.url);
Bll.toast('/video/editVideo', item, "修改视频");
});
/***/ }
]);