qualifications.js 8.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215
  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. var formData = new FormData();
  135. var size = file.size;
  136. var newfilename = file.name;
  137. //截取
  138. var fixFile = newfilename.substr(newfilename.lastIndexOf('.'));
  139. //统一转成小写
  140. var lowFixFile = fixFile.toLowerCase();
  141. if ( lowFixFile != '.pdf' && lowFixFile != '.doc' && lowFixFile != '.docx' ){ //限制了文件类型
  142. CAIMEI.dialog('文件格式不正确!');
  143. event.target.value = '';
  144. return;
  145. }
  146. if(size > 52428800){//限制了文件的大小20MB
  147. CAIMEI.dialog('文件大小不能超过50M');
  148. event.target.value = '';
  149. return;
  150. }
  151. formData.append('file', file);
  152. PublicApi.uploadFile(formData,function(response){
  153. var obj = {
  154. fileName:response.data.fileName,
  155. ossName:response.data.ossName
  156. };
  157. array.push(obj);
  158. console.log('array',array);
  159. event.target.value = '';
  160. });
  161. },
  162. removeGoodsImagesFn: function(index){//删除商品图片
  163. var _this = this;
  164. _this.GoodsImagesList.splice(index,1);
  165. _this.secondParams.image =_this.GoodsImagesList.toString()+',';
  166. },
  167. deleteImageFileFn: function(array,index){//删除图片
  168. array.splice(index, 1);
  169. },
  170. deleteFileFn:function(array,index){//删除商品资质文件
  171. var _this = this;
  172. PublicApi.deleteOssFile({ ossName : array[index].ossName },function (response) {
  173. if (response.code==0){
  174. array.splice(index, 1);
  175. }else{
  176. console.log('删除文件异常提示===>',response.msg)
  177. }
  178. })
  179. },
  180. addListFn : function(){//添加商品
  181. var _this = this;
  182. var obj ={
  183. productName:'',
  184. recordId:'',
  185. sn:'',
  186. fileList:[],
  187. imageList:[]
  188. };
  189. _this.qualificationsList.push(obj)
  190. },
  191. deleteLogistItemFn: function(item,index){
  192. var _this = this;
  193. CAIMEI.Modal('确认删除商品吗?','取消','确定',function () {
  194. _this.qualificationsList.splice(index, 1);
  195. });
  196. },
  197. editButtonCanel:function(){//暂不填写
  198. var _this = this;
  199. window.location.href = '/supplier/order/delivery_record.html?shopOrderId='+_this.shopOrderId;
  200. }
  201. },
  202. mounted:function () {
  203. var _self = this;
  204. _self.shopOrderId=CAIMEI.getUrlParam('shopOrderId');
  205. _self.logisticsBatchId = CAIMEI.getUrlParam('logisticsBatchId');
  206. _self.pageType = CAIMEI.getUrlParam('type');
  207. if( _self.pageType == 'edit'){
  208. _self.GetSupplierLogisticsRecord( _self.logisticsBatchId);
  209. _self.GetSupplierQualificationData( _self.logisticsBatchId);
  210. }else{
  211. _self.GetSupplierLogisticsRecord(_self.logisticsBatchId);
  212. }
  213. _self.open=true;
  214. }
  215. });