createProduct.vue 15 KB

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