release.js 47 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886887888889890891892893894895896897898899900901902903904905906907908909910911912913914915916917918919920921922923924925926927928929930931932933934935936937938939940941942943944945946947948949950951952953954955956957958959960961962963964965966967968969970971972973974975976977978979980981982983984985986987988989990991992993994995996997998999100010011002100310041005100610071008100910101011101210131014101510161017101810191020102110221023102410251026102710281029103010311032103310341035103610371038103910401041104210431044104510461047104810491050105110521053105410551056105710581059106010611062106310641065106610671068106910701071107210731074107510761077107810791080108110821083108410851086108710881089109010911092109310941095109610971098109911001101110211031104110511061107110811091110111111121113111411151116111711181119112011211122112311241125112611271128112911301131113211331134113511361137113811391140
  1. /**
  2. * Created by ZHJY on 2020/9/17.
  3. */
  4. ;
  5. $('.navLayout').find('.navList').removeClass("on").find('.con').hide().find('a').removeClass("on");
  6. $('.navLayout').find('.navList').eq(1).addClass("on").find('.con').show().find('a').eq(2).addClass("on");
  7. var releaseContainer = new Vue({
  8. el:"#releaseContainer",
  9. data: {
  10. NODE_ENV_BASE_URL:'',
  11. releaseType:'',
  12. productId:'',
  13. activeNum:0,
  14. isSelectActive:0,
  15. isRequest:true,
  16. isAddBrand:false,//控制提交品牌弹窗
  17. tagsText:'',//标签输入框
  18. brandImage:'',//品牌LOGO
  19. brandTextarea:'',//品牌描述
  20. brandAssociationList:[],//品牌联想
  21. isNoneBrand:false,
  22. releaseParams:{
  23. userId:0,
  24. shopId:0,
  25. name:'', //商品名称
  26. aliasName:'',//内部商品名称
  27. bigTypeId:'',
  28. smallTypeId:'',
  29. tinyTypeId:'',//三级分类ID
  30. brandId:'',//品牌ID
  31. tags:'',//商品标签
  32. unit:'',//包装规格
  33. productCode:'',//商品编码
  34. productType:'',//商品类型,
  35. machineType:'',//医疗器械类型
  36. searchKey:'',//搜索关键词
  37. qualificationImg:"",//器械资质
  38. normalPrice:'',//市场价
  39. price:'',//售价
  40. costPrice:'',//结算价
  41. includedTax:1,//是否含税
  42. invoiceType:1,//发票类型
  43. taxPoint:13,//税率
  44. minBuyNumber:'',//起订量
  45. stock:'',//库存
  46. step:1,//购买数量
  47. // byFlag:0,//运费
  48. allAreaFlag:1,//销售区域
  49. provinceIds:0,//指定区域
  50. detailInfo:'',//商品详情信息
  51. orderInfo :'',//订购方案
  52. serviceInfo:'',//服务详情
  53. firstClassifyName:'',
  54. twoClassifyName:'',
  55. threeClassifyName:'',
  56. brandName:'',
  57. commodityType:1
  58. },
  59. params:{
  60. param:[],//相关参数
  61. image:[],//商品图片
  62. },
  63. viewer:{},
  64. tagsList:[],//本地存储标签
  65. searchKeyArr:[],//本地存储关键词
  66. paramKeyList:[{paramsName:'',paramsContent:''}],//相关参数
  67. formData:new FormData(),
  68. classificationFirstList:[{name:'请选择',value:''}],
  69. classificationTwoList:[],
  70. classificationThreeList:[],
  71. keywordText:'请务必准确定义关键词,关键词会影响商品的搜索结果,建议从品牌,商品学名,商品别名,商品大类别和商品小类别5个方面考虑,每个关键词不超过16个汉字',
  72. selectText:{
  73. bigTypeID:'请选择一级分类',
  74. smallTypeID:'请选择二级分类',
  75. tinyTypeID:'请选择三级分类',
  76. goodsType:'请选择商品类型',
  77. apparatusType:'请选择器械类型',
  78. },
  79. goodsTypeList:[
  80. {name:'妆字号',value:1},
  81. {name:'械字号',value:2},
  82. {name:'其他',value:0},
  83. ],
  84. apparatusTypeList:[
  85. {name:'一类医疗器械',value:1},
  86. {name:'二类医疗器械',value:2},
  87. {name:'三类医疗器械',value:3},
  88. ],
  89. searchKeyList:[
  90. {placeholder:'建议输入品牌关键词',value:""},
  91. {placeholder:'建议输入品牌学名关键词',value:""},
  92. {placeholder:'建议输入商品别名/市场称呼关键词',value:""},
  93. {placeholder:'建议输入商品大类别关键词',value:""},
  94. {placeholder:'建议输入商品小类别关键词',value:""},
  95. ],
  96. attributeList:[
  97. {name:'产品',value:'1'},
  98. {name:'仪器',value:'2'}
  99. ],
  100. productDetailInfoId:null,
  101. ProvinceList:[],
  102. GoodsImagesList:[],
  103. isProvince:false,
  104. provinceIns:0,
  105. oldNum:0,
  106. newNum: 0,
  107. orderingMin:0,
  108. orderingMax:500,
  109. severiMin:0,
  110. severiMax:500,
  111. isTaxPonitEditPopup:false,
  112. isTaxPonitEdit:false,
  113. fromMessage:'',//提示文字
  114. isBrandAssociation:false,
  115. vShow_Name:false,
  116. vShow_AliasName:false,
  117. vShow_TinyTypeID:false,
  118. vShow_BrandID:false,
  119. vShow_GoodsType:false,
  120. vShow_QualificationImg:false,
  121. vShow_Tags:false,
  122. vShow_Unit:false,
  123. vShow_NormalPrice:false,
  124. vShow_Price1:false,
  125. vShow_includedTax:false,
  126. vShow_MinBuyNumber:false,
  127. vShow_Stock:false,
  128. vShow_isProvince:false,
  129. vShow_taxPoint:false,
  130. vShow_GoodsImages:false,
  131. vShow_detailInfoEditor:true,
  132. vShow_orderInfoEditor:true,
  133. vShow_attribute:false,
  134. },
  135. computed: {
  136. },
  137. methods: {
  138. getclass:function(val){
  139. this.selectText.bigTypeID='请选择一级分类';
  140. this.selectText.smallTypeID = '请选择二级分类';
  141. this.releaseParams.bigTypeId ='';
  142. this.classificationTwoList=[];
  143. this.classificationThreeList =[];
  144. this.GetFistClassFn(val);
  145. },
  146. GetEditReleaseProductInfo: function(productId){
  147. var _this = this;
  148. SupplierApi.EditReleaseProductInfo({productId:productId},function(response){
  149. if(response.code == 0){
  150. console.log(response);
  151. var data = response.data;
  152. _this.releaseParams.brandId = data.brandId;
  153. _this.releaseParams.name = data.name;
  154. _this.releaseParams.aliasName = data.aliasName;
  155. _this.releaseParams.productType = data.productType;
  156. _this.releaseParams.machineType = data.machineType;
  157. _this.releaseParams.qualificationImg = data.qualificationImg;
  158. _this.releaseParams.unit = data.unit;
  159. _this.releaseParams.productCode = data.productCode;
  160. _this.releaseParams.normalPrice = data.normalPrice;
  161. _this.releaseParams.price = data.price;
  162. _this.releaseParams.includedTax = data.includedTax == '' ? 1 : data.includedTax;
  163. _this.releaseParams.invoiceType = data.invoiceType;
  164. _this.releaseParams.taxPoint = data.supplierTaxPoint;
  165. _this.releaseParams.costPrice = data.costPrice;
  166. _this.releaseParams.minBuyNumber = data.minBuyNumber;
  167. _this.releaseParams.stock = data.stock;
  168. _this.releaseParams.step = data.step;
  169. _this.releaseParams.byFlag = data.byFlag;
  170. _this.releaseParams.allAreaFlag = data.allAreaFlag;
  171. _this.releaseParams.detailInfo = data.productDetail.detailInfo;
  172. _this.releaseParams.serviceInfo = data.productDetail.serviceInfo;
  173. _this.releaseParams.orderInfo = data.productDetail.orderInfo;
  174. _this.productDetailInfoId = data.productDetail.productDetailInfoId;
  175. _this.tagsList = _this.setTagArray(data.tags);
  176. _this.EchoProductFn(data.productType);
  177. _this.EchoMachineTypeFn(data.machineType);
  178. _this.selectText.bigTypeID = data.bigTypeName;
  179. _this.selectText.smallTypeID = data.smallTypeName;
  180. _this.selectText.tinyTypeID = data.tinyTypeName;
  181. _this.releaseParams.bigTypeId = data.bigTypeId;
  182. _this.releaseParams.smallTypeId =data.smallTypeId;
  183. _this.releaseParams.tinyTypeId =data.tinyTypeId;
  184. _this.releaseParams.firstClassifyName = data.bigTypeName;
  185. _this.releaseParams.twoClassifyName = data.smallTypeName;
  186. _this.releaseParams.threeClassifyName = data.tinyTypeName;
  187. _this.releaseParams.commodityType =data.commodityType;
  188. _this.releaseParams.brandName = data.brandName;
  189. _this.GoodsImagesList = _this.EchoGoodsImagesListFn(data.imageList);
  190. _this.classificationTwoList = data.smallTypeName;
  191. _this.classificationThreeList = data.tinyTypeName;
  192. if(data.commodityType !=null||data.commodityType != ''){
  193. _this.releaseParams.commodityType = data.commodityType;
  194. _this.GetFistClassFn(data.commodityType);
  195. }
  196. if(_this.classificationTwoList!=''){
  197. _this.GetTwoClassFn(data.bigTypeID);
  198. }
  199. if (_this.classificationThreeList){
  200. _this.GetThreeClassFn(data.smallTypeID);
  201. }
  202. if(data.searchKey != null){
  203. _this.setSearchKeyArray(data.searchKey);
  204. }
  205. if(data.parametersList == ''){
  206. _this.paramKeyList = [{paramsName:'',paramsContent:''}];
  207. }else{
  208. _this.paramKeyList = data.parametersList;
  209. }
  210. // 下拉列表初始化
  211. setTimeout(function(){
  212. _this.ChangeClassificationFirst({bigTypeId:data.bigTypeId, name:data.bigTypeName});
  213. setTimeout(function(){
  214. _this.ChangeClassificationTwo({smallTypeId:data.smallTypeId, name:data.smallTypeName});
  215. setTimeout(function(){
  216. _this.ChangeClassificationThree({tinyTypeId:data.tinyTypeId, name:data.tinyTypeName});
  217. },500);
  218. },500);
  219. },500);
  220. }else{
  221. CAIMEI.Alert(response.msg, '确定', false);
  222. }
  223. })
  224. },
  225. EchoProductFn : function(type) {
  226. switch (type) {
  227. case 0 && null:
  228. this.selectText.goodsType = '其他';
  229. break;
  230. case 1:
  231. this.selectText.goodsType = '妆字号';
  232. break;
  233. case 2:
  234. this.selectText.goodsType = '械字号';
  235. break;
  236. }
  237. },
  238. EchoMachineTypeFn : function(type) {
  239. switch (type) {
  240. case 1 && null:
  241. this.selectText.apparatusType = '一类医疗器械';
  242. break;
  243. case 2:
  244. this.selectText.apparatusType = '二类医疗器械';
  245. break;
  246. case 3:
  247. this.selectText.apparatusType = '三类医疗器械';
  248. break;
  249. }
  250. },
  251. EchoGoodsImagesListFn: function(arr){//处理商品主图回显
  252. var newArray =[];
  253. arr.forEach( function(el){ newArray.push(el.image) });
  254. return newArray;
  255. },
  256. touchmoveFn: function(){
  257. this.isSelectActive =0;
  258. },
  259. showOption: function(type){//显示option
  260. var _this = this;
  261. switch (type) {
  262. case 'first':
  263. _this.vShow_TinyTypeID = false;
  264. _this.isSelectActive=1;
  265. break;
  266. case 'two':
  267. _this.vShow_TinyTypeID = false;
  268. _this.isSelectActive=2;
  269. break;
  270. case 'three':
  271. _this.vShow_TinyTypeID = false;
  272. _this.isSelectActive=3;
  273. break;
  274. case 'type':
  275. _this.vShow_GoodsType = false;
  276. _this.isSelectActive=4;
  277. break;
  278. case 'ratus':
  279. _this.isSelectActive=5;
  280. break;
  281. }
  282. },
  283. SelectChangeTypeFn: function(option){//选择商品类型
  284. var _this = this;
  285. _this.releaseParams.productType = Number(option.value);
  286. _this.selectText.goodsType = option.name;
  287. _this.isSelectActive = 0;
  288. _this.vShow_GoodsType = false;
  289. },
  290. SelectChangeApparatusFn: function(option){//选择器械类型
  291. var _this = this;
  292. _this.releaseParams.machineType = Number(option.value);
  293. _this.selectText.apparatusType = option.name;
  294. _this.isSelectActive = 0;
  295. _this.vShow_GoodsType = false;
  296. },
  297. bindBrandAssociationFn: function(e){//品牌输入联想
  298. var _this = this;
  299. var name = e.target.value;
  300. if (name != ''){
  301. SupplierApi.GetBrandAssociation({userId: _this.releaseParams.userId,name:name},function(response){
  302. if(response.code ==0){
  303. if(response.data&&response.data.length>0){
  304. _this.brandAssociationList = response.data;
  305. _this.isBrandAssociation = true;
  306. }else{
  307. _this.brandAssociationList = [];
  308. _this.isBrandAssociation = false;
  309. }
  310. }
  311. });
  312. }else{
  313. _this.isBrandAssociation = false;
  314. }
  315. },
  316. brandAssociationFn: function(){//失去焦点判断是否存在品牌信息
  317. var _this = this;
  318. if(_this.releaseParams.brandName == ''){
  319. CAIMEI.dialog('请输入商品品牌名称');
  320. }else{
  321. SupplierApi.CheckSupplierBrandDetection({name:_this.releaseParams.brandName},function(response){
  322. if(response.code ==0){
  323. CAIMEI.dialog('您的品牌可以使用~');
  324. _this.releaseParams.brandId = response.data.id;
  325. }else{
  326. _this.releaseParams.brandId = '';
  327. CAIMEI.Modal('您输入的品牌名称暂未被采美收录,请检查品牌名称是否输入正确或者向采美提交该品牌','确定','去提交',function () {
  328. setTimeout(function(){
  329. _this.isAddBrand = true;
  330. },200);
  331. });
  332. }
  333. });
  334. }
  335. },
  336. uploadBrandImagesFn: function(){//上传品牌LOGO
  337. var _this = this;
  338. var inputDOM = _this.$refs.brandImage;
  339. var formData = new FormData();
  340. var file = inputDOM.files;
  341. formData.append('file', file[0]);
  342. SupplierApi.uploadimg(formData,function(response){
  343. _this.brandImage = response.data;
  344. });
  345. },
  346. removeBrandImageFn: function(){//删除品牌LOGO
  347. var _this = this;
  348. _this.brandImage = '';
  349. },
  350. confimAddBrandPopup: function(){//确定提交新品牌
  351. var _this = this;
  352. var params = {
  353. name:_this.releaseParams.brandName,
  354. userId:_this.releaseParams.userId,
  355. logo:_this.brandImage,
  356. description:_this.brandTextarea,
  357. source:1
  358. };
  359. SupplierApi.AddSupplierBrand(params,function(response){
  360. if(response.code == 0){
  361. CAIMEI.Alert('品牌提交成功,将在1-2个工作日内进行审核~','确定',true,function () {
  362. _this.releaseParams.brandId = response.data.id;
  363. _this.isBrandAssociation = false;
  364. _this.isAddBrand = false;
  365. });
  366. }else{
  367. CAIMEI.Alert(response.msg, '确定', false);
  368. }
  369. });
  370. },
  371. hideAddBrandPopup: function(){//取消提交新品牌
  372. var _this = this;
  373. _this.isAddBrand = false;
  374. },
  375. SelectChangeAssociationFn: function(option){//选择品牌
  376. var _this = this;
  377. _this.releaseParams.brandName = option.name;
  378. _this.releaseParams.brandId = option.id;
  379. _this.isBrandAssociation = false;
  380. _this.vShow_BrandID = false;
  381. },
  382. GetFistClassFn: function(val){//获取一级分类菜单
  383. var _this = this;
  384. PublicApi.GetFirstClassFication({typeSort:val},function (response) {
  385. if(response.code == 0){
  386. _this.classificationFirstList = response.data;
  387. }else{
  388. CAIMEI.Alert(response.msg, '确定', false);
  389. }
  390. })
  391. },
  392. GetTwoClassFn: function(value){//获取二级分类菜单
  393. var _this = this;
  394. PublicApi.GetTwoClassFication({bigTypeId:value},function (response) {
  395. if(response.code == 0){
  396. if(response.data.length>0){
  397. _this.classificationTwoList = response.data;
  398. }else {
  399. _this.classificationTwoList = [];
  400. _this.releaseParams.twoClassifyName = '';
  401. _this.releaseParams.smallTypeId = ''
  402. }
  403. }else{
  404. CAIMEI.Alert(response.msg, '确定', false);
  405. }
  406. })
  407. },
  408. GetThreeClassFn: function(value){//获取三级分类菜单
  409. var _this = this;
  410. PublicApi.GetThreeClassFication({smallTypeId:value},function (response) {
  411. if(response.code == 0){
  412. if(response.data.length>0){
  413. _this.classificationThreeList = response.data;
  414. }else {
  415. _this.releaseParams.threeClassifyName = '';
  416. _this.classificationThreeList = [];
  417. _this.releaseParams.tinyTypeId = ''
  418. }
  419. }else{
  420. CAIMEI.Alert(response.msg, '确定', false);
  421. }
  422. })
  423. },
  424. ChangeClassificationFirst: function(option){//选择一级分类
  425. var _this = this;
  426. _this.selectText.bigTypeID = option.name;
  427. _this.releaseParams.firstClassifyName = option.name;
  428. _this.releaseParams.bigTypeId = option.bigTypeId
  429. _this.selectText.smallTypeID='请选择二级分类';
  430. _this.selectText.tinyTypeID = '请选择三级分类';
  431. _this.releaseParams.smallTypeId ='';
  432. _this.releaseParams.tinyTypeId ='';
  433. _this.classificationTwoList=[];
  434. _this.classificationThreeList =[];
  435. _this.isSelectActive = 0;
  436. if(_this.releaseParams.bigTypeId!=''){
  437. _this.GetTwoClassFn(option.bigTypeId);
  438. }
  439. },
  440. ChangeClassificationTwo: function(option){//选择二级分类
  441. var _this = this;
  442. if(!option.smallTypeId){_this.isSelectActive = 0; return;}
  443. _this.selectText.smallTypeID = option.name;
  444. _this.selectText.tinyTypeID = '请选择三级分类';
  445. _this.releaseParams.smallTypeId = option.smallTypeId;
  446. _this.releaseParams.twoClassifyName = option.name;
  447. _this.isSelectActive = 0;
  448. _this.GetThreeClassFn(option.smallTypeId);
  449. },
  450. ChangeClassificationThree: function(option){//选择三级分类
  451. var _this = this;
  452. if(!option.tinyTypeId){_this.isSelectActive = 0; return;}
  453. _this.releaseParams.tinyTypeId = option.tinyTypeId;
  454. _this.selectText.tinyTypeID = option.name;
  455. _this.releaseParams.threeClassifyName = option.name;
  456. _this.isSelectActive = 0;
  457. _this.vShow_TinyTypeID = false;
  458. },
  459. addTag:function(){//添加标签
  460. var _this = this;
  461. if(_this.tagsText == ''){
  462. _this.vShow_Tags = true;
  463. _this.fromMessage = '请输入商品标签!';
  464. }else if(_this.in_array(_this.tagsText,_this.tagsList)){
  465. _this.vShow_Tags = true;
  466. _this.fromMessage = '商品标签已存在!';
  467. }else{
  468. _this.tagsList.push({"tag":_this.tagsText});
  469. _this.tagsText = '';
  470. _this.vShow_Tags = false;
  471. _this.fromMessage = '';
  472. }
  473. },
  474. removeTags:function(index){//删除标签
  475. this.tagsList.splice(index,1);
  476. },
  477. in_array:function(search,array){//判断标签是否已存在
  478. for(var i in array){
  479. if(array[i].tag==search){
  480. return true;
  481. }
  482. }
  483. return false;
  484. },
  485. uploadQualificationsFn: function(el) {//上传资质证书
  486. var _this = this;
  487. var inputDOM = _this.$refs.inputer;
  488. var file = inputDOM.files;
  489. _this.formData.append('file', file[0]);
  490. SupplierApi.uploadimg(_this.formData,function(response){
  491. _this.releaseParams.qualificationImg = response.data;
  492. _this.vShow_QualificationImg = false;
  493. });
  494. },
  495. removeQualificationsFn: function(){//删除资质图片
  496. var _this = this;
  497. _this.releaseParams.qualificationImg = '';
  498. },
  499. addParamsFn: function(){//添加参数
  500. var _this = this;
  501. if(_this.paramKeyList.length>50){return;}
  502. var obj ={paramsName:'',paramsContent:''};
  503. _this.paramKeyList.push(obj)
  504. },
  505. removeParamsFn: function(index){//删除参数
  506. var _this = this;
  507. _this.paramKeyList.splice(index,1);
  508. },
  509. radioChangeInvoiceType: function(event) {//选择发票类型
  510. var _this = this;
  511. _this.releaseParams.invoiceType= event.target.value;
  512. switch (_this.releaseParams.invoiceType) {
  513. case '1':
  514. _this.releaseParams.taxPoint = 13;
  515. _this.isTaxPonitEdit = true;
  516. break;
  517. case '2':
  518. _this.releaseParams.taxPoint = 6;
  519. _this.isTaxPonitEdit = true;
  520. break;
  521. case '3':
  522. _this.releaseParams.taxPoint = '';
  523. _this.isTaxPonitEdit = false;
  524. break;
  525. }
  526. },
  527. taxPonitEdit: function(){//修改税率
  528. this.isTaxPonitEditPopup = true;
  529. },
  530. hideTaxPonitEditPopup: function(){//取消修改税率弹窗
  531. var _this = this;
  532. if(_this.releaseParams.taxPoint == ''){
  533. _this.vShow_taxPoint = true;
  534. _this.fromMessage = '请输入税率';
  535. return
  536. }
  537. if(_this.releaseParams.taxPoint == 0){
  538. _this.vShow_taxPoint = true;
  539. _this.fromMessage = '税率不能为0';
  540. return
  541. }
  542. this.isTaxPonitEditPopup = false;
  543. },
  544. confimTaxPonitEditPopup: function(){//确定修改税率
  545. var _this = this;
  546. if(_this.releaseParams.taxPoint == ''){
  547. _this.vShow_taxPoint = true;
  548. _this.fromMessage = '请输入税率';
  549. return
  550. }
  551. if(_this.releaseParams.taxPoint == 0){
  552. _this.vShow_taxPoint = true;
  553. _this.fromMessage = '税率不能为0';
  554. return
  555. }
  556. this.isTaxPonitEditPopup = false;
  557. },
  558. radioChangeStep: function(event){//选择指定购买数量
  559. this.releaseParams.step= event.target.value;
  560. },
  561. radioChangeByFlag: function(event){//选择运费
  562. this.releaseParams.byFlag= event.target.value;
  563. },
  564. radioChangeAllAreaFlag: function(event){//选择指定区域
  565. var _this = this;
  566. _this.releaseParams.areaFlag= event.target.value;
  567. if( _this.releaseParams.areaFlag == '0'){
  568. _this.isProvince=true;
  569. _this.GetProvinceFn();
  570. }else{
  571. _this.vShow_isProvince = false;
  572. _this.isProvince=false;
  573. }
  574. },
  575. addProvinceFn: function(item){//选择指定区域
  576. item.isChecked = ! item.isChecked;
  577. },
  578. GetProvinceFn: function(){//查询指定区域
  579. var _this = this;
  580. PublicApi.GetProvince({},function(response){
  581. if(response.code == 0){
  582. var arr =[];
  583. var data = response.data;
  584. data.forEach(function(el){
  585. CAIMEI.returnedTarget();
  586. arr.push(Object.assign({},el,{ isChecked : false }))
  587. });
  588. _this.ProvinceList =arr;
  589. }else{
  590. CAIMEI.Alert(response.msg, '确定', false);
  591. }
  592. })
  593. },
  594. uploadGoodsImagesFn: function(event){//上传商品图片
  595. var _this = this;
  596. var inputDOM = _this.$refs.goodsImages;
  597. var file = inputDOM.files;
  598. var reader = new FileReader();
  599. reader.readAsDataURL(file[0]);
  600. reader.onload = function(e) {
  601. var image = new Image();
  602. image.src = e.target.result;
  603. image.onload = function() {
  604. var w = this.width;
  605. var h = this.height;
  606. if (w != h) {
  607. CAIMEI.dialog('请上传尺寸比例为1:1的图片');
  608. return false;
  609. }
  610. if (w < 750 || h < 750) {
  611. CAIMEI.dialog('请上传分辨率大于750*750的图片');
  612. return false;
  613. }
  614. _this.formData.append('file', file[0]);
  615. SupplierApi.uploadimg(_this.formData,function(response){
  616. _this.GoodsImagesList.push(response.data);
  617. event.target.value = '';
  618. });
  619. }
  620. };
  621. },
  622. showViewerImageFn: function(index ){//预览上传图片
  623. var _this = this;
  624. var DomEven = '#uploadGoodsImages'+index;
  625. var ViewerDom = document.querySelector(DomEven);
  626. _this.viewer = new Viewer(ViewerDom, {url:'data-image'});
  627. },
  628. removeGoodsImagesFn: function(index){//删除商品图片
  629. var _this = this;
  630. _this.GoodsImagesList.splice(index,1);
  631. },
  632. orderingTextConInput: function(event){//订购方案文字控制
  633. var value = event.target.value;
  634. var len = parseInt(value.length);
  635. if (len > this.orderingMax) return;
  636. this.orderingMin = len;
  637. if(this.orderingMin == 500){
  638. return;
  639. }
  640. },
  641. severiTextConInput: function(event){//服务项目文字控制
  642. var value = event.target.value;
  643. var len = parseInt(value.length);
  644. if (len > this.severiMax) return;
  645. this.severiMin = len;
  646. if(this.severiMin == 500){
  647. return;
  648. }
  649. },
  650. PrevStep: function(){//返回上一步
  651. this.activeNum--;
  652. this.scrollIntoView();
  653. },
  654. NextStep: function(){//进入第二步
  655. var _this = this;
  656. var KeyString = '',TagString='';
  657. console.log(_this.releaseParams);
  658. if(_this.releaseParams.name == ''){
  659. _this.vShow_Name = true;
  660. _this.fromMessage = '请输入商品显示名';
  661. _this.scrollIntoView();
  662. setTimeout(function(){
  663. _this.vShow_Name = false;
  664. },2000);
  665. return
  666. }
  667. if(_this.releaseParams.aliasName == ''){
  668. _this.vShow_AliasName = true;
  669. _this.fromMessage = '请输入内部商品名';
  670. _this.scrollIntoView();
  671. setTimeout(function(){
  672. _this.vShow_AliasName = false;
  673. },2000);
  674. return;
  675. }
  676. if(_this.releaseParams.commodityType == ''){
  677. _this.vShow_attribute=true;
  678. _this.fromMessage = '请选择商品属性';
  679. _this.scrollIntoView();
  680. setTimeout(function(){
  681. _this.vShow_attribute = false;
  682. },2000);
  683. return;
  684. }
  685. if(_this.releaseParams.bigTypeId == ''){
  686. _this.vShow_TinyTypeID = true;
  687. _this.fromMessage = '请选择商品分类';
  688. _this.scrollIntoView();
  689. setTimeout(function(){
  690. _this.vShow_TinyTypeID = false;
  691. },2000);
  692. return;
  693. }
  694. if(_this.classificationTwoList!=''&& _this.classificationTwoList!=null){
  695. if(_this.releaseParams.smallTypeId == ''){
  696. _this.vShow_TinyTypeID = true;
  697. _this.fromMessage = '请选择二级分类';
  698. _this.scrollIntoView();
  699. setTimeout(function(){
  700. _this.vShow_TinyTypeID = false;
  701. },2000);
  702. return;
  703. }
  704. }
  705. if(_this.classificationThreeList!='' && _this.classificationThreeList!=null){
  706. if(_this.releaseParams.tinyTypeId == ''){
  707. _this.vShow_TinyTypeID = true;
  708. _this.fromMessage = '请选择三级分类';
  709. _this.scrollIntoView();
  710. setTimeout(function(){
  711. _this.vShow_TinyTypeID = false;
  712. },2000);
  713. return;
  714. }
  715. }
  716. if(_this.releaseParams.brandId == ''){
  717. _this.vShow_BrandID = true;
  718. _this.fromMessage = '请选择商品品牌';
  719. _this.scrollIntoView();
  720. setTimeout(function(){
  721. _this.vShow_BrandID = false;
  722. },2000);
  723. return;
  724. }
  725. if(_this.releaseParams.productType === ""){
  726. _this.vShow_GoodsType = true;
  727. _this.fromMessage = '请选择商品类型';
  728. _this.scrollIntoView();
  729. setTimeout(function(){
  730. _this.vShow_GoodsType = false;
  731. },2000);
  732. return;
  733. }
  734. if(_this.releaseParams.productType == 2){
  735. if(_this.releaseParams.machineType == ''){
  736. _this.vShow_GoodsType = true;
  737. _this.fromMessage = '请选择器械类型';
  738. _this.scrollIntoView();
  739. setTimeout(function(){
  740. _this.vShow_GoodsType = false;
  741. },2000);
  742. return;
  743. }
  744. if(_this.releaseParams.qualificationImg == ''){
  745. _this.vShow_QualificationImg = true;
  746. _this.fromMessage = '请上传资质图片';
  747. _this.scrollIntoView();
  748. setTimeout(function(){
  749. _this.vShow_QualificationImg = false;
  750. },2000);
  751. return;
  752. }
  753. }
  754. //商品标签
  755. if(_this.tagsList =='') {
  756. _this.vShow_Tags = true;
  757. _this.fromMessage = '请添加商品标签';
  758. _this.scrollIntoView();
  759. setTimeout(function(){
  760. _this.vShow_Tags = false;
  761. },2000);
  762. return;
  763. }else{
  764. _this.tagsList.forEach(function(el){
  765. TagString += el.tag+',';
  766. });
  767. _this.releaseParams.tags = TagString.substring(0, TagString.lastIndexOf(','));
  768. }
  769. if(_this.releaseParams.unit == ''){
  770. _this.vShow_Unit = true;
  771. _this.fromMessage = '请输入包装规格';
  772. setTimeout(function(){
  773. _this.vShow_Unit = false;
  774. },2000);
  775. _this.scrollIntoView();
  776. return;
  777. }
  778. //搜索关键词
  779. if(_this.searchKeyList!=''){
  780. _this.searchKeyList.forEach(function(el){
  781. KeyString+=el.value+',';
  782. });
  783. _this.releaseParams.searchKey = KeyString.substring(0, KeyString.lastIndexOf(','));
  784. }
  785. if( _this.paramKeyList[0].paramsName == ''){
  786. _this.params.param = [];
  787. }else{
  788. _this.params.param = _this.paramKeyList;
  789. }
  790. _this.activeNum++;
  791. _this.scrollIntoView();
  792. },
  793. NextStep1: function(){//进入第三步
  794. var _this = this;
  795. if(_this.releaseParams.normalPrice == ''){
  796. _this.vShow_NormalPrice = true;
  797. _this.fromMessage = '请输入市场价';
  798. _this.scrollIntoView();
  799. setTimeout(function(){
  800. _this.vShow_NormalPrice = false;
  801. },2000);
  802. return
  803. }
  804. if(_this.releaseParams.normalPrice == 0){
  805. _this.vShow_NormalPrice = true;
  806. _this.fromMessage = '市场价不能为0';
  807. _this.scrollIntoView();
  808. setTimeout(function(){
  809. _this.vShow_NormalPrice = false;
  810. },2000);
  811. return
  812. }
  813. if(_this.releaseParams.price == ''){
  814. _this.vShow_Price1 = true;
  815. _this.fromMessage = '请输入售价';
  816. _this.scrollIntoView();
  817. setTimeout(function(){
  818. _this.vShow_Price1 = false;
  819. },2000);
  820. return;
  821. }
  822. if(_this.releaseParams.price1 == 0){
  823. _this.vShow_Price1 = true;
  824. _this.fromMessage = '售价不能为0';
  825. _this.scrollIntoView();
  826. setTimeout(function(){
  827. _this.vShow_Price1 = false;
  828. },2000);
  829. return;
  830. }
  831. if(_this.releaseParams.includedTax == 3){
  832. _this.vShow_includedTax = true;
  833. _this.fromMessage = '请选择是否含税';
  834. _this.scrollIntoView();
  835. setTimeout(function(){
  836. _this.vShow_includedTax = false;
  837. },2000);
  838. return;
  839. }
  840. if(_this.releaseParams.minBuyNumber === ''){
  841. _this.vShow_MinBuyNumber = true;
  842. _this.fromMessage = '请输入起订量';
  843. _this.scrollIntoView();
  844. setTimeout(function(){
  845. _this.vShow_MinBuyNumber = false;
  846. },2000);
  847. return;
  848. }
  849. if(_this.releaseParams.stock === ''){
  850. _this.vShow_Stock = true;
  851. _this.fromMessage = '请输入库存';
  852. _this.scrollIntoView();
  853. setTimeout(function(){
  854. _this.vShow_Stock = false;
  855. },2000);
  856. return;
  857. }
  858. if(_this.releaseParams.minBuyNumber > _this.releaseParams.stock){
  859. _this.vShow_MinBuyNumber = true;
  860. _this.fromMessage = '起订量不能大于库存';
  861. _this.scrollIntoView();
  862. setTimeout(function(){
  863. _this.vShow_MinBuyNumber = false;
  864. },2000);
  865. return;
  866. }
  867. if(_this.releaseParams.areaFlag == '0'){
  868. _this.ProvinceList.forEach(function(el){
  869. if(el.isChecked){
  870. _this.releaseParams.provinceIds+=el.provinceID+',';
  871. }
  872. });
  873. if(_this.releaseParams.provinceIds == ''){
  874. _this.vShow_isProvince = true;
  875. _this.fromMessage = '请选择指定区域';
  876. setTimeout(function(){
  877. _this.vShow_isProvince = false;
  878. },2000);
  879. return;
  880. }
  881. }
  882. _this.activeNum++;
  883. _this.scrollIntoView();
  884. if(_this.vShow_detailInfoEditor){
  885. _this.initCKeditor();
  886. }
  887. },
  888. NextStep2: function() {//点击进入第四步
  889. var _this = this;
  890. var detailInfo= detailInfoEditor.getData();
  891. _this.releaseParams.detailInfo = detailInfo;
  892. if(_this.GoodsImagesList ==''){
  893. CAIMEI.dialog('请上传商品图片');
  894. return;
  895. }
  896. if( _this.releaseParams.detailInfo ==''){
  897. CAIMEI.dialog('请填写商品详情');
  898. return;
  899. }
  900. _this.params.image = [];
  901. _this.GoodsImagesList.forEach(function(el,index){
  902. var imageObject = {};
  903. if(index == 0 ){
  904. imageObject = {productImageId:'',image:el,mainFlag:'1'};
  905. }else{
  906. imageObject = {productImageId:'',image:el,mainFlag:'0'};
  907. }
  908. _this.params.image.push(imageObject);
  909. });
  910. _this.activeNum++;
  911. _this.scrollIntoView();
  912. if(_this.vShow_orderInfoEditor){
  913. _this.initOrderCKeditor();
  914. _this.initSeverCKeditor();
  915. }
  916. },
  917. initCKeditor: function(){//富文本
  918. var _this = this;
  919. _this.vShow_detailInfoEditor = false;
  920. ClassicEditor.create(document.querySelector('#detailInfoEditor'), {
  921. ckfinder: {
  922. uploadUrl: _this.NODE_ENV_BASE_URL+'/formData/ckeditorImage'
  923. }
  924. }).then(function(editor) {
  925. window.detailInfoEditor = editor;
  926. var detailInfo= detailInfoEditor.getData();
  927. ClassicEditor.instances.WORK_INTRODUCTION.setData(detailInfo);
  928. console.log(detailInfo);
  929. }).catch(function(error){
  930. console.log(error);
  931. });
  932. },
  933. initOrderCKeditor: function(){//富文本
  934. var _this = this;
  935. _this.vShow_orderInfoEditor = false;
  936. ClassicEditor.create(document.querySelector('#orderInfoEditor'), {
  937. ckfinder: {
  938. uploadUrl: _this.NODE_ENV_BASE_URL+'/formData/ckeditorImage'
  939. }
  940. }).then(function(editor) {
  941. window.orderInfoEditor = editor;
  942. var detailInfo= orderInfoEditor.getData();
  943. ClassicEditor.instances.WORK_INTRODUCTION.setData(detailInfo);
  944. console.log(detailInfo);
  945. }).catch(function(error){
  946. console.log(error);
  947. });
  948. },
  949. initSeverCKeditor: function(){//富文本
  950. var _this = this;
  951. _this.vShow_orderInfoEditor = false;
  952. ClassicEditor.create(document.querySelector('#severInfoEditor'), {
  953. ckfinder: {
  954. uploadUrl: _this.NODE_ENV_BASE_URL+'/formData/ckeditorImage'
  955. }
  956. }).then(function(editor) {
  957. window.severInfoEditor = editor;
  958. var detailInfo= severInfoEditor.getData();
  959. ClassicEditor.instances.WORK_INTRODUCTION.setData(detailInfo);
  960. }).catch(function(error){
  961. console.log(error);
  962. });
  963. },
  964. addReleaseGoodSubmitFn: function(){//提交发布商品
  965. var _this = this;
  966. _this.releaseParams.orderInfo = orderInfoEditor.getData();
  967. _this.releaseParams.serviceInfo = severInfoEditor.getData();
  968. if(_this.releaseType == 'edit'){
  969. _this.releaseParams.productDetailInfoId = _this.productDetailInfoId;
  970. _this.releaseParams.productId = _this.productId;
  971. CAIMEI.returnedTarget();
  972. _this.releaseParams = Object.assign(_this.releaseParams,{params:JSON.stringify(_this.params)});
  973. delete _this.releaseParams.imageList;
  974. delete _this.releaseParams.parametersList;
  975. delete _this.releaseParams.productDetail;
  976. }else{
  977. CAIMEI.returnedTarget();
  978. _this.releaseParams = Object.assign(_this.releaseParams,{params:JSON.stringify(_this.params)});
  979. }
  980. // console.log( _this.releaseParams);
  981. SupplierApi.AddSupplierReleaseProduct(_this.releaseParams,function(response){
  982. if(response.code == 0){
  983. CAIMEI.dialog('提交成功,等待审核',true,function () {
  984. if(_this.releaseType == 'edit'){
  985. SupplierApi.UpdateSearchManageProduct({productId:_this.productId},function (res) {
  986. console.log('编辑商品更新搜索索引~~~成功');
  987. })
  988. }
  989. location.href = '/supplier/goods.html';
  990. if(CAIMEI.Storage.getItem('adProductPeview')){
  991. CAIMEI.Storage.removeItem('adProductPeview');
  992. }
  993. });
  994. }else{
  995. CAIMEI.Alert(response.msg, '确定', false);
  996. }
  997. });
  998. },
  999. addReleasePeview: function(){//预览按钮
  1000. var _this = this;
  1001. CAIMEI.returnedTarget();
  1002. _this.releaseParams.orderInfo = orderInfoEditor.getData();
  1003. _this.releaseParams.serviceInfo = severInfoEditor.getData();
  1004. _this.releaseParams = Object.assign(_this.releaseParams,{params:_this.params});
  1005. CAIMEI.Storage.setItem('adProductPeview', JSON.stringify(_this.releaseParams));
  1006. setTimeout(function(){
  1007. window.open('/supplier/goods/preview.html');
  1008. },1000)
  1009. },
  1010. blur_name: function(e){//商品名失去焦点
  1011. var _this = this;
  1012. _this.vShow_Name = false;
  1013. if(e.target.value == ''){
  1014. _this.vShow_Name = true;
  1015. _this.fromMessage = '请输入商品显示名';
  1016. setTimeout(function(){
  1017. _this.vShow_Name = false;
  1018. },2000);
  1019. }else{
  1020. _this.vShow_Name = false;
  1021. }
  1022. },
  1023. blur_aliasName: function(e){//内部商品名失去焦点
  1024. var _this = this;
  1025. _this.vShow_AliasName = false;
  1026. if(e.target.value == ''){
  1027. _this.vShow_AliasName = true;
  1028. _this.fromMessage = '请输入内部商品名';
  1029. setTimeout(function(){
  1030. _this.vShow_AliasName = false;
  1031. },2000);
  1032. }else{
  1033. _this.vShow_AliasName = false;
  1034. }
  1035. },
  1036. blur_taxPoint: function(event){
  1037. var E_TaxPoint = event.target.value;
  1038. if(E_TaxPoint!=''){
  1039. this.releaseParams.taxPoint = parseFloat(E_TaxPoint);
  1040. }else{
  1041. this.releaseParams.taxPoint = '';
  1042. }
  1043. this.vShow_taxPoint = false;
  1044. },
  1045. blur_tags: function(e){
  1046. this.vShow_Tags = false;
  1047. },
  1048. blur_aliasUnit: function(e){
  1049. this.vShow_Unit = false;
  1050. },
  1051. input_normalPrice: function(e){
  1052. this.vShow_NormalPrice = false;
  1053. },
  1054. input_price1: function(e){
  1055. this.vShow_Price1 = false;
  1056. },
  1057. input_minBuyNumber: function(event){
  1058. this.vShow_MinBuyNumber = false;
  1059. var E_Number = event.target.value;
  1060. if(E_Number!=''){
  1061. this.releaseParams.minBuyNumber = parseInt(E_Number.replace(/[^0-9]/g,''));
  1062. }else{
  1063. this.releaseParams.minBuyNumber = '';
  1064. }
  1065. },
  1066. input_stock: function(event){
  1067. this.vShow_Stock = false;
  1068. var E_stock = event.target.value;
  1069. if(E_stock!=''){
  1070. this.releaseParams.stock = parseInt(E_stock.replace(/[^0-9]/g,''));
  1071. }else{
  1072. this.releaseParams.stock = '';
  1073. }
  1074. },
  1075. toFixedFn: function(text){
  1076. return Number(text).toFixed(2);
  1077. },
  1078. scrollIntoView: function(){
  1079. document.getElementById('releaseContainer').scrollIntoView({block: 'start', behavior: 'smooth'});
  1080. },
  1081. setTagArray: function(arr){//回显处理商品标签
  1082. var arrSplit = arr.split(',');
  1083. var _ARRAY = [];
  1084. arrSplit.forEach(function(item){
  1085. var _OBJ = {tag:item};
  1086. _ARRAY.push(_OBJ)
  1087. });
  1088. return _ARRAY
  1089. },
  1090. setSearchKeyArray: function(arr){//回显处理商品搜索关键词
  1091. var _this = this;
  1092. var arrSplit = arr.split(',');
  1093. return _this.searchKeyList.map(function(el,index){
  1094. el.value = arrSplit[index] || '';
  1095. })
  1096. },
  1097. gernerateTitleId: function(index){
  1098. return "title_" +index
  1099. },
  1100. dragstart: function(value) { // 记录初始信息
  1101. this.oldNum = value;
  1102. },
  1103. dragend: function(value) { // 做最终操作
  1104. if (this.oldNum != this.newNum) {
  1105. var oldIndex = this.GoodsImagesList.indexOf(this.oldNum);
  1106. var newIndex = this.GoodsImagesList.indexOf(this.newNum);
  1107. var newItems = this.GoodsImagesList;
  1108. // 删除老的节点
  1109. newItems.splice(oldIndex, 1);
  1110. // 在列表中目标位置增加新的节点
  1111. newItems.splice(newIndex, 0, this.oldNum);
  1112. // this.items一改变,transition-group就起了作用
  1113. this.GoodsImagesList = newItems;
  1114. }
  1115. },
  1116. dragenter: function(value) {//记录移动过程中信息
  1117. this.newNum = value;
  1118. },
  1119. },
  1120. created: function () {
  1121. // 获取初始一级分类菜单
  1122. this.GetFistClassFn(this.releaseParams.commodityType);
  1123. },
  1124. mounted: function () {
  1125. var _this = this;
  1126. // var NODE_ENV_BASE_URL = $('#spiServer').val();
  1127. var NODE_ENV_BASE_URL = 'https://spi-b.caimei365.com';
  1128. _this.NODE_ENV_BASE_URL = NODE_ENV_BASE_URL;
  1129. if(globalUserData){
  1130. _this.releaseParams.shopId = globalUserData.shopId;
  1131. _this.releaseParams.userId = globalUserData.userId;
  1132. _this.releaseType = CAIMEI.getUrlParam('type');
  1133. if( _this.releaseType == 'edit'){
  1134. _this.productId = Number(CAIMEI.getUrlParam('productId'));
  1135. _this.GetEditReleaseProductInfo(_this.productId);
  1136. }
  1137. }
  1138. }
  1139. });