createProduct.vue 14 KB

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