goodsDetail.vue 30 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886887888889890891892893894895896897898899900901902903904905906907908909910911912913914915916917918919920921922923924925926927928929930931932933934935936937938939940941942943944945946947948949950951952953954955
  1. <!--
  2. * @Author: wj 1454560336@qq.com
  3. * @Date: 2023-11-24 14:39:54
  4. * @LastEditors: wenjie 1454560336@qq.com
  5. * @LastEditTime: 2024-12-02 09:11:47
  6. * @FilePath: \admin-manage\src\views\operationManage\goodsManage\goodsDetail.vue
  7. * @Description:
  8. *
  9. * Copyright (c) 2023 by ${git_name_email}, All Rights Reserved.
  10. -->
  11. <template>
  12. <div class="addGoods app-container">
  13. <el-form
  14. :model="setQuery"
  15. :rules="rules"
  16. v-loading="loading"
  17. label-width="170px"
  18. disabled
  19. >
  20. <el-tabs v-model="activeName">
  21. <el-tab-pane label="基本信息" name="基本信息">
  22. <el-form-item label="商品类型:" prop="goodsType">
  23. <el-select
  24. v-model="setQuery.goodsType"
  25. class="item-width-300"
  26. placeholder="请选择商品类型"
  27. >
  28. <el-option
  29. v-for="item in options"
  30. :key="item.value"
  31. :label="item.label"
  32. :value="item.value"
  33. >
  34. </el-option>
  35. </el-select>
  36. </el-form-item>
  37. <el-form-item label="商品名称:" prop="goodsName">
  38. <el-input
  39. v-model="setQuery.goodsName"
  40. class="item-width-300"
  41. ></el-input>
  42. </el-form-item>
  43. <el-form-item label="商品描述:" prop="goodsDescribe">
  44. <el-input
  45. v-model="setQuery.goodsDescribe"
  46. class="item-width-300"
  47. ></el-input>
  48. </el-form-item>
  49. <el-form-item label="商品分类:" prop="goodsCateId">
  50. <el-cascader
  51. class="item-width-300"
  52. v-model="setQuery.goodsCateId"
  53. :show-all-levels="false"
  54. placeholder=""
  55. :options="typeOptions"
  56. :props="{ value: 'id', label: 'cateName', children: 'child', emitPath: false }"
  57. ></el-cascader>
  58. </el-form-item>
  59. <el-form-item label="市场价:" prop="marketPrice">
  60. <el-input
  61. type="number"
  62. v-model="setQuery.marketPrice"
  63. class="item-width-300"
  64. >
  65. <template slot="append">元</template>
  66. </el-input>
  67. </el-form-item>
  68. <!-- <template v-if="setQuery.prePlatformType && mode=='audit'"> -->
  69. <template v-if="setQuery.prices">
  70. <el-form-item label="商品操作平台商品信息:">
  71. <div class="platformType">{{filterMasterName(filterCurrentData().platformType)}}</div>
  72. <!-- <div class="platformType">{{filterCurrentData()}}</div> -->
  73. </el-form-item>
  74. <el-form-item label="售价:" prop="platformPrice">
  75. <el-input
  76. type="number"
  77. v-model="filterCurrentData().price"
  78. class="item-width-300"
  79. >
  80. <template slot="append">元</template>
  81. </el-input>
  82. </el-form-item>
  83. </template>
  84. <!-- <el-form-item v-if="setQuery.prePlatformType && mode=='detail'" label="商品操作平台商品信息:">
  85. <el-checkbox-group v-model="setQuery.platformType" prop="platformType">
  86. <div class="flex" v-for="(item,index) in setQuery.prices" :key="index" ><el-checkbox :label="item.platformType">{{filterMasterName(item.platformType) }}</el-checkbox>
  87. <el-form-item >
  88. <el-input type="number" v-model="setQuery.prices[index].price" class="item-width-300 ml10">
  89. <template slot="append">元</template>
  90. </el-input>
  91. </el-form-item>
  92. </div>
  93. </el-checkbox-group>
  94. </el-form-item> -->
  95. <el-form-item label="售价:" v-else prop="realPrice">
  96. <el-input
  97. type="number"
  98. v-model="setQuery.realPrice"
  99. class="item-width-300"
  100. >
  101. <template slot="append">元</template>
  102. </el-input>
  103. </el-form-item>
  104. <el-form-item label="库存:" prop="stockNum">
  105. <el-input
  106. type="number"
  107. v-model.number="setQuery.realStockNum"
  108. class="item-width-300"
  109. >
  110. </el-input>
  111. </el-form-item>
  112. <el-form-item label="排序:" prop="goodsSort">
  113. <el-input
  114. type="number"
  115. v-model.number="setQuery.goodsSort"
  116. class="item-width-300"
  117. >
  118. </el-input>
  119. </el-form-item>
  120. <el-form-item label="商品图片:" prop="goodsPath">
  121. <Upload
  122. width="100px"
  123. height="100px"
  124. type="goodsPath"
  125. :imgUrl="setQuery.goodsPath"
  126. @uploadEnd="uploadEnd"
  127. ></Upload>
  128. </el-form-item>
  129. <!-- <el-form-item label="退款服务:">
  130. <el-radio-group v-model="setQuery.refundType">
  131. <el-radio :label="1">自动退款</el-radio>
  132. <el-radio :label="3">人工审核退款</el-radio>
  133. <el-radio :label="2">不支持退款</el-radio>
  134. </el-radio-group>
  135. </el-form-item> -->
  136. </el-tab-pane>
  137. <el-tab-pane label="商品规格" name="商品规格">
  138. <el-form-item :label="item.attrName == 'validDay'?'有效期': item.attrName" v-for="(item, index) in setQuery.attrs" :key="'attrs' + index" :prop="'attrs.' + index + '.attrValue'" >
  139. <el-input
  140. v-if="item.attrName == 'validDay'"
  141. placeholder="有效期不能超过90天"
  142. v-model="item.attrValue"
  143. class="item-width-300 ml20 "
  144. >
  145. </el-input>
  146. <el-input
  147. v-else
  148. placeholder="请输入属性名称,多行用回车换行"
  149. type="textarea"
  150. v-model="item.attrValue"
  151. :maxlength="500"
  152. class="item-width-300 ml20 textarea"
  153. >
  154. </el-input>
  155. <el-checkbox
  156. class="ml20"
  157. v-model="item.status"
  158. :true-label="1"
  159. :false-label="2"
  160. v-if="index>1 "
  161. ></el-checkbox>
  162. </el-form-item>
  163. <!-- <el-form-item label="商品属性:">
  164. <div
  165. class="item"
  166. v-for="(item, index) in setQuery.attrs"
  167. :key="'attrs' + index"
  168. >
  169. <el-input
  170. placeholder="请输入属性名称"
  171. v-model="item.attrName"
  172. class="item-width-150"
  173. >
  174. </el-input>
  175. <el-input
  176. placeholder="请输入属性名称,多行用回车换行"
  177. type="textarea"
  178. v-model="item.attrValue"
  179. class="item-width-300 ml20 textarea"
  180. >
  181. </el-input>
  182. <el-checkbox
  183. class="ml20"
  184. v-model="item.status"
  185. :true-label="1"
  186. :false-label="2"
  187. ></el-checkbox>
  188. <i class="icon el-icon-plus"></i>
  189. <i class="icon el-icon-minus"></i>
  190. </div>
  191. </el-form-item> -->
  192. <el-form-item label="商品规格:">
  193. <div
  194. class="item"
  195. v-for="(item, index) in setQuery.specs"
  196. :key="'specs' + index"
  197. >
  198. <el-input
  199. placeholder="请输入属性名称"
  200. v-model="item.specName"
  201. class="item-width-150"
  202. >
  203. </el-input>
  204. <div class="box">
  205. <div class="" v-for="(i, d) in setQuery.specs[index].specValues" :key="d">
  206. <el-input
  207. placeholder="请输入属性名称"
  208. v-model="i.specValue"
  209. class="item-width-300 ml20"
  210. >
  211. </el-input>
  212. <el-checkbox
  213. class="ml20"
  214. v-model="i.status"
  215. :true-label="1"
  216. :false-label="2"
  217. ></el-checkbox>
  218. <el-button class="add1" type="text"
  219. >+添加属性</el-button
  220. >
  221. <el-button class="add1 red" type="text"
  222. >-删除属性</el-button
  223. >
  224. </div>
  225. </div>
  226. <i
  227. class="add icon el-icon-plus"
  228. ></i>
  229. <i
  230. class="remove icon el-icon-minus"
  231. ></i>
  232. </div>
  233. </el-form-item>
  234. </el-tab-pane>
  235. <el-tab-pane label="商品详情" name="商品详情">
  236. <el-form-item label="商品详情:" prop="goodsDetail">
  237. <!-- <div style="border: 1px solid #ccc; width: 500px">
  238. <Toolbar
  239. style="border-bottom: 1px solid #ccc"
  240. :editor="editor"
  241. :defaultConfig="toolbarConfig"
  242. :mode="editorMode"
  243. />
  244. <Editor
  245. style="height: 500px; overflow-y: hidden"
  246. v-model="setQuery.goodsDetail"
  247. :defaultConfig="editorConfig"
  248. :mode="editorMode"
  249. @onCreated="onCreated"
  250. />
  251. </div> -->
  252. <div style="border: 1px solid #ccc; width: 800px;border-radius:4px;padding:0 15px;min-height:60px;" v-html="setQuery.goodsDetail">
  253. </div>
  254. </el-form-item>
  255. </el-tab-pane>
  256. <el-tab-pane label="其他信息" name="其他信息">
  257. <el-form-item label="销量:" prop="saleNum">
  258. <el-input
  259. type="number"
  260. v-model.number="setQuery.saleNum"
  261. class="item-width-300"
  262. >
  263. </el-input>
  264. </el-form-item>
  265. <!-- <el-form-item label="库存预警:" prop="stockThresholdNum">
  266. <el-input
  267. type="number"
  268. v-model.number="setQuery.stockThresholdNum"
  269. class="item-width-300"
  270. >
  271. </el-input>
  272. </el-form-item> -->
  273. </el-tab-pane>
  274. <el-tab-pane v-if="$route.query.mode != 'detail'" label="商品配置" name="商品配置">
  275. <el-form
  276. :model="setQuery"
  277. ref="setQuery"
  278. :rules="rules"
  279. v-loading="loading"
  280. label-width="170px"
  281. >
  282. <!-- <el-form-item label="商品税费:" prop="taxRate">
  283. <el-input
  284. type="number"
  285. :disabled="false"
  286. v-model.number="setQuery.taxRate"
  287. class="item-width-300"
  288. >
  289. <template slot="append">%</template>
  290. </el-input>
  291. </el-form-item>
  292. <el-form-item label="提现手续费:" prop="withdrawalRate">
  293. <el-input
  294. type="number"
  295. v-model.number="setQuery.withdrawalRate"
  296. class="item-width-300"
  297. >
  298. <template slot="append">‰</template>
  299. </el-input>
  300. </el-form-item>
  301. <el-form-item label="商品购买设置:">
  302. <el-table
  303. :data="setQuery.goodsSets"
  304. tooltip-effect="dark"
  305. border
  306. style="width: 600px"
  307. >
  308. <el-table-column
  309. align="center"
  310. label="人员类型"
  311. prop="setMealId"
  312. show-overflow-tooltip
  313. >
  314. <template slot-scope="scope">
  315. {{ scope.row.setMealId | filterMeal(that) }}
  316. </template>
  317. </el-table-column>
  318. <el-table-column
  319. prop="shopName"
  320. align="center"
  321. label="购买设置"
  322. show-overflow-tooltip
  323. >
  324. <template slot-scope="scope">
  325. <el-checkbox
  326. :true-label="2"
  327. :false-label="1"
  328. v-model="scope.row.buySet"
  329. >限制购买</el-checkbox
  330. >
  331. </template>
  332. </el-table-column>
  333. <el-table-column
  334. prop="shopName"
  335. align="center"
  336. label="限购数量"
  337. show-overflow-tooltip
  338. >
  339. <template slot-scope="scope">
  340. <el-input
  341. v-model="scope.row.buyNum"
  342. :maxlength="8"
  343. size="small"
  344. class="item-width-100"
  345. >
  346. </el-input>
  347. </template>
  348. </el-table-column>
  349. <el-table-column
  350. prop="shopName"
  351. align="center"
  352. label="优惠价格"
  353. show-overflow-tooltip
  354. >
  355. <template slot-scope="scope">
  356. <el-input
  357. v-model="scope.row.buyPrice"
  358. :maxlength="8"
  359. size="small"
  360. class="item-width-100"
  361. >
  362. </el-input>
  363. </template>
  364. </el-table-column>
  365. </el-table>
  366. </el-form-item> -->
  367. <el-form-item label="分账规则:" prop="shareId">
  368. <el-select
  369. v-model="setQuery.shareId"
  370. class="item-width-300"
  371. placeholder="请选择分账规则"
  372. >
  373. <el-option
  374. v-for="item in ruleOptions"
  375. :key="item.value"
  376. :label="item.label"
  377. :value="item.value"
  378. >
  379. </el-option>
  380. </el-select>
  381. </el-form-item>
  382. <template v-if="mode == 'audit'">
  383. <el-form-item label="价格标签:">
  384. <el-radio-group v-model="showGoodsLabel">
  385. <el-radio :label="1">展示标签</el-radio>
  386. <el-radio :label="2">不展示标签</el-radio>
  387. </el-radio-group>
  388. <div v-if="showGoodsLabel == 1">
  389. <el-radio-group v-model="labelId">
  390. <el-radio v-for="item in labelList" :key="item.id" :label="item.id">{{item.labelName}}</el-radio>
  391. </el-radio-group>
  392. </div>
  393. </el-form-item>
  394. </template>
  395. <el-form-item v-if="mode == 'audit'" label="审核意见:" prop="checkDetail">
  396. <el-input
  397. type="textarea"
  398. placeholder="请输入审核意见"
  399. v-model="setQuery.checkDetail"
  400. maxlength="400"
  401. :rows="6"
  402. class="item-width-500"
  403. show-word-limit
  404. >
  405. </el-input>
  406. </el-form-item>
  407. </el-form>
  408. </el-tab-pane>
  409. </el-tabs>
  410. </el-form>
  411. <div class="btn-group" v-if="mode == 'audit'">
  412. <el-button type="danger" :loading="loading" @click="save(3)">拒 绝</el-button>
  413. <el-button type="primary" :loading="loading" @click="save(2)">通过</el-button>
  414. </div>
  415. <div class="btn-group" v-else-if="mode == 'edit'">
  416. <!-- <el-button :loading="loading" @click="">取消</el-button> -->
  417. <el-button type="primary" :loading="loading" @click="save()">保存</el-button>
  418. </div>
  419. </div>
  420. </template>
  421. <script>
  422. import { goodsSet, detail, getData,check,getLabelList } from "@/api/goods";
  423. import {getRuleList } from "@/api/rule";
  424. import { requestUploadImg, finishUploadImg,getSetMealNameAndId } from "@/api/common";
  425. import Upload from "@/components/Upload";
  426. import Vue from "vue";
  427. import { Editor, Toolbar } from "@wangeditor/editor-for-vue";
  428. import OSS from "ali-oss";
  429. export default Vue.extend({
  430. components: {
  431. Upload,
  432. Editor,
  433. Toolbar,
  434. },
  435. data() {
  436. return {
  437. that:this,
  438. showGoodsLabel:1,
  439. labelId:0,//标签id
  440. labelList:[],//标签列表
  441. activeName: "基本信息",
  442. editor: null,
  443. editorMode: "default", // or 'simple'
  444. toolbarConfig: {},
  445. editorConfig: {
  446. placeholder: "请输入内容...",
  447. MENU_CONF: {
  448. uploadImage: {
  449. // 自定义上传
  450. customUpload(file, insertFn) {
  451. // file 即选中的文件
  452. requestUploadImg({
  453. fineName: file.name,
  454. operate: "OTHER",
  455. }).then((res) => {
  456. if (res.state == "Success") {
  457. const client = new OSS({
  458. // yourregion填写Bucket所在地域。以华东1(杭州)为例,Region填写为oss-cn-hangzhou。
  459. region: res.content.endPoint.split(".")[0],
  460. // 从环境变量中获取访问凭证。运行本代码示例之前,请确保已设置环境变量OSS_ACCESS_KEY_ID和OSS_ACCESS_KEY_SECRET。
  461. accessKeyId: res.content.token.accessKeyId,
  462. accessKeySecret: res.content.token.accessKeySecret,
  463. // 填写Bucket名称。
  464. bucket: res.content.bucket,
  465. stsToken: res.content.token.securityToken,
  466. });
  467. client
  468. .multipartUpload(res.content.paths[0].join("/"), file)
  469. .then((r) => {
  470. // 上传完成
  471. finishUploadImg([{ path: res.content.paths[0] }]).then(
  472. (msg) => {
  473. if (msg.state == "Success") {
  474. let url =
  475. "http://" +
  476. res.content.bucket +
  477. "." +
  478. res.content.endPoint +
  479. "/" +
  480. res.content.paths[0].join("/");
  481. insertFn(url, "", "");
  482. }
  483. }
  484. );
  485. })
  486. .catch((err) => {
  487. console.log(err); //上传失败之后
  488. });
  489. }
  490. });
  491. },
  492. },
  493. },
  494. },
  495. mode: "add",
  496. loading: false,
  497. setQuery: {
  498. attrs: [
  499. {
  500. attrName: "",
  501. attrValue: "",
  502. status: 2,
  503. },
  504. ],
  505. goodsCateId: "",
  506. goodsDescribe: "",
  507. goodsDetail: "",
  508. goodsId: "",
  509. goodsName: "",
  510. goodsPath: "1",
  511. goodsSort: 0,
  512. goodsType: "",
  513. marketPrice: 0,
  514. realPrice: 0,
  515. saleNum: 0,
  516. shopId: localStorage.getItem("epid"),
  517. specs: [
  518. {
  519. specName: "",
  520. specValues: [
  521. {
  522. specValue: "",
  523. status: 2,
  524. },
  525. ],
  526. },
  527. ],
  528. stockNum: 0,
  529. stockThresholdNum: 0,
  530. syncEnable: 0,
  531. syncRang: "",
  532. validRang: 0,
  533. taxRate:0,
  534. withdrawalRate:0,
  535. shareId:'',
  536. goodsSets:[],
  537. refundType:1
  538. },
  539. rules: {
  540. taxRate: [
  541. { required: true, message: "请输入商品税费", trigger: "blur" },
  542. ],
  543. withdrawalRate: [
  544. { required: true, message: "请输入提现手续费", trigger: "blur" },
  545. ],
  546. shareId: [{ required: true, message: "请输入分账规则", trigger: "change" }],
  547. checkDetail: [{ required: true, message: "请输入审核意见", trigger: "blur" }],
  548. },
  549. options: [
  550. {
  551. value: "801",
  552. label: "研学商品",
  553. },
  554. {
  555. value: "802",
  556. label: "虚拟商品充值",
  557. },
  558. {
  559. value: "803",
  560. label: "餐饮商品",
  561. },
  562. ],
  563. typeOptions: [],
  564. ruleOptions:[],
  565. mealOption: [],
  566. pickerOptions: {
  567. shortcuts: [
  568. {
  569. text: "最近一周",
  570. onClick(picker) {
  571. const end = new Date();
  572. const start = new Date();
  573. start.setTime(start.getTime() - 3600 * 1000 * 24 * 6);
  574. picker.$emit("pick", [start, end]);
  575. },
  576. },
  577. {
  578. text: "最近一个月",
  579. onClick(picker) {
  580. const end = new Date();
  581. const start = new Date();
  582. start.setTime(start.getTime() - 3600 * 1000 * 24 * 30);
  583. picker.$emit("pick", [start, end]);
  584. },
  585. },
  586. {
  587. text: "最近三个月",
  588. onClick(picker) {
  589. const end = new Date();
  590. const start = new Date();
  591. start.setTime(start.getTime() - 3600 * 1000 * 24 * 90);
  592. picker.$emit("pick", [start, end]);
  593. },
  594. },
  595. ],
  596. },
  597. };
  598. },
  599. filters: {
  600. filterMeal: function (val, that) {
  601. let msg;
  602. that.mealOption.map((item) => {
  603. if (val == item.value) {
  604. msg = item.label;
  605. } else if (val === 0) {
  606. msg = "无套餐";
  607. }
  608. });
  609. return msg;
  610. },
  611. },
  612. methods: {
  613. filterCurrentData(){
  614. let data
  615. this.setQuery.prices.forEach(item=>{
  616. if(item.platformType == this.$route.query.source){
  617. data = item
  618. }
  619. })
  620. return data
  621. },
  622. add(index, key) {
  623. //最外层的index,属性名,内部输入框的index
  624. let obj;
  625. if (key == "attrs") {
  626. obj = {
  627. specName: "",
  628. specValue: "",
  629. status: 2,
  630. };
  631. } else if (key == "specs") {
  632. obj = {
  633. specName: "",
  634. specValues: [
  635. {
  636. specValue: "",
  637. status: 2,
  638. },
  639. ],
  640. };
  641. }
  642. this.setQuery[key].splice(index + 1, 0, obj);
  643. },
  644. add1(index, d) {
  645. this.setQuery.specs[index].specValues.splice(d + 1, 0, {
  646. specValue: "",
  647. status: 2,
  648. });
  649. },
  650. remove1(index, d) {
  651. if (this.setQuery.specs[index].specValues.length == 1) return;
  652. this.setQuery.specs[index].specValues.splice(d, 1);
  653. },
  654. remove(index, key) {
  655. if (this.setQuery[key].length == 1) return;
  656. this.setQuery[key].splice(index, 1);
  657. },
  658. onCreated(editor) {
  659. this.editor = Object.seal(editor); // 一定要用 Object.seal() ,否则会报错
  660. if (this.mode == "detail") {
  661. this.editor.disable();
  662. }
  663. },
  664. uploadEnd(val) {
  665. this.setQuery[val.type] = val.url;
  666. },
  667. save(applyState) {
  668. if(applyState == 2){
  669. this.setQuery.checkDetail = this.setQuery.checkDetail || '通过'
  670. // this.rules = {
  671. // shareId: [{ required: true, message: "请选择分账规则", trigger: "change" }],
  672. // taxRate: [
  673. // { required: true, message: "请输入商品税费", trigger: "blur" },
  674. // ],
  675. // withdrawalRate: [
  676. // { required: true, message: "请输入提现手续费", trigger: "blur" },
  677. // ],
  678. // }
  679. }else if(applyState == 3){
  680. if(this.setQuery.checkDetail == '通过'){
  681. this.setQuery.checkDetail = ''
  682. }
  683. // this.rules = {
  684. // checkDetail: [{ required: true, message: "请输入审核意见", trigger: "blur" }],
  685. // shareId: [{ required: true, message: "请选择分账规则", trigger: "change" }],
  686. // taxRate: [
  687. // { required: true, message: "请输入商品税费", trigger: "blur" },
  688. // ],
  689. // withdrawalRate: [
  690. // { required: true, message: "请输入提现手续费", trigger: "blur" },
  691. // ],
  692. // }
  693. }
  694. this.$nextTick(()=>{
  695. this.$refs.setQuery.validate((v) => {
  696. if (v) {
  697. this.loading = true;
  698. // this.check(applyState)
  699. let {goodsSets,goodsId,shareId,shopId,taxRate,withdrawalRate} = this.setQuery
  700. let obj = {
  701. // "goodsCouponSets":goodsSets,
  702. "goodsId": goodsId,
  703. "shareId": shareId,
  704. "shopId":shopId,
  705. "taxRate": 0,
  706. "withdrawalRate": 0,
  707. "platform":this.$route.query.source,
  708. }
  709. goodsSet(obj).then((res) => {
  710. this.loading = false;
  711. if (res.state == "Success") {
  712. if(this.mode == 'audit'){
  713. this.check(applyState)
  714. }else{
  715. this.$notify({
  716. title: '成功',
  717. message: '操作成功',
  718. type: 'success'
  719. });
  720. this.$router.push('/operationManage/goodsManage/index')
  721. }
  722. }
  723. });
  724. }else{
  725. this.activeName = '商品配置'
  726. }
  727. });
  728. })
  729. },
  730. // 审核
  731. check(applyState){
  732. check({
  733. "goodsId":this.$route.query.id,
  734. "applyState": applyState,
  735. "labelId":this.showGoodsLabel == 1? this.labelId:null,
  736. "checkDetail": this.setQuery.checkDetail,
  737. "checkUserId": localStorage.getItem('epid'),
  738. "platformType": this.$route.query.source,
  739. }).then(res=>{
  740. this.loading = false
  741. if(res.state == 'Success'){
  742. this.$notify({
  743. title: '成功',
  744. message: '操作成功',
  745. type: 'success'
  746. });
  747. this.$router.push('/operationManage/goodsManage/index')
  748. }
  749. })
  750. },
  751. // 获取套餐
  752. getSetMealNameAndId() {
  753. return new Promise((resolve, reject) => {
  754. getSetMealNameAndId().then((res) => {
  755. if (res.state == "Success") {
  756. for (const key in res.content) {
  757. if (Object.hasOwnProperty.call(res.content, key)) {
  758. this.mealOption.push({
  759. label: res.content[key],
  760. value: key,
  761. });
  762. }
  763. }
  764. this.mealOption.push({
  765. label:'无套餐',
  766. value:0
  767. })
  768. resolve();
  769. }
  770. });
  771. });
  772. },
  773. // 获取商品分类
  774. getData() {
  775. getData().then((res) => {
  776. if (res.state == "Success") {
  777. this.typeOptions = res.content.map(e=>{
  778. try{
  779. e.child.map(
  780. r=>{
  781. delete r.child
  782. return r
  783. }
  784. )
  785. }catch(e){
  786. console.log(e);
  787. }
  788. return e
  789. });
  790. }
  791. })
  792. },
  793. // 规则
  794. getRuleList() {
  795. getRuleList({currentPage:1,pageSize:999}).then((res) => {
  796. if (res.state == "Success") {
  797. res.content.records.map(item=>{
  798. this.ruleOptions.push({
  799. label:item.shareRule,
  800. value:item.id
  801. })
  802. })
  803. }
  804. });
  805. },
  806. // 商品详情
  807. get() {
  808. this.loading = true;
  809. detail({
  810. goodsId: this.$route.query.id,
  811. resource: this.mode == 'audit'? 3:1,
  812. // shopId: localStorage.getItem("epid"),
  813. }).then((res) => {
  814. this.loading = false;
  815. if (res.state == "Success") {
  816. this.setQuery = res.content;
  817. this.setQuery.prices = JSON.parse(this.setQuery.prices)
  818. if(this.setQuery.prices){
  819. this.setQuery.platformType = []
  820. this.setQuery.prices.map(item=>{
  821. if(item.platformType == this.setQuery.prePlatformType){
  822. this.setQuery.platformPrice = item.price
  823. }
  824. if(item.status == 2){
  825. this.setQuery.platformType.push(Number(item.platformType) )
  826. }
  827. })
  828. }
  829. this.labelId = Number(res.content.goodsLabelId) || this.labelList[0].id
  830. this.setQuery.goodsCateId = Number(this.setQuery.goodsCateId);
  831. // 初始化购买设置
  832. if (!this.setQuery.goodsSets.length) {
  833. this.setQuery.goodsSets = [];
  834. this.mealOption.map((item) => {
  835. this.setQuery.goodsSets.push({
  836. buyNum: 0,
  837. buyPrice: this.setQuery.realPrice,
  838. buySet: 1,
  839. setMealId: item.value,
  840. });
  841. });
  842. }
  843. }
  844. });
  845. },
  846. // 获取标签列表
  847. getLabelList(){
  848. getLabelList({
  849. currentPage: 1,
  850. pageSize: 99,}).then(res=>{
  851. if(res.state == 'Success'){
  852. this.labelList = res.content.records
  853. }
  854. })
  855. },
  856. },
  857. created() {
  858. this.options = []
  859. let goodsTypeObj = JSON.parse(sessionStorage.getItem('goodsTypeObj'))
  860. for (const key in goodsTypeObj) {
  861. if (Object.hasOwnProperty.call(goodsTypeObj, key)) {
  862. this.options.push({
  863. label:goodsTypeObj[key],
  864. value:key
  865. })
  866. }
  867. }
  868. this.getRuleList()
  869. this.getData();
  870. this.getLabelList()
  871. this.mode = this.$route.query.mode || "add";
  872. this.getSetMealNameAndId().then(() => {
  873. if (this.$route.query.id) {
  874. this.get();
  875. }
  876. });
  877. },
  878. });
  879. </script>
  880. <style src="@wangeditor/editor/dist/css/style.css"></style>
  881. <style lang="scss" >
  882. @import "@/styles/element-variables";
  883. .addGoods {
  884. padding-bottom: 40px;
  885. .platformType{
  886. font-size: 14px;
  887. color: #606266;
  888. }
  889. .flex{
  890. display: flex;
  891. align-items: center;
  892. margin-bottom: 10px;
  893. }
  894. .item {
  895. display: flex;
  896. align-items: center;
  897. margin-bottom: 10px;
  898. .ml20{
  899. margin-left: 20px;
  900. }
  901. .textarea textarea{
  902. height: 40px;
  903. }
  904. .icon {
  905. font-size: 18px;
  906. font-weight: bold;
  907. margin-left: 10px;
  908. cursor: pointer;
  909. }
  910. .box {
  911. }
  912. }
  913. .btn-group {
  914. display: flex;
  915. align-items: center;
  916. justify-content: center;
  917. }
  918. }
  919. </style>