addComponent.vue 26 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826
  1. <template>
  2. <div class="style-information-component">
  3. <el-form-item label="商品图片" />
  4. <div class="upload-wrap">
  5. <el-upload
  6. ref="upImagesFiles"
  7. list-type="picture-card" :on-preview="handlePictureCardPreview" :on-remove="handleRemove"
  8. :headers="headers" :data="dataObj" :file-list="form.imgs" :limit="20"
  9. :on-success="handleImageSuccess"
  10. :action="action"
  11. :before-upload="changeFiles"
  12. >
  13. <i slot="default" class="el-icon-plus" />
  14. <div slot="file" slot-scope="{ file }">
  15. <img v-if="!isVideo(file.imgPath)" class="el-upload-list__item-thumbnail" :src="file.imgPath">
  16. <video
  17. v-else class="el-upload-list__item-thumbnail" style="width: 148px;height: 148px;"
  18. :src="file.imgPath"
  19. ></video>
  20. <span class="el-upload-list__item-actions">
  21. <span
  22. v-if="!isVideo(file.imgPath)" class="el-upload-list__item-preview"
  23. @click="handlePictureCardPreview(file)"
  24. >
  25. <i class="el-icon-zoom-in" />
  26. </span>
  27. <span @click="playVideo(file.imgPath)">
  28. <i class="el-icon-video-play"></i>
  29. </span>
  30. <span class="el-upload-list__item-delete" @click="handleRemove(file)">
  31. <i class="el-icon-delete" />
  32. </span>
  33. </span>
  34. </div>
  35. </el-upload>
  36. </div>
  37. <el-form-item label="款式设置">
  38. <el-radio-group v-model="form.attrStyle">
  39. <el-radio :label="0">单款式</el-radio>
  40. <el-radio :label="1">多款式</el-radio>
  41. </el-radio-group>
  42. </el-form-item>
  43. <div class="style-container">
  44. <div v-if="form.attrStyle === 0" class="single-style">
  45. <el-table :data="skuList" style="width: 100%" :header-cell-style="{ background: '#EEF3FF', color: '#333333' }">
  46. <el-table-column label="规格">
  47. <template slot-scope="scope">
  48. <el-input v-model="singleStyle.skuValue" :sss="scope" maxlength="20" />
  49. </template>
  50. </el-table-column>
  51. <el-table-column label="售价">
  52. <template slot-scope="scope">
  53. <el-input-number
  54. v-model="scope.row.price" :controls="false" :max="999999999" :min="0"
  55. :precision="2"
  56. :step="0.01" style="width: auto;"
  57. />
  58. </template>
  59. </el-table-column>
  60. <el-table-column label="原价">
  61. <template slot-scope="scope">
  62. <el-input-number
  63. v-model="scope.row.originalPrice" :controls="false" :max="999999999" :min="0"
  64. :precision="2" :step="0.01" style="width: auto;"
  65. />
  66. </template>
  67. </el-table-column>
  68. <el-table-column label="库存">
  69. <template slot-scope="scope">
  70. <el-input-number
  71. v-model="scope.row.stockNumber" :controls="false" :max="999999999" :min="0"
  72. :precision="0" style="width: auto;"
  73. />
  74. </template>
  75. </el-table-column>
  76. <el-table-column label="重量(KG)">
  77. <template slot-scope="scope">
  78. <el-input-number
  79. v-model="scope.row.weight" :controls="false" :max="999" :min="0"
  80. :precision="2"
  81. :step="0.01" style="width: auto;"
  82. />
  83. </template>
  84. </el-table-column>
  85. <el-table-column label="赠送代金券">
  86. <template slot-scope="scope">
  87. <el-input-number
  88. v-model="scope.row.presenterVoucher" :controls="false" :max="scope.row.price" :min="0"
  89. :precision="2"
  90. :step="0.01" style="width: auto;"
  91. />
  92. </template>
  93. </el-table-column>
  94. <el-table-column label="代金券最大抵扣额度(一般设置全额抵扣)">
  95. <template slot-scope="scope">
  96. <el-input-number v-model="scope.row.voucherPrice" :controls="false" :min="0" :precision="6" :step="0.01" style="width: auto;" />
  97. </template>
  98. </el-table-column>
  99. <el-table-column label="商品绑定的代金券">
  100. <template slot-scope="scope">
  101. <el-select v-model="scope.row.voucherId" placeholder="请选择商品绑定的代金券">
  102. <el-option v-for="item in voucherList" :key="item.id" :label="item.voucherName" :value="item.id">
  103. </el-option>
  104. </el-select>
  105. </template>
  106. </el-table-column>
  107. <el-table-column label="国际条码">
  108. <template slot-scope="scope">
  109. <el-input v-model="scope.row.sku" maxlength="20" />
  110. </template>
  111. </el-table-column>
  112. </el-table>
  113. </div>
  114. <div v-else class="multiple-styles">
  115. <div v-for="(skuAttr, index) in form.skuAttrList" :key="index" class="sku-attr-list">
  116. <el-form-item label="规格名">
  117. <el-input v-model="skuAttr.skuName" maxlength="20" />
  118. <i v-if="index != 0" class="el-icon-close delImg" @click="delSkuAttrList(index)" />
  119. <el-checkbox v-if="index === 0" v-model="skuAttr.needImg" style="margin-left: 20px;">需要配图</el-checkbox>
  120. </el-form-item>
  121. <el-form-item label="规格值">
  122. <div class="attr-value-list">
  123. <div v-for="(sku, index1) in skuAttr.values" :key="index + '-' + index1" class="main-diagram m-8">
  124. <!-- 去除了长度限制 -->
  125. <el-input v-model="sku.skuValue" />
  126. <i v-if="index === 0 && index1 === 0" />
  127. <i v-else class="el-icon-close delImg" @click="delValue(index, index1)" />
  128. <div v-if="skuAttr.needImg && index === 0" class="upload-wrap diagram-upload">
  129. <div class="span-wrap">
  130. <el-upload
  131. list-type="picture-card" :show-file-list="false" :on-preview="handlePictureCardPreview"
  132. :on-remove="handleRemove" :headers="headers" :data="dataObj" :file-list="[ sku ]"
  133. :multiple="false"
  134. :on-success="handleImageSuccess1" :action="action"
  135. >
  136. <i v-if="!sku.image" slot="trigger" class="el-icon-plus" />
  137. <div v-else class="attr-value-img">
  138. <img class="attr-thumbnail" :src="sku.image">
  139. </div>
  140. </el-upload>
  141. <div v-if="sku.image" class="attr-actions">
  142. <span class="attr-preview" @click="handlePictureCardPreview({ imgPath: sku.image })">
  143. <i class="el-icon-zoom-in" />
  144. </span>
  145. <span class="attr-delete" @click="handleRemove1(sku)">
  146. <i class="el-icon-delete" />
  147. </span>
  148. </div>
  149. </div>
  150. </div>
  151. </div>
  152. <el-button type="text" style="margin-left: 10px;" @click="addAttrValue(index)">添加</el-button>
  153. </div>
  154. </el-form-item>
  155. </div>
  156. <el-button class="add-attr-btn" type="primary" @click="addSkuAttrList">添加规格</el-button>
  157. <el-table :data="skuList" style="width: 100%" :header-cell-style="{ background: '#EEF3FF', color: '#333333' }">
  158. <el-table-column v-for="(skuAttr, index) in skuAttrName" :key="index" :label="skuAttr.skuName">
  159. <template slot-scope="scope">
  160. <el-tooltip class="item" effect="dark" :content="scope.row.skuAttrCodeDTOList && scope.row.skuAttrCodeDTOList[index] | attrValueFilter(form.skuAttrList)" placement="top-start">
  161. <div class="tipsView">
  162. {{ scope.row.skuAttrCodeDTOList && scope.row.skuAttrCodeDTOList[index] | attrValueFilter(form.skuAttrList) }}
  163. </div>
  164. </el-tooltip>
  165. </template>
  166. </el-table-column>
  167. <el-table-column label="优惠价">
  168. <template slot-scope="scope">
  169. <el-input-number
  170. v-model="scope.row.price" :controls="false" :max="999999999" :min="0"
  171. :precision="2"
  172. :step="0.01" style="width: auto;"
  173. />
  174. </template>
  175. </el-table-column>
  176. <el-table-column label="市场价">
  177. <template slot-scope="scope">
  178. <el-input-number
  179. v-model="scope.row.originalPrice" :controls="false" :max="999999999" :min="0"
  180. :precision="2" :step="0.01" style="width: auto;"
  181. />
  182. </template>
  183. </el-table-column>
  184. <el-table-column label="供货价">
  185. <template slot-scope="scope">
  186. <el-input-number
  187. v-model="scope.row.manufacturerBasePrice" :controls="false" :max="999999999" :min="0"
  188. :precision="2"
  189. :step="0.01" style="width: auto;"
  190. />
  191. </template>
  192. </el-table-column>
  193. <el-table-column label="渠道价">
  194. <template slot-scope="scope">
  195. <el-input-number
  196. v-model="scope.row.manufacturerGuidePrice" :controls="false" :max="999999999" :min="0"
  197. :precision="2"
  198. :step="0.01" style="width: auto;"
  199. />
  200. </template>
  201. </el-table-column>
  202. <!-- <el-table-column label="平台底价">
  203. <template slot-scope="scope">
  204. <el-input-number
  205. v-model="scope.row.platformBasePrice" :controls="false" :max="999999999" :min="0"
  206. :precision="2"
  207. :step="0.01" style="width: auto;"
  208. />
  209. </template>
  210. </el-table-column>
  211. <el-table-column label="平台指导价">
  212. <template slot-scope="scope">
  213. <el-input-number
  214. v-model="scope.row.platformGuidePrice" :controls="false" :max="999999999" :min="0"
  215. :precision="2"
  216. :step="0.01" style="width: auto;"
  217. />
  218. </template>
  219. </el-table-column> -->
  220. <el-table-column label="库存">
  221. <template slot-scope="scope">
  222. <el-input-number
  223. v-model="scope.row.stockNumber" :controls="false" :max="999999999" :min="0"
  224. :precision="0" style="width: auto;"
  225. />
  226. </template>
  227. </el-table-column>
  228. <el-table-column label="重量(KG)">
  229. <template slot-scope="scope">
  230. <el-input-number
  231. v-model="scope.row.weight" :controls="false" :max="999" :min="0"
  232. :precision="6"
  233. :step="0.01" style="width: auto;"
  234. />
  235. </template>
  236. </el-table-column>
  237. <el-table-column label="赠送代金券">
  238. <template slot-scope="scope">
  239. <el-input-number
  240. v-model="scope.row.presenterVoucher" :controls="false" :max="scope.row.price" :min="0"
  241. :precision="6"
  242. :step="1" style="width: auto;"
  243. />
  244. </template>
  245. </el-table-column>
  246. <el-table-column label="代金券最大抵扣额度(一般设置全额抵扣)">
  247. <template #header="scope">
  248. <div>代金券最大抵扣额度(一般设置全额抵扣)<el-button type="warning" size="mini" @click="$emit('syncVoucherPrice')">同步售价</el-button></div>
  249. </template>
  250. <template slot-scope="scope">
  251. <el-input-number v-model="scope.row.voucherPrice" :controls="false" :min="0" :precision="6" :step="0.01" style="width: auto;" />
  252. </template>
  253. </el-table-column>
  254. <el-table-column label="商品绑定的代金券">
  255. <template #header="scope">
  256. <div>
  257. 商品绑定的代金券
  258. <el-dropdown size="mini" split-button type="primary" @command="(e) => $emit('syncVoucherId', e)">
  259. 统一选择
  260. <el-dropdown-menu slot="dropdown">
  261. <el-dropdown-item v-for="item in voucherList" :key="item.id" :command="item.id">{{ item.voucherName }}</el-dropdown-item>
  262. </el-dropdown-menu>
  263. </el-dropdown>
  264. </div>
  265. </template>
  266. <template slot-scope="scope">
  267. <el-select v-model="scope.row.voucherId" placeholder="请选择商品绑定的代金券">
  268. <el-option v-for="item in voucherList" :key="item.id" :label="item.voucherName" :value="item.id">
  269. </el-option>
  270. </el-select>
  271. </template>
  272. </el-table-column>
  273. <el-table-column label="国际条码">
  274. <template slot-scope="scope">
  275. <el-input v-model="scope.row.sku" maxlength="20" />
  276. </template>
  277. </el-table-column>
  278. <!-- <el-table-column label="操作">
  279. <template slot-scope="scope">
  280. <el-button type="text" @click="delAttrValue(scope.row,scope.$index,scope.row,scope)">删除</el-button>
  281. </template>
  282. </el-table-column> -->
  283. </el-table>
  284. </div>
  285. </div>
  286. <el-dialog
  287. :append-to-body="true" :visible.sync="dialogVisible" class="check-image-dialog" title="查看图片"
  288. center="center"
  289. >
  290. <img width="100%" :src="dialogImageUrl" alt>
  291. </el-dialog>
  292. <el-dialog
  293. width="30%" :append-to-body="true" :visible.sync="previewVideoVisible" class="check-image-dialog"
  294. title="预览视频" center="center"
  295. >
  296. <div style="display: flex; align-items: center; justify-content: center;">
  297. <video controls autoplay muted style="width: 400px; height: 400px;" :src="dialogVideoUrl"></video>
  298. </div>
  299. </el-dialog>
  300. </div>
  301. </template>
  302. <script>
  303. import { uploadUrl } from '@/utils/request'
  304. import { getToken } from '@/utils/auth'
  305. import { isVideo } from '@/utils/index'
  306. export default {
  307. // eslint-disable-next-line vue/match-component-file-name, vue/component-definition-name-casing
  308. name: 'addComponent',
  309. filters: {
  310. attrValueFilter(map, list) {
  311. const hasChilds =
  312. list &&
  313. list.filter((skuAttr) => {
  314. const hasChild = skuAttr.values.some((attr) => attr.skuValue)
  315. return skuAttr.skuName && hasChild
  316. })
  317. if (!map) {
  318. return ''
  319. }
  320. const { code, valueCode } = map
  321. let codeStr = ''
  322. // eslint-disable-next-line array-callback-return
  323. hasChilds.map((item) => {
  324. const { values } = item
  325. values &&
  326. values.some((attr) => {
  327. const isSome = item.code === code && attr.valueCode === valueCode
  328. if (isSome) {
  329. codeStr = attr.skuValue
  330. }
  331. return isSome
  332. })
  333. })
  334. return codeStr
  335. }
  336. },
  337. props: {
  338. form: {
  339. type: Object,
  340. default() {
  341. return {}
  342. }
  343. },
  344. voucherList: {
  345. type: Array,
  346. // eslint-disable-next-line vue/require-valid-default-prop
  347. default: []
  348. }
  349. },
  350. data() {
  351. return {
  352. dialogImageUrl: '',
  353. dialogVideoUrl: '',
  354. dialogVisible: false,
  355. previewVideoVisible: false,
  356. headers: {
  357. 'Authorization-business': getToken(),
  358. 'tenant': 'MDAwMA=='
  359. },
  360. action: uploadUrl,
  361. dataObj: {
  362. folderId: 1
  363. },
  364. fileList: [],
  365. // 记录当前是哪里增加或者删除的
  366. idx: null
  367. }
  368. },
  369. computed: {
  370. skuAttrName() {
  371. return (
  372. this.form.skuAttrList &&
  373. this.form.skuAttrList.filter((skuAttr) => {
  374. const hasChilds = skuAttr.values.some((attr) => attr.skuValue)
  375. return skuAttr.skuName && hasChilds
  376. })
  377. )
  378. },
  379. singleStyle() {
  380. if (this.form.skuAttrList && this.form.skuAttrList[0]) {
  381. return this.form.skuAttrList && this.form.skuAttrList[0].values[0]
  382. }
  383. return {
  384. skuValue: ''
  385. }
  386. },
  387. skuList() {
  388. // console.log(this.form)
  389. if (this.form.attrStyle === 0) {
  390. return this.form.skuList.slice(0, 1)
  391. }
  392. return this.form.skuList
  393. }
  394. },
  395. watch: {
  396. 'form.skuAttrList': {
  397. handler(newVal, oldVal) {
  398. // 判断是否有规格值
  399. const hasChilds =
  400. this.form.skuAttrList &&
  401. this.form.skuAttrList.filter((skuAttr) => {
  402. const hasChild = skuAttr.values.some((attr) => attr.skuValue)
  403. return skuAttr.skuName && hasChild
  404. })
  405. // console.log(hasChilds);
  406. if (this.form.attrStyle === 1 && hasChilds.length) {
  407. this.skuFormat()
  408. }
  409. },
  410. deep: true
  411. },
  412. 'form.skuList': {
  413. handler(newVal, oldVal) {
  414. // console.log(newVal)
  415. // console.log(oldVal)
  416. // 修复因为添加规格导致的价格归零的问题
  417. oldVal.forEach((item, index) => {
  418. // newVal[index] = Object.assign(item, newVal[index])
  419. for (const key in newVal[index]) {
  420. if (item[key]) {
  421. newVal[index][key] = item[key]
  422. }
  423. }
  424. })
  425. // console.log(newVal)
  426. },
  427. deep: true
  428. }
  429. },
  430. methods: {
  431. isVideo,
  432. playVideo(url) {
  433. this.dialogVideoUrl = url
  434. this.previewVideoVisible = true
  435. },
  436. handleImageSuccess(response) {
  437. const url = response.data.url
  438. // eslint-disable-next-line vue/no-mutating-props
  439. this.form.imgs.push({
  440. imgPath: url
  441. })
  442. },
  443. // 移除图片
  444. handleRemove(file) {
  445. const { imgPath } = file
  446. // eslint-disable-next-line vue/no-mutating-props
  447. this.form.imgs = this.form.imgs.filter((item) => item.imgPath !== imgPath)
  448. },
  449. handleRemove1(file) {
  450. file.image = ''
  451. },
  452. handlePictureCardPreview(file) {
  453. this.dialogImageUrl = file.imgPath
  454. this.dialogVisible = true
  455. },
  456. handleImageSuccess1(response, file, fileList) {
  457. const url = response.data.url
  458. fileList[0].image = url
  459. },
  460. addAttrValue(index) {
  461. // eslint-disable-next-line vue/no-mutating-props
  462. this.form.skuAttrList[index].values.push({
  463. skuId: '',
  464. valueCode: '',
  465. skuValue: '',
  466. image: ''
  467. })
  468. if (this.idx == index) {
  469. this.form.deletes.splice(this.form.deletes.length - 1, 1)
  470. }
  471. // console.log(JSON.parse(JSON.stringify(this.form)))
  472. // console.log(this.form.skuAttrList[index])
  473. },
  474. addSkuAttrList() {
  475. // eslint-disable-next-line vue/no-mutating-props
  476. this.form.skuAttrList.push({
  477. code: '',
  478. skuName: '',
  479. values: [
  480. {
  481. skuValue: '',
  482. valueCode: '',
  483. image: '',
  484. isDelete: 0,
  485. sortOrder: 0
  486. }
  487. ],
  488. isDelete: 0,
  489. needImg: 0,
  490. sortOrder: 0
  491. })
  492. // console.log(this.form.skuAttrList)
  493. },
  494. // 删除规格值
  495. delValue(index, index1) {
  496. if (index1 < this.form.skuAttrList[index].values.length - 1) return
  497. this.idx = index
  498. const newList = JSON.parse(JSON.stringify(this.form.skuAttrList[index]))
  499. const valueObj = {
  500. code: newList.code,
  501. skuId: newList.skuId,
  502. valueCode: newList.values[index1].valueCode
  503. }
  504. // eslint-disable-next-line vue/no-mutating-props
  505. this.form.deletes.push(valueObj)
  506. console.log(this.form.deletes, '删除')
  507. // console.log(this.valueObj)
  508. this.form.skuAttrList[index].values.splice(index1, 1)
  509. // console.log(this.form.skuAttrList[index].values);
  510. },
  511. // 删除规格名
  512. delSkuAttrList(index) {
  513. const newList = JSON.parse(JSON.stringify(this.form.skuAttrList[index]))
  514. newList.values.forEach((item) => {
  515. const valueObj = {
  516. code: newList.code,
  517. skuId: newList.skuId,
  518. valueCode: ''
  519. }
  520. valueObj.valueCode = item.valueCode
  521. // eslint-disable-next-line vue/no-mutating-props
  522. this.form.deletes.push(valueObj)
  523. })
  524. // eslint-disable-next-line vue/no-mutating-props
  525. this.form.skuAttrList.splice(index, 1)
  526. },
  527. delAttrValue1(row, index, arr) { },
  528. skuFormat() {
  529. const skuListArray = []
  530. const result = {
  531. originalPrice: 0,
  532. price: 0,
  533. productId: '',
  534. skuAttrCodeDTOList: [
  535. {
  536. code: '',
  537. valueCode: ''
  538. }
  539. ],
  540. skuId: '',
  541. skuImage: '',
  542. stockNumber: 0,
  543. voucherId: 0,
  544. voucherPrice: 0,
  545. weight: 0
  546. }
  547. const doExchange = (arr, depth) => {
  548. const map = {
  549. arr: []
  550. }
  551. for (var i = 0; i < arr[depth].length; i++) {
  552. map.arr.push(arr[depth][i])
  553. const { code, valueCode, attrId } = arr[depth][i]
  554. result.skuAttrCodeDTOList[depth] = {
  555. code,
  556. valueCode,
  557. attrId
  558. }
  559. if (depth !== arr.length - 1) {
  560. doExchange(arr, depth + 1)
  561. } else {
  562. skuListArray.push(JSON.parse(JSON.stringify(result)))
  563. }
  564. }
  565. }
  566. // this.form.skuList = skuListArray
  567. // 获取规格值的所有组合
  568. const values = []
  569. // eslint-disable-next-line array-callback-return
  570. this.form.skuAttrList.map((skuItem, index) => {
  571. const attrList = []
  572. skuItem.code = skuItem.code || 'attr_code_' + index
  573. const { code } = skuItem
  574. skuItem.values &&
  575. // eslint-disable-next-line array-callback-return
  576. skuItem.values.map((attrItem, index1) => {
  577. attrItem.valueCode = skuItem.valueCode || code + '_value_' + index1
  578. const skuId = attrItem.skuId
  579. const attrId = attrItem.attrId
  580. if (attrItem.skuValue) {
  581. attrList.push({
  582. skuId,
  583. attrId,
  584. code,
  585. valueCode: attrItem.valueCode
  586. })
  587. }
  588. })
  589. if (attrList.length) {
  590. values.push(attrList)
  591. }
  592. })
  593. // 相互组合
  594. if (values.length) {
  595. doExchange(values, 0)
  596. }
  597. // console.log(this.form.skuList)
  598. // eslint-disable-next-line vue/no-mutating-props
  599. this.form.skuList = skuListArray.map((sku1) => {
  600. const { skuAttrList, skuAttrCodeDTOList } = sku1
  601. const skuAttrList1 = skuAttrCodeDTOList || skuAttrList
  602. const skuMap = this.form.skuList.filter((sku2) => {
  603. const skuAttrList2 = sku2.skuAttrList
  604. sku2.skuAttrCodeDTOList = skuAttrList2
  605. if (!skuAttrList2) return false
  606. const ids = []
  607. skuAttrList1.filter((item) => ids.push(item.id))
  608. const result = skuAttrList2.every((item) => ids.indexOf(item.attrValueId) !== -1)
  609. return result
  610. })
  611. let selectMap = sku1
  612. if (skuMap && skuMap.length) {
  613. selectMap = JSON.parse(JSON.stringify(skuMap[0]))
  614. selectMap.skuAttrCodeDTOList = skuAttrCodeDTOList
  615. }
  616. return selectMap
  617. })
  618. },
  619. changeFiles(file, fileList) {
  620. // console.log(file)
  621. // console.log(fileList)
  622. // eslint-disable-next-line prefer-const
  623. let uid = file.uid
  624. const isLt =
  625. file.size / 1024 / 5 >= 1 && file.size / 1024 / 1024 / 5 <= 1
  626. if (!isLt) {
  627. // this.$refs.upImagesFiles.abort()
  628. this.$message.error('上传文件大小不得小于5KB,不得大于5MB!')
  629. return false
  630. }
  631. // console.log(fileList)
  632. }
  633. }
  634. }
  635. </script>
  636. <style lang="scss" scoped>
  637. @import url("../../../styles/elDialog.scss");
  638. .tipsView {
  639. width: 110px;
  640. height: 46px;
  641. overflow: hidden;
  642. text-overflow: ellipsis;
  643. display: -webkit-box;
  644. -webkit-box-orient: vertical;
  645. -webkit-line-clamp: 2; /*行数*/
  646. }
  647. .style-information-component {
  648. width: 100%;
  649. min-height: 300px;
  650. padding: 24px;
  651. background-color: rgb(255, 255, 255);
  652. .el-form-item {
  653. margin-bottom: 10px;
  654. }
  655. .attr-value-list {
  656. display: flex;
  657. flex-wrap: wrap;
  658. .main-diagram {
  659. position: relative;
  660. width: 180px;
  661. .span-wrap {
  662. position: relative;
  663. display: inline-block;
  664. margin-top: 10px;
  665. .attr-actions {
  666. line-height: 100px;
  667. position: absolute;
  668. width: 100%;
  669. height: 100%;
  670. left: 0;
  671. top: 0;
  672. cursor: default;
  673. text-align: center;
  674. color: #fff;
  675. opacity: 0;
  676. font-size: 20px;
  677. background-color: rgba(0, 0, 0, 0.5);
  678. -webkit-transition: opacity 0.3s;
  679. transition: opacity 0.3s;
  680. z-index: 1;
  681. &:hover {
  682. opacity: 1;
  683. .attr-preview {
  684. display: inline-block;
  685. }
  686. i {
  687. color: #fff;
  688. font-size: 20px;
  689. }
  690. }
  691. }
  692. .attr-preview {
  693. display: none;
  694. cursor: pointer;
  695. font-size: 20px;
  696. color: #fff;
  697. }
  698. .attr-delete {
  699. margin-left: 15px;
  700. color: #fff;
  701. }
  702. }
  703. .attr-value-img {
  704. width: 100%;
  705. height: 100%;
  706. img {
  707. width: 100%;
  708. height: 100%;
  709. object-fit: contain;
  710. }
  711. }
  712. }
  713. }
  714. .m-8 {
  715. margin-right: 8px;
  716. }
  717. .upload-btn {
  718. box-sizing: border-box;
  719. display: flex;
  720. align-items: center;
  721. justify-content: center;
  722. width: 100%;
  723. height: 110px;
  724. cursor: pointer;
  725. border: 2px dashed #2e60f8;
  726. border-radius: 2px;
  727. background-color: #f8f9fb;
  728. text-align: center;
  729. font-size: 20px;
  730. color: #2e60f8;
  731. i {
  732. color: #2e60f8;
  733. font-size: 20px;
  734. }
  735. .upload-title {
  736. margin-left: 10px;
  737. font-size: 14px;
  738. }
  739. }
  740. .upload-wrap {
  741. margin-bottom: 25px;
  742. .el-upload-list__item {
  743. transition: none !important;
  744. }
  745. .el-upload,
  746. .el-upload-list__item {
  747. width: 100px;
  748. height: 100px;
  749. line-height: 100px;
  750. }
  751. .el-progress,
  752. .el-progress-circle {
  753. width: 80px !important;
  754. height: 80px !important;
  755. }
  756. }
  757. .sku-attr-list {
  758. .el-input {
  759. width: 180px;
  760. }
  761. }
  762. .single-style {
  763. .el-input {
  764. max-width: 180px;
  765. }
  766. }
  767. .add-attr-btn {
  768. margin-bottom: 25px;
  769. }
  770. .check-image-dialog {
  771. .el-dialog {
  772. margin-top: 25px;
  773. .el-dialog__body {
  774. img {
  775. max-width: 100%;
  776. max-height: 100%;
  777. height: 500px;
  778. object-fit: contain;
  779. }
  780. }
  781. }
  782. }
  783. .delImg {
  784. position: absolute;
  785. top: 12px;
  786. margin-left: -24px
  787. }
  788. .delImg:hover {
  789. border-radius: 50%;
  790. color: #ffffff;
  791. background: #2e60f8;
  792. cursor: pointer;
  793. }
  794. }
  795. </style>