code.js 22 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647
  1. define({
  2. name: "basic",
  3. template: `
  4. <div id="basicGoods">
  5. <div class="vue-main-title">
  6. <div class="vue-main-title-left"></div>
  7. <div class="vue-main-title-content">基础信息</div>
  8. </div>
  9. <div style="margin:0 auto;width:80%;">
  10. <el-form :rules="rules" :model="form" label-width="130px">
  11. <el-form-item label="排序" prop="sort" required>
  12. <el-input v-model="form.goods.display_order"></el-input>
  13. <div class="form-item_tips">数字大的排名在前,默认排序方式为创建时间,注意:输入最大数为9位数,只能输入数字</div>
  14. </el-form-item>
  15. <el-form-item label="收款码名称">
  16. <el-input v-model="form.goods.title"></el-input>
  17. </el-form-item>
  18. <el-form-item label="商品分类">
  19. <el-row v-for="(categoryItem,itemIndex) in categoryList" style="margin-bottom:10px;" :key="itemIndex">
  20. <el-col :span="4" v-if="form.category_level * 1 >= 1">
  21. <el-select placeholder="请选择一级分类" v-model="categoryItem[0].id" clearable filterable @change="btnfirst($event,itemIndex,categoryItem[0].id)" >
  22. <el-option :value="firstItem.id" :label="firstItem.name" v-for="(firstItem,firstIndex) in form.category_list" :key="firstItem.id">{{firstItem.name}}</el-option>
  23. </el-select>
  24. </el-col>
  25. <el-col :span="4" v-if="form.category_level * 1 >= 2">
  26. <el-select v-if="secondChildrensIsshow" placeholder="请选择二级分类" style="margin:0 10px;" v-model="categoryItem[1].id" clearable filterable @change="btnSecond($event,itemIndex,categoryItem[1].id)" @click.native="btnChangeSecond($event,itemIndex,categoryItem[0])">
  27. <el-option :value="secondItem.id" :label="secondItem.name" v-for="(secondItem,secondIndex) in category_list_box[itemIndex].secondCategory" :key="secondItem.id">{{secondItem.name}}</el-option>
  28. </el-select>
  29. </el-col>
  30. <el-col :span="4" v-if="form.category_level * 1 >= 3">
  31. <el-select v-if="threeChildrensIsshow" placeholder="请选择三级分类" style="margin:0 10px;" v-model="categoryItem[2].id" clearable filterable @change="btnThree($event,itemIndex)" @click.native="btnChangeThree($event,itemIndex,categoryItem[1],categoryItem[0])">
  32. <el-option :value="threeItem.id" :label="threeItem.name" v-for="(threeItem,threeIndex) in category_list_box[itemIndex].threeCategory" :key="threeItem.id">{{threeItem.name}}</el-option>
  33. </el-select>
  34. </el-col>
  35. <el-col :span="4" v-if="form.category_to_option_open==1">
  36. <el-select placeholder="请选择规格" style="margin:0 10px;" v-model="form.goods.category_to_option[itemIndex].goods_option_id" clearable filterable>
  37. <el-option :value="optionItem.id" :label="optionItem.title" v-for="(optionItem,optionIndex) in form.options" :key="optionItem.id">{{optionItem.title}}</el-option>
  38. </el-select>
  39. </el-col>
  40. <el-col :span="4" >
  41. <el-button icon="el-icon-plus" v-if="itemIndex==0" @click="addCategory">添加分类</el-button>
  42. <el-button icon="el-icon-delete" v-else @click="removeCategory(itemIndex)"></el-button>
  43. </el-col>
  44. </el-row>
  45. </el-form-item>
  46. <el-form-item label="收款码图片">
  47. <div class="upload-boxed" @click="displaySelectMaterialPopup('thumb')">
  48. <img
  49. :src="form.goods.thumb_link"
  50. style="width: 150px; height: 150px; border-radius: 5px; cursor: pointer;object-fit:cover;"
  51. v-show="form.goods.thumb"
  52. />
  53. <div class="el-icon-plus" v-show="!form.goods.thumb"></div>
  54. <div class="upload-boxed-text">点击重新上传</div>
  55. </div>
  56. <div class="form-item_tips">建议尺寸: 640 * 640 ,或正方型图片</div>
  57. </el-form-item>
  58. <el-form-item label="是否上架">
  59. <el-switch v-model="form.goods.status" :active-value="1" :inactive-value="0"></el-switch>
  60. </el-form-item>
  61. </el-form>
  62. </div>
  63. <upload-multimedia-img
  64. :upload-show="showSelectMaterialPopup"
  65. :type="materialType"
  66. :name="formFieldName"
  67. :selNum="selNum"
  68. :select="select"
  69. @replace="showSelectMaterialPopup = !showSelectMaterialPopup"
  70. @sureSelect="sureSelectImg"
  71. @sure="selectedMaterial"
  72. ></upload-multimedia-img>
  73. </div>`,
  74. style: `
  75. .goods-image_list {
  76. margin-right:20px;
  77. }
  78. .goods-image_list .upload-boxed {
  79. position:relative;
  80. }
  81. .goods-image_list > div {
  82. display:inline-flex;
  83. flex-wrap:wrap;
  84. column-gap:10px;
  85. row-gap:10px;
  86. }
  87. #basicGoods input::-webkit-outer-spin-button,
  88. #basicGoods input::-webkit-inner-spin-button {
  89. -webkit-appearance: none;
  90. }
  91. #basicGoods input[type="number"] {
  92. -moz-appearance: textfield;
  93. }
  94. `,
  95. props: {
  96. form: {
  97. default() {
  98. return ;
  99. },
  100. },
  101. formKey: {
  102. type: String,
  103. default: "goods",
  104. },
  105. attr_hide:{
  106. default() {
  107. return {}
  108. }
  109. }
  110. },
  111. data() {
  112. let regular = new RegExp("^[0-9][0-9]*$")
  113. let checkoutSort = (rule, value, callback) => {
  114. this.sortRegular = true
  115. let sort = regular.test(this.form.goods.display_order);
  116. if(!sort){
  117. callback(new Error('请输入正整数'));
  118. this.sortRegular = false
  119. }
  120. };
  121. let checkoutTitle = (rule, value, callback) => {
  122. this.titleRegular = true
  123. if(!this.form.goods.title){
  124. callback(new Error('请输入商品名称'));
  125. this.titleRegular = false
  126. }
  127. };
  128. let checkoutCategory = (rule, value, callback) => {
  129. if(!this.attr_hide.hide_category){
  130. let info = true
  131. this.categoryList.forEach(item => {
  132. item.forEach(el => {
  133. if(!el.id){
  134. info = false
  135. return
  136. }
  137. })
  138. })
  139. this.categoryRegular = true
  140. if(!info){
  141. callback(new Error('请选择商品分类'));
  142. this.categoryRegular = false
  143. }
  144. }else{
  145. this.categoryRegular = true
  146. }
  147. };
  148. let checkoutThumb = (rule, value, callback) => {
  149. this.thumbRegular = true
  150. if(!this.form.goods.thumb){
  151. callback(new Error('请选择商品图片'));
  152. this.thumbRegular = false
  153. }
  154. };
  155. let checkoutVirtualSales = (rule, value, callback) => {
  156. let virtualSales = regular.test(this.form.goods.virtual_sales);
  157. this.virtualSalesRegular = true
  158. if(!virtualSales){
  159. callback(new Error('请输入正整数'));
  160. this.virtualSalesRegular = false
  161. }
  162. };
  163. let checkoutStock = (rule, value, callback) => {
  164. let stock = regular.test(this.form.goods.stock);
  165. this.stockRegular = true
  166. if(!stock){
  167. callback(new Error('请输入正整数'));
  168. this.stockRegular = false
  169. }
  170. };
  171. return {
  172. showSelectMaterialPopup: false,
  173. formFieldName: "",
  174. goodsImagesChangeIndex: null,
  175. materialType: "",
  176. selNum: "one",
  177. select:"open",
  178. rules:{
  179. sort:{ validator: checkoutSort},
  180. title:{validator:checkoutTitle},
  181. category:{validator:checkoutCategory},
  182. // goodsSku:{validator:checkoutSku},
  183. thumb:{validator:checkoutThumb},
  184. virtualSales:{validator:checkoutVirtualSales},
  185. stock:{validator:checkoutStock},
  186. },
  187. submitPropertyKeyWhiteList: [],
  188. // yesRegular:true,
  189. categoryList:[],
  190. // 原始值
  191. OriginCategory:[],
  192. // 改变后的值
  193. changeCategoryList:[],
  194. // 分类值
  195. category_list_box:[],
  196. isShow:true,
  197. sortRegular:true,
  198. titleRegular:true,
  199. // skuRegular:true,
  200. categoryRegular:true,
  201. virtualSalesRegular:true,
  202. stockRegular:true,
  203. thumbRegular:true,
  204. // 提交的数据
  205. threeChildrensIsshow:true,
  206. secondChildrensIsshow:true,
  207. };
  208. },
  209. mounted() {
  210. this.addDefaul()
  211. // 设置默认品牌
  212. if(this.form.goods.brand_id === 0){
  213. this.form.goods.brand_id = ""
  214. }
  215. this.goodsCategoryShow()
  216. this.getCategoryValue()
  217. },
  218. methods: {
  219. // 添加默认值
  220. addDefaul(){
  221. if(JSON.stringify(this.attr_hide) !== '[]'){
  222. if(this.attr_hide.appoint_type){
  223. this.form.goods.type = this.attr_hide.appoint_type
  224. }
  225. if(this.attr_hide.appoint_need_address){
  226. this.form.goods.need_address = this.attr_hide.appoint_need_address
  227. }
  228. }
  229. if(!this.form.goods.display_order){
  230. this.$set(this.form.goods,"display_order",0)
  231. }
  232. if(!this.form.goods.category_to_option){
  233. this.$set(this.form.goods,"category_to_option",[{goods_option_id:""}])
  234. }
  235. if(!this.form.goods.type){
  236. this.$set(this.form.goods,"type",1)
  237. }
  238. if(!this.form.goods.need_address){
  239. this.$set(this.form.goods,"need_address",0)
  240. }
  241. if(!this.form.goods.price){
  242. this.$set(this.form.goods,"price",0)
  243. }
  244. if(!this.form.goods.market_price){
  245. this.$set(this.form.goods,"market_price",0)
  246. }
  247. if(!this.form.goods.cost_price){
  248. this.$set(this.form.goods,"cost_price",0)
  249. }
  250. if(!this.form.goods.weight){
  251. this.$set(this.form.goods,"weight",0)
  252. }
  253. if(!this.form.goods.volume){
  254. this.$set(this.form.goods,"volume",0)
  255. }
  256. if(!this.form.goods.reduce_stock_method){
  257. this.$set(this.form.goods,"reduce_stock_method",0)
  258. }
  259. if(!this.form.goods.withhold_stock){
  260. this.$set(this.form.goods,"withhold_stock",0)
  261. }
  262. if(!this.form.goods.no_refund){
  263. this.$set(this.form.goods,"no_refund",0)
  264. }
  265. if(!this.form.goods.cost_price){
  266. this.$set(this.form.goods,"cost_price",0)
  267. }
  268. if(!this.form.goods.virtual_sales){
  269. this.$set(this.form.goods,"virtual_sales",0)
  270. }
  271. },
  272. // 商品分类回显
  273. goodsCategoryShow(){
  274. // 判断回显时商品类型是否存在,不存在根据category_level长度添加数据--this.judgeCategoryLevel()
  275. // 如果category_level的长度与返回的长度不一致,则不全默认值
  276. if(this.form.goods.category){
  277. this.OriginCategory = JSON.parse(JSON.stringify(this.form.goods.category))
  278. if(this.form.category_level == 3){
  279. this.OriginCategory.forEach(item => {
  280. if(item.length === 2){
  281. item.push({ "id": '', "level": 3 })
  282. }
  283. })
  284. }else if(this.form.category_level == 2){
  285. this.OriginCategory.forEach(item => {
  286. if(item.length === 1){
  287. item.push({ "id": '', "level": 2 })
  288. }
  289. })
  290. }
  291. }else{
  292. this.judgeCategoryLevel()
  293. }
  294. if(!this.form.goods.category){ this.isShow = false }
  295. if(this.form.goods.category){
  296. if(this.form.goods.category.length){
  297. if(this.form.goods.category[0].length){
  298. for(item of this.form.goods.category){
  299. item.forEach(cateItem => {
  300. let id = cateItem.id
  301. cateItem.id = cateItem.name
  302. cateItem.name = id
  303. })
  304. item = item.map(el => ({'id':el.id , 'level':el.level,'name':el.name}))
  305. // 判断是否有一级分类
  306. let firstLevel = item.find(threeItem => threeItem.level === 1)
  307. if(this.form.category_level * 1 === 1 && !firstLevel){
  308. item.push({'id':'' , 'level':1})
  309. }
  310. // 判断是否有二级分类
  311. let secondLevel = item.find(threeItem => threeItem.level === 2)
  312. if(this.form.category_level * 1 === 2 && !secondLevel){
  313. item.push({'id':'' , 'level':2})
  314. }
  315. // 判断是否有三级分类
  316. let threeLevel = item.find(threeItem => threeItem.level === 3)
  317. if(this.form.category_level * 1 === 3 && !threeLevel){
  318. item.push({'id':'' , 'level':3})
  319. }
  320. this.categoryList.push(item)
  321. this.changeCategoryList = this.categoryList
  322. }
  323. }else{
  324. this.judgeCategoryLevel()
  325. }
  326. }else{
  327. this.judgeCategoryLevel()
  328. }
  329. }else{
  330. this.judgeCategoryLevel()
  331. this.changeCategoryList = this.categoryList
  332. }
  333. },
  334. // 获取分类值
  335. getCategoryValue(){
  336. this.category_list_box = []
  337. this.categoryList.forEach((item,index) => {
  338. let filterCategry = []
  339. filterCategry.push({secondCategory:[]})
  340. filterCategry.push({threeCategory:[]})
  341. this.category_list_box.push(filterCategry)
  342. })
  343. },
  344. // 判断分类等级
  345. judgeCategoryLevel(){
  346. switch (this.form.category_level * 1){
  347. case 1 :
  348. this.categoryList = [[{ "id": '', "level": 1 }]];
  349. this.OriginCategory = this.categoryList
  350. break;
  351. case 2 :
  352. this.categoryList = [[{ "id": '', "level": 1 }, { "id": '', "level": 2 }]];
  353. this.OriginCategory = this.categoryList
  354. break;
  355. default:
  356. this.categoryList = [[{ "id": '', "level": 1 }, { "id": '', "level": 2 }, { "id": '', "level": 3 }]];
  357. this.OriginCategory = this.categoryList
  358. break;
  359. }
  360. },
  361. displaySelectMaterialPopup(fieldName = "thumb", type = 1) {
  362. if(fieldName == 'other'){
  363. this.selNum = 'more'
  364. }else{
  365. this.selNum = 'one'
  366. }
  367. this.formFieldName = fieldName;
  368. this.showSelectMaterialPopup = !this.showSelectMaterialPopup;
  369. this.materialType = String(type);
  370. },
  371. selectedMaterial(name, image, imageUrl) {
  372. console.log(name,image,imageUrl,"imageUrl*-",this.formFieldName);
  373. let originalImageUrl = JSON.parse(JSON.stringify(imageUrl))
  374. if(name == "video"){
  375. this.form.goods.goods_video_link = imageUrl[0].url
  376. this.form.goods.goods_video = originalImageUrl[0].attachment
  377. }
  378. if(name == "video_cover"){
  379. this.form.goods.video_image_link = imageUrl[0].url
  380. this.form.goods.video_image = originalImageUrl[0].attachment
  381. }
  382. if (Array.isArray(imageUrl)) {
  383. imageUrl = imageUrl.map((item) => {
  384. return item.url;
  385. });
  386. }
  387. if (this.formFieldName === "other") {
  388. if (this.goodsImagesChangeIndex === null) {
  389. if(!this.form.goods.thumb_url){
  390. this.$set(this.form.goods,"thumb_url",[])
  391. }
  392. for(let item of originalImageUrl){
  393. this.form.goods["thumb_url"].push({
  394. thumb_link:item.url,
  395. thumb:item.attachment
  396. });
  397. }
  398. } else {
  399. // this.form.goods["thumb_url"][this.goodsImagesChangeIndex] = imageUrl[0];
  400. this.goodsImagesChangeIndex = null;
  401. }
  402. } else {
  403. this.form.goods[this.formFieldName] = originalImageUrl[0].attachment;
  404. if(this.formFieldName == 'thumb') {
  405. this.form.goods['thumb_link'] = imageUrl[0]
  406. }
  407. }
  408. },
  409. // 点击图片选中
  410. sureSelectImg(val,id,item){
  411. console.log(val,id,item);
  412. // console.log(val,id,item,'点击图片选中');
  413. // if(this.formFieldName == "video_cover"){
  414. // this.form.goods.video_image = item.url
  415. // }
  416. // if(this.formFieldName == "thumb"){
  417. // this.form.goods[this.formFieldName] = item.url
  418. // }
  419. },
  420. addCategory() {
  421. switch (this.form.category_level * 1){
  422. case 1 :
  423. this.categoryList.push([{ "id": '', "level": 1 }]);
  424. if(this.isShow){this.OriginCategory.push([{ "id": '', "level": 1 }])}
  425. break;
  426. case 2 :
  427. this.categoryList.push([{ "id": '', "level": 1 }, { "id": '', "level": 2 }]);
  428. if(this.isShow){this.OriginCategory.push([{ "id": '', "level": 1 }, { "id": '', "level": 2 }])}
  429. break;
  430. default:
  431. this.categoryList.push([{ "id": '', "level": 1 }, { "id": '', "level": 2 }, { "id": '', "level": 3 }]);
  432. if(this.isShow){this.OriginCategory.push([{ "id": '', "level": 1 }, { "id": '', "level": 2 },{ "id": '', "level": 3 }])}
  433. break;
  434. }
  435. this.form.goods.category_to_option.push({'goods_option_id':""});
  436. this.getCategoryValue()
  437. },
  438. removeCategory(itemIndex) {
  439. this.categoryList.splice(itemIndex, 1);
  440. this.category_list_box.splice(itemIndex,1)
  441. this.OriginCategory.splice(itemIndex,1)
  442. this.form.goods.category_to_option.splice(itemIndex,1);
  443. },
  444. validate() {
  445. let submitCategoryList = []
  446. this.OriginCategory.forEach(element => {
  447. element = element.map(item => {
  448. delete item.name
  449. })
  450. })
  451. this.OriginCategory.forEach(item =>{
  452. let filterCatrgorys = item.filter((value, index, arr) => {
  453. return value.id !== ''
  454. })
  455. submitCategoryList.push(filterCatrgorys)
  456. })
  457. // 过滤空数组
  458. let filterSubmitCategoryList = []
  459. submitCategoryList.forEach((element,index) => {
  460. if(element.length !== 0){
  461. filterSubmitCategoryList.push(element)
  462. }
  463. });
  464. let obj = {
  465. category: filterSubmitCategoryList,
  466. status:this.form.goods.status,
  467. title:this.form.goods.title,
  468. thumb:this.form.goods.thumb,
  469. display_order:this.form.goods.display_order
  470. }
  471. console.log(obj);
  472. return obj
  473. },
  474. tipValidator(){
  475. if(!this.sortRegular){
  476. this.$message({
  477. message: '请输入排序',
  478. type: 'warning'
  479. });
  480. return
  481. }else if(!this.form.goods.title){
  482. this.$message({
  483. message: '请输入商品名称',
  484. type: 'warning'
  485. });
  486. return
  487. }else if(!this.form.goods.sku){
  488. this.$message({
  489. message: '请填写商品单位',
  490. type: 'warning'
  491. });
  492. }else if(!this.form.goods.thumb){
  493. this.$message({
  494. message: '请选择商品图片',
  495. type: 'warning'
  496. });
  497. return
  498. }else if(!this.virtualSalesRegular && this.form.goods.virtual_sales !== ''){
  499. this.$message({
  500. message: '请输入第三方销量',
  501. type: 'warning'
  502. });
  503. return
  504. }else if(!this.stockRegular){
  505. this.$message({
  506. message: '请输入库存',
  507. type: 'warning'
  508. });
  509. return
  510. }
  511. // if(!this.form.goods.virtual_sales){this.virtualSalesRegular = false }
  512. // if(!this.form.goods.stock){this.stockRegular = false }
  513. },
  514. // extraDate(){
  515. // return {
  516. // 'extra':"额外数据"
  517. // }
  518. // },
  519. // 监听一级商品分类
  520. btnfirst(value,itemIndex,firstValue){
  521. if(!firstValue){
  522. this.category_list_box[itemIndex].secondCategory = []
  523. this.category_list_box[itemIndex].threeCategory = []
  524. this.categoryList[itemIndex].forEach(item => {
  525. item.id = ""
  526. })
  527. }
  528. this.categoryList[itemIndex].forEach((item,key) => {
  529. if(key == 0){
  530. item.id = item.id
  531. }else{
  532. item.id = ""
  533. }
  534. })
  535. // 点击一级分类获取二级分类数据
  536. this.form.category_list.forEach(item => {
  537. if(item.id == value){
  538. // this.secondCategory = item.childrens
  539. this.category_list_box[itemIndex].secondCategory = item.childrens
  540. return
  541. }
  542. })
  543. this.listenCategory(value,itemIndex,0)
  544. },
  545. // 监听二级商品分类
  546. btnChangeSecond(value,itemIndex,secondValue){
  547. let category_list = JSON.parse(JSON.stringify(this.form.category_list))
  548. let secondChildrens = []
  549. if(typeof secondValue.id == "string" && secondValue.id){
  550. this.secondChildrensIsshow = false
  551. category_list.forEach((item,index) => {
  552. if(item.id == secondValue.name){
  553. secondChildrens.push(...item.childrens)
  554. return
  555. }
  556. })
  557. this.category_list_box[itemIndex].secondCategory = secondChildrens
  558. this.secondChildrensIsshow = true
  559. }
  560. },
  561. btnSecond(value,itemIndex,secondValue){
  562. if(!secondValue){
  563. this.category_list_box[itemIndex].threeCategory = []
  564. }
  565. this.categoryList[itemIndex].forEach((item,key) => {
  566. if(key === 2){
  567. item.id = ''
  568. }
  569. })
  570. // 点击二级分类获取三级分类数据
  571. if(this.category_list_box[itemIndex].secondCategory){
  572. this.category_list_box[itemIndex].secondCategory.forEach((item,index) => {
  573. if(item.id == value ){
  574. // this.threeCategory = item.childrens
  575. this.category_list_box[itemIndex].threeCategory = item.childrens
  576. return
  577. }
  578. })
  579. }
  580. this.listenCategory(value,itemIndex,1)
  581. },
  582. // 监听三级商品分类
  583. btnChangeThree(value,itemIndex,secondValue,oneValue){
  584. let category_list = JSON.parse(JSON.stringify(this.form.category_list))
  585. let threeChildrens = []
  586. if(typeof secondValue.id == "string" && secondValue.id){
  587. this.threeChildrensIsshow = false
  588. category_list.forEach((item,index) => {
  589. if(item.id == oneValue.name){
  590. item.childrens.forEach((el,key) => {
  591. if(el.id == secondValue.name){
  592. threeChildrens.push(...el.childrens)
  593. return
  594. }
  595. })
  596. return
  597. }
  598. })
  599. this.category_list_box[itemIndex].threeCategory = threeChildrens
  600. this.threeChildrensIsshow = true
  601. }
  602. },
  603. btnThree(value,itemIndex){
  604. this.listenCategory(value,itemIndex,2)
  605. },
  606. listenCategory(value,itemIndex,type){
  607. let info = false
  608. this.changeCategoryList[itemIndex].forEach((el,key) => {
  609. if(el.id === this.categoryList[itemIndex][key].id){
  610. info = true
  611. return
  612. }
  613. })
  614. if(this.isShow){
  615. if(info){
  616. let categoryBoxList = []
  617. this.OriginCategory[itemIndex].forEach((item,key) => {
  618. if(type == 2){
  619. if(key === 2){
  620. item = this.categoryList[itemIndex][key]
  621. }
  622. }else if(type == 1){
  623. if(key === 2 || key === 1){
  624. item = this.categoryList[itemIndex][key]
  625. }
  626. }else if(type == 0){
  627. if(key === 2 || key === 1 || key === 0){
  628. item = this.categoryList[itemIndex][key]
  629. // item.id = ""
  630. }
  631. }
  632. categoryBoxList.push(item)
  633. })
  634. this.OriginCategory[itemIndex] = categoryBoxList
  635. }else{
  636. this.OriginCategory[itemIndex] = this.categoryList[itemIndex]
  637. }
  638. }
  639. }
  640. },
  641. });