qualifications.js 8.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217
  1. var addlogistics = new Vue({
  2. el:'#qualifications',
  3. data:{
  4. open:false,
  5. pageType:'',
  6. shopOrderId:0,
  7. logisticsBatchId:0,
  8. selectGoods:false,
  9. productActions:[],
  10. qualificationsList:[
  11. {
  12. productName:'请选择商品',
  13. recordId:'',
  14. sn:'',
  15. fileList:[],
  16. imageList:[]
  17. }
  18. ]
  19. },
  20. methods:{
  21. GetSupplierQualificationData:function(logisticsBatchId){//编辑回显商品资质信息
  22. var _this = this;
  23. SupplierApi.GetSupplierQualificationData({logisticsBatchId:logisticsBatchId},function(response){
  24. if(response.code == 0 ){
  25. var data = response.data;
  26. if(data && data.length > 0) {
  27. _this.qualificationsList = data;
  28. _this.isEmpty = false
  29. }else{
  30. _this.isEmpty = true
  31. }
  32. }else{
  33. CAIMEI.Alert(response.msg, '确定', false);
  34. }
  35. })
  36. },
  37. GetSupplierLogisticsRecord:function(logisticsBatchId){//添加商品资质初始化查询商品信息
  38. var _this = this;
  39. SupplierApi.GetSupplierLogisticsRecord({ logisticsBatchId : logisticsBatchId },function(response){
  40. if(response.code == 0 ){
  41. var data = response.data;
  42. data.forEach(function(el,index){
  43. var obj = {
  44. id : el.id,
  45. productName : el.productName
  46. };
  47. _this.productActions.push(obj)
  48. });
  49. }else{
  50. CAIMEI.Alert(response.msg, '确定', false);
  51. }
  52. })
  53. },
  54. editButtonConfim:function(){//确定添加商品资质信息
  55. var _this = this;
  56. var params = [];
  57. var isRecordId = false;
  58. var isSnCode = false;
  59. var isFileList = false;
  60. var isImageList = false;
  61. _this.qualificationsList.forEach(function(el){
  62. if( el.recordId == '' ){ isRecordId = true }
  63. if( el.sn == '' ){ isSnCode = true }
  64. if( el.fileList == '' ){ isFileList = true }
  65. if( el.imageList == '' ){ isImageList = true }
  66. var obj = {
  67. recordId : el.recordId,
  68. sn : el.sn,
  69. files : el.fileList,
  70. images : el.imageList
  71. };
  72. params.push(obj)
  73. });
  74. if(isRecordId){
  75. CAIMEI.dialog('请选择商品');
  76. return
  77. }
  78. if(isSnCode){
  79. CAIMEI.dialog('请输入商品SN码');
  80. return
  81. }
  82. if(isFileList && isImageList){
  83. CAIMEI.dialog('请上传商品资质文件');
  84. return
  85. }
  86. console.log('params========>',params);
  87. SupplierApi.GetSupplierQualificationUpdata({ params:JSON.stringify(params) },function(response){
  88. if(response.code == 0 ){
  89. CAIMEI.dialog('保存资质成功');
  90. setTimeout(function(){
  91. window.location.href = '/supplier/order/delivery_record.html?shopOrderID='+_this.shopOrderId;
  92. },2000);
  93. }else{
  94. CAIMEI.Alert(response.msg, '确定', false);
  95. }
  96. })
  97. },
  98. hanldSnCodeChecked: function(e){//校验SN码格式错误
  99. if(!this.$reg.isNoChinese(e.detail.value)){
  100. this.$util.msg('SN码格式错误',2000);
  101. return
  102. }
  103. },
  104. showViewerImageFn: function(index,imageIndex ){//预览图片
  105. var _this = this;
  106. var DomEven = '#listViewImage'+index+''+imageIndex;
  107. var ViewerDom = document.querySelector(DomEven);
  108. _this.viewer = new Viewer(ViewerDom, {url:'data-image'});
  109. },
  110. showGoodSelect:function(){//显示选择商品下拉框
  111. var _this = this;
  112. _this.selectGoods = !_this.selectGoods;
  113. },
  114. changeGoodsFn:function(item,good){ //品牌列表
  115. var _this = this;
  116. item.recordId = good.id;
  117. item.productName = good.productName;
  118. },
  119. uploadImagesFn: function(index,array,event){//上传商品资质图片
  120. var _this = this;
  121. var inputDOM = _this.$refs['Qualificationsimage'+index];
  122. var file = inputDOM[0].files;
  123. var formData = new FormData();
  124. formData.append('file', file[0]);
  125. PublicApi.uploadimg(formData,function(response){
  126. array.push(response.data);
  127. event.target.value = '';
  128. });
  129. },
  130. uploadFileFn : function(index,array,event){//上传承诺函文件
  131. var _this = this;
  132. var inputDOM = _this.$refs['QualificationsFile'+index];
  133. var file = inputDOM[0].files[0];
  134. console.log('file========>',file);
  135. var formData = new FormData();
  136. var size = file.size;
  137. var newfilename = file.name;
  138. //截取
  139. var fixFile = newfilename.substr(newfilename.lastIndexOf('.'));
  140. console.log(fixFile);
  141. //统一转成小写
  142. var lowFixFile = fixFile.toLowerCase();
  143. if ( lowFixFile != '.pdf' && lowFixFile != '.doc' && lowFixFile != '.docx' ){ //限制了文件类型
  144. CAIMEI.dialog('文件格式不正确!');
  145. event.target.value = '';
  146. return;
  147. }
  148. if(size > 52428800){//限制了文件的大小20MB
  149. CAIMEI.dialog('文件大小不能超过50M');
  150. event.target.value = '';
  151. return;
  152. }
  153. formData.append('file', file);
  154. PublicApi.uploadFile(formData,function(response){
  155. var obj = {
  156. fileName:response.data.fileName,
  157. ossName:response.data.ossName
  158. };
  159. array.push(obj);
  160. console.log('array',array);
  161. event.target.value = '';
  162. });
  163. },
  164. removeGoodsImagesFn: function(index){//删除商品图片
  165. var _this = this;
  166. _this.GoodsImagesList.splice(index,1);
  167. _this.secondParams.image =_this.GoodsImagesList.toString()+',';
  168. },
  169. deleteImageFileFn: function(array,index){//删除图片
  170. array.splice(index, 1);
  171. },
  172. deleteFileFn:function(array,index){//删除商品资质文件
  173. var _this = this;
  174. PublicApi.deleteOssFile({ ossName : array[index].ossName },function (response) {
  175. if (response.code==0){
  176. array.splice(index, 1);
  177. }else{
  178. console.log('删除文件异常提示===>',response.msg)
  179. }
  180. })
  181. },
  182. addListFn : function(){//添加商品
  183. var _this = this;
  184. var obj ={
  185. productName:'',
  186. recordId:'',
  187. sn:'',
  188. fileList:[],
  189. imageList:[]
  190. };
  191. _this.qualificationsList.push(obj)
  192. },
  193. deleteLogistItemFn: function(item,index){
  194. var _this = this;
  195. CAIMEI.Modal('确认删除商品吗?','取消','确定',function () {
  196. _this.qualificationsList.splice(index, 1);
  197. });
  198. },
  199. editButtonCanel:function(){//暂不填写
  200. var _this = this;
  201. window.location.href = '/supplier/order/delivery_record.html?shopOrderID='+_this.shopOrderId;
  202. }
  203. },
  204. mounted:function () {
  205. var _self = this;
  206. _self.shopOrderId=CAIMEI.getUrlParam('shopOrderId');
  207. _self.logisticsBatchId = CAIMEI.getUrlParam('logisticsBatchId');
  208. _self.pageType = CAIMEI.getUrlParam('type');
  209. if( _self.pageType == 'edit'){
  210. _self.GetSupplierLogisticsRecord( _self.logisticsBatchId);
  211. _self.GetSupplierQualificationData( _self.logisticsBatchId);
  212. }else{
  213. _self.GetSupplierLogisticsRecord(_self.logisticsBatchId);
  214. }
  215. _self.open=true;
  216. }
  217. });