upload.js 6.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166
  1. define(['jquery', 'bootstrap', 'backend', 'table', 'form', 'plupload'], function ($, undefined, Backend, Table, Form, Plupload) {
  2. var Controller = {
  3. index: function () {
  4. var uploadIndex = new Vue({
  5. el: "#uploadIndex",
  6. data() {
  7. return {}
  8. },
  9. methods: {
  10. selectPic(type) {
  11. Fast.api.open('shopro/upload/select?type=' + type, '选择', {
  12. callback(data) {
  13. }
  14. })
  15. },
  16. }
  17. })
  18. },
  19. recyclebin: function () {
  20. // 初始化表格参数配置
  21. Table.api.init({
  22. extend: {
  23. 'dragsort_url': ''
  24. }
  25. });
  26. var table = $("#table");
  27. // 初始化表格
  28. table.bootstrapTable({
  29. url: 'shopro/upload/recyclebin' + location.search,
  30. pk: 'id',
  31. sortName: 'id',
  32. columns: [
  33. [{
  34. checkbox: true
  35. },
  36. {
  37. field: 'id',
  38. title: __('Id')
  39. },
  40. {
  41. field: 'name',
  42. title: __('Name'),
  43. align: 'left'
  44. },
  45. {
  46. field: 'deletetime',
  47. title: __('Deletetime'),
  48. operate: 'RANGE',
  49. addclass: 'datetimerange',
  50. formatter: Table.api.formatter.datetime
  51. },
  52. {
  53. field: 'operate',
  54. width: '130px',
  55. title: __('Operate'),
  56. table: table,
  57. events: Table.api.events.operate,
  58. buttons: [{
  59. name: 'Restore',
  60. text: __('Restore'),
  61. classname: 'btn btn-xs btn-info btn-ajax btn-restoreit',
  62. icon: 'fa fa-rotate-left',
  63. url: 'shopro/upload/restore',
  64. refresh: true
  65. },
  66. {
  67. name: 'Destroy',
  68. text: __('Destroy'),
  69. classname: 'btn btn-xs btn-danger btn-ajax btn-destroyit',
  70. icon: 'fa fa-times',
  71. url: 'shopro/upload/destroy',
  72. refresh: true
  73. }
  74. ],
  75. formatter: Table.api.formatter.operate
  76. }
  77. ]
  78. ]
  79. });
  80. // 为表格绑定事件
  81. Table.api.bindevent(table);
  82. },
  83. select: function () {
  84. var uploadSelect = new Vue({
  85. el: "#uploadSelect",
  86. data() {
  87. return {
  88. searchKey: '',
  89. type: window.location.search.replace('?', '').split('&')[0].split('=')[1] ? window.location.search.replace('?', '').split('&')[0].split('=')[1] : 'pic',
  90. datalist: [{
  91. url: "/uploads/20200720/dc6d42eaaa0ca252c6d610b5fdea48d9.png",
  92. },{
  93. url: "/uploads/20200720/dc6d42eaaa0ca252c6d610b5fdea48d9.png",
  94. },{
  95. url: "/uploads/20200720/dc6d42eaaa0ca252c6d610b5fdea48d9.png",
  96. },{
  97. url: "/uploads/20200720/dc6d42eaaa0ca252c6d610b5fdea48d9.png",
  98. },{
  99. url: "/uploads/20200720/dc6d42eaaa0ca252c6d610b5fdea48d9.png",
  100. },{
  101. url: "/uploads/20200720/dc6d42eaaa0ca252c6d610b5fdea48d9.png",
  102. }],
  103. currentPage: 1,
  104. totalPage: 700
  105. }
  106. },
  107. created() {
  108. this.getdatalist()
  109. },
  110. methods: {
  111. getdatalist() {
  112. // Fast.api.ajax({
  113. // url: '',
  114. // data: {
  115. // }
  116. // }, function (ret, res) {
  117. // })
  118. this.datalist.forEach(e => {
  119. e.selected = false;
  120. });
  121. },
  122. selectfun(index) {
  123. this.datalist[index].selected = !this.datalist[index].selected;
  124. this.$forceUpdate()
  125. },
  126. submitfun(url) {
  127. let arrsrc = []
  128. this.datalist.forEach(e => {
  129. if (e.selected) {
  130. arrsrc.push(Fast.api.cdnurl(e.url))
  131. }
  132. });
  133. let strlist = arrsrc.join(',')
  134. Fast.api.close({
  135. selecturl: strlist
  136. })
  137. },
  138. handleSizeChange(val) {
  139. },
  140. handleCurrentChange(val) {
  141. }
  142. },
  143. })
  144. Controller.api.bindevent();
  145. },
  146. add: function () {
  147. Controller.api.bindevent();
  148. },
  149. edit: function () {
  150. Controller.api.bindevent();
  151. },
  152. api: {
  153. bindevent: function () {
  154. Form.api.bindevent($("form[role=form]"));
  155. }
  156. }
  157. };
  158. return Controller;
  159. });