dialogAppFile.js 6.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242
  1. define(function (require) {
  2. return function (context) {
  3. var $grid1, $form, $dlg;
  4. // 输入搜索文本后点击回车按钮查询列表
  5. function enterQueryGrid1(e) {
  6. if (e.keyCode === 13) {
  7. //如果按下回车键,就发出确认
  8. var tmp = $(this).val();
  9. $form.formSet({queryProperties: tmp});
  10. queryGrid1();
  11. }
  12. }
  13. function queryGrid1() {
  14. var obj = $form.formGet();
  15. obj.verId = context.verId;
  16. obj.appId = context.appId;
  17. obj.guid = '700cbc18ab1049e19b88d8fd29410bb6';
  18. $grid1.reload({
  19. url: api('/sys/sysAppFile/query'),// /term/hd/verCheck /sys/sysAppFile/query
  20. mtype: 'POST',
  21. queryParams: obj
  22. }, true);
  23. }
  24. function saveFile(file) {
  25. $.yvan.ajax({
  26. url: api('/sys/sysAppFile/insert'),
  27. data: {
  28. verId: context.verId,
  29. appId: context.appId,
  30. fileName: file.fileName,
  31. ext: file.ext,
  32. filePath: file.filePath,
  33. md5: file.md5,
  34. size: file.size
  35. },
  36. method: 'post',
  37. success: function (data) {
  38. if (close) {
  39. $.yvan.msg('操作成功');
  40. }
  41. if ($.type(context.confirm) === 'function') {
  42. context.confirm();
  43. }
  44. }
  45. });
  46. }
  47. //编辑
  48. function editRow1(obj) {
  49. var row = $grid1.rowData();
  50. if (!row) {
  51. $.yvan.msg('选择一行数据');
  52. return;
  53. }
  54. var dlg = require('/app/sys/app/dialogAppFileInfo.js')({
  55. isEdit: true,
  56. fileId: row.fileId,
  57. verId: row.verId,
  58. appId: row.appId,
  59. confirm: function () {
  60. $grid1.reload();
  61. }
  62. });
  63. $.yvan.showDialog(obj, dlg);
  64. }
  65. //删除
  66. function deleteRow1() {
  67. var row = $grid1.rowData();
  68. if (!row) {
  69. $.yvan.msg('请先选择一行数据');
  70. return;
  71. }
  72. $.yvan.confirm('确定删除 [' + row.fileName + "] ?", {
  73. yes: function (index) {
  74. $.yvan.ajax({
  75. url: api('/sys/sysAppFile/delete'),
  76. data: {
  77. fileId: row.fileId,
  78. },
  79. method: 'post',
  80. success: function (data) {
  81. $.yvan.msg(data.msg);
  82. $grid1.reload();
  83. }
  84. });
  85. }
  86. });
  87. }
  88. // 搜索按钮
  89. var queryToolbarTitle = '应用程序管理';// 自行替换此参数
  90. var queryToolbar = {
  91. xtype: 'toolbar', title: queryToolbarTitle, items: [
  92. {
  93. text: '查询', iconCls: 'fa fa-search', onClick: function () {
  94. queryGrid1();
  95. }
  96. }, {
  97. text: '重置', iconCls: 'fa fa-refresh', onClick: function () {
  98. $form.formClear();
  99. queryGrid1();
  100. }
  101. }, {
  102. text: '关闭', iconCls: 'fa fa-times-circle', onClick: function () {
  103. $dlg.window('close');
  104. }
  105. }
  106. ]
  107. };
  108. // 搜索条件
  109. var queryForm = {
  110. onRender: function () {
  111. $form = $(this);
  112. },
  113. xtype: 'form',
  114. items: [[
  115. {
  116. xtype: 'textbox',
  117. label: '检索条件',
  118. name: 'queryProperties',
  119. prompt: '文件名称/文件路径/文件版本/MD5',
  120. labelWidth: 'auto',
  121. events: {keydown: enterQueryGrid1}
  122. }
  123. ]]
  124. };
  125. // 列表1增删改查按钮
  126. var gridToolbarTitle1 = '程序文件列表';// 自行替换此参数
  127. var gridToolbar1 = {
  128. xtype: 'toolbar', title: gridToolbarTitle1, items: [
  129. {
  130. name: 'file',
  131. text: '文件上传',
  132. iconCls: 'fa fa-cloud-upload',
  133. // accept: 'image/jpeg,image/png',
  134. accept: {
  135. title: 'file',
  136. // extensions: 'jpg,mp4,pdf,png,ppt,doc,xls,docx,xlsx,pptx',
  137. // mimeTypes: 'image/jpeg,video/mp4,application/pdf,image/png,application/vnd.ms-powerpoint,application/msword,application/vnd.ms-excel,application/vnd.openxmlformats-officedocument.wordprocessingml.document,application/vnd.openxmlformats-officedocument.spreadsheetml.sheet,application/vnd.openxmlformats-officedocument.presentationml.presentation'
  138. extensions: '*',
  139. mimeTypes: '*/*'
  140. },
  141. onClick: function () {
  142. var _data = $form.formGet();
  143. //onsole.log(_data.appFileType);
  144. if (_data.appFileType == 0) {
  145. $.yvan.msg('请先选择文件类型');
  146. return;
  147. }
  148. $.yvan.showUploadWindow($(this), {
  149. url: fileUrl('/file/appUpload'), //上传路径
  150. param: JSON.stringify({busiId: context.verId, busiType: _data.fileType}),
  151. uploadSuccess: function (file) {
  152. //已弃用
  153. },
  154. success: function (data) {
  155. //上传一个文件,成功之后的回调.
  156. //如果有多个文件会回调多次
  157. saveFile(data.data);
  158. }
  159. });
  160. }
  161. }, {
  162. text: '编辑', iconCls: 'fa fa-pencil-square-o', onClick: function () {
  163. editRow1(this);
  164. }
  165. }, {
  166. text: '删除', iconCls: 'fa fa-trash-o fa-lg', onClick: function () {
  167. deleteRow1();
  168. }
  169. },
  170. ]
  171. };
  172. //界面
  173. return {
  174. xtype: 'dialog',
  175. dialogId: 'dialog3',
  176. title: '版本文件信息',
  177. width: '100%',
  178. height: '100%',
  179. onOpen: function () {
  180. $dlg = $(this);
  181. debugger
  182. $form.formSet({
  183. "verId": context.verId,
  184. "appId": context.appId,
  185. "fileType": 11,
  186. "appFileType": 1
  187. });
  188. },
  189. north: {
  190. height: 90,
  191. split: true,
  192. border: false,
  193. items: [
  194. queryToolbar,
  195. queryForm
  196. ]
  197. },
  198. center: {
  199. width: "100%",
  200. border: false,
  201. split: true,
  202. items: {
  203. onRender: function () {
  204. $grid1 = $(this);
  205. queryGrid1();
  206. },
  207. xtype: 'grid',
  208. toolbar: gridToolbar1,
  209. pagination: false,
  210. autoSizeColumns: true,
  211. //idField: 'fileId',
  212. title: '应用程序列表',
  213. columns: [[
  214. {field: 'fileId', hidden: true},
  215. {field: 'verId', hidden: true},
  216. {field: 'appId', hidden: true},
  217. {field: 'filePath', title: '文件相对路径'},
  218. {field: 'fileName', title: '文件名称'},
  219. {field: 'fileMd5', title: '文件MD5'},
  220. {
  221. field: 'fileSize', width: 100, title: '大小(KB)', align: 'right', formatter: function (value, row, index) {
  222. return Math.round(row.rowData.fileSize / 1024);
  223. }
  224. },
  225. {field: 'fileUrl', title: '文件下载地址'},
  226. {field: 'timeCreate', title: '新增时间', formatter: 'ts'}
  227. ]]
  228. }
  229. }
  230. };
  231. };
  232. });