createProduct.vue 16 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505
  1. <template>
  2. <div class="app-container">
  3. <div style="width: 100%; height: 85vh; overflow: auto">
  4. <el-row style="padding-top: 20px">
  5. <el-col :span="24">
  6. <el-descriptions title="基本信息" column="1"> </el-descriptions>
  7. <basicInfo @updateValue="updateValue" ref="basicRefs"></basicInfo>
  8. <el-descriptions title="销售信息" column="1"> </el-descriptions>
  9. <salesInfo
  10. @updateValue="updateValue"
  11. ref="salesRefs"
  12. :saleType="form.saleType"
  13. :saleModels="form.saleModel"
  14. ></salesInfo>
  15. <el-descriptions title="商品详情" column="1"> </el-descriptions>
  16. <productInfo
  17. @updateValue="updateValue"
  18. ref="productRefs"
  19. ></productInfo>
  20. <div class="dialog-footer" style="text-align: center">
  21. <el-button @click="submitCancel">取 消</el-button>
  22. <el-button type="primary" @click="submitForm" :loading="btnLading"
  23. >发 布</el-button
  24. >
  25. <el-button type="primary" @click="submitFormDraft"
  26. >存入草稿箱</el-button
  27. >
  28. </div>
  29. </el-col>
  30. <phoneView style="position: absolute; bottom: -80px; right: 50px">
  31. <div slot="conts">
  32. <div>
  33. <el-carousel height="200px">
  34. <el-carousel-item
  35. v-for="(item, index) in headerImg.slice(1)"
  36. :key="index"
  37. >
  38. <el-image
  39. v-if="item.type == 'img'"
  40. style="width: 100%; height: 200px"
  41. :src="item.src"
  42. :preview-src-list="[item.src]"
  43. >
  44. </el-image>
  45. <video
  46. v-if="item.type == 'video'"
  47. :key="index"
  48. controls
  49. :src="item.src"
  50. style="width: 100%; height: 200px"
  51. ></video>
  52. </el-carousel-item>
  53. </el-carousel>
  54. </div>
  55. <img
  56. style="width: 100%"
  57. src="https://bucket.sxdirectpurchase.com/fileUpload/test/47fc6132-0b3e-4b5c-b858-f78d363eba90.png"
  58. alt=""
  59. />
  60. <div class="card">
  61. <div class="spuName">{{ form ? form.title : "" }}</div>
  62. <div class="price_info">
  63. <div class="price_group">
  64. <span>¥</span>
  65. <span
  66. class="price"
  67. :key="item"
  68. v-for="item in form.skuList ? form.skuList.slice(0, 1) : []"
  69. >{{
  70. item.skuPriceList ? item.skuPriceList[0].price : 0
  71. }}元</span
  72. >
  73. <span>/{{ form.unit }}</span>
  74. </div>
  75. <span class="ys">已售 0</span>
  76. </div>
  77. </div>
  78. <div class="card" style="margin-top: 10px">
  79. <div class="spuName">规格/价格</div>
  80. <div v-for="(item, index) in form.skuList" :key="index">
  81. <div class="price_info">
  82. <span
  83. >{{
  84. item.skuSpecsList[0] ? item.skuSpecsList[0].specsName : ""
  85. }}
  86. {{
  87. item.skuSpecsList[0].specsValue
  88. ? item.skuSpecsList[0].specsValue
  89. : ""
  90. }}</span
  91. >
  92. </div>
  93. <div
  94. style="
  95. display: flex;
  96. flex-direction: row;
  97. justify-content: space-between;
  98. "
  99. >
  100. <span style="font-size: 14px; color: red">
  101. <span>¥</span>
  102. <span
  103. >{{
  104. item.skuPriceList
  105. ? item.skuPriceList[0].price
  106. ? item.skuPriceList[0].price
  107. : ""
  108. : ""
  109. }}元</span
  110. ><span>/{{ form.unit }}</span></span
  111. >
  112. <span style="font-size: 14px"
  113. >{{
  114. item.skuPriceList
  115. ? item.skuPriceList[0].minPurchase
  116. ? item.skuPriceList[0].minPurchase
  117. : ""
  118. : ""
  119. }}/{{ form.unit }}起购</span
  120. >
  121. <span style="font-size: 14px"
  122. >库存:{{ item.stock + item.predictStocks
  123. }}{{ form.unit }}</span
  124. >
  125. </div>
  126. </div>
  127. </div>
  128. <div class="card" style="margin-top: 10px">
  129. <el-form
  130. :model="form"
  131. ref="queryForm"
  132. size="small"
  133. :inline="true"
  134. label-width="80px"
  135. label-position="left"
  136. >
  137. <el-row>
  138. <el-col :span="24">
  139. <el-form-item label="发货地" prop="spuName">
  140. <div style="width: 185px">
  141. {{
  142. form.shippingAddrBean
  143. ? form.shippingAddrBean.addr
  144. : ""
  145. }}
  146. {{
  147. form.shippingAddrBean
  148. ? form.shippingAddrBean.addrDetail
  149. ? form.shippingAddrBean.addrDetail
  150. : ""
  151. : ""
  152. }}
  153. </div>
  154. </el-form-item>
  155. </el-col>
  156. <el-col :span="24">
  157. <el-form-item label="发货时间" prop="spuName">
  158. {{ form.shippingTimeDesc }}
  159. </el-form-item>
  160. </el-col>
  161. <el-col :span="24">
  162. <el-form-item label="商品属性" prop="spuName">
  163. <div>查看></div>
  164. </el-form-item>
  165. </el-col>
  166. <el-col :span="24">
  167. <el-form-item label="包装方式" prop="spuName">
  168. {{ form.packing }}
  169. </el-form-item>
  170. </el-col>
  171. </el-row>
  172. </el-form>
  173. </div>
  174. <div class="card" style="margin-top: 10px">
  175. <div
  176. style="
  177. display: flex;
  178. flex-direction: row;
  179. justify-content: space-between;
  180. align-items: center;
  181. "
  182. >
  183. <span class="spuName">商品评价</span>
  184. <span>好评率 <span style="color: red">100%</span></span>
  185. </div>
  186. <div
  187. style="
  188. display: flex;
  189. flex-direction: column;
  190. justify-content: center;
  191. align-items: center;
  192. "
  193. >
  194. <img
  195. style="width: 40%"
  196. src="https://directpurchase-oss-dev.oss-cn-chengdu.aliyuncs.com/wx/static/images/kong.png"
  197. alt=""
  198. />
  199. <span>还没有评价~</span>
  200. </div>
  201. </div>
  202. <div class="card" style="margin-top: 10px">
  203. <div class="spuName">商品介绍</div>
  204. <div style="font-size: 14px; line-height: 25px">
  205. {{ form.spuDesc }}
  206. </div>
  207. </div>
  208. <div class="card" style="margin-top: 10px">
  209. <div class="spuName">商品详情</div>
  210. <div style="font-size: 14px; line-height: 25px">
  211. <el-image
  212. v-for="(item, index) in form.spuDetailList"
  213. :key="index"
  214. :src="item.fileUrl"
  215. fit="fill"
  216. :preview-src-list="[item.fileUrl]"
  217. >
  218. </el-image>
  219. </div>
  220. <div style="font-size: 14px; line-height: 25px">
  221. <el-image
  222. v-for="(item, index) in form.specialList"
  223. :key="index"
  224. :src="item.fileUrl"
  225. fit="fill"
  226. :preview-src-list="[item.fileUrl]"
  227. >
  228. </el-image>
  229. </div>
  230. </div>
  231. </div>
  232. </phoneView>
  233. </el-row>
  234. </div>
  235. <Amap></Amap>
  236. </div>
  237. </template>
  238. <script>
  239. import { getStoreInfo } from "@/api/common/index";
  240. import { publishGoods } from "@/api/publish/index";
  241. import {
  242. saveGoodsDraft,
  243. queryUserRelevanceTemplate,
  244. } from "@/api/manage/product";
  245. import basicInfo from "./module/basic-info.vue";
  246. import productInfo from "./module/product-info.vue";
  247. import salesInfo from "./module/sales-info.vue";
  248. import phoneView from "@/components/phoneView/index.vue";
  249. import Amap from "@/components/Map/map.vue";
  250. import moment from "moment";
  251. export default {
  252. components: { Amap, phoneView, basicInfo, salesInfo, productInfo },
  253. data() {
  254. return {
  255. form: {},
  256. headerImg: [],
  257. btnLading: false,
  258. };
  259. },
  260. mounted() {
  261. this.getInfo();
  262. },
  263. methods: {
  264. getInfo() {
  265. getStoreInfo().then((res) => {
  266. if (res.code == 200) {
  267. if (res.data.scope == 0) {
  268. if (this.form.saleType == 2) {
  269. this.$refs.salesRefs.setShowCom(true);
  270. } else {
  271. this.$refs.salesRefs.setShowCom(false);
  272. }
  273. } else {
  274. this.$refs.salesRefs.setShowCom(true);
  275. }
  276. }
  277. });
  278. },
  279. submitFormDraft() {
  280. if (this.form.categoryId?.length > 0) {
  281. this.form.categoryId =
  282. this.form.categoryId[this.form.categoryId.length - 1];
  283. }
  284. if (this.form.categoryIds.length < 1) {
  285. this.form.categoryIds = "";
  286. }
  287. if (!this.form.presaleStartTime && !this.form.presaleEndTime) {
  288. if (this.form.datePicke) {
  289. this.form.presaleStartTime = moment(
  290. this.form.datePicker[0]
  291. ).valueOf();
  292. this.form.presaleEndTime = moment(this.form.datePicker[1]).valueOf();
  293. }
  294. }
  295. if (this.form.saleModel == 2) {
  296. this.form.merchantClassifyId = "[217524]";
  297. this.form.merchantClassifyName = "预售专区";
  298. } else if (this.form.saleModel == 3) {
  299. this.form.merchantClassifyId = "[217522]";
  300. this.form.merchantClassifyName = "团购秒杀";
  301. } else if (this.form.saleModel == 4) {
  302. this.form.merchantClassifyId = "[217523]";
  303. this.form.merchantClassifyName = "特价卖场";
  304. } else if (this.form.saleModel == 5) {
  305. this.form.merchantClassifyId = "[217521]";
  306. this.form.merchantClassifyName = "新人福利";
  307. }
  308. saveGoodsDraft(this.form).then((res) => {
  309. if (res.code == 200) {
  310. this.$message.success(`发布成功!请前往草稿箱查看`);
  311. this.$store.dispatch("tagsView/delView", this.$route); //关闭当前页
  312. this.$router.replace({ path: "/product/transmission/index" });
  313. }
  314. });
  315. },
  316. submitCancel() {
  317. this.$confirm("是否取消发布,所填写的信息将会消失?", "提示", {
  318. confirmButtonText: "确定",
  319. cancelButtonText: "取消",
  320. type: "warning",
  321. })
  322. .then(() => {
  323. this.$store.dispatch("tagsView/delView", this.$route); //关闭当前页
  324. this.$router.replace({ path: "/product/transmission/index" });
  325. })
  326. .catch(() => {
  327. this.$message({
  328. type: "info",
  329. message: "已取消删除",
  330. });
  331. });
  332. },
  333. async submitForm() {
  334. let bool = false;
  335. queryUserRelevanceTemplate().then((res) => {
  336. if (res.code == 200) {
  337. if (res.data) {
  338. bool = res.data;
  339. }
  340. }
  341. });
  342. if (bool) {
  343. this.$message.error(
  344. "您未设置同城运费规则,请先暂存草稿箱,待设置同城运费规则后再次进行发布!"
  345. );
  346. return;
  347. }
  348. let basic = await this.$refs.basicRefs.formvalidate();
  349. if (basic) {
  350. let sales = await this.$refs.salesRefs.formvalidate();
  351. if (sales) {
  352. let product = await this.$refs.productRefs.formvalidate();
  353. if (!product) {
  354. return;
  355. }
  356. } else {
  357. return;
  358. }
  359. } else {
  360. return;
  361. }
  362. if (this.form.skuList.length < 1 || this.form.skuList === "") {
  363. this.$message.error(`商品规格不能为空`);
  364. return;
  365. }
  366. if (this.form.categoryId?.length > 0) {
  367. this.form.categoryId =
  368. this.form.categoryId[this.form.categoryId.length - 1];
  369. }
  370. if (!this.form.presaleStartTime && !this.form.presaleEndTime) {
  371. if (this.form.datePicke) {
  372. this.form.presaleStartTime = moment(
  373. this.form.datePicker[0]
  374. ).valueOf();
  375. this.form.presaleEndTime = moment(this.form.datePicker[1]).valueOf();
  376. }
  377. }
  378. if (this.form.saleModel == 2) {
  379. this.form.merchantClassifyId = "[217524]";
  380. this.form.merchantClassifyName = "预售专区";
  381. } else if (this.form.saleModel == 3) {
  382. this.form.merchantClassifyId = "[217522]";
  383. this.form.merchantClassifyName = "团购秒杀";
  384. } else if (this.form.saleModel == 4) {
  385. this.form.merchantClassifyId = "[217523]";
  386. this.form.merchantClassifyName = "特价卖场";
  387. } else if (this.form.saleModel == 5) {
  388. this.form.merchantClassifyId = "[217521]";
  389. this.form.merchantClassifyName = "新人福利";
  390. }
  391. this.btnLading = true;
  392. publishGoods(this.form).then((res) => {
  393. if (res.code == 200) {
  394. this.btnLading = false;
  395. this.$message.success(`发布成功!`);
  396. this.$store.dispatch("tagsView/delView", this.$route); //关闭当前页
  397. this.$router.replace({ path: "/product/transmission/index" });
  398. } else {
  399. this.btnLading = false;
  400. }
  401. });
  402. },
  403. updateValue(val) {
  404. this.form = { ...this.form, ...val };
  405. if (this.form.saleType == 2) {
  406. this.$refs.salesRefs.setShowCom(true);
  407. } else if (this.form.scope == 0) {
  408. this.$refs.salesRefs.setShowCom(false);
  409. } else {
  410. this.$refs.salesRefs.setShowCom(true);
  411. }
  412. this.headerImg = [];
  413. if (val.vid || this.form.vid) {
  414. this.headerImg.push({
  415. type: "video",
  416. src: val.vid ? val.vid : this.form.vid,
  417. sort: 1,
  418. });
  419. }
  420. if (this.form?.bannerList && this.form?.bannerList.length > 0) {
  421. this.form.bannerList.forEach((e, index) => {
  422. this.headerImg.push({
  423. type: "img",
  424. src: e.fileUrl,
  425. sort: index + 4,
  426. });
  427. });
  428. }
  429. this.headerImg.sort((a, b) => a.sort - b.sort); //排序 视频在最前面>封面>商品banner
  430. },
  431. unique(arr) {
  432. const res = new Map();
  433. return arr.filter((arr) => !res.has(arr.src) && res.set(arr.src, 1));
  434. },
  435. },
  436. };
  437. </script>
  438. <style>
  439. .required {
  440. color: red;
  441. }
  442. .el-upload-list__item {
  443. width: 60px !important;
  444. height: 60px !important;
  445. }
  446. .el-upload--picture-card {
  447. width: 80px;
  448. height: 80px;
  449. display: flex;
  450. flex-direction: row;
  451. justify-content: center;
  452. align-items: center;
  453. }
  454. .tips {
  455. font-size: 12px;
  456. color: red;
  457. }
  458. </style>
  459. <style scoped>
  460. .card {
  461. /* height: 85px; */
  462. width: 95%;
  463. background: white;
  464. margin: auto;
  465. border-radius: 10px;
  466. line-height: 30px;
  467. padding: 10px;
  468. }
  469. .spuName {
  470. text-decoration: none;
  471. font-weight: bold;
  472. word-wrap: normal;
  473. font-size: 18px;
  474. color: #333333;
  475. }
  476. .price_group {
  477. color: #ff2f2f;
  478. }
  479. .price {
  480. text-decoration: none;
  481. font-weight: bold;
  482. word-wrap: normal;
  483. font-size: 25px;
  484. color: #ff2f2f;
  485. }
  486. .price_info {
  487. display: flex;
  488. flex-direction: row;
  489. justify-content: space-between;
  490. align-items: center;
  491. }
  492. .ys {
  493. font-size: 14px;
  494. }
  495. </style>