addComponent.vue 26 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831
  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" :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}(${item.id})`" :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. <el-input-number
  245. v-model="scope.row.presenterVoucher" :controls="false" :min="0"
  246. :precision="6"
  247. :step="1" style="width: auto;"
  248. />
  249. </template>
  250. </el-table-column>
  251. <el-table-column label="代金券最大抵扣额度(一般设置全额抵扣)">
  252. <template #header="scope">
  253. <div>代金券最大抵扣额度(一般设置全额抵扣)<el-button type="warning" size="mini" @click="$emit('syncVoucherPrice')">同步售价</el-button></div>
  254. </template>
  255. <template slot-scope="scope">
  256. <el-input-number v-model="scope.row.voucherPrice" :controls="false" :min="0" :precision="6" :step="0.01" style="width: auto;" />
  257. </template>
  258. </el-table-column>
  259. <el-table-column label="商品绑定的代金券">
  260. <template #header="scope">
  261. <div>
  262. 商品绑定的代金券
  263. <el-dropdown size="mini" split-button type="primary" @command="(e) => $emit('syncVoucherId', e)">
  264. 统一选择
  265. <el-dropdown-menu slot="dropdown">
  266. <el-dropdown-item v-for="item in voucherList" :key="item.id" :command="item.id">{{ `${item.voucherName}(${item.id})` }}</el-dropdown-item>
  267. </el-dropdown-menu>
  268. </el-dropdown>
  269. </div>
  270. </template>
  271. <template slot-scope="scope">
  272. <el-select v-model="scope.row.voucherId" placeholder="请选择商品绑定的代金券">
  273. <el-option v-for="item in voucherList" :key="item.id" :label="`${item.voucherName}(${item.id})`" :value="item.id">
  274. </el-option>
  275. </el-select>
  276. </template>
  277. </el-table-column>
  278. <el-table-column label="国际条码">
  279. <template slot-scope="scope">
  280. <el-input v-model="scope.row.sku" maxlength="20" />
  281. </template>
  282. </el-table-column>
  283. <!-- <el-table-column label="操作">
  284. <template slot-scope="scope">
  285. <el-button type="text" @click="delAttrValue(scope.row,scope.$index,scope.row,scope)">删除</el-button>
  286. </template>
  287. </el-table-column> -->
  288. </el-table>
  289. </div>
  290. </div>
  291. <el-dialog
  292. :append-to-body="true" :visible.sync="dialogVisible" class="check-image-dialog" title="查看图片"
  293. center="center"
  294. >
  295. <img width="100%" :src="dialogImageUrl" alt>
  296. </el-dialog>
  297. <el-dialog
  298. width="30%" :append-to-body="true" :visible.sync="previewVideoVisible" class="check-image-dialog"
  299. title="预览视频" center="center"
  300. >
  301. <div style="display: flex; align-items: center; justify-content: center;">
  302. <video controls autoplay muted style="width: 400px; height: 400px;" :src="dialogVideoUrl"></video>
  303. </div>
  304. </el-dialog>
  305. </div>
  306. </template>
  307. <script>
  308. import { uploadUrl } from '@/utils/request'
  309. import { getToken } from '@/utils/auth'
  310. import { isVideo } from '@/utils/index'
  311. export default {
  312. // eslint-disable-next-line vue/match-component-file-name, vue/component-definition-name-casing
  313. name: 'addComponent',
  314. filters: {
  315. attrValueFilter(map, list) {
  316. const hasChilds =
  317. list &&
  318. list.filter((skuAttr) => {
  319. const hasChild = skuAttr.values.some((attr) => attr.skuValue)
  320. return skuAttr.skuName && hasChild
  321. })
  322. if (!map) {
  323. return ''
  324. }
  325. const { code, valueCode } = map
  326. let codeStr = ''
  327. // eslint-disable-next-line array-callback-return
  328. hasChilds.map((item) => {
  329. const { values } = item
  330. values &&
  331. values.some((attr) => {
  332. const isSome = item.code === code && attr.valueCode === valueCode
  333. if (isSome) {
  334. codeStr = attr.skuValue
  335. }
  336. return isSome
  337. })
  338. })
  339. return codeStr
  340. }
  341. },
  342. props: {
  343. form: {
  344. type: Object,
  345. default() {
  346. return {}
  347. }
  348. },
  349. voucherList: {
  350. type: Array,
  351. // eslint-disable-next-line vue/require-valid-default-prop
  352. default: []
  353. }
  354. },
  355. data() {
  356. return {
  357. dialogImageUrl: '',
  358. dialogVideoUrl: '',
  359. dialogVisible: false,
  360. previewVideoVisible: false,
  361. headers: {
  362. 'Authorization-business': getToken(),
  363. 'tenant': 'MDAwMA=='
  364. },
  365. action: uploadUrl,
  366. dataObj: {
  367. folderId: 1
  368. },
  369. fileList: [],
  370. // 记录当前是哪里增加或者删除的
  371. idx: null
  372. }
  373. },
  374. computed: {
  375. skuAttrName() {
  376. return (
  377. this.form.skuAttrList &&
  378. this.form.skuAttrList.filter((skuAttr) => {
  379. const hasChilds = skuAttr.values.some((attr) => attr.skuValue)
  380. return skuAttr.skuName && hasChilds
  381. })
  382. )
  383. },
  384. singleStyle() {
  385. if (this.form.skuAttrList && this.form.skuAttrList[0]) {
  386. return this.form.skuAttrList && this.form.skuAttrList[0].values[0]
  387. }
  388. return {
  389. skuValue: ''
  390. }
  391. },
  392. skuList() {
  393. // console.log(this.form)
  394. if (this.form.attrStyle === 0) {
  395. return this.form.skuList.slice(0, 1)
  396. }
  397. return this.form.skuList
  398. }
  399. },
  400. watch: {
  401. 'form.skuAttrList': {
  402. handler(newVal, oldVal) {
  403. // 判断是否有规格值
  404. const hasChilds =
  405. this.form.skuAttrList &&
  406. this.form.skuAttrList.filter((skuAttr) => {
  407. const hasChild = skuAttr.values.some((attr) => attr.skuValue)
  408. return skuAttr.skuName && hasChild
  409. })
  410. // console.log(hasChilds);
  411. if (this.form.attrStyle === 1 && hasChilds.length) {
  412. this.skuFormat()
  413. }
  414. },
  415. deep: true
  416. },
  417. 'form.skuList': {
  418. handler(newVal, oldVal) {
  419. // console.log(newVal)
  420. // console.log(oldVal)
  421. // 修复因为添加规格导致的价格归零的问题
  422. oldVal.forEach((item, index) => {
  423. // newVal[index] = Object.assign(item, newVal[index])
  424. for (const key in newVal[index]) {
  425. if (item[key]) {
  426. newVal[index][key] = item[key]
  427. }
  428. }
  429. })
  430. // console.log(newVal)
  431. },
  432. deep: true
  433. }
  434. },
  435. methods: {
  436. isVideo,
  437. playVideo(url) {
  438. this.dialogVideoUrl = url
  439. this.previewVideoVisible = true
  440. },
  441. handleImageSuccess(response) {
  442. const url = response.data.url
  443. // eslint-disable-next-line vue/no-mutating-props
  444. this.form.imgs.push({
  445. imgPath: url
  446. })
  447. },
  448. // 移除图片
  449. handleRemove(file) {
  450. const { imgPath } = file
  451. // eslint-disable-next-line vue/no-mutating-props
  452. this.form.imgs = this.form.imgs.filter((item) => item.imgPath !== imgPath)
  453. },
  454. handleRemove1(file) {
  455. file.image = ''
  456. },
  457. handlePictureCardPreview(file) {
  458. this.dialogImageUrl = file.imgPath
  459. this.dialogVisible = true
  460. },
  461. handleImageSuccess1(response, file, fileList) {
  462. const url = response.data.url
  463. fileList[0].image = url
  464. },
  465. addAttrValue(index) {
  466. // eslint-disable-next-line vue/no-mutating-props
  467. this.form.skuAttrList[index].values.push({
  468. skuId: '',
  469. valueCode: '',
  470. skuValue: '',
  471. image: ''
  472. })
  473. if (this.idx == index) {
  474. this.form.deletes.splice(this.form.deletes.length - 1, 1)
  475. }
  476. // console.log(JSON.parse(JSON.stringify(this.form)))
  477. // console.log(this.form.skuAttrList[index])
  478. },
  479. addSkuAttrList() {
  480. // eslint-disable-next-line vue/no-mutating-props
  481. this.form.skuAttrList.push({
  482. code: '',
  483. skuName: '',
  484. values: [
  485. {
  486. skuValue: '',
  487. valueCode: '',
  488. image: '',
  489. isDelete: 0,
  490. sortOrder: 0
  491. }
  492. ],
  493. isDelete: 0,
  494. needImg: 0,
  495. sortOrder: 0
  496. })
  497. // console.log(this.form.skuAttrList)
  498. },
  499. // 删除规格值
  500. delValue(index, index1) {
  501. if (index1 < this.form.skuAttrList[index].values.length - 1) return
  502. this.idx = index
  503. const newList = JSON.parse(JSON.stringify(this.form.skuAttrList[index]))
  504. const valueObj = {
  505. code: newList.code,
  506. skuId: newList.skuId,
  507. valueCode: newList.values[index1].valueCode
  508. }
  509. // eslint-disable-next-line vue/no-mutating-props
  510. this.form.deletes.push(valueObj)
  511. console.log(this.form.deletes, '删除')
  512. // console.log(this.valueObj)
  513. this.form.skuAttrList[index].values.splice(index1, 1)
  514. // console.log(this.form.skuAttrList[index].values);
  515. },
  516. // 删除规格名
  517. delSkuAttrList(index) {
  518. const newList = JSON.parse(JSON.stringify(this.form.skuAttrList[index]))
  519. newList.values.forEach((item) => {
  520. const valueObj = {
  521. code: newList.code,
  522. skuId: newList.skuId,
  523. valueCode: ''
  524. }
  525. valueObj.valueCode = item.valueCode
  526. // eslint-disable-next-line vue/no-mutating-props
  527. this.form.deletes.push(valueObj)
  528. })
  529. // eslint-disable-next-line vue/no-mutating-props
  530. this.form.skuAttrList.splice(index, 1)
  531. },
  532. delAttrValue1(row, index, arr) { },
  533. skuFormat() {
  534. const skuListArray = []
  535. const result = {
  536. originalPrice: 0,
  537. price: 0,
  538. productId: '',
  539. skuAttrCodeDTOList: [
  540. {
  541. code: '',
  542. valueCode: ''
  543. }
  544. ],
  545. skuId: '',
  546. skuImage: '',
  547. stockNumber: 0,
  548. voucherId: 0,
  549. voucherPrice: 0,
  550. weight: 0
  551. }
  552. const doExchange = (arr, depth) => {
  553. const map = {
  554. arr: []
  555. }
  556. for (var i = 0; i < arr[depth].length; i++) {
  557. map.arr.push(arr[depth][i])
  558. const { code, valueCode, attrId } = arr[depth][i]
  559. result.skuAttrCodeDTOList[depth] = {
  560. code,
  561. valueCode,
  562. attrId
  563. }
  564. if (depth !== arr.length - 1) {
  565. doExchange(arr, depth + 1)
  566. } else {
  567. skuListArray.push(JSON.parse(JSON.stringify(result)))
  568. }
  569. }
  570. }
  571. // this.form.skuList = skuListArray
  572. // 获取规格值的所有组合
  573. const values = []
  574. // eslint-disable-next-line array-callback-return
  575. this.form.skuAttrList.map((skuItem, index) => {
  576. const attrList = []
  577. skuItem.code = skuItem.code || 'attr_code_' + index
  578. const { code } = skuItem
  579. skuItem.values &&
  580. // eslint-disable-next-line array-callback-return
  581. skuItem.values.map((attrItem, index1) => {
  582. attrItem.valueCode = skuItem.valueCode || code + '_value_' + index1
  583. const skuId = attrItem.skuId
  584. const attrId = attrItem.attrId
  585. if (attrItem.skuValue) {
  586. attrList.push({
  587. skuId,
  588. attrId,
  589. code,
  590. valueCode: attrItem.valueCode
  591. })
  592. }
  593. })
  594. if (attrList.length) {
  595. values.push(attrList)
  596. }
  597. })
  598. // 相互组合
  599. if (values.length) {
  600. doExchange(values, 0)
  601. }
  602. // console.log(this.form.skuList)
  603. // eslint-disable-next-line vue/no-mutating-props
  604. this.form.skuList = skuListArray.map((sku1) => {
  605. const { skuAttrList, skuAttrCodeDTOList } = sku1
  606. const skuAttrList1 = skuAttrCodeDTOList || skuAttrList
  607. const skuMap = this.form.skuList.filter((sku2) => {
  608. const skuAttrList2 = sku2.skuAttrList
  609. sku2.skuAttrCodeDTOList = skuAttrList2
  610. if (!skuAttrList2) return false
  611. const ids = []
  612. skuAttrList1.filter((item) => ids.push(item.id))
  613. const result = skuAttrList2.every((item) => ids.indexOf(item.attrValueId) !== -1)
  614. return result
  615. })
  616. let selectMap = sku1
  617. if (skuMap && skuMap.length) {
  618. selectMap = JSON.parse(JSON.stringify(skuMap[0]))
  619. selectMap.skuAttrCodeDTOList = skuAttrCodeDTOList
  620. }
  621. return selectMap
  622. })
  623. },
  624. changeFiles(file, fileList) {
  625. // console.log(file)
  626. // console.log(fileList)
  627. // eslint-disable-next-line prefer-const
  628. let uid = file.uid
  629. const isLt =
  630. file.size / 1024 / 5 >= 1 && file.size / 1024 / 1024 / 5 <= 1
  631. if (!isLt) {
  632. // this.$refs.upImagesFiles.abort()
  633. this.$message.error('上传文件大小不得小于5KB,不得大于5MB!')
  634. return false
  635. }
  636. // console.log(fileList)
  637. }
  638. }
  639. }
  640. </script>
  641. <style lang="scss" scoped>
  642. @import url("../../../styles/elDialog.scss");
  643. .tipsView {
  644. width: 110px;
  645. height: 46px;
  646. overflow: hidden;
  647. text-overflow: ellipsis;
  648. display: -webkit-box;
  649. -webkit-box-orient: vertical;
  650. -webkit-line-clamp: 2; /*行数*/
  651. }
  652. .style-information-component {
  653. width: 100%;
  654. min-height: 300px;
  655. padding: 24px;
  656. background-color: rgb(255, 255, 255);
  657. .el-form-item {
  658. margin-bottom: 10px;
  659. }
  660. .attr-value-list {
  661. display: flex;
  662. flex-wrap: wrap;
  663. .main-diagram {
  664. position: relative;
  665. width: 180px;
  666. .span-wrap {
  667. position: relative;
  668. display: inline-block;
  669. margin-top: 10px;
  670. .attr-actions {
  671. line-height: 100px;
  672. position: absolute;
  673. width: 100%;
  674. height: 100%;
  675. left: 0;
  676. top: 0;
  677. cursor: default;
  678. text-align: center;
  679. color: #fff;
  680. opacity: 0;
  681. font-size: 20px;
  682. background-color: rgba(0, 0, 0, 0.5);
  683. -webkit-transition: opacity 0.3s;
  684. transition: opacity 0.3s;
  685. z-index: 1;
  686. &:hover {
  687. opacity: 1;
  688. .attr-preview {
  689. display: inline-block;
  690. }
  691. i {
  692. color: #fff;
  693. font-size: 20px;
  694. }
  695. }
  696. }
  697. .attr-preview {
  698. display: none;
  699. cursor: pointer;
  700. font-size: 20px;
  701. color: #fff;
  702. }
  703. .attr-delete {
  704. margin-left: 15px;
  705. color: #fff;
  706. }
  707. }
  708. .attr-value-img {
  709. width: 100%;
  710. height: 100%;
  711. img {
  712. width: 100%;
  713. height: 100%;
  714. object-fit: contain;
  715. }
  716. }
  717. }
  718. }
  719. .m-8 {
  720. margin-right: 8px;
  721. }
  722. .upload-btn {
  723. box-sizing: border-box;
  724. display: flex;
  725. align-items: center;
  726. justify-content: center;
  727. width: 100%;
  728. height: 110px;
  729. cursor: pointer;
  730. border: 2px dashed #2e60f8;
  731. border-radius: 2px;
  732. background-color: #f8f9fb;
  733. text-align: center;
  734. font-size: 20px;
  735. color: #2e60f8;
  736. i {
  737. color: #2e60f8;
  738. font-size: 20px;
  739. }
  740. .upload-title {
  741. margin-left: 10px;
  742. font-size: 14px;
  743. }
  744. }
  745. .upload-wrap {
  746. margin-bottom: 25px;
  747. .el-upload-list__item {
  748. transition: none !important;
  749. }
  750. .el-upload,
  751. .el-upload-list__item {
  752. width: 100px;
  753. height: 100px;
  754. line-height: 100px;
  755. }
  756. .el-progress,
  757. .el-progress-circle {
  758. width: 80px !important;
  759. height: 80px !important;
  760. }
  761. }
  762. .sku-attr-list {
  763. .el-input {
  764. width: 180px;
  765. }
  766. }
  767. .single-style {
  768. .el-input {
  769. max-width: 180px;
  770. }
  771. }
  772. .add-attr-btn {
  773. margin-bottom: 25px;
  774. }
  775. .check-image-dialog {
  776. .el-dialog {
  777. margin-top: 25px;
  778. .el-dialog__body {
  779. img {
  780. max-width: 100%;
  781. max-height: 100%;
  782. height: 500px;
  783. object-fit: contain;
  784. }
  785. }
  786. }
  787. }
  788. .delImg {
  789. position: absolute;
  790. top: 12px;
  791. margin-left: -24px
  792. }
  793. .delImg:hover {
  794. border-radius: 50%;
  795. color: #ffffff;
  796. background: #2e60f8;
  797. cursor: pointer;
  798. }
  799. }
  800. </style>