qualifications.js 6.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174
  1. ;
  2. var addlogistics = new Vue({
  3. el:'#qualifications',
  4. data:{
  5. open:false,
  6. pageType:'',
  7. shopOrderId:0,
  8. logisticsBatchId:0,
  9. selectGoods:false,
  10. productActions:[],
  11. qualificationsList:[
  12. {
  13. productName:'请选择商品',
  14. recordId:'',
  15. sn:'',
  16. fileList:[],
  17. imageList:[]
  18. }
  19. ]
  20. },
  21. methods:{
  22. GetSupplierQualificationData:function(logisticsBatchId){//编辑回显商品资质信息
  23. var _this = this;
  24. SupplierApi.GetSupplierQualificationData({logisticsBatchId:logisticsBatchId},function(response){
  25. if(response.code == 0 ){
  26. var data = response.data;
  27. if(data && data.length > 0) {
  28. _this.qualificationsList = data;
  29. _this.isEmpty = false
  30. }else{
  31. _this.isEmpty = true
  32. }
  33. }else{
  34. CAIMEI.Alert(response.msg, '确定', false);
  35. }
  36. })
  37. },
  38. GetSupplierLogisticsRecord:function(logisticsBatchId){//添加商品资质初始化查询商品信息
  39. var _this = this;
  40. SupplierApi.GetSupplierLogisticsRecord({ logisticsBatchId : logisticsBatchId },function(response){
  41. if(response.code == 0 ){
  42. var data = response.data;
  43. data.forEach(function(el,index){
  44. var obj = {
  45. id : el.id,
  46. productName : el.productName
  47. };
  48. _this.productActions.push(obj)
  49. });
  50. }else{
  51. CAIMEI.Alert(response.msg, '确定', false);
  52. }
  53. })
  54. },
  55. editButtonConfim:function(){//确定添加商品资质信息
  56. var _this = this;
  57. var params = [];
  58. _this.qualificationsList.forEach(function(el,index){
  59. var obj = {
  60. recordId : el.recordId,
  61. sn : el.sn,
  62. files : el.fileList,
  63. images : el.imageList
  64. };
  65. params.push(obj)
  66. });
  67. SupplierApi.GetSupplierQualificationUpdata({ params:JSON.stringify(params) },function(response){
  68. if(response.code == 0 ){
  69. CAIMEI.dialog('保存资质成功');
  70. }else{
  71. CAIMEI.Alert(response.msg, '确定', false);
  72. }
  73. })
  74. },
  75. showViewerImageFn: function(index,imageIndex ){//预览图片
  76. var _this = this;
  77. var DomEven = '#listViewImage'+index+''+imageIndex;
  78. var ViewerDom = document.querySelector(DomEven);
  79. _this.viewer = new Viewer(ViewerDom, {url:'data-image'});
  80. },
  81. showGoodSelect:function(){
  82. var _this = this;
  83. _this.selectGoods = !_this.selectGoods;
  84. },
  85. changeGoodsFn:function(item,good){ //品牌列表
  86. var _this = this;
  87. item.recordId = good.id;
  88. item.productName = good.productName;
  89. },
  90. uploadImagesFn: function(index,array,event){//上传商品资质图片
  91. var _this = this;
  92. var inputDOM = _this.$refs['Qualificationsimage'+index];
  93. var file = inputDOM[0].files;
  94. var formData = new FormData();
  95. formData.append('file', file[0]);
  96. PublicApi.uploadimg(formData,function(response){
  97. array.push(response.data);
  98. event.target.value = '';
  99. });
  100. },
  101. uploadFileFn : function(index,array,event){//上传承诺函文件
  102. var _this = this;
  103. var inputDOM = _this.$refs['QualificationsFile'+index];
  104. var file = inputDOM[0].files;
  105. console.log('file========>',file);
  106. var formData = new FormData();
  107. formData.append('file', file[0]);
  108. PublicApi.uploadFile(formData,function(response){
  109. var obj = {
  110. fileName:response.data.fileName,
  111. ossName:response.data.ossName
  112. };
  113. array.push(obj);
  114. console.log('array',array);
  115. event.target.value = '';
  116. });
  117. },
  118. removeGoodsImagesFn: function(index){//删除商品图片
  119. var _this = this;
  120. _this.GoodsImagesList.splice(index,1);
  121. _this.secondParams.image =_this.GoodsImagesList.toString()+',';
  122. },
  123. deleteImageFileFn: function(array,index){//删除图片
  124. array.splice(index, 1);
  125. },
  126. deleteFileFn:function(array,index){//删除商品资质文件
  127. var _this = this;
  128. PublicApi.deleteOssFile({ ossName : array[index].ossName },function (response) {
  129. if (response.code==0){
  130. array.splice(index, 1);
  131. }else{
  132. console.log('删除文件异常提示===>',response.msg)
  133. }
  134. })
  135. },
  136. addListFn : function(){//添加商品
  137. var _this = this;
  138. var obj ={
  139. productName:'',
  140. recordId:'',
  141. sn:'',
  142. fileList:[],
  143. imageList:[
  144. 'https://dss1.bdstatic.com/70cFuXSh_Q1YnxGkpoWK1HF6hhy/it/u=1194131577,2954769920&fm=26&gp=0.jpg',
  145. 'https://dss1.bdstatic.com/70cFuXSh_Q1YnxGkpoWK1HF6hhy/it/u=1194131577,2954769920&fm=26&gp=0.jpg'
  146. ]
  147. };
  148. _this.qualificationsList.push(obj)
  149. },
  150. deleteLogistItemFn: function(item,index){
  151. var _this = this;
  152. CAIMEI.Modal('确认删除商品吗?','取消','确定',function () {
  153. _this.qualificationsList.splice(index, 1);
  154. });
  155. },
  156. editButtonCanel:function(){//暂不填写
  157. var _this = this;
  158. window.location.href = '/supplier/order/delivery_record.html?shopOrderID='+_this.shopOrderId;
  159. }
  160. },
  161. mounted:function () {
  162. var _self = this;
  163. _self.shopOrderId=CAIMEI.getUrlParam('shopOrderId');
  164. _self.logisticsBatchId = CAIMEI.getUrlParam('logisticsBatchId');
  165. _self.pageType = CAIMEI.getUrlParam('type');
  166. if( _self.pageType == 'edit'){
  167. _self.GetSupplierLogisticsRecord( _self.logisticsBatchId);
  168. _self.GetSupplierQualificationData( _self.logisticsBatchId);
  169. }else{
  170. _self.GetSupplierLogisticsRecord(_self.logisticsBatchId);
  171. }
  172. _self.open=true;
  173. }
  174. });