brand.js 8.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258
  1. $(function () {
  2. var types = {
  3. 0:'其他',
  4. 1:'生活',
  5. 2:'文化',
  6. 3:'工业',
  7. }
  8. $("#jqGrid").Grid({
  9. url: '../brand/list',
  10. rownumWidth:60,
  11. colModel: [{
  12. label: 'id', name: 'id', index: 'id', key: true, hidden: true
  13. }, {
  14. label: '店铺名称', name: 'name', index: 'name', width: 80
  15. },
  16. {
  17. label: '类型', name: 'type', index: 'type', width: 80,formatter: function (value) {
  18. return types[value] || '-'
  19. }
  20. },
  21. {
  22. label: '场景地址', name: 'sceneUrl', index: 'scene_url', width: 140
  23. },
  24. {
  25. label: '店铺封面',align:'center', name: 'listPicUrl', index: 'list_pic_url', width: 120, formatter: function (value) {
  26. return transImg(value,100,'auto');
  27. }
  28. },
  29. {
  30. label: '分享图', align:'center', name: 'newPicUrl', index: 'new_pic_url', width: 120, formatter: function (value) {
  31. return transImg(value,100,'auto');
  32. }
  33. },
  34. // {
  35. // label: '描述', name: 'simpleDesc', index: 'simple_desc', width: 80
  36. // },
  37. // {
  38. // label: '缩略图', align:'center',name: 'picUrl', index: 'pic_url', width: 120, formatter: function (value) {
  39. // return transImg(value,100,'auto');
  40. // }
  41. // },
  42. {
  43. label: '排序', name: 'sortOrder', index: 'sort_order', width: 80
  44. },
  45. {
  46. label: '显示', name: 'isShow', index: 'is_show', width: 80, formatter: function (value) {
  47. return transIsNot(value)
  48. }
  49. },
  50. // {
  51. // label: '展示价格', name: 'floorPrice', index: 'floor_Price', width: 80
  52. // },
  53. // {
  54. // label: '封面图',align:'center', name: 'appListPicUrl', index: 'app_list_pic_url', width: 120, formatter: function (value) {
  55. // return transImg(value,100,'auto');
  56. // }
  57. // },
  58. // {
  59. // label: '新店铺', name: 'isNew', index: 'is_new', width: 80, formatter: function (value) {
  60. // return transIsNot(value)
  61. // }
  62. // },
  63. // {
  64. // label: '新店铺排序', name: 'newSortOrder', index: 'new_sort_order', width: 80
  65. // }
  66. ]
  67. });
  68. });
  69. const validateSceneUrlCheck = function (rule, value, callback){
  70. console.log(value)
  71. var link1 ='https://test.4dkankan.com/eShopMobile.html?m='
  72. var link2 ='https://www.4dkankan.com/eShopMobile.html?m='
  73. if (value === ''||!value) {
  74. callback(new Error('场景地址不能为空'));
  75. } else if(!~value.indexOf(link1)&&!~value.indexOf(link2)){
  76. callback(new Error('场景地址需为'+link2+'或'+link1));
  77. } else {
  78. callback();
  79. }
  80. };
  81. var vm = new Vue({
  82. el: '#rrapp',
  83. data: {
  84. showList: true,
  85. title: null,
  86. brand: {listPicUrl: '',type:0, picUrl: '', appListPicUrl: '', newPicUrl: '', isShow: 1, isNew: 0},
  87. ruleValidate: {
  88. name: [
  89. {required: true, message: '店铺名称不能为空', trigger: 'blur'}
  90. ],
  91. listPicUrl: [
  92. {required: true, message: '图片不能为空', trigger: 'blur'}
  93. ],
  94. simpleDesc: [
  95. {required: true, message: '描述不能为空', trigger: 'blur'}
  96. ],
  97. sceneUrl: [
  98. {required: true, validator: validateSceneUrlCheck, trigger: 'blur'}
  99. ],
  100. picUrl: [
  101. {required: true, message: '缩略图不能为空', trigger: 'blur'}
  102. ]
  103. },
  104. q: {
  105. name: '',
  106. type:''
  107. },
  108. typeList:[
  109. {
  110. id:0,
  111. name:'其他'
  112. },
  113. {
  114. id:1,
  115. name:'生活'
  116. },
  117. {
  118. id:2,
  119. name:'文化'
  120. },
  121. {
  122. id:3,
  123. name:'工业'
  124. },
  125. ]
  126. },
  127. methods: {
  128. query: function () {
  129. vm.reload();
  130. },
  131. add: function () {
  132. vm.showList = false;
  133. vm.title = "新增";
  134. vm.brand = {listPicUrl: '',type:0, picUrl: '', appListPicUrl: '', newPicUrl: '', isShow: 1, isNew: 0};
  135. },
  136. update: function (event) {
  137. var id = getSelectedRow("#jqGrid");
  138. if (id == null) {
  139. return;
  140. }
  141. vm.showList = false;
  142. vm.title = "修改";
  143. vm.getInfo(id)
  144. },
  145. saveOrUpdate: function (event) {
  146. var url = vm.brand.id == null ? "../brand/save" : "../brand/update";
  147. Ajax.request({
  148. type: "POST",
  149. url: url,
  150. contentType: "application/json",
  151. params: JSON.stringify(vm.brand),
  152. successCallback: function () {
  153. alert('操作成功', function (index) {
  154. vm.reload();
  155. });
  156. }
  157. });
  158. },
  159. del: function (event) {
  160. var ids = getSelectedRows("#jqGrid");
  161. if (ids == null) {
  162. return;
  163. }
  164. confirm('确定要删除选中的记录?', function () {
  165. Ajax.request({
  166. type: "POST",
  167. url: "../brand/delete",
  168. contentType: "application/json",
  169. params: JSON.stringify(ids),
  170. successCallback: function () {
  171. alert('操作成功', function (index) {
  172. vm.reload();
  173. });
  174. }
  175. });
  176. });
  177. },
  178. getInfo: function (id) {
  179. Ajax.request({
  180. url: "../brand/info/" + id,
  181. async: true,
  182. successCallback: function (r) {
  183. vm.brand = r.brand;
  184. }
  185. });
  186. },
  187. reload: function (event) {
  188. vm.showList = true;
  189. var page = $("#jqGrid").jqGrid('getGridParam', 'page');
  190. $("#jqGrid").jqGrid('setGridParam', {
  191. postData: {'name': vm.q.name,'type': vm.q.type},
  192. page: page
  193. }).trigger("reloadGrid");
  194. vm.handleReset('formValidate');
  195. },
  196. handleSuccessListPicUrl: function (res, file) {
  197. vm.brand.listPicUrl = file.response.url;
  198. vm.brand.appListPicUrl = file.response.url;
  199. },
  200. handleSuccessPicUrl: function (res, file) {
  201. vm.brand.picUrl = file.response.url;
  202. },
  203. handleSuccessAppListPicUrl: function (res, file) {
  204. vm.brand.appListPicUrl = file.response.url;
  205. },
  206. handleSuccessNewPicUrl: function (res, file) {
  207. vm.brand.newPicUrl = file.response.url;
  208. },
  209. handleFormatError: function (file) {
  210. this.$Notice.warning({
  211. title: '文件格式不正确',
  212. desc: '文件 ' + file.name + ' 格式不正确,请上传 jpg 或 png 格式的图片。'
  213. });
  214. },
  215. handleMaxSize: function (file) {
  216. this.$Notice.warning({
  217. title: '超出文件大小限制',
  218. desc: '文件 ' + file.name + ' 太大,不能超过 2M。'
  219. });
  220. },
  221. eyeImageListPicUrl: function () {
  222. var url = vm.brand.listPicUrl;
  223. eyeImage(url);
  224. },
  225. eyeImagePicUrl: function () {
  226. var url = vm.brand.picUrl;
  227. eyeImage(url);
  228. },
  229. eyeImageAppListPicUrl: function () {
  230. var url = vm.brand.appListPicUrl;
  231. eyeImage(url);
  232. },
  233. eyeImageNewPicUrl: function () {
  234. var url = vm.brand.newPicUrl;
  235. eyeImage(url);
  236. },
  237. handleSubmit: function (name) {
  238. handleSubmitValidate(this, name, function () {
  239. vm.saveOrUpdate()
  240. });
  241. },
  242. handleReset: function (name) {
  243. handleResetForm(this, name);
  244. }
  245. }
  246. });