prodInfo.vue 26 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850
  1. <template>
  2. <div class="mod-prod-info">
  3. <el-form :model="dataForm" ref="dataForm" label-width="100px" :rules="dataRule">
  4. <!-- 基本信息 -->
  5. <div class="tittle">
  6. {{this.$i18n.t('product.basicInformation')}}
  7. </div>
  8. <div class="basic-info">
  9. <!-- 商品主图 -->
  10. <el-form-item :label="this.$i18n.t('temp.productMainImage')"
  11. :label-width="this.$i18n.t('language') === 'English'?'146px':'100px'"
  12. :rules="[
  13. { required: true, message: this.$i18n.t('product.thisProductImg') },
  14. ]"
  15. >
  16. <imgs-upload v-model="dataForm.imgs" />
  17. <span
  18. style="color:#999"
  19. >{{ $t("admin.recommImgSize") }}800*800,{{
  20. $t("product.draggableSort")
  21. }}9{{ $t("marketing.piece") }}</span
  22. >
  23. </el-form-item>
  24. <!-- 商品视频 -->
  25. <el-form-item :label="this.$i18n.t('product.productVideo')" class="video-k"
  26. :label-width="this.$i18n.t('language') === 'English'?'140px':'100px'"
  27. >
  28. <video-upload v-model="dataForm.video" />
  29. </el-form-item>
  30. <!-- 平台分类 -->
  31. <el-form-item
  32. :label="this.$i18n.t('product.platforation')"
  33. prop="categoryId"
  34. :rules="[
  35. { required: true, message: this.$i18n.t('product.thisPlatformEmpty') },
  36. ]"
  37. >
  38. <div>
  39. <!-- <el-col :span="8"> -->
  40. <el-cascader
  41. expand-trigger="hover"
  42. :options="category.list"
  43. :props="category.props"
  44. v-model="category.selected"
  45. change-on-select
  46. @change="handleCategoryChange"
  47. ></el-cascader>
  48. <!-- 刷新 -->
  49. <div class="default-btn text-btn"
  50. @click="refreshCategoryTree">{{$t('admin.refresh')}}</div>
  51. <!-- </el-col> -->
  52. </div>
  53. <div v-if="!category.list.length">{{ $t('product.noContractedCategories') }}
  54. <span class="default-btn text-btn" @click="toShopInfo">{{$t('product.shopInfo')}}</span>
  55. {{ $t('product.applyContracting') }}
  56. </div>
  57. </el-form-item>
  58. <!-- 本店分类 -->
  59. <el-form-item
  60. :label="this.$i18n.t('product.shopCategory')"
  61. :label-width="this.$i18n.t('language') === 'English'?'140px':'100px'"
  62. prop="shopCategoryId"
  63. :rules="[
  64. { required: true, message: this.$i18n.t('product.thisShopeEmpty') },
  65. ]"
  66. >
  67. <el-col :span="8">
  68. <el-select
  69. v-model="dataForm.shopCategoryId"
  70. :placeholder="this.$i18n.t('product.thisShopCategroy')"
  71. >
  72. <el-option
  73. v-for="item in categoryList"
  74. :key="item.categoryId"
  75. :label="item.categoryName"
  76. :value="item.categoryId"
  77. ></el-option>
  78. </el-select>
  79. <!-- 新建/刷新-->
  80. <div class="default-btn text-btn"
  81. @click="refreshChange">{{$t('admin.refresh')}}</div>
  82. <el-divider direction="vertical"></el-divider>
  83. <div class="default-btn text-btn"
  84. @click.stop="addOrUpdateHandle()">{{$t('admin.newConstruction')}}</div>
  85. </el-col>
  86. </el-form-item>
  87. <!-- 弹窗, 新建 -->
  88. <add-or-update v-if="addOrUpdateVisible"
  89. ref="addOrUpdate"
  90. @refreshDataList="getCategoryList"></add-or-update>
  91. <!-- 品牌-->
  92. <el-form-item :label="this.$i18n.t('product.brand')" prop="brandId">
  93. <el-tooltip effect="light" :disabled="dataForm.categoryId" :content="this.$i18n.t('product.pleaseSelectCategoryAgainSelectBrand')" placement="top">
  94. <div style="width: 100px">
  95. <el-button
  96. plain
  97. @click="brandSelectHandle()"
  98. style="float: left"
  99. v-if="!brandName"
  100. :disabled="!dataForm.categoryId"
  101. >{{ $t("product.chooseABrand") }}</el-button
  102. >
  103. <el-tag v-else :closable="true" @close="handleClose()">{{ dataForm.brandName }}</el-tag>
  104. </div>
  105. </el-tooltip>
  106. </el-form-item>
  107. <!-- 商品排序 -->
  108. <el-form-item label="商品排序">
  109. <el-input-number v-model="dataForm.seq" :max="32767" placeholder="请输入商品排序" :min="0" validate-event style="width:200px" />
  110. </el-form-item>
  111. <el-form-item :label="this.$i18n.t('product.whetPreSale')" :label-width="this.$i18n.t('language') === 'English'?'184px':'100px'">
  112. <el-radio-group v-model="dataForm.preSellStatus">
  113. <el-radio :label="0">{{ $t("station.close") }}</el-radio>
  114. <el-radio :label="1">{{ $t("groups.turnOn") }}</el-radio>
  115. </el-radio-group>
  116. </el-form-item>
  117. <!-- 预售发货时间 -->
  118. <el-form-item
  119. v-if="dataForm.preSellStatus === 1"
  120. :label="this.$i18n.t('product.preSaleTime')"
  121. :label-width="this.$i18n.t('language') === 'English'?'181px':'106px'"
  122. prop="preSellTime"
  123. >
  124. <el-date-picker
  125. v-model="dataForm.preSellTime"
  126. type="datetime"
  127. :placeholder="this.$i18n.t('product.choosengDate')"
  128. value-format="yyyy-MM-dd HH:mm:ss"
  129. ></el-date-picker>
  130. </el-form-item>
  131. </div>
  132. <!-- 规格库存 -->
  133. <div class="tittle">
  134. {{this.$i18n.t('product.specificationStock')}}
  135. </div>
  136. <div class="basic-info">
  137. <sku-tag
  138. ref="skuTag"
  139. @change="skuTagChangeSkuHandler"
  140. :skuList="dataForm.skuList"
  141. ></sku-tag>
  142. <sku-table
  143. ref="skuTable"
  144. v-model="dataForm.skuList"
  145. :prodNameCn.sync="prodNameCn"
  146. :prodNameEn.sync="prodNameEn"
  147. :isCompose="dataForm.isCompose"
  148. ></sku-table>
  149. </div>
  150. <!-- 物流信息 -->
  151. <div class="tittle">
  152. {{this.$i18n.t('order.logisticsInformation')}}
  153. </div>
  154. <div class="basic-info">
  155. <!-- 配送方式 -->
  156. <el-form-item :label="this.$i18n.t('order.delType')">
  157. <el-checkbox v-model="dataForm.deliveryMode.hasShopDelivery" disabled>{{
  158. $t("product.ExpressDistribution")
  159. }}</el-checkbox>
  160. <el-checkbox v-model="dataForm.deliveryMode.hasUserPickUp" class="delType-text">{{
  161. $t("product.userMention")
  162. }}</el-checkbox>
  163. <el-checkbox
  164. v-model="dataForm.deliveryMode.hasCityDelivery"
  165. :disabled="sameCityStatus === 0"
  166. class="delType-text"
  167. >{{ $t("order.sameCityDelivery") }}</el-checkbox
  168. >
  169. </el-form-item>
  170. <!-- 运费设置 -->
  171. <prod-transport
  172. v-show="dataForm.deliveryMode.hasShopDelivery"
  173. v-model="dataForm.deliveryTemplateId"
  174. ></prod-transport>
  175. </div>
  176. <!-- <el-form-item :label="this.$i18n.t('product.')产品详情" prop="content">
  177. <tiny-mce v-model="dataForm.content" ref="content" style="width:1000px"></tiny-mce>
  178. </el-form-item>-->
  179. <!-- <el-tabs type="card">
  180. <el-tab-pane :label="this.$i18n.t('product.chinenInput')">
  181. <el-form-item
  182. :label="this.$i18n.t('homes.productDetails')"
  183. prop="contentCn"
  184. >
  185. <tiny-mce
  186. v-model="contentCn"
  187. ref="content"
  188. style="width: 1000px"
  189. ></tiny-mce>
  190. </el-form-item>
  191. </el-tab-pane>
  192. <el-tab-pane label="English Information">
  193. <el-form-item label="Prod name" prop="prodNameEn">
  194. <el-col :span="8">
  195. <el-input
  196. v-model="prodNameEn"
  197. placeholder="Prod name"
  198. maxlength="50"
  199. ></el-input>
  200. </el-col>
  201. </el-form-item>
  202. <el-form-item label="Selling point" prop="briefEn">
  203. <el-col :span="8">
  204. <el-input
  205. v-model="briefEn"
  206. type="textarea"
  207. :autosize="{ minRows: 2, maxRows: 4 }"
  208. placeholder="Selling point"
  209. ></el-input>
  210. </el-col>
  211. </el-form-item>
  212. <el-form-item label="details" prop="contentEn">
  213. <tiny-mce
  214. v-model="contentEn"
  215. ref="content"
  216. style="width: 1000px"
  217. ></tiny-mce>
  218. </el-form-item>
  219. </el-tab-pane>
  220. </el-tabs> -->
  221. <!-- 商品详细信息 -->
  222. <div class="tittle">
  223. {{this.$i18n.t('homes.productDetails')}}
  224. </div>
  225. <div class="basic-info basic-iny-mce">
  226. <!-- <el-form-item
  227. prop="contentCn"
  228. >
  229. <tiny-mce
  230. v-model="contentCn"
  231. ref="content"
  232. style="width: 1000px"
  233. :key="tinymceFlag"
  234. ></tiny-mce>
  235. </el-form-item>
  236. <el-form-item>
  237. <el-button type="primary" @click="dataFormSubmit()">{{
  238. $t("crud.filter.submitBtn")
  239. }}</el-button>
  240. </el-form-item> -->
  241. <!-- :rules="[{ required: true, message: this.$i18n.t('live.productNameEmpty')}]" -->
  242. <el-tabs type="card">
  243. <el-tab-pane :label="this.$i18n.t('product.chinenInput')">
  244. <el-form-item
  245. :label="this.$i18n.t('product.prodName')"
  246. prop="prodNameCn"
  247. class="product-prodName"
  248. >
  249. <!-- :rules="[{ required: true, message: '产品名称不能为空'}]" -->
  250. <el-col :span="8">
  251. <el-input
  252. v-model="prodNameCn"
  253. :placeholder="this.$i18n.t('product.prodName')"
  254. maxlength="50"
  255. ></el-input>
  256. </el-col>
  257. </el-form-item>
  258. <el-form-item
  259. :label="this.$i18n.t('product.prodellingPoint')"
  260. prop="briefCn"
  261. >
  262. <el-col :span="8">
  263. <el-input
  264. v-model="briefCn"
  265. type="textarea"
  266. :autosize="{ minRows: 2, maxRows: 4 }"
  267. :placeholder="this.$i18n.t('product.prodellingPoint')"
  268. ></el-input>
  269. </el-col>
  270. </el-form-item>
  271. <el-form-item
  272. :label="this.$i18n.t('homes.productDetails')"
  273. prop="contentCn"
  274. >
  275. <tiny-mce
  276. v-model="contentCn"
  277. ref="content"
  278. style="width: 1000px"
  279. v-if='tinymceShow'
  280. ></tiny-mce>
  281. </el-form-item>
  282. </el-tab-pane>
  283. <el-tab-pane label="English Information">
  284. <el-form-item label="Product name" prop="prodNameEn">
  285. <!-- :rules="[{ required: true, message: 'Product English name cannot be empty'}]" -->
  286. <el-col :span="8">
  287. <el-input
  288. v-model="prodNameEn"
  289. placeholder="Product name"
  290. maxlength="50"
  291. ></el-input>
  292. </el-col>
  293. </el-form-item>
  294. <el-form-item label="Selling point" prop="briefEn">
  295. <el-col :span="8">
  296. <el-input
  297. v-model="briefEn"
  298. type="textarea"
  299. :autosize="{ minRows: 2, maxRows: 4 }"
  300. placeholder="Selling point"
  301. ></el-input>
  302. </el-col>
  303. </el-form-item>
  304. <el-form-item label="details" prop="contentEn">
  305. <tiny-mce
  306. v-model="contentEn"
  307. ref="content"
  308. style="width: 1000px"
  309. v-if='tinymceShow'
  310. ></tiny-mce>
  311. </el-form-item>
  312. </el-tab-pane>
  313. </el-tabs>
  314. </div>
  315. <el-form-item class="submit-product">
  316. <el-button type="primary" @click="dataFormSubmit()">{{
  317. $t("crud.filter.submitBtn")
  318. }}</el-button>
  319. </el-form-item>
  320. </el-form>
  321. <!-- 品牌选择弹窗-->
  322. <brand-select
  323. v-if="brandSelectVisible"
  324. ref="brandSelect"
  325. :isSingle="true"
  326. :categoryId="dataForm.categoryId"
  327. @refreshSelectBrand="selectBrand"
  328. ></brand-select>
  329. </div>
  330. </template>
  331. <script>
  332. // import MulPicUpload from '@/components/mul-pic-upload'
  333. import ImgsUpload from '@/components/imgs-upload'
  334. import VideoUpload from '@/components/video-upload'
  335. import ProdTransport from './prod-transport'
  336. import SkuTag from './sku-tag'
  337. import SkuTable from './sku-table'
  338. import TinyMce from '@/components/tiny-mce'
  339. import BrandSelect from '@/components/brand-select'
  340. import { treeDataTranslate, idList } from '@/utils'
  341. import AddOrUpdate from './category-add-or-update'
  342. export default {
  343. data () {
  344. var validateTime = (rule, value, callback) => {
  345. if (rule.field === 'preSellTime' && new Date() > Date.parse(value)) {
  346. callback(new Error(this.$i18n.t('groups.deliveryTime')))
  347. } else {
  348. callback()
  349. }
  350. }
  351. return {
  352. // 平台分类树展示与回显
  353. category: {
  354. list: [],
  355. selected: [],
  356. props: {
  357. value: 'categoryId',
  358. label: 'categoryName',
  359. checkStrictly: false
  360. }
  361. },
  362. addOrUpdateVisible: false,
  363. dataRule: {
  364. preSellTime: [{ required: true, message: this.$i18n.t('product.thePreSaleDtBeEmpty'), trigger: 'blur' },
  365. { required: true, validator: validateTime, trigger: 'blur' }
  366. ]},
  367. // 本店分类
  368. categoryList: [],
  369. brandSelectVisible: false,
  370. tinymceShow: true,
  371. prodNameEn: '',
  372. prodNameCn: '',
  373. contentEn: '',
  374. contentCn: '',
  375. briefEn: '',
  376. briefCn: '',
  377. sameCityStatus: 0,
  378. // 规格列表
  379. dataForm: {
  380. prodNameEn: '',
  381. prodNameCn: '',
  382. contentEn: '',
  383. contentCn: '',
  384. briefEn: '',
  385. briefCn: '',
  386. video: '',
  387. seq: '',
  388. pic: '',
  389. imgs: '',
  390. preSellStatus: 0,
  391. preSellTime: null,
  392. categoryId: this.$route.query.categoryId ? parseInt(this.$route.query.categoryId) : null,
  393. shopCategoryId: null, // 店铺分类id
  394. prodId: 0,
  395. brandId: 0,
  396. skuList: [],
  397. prodLangList: [],
  398. brandName: '',
  399. deliveryMode: {
  400. hasShopDelivery: true,
  401. hasUserPickUp: false,
  402. hasCityDelivery: false
  403. },
  404. deliveryTemplateId: null,
  405. isCompose: this.$route.query.isCompose != null ? parseInt(this.$route.query.isCompose) : null
  406. },
  407. brandName: '',
  408. isSubmit: false,
  409. resourcesUrl: process.env.VUE_APP_RESOURCES_URL
  410. }
  411. },
  412. components: {
  413. ImgsUpload,
  414. BrandSelect,
  415. VideoUpload,
  416. ProdTransport,
  417. TinyMce,
  418. SkuTag,
  419. SkuTable,
  420. AddOrUpdate
  421. },
  422. computed: {
  423. defalutSku () {
  424. return this.$store.state.prod.defalutSku
  425. }
  426. },
  427. activated () {
  428. this.tinymceShow = true
  429. this.dataForm.prodId = this.$route.query.prodId
  430. this.getCategoryList()
  431. this.getCategoryTree()
  432. this.getSameCityDetail()
  433. this.getDataList()
  434. },
  435. deactivated () {
  436. this.tinymceShow = false
  437. },
  438. methods: {
  439. // 新增
  440. addOrUpdateHandle (id) {
  441. this.addOrUpdateVisible = true
  442. this.$nextTick(() => {
  443. this.$refs.addOrUpdate.init(id)
  444. })
  445. },
  446. refreshChange () {
  447. this.getCategoryList()
  448. },
  449. refreshCategoryTree () {
  450. this.getCategoryTree()
  451. },
  452. /**
  453. * 获取店铺同城配送的配置
  454. */
  455. getSameCityDetail () {
  456. this.$http({
  457. url: this.$http.adornUrl(`/delivery/sameCity/getSameCityInfo`),
  458. method: 'get',
  459. params: this.$http.adornParams()
  460. }).then(({ data }) => {
  461. if (data) {
  462. this.sameCityStatus = data.status
  463. }
  464. })
  465. },
  466. testCategory () {
  467. var categoryTest = this.categoryList
  468. // for ()
  469. for (var i = 0; i < categoryTest.length; i++) {
  470. if (categoryTest[i].status === 0) {
  471. categoryTest.splice(i, 1)
  472. }
  473. }
  474. this.categoryList = categoryTest
  475. },
  476. // 获取分类数据
  477. getDataList () {
  478. if (this.dataForm.prodId) {
  479. // 获取产品数据
  480. this.$http({
  481. url: this.$http.adornUrl(`/prod/prod/info/${this.dataForm.prodId}`),
  482. method: 'get',
  483. params: this.$http.adornParams()
  484. }).then(({ data }) => {
  485. this.dataForm = data
  486. this.dataForm.prodLangList.forEach(prodLang => {
  487. if (prodLang.lang === 0) {
  488. this.prodNameCn = prodLang.prodName
  489. this.briefCn = prodLang.brief
  490. this.contentCn = prodLang.content
  491. }
  492. if (prodLang.lang === 1) {
  493. this.prodNameEn = prodLang.prodName
  494. this.briefEn = prodLang.brief
  495. this.contentEn = prodLang.content
  496. }
  497. })
  498. this.dataForm.deliveryMode = JSON.parse(data.deliveryMode)
  499. this.dataForm.deliveryMode.hasShopDelivery = true
  500. this.category.selected = idList(this.category.list, this.dataForm.categoryId, 'categoryId', 'children').reverse()
  501. this.$refs.skuTag.init(data.skuList)
  502. if (data.brand) {
  503. this.dataForm.brandId = data.brand.brandId
  504. this.dataForm.brandName = data.brand.name
  505. this.brandName = data.brand.name
  506. }
  507. this.dataForm.skuList.forEach(sku => {
  508. sku.skuLangList.forEach(skulang => {
  509. if (skulang.lang === 0) {
  510. sku.prodNameCn = skulang.prodName
  511. } else {
  512. sku.prodNameEn = skulang.prodName
  513. }
  514. })
  515. })
  516. this.$refs.skuTable.init()
  517. this.dataForm.skuList.forEach(item => {
  518. item.changeStock = item.stocks
  519. })
  520. })
  521. } else {
  522. this.$nextTick(() => {
  523. this.$refs['dataForm'].resetFields()
  524. this.$refs.skuTag.init()
  525. this.dataForm.pic = ''
  526. this.dataForm.imgs = ''
  527. this.dataForm.video = ''
  528. })
  529. }
  530. },
  531. // 获取分类信息
  532. getCategoryList () {
  533. return this.$http({
  534. url: this.$http.adornUrl('/prod/category/listCategory'),
  535. method: 'get',
  536. params: this.$http.adornParams({
  537. status: 1
  538. })
  539. }).then(({ data }) => {
  540. console.log(data)
  541. this.categoryList = data
  542. // this.testCategory()
  543. })
  544. },
  545. // 获取分类信息
  546. getCategoryTree () {
  547. return this.$http({
  548. url: this.$http.adornUrl('/prod/category/listAvailableSigningCategory'),
  549. method: 'get',
  550. params: this.$http.adornParams({
  551. maxGrade: 2
  552. })
  553. }).then(({ data }) => {
  554. if (data && data.length) {
  555. this.$set(this.category, 'list', treeDataTranslate(data, 'categoryId', 'parentId'))
  556. this.$set(this.category, 'selected', idList(this.category.list, this.dataForm.categoryId, 'categoryId', 'children').reverse())
  557. }
  558. })
  559. },
  560. // 选择平台分类改变事件
  561. handleCategoryChange (val) {
  562. this.dataForm.categoryId = val[val.length - 1]
  563. },
  564. // 表单提交
  565. dataFormSubmit () {
  566. if (this.category.selected.length === 0) {
  567. this.errorMsg(this.$i18n.t('product.thisPlatformEmpty'))
  568. return
  569. }
  570. this.$refs['dataForm'].validate((valid) => {
  571. if (!valid) {
  572. return
  573. }
  574. if (!this.dataForm.imgs) {
  575. this.errorMsg(this.$i18n.t('product.plePictureToUpload'))
  576. return
  577. }
  578. if (!this.dataForm.deliveryMode) {
  579. this.errorMsg(this.$i18n.t('product.pleeliveryMethod'))
  580. return
  581. }
  582. if (this.dataForm.deliveryMode.hasShopDelivery && !this.dataForm.deliveryTemplateId) {
  583. this.errorMsg(this.$i18n.t('product.pleShgTlate'))
  584. return
  585. }
  586. if (!this.prodNameCn) {
  587. this.errorMsg(this.$i18n.t('product.zhpleComAndEnName'))
  588. return
  589. }
  590. if (!this.prodNameEn) {
  591. this.prodNameEn = this.prodNameCn
  592. }
  593. if (/^\s+$/g.test(this.prodNameEn)) {
  594. this.prodNameEn = this.prodNameCn
  595. }
  596. this.dataForm.prodNameCn = this.prodNameCn
  597. this.dataForm.briefCn = this.briefCn
  598. this.dataForm.prodNameEn = this.prodNameEn
  599. this.dataForm.briefEn = this.briefEn
  600. this.dataForm.prodName = this.dataForm.prodNameCn
  601. let param = Object.assign({}, this.dataForm)
  602. // 设置价格和库存
  603. let flag = this.paramSetPriceAndStocks(param)
  604. if (flag === false) {
  605. return
  606. }
  607. param.content = null
  608. param.contentCn = this.contentCn
  609. param.contentEn = this.contentEn
  610. param.prodLangList = null
  611. param.deliveryMode = undefined
  612. param.deliveryModeVo = this.dataForm.deliveryMode
  613. this.dataForm.skuList.forEach(item => {
  614. item.changeStock = item.stocks - item.changeStock
  615. })
  616. // 商品主图
  617. this.dataForm.imgs.forEach(img => {
  618. img = img.split('?')[0]
  619. })
  620. param.pic = this.dataForm.imgs.split(',')[0]
  621. if (this.isSubmit) {
  622. return false
  623. }
  624. this.isSubmit = true
  625. this.$http({
  626. url: this.$http.adornUrl(`/prod/prod`),
  627. method: param.prodId ? 'put' : 'post',
  628. data: this.$http.adornData(param)
  629. }).then(({ data }) => {
  630. this.$message({
  631. message: this.$i18n.t('publics.operation'),
  632. type: 'success',
  633. duration: 1500,
  634. onClose: () => {
  635. this.visible = false
  636. this.$store.commit('common/removeMainActiveTab')
  637. this.$router.push({ name: 'prod-prodList' })
  638. this.$emit('refreshDataList')
  639. }
  640. })
  641. }).catch((e) => {
  642. this.isSubmit = false
  643. })
  644. })
  645. },
  646. /**
  647. * 品牌删除按钮
  648. */
  649. handleClose () {
  650. // this.dataForm.brandId = null
  651. this.brandName = ''
  652. this.dataForm.brandName = this.brandName
  653. },
  654. /**
  655. * 显示添加指定品牌弹框
  656. */
  657. brandSelectHandle () {
  658. // this.brandSelectVisible = true
  659. // this.$nextTick(() => {
  660. // this.$refs.brandSelect.init()
  661. // })
  662. let brands = []
  663. brands.push({ brandId: this.dataForm.brandId })
  664. // console.log(brands)
  665. this.brandSelectVisible = true
  666. this.$nextTick(() => {
  667. this.$refs.brandSelect.init(brands)
  668. })
  669. },
  670. /**
  671. * 添加指定品牌
  672. */
  673. selectBrand (brands) {
  674. if (brands) {
  675. this.brandName = brands[0].brandName
  676. this.dataForm.brandId = brands[0].brandId
  677. this.dataForm.brandName = this.brandName
  678. }
  679. },
  680. paramSetPriceAndStocks (param) {
  681. // 获取规格属性信息
  682. // param.skuList = this.$refs.prodSpec.getTableSpecData()
  683. // 商品库存
  684. param.totalStocks = 0
  685. // 商品价格
  686. param.price = 0
  687. // 商品原价
  688. param.oriPrice = 0
  689. // 商品实际库存
  690. for (let i = 0; i < param.skuList.length; i++) {
  691. const element = param.skuList[i]
  692. // if (element.oriPrice < element.price) {
  693. // this.errorMsg(this.$i18n.t('product.priceTip'))
  694. // return false
  695. // }
  696. if (element.status !== 1) {
  697. continue
  698. }
  699. if (param.price === 0) {
  700. param.price = element.price ? Number.parseFloat(element.price) : 0
  701. }
  702. // 商品价格为最低价的那件商品的价格
  703. param.price = Math.min(param.price, element.price)
  704. if (param.price === element.price) {
  705. param.oriPrice = element.oriPrice ? Number.parseFloat(element.oriPrice) : 0
  706. }
  707. param.totalStocks += element.stocks ? Number.parseInt(element.stocks) : 0
  708. }
  709. // 如果sku没有商品名称,则使用商品的商品名称
  710. if (param.skuList.length === 1 && !param.skuList[0].skuName) {
  711. param.skuList[0].prodNameCn = this.dataForm.prodNameCn
  712. param.skuList[0].prodNameEn = this.dataForm.prodNameEn
  713. }
  714. },
  715. skuTagChangeSkuHandler (skuList) {
  716. const prodNameCn = this.prodNameCn
  717. const prodNameEn = this.prodNameEn
  718. skuList.forEach(sku => {
  719. if (sku.properties) {
  720. sku.skuName = ''
  721. sku.skuNameEn = ''
  722. let properties = sku.properties.split(';')
  723. let propertiesEn = sku.propertiesEn.split(';')
  724. for (const propertiesKey in properties) {
  725. sku.skuName += properties[propertiesKey].split(':')[1] + ' '
  726. }
  727. for (const propertiesKey in propertiesEn) {
  728. sku.skuNameEn += propertiesEn[propertiesKey].split(':')[1] + ' '
  729. }
  730. sku.prodNameCn = prodNameCn + ' ' + sku.skuName
  731. sku.prodNameEn = prodNameEn + ' ' + sku.skuNameEn
  732. }
  733. })
  734. this.dataForm.skuList = skuList
  735. },
  736. errorMsg (message) {
  737. this.$message({
  738. message: message,
  739. type: 'error',
  740. duration: 1500
  741. })
  742. },
  743. /**
  744. * 前往店铺信息
  745. */
  746. toShopInfo () {
  747. window.open('/#/shop-shopInfo?navStatus=2', '_blank')
  748. }
  749. }
  750. }
  751. </script>
  752. <style scoped>
  753. /* 每项内容的标题 */
  754. .tittle{
  755. margin: 5px 0 28px 0px;
  756. padding-left: 15px;
  757. background-color: #f6f6f6;
  758. line-height: 40px;
  759. font-weight: 800;
  760. }
  761. /* 每项内容盒子的设置 */
  762. .basic-info{
  763. margin-left: 35px;
  764. }
  765. /* 商品分类警告的下方红字 */
  766. .productCategories-error{
  767. color: red;
  768. width: 600px;
  769. }
  770. /* 图片和视频上传样式修改 */
  771. div >>> .mul-pic-upload div{
  772. color: #999;
  773. }
  774. div >>> .el-upload-list--picture-card .el-upload-list__item{
  775. border:0
  776. }
  777. div >>> .el-upload--picture-card{
  778. width: 100px;
  779. height: 100px;
  780. background: #FFFFFF;
  781. border: 1px dashed #c0ccda;
  782. }
  783. .video-k >>> .el-form-item__content{
  784. line-height: 1em;
  785. }
  786. /* .video-k >>> .el-form-item__content span{
  787. margin-top: 20px;
  788. display: inline-block;
  789. } */
  790. .video-k >>> .pic-uploader-component .el-upload{
  791. border: 0;
  792. background-color: #f6f6f6;
  793. }
  794. div >>> .el-upload--picture-card .el-icon-plus{
  795. position: relative;
  796. top: -19px;
  797. }
  798. div >>> .el-upload-list--picture-card .el-upload-list__item{
  799. width: 100px;
  800. height: 100px
  801. }
  802. .delType-text{
  803. color:#999
  804. }
  805. .basic-iny-mce >>> .el-form-item__content{
  806. margin-left: 100px !important;
  807. }
  808. .submit-product{
  809. margin-top: 20px;
  810. text-align: center;
  811. /* margin-bottom: -10px; */
  812. /* box-shadow: 0px -8px 18px -10px #999; */
  813. }
  814. .submit-product button{
  815. margin-top: 10px;
  816. margin-bottom: -20px;
  817. }
  818. .product-prodName .is-required:not(.is-no-asterisk)>.el-form-item__label:before {
  819. content: '*';
  820. color: #181515;
  821. margin-right: 4px;
  822. }
  823. </style>