createProduct.vue 16 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487
  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: 50px; 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 "@/views/product/module/product-info.vue";
  247. import salesInfo from "@/views/product/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. methods: {
  261. submitFormDraft() {
  262. if (this.form.categoryId?.length > 0) {
  263. this.form.categoryId =
  264. this.form.categoryId[this.form.categoryId.length - 1];
  265. }
  266. if (this.form.categoryIds.length < 1) {
  267. this.form.categoryIds = "";
  268. }
  269. if (!this.form.presaleStartTime && !this.form.presaleEndTime) {
  270. if (this.form.datePicke) {
  271. this.form.presaleStartTime = moment(
  272. this.form.datePicker[0]
  273. ).valueOf();
  274. this.form.presaleEndTime = moment(this.form.datePicker[1]).valueOf();
  275. }
  276. }
  277. // if (this.form.bannerList?.length > 0) {
  278. // this.form.bannerList.shift();
  279. // }
  280. if (this.form.saleModel == 2) {
  281. this.form.merchantClassifyId = "[217527]";
  282. this.form.merchantClassifyName = "集采预售";
  283. } else if (this.form.saleModel == 3) {
  284. this.form.merchantClassifyId = "[217526]";
  285. this.form.merchantClassifyName = "团批秒杀";
  286. } else if (this.form.saleModel == 4) {
  287. this.form.merchantClassifyId = "[217528]";
  288. this.form.merchantClassifyName = "清库专区";
  289. } else if (this.form.saleModel == 5) {
  290. this.form.merchantClassifyId = "[217525]";
  291. this.form.merchantClassifyName = "新店福利";
  292. }
  293. saveGoodsDraft(this.form).then((res) => {
  294. if (res.code == 200) {
  295. this.$message.success(`发布成功!请前往草稿箱查看`);
  296. this.$store.dispatch("tagsView/delView", this.$route); //关闭当前页
  297. this.$router.replace({ path: "/product/shipping/index" });
  298. }
  299. });
  300. },
  301. submitCancel() {
  302. this.$confirm("是否取消发布,所填写的信息将会消失?", "提示", {
  303. confirmButtonText: "确定",
  304. cancelButtonText: "取消",
  305. type: "warning",
  306. })
  307. .then(() => {
  308. this.$store.dispatch("tagsView/delView", this.$route); //关闭当前页
  309. this.$router.replace({ path: "/product/shipping/index" });
  310. })
  311. .catch(() => {
  312. this.$message({
  313. type: "info",
  314. message: "已取消",
  315. });
  316. });
  317. },
  318. async submitForm() {
  319. let bool = false;
  320. queryUserRelevanceTemplate().then((res) => {
  321. if (res.code == 200) {
  322. if (res.data) {
  323. bool = res.data;
  324. }
  325. }
  326. });
  327. if (bool) {
  328. this.$message.error(
  329. "您未设置同城运费规则,请先暂存草稿箱,待设置同城运费规则后再次进行发布!"
  330. );
  331. return;
  332. }
  333. let basic = await this.$refs.basicRefs.formvalidate();
  334. if (basic) {
  335. let sales = await this.$refs.salesRefs.formvalidate();
  336. if (sales) {
  337. let product = await this.$refs.productRefs.formvalidate();
  338. if (!product) {
  339. return;
  340. }
  341. } else {
  342. return;
  343. }
  344. } else {
  345. return;
  346. }
  347. if (this.form.skuList.length < 1 || this.form.skuList === "") {
  348. this.$message.error(`商品规格不能为空`);
  349. return;
  350. }
  351. if (!this.form.shippingAddrBean.provinceCode) {
  352. this.$message.error(`请点击选择地址,选择发货地址的省市区!`);
  353. return;
  354. }
  355. if (this.form.categoryId?.length > 0) {
  356. this.form.categoryId =
  357. this.form.categoryId[this.form.categoryId.length - 1];
  358. }
  359. if (!this.form.presaleStartTime && !this.form.presaleEndTime) {
  360. if (this.form.datePicke) {
  361. this.form.presaleStartTime = moment(
  362. this.form.datePicker[0]
  363. ).valueOf();
  364. this.form.presaleEndTime = moment(this.form.datePicker[1]).valueOf();
  365. }
  366. }
  367. if (this.form.saleModel == 2) {
  368. this.form.merchantClassifyId = "[217527]";
  369. this.form.merchantClassifyName = "集采预售";
  370. } else if (this.form.saleModel == 3) {
  371. this.form.merchantClassifyId = "[217526]";
  372. this.form.merchantClassifyName = "团批秒杀";
  373. } else if (this.form.saleModel == 4) {
  374. this.form.merchantClassifyId = "[217528]";
  375. this.form.merchantClassifyName = "清库专区";
  376. } else if (this.form.saleModel == 5) {
  377. this.form.merchantClassifyId = "[217525]";
  378. this.form.merchantClassifyName = "新店福利";
  379. }
  380. this.btnLading = true;
  381. publishGoods(this.form).then((res) => {
  382. if (res.code == 200) {
  383. this.btnLading = false;
  384. this.$message.success(`发布成功!`);
  385. this.$store.dispatch("tagsView/delView", this.$route); //关闭当前页
  386. this.$router.replace({ path: "/product/shipping/index" });
  387. } else {
  388. this.btnLading = false;
  389. }
  390. });
  391. },
  392. updateValue(val) {
  393. this.form = { ...this.form, ...val };
  394. console.log(this.form);
  395. this.headerImg = [];
  396. if (val.vid || this.form.vid) {
  397. this.headerImg.push({
  398. type: "video",
  399. src: val.vid ? val.vid : this.form.vid,
  400. sort: 1,
  401. });
  402. }
  403. if (this.form?.bannerList && this.form?.bannerList.length > 0) {
  404. this.form.bannerList.forEach((e, index) => {
  405. this.headerImg.push({
  406. type: "img",
  407. src: e.fileUrl,
  408. sort: index + 4,
  409. });
  410. });
  411. }
  412. this.headerImg.sort((a, b) => a.sort - b.sort); //排序 视频在最前面>封面>商品banner
  413. },
  414. unique(arr) {
  415. const res = new Map();
  416. return arr.filter((arr) => !res.has(arr.src) && res.set(arr.src, 1));
  417. },
  418. },
  419. };
  420. </script>
  421. <style>
  422. .required {
  423. color: red;
  424. }
  425. .el-upload-list__item {
  426. width: 60px !important;
  427. height: 60px !important;
  428. }
  429. .el-upload--picture-card {
  430. width: 80px;
  431. height: 80px;
  432. display: flex;
  433. flex-direction: row;
  434. justify-content: center;
  435. align-items: center;
  436. }
  437. .tips {
  438. font-size: 12px;
  439. color: red;
  440. }
  441. </style>
  442. <style scoped>
  443. .card {
  444. /* height: 85px; */
  445. width: 95%;
  446. background: white;
  447. margin: auto;
  448. border-radius: 10px;
  449. line-height: 30px;
  450. padding: 10px;
  451. }
  452. .spuName {
  453. text-decoration: none;
  454. font-weight: bold;
  455. word-wrap: normal;
  456. font-size: 18px;
  457. color: #333333;
  458. }
  459. .price_group {
  460. color: #ff2f2f;
  461. }
  462. .price {
  463. text-decoration: none;
  464. font-weight: bold;
  465. word-wrap: normal;
  466. font-size: 25px;
  467. color: #ff2f2f;
  468. }
  469. .price_info {
  470. display: flex;
  471. flex-direction: row;
  472. justify-content: space-between;
  473. align-items: center;
  474. }
  475. .ys {
  476. font-size: 14px;
  477. }
  478. </style>